@contentful/rich-text-html-renderer
Advanced tools
Comparing version 16.3.5 to 16.4.0
'use strict'; | ||
Object.defineProperty(exports, '__esModule', { value: true }); | ||
/****************************************************************************** | ||
@@ -19,3 +17,5 @@ Copyright (c) Microsoft Corporation. | ||
***************************************************************************** */ | ||
/* global Reflect, Promise, SuppressedError, Symbol */ | ||
var __assign = function() { | ||
@@ -32,3 +32,3 @@ __assign = Object.assign || function __assign(t) { | ||
var _SuppressedError = typeof SuppressedError === "function" ? SuppressedError : function (error, suppressed, message) { | ||
typeof SuppressedError === "function" ? SuppressedError : function (error, suppressed, message) { | ||
var e = new Error(message); | ||
@@ -38,2 +38,8 @@ return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e; | ||
var commonjsGlobal = typeof globalThis !== 'undefined' ? globalThis : typeof window !== 'undefined' ? window : typeof global !== 'undefined' ? global : typeof self !== 'undefined' ? self : {}; | ||
function getDefaultExportFromCjs (x) { | ||
return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, 'default') ? x['default'] : x; | ||
} | ||
/*! | ||
@@ -116,15 +122,10 @@ * escape-html | ||
var commonjsGlobal = typeof globalThis !== 'undefined' ? globalThis : typeof window !== 'undefined' ? window : typeof global !== 'undefined' ? global : typeof self !== 'undefined' ? self : {}; | ||
var escape = /*@__PURE__*/getDefaultExportFromCjs(escapeHtml_1); | ||
function unwrapExports (x) { | ||
return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, 'default') ? x['default'] : x; | ||
} | ||
var dist = {}; | ||
function createCommonjsModule(fn, module) { | ||
return module = { exports: {} }, fn(module, module.exports), module.exports; | ||
} | ||
var blocks = {}; | ||
var blocks = createCommonjsModule(function (module, exports) { | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.BLOCKS = void 0; | ||
Object.defineProperty(blocks, "__esModule", { value: true }); | ||
blocks.BLOCKS = void 0; | ||
/** | ||
@@ -155,12 +156,8 @@ * Map of all Contentful block types. Blocks contain inline or block nodes. | ||
BLOCKS["TABLE_HEADER_CELL"] = "table-header-cell"; | ||
})(BLOCKS || (exports.BLOCKS = BLOCKS = {})); | ||
})(BLOCKS || (blocks.BLOCKS = BLOCKS = {})); | ||
}); | ||
var inlines = {}; | ||
unwrapExports(blocks); | ||
var blocks_1 = blocks.BLOCKS; | ||
var inlines = createCommonjsModule(function (module, exports) { | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.INLINES = void 0; | ||
Object.defineProperty(inlines, "__esModule", { value: true }); | ||
inlines.INLINES = void 0; | ||
/** | ||
@@ -177,12 +174,8 @@ * Map of all Contentful inline types. Inline contain inline or text nodes. | ||
INLINES["EMBEDDED_RESOURCE"] = "embedded-resource-inline"; | ||
})(INLINES || (exports.INLINES = INLINES = {})); | ||
})(INLINES || (inlines.INLINES = INLINES = {})); | ||
}); | ||
var marks = {}; | ||
unwrapExports(inlines); | ||
var inlines_1 = inlines.INLINES; | ||
var marks = createCommonjsModule(function (module, exports) { | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.MARKS = void 0; | ||
Object.defineProperty(marks, "__esModule", { value: true }); | ||
marks.MARKS = void 0; | ||
/** | ||
@@ -199,171 +192,152 @@ * Map of all Contentful marks. | ||
MARKS["SUBSCRIPT"] = "subscript"; | ||
})(MARKS || (exports.MARKS = MARKS = {})); | ||
})(MARKS || (marks.MARKS = MARKS = {})); | ||
}); | ||
var schemaConstraints = {}; | ||
unwrapExports(marks); | ||
var marks_1 = marks.MARKS; | ||
(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], | ||
_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 schemaConstraints = createCommonjsModule(function (module, 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 types = {}; | ||
Object.defineProperty(types, "__esModule", { value: true }); | ||
var nodeTypes = {}; | ||
/** | ||
* Array of all top level block types. | ||
* Only these block types can be the direct children of the document. | ||
*/ | ||
exports.TOP_LEVEL_BLOCKS = [ | ||
blocks.BLOCKS.PARAGRAPH, | ||
blocks.BLOCKS.HEADING_1, | ||
blocks.BLOCKS.HEADING_2, | ||
blocks.BLOCKS.HEADING_3, | ||
blocks.BLOCKS.HEADING_4, | ||
blocks.BLOCKS.HEADING_5, | ||
blocks.BLOCKS.HEADING_6, | ||
blocks.BLOCKS.OL_LIST, | ||
blocks.BLOCKS.UL_LIST, | ||
blocks.BLOCKS.HR, | ||
blocks.BLOCKS.QUOTE, | ||
blocks.BLOCKS.EMBEDDED_ENTRY, | ||
blocks.BLOCKS.EMBEDDED_ASSET, | ||
blocks.BLOCKS.EMBEDDED_RESOURCE, | ||
blocks.BLOCKS.TABLE, | ||
]; | ||
/** | ||
* Array of all allowed block types inside list items | ||
*/ | ||
exports.LIST_ITEM_BLOCKS = [ | ||
blocks.BLOCKS.PARAGRAPH, | ||
blocks.BLOCKS.HEADING_1, | ||
blocks.BLOCKS.HEADING_2, | ||
blocks.BLOCKS.HEADING_3, | ||
blocks.BLOCKS.HEADING_4, | ||
blocks.BLOCKS.HEADING_5, | ||
blocks.BLOCKS.HEADING_6, | ||
blocks.BLOCKS.OL_LIST, | ||
blocks.BLOCKS.UL_LIST, | ||
blocks.BLOCKS.HR, | ||
blocks.BLOCKS.QUOTE, | ||
blocks.BLOCKS.EMBEDDED_ENTRY, | ||
blocks.BLOCKS.EMBEDDED_ASSET, | ||
blocks.BLOCKS.EMBEDDED_RESOURCE, | ||
]; | ||
exports.TABLE_BLOCKS = [ | ||
blocks.BLOCKS.TABLE, | ||
blocks.BLOCKS.TABLE_ROW, | ||
blocks.BLOCKS.TABLE_CELL, | ||
blocks.BLOCKS.TABLE_HEADER_CELL, | ||
]; | ||
/** | ||
* Array of all void block types | ||
*/ | ||
exports.VOID_BLOCKS = [ | ||
blocks.BLOCKS.HR, | ||
blocks.BLOCKS.EMBEDDED_ENTRY, | ||
blocks.BLOCKS.EMBEDDED_ASSET, | ||
blocks.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.BLOCKS.OL_LIST] = [blocks.BLOCKS.LIST_ITEM], | ||
_a[blocks.BLOCKS.UL_LIST] = [blocks.BLOCKS.LIST_ITEM], | ||
_a[blocks.BLOCKS.LIST_ITEM] = exports.LIST_ITEM_BLOCKS, | ||
_a[blocks.BLOCKS.QUOTE] = [blocks.BLOCKS.PARAGRAPH], | ||
_a[blocks.BLOCKS.TABLE] = [blocks.BLOCKS.TABLE_ROW], | ||
_a[blocks.BLOCKS.TABLE_ROW] = [blocks.BLOCKS.TABLE_CELL, blocks.BLOCKS.TABLE_HEADER_CELL], | ||
_a[blocks.BLOCKS.TABLE_CELL] = [blocks.BLOCKS.PARAGRAPH], | ||
_a[blocks.BLOCKS.TABLE_HEADER_CELL] = [blocks.BLOCKS.PARAGRAPH], | ||
_a); | ||
/** | ||
* Array of all heading levels | ||
*/ | ||
exports.HEADINGS = [ | ||
blocks.BLOCKS.HEADING_1, | ||
blocks.BLOCKS.HEADING_2, | ||
blocks.BLOCKS.HEADING_3, | ||
blocks.BLOCKS.HEADING_4, | ||
blocks.BLOCKS.HEADING_5, | ||
blocks.BLOCKS.HEADING_6, | ||
]; | ||
/** | ||
* Array of all block types that may contain text and inline nodes. | ||
*/ | ||
exports.TEXT_CONTAINERS = __spreadArray([blocks.BLOCKS.PARAGRAPH], exports.HEADINGS, true); | ||
/** | ||
* Node types before `tables` release. | ||
*/ | ||
exports.V1_NODE_TYPES = [ | ||
blocks.BLOCKS.DOCUMENT, | ||
blocks.BLOCKS.PARAGRAPH, | ||
blocks.BLOCKS.HEADING_1, | ||
blocks.BLOCKS.HEADING_2, | ||
blocks.BLOCKS.HEADING_3, | ||
blocks.BLOCKS.HEADING_4, | ||
blocks.BLOCKS.HEADING_5, | ||
blocks.BLOCKS.HEADING_6, | ||
blocks.BLOCKS.OL_LIST, | ||
blocks.BLOCKS.UL_LIST, | ||
blocks.BLOCKS.LIST_ITEM, | ||
blocks.BLOCKS.HR, | ||
blocks.BLOCKS.QUOTE, | ||
blocks.BLOCKS.EMBEDDED_ENTRY, | ||
blocks.BLOCKS.EMBEDDED_ASSET, | ||
inlines.INLINES.HYPERLINK, | ||
inlines.INLINES.ENTRY_HYPERLINK, | ||
inlines.INLINES.ASSET_HYPERLINK, | ||
inlines.INLINES.EMBEDDED_ENTRY, | ||
'text', | ||
]; | ||
/** | ||
* Marks before `superscript` & `subscript` release. | ||
*/ | ||
exports.V1_MARKS = [marks.MARKS.BOLD, marks.MARKS.CODE, marks.MARKS.ITALIC, marks.MARKS.UNDERLINE]; | ||
Object.defineProperty(nodeTypes, "__esModule", { value: true }); | ||
}); | ||
var emptyDocument = {}; | ||
unwrapExports(schemaConstraints); | ||
var schemaConstraints_1 = schemaConstraints.V1_MARKS; | ||
var schemaConstraints_2 = schemaConstraints.V1_NODE_TYPES; | ||
var schemaConstraints_3 = schemaConstraints.TEXT_CONTAINERS; | ||
var schemaConstraints_4 = schemaConstraints.HEADINGS; | ||
var schemaConstraints_5 = schemaConstraints.CONTAINERS; | ||
var schemaConstraints_6 = schemaConstraints.VOID_BLOCKS; | ||
var schemaConstraints_7 = schemaConstraints.TABLE_BLOCKS; | ||
var schemaConstraints_8 = schemaConstraints.LIST_ITEM_BLOCKS; | ||
var schemaConstraints_9 = schemaConstraints.TOP_LEVEL_BLOCKS; | ||
var types = createCommonjsModule(function (module, exports) { | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
}); | ||
unwrapExports(types); | ||
var nodeTypes = createCommonjsModule(function (module, exports) { | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
}); | ||
unwrapExports(nodeTypes); | ||
var emptyDocument = createCommonjsModule(function (module, exports) { | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.EMPTY_DOCUMENT = void 0; | ||
Object.defineProperty(emptyDocument, "__esModule", { value: true }); | ||
emptyDocument.EMPTY_DOCUMENT = void 0; | ||
var blocks_1$1 = blocks; | ||
/** | ||
@@ -373,8 +347,8 @@ * A rich text document considered to be empty. | ||
*/ | ||
exports.EMPTY_DOCUMENT = { | ||
nodeType: blocks.BLOCKS.DOCUMENT, | ||
emptyDocument.EMPTY_DOCUMENT = { | ||
nodeType: blocks_1$1.BLOCKS.DOCUMENT, | ||
data: {}, | ||
content: [ | ||
{ | ||
nodeType: blocks.BLOCKS.PARAGRAPH, | ||
nodeType: blocks_1$1.BLOCKS.PARAGRAPH, | ||
data: {}, | ||
@@ -393,12 +367,8 @@ content: [ | ||
}); | ||
var helpers = {}; | ||
unwrapExports(emptyDocument); | ||
var emptyDocument_1 = emptyDocument.EMPTY_DOCUMENT; | ||
var helpers = createCommonjsModule(function (module, exports) { | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.isText = exports.isBlock = exports.isInline = void 0; | ||
Object.defineProperty(helpers, "__esModule", { value: true }); | ||
helpers.isText = helpers.isBlock = helpers.isInline = void 0; | ||
var blocks_1 = blocks; | ||
var inlines_1 = inlines; | ||
/** | ||
@@ -421,5 +391,5 @@ * Tiny replacement for Object.values(object).includes(key) to | ||
function isInline(node) { | ||
return hasValue(inlines.INLINES, node.nodeType); | ||
return hasValue(inlines_1.INLINES, node.nodeType); | ||
} | ||
exports.isInline = isInline; | ||
helpers.isInline = isInline; | ||
/** | ||
@@ -429,5 +399,5 @@ * Checks if the node is an instance of Block. | ||
function isBlock(node) { | ||
return hasValue(blocks.BLOCKS, node.nodeType); | ||
return hasValue(blocks_1.BLOCKS, node.nodeType); | ||
} | ||
exports.isBlock = isBlock; | ||
helpers.isBlock = isBlock; | ||
/** | ||
@@ -439,94 +409,80 @@ * Checks if the node is an instance of Text. | ||
} | ||
exports.isText = isText; | ||
helpers.isText = isText; | ||
}); | ||
(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.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; | ||
} (dist)); | ||
unwrapExports(helpers); | ||
var helpers_1 = helpers.isText; | ||
var helpers_2 = helpers.isBlock; | ||
var helpers_3 = helpers.isInline; | ||
var dist = createCommonjsModule(function (module, 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.helpers = exports.EMPTY_DOCUMENT = exports.MARKS = exports.INLINES = exports.BLOCKS = void 0; | ||
Object.defineProperty(exports, "BLOCKS", { enumerable: true, get: function () { return blocks.BLOCKS; } }); | ||
Object.defineProperty(exports, "INLINES", { enumerable: true, get: function () { return inlines.INLINES; } }); | ||
Object.defineProperty(exports, "MARKS", { enumerable: true, get: function () { return marks.MARKS; } }); | ||
__exportStar(schemaConstraints, exports); | ||
__exportStar(types, exports); | ||
__exportStar(nodeTypes, exports); | ||
Object.defineProperty(exports, "EMPTY_DOCUMENT", { enumerable: true, get: function () { return emptyDocument.EMPTY_DOCUMENT; } }); | ||
var helpers$1 = __importStar(helpers); | ||
exports.helpers = helpers$1; | ||
}); | ||
unwrapExports(dist); | ||
var dist_1 = dist.helpers; | ||
var dist_2 = dist.EMPTY_DOCUMENT; | ||
var dist_3 = dist.MARKS; | ||
var dist_4 = dist.INLINES; | ||
var dist_5 = dist.BLOCKS; | ||
var _a, _b; | ||
var attributeValue = function (value) { return "\"".concat(value.replace(/"/g, '"'), "\""); }; | ||
var defaultNodeRenderers = (_a = {}, | ||
_a[dist_5.PARAGRAPH] = function (node, next) { return "<p>".concat(next(node.content), "</p>"); }, | ||
_a[dist_5.HEADING_1] = function (node, next) { return "<h1>".concat(next(node.content), "</h1>"); }, | ||
_a[dist_5.HEADING_2] = function (node, next) { return "<h2>".concat(next(node.content), "</h2>"); }, | ||
_a[dist_5.HEADING_3] = function (node, next) { return "<h3>".concat(next(node.content), "</h3>"); }, | ||
_a[dist_5.HEADING_4] = function (node, next) { return "<h4>".concat(next(node.content), "</h4>"); }, | ||
_a[dist_5.HEADING_5] = function (node, next) { return "<h5>".concat(next(node.content), "</h5>"); }, | ||
_a[dist_5.HEADING_6] = function (node, next) { return "<h6>".concat(next(node.content), "</h6>"); }, | ||
_a[dist_5.EMBEDDED_ENTRY] = function (node, next) { return "<div>".concat(next(node.content), "</div>"); }, | ||
_a[dist_5.EMBEDDED_RESOURCE] = function (node, next) { return "<div>".concat(next(node.content), "</div>"); }, | ||
_a[dist_5.UL_LIST] = function (node, next) { return "<ul>".concat(next(node.content), "</ul>"); }, | ||
_a[dist_5.OL_LIST] = function (node, next) { return "<ol>".concat(next(node.content), "</ol>"); }, | ||
_a[dist_5.LIST_ITEM] = function (node, next) { return "<li>".concat(next(node.content), "</li>"); }, | ||
_a[dist_5.QUOTE] = function (node, next) { return "<blockquote>".concat(next(node.content), "</blockquote>"); }, | ||
_a[dist_5.HR] = function () { return '<hr/>'; }, | ||
_a[dist_5.TABLE] = function (node, next) { return "<table>".concat(next(node.content), "</table>"); }, | ||
_a[dist_5.TABLE_ROW] = function (node, next) { return "<tr>".concat(next(node.content), "</tr>"); }, | ||
_a[dist_5.TABLE_HEADER_CELL] = function (node, next) { return "<th>".concat(next(node.content), "</th>"); }, | ||
_a[dist_5.TABLE_CELL] = function (node, next) { return "<td>".concat(next(node.content), "</td>"); }, | ||
_a[dist_4.ASSET_HYPERLINK] = function (node) { return defaultInline(dist_4.ASSET_HYPERLINK, node); }, | ||
_a[dist_4.ENTRY_HYPERLINK] = function (node) { return defaultInline(dist_4.ENTRY_HYPERLINK, node); }, | ||
_a[dist_4.RESOURCE_HYPERLINK] = function (node) { | ||
return defaultInlineResource(dist_4.RESOURCE_HYPERLINK, node); | ||
_a[dist.BLOCKS.PARAGRAPH] = function (node, next) { return "<p>".concat(next(node.content), "</p>"); }, | ||
_a[dist.BLOCKS.HEADING_1] = function (node, next) { return "<h1>".concat(next(node.content), "</h1>"); }, | ||
_a[dist.BLOCKS.HEADING_2] = function (node, next) { return "<h2>".concat(next(node.content), "</h2>"); }, | ||
_a[dist.BLOCKS.HEADING_3] = function (node, next) { return "<h3>".concat(next(node.content), "</h3>"); }, | ||
_a[dist.BLOCKS.HEADING_4] = function (node, next) { return "<h4>".concat(next(node.content), "</h4>"); }, | ||
_a[dist.BLOCKS.HEADING_5] = function (node, next) { return "<h5>".concat(next(node.content), "</h5>"); }, | ||
_a[dist.BLOCKS.HEADING_6] = function (node, next) { return "<h6>".concat(next(node.content), "</h6>"); }, | ||
_a[dist.BLOCKS.EMBEDDED_ENTRY] = function (node, next) { return "<div>".concat(next(node.content), "</div>"); }, | ||
_a[dist.BLOCKS.EMBEDDED_RESOURCE] = function (node, next) { return "<div>".concat(next(node.content), "</div>"); }, | ||
_a[dist.BLOCKS.UL_LIST] = function (node, next) { return "<ul>".concat(next(node.content), "</ul>"); }, | ||
_a[dist.BLOCKS.OL_LIST] = function (node, next) { return "<ol>".concat(next(node.content), "</ol>"); }, | ||
_a[dist.BLOCKS.LIST_ITEM] = function (node, next) { return "<li>".concat(next(node.content), "</li>"); }, | ||
_a[dist.BLOCKS.QUOTE] = function (node, next) { return "<blockquote>".concat(next(node.content), "</blockquote>"); }, | ||
_a[dist.BLOCKS.HR] = function () { return '<hr/>'; }, | ||
_a[dist.BLOCKS.TABLE] = function (node, next) { return "<table>".concat(next(node.content), "</table>"); }, | ||
_a[dist.BLOCKS.TABLE_ROW] = function (node, next) { return "<tr>".concat(next(node.content), "</tr>"); }, | ||
_a[dist.BLOCKS.TABLE_HEADER_CELL] = function (node, next) { return "<th>".concat(next(node.content), "</th>"); }, | ||
_a[dist.BLOCKS.TABLE_CELL] = function (node, next) { return "<td>".concat(next(node.content), "</td>"); }, | ||
_a[dist.INLINES.ASSET_HYPERLINK] = function (node) { return defaultInline(dist.INLINES.ASSET_HYPERLINK, node); }, | ||
_a[dist.INLINES.ENTRY_HYPERLINK] = function (node) { return defaultInline(dist.INLINES.ENTRY_HYPERLINK, node); }, | ||
_a[dist.INLINES.RESOURCE_HYPERLINK] = function (node) { | ||
return defaultInlineResource(dist.INLINES.RESOURCE_HYPERLINK, node); | ||
}, | ||
_a[dist_4.EMBEDDED_ENTRY] = function (node) { return defaultInline(dist_4.EMBEDDED_ENTRY, node); }, | ||
_a[dist_4.EMBEDDED_RESOURCE] = function (node) { | ||
return defaultInlineResource(dist_4.EMBEDDED_RESOURCE, node); | ||
_a[dist.INLINES.EMBEDDED_ENTRY] = function (node) { return defaultInline(dist.INLINES.EMBEDDED_ENTRY, node); }, | ||
_a[dist.INLINES.EMBEDDED_RESOURCE] = function (node) { | ||
return defaultInlineResource(dist.INLINES.EMBEDDED_RESOURCE, node); | ||
}, | ||
_a[dist_4.HYPERLINK] = function (node, next) { | ||
_a[dist.INLINES.HYPERLINK] = function (node, next) { | ||
var href = typeof node.data.uri === 'string' ? node.data.uri : ''; | ||
@@ -537,14 +493,14 @@ return "<a href=".concat(attributeValue(href), ">").concat(next(node.content), "</a>"); | ||
var defaultMarkRenderers = (_b = {}, | ||
_b[dist_3.BOLD] = function (text) { return "<b>".concat(text, "</b>"); }, | ||
_b[dist_3.ITALIC] = function (text) { return "<i>".concat(text, "</i>"); }, | ||
_b[dist_3.UNDERLINE] = function (text) { return "<u>".concat(text, "</u>"); }, | ||
_b[dist_3.CODE] = function (text) { return "<code>".concat(text, "</code>"); }, | ||
_b[dist_3.SUPERSCRIPT] = function (text) { return "<sup>".concat(text, "</sup>"); }, | ||
_b[dist_3.SUBSCRIPT] = function (text) { return "<sub>".concat(text, "</sub>"); }, | ||
_b[dist.MARKS.BOLD] = function (text) { return "<b>".concat(text, "</b>"); }, | ||
_b[dist.MARKS.ITALIC] = function (text) { return "<i>".concat(text, "</i>"); }, | ||
_b[dist.MARKS.UNDERLINE] = function (text) { return "<u>".concat(text, "</u>"); }, | ||
_b[dist.MARKS.CODE] = function (text) { return "<code>".concat(text, "</code>"); }, | ||
_b[dist.MARKS.SUPERSCRIPT] = function (text) { return "<sup>".concat(text, "</sup>"); }, | ||
_b[dist.MARKS.SUBSCRIPT] = function (text) { return "<sub>".concat(text, "</sub>"); }, | ||
_b); | ||
var defaultInline = function (type, node) { | ||
return "<span>type: ".concat(escapeHtml_1(type), " id: ").concat(escapeHtml_1(node.data.target.sys.id), "</span>"); | ||
return "<span>type: ".concat(escape(type), " id: ").concat(escape(node.data.target.sys.id), "</span>"); | ||
}; | ||
var defaultInlineResource = function (type, node) { | ||
return "<span>type: ".concat(escapeHtml_1(type), " urn: ").concat(escapeHtml_1(node.data.target.sys.urn), "</span>"); | ||
return "<span>type: ".concat(escape(type), " urn: ").concat(escape(node.data.target.sys.urn), "</span>"); | ||
}; | ||
@@ -573,4 +529,4 @@ /** | ||
var renderNode = _a.renderNode, renderMark = _a.renderMark, preserveWhitespace = _a.preserveWhitespace; | ||
if (dist_1.isText(node)) { | ||
var nodeValue = escapeHtml_1(node.value); | ||
if (dist.helpers.isText(node)) { | ||
var nodeValue = escape(node.value); | ||
// If preserveWhitespace is true, handle line breaks and spaces. | ||
@@ -577,0 +533,0 @@ if (preserveWhitespace) { |
{ | ||
"name": "@contentful/rich-text-html-renderer", | ||
"version": "16.3.5", | ||
"version": "16.4.0", | ||
"main": "dist/rich-text-html-renderer.es5.js", | ||
@@ -23,4 +23,4 @@ "typings": "dist/types/index.d.ts", | ||
"prebuild": "rimraf dist", | ||
"build": "tsc --module commonjs && rollup -c rollup.config.js", | ||
"start": "tsc && rollup -c rollup.config.js -w", | ||
"build": "tsc --module commonjs && rollup -c --bundleConfigAsCjs rollup.config.js", | ||
"start": "tsc && rollup -c --bundleConfigAsCjs rollup.config.js -w", | ||
"lint": "tslint -t codeFrame '@(src|bin)/*.ts'", | ||
@@ -30,3 +30,3 @@ "test": "jest" | ||
"dependencies": { | ||
"@contentful/rich-text-types": "^16.3.5", | ||
"@contentful/rich-text-types": "^16.4.0", | ||
"escape-html": "^1.0.3" | ||
@@ -37,11 +37,4 @@ }, | ||
"@types/lodash.clonedeep": "^4.5.6", | ||
"jest": "^27.1.0", | ||
"lodash.clonedeep": "^4.5.0", | ||
"rimraf": "^2.6.3", | ||
"rollup": "^1.32.1", | ||
"rollup-plugin-commonjs": "^9.3.4", | ||
"rollup-plugin-json": "^4.0.0", | ||
"rollup-plugin-node-resolve": "^4.2.3", | ||
"rollup-plugin-sourcemaps": "^0.6.3", | ||
"rollup-plugin-typescript2": "^0.36.0", | ||
"ts-jest": "^29.1.2", | ||
@@ -51,3 +44,3 @@ "tslint": "^6.1.3", | ||
}, | ||
"gitHead": "63b4725a298fa5ea480f19e06cfc324996941c95" | ||
"gitHead": "f39fbb99956d719a695eb917dbddb5af969d52b6" | ||
} |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
145585
7
1770