@uiw/react-md-editor 3.19.5 → 3.19.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/mdeditor.js +87 -653
- package/dist/mdeditor.min.js +1 -1
- package/esm/commands/bold.js +2 -1
- package/esm/commands/bold.js.map +2 -2
- package/esm/commands/index.js +2 -1
- package/esm/commands/index.js.map +2 -2
- package/esm/commands/preview.js +3 -0
- package/esm/commands/preview.js.map +4 -2
- package/esm/components/TextArea/Markdown.js +25 -25
- package/esm/components/TextArea/Markdown.js.map +4 -3
- package/lib/commands/bold.js +2 -1
- package/lib/commands/bold.js.map +2 -2
- package/lib/commands/index.js +2 -1
- package/lib/commands/index.js.map +2 -2
- package/lib/commands/preview.js +3 -0
- package/lib/commands/preview.js.map +4 -2
- package/lib/components/TextArea/Markdown.js +24 -24
- package/lib/components/TextArea/Markdown.js.map +4 -3
- package/package.json +1 -1
- package/src/commands/bold.tsx +1 -1
- package/src/commands/index.ts +1 -1
- package/src/commands/preview.tsx +3 -0
- package/src/components/TextArea/Markdown.tsx +20 -23
|
@@ -6,7 +6,7 @@ import { EditorContext } from '../../Context';
|
|
|
6
6
|
|
|
7
7
|
function html2Escape(sHtml: string) {
|
|
8
8
|
return sHtml
|
|
9
|
-
.replace(/```(
|
|
9
|
+
.replace(/```(\w+)?([\s\S]*?)(\s.+)?```/g, (str: string) => {
|
|
10
10
|
return str.replace(
|
|
11
11
|
/[<&"]/g,
|
|
12
12
|
(c: string) => (({ '<': '<', '>': '>', '&': '&', '"': '"' } as Record<string, string>)[c]),
|
|
@@ -30,28 +30,25 @@ export default function Markdown(props: MarkdownProps) {
|
|
|
30
30
|
}
|
|
31
31
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
32
32
|
}, []);
|
|
33
|
+
if (!markdown) {
|
|
34
|
+
return <pre ref={preRef} className={`${prefixCls}-text-pre wmde-markdown-color`} />;
|
|
35
|
+
}
|
|
36
|
+
let mdStr = `<pre class="language-markdown ${prefixCls}-text-pre wmde-markdown-color"><code class="language-markdown">${html2Escape(
|
|
37
|
+
String.raw`${markdown}`,
|
|
38
|
+
)}\n</code></pre>`;
|
|
33
39
|
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
try {
|
|
44
|
-
mdStr = rehype()
|
|
45
|
-
.data('settings', { fragment: true })
|
|
46
|
-
.use(rehypePrism, { ignoreMissing: true })
|
|
47
|
-
.processSync(mdStr)
|
|
48
|
-
.toString();
|
|
49
|
-
} catch (error) {}
|
|
50
|
-
}
|
|
40
|
+
if (highlightEnable) {
|
|
41
|
+
try {
|
|
42
|
+
mdStr = rehype()
|
|
43
|
+
.data('settings', { fragment: true })
|
|
44
|
+
.use(rehypePrism, { ignoreMissing: true })
|
|
45
|
+
.processSync(mdStr)
|
|
46
|
+
.toString();
|
|
47
|
+
} catch (error) {}
|
|
48
|
+
}
|
|
51
49
|
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
}, [markdown, preRef, prefixCls]);
|
|
50
|
+
return React.createElement('div', {
|
|
51
|
+
className: 'wmde-markdown-color',
|
|
52
|
+
dangerouslySetInnerHTML: { __html: mdStr || '' },
|
|
53
|
+
});
|
|
57
54
|
}
|