Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

## [1.3.20](https://github.com/contentstack/contentstack-utils-javascript/tree/v1.3.20) (2025-02-24)
- Fix: Added data-mtec as allowed attribute
- Fix: customRenderOption for entry-embedded-as-link nodes

## [1.3.19](https://github.com/contentstack/contentstack-utils-javascript/tree/v1.3.19) (2025-02-24)
- Fix: Added fix for html injection in keys and values of attributes
Expand Down
12 changes: 8 additions & 4 deletions src/helper/enumerate-entries.ts
Original file line number Diff line number Diff line change
Expand Up @@ -77,8 +77,16 @@ export function referenceToHTML(
renderOption: RenderOption,
renderEmbed?: (metadata: Metadata) => EmbeddedItem | EntryNode,
): string {

function sendToRenderOption(referenceNode: Node): string {
return (renderOption[referenceNode.type] as RenderNode)(referenceNode, undefined);
}

if ((node.attrs.type === 'entry' || node.attrs.type === 'asset') && node.attrs['display-type'] === 'link') {
const entryText = node.children ? nodeChildrenToHTML(node.children, renderOption, renderEmbed) : '';
if (renderOption[node.type] !== undefined) {
return sendToRenderOption(node);
}

let aTagAttrs = `${node.attrs.style ? ` style="${node.attrs.style}"` : ``}${node.attrs['class-name'] ? ` class="${node.attrs['class-name']}"` : ``}${node.attrs.id ? ` id="${node.attrs.id}"` : ``} href="${node.attrs.href || node.attrs.url}"`;
if (node.attrs.target) {
Expand All @@ -90,10 +98,6 @@ export function referenceToHTML(
const aTag = `<a${aTagAttrs}>${entryText}</a>`;
return aTag;
}

function sendToRenderOption(referenceNode: Node): string {
return (renderOption[referenceNode.type] as RenderNode)(referenceNode, undefined);
}

if (!renderEmbed && renderOption[node.type] !== undefined) {
return sendToRenderOption(node);
Expand Down
Loading