Skip to content

Commit

Permalink
fix: undefined mappings in csm
Browse files Browse the repository at this point in the history
  • Loading branch information
YvesRijckaert committed Dec 10, 2024
1 parent d47d498 commit 6b78bc9
Showing 1 changed file with 11 additions and 8 deletions.
19 changes: 11 additions & 8 deletions packages/content-source-maps/src/richText.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,15 +15,18 @@ export const encodeRichTextValue = ({
hiddenStrings: SourceMapMetadata;
}) => {
const source = mappings[pointer];
// remove old pointer to rich text field as we will just be mapping the text nodes
delete mappings[pointer];

const textNodes = findRichTextNodes(data, pointer);
for (const textNode of textNodes) {
mappings[textNode] = source;
const currentTextNodeValue = get(data, textNode);
const encodedValue = combine(currentTextNodeValue, hiddenStrings);
set(data, textNode, encodedValue);
if (source) {
// remove old pointer to rich text field as we will just be mapping the text nodes
delete mappings[pointer];

const textNodes = findRichTextNodes(data, pointer);
for (const textNode of textNodes) {
mappings[textNode] = source;
const currentTextNodeValue = get(data, textNode);
const encodedValue = combine(currentTextNodeValue, hiddenStrings);
set(data, textNode, encodedValue);
}
}
};

Expand Down

0 comments on commit 6b78bc9

Please sign in to comment.