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

@contentstack/utils

Package Overview
Dependencies
Maintainers
13
Versions
23
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@contentstack/utils - npm Package Compare versions

Comparing version 1.3.4 to 1.3.5

dist/lib/updateAssetURLForGQL.js

97

dist/index.es.js

@@ -439,3 +439,3 @@ 'use strict';

_a[NodeType$1.PARAGRAPH] = function (node, next) {
return "<p".concat(node.attrs.style ? " style=\"".concat(node.attrs.style, "\"") : "").concat(node.attrs.class ? " class=\"".concat(node.attrs.class, "\"") : "").concat(node.attrs.id ? " id=\"".concat(node.attrs.id, "\"") : "", ">").concat(next(node.children), "</p>");
return "<p".concat(node.attrs.style ? " style=\"".concat(node.attrs.style, "\"") : "").concat(node.attrs['class-name'] ? " class=\"".concat(node.attrs['class-name'], "\"") : "").concat(node.attrs.id ? " id=\"".concat(node.attrs.id, "\"") : "", ">").concat(next(node.children), "</p>");
},

@@ -445,34 +445,34 @@ _a[NodeType$1.LINK] = function (node, next) {

if (node.attrs.target) {
return "<a".concat(node.attrs.style ? " style=\"".concat(node.attrs.style, "\"") : "").concat(node.attrs.class ? " class=\"".concat(node.attrs.class, "\"") : "").concat(node.attrs.id ? " id=\"".concat(node.attrs.id, "\"") : "", " href=\"").concat(sanitizedHref, "\" target=\"").concat(node.attrs.target, "\">").concat(next(node.children), "</a>");
return "<a".concat(node.attrs.style ? " style=\"".concat(node.attrs.style, "\"") : "").concat(node.attrs['class-name'] ? " class=\"".concat(node.attrs['class-name'], "\"") : "").concat(node.attrs.id ? " id=\"".concat(node.attrs.id, "\"") : "", " href=\"").concat(sanitizedHref, "\" target=\"").concat(node.attrs.target, "\">").concat(next(node.children), "</a>");
}
return "<a".concat(node.attrs.style ? " style=\"".concat(node.attrs.style, "\"") : "").concat(node.attrs.class ? " class=\"".concat(node.attrs.class, "\"") : "").concat(node.attrs.id ? " id=\"".concat(node.attrs.id, "\"") : "", " href=\"").concat(sanitizedHref, "\">").concat(next(node.children), "</a>");
return "<a".concat(node.attrs.style ? " style=\"".concat(node.attrs.style, "\"") : "").concat(node.attrs['class-name'] ? " class=\"".concat(node.attrs['class-name'], "\"") : "").concat(node.attrs.id ? " id=\"".concat(node.attrs.id, "\"") : "", " href=\"").concat(sanitizedHref, "\">").concat(next(node.children), "</a>");
},
_a[NodeType$1.IMAGE] = function (node, next) {
var sanitizedSrc = DOMPurify__namespace.sanitize(node.attrs.src || node.attrs.url);
return "<img".concat(node.attrs.style ? " style=\"".concat(node.attrs.style, "\"") : "").concat(node.attrs.class ? " class=\"".concat(node.attrs.class, "\"") : "").concat(node.attrs.id ? " id=\"".concat(node.attrs.id, "\"") : "", " src=\"").concat(sanitizedSrc, "\" />").concat(next(node.children));
return "<img".concat(node.attrs.style ? " style=\"".concat(node.attrs.style, "\"") : "").concat(node.attrs['class-name'] ? " class=\"".concat(node.attrs['class-name'], "\"") : "").concat(node.attrs.id ? " id=\"".concat(node.attrs.id, "\"") : "", " src=\"").concat(sanitizedSrc, "\" />").concat(next(node.children));
},
_a[NodeType$1.EMBED] = function (node, next) {
var sanitizedSrc = DOMPurify__namespace.sanitize(node.attrs.src || node.attrs.url);
return "<iframe".concat(node.attrs.style ? " style=\"".concat(node.attrs.style, "\"") : "").concat(node.attrs.class ? " class=\"".concat(node.attrs.class, "\"") : "").concat(node.attrs.id ? " id=\"".concat(node.attrs.id, "\"") : "", " src=\"").concat(sanitizedSrc, "\">").concat(next(node.children), "</iframe>");
return "<iframe".concat(node.attrs.style ? " style=\"".concat(node.attrs.style, "\"") : "").concat(node.attrs['class-name'] ? " class=\"".concat(node.attrs['class-name'], "\"") : "").concat(node.attrs.id ? " id=\"".concat(node.attrs.id, "\"") : "", " src=\"").concat(sanitizedSrc, "\">").concat(next(node.children), "</iframe>");
},
_a[NodeType$1.HEADING_1] = function (node, next) {
return "<h1".concat(node.attrs.style ? " style=\"".concat(node.attrs.style, "\"") : "").concat(node.attrs.class ? " class=\"".concat(node.attrs.class, "\"") : "").concat(node.attrs.id ? " id=\"".concat(node.attrs.id, "\"") : "", ">").concat(next(node.children), "</h1>");
return "<h1".concat(node.attrs.style ? " style=\"".concat(node.attrs.style, "\"") : "").concat(node.attrs['class-name'] ? " class=\"".concat(node.attrs['class-name'], "\"") : "").concat(node.attrs.id ? " id=\"".concat(node.attrs.id, "\"") : "", ">").concat(next(node.children), "</h1>");
},
_a[NodeType$1.HEADING_2] = function (node, next) {
return "<h2".concat(node.attrs.style ? " style=\"".concat(node.attrs.style, "\"") : "").concat(node.attrs.class ? " class=\"".concat(node.attrs.class, "\"") : "").concat(node.attrs.id ? " id=\"".concat(node.attrs.id, "\"") : "", ">").concat(next(node.children), "</h2>");
return "<h2".concat(node.attrs.style ? " style=\"".concat(node.attrs.style, "\"") : "").concat(node.attrs['class-name'] ? " class=\"".concat(node.attrs['class-name'], "\"") : "").concat(node.attrs.id ? " id=\"".concat(node.attrs.id, "\"") : "", ">").concat(next(node.children), "</h2>");
},
_a[NodeType$1.HEADING_3] = function (node, next) {
return "<h3".concat(node.attrs.style ? " style=\"".concat(node.attrs.style, "\"") : "").concat(node.attrs.class ? " class=\"".concat(node.attrs.class, "\"") : "").concat(node.attrs.id ? " id=\"".concat(node.attrs.id, "\"") : "", ">").concat(next(node.children), "</h3>");
return "<h3".concat(node.attrs.style ? " style=\"".concat(node.attrs.style, "\"") : "").concat(node.attrs['class-name'] ? " class=\"".concat(node.attrs['class-name'], "\"") : "").concat(node.attrs.id ? " id=\"".concat(node.attrs.id, "\"") : "", ">").concat(next(node.children), "</h3>");
},
_a[NodeType$1.HEADING_4] = function (node, next) {
return "<h4".concat(node.attrs.style ? " style=\"".concat(node.attrs.style, "\"") : "").concat(node.attrs.class ? " class=\"".concat(node.attrs.class, "\"") : "").concat(node.attrs.id ? " id=\"".concat(node.attrs.id, "\"") : "", ">").concat(next(node.children), "</h4>");
return "<h4".concat(node.attrs.style ? " style=\"".concat(node.attrs.style, "\"") : "").concat(node.attrs['class-name'] ? " class=\"".concat(node.attrs['class-name'], "\"") : "").concat(node.attrs.id ? " id=\"".concat(node.attrs.id, "\"") : "", ">").concat(next(node.children), "</h4>");
},
_a[NodeType$1.HEADING_5] = function (node, next) {
return "<h5".concat(node.attrs.style ? " style=\"".concat(node.attrs.style, "\"") : "").concat(node.attrs.class ? " class=\"".concat(node.attrs.class, "\"") : "").concat(node.attrs.id ? " id=\"".concat(node.attrs.id, "\"") : "", ">").concat(next(node.children), "</h5>");
return "<h5".concat(node.attrs.style ? " style=\"".concat(node.attrs.style, "\"") : "").concat(node.attrs['class-name'] ? " class=\"".concat(node.attrs['class-name'], "\"") : "").concat(node.attrs.id ? " id=\"".concat(node.attrs.id, "\"") : "", ">").concat(next(node.children), "</h5>");
},
_a[NodeType$1.HEADING_6] = function (node, next) {
return "<h6".concat(node.attrs.style ? " style=\"".concat(node.attrs.style, "\"") : "").concat(node.attrs.class ? " class=\"".concat(node.attrs.class, "\"") : "").concat(node.attrs.id ? " id=\"".concat(node.attrs.id, "\"") : "", ">").concat(next(node.children), "</h6>");
return "<h6".concat(node.attrs.style ? " style=\"".concat(node.attrs.style, "\"") : "").concat(node.attrs['class-name'] ? " class=\"".concat(node.attrs['class-name'], "\"") : "").concat(node.attrs.id ? " id=\"".concat(node.attrs.id, "\"") : "", ">").concat(next(node.children), "</h6>");
},
_a[NodeType$1.ORDER_LIST] = function (node, next) {
return "<ol".concat(node.attrs.style ? " style=\"".concat(node.attrs.style, "\"") : "").concat(node.attrs.class ? " class=\"".concat(node.attrs.class, "\"") : "").concat(node.attrs.id ? " id=\"".concat(node.attrs.id, "\"") : "", ">").concat(next(node.children), "</ol>");
return "<ol".concat(node.attrs.style ? " style=\"".concat(node.attrs.style, "\"") : "").concat(node.attrs['class-name'] ? " class=\"".concat(node.attrs['class-name'], "\"") : "").concat(node.attrs.id ? " id=\"".concat(node.attrs.id, "\"") : "", ">").concat(next(node.children), "</ol>");
},

@@ -483,6 +483,6 @@ _a[NodeType$1.FRAGMENT] = function (node, next) {

_a[NodeType$1.UNORDER_LIST] = function (node, next) {
return "<ul".concat(node.attrs.style ? " style=\"".concat(node.attrs.style, "\"") : "").concat(node.attrs.class ? " class=\"".concat(node.attrs.class, "\"") : "").concat(node.attrs.id ? " id=\"".concat(node.attrs.id, "\"") : "", ">").concat(next(node.children), "</ul>");
return "<ul".concat(node.attrs.style ? " style=\"".concat(node.attrs.style, "\"") : "").concat(node.attrs['class-name'] ? " class=\"".concat(node.attrs['class-name'], "\"") : "").concat(node.attrs.id ? " id=\"".concat(node.attrs.id, "\"") : "", ">").concat(next(node.children), "</ul>");
},
_a[NodeType$1.LIST_ITEM] = function (node, next) {
return "<li".concat(node.attrs.style ? " style=\"".concat(node.attrs.style, "\"") : "").concat(node.attrs.class ? " class=\"".concat(node.attrs.class, "\"") : "").concat(node.attrs.id ? " id=\"".concat(node.attrs.id, "\"") : "", ">").concat(next(node.children), "</li>");
return "<li".concat(node.attrs.style ? " style=\"".concat(node.attrs.style, "\"") : "").concat(node.attrs['class-name'] ? " class=\"".concat(node.attrs['class-name'], "\"") : "").concat(node.attrs.id ? " id=\"".concat(node.attrs.id, "\"") : "", ">").concat(next(node.children), "</li>");
},

@@ -493,27 +493,39 @@ _a[NodeType$1.HR] = function (node, next) {

_a[NodeType$1.TABLE] = function (node, next) {
return "<table".concat(node.attrs.style ? " style=\"".concat(node.attrs.style, "\"") : "").concat(node.attrs.class ? " class=\"".concat(node.attrs.class, "\"") : "").concat(node.attrs.id ? " id=\"".concat(node.attrs.id, "\"") : "", ">").concat(next(node.children), "</table>");
return "<table".concat(node.attrs.style ? " style=\"".concat(node.attrs.style, "\"") : "").concat(node.attrs['class-name'] ? " class=\"".concat(node.attrs['class-name'], "\"") : "").concat(node.attrs.id ? " id=\"".concat(node.attrs.id, "\"") : "", ">").concat(next(node.children), "</table>");
},
_a[NodeType$1.TABLE_HEADER] = function (node, next) {
return "<thead".concat(node.attrs.style ? " style=\"".concat(node.attrs.style, "\"") : "").concat(node.attrs.class ? " class=\"".concat(node.attrs.class, "\"") : "").concat(node.attrs.id ? " id=\"".concat(node.attrs.id, "\"") : "", ">").concat(next(node.children), "</thead>");
return "<thead".concat(node.attrs.style ? " style=\"".concat(node.attrs.style, "\"") : "").concat(node.attrs['class-name'] ? " class=\"".concat(node.attrs['class-name'], "\"") : "").concat(node.attrs.id ? " id=\"".concat(node.attrs.id, "\"") : "", ">").concat(next(node.children), "</thead>");
},
_a[NodeType$1.TABLE_BODY] = function (node, next) {
return "<tbody".concat(node.attrs.style ? " style=\"".concat(node.attrs.style, "\"") : "").concat(node.attrs.class ? " class=\"".concat(node.attrs.class, "\"") : "").concat(node.attrs.id ? " id=\"".concat(node.attrs.id, "\"") : "", ">").concat(next(node.children), "</tbody>");
return "<tbody".concat(node.attrs.style ? " style=\"".concat(node.attrs.style, "\"") : "").concat(node.attrs['class-name'] ? " class=\"".concat(node.attrs['class-name'], "\"") : "").concat(node.attrs.id ? " id=\"".concat(node.attrs.id, "\"") : "", ">").concat(next(node.children), "</tbody>");
},
_a[NodeType$1.TABLE_FOOTER] = function (node, next) {
return "<tfoot".concat(node.attrs.style ? " style=\"".concat(node.attrs.style, "\"") : "").concat(node.attrs.class ? " class=\"".concat(node.attrs.class, "\"") : "").concat(node.attrs.id ? " id=\"".concat(node.attrs.id, "\"") : "", ">").concat(next(node.children), "</tfoot>");
return "<tfoot".concat(node.attrs.style ? " style=\"".concat(node.attrs.style, "\"") : "").concat(node.attrs['class-name'] ? " class=\"".concat(node.attrs['class-name'], "\"") : "").concat(node.attrs.id ? " id=\"".concat(node.attrs.id, "\"") : "", ">").concat(next(node.children), "</tfoot>");
},
_a[NodeType$1.TABLE_ROW] = function (node, next) {
return "<tr".concat(node.attrs.style ? " style=\"".concat(node.attrs.style, "\"") : "").concat(node.attrs.class ? " class=\"".concat(node.attrs.class, "\"") : "").concat(node.attrs.id ? " id=\"".concat(node.attrs.id, "\"") : "", ">").concat(next(node.children), "</tr>");
return "<tr".concat(node.attrs.style ? " style=\"".concat(node.attrs.style, "\"") : "").concat(node.attrs['class-name'] ? " class=\"".concat(node.attrs['class-name'], "\"") : "").concat(node.attrs.id ? " id=\"".concat(node.attrs.id, "\"") : "", ">").concat(next(node.children), "</tr>");
},
_a[NodeType$1.TABLE_HEAD] = function (node, next) {
return "<th".concat(node.attrs.style ? " style=\"".concat(node.attrs.style, "\"") : "").concat(node.attrs.class ? " class=\"".concat(node.attrs.class, "\"") : "").concat(node.attrs.id ? " id=\"".concat(node.attrs.id, "\"") : "", ">").concat(next(node.children), "</th>");
return "<th" +
"".concat(node.attrs.rowSpan ? " rowspan=\"".concat(node.attrs.rowSpan, "\"") : "") +
"".concat(node.attrs.colSpan ? " colspan=\"".concat(node.attrs.colSpan, "\"") : "") +
"".concat(node.attrs.style ? " style=\"".concat(node.attrs.style, "\"") : "") +
"".concat(node.attrs['class-name'] ? " class=\"".concat(node.attrs['class-name'], "\"") : "") +
"".concat(node.attrs.id ? " id=\"".concat(node.attrs.id, "\"") : "", ">").concat(next(node.children)) +
"</th>";
},
_a[NodeType$1.TABLE_DATA] = function (node, next) {
return "<td".concat(node.attrs.style ? " style=\"".concat(node.attrs.style, "\"") : "").concat(node.attrs.class ? " class=\"".concat(node.attrs.class, "\"") : "").concat(node.attrs.id ? " id=\"".concat(node.attrs.id, "\"") : "", ">").concat(next(node.children), "</td>");
return "<td" +
"".concat(node.attrs.rowSpan ? " rowspan=\"".concat(node.attrs.rowSpan, "\"") : "") +
"".concat(node.attrs.colSpan ? " colspan=\"".concat(node.attrs.colSpan, "\"") : "") +
"".concat(node.attrs.style ? " style=\"".concat(node.attrs.style, "\"") : "") +
"".concat(node.attrs['class-name'] ? " class=\"".concat(node.attrs['class-name'], "\"") : "") +
"".concat(node.attrs.id ? " id=\"".concat(node.attrs.id, "\"") : "", ">").concat(next(node.children)) +
"</td>";
},
_a[NodeType$1.BLOCK_QUOTE] = function (node, next) {
return "<blockquote".concat(node.attrs.class ? " class=\"".concat(node.attrs.class, "\"") : "").concat(node.attrs.id ? " id=\"".concat(node.attrs.id, "\"") : "", ">").concat(next(node.children), "</blockquote>");
return "<blockquote".concat(node.attrs['class-name'] ? " class=\"".concat(node.attrs['class-name'], "\"") : "").concat(node.attrs.id ? " id=\"".concat(node.attrs.id, "\"") : "", ">").concat(next(node.children), "</blockquote>");
},
_a[NodeType$1.CODE] = function (node, next) {
return "<code".concat(node.attrs.class ? " class=\"".concat(node.attrs.class, "\"") : "").concat(node.attrs.id ? " id=\"".concat(node.attrs.id, "\"") : "", ">").concat(next(node.children), "</code>");
return "<code".concat(node.attrs['class-name'] ? " class=\"".concat(node.attrs['class-name'], "\"") : "").concat(node.attrs.id ? " id=\"".concat(node.attrs.id, "\"") : "", ">").concat(next(node.children), "</code>");
},

@@ -523,3 +535,3 @@ _a['reference'] = function (node, next) {

if (node.attrs.type === 'asset') {
return "<img".concat(node.attrs.style ? " style=\"".concat(node.attrs.style, "\"") : "").concat(node.attrs.class ? " class=\"".concat(node.attrs.class, "\"") : "").concat(node.attrs.id ? " id=\"".concat(node.attrs.id, "\"") : "", " src=\"").concat(sanitizedAsset, "\" />");
return "<img".concat(node.attrs.style ? " style=\"".concat(node.attrs.style, "\"") : "").concat(node.attrs['class-name'] ? " class=\"".concat(node.attrs['class-name'], "\"") : "").concat(node.attrs.id ? " id=\"".concat(node.attrs.id, "\"") : "", " src=\"").concat(sanitizedAsset, "\" />");
}

@@ -615,5 +627,5 @@ return "";

if (node.attrs.target) {
return "<a".concat(node.attrs.style ? " style=\"".concat(node.attrs.style, "\"") : "").concat(node.attrs.class ? " class=\"".concat(node.attrs.class, "\"") : "").concat(node.attrs.id ? " id=\"".concat(node.attrs.id, "\"") : "", " href=\"").concat(node.attrs.href || node.attrs.url, "\" target=\"").concat(node.attrs.target, "\">").concat(entryText, "</a>");
return "<a".concat(node.attrs.style ? " style=\"".concat(node.attrs.style, "\"") : "").concat(node.attrs['class-name'] ? " class=\"".concat(node.attrs['class-name'], "\"") : "").concat(node.attrs.id ? " id=\"".concat(node.attrs.id, "\"") : "", " href=\"").concat(node.attrs.href || node.attrs.url, "\" target=\"").concat(node.attrs.target, "\">").concat(entryText, "</a>");
}
return "<a".concat(node.attrs.style ? " style=\"".concat(node.attrs.style, "\"") : "").concat(node.attrs.class ? " class=\"".concat(node.attrs.class, "\"") : "").concat(node.attrs.id ? " id=\"".concat(node.attrs.id, "\"") : "", " href=\"").concat(node.attrs.href || node.attrs.url, "\">").concat(entryText, "</a>");
return "<a".concat(node.attrs.style ? " style=\"".concat(node.attrs.style, "\"") : "").concat(node.attrs['class-name'] ? " class=\"".concat(node.attrs['class-name'], "\"") : "").concat(node.attrs.id ? " id=\"".concat(node.attrs.id, "\"") : "", " href=\"").concat(node.attrs.href || node.attrs.url, "\">").concat(entryText, "</a>");
}

@@ -852,2 +864,34 @@ function sendToRenderOption(referenceNode) {

function updateAssetURLForGQL(gqlResponse) {
var _a;
try {
var response = gqlResponse === null || gqlResponse === void 0 ? void 0 : gqlResponse.data;
for (var contentType in response) {
var entry = response[contentType]; // page_json_rte
var _loop_1 = function (field) {
var fieldData = entry[field];
if (fieldData && fieldData.embedded_itemsConnection) { // rte field with embedded items e.g rte_2
var edges = (_a = fieldData === null || fieldData === void 0 ? void 0 : fieldData.embedded_itemsConnection) === null || _a === void 0 ? void 0 : _a.edges;
edges.forEach(function (edge) {
var _a, _b, _c;
var node = edge.node;
if ((node === null || node === void 0 ? void 0 : node.url) && (node === null || node === void 0 ? void 0 : node.filename)) {
if (!((_a = node === null || node === void 0 ? void 0 : node.system) === null || _a === void 0 ? void 0 : _a.uid))
throw new Error('Asset UID not found in the response');
var correspondingAsset = (_c = (_b = fieldData === null || fieldData === void 0 ? void 0 : fieldData.json) === null || _b === void 0 ? void 0 : _b.children) === null || _c === void 0 ? void 0 : _c.find(function (child) { return child.attrs['asset-uid'] === node.system.uid; });
correspondingAsset.attrs['asset-link'] = node.url;
}
});
}
};
for (var field in entry) {
_loop_1(field);
}
}
}
catch (error) {
console.error('Error in updating asset URL for GQL response', error);
}
}
exports.Document = Document;

@@ -865,2 +909,3 @@ exports.GQL = GQL;

exports.renderContent = renderContent;
exports.updateAssetURLForGQL = updateAssetURLForGQL;
//# sourceMappingURL=index.es.js.map

@@ -71,5 +71,5 @@ var __assign = (this && this.__assign) || function () {

if (node.attrs.target) {
return "<a".concat(node.attrs.style ? " style=\"".concat(node.attrs.style, "\"") : "").concat(node.attrs.class ? " class=\"".concat(node.attrs.class, "\"") : "").concat(node.attrs.id ? " id=\"".concat(node.attrs.id, "\"") : "", " href=\"").concat(node.attrs.href || node.attrs.url, "\" target=\"").concat(node.attrs.target, "\">").concat(entryText, "</a>");
return "<a".concat(node.attrs.style ? " style=\"".concat(node.attrs.style, "\"") : "").concat(node.attrs['class-name'] ? " class=\"".concat(node.attrs['class-name'], "\"") : "").concat(node.attrs.id ? " id=\"".concat(node.attrs.id, "\"") : "", " href=\"").concat(node.attrs.href || node.attrs.url, "\" target=\"").concat(node.attrs.target, "\">").concat(entryText, "</a>");
}
return "<a".concat(node.attrs.style ? " style=\"".concat(node.attrs.style, "\"") : "").concat(node.attrs.class ? " class=\"".concat(node.attrs.class, "\"") : "").concat(node.attrs.id ? " id=\"".concat(node.attrs.id, "\"") : "", " href=\"").concat(node.attrs.href || node.attrs.url, "\">").concat(entryText, "</a>");
return "<a".concat(node.attrs.style ? " style=\"".concat(node.attrs.style, "\"") : "").concat(node.attrs['class-name'] ? " class=\"".concat(node.attrs['class-name'], "\"") : "").concat(node.attrs.id ? " id=\"".concat(node.attrs.id, "\"") : "", " href=\"").concat(node.attrs.href || node.attrs.url, "\">").concat(entryText, "</a>");
}

@@ -76,0 +76,0 @@ function sendToRenderOption(referenceNode) {

@@ -12,2 +12,3 @@ export { attributeToString } from './Models/metadata-model';

export { addTags as addEditableTags } from './entry-editable';
export { updateAssetURLForGQL } from './updateAssetURLForGQL';
//# sourceMappingURL=index.js.map

@@ -10,3 +10,3 @@ var _a;

_a[NodeType.PARAGRAPH] = function (node, next) {
return "<p".concat(node.attrs.style ? " style=\"".concat(node.attrs.style, "\"") : "").concat(node.attrs.class ? " class=\"".concat(node.attrs.class, "\"") : "").concat(node.attrs.id ? " id=\"".concat(node.attrs.id, "\"") : "", ">").concat(next(node.children), "</p>");
return "<p".concat(node.attrs.style ? " style=\"".concat(node.attrs.style, "\"") : "").concat(node.attrs['class-name'] ? " class=\"".concat(node.attrs['class-name'], "\"") : "").concat(node.attrs.id ? " id=\"".concat(node.attrs.id, "\"") : "", ">").concat(next(node.children), "</p>");
},

@@ -16,34 +16,34 @@ _a[NodeType.LINK] = function (node, next) {

if (node.attrs.target) {
return "<a".concat(node.attrs.style ? " style=\"".concat(node.attrs.style, "\"") : "").concat(node.attrs.class ? " class=\"".concat(node.attrs.class, "\"") : "").concat(node.attrs.id ? " id=\"".concat(node.attrs.id, "\"") : "", " href=\"").concat(sanitizedHref, "\" target=\"").concat(node.attrs.target, "\">").concat(next(node.children), "</a>");
return "<a".concat(node.attrs.style ? " style=\"".concat(node.attrs.style, "\"") : "").concat(node.attrs['class-name'] ? " class=\"".concat(node.attrs['class-name'], "\"") : "").concat(node.attrs.id ? " id=\"".concat(node.attrs.id, "\"") : "", " href=\"").concat(sanitizedHref, "\" target=\"").concat(node.attrs.target, "\">").concat(next(node.children), "</a>");
}
return "<a".concat(node.attrs.style ? " style=\"".concat(node.attrs.style, "\"") : "").concat(node.attrs.class ? " class=\"".concat(node.attrs.class, "\"") : "").concat(node.attrs.id ? " id=\"".concat(node.attrs.id, "\"") : "", " href=\"").concat(sanitizedHref, "\">").concat(next(node.children), "</a>");
return "<a".concat(node.attrs.style ? " style=\"".concat(node.attrs.style, "\"") : "").concat(node.attrs['class-name'] ? " class=\"".concat(node.attrs['class-name'], "\"") : "").concat(node.attrs.id ? " id=\"".concat(node.attrs.id, "\"") : "", " href=\"").concat(sanitizedHref, "\">").concat(next(node.children), "</a>");
},
_a[NodeType.IMAGE] = function (node, next) {
var sanitizedSrc = DOMPurify.sanitize(node.attrs.src || node.attrs.url);
return "<img".concat(node.attrs.style ? " style=\"".concat(node.attrs.style, "\"") : "").concat(node.attrs.class ? " class=\"".concat(node.attrs.class, "\"") : "").concat(node.attrs.id ? " id=\"".concat(node.attrs.id, "\"") : "", " src=\"").concat(sanitizedSrc, "\" />").concat(next(node.children));
return "<img".concat(node.attrs.style ? " style=\"".concat(node.attrs.style, "\"") : "").concat(node.attrs['class-name'] ? " class=\"".concat(node.attrs['class-name'], "\"") : "").concat(node.attrs.id ? " id=\"".concat(node.attrs.id, "\"") : "", " src=\"").concat(sanitizedSrc, "\" />").concat(next(node.children));
},
_a[NodeType.EMBED] = function (node, next) {
var sanitizedSrc = DOMPurify.sanitize(node.attrs.src || node.attrs.url);
return "<iframe".concat(node.attrs.style ? " style=\"".concat(node.attrs.style, "\"") : "").concat(node.attrs.class ? " class=\"".concat(node.attrs.class, "\"") : "").concat(node.attrs.id ? " id=\"".concat(node.attrs.id, "\"") : "", " src=\"").concat(sanitizedSrc, "\">").concat(next(node.children), "</iframe>");
return "<iframe".concat(node.attrs.style ? " style=\"".concat(node.attrs.style, "\"") : "").concat(node.attrs['class-name'] ? " class=\"".concat(node.attrs['class-name'], "\"") : "").concat(node.attrs.id ? " id=\"".concat(node.attrs.id, "\"") : "", " src=\"").concat(sanitizedSrc, "\">").concat(next(node.children), "</iframe>");
},
_a[NodeType.HEADING_1] = function (node, next) {
return "<h1".concat(node.attrs.style ? " style=\"".concat(node.attrs.style, "\"") : "").concat(node.attrs.class ? " class=\"".concat(node.attrs.class, "\"") : "").concat(node.attrs.id ? " id=\"".concat(node.attrs.id, "\"") : "", ">").concat(next(node.children), "</h1>");
return "<h1".concat(node.attrs.style ? " style=\"".concat(node.attrs.style, "\"") : "").concat(node.attrs['class-name'] ? " class=\"".concat(node.attrs['class-name'], "\"") : "").concat(node.attrs.id ? " id=\"".concat(node.attrs.id, "\"") : "", ">").concat(next(node.children), "</h1>");
},
_a[NodeType.HEADING_2] = function (node, next) {
return "<h2".concat(node.attrs.style ? " style=\"".concat(node.attrs.style, "\"") : "").concat(node.attrs.class ? " class=\"".concat(node.attrs.class, "\"") : "").concat(node.attrs.id ? " id=\"".concat(node.attrs.id, "\"") : "", ">").concat(next(node.children), "</h2>");
return "<h2".concat(node.attrs.style ? " style=\"".concat(node.attrs.style, "\"") : "").concat(node.attrs['class-name'] ? " class=\"".concat(node.attrs['class-name'], "\"") : "").concat(node.attrs.id ? " id=\"".concat(node.attrs.id, "\"") : "", ">").concat(next(node.children), "</h2>");
},
_a[NodeType.HEADING_3] = function (node, next) {
return "<h3".concat(node.attrs.style ? " style=\"".concat(node.attrs.style, "\"") : "").concat(node.attrs.class ? " class=\"".concat(node.attrs.class, "\"") : "").concat(node.attrs.id ? " id=\"".concat(node.attrs.id, "\"") : "", ">").concat(next(node.children), "</h3>");
return "<h3".concat(node.attrs.style ? " style=\"".concat(node.attrs.style, "\"") : "").concat(node.attrs['class-name'] ? " class=\"".concat(node.attrs['class-name'], "\"") : "").concat(node.attrs.id ? " id=\"".concat(node.attrs.id, "\"") : "", ">").concat(next(node.children), "</h3>");
},
_a[NodeType.HEADING_4] = function (node, next) {
return "<h4".concat(node.attrs.style ? " style=\"".concat(node.attrs.style, "\"") : "").concat(node.attrs.class ? " class=\"".concat(node.attrs.class, "\"") : "").concat(node.attrs.id ? " id=\"".concat(node.attrs.id, "\"") : "", ">").concat(next(node.children), "</h4>");
return "<h4".concat(node.attrs.style ? " style=\"".concat(node.attrs.style, "\"") : "").concat(node.attrs['class-name'] ? " class=\"".concat(node.attrs['class-name'], "\"") : "").concat(node.attrs.id ? " id=\"".concat(node.attrs.id, "\"") : "", ">").concat(next(node.children), "</h4>");
},
_a[NodeType.HEADING_5] = function (node, next) {
return "<h5".concat(node.attrs.style ? " style=\"".concat(node.attrs.style, "\"") : "").concat(node.attrs.class ? " class=\"".concat(node.attrs.class, "\"") : "").concat(node.attrs.id ? " id=\"".concat(node.attrs.id, "\"") : "", ">").concat(next(node.children), "</h5>");
return "<h5".concat(node.attrs.style ? " style=\"".concat(node.attrs.style, "\"") : "").concat(node.attrs['class-name'] ? " class=\"".concat(node.attrs['class-name'], "\"") : "").concat(node.attrs.id ? " id=\"".concat(node.attrs.id, "\"") : "", ">").concat(next(node.children), "</h5>");
},
_a[NodeType.HEADING_6] = function (node, next) {
return "<h6".concat(node.attrs.style ? " style=\"".concat(node.attrs.style, "\"") : "").concat(node.attrs.class ? " class=\"".concat(node.attrs.class, "\"") : "").concat(node.attrs.id ? " id=\"".concat(node.attrs.id, "\"") : "", ">").concat(next(node.children), "</h6>");
return "<h6".concat(node.attrs.style ? " style=\"".concat(node.attrs.style, "\"") : "").concat(node.attrs['class-name'] ? " class=\"".concat(node.attrs['class-name'], "\"") : "").concat(node.attrs.id ? " id=\"".concat(node.attrs.id, "\"") : "", ">").concat(next(node.children), "</h6>");
},
_a[NodeType.ORDER_LIST] = function (node, next) {
return "<ol".concat(node.attrs.style ? " style=\"".concat(node.attrs.style, "\"") : "").concat(node.attrs.class ? " class=\"".concat(node.attrs.class, "\"") : "").concat(node.attrs.id ? " id=\"".concat(node.attrs.id, "\"") : "", ">").concat(next(node.children), "</ol>");
return "<ol".concat(node.attrs.style ? " style=\"".concat(node.attrs.style, "\"") : "").concat(node.attrs['class-name'] ? " class=\"".concat(node.attrs['class-name'], "\"") : "").concat(node.attrs.id ? " id=\"".concat(node.attrs.id, "\"") : "", ">").concat(next(node.children), "</ol>");
},

@@ -54,6 +54,6 @@ _a[NodeType.FRAGMENT] = function (node, next) {

_a[NodeType.UNORDER_LIST] = function (node, next) {
return "<ul".concat(node.attrs.style ? " style=\"".concat(node.attrs.style, "\"") : "").concat(node.attrs.class ? " class=\"".concat(node.attrs.class, "\"") : "").concat(node.attrs.id ? " id=\"".concat(node.attrs.id, "\"") : "", ">").concat(next(node.children), "</ul>");
return "<ul".concat(node.attrs.style ? " style=\"".concat(node.attrs.style, "\"") : "").concat(node.attrs['class-name'] ? " class=\"".concat(node.attrs['class-name'], "\"") : "").concat(node.attrs.id ? " id=\"".concat(node.attrs.id, "\"") : "", ">").concat(next(node.children), "</ul>");
},
_a[NodeType.LIST_ITEM] = function (node, next) {
return "<li".concat(node.attrs.style ? " style=\"".concat(node.attrs.style, "\"") : "").concat(node.attrs.class ? " class=\"".concat(node.attrs.class, "\"") : "").concat(node.attrs.id ? " id=\"".concat(node.attrs.id, "\"") : "", ">").concat(next(node.children), "</li>");
return "<li".concat(node.attrs.style ? " style=\"".concat(node.attrs.style, "\"") : "").concat(node.attrs['class-name'] ? " class=\"".concat(node.attrs['class-name'], "\"") : "").concat(node.attrs.id ? " id=\"".concat(node.attrs.id, "\"") : "", ">").concat(next(node.children), "</li>");
},

@@ -64,27 +64,39 @@ _a[NodeType.HR] = function (node, next) {

_a[NodeType.TABLE] = function (node, next) {
return "<table".concat(node.attrs.style ? " style=\"".concat(node.attrs.style, "\"") : "").concat(node.attrs.class ? " class=\"".concat(node.attrs.class, "\"") : "").concat(node.attrs.id ? " id=\"".concat(node.attrs.id, "\"") : "", ">").concat(next(node.children), "</table>");
return "<table".concat(node.attrs.style ? " style=\"".concat(node.attrs.style, "\"") : "").concat(node.attrs['class-name'] ? " class=\"".concat(node.attrs['class-name'], "\"") : "").concat(node.attrs.id ? " id=\"".concat(node.attrs.id, "\"") : "", ">").concat(next(node.children), "</table>");
},
_a[NodeType.TABLE_HEADER] = function (node, next) {
return "<thead".concat(node.attrs.style ? " style=\"".concat(node.attrs.style, "\"") : "").concat(node.attrs.class ? " class=\"".concat(node.attrs.class, "\"") : "").concat(node.attrs.id ? " id=\"".concat(node.attrs.id, "\"") : "", ">").concat(next(node.children), "</thead>");
return "<thead".concat(node.attrs.style ? " style=\"".concat(node.attrs.style, "\"") : "").concat(node.attrs['class-name'] ? " class=\"".concat(node.attrs['class-name'], "\"") : "").concat(node.attrs.id ? " id=\"".concat(node.attrs.id, "\"") : "", ">").concat(next(node.children), "</thead>");
},
_a[NodeType.TABLE_BODY] = function (node, next) {
return "<tbody".concat(node.attrs.style ? " style=\"".concat(node.attrs.style, "\"") : "").concat(node.attrs.class ? " class=\"".concat(node.attrs.class, "\"") : "").concat(node.attrs.id ? " id=\"".concat(node.attrs.id, "\"") : "", ">").concat(next(node.children), "</tbody>");
return "<tbody".concat(node.attrs.style ? " style=\"".concat(node.attrs.style, "\"") : "").concat(node.attrs['class-name'] ? " class=\"".concat(node.attrs['class-name'], "\"") : "").concat(node.attrs.id ? " id=\"".concat(node.attrs.id, "\"") : "", ">").concat(next(node.children), "</tbody>");
},
_a[NodeType.TABLE_FOOTER] = function (node, next) {
return "<tfoot".concat(node.attrs.style ? " style=\"".concat(node.attrs.style, "\"") : "").concat(node.attrs.class ? " class=\"".concat(node.attrs.class, "\"") : "").concat(node.attrs.id ? " id=\"".concat(node.attrs.id, "\"") : "", ">").concat(next(node.children), "</tfoot>");
return "<tfoot".concat(node.attrs.style ? " style=\"".concat(node.attrs.style, "\"") : "").concat(node.attrs['class-name'] ? " class=\"".concat(node.attrs['class-name'], "\"") : "").concat(node.attrs.id ? " id=\"".concat(node.attrs.id, "\"") : "", ">").concat(next(node.children), "</tfoot>");
},
_a[NodeType.TABLE_ROW] = function (node, next) {
return "<tr".concat(node.attrs.style ? " style=\"".concat(node.attrs.style, "\"") : "").concat(node.attrs.class ? " class=\"".concat(node.attrs.class, "\"") : "").concat(node.attrs.id ? " id=\"".concat(node.attrs.id, "\"") : "", ">").concat(next(node.children), "</tr>");
return "<tr".concat(node.attrs.style ? " style=\"".concat(node.attrs.style, "\"") : "").concat(node.attrs['class-name'] ? " class=\"".concat(node.attrs['class-name'], "\"") : "").concat(node.attrs.id ? " id=\"".concat(node.attrs.id, "\"") : "", ">").concat(next(node.children), "</tr>");
},
_a[NodeType.TABLE_HEAD] = function (node, next) {
return "<th".concat(node.attrs.style ? " style=\"".concat(node.attrs.style, "\"") : "").concat(node.attrs.class ? " class=\"".concat(node.attrs.class, "\"") : "").concat(node.attrs.id ? " id=\"".concat(node.attrs.id, "\"") : "", ">").concat(next(node.children), "</th>");
return "<th" +
"".concat(node.attrs.rowSpan ? " rowspan=\"".concat(node.attrs.rowSpan, "\"") : "") +
"".concat(node.attrs.colSpan ? " colspan=\"".concat(node.attrs.colSpan, "\"") : "") +
"".concat(node.attrs.style ? " style=\"".concat(node.attrs.style, "\"") : "") +
"".concat(node.attrs['class-name'] ? " class=\"".concat(node.attrs['class-name'], "\"") : "") +
"".concat(node.attrs.id ? " id=\"".concat(node.attrs.id, "\"") : "", ">").concat(next(node.children)) +
"</th>";
},
_a[NodeType.TABLE_DATA] = function (node, next) {
return "<td".concat(node.attrs.style ? " style=\"".concat(node.attrs.style, "\"") : "").concat(node.attrs.class ? " class=\"".concat(node.attrs.class, "\"") : "").concat(node.attrs.id ? " id=\"".concat(node.attrs.id, "\"") : "", ">").concat(next(node.children), "</td>");
return "<td" +
"".concat(node.attrs.rowSpan ? " rowspan=\"".concat(node.attrs.rowSpan, "\"") : "") +
"".concat(node.attrs.colSpan ? " colspan=\"".concat(node.attrs.colSpan, "\"") : "") +
"".concat(node.attrs.style ? " style=\"".concat(node.attrs.style, "\"") : "") +
"".concat(node.attrs['class-name'] ? " class=\"".concat(node.attrs['class-name'], "\"") : "") +
"".concat(node.attrs.id ? " id=\"".concat(node.attrs.id, "\"") : "", ">").concat(next(node.children)) +
"</td>";
},
_a[NodeType.BLOCK_QUOTE] = function (node, next) {
return "<blockquote".concat(node.attrs.class ? " class=\"".concat(node.attrs.class, "\"") : "").concat(node.attrs.id ? " id=\"".concat(node.attrs.id, "\"") : "", ">").concat(next(node.children), "</blockquote>");
return "<blockquote".concat(node.attrs['class-name'] ? " class=\"".concat(node.attrs['class-name'], "\"") : "").concat(node.attrs.id ? " id=\"".concat(node.attrs.id, "\"") : "", ">").concat(next(node.children), "</blockquote>");
},
_a[NodeType.CODE] = function (node, next) {
return "<code".concat(node.attrs.class ? " class=\"".concat(node.attrs.class, "\"") : "").concat(node.attrs.id ? " id=\"".concat(node.attrs.id, "\"") : "", ">").concat(next(node.children), "</code>");
return "<code".concat(node.attrs['class-name'] ? " class=\"".concat(node.attrs['class-name'], "\"") : "").concat(node.attrs.id ? " id=\"".concat(node.attrs.id, "\"") : "", ">").concat(next(node.children), "</code>");
},

@@ -94,3 +106,3 @@ _a['reference'] = function (node, next) {

if (node.attrs.type === 'asset') {
return "<img".concat(node.attrs.style ? " style=\"".concat(node.attrs.style, "\"") : "").concat(node.attrs.class ? " class=\"".concat(node.attrs.class, "\"") : "").concat(node.attrs.id ? " id=\"".concat(node.attrs.id, "\"") : "", " src=\"").concat(sanitizedAsset, "\" />");
return "<img".concat(node.attrs.style ? " style=\"".concat(node.attrs.style, "\"") : "").concat(node.attrs['class-name'] ? " class=\"".concat(node.attrs['class-name'], "\"") : "").concat(node.attrs.id ? " id=\"".concat(node.attrs.id, "\"") : "", " src=\"").concat(sanitizedAsset, "\" />");
}

@@ -97,0 +109,0 @@ return "";

@@ -15,1 +15,2 @@ export { Next, Option, RenderNode, RenderMark, RenderItem, RenderContentType, RenderOption } from './options/index';

export { addTags as addEditableTags } from './entry-editable';
export { updateAssetURLForGQL } from './updateAssetURLForGQL';
{
"name": "@contentstack/utils",
"version": "1.3.4",
"version": "1.3.5",
"description": "Contentstack utilities for Javascript",

@@ -29,6 +29,4 @@ "main": "dist/index.es.js",

"format": "prettier --write \"src/**/*.ts\"",
"lint": "tslint -p tsconfig.json",
"prepare": "husky install && npm run build",
"prepublishOnly": "npm test && npm run lint",
"preversion": "npm run lint",
"prepublishOnly": "npm test",
"version": "npm run format && git add -A src",

@@ -53,3 +51,3 @@ "postversion": "git push && git push --tags"

"jest": "^29.7.0",
"jest-coverage-badges": "^1.1.2",
"jest-coverage-badges": "^1.0.0",
"jest-environment-jsdom": "^29.7.0",

@@ -56,0 +54,0 @@ "jest-html-reporters": "^2.1.7",

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