@readme/markdown 13.7.2 → 13.7.3
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/CodeTabs/index.tsx +62 -19
- package/components/TailwindStyle/index.tsx +4 -3
- package/dist/main.js +81 -26
- package/dist/main.node.js +81 -26
- package/dist/main.node.js.map +1 -1
- package/package.json +1 -1
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { Mermaid } from 'mermaid';
|
|
2
2
|
|
|
3
3
|
import syntaxHighlighterUtils from '@readme/syntax-highlighter/utils';
|
|
4
|
-
import React, { useContext, useEffect } from 'react';
|
|
4
|
+
import React, { useContext, useEffect, useRef } from 'react';
|
|
5
5
|
|
|
6
6
|
import ThemeContext from '../../contexts/Theme';
|
|
7
7
|
import useHydrated from '../../hooks/useHydrated';
|
|
@@ -10,6 +10,47 @@ let mermaid: Mermaid;
|
|
|
10
10
|
|
|
11
11
|
const { uppercase } = syntaxHighlighterUtils;
|
|
12
12
|
|
|
13
|
+
// Module-level queue that batches mermaid nodes across all CodeTabs instances into a
|
|
14
|
+
// single mermaid.run() call. This is necessary because mermaid generates SVG element IDs
|
|
15
|
+
// using Date.now(), which collides when multiple diagrams render in the same millisecond.
|
|
16
|
+
// Colliding IDs cause diagrams to overlap or break layout.
|
|
17
|
+
//
|
|
18
|
+
// Why not use `deterministicIDSeed` with a unique ID per diagram? Mermaid's implementation
|
|
19
|
+
// only uses seed.length (not the seed value) to compute the starting ID, so every UUID
|
|
20
|
+
// (36 chars) produces the same `mermaid-36` prefix — the collision remains.
|
|
21
|
+
// See: https://github.com/mermaid-js/mermaid/blob/mermaid%4011.12.0/packages/mermaid/src/utils.ts#L755-L761
|
|
22
|
+
//
|
|
23
|
+
// These vars must be module-scoped (not per-instance refs) because the batching requires
|
|
24
|
+
// cross-instance coordination. They are short-lived: the queue drains on the next macrotask
|
|
25
|
+
// and cleanup clears everything on unmount.
|
|
26
|
+
let mermaidQueue: HTMLPreElement[] = [];
|
|
27
|
+
let mermaidFlushTimer: ReturnType<typeof setTimeout> | null = null;
|
|
28
|
+
let currentTheme: string | undefined;
|
|
29
|
+
|
|
30
|
+
function queueMermaidNode(node: HTMLPreElement, theme: string) {
|
|
31
|
+
mermaidQueue.push(node);
|
|
32
|
+
currentTheme = theme;
|
|
33
|
+
|
|
34
|
+
if (!mermaidFlushTimer) {
|
|
35
|
+
// setTimeout(0) defers to a macrotask, after all useEffects have queued their nodes
|
|
36
|
+
mermaidFlushTimer = setTimeout(async () => {
|
|
37
|
+
const nodes = [...mermaidQueue];
|
|
38
|
+
mermaidQueue = [];
|
|
39
|
+
mermaidFlushTimer = null;
|
|
40
|
+
|
|
41
|
+
const module = await import('mermaid');
|
|
42
|
+
mermaid = module.default;
|
|
43
|
+
mermaid.initialize({
|
|
44
|
+
startOnLoad: false,
|
|
45
|
+
theme: currentTheme === 'dark' ? 'dark' : 'default',
|
|
46
|
+
deterministicIds: true,
|
|
47
|
+
});
|
|
48
|
+
|
|
49
|
+
await mermaid.run({ nodes });
|
|
50
|
+
}, 0);
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
|
|
13
54
|
interface Props {
|
|
14
55
|
children: JSX.Element | JSX.Element[];
|
|
15
56
|
}
|
|
@@ -18,6 +59,7 @@ const CodeTabs = (props: Props) => {
|
|
|
18
59
|
const { children } = props;
|
|
19
60
|
const theme = useContext(ThemeContext);
|
|
20
61
|
const isHydrated = useHydrated();
|
|
62
|
+
const mermaidRef = useRef<HTMLPreElement>(null);
|
|
21
63
|
|
|
22
64
|
// Handle both array (from rehype-react in rendering mdxish) and single element (MDX/JSX runtime) cases
|
|
23
65
|
// The children here is the individual code block objects
|
|
@@ -32,22 +74,21 @@ const CodeTabs = (props: Props) => {
|
|
|
32
74
|
|
|
33
75
|
const containAtLeastOneMermaid = childrenArray.some(pre => getCodeComponent(pre)?.props?.lang === 'mermaid');
|
|
34
76
|
|
|
35
|
-
// Render Mermaid diagram
|
|
36
77
|
useEffect(() => {
|
|
37
|
-
//
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
import('mermaid').then(module => {
|
|
41
|
-
mermaid = module.default;
|
|
42
|
-
mermaid.initialize({
|
|
43
|
-
startOnLoad: false,
|
|
44
|
-
theme: theme === 'dark' ? 'dark' : 'default',
|
|
45
|
-
});
|
|
46
|
-
mermaid.run({
|
|
47
|
-
nodes: document.querySelectorAll('.mermaid-render'),
|
|
48
|
-
});
|
|
49
|
-
});
|
|
78
|
+
// Wait for hydration so mermaid's DOM mutations don't cause mismatches
|
|
79
|
+
if (typeof window !== 'undefined' && containAtLeastOneMermaid && isHydrated && mermaidRef.current) {
|
|
80
|
+
queueMermaidNode(mermaidRef.current, theme);
|
|
50
81
|
}
|
|
82
|
+
|
|
83
|
+
return () => {
|
|
84
|
+
// Clear the batch timer on unmount to prevent mermaid from running
|
|
85
|
+
// after the DOM is torn down
|
|
86
|
+
if (mermaidFlushTimer) {
|
|
87
|
+
clearTimeout(mermaidFlushTimer);
|
|
88
|
+
mermaidFlushTimer = null;
|
|
89
|
+
mermaidQueue = [];
|
|
90
|
+
}
|
|
91
|
+
};
|
|
51
92
|
}, [containAtLeastOneMermaid, theme, isHydrated]);
|
|
52
93
|
|
|
53
94
|
function handleClick({ target }, index: number) {
|
|
@@ -67,7 +108,11 @@ const CodeTabs = (props: Props) => {
|
|
|
67
108
|
const codeComponent = getCodeComponent(childrenArray[0]);
|
|
68
109
|
if (codeComponent?.props?.lang === 'mermaid') {
|
|
69
110
|
const value = codeComponent?.props?.value;
|
|
70
|
-
return
|
|
111
|
+
return (
|
|
112
|
+
<pre ref={mermaidRef} className="mermaid-render mermaid_single">
|
|
113
|
+
{value}
|
|
114
|
+
</pre>
|
|
115
|
+
);
|
|
71
116
|
}
|
|
72
117
|
}
|
|
73
118
|
|
|
@@ -76,9 +121,7 @@ const CodeTabs = (props: Props) => {
|
|
|
76
121
|
<div className="CodeTabs-toolbar">
|
|
77
122
|
{childrenArray.map((pre, i) => {
|
|
78
123
|
// the first or only child should be our Code component
|
|
79
|
-
const tabCodeComponent = Array.isArray(pre.props?.children)
|
|
80
|
-
? pre.props.children[0]
|
|
81
|
-
: pre.props?.children;
|
|
124
|
+
const tabCodeComponent = Array.isArray(pre.props?.children) ? pre.props.children[0] : pre.props?.children;
|
|
82
125
|
const lang = tabCodeComponent?.props?.lang;
|
|
83
126
|
const meta = tabCodeComponent?.props?.meta;
|
|
84
127
|
|
|
@@ -97,10 +97,11 @@ const TailwindStyle = ({ children, darkModeDataAttribute }: Props) => {
|
|
|
97
97
|
shouldUpdate = true;
|
|
98
98
|
}
|
|
99
99
|
|
|
100
|
-
if (shouldUpdate) {
|
|
101
|
-
setClasses(Array.from(classesSet.current));
|
|
102
|
-
}
|
|
103
100
|
});
|
|
101
|
+
|
|
102
|
+
if (shouldUpdate) {
|
|
103
|
+
setClasses(Array.from(classesSet.current));
|
|
104
|
+
}
|
|
104
105
|
});
|
|
105
106
|
|
|
106
107
|
observer.observe(ref.current.parentElement, {
|
package/dist/main.js
CHANGED
|
@@ -11704,10 +11704,47 @@ var dist_utils_default = /*#__PURE__*/__webpack_require__.n(dist_utils);
|
|
|
11704
11704
|
|
|
11705
11705
|
let mermaid;
|
|
11706
11706
|
const { uppercase } = (dist_utils_default());
|
|
11707
|
+
// Module-level queue that batches mermaid nodes across all CodeTabs instances into a
|
|
11708
|
+
// single mermaid.run() call. This is necessary because mermaid generates SVG element IDs
|
|
11709
|
+
// using Date.now(), which collides when multiple diagrams render in the same millisecond.
|
|
11710
|
+
// Colliding IDs cause diagrams to overlap or break layout.
|
|
11711
|
+
//
|
|
11712
|
+
// Why not use `deterministicIDSeed` with a unique ID per diagram? Mermaid's implementation
|
|
11713
|
+
// only uses seed.length (not the seed value) to compute the starting ID, so every UUID
|
|
11714
|
+
// (36 chars) produces the same `mermaid-36` prefix — the collision remains.
|
|
11715
|
+
// See: https://github.com/mermaid-js/mermaid/blob/mermaid%4011.12.0/packages/mermaid/src/utils.ts#L755-L761
|
|
11716
|
+
//
|
|
11717
|
+
// These vars must be module-scoped (not per-instance refs) because the batching requires
|
|
11718
|
+
// cross-instance coordination. They are short-lived: the queue drains on the next macrotask
|
|
11719
|
+
// and cleanup clears everything on unmount.
|
|
11720
|
+
let mermaidQueue = [];
|
|
11721
|
+
let mermaidFlushTimer = null;
|
|
11722
|
+
let currentTheme;
|
|
11723
|
+
function queueMermaidNode(node, theme) {
|
|
11724
|
+
mermaidQueue.push(node);
|
|
11725
|
+
currentTheme = theme;
|
|
11726
|
+
if (!mermaidFlushTimer) {
|
|
11727
|
+
// setTimeout(0) defers to a macrotask, after all useEffects have queued their nodes
|
|
11728
|
+
mermaidFlushTimer = setTimeout(async () => {
|
|
11729
|
+
const nodes = [...mermaidQueue];
|
|
11730
|
+
mermaidQueue = [];
|
|
11731
|
+
mermaidFlushTimer = null;
|
|
11732
|
+
const module = await Promise.resolve(/* import() */).then(__webpack_require__.t.bind(__webpack_require__, 1387, 23));
|
|
11733
|
+
mermaid = module.default;
|
|
11734
|
+
mermaid.initialize({
|
|
11735
|
+
startOnLoad: false,
|
|
11736
|
+
theme: currentTheme === 'dark' ? 'dark' : 'default',
|
|
11737
|
+
deterministicIds: true,
|
|
11738
|
+
});
|
|
11739
|
+
await mermaid.run({ nodes });
|
|
11740
|
+
}, 0);
|
|
11741
|
+
}
|
|
11742
|
+
}
|
|
11707
11743
|
const CodeTabs = (props) => {
|
|
11708
11744
|
const { children } = props;
|
|
11709
11745
|
const theme = (0,external_amd_react_commonjs_react_commonjs2_react_root_React_umd_react_.useContext)(Theme);
|
|
11710
11746
|
const isHydrated = useHydrated();
|
|
11747
|
+
const mermaidRef = (0,external_amd_react_commonjs_react_commonjs2_react_root_React_umd_react_.useRef)(null);
|
|
11711
11748
|
// Handle both array (from rehype-react in rendering mdxish) and single element (MDX/JSX runtime) cases
|
|
11712
11749
|
// The children here is the individual code block objects
|
|
11713
11750
|
const childrenArray = Array.isArray(children) ? children : [children];
|
|
@@ -11718,22 +11755,20 @@ const CodeTabs = (props) => {
|
|
|
11718
11755
|
return Array.isArray(pre?.props?.children) ? pre.props.children[0] : pre?.props?.children;
|
|
11719
11756
|
};
|
|
11720
11757
|
const containAtLeastOneMermaid = childrenArray.some(pre => getCodeComponent(pre)?.props?.lang === 'mermaid');
|
|
11721
|
-
// Render Mermaid diagram
|
|
11722
11758
|
(0,external_amd_react_commonjs_react_commonjs2_react_root_React_umd_react_.useEffect)(() => {
|
|
11723
|
-
//
|
|
11724
|
-
|
|
11725
|
-
|
|
11726
|
-
|
|
11727
|
-
|
|
11728
|
-
|
|
11729
|
-
|
|
11730
|
-
|
|
11731
|
-
|
|
11732
|
-
|
|
11733
|
-
|
|
11734
|
-
|
|
11735
|
-
|
|
11736
|
-
}
|
|
11759
|
+
// Wait for hydration so mermaid's DOM mutations don't cause mismatches
|
|
11760
|
+
if (typeof window !== 'undefined' && containAtLeastOneMermaid && isHydrated && mermaidRef.current) {
|
|
11761
|
+
queueMermaidNode(mermaidRef.current, theme);
|
|
11762
|
+
}
|
|
11763
|
+
return () => {
|
|
11764
|
+
// Clear the batch timer on unmount to prevent mermaid from running
|
|
11765
|
+
// after the DOM is torn down
|
|
11766
|
+
if (mermaidFlushTimer) {
|
|
11767
|
+
clearTimeout(mermaidFlushTimer);
|
|
11768
|
+
mermaidFlushTimer = null;
|
|
11769
|
+
mermaidQueue = [];
|
|
11770
|
+
}
|
|
11771
|
+
};
|
|
11737
11772
|
}, [containAtLeastOneMermaid, theme, isHydrated]);
|
|
11738
11773
|
function handleClick({ target }, index) {
|
|
11739
11774
|
const $wrap = target.parentElement.parentElement;
|
|
@@ -11749,15 +11784,13 @@ const CodeTabs = (props) => {
|
|
|
11749
11784
|
const codeComponent = getCodeComponent(childrenArray[0]);
|
|
11750
11785
|
if (codeComponent?.props?.lang === 'mermaid') {
|
|
11751
11786
|
const value = codeComponent?.props?.value;
|
|
11752
|
-
return external_amd_react_commonjs_react_commonjs2_react_root_React_umd_react_default().createElement("pre", { className: "mermaid-render mermaid_single" }, value);
|
|
11787
|
+
return (external_amd_react_commonjs_react_commonjs2_react_root_React_umd_react_default().createElement("pre", { ref: mermaidRef, className: "mermaid-render mermaid_single" }, value));
|
|
11753
11788
|
}
|
|
11754
11789
|
}
|
|
11755
11790
|
return (external_amd_react_commonjs_react_commonjs2_react_root_React_umd_react_default().createElement("div", { className: `CodeTabs CodeTabs_initial theme-${theme}` },
|
|
11756
11791
|
external_amd_react_commonjs_react_commonjs2_react_root_React_umd_react_default().createElement("div", { className: "CodeTabs-toolbar" }, childrenArray.map((pre, i) => {
|
|
11757
11792
|
// the first or only child should be our Code component
|
|
11758
|
-
const tabCodeComponent = Array.isArray(pre.props?.children)
|
|
11759
|
-
? pre.props.children[0]
|
|
11760
|
-
: pre.props?.children;
|
|
11793
|
+
const tabCodeComponent = Array.isArray(pre.props?.children) ? pre.props.children[0] : pre.props?.children;
|
|
11761
11794
|
const lang = tabCodeComponent?.props?.lang;
|
|
11762
11795
|
const meta = tabCodeComponent?.props?.meta;
|
|
11763
11796
|
/* istanbul ignore next */
|
|
@@ -12330,10 +12363,10 @@ const TailwindStyle = ({ children, darkModeDataAttribute }) => {
|
|
|
12330
12363
|
addClasses(record.target);
|
|
12331
12364
|
shouldUpdate = true;
|
|
12332
12365
|
}
|
|
12333
|
-
if (shouldUpdate) {
|
|
12334
|
-
setClasses(Array.from(classesSet.current));
|
|
12335
|
-
}
|
|
12336
12366
|
});
|
|
12367
|
+
if (shouldUpdate) {
|
|
12368
|
+
setClasses(Array.from(classesSet.current));
|
|
12369
|
+
}
|
|
12337
12370
|
});
|
|
12338
12371
|
observer.observe(ref.current.parentElement, {
|
|
12339
12372
|
subtree: true,
|
|
@@ -96062,11 +96095,33 @@ const parseBlock = (text) => {
|
|
|
96062
96095
|
const tree = contentParser.runSync(contentParser.parse(text));
|
|
96063
96096
|
return tree.children;
|
|
96064
96097
|
};
|
|
96065
|
-
|
|
96098
|
+
/**
|
|
96099
|
+
* Minimal parser for api-header titles.
|
|
96100
|
+
* Disables markdown constructs that are not parsed in legacy (headings, lists)
|
|
96101
|
+
*/
|
|
96102
|
+
const apiHeaderTitleParser = unified()
|
|
96103
|
+
.data('micromarkExtensions', [
|
|
96104
|
+
legacyVariable(),
|
|
96105
|
+
looseHtmlEntity(),
|
|
96106
|
+
{
|
|
96107
|
+
disable: {
|
|
96108
|
+
null: [
|
|
96109
|
+
'blockQuote',
|
|
96110
|
+
'headingAtx',
|
|
96111
|
+
'list',
|
|
96112
|
+
'thematicBreak',
|
|
96113
|
+
],
|
|
96114
|
+
},
|
|
96115
|
+
},
|
|
96116
|
+
])
|
|
96117
|
+
.data('fromMarkdownExtensions', [legacyVariableFromMarkdown(), looseHtmlEntityFromMarkdown()])
|
|
96118
|
+
.use(remarkParse)
|
|
96119
|
+
.use(remarkGfm);
|
|
96120
|
+
const parseApiHeaderTitle = (text) => {
|
|
96066
96121
|
if (!text.trim())
|
|
96067
96122
|
return textToInline(text);
|
|
96068
|
-
const tree =
|
|
96069
|
-
return tree.children;
|
|
96123
|
+
const tree = apiHeaderTitleParser.runSync(apiHeaderTitleParser.parse(text));
|
|
96124
|
+
return tree.children.flatMap(n => n.type === 'paragraph' && 'children' in n ? n.children : [n]);
|
|
96070
96125
|
};
|
|
96071
96126
|
/**
|
|
96072
96127
|
* Transform a magicBlock node into final MDAST nodes.
|
|
@@ -96125,7 +96180,7 @@ function transformMagicBlock(blockType, data, rawValue, options = {}) {
|
|
|
96125
96180
|
const depth = headerJson.level || (compatibilityMode ? 1 : 2);
|
|
96126
96181
|
return [
|
|
96127
96182
|
wrapPinnedBlocks({
|
|
96128
|
-
children: 'title' in headerJson ?
|
|
96183
|
+
children: 'title' in headerJson ? parseApiHeaderTitle(headerJson.title || '') : [],
|
|
96129
96184
|
depth,
|
|
96130
96185
|
type: 'heading',
|
|
96131
96186
|
}, data),
|
package/dist/main.node.js
CHANGED
|
@@ -19358,10 +19358,47 @@ var dist_utils_default = /*#__PURE__*/__webpack_require__.n(dist_utils);
|
|
|
19358
19358
|
|
|
19359
19359
|
let mermaid;
|
|
19360
19360
|
const { uppercase } = (dist_utils_default());
|
|
19361
|
+
// Module-level queue that batches mermaid nodes across all CodeTabs instances into a
|
|
19362
|
+
// single mermaid.run() call. This is necessary because mermaid generates SVG element IDs
|
|
19363
|
+
// using Date.now(), which collides when multiple diagrams render in the same millisecond.
|
|
19364
|
+
// Colliding IDs cause diagrams to overlap or break layout.
|
|
19365
|
+
//
|
|
19366
|
+
// Why not use `deterministicIDSeed` with a unique ID per diagram? Mermaid's implementation
|
|
19367
|
+
// only uses seed.length (not the seed value) to compute the starting ID, so every UUID
|
|
19368
|
+
// (36 chars) produces the same `mermaid-36` prefix — the collision remains.
|
|
19369
|
+
// See: https://github.com/mermaid-js/mermaid/blob/mermaid%4011.12.0/packages/mermaid/src/utils.ts#L755-L761
|
|
19370
|
+
//
|
|
19371
|
+
// These vars must be module-scoped (not per-instance refs) because the batching requires
|
|
19372
|
+
// cross-instance coordination. They are short-lived: the queue drains on the next macrotask
|
|
19373
|
+
// and cleanup clears everything on unmount.
|
|
19374
|
+
let mermaidQueue = [];
|
|
19375
|
+
let mermaidFlushTimer = null;
|
|
19376
|
+
let currentTheme;
|
|
19377
|
+
function queueMermaidNode(node, theme) {
|
|
19378
|
+
mermaidQueue.push(node);
|
|
19379
|
+
currentTheme = theme;
|
|
19380
|
+
if (!mermaidFlushTimer) {
|
|
19381
|
+
// setTimeout(0) defers to a macrotask, after all useEffects have queued their nodes
|
|
19382
|
+
mermaidFlushTimer = setTimeout(async () => {
|
|
19383
|
+
const nodes = [...mermaidQueue];
|
|
19384
|
+
mermaidQueue = [];
|
|
19385
|
+
mermaidFlushTimer = null;
|
|
19386
|
+
const module = await __webpack_require__.e(/* import() */ 486).then(__webpack_require__.bind(__webpack_require__, 5486));
|
|
19387
|
+
mermaid = module.default;
|
|
19388
|
+
mermaid.initialize({
|
|
19389
|
+
startOnLoad: false,
|
|
19390
|
+
theme: currentTheme === 'dark' ? 'dark' : 'default',
|
|
19391
|
+
deterministicIds: true,
|
|
19392
|
+
});
|
|
19393
|
+
await mermaid.run({ nodes });
|
|
19394
|
+
}, 0);
|
|
19395
|
+
}
|
|
19396
|
+
}
|
|
19361
19397
|
const CodeTabs = (props) => {
|
|
19362
19398
|
const { children } = props;
|
|
19363
19399
|
const theme = (0,external_react_.useContext)(Theme);
|
|
19364
19400
|
const isHydrated = useHydrated();
|
|
19401
|
+
const mermaidRef = (0,external_react_.useRef)(null);
|
|
19365
19402
|
// Handle both array (from rehype-react in rendering mdxish) and single element (MDX/JSX runtime) cases
|
|
19366
19403
|
// The children here is the individual code block objects
|
|
19367
19404
|
const childrenArray = Array.isArray(children) ? children : [children];
|
|
@@ -19372,22 +19409,20 @@ const CodeTabs = (props) => {
|
|
|
19372
19409
|
return Array.isArray(pre?.props?.children) ? pre.props.children[0] : pre?.props?.children;
|
|
19373
19410
|
};
|
|
19374
19411
|
const containAtLeastOneMermaid = childrenArray.some(pre => getCodeComponent(pre)?.props?.lang === 'mermaid');
|
|
19375
|
-
// Render Mermaid diagram
|
|
19376
19412
|
(0,external_react_.useEffect)(() => {
|
|
19377
|
-
//
|
|
19378
|
-
|
|
19379
|
-
|
|
19380
|
-
|
|
19381
|
-
|
|
19382
|
-
|
|
19383
|
-
|
|
19384
|
-
|
|
19385
|
-
|
|
19386
|
-
|
|
19387
|
-
|
|
19388
|
-
|
|
19389
|
-
|
|
19390
|
-
}
|
|
19413
|
+
// Wait for hydration so mermaid's DOM mutations don't cause mismatches
|
|
19414
|
+
if (typeof window !== 'undefined' && containAtLeastOneMermaid && isHydrated && mermaidRef.current) {
|
|
19415
|
+
queueMermaidNode(mermaidRef.current, theme);
|
|
19416
|
+
}
|
|
19417
|
+
return () => {
|
|
19418
|
+
// Clear the batch timer on unmount to prevent mermaid from running
|
|
19419
|
+
// after the DOM is torn down
|
|
19420
|
+
if (mermaidFlushTimer) {
|
|
19421
|
+
clearTimeout(mermaidFlushTimer);
|
|
19422
|
+
mermaidFlushTimer = null;
|
|
19423
|
+
mermaidQueue = [];
|
|
19424
|
+
}
|
|
19425
|
+
};
|
|
19391
19426
|
}, [containAtLeastOneMermaid, theme, isHydrated]);
|
|
19392
19427
|
function handleClick({ target }, index) {
|
|
19393
19428
|
const $wrap = target.parentElement.parentElement;
|
|
@@ -19403,15 +19438,13 @@ const CodeTabs = (props) => {
|
|
|
19403
19438
|
const codeComponent = getCodeComponent(childrenArray[0]);
|
|
19404
19439
|
if (codeComponent?.props?.lang === 'mermaid') {
|
|
19405
19440
|
const value = codeComponent?.props?.value;
|
|
19406
|
-
return external_react_default().createElement("pre", { className: "mermaid-render mermaid_single" }, value);
|
|
19441
|
+
return (external_react_default().createElement("pre", { ref: mermaidRef, className: "mermaid-render mermaid_single" }, value));
|
|
19407
19442
|
}
|
|
19408
19443
|
}
|
|
19409
19444
|
return (external_react_default().createElement("div", { className: `CodeTabs CodeTabs_initial theme-${theme}` },
|
|
19410
19445
|
external_react_default().createElement("div", { className: "CodeTabs-toolbar" }, childrenArray.map((pre, i) => {
|
|
19411
19446
|
// the first or only child should be our Code component
|
|
19412
|
-
const tabCodeComponent = Array.isArray(pre.props?.children)
|
|
19413
|
-
? pre.props.children[0]
|
|
19414
|
-
: pre.props?.children;
|
|
19447
|
+
const tabCodeComponent = Array.isArray(pre.props?.children) ? pre.props.children[0] : pre.props?.children;
|
|
19415
19448
|
const lang = tabCodeComponent?.props?.lang;
|
|
19416
19449
|
const meta = tabCodeComponent?.props?.meta;
|
|
19417
19450
|
/* istanbul ignore next */
|
|
@@ -24926,10 +24959,10 @@ const TailwindStyle = ({ children, darkModeDataAttribute }) => {
|
|
|
24926
24959
|
addClasses(record.target);
|
|
24927
24960
|
shouldUpdate = true;
|
|
24928
24961
|
}
|
|
24929
|
-
if (shouldUpdate) {
|
|
24930
|
-
setClasses(Array.from(classesSet.current));
|
|
24931
|
-
}
|
|
24932
24962
|
});
|
|
24963
|
+
if (shouldUpdate) {
|
|
24964
|
+
setClasses(Array.from(classesSet.current));
|
|
24965
|
+
}
|
|
24933
24966
|
});
|
|
24934
24967
|
observer.observe(ref.current.parentElement, {
|
|
24935
24968
|
subtree: true,
|
|
@@ -116256,11 +116289,33 @@ const parseBlock = (text) => {
|
|
|
116256
116289
|
const tree = contentParser.runSync(contentParser.parse(text));
|
|
116257
116290
|
return tree.children;
|
|
116258
116291
|
};
|
|
116259
|
-
|
|
116292
|
+
/**
|
|
116293
|
+
* Minimal parser for api-header titles.
|
|
116294
|
+
* Disables markdown constructs that are not parsed in legacy (headings, lists)
|
|
116295
|
+
*/
|
|
116296
|
+
const apiHeaderTitleParser = unified()
|
|
116297
|
+
.data('micromarkExtensions', [
|
|
116298
|
+
legacyVariable(),
|
|
116299
|
+
looseHtmlEntity(),
|
|
116300
|
+
{
|
|
116301
|
+
disable: {
|
|
116302
|
+
null: [
|
|
116303
|
+
'blockQuote',
|
|
116304
|
+
'headingAtx',
|
|
116305
|
+
'list',
|
|
116306
|
+
'thematicBreak',
|
|
116307
|
+
],
|
|
116308
|
+
},
|
|
116309
|
+
},
|
|
116310
|
+
])
|
|
116311
|
+
.data('fromMarkdownExtensions', [legacyVariableFromMarkdown(), looseHtmlEntityFromMarkdown()])
|
|
116312
|
+
.use(remarkParse)
|
|
116313
|
+
.use(remarkGfm);
|
|
116314
|
+
const parseApiHeaderTitle = (text) => {
|
|
116260
116315
|
if (!text.trim())
|
|
116261
116316
|
return textToInline(text);
|
|
116262
|
-
const tree =
|
|
116263
|
-
return tree.children;
|
|
116317
|
+
const tree = apiHeaderTitleParser.runSync(apiHeaderTitleParser.parse(text));
|
|
116318
|
+
return tree.children.flatMap(n => n.type === 'paragraph' && 'children' in n ? n.children : [n]);
|
|
116264
116319
|
};
|
|
116265
116320
|
/**
|
|
116266
116321
|
* Transform a magicBlock node into final MDAST nodes.
|
|
@@ -116319,7 +116374,7 @@ function transformMagicBlock(blockType, data, rawValue, options = {}) {
|
|
|
116319
116374
|
const depth = headerJson.level || (compatibilityMode ? 1 : 2);
|
|
116320
116375
|
return [
|
|
116321
116376
|
wrapPinnedBlocks({
|
|
116322
|
-
children: 'title' in headerJson ?
|
|
116377
|
+
children: 'title' in headerJson ? parseApiHeaderTitle(headerJson.title || '') : [],
|
|
116323
116378
|
depth,
|
|
116324
116379
|
type: 'heading',
|
|
116325
116380
|
}, data),
|