From d9097ccd40f88f5645f1535714ba912b59183032 Mon Sep 17 00:00:00 2001 From: 7w1 Date: Sun, 28 Jun 2026 17:15:31 -0500 Subject: [PATCH] potential fix --- src/app/components/editor/output.ts | 18 ++++++++---------- 1 file changed, 8 insertions(+), 10 deletions(-) diff --git a/src/app/components/editor/output.ts b/src/app/components/editor/output.ts index d8be87e30..6c3665925 100644 --- a/src/app/components/editor/output.ts +++ b/src/app/components/editor/output.ts @@ -74,11 +74,11 @@ const elementToCustomHtml = ( return sanitizeText(matrixTo); } case BlockType.Emoticon: - return node.key.startsWith('mxc://') + return node.key?.startsWith('mxc://') ? `${sanitizeText(
             node.shortcode
           )}` - : sanitizeText(node.key); + : sanitizeText(node.key ?? ''); case BlockType.Link: return testMatrixTo(node.href) ? sanitizeText(node.href) @@ -111,10 +111,9 @@ export const toMatrixCustomHTML = ( // strip nicknames if needed if (opts.stripNickname && opts.nickNameReplacement) { - opts.nickNameReplacement?.keys().forEach((key) => { - const replacement = opts.nickNameReplacement!.get(key) ?? ''; + for (const [key, replacement] of opts.nickNameReplacement) { line = line.replaceAll(key, replacement); - }); + } } markdownLines += line; if (index === targetNodes.length - 1) { @@ -145,7 +144,7 @@ const elementToPlainText = (node: CustomElement, children: string): string => { case BlockType.Mention: return node.name === '@room' ? node.name : node.id; case BlockType.Emoticon: - return node.key.startsWith('mxc://') ? `:${node.shortcode}:` : node.key; + return node.key?.startsWith('mxc://') ? `:${node.shortcode}:` : (node.key ?? ''); case BlockType.Link: return `[${children}](${node.href})`; case BlockType.Command: @@ -182,10 +181,9 @@ export const toPlainText = ( text = text.replaceAll(SPOILEREDLINKINPUTREGEX, '$1'); if (stripNickname && nickNameReplacement) { - nickNameReplacement?.keys().forEach((key) => { - const replacement = nickNameReplacement.get(key) ?? ''; + for (const [key, replacement] of nickNameReplacement) { text = text.replaceAll(key, replacement); - }); + } } return text; } @@ -211,7 +209,7 @@ export const toRawText = (node: Descendant | Descendant[]): string => { case BlockType.Link: return `[${children}](${node.href})`; case BlockType.Emoticon: - return node.key.startsWith('mxc://') ? `:${node.shortcode}:` : node.key; + return node.key?.startsWith('mxc://') ? `:${node.shortcode}:` : (node.key ?? ''); case BlockType.Mention: return node.name === '@room' ? node.name : node.id; case BlockType.Command: