@uiw/react-md-editor 3.25.6 → 4.0.1
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/README.md +32 -24
- package/dist/mdeditor.css +1 -1
- package/dist/mdeditor.js +33885 -32579
- package/dist/mdeditor.min.css +1 -1
- package/dist/mdeditor.min.js +1 -1
- package/dist/mdeditor.min.js.LICENSE.txt +0 -17
- package/esm/components/TextArea/Markdown.js +4 -1
- package/esm/components/TextArea/index.js +2 -2
- package/esm/components/TextArea/index.nohighlight.js +2 -2
- package/esm/components/Toolbar/index.css +1 -1
- package/esm/components/Toolbar/index.less +1 -1
- package/lib/components/TextArea/Markdown.js +4 -1
- package/lib/components/TextArea/index.js +2 -2
- package/lib/components/TextArea/index.nohighlight.js +2 -2
- package/lib/components/Toolbar/index.less +1 -1
- package/markdown-editor.css +1 -1
- package/package.json +4 -3
- package/src/components/TextArea/Markdown.tsx +2 -0
- package/src/components/Toolbar/index.less +1 -1
package/README.md
CHANGED
|
@@ -6,6 +6,9 @@
|
|
|
6
6
|
</p>
|
|
7
7
|
|
|
8
8
|
<p align="center">
|
|
9
|
+
<a href="https://jaywcjlove.github.io/#/sponsor" target="__blank">
|
|
10
|
+
<img alt="Buy me a coffee" src="https://img.shields.io/badge/Buy%20me%20a%20coffee-048754?logo=buymeacoffee">
|
|
11
|
+
</a>
|
|
9
12
|
<a href="https://www.npmjs.com/package/@uiw/react-md-editor" target="__blank">
|
|
10
13
|
<img alt="Downloads" src="https://img.shields.io/npm/dm/@uiw/react-md-editor.svg?style=flat">
|
|
11
14
|
</a>
|
|
@@ -594,18 +597,14 @@ export default function App() {
|
|
|
594
597
|
onChange={(val) => setValue(val)}
|
|
595
598
|
previewOptions={{
|
|
596
599
|
components: {
|
|
597
|
-
code: ({
|
|
598
|
-
|
|
599
|
-
|
|
600
|
-
|
|
601
|
-
|
|
602
|
-
|
|
603
|
-
});
|
|
604
|
-
return <code dangerouslySetInnerHTML={{ __html: html }} />;
|
|
605
|
-
}
|
|
606
|
-
return <code>{txt}</code>;
|
|
600
|
+
code: ({ children = [], className, ...props }) => {
|
|
601
|
+
if (typeof children === 'string' && /^\$\$(.*)\$\$/.test(children)) {
|
|
602
|
+
const html = katex.renderToString(children.replace(/^\$\$(.*)\$\$/, '$1'), {
|
|
603
|
+
throwOnError: false,
|
|
604
|
+
});
|
|
605
|
+
return <code dangerouslySetInnerHTML={{ __html: html }} style={{ background: 'transparent' }} />;
|
|
607
606
|
}
|
|
608
|
-
const code = props.node && props.node.children ? getCodeString(props.node.children) :
|
|
607
|
+
const code = props.node && props.node.children ? getCodeString(props.node.children) : children;
|
|
609
608
|
if (
|
|
610
609
|
typeof code === 'string' &&
|
|
611
610
|
typeof className === 'string' &&
|
|
@@ -718,16 +717,25 @@ const randomid = () => parseInt(String(Math.random() * 1e15), 10).toString(36);
|
|
|
718
717
|
const Code = ({ inline, children = [], className, ...props }) => {
|
|
719
718
|
const demoid = useRef(`dome${randomid()}`);
|
|
720
719
|
const [container, setContainer] = useState(null);
|
|
721
|
-
const isMermaid =
|
|
722
|
-
|
|
720
|
+
const isMermaid =
|
|
721
|
+
className && /^language-mermaid/.test(className.toLocaleLowerCase());
|
|
722
|
+
const code = children
|
|
723
|
+
? getCodeString(props.node.children)
|
|
724
|
+
: children[0] || "";
|
|
725
|
+
|
|
723
726
|
useEffect(() => {
|
|
724
|
-
if (container && isMermaid) {
|
|
725
|
-
|
|
726
|
-
|
|
727
|
-
|
|
728
|
-
|
|
729
|
-
|
|
730
|
-
|
|
727
|
+
if (container && isMermaid && demoid.current && code) {
|
|
728
|
+
mermaid
|
|
729
|
+
.render(demoid.current, code)
|
|
730
|
+
.then(({ svg, bindFunctions }) => {
|
|
731
|
+
container.innerHTML = svg;
|
|
732
|
+
if (bindFunctions) {
|
|
733
|
+
bindFunctions(container);
|
|
734
|
+
}
|
|
735
|
+
})
|
|
736
|
+
.catch((error) => {
|
|
737
|
+
console.log("error:", error);
|
|
738
|
+
});
|
|
731
739
|
}
|
|
732
740
|
}, [container, isMermaid, code, demoid]);
|
|
733
741
|
|
|
@@ -741,11 +749,11 @@ const Code = ({ inline, children = [], className, ...props }) => {
|
|
|
741
749
|
return (
|
|
742
750
|
<Fragment>
|
|
743
751
|
<code id={demoid.current} style={{ display: "none" }} />
|
|
744
|
-
<code ref={refElement} data-name="mermaid" />
|
|
752
|
+
<code className={className} ref={refElement} data-name="mermaid" />
|
|
745
753
|
</Fragment>
|
|
746
754
|
);
|
|
747
755
|
}
|
|
748
|
-
return <code>{children}</code>;
|
|
756
|
+
return <code className={className}>{children}</code>;
|
|
749
757
|
};
|
|
750
758
|
|
|
751
759
|
export default function App() {
|
|
@@ -935,8 +943,8 @@ As always, thanks to our amazing contributors!
|
|
|
935
943
|
<a href="https://github.com/MercierCorentin" title="Corentin Mercier">
|
|
936
944
|
<img src="https://avatars.githubusercontent.com/u/46066895?v=4" width="42;" alt="Corentin Mercier"/>
|
|
937
945
|
</a>
|
|
938
|
-
<a href="https://github.com/dmitriyyan" title="
|
|
939
|
-
<img src="https://avatars.githubusercontent.com/u/89025862?v=4" width="42;" alt="
|
|
946
|
+
<a href="https://github.com/dmitriyyan" title="Dmitrii Ianushkevich">
|
|
947
|
+
<img src="https://avatars.githubusercontent.com/u/89025862?v=4" width="42;" alt="Dmitrii Ianushkevich"/>
|
|
940
948
|
</a>
|
|
941
949
|
<a href="https://github.com/jnishiyama" title="James Finucane">
|
|
942
950
|
<img src="https://avatars.githubusercontent.com/u/2048195?v=4" width="42;" alt="James Finucane"/>
|
package/dist/mdeditor.css
CHANGED
|
@@ -1183,7 +1183,7 @@ body[data-color-mode*='light'] {
|
|
|
1183
1183
|
.w-md-editor-toolbar {
|
|
1184
1184
|
border-bottom: 1px solid var(--md-editor-box-shadow-color);
|
|
1185
1185
|
background-color: var(--md-editor-background-color);
|
|
1186
|
-
padding:
|
|
1186
|
+
padding: 3px;
|
|
1187
1187
|
display: flex;
|
|
1188
1188
|
justify-content: space-between;
|
|
1189
1189
|
align-items: center;
|