mirror of
https://github.com/SableClient/Sable.git
synced 2026-11-28 04:46:28 -08:00
Merge remote-tracking branch 'origin/dev' into hazre/refactor/tsconfig-tooling-cleanup
This commit is contained in:
2 files changed
+12
-4
No files matched your search
@@ -0,0 +1,5 @@
|
||||
---
|
||||
default: patch
|
||||
---
|
||||
|
||||
spoilered text now gets replaced with `[Spoiler]` in the plain text fallback, as per MSC4454
|
||||
@@ -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('');
|
||||
|
||||
Reference in new issue
Block a user