Merge remote-tracking branch 'origin/dev' into hazre/refactor/tsconfig-tooling-cleanup

This commit is contained in:
hazre committed 2026-04-24 18:19:50 +02:00
commit d682fdd7c9
2 files changed
+12 -4

No files matched your search

+5
View File
@@ -0,0 +1,5 @@
---
default: patch
---
spoilered text now gets replaced with `[Spoiler]` in the plain text fallback, as per MSC4454
+7 -4
View File
@@ -198,6 +198,8 @@ const elementToPlainText = (node: CustomElement, children: string): string => {
}
};
const SPOILERINPUTREGEX = /\|\|.+?\|\|/g;
/**
* convert slate internal representation to a plain text string that can be sent to the server
* @param node the slate node
@@ -215,9 +217,10 @@ export const toPlainText = (
if (Array.isArray(node))
return node.map((n) => toPlainText(n, isMarkdown, stripNickname, nickNameReplacement)).join('');
if (Text.isText(node)) {
let { text } = node;
text = text.replaceAll(SPOILERINPUTREGEX, '[Spoiler]');
if (stripNickname && nickNameReplacement) {
let { text } = node;
[...nickNameReplacement.keys()].forEach((key) => {
nickNameReplacement?.keys().forEach((key) => {
const replacement = nickNameReplacement.get(key) ?? '';
text = text.replaceAll(key, replacement);
});
@@ -226,8 +229,8 @@ export const toPlainText = (
: text;
}
return isMarkdown
? unescapeMarkdownBlockSequences(node.text, unescapeMarkdownInlineSequences)
: node.text;
? unescapeMarkdownBlockSequences(text, unescapeMarkdownInlineSequences)
: text;
}
const children = node.children.map((n) => toPlainText(n, isMarkdown)).join('');