@multiplatform.one/markdown 6.0.4 → 6.3.0
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 +61 -0
- package/dist/cjs/Aside/index.cjs +37 -32
- package/dist/cjs/Aside/index.native.js +41 -34
- package/dist/cjs/Aside/index.native.js.map +1 -1
- package/dist/cjs/ExternalIcon/index.cjs +2 -0
- package/dist/cjs/ExternalIcon/index.native.js +2 -0
- package/dist/cjs/ExternalIcon/index.native.js.map +1 -1
- package/dist/cjs/Hr/index.cjs +3 -11
- package/dist/cjs/Hr/index.native.js +3 -11
- package/dist/cjs/Hr/index.native.js.map +1 -1
- package/dist/cjs/{SimpleTable → MarkdownSimpleTable}/index.cjs +27 -9
- package/dist/{jsx/SimpleTable → cjs/MarkdownSimpleTable}/index.native.js +32 -11
- package/dist/cjs/MarkdownSimpleTable/index.native.js.map +1 -0
- package/dist/cjs/Mdx/index.cjs +15 -7
- package/dist/cjs/Mdx/index.native.js +15 -7
- package/dist/cjs/Mdx/index.native.js.map +1 -1
- package/dist/cjs/MdxCodeBlock/index.cjs +28 -20
- package/dist/cjs/MdxCodeBlock/index.native.js +33 -22
- package/dist/cjs/MdxCodeBlock/index.native.js.map +1 -1
- package/dist/cjs/Notice/index.cjs +13 -56
- package/dist/cjs/Notice/index.native.js +13 -56
- package/dist/cjs/Notice/index.native.js.map +1 -1
- package/dist/cjs/Table/index.cjs +13 -0
- package/dist/cjs/Table/index.native.js +15 -0
- package/dist/cjs/Table/index.native.js.map +1 -1
- package/dist/cjs/Tabs/index.cjs +15 -47
- package/dist/cjs/Tabs/index.native.js +20 -52
- package/dist/cjs/Tabs/index.native.js.map +1 -1
- package/dist/cjs/Ul/index.cjs +2 -2
- package/dist/cjs/Ul/index.native.js +2 -2
- package/dist/cjs/Ul/index.native.js.map +1 -1
- package/dist/cjs/Video/index.cjs +4 -2
- package/dist/cjs/Video/index.native.js +4 -2
- package/dist/cjs/Video/index.native.js.map +1 -1
- package/dist/cjs/components/Blockquote.cjs +16 -3
- package/dist/cjs/components/Blockquote.native.js +25 -3
- package/dist/cjs/components/Blockquote.native.js.map +1 -1
- package/dist/cjs/components/Break.cjs +1 -0
- package/dist/cjs/components/Break.native.js +1 -0
- package/dist/cjs/components/Break.native.js.map +1 -1
- package/dist/cjs/components/CodeBlock.cjs +20 -60
- package/dist/cjs/components/CodeBlock.native.js +22 -64
- package/dist/cjs/components/CodeBlock.native.js.map +1 -1
- package/dist/cjs/components/Heading.cjs +23 -0
- package/dist/cjs/components/Heading.native.js +24 -0
- package/dist/cjs/components/Heading.native.js.map +1 -1
- package/dist/cjs/components/Image.cjs +3 -5
- package/dist/cjs/components/Image.native.js +6 -5
- package/dist/cjs/components/Image.native.js.map +1 -1
- package/dist/cjs/components/InlineCode.cjs +3 -6
- package/dist/cjs/components/InlineCode.native.js +3 -6
- package/dist/cjs/components/InlineCode.native.js.map +1 -1
- package/dist/cjs/components/InlineStyles.cjs +3 -0
- package/dist/cjs/components/InlineStyles.native.js +3 -0
- package/dist/cjs/components/InlineStyles.native.js.map +1 -1
- package/dist/cjs/components/Link.cjs +22 -5
- package/dist/cjs/components/Link.native.js +23 -5
- package/dist/cjs/components/Link.native.js.map +1 -1
- package/dist/cjs/components/List.cjs +87 -9
- package/dist/cjs/components/List.native.js +91 -9
- package/dist/cjs/components/List.native.js.map +1 -1
- package/dist/cjs/components/Paragraph.cjs +6 -1
- package/dist/cjs/components/Paragraph.native.js +6 -1
- package/dist/cjs/components/Paragraph.native.js.map +1 -1
- package/dist/cjs/components/Table.cjs +57 -24
- package/dist/cjs/components/Table.native.js +67 -25
- package/dist/cjs/components/Table.native.js.map +1 -1
- package/dist/cjs/hooks/useCompileMdx.cjs +61 -28
- package/dist/cjs/hooks/useCompileMdx.native.js +80 -28
- package/dist/cjs/hooks/useCompileMdx.native.js.map +1 -1
- package/dist/cjs/hooks/useEvaluateMdx.cjs +7 -1
- package/dist/cjs/hooks/useEvaluateMdx.native.js +9 -3
- package/dist/cjs/hooks/useEvaluateMdx.native.js.map +1 -1
- package/dist/cjs/icons/index.cjs +31 -101
- package/dist/cjs/icons/index.native.js +36 -116
- package/dist/cjs/icons/index.native.js.map +1 -1
- package/dist/cjs/index.cjs +6 -4
- package/dist/cjs/index.native.js +6 -4
- package/dist/cjs/index.native.js.map +1 -1
- package/dist/cjs/mdxComponents.cjs +13 -6
- package/dist/cjs/mdxComponents.native.js +16 -6
- package/dist/cjs/mdxComponents.native.js.map +1 -1
- package/dist/cjs/mermaid/MermaidBlock.cjs +110 -0
- package/dist/cjs/mermaid/MermaidBlock.native.js +41 -0
- package/dist/cjs/mermaid/MermaidBlock.native.js.map +1 -0
- package/dist/cjs/mermaid/index.cjs +31 -0
- package/dist/cjs/mermaid/index.native.js +34 -0
- package/dist/cjs/mermaid/index.native.js.map +1 -0
- package/dist/cjs/mermaid/mountDiagramSvg.cjs +54 -0
- package/dist/cjs/mermaid/mountDiagramSvg.native.js +98 -0
- package/dist/cjs/mermaid/mountDiagramSvg.native.js.map +1 -0
- package/dist/cjs/mermaid/renderMermaidDiagram.cjs +92 -0
- package/dist/cjs/mermaid/renderMermaidDiagram.native.js +110 -0
- package/dist/cjs/mermaid/renderMermaidDiagram.native.js.map +1 -0
- package/dist/cjs/renderer.cjs +9 -1
- package/dist/cjs/renderer.native.js +10 -2
- package/dist/cjs/renderer.native.js.map +1 -1
- package/dist/cjs/shared/colorRamps.cjs +1 -11
- package/dist/cjs/shared/colorRamps.native.js +1 -11
- package/dist/cjs/shared/colorRamps.native.js.map +1 -1
- package/dist/cjs/shared/cutoffGradient.cjs +54 -0
- package/dist/cjs/shared/cutoffGradient.native.js +63 -0
- package/dist/cjs/shared/cutoffGradient.native.js.map +1 -0
- package/dist/cjs/shiki/index.cjs +1 -16
- package/dist/cjs/shiki/index.native.js +0 -15
- package/dist/cjs/shiki/index.native.js.map +1 -1
- package/dist/esm/Aside/index.mjs +39 -34
- package/dist/esm/Aside/index.mjs.map +1 -1
- package/dist/esm/Aside/index.native.js +43 -36
- package/dist/esm/Aside/index.native.js.map +1 -1
- package/dist/esm/ExternalIcon/index.mjs +2 -0
- package/dist/esm/ExternalIcon/index.mjs.map +1 -1
- package/dist/esm/ExternalIcon/index.native.js +2 -0
- package/dist/esm/ExternalIcon/index.native.js.map +1 -1
- package/dist/esm/Hr/index.mjs +4 -12
- package/dist/esm/Hr/index.mjs.map +1 -1
- package/dist/esm/Hr/index.native.js +4 -12
- package/dist/esm/Hr/index.native.js.map +1 -1
- package/dist/esm/{SimpleTable → MarkdownSimpleTable}/index.mjs +24 -6
- package/dist/esm/MarkdownSimpleTable/index.mjs.map +1 -0
- package/dist/esm/{SimpleTable → MarkdownSimpleTable}/index.native.js +29 -8
- package/dist/esm/MarkdownSimpleTable/index.native.js.map +1 -0
- package/dist/esm/Mdx/index.mjs +15 -7
- package/dist/esm/Mdx/index.mjs.map +1 -1
- package/dist/esm/Mdx/index.native.js +15 -7
- package/dist/esm/Mdx/index.native.js.map +1 -1
- package/dist/esm/MdxCodeBlock/index.mjs +30 -22
- package/dist/esm/MdxCodeBlock/index.mjs.map +1 -1
- package/dist/esm/MdxCodeBlock/index.native.js +35 -24
- package/dist/esm/MdxCodeBlock/index.native.js.map +1 -1
- package/dist/esm/Notice/index.mjs +15 -57
- package/dist/esm/Notice/index.mjs.map +1 -1
- package/dist/esm/Notice/index.native.js +15 -57
- package/dist/esm/Notice/index.native.js.map +1 -1
- package/dist/esm/Table/index.mjs +13 -0
- package/dist/esm/Table/index.mjs.map +1 -1
- package/dist/esm/Table/index.native.js +15 -0
- package/dist/esm/Table/index.native.js.map +1 -1
- package/dist/esm/Tabs/index.mjs +17 -49
- package/dist/esm/Tabs/index.mjs.map +1 -1
- package/dist/esm/Tabs/index.native.js +22 -54
- package/dist/esm/Tabs/index.native.js.map +1 -1
- package/dist/esm/Ul/index.mjs +2 -2
- package/dist/esm/Ul/index.mjs.map +1 -1
- package/dist/esm/Ul/index.native.js +2 -2
- package/dist/esm/Ul/index.native.js.map +1 -1
- package/dist/esm/Video/index.mjs +4 -2
- package/dist/esm/Video/index.mjs.map +1 -1
- package/dist/esm/Video/index.native.js +4 -2
- package/dist/esm/Video/index.native.js.map +1 -1
- package/dist/esm/components/Blockquote.mjs +17 -4
- package/dist/esm/components/Blockquote.mjs.map +1 -1
- package/dist/esm/components/Blockquote.native.js +26 -4
- package/dist/esm/components/Blockquote.native.js.map +1 -1
- package/dist/esm/components/Break.mjs +2 -1
- package/dist/esm/components/Break.mjs.map +1 -1
- package/dist/esm/components/Break.native.js +2 -1
- package/dist/esm/components/Break.native.js.map +1 -1
- package/dist/esm/components/CodeBlock.mjs +21 -61
- package/dist/esm/components/CodeBlock.mjs.map +1 -1
- package/dist/esm/components/CodeBlock.native.js +23 -65
- package/dist/esm/components/CodeBlock.native.js.map +1 -1
- package/dist/esm/components/Heading.mjs +24 -1
- package/dist/esm/components/Heading.mjs.map +1 -1
- package/dist/esm/components/Heading.native.js +25 -1
- package/dist/esm/components/Heading.native.js.map +1 -1
- package/dist/esm/components/Image.mjs +3 -5
- package/dist/esm/components/Image.mjs.map +1 -1
- package/dist/esm/components/Image.native.js +6 -5
- package/dist/esm/components/Image.native.js.map +1 -1
- package/dist/esm/components/InlineCode.mjs +3 -6
- package/dist/esm/components/InlineCode.mjs.map +1 -1
- package/dist/esm/components/InlineCode.native.js +3 -6
- package/dist/esm/components/InlineCode.native.js.map +1 -1
- package/dist/esm/components/InlineStyles.mjs +3 -0
- package/dist/esm/components/InlineStyles.mjs.map +1 -1
- package/dist/esm/components/InlineStyles.native.js +3 -0
- package/dist/esm/components/InlineStyles.native.js.map +1 -1
- package/dist/esm/components/Link.mjs +23 -6
- package/dist/esm/components/Link.mjs.map +1 -1
- package/dist/esm/components/Link.native.js +24 -6
- package/dist/esm/components/Link.native.js.map +1 -1
- package/dist/esm/components/List.mjs +88 -10
- package/dist/esm/components/List.mjs.map +1 -1
- package/dist/esm/components/List.native.js +92 -10
- package/dist/esm/components/List.native.js.map +1 -1
- package/dist/esm/components/Paragraph.mjs +6 -1
- package/dist/esm/components/Paragraph.mjs.map +1 -1
- package/dist/esm/components/Paragraph.native.js +6 -1
- package/dist/esm/components/Paragraph.native.js.map +1 -1
- package/dist/esm/components/Table.mjs +59 -26
- package/dist/esm/components/Table.mjs.map +1 -1
- package/dist/esm/components/Table.native.js +69 -27
- package/dist/esm/components/Table.native.js.map +1 -1
- package/dist/esm/hooks/useCompileMdx.mjs +61 -29
- package/dist/esm/hooks/useCompileMdx.mjs.map +1 -1
- package/dist/esm/hooks/useCompileMdx.native.js +80 -29
- package/dist/esm/hooks/useCompileMdx.native.js.map +1 -1
- package/dist/esm/hooks/useEvaluateMdx.mjs +7 -1
- package/dist/esm/hooks/useEvaluateMdx.mjs.map +1 -1
- package/dist/esm/hooks/useEvaluateMdx.native.js +9 -3
- package/dist/esm/hooks/useEvaluateMdx.native.js.map +1 -1
- package/dist/esm/icons/index.mjs +32 -100
- package/dist/esm/icons/index.mjs.map +1 -1
- package/dist/esm/icons/index.native.js +37 -115
- package/dist/esm/icons/index.native.js.map +1 -1
- package/dist/esm/index.mjs +5 -3
- package/dist/esm/index.mjs.map +1 -1
- package/dist/esm/index.native.js +5 -3
- package/dist/esm/index.native.js.map +1 -1
- package/dist/esm/mdxComponents.mjs +14 -7
- package/dist/esm/mdxComponents.mjs.map +1 -1
- package/dist/esm/mdxComponents.native.js +17 -7
- package/dist/esm/mdxComponents.native.js.map +1 -1
- package/dist/esm/mermaid/MermaidBlock.mjs +85 -0
- package/dist/esm/mermaid/MermaidBlock.mjs.map +1 -0
- package/dist/esm/mermaid/MermaidBlock.native.js +13 -0
- package/dist/esm/mermaid/MermaidBlock.native.js.map +1 -0
- package/dist/esm/mermaid/index.mjs +4 -0
- package/dist/esm/mermaid/index.mjs.map +1 -0
- package/dist/esm/mermaid/index.native.js +4 -0
- package/dist/esm/mermaid/index.native.js.map +1 -0
- package/dist/esm/mermaid/mountDiagramSvg.mjs +29 -0
- package/dist/esm/mermaid/mountDiagramSvg.mjs.map +1 -0
- package/dist/esm/mermaid/mountDiagramSvg.native.js +70 -0
- package/dist/esm/mermaid/mountDiagramSvg.native.js.map +1 -0
- package/dist/esm/mermaid/renderMermaidDiagram.mjs +55 -0
- package/dist/esm/mermaid/renderMermaidDiagram.mjs.map +1 -0
- package/dist/esm/mermaid/renderMermaidDiagram.native.js +70 -0
- package/dist/esm/mermaid/renderMermaidDiagram.native.js.map +1 -0
- package/dist/esm/renderer.mjs +9 -1
- package/dist/esm/renderer.mjs.map +1 -1
- package/dist/esm/renderer.native.js +10 -2
- package/dist/esm/renderer.native.js.map +1 -1
- package/dist/esm/shared/colorRamps.mjs +1 -10
- package/dist/esm/shared/colorRamps.mjs.map +1 -1
- package/dist/esm/shared/colorRamps.native.js +1 -10
- package/dist/esm/shared/colorRamps.native.js.map +1 -1
- package/dist/esm/shared/cutoffGradient.mjs +28 -0
- package/dist/esm/shared/cutoffGradient.mjs.map +1 -0
- package/dist/esm/shared/cutoffGradient.native.js +34 -0
- package/dist/esm/shared/cutoffGradient.native.js.map +1 -0
- package/dist/esm/shiki/index.mjs +1 -2
- package/dist/esm/shiki/index.mjs.map +1 -1
- package/dist/esm/shiki/index.native.js +1 -2
- package/dist/esm/shiki/index.native.js.map +1 -1
- package/dist/jsx/Aside/index.mjs +39 -34
- package/dist/jsx/Aside/index.mjs.map +1 -1
- package/dist/jsx/Aside/index.native.js +41 -34
- package/dist/jsx/Aside/index.native.js.map +1 -1
- package/dist/jsx/ExternalIcon/index.mjs +2 -0
- package/dist/jsx/ExternalIcon/index.mjs.map +1 -1
- package/dist/jsx/ExternalIcon/index.native.js +2 -0
- package/dist/jsx/ExternalIcon/index.native.js.map +1 -1
- package/dist/jsx/Hr/index.mjs +4 -12
- package/dist/jsx/Hr/index.mjs.map +1 -1
- package/dist/jsx/Hr/index.native.js +3 -11
- package/dist/jsx/Hr/index.native.js.map +1 -1
- package/dist/jsx/{SimpleTable → MarkdownSimpleTable}/index.mjs +24 -6
- package/dist/jsx/MarkdownSimpleTable/index.mjs.map +1 -0
- package/dist/{cjs/SimpleTable → jsx/MarkdownSimpleTable}/index.native.js +32 -11
- package/dist/jsx/MarkdownSimpleTable/index.native.js.map +1 -0
- package/dist/jsx/Mdx/index.mjs +15 -7
- package/dist/jsx/Mdx/index.mjs.map +1 -1
- package/dist/jsx/Mdx/index.native.js +15 -7
- package/dist/jsx/Mdx/index.native.js.map +1 -1
- package/dist/jsx/MdxCodeBlock/index.mjs +30 -22
- package/dist/jsx/MdxCodeBlock/index.mjs.map +1 -1
- package/dist/jsx/MdxCodeBlock/index.native.js +33 -22
- package/dist/jsx/MdxCodeBlock/index.native.js.map +1 -1
- package/dist/jsx/Notice/index.mjs +15 -57
- package/dist/jsx/Notice/index.mjs.map +1 -1
- package/dist/jsx/Notice/index.native.js +13 -56
- package/dist/jsx/Notice/index.native.js.map +1 -1
- package/dist/jsx/Table/index.mjs +13 -0
- package/dist/jsx/Table/index.mjs.map +1 -1
- package/dist/jsx/Table/index.native.js +15 -0
- package/dist/jsx/Table/index.native.js.map +1 -1
- package/dist/jsx/Tabs/index.mjs +17 -49
- package/dist/jsx/Tabs/index.mjs.map +1 -1
- package/dist/jsx/Tabs/index.native.js +20 -52
- package/dist/jsx/Tabs/index.native.js.map +1 -1
- package/dist/jsx/Ul/index.mjs +2 -2
- package/dist/jsx/Ul/index.mjs.map +1 -1
- package/dist/jsx/Ul/index.native.js +2 -2
- package/dist/jsx/Ul/index.native.js.map +1 -1
- package/dist/jsx/Video/index.mjs +4 -2
- package/dist/jsx/Video/index.mjs.map +1 -1
- package/dist/jsx/Video/index.native.js +4 -2
- package/dist/jsx/Video/index.native.js.map +1 -1
- package/dist/jsx/components/Blockquote.mjs +17 -4
- package/dist/jsx/components/Blockquote.mjs.map +1 -1
- package/dist/jsx/components/Blockquote.native.js +25 -3
- package/dist/jsx/components/Blockquote.native.js.map +1 -1
- package/dist/jsx/components/Break.mjs +2 -1
- package/dist/jsx/components/Break.mjs.map +1 -1
- package/dist/jsx/components/Break.native.js +1 -0
- package/dist/jsx/components/Break.native.js.map +1 -1
- package/dist/jsx/components/CodeBlock.mjs +21 -61
- package/dist/jsx/components/CodeBlock.mjs.map +1 -1
- package/dist/jsx/components/CodeBlock.native.js +22 -64
- package/dist/jsx/components/CodeBlock.native.js.map +1 -1
- package/dist/jsx/components/Heading.mjs +24 -1
- package/dist/jsx/components/Heading.mjs.map +1 -1
- package/dist/jsx/components/Heading.native.js +24 -0
- package/dist/jsx/components/Heading.native.js.map +1 -1
- package/dist/jsx/components/Image.mjs +3 -5
- package/dist/jsx/components/Image.mjs.map +1 -1
- package/dist/jsx/components/Image.native.js +6 -5
- package/dist/jsx/components/Image.native.js.map +1 -1
- package/dist/jsx/components/InlineCode.mjs +3 -6
- package/dist/jsx/components/InlineCode.mjs.map +1 -1
- package/dist/jsx/components/InlineCode.native.js +3 -6
- package/dist/jsx/components/InlineCode.native.js.map +1 -1
- package/dist/jsx/components/InlineStyles.mjs +3 -0
- package/dist/jsx/components/InlineStyles.mjs.map +1 -1
- package/dist/jsx/components/InlineStyles.native.js +3 -0
- package/dist/jsx/components/InlineStyles.native.js.map +1 -1
- package/dist/jsx/components/Link.mjs +23 -6
- package/dist/jsx/components/Link.mjs.map +1 -1
- package/dist/jsx/components/Link.native.js +23 -5
- package/dist/jsx/components/Link.native.js.map +1 -1
- package/dist/jsx/components/List.mjs +88 -10
- package/dist/jsx/components/List.mjs.map +1 -1
- package/dist/jsx/components/List.native.js +91 -9
- package/dist/jsx/components/List.native.js.map +1 -1
- package/dist/jsx/components/Paragraph.mjs +6 -1
- package/dist/jsx/components/Paragraph.mjs.map +1 -1
- package/dist/jsx/components/Paragraph.native.js +6 -1
- package/dist/jsx/components/Paragraph.native.js.map +1 -1
- package/dist/jsx/components/Table.mjs +59 -26
- package/dist/jsx/components/Table.mjs.map +1 -1
- package/dist/jsx/components/Table.native.js +67 -25
- package/dist/jsx/components/Table.native.js.map +1 -1
- package/dist/jsx/hooks/useCompileMdx.mjs +61 -29
- package/dist/jsx/hooks/useCompileMdx.mjs.map +1 -1
- package/dist/jsx/hooks/useCompileMdx.native.js +80 -28
- package/dist/jsx/hooks/useCompileMdx.native.js.map +1 -1
- package/dist/jsx/hooks/useEvaluateMdx.mjs +7 -1
- package/dist/jsx/hooks/useEvaluateMdx.mjs.map +1 -1
- package/dist/jsx/hooks/useEvaluateMdx.native.js +9 -3
- package/dist/jsx/hooks/useEvaluateMdx.native.js.map +1 -1
- package/dist/jsx/icons/index.mjs +32 -100
- package/dist/jsx/icons/index.mjs.map +1 -1
- package/dist/jsx/icons/index.native.js +36 -116
- package/dist/jsx/icons/index.native.js.map +1 -1
- package/dist/jsx/index.js +5 -3
- package/dist/jsx/index.js.map +1 -1
- package/dist/jsx/index.mjs +5 -3
- package/dist/jsx/index.mjs.map +1 -1
- package/dist/jsx/index.native.js +6 -4
- package/dist/jsx/index.native.js.map +1 -1
- package/dist/jsx/mdxComponents.mjs +14 -7
- package/dist/jsx/mdxComponents.mjs.map +1 -1
- package/dist/jsx/mdxComponents.native.js +16 -6
- package/dist/jsx/mdxComponents.native.js.map +1 -1
- package/dist/jsx/mermaid/MermaidBlock.mjs +85 -0
- package/dist/jsx/mermaid/MermaidBlock.mjs.map +1 -0
- package/dist/jsx/mermaid/MermaidBlock.native.js +41 -0
- package/dist/jsx/mermaid/MermaidBlock.native.js.map +1 -0
- package/dist/jsx/mermaid/index.mjs +4 -0
- package/dist/jsx/mermaid/index.mjs.map +1 -0
- package/dist/jsx/mermaid/index.native.js +34 -0
- package/dist/jsx/mermaid/index.native.js.map +1 -0
- package/dist/jsx/mermaid/mountDiagramSvg.mjs +29 -0
- package/dist/jsx/mermaid/mountDiagramSvg.mjs.map +1 -0
- package/dist/jsx/mermaid/mountDiagramSvg.native.js +98 -0
- package/dist/jsx/mermaid/mountDiagramSvg.native.js.map +1 -0
- package/dist/jsx/mermaid/renderMermaidDiagram.mjs +55 -0
- package/dist/jsx/mermaid/renderMermaidDiagram.mjs.map +1 -0
- package/dist/jsx/mermaid/renderMermaidDiagram.native.js +110 -0
- package/dist/jsx/mermaid/renderMermaidDiagram.native.js.map +1 -0
- package/dist/jsx/renderer.mjs +9 -1
- package/dist/jsx/renderer.mjs.map +1 -1
- package/dist/jsx/renderer.native.js +10 -2
- package/dist/jsx/renderer.native.js.map +1 -1
- package/dist/jsx/shared/colorRamps.mjs +1 -10
- package/dist/jsx/shared/colorRamps.mjs.map +1 -1
- package/dist/jsx/shared/colorRamps.native.js +1 -11
- package/dist/jsx/shared/colorRamps.native.js.map +1 -1
- package/dist/jsx/shared/cutoffGradient.mjs +28 -0
- package/dist/jsx/shared/cutoffGradient.mjs.map +1 -0
- package/dist/jsx/shared/cutoffGradient.native.js +63 -0
- package/dist/jsx/shared/cutoffGradient.native.js.map +1 -0
- package/dist/jsx/shiki/index.mjs +1 -2
- package/dist/jsx/shiki/index.mjs.map +1 -1
- package/dist/jsx/shiki/index.native.js +0 -15
- package/dist/jsx/shiki/index.native.js.map +1 -1
- package/package.json +25 -14
- package/src/Aside/index.tsx +42 -35
- package/src/ExternalIcon/index.tsx +8 -1
- package/src/Hr/index.tsx +3 -6
- package/src/{SimpleTable → MarkdownSimpleTable}/index.tsx +30 -12
- package/src/MarkdownSimpleTable/markdownSimpleTable.spec.tsx +92 -0
- package/src/Mdx/index.tsx +12 -7
- package/src/MdxCodeBlock/index.tsx +33 -20
- package/src/Notice/index.tsx +12 -54
- package/src/Table/index.tsx +22 -6
- package/src/Tabs/index.tsx +26 -52
- package/src/Ul/index.ts +2 -2
- package/src/Video/index.tsx +15 -12
- package/src/components/Blockquote.tsx +29 -4
- package/src/components/Break.tsx +3 -1
- package/src/components/CodeBlock.tsx +49 -79
- package/src/components/Heading.tsx +15 -2
- package/src/components/Image.tsx +6 -3
- package/src/components/InlineCode.tsx +14 -7
- package/src/components/InlineStyles.tsx +15 -3
- package/src/components/Link.tsx +29 -6
- package/src/components/List.tsx +111 -11
- package/src/components/Paragraph.tsx +6 -1
- package/src/components/Table.tsx +56 -35
- package/src/components/markdownPrimitives.spec.tsx +121 -0
- package/src/docBlocks.spec.tsx +85 -0
- package/src/hooks/useCompileMdx.ts +75 -35
- package/src/hooks/useEvaluateMdx.ts +7 -1
- package/src/icons/index.tsx +36 -58
- package/src/index.ts +15 -3
- package/src/markdownComponent.spec.tsx +58 -0
- package/src/mdx.spec.tsx +4 -0
- package/src/mdxComponents.spec.tsx +185 -0
- package/src/mdxComponents.tsx +14 -5
- package/src/mermaid/MermaidBlock.native.tsx +15 -0
- package/src/mermaid/MermaidBlock.tsx +88 -0
- package/src/mermaid/index.ts +23 -0
- package/src/mermaid/mountDiagramSvg.ts +49 -0
- package/src/mermaid/renderMermaidDiagram.spec.ts +89 -0
- package/src/mermaid/renderMermaidDiagram.ts +78 -0
- package/src/renderer.spec.tsx +276 -0
- package/src/renderer.tsx +13 -1
- package/src/shared/colorRamps.ts +0 -10
- package/src/shared/cutoffGradient.ts +40 -0
- package/src/shiki/index.ts +7 -11
- package/src/stories/Blocks.stories.tsx +232 -0
- package/src/stories/Callouts.stories.tsx +147 -0
- package/src/stories/Code.stories.tsx +116 -0
- package/src/stories/Inline.stories.tsx +162 -0
- package/src/stories/Mdx.stories.tsx +107 -0
- package/src/stories/Media.stories.tsx +148 -0
- package/src/stories/Tables.stories.tsx +173 -0
- package/types/Aside/index.d.ts +11 -0
- package/types/Aside/index.d.ts.map +1 -0
- package/types/ExternalIcon/index.d.ts +2 -0
- package/types/ExternalIcon/index.d.ts.map +1 -0
- package/types/Hr/index.d.ts +2 -0
- package/types/Hr/index.d.ts.map +1 -0
- package/types/Li/index.d.ts +6 -0
- package/types/Li/index.d.ts.map +1 -0
- package/types/Markdown.d.ts +22 -0
- package/types/Markdown.d.ts.map +1 -0
- package/types/MarkdownSimpleTable/index.d.ts +16 -0
- package/types/MarkdownSimpleTable/index.d.ts.map +1 -0
- package/types/Mdx/index.d.ts +9 -0
- package/types/Mdx/index.d.ts.map +1 -0
- package/types/MdxCodeBlock/index.d.ts +7 -0
- package/types/MdxCodeBlock/index.d.ts.map +1 -0
- package/types/MdxCodeBlock/mdxCodeBlockContext.d.ts +13 -0
- package/types/MdxCodeBlock/mdxCodeBlockContext.d.ts.map +1 -0
- package/types/Notice/index.d.ts +12 -0
- package/types/Notice/index.d.ts.map +1 -0
- package/types/Table/index.d.ts +20 -0
- package/types/Table/index.d.ts.map +1 -0
- package/types/Tabs/index.d.ts +21 -0
- package/types/Tabs/index.d.ts.map +1 -0
- package/types/Ul/index.d.ts +6 -0
- package/types/Ul/index.d.ts.map +1 -0
- package/types/Video/index.d.ts +12 -0
- package/types/Video/index.d.ts.map +1 -0
- package/types/components/Blockquote.d.ts +3 -0
- package/types/components/Blockquote.d.ts.map +1 -0
- package/types/components/Break.d.ts +3 -0
- package/types/components/Break.d.ts.map +1 -0
- package/types/components/CodeBlock.d.ts +17 -0
- package/types/components/CodeBlock.d.ts.map +1 -0
- package/types/components/Heading.d.ts +3 -0
- package/types/components/Heading.d.ts.map +1 -0
- package/types/components/HorizontalRule.d.ts +3 -0
- package/types/components/HorizontalRule.d.ts.map +1 -0
- package/types/components/Image.d.ts +3 -0
- package/types/components/Image.d.ts.map +1 -0
- package/types/components/InlineCode.d.ts +12 -0
- package/types/components/InlineCode.d.ts.map +1 -0
- package/types/components/InlineStyles.d.ts +5 -0
- package/types/components/InlineStyles.d.ts.map +1 -0
- package/types/components/Link.d.ts +3 -0
- package/types/components/Link.d.ts.map +1 -0
- package/types/components/List.d.ts +10 -0
- package/types/components/List.d.ts.map +1 -0
- package/types/components/Paragraph.d.ts +3 -0
- package/types/components/Paragraph.d.ts.map +1 -0
- package/types/components/Table.d.ts +13 -0
- package/types/components/Table.d.ts.map +1 -0
- package/types/components/index.d.ts +13 -0
- package/types/components/index.d.ts.map +1 -0
- package/types/hooks/index.d.ts +4 -0
- package/types/hooks/index.d.ts.map +1 -0
- package/types/hooks/useCompileAndEvaluateMdx.d.ts +9 -0
- package/types/hooks/useCompileAndEvaluateMdx.d.ts.map +1 -0
- package/types/hooks/useCompileMdx.d.ts +13 -0
- package/types/hooks/useCompileMdx.d.ts.map +1 -0
- package/types/hooks/useEvaluateMdx.d.ts +5 -0
- package/types/hooks/useEvaluateMdx.d.ts.map +1 -0
- package/types/icons/index.d.ts +12 -0
- package/types/icons/index.d.ts.map +1 -0
- package/types/index.d.ts +29 -0
- package/types/index.d.ts.map +1 -0
- package/types/mdxComponents.d.ts +8 -0
- package/types/mdxComponents.d.ts.map +1 -0
- package/types/mermaid/MermaidBlock.d.ts +15 -0
- package/types/mermaid/MermaidBlock.d.ts.map +1 -0
- package/types/mermaid/MermaidBlock.native.d.ts +10 -0
- package/types/mermaid/MermaidBlock.native.d.ts.map +1 -0
- package/types/mermaid/index.d.ts +18 -0
- package/types/mermaid/index.d.ts.map +1 -0
- package/types/mermaid/mountDiagramSvg.d.ts +11 -0
- package/types/mermaid/mountDiagramSvg.d.ts.map +1 -0
- package/types/mermaid/renderMermaidDiagram.d.ts +33 -0
- package/types/mermaid/renderMermaidDiagram.d.ts.map +1 -0
- package/types/parser.d.ts +11 -0
- package/types/parser.d.ts.map +1 -0
- package/types/renderer.d.ts +32 -0
- package/types/renderer.d.ts.map +1 -0
- package/types/shared/colorRamps.d.ts +39 -0
- package/types/shared/colorRamps.d.ts.map +1 -0
- package/types/shared/cutoffGradient.d.ts +12 -0
- package/types/shared/cutoffGradient.d.ts.map +1 -0
- package/types/shared/index.d.ts +2 -0
- package/types/shared/index.d.ts.map +1 -0
- package/types/shiki/index.d.ts +8 -0
- package/types/shiki/index.d.ts.map +1 -0
- package/types/types.d.ts +160 -0
- package/types/types.d.ts.map +1 -0
- package/types/util/rehypeMetaAttributes.d.ts +2 -0
- package/types/util/rehypeMetaAttributes.d.ts.map +1 -0
- package/dist/cjs/ExternalIcon/ExternalIcon.spec.cjs +0 -37
- package/dist/cjs/ExternalIcon/ExternalIcon.spec.native.js +0 -40
- package/dist/cjs/ExternalIcon/ExternalIcon.spec.native.js.map +0 -1
- package/dist/cjs/Hr/hr.spec.cjs +0 -21
- package/dist/cjs/Hr/hr.spec.native.js +0 -24
- package/dist/cjs/Hr/hr.spec.native.js.map +0 -1
- package/dist/cjs/Li/li.spec.cjs +0 -45
- package/dist/cjs/Li/li.spec.native.js +0 -50
- package/dist/cjs/Li/li.spec.native.js.map +0 -1
- package/dist/cjs/Markdown.stories.cjs +0 -153
- package/dist/cjs/Markdown.stories.native.js +0 -162
- package/dist/cjs/Markdown.stories.native.js.map +0 -1
- package/dist/cjs/Mdx/mdx.spec.cjs +0 -139
- package/dist/cjs/Mdx/mdx.spec.native.js +0 -158
- package/dist/cjs/Mdx/mdx.spec.native.js.map +0 -1
- package/dist/cjs/MdxCodeBlock/mdxCodeBlock.spec.cjs +0 -90
- package/dist/cjs/MdxCodeBlock/mdxCodeBlock.spec.native.js +0 -122
- package/dist/cjs/MdxCodeBlock/mdxCodeBlock.spec.native.js.map +0 -1
- package/dist/cjs/SimpleTable/index.native.js.map +0 -1
- package/dist/cjs/Ul/ul.spec.cjs +0 -150
- package/dist/cjs/Ul/ul.spec.native.js +0 -153
- package/dist/cjs/Ul/ul.spec.native.js.map +0 -1
- package/dist/cjs/hooks/useCompileAndEvaluateMdx.spec.cjs +0 -34
- package/dist/cjs/hooks/useCompileAndEvaluateMdx.spec.native.js +0 -49
- package/dist/cjs/hooks/useCompileAndEvaluateMdx.spec.native.js.map +0 -1
- package/dist/cjs/mdx.spec.cjs +0 -400
- package/dist/cjs/mdx.spec.native.js +0 -465
- package/dist/cjs/mdx.spec.native.js.map +0 -1
- package/dist/cjs/parser.spec.cjs +0 -109
- package/dist/cjs/parser.spec.native.js +0 -114
- package/dist/cjs/parser.spec.native.js.map +0 -1
- package/dist/cjs/shiki/highlighter.cjs +0 -89
- package/dist/cjs/shiki/highlighter.native.js +0 -94
- package/dist/cjs/shiki/highlighter.native.js.map +0 -1
- package/dist/cjs/util/util.spec.cjs +0 -81
- package/dist/cjs/util/util.spec.native.js +0 -84
- package/dist/cjs/util/util.spec.native.js.map +0 -1
- package/dist/esm/ExternalIcon/ExternalIcon.spec.mjs +0 -38
- package/dist/esm/ExternalIcon/ExternalIcon.spec.mjs.map +0 -1
- package/dist/esm/ExternalIcon/ExternalIcon.spec.native.js +0 -38
- package/dist/esm/ExternalIcon/ExternalIcon.spec.native.js.map +0 -1
- package/dist/esm/Hr/hr.spec.mjs +0 -22
- package/dist/esm/Hr/hr.spec.mjs.map +0 -1
- package/dist/esm/Hr/hr.spec.native.js +0 -22
- package/dist/esm/Hr/hr.spec.native.js.map +0 -1
- package/dist/esm/Li/li.spec.mjs +0 -46
- package/dist/esm/Li/li.spec.mjs.map +0 -1
- package/dist/esm/Li/li.spec.native.js +0 -48
- package/dist/esm/Li/li.spec.native.js.map +0 -1
- package/dist/esm/Markdown.stories.mjs +0 -125
- package/dist/esm/Markdown.stories.mjs.map +0 -1
- package/dist/esm/Markdown.stories.native.js +0 -131
- package/dist/esm/Markdown.stories.native.js.map +0 -1
- package/dist/esm/Mdx/mdx.spec.mjs +0 -140
- package/dist/esm/Mdx/mdx.spec.mjs.map +0 -1
- package/dist/esm/Mdx/mdx.spec.native.js +0 -156
- package/dist/esm/Mdx/mdx.spec.native.js.map +0 -1
- package/dist/esm/MdxCodeBlock/mdxCodeBlock.spec.mjs +0 -91
- package/dist/esm/MdxCodeBlock/mdxCodeBlock.spec.mjs.map +0 -1
- package/dist/esm/MdxCodeBlock/mdxCodeBlock.spec.native.js +0 -96
- package/dist/esm/MdxCodeBlock/mdxCodeBlock.spec.native.js.map +0 -1
- package/dist/esm/SimpleTable/index.mjs.map +0 -1
- package/dist/esm/SimpleTable/index.native.js.map +0 -1
- package/dist/esm/Ul/ul.spec.mjs +0 -151
- package/dist/esm/Ul/ul.spec.mjs.map +0 -1
- package/dist/esm/Ul/ul.spec.native.js +0 -151
- package/dist/esm/Ul/ul.spec.native.js.map +0 -1
- package/dist/esm/hooks/useCompileAndEvaluateMdx.spec.mjs +0 -35
- package/dist/esm/hooks/useCompileAndEvaluateMdx.spec.mjs.map +0 -1
- package/dist/esm/hooks/useCompileAndEvaluateMdx.spec.native.js +0 -47
- package/dist/esm/hooks/useCompileAndEvaluateMdx.spec.native.js.map +0 -1
- package/dist/esm/mdx.spec.mjs +0 -377
- package/dist/esm/mdx.spec.mjs.map +0 -1
- package/dist/esm/mdx.spec.native.js +0 -439
- package/dist/esm/mdx.spec.native.js.map +0 -1
- package/dist/esm/parser.spec.mjs +0 -110
- package/dist/esm/parser.spec.mjs.map +0 -1
- package/dist/esm/parser.spec.native.js +0 -112
- package/dist/esm/parser.spec.native.js.map +0 -1
- package/dist/esm/shiki/highlighter.mjs +0 -59
- package/dist/esm/shiki/highlighter.mjs.map +0 -1
- package/dist/esm/shiki/highlighter.native.js +0 -61
- package/dist/esm/shiki/highlighter.native.js.map +0 -1
- package/dist/esm/util/util.spec.mjs +0 -82
- package/dist/esm/util/util.spec.mjs.map +0 -1
- package/dist/esm/util/util.spec.native.js +0 -82
- package/dist/esm/util/util.spec.native.js.map +0 -1
- package/dist/jsx/ExternalIcon/ExternalIcon.spec.mjs +0 -38
- package/dist/jsx/ExternalIcon/ExternalIcon.spec.mjs.map +0 -1
- package/dist/jsx/ExternalIcon/ExternalIcon.spec.native.js +0 -40
- package/dist/jsx/ExternalIcon/ExternalIcon.spec.native.js.map +0 -1
- package/dist/jsx/Hr/hr.spec.mjs +0 -22
- package/dist/jsx/Hr/hr.spec.mjs.map +0 -1
- package/dist/jsx/Hr/hr.spec.native.js +0 -24
- package/dist/jsx/Hr/hr.spec.native.js.map +0 -1
- package/dist/jsx/Li/li.spec.mjs +0 -46
- package/dist/jsx/Li/li.spec.mjs.map +0 -1
- package/dist/jsx/Li/li.spec.native.js +0 -50
- package/dist/jsx/Li/li.spec.native.js.map +0 -1
- package/dist/jsx/Markdown.stories.mjs +0 -125
- package/dist/jsx/Markdown.stories.mjs.map +0 -1
- package/dist/jsx/Markdown.stories.native.js +0 -162
- package/dist/jsx/Markdown.stories.native.js.map +0 -1
- package/dist/jsx/Mdx/mdx.spec.mjs +0 -140
- package/dist/jsx/Mdx/mdx.spec.mjs.map +0 -1
- package/dist/jsx/Mdx/mdx.spec.native.js +0 -158
- package/dist/jsx/Mdx/mdx.spec.native.js.map +0 -1
- package/dist/jsx/MdxCodeBlock/mdxCodeBlock.spec.mjs +0 -91
- package/dist/jsx/MdxCodeBlock/mdxCodeBlock.spec.mjs.map +0 -1
- package/dist/jsx/MdxCodeBlock/mdxCodeBlock.spec.native.js +0 -122
- package/dist/jsx/MdxCodeBlock/mdxCodeBlock.spec.native.js.map +0 -1
- package/dist/jsx/SimpleTable/index.mjs.map +0 -1
- package/dist/jsx/SimpleTable/index.native.js.map +0 -1
- package/dist/jsx/Ul/ul.spec.mjs +0 -151
- package/dist/jsx/Ul/ul.spec.mjs.map +0 -1
- package/dist/jsx/Ul/ul.spec.native.js +0 -153
- package/dist/jsx/Ul/ul.spec.native.js.map +0 -1
- package/dist/jsx/hooks/useCompileAndEvaluateMdx.spec.mjs +0 -35
- package/dist/jsx/hooks/useCompileAndEvaluateMdx.spec.mjs.map +0 -1
- package/dist/jsx/hooks/useCompileAndEvaluateMdx.spec.native.js +0 -49
- package/dist/jsx/hooks/useCompileAndEvaluateMdx.spec.native.js.map +0 -1
- package/dist/jsx/mdx.spec.mjs +0 -377
- package/dist/jsx/mdx.spec.mjs.map +0 -1
- package/dist/jsx/mdx.spec.native.js +0 -465
- package/dist/jsx/mdx.spec.native.js.map +0 -1
- package/dist/jsx/parser.spec.mjs +0 -110
- package/dist/jsx/parser.spec.mjs.map +0 -1
- package/dist/jsx/parser.spec.native.js +0 -114
- package/dist/jsx/parser.spec.native.js.map +0 -1
- package/dist/jsx/shiki/highlighter.mjs +0 -59
- package/dist/jsx/shiki/highlighter.mjs.map +0 -1
- package/dist/jsx/shiki/highlighter.native.js +0 -94
- package/dist/jsx/shiki/highlighter.native.js.map +0 -1
- package/dist/jsx/util/util.spec.mjs +0 -82
- package/dist/jsx/util/util.spec.mjs.map +0 -1
- package/dist/jsx/util/util.spec.native.js +0 -84
- package/dist/jsx/util/util.spec.native.js.map +0 -1
- package/src/shiki/highlighter.ts +0 -148
|
@@ -0,0 +1,121 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* LC-16 wrapper specs — the markdown package renders code blocks, inline
|
|
3
|
+
* code, and doc tabs through the canonical `@multiplatform.one/components`
|
|
4
|
+
* implementations (census items #9 / #12); these tests pin the wrappers to
|
|
5
|
+
* the canonical anatomy.
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
import { fireEvent, screen, waitFor } from "@testing-library/react";
|
|
9
|
+
import { renderWithProviders } from "@multiplatform.one/test-utils";
|
|
10
|
+
import { Text } from "tamagui";
|
|
11
|
+
import { describe, expect, it } from "vitest";
|
|
12
|
+
import { CodeBlock } from "./CodeBlock";
|
|
13
|
+
import { InlineCode } from "./InlineCode";
|
|
14
|
+
import { MDXTab, MDXTabs } from "../Tabs";
|
|
15
|
+
|
|
16
|
+
describe("markdown CodeBlock (canonical code family)", () => {
|
|
17
|
+
it("renders code content inside a real <code> element", async () => {
|
|
18
|
+
const { container } = renderWithProviders(
|
|
19
|
+
<CodeBlock lang="typescript">{"const x = 1;"}</CodeBlock>,
|
|
20
|
+
);
|
|
21
|
+
expect(container.querySelector("code")).toBeTruthy();
|
|
22
|
+
expect(container.textContent).toContain("const x = 1;");
|
|
23
|
+
});
|
|
24
|
+
|
|
25
|
+
it("tokenizes through the shared shiki stack (colored tokens appear)", async () => {
|
|
26
|
+
const { container } = renderWithProviders(
|
|
27
|
+
<CodeBlock lang="typescript">{"const x = 1;"}</CodeBlock>,
|
|
28
|
+
);
|
|
29
|
+
await waitFor(
|
|
30
|
+
() => {
|
|
31
|
+
const colored = Array.from(container.querySelectorAll("span")).some(
|
|
32
|
+
(el) => el.style.color !== "",
|
|
33
|
+
);
|
|
34
|
+
expect(colored).toBe(true);
|
|
35
|
+
},
|
|
36
|
+
{ timeout: 30000 },
|
|
37
|
+
);
|
|
38
|
+
expect(container.textContent).toContain("const x = 1;");
|
|
39
|
+
}, 35000);
|
|
40
|
+
|
|
41
|
+
it("falls back to plain text for unknown languages", async () => {
|
|
42
|
+
const { container } = renderWithProviders(
|
|
43
|
+
<CodeBlock lang="not-a-real-language">{"plain fallback"}</CodeBlock>,
|
|
44
|
+
);
|
|
45
|
+
await waitFor(() => {
|
|
46
|
+
expect(container.textContent).toContain("plain fallback");
|
|
47
|
+
});
|
|
48
|
+
});
|
|
49
|
+
});
|
|
50
|
+
|
|
51
|
+
describe("markdown InlineCode (canonical CodeInline)", () => {
|
|
52
|
+
it("renders a real <code> element with the content", () => {
|
|
53
|
+
const { container } = renderWithProviders(<InlineCode>npm install</InlineCode>);
|
|
54
|
+
const code = container.querySelector("code");
|
|
55
|
+
expect(code).toBeTruthy();
|
|
56
|
+
expect(code!.textContent).toBe("npm install");
|
|
57
|
+
});
|
|
58
|
+
});
|
|
59
|
+
|
|
60
|
+
describe("MDXTabs (canonical Tabs)", () => {
|
|
61
|
+
const renderTabs = (defaultValue?: string) =>
|
|
62
|
+
renderWithProviders(
|
|
63
|
+
<MDXTabs items={["npm", "pnpm"]} defaultValue={defaultValue}>
|
|
64
|
+
{[
|
|
65
|
+
<MDXTab key="npm">
|
|
66
|
+
<Text>npm panel</Text>
|
|
67
|
+
</MDXTab>,
|
|
68
|
+
<MDXTab key="pnpm">
|
|
69
|
+
<Text>pnpm panel</Text>
|
|
70
|
+
</MDXTab>,
|
|
71
|
+
]}
|
|
72
|
+
</MDXTabs>,
|
|
73
|
+
);
|
|
74
|
+
|
|
75
|
+
it("renders a real tablist with aria-selected tabs", () => {
|
|
76
|
+
renderTabs();
|
|
77
|
+
expect(screen.getByRole("tablist")).toBeInTheDocument();
|
|
78
|
+
const tabs = screen.getAllByRole("tab");
|
|
79
|
+
expect(tabs).toHaveLength(2);
|
|
80
|
+
expect(tabs[0]).toHaveAttribute("aria-selected", "true");
|
|
81
|
+
expect(screen.getByText("npm panel")).toBeInTheDocument();
|
|
82
|
+
});
|
|
83
|
+
|
|
84
|
+
it("switches panels on click", () => {
|
|
85
|
+
renderTabs();
|
|
86
|
+
fireEvent.click(screen.getByText("pnpm"));
|
|
87
|
+
expect(screen.getByText("pnpm panel")).toBeInTheDocument();
|
|
88
|
+
const tabs = screen.getAllByRole("tab");
|
|
89
|
+
expect(tabs[1]).toHaveAttribute("aria-selected", "true");
|
|
90
|
+
});
|
|
91
|
+
|
|
92
|
+
it("respects defaultValue addressed by label", () => {
|
|
93
|
+
renderTabs("pnpm");
|
|
94
|
+
expect(screen.getByText("pnpm panel")).toBeInTheDocument();
|
|
95
|
+
});
|
|
96
|
+
|
|
97
|
+
it("handles duplicate labels via index-suffixed values", () => {
|
|
98
|
+
renderWithProviders(
|
|
99
|
+
<MDXTabs items={["same", "same"]}>
|
|
100
|
+
{[
|
|
101
|
+
<MDXTab key="a">
|
|
102
|
+
<Text>first panel</Text>
|
|
103
|
+
</MDXTab>,
|
|
104
|
+
<MDXTab key="b">
|
|
105
|
+
<Text>second panel</Text>
|
|
106
|
+
</MDXTab>,
|
|
107
|
+
]}
|
|
108
|
+
</MDXTabs>,
|
|
109
|
+
);
|
|
110
|
+
const tabs = screen.getAllByRole("tab");
|
|
111
|
+
expect(tabs).toHaveLength(2);
|
|
112
|
+
fireEvent.click(tabs[1]!);
|
|
113
|
+
expect(screen.getByText("second panel")).toBeInTheDocument();
|
|
114
|
+
});
|
|
115
|
+
|
|
116
|
+
it("renders nothing dangerous for empty items", () => {
|
|
117
|
+
const { container } = renderWithProviders(<MDXTabs items={[]}>{[]}</MDXTabs>);
|
|
118
|
+
expect(container).toBeTruthy();
|
|
119
|
+
expect(screen.queryAllByRole("tab")).toHaveLength(0);
|
|
120
|
+
});
|
|
121
|
+
});
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Doc building-block specs — the MDX-facing blocks docs compose directly:
|
|
3
|
+
* `Video` (web <video> anatomy + SB-M-1227 empty-src omission), `MDXAside`
|
|
4
|
+
* (cutoff + "Show more" expansion) and `MDXNote` (Alert-based note box).
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
import { fireEvent, screen } from "@testing-library/react";
|
|
8
|
+
import { renderWithProviders } from "@multiplatform.one/test-utils";
|
|
9
|
+
import { Text } from "tamagui";
|
|
10
|
+
import { describe, expect, it } from "vitest";
|
|
11
|
+
import { MDXAside, MDXNote } from "./Aside";
|
|
12
|
+
import { Video } from "./Video";
|
|
13
|
+
|
|
14
|
+
describe("Video (web)", () => {
|
|
15
|
+
it("renders a muted, autoplaying, looping inline <video> inside a figure", () => {
|
|
16
|
+
const { container } = renderWithProviders(<Video src="https://example.com/clip.mp4" />);
|
|
17
|
+
expect(container.querySelector("figure")).toBeTruthy();
|
|
18
|
+
const video = container.querySelector("video");
|
|
19
|
+
expect(video).toBeTruthy();
|
|
20
|
+
expect(video!.getAttribute("src")).toBe("https://example.com/clip.mp4");
|
|
21
|
+
// Boolean media attributes reflect the safe-autoplay defaults.
|
|
22
|
+
expect(video!.hasAttribute("autoplay")).toBe(true);
|
|
23
|
+
expect(video!.hasAttribute("loop")).toBe(true);
|
|
24
|
+
expect(video!.hasAttribute("playsinline")).toBe(true);
|
|
25
|
+
expect(video!.hasAttribute("controls")).toBe(false);
|
|
26
|
+
});
|
|
27
|
+
|
|
28
|
+
it("omits the <video> element entirely for an empty src (SB-M-1227)", () => {
|
|
29
|
+
const { container } = renderWithProviders(<Video src="" />);
|
|
30
|
+
expect(container.querySelector("video")).toBeNull();
|
|
31
|
+
expect(container.querySelector("figure")).toBeTruthy();
|
|
32
|
+
});
|
|
33
|
+
|
|
34
|
+
it("forwards controls/poster and renders children as a figcaption", () => {
|
|
35
|
+
const { container } = renderWithProviders(
|
|
36
|
+
<Video src="https://example.com/clip.mp4" controls poster="https://example.com/poster.png">
|
|
37
|
+
A demo caption
|
|
38
|
+
</Video>,
|
|
39
|
+
);
|
|
40
|
+
const video = container.querySelector("video");
|
|
41
|
+
expect(video!.hasAttribute("controls")).toBe(true);
|
|
42
|
+
expect(video!.getAttribute("poster")).toBe("https://example.com/poster.png");
|
|
43
|
+
const caption = container.querySelector("figcaption");
|
|
44
|
+
expect(caption).toBeTruthy();
|
|
45
|
+
expect(caption!.textContent).toBe("A demo caption");
|
|
46
|
+
});
|
|
47
|
+
|
|
48
|
+
it("renders no figcaption without children", () => {
|
|
49
|
+
const { container } = renderWithProviders(<Video src="https://example.com/clip.mp4" />);
|
|
50
|
+
expect(container.querySelector("figcaption")).toBeNull();
|
|
51
|
+
});
|
|
52
|
+
});
|
|
53
|
+
|
|
54
|
+
describe("MDXAside", () => {
|
|
55
|
+
it("renders string content as a plain aside without a cutoff", () => {
|
|
56
|
+
const { container } = renderWithProviders(<MDXAside>just a note</MDXAside>);
|
|
57
|
+
expect(container.querySelector("aside")).toBeTruthy();
|
|
58
|
+
expect(container.textContent).toContain("just a note");
|
|
59
|
+
expect(screen.queryByText("Show more")).toBeNull();
|
|
60
|
+
});
|
|
61
|
+
|
|
62
|
+
it("cuts off unmeasured element content and expands on Show more", () => {
|
|
63
|
+
renderWithProviders(
|
|
64
|
+
<MDXAside>
|
|
65
|
+
<Text>long embedded content</Text>
|
|
66
|
+
</MDXAside>,
|
|
67
|
+
);
|
|
68
|
+
// Content is still rendered inside the clipped container...
|
|
69
|
+
expect(screen.getByText("long embedded content")).toBeTruthy();
|
|
70
|
+
// ...with the expansion affordance visible.
|
|
71
|
+
const showMore = screen.getByText("Show more");
|
|
72
|
+
expect(showMore).toBeTruthy();
|
|
73
|
+
fireEvent.click(showMore);
|
|
74
|
+
expect(screen.queryByText("Show more")).toBeNull();
|
|
75
|
+
expect(screen.getByText("long embedded content")).toBeTruthy();
|
|
76
|
+
});
|
|
77
|
+
});
|
|
78
|
+
|
|
79
|
+
describe("MDXNote", () => {
|
|
80
|
+
it("renders note content inside an aside", () => {
|
|
81
|
+
const { container } = renderWithProviders(<MDXNote>remember this</MDXNote>);
|
|
82
|
+
expect(container.querySelector("aside")).toBeTruthy();
|
|
83
|
+
expect(container.textContent).toContain("remember this");
|
|
84
|
+
});
|
|
85
|
+
});
|
|
@@ -1,5 +1,35 @@
|
|
|
1
1
|
import { useEffect, useState } from "react";
|
|
2
2
|
|
|
3
|
+
const logger = console;
|
|
4
|
+
|
|
5
|
+
const frontmatterRegex = /^---\r?\n([\s\S]*?)\r?\n---\r?\n?/;
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* Minimal browser-safe frontmatter parser (gray-matter depends on Buffer,
|
|
9
|
+
* which does not exist in the browser). Handles simple `key: value` YAML.
|
|
10
|
+
*/
|
|
11
|
+
export function parseFrontmatter(source: string): {
|
|
12
|
+
content: string;
|
|
13
|
+
data: Record<string, any>;
|
|
14
|
+
} {
|
|
15
|
+
const match = source.match(frontmatterRegex);
|
|
16
|
+
if (!match) return { content: source, data: {} };
|
|
17
|
+
const data: Record<string, any> = {};
|
|
18
|
+
for (const line of match[1].split(/\r?\n/)) {
|
|
19
|
+
const separatorIndex = line.indexOf(":");
|
|
20
|
+
if (separatorIndex <= 0) continue;
|
|
21
|
+
const key = line.slice(0, separatorIndex).trim();
|
|
22
|
+
let value: any = line.slice(separatorIndex + 1).trim();
|
|
23
|
+
if (/^(["']).*\1$/.test(value)) value = value.slice(1, -1);
|
|
24
|
+
else if (value === "true") value = true;
|
|
25
|
+
else if (value === "false") value = false;
|
|
26
|
+
else if (value === "null") value = null;
|
|
27
|
+
else if (value !== "" && !Number.isNaN(Number(value))) value = Number(value);
|
|
28
|
+
data[key] = value;
|
|
29
|
+
}
|
|
30
|
+
return { content: source.slice(match[0].length), data };
|
|
31
|
+
}
|
|
32
|
+
|
|
3
33
|
export function useCompileMdx(
|
|
4
34
|
source: string,
|
|
5
35
|
options?: Record<string, any>,
|
|
@@ -11,43 +41,53 @@ export function useCompileMdx(
|
|
|
11
41
|
const [frontmatter, setFrontmatter] = useState<Record<string, any> | undefined>();
|
|
12
42
|
|
|
13
43
|
useEffect(() => {
|
|
44
|
+
let cancelled = false;
|
|
14
45
|
(async () => {
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
46
|
+
try {
|
|
47
|
+
const [
|
|
48
|
+
{ compile },
|
|
49
|
+
{ default: rehypeAutolinkHeadings },
|
|
50
|
+
{ default: rehypeSlug },
|
|
51
|
+
{ default: remarkFrontmatter },
|
|
52
|
+
{ default: remarkMdxFrontmatter },
|
|
53
|
+
{ rehypeMetaAttributes },
|
|
54
|
+
] = await Promise.all([
|
|
55
|
+
import("@mdx-js/mdx"),
|
|
56
|
+
import("rehype-autolink-headings"),
|
|
57
|
+
import("rehype-slug"),
|
|
58
|
+
import("remark-frontmatter"),
|
|
59
|
+
import("remark-mdx-frontmatter"),
|
|
60
|
+
import("../util/rehypeMetaAttributes"),
|
|
61
|
+
]);
|
|
62
|
+
const { value } = await compile(source, {
|
|
63
|
+
...options,
|
|
64
|
+
development: false,
|
|
65
|
+
outputFormat: "function-body",
|
|
66
|
+
remarkPlugins: [
|
|
67
|
+
...(options?.remarkPlugins || []),
|
|
68
|
+
[remarkMdxFrontmatter, { name: "frontmatter" }],
|
|
69
|
+
remarkFrontmatter,
|
|
70
|
+
],
|
|
71
|
+
rehypePlugins: [
|
|
72
|
+
...(options?.rehypePlugins || []),
|
|
73
|
+
rehypeAutolinkHeadings,
|
|
74
|
+
rehypeMetaAttributes,
|
|
75
|
+
rehypeSlug,
|
|
76
|
+
],
|
|
77
|
+
});
|
|
78
|
+
if (cancelled) return;
|
|
79
|
+
setCode(value.toString());
|
|
80
|
+
setFrontmatter(parseFrontmatter(source));
|
|
81
|
+
} catch (err) {
|
|
82
|
+
if (cancelled) return;
|
|
83
|
+
logger.error("useCompileMdx: failed to compile MDX source", err);
|
|
84
|
+
setCode(undefined);
|
|
85
|
+
setFrontmatter(undefined);
|
|
86
|
+
}
|
|
50
87
|
})();
|
|
88
|
+
return () => {
|
|
89
|
+
cancelled = true;
|
|
90
|
+
};
|
|
51
91
|
}, [source, options]);
|
|
52
92
|
|
|
53
93
|
if (!code || !frontmatter) return {};
|
|
@@ -8,7 +8,13 @@ export function useEvaluateMdx(code?: string, options?: Record<string, any>) {
|
|
|
8
8
|
|
|
9
9
|
useEffect(() => {
|
|
10
10
|
if (!code) return;
|
|
11
|
-
|
|
11
|
+
try {
|
|
12
|
+
const Evaluated = evaluateMdx(code, options);
|
|
13
|
+
setComponent(() => Evaluated);
|
|
14
|
+
} catch (err) {
|
|
15
|
+
console.error("useEvaluateMdx: failed to evaluate compiled MDX", err);
|
|
16
|
+
setComponent(undefined);
|
|
17
|
+
}
|
|
12
18
|
}, [code, options]);
|
|
13
19
|
|
|
14
20
|
return Component;
|
package/src/icons/index.tsx
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Circle,
|
|
1
|
+
import { Circle, Path, Rect, Svg } from "@tamagui/react-native-svg";
|
|
2
2
|
import { useTheme } from "tamagui";
|
|
3
3
|
|
|
4
4
|
interface IconProps {
|
|
@@ -6,9 +6,20 @@ interface IconProps {
|
|
|
6
6
|
color?: string;
|
|
7
7
|
}
|
|
8
8
|
|
|
9
|
-
|
|
9
|
+
/**
|
|
10
|
+
* Resolve theme tokens like "$color10" to concrete values — raw SVG stroke
|
|
11
|
+
* attributes cannot consume unresolved token strings (SB-M-1206).
|
|
12
|
+
*/
|
|
13
|
+
function useIconColor(color?: string): string {
|
|
10
14
|
const theme = useTheme();
|
|
11
|
-
|
|
15
|
+
if (color?.startsWith("$")) {
|
|
16
|
+
return (theme as any)[color.slice(1)]?.val ?? theme.color?.val ?? "currentColor";
|
|
17
|
+
}
|
|
18
|
+
return color ?? theme.color?.val ?? "currentColor";
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
export function ClipboardIcon({ size = 16, color }: IconProps) {
|
|
22
|
+
const fill = useIconColor(color);
|
|
12
23
|
return (
|
|
13
24
|
<Svg width={size} height={size} viewBox="0 0 24 24" fill="none">
|
|
14
25
|
<Rect x="9" y="2" width="6" height="4" rx="1" stroke={fill} strokeWidth={2} />
|
|
@@ -21,16 +32,18 @@ export function ClipboardIcon({ size = 16, color }: IconProps) {
|
|
|
21
32
|
);
|
|
22
33
|
}
|
|
23
34
|
|
|
24
|
-
export function
|
|
25
|
-
|
|
26
|
-
|
|
35
|
+
export function CheckIcon({
|
|
36
|
+
size = 16,
|
|
37
|
+
color,
|
|
38
|
+
strokeWidth = 2.5,
|
|
39
|
+
}: IconProps & { strokeWidth?: number }) {
|
|
40
|
+
const stroke = useIconColor(color);
|
|
27
41
|
return (
|
|
28
42
|
<Svg width={size} height={size} viewBox="0 0 24 24" fill="none">
|
|
29
|
-
<Circle cx="12" cy="12" r="10" stroke={fill} strokeWidth={2} />
|
|
30
43
|
<Path
|
|
31
|
-
d="
|
|
32
|
-
stroke={
|
|
33
|
-
strokeWidth={
|
|
44
|
+
d="M4.5 12.75l5.25 5.25L19.5 7.5"
|
|
45
|
+
stroke={stroke}
|
|
46
|
+
strokeWidth={strokeWidth}
|
|
34
47
|
strokeLinecap="round"
|
|
35
48
|
strokeLinejoin="round"
|
|
36
49
|
/>
|
|
@@ -38,20 +51,13 @@ export function CheckCircleIcon({ size = 16, color }: IconProps) {
|
|
|
38
51
|
);
|
|
39
52
|
}
|
|
40
53
|
|
|
41
|
-
export function
|
|
42
|
-
const
|
|
43
|
-
const fill = color ?? theme.color?.val ?? "currentColor";
|
|
54
|
+
export function CheckCircleIcon({ size = 16, color }: IconProps) {
|
|
55
|
+
const fill = useIconColor(color);
|
|
44
56
|
return (
|
|
45
57
|
<Svg width={size} height={size} viewBox="0 0 24 24" fill="none">
|
|
58
|
+
<Circle cx="12" cy="12" r="10" stroke={fill} strokeWidth={2} />
|
|
46
59
|
<Path
|
|
47
|
-
d="
|
|
48
|
-
stroke={fill}
|
|
49
|
-
strokeWidth={2}
|
|
50
|
-
strokeLinecap="round"
|
|
51
|
-
strokeLinejoin="round"
|
|
52
|
-
/>
|
|
53
|
-
<Path
|
|
54
|
-
d="M14 11a5 5 0 0 0-7.54-.54l-3 3a5 5 0 0 0 7.07 7.07l1.71-1.71"
|
|
60
|
+
d="M9 12l2 2 4-4"
|
|
55
61
|
stroke={fill}
|
|
56
62
|
strokeWidth={2}
|
|
57
63
|
strokeLinecap="round"
|
|
@@ -61,51 +67,19 @@ export function LinkIcon({ size = 12, color }: IconProps) {
|
|
|
61
67
|
);
|
|
62
68
|
}
|
|
63
69
|
|
|
64
|
-
export function
|
|
65
|
-
const
|
|
66
|
-
const fill = color ?? theme.color?.val ?? "currentColor";
|
|
70
|
+
export function LinkIcon({ size = 12, color }: IconProps) {
|
|
71
|
+
const fill = useIconColor(color);
|
|
67
72
|
return (
|
|
68
73
|
<Svg width={size} height={size} viewBox="0 0 24 24" fill="none">
|
|
69
74
|
<Path
|
|
70
|
-
d="M10
|
|
75
|
+
d="M10 13a5 5 0 0 0 7.54.54l3-3a5 5 0 0 0-7.07-7.07l-1.72 1.71"
|
|
71
76
|
stroke={fill}
|
|
72
77
|
strokeWidth={2}
|
|
73
78
|
strokeLinecap="round"
|
|
74
79
|
strokeLinejoin="round"
|
|
75
80
|
/>
|
|
76
|
-
<
|
|
77
|
-
|
|
78
|
-
x1="12"
|
|
79
|
-
y1="17"
|
|
80
|
-
x2="12.01"
|
|
81
|
-
y2="17"
|
|
82
|
-
stroke={fill}
|
|
83
|
-
strokeWidth={2}
|
|
84
|
-
strokeLinecap="round"
|
|
85
|
-
/>
|
|
86
|
-
</Svg>
|
|
87
|
-
);
|
|
88
|
-
}
|
|
89
|
-
|
|
90
|
-
export function InfoIcon({ size = 16, color }: IconProps) {
|
|
91
|
-
const theme = useTheme();
|
|
92
|
-
const fill = color ?? theme.color?.val ?? "currentColor";
|
|
93
|
-
return (
|
|
94
|
-
<Svg width={size} height={size} viewBox="0 0 24 24" fill="none">
|
|
95
|
-
<Circle cx="12" cy="12" r="10" stroke={fill} strokeWidth={2} />
|
|
96
|
-
<Line x1="12" y1="16" x2="12" y2="12" stroke={fill} strokeWidth={2} strokeLinecap="round" />
|
|
97
|
-
<Line x1="12" y1="8" x2="12.01" y2="8" stroke={fill} strokeWidth={2} strokeLinecap="round" />
|
|
98
|
-
</Svg>
|
|
99
|
-
);
|
|
100
|
-
}
|
|
101
|
-
|
|
102
|
-
export function ChevronRightIcon({ size = 16, color }: IconProps) {
|
|
103
|
-
const theme = useTheme();
|
|
104
|
-
const fill = color ?? theme.color?.val ?? "currentColor";
|
|
105
|
-
return (
|
|
106
|
-
<Svg width={size} height={size} viewBox="0 0 24 24" fill="none">
|
|
107
|
-
<Polyline
|
|
108
|
-
points="9,18 15,12 9,6"
|
|
81
|
+
<Path
|
|
82
|
+
d="M14 11a5 5 0 0 0-7.54-.54l-3 3a5 5 0 0 0 7.07 7.07l1.71-1.71"
|
|
109
83
|
stroke={fill}
|
|
110
84
|
strokeWidth={2}
|
|
111
85
|
strokeLinecap="round"
|
|
@@ -114,3 +88,7 @@ export function ChevronRightIcon({ size = 16, color }: IconProps) {
|
|
|
114
88
|
</Svg>
|
|
115
89
|
);
|
|
116
90
|
}
|
|
91
|
+
|
|
92
|
+
// AlertTriangleIcon / InfoIcon / ChevronRightIcon were removed in the
|
|
93
|
+
// duplication census: they duplicated the catalog's intent icons and were
|
|
94
|
+
// orphaned when markdown's Notice was replaced by the catalog Alert.
|
package/src/index.ts
CHANGED
|
@@ -12,8 +12,20 @@ export type { MarkdownProps, CodeTheme } from "./types";
|
|
|
12
12
|
export { parseMarkdown } from "./parser";
|
|
13
13
|
export { renderMarkdown } from "./renderer";
|
|
14
14
|
|
|
15
|
-
//
|
|
16
|
-
|
|
15
|
+
// Mermaid diagrams — canonical lazy renderer (LC-16), shared with the
|
|
16
|
+
// rich-text editor's live code-block preview (which imports the
|
|
17
|
+
// dependency-free "./mermaid" subpath instead of this barrel)
|
|
18
|
+
export * from "./mermaid";
|
|
19
|
+
export { MermaidBlock, type MermaidBlockProps } from "./mermaid/MermaidBlock";
|
|
20
|
+
|
|
21
|
+
// Shiki syntax highlighting — canonical stack lives in
|
|
22
|
+
// @multiplatform.one/components (LC-16); re-exported for compatibility.
|
|
23
|
+
export {
|
|
24
|
+
highlightCode,
|
|
25
|
+
type HighlightLine,
|
|
26
|
+
type HighlightToken,
|
|
27
|
+
} from "@multiplatform.one/components";
|
|
28
|
+
export type { BundledLanguage, BundledTheme } from "shiki";
|
|
17
29
|
|
|
18
30
|
// MDX components
|
|
19
31
|
export * from "./Aside";
|
|
@@ -22,11 +34,11 @@ export * from "./hooks";
|
|
|
22
34
|
export * from "./Hr";
|
|
23
35
|
export * from "./icons";
|
|
24
36
|
export * from "./Li";
|
|
37
|
+
export * from "./MarkdownSimpleTable";
|
|
25
38
|
export * from "./Mdx";
|
|
26
39
|
export * from "./MdxCodeBlock";
|
|
27
40
|
export * from "./mdxComponents";
|
|
28
41
|
export * from "./Notice";
|
|
29
|
-
export * from "./SimpleTable";
|
|
30
42
|
export * from "./Table";
|
|
31
43
|
export * from "./Tabs";
|
|
32
44
|
export * from "./Ul";
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* <Markdown> component specs — the string-in, UI-out entry point. Locks down:
|
|
3
|
+
* string children parse + render, non-string children render nothing instead
|
|
4
|
+
* of crashing, and custom components reach the renderer.
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
import { renderWithProviders } from "@multiplatform.one/test-utils";
|
|
8
|
+
import { Text, View } from "tamagui";
|
|
9
|
+
import { describe, expect, it } from "vitest";
|
|
10
|
+
import { Markdown } from "./Markdown";
|
|
11
|
+
|
|
12
|
+
describe("Markdown", () => {
|
|
13
|
+
it("parses and renders a markdown string", () => {
|
|
14
|
+
const { container } = renderWithProviders(
|
|
15
|
+
<Markdown>{"# Hello\n\nSome **bold** text."}</Markdown>,
|
|
16
|
+
);
|
|
17
|
+
expect(container.querySelector("h1")?.textContent).toBe("Hello");
|
|
18
|
+
expect(container.querySelector("strong")?.textContent).toBe("bold");
|
|
19
|
+
});
|
|
20
|
+
|
|
21
|
+
it("renders nothing (no crash) for non-string children", () => {
|
|
22
|
+
// Consumers sometimes pass elements by mistake; cast to exercise that path.
|
|
23
|
+
const notMarkdown = (
|
|
24
|
+
<View>
|
|
25
|
+
<Text>not markdown</Text>
|
|
26
|
+
</View>
|
|
27
|
+
) as unknown as string;
|
|
28
|
+
const { container } = renderWithProviders(<Markdown>{notMarkdown}</Markdown>);
|
|
29
|
+
expect(container.textContent).not.toContain("not markdown");
|
|
30
|
+
});
|
|
31
|
+
|
|
32
|
+
it("renders nothing for empty children", () => {
|
|
33
|
+
const { container } = renderWithProviders(<Markdown>{""}</Markdown>);
|
|
34
|
+
expect(container.querySelector("h1")).toBeNull();
|
|
35
|
+
expect(container.querySelector("p")).toBeNull();
|
|
36
|
+
});
|
|
37
|
+
|
|
38
|
+
it("threads custom components through to the renderer", () => {
|
|
39
|
+
const { getByTestId } = renderWithProviders(
|
|
40
|
+
<Markdown
|
|
41
|
+
components={{
|
|
42
|
+
h1: ({ children }) => <Text data-testid="branded-h1">{children}</Text>,
|
|
43
|
+
}}
|
|
44
|
+
>
|
|
45
|
+
{"# Branded"}
|
|
46
|
+
</Markdown>,
|
|
47
|
+
);
|
|
48
|
+
expect(getByTestId("branded-h1").textContent).toBe("Branded");
|
|
49
|
+
});
|
|
50
|
+
|
|
51
|
+
it("spreads extra view props onto the wrapper", () => {
|
|
52
|
+
const { getByTestId } = renderWithProviders(
|
|
53
|
+
<Markdown data-testid="md-root">{"content"}</Markdown>,
|
|
54
|
+
);
|
|
55
|
+
expect(getByTestId("md-root")).toBeTruthy();
|
|
56
|
+
expect(getByTestId("md-root").textContent).toContain("content");
|
|
57
|
+
});
|
|
58
|
+
});
|
package/src/mdx.spec.tsx
CHANGED
|
@@ -110,6 +110,10 @@ vi.mock("@tamagui/react-native-svg", () => ({
|
|
|
110
110
|
Line: (props: any) => <line {...props} />,
|
|
111
111
|
Rect: (props: any) => <rect {...props} />,
|
|
112
112
|
Polyline: (props: any) => <polyline {...props} />,
|
|
113
|
+
// The components barrel (now in this spec's graph via the LC-16 code/tabs
|
|
114
|
+
// wrappers) pulls charts/svg.ts, which also needs G and Text.
|
|
115
|
+
G: ({ children, ...props }: any) => <g {...props}>{children}</g>,
|
|
116
|
+
Text: ({ children, ...props }: any) => <text {...props}>{children}</text>,
|
|
113
117
|
}));
|
|
114
118
|
|
|
115
119
|
describe("MDX Components", () => {
|