mirror of
https://github.com/cinnyapp/cinny.git
synced 2025-11-12 02:00:28 +03:00
Timeline Perf Improvement (#1521)
* emojify msg txt find&replace instead of recursion * move findAndReplace func in its own file * improve find and replace * move markdown file to plugins * make find and replace work without g flag regex * fix pagination stop on msg arrive * render blurhash in small size
This commit is contained in:
parent
3713125f57
commit
c854c7f9d2
7 changed files with 65 additions and 30 deletions
|
|
@ -3,7 +3,8 @@ import { Descendant, Text } from 'slate';
|
|||
import { sanitizeText } from '../../utils/sanitize';
|
||||
import { BlockType } from './types';
|
||||
import { CustomElement } from './slate';
|
||||
import { parseBlockMD, parseInlineMD, replaceMatch } from '../../utils/markdown';
|
||||
import { parseBlockMD, parseInlineMD } from '../../plugins/markdown';
|
||||
import { findAndReplace } from '../../utils/findAndReplace';
|
||||
|
||||
export type OutputOptions = {
|
||||
allowTextFormatting?: boolean;
|
||||
|
|
@ -69,14 +70,14 @@ const elementToCustomHtml = (node: CustomElement, children: string): string => {
|
|||
}
|
||||
};
|
||||
|
||||
const HTML_TAG_REG = /<([\w-]+)(?: [^>]*)?(?:(?:\/>)|(?:>.*?<\/\1>))/;
|
||||
const ignoreHTMLParseInlineMD = (text: string): string => {
|
||||
if (text === '') return text;
|
||||
const match = text.match(HTML_TAG_REG);
|
||||
if (!match) return parseInlineMD(text);
|
||||
const [matchedTxt] = match;
|
||||
return replaceMatch((txt) => [ignoreHTMLParseInlineMD(txt)], text, match, matchedTxt).join('');
|
||||
};
|
||||
const HTML_TAG_REG_G = /<([\w-]+)(?: [^>]*)?(?:(?:\/>)|(?:>.*?<\/\1>))/g;
|
||||
const ignoreHTMLParseInlineMD = (text: string): string =>
|
||||
findAndReplace(
|
||||
text,
|
||||
HTML_TAG_REG_G,
|
||||
(match) => match[0],
|
||||
(txt) => parseInlineMD(txt)
|
||||
).join('');
|
||||
|
||||
export const toMatrixCustomHTML = (
|
||||
node: Descendant | Descendant[],
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue