Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@contentful/rich-text-plain-text-renderer

Package Overview
Dependencies
Maintainers
0
Versions
78
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@contentful/rich-text-plain-text-renderer - npm Package Compare versions

Comparing version 16.2.10 to 17.0.0

355

dist/rich-text-plain-text-renderer.es5.js
'use strict';
var commonjsGlobal = typeof globalThis !== 'undefined' ? globalThis : typeof window !== 'undefined' ? window : typeof global !== 'undefined' ? global : typeof self !== 'undefined' ? self : {};
var richTextTypes = require('@contentful/rich-text-types');
var dist = {};
var blocks = {};
Object.defineProperty(blocks, "__esModule", { value: true });
blocks.BLOCKS = void 0;
/**
* Map of all Contentful block types. Blocks contain inline or block nodes.
*/
var BLOCKS;
(function (BLOCKS) {
BLOCKS["DOCUMENT"] = "document";
BLOCKS["PARAGRAPH"] = "paragraph";
BLOCKS["HEADING_1"] = "heading-1";
BLOCKS["HEADING_2"] = "heading-2";
BLOCKS["HEADING_3"] = "heading-3";
BLOCKS["HEADING_4"] = "heading-4";
BLOCKS["HEADING_5"] = "heading-5";
BLOCKS["HEADING_6"] = "heading-6";
BLOCKS["OL_LIST"] = "ordered-list";
BLOCKS["UL_LIST"] = "unordered-list";
BLOCKS["LIST_ITEM"] = "list-item";
BLOCKS["HR"] = "hr";
BLOCKS["QUOTE"] = "blockquote";
BLOCKS["EMBEDDED_ENTRY"] = "embedded-entry-block";
BLOCKS["EMBEDDED_ASSET"] = "embedded-asset-block";
BLOCKS["EMBEDDED_RESOURCE"] = "embedded-resource-block";
BLOCKS["TABLE"] = "table";
BLOCKS["TABLE_ROW"] = "table-row";
BLOCKS["TABLE_CELL"] = "table-cell";
BLOCKS["TABLE_HEADER_CELL"] = "table-header-cell";
})(BLOCKS || (blocks.BLOCKS = BLOCKS = {}));
var inlines = {};
Object.defineProperty(inlines, "__esModule", { value: true });
inlines.INLINES = void 0;
/**
* Map of all Contentful inline types. Inline contain inline or text nodes.
*
* @note This should be kept in alphabetical order since the
* [validation package](https://github.com/contentful/content-stack/tree/master/packages/validation)
* relies on the values being in a predictable order.
*/
var INLINES;
(function (INLINES) {
INLINES["ASSET_HYPERLINK"] = "asset-hyperlink";
INLINES["EMBEDDED_ENTRY"] = "embedded-entry-inline";
INLINES["EMBEDDED_RESOURCE"] = "embedded-resource-inline";
INLINES["ENTRY_HYPERLINK"] = "entry-hyperlink";
INLINES["HYPERLINK"] = "hyperlink";
INLINES["RESOURCE_HYPERLINK"] = "resource-hyperlink";
})(INLINES || (inlines.INLINES = INLINES = {}));
var marks = {};
Object.defineProperty(marks, "__esModule", { value: true });
marks.MARKS = void 0;
/**
* Map of all Contentful marks.
*/
var MARKS;
(function (MARKS) {
MARKS["BOLD"] = "bold";
MARKS["ITALIC"] = "italic";
MARKS["UNDERLINE"] = "underline";
MARKS["CODE"] = "code";
MARKS["SUPERSCRIPT"] = "superscript";
MARKS["SUBSCRIPT"] = "subscript";
MARKS["STRIKETHROUGH"] = "strikethrough";
})(MARKS || (marks.MARKS = MARKS = {}));
var schemaConstraints = {};
(function (exports) {
var __spreadArray = (commonjsGlobal && commonjsGlobal.__spreadArray) || function (to, from, pack) {
if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
if (ar || !(i in from)) {
if (!ar) ar = Array.prototype.slice.call(from, 0, i);
ar[i] = from[i];
}
}
return to.concat(ar || Array.prototype.slice.call(from));
};
var _a;
Object.defineProperty(exports, "__esModule", { value: true });
exports.V1_MARKS = exports.V1_NODE_TYPES = exports.TEXT_CONTAINERS = exports.HEADINGS = exports.CONTAINERS = exports.VOID_BLOCKS = exports.TABLE_BLOCKS = exports.LIST_ITEM_BLOCKS = exports.TOP_LEVEL_BLOCKS = void 0;
var blocks_1 = blocks;
var inlines_1 = inlines;
var marks_1 = marks;
/**
* Array of all top level block types.
* Only these block types can be the direct children of the document.
*/
exports.TOP_LEVEL_BLOCKS = [
blocks_1.BLOCKS.PARAGRAPH,
blocks_1.BLOCKS.HEADING_1,
blocks_1.BLOCKS.HEADING_2,
blocks_1.BLOCKS.HEADING_3,
blocks_1.BLOCKS.HEADING_4,
blocks_1.BLOCKS.HEADING_5,
blocks_1.BLOCKS.HEADING_6,
blocks_1.BLOCKS.OL_LIST,
blocks_1.BLOCKS.UL_LIST,
blocks_1.BLOCKS.HR,
blocks_1.BLOCKS.QUOTE,
blocks_1.BLOCKS.EMBEDDED_ENTRY,
blocks_1.BLOCKS.EMBEDDED_ASSET,
blocks_1.BLOCKS.EMBEDDED_RESOURCE,
blocks_1.BLOCKS.TABLE,
];
/**
* Array of all allowed block types inside list items
*/
exports.LIST_ITEM_BLOCKS = [
blocks_1.BLOCKS.PARAGRAPH,
blocks_1.BLOCKS.HEADING_1,
blocks_1.BLOCKS.HEADING_2,
blocks_1.BLOCKS.HEADING_3,
blocks_1.BLOCKS.HEADING_4,
blocks_1.BLOCKS.HEADING_5,
blocks_1.BLOCKS.HEADING_6,
blocks_1.BLOCKS.OL_LIST,
blocks_1.BLOCKS.UL_LIST,
blocks_1.BLOCKS.HR,
blocks_1.BLOCKS.QUOTE,
blocks_1.BLOCKS.EMBEDDED_ENTRY,
blocks_1.BLOCKS.EMBEDDED_ASSET,
blocks_1.BLOCKS.EMBEDDED_RESOURCE,
];
exports.TABLE_BLOCKS = [
blocks_1.BLOCKS.TABLE,
blocks_1.BLOCKS.TABLE_ROW,
blocks_1.BLOCKS.TABLE_CELL,
blocks_1.BLOCKS.TABLE_HEADER_CELL,
];
/**
* Array of all void block types
*/
exports.VOID_BLOCKS = [
blocks_1.BLOCKS.HR,
blocks_1.BLOCKS.EMBEDDED_ENTRY,
blocks_1.BLOCKS.EMBEDDED_ASSET,
blocks_1.BLOCKS.EMBEDDED_RESOURCE,
];
/**
* Dictionary of all container block types, and the set block types they accept as children.
*
* Note: This does not include `[BLOCKS.DOCUMENT]: TOP_LEVEL_BLOCKS`
*/
exports.CONTAINERS = (_a = {},
_a[blocks_1.BLOCKS.OL_LIST] = [blocks_1.BLOCKS.LIST_ITEM],
_a[blocks_1.BLOCKS.UL_LIST] = [blocks_1.BLOCKS.LIST_ITEM],
_a[blocks_1.BLOCKS.LIST_ITEM] = exports.LIST_ITEM_BLOCKS,
_a[blocks_1.BLOCKS.QUOTE] = [blocks_1.BLOCKS.PARAGRAPH],
_a[blocks_1.BLOCKS.TABLE] = [blocks_1.BLOCKS.TABLE_ROW],
_a[blocks_1.BLOCKS.TABLE_ROW] = [blocks_1.BLOCKS.TABLE_CELL, blocks_1.BLOCKS.TABLE_HEADER_CELL],
_a[blocks_1.BLOCKS.TABLE_CELL] = [blocks_1.BLOCKS.PARAGRAPH, blocks_1.BLOCKS.UL_LIST, blocks_1.BLOCKS.OL_LIST],
_a[blocks_1.BLOCKS.TABLE_HEADER_CELL] = [blocks_1.BLOCKS.PARAGRAPH],
_a);
/**
* Array of all heading levels
*/
exports.HEADINGS = [
blocks_1.BLOCKS.HEADING_1,
blocks_1.BLOCKS.HEADING_2,
blocks_1.BLOCKS.HEADING_3,
blocks_1.BLOCKS.HEADING_4,
blocks_1.BLOCKS.HEADING_5,
blocks_1.BLOCKS.HEADING_6,
];
/**
* Array of all block types that may contain text and inline nodes.
*/
exports.TEXT_CONTAINERS = __spreadArray([blocks_1.BLOCKS.PARAGRAPH], exports.HEADINGS, true);
/**
* Node types before `tables` release.
*/
exports.V1_NODE_TYPES = [
blocks_1.BLOCKS.DOCUMENT,
blocks_1.BLOCKS.PARAGRAPH,
blocks_1.BLOCKS.HEADING_1,
blocks_1.BLOCKS.HEADING_2,
blocks_1.BLOCKS.HEADING_3,
blocks_1.BLOCKS.HEADING_4,
blocks_1.BLOCKS.HEADING_5,
blocks_1.BLOCKS.HEADING_6,
blocks_1.BLOCKS.OL_LIST,
blocks_1.BLOCKS.UL_LIST,
blocks_1.BLOCKS.LIST_ITEM,
blocks_1.BLOCKS.HR,
blocks_1.BLOCKS.QUOTE,
blocks_1.BLOCKS.EMBEDDED_ENTRY,
blocks_1.BLOCKS.EMBEDDED_ASSET,
inlines_1.INLINES.HYPERLINK,
inlines_1.INLINES.ENTRY_HYPERLINK,
inlines_1.INLINES.ASSET_HYPERLINK,
inlines_1.INLINES.EMBEDDED_ENTRY,
'text',
];
/**
* Marks before `superscript` & `subscript` release.
*/
exports.V1_MARKS = [marks_1.MARKS.BOLD, marks_1.MARKS.CODE, marks_1.MARKS.ITALIC, marks_1.MARKS.UNDERLINE];
} (schemaConstraints));
var types = {};
Object.defineProperty(types, "__esModule", { value: true });
var nodeTypes = {};
Object.defineProperty(nodeTypes, "__esModule", { value: true });
var emptyDocument = {};
Object.defineProperty(emptyDocument, "__esModule", { value: true });
emptyDocument.EMPTY_DOCUMENT = void 0;
var blocks_1$1 = blocks;
/**
* A rich text document considered to be empty.
* Any other document structure than this is not considered empty.
*/
emptyDocument.EMPTY_DOCUMENT = {
nodeType: blocks_1$1.BLOCKS.DOCUMENT,
data: {},
content: [
{
nodeType: blocks_1$1.BLOCKS.PARAGRAPH,
data: {},
content: [
{
nodeType: 'text',
value: '',
marks: [],
data: {},
},
],
},
],
};
var helpers = {};
Object.defineProperty(helpers, "__esModule", { value: true });
helpers.isInline = isInline;
helpers.isBlock = isBlock;
helpers.isText = isText;
var blocks_1 = blocks;
var inlines_1 = inlines;
/**
* Tiny replacement for Object.values(object).includes(key) to
* avoid including CoreJS polyfills
*/
function hasValue(obj, value) {
for (var _i = 0, _a = Object.keys(obj); _i < _a.length; _i++) {
var key = _a[_i];
if (value === obj[key]) {
return true;
}
}
return false;
}
/**
* Checks if the node is an instance of Inline.
*/
function isInline(node) {
return hasValue(inlines_1.INLINES, node.nodeType);
}
/**
* Checks if the node is an instance of Block.
*/
function isBlock(node) {
return hasValue(blocks_1.BLOCKS, node.nodeType);
}
/**
* Checks if the node is an instance of Text.
*/
function isText(node) {
return node.nodeType === 'text';
}
function commonjsRequire(path) {
throw new Error('Could not dynamically require "' + path + '". Please configure the dynamicRequireTargets or/and ignoreDynamicRequires option of @rollup/plugin-commonjs appropriately for this require call to work.');
}
var schemas = {};
Object.defineProperty(schemas, "__esModule", { value: true });
schemas.getSchemaWithNodeType = getSchemaWithNodeType;
function getSchemaWithNodeType(nodeType) {
try {
return commonjsRequire("./generated/".concat(nodeType, ".json"));
}
catch (error) {
throw new Error("Schema for nodeType \"".concat(nodeType, "\" was not found."));
}
}
(function (exports) {
var __createBinding = (commonjsGlobal && commonjsGlobal.__createBinding) || (Object.create ? (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
var desc = Object.getOwnPropertyDescriptor(m, k);
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
desc = { enumerable: true, get: function() { return m[k]; } };
}
Object.defineProperty(o, k2, desc);
}) : (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
o[k2] = m[k];
}));
var __setModuleDefault = (commonjsGlobal && commonjsGlobal.__setModuleDefault) || (Object.create ? (function(o, v) {
Object.defineProperty(o, "default", { enumerable: true, value: v });
}) : function(o, v) {
o["default"] = v;
});
var __exportStar = (commonjsGlobal && commonjsGlobal.__exportStar) || function(m, exports) {
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
};
var __importStar = (commonjsGlobal && commonjsGlobal.__importStar) || function (mod) {
if (mod && mod.__esModule) return mod;
var result = {};
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
__setModuleDefault(result, mod);
return result;
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.getSchemaWithNodeType = exports.helpers = exports.EMPTY_DOCUMENT = exports.MARKS = exports.INLINES = exports.BLOCKS = void 0;
var blocks_1 = blocks;
Object.defineProperty(exports, "BLOCKS", { enumerable: true, get: function () { return blocks_1.BLOCKS; } });
var inlines_1 = inlines;
Object.defineProperty(exports, "INLINES", { enumerable: true, get: function () { return inlines_1.INLINES; } });
var marks_1 = marks;
Object.defineProperty(exports, "MARKS", { enumerable: true, get: function () { return marks_1.MARKS; } });
__exportStar(schemaConstraints, exports);
__exportStar(types, exports);
__exportStar(nodeTypes, exports);
var emptyDocument_1 = emptyDocument;
Object.defineProperty(exports, "EMPTY_DOCUMENT", { enumerable: true, get: function () { return emptyDocument_1.EMPTY_DOCUMENT; } });
var helpers$1 = __importStar(helpers);
exports.helpers = helpers$1;
var schemas_1 = schemas;
Object.defineProperty(exports, "getSchemaWithNodeType", { enumerable: true, get: function () { return schemas_1.getSchemaWithNodeType; } });
} (dist));
/**
* Returns the text value of a rich text document.

@@ -435,6 +88,6 @@ *

var nodeTextValue;
if (dist.helpers.isText(node)) {
if (richTextTypes.helpers.isText(node)) {
nodeTextValue = node.value;
}
else if (dist.helpers.isBlock(node) || dist.helpers.isInline(node)) {
else if (richTextTypes.helpers.isBlock(node) || richTextTypes.helpers.isInline(node)) {
nodeTextValue = documentToPlainTextString(node, blockDivisor);

@@ -446,3 +99,3 @@ if (!nodeTextValue.length) {

var nextNode = rootNode.content[i + 1];
var isNextNodeBlock = nextNode && dist.helpers.isBlock(nextNode);
var isNextNodeBlock = nextNode && richTextTypes.helpers.isBlock(nextNode);
var divisor = isNextNodeBlock ? blockDivisor : '';

@@ -449,0 +102,0 @@ return acc + nodeTextValue + divisor;

6

package.json
{
"name": "@contentful/rich-text-plain-text-renderer",
"version": "16.2.10",
"version": "17.0.0",
"main": "dist/rich-text-plain-text-renderer.es5.js",

@@ -28,3 +28,3 @@ "typings": "dist/types/index.d.ts",

"dependencies": {
"@contentful/rich-text-types": "^16.8.5"
"@contentful/rich-text-types": "^17.0.0"
},

@@ -34,3 +34,3 @@ "devDependencies": {

},
"gitHead": "f54d44b5bb22f17feb3b691897003010520daed0"
"gitHead": "10b4fbac140f7d2505e724dbb312f6ccddb3d09e"
}

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc