markdown-flow-ui 0.2.13 → 0.2.15
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 +7 -0
- package/dist/_virtual/index.es3.js +5 -4
- package/dist/_virtual/index.es3.js.map +1 -1
- package/dist/_virtual/index.es4.js +4 -5
- package/dist/_virtual/index.es4.js.map +1 -1
- package/dist/_virtual/index3.cjs +1 -1
- package/dist/_virtual/index4.cjs +1 -1
- package/dist/assets/markdown-flow-ui.css +10 -1
- package/dist/components/ContentRender/CodeBlock.cjs +1 -1
- package/dist/components/ContentRender/CodeBlock.cjs.map +1 -1
- package/dist/components/ContentRender/CodeBlock.d.ts +5 -0
- package/dist/components/ContentRender/CodeBlock.es.js +41 -38
- package/dist/components/ContentRender/CodeBlock.es.js.map +1 -1
- package/dist/components/ContentRender/ContentRender.cjs +2 -2
- package/dist/components/ContentRender/ContentRender.cjs.map +1 -1
- package/dist/components/ContentRender/ContentRender.d.ts +9 -4
- package/dist/components/ContentRender/ContentRender.es.js +389 -298
- package/dist/components/ContentRender/ContentRender.es.js.map +1 -1
- package/dist/components/ContentRender/IframeSandbox.cjs +7 -7
- package/dist/components/ContentRender/IframeSandbox.cjs.map +1 -1
- package/dist/components/ContentRender/IframeSandbox.d.ts +5 -1
- package/dist/components/ContentRender/IframeSandbox.es.js +311 -266
- package/dist/components/ContentRender/IframeSandbox.es.js.map +1 -1
- package/dist/components/ContentRender/MarkdownFlowInput.cjs +1 -1
- package/dist/components/ContentRender/MarkdownFlowInput.cjs.map +1 -1
- package/dist/components/ContentRender/MarkdownFlowInput.d.ts +5 -1
- package/dist/components/ContentRender/MarkdownFlowInput.es.js +37 -32
- package/dist/components/ContentRender/MarkdownFlowInput.es.js.map +1 -1
- package/dist/components/ContentRender/SandboxApp.cjs +2 -2
- package/dist/components/ContentRender/SandboxApp.cjs.map +1 -1
- package/dist/components/ContentRender/SandboxApp.d.ts +5 -1
- package/dist/components/ContentRender/SandboxApp.es.js +108 -103
- package/dist/components/ContentRender/SandboxApp.es.js.map +1 -1
- package/dist/components/ContentRender/blackboard-vendor.d.ts +1 -1
- package/dist/components/ContentRender/contentRenderI18n.cjs +1 -1
- package/dist/components/ContentRender/contentRenderI18n.cjs.map +1 -1
- package/dist/components/ContentRender/contentRenderI18n.d.ts +6 -1
- package/dist/components/ContentRender/contentRenderI18n.es.js +5 -56
- package/dist/components/ContentRender/contentRenderI18n.es.js.map +1 -1
- package/dist/components/ContentRender/contentRenderI18n.test.d.ts +1 -0
- package/dist/components/ContentRender/index.cjs +1 -1
- package/dist/components/ContentRender/index.d.ts +11 -11
- package/dist/components/ContentRender/index.es.js +1 -2
- package/dist/components/ContentRender/index.es.js.map +1 -1
- package/dist/components/ContentRender/locales/contentRender.json.cjs +2 -0
- package/dist/components/ContentRender/locales/contentRender.json.cjs.map +1 -0
- package/dist/components/ContentRender/locales/contentRender.json.d.ts +90 -0
- package/dist/components/ContentRender/locales/contentRender.json.es.js +11 -0
- package/dist/components/ContentRender/locales/contentRender.json.es.js.map +1 -0
- package/dist/components/ContentRender/plugins/CustomVariable.cjs +1 -1
- package/dist/components/ContentRender/plugins/CustomVariable.cjs.map +1 -1
- package/dist/components/ContentRender/plugins/CustomVariable.d.ts +7 -3
- package/dist/components/ContentRender/plugins/CustomVariable.es.js +165 -151
- package/dist/components/ContentRender/plugins/CustomVariable.es.js.map +1 -1
- package/dist/components/ContentRender/plugins/MermaidChart.cjs +1 -1
- package/dist/components/ContentRender/plugins/MermaidChart.cjs.map +1 -1
- package/dist/components/ContentRender/plugins/MermaidChart.d.ts +1 -0
- package/dist/components/ContentRender/plugins/MermaidChart.es.js +68 -44
- package/dist/components/ContentRender/plugins/MermaidChart.es.js.map +1 -1
- package/dist/components/MarkdownFlow/MarkdownFlow.cjs +1 -1
- package/dist/components/MarkdownFlow/MarkdownFlow.cjs.map +1 -1
- package/dist/components/MarkdownFlow/MarkdownFlow.d.ts +12 -4
- package/dist/components/MarkdownFlow/MarkdownFlow.es.js +51 -39
- package/dist/components/MarkdownFlow/MarkdownFlow.es.js.map +1 -1
- package/dist/components/MarkdownFlow/ScrollToBottomButton.cjs +1 -1
- package/dist/components/MarkdownFlow/ScrollToBottomButton.cjs.map +1 -1
- package/dist/components/MarkdownFlow/ScrollToBottomButton.d.ts +31 -1
- package/dist/components/MarkdownFlow/ScrollToBottomButton.es.js +46 -17
- package/dist/components/MarkdownFlow/ScrollToBottomButton.es.js.map +1 -1
- package/dist/components/MarkdownFlow/ScrollToBottomControl.cjs +2 -0
- package/dist/components/MarkdownFlow/ScrollToBottomControl.cjs.map +1 -0
- package/dist/components/MarkdownFlow/ScrollToBottomControl.d.ts +18 -0
- package/dist/components/MarkdownFlow/ScrollToBottomControl.es.js +47 -0
- package/dist/components/MarkdownFlow/ScrollToBottomControl.es.js.map +1 -0
- package/dist/components/MarkdownFlow/ScrollableMarkdownFlow.cjs +1 -1
- package/dist/components/MarkdownFlow/ScrollableMarkdownFlow.cjs.map +1 -1
- package/dist/components/MarkdownFlow/ScrollableMarkdownFlow.d.ts +1 -1
- package/dist/components/MarkdownFlow/ScrollableMarkdownFlow.es.js +33 -52
- package/dist/components/MarkdownFlow/ScrollableMarkdownFlow.es.js.map +1 -1
- package/dist/components/MarkdownFlow/index.cjs +1 -1
- package/dist/components/MarkdownFlow/index.d.ts +9 -6
- package/dist/components/MarkdownFlow/index.es.js +6 -6
- package/dist/components/MarkdownFlow/index.es.js.map +1 -1
- package/dist/components/MarkdownFlow/useScrollToBottom.cjs +1 -1
- package/dist/components/MarkdownFlow/useScrollToBottom.cjs.map +1 -1
- package/dist/components/MarkdownFlow/useScrollToBottom.d.ts +40 -8
- package/dist/components/MarkdownFlow/useScrollToBottom.es.js +352 -83
- package/dist/components/MarkdownFlow/useScrollToBottom.es.js.map +1 -1
- package/dist/components/MarkdownFlowEditor/MarkdownFlowEditor.cjs +1 -1
- package/dist/components/MarkdownFlowEditor/MarkdownFlowEditor.cjs.map +1 -1
- package/dist/components/MarkdownFlowEditor/MarkdownFlowEditor.d.ts +5 -3
- package/dist/components/MarkdownFlowEditor/MarkdownFlowEditor.es.js +371 -324
- package/dist/components/MarkdownFlowEditor/MarkdownFlowEditor.es.js.map +1 -1
- package/dist/components/MarkdownFlowEditor/components/CustomDialog.cjs +1 -1
- package/dist/components/MarkdownFlowEditor/components/CustomDialog.cjs.map +1 -1
- package/dist/components/MarkdownFlowEditor/components/CustomDialog.d.ts +10 -0
- package/dist/components/MarkdownFlowEditor/components/CustomDialog.es.js +22 -19
- package/dist/components/MarkdownFlowEditor/components/CustomDialog.es.js.map +1 -1
- package/dist/components/MarkdownFlowEditor/components/CustomPopover.cjs +1 -1
- package/dist/components/MarkdownFlowEditor/components/CustomPopover.cjs.map +1 -1
- package/dist/components/MarkdownFlowEditor/components/CustomPopover.d.ts +8 -0
- package/dist/components/MarkdownFlowEditor/components/CustomPopover.es.js +19 -15
- package/dist/components/MarkdownFlowEditor/components/CustomPopover.es.js.map +1 -1
- package/dist/components/MarkdownFlowEditor/components/EditorToolbar.cjs +1 -1
- package/dist/components/MarkdownFlowEditor/components/EditorToolbar.cjs.map +1 -1
- package/dist/components/MarkdownFlowEditor/components/EditorToolbar.d.ts +4 -1
- package/dist/components/MarkdownFlowEditor/components/EditorToolbar.es.js +99 -93
- package/dist/components/MarkdownFlowEditor/components/EditorToolbar.es.js.map +1 -1
- package/dist/components/MarkdownFlowEditor/components/ImageInject.cjs +1 -1
- package/dist/components/MarkdownFlowEditor/components/ImageInject.cjs.map +1 -1
- package/dist/components/MarkdownFlowEditor/components/ImageInject.d.ts +1 -1
- package/dist/components/MarkdownFlowEditor/components/ImageInject.es.js +183 -182
- package/dist/components/MarkdownFlowEditor/components/ImageInject.es.js.map +1 -1
- package/dist/components/MarkdownFlowEditor/components/VariableSearchDropdown.cjs +1 -1
- package/dist/components/MarkdownFlowEditor/components/VariableSearchDropdown.cjs.map +1 -1
- package/dist/components/MarkdownFlowEditor/components/VariableSearchDropdown.d.ts +1 -1
- package/dist/components/MarkdownFlowEditor/components/VariableSearchDropdown.es.js +107 -103
- package/dist/components/MarkdownFlowEditor/components/VariableSearchDropdown.es.js.map +1 -1
- package/dist/components/MarkdownFlowEditor/components/VariableSelect.cjs +1 -1
- package/dist/components/MarkdownFlowEditor/components/VariableSelect.cjs.map +1 -1
- package/dist/components/MarkdownFlowEditor/components/VariableSelect.d.ts +1 -1
- package/dist/components/MarkdownFlowEditor/components/VariableSelect.es.js +106 -106
- package/dist/components/MarkdownFlowEditor/components/VariableSelect.es.js.map +1 -1
- package/dist/components/MarkdownFlowEditor/components/VideoInject.cjs +1 -1
- package/dist/components/MarkdownFlowEditor/components/VideoInject.cjs.map +1 -1
- package/dist/components/MarkdownFlowEditor/components/VideoInject.es.js +64 -63
- package/dist/components/MarkdownFlowEditor/components/VideoInject.es.js.map +1 -1
- package/dist/components/MarkdownFlowEditor/components/icons/ButtonIcon.cjs +1 -1
- package/dist/components/MarkdownFlowEditor/components/icons/ButtonIcon.cjs.map +1 -1
- package/dist/components/MarkdownFlowEditor/components/icons/ButtonIcon.es.js +13 -13
- package/dist/components/MarkdownFlowEditor/components/icons/ButtonIcon.es.js.map +1 -1
- package/dist/components/MarkdownFlowEditor/components/icons/SearchBracesIcon.cjs +1 -1
- package/dist/components/MarkdownFlowEditor/components/icons/SearchBracesIcon.cjs.map +1 -1
- package/dist/components/MarkdownFlowEditor/components/icons/SearchBracesIcon.es.js +12 -12
- package/dist/components/MarkdownFlowEditor/components/icons/SearchBracesIcon.es.js.map +1 -1
- package/dist/components/MarkdownFlowEditor/editor-context.d.ts +1 -1
- package/dist/components/MarkdownFlowEditor/editorI18n.cjs +1 -1
- package/dist/components/MarkdownFlowEditor/editorI18n.cjs.map +1 -1
- package/dist/components/MarkdownFlowEditor/editorI18n.d.ts +290 -0
- package/dist/components/MarkdownFlowEditor/editorI18n.es.js +12 -8
- package/dist/components/MarkdownFlowEditor/editorI18n.es.js.map +1 -1
- package/dist/components/MarkdownFlowEditor/editorI18n.test.d.ts +1 -0
- package/dist/components/MarkdownFlowEditor/index.d.ts +6 -6
- package/dist/components/MarkdownFlowEditor/locales/ar-SA.json.cjs +2 -0
- package/dist/components/MarkdownFlowEditor/locales/ar-SA.json.cjs.map +1 -0
- package/dist/components/MarkdownFlowEditor/locales/ar-SA.json.d.ts +72 -0
- package/dist/components/MarkdownFlowEditor/locales/ar-SA.json.es.js +140 -0
- package/dist/components/MarkdownFlowEditor/locales/ar-SA.json.es.js.map +1 -0
- package/dist/components/MarkdownFlowEditor/locales/en-US.json.cjs +1 -1
- package/dist/components/MarkdownFlowEditor/locales/en-US.json.d.ts +2 -0
- package/dist/components/MarkdownFlowEditor/locales/en-US.json.es.js +118 -114
- package/dist/components/MarkdownFlowEditor/locales/en-US.json.es.js.map +1 -1
- package/dist/components/MarkdownFlowEditor/locales/fr-FR.json.cjs +1 -1
- package/dist/components/MarkdownFlowEditor/locales/fr-FR.json.d.ts +2 -0
- package/dist/components/MarkdownFlowEditor/locales/fr-FR.json.es.js +118 -114
- package/dist/components/MarkdownFlowEditor/locales/fr-FR.json.es.js.map +1 -1
- package/dist/components/MarkdownFlowEditor/locales/th-TH.json.cjs +2 -0
- package/dist/components/MarkdownFlowEditor/locales/th-TH.json.cjs.map +1 -0
- package/dist/components/MarkdownFlowEditor/locales/th-TH.json.d.ts +72 -0
- package/dist/components/MarkdownFlowEditor/locales/th-TH.json.es.js +140 -0
- package/dist/components/MarkdownFlowEditor/locales/th-TH.json.es.js.map +1 -0
- package/dist/components/MarkdownFlowEditor/locales/zh-CN.json.cjs +1 -1
- package/dist/components/MarkdownFlowEditor/locales/zh-CN.json.d.ts +2 -0
- package/dist/components/MarkdownFlowEditor/locales/zh-CN.json.es.js +70 -66
- package/dist/components/MarkdownFlowEditor/locales/zh-CN.json.es.js.map +1 -1
- package/dist/components/MarkdownFlowEditor/plugins/ImgPlaceholder.cjs +1 -1
- package/dist/components/MarkdownFlowEditor/plugins/ImgPlaceholder.cjs.map +1 -1
- package/dist/components/MarkdownFlowEditor/plugins/ImgPlaceholder.es.js +40 -35
- package/dist/components/MarkdownFlowEditor/plugins/ImgPlaceholder.es.js.map +1 -1
- package/dist/components/MarkdownFlowEditor/plugins/PlaceholderWidget.d.ts +1 -1
- package/dist/components/MarkdownFlowEditor/plugins/VideoPlaceholder.cjs +1 -1
- package/dist/components/MarkdownFlowEditor/plugins/VideoPlaceholder.cjs.map +1 -1
- package/dist/components/MarkdownFlowEditor/plugins/VideoPlaceholder.es.js +27 -23
- package/dist/components/MarkdownFlowEditor/plugins/VideoPlaceholder.es.js.map +1 -1
- package/dist/components/MarkdownFlowEditor/plugins/mediaPlaceholderLabels.cjs +2 -0
- package/dist/components/MarkdownFlowEditor/plugins/mediaPlaceholderLabels.cjs.map +1 -0
- package/dist/components/MarkdownFlowEditor/plugins/mediaPlaceholderLabels.d.ts +7 -0
- package/dist/components/MarkdownFlowEditor/plugins/mediaPlaceholderLabels.es.js +12 -0
- package/dist/components/MarkdownFlowEditor/plugins/mediaPlaceholderLabels.es.js.map +1 -0
- package/dist/components/MarkdownFlowEditor/utils.d.ts +1 -1
- package/dist/components/Slide/MarkdownSlideScaling.cjs +1 -1
- package/dist/components/Slide/MarkdownSlideScaling.cjs.map +1 -1
- package/dist/components/Slide/MarkdownSlideScaling.d.ts +1 -1
- package/dist/components/Slide/MarkdownSlideScaling.es.js +20 -20
- package/dist/components/Slide/MarkdownSlideScaling.es.js.map +1 -1
- package/dist/components/Slide/MobilePlayerSettingsSheet.cjs +1 -1
- package/dist/components/Slide/MobilePlayerSettingsSheet.cjs.map +1 -1
- package/dist/components/Slide/MobilePlayerSettingsSheet.d.ts +7 -2
- package/dist/components/Slide/MobilePlayerSettingsSheet.es.js +61 -57
- package/dist/components/Slide/MobilePlayerSettingsSheet.es.js.map +1 -1
- package/dist/components/Slide/Player.cjs +1 -1
- package/dist/components/Slide/Player.cjs.map +1 -1
- package/dist/components/Slide/Player.d.ts +6 -6
- package/dist/components/Slide/Player.es.js +547 -541
- package/dist/components/Slide/Player.es.js.map +1 -1
- package/dist/components/Slide/Slide.cjs +1 -1
- package/dist/components/Slide/Slide.cjs.map +1 -1
- package/dist/components/Slide/Slide.d.ts +14 -12
- package/dist/components/Slide/Slide.es.js +745 -726
- package/dist/components/Slide/Slide.es.js.map +1 -1
- package/dist/components/Slide/SubtitleOverlay.cjs +1 -1
- package/dist/components/Slide/SubtitleOverlay.cjs.map +1 -1
- package/dist/components/Slide/SubtitleOverlay.d.ts +2 -2
- package/dist/components/Slide/SubtitleOverlay.es.js +17 -17
- package/dist/components/Slide/SubtitleOverlay.es.js.map +1 -1
- package/dist/components/Slide/diff-utils.d.ts +1 -1
- package/dist/components/Slide/index.d.ts +12 -12
- package/dist/components/Slide/locales/slide.json.cjs +2 -0
- package/dist/components/Slide/locales/slide.json.cjs.map +1 -0
- package/dist/components/Slide/locales/slide.json.d.ts +205 -0
- package/dist/components/Slide/locales/slide.json.es.js +11 -0
- package/dist/components/Slide/locales/slide.json.es.js.map +1 -0
- package/dist/components/Slide/slideI18n.cjs +1 -1
- package/dist/components/Slide/slideI18n.cjs.map +1 -1
- package/dist/components/Slide/slideI18n.d.ts +6 -3
- package/dist/components/Slide/slideI18n.es.js +10 -155
- package/dist/components/Slide/slideI18n.es.js.map +1 -1
- package/dist/components/Slide/useSlide.d.ts +1 -1
- package/dist/components/Slide/utils/appendedMarkerAdvance.d.ts +1 -1
- package/dist/components/Slide/utils/audioSegments.d.ts +1 -1
- package/dist/components/Slide/utils/interactionResolution.d.ts +2 -2
- package/dist/components/Slide/utils/listenModeElementList.d.ts +2 -2
- package/dist/components/Slide/utils/markdownScaling.d.ts +1 -1
- package/dist/components/Slide/utils/playerCustomActions.d.ts +2 -2
- package/dist/components/Slide/utils/playerKeyboardShortcuts.cjs +1 -1
- package/dist/components/Slide/utils/playerKeyboardShortcuts.cjs.map +1 -1
- package/dist/components/Slide/utils/playerKeyboardShortcuts.d.ts +1 -1
- package/dist/components/Slide/utils/playerKeyboardShortcuts.es.js +20 -20
- package/dist/components/Slide/utils/playerKeyboardShortcuts.es.js.map +1 -1
- package/dist/components/Slide/utils/runStreamFixture.d.ts +1 -1
- package/dist/components/Slide/utils/segmentSeek.d.ts +1 -1
- package/dist/components/Slide/utils/silentStepAutoAdvance.d.ts +1 -1
- package/dist/components/Slide/utils/streamingNavigation.d.ts +1 -1
- package/dist/components/Slide/utils/subtitleCue.d.ts +1 -1
- package/dist/components/Slide/utils/subtitleJumpNavigation.d.ts +1 -1
- package/dist/components/index.d.ts +22 -18
- package/dist/components/ui/button.cjs +1 -1
- package/dist/components/ui/button.cjs.map +1 -1
- package/dist/components/ui/button.es.js +12 -13
- package/dist/components/ui/button.es.js.map +1 -1
- package/dist/components/ui/checkbox.cjs +1 -1
- package/dist/components/ui/checkbox.cjs.map +1 -1
- package/dist/components/ui/checkbox.es.js +35 -35
- package/dist/components/ui/checkbox.es.js.map +1 -1
- package/dist/components/ui/dialog.cjs +1 -1
- package/dist/components/ui/dialog.cjs.map +1 -1
- package/dist/components/ui/dialog.d.ts +5 -1
- package/dist/components/ui/dialog.es.js +37 -37
- package/dist/components/ui/dialog.es.js.map +1 -1
- package/dist/components/ui/input.cjs +1 -1
- package/dist/components/ui/input.cjs.map +1 -1
- package/dist/components/ui/input.es.js +4 -4
- package/dist/components/ui/input.es.js.map +1 -1
- package/dist/components/ui/inputGroup/button.cjs +1 -1
- package/dist/components/ui/inputGroup/button.cjs.map +1 -1
- package/dist/components/ui/inputGroup/button.es.js +9 -10
- package/dist/components/ui/inputGroup/button.es.js.map +1 -1
- package/dist/components/ui/inputGroup/input-group.cjs +1 -1
- package/dist/components/ui/inputGroup/input-group.cjs.map +1 -1
- package/dist/components/ui/inputGroup/input-group.d.ts +1 -1
- package/dist/components/ui/inputGroup/input-group.es.js +10 -10
- package/dist/components/ui/inputGroup/input-group.es.js.map +1 -1
- package/dist/components/ui/inputGroup/textarea.cjs +1 -1
- package/dist/components/ui/inputGroup/textarea.cjs.map +1 -1
- package/dist/components/ui/inputGroup/textarea.es.js +3 -3
- package/dist/components/ui/inputGroup/textarea.es.js.map +1 -1
- package/dist/components/ui/loading-overlay-card.cjs +2 -2
- package/dist/components/ui/loading-overlay-card.cjs.map +1 -1
- package/dist/components/ui/loading-overlay-card.es.js +11 -11
- package/dist/components/ui/loading-overlay-card.es.js.map +1 -1
- package/dist/components/ui/popover.cjs +1 -1
- package/dist/components/ui/popover.cjs.map +1 -1
- package/dist/components/ui/popover.es.js +6 -6
- package/dist/components/ui/popover.es.js.map +1 -1
- package/dist/components/ui/tooltip.cjs +1 -1
- package/dist/components/ui/tooltip.cjs.map +1 -1
- package/dist/components/ui/tooltip.es.js +16 -16
- package/dist/components/ui/tooltip.es.js.map +1 -1
- package/dist/editor.d.ts +2 -2
- package/dist/fonts/KaTeX_AMS-Regular.ttf +0 -0
- package/dist/fonts/KaTeX_AMS-Regular.woff +0 -0
- package/dist/fonts/KaTeX_AMS-Regular.woff2 +0 -0
- package/dist/fonts/KaTeX_Caligraphic-Bold.ttf +0 -0
- package/dist/fonts/KaTeX_Caligraphic-Bold.woff +0 -0
- package/dist/fonts/KaTeX_Caligraphic-Bold.woff2 +0 -0
- package/dist/fonts/KaTeX_Caligraphic-Regular.ttf +0 -0
- package/dist/fonts/KaTeX_Caligraphic-Regular.woff +0 -0
- package/dist/fonts/KaTeX_Caligraphic-Regular.woff2 +0 -0
- package/dist/fonts/KaTeX_Fraktur-Bold.ttf +0 -0
- package/dist/fonts/KaTeX_Fraktur-Bold.woff +0 -0
- package/dist/fonts/KaTeX_Fraktur-Bold.woff2 +0 -0
- package/dist/fonts/KaTeX_Fraktur-Regular.ttf +0 -0
- package/dist/fonts/KaTeX_Fraktur-Regular.woff +0 -0
- package/dist/fonts/KaTeX_Fraktur-Regular.woff2 +0 -0
- package/dist/fonts/KaTeX_Main-Bold.ttf +0 -0
- package/dist/fonts/KaTeX_Main-Bold.woff +0 -0
- package/dist/fonts/KaTeX_Main-Bold.woff2 +0 -0
- package/dist/fonts/KaTeX_Main-BoldItalic.ttf +0 -0
- package/dist/fonts/KaTeX_Main-BoldItalic.woff +0 -0
- package/dist/fonts/KaTeX_Main-BoldItalic.woff2 +0 -0
- package/dist/fonts/KaTeX_Main-Italic.ttf +0 -0
- package/dist/fonts/KaTeX_Main-Italic.woff +0 -0
- package/dist/fonts/KaTeX_Main-Italic.woff2 +0 -0
- package/dist/fonts/KaTeX_Main-Regular.ttf +0 -0
- package/dist/fonts/KaTeX_Main-Regular.woff +0 -0
- package/dist/fonts/KaTeX_Main-Regular.woff2 +0 -0
- package/dist/fonts/KaTeX_Math-BoldItalic.ttf +0 -0
- package/dist/fonts/KaTeX_Math-BoldItalic.woff +0 -0
- package/dist/fonts/KaTeX_Math-BoldItalic.woff2 +0 -0
- package/dist/fonts/KaTeX_Math-Italic.ttf +0 -0
- package/dist/fonts/KaTeX_Math-Italic.woff +0 -0
- package/dist/fonts/KaTeX_Math-Italic.woff2 +0 -0
- package/dist/fonts/KaTeX_SansSerif-Bold.ttf +0 -0
- package/dist/fonts/KaTeX_SansSerif-Bold.woff +0 -0
- package/dist/fonts/KaTeX_SansSerif-Bold.woff2 +0 -0
- package/dist/fonts/KaTeX_SansSerif-Italic.ttf +0 -0
- package/dist/fonts/KaTeX_SansSerif-Italic.woff +0 -0
- package/dist/fonts/KaTeX_SansSerif-Italic.woff2 +0 -0
- package/dist/fonts/KaTeX_SansSerif-Regular.ttf +0 -0
- package/dist/fonts/KaTeX_SansSerif-Regular.woff +0 -0
- package/dist/fonts/KaTeX_SansSerif-Regular.woff2 +0 -0
- package/dist/fonts/KaTeX_Script-Regular.ttf +0 -0
- package/dist/fonts/KaTeX_Script-Regular.woff +0 -0
- package/dist/fonts/KaTeX_Script-Regular.woff2 +0 -0
- package/dist/fonts/KaTeX_Size1-Regular.ttf +0 -0
- package/dist/fonts/KaTeX_Size1-Regular.woff +0 -0
- package/dist/fonts/KaTeX_Size1-Regular.woff2 +0 -0
- package/dist/fonts/KaTeX_Size2-Regular.ttf +0 -0
- package/dist/fonts/KaTeX_Size2-Regular.woff +0 -0
- package/dist/fonts/KaTeX_Size2-Regular.woff2 +0 -0
- package/dist/fonts/KaTeX_Size3-Regular.ttf +0 -0
- package/dist/fonts/KaTeX_Size3-Regular.woff +0 -0
- package/dist/fonts/KaTeX_Size3-Regular.woff2 +0 -0
- package/dist/fonts/KaTeX_Size4-Regular.ttf +0 -0
- package/dist/fonts/KaTeX_Size4-Regular.woff +0 -0
- package/dist/fonts/KaTeX_Size4-Regular.woff2 +0 -0
- package/dist/fonts/KaTeX_Typewriter-Regular.ttf +0 -0
- package/dist/fonts/KaTeX_Typewriter-Regular.woff +0 -0
- package/dist/fonts/KaTeX_Typewriter-Regular.woff2 +0 -0
- package/dist/index.cjs +1 -1
- package/dist/index.d.ts +2 -2
- package/dist/index.es.js +22 -19
- package/dist/index.es.js.map +1 -1
- package/dist/lib/locale.cjs +1 -1
- package/dist/lib/locale.cjs.map +1 -1
- package/dist/lib/locale.d.ts +5 -1
- package/dist/lib/locale.es.js +26 -13
- package/dist/lib/locale.es.js.map +1 -1
- package/dist/lib/locale.test.d.ts +1 -0
- package/dist/lib/useDetachedLanguage.cjs +2 -0
- package/dist/lib/useDetachedLanguage.cjs.map +1 -0
- package/dist/lib/useDetachedLanguage.d.ts +3 -0
- package/dist/lib/useDetachedLanguage.es.js +25 -0
- package/dist/lib/useDetachedLanguage.es.js.map +1 -0
- package/dist/lib/useResolvedDirection.cjs +2 -0
- package/dist/lib/useResolvedDirection.cjs.map +1 -0
- package/dist/lib/useResolvedDirection.d.ts +6 -0
- package/dist/lib/useResolvedDirection.es.js +37 -0
- package/dist/lib/useResolvedDirection.es.js.map +1 -0
- package/dist/markdown-flow-ui-lib.css +1 -1
- package/dist/node_modules/@radix-ui/react-arrow/dist/index.cjs +1 -1
- package/dist/node_modules/@radix-ui/react-arrow/dist/index.cjs.map +1 -1
- package/dist/node_modules/@radix-ui/react-arrow/dist/index.es.js +6 -6
- package/dist/node_modules/@radix-ui/react-arrow/dist/index.es.js.map +1 -1
- package/dist/node_modules/@radix-ui/react-context/dist/index.cjs +1 -1
- package/dist/node_modules/@radix-ui/react-context/dist/index.cjs.map +1 -1
- package/dist/node_modules/@radix-ui/react-context/dist/index.es.js +21 -21
- package/dist/node_modules/@radix-ui/react-context/dist/index.es.js.map +1 -1
- package/dist/node_modules/@radix-ui/react-dialog/dist/index.cjs +2 -2
- package/dist/node_modules/@radix-ui/react-dialog/dist/index.cjs.map +1 -1
- package/dist/node_modules/@radix-ui/react-dialog/dist/index.es.js +100 -100
- package/dist/node_modules/@radix-ui/react-dialog/dist/index.es.js.map +1 -1
- package/dist/node_modules/@radix-ui/react-dismissable-layer/dist/index.cjs +1 -1
- package/dist/node_modules/@radix-ui/react-dismissable-layer/dist/index.cjs.map +1 -1
- package/dist/node_modules/@radix-ui/react-dismissable-layer/dist/index.es.js +38 -38
- package/dist/node_modules/@radix-ui/react-dismissable-layer/dist/index.es.js.map +1 -1
- package/dist/node_modules/@radix-ui/react-focus-scope/dist/index.cjs +1 -1
- package/dist/node_modules/@radix-ui/react-focus-scope/dist/index.cjs.map +1 -1
- package/dist/node_modules/@radix-ui/react-focus-scope/dist/index.es.js +9 -9
- package/dist/node_modules/@radix-ui/react-focus-scope/dist/index.es.js.map +1 -1
- package/dist/node_modules/@radix-ui/react-popover/dist/index.cjs +1 -1
- package/dist/node_modules/@radix-ui/react-popover/dist/index.cjs.map +1 -1
- package/dist/node_modules/@radix-ui/react-popover/dist/index.es.js +95 -95
- package/dist/node_modules/@radix-ui/react-popover/dist/index.es.js.map +1 -1
- package/dist/node_modules/@radix-ui/react-popper/dist/index.cjs +1 -1
- package/dist/node_modules/@radix-ui/react-popper/dist/index.cjs.map +1 -1
- package/dist/node_modules/@radix-ui/react-popper/dist/index.es.js +48 -48
- package/dist/node_modules/@radix-ui/react-popper/dist/index.es.js.map +1 -1
- package/dist/node_modules/@radix-ui/react-portal/dist/index.cjs +1 -1
- package/dist/node_modules/@radix-ui/react-portal/dist/index.cjs.map +1 -1
- package/dist/node_modules/@radix-ui/react-portal/dist/index.es.js +6 -6
- package/dist/node_modules/@radix-ui/react-portal/dist/index.es.js.map +1 -1
- package/dist/node_modules/@radix-ui/react-primitive/dist/index.cjs +1 -1
- package/dist/node_modules/@radix-ui/react-primitive/dist/index.cjs.map +1 -1
- package/dist/node_modules/@radix-ui/react-primitive/dist/index.es.js +9 -9
- package/dist/node_modules/@radix-ui/react-primitive/dist/index.es.js.map +1 -1
- package/dist/node_modules/@radix-ui/react-slot/dist/index.cjs +1 -1
- package/dist/node_modules/@radix-ui/react-slot/dist/index.cjs.map +1 -1
- package/dist/node_modules/@radix-ui/react-slot/dist/index.es.js +17 -17
- package/dist/node_modules/@radix-ui/react-slot/dist/index.es.js.map +1 -1
- package/dist/node_modules/@radix-ui/react-tooltip/dist/index.cjs +1 -1
- package/dist/node_modules/@radix-ui/react-tooltip/dist/index.cjs.map +1 -1
- package/dist/node_modules/@radix-ui/react-tooltip/dist/index.es.js +100 -100
- package/dist/node_modules/@radix-ui/react-tooltip/dist/index.es.js.map +1 -1
- package/dist/node_modules/@radix-ui/react-visually-hidden/dist/index.cjs +1 -1
- package/dist/node_modules/@radix-ui/react-visually-hidden/dist/index.cjs.map +1 -1
- package/dist/node_modules/@radix-ui/react-visually-hidden/dist/index.es.js +6 -6
- package/dist/node_modules/@radix-ui/react-visually-hidden/dist/index.es.js.map +1 -1
- package/dist/node_modules/@uiw/react-codemirror/esm/index.cjs +1 -1
- package/dist/node_modules/@uiw/react-codemirror/esm/index.cjs.map +1 -1
- package/dist/node_modules/@uiw/react-codemirror/esm/index.es.js +27 -27
- package/dist/node_modules/@uiw/react-codemirror/esm/index.es.js.map +1 -1
- package/dist/node_modules/lucide-react/dist/esm/icons/{chevron-down.cjs → chevrons-down.cjs} +2 -2
- package/dist/node_modules/lucide-react/dist/esm/icons/chevrons-down.cjs.map +1 -0
- package/dist/node_modules/lucide-react/dist/esm/icons/{chevron-down.es.js → chevrons-down.es.js} +6 -3
- package/dist/node_modules/lucide-react/dist/esm/icons/chevrons-down.es.js.map +1 -0
- package/dist/node_modules/rc-input/es/BaseInput.cjs +1 -1
- package/dist/node_modules/rc-input/es/BaseInput.es.js +1 -1
- package/dist/node_modules/rc-textarea/es/ResizableTextArea.cjs +1 -1
- package/dist/node_modules/rc-textarea/es/ResizableTextArea.es.js +1 -1
- package/dist/node_modules/rc-textarea/es/TextArea.cjs +1 -1
- package/dist/node_modules/rc-textarea/es/TextArea.es.js +1 -1
- package/dist/node_modules/rc-textarea/es/index.cjs +1 -1
- package/dist/node_modules/rc-textarea/es/index.es.js +1 -1
- package/dist/node_modules/react-markdown/lib/index.cjs +1 -1
- package/dist/node_modules/react-markdown/lib/index.cjs.map +1 -1
- package/dist/node_modules/react-markdown/lib/index.es.js +39 -39
- package/dist/node_modules/react-markdown/lib/index.es.js.map +1 -1
- package/dist/node_modules/remark-flow/dist/interaction-plugin-core.cjs +1 -1
- package/dist/node_modules/remark-flow/dist/interaction-plugin-core.es.js +1 -1
- package/dist/renderer.cjs +1 -1
- package/dist/renderer.d.ts +18 -17
- package/dist/renderer.es.js +20 -17
- package/dist/renderer.es.js.map +1 -1
- package/dist/scroll.cjs +2 -0
- package/dist/scroll.cjs.map +1 -0
- package/dist/scroll.d.ts +6 -0
- package/dist/scroll.es.js +9 -0
- package/dist/scroll.es.js.map +1 -0
- package/dist/slide.d.ts +3 -3
- package/package.json +13 -2
- package/dist/_virtual/jsx-runtime.cjs +0 -2
- package/dist/_virtual/jsx-runtime.cjs.map +0 -1
- package/dist/_virtual/jsx-runtime.es.js +0 -6
- package/dist/_virtual/jsx-runtime.es.js.map +0 -1
- package/dist/_virtual/jsx-runtime.es2.js +0 -5
- package/dist/_virtual/jsx-runtime.es2.js.map +0 -1
- package/dist/_virtual/jsx-runtime2.cjs +0 -2
- package/dist/_virtual/jsx-runtime2.cjs.map +0 -1
- package/dist/_virtual/react-jsx-runtime.development.cjs +0 -2
- package/dist/_virtual/react-jsx-runtime.development.cjs.map +0 -1
- package/dist/_virtual/react-jsx-runtime.development.es.js +0 -5
- package/dist/_virtual/react-jsx-runtime.development.es.js.map +0 -1
- package/dist/_virtual/react-jsx-runtime.production.cjs +0 -2
- package/dist/_virtual/react-jsx-runtime.production.cjs.map +0 -1
- package/dist/_virtual/react-jsx-runtime.production.es.js +0 -5
- package/dist/_virtual/react-jsx-runtime.production.es.js.map +0 -1
- package/dist/lib/localeTextMap.cjs +0 -2
- package/dist/lib/localeTextMap.cjs.map +0 -1
- package/dist/lib/localeTextMap.es.js +0 -5
- package/dist/lib/localeTextMap.es.js.map +0 -1
- package/dist/node_modules/lucide-react/dist/esm/icons/chevron-down.cjs.map +0 -1
- package/dist/node_modules/lucide-react/dist/esm/icons/chevron-down.es.js.map +0 -1
- package/dist/node_modules/react/cjs/react-jsx-runtime.development.cjs +0 -24
- package/dist/node_modules/react/cjs/react-jsx-runtime.development.cjs.map +0 -1
- package/dist/node_modules/react/cjs/react-jsx-runtime.development.es.js +0 -409
- package/dist/node_modules/react/cjs/react-jsx-runtime.development.es.js.map +0 -1
- package/dist/node_modules/react/cjs/react-jsx-runtime.production.cjs +0 -10
- package/dist/node_modules/react/cjs/react-jsx-runtime.production.cjs.map +0 -1
- package/dist/node_modules/react/cjs/react-jsx-runtime.production.es.js +0 -36
- package/dist/node_modules/react/cjs/react-jsx-runtime.production.es.js.map +0 -1
- package/dist/node_modules/react/jsx-runtime.cjs +0 -2
- package/dist/node_modules/react/jsx-runtime.cjs.map +0 -1
- package/dist/node_modules/react/jsx-runtime.es.js +0 -11
- package/dist/node_modules/react/jsx-runtime.es.js.map +0 -1
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const
|
|
1
|
+
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const e=require("react/jsx-runtime"),t=require("react");;/* empty css */const h=require("../../node_modules/lucide-react/dist/esm/icons/check.cjs"),j=require("../../node_modules/lucide-react/dist/esm/icons/copy.cjs"),p=t.createContext(!1),m=s=>{let c="";return t.Children.forEach(s,o=>{typeof o=="string"?c+=o:t.isValidElement(o)&&o?.props?.children&&(c+=m(o.props.children))}),c},f=({children:s,className:c,dir:o="ltr",lang:C,copyButtonText:x="Copy",copiedButtonText:g="Copied"})=>{const[l,i]=t.useState(!1),r=t.useRef(null);t.useEffect(()=>()=>{r.current&&window.clearTimeout(r.current)},[]);let u="";t.Children.forEach(s,a=>{if(t.isValidElement(a)){const n=a.props;n.className&&(u=n.className)}});const d=/language-(\w+)/.exec(u||""),y=d?d[1]:"",N=async()=>{const a=m(s);try{await navigator.clipboard.writeText(a),i(!0),r.current&&window.clearTimeout(r.current),r.current=window.setTimeout(()=>{i(!1)},2e3)}catch(n){console.error("Failed to copy text: ",n)}};return e.jsxs("div",{className:"code-block-container",children:[e.jsxs("div",{className:"code-block-header",children:[e.jsx("span",{className:"language-name",children:y}),e.jsxs("button",{onClick:N,className:"copy-button",children:[l?e.jsx(h.default,{className:"copy-icon"}):e.jsx(j.default,{className:"copy-icon"}),l?g:x]})]}),e.jsx(p.Provider,{value:!0,children:e.jsx("pre",{className:c,dir:o,lang:C,children:s})})]})};f.displayName="CodeBlock";exports.CodeBlockContext=p;exports.default=f;
|
|
2
2
|
//# sourceMappingURL=CodeBlock.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CodeBlock.cjs","sources":["../../../src/components/ContentRender/CodeBlock.tsx"],"sourcesContent":["import React, { useState, ReactNode } from \"react\";\nimport \"./CodeBlock.css\";\nimport { Copy, Check } from \"lucide-react\";\n\n/**\n * Props for the CodeBlock component.\n */\nexport interface CodeBlockProps {\n /** The code content and nested elements to render.*/\n children?: React.ReactNode;\n /** Optional CSS class name for the pre element. */\n className?: string;\n /** Text to display on the copy button (i18n support). */\n copyButtonText?: string;\n /** Text to display when code is copied (i18n support). */\n copiedButtonText?: string;\n}\n\nconst getCodeString = (children: ReactNode): string => {\n let text = \"\";\n React.Children.forEach(children, (child) => {\n if (typeof child === \"string\") {\n text += child;\n } else if (\n React.isValidElement(child) &&\n (child?.props as { children?: ReactNode })?.children\n ) {\n text += getCodeString((child.props as { children: ReactNode }).children);\n }\n });\n return text;\n};\n\nconst CodeBlock: React.FC<CodeBlockProps> = ({\n children,\n className: preClassName,\n copyButtonText = \"Copy\",\n copiedButtonText = \"Copied\",\n}) => {\n const [isCopied, setIsCopied] = useState(false);\n const timeoutRef = React.useRef<number | null>(null);\n\n React.useEffect(() => {\n // Cleanup timeout on component unmount\n return () => {\n if (timeoutRef.current) {\n window.clearTimeout(timeoutRef.current);\n }\n };\n }, []);\n\n let codeClassName = \"\";\n React.Children.forEach(children, (child) => {\n if (React.isValidElement(child)) {\n const childProps = child.props as { className?: string };\n if (childProps.className) {\n codeClassName = childProps.className;\n }\n }\n });\n\n const match = /language-(\\w+)/.exec(codeClassName || \"\");\n const language = match ? match[1] : \"\";\n\n const handleCopy = async () => {\n const codeString = getCodeString(children);\n try {\n await navigator.clipboard.writeText(codeString);\n setIsCopied(true);\n\n if (timeoutRef.current) {\n window.clearTimeout(timeoutRef.current);\n }\n timeoutRef.current = window.setTimeout(() => {\n setIsCopied(false);\n }, 2000);\n } catch (err) {\n console.error(\"Failed to copy text: \", err);\n }\n };\n\n return (\n <div className=\"code-block-container\">\n <div className=\"code-block-header\">\n <span className=\"language-name\">{language}</span>\n <button onClick={handleCopy} className=\"copy-button\">\n {isCopied ? (\n <Check className=\"copy-icon\" />\n ) : (\n <Copy className=\"copy-icon\" />\n )}\n {isCopied ? copiedButtonText : copyButtonText}\n </button>\n </div>\n <pre className={preClassName}
|
|
1
|
+
{"version":3,"file":"CodeBlock.cjs","sources":["../../../src/components/ContentRender/CodeBlock.tsx"],"sourcesContent":["import React, { useState, ReactNode } from \"react\";\nimport \"./CodeBlock.css\";\nimport { Copy, Check } from \"lucide-react\";\n\n// Nested code inherits the pre element's direction unless the author overrides it.\nexport const CodeBlockContext = React.createContext(false);\n\n/**\n * Props for the CodeBlock component.\n */\nexport interface CodeBlockProps {\n /** The code content and nested elements to render.*/\n children?: React.ReactNode;\n /** Optional CSS class name for the pre element. */\n className?: string;\n /** Authored text direction; defaults to LTR for ordinary source code. */\n dir?: React.HTMLAttributes<HTMLPreElement>[\"dir\"];\n /** Preserves the language supplied on authored preformatted content. */\n lang?: string;\n /** Text to display on the copy button (i18n support). */\n copyButtonText?: string;\n /** Text to display when code is copied (i18n support). */\n copiedButtonText?: string;\n}\n\nconst getCodeString = (children: ReactNode): string => {\n let text = \"\";\n React.Children.forEach(children, (child) => {\n if (typeof child === \"string\") {\n text += child;\n } else if (\n React.isValidElement(child) &&\n (child?.props as { children?: ReactNode })?.children\n ) {\n text += getCodeString((child.props as { children: ReactNode }).children);\n }\n });\n return text;\n};\n\nconst CodeBlock: React.FC<CodeBlockProps> = ({\n children,\n className: preClassName,\n dir = \"ltr\",\n lang,\n copyButtonText = \"Copy\",\n copiedButtonText = \"Copied\",\n}) => {\n const [isCopied, setIsCopied] = useState(false);\n const timeoutRef = React.useRef<number | null>(null);\n\n React.useEffect(() => {\n // Cleanup timeout on component unmount\n return () => {\n if (timeoutRef.current) {\n window.clearTimeout(timeoutRef.current);\n }\n };\n }, []);\n\n let codeClassName = \"\";\n React.Children.forEach(children, (child) => {\n if (React.isValidElement(child)) {\n const childProps = child.props as { className?: string };\n if (childProps.className) {\n codeClassName = childProps.className;\n }\n }\n });\n\n const match = /language-(\\w+)/.exec(codeClassName || \"\");\n const language = match ? match[1] : \"\";\n\n const handleCopy = async () => {\n const codeString = getCodeString(children);\n try {\n await navigator.clipboard.writeText(codeString);\n setIsCopied(true);\n\n if (timeoutRef.current) {\n window.clearTimeout(timeoutRef.current);\n }\n timeoutRef.current = window.setTimeout(() => {\n setIsCopied(false);\n }, 2000);\n } catch (err) {\n console.error(\"Failed to copy text: \", err);\n }\n };\n\n return (\n <div className=\"code-block-container\">\n <div className=\"code-block-header\">\n <span className=\"language-name\">{language}</span>\n <button onClick={handleCopy} className=\"copy-button\">\n {isCopied ? (\n <Check className=\"copy-icon\" />\n ) : (\n <Copy className=\"copy-icon\" />\n )}\n {isCopied ? copiedButtonText : copyButtonText}\n </button>\n </div>\n <CodeBlockContext.Provider value={true}>\n <pre className={preClassName} dir={dir} lang={lang}>\n {children}\n </pre>\n </CodeBlockContext.Provider>\n </div>\n );\n};\n\nCodeBlock.displayName = \"CodeBlock\";\nexport default CodeBlock;\n"],"names":["CodeBlockContext","React","getCodeString","children","text","child","CodeBlock","preClassName","dir","lang","copyButtonText","copiedButtonText","isCopied","setIsCopied","useState","timeoutRef","codeClassName","childProps","match","language","handleCopy","codeString","err","jsxs","jsx","Check","Copy"],"mappings":"oVAKaA,EAAmBC,EAAM,cAAc,EAAK,EAoBnDC,EAAiBC,GAAgC,CACrD,IAAIC,EAAO,GACX,OAAAH,EAAM,SAAS,QAAQE,EAAWE,GAAU,CACtC,OAAOA,GAAU,SACnBD,GAAQC,EAERJ,EAAM,eAAeI,CAAK,GACzBA,GAAO,OAAoC,WAE5CD,GAAQF,EAAeG,EAAM,MAAkC,QAAQ,EAE3E,CAAC,EACMD,CACT,EAEME,EAAsC,CAAC,CAC3C,SAAAH,EACA,UAAWI,EACX,IAAAC,EAAM,MACN,KAAAC,EACA,eAAAC,EAAiB,OACjB,iBAAAC,EAAmB,QACrB,IAAM,CACJ,KAAM,CAACC,EAAUC,CAAW,EAAIC,EAAAA,SAAS,EAAK,EACxCC,EAAad,EAAM,OAAsB,IAAI,EAEnDA,EAAM,UAAU,IAEP,IAAM,CACPc,EAAW,SACb,OAAO,aAAaA,EAAW,OAAO,CAE1C,EACC,CAAA,CAAE,EAEL,IAAIC,EAAgB,GACpBf,EAAM,SAAS,QAAQE,EAAWE,GAAU,CAC1C,GAAIJ,EAAM,eAAeI,CAAK,EAAG,CAC/B,MAAMY,EAAaZ,EAAM,MACrBY,EAAW,YACbD,EAAgBC,EAAW,UAE/B,CACF,CAAC,EAED,MAAMC,EAAQ,iBAAiB,KAAKF,GAAiB,EAAE,EACjDG,EAAWD,EAAQA,EAAM,CAAC,EAAI,GAE9BE,EAAa,SAAY,CAC7B,MAAMC,EAAanB,EAAcC,CAAQ,EACzC,GAAI,CACF,MAAM,UAAU,UAAU,UAAUkB,CAAU,EAC9CR,EAAY,EAAI,EAEZE,EAAW,SACb,OAAO,aAAaA,EAAW,OAAO,EAExCA,EAAW,QAAU,OAAO,WAAW,IAAM,CAC3CF,EAAY,EAAK,CACnB,EAAG,GAAI,CACT,OAASS,EAAK,CACZ,QAAQ,MAAM,wBAAyBA,CAAG,CAC5C,CACF,EAEA,OACEC,EAAAA,KAAC,MAAA,CAAI,UAAU,uBACb,SAAA,CAAAA,EAAAA,KAAC,MAAA,CAAI,UAAU,oBACb,SAAA,CAAAC,EAAAA,IAAC,OAAA,CAAK,UAAU,gBAAiB,SAAAL,EAAS,EAC1CI,EAAAA,KAAC,SAAA,CAAO,QAASH,EAAY,UAAU,cACpC,SAAA,CAAAR,EACCY,EAAAA,IAACC,WAAM,UAAU,WAAA,CAAY,EAE7BD,EAAAA,IAACE,EAAAA,QAAA,CAAK,UAAU,WAAA,CAAY,EAE7Bd,EAAWD,EAAmBD,CAAA,CAAA,CACjC,CAAA,EACF,EACAc,EAAAA,IAACxB,EAAiB,SAAjB,CAA0B,MAAO,GAChC,SAAAwB,EAAAA,IAAC,MAAA,CAAI,UAAWjB,EAAc,IAAAC,EAAU,KAAAC,EACrC,SAAAN,EACH,CAAA,CACF,CAAA,EACF,CAEJ,EAEAG,EAAU,YAAc"}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { default as React } from 'react';
|
|
2
|
+
export declare const CodeBlockContext: React.Context<boolean>;
|
|
2
3
|
/**
|
|
3
4
|
* Props for the CodeBlock component.
|
|
4
5
|
*/
|
|
@@ -7,6 +8,10 @@ export interface CodeBlockProps {
|
|
|
7
8
|
children?: React.ReactNode;
|
|
8
9
|
/** Optional CSS class name for the pre element. */
|
|
9
10
|
className?: string;
|
|
11
|
+
/** Authored text direction; defaults to LTR for ordinary source code. */
|
|
12
|
+
dir?: React.HTMLAttributes<HTMLPreElement>["dir"];
|
|
13
|
+
/** Preserves the language supplied on authored preformatted content. */
|
|
14
|
+
lang?: string;
|
|
10
15
|
/** Text to display on the copy button (i18n support). */
|
|
11
16
|
copyButtonText?: string;
|
|
12
17
|
/** Text to display when code is copied (i18n support). */
|
|
@@ -1,53 +1,56 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import
|
|
1
|
+
import { jsxs as l, jsx as c } from "react/jsx-runtime";
|
|
2
|
+
import o, { useState as g } from "react";
|
|
3
3
|
/* empty css */
|
|
4
|
-
import
|
|
5
|
-
import
|
|
6
|
-
const
|
|
7
|
-
let
|
|
8
|
-
return
|
|
9
|
-
typeof e == "string" ?
|
|
10
|
-
}),
|
|
11
|
-
},
|
|
4
|
+
import h from "../../node_modules/lucide-react/dist/esm/icons/check.es.js";
|
|
5
|
+
import w from "../../node_modules/lucide-react/dist/esm/icons/copy.es.js";
|
|
6
|
+
const x = o.createContext(!1), u = (t) => {
|
|
7
|
+
let r = "";
|
|
8
|
+
return o.Children.forEach(t, (e) => {
|
|
9
|
+
typeof e == "string" ? r += e : o.isValidElement(e) && e?.props?.children && (r += u(e.props.children));
|
|
10
|
+
}), r;
|
|
11
|
+
}, k = ({
|
|
12
12
|
children: t,
|
|
13
|
-
className:
|
|
14
|
-
|
|
15
|
-
|
|
13
|
+
className: r,
|
|
14
|
+
dir: e = "ltr",
|
|
15
|
+
lang: f,
|
|
16
|
+
copyButtonText: C = "Copy",
|
|
17
|
+
copiedButtonText: y = "Copied"
|
|
16
18
|
}) => {
|
|
17
|
-
const [i,
|
|
18
|
-
|
|
19
|
-
|
|
19
|
+
const [i, d] = g(!1), a = o.useRef(null);
|
|
20
|
+
o.useEffect(() => () => {
|
|
21
|
+
a.current && window.clearTimeout(a.current);
|
|
20
22
|
}, []);
|
|
21
23
|
let m = "";
|
|
22
|
-
|
|
23
|
-
if (
|
|
24
|
-
const n =
|
|
24
|
+
o.Children.forEach(t, (s) => {
|
|
25
|
+
if (o.isValidElement(s)) {
|
|
26
|
+
const n = s.props;
|
|
25
27
|
n.className && (m = n.className);
|
|
26
28
|
}
|
|
27
29
|
});
|
|
28
|
-
const p = /language-(\w+)/.exec(m || ""),
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
i ? /* @__PURE__ */
|
|
43
|
-
i ?
|
|
30
|
+
const p = /language-(\w+)/.exec(m || ""), N = p ? p[1] : "";
|
|
31
|
+
return /* @__PURE__ */ l("div", { className: "code-block-container", children: [
|
|
32
|
+
/* @__PURE__ */ l("div", { className: "code-block-header", children: [
|
|
33
|
+
/* @__PURE__ */ c("span", { className: "language-name", children: N }),
|
|
34
|
+
/* @__PURE__ */ l("button", { onClick: async () => {
|
|
35
|
+
const s = u(t);
|
|
36
|
+
try {
|
|
37
|
+
await navigator.clipboard.writeText(s), d(!0), a.current && window.clearTimeout(a.current), a.current = window.setTimeout(() => {
|
|
38
|
+
d(!1);
|
|
39
|
+
}, 2e3);
|
|
40
|
+
} catch (n) {
|
|
41
|
+
console.error("Failed to copy text: ", n);
|
|
42
|
+
}
|
|
43
|
+
}, className: "copy-button", children: [
|
|
44
|
+
i ? /* @__PURE__ */ c(h, { className: "copy-icon" }) : /* @__PURE__ */ c(w, { className: "copy-icon" }),
|
|
45
|
+
i ? y : C
|
|
44
46
|
] })
|
|
45
47
|
] }),
|
|
46
|
-
/* @__PURE__ */
|
|
48
|
+
/* @__PURE__ */ c(x.Provider, { value: !0, children: /* @__PURE__ */ c("pre", { className: r, dir: e, lang: f, children: t }) })
|
|
47
49
|
] });
|
|
48
50
|
};
|
|
49
|
-
|
|
51
|
+
k.displayName = "CodeBlock";
|
|
50
52
|
export {
|
|
51
|
-
|
|
53
|
+
x as CodeBlockContext,
|
|
54
|
+
k as default
|
|
52
55
|
};
|
|
53
56
|
//# sourceMappingURL=CodeBlock.es.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CodeBlock.es.js","sources":["../../../src/components/ContentRender/CodeBlock.tsx"],"sourcesContent":["import React, { useState, ReactNode } from \"react\";\nimport \"./CodeBlock.css\";\nimport { Copy, Check } from \"lucide-react\";\n\n/**\n * Props for the CodeBlock component.\n */\nexport interface CodeBlockProps {\n /** The code content and nested elements to render.*/\n children?: React.ReactNode;\n /** Optional CSS class name for the pre element. */\n className?: string;\n /** Text to display on the copy button (i18n support). */\n copyButtonText?: string;\n /** Text to display when code is copied (i18n support). */\n copiedButtonText?: string;\n}\n\nconst getCodeString = (children: ReactNode): string => {\n let text = \"\";\n React.Children.forEach(children, (child) => {\n if (typeof child === \"string\") {\n text += child;\n } else if (\n React.isValidElement(child) &&\n (child?.props as { children?: ReactNode })?.children\n ) {\n text += getCodeString((child.props as { children: ReactNode }).children);\n }\n });\n return text;\n};\n\nconst CodeBlock: React.FC<CodeBlockProps> = ({\n children,\n className: preClassName,\n copyButtonText = \"Copy\",\n copiedButtonText = \"Copied\",\n}) => {\n const [isCopied, setIsCopied] = useState(false);\n const timeoutRef = React.useRef<number | null>(null);\n\n React.useEffect(() => {\n // Cleanup timeout on component unmount\n return () => {\n if (timeoutRef.current) {\n window.clearTimeout(timeoutRef.current);\n }\n };\n }, []);\n\n let codeClassName = \"\";\n React.Children.forEach(children, (child) => {\n if (React.isValidElement(child)) {\n const childProps = child.props as { className?: string };\n if (childProps.className) {\n codeClassName = childProps.className;\n }\n }\n });\n\n const match = /language-(\\w+)/.exec(codeClassName || \"\");\n const language = match ? match[1] : \"\";\n\n const handleCopy = async () => {\n const codeString = getCodeString(children);\n try {\n await navigator.clipboard.writeText(codeString);\n setIsCopied(true);\n\n if (timeoutRef.current) {\n window.clearTimeout(timeoutRef.current);\n }\n timeoutRef.current = window.setTimeout(() => {\n setIsCopied(false);\n }, 2000);\n } catch (err) {\n console.error(\"Failed to copy text: \", err);\n }\n };\n\n return (\n <div className=\"code-block-container\">\n <div className=\"code-block-header\">\n <span className=\"language-name\">{language}</span>\n <button onClick={handleCopy} className=\"copy-button\">\n {isCopied ? (\n <Check className=\"copy-icon\" />\n ) : (\n <Copy className=\"copy-icon\" />\n )}\n {isCopied ? copiedButtonText : copyButtonText}\n </button>\n </div>\n <pre className={preClassName}
|
|
1
|
+
{"version":3,"file":"CodeBlock.es.js","sources":["../../../src/components/ContentRender/CodeBlock.tsx"],"sourcesContent":["import React, { useState, ReactNode } from \"react\";\nimport \"./CodeBlock.css\";\nimport { Copy, Check } from \"lucide-react\";\n\n// Nested code inherits the pre element's direction unless the author overrides it.\nexport const CodeBlockContext = React.createContext(false);\n\n/**\n * Props for the CodeBlock component.\n */\nexport interface CodeBlockProps {\n /** The code content and nested elements to render.*/\n children?: React.ReactNode;\n /** Optional CSS class name for the pre element. */\n className?: string;\n /** Authored text direction; defaults to LTR for ordinary source code. */\n dir?: React.HTMLAttributes<HTMLPreElement>[\"dir\"];\n /** Preserves the language supplied on authored preformatted content. */\n lang?: string;\n /** Text to display on the copy button (i18n support). */\n copyButtonText?: string;\n /** Text to display when code is copied (i18n support). */\n copiedButtonText?: string;\n}\n\nconst getCodeString = (children: ReactNode): string => {\n let text = \"\";\n React.Children.forEach(children, (child) => {\n if (typeof child === \"string\") {\n text += child;\n } else if (\n React.isValidElement(child) &&\n (child?.props as { children?: ReactNode })?.children\n ) {\n text += getCodeString((child.props as { children: ReactNode }).children);\n }\n });\n return text;\n};\n\nconst CodeBlock: React.FC<CodeBlockProps> = ({\n children,\n className: preClassName,\n dir = \"ltr\",\n lang,\n copyButtonText = \"Copy\",\n copiedButtonText = \"Copied\",\n}) => {\n const [isCopied, setIsCopied] = useState(false);\n const timeoutRef = React.useRef<number | null>(null);\n\n React.useEffect(() => {\n // Cleanup timeout on component unmount\n return () => {\n if (timeoutRef.current) {\n window.clearTimeout(timeoutRef.current);\n }\n };\n }, []);\n\n let codeClassName = \"\";\n React.Children.forEach(children, (child) => {\n if (React.isValidElement(child)) {\n const childProps = child.props as { className?: string };\n if (childProps.className) {\n codeClassName = childProps.className;\n }\n }\n });\n\n const match = /language-(\\w+)/.exec(codeClassName || \"\");\n const language = match ? match[1] : \"\";\n\n const handleCopy = async () => {\n const codeString = getCodeString(children);\n try {\n await navigator.clipboard.writeText(codeString);\n setIsCopied(true);\n\n if (timeoutRef.current) {\n window.clearTimeout(timeoutRef.current);\n }\n timeoutRef.current = window.setTimeout(() => {\n setIsCopied(false);\n }, 2000);\n } catch (err) {\n console.error(\"Failed to copy text: \", err);\n }\n };\n\n return (\n <div className=\"code-block-container\">\n <div className=\"code-block-header\">\n <span className=\"language-name\">{language}</span>\n <button onClick={handleCopy} className=\"copy-button\">\n {isCopied ? (\n <Check className=\"copy-icon\" />\n ) : (\n <Copy className=\"copy-icon\" />\n )}\n {isCopied ? copiedButtonText : copyButtonText}\n </button>\n </div>\n <CodeBlockContext.Provider value={true}>\n <pre className={preClassName} dir={dir} lang={lang}>\n {children}\n </pre>\n </CodeBlockContext.Provider>\n </div>\n );\n};\n\nCodeBlock.displayName = \"CodeBlock\";\nexport default CodeBlock;\n"],"names":["CodeBlockContext","React","getCodeString","children","text","child","CodeBlock","preClassName","dir","lang","copyButtonText","copiedButtonText","isCopied","setIsCopied","useState","timeoutRef","codeClassName","childProps","match","language","jsxs","jsx","codeString","err","Check","Copy"],"mappings":";;;;;AAKO,MAAMA,IAAmBC,EAAM,cAAc,EAAK,GAoBnDC,IAAgB,CAACC,MAAgC;AACrD,MAAIC,IAAO;AACXH,SAAAA,EAAM,SAAS,QAAQE,GAAU,CAACE,MAAU;AAC1C,IAAI,OAAOA,KAAU,WACnBD,KAAQC,IAERJ,EAAM,eAAeI,CAAK,KACzBA,GAA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ASU,GAAK;AACZ,kBAAQ,MAAM,yBAAyBA,CAAG;AAAA,QAC5C;AAAA,MACF,GAMmC,WAAU,eACpC,UAAA;AAAA,QAAAX,IACC,gBAAAS,EAACG,KAAM,WAAU,YAAA,CAAY,IAE7B,gBAAAH,EAACI,GAAA,EAAK,WAAU,YAAA,CAAY;AAAA,QAE7Bb,IAAWD,IAAmBD;AAAA,MAAA,EAAA,CACjC;AAAA,IAAA,GACF;AAAA,IACA,gBAAAW,EAACrB,EAAiB,UAAjB,EAA0B,OAAO,IAChC,UAAA,gBAAAqB,EAAC,OAAA,EAAI,WAAWd,GAAc,KAAAC,GAAU,MAAAC,GACrC,UAAAN,GACH,EAAA,CACF;AAAA,EAAA,GACF;AAEJ;AAEAG,EAAU,cAAc;"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const n=require("
|
|
1
|
+
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const n=require("react/jsx-runtime"),o=require("react"),Ne=require("../../_virtual/index.cjs"),Me=require("./utils/sanitize-invalid-tag-name.cjs"),qe=require("./utils/strip-svg-text-line-breaks.cjs");;/* empty css */;/* empty css */;/* empty css */;/* empty css */const ve=require("./CodeBlock.cjs"),Le=require("./plugins/CustomVariable.cjs"),Q=require("./plugins/MermaidChart.cjs"),fe=require("./utils/custom-variable-props.cjs"),xe=require("./utils/highlight-languages.cjs"),Y=require("./utils/mermaid-parse.cjs"),he=require("./utils/normalize-inline-html.cjs"),Ae=require("./IframeSandbox.cjs"),$e=require("./utils/split-content.cjs"),ze=require("../../lib/interaction-defaults.cjs"),pe=require("../../lib/locale.cjs"),ye=require("./contentRenderI18n.cjs"),Ve=require("../../node_modules/react-markdown/lib/index.cjs"),De=require("../../node_modules/rehype-raw/lib/index.cjs"),Ie=require("../../node_modules/rehype-highlight/lib/index.cjs"),Ee=require("../../node_modules/rehype-katex/lib/index.cjs"),Fe=require("../../node_modules/remark-gfm/lib/index.cjs"),Pe=require("../../node_modules/remark-math/lib/index.cjs"),He=require("../../node_modules/remark-breaks/lib/index.cjs"),We=/<(script|style|link|iframe|html|head|body|meta|title|base|template|div|section|article|main)\b/i,ge=({svg:t})=>{const r=o.useRef(null);return o.useEffect(()=>{const s=r.current;if(!s)return;const a=s.shadowRoot??s.attachShadow({mode:"open"}),g="content-render-svg-style";let d=a.getElementById(g);d||(d=document.createElement("style"),d.id=g,d.textContent=`
|
|
2
2
|
svg { height: auto; display: inline-block; }
|
|
3
3
|
svg.content-render-svg-el--responsive { width: 100%; max-width: 100%; }
|
|
4
4
|
svg.content-render-svg-el--fixed { max-width: none; }
|
|
5
|
-
`,
|
|
5
|
+
`,a.appendChild(d)),Array.from(a.childNodes).filter(i=>i!==d).forEach(i=>a.removeChild(i));const M=document.createElement("template"),B=qe.stripSvgTextLineBreaks(t);M.innerHTML=B,a.append(M.content.cloneNode(!0));let C=!1,q=!1;a.querySelectorAll("svg").forEach(i=>{const $=i.getAttribute("viewBox");if(!$)return;const L=$.trim().split(/[\s,]+/).map(l=>Number(l));if(L.length!==4||L.some(Number.isNaN))return;const[,,k,y]=L,R=i.getAttribute("width"),j=i.getAttribute("height"),z=l=>{if(!l)return!1;const x=l.trim().toLowerCase();return x==="auto"||x.endsWith("%")},V=l=>{if(!l)return null;const x=l.trim().toLowerCase();if(x==="auto"||x.endsWith("%"))return null;const b=Number.parseFloat(x);return Number.isNaN(b)?null:b},E=z(R),F=z(j),D=!R||R==="0",I=!j||j==="0",P=V(R),H=V(j);if(E||F||D&&I||P===k&&H===y){C=!0,i.classList.add("content-render-svg-el--responsive"),i.classList.remove("content-render-svg-el--fixed"),i.style.width="100%",i.style.height="auto",!i.style.aspectRatio&&y>0&&(i.style.aspectRatio=`${k} / ${y}`);return}q=!0,i.classList.add("content-render-svg-el--fixed"),i.classList.remove("content-render-svg-el--responsive"),D&&k>0&&i.setAttribute("width",`${k}`),I&&y>0&&i.setAttribute("height",`${y}`)});const v=C&&!q;s.classList.toggle("content-render-svg--responsive",v),s.classList.toggle("content-render-svg--fixed",!v)},[t]),n.jsx("div",{className:"content-render-svg-scroll",children:n.jsx("div",{className:"content-render-svg",ref:r})})},Z=o.createContext(null),_e=t=>{const r=o.useContext(Z),s=o.useContext(ve.CodeBlockContext);if(!r)throw new Error("Markdown code renderer requires ContentRender context.");const{className:a,children:g,...d}=t;if(/language-(\w+)/.exec(a||"")?.[1]==="mermaid"){const B=g?.toString().replace(/\n$/,"")||"",C=Y.mermaidBlockIsComplete(r.current.renderContent,B);return n.jsx(Q.default,{chart:B,frozen:C,messages:r.current.mermaidMessages})}return n.jsx("code",{className:a,...d,dir:d.dir??(s?void 0:"ltr"),children:g})},Oe=[Fe.default,Pe.default,Ne.default,He.default],Ue=[fe.preserveCustomVariableProperties,De.default,Me.sanitizeInvalidTagName,fe.restoreCustomVariableProperties,[Ie.default,{languages:xe.highlightLanguages,subset:xe.subsetLanguages}],Ee.default],ee=({content:t,components:r,locale:s})=>{const a=ye.getContentRenderLocaleTexts(s);return n.jsx("div",{className:"markdown-renderer",children:n.jsx(Ve.Markdown,{remarkPlugins:Oe,rehypePlugins:Ue,remarkRehypeOptions:{footnoteLabel:a.footnoteLabel,footnoteBackLabel:(g,d)=>{const w=String(g+1)+(d>1?`-${d}`:"");return a.footnoteBackLabel.replace("{reference}",w)}},components:r,children:t})})},Ge=t=>{if(t.length<=1)return t;const r=[];return t.forEach(s=>{if(s.type==="sandbox"){r.push(s);return}const a=r[r.length-1];if(a&&a.type!=="sandbox"){r[r.length-1]={type:"markdown",value:`${a.value}${s.value}`};return}r.push({type:"markdown",value:s.value})}),r},Xe=(t,r)=>{const s=Math.max(1,r),a=Array.from(t);return{chunk:a.slice(0,s).join(""),rest:a.slice(s).join("")}},Je=(t,r)=>t===r?!0:!t||!r||t.length!==r.length?!1:t.every((s,a)=>s===r[a]),Ke=t=>{const r=o.useRef(t);return Je(r.current,t)||(r.current=t),r.current},Qe=({content:t,contentType:r,locale:s,lang:a,dir:g,customRenderBar:d,onSend:w,typingSpeed:M=40,enableTypewriter:B=!1,onTypeFinished:C,onTypewriterStateChange:q,userInput:v,interactionDefaultValueOptions:i,defaultButtonText:$,defaultInputText:L,defaultSelectedValues:k,readonly:y=!1,confirmButtonText:R,copyButtonText:j,copiedButtonText:z,sandboxLoadingText:V,sandboxStyleLoadingText:E,sandboxScriptLoadingText:F,disableSandboxLoadingOverlay:D=!1,sandboxFullscreenButtonText:I,sandboxExitFullscreenButtonText:P,sandboxMode:H="content",onClickCustomButtonAfterContent:W,beforeSend:_})=>{const l=ye.getContentRenderLocaleTexts(s),x=o.useMemo(()=>({loading:l.mermaidLoadingText,emptyChart:l.mermaidEmptyChartText,error:l.mermaidErrorText}),[l]),b=g??pe.getMarkdownFlowDirection(s),A=a??pe.getMarkdownFlowLanguage(s),te=R||l.confirmButtonText,ne=j||l.copyButtonText,re=z||l.copiedButtonText,be=I||l.sandboxFullscreenButtonText,Te=P||l.sandboxExitFullscreenButtonText,m=!!B&&(!r||r==="text"),se=2,oe=Math.max(0,M),[T,O]=o.useState(()=>m?"":t),S=o.useRef(""),ae=o.useRef(m),U=o.useRef(!1);o.useEffect(()=>{const e=ae.current;if(ae.current=m,U.current=!1,!m){S.current="",O(t);return}O(c=>{const f=!e,N=t.startsWith(c);if(!f&&!N)return S.current="",t;const h=f||!N?"":c;return S.current=t.slice(h.length),h})},[t,m]),o.useEffect(()=>{m&&(U.current||S.current||T!==t||(U.current=!0,C?.()))},[t,T,m,C]),o.useEffect(()=>{if(!m||!S.current)return;const e=window.setTimeout(()=>{O(c=>{const{chunk:f,rest:N}=Xe(S.current,se);return f?(S.current=N,`${c}${f}`):c})},oe);return()=>window.clearTimeout(e)},[t,T,m,se,oe]);const ie=o.useMemo(()=>({isTypewriterEnabled:m,isTyping:m&&T!==t,isComplete:T===t,renderedLength:T.length,totalLength:t.length}),[t,T,m]);o.useEffect(()=>{q?.(ie)},[q,ie]);const p=m?T:t,G=o.useMemo(()=>he.normalizeInlineHtml(p),[p]),X=o.useMemo(()=>ze.getInteractionDefaultValues(p,v,i),[i,p,v]),ce=$?.trim()||X.buttonText,le=L?.trim()||X.inputText,we=o.useMemo(()=>v?v.split(",").map(e=>e.trim()).filter(Boolean):void 0,[v]),Ce=k?.length?k:X.selectedValues||we,ue=Ke(Ce),u=o.useRef({direction:b,language:A,mermaidMessages:x,beforeSend:_,locale:s,onClickCustomButtonAfterContent:W,onSend:w,readonly:y,renderContent:p,resolvedConfirmButtonText:te,resolvedCopiedButtonText:re,resolvedCopyButtonText:ne,resolvedDefaultButtonText:ce,resolvedDefaultInputText:le,resolvedDefaultSelectedValues:ue});u.current={direction:b,language:A,mermaidMessages:x,beforeSend:_,locale:s,onClickCustomButtonAfterContent:W,onSend:w,readonly:y,renderContent:p,resolvedConfirmButtonText:te,resolvedCopiedButtonText:re,resolvedCopyButtonText:ne,resolvedDefaultButtonText:ce,resolvedDefaultInputText:le,resolvedDefaultSelectedValues:ue};const de=o.useMemo(()=>({"custom-button-after-content":({children:e})=>n.jsx("button",{className:"content-render-custom-button-after-content",onClick:u.current.onClickCustomButtonAfterContent,children:n.jsx("span",{className:"content-render-custom-button-after-content-inner",children:e})}),"custom-variable":e=>n.jsx(Le.default,{...e,readonly:u.current.readonly,defaultButtonText:u.current.resolvedDefaultButtonText,defaultInputText:u.current.resolvedDefaultInputText,defaultSelectedValues:u.current.resolvedDefaultSelectedValues,onSend:u.current.onSend,beforeSend:u.current.beforeSend,locale:u.current.locale,dir:u.current.direction,lang:u.current.language,confirmButtonText:u.current.resolvedConfirmButtonText}),code:_e,table:({...e})=>n.jsx("div",{className:"content-render-table-container",children:n.jsx("table",{className:"content-render-table",...e})}),th:({...e})=>n.jsx("th",{className:"content-render-th",...e}),td:({...e})=>n.jsx("td",{className:"content-render-td",...e}),tr:({...e})=>n.jsx("tr",{className:"content-render-tr",...e}),li:({node:e,...c})=>{const f=e?.properties?.className;return typeof f=="string"&&f.includes("task-list-item")||Array.isArray(f)&&f.includes("task-list-item")?n.jsx("li",{className:"content-render-task-list-item",...c}):n.jsx("li",{...c})},ol:({...e})=>n.jsx("ol",{className:"content-render-ol",...e}),ul:({...e})=>n.jsx("ul",{className:"content-render-ul",...e}),input:({...e})=>e.type==="checkbox"?n.jsx("input",{type:"checkbox",className:"content-render-checkbox",disabled:!0,...e}):n.jsx("input",{...e}),a:({children:e,...c})=>n.jsx("a",{target:"_blank",rel:"noopener noreferrer",...c,children:e}),pre:e=>n.jsx(ve.default,{...e,copyButtonText:u.current.resolvedCopyButtonText,copiedButtonText:u.current.resolvedCopiedButtonText})}),[]),me=o.useMemo(()=>We.test(p),[p]),J=o.useMemo(()=>me?$e.splitContentSegments(p,!0):[],[p,me]),ke=J.some(e=>e.type==="sandbox"),Se=o.useMemo(()=>Ge(J),[J]),Be=o.useMemo(()=>Y.parseMarkdownSegments(G),[G]),Re=(e,c)=>{const f=he.normalizeInlineHtml(e);return Y.parseMarkdownSegments(f).map((h,je)=>{const K=`${c}-${h.type}-${je}`;return h.type==="text"?n.jsx(Z.Provider,{value:u,children:n.jsx(ee,{locale:s,components:de,content:h.value})},K):h.type==="mermaid"?n.jsx(Q.default,{chart:h.value,frozen:!h.complete,messages:x},K):h.type==="svg"?n.jsx(ge,{svg:h.value},K):null})};return ke?n.jsx("div",{className:"content-render markdown-body",dir:b,lang:A,children:Se.map((e,c)=>e.type==="sandbox"?n.jsx(Ae.default,{hideFullScreen:!0,type:"sandbox",content:e.value,className:"content-render-iframe",locale:s,dir:b,lang:A,loadingText:V,styleLoadingText:E,scriptLoadingText:F,disableLoadingOverlay:D,fullScreenButtonText:be,exitFullScreenButtonText:Te,mode:H},`sandbox-${c}`):n.jsx(o.Fragment,{children:Re(e.value,`md-${c}`)},`md-${c}`))}):n.jsxs("div",{className:"content-render markdown-body",dir:b,lang:A,children:[Be.map((e,c)=>{if(e.type==="text")return n.jsx(Z.Provider,{value:u,children:n.jsx(ee,{locale:s,components:de,content:e.value})},c);if(e.type==="mermaid")return n.jsx(Q.default,{chart:e.value,frozen:!e.complete,messages:x},c);if(e.type==="svg")return n.jsx(ge,{svg:e.value},c)}),d&&n.jsx("div",{className:"content-render-custom-bar",children:o.createElement(d,{content:t,displayContent:G,onSend:w})})]})};exports.MarkdownRenderer=ee;exports.default=Qe;
|
|
6
6
|
//# sourceMappingURL=ContentRender.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ContentRender.cjs","sources":["../../../src/components/ContentRender/ContentRender.tsx"],"sourcesContent":["import React, { useEffect, useMemo, useRef, useState } from \"react\";\nimport ReactMarkdown from \"react-markdown\";\nimport rehypeHighlight from \"rehype-highlight\";\nimport rehypeKatex from \"rehype-katex\";\nimport rehypeRaw from \"rehype-raw\";\nimport remarkBreaks from \"remark-breaks\";\nimport remarkFlow from \"remark-flow\";\nimport remarkGfm from \"remark-gfm\";\nimport remarkMath from \"remark-math\";\nimport type { PluggableList } from \"unified\";\nimport { CustomRenderBarProps, OnSendContentParams } from \"../types\";\nimport { sanitizeInvalidTagName } from \"./utils/sanitize-invalid-tag-name\";\nimport { stripSvgTextLineBreaks } from \"./utils/strip-svg-text-line-breaks\";\nimport \"./contentRender.css\";\nimport \"./github-markdown-light.css\";\nimport CodeBlock from \"./CodeBlock\";\nimport CustomButtonInputVariable, {\n ComponentsWithCustomVariable,\n} from \"./plugins/CustomVariable\";\nimport MermaidChart from \"./plugins/MermaidChart\";\nimport {\n preserveCustomVariableProperties,\n restoreCustomVariableProperties,\n} from \"./utils/custom-variable-props\";\nimport {\n highlightLanguages,\n subsetLanguages,\n} from \"./utils/highlight-languages\";\n// import { processMarkdownText } from \"./utils/process-markdown\";\nimport {\n parseMarkdownSegments,\n mermaidBlockIsComplete,\n} from \"./utils/mermaid-parse\";\nimport { normalizeInlineHtml } from \"./utils/normalize-inline-html\";\nimport IframeSandbox from \"./IframeSandbox\";\nimport {\n splitContentSegments,\n type RenderSegment,\n} from \"./utils/split-content\";\nimport {\n getInteractionDefaultValues,\n type InteractionDefaultValueOptions,\n} from \"../../lib/interaction-defaults\";\nimport type { MarkdownFlowLocale } from \"../../lib/locale\";\nimport { getContentRenderLocaleTexts } from \"./contentRenderI18n\";\n\nconst SANDBOX_TAG_HINT_PATTERN =\n /<(script|style|link|iframe|html|head|body|meta|title|base|template|div|section|article|main)\\b/i;\n\n// Define component Props type\nexport interface ContentRenderProps {\n content: string;\n contentType?: string;\n /** Locale used for built-in UI text when a more specific text prop is not provided. */\n locale?: MarkdownFlowLocale;\n /**\n * Callback invoked when the custom button after content is clicked.\n * This button is rendered via the `<custom-button-after-content>` tag in markdown content.\n * @example\n * ```tsx\n * <ContentRender\n * content=\"Hello <custom-button-after-content>Ask</custom-button-after-content>\"\n * onClickCustomButtonAfterContent={() => console.log('Button clicked')}\n * />\n * ```\n */\n customRenderBar?: CustomRenderBarProps;\n onClickCustomButtonAfterContent?: () => void;\n onSend?: (content: OnSendContentParams) => void;\n typingSpeed?: number;\n enableTypewriter?: boolean;\n onTypeFinished?: () => void;\n onTypewriterStateChange?: (state: ContentRenderTypewriterState) => void;\n userInput?: string;\n interactionDefaultValueOptions?: InteractionDefaultValueOptions;\n defaultButtonText?: string;\n defaultInputText?: string; // Text input by user\n defaultSelectedValues?: string[]; // Default selected values for multi-select\n readonly?: boolean;\n // Multi-select confirm button text (i18n support)\n confirmButtonText?: string;\n // Copy button text (i18n support)\n copyButtonText?: string;\n // Copied state text (i18n support)\n copiedButtonText?: string;\n // Dynamic interaction format for multi-select support\n dynamicInteractionFormat?: string;\n // Loading text before first HTML block renders inside iframe (i18n support)\n sandboxLoadingText?: string;\n // Loading text while styles are being generated inside iframe\n sandboxStyleLoadingText?: string;\n // Loading text while scripts are being cached/executed inside iframe\n sandboxScriptLoadingText?: string;\n // Disable sandbox loading overlays when upper layers have already entered an error state\n disableSandboxLoadingOverlay?: boolean;\n // Fullscreen button text for iframe sandbox\n sandboxFullscreenButtonText?: string;\n // Exit fullscreen button text for iframe sandbox\n sandboxExitFullscreenButtonText?: string;\n // Sandbox render mode\n sandboxMode?: \"content\" | \"blackboard\";\n beforeSend?: (param: OnSendContentParams) => boolean;\n // tooltipMinLength?: number; // Control minimum character length for tooltip display, default 10\n}\n\nexport interface ContentRenderTypewriterState {\n isTypewriterEnabled: boolean;\n isTyping: boolean;\n isComplete: boolean;\n renderedLength: number;\n totalLength: number;\n}\n\n// Render svg string via Shadow DOM to avoid markdown wrapping\nconst SvgBlockInShadow: React.FC<{ svg: string }> = ({ svg }) => {\n const hostRef = useRef<HTMLDivElement>(null);\n\n useEffect(() => {\n const host = hostRef.current;\n if (!host) return;\n const shadowRoot = host.shadowRoot ?? host.attachShadow({ mode: \"open\" });\n const styleId = \"content-render-svg-style\";\n let styleEl = shadowRoot.getElementById(styleId) as HTMLStyleElement | null;\n\n if (!styleEl) {\n styleEl = document.createElement(\"style\");\n styleEl.id = styleId;\n // Keep intrinsic SVG width so the wrapper can scroll horizontally when needed\n styleEl.textContent = `\n svg { height: auto; display: inline-block; }\n svg.content-render-svg-el--responsive { width: 100%; max-width: 100%; }\n svg.content-render-svg-el--fixed { max-width: none; }\n `;\n shadowRoot.appendChild(styleEl);\n }\n\n const nodesToRemove = Array.from(shadowRoot.childNodes).filter(\n (node) => node !== styleEl\n );\n nodesToRemove.forEach((node) => shadowRoot.removeChild(node));\n\n const template = document.createElement(\"template\");\n const cleanedSvg = stripSvgTextLineBreaks(svg);\n template.innerHTML = cleanedSvg;\n shadowRoot.append(template.content.cloneNode(true));\n\n let hasResponsiveSvg = false;\n let hasFixedSvg = false;\n\n shadowRoot.querySelectorAll(\"svg\").forEach((svgEl) => {\n // Derive responsive sizing from viewBox so pure viewBox SVGs stay visible and fluid\n const viewBox = svgEl.getAttribute(\"viewBox\");\n if (!viewBox) return;\n\n const dimensions = viewBox\n .trim()\n .split(/[\\s,]+/)\n .map((value) => Number(value));\n\n if (dimensions.length !== 4 || dimensions.some(Number.isNaN)) return;\n\n const [, , viewBoxWidth, viewBoxHeight] = dimensions;\n const widthAttr = svgEl.getAttribute(\"width\");\n const heightAttr = svgEl.getAttribute(\"height\");\n const isRelativeLength = (value?: string | null) => {\n if (!value) return false;\n const normalized = value.trim().toLowerCase();\n return normalized === \"auto\" || normalized.endsWith(\"%\");\n };\n const toNumericLength = (value?: string | null) => {\n if (!value) return null;\n const normalized = value.trim().toLowerCase();\n if (normalized === \"auto\" || normalized.endsWith(\"%\")) {\n return null;\n }\n const parsed = Number.parseFloat(normalized);\n return Number.isNaN(parsed) ? null : parsed;\n };\n // Treat percentage/auto sizing as responsive so viewBox drives the layout\n const isWidthRelative = isRelativeLength(widthAttr);\n const isHeightRelative = isRelativeLength(heightAttr);\n const widthMissing = !widthAttr || widthAttr === \"0\";\n const heightMissing = !heightAttr || heightAttr === \"0\";\n const numericWidth = toNumericLength(widthAttr);\n const numericHeight = toNumericLength(heightAttr);\n const matchesViewBox =\n numericWidth === viewBoxWidth && numericHeight === viewBoxHeight;\n\n // Prefer responsive layout when sizing is relative or matches the viewBox\n const shouldUseResponsiveSize =\n isWidthRelative ||\n isHeightRelative ||\n (widthMissing && heightMissing) ||\n matchesViewBox;\n\n if (shouldUseResponsiveSize) {\n hasResponsiveSvg = true;\n svgEl.classList.add(\"content-render-svg-el--responsive\");\n svgEl.classList.remove(\"content-render-svg-el--fixed\");\n svgEl.style.width = \"100%\";\n svgEl.style.height = \"auto\";\n if (!svgEl.style.aspectRatio && viewBoxHeight > 0) {\n svgEl.style.aspectRatio = `${viewBoxWidth} / ${viewBoxHeight}`;\n }\n return;\n }\n\n hasFixedSvg = true;\n svgEl.classList.add(\"content-render-svg-el--fixed\");\n svgEl.classList.remove(\"content-render-svg-el--responsive\");\n if (widthMissing && viewBoxWidth > 0) {\n svgEl.setAttribute(\"width\", `${viewBoxWidth}`);\n }\n if (heightMissing && viewBoxHeight > 0) {\n svgEl.setAttribute(\"height\", `${viewBoxHeight}`);\n }\n });\n\n const hostResponsive = hasResponsiveSvg && !hasFixedSvg;\n host.classList.toggle(\"content-render-svg--responsive\", hostResponsive);\n host.classList.toggle(\"content-render-svg--fixed\", !hostResponsive);\n }, [svg]);\n\n return (\n <div className=\"content-render-svg-scroll\">\n <div className=\"content-render-svg\" ref={hostRef} />\n </div>\n );\n};\n\n// Extended component interface\ntype CustomComponents = ComponentsWithCustomVariable & {\n \"custom-button-after-content\"?: React.ComponentType<{\n children: React.ReactNode;\n }>;\n};\n\ntype MarkdownComponentRuntimeValues = {\n beforeSend?: (param: OnSendContentParams) => boolean;\n locale?: MarkdownFlowLocale;\n onClickCustomButtonAfterContent?: () => void;\n onSend?: (content: OnSendContentParams) => void;\n readonly: boolean;\n renderContent: string;\n resolvedConfirmButtonText: string;\n resolvedCopiedButtonText: string;\n resolvedCopyButtonText: string;\n resolvedDefaultButtonText?: string;\n resolvedDefaultInputText?: string;\n resolvedDefaultSelectedValues?: string[];\n};\n\nconst remarkPlugins: PluggableList = [\n remarkGfm,\n remarkMath,\n remarkFlow,\n remarkBreaks,\n];\n\nconst rehypePlugins: PluggableList = [\n preserveCustomVariableProperties,\n rehypeRaw,\n sanitizeInvalidTagName,\n restoreCustomVariableProperties,\n [rehypeHighlight, { languages: highlightLanguages, subset: subsetLanguages }],\n rehypeKatex,\n];\n\nexport const MarkdownRenderer: React.FC<{\n content: string;\n components: CustomComponents;\n}> = ({ content: markdownContent, components }) => (\n <div className=\"markdown-renderer\">\n <ReactMarkdown\n remarkPlugins={remarkPlugins}\n rehypePlugins={rehypePlugins}\n components={components}\n >\n {markdownContent}\n </ReactMarkdown>\n </div>\n);\n\nconst mergeNonSandboxSegments = (segments: RenderSegment[]) => {\n if (segments.length <= 1) return segments;\n const merged: RenderSegment[] = [];\n\n segments.forEach((segment) => {\n if (segment.type === \"sandbox\") {\n merged.push(segment);\n return;\n }\n\n const last = merged[merged.length - 1];\n if (last && last.type !== \"sandbox\") {\n merged[merged.length - 1] = {\n type: \"markdown\",\n value: `${last.value}${segment.value}`,\n };\n return;\n }\n\n merged.push({ type: \"markdown\", value: segment.value });\n });\n\n return merged;\n};\n\nconst splitTextByCharacterChunk = (value: string, chunkSize: number) => {\n const safeChunkSize = Math.max(1, chunkSize);\n const characters = Array.from(value);\n\n return {\n chunk: characters.slice(0, safeChunkSize).join(\"\"),\n rest: characters.slice(safeChunkSize).join(\"\"),\n };\n};\n\nconst areStringArraysEqual = (left?: string[], right?: string[]) => {\n if (left === right) {\n return true;\n }\n if (!left || !right || left.length !== right.length) {\n return false;\n }\n return left.every((value, index) => value === right[index]);\n};\n\nconst useStableStringArray = (values?: string[]) => {\n const valuesRef = useRef<string[] | undefined>(values);\n\n if (!areStringArraysEqual(valuesRef.current, values)) {\n valuesRef.current = values;\n }\n\n return valuesRef.current;\n};\n\nconst ContentRender: React.FC<ContentRenderProps> = ({\n content,\n contentType,\n locale,\n customRenderBar,\n onSend,\n typingSpeed = 40,\n enableTypewriter = false,\n onTypeFinished,\n onTypewriterStateChange,\n userInput,\n interactionDefaultValueOptions,\n defaultButtonText,\n defaultInputText,\n defaultSelectedValues,\n readonly = false,\n confirmButtonText,\n copyButtonText,\n copiedButtonText,\n sandboxLoadingText,\n sandboxStyleLoadingText,\n sandboxScriptLoadingText,\n disableSandboxLoadingOverlay = false,\n sandboxFullscreenButtonText,\n sandboxExitFullscreenButtonText,\n sandboxMode = \"content\",\n onClickCustomButtonAfterContent,\n beforeSend,\n // tooltipMinLength,\n}) => {\n const localeTexts = getContentRenderLocaleTexts(locale);\n const resolvedConfirmButtonText =\n confirmButtonText || localeTexts.confirmButtonText;\n const resolvedCopyButtonText = copyButtonText || localeTexts.copyButtonText;\n const resolvedCopiedButtonText =\n copiedButtonText || localeTexts.copiedButtonText;\n const resolvedSandboxFullscreenButtonText =\n sandboxFullscreenButtonText || localeTexts.sandboxFullscreenButtonText;\n const resolvedSandboxExitFullscreenButtonText =\n sandboxExitFullscreenButtonText ||\n localeTexts.sandboxExitFullscreenButtonText;\n const shouldApplyTypewriterByContentType =\n !contentType || contentType === \"text\";\n const isTypewriterEnabled =\n Boolean(enableTypewriter) && shouldApplyTypewriterByContentType;\n const typewriterChunkSize = 2;\n const typewriterTickMs = Math.max(0, typingSpeed);\n const [displayContent, setDisplayContent] = useState(() =>\n isTypewriterEnabled ? \"\" : content\n );\n const pendingContentRef = useRef(\"\");\n const previousTypewriterEnabledRef = useRef(isTypewriterEnabled);\n const hasReportedTypeFinishedRef = useRef(false);\n\n useEffect(() => {\n const wasTypewriterEnabled = previousTypewriterEnabledRef.current;\n previousTypewriterEnabledRef.current = isTypewriterEnabled;\n hasReportedTypeFinishedRef.current = false;\n\n if (!isTypewriterEnabled) {\n pendingContentRef.current = \"\";\n setDisplayContent(content);\n return;\n }\n\n setDisplayContent((current) => {\n const shouldRestartTyping = !wasTypewriterEnabled;\n const canContinueTyping = content.startsWith(current);\n\n if (!shouldRestartTyping && !canContinueTyping) {\n pendingContentRef.current = \"\";\n return content;\n }\n\n const nextVisibleContent =\n shouldRestartTyping || !canContinueTyping ? \"\" : current;\n\n pendingContentRef.current = content.slice(nextVisibleContent.length);\n return nextVisibleContent;\n });\n }, [content, isTypewriterEnabled]);\n\n useEffect(() => {\n if (!isTypewriterEnabled) {\n return;\n }\n\n if (\n hasReportedTypeFinishedRef.current ||\n pendingContentRef.current ||\n displayContent !== content\n ) {\n return;\n }\n\n hasReportedTypeFinishedRef.current = true;\n onTypeFinished?.();\n }, [content, displayContent, isTypewriterEnabled, onTypeFinished]);\n\n useEffect(() => {\n if (!isTypewriterEnabled || !pendingContentRef.current) {\n return undefined;\n }\n\n const typewriterTimer = window.setTimeout(() => {\n setDisplayContent((current) => {\n const { chunk, rest } = splitTextByCharacterChunk(\n pendingContentRef.current,\n typewriterChunkSize\n );\n\n if (!chunk) {\n return current;\n }\n\n pendingContentRef.current = rest;\n return `${current}${chunk}`;\n });\n }, typewriterTickMs);\n\n return () => window.clearTimeout(typewriterTimer);\n }, [\n content,\n displayContent,\n isTypewriterEnabled,\n typewriterChunkSize,\n typewriterTickMs,\n ]);\n\n const typewriterState = useMemo<ContentRenderTypewriterState>(\n () => ({\n isTypewriterEnabled,\n isTyping: isTypewriterEnabled && displayContent !== content,\n isComplete: displayContent === content,\n renderedLength: displayContent.length,\n totalLength: content.length,\n }),\n [content, displayContent, isTypewriterEnabled]\n );\n\n useEffect(() => {\n onTypewriterStateChange?.(typewriterState);\n }, [onTypewriterStateChange, typewriterState]);\n\n const renderContent = isTypewriterEnabled ? displayContent : content;\n const normalizedContent = useMemo(\n () => normalizeInlineHtml(renderContent),\n [renderContent]\n );\n\n const interactionDefaults = useMemo(\n () =>\n getInteractionDefaultValues(\n renderContent,\n userInput,\n interactionDefaultValueOptions\n ),\n [interactionDefaultValueOptions, renderContent, userInput]\n );\n\n const resolvedDefaultButtonText =\n defaultButtonText?.trim() || interactionDefaults.buttonText;\n const resolvedDefaultInputText =\n defaultInputText?.trim() || interactionDefaults.inputText;\n const fallbackSelectedValues = useMemo(\n () =>\n userInput\n ? userInput\n .split(\",\")\n .map((value) => value.trim())\n .filter(Boolean)\n : undefined,\n [userInput]\n );\n const resolvedDefaultSelectedValues = defaultSelectedValues?.length\n ? defaultSelectedValues\n : interactionDefaults.selectedValues || fallbackSelectedValues;\n const stableDefaultSelectedValues = useStableStringArray(\n resolvedDefaultSelectedValues\n );\n const componentRuntimeValuesRef = useRef<MarkdownComponentRuntimeValues>({\n beforeSend,\n locale,\n onClickCustomButtonAfterContent,\n onSend,\n readonly,\n renderContent,\n resolvedConfirmButtonText,\n resolvedCopiedButtonText,\n resolvedCopyButtonText,\n resolvedDefaultButtonText,\n resolvedDefaultInputText,\n resolvedDefaultSelectedValues: stableDefaultSelectedValues,\n });\n\n componentRuntimeValuesRef.current = {\n beforeSend,\n locale,\n onClickCustomButtonAfterContent,\n onSend,\n readonly,\n renderContent,\n resolvedConfirmButtonText,\n resolvedCopiedButtonText,\n resolvedCopyButtonText,\n resolvedDefaultButtonText,\n resolvedDefaultInputText,\n resolvedDefaultSelectedValues: stableDefaultSelectedValues,\n };\n\n const components = useMemo<CustomComponents>(\n () => ({\n \"custom-button-after-content\": ({\n children,\n }: {\n children: React.ReactNode;\n }) => {\n return (\n <button\n className=\"content-render-custom-button-after-content\"\n onClick={\n componentRuntimeValuesRef.current.onClickCustomButtonAfterContent\n }\n >\n <span className=\"content-render-custom-button-after-content-inner\">\n {children}\n </span>\n </button>\n );\n },\n \"custom-variable\": (props) => (\n <CustomButtonInputVariable\n {...props}\n readonly={componentRuntimeValuesRef.current.readonly}\n defaultButtonText={\n componentRuntimeValuesRef.current.resolvedDefaultButtonText\n }\n defaultInputText={\n componentRuntimeValuesRef.current.resolvedDefaultInputText\n }\n defaultSelectedValues={\n componentRuntimeValuesRef.current.resolvedDefaultSelectedValues\n }\n onSend={componentRuntimeValuesRef.current.onSend}\n beforeSend={componentRuntimeValuesRef.current.beforeSend}\n locale={componentRuntimeValuesRef.current.locale}\n confirmButtonText={\n componentRuntimeValuesRef.current.resolvedConfirmButtonText\n }\n // tooltipMinLength={tooltipMinLength}\n />\n ),\n code: (props) => {\n const { className, children, ...rest } = props as {\n className?: string;\n children?: React.ReactNode;\n };\n const match = /language-(\\w+)/.exec(className || \"\");\n const language = match?.[1];\n if (language === \"mermaid\") {\n const chartContent = children?.toString().replace(/\\n$/, \"\") || \"\";\n const frozen = mermaidBlockIsComplete(\n componentRuntimeValuesRef.current.renderContent,\n chartContent\n );\n return <MermaidChart chart={chartContent} frozen={frozen} />;\n }\n\n return (\n <code className={className} {...rest}>\n {children}\n </code>\n );\n },\n table: ({ ...props }) => (\n <div className=\"content-render-table-container\">\n <table className=\"content-render-table\" {...props} />\n </div>\n ),\n th: ({ ...props }) => <th className=\"content-render-th\" {...props} />,\n td: ({ ...props }) => <td className=\"content-render-td\" {...props} />,\n tr: ({ ...props }) => <tr className=\"content-render-tr\" {...props} />,\n li: ({ node, ...props }) => {\n const className = node?.properties?.className;\n const hasTaskListItem =\n (typeof className === \"string\" &&\n className.includes(\"task-list-item\")) ||\n (Array.isArray(className) && className.includes(\"task-list-item\"));\n if (hasTaskListItem) {\n return <li className=\"content-render-task-list-item\" {...props} />;\n }\n return <li {...props} />;\n },\n ol: ({ ...props }) => <ol className=\"content-render-ol\" {...props} />,\n ul: ({ ...props }) => <ul className=\"content-render-ul\" {...props} />,\n input: ({ ...props }) => {\n if (props.type === \"checkbox\") {\n return (\n <input\n type=\"checkbox\"\n className=\"content-render-checkbox\"\n disabled\n {...props}\n />\n );\n }\n return <input {...props} />;\n },\n a: ({ children, ...props }) => (\n <a target=\"_blank\" rel=\"noopener noreferrer\" {...props}>\n {children}\n </a>\n ),\n pre: (props) => (\n <CodeBlock\n {...props}\n copyButtonText={\n componentRuntimeValuesRef.current.resolvedCopyButtonText\n }\n copiedButtonText={\n componentRuntimeValuesRef.current.resolvedCopiedButtonText\n }\n />\n ),\n }),\n []\n );\n\n const hasPotentialSandboxTags = useMemo(\n () => SANDBOX_TAG_HINT_PATTERN.test(renderContent),\n [renderContent]\n );\n\n const renderSegments = useMemo(\n () =>\n hasPotentialSandboxTags ? splitContentSegments(renderContent, true) : [],\n [renderContent, hasPotentialSandboxTags]\n );\n\n const hasSandbox = renderSegments.some(\n (segment) => segment.type === \"sandbox\"\n );\n const mergedRenderSegments = useMemo(\n () => mergeNonSandboxSegments(renderSegments),\n [renderSegments]\n );\n\n const segments = useMemo(\n () => parseMarkdownSegments(normalizedContent),\n [normalizedContent]\n );\n\n const renderMarkdownSegments = (raw: string, keyPrefix: string) => {\n const normalized = normalizeInlineHtml(raw);\n const parsed = parseMarkdownSegments(normalized);\n\n return parsed.map((seg, index) => {\n const key = `${keyPrefix}-${seg.type}-${index}`;\n\n if (seg.type === \"text\") {\n return (\n <MarkdownRenderer\n key={key}\n components={components}\n content={seg.value}\n />\n );\n }\n\n if (seg.type === \"mermaid\") {\n return (\n <MermaidChart key={key} chart={seg.value} frozen={!seg.complete} />\n );\n }\n\n if (seg.type === \"svg\") {\n return <SvgBlockInShadow key={key} svg={seg.value} />;\n }\n\n return null;\n });\n };\n\n if (hasSandbox) {\n return (\n <div className=\"content-render markdown-body\">\n {mergedRenderSegments.map((segment, idx) =>\n segment.type === \"sandbox\" ? (\n <IframeSandbox\n key={`sandbox-${idx}`}\n hideFullScreen\n type=\"sandbox\"\n content={segment.value}\n className=\"content-render-iframe\"\n locale={locale}\n loadingText={sandboxLoadingText}\n styleLoadingText={sandboxStyleLoadingText}\n scriptLoadingText={sandboxScriptLoadingText}\n disableLoadingOverlay={disableSandboxLoadingOverlay}\n fullScreenButtonText={resolvedSandboxFullscreenButtonText}\n exitFullScreenButtonText={resolvedSandboxExitFullscreenButtonText}\n mode={sandboxMode}\n />\n ) : (\n <React.Fragment key={`md-${idx}`}>\n {renderMarkdownSegments(segment.value, `md-${idx}`)}\n </React.Fragment>\n )\n )}\n </div>\n );\n }\n\n return (\n <div className=\"content-render markdown-body\">\n {segments.map((seg, index) => {\n if (seg.type === \"text\") {\n return (\n <MarkdownRenderer\n key={index}\n components={components}\n content={seg.value}\n />\n );\n }\n\n if (seg.type === \"mermaid\") {\n return (\n <MermaidChart\n key={index}\n chart={seg.value}\n frozen={!seg.complete}\n />\n );\n }\n\n if (seg.type === \"svg\") {\n return <SvgBlockInShadow key={index} svg={seg.value} />;\n }\n })}\n\n {customRenderBar && (\n <div className=\"content-render-custom-bar\">\n {React.createElement(customRenderBar, {\n content,\n displayContent: normalizedContent,\n onSend,\n })}\n </div>\n )}\n </div>\n );\n};\n\nexport default ContentRender;\n"],"names":["SANDBOX_TAG_HINT_PATTERN","SvgBlockInShadow","svg","hostRef","useRef","useEffect","host","shadowRoot","styleId","styleEl","node","template","cleanedSvg","stripSvgTextLineBreaks","hasResponsiveSvg","hasFixedSvg","svgEl","viewBox","dimensions","value","viewBoxWidth","viewBoxHeight","widthAttr","heightAttr","isRelativeLength","normalized","toNumericLength","parsed","isWidthRelative","isHeightRelative","widthMissing","heightMissing","numericWidth","numericHeight","hostResponsive","jsx","remarkPlugins","remarkGfm","remarkMath","remarkFlow","remarkBreaks","rehypePlugins","preserveCustomVariableProperties","rehypeRaw","sanitizeInvalidTagName","restoreCustomVariableProperties","rehypeHighlight","highlightLanguages","subsetLanguages","rehypeKatex","MarkdownRenderer","markdownContent","components","ReactMarkdown","mergeNonSandboxSegments","segments","merged","segment","last","splitTextByCharacterChunk","chunkSize","safeChunkSize","characters","areStringArraysEqual","left","right","index","useStableStringArray","values","valuesRef","ContentRender","content","contentType","locale","customRenderBar","onSend","typingSpeed","enableTypewriter","onTypeFinished","onTypewriterStateChange","userInput","interactionDefaultValueOptions","defaultButtonText","defaultInputText","defaultSelectedValues","readonly","confirmButtonText","copyButtonText","copiedButtonText","sandboxLoadingText","sandboxStyleLoadingText","sandboxScriptLoadingText","disableSandboxLoadingOverlay","sandboxFullscreenButtonText","sandboxExitFullscreenButtonText","sandboxMode","onClickCustomButtonAfterContent","beforeSend","localeTexts","getContentRenderLocaleTexts","resolvedConfirmButtonText","resolvedCopyButtonText","resolvedCopiedButtonText","resolvedSandboxFullscreenButtonText","resolvedSandboxExitFullscreenButtonText","isTypewriterEnabled","typewriterChunkSize","typewriterTickMs","displayContent","setDisplayContent","useState","pendingContentRef","previousTypewriterEnabledRef","hasReportedTypeFinishedRef","wasTypewriterEnabled","current","shouldRestartTyping","canContinueTyping","nextVisibleContent","typewriterTimer","chunk","rest","typewriterState","useMemo","renderContent","normalizedContent","normalizeInlineHtml","interactionDefaults","getInteractionDefaultValues","resolvedDefaultButtonText","resolvedDefaultInputText","fallbackSelectedValues","resolvedDefaultSelectedValues","stableDefaultSelectedValues","componentRuntimeValuesRef","children","props","CustomButtonInputVariable","className","chartContent","frozen","mermaidBlockIsComplete","MermaidChart","CodeBlock","hasPotentialSandboxTags","renderSegments","splitContentSegments","hasSandbox","mergedRenderSegments","parseMarkdownSegments","renderMarkdownSegments","raw","keyPrefix","seg","key","idx","IframeSandbox","React","jsxs"],"mappings":"kwCA8CMA,GACJ,kGAmEIC,GAA8C,CAAC,C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C,EACnB,sBAAuBC,EACvB,qBAAsBW,EACtB,yBAA0BC,GAC1B,KAAMT,CAAA,EAZD,WAAW4D,CAAG,EAAA,EAerBxH,EAAAA,kBAAAA,IAAC0H,EAAM,SAAN,CACE,SAAAP,GAAuB7F,EAAQ,MAAO,MAAMkG,CAAG,EAAE,CAAA,EAD/B,MAAMA,CAAG,EAE9B,CAAA,EAGN,EAKFG,EAAAA,kBAAAA,KAAC,MAAA,CAAI,UAAU,+BACZ,SAAA,CAAAvG,GAAS,IAAI,CAACkG,EAAKvF,IAAU,CAC5B,GAAIuF,EAAI,OAAS,OACf,OACEtH,EAAAA,kBAAAA,IAACe,EAAA,CAEC,WAAAE,GACA,QAASqG,EAAI,KAAA,EAFRvF,CAAA,EAOX,GAAIuF,EAAI,OAAS,UACf,OACEtH,EAAAA,kBAAAA,IAAC2G,EAAAA,QAAA,CAEC,MAAOW,EAAI,MACX,OAAQ,CAACA,EAAI,QAAA,EAFRvF,CAAA,EAOX,GAAIuF,EAAI,OAAS,MACf,OAAOtH,EAAAA,kBAAAA,IAAClC,GAAA,CAA6B,IAAKwJ,EAAI,OAAhBvF,CAAuB,CAEzD,CAAC,EAEAQ,GACCvC,EAAAA,kBAAAA,IAAC,MAAA,CAAI,UAAU,4BACZ,SAAA0H,EAAM,cAAcnF,EAAiB,CACpC,QAAAH,EACA,eAAgBsD,EAChB,OAAAlD,CAAA,CACD,CAAA,CACH,CAAA,EAEJ,CAEJ"}
|
|
1
|
+
{"version":3,"file":"ContentRender.cjs","sources":["../../../src/components/ContentRender/ContentRender.tsx"],"sourcesContent":["import React, { useEffect, useMemo, useRef, useState } from \"react\";\nimport ReactMarkdown from \"react-markdown\";\nimport rehypeHighlight from \"rehype-highlight\";\nimport rehypeKatex from \"rehype-katex\";\nimport rehypeRaw from \"rehype-raw\";\nimport remarkBreaks from \"remark-breaks\";\nimport remarkFlow from \"remark-flow\";\nimport remarkGfm from \"remark-gfm\";\nimport remarkMath from \"remark-math\";\nimport type { PluggableList } from \"unified\";\nimport { CustomRenderBarProps, OnSendContentParams } from \"../types\";\nimport { sanitizeInvalidTagName } from \"./utils/sanitize-invalid-tag-name\";\nimport { stripSvgTextLineBreaks } from \"./utils/strip-svg-text-line-breaks\";\nimport \"./contentRender.css\";\nimport \"./github-markdown-light.css\";\nimport \"highlight.js/styles/github.css\";\nimport \"katex/dist/katex.min.css\";\nimport CodeBlock, { CodeBlockContext } from \"./CodeBlock\";\nimport CustomButtonInputVariable, {\n ComponentsWithCustomVariable,\n} from \"./plugins/CustomVariable\";\nimport MermaidChart, { type MermaidChartProps } from \"./plugins/MermaidChart\";\nimport {\n preserveCustomVariableProperties,\n restoreCustomVariableProperties,\n} from \"./utils/custom-variable-props\";\nimport {\n highlightLanguages,\n subsetLanguages,\n} from \"./utils/highlight-languages\";\n// import { processMarkdownText } from \"./utils/process-markdown\";\nimport {\n parseMarkdownSegments,\n mermaidBlockIsComplete,\n} from \"./utils/mermaid-parse\";\nimport { normalizeInlineHtml } from \"./utils/normalize-inline-html\";\nimport IframeSandbox from \"./IframeSandbox\";\nimport {\n splitContentSegments,\n type RenderSegment,\n} from \"./utils/split-content\";\nimport {\n getInteractionDefaultValues,\n type InteractionDefaultValueOptions,\n} from \"../../lib/interaction-defaults\";\nimport {\n getMarkdownFlowDirection,\n getMarkdownFlowLanguage,\n type MarkdownFlowLocale,\n} from \"../../lib/locale\";\nimport { getContentRenderLocaleTexts } from \"./contentRenderI18n\";\n\nconst SANDBOX_TAG_HINT_PATTERN =\n /<(script|style|link|iframe|html|head|body|meta|title|base|template|div|section|article|main)\\b/i;\n\n// Define component Props type\nexport interface ContentRenderProps {\n content: string;\n contentType?: string;\n /** Locale used for built-in UI text when a more specific text prop is not provided. */\n locale?: MarkdownFlowLocale;\n /** Overrides the locale-derived language; omitted values inherit from the host. */\n lang?: string;\n /** Overrides locale-derived direction; omitted values inherit when no locale is set. */\n dir?: React.HTMLAttributes<HTMLDivElement>[\"dir\"];\n /**\n * Callback invoked when the custom button after content is clicked.\n * This button is rendered via the `<custom-button-after-content>` tag in markdown content.\n * @example\n * ```tsx\n * <ContentRender\n * content=\"Hello <custom-button-after-content>Ask</custom-button-after-content>\"\n * onClickCustomButtonAfterContent={() => console.log('Button clicked')}\n * />\n * ```\n */\n customRenderBar?: CustomRenderBarProps;\n onClickCustomButtonAfterContent?: () => void;\n onSend?: (content: OnSendContentParams) => void;\n typingSpeed?: number;\n enableTypewriter?: boolean;\n onTypeFinished?: () => void;\n onTypewriterStateChange?: (state: ContentRenderTypewriterState) => void;\n userInput?: string;\n interactionDefaultValueOptions?: InteractionDefaultValueOptions;\n defaultButtonText?: string;\n defaultInputText?: string; // Text input by user\n defaultSelectedValues?: string[]; // Default selected values for multi-select\n readonly?: boolean;\n // Multi-select confirm button text (i18n support)\n confirmButtonText?: string;\n // Copy button text (i18n support)\n copyButtonText?: string;\n // Copied state text (i18n support)\n copiedButtonText?: string;\n // Dynamic interaction format for multi-select support\n dynamicInteractionFormat?: string;\n // Loading text before first HTML block renders inside iframe (i18n support)\n sandboxLoadingText?: string;\n // Loading text while styles are being generated inside iframe\n sandboxStyleLoadingText?: string;\n // Loading text while scripts are being cached/executed inside iframe\n sandboxScriptLoadingText?: string;\n // Disable sandbox loading overlays when upper layers have already entered an error state\n disableSandboxLoadingOverlay?: boolean;\n // Fullscreen button text for iframe sandbox\n sandboxFullscreenButtonText?: string;\n // Exit fullscreen button text for iframe sandbox\n sandboxExitFullscreenButtonText?: string;\n // Sandbox render mode\n sandboxMode?: \"content\" | \"blackboard\";\n beforeSend?: (param: OnSendContentParams) => boolean;\n // tooltipMinLength?: number; // Control minimum character length for tooltip display, default 10\n}\n\nexport interface ContentRenderTypewriterState {\n isTypewriterEnabled: boolean;\n isTyping: boolean;\n isComplete: boolean;\n renderedLength: number;\n totalLength: number;\n}\n\n// Render svg string via Shadow DOM to avoid markdown wrapping\nconst SvgBlockInShadow: React.FC<{ svg: string }> = ({ svg }) => {\n const hostRef = useRef<HTMLDivElement>(null);\n\n useEffect(() => {\n const host = hostRef.current;\n if (!host) return;\n const shadowRoot = host.shadowRoot ?? host.attachShadow({ mode: \"open\" });\n const styleId = \"content-render-svg-style\";\n let styleEl = shadowRoot.getElementById(styleId) as HTMLStyleElement | null;\n\n if (!styleEl) {\n styleEl = document.createElement(\"style\");\n styleEl.id = styleId;\n // Keep intrinsic SVG width so the wrapper can scroll horizontally when needed\n styleEl.textContent = `\n svg { height: auto; display: inline-block; }\n svg.content-render-svg-el--responsive { width: 100%; max-width: 100%; }\n svg.content-render-svg-el--fixed { max-width: none; }\n `;\n shadowRoot.appendChild(styleEl);\n }\n\n const nodesToRemove = Array.from(shadowRoot.childNodes).filter(\n (node) => node !== styleEl\n );\n nodesToRemove.forEach((node) => shadowRoot.removeChild(node));\n\n const template = document.createElement(\"template\");\n const cleanedSvg = stripSvgTextLineBreaks(svg);\n template.innerHTML = cleanedSvg;\n shadowRoot.append(template.content.cloneNode(true));\n\n let hasResponsiveSvg = false;\n let hasFixedSvg = false;\n\n shadowRoot.querySelectorAll(\"svg\").forEach((svgEl) => {\n // Derive responsive sizing from viewBox so pure viewBox SVGs stay visible and fluid\n const viewBox = svgEl.getAttribute(\"viewBox\");\n if (!viewBox) return;\n\n const dimensions = viewBox\n .trim()\n .split(/[\\s,]+/)\n .map((value) => Number(value));\n\n if (dimensions.length !== 4 || dimensions.some(Number.isNaN)) return;\n\n const [, , viewBoxWidth, viewBoxHeight] = dimensions;\n const widthAttr = svgEl.getAttribute(\"width\");\n const heightAttr = svgEl.getAttribute(\"height\");\n const isRelativeLength = (value?: string | null) => {\n if (!value) return false;\n const normalized = value.trim().toLowerCase();\n return normalized === \"auto\" || normalized.endsWith(\"%\");\n };\n const toNumericLength = (value?: string | null) => {\n if (!value) return null;\n const normalized = value.trim().toLowerCase();\n if (normalized === \"auto\" || normalized.endsWith(\"%\")) {\n return null;\n }\n const parsed = Number.parseFloat(normalized);\n return Number.isNaN(parsed) ? null : parsed;\n };\n // Treat percentage/auto sizing as responsive so viewBox drives the layout\n const isWidthRelative = isRelativeLength(widthAttr);\n const isHeightRelative = isRelativeLength(heightAttr);\n const widthMissing = !widthAttr || widthAttr === \"0\";\n const heightMissing = !heightAttr || heightAttr === \"0\";\n const numericWidth = toNumericLength(widthAttr);\n const numericHeight = toNumericLength(heightAttr);\n const matchesViewBox =\n numericWidth === viewBoxWidth && numericHeight === viewBoxHeight;\n\n // Prefer responsive layout when sizing is relative or matches the viewBox\n const shouldUseResponsiveSize =\n isWidthRelative ||\n isHeightRelative ||\n (widthMissing && heightMissing) ||\n matchesViewBox;\n\n if (shouldUseResponsiveSize) {\n hasResponsiveSvg = true;\n svgEl.classList.add(\"content-render-svg-el--responsive\");\n svgEl.classList.remove(\"content-render-svg-el--fixed\");\n svgEl.style.width = \"100%\";\n svgEl.style.height = \"auto\";\n if (!svgEl.style.aspectRatio && viewBoxHeight > 0) {\n svgEl.style.aspectRatio = `${viewBoxWidth} / ${viewBoxHeight}`;\n }\n return;\n }\n\n hasFixedSvg = true;\n svgEl.classList.add(\"content-render-svg-el--fixed\");\n svgEl.classList.remove(\"content-render-svg-el--responsive\");\n if (widthMissing && viewBoxWidth > 0) {\n svgEl.setAttribute(\"width\", `${viewBoxWidth}`);\n }\n if (heightMissing && viewBoxHeight > 0) {\n svgEl.setAttribute(\"height\", `${viewBoxHeight}`);\n }\n });\n\n const hostResponsive = hasResponsiveSvg && !hasFixedSvg;\n host.classList.toggle(\"content-render-svg--responsive\", hostResponsive);\n host.classList.toggle(\"content-render-svg--fixed\", !hostResponsive);\n }, [svg]);\n\n return (\n <div className=\"content-render-svg-scroll\">\n <div className=\"content-render-svg\" ref={hostRef} />\n </div>\n );\n};\n\n// Extended component interface\ntype CustomComponents = ComponentsWithCustomVariable & {\n \"custom-button-after-content\"?: React.ComponentType<{\n children: React.ReactNode;\n }>;\n};\n\ntype MarkdownComponentRuntimeValues = {\n direction?: ContentRenderProps[\"dir\"];\n language?: string;\n mermaidMessages: MermaidChartProps[\"messages\"];\n beforeSend?: (param: OnSendContentParams) => boolean;\n locale?: MarkdownFlowLocale;\n onClickCustomButtonAfterContent?: () => void;\n onSend?: (content: OnSendContentParams) => void;\n readonly: boolean;\n renderContent: string;\n resolvedConfirmButtonText: string;\n resolvedCopiedButtonText: string;\n resolvedCopyButtonText: string;\n resolvedDefaultButtonText?: string;\n resolvedDefaultInputText?: string;\n resolvedDefaultSelectedValues?: string[];\n};\n\nconst MarkdownComponentRuntimeContext =\n React.createContext<React.RefObject<MarkdownComponentRuntimeValues> | null>(\n null\n );\n\nconst MarkdownCode = (props: React.ComponentProps<\"code\">) => {\n const runtimeValuesRef = React.useContext(MarkdownComponentRuntimeContext);\n const isInCodeBlock = React.useContext(CodeBlockContext);\n if (!runtimeValuesRef) {\n throw new Error(\"Markdown code renderer requires ContentRender context.\");\n }\n const { className, children, ...rest } = props as {\n className?: string;\n children?: React.ReactNode;\n dir?: string;\n };\n const match = /language-(\\w+)/.exec(className || \"\");\n const language = match?.[1];\n if (language === \"mermaid\") {\n const chartContent = children?.toString().replace(/\\n$/, \"\") || \"\";\n const frozen = mermaidBlockIsComplete(\n runtimeValuesRef.current.renderContent,\n chartContent\n );\n return (\n <MermaidChart\n chart={chartContent}\n frozen={frozen}\n messages={runtimeValuesRef.current.mermaidMessages}\n />\n );\n }\n\n return (\n <code\n className={className}\n {...rest}\n dir={rest.dir ?? (isInCodeBlock ? undefined : \"ltr\")}\n >\n {children}\n </code>\n );\n};\n\nconst remarkPlugins: PluggableList = [\n remarkGfm,\n remarkMath,\n remarkFlow,\n remarkBreaks,\n];\n\nconst rehypePlugins: PluggableList = [\n preserveCustomVariableProperties,\n rehypeRaw,\n sanitizeInvalidTagName,\n restoreCustomVariableProperties,\n [rehypeHighlight, { languages: highlightLanguages, subset: subsetLanguages }],\n rehypeKatex,\n];\n\nexport const MarkdownRenderer: React.FC<{\n content: string;\n components: CustomComponents;\n locale?: MarkdownFlowLocale;\n}> = ({ content: markdownContent, components, locale }) => {\n const texts = getContentRenderLocaleTexts(locale);\n return (\n <div className=\"markdown-renderer\">\n <ReactMarkdown\n remarkPlugins={remarkPlugins}\n rehypePlugins={rehypePlugins}\n remarkRehypeOptions={{\n footnoteLabel: texts.footnoteLabel,\n footnoteBackLabel: (referenceIndex, rereferenceIndex) => {\n const reference =\n String(referenceIndex + 1) +\n (rereferenceIndex > 1 ? `-${rereferenceIndex}` : \"\");\n return texts.footnoteBackLabel.replace(\"{reference}\", reference);\n },\n }}\n components={components}\n >\n {markdownContent}\n </ReactMarkdown>\n </div>\n );\n};\n\nconst mergeNonSandboxSegments = (segments: RenderSegment[]) => {\n if (segments.length <= 1) return segments;\n const merged: RenderSegment[] = [];\n\n segments.forEach((segment) => {\n if (segment.type === \"sandbox\") {\n merged.push(segment);\n return;\n }\n\n const last = merged[merged.length - 1];\n if (last && last.type !== \"sandbox\") {\n merged[merged.length - 1] = {\n type: \"markdown\",\n value: `${last.value}${segment.value}`,\n };\n return;\n }\n\n merged.push({ type: \"markdown\", value: segment.value });\n });\n\n return merged;\n};\n\nconst splitTextByCharacterChunk = (value: string, chunkSize: number) => {\n const safeChunkSize = Math.max(1, chunkSize);\n const characters = Array.from(value);\n\n return {\n chunk: characters.slice(0, safeChunkSize).join(\"\"),\n rest: characters.slice(safeChunkSize).join(\"\"),\n };\n};\n\nconst areStringArraysEqual = (left?: string[], right?: string[]) => {\n if (left === right) {\n return true;\n }\n if (!left || !right || left.length !== right.length) {\n return false;\n }\n return left.every((value, index) => value === right[index]);\n};\n\nconst useStableStringArray = (values?: string[]) => {\n const valuesRef = useRef<string[] | undefined>(values);\n\n if (!areStringArraysEqual(valuesRef.current, values)) {\n valuesRef.current = values;\n }\n\n return valuesRef.current;\n};\n\nconst ContentRender: React.FC<ContentRenderProps> = ({\n content,\n contentType,\n locale,\n lang,\n dir,\n customRenderBar,\n onSend,\n typingSpeed = 40,\n enableTypewriter = false,\n onTypeFinished,\n onTypewriterStateChange,\n userInput,\n interactionDefaultValueOptions,\n defaultButtonText,\n defaultInputText,\n defaultSelectedValues,\n readonly = false,\n confirmButtonText,\n copyButtonText,\n copiedButtonText,\n sandboxLoadingText,\n sandboxStyleLoadingText,\n sandboxScriptLoadingText,\n disableSandboxLoadingOverlay = false,\n sandboxFullscreenButtonText,\n sandboxExitFullscreenButtonText,\n sandboxMode = \"content\",\n onClickCustomButtonAfterContent,\n beforeSend,\n // tooltipMinLength,\n}) => {\n const localeTexts = getContentRenderLocaleTexts(locale);\n const mermaidMessages = useMemo(\n () => ({\n loading: localeTexts.mermaidLoadingText,\n emptyChart: localeTexts.mermaidEmptyChartText,\n error: localeTexts.mermaidErrorText,\n }),\n [localeTexts]\n );\n const direction = dir ?? getMarkdownFlowDirection(locale);\n const language = lang ?? getMarkdownFlowLanguage(locale);\n const resolvedConfirmButtonText =\n confirmButtonText || localeTexts.confirmButtonText;\n const resolvedCopyButtonText = copyButtonText || localeTexts.copyButtonText;\n const resolvedCopiedButtonText =\n copiedButtonText || localeTexts.copiedButtonText;\n const resolvedSandboxFullscreenButtonText =\n sandboxFullscreenButtonText || localeTexts.sandboxFullscreenButtonText;\n const resolvedSandboxExitFullscreenButtonText =\n sandboxExitFullscreenButtonText ||\n localeTexts.sandboxExitFullscreenButtonText;\n const shouldApplyTypewriterByContentType =\n !contentType || contentType === \"text\";\n const isTypewriterEnabled =\n Boolean(enableTypewriter) && shouldApplyTypewriterByContentType;\n const typewriterChunkSize = 2;\n const typewriterTickMs = Math.max(0, typingSpeed);\n const [displayContent, setDisplayContent] = useState(() =>\n isTypewriterEnabled ? \"\" : content\n );\n const pendingContentRef = useRef(\"\");\n const previousTypewriterEnabledRef = useRef(isTypewriterEnabled);\n const hasReportedTypeFinishedRef = useRef(false);\n\n useEffect(() => {\n const wasTypewriterEnabled = previousTypewriterEnabledRef.current;\n previousTypewriterEnabledRef.current = isTypewriterEnabled;\n hasReportedTypeFinishedRef.current = false;\n\n if (!isTypewriterEnabled) {\n pendingContentRef.current = \"\";\n setDisplayContent(content);\n return;\n }\n\n setDisplayContent((current) => {\n const shouldRestartTyping = !wasTypewriterEnabled;\n const canContinueTyping = content.startsWith(current);\n\n if (!shouldRestartTyping && !canContinueTyping) {\n pendingContentRef.current = \"\";\n return content;\n }\n\n const nextVisibleContent =\n shouldRestartTyping || !canContinueTyping ? \"\" : current;\n\n pendingContentRef.current = content.slice(nextVisibleContent.length);\n return nextVisibleContent;\n });\n }, [content, isTypewriterEnabled]);\n\n useEffect(() => {\n if (!isTypewriterEnabled) {\n return;\n }\n\n if (\n hasReportedTypeFinishedRef.current ||\n pendingContentRef.current ||\n displayContent !== content\n ) {\n return;\n }\n\n hasReportedTypeFinishedRef.current = true;\n onTypeFinished?.();\n }, [content, displayContent, isTypewriterEnabled, onTypeFinished]);\n\n useEffect(() => {\n if (!isTypewriterEnabled || !pendingContentRef.current) {\n return undefined;\n }\n\n const typewriterTimer = window.setTimeout(() => {\n setDisplayContent((current) => {\n const { chunk, rest } = splitTextByCharacterChunk(\n pendingContentRef.current,\n typewriterChunkSize\n );\n\n if (!chunk) {\n return current;\n }\n\n pendingContentRef.current = rest;\n return `${current}${chunk}`;\n });\n }, typewriterTickMs);\n\n return () => window.clearTimeout(typewriterTimer);\n }, [\n content,\n displayContent,\n isTypewriterEnabled,\n typewriterChunkSize,\n typewriterTickMs,\n ]);\n\n const typewriterState = useMemo<ContentRenderTypewriterState>(\n () => ({\n isTypewriterEnabled,\n isTyping: isTypewriterEnabled && displayContent !== content,\n isComplete: displayContent === content,\n renderedLength: displayContent.length,\n totalLength: content.length,\n }),\n [content, displayContent, isTypewriterEnabled]\n );\n\n useEffect(() => {\n onTypewriterStateChange?.(typewriterState);\n }, [onTypewriterStateChange, typewriterState]);\n\n const renderContent = isTypewriterEnabled ? displayContent : content;\n const normalizedContent = useMemo(\n () => normalizeInlineHtml(renderContent),\n [renderContent]\n );\n\n const interactionDefaults = useMemo(\n () =>\n getInteractionDefaultValues(\n renderContent,\n userInput,\n interactionDefaultValueOptions\n ),\n [interactionDefaultValueOptions, renderContent, userInput]\n );\n\n const resolvedDefaultButtonText =\n defaultButtonText?.trim() || interactionDefaults.buttonText;\n const resolvedDefaultInputText =\n defaultInputText?.trim() || interactionDefaults.inputText;\n const fallbackSelectedValues = useMemo(\n () =>\n userInput\n ? userInput\n .split(\",\")\n .map((value) => value.trim())\n .filter(Boolean)\n : undefined,\n [userInput]\n );\n const resolvedDefaultSelectedValues = defaultSelectedValues?.length\n ? defaultSelectedValues\n : interactionDefaults.selectedValues || fallbackSelectedValues;\n const stableDefaultSelectedValues = useStableStringArray(\n resolvedDefaultSelectedValues\n );\n const componentRuntimeValuesRef = useRef<MarkdownComponentRuntimeValues>({\n direction,\n language,\n mermaidMessages,\n beforeSend,\n locale,\n onClickCustomButtonAfterContent,\n onSend,\n readonly,\n renderContent,\n resolvedConfirmButtonText,\n resolvedCopiedButtonText,\n resolvedCopyButtonText,\n resolvedDefaultButtonText,\n resolvedDefaultInputText,\n resolvedDefaultSelectedValues: stableDefaultSelectedValues,\n });\n\n componentRuntimeValuesRef.current = {\n direction,\n language,\n mermaidMessages,\n beforeSend,\n locale,\n onClickCustomButtonAfterContent,\n onSend,\n readonly,\n renderContent,\n resolvedConfirmButtonText,\n resolvedCopiedButtonText,\n resolvedCopyButtonText,\n resolvedDefaultButtonText,\n resolvedDefaultInputText,\n resolvedDefaultSelectedValues: stableDefaultSelectedValues,\n };\n\n const components = useMemo<CustomComponents>(\n () => ({\n \"custom-button-after-content\": ({\n children,\n }: {\n children: React.ReactNode;\n }) => {\n return (\n <button\n className=\"content-render-custom-button-after-content\"\n onClick={\n componentRuntimeValuesRef.current.onClickCustomButtonAfterContent\n }\n >\n <span className=\"content-render-custom-button-after-content-inner\">\n {children}\n </span>\n </button>\n );\n },\n \"custom-variable\": (props) => (\n <CustomButtonInputVariable\n {...props}\n readonly={componentRuntimeValuesRef.current.readonly}\n defaultButtonText={\n componentRuntimeValuesRef.current.resolvedDefaultButtonText\n }\n defaultInputText={\n componentRuntimeValuesRef.current.resolvedDefaultInputText\n }\n defaultSelectedValues={\n componentRuntimeValuesRef.current.resolvedDefaultSelectedValues\n }\n onSend={componentRuntimeValuesRef.current.onSend}\n beforeSend={componentRuntimeValuesRef.current.beforeSend}\n locale={componentRuntimeValuesRef.current.locale}\n dir={componentRuntimeValuesRef.current.direction}\n lang={componentRuntimeValuesRef.current.language}\n confirmButtonText={\n componentRuntimeValuesRef.current.resolvedConfirmButtonText\n }\n // tooltipMinLength={tooltipMinLength}\n />\n ),\n code: MarkdownCode,\n table: ({ ...props }) => (\n <div className=\"content-render-table-container\">\n <table className=\"content-render-table\" {...props} />\n </div>\n ),\n th: ({ ...props }) => <th className=\"content-render-th\" {...props} />,\n td: ({ ...props }) => <td className=\"content-render-td\" {...props} />,\n tr: ({ ...props }) => <tr className=\"content-render-tr\" {...props} />,\n li: ({ node, ...props }) => {\n const className = node?.properties?.className;\n const hasTaskListItem =\n (typeof className === \"string\" &&\n className.includes(\"task-list-item\")) ||\n (Array.isArray(className) && className.includes(\"task-list-item\"));\n if (hasTaskListItem) {\n return <li className=\"content-render-task-list-item\" {...props} />;\n }\n return <li {...props} />;\n },\n ol: ({ ...props }) => <ol className=\"content-render-ol\" {...props} />,\n ul: ({ ...props }) => <ul className=\"content-render-ul\" {...props} />,\n input: ({ ...props }) => {\n if (props.type === \"checkbox\") {\n return (\n <input\n type=\"checkbox\"\n className=\"content-render-checkbox\"\n disabled\n {...props}\n />\n );\n }\n return <input {...props} />;\n },\n a: ({ children, ...props }) => (\n <a target=\"_blank\" rel=\"noopener noreferrer\" {...props}>\n {children}\n </a>\n ),\n pre: (props) => (\n <CodeBlock\n {...props}\n copyButtonText={\n componentRuntimeValuesRef.current.resolvedCopyButtonText\n }\n copiedButtonText={\n componentRuntimeValuesRef.current.resolvedCopiedButtonText\n }\n />\n ),\n }),\n []\n );\n\n const hasPotentialSandboxTags = useMemo(\n () => SANDBOX_TAG_HINT_PATTERN.test(renderContent),\n [renderContent]\n );\n\n const renderSegments = useMemo(\n () =>\n hasPotentialSandboxTags ? splitContentSegments(renderContent, true) : [],\n [renderContent, hasPotentialSandboxTags]\n );\n\n const hasSandbox = renderSegments.some(\n (segment) => segment.type === \"sandbox\"\n );\n const mergedRenderSegments = useMemo(\n () => mergeNonSandboxSegments(renderSegments),\n [renderSegments]\n );\n\n const segments = useMemo(\n () => parseMarkdownSegments(normalizedContent),\n [normalizedContent]\n );\n\n const renderMarkdownSegments = (raw: string, keyPrefix: string) => {\n const normalized = normalizeInlineHtml(raw);\n const parsed = parseMarkdownSegments(normalized);\n\n return parsed.map((seg, index) => {\n const key = `${keyPrefix}-${seg.type}-${index}`;\n\n if (seg.type === \"text\") {\n return (\n <MarkdownComponentRuntimeContext.Provider\n key={key}\n value={componentRuntimeValuesRef}\n >\n <MarkdownRenderer\n locale={locale}\n components={components}\n content={seg.value}\n />\n </MarkdownComponentRuntimeContext.Provider>\n );\n }\n\n if (seg.type === \"mermaid\") {\n return (\n <MermaidChart\n key={key}\n chart={seg.value}\n frozen={!seg.complete}\n messages={mermaidMessages}\n />\n );\n }\n\n if (seg.type === \"svg\") {\n return <SvgBlockInShadow key={key} svg={seg.value} />;\n }\n\n return null;\n });\n };\n\n if (hasSandbox) {\n return (\n <div\n className=\"content-render markdown-body\"\n dir={direction}\n lang={language}\n >\n {mergedRenderSegments.map((segment, idx) =>\n segment.type === \"sandbox\" ? (\n <IframeSandbox\n key={`sandbox-${idx}`}\n hideFullScreen\n type=\"sandbox\"\n content={segment.value}\n className=\"content-render-iframe\"\n locale={locale}\n dir={direction}\n lang={language}\n loadingText={sandboxLoadingText}\n styleLoadingText={sandboxStyleLoadingText}\n scriptLoadingText={sandboxScriptLoadingText}\n disableLoadingOverlay={disableSandboxLoadingOverlay}\n fullScreenButtonText={resolvedSandboxFullscreenButtonText}\n exitFullScreenButtonText={resolvedSandboxExitFullscreenButtonText}\n mode={sandboxMode}\n />\n ) : (\n <React.Fragment key={`md-${idx}`}>\n {renderMarkdownSegments(segment.value, `md-${idx}`)}\n </React.Fragment>\n )\n )}\n </div>\n );\n }\n\n return (\n <div\n className=\"content-render markdown-body\"\n dir={direction}\n lang={language}\n >\n {segments.map((seg, index) => {\n if (seg.type === \"text\") {\n return (\n <MarkdownComponentRuntimeContext.Provider\n key={index}\n value={componentRuntimeValuesRef}\n >\n <MarkdownRenderer\n locale={locale}\n components={components}\n content={seg.value}\n />\n </MarkdownComponentRuntimeContext.Provider>\n );\n }\n\n if (seg.type === \"mermaid\") {\n return (\n <MermaidChart\n key={index}\n chart={seg.value}\n frozen={!seg.complete}\n messages={mermaidMessages}\n />\n );\n }\n\n if (seg.type === \"svg\") {\n return <SvgBlockInShadow key={index} svg={seg.value} />;\n }\n })}\n\n {customRenderBar && (\n <div className=\"content-render-custom-bar\">\n {React.createElement(customRenderBar, {\n content,\n displayContent: normalizedContent,\n onSend,\n })}\n </div>\n )}\n </div>\n );\n};\n\nexport default ContentRender;\n"],"names":["SANDBOX_TAG_HINT_PATTERN","SvgBlockInShadow","svg","hostRef","useRef","useEffect","host","shadowRoot","styleId","styleEl","node","template","cleanedSvg","stripSvgTextLineBreaks","hasResponsiveSvg","hasFixedSvg","svgEl","viewBox","dimensions","value","viewBoxWidth","viewBoxHeight","widthAttr","heightAttr","isRelativeLength","normalized","toNumericLength","parsed","isWidthRelative","isHeightRelative","widthMissing","heightMissing","numericWidth","numericHeight","hostResponsive","jsx","MarkdownComponentRuntimeContext","React","MarkdownCode","props","runtimeValuesRef","isInCodeBlock","CodeBlockContext","className","children","rest","chartContent","frozen","mermaidBlockIsComplete","MermaidChart","remarkPlugins","remarkGfm","remarkMath","remarkFlow","remarkBreaks","rehypePlugins","preserveCustomVariableProperties","rehypeRaw","sanitizeInvalidTagName","restoreCustomVariableProperties","rehypeHighlight","highlightLanguages","subsetLanguages","rehypeKatex","MarkdownRenderer","markdownContent","components","locale","texts","getContentRenderLocaleTexts","ReactMarkdown","referenceIndex","rereferenceIndex","reference","mergeNonSandboxSegments","segments","merged","segment","last","splitTextByCharacterChunk","chunkSize","safeChunkSize","characters","areStringArraysEqual","left","right","index","useStableStringArray","values","valuesRef","ContentRender","content","contentType","lang","dir","customRenderBar","onSend","typingSpeed","enableTypewriter","onTypeFinished","onTypewriterStateChange","userInput","interactionDefaultValueOptions","defaultButtonText","defaultInputText","defaultSelectedValues","readonly","confirmButtonText","copyButtonText","copiedButtonText","sandboxLoadingText","sandboxStyleLoadingText","sandboxScriptLoadingText","disableSandboxLoadingOverlay","sandboxFullscreenButtonText","sandboxExitFullscreenButtonText","sandboxMode","onClickCustomButtonAfterContent","beforeSend","localeTexts","mermaidMessages","useMemo","direction","getMarkdownFlowDirection","language","getMarkdownFlowLanguage","resolvedConfirmButtonText","resolvedCopyButtonText","resolvedCopiedButtonText","resolvedSandboxFullscreenButtonText","resolvedSandboxExitFullscreenButtonText","isTypewriterEnabled","typewriterChunkSize","typewriterTickMs","displayContent","setDisplayContent","useState","pendingContentRef","previousTypewriterEnabledRef","hasReportedTypeFinishedRef","wasTypewriterEnabled","current","shouldRestartTyping","canContinueTyping","nextVisibleContent","typewriterTimer","chunk","typewriterState","renderContent","normalizedContent","normalizeInlineHtml","interactionDefaults","getInteractionDefaultValues","resolvedDefaultButtonText","resolvedDefaultInputText","fallbackSelectedValues","resolvedDefaultSelectedValues","stableDefaultSelectedValues","componentRuntimeValuesRef","CustomButtonInputVariable","CodeBlock","hasPotentialSandboxTags","renderSegments","splitContentSegments","hasSandbox","mergedRenderSegments","parseMarkdownSegments","renderMarkdownSegments","raw","keyPrefix","seg","key","idx","IframeSandbox","jsxs"],"mappings":"o5CAoDMA,GACJ,kGAuEIC,GAA8C,CAAC,CAAE,IAAAC,KAAU,CAC/D,MAAMC,EAAUC,EAAAA,OAAuB,IAAI,EAE3CC,OAAAA,EAAAA,UAAU,IAAM,CACd,MAAMC,EAAOH,EAAQ,QACrB,GAAI,CAACG,EAAM,OACX,MAAMC,EAAaD,EAAK,YAAcA,EAAK,aAAa,CAAE,KAAM,OAAQ,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AAS,UACf,OACEvI,EAAAA,IAACc,EAAAA,QAAA,CAEC,MAAOyH,EAAI,MACX,OAAQ,CAACA,EAAI,SACb,SAAUlD,CAAA,EAHLlC,CAAA,EAQX,GAAIoF,EAAI,OAAS,MACf,OAAOvI,EAAAA,IAAClC,GAAA,CAA6B,IAAKyK,EAAI,OAAhBpF,CAAuB,CAEzD,CAAC,EAEAS,GACC5D,EAAAA,IAAC,MAAA,CAAI,UAAU,4BACZ,SAAAE,EAAM,cAAc0D,EAAiB,CACpC,QAAAJ,EACA,eAAgB0D,EAChB,OAAArD,CAAA,CACD,CAAA,CACH,CAAA,CAAA,CAAA,CAIR"}
|
|
@@ -1,13 +1,17 @@
|
|
|
1
1
|
import { default as React } from 'react';
|
|
2
|
-
import { CustomRenderBarProps, OnSendContentParams } from '../types';
|
|
3
|
-
import { ComponentsWithCustomVariable } from './plugins/CustomVariable';
|
|
4
|
-
import { InteractionDefaultValueOptions } from '../../lib/interaction-defaults';
|
|
5
|
-
import { MarkdownFlowLocale } from '../../lib/locale';
|
|
2
|
+
import { CustomRenderBarProps, OnSendContentParams } from '../types.js';
|
|
3
|
+
import { ComponentsWithCustomVariable } from './plugins/CustomVariable.js';
|
|
4
|
+
import { InteractionDefaultValueOptions } from '../../lib/interaction-defaults.js';
|
|
5
|
+
import { MarkdownFlowLocale } from '../../lib/locale.js';
|
|
6
6
|
export interface ContentRenderProps {
|
|
7
7
|
content: string;
|
|
8
8
|
contentType?: string;
|
|
9
9
|
/** Locale used for built-in UI text when a more specific text prop is not provided. */
|
|
10
10
|
locale?: MarkdownFlowLocale;
|
|
11
|
+
/** Overrides the locale-derived language; omitted values inherit from the host. */
|
|
12
|
+
lang?: string;
|
|
13
|
+
/** Overrides locale-derived direction; omitted values inherit when no locale is set. */
|
|
14
|
+
dir?: React.HTMLAttributes<HTMLDivElement>["dir"];
|
|
11
15
|
/**
|
|
12
16
|
* Callback invoked when the custom button after content is clicked.
|
|
13
17
|
* This button is rendered via the `<custom-button-after-content>` tag in markdown content.
|
|
@@ -60,6 +64,7 @@ type CustomComponents = ComponentsWithCustomVariable & {
|
|
|
60
64
|
export declare const MarkdownRenderer: React.FC<{
|
|
61
65
|
content: string;
|
|
62
66
|
components: CustomComponents;
|
|
67
|
+
locale?: MarkdownFlowLocale;
|
|
63
68
|
}>;
|
|
64
69
|
declare const ContentRender: React.FC<ContentRenderProps>;
|
|
65
70
|
export default ContentRender;
|