New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

@contentful/rich-text-html-renderer

Package Overview
Dependencies
Maintainers
142
Versions
86
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

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

Comparing version 15.13.1 to 15.15.1

18

dist/lib/__test__/index.test.js

@@ -58,2 +58,10 @@ "use strict";

},
{
doc: (0, documents_1.marksDoc)(rich_text_types_1.MARKS.SUPERSCRIPT),
expected: '<p><sup>hello world</sup></p>',
},
{
doc: (0, documents_1.marksDoc)(rich_text_types_1.MARKS.SUBSCRIPT),
expected: '<p><sub>hello world</sub></p>',
},
];

@@ -69,3 +77,3 @@ docs.forEach(function (_a) {

renderNode: (_a = {},
_a[rich_text_types_1.BLOCKS.PARAGRAPH] = function (node, next) { return "<p>" + next(node.content) + "</p>"; },
_a[rich_text_types_1.BLOCKS.PARAGRAPH] = function (node, next) { return "<p>".concat(next(node.content), "</p>"); },
_a),

@@ -81,3 +89,3 @@ };

renderMark: (_a = {},
_a[rich_text_types_1.MARKS.UNDERLINE] = function (text) { return "<u>" + text + "</u>"; },
_a[rich_text_types_1.MARKS.UNDERLINE] = function (text) { return "<u>".concat(text, "</u>"); },
_a),

@@ -222,3 +230,3 @@ };

var document = (0, inline_entity_1.default)(asset, rich_text_types_1.INLINES.ASSET_HYPERLINK);
var expected = "<p><span>type: " + rich_text_types_1.INLINES.ASSET_HYPERLINK + " id: " + asset.target.sys.id + "</span></p>";
var expected = "<p><span>type: ".concat(rich_text_types_1.INLINES.ASSET_HYPERLINK, " id: ").concat(asset.target.sys.id, "</span></p>");
expect((0, index_1.documentToHtmlString)(document)).toEqual(expected);

@@ -237,3 +245,3 @@ });

var document = (0, inline_entity_1.default)(entry, rich_text_types_1.INLINES.ENTRY_HYPERLINK);
var expected = "<p><span>type: " + rich_text_types_1.INLINES.ENTRY_HYPERLINK + " id: " + entry.target.sys.id + "</span></p>";
var expected = "<p><span>type: ".concat(rich_text_types_1.INLINES.ENTRY_HYPERLINK, " id: ").concat(entry.target.sys.id, "</span></p>");
expect((0, index_1.documentToHtmlString)(document)).toEqual(expected);

@@ -252,3 +260,3 @@ });

var document = (0, inline_entity_1.default)(entry, rich_text_types_1.INLINES.EMBEDDED_ENTRY);
var expected = "<p><span>type: " + rich_text_types_1.INLINES.EMBEDDED_ENTRY + " id: " + entry.target.sys.id + "</span></p>";
var expected = "<p><span>type: ".concat(rich_text_types_1.INLINES.EMBEDDED_ENTRY, " id: ").concat(entry.target.sys.id, "</span></p>");
expect((0, index_1.documentToHtmlString)(document)).toEqual(expected);

@@ -255,0 +263,0 @@ });

@@ -21,21 +21,21 @@ "use strict";

var rich_text_types_1 = require("@contentful/rich-text-types");
var attributeValue = function (value) { return "\"" + value.replace(/"/g, '&quot;') + "\""; };
var attributeValue = function (value) { return "\"".concat(value.replace(/"/g, '&quot;'), "\""); };
var defaultNodeRenderers = (_a = {},
_a[rich_text_types_1.BLOCKS.PARAGRAPH] = function (node, next) { return "<p>" + next(node.content) + "</p>"; },
_a[rich_text_types_1.BLOCKS.HEADING_1] = function (node, next) { return "<h1>" + next(node.content) + "</h1>"; },
_a[rich_text_types_1.BLOCKS.HEADING_2] = function (node, next) { return "<h2>" + next(node.content) + "</h2>"; },
_a[rich_text_types_1.BLOCKS.HEADING_3] = function (node, next) { return "<h3>" + next(node.content) + "</h3>"; },
_a[rich_text_types_1.BLOCKS.HEADING_4] = function (node, next) { return "<h4>" + next(node.content) + "</h4>"; },
_a[rich_text_types_1.BLOCKS.HEADING_5] = function (node, next) { return "<h5>" + next(node.content) + "</h5>"; },
_a[rich_text_types_1.BLOCKS.HEADING_6] = function (node, next) { return "<h6>" + next(node.content) + "</h6>"; },
_a[rich_text_types_1.BLOCKS.EMBEDDED_ENTRY] = function (node, next) { return "<div>" + next(node.content) + "</div>"; },
_a[rich_text_types_1.BLOCKS.UL_LIST] = function (node, next) { return "<ul>" + next(node.content) + "</ul>"; },
_a[rich_text_types_1.BLOCKS.OL_LIST] = function (node, next) { return "<ol>" + next(node.content) + "</ol>"; },
_a[rich_text_types_1.BLOCKS.LIST_ITEM] = function (node, next) { return "<li>" + next(node.content) + "</li>"; },
_a[rich_text_types_1.BLOCKS.QUOTE] = function (node, next) { return "<blockquote>" + next(node.content) + "</blockquote>"; },
_a[rich_text_types_1.BLOCKS.PARAGRAPH] = function (node, next) { return "<p>".concat(next(node.content), "</p>"); },
_a[rich_text_types_1.BLOCKS.HEADING_1] = function (node, next) { return "<h1>".concat(next(node.content), "</h1>"); },
_a[rich_text_types_1.BLOCKS.HEADING_2] = function (node, next) { return "<h2>".concat(next(node.content), "</h2>"); },
_a[rich_text_types_1.BLOCKS.HEADING_3] = function (node, next) { return "<h3>".concat(next(node.content), "</h3>"); },
_a[rich_text_types_1.BLOCKS.HEADING_4] = function (node, next) { return "<h4>".concat(next(node.content), "</h4>"); },
_a[rich_text_types_1.BLOCKS.HEADING_5] = function (node, next) { return "<h5>".concat(next(node.content), "</h5>"); },
_a[rich_text_types_1.BLOCKS.HEADING_6] = function (node, next) { return "<h6>".concat(next(node.content), "</h6>"); },
_a[rich_text_types_1.BLOCKS.EMBEDDED_ENTRY] = function (node, next) { return "<div>".concat(next(node.content), "</div>"); },
_a[rich_text_types_1.BLOCKS.UL_LIST] = function (node, next) { return "<ul>".concat(next(node.content), "</ul>"); },
_a[rich_text_types_1.BLOCKS.OL_LIST] = function (node, next) { return "<ol>".concat(next(node.content), "</ol>"); },
_a[rich_text_types_1.BLOCKS.LIST_ITEM] = function (node, next) { return "<li>".concat(next(node.content), "</li>"); },
_a[rich_text_types_1.BLOCKS.QUOTE] = function (node, next) { return "<blockquote>".concat(next(node.content), "</blockquote>"); },
_a[rich_text_types_1.BLOCKS.HR] = function () { return '<hr/>'; },
_a[rich_text_types_1.BLOCKS.TABLE] = function (node, next) { return "<table>" + next(node.content) + "</table>"; },
_a[rich_text_types_1.BLOCKS.TABLE_ROW] = function (node, next) { return "<tr>" + next(node.content) + "</tr>"; },
_a[rich_text_types_1.BLOCKS.TABLE_HEADER_CELL] = function (node, next) { return "<th>" + next(node.content) + "</th>"; },
_a[rich_text_types_1.BLOCKS.TABLE_CELL] = function (node, next) { return "<td>" + next(node.content) + "</td>"; },
_a[rich_text_types_1.BLOCKS.TABLE] = function (node, next) { return "<table>".concat(next(node.content), "</table>"); },
_a[rich_text_types_1.BLOCKS.TABLE_ROW] = function (node, next) { return "<tr>".concat(next(node.content), "</tr>"); },
_a[rich_text_types_1.BLOCKS.TABLE_HEADER_CELL] = function (node, next) { return "<th>".concat(next(node.content), "</th>"); },
_a[rich_text_types_1.BLOCKS.TABLE_CELL] = function (node, next) { return "<td>".concat(next(node.content), "</td>"); },
_a[rich_text_types_1.INLINES.ASSET_HYPERLINK] = function (node) { return defaultInline(rich_text_types_1.INLINES.ASSET_HYPERLINK, node); },

@@ -46,13 +46,15 @@ _a[rich_text_types_1.INLINES.ENTRY_HYPERLINK] = function (node) { return defaultInline(rich_text_types_1.INLINES.ENTRY_HYPERLINK, node); },

var href = typeof node.data.uri === 'string' ? node.data.uri : '';
return "<a href=" + attributeValue(href) + ">" + next(node.content) + "</a>";
return "<a href=".concat(attributeValue(href), ">").concat(next(node.content), "</a>");
},
_a);
var defaultMarkRenderers = (_b = {},
_b[rich_text_types_1.MARKS.BOLD] = function (text) { return "<b>" + text + "</b>"; },
_b[rich_text_types_1.MARKS.ITALIC] = function (text) { return "<i>" + text + "</i>"; },
_b[rich_text_types_1.MARKS.UNDERLINE] = function (text) { return "<u>" + text + "</u>"; },
_b[rich_text_types_1.MARKS.CODE] = function (text) { return "<code>" + text + "</code>"; },
_b[rich_text_types_1.MARKS.BOLD] = function (text) { return "<b>".concat(text, "</b>"); },
_b[rich_text_types_1.MARKS.ITALIC] = function (text) { return "<i>".concat(text, "</i>"); },
_b[rich_text_types_1.MARKS.UNDERLINE] = function (text) { return "<u>".concat(text, "</u>"); },
_b[rich_text_types_1.MARKS.CODE] = function (text) { return "<code>".concat(text, "</code>"); },
_b[rich_text_types_1.MARKS.SUPERSCRIPT] = function (text) { return "<sup>".concat(text, "</sup>"); },
_b[rich_text_types_1.MARKS.SUBSCRIPT] = function (text) { return "<sub>".concat(text, "</sub>"); },
_b);
var defaultInline = function (type, node) {
return "<span>type: " + (0, escape_html_1.default)(type) + " id: " + (0, escape_html_1.default)(node.data.target.sys.id) + "</span>";
return "<span>type: ".concat((0, escape_html_1.default)(type), " id: ").concat((0, escape_html_1.default)(node.data.target.sys.id), "</span>");
};

@@ -75,5 +77,3 @@ /**

var renderNode = _a.renderNode, renderMark = _a.renderMark;
return nodes
.map(function (node) { return nodeToHtmlString(node, { renderNode: renderNode, renderMark: renderMark }); })
.join('');
return nodes.map(function (node) { return nodeToHtmlString(node, { renderNode: renderNode, renderMark: renderMark }); }).join('');
}

@@ -80,0 +80,0 @@ function nodeToHtmlString(node, _a) {

@@ -182,2 +182,4 @@ 'use strict';

MARKS["CODE"] = "code";
MARKS["SUPERSCRIPT"] = "superscript";
MARKS["SUBSCRIPT"] = "subscript";
})(MARKS || (MARKS = {}));

@@ -200,7 +202,11 @@ exports.default = MARKS;

};
var __importDefault = (commonjsGlobal && commonjsGlobal.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
var _a;
Object.defineProperty(exports, "__esModule", { value: true });
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;
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 marks_1 = __importDefault(marks);
/**

@@ -309,2 +315,6 @@ * Array of all top level block types.

];
/**
* Marks before `superscript` & `subscript` release.
*/
exports.V1_MARKS = [marks_1.default.BOLD, marks_1.default.CODE, marks_1.default.ITALIC, marks_1.default.UNDERLINE];

@@ -314,10 +324,11 @@ });

unwrapExports(schemaConstraints);
var schemaConstraints_1 = schemaConstraints.V1_NODE_TYPES;
var schemaConstraints_2 = schemaConstraints.TEXT_CONTAINERS;
var schemaConstraints_3 = schemaConstraints.HEADINGS;
var schemaConstraints_4 = schemaConstraints.CONTAINERS;
var schemaConstraints_5 = schemaConstraints.VOID_BLOCKS;
var schemaConstraints_6 = schemaConstraints.TABLE_BLOCKS;
var schemaConstraints_7 = schemaConstraints.LIST_ITEM_BLOCKS;
var schemaConstraints_8 = schemaConstraints.TOP_LEVEL_BLOCKS;
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;

@@ -419,3 +430,7 @@ var types = createCommonjsModule(function (module, exports) {

if (k2 === undefined) k2 = k;
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[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) {

@@ -469,21 +484,21 @@ if (k2 === undefined) k2 = k;

var _a, _b;
var attributeValue = function (value) { return "\"" + value.replace(/"/g, '&quot;') + "\""; };
var attributeValue = function (value) { return "\"".concat(value.replace(/"/g, '&quot;'), "\""); };
var defaultNodeRenderers = (_a = {},
_a[dist_5.PARAGRAPH] = function (node, next) { return "<p>" + next(node.content) + "</p>"; },
_a[dist_5.HEADING_1] = function (node, next) { return "<h1>" + next(node.content) + "</h1>"; },
_a[dist_5.HEADING_2] = function (node, next) { return "<h2>" + next(node.content) + "</h2>"; },
_a[dist_5.HEADING_3] = function (node, next) { return "<h3>" + next(node.content) + "</h3>"; },
_a[dist_5.HEADING_4] = function (node, next) { return "<h4>" + next(node.content) + "</h4>"; },
_a[dist_5.HEADING_5] = function (node, next) { return "<h5>" + next(node.content) + "</h5>"; },
_a[dist_5.HEADING_6] = function (node, next) { return "<h6>" + next(node.content) + "</h6>"; },
_a[dist_5.EMBEDDED_ENTRY] = function (node, next) { return "<div>" + next(node.content) + "</div>"; },
_a[dist_5.UL_LIST] = function (node, next) { return "<ul>" + next(node.content) + "</ul>"; },
_a[dist_5.OL_LIST] = function (node, next) { return "<ol>" + next(node.content) + "</ol>"; },
_a[dist_5.LIST_ITEM] = function (node, next) { return "<li>" + next(node.content) + "</li>"; },
_a[dist_5.QUOTE] = function (node, next) { return "<blockquote>" + next(node.content) + "</blockquote>"; },
_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.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>" + next(node.content) + "</table>"; },
_a[dist_5.TABLE_ROW] = function (node, next) { return "<tr>" + next(node.content) + "</tr>"; },
_a[dist_5.TABLE_HEADER_CELL] = function (node, next) { return "<th>" + next(node.content) + "</th>"; },
_a[dist_5.TABLE_CELL] = function (node, next) { return "<td>" + next(node.content) + "</td>"; },
_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); },

@@ -494,13 +509,15 @@ _a[dist_4.ENTRY_HYPERLINK] = function (node) { return defaultInline(dist_4.ENTRY_HYPERLINK, node); },

var href = typeof node.data.uri === 'string' ? node.data.uri : '';
return "<a href=" + attributeValue(href) + ">" + next(node.content) + "</a>";
return "<a href=".concat(attributeValue(href), ">").concat(next(node.content), "</a>");
},
_a);
var defaultMarkRenderers = (_b = {},
_b[dist_3.BOLD] = function (text) { return "<b>" + text + "</b>"; },
_b[dist_3.ITALIC] = function (text) { return "<i>" + text + "</i>"; },
_b[dist_3.UNDERLINE] = function (text) { return "<u>" + text + "</u>"; },
_b[dist_3.CODE] = function (text) { return "<code>" + text + "</code>"; },
_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);
var defaultInline = function (type, node) {
return "<span>type: " + escapeHtml_1(type) + " id: " + escapeHtml_1(node.data.target.sys.id) + "</span>";
return "<span>type: ".concat(escapeHtml_1(type), " id: ").concat(escapeHtml_1(node.data.target.sys.id), "</span>");
};

@@ -522,5 +539,3 @@ /**

var renderNode = _a.renderNode, renderMark = _a.renderMark;
return nodes
.map(function (node) { return nodeToHtmlString(node, { renderNode: renderNode, renderMark: renderMark }); })
.join('');
return nodes.map(function (node) { return nodeToHtmlString(node, { renderNode: renderNode, renderMark: renderMark }); }).join('');
}

@@ -527,0 +542,0 @@ function nodeToHtmlString(node, _a) {

import { Document, Text, Block, Inline } from '@contentful/rich-text-types';
export declare type CommonNode = Text | Block | Inline;
export type CommonNode = Text | Block | Inline;
export interface Next {

@@ -4,0 +4,0 @@ (nodes: CommonNode[]): string;

{
"name": "@contentful/rich-text-html-renderer",
"version": "15.13.1",
"version": "15.15.1",
"main": "dist/rich-text-html-renderer.es5.js",

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

"dependencies": {
"@contentful/rich-text-types": "^15.12.1",
"@contentful/rich-text-types": "^15.15.1",
"escape-html": "^1.0.3"

@@ -47,3 +47,3 @@ },

},
"gitHead": "b29c17da186b4211a17fda22052c466651960015"
"gitHead": "c7e34bc0f0172728999b121af43df88995eec305"
}

@@ -146,2 +146,3 @@ # rich-text-html-renderer

- `BLOCKS`
- `DOCUMENT`

@@ -175,1 +176,3 @@ - `PARAGRAPH`

- `CODE`
- `SUPERSCRIPT`
- `SUBSCRIPT`

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

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