@readme/markdown 7.6.7 → 7.7.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/components/Code/index.tsx +4 -0
- package/components/Code/style.scss +6 -0
- package/components/CodeTabs/index.tsx +25 -2
- package/components/Image/style.scss +1 -4
- package/dist/10.js +22718 -0
- package/dist/10.node.js +22721 -0
- package/dist/11.js +1440 -0
- package/dist/11.node.js +1443 -0
- package/dist/120.js +19 -0
- package/dist/120.node.js +22 -0
- package/dist/134.js +19 -0
- package/dist/134.node.js +22 -0
- package/dist/150.js +1888 -0
- package/dist/150.node.js +1891 -0
- package/dist/17.js +1373 -0
- package/dist/17.node.js +1376 -0
- package/dist/246.js +1929 -0
- package/dist/246.node.js +1932 -0
- package/dist/351.js +2400 -0
- package/dist/351.node.js +2403 -0
- package/dist/366.js +1181 -0
- package/dist/366.node.js +1184 -0
- package/dist/403.js +2192 -0
- package/dist/403.node.js +2195 -0
- package/dist/429.js +11130 -0
- package/dist/429.node.js +11133 -0
- package/dist/485.js +514 -0
- package/dist/485.node.js +517 -0
- package/dist/486.js +31820 -0
- package/dist/486.node.js +31818 -0
- package/dist/488.js +55 -0
- package/dist/488.node.js +58 -0
- package/dist/489.js +18472 -0
- package/dist/489.node.js +18475 -0
- package/dist/510.js +246 -0
- package/dist/510.node.js +249 -0
- package/dist/52.js +808 -0
- package/dist/52.node.js +811 -0
- package/dist/550.node.js +1456 -0
- package/dist/551.js +2722 -0
- package/dist/551.node.js +2725 -0
- package/dist/617.js +19 -0
- package/dist/617.node.js +22 -0
- package/dist/687.js +3671 -0
- package/dist/687.node.js +3674 -0
- package/dist/745.js +7504 -0
- package/dist/745.node.js +7507 -0
- package/dist/775.js +1900 -0
- package/dist/775.node.js +1903 -0
- package/dist/786.js +31378 -0
- package/dist/786.node.js +31381 -0
- package/dist/788.js +1021 -0
- package/dist/788.node.js +1024 -0
- package/dist/81.js +382 -0
- package/dist/81.node.js +385 -0
- package/dist/849.js +2586 -0
- package/dist/849.node.js +2589 -0
- package/dist/863.js +19 -0
- package/dist/863.node.js +22 -0
- package/dist/867.js +1414 -0
- package/dist/867.node.js +1417 -0
- package/dist/871.js +1533 -0
- package/dist/881.js +1276 -0
- package/dist/881.node.js +1279 -0
- package/dist/885.js +48 -0
- package/dist/885.node.js +51 -0
- package/dist/896.js +1613 -0
- package/dist/896.node.js +1616 -0
- package/dist/906.js +1815 -0
- package/dist/906.node.js +1818 -0
- package/dist/91.js +19 -0
- package/dist/91.node.js +22 -0
- package/dist/940.js +3359 -0
- package/dist/940.node.js +3362 -0
- package/dist/952.js +243 -0
- package/dist/952.node.js +246 -0
- package/dist/995.js +5734 -0
- package/dist/995.node.js +5737 -0
- package/dist/components/Code/index.d.ts +1 -1
- package/dist/lib/ast-processor.d.ts +1 -1
- package/dist/main.css +1 -1
- package/dist/main.js +453 -11212
- package/dist/main.node.js +387 -11250
- package/dist/processor/transform/index.d.ts +2 -1
- package/dist/processor/transform/mermaid.d.ts +3 -0
- package/package.json +6 -3
|
@@ -57,6 +57,10 @@ const Code = (props: CodeProps) => {
|
|
|
57
57
|
const code = value ?? (Array.isArray(children) ? children[0] : children) ?? '';
|
|
58
58
|
const highlightedCode = syntaxHighlighter && code ? syntaxHighlighter(code, language, codeOpts, { mdx: true }) : code;
|
|
59
59
|
|
|
60
|
+
if (language === 'mermaid') {
|
|
61
|
+
return code;
|
|
62
|
+
}
|
|
63
|
+
|
|
60
64
|
return (
|
|
61
65
|
<>
|
|
62
66
|
{copyButtons && <CopyCode className="fa" codeRef={codeRef} />}
|
|
@@ -1,9 +1,26 @@
|
|
|
1
|
+
import type { Mermaid } from 'mermaid';
|
|
2
|
+
|
|
1
3
|
import { uppercase } from '@readme/syntax-highlighter';
|
|
2
|
-
import React from 'react';
|
|
4
|
+
import React, { useEffect } from 'react';
|
|
5
|
+
|
|
6
|
+
let mermaid: Mermaid;
|
|
7
|
+
|
|
8
|
+
if (typeof window !== 'undefined') {
|
|
9
|
+
import('mermaid').then(module => {
|
|
10
|
+
mermaid = module.default;
|
|
11
|
+
});
|
|
12
|
+
}
|
|
3
13
|
|
|
4
14
|
const CodeTabs = props => {
|
|
5
15
|
const { children, theme } = props;
|
|
6
16
|
|
|
17
|
+
// set Mermaid theme
|
|
18
|
+
useEffect(() => {
|
|
19
|
+
mermaid?.initialize({
|
|
20
|
+
theme: theme === 'dark' ? 'dark' : 'default',
|
|
21
|
+
});
|
|
22
|
+
}, [theme]);
|
|
23
|
+
|
|
7
24
|
function handleClick({ target }, index: number) {
|
|
8
25
|
const $wrap = target.parentElement.parentElement;
|
|
9
26
|
const $open = [].slice.call($wrap.querySelectorAll('.CodeTabs_active'));
|
|
@@ -16,6 +33,12 @@ const CodeTabs = props => {
|
|
|
16
33
|
target.classList.add('CodeTabs_active');
|
|
17
34
|
}
|
|
18
35
|
|
|
36
|
+
// render single Mermaid diagram
|
|
37
|
+
if (!Array.isArray(children) && children.props?.children.props.lang === 'mermaid') {
|
|
38
|
+
const value = children.props.children.props.value;
|
|
39
|
+
return <pre className="mermaid mermaid_single">{value}</pre>;
|
|
40
|
+
}
|
|
41
|
+
|
|
19
42
|
return (
|
|
20
43
|
<div className={`CodeTabs CodeTabs_initial theme-${theme}`}>
|
|
21
44
|
<div className="CodeTabs-toolbar">
|
|
@@ -24,7 +47,7 @@ const CodeTabs = props => {
|
|
|
24
47
|
|
|
25
48
|
/* istanbul ignore next */
|
|
26
49
|
return (
|
|
27
|
-
<button key={i} onClick={e => handleClick(e, i)} type="button">
|
|
50
|
+
<button key={i} onClick={e => handleClick(e, i)} type="button" value={lang}>
|
|
28
51
|
{meta || `${!lang ? 'Text' : uppercase(lang)}`}
|
|
29
52
|
</button>
|
|
30
53
|
);
|
|
@@ -103,16 +103,13 @@
|
|
|
103
103
|
content: '\f00d';
|
|
104
104
|
cursor: pointer;
|
|
105
105
|
display: inline-block;
|
|
106
|
-
font:
|
|
106
|
+
font-family: var(--fa-style-family, 'Font Awesome 6 Pro');
|
|
107
107
|
font-size: inherit;
|
|
108
|
-
-webkit-font-smoothing: antialiased;
|
|
109
|
-
-moz-osx-font-smoothing: grayscale;
|
|
110
108
|
opacity: 1;
|
|
111
109
|
position: fixed;
|
|
112
110
|
right: 1em;
|
|
113
111
|
text-rendering: auto;
|
|
114
112
|
top: 1em;
|
|
115
|
-
transform: translate(0, 0);
|
|
116
113
|
transform: scale(1.5);
|
|
117
114
|
transition: 0.3s 0.3s ease-in;
|
|
118
115
|
}
|