@ai-matrx/rich-content 0.2.3 → 0.2.6
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/CHANGELOG.md +22 -0
- package/dist/code-block/CodeBlock.d.ts +44 -0
- package/dist/code-block/CodeBlock.js +449 -0
- package/dist/code-block/CodeBlockHeader.d.ts +63 -0
- package/dist/code-block/CodeBlockHeader.js +472 -0
- package/dist/code-block/CodeEditorLoading.d.ts +3 -0
- package/dist/code-block/CodeEditorLoading.js +34 -0
- package/dist/code-block/LanguageDisplay.d.ts +28 -0
- package/dist/code-block/LanguageDisplay.js +279 -0
- package/dist/code-block/SmallCodeEditor.d.ts +30 -0
- package/dist/code-block/SmallCodeEditor.js +22 -0
- package/dist/code-block/StickyButtons.d.ts +35 -0
- package/dist/code-block/StickyButtons.js +88 -0
- package/dist/code-block/highlight/ShikiCodeView.d.ts +26 -0
- package/dist/code-block/highlight/ShikiCodeView.js +134 -0
- package/dist/code-block/highlight/shiki-highlighter.d.ts +14 -0
- package/dist/code-block/highlight/shiki-highlighter.js +126 -0
- package/dist/code-block/highlight/useHighlightedLines.d.ts +18 -0
- package/dist/code-block/highlight/useHighlightedLines.js +142 -0
- package/dist/code-block/sticky-inset.d.ts +6 -0
- package/dist/code-block/sticky-inset.js +10 -0
- package/dist/display/block-interaction.d.ts +33 -0
- package/dist/display/block-interaction.js +13 -0
- package/dist/display/blocks/ChatCollapsibleWrapper.d.ts +13 -0
- package/dist/display/blocks/ChatCollapsibleWrapper.js +56 -0
- package/dist/display/blocks/buildMediaSource.d.ts +25 -0
- package/dist/display/blocks/buildMediaSource.js +43 -0
- package/dist/display/blocks/canvas-adaptive.d.ts +118 -0
- package/dist/display/blocks/canvas-adaptive.js +127 -0
- package/dist/display/blocks/canvas-fit.d.ts +24 -0
- package/dist/display/blocks/canvas-fit.js +19 -0
- package/dist/display/blocks/chart/ChartBlock.d.ts +8 -0
- package/dist/display/blocks/chart/ChartBlock.js +125 -0
- package/dist/display/blocks/chart/ChartCanvas.d.ts +18 -0
- package/dist/display/blocks/chart/ChartCanvas.js +159 -0
- package/dist/display/blocks/chart/TableChart.d.ts +25 -0
- package/dist/display/blocks/chart/TableChart.js +97 -0
- package/dist/display/blocks/chart/chart-spec.d.ts +39 -0
- package/dist/display/blocks/chart/chart-spec.js +128 -0
- package/dist/display/blocks/chart/labels.d.ts +20 -0
- package/dist/display/blocks/chart/labels.js +7 -0
- package/dist/display/blocks/chart/table-chart.d.ts +37 -0
- package/dist/display/blocks/chart/table-chart.js +231 -0
- package/dist/display/blocks/common/BlockHeaderWrapper.d.ts +56 -0
- package/dist/display/blocks/common/BlockHeaderWrapper.js +310 -0
- package/dist/display/blocks/common/ContentBlockWrapper.d.ts +40 -0
- package/dist/display/blocks/common/ContentBlockWrapper.js +214 -0
- package/dist/display/blocks/common/SandboxedHtml.d.ts +27 -0
- package/dist/display/blocks/common/SandboxedHtml.js +26 -0
- package/dist/display/blocks/csv/CsvBlock.js +5 -1
- package/dist/display/blocks/diagram/DiagramLoadingVisualization.d.ts +6 -0
- package/dist/display/blocks/diagram/DiagramLoadingVisualization.js +190 -0
- package/dist/display/blocks/diagram/InteractiveDiagramBlock.d.ts +51 -0
- package/dist/display/blocks/diagram/InteractiveDiagramBlock.js +2415 -0
- package/dist/display/blocks/diagram/diagram-printer.d.ts +16 -0
- package/dist/display/blocks/diagram/diagram-printer.js +294 -0
- package/dist/display/blocks/diagram/diagram-visual-defaults.d.ts +116 -0
- package/dist/display/blocks/diagram/diagram-visual-defaults.js +400 -0
- package/dist/display/blocks/diagram/layout-utils.d.ts +90 -0
- package/dist/display/blocks/diagram/layout-utils.js +347 -0
- package/dist/display/blocks/diagram/parseDiagramJSON.d.ts +105 -0
- package/dist/display/blocks/diagram/parseDiagramJSON.js +296 -0
- package/dist/display/blocks/diagram/presentation-direction.d.ts +29 -0
- package/dist/display/blocks/diagram/presentation-direction.js +19 -0
- package/dist/display/blocks/diagram/ui-utils.d.ts +1 -0
- package/dist/display/blocks/diagram/ui-utils.js +18 -0
- package/dist/display/blocks/diff/DiffBlock.d.ts +10 -0
- package/dist/display/blocks/diff/DiffBlock.js +119 -0
- package/dist/display/blocks/diff/DiffCanvas.d.ts +15 -0
- package/dist/display/blocks/diff/DiffCanvas.js +20 -0
- package/dist/display/blocks/generic/GenericStructuredBlock.d.ts +24 -0
- package/dist/display/blocks/generic/GenericStructuredBlock.js +53 -0
- package/dist/display/blocks/generic/StructuredValueTabs.d.ts +21 -0
- package/dist/display/blocks/generic/StructuredValueTabs.js +124 -0
- package/dist/display/blocks/generic/tile-actions-slot.d.ts +39 -0
- package/dist/display/blocks/generic/tile-actions-slot.js +33 -0
- package/dist/display/blocks/images/ImageBlock.d.ts +8 -0
- package/dist/display/blocks/images/ImageBlock.js +265 -0
- package/dist/display/blocks/json/JsonBlock.d.ts +34 -0
- package/dist/display/blocks/json/JsonBlock.js +562 -0
- package/dist/display/blocks/json/JsonTableView.d.ts +10 -0
- package/dist/display/blocks/json/JsonTableView.js +173 -0
- package/dist/display/blocks/json/json-compact-stringify.d.ts +25 -0
- package/dist/display/blocks/json/json-compact-stringify.js +52 -0
- package/dist/display/blocks/json/json-tabular-utils.d.ts +65 -0
- package/dist/display/blocks/json/json-tabular-utils.js +121 -0
- package/dist/display/blocks/links/LinkComponent.d.ts +6 -0
- package/dist/display/blocks/links/LinkComponent.js +373 -0
- package/dist/display/blocks/links/LinkComponentWithFetch.d.ts +1 -0
- package/dist/display/blocks/links/LinkComponentWithFetch.js +0 -0
- package/dist/display/blocks/markdown/MarkdownKindBlock.d.ts +48 -0
- package/dist/display/blocks/markdown/MarkdownKindBlock.js +52 -0
- package/dist/display/blocks/markdown-preview/MarkdownPreviewBlock.d.ts +17 -0
- package/dist/display/blocks/markdown-preview/MarkdownPreviewBlock.js +70 -0
- package/dist/display/blocks/mermaid/MermaidBlock.d.ts +19 -0
- package/dist/display/blocks/mermaid/MermaidBlock.js +386 -0
- package/dist/display/blocks/search-replace/SearchReplaceBlock.d.ts +50 -0
- package/dist/display/blocks/search-replace/SearchReplaceBlock.js +71 -0
- package/dist/display/blocks/svg/SvgBlock.d.ts +8 -0
- package/dist/display/blocks/svg/SvgBlock.js +126 -0
- package/dist/display/blocks/table/StreamingTableRenderer.d.ts +53 -0
- package/dist/display/blocks/table/StreamingTableRenderer.js +907 -0
- package/dist/display/blocks/table/TableRenderPathDiagnostic.d.ts +21 -0
- package/dist/display/blocks/table/TableRenderPathDiagnostic.js +79 -0
- package/dist/display/blocks/thinking-reasoning/ConsolidatedReasoningVisualization.d.ts +14 -0
- package/dist/display/blocks/thinking-reasoning/ConsolidatedReasoningVisualization.js +15 -0
- package/dist/display/blocks/thinking-reasoning/ReasoningVisualization.d.ts +13 -0
- package/dist/display/blocks/thinking-reasoning/ReasoningVisualization.js +19 -0
- package/dist/display/blocks/thinking-reasoning/ThinkingTrace.d.ts +30 -0
- package/dist/display/blocks/thinking-reasoning/ThinkingTrace.js +75 -0
- package/dist/display/blocks/thinking-reasoning/ThinkingTraceMarkdown.d.ts +13 -0
- package/dist/display/blocks/thinking-reasoning/ThinkingTraceMarkdown.js +48 -0
- package/dist/display/blocks/thinking-reasoning/ThinkingVisualization.d.ts +12 -0
- package/dist/display/blocks/thinking-reasoning/ThinkingVisualization.js +19 -0
- package/dist/display/blocks/toml/TomlBlock.d.ts +7 -0
- package/dist/display/blocks/toml/TomlBlock.js +167 -0
- package/dist/display/blocks/tree/TreeBlock.d.ts +7 -0
- package/dist/display/blocks/tree/TreeBlock.js +163 -0
- package/dist/display/blocks/xml/XmlBlock.d.ts +23 -0
- package/dist/display/blocks/xml/XmlBlock.js +197 -0
- package/dist/display/blocks/xml/readXmlTag.d.ts +1 -0
- package/dist/display/blocks/xml/readXmlTag.js +1 -0
- package/dist/display/blocks/xml/xml-tokenize.d.ts +13 -0
- package/dist/display/blocks/xml/xml-tokenize.js +169 -0
- package/dist/display/blocks/yaml/YamlBlock.d.ts +7 -0
- package/dist/display/blocks/yaml/YamlBlock.js +191 -0
- package/dist/display/chat-markdown/BasicMarkdownContent.d.ts +29 -0
- package/dist/display/chat-markdown/BasicMarkdownContent.js +122 -0
- package/dist/display/chat-markdown/BlockRenderingContext.d.ts +23 -0
- package/dist/display/chat-markdown/BlockRenderingContext.js +17 -0
- package/dist/display/chat-markdown/ConfigurableMarkdownContent.d.ts +172 -0
- package/dist/display/chat-markdown/ConfigurableMarkdownContent.js +649 -0
- package/dist/display/chat-markdown/InlineCodeSnippet.d.ts +19 -0
- package/dist/display/chat-markdown/InlineCodeSnippet.js +146 -0
- package/dist/display/chat-markdown/InlineCodeSnippetKindGate.d.ts +11 -0
- package/dist/display/chat-markdown/InlineCodeSnippetKindGate.js +9 -0
- package/dist/display/chat-markdown/KindTextGate.d.ts +31 -0
- package/dist/display/chat-markdown/KindTextGate.js +60 -0
- package/dist/display/chat-markdown/QuestionnaireLoadingVisualization.d.ts +6 -0
- package/dist/display/chat-markdown/QuestionnaireLoadingVisualization.js +92 -0
- package/dist/display/chat-markdown/block-registry/BlockComponentRegistry.d.ts +72 -0
- package/dist/display/chat-markdown/block-registry/BlockComponentRegistry.js +94 -0
- package/dist/display/chat-markdown/block-registry/BlockRenderer.d.ts +126 -0
- package/dist/display/chat-markdown/block-registry/BlockRenderer.js +473 -0
- package/dist/display/chat-markdown/block-registry/block-dispatch.d.ts +410 -0
- package/dist/display/chat-markdown/block-registry/block-dispatch.js +495 -0
- package/dist/display/chat-markdown/block-registry/json-parse-utils.d.ts +13 -0
- package/dist/display/chat-markdown/block-registry/json-parse-utils.js +236 -0
- package/dist/display/chat-markdown/constants.d.ts +14 -0
- package/dist/display/chat-markdown/constants.js +317 -0
- package/dist/display/chat-markdown/diff-blocks/DiffCollapsible.d.ts +31 -0
- package/dist/display/chat-markdown/diff-blocks/DiffCollapsible.js +62 -0
- package/dist/display/chat-markdown/diff-blocks/DiffLoadingIndicator.d.ts +12 -0
- package/dist/display/chat-markdown/diff-blocks/DiffLoadingIndicator.js +18 -0
- package/dist/display/chat-markdown/diff-blocks/StreamingDiffBlock.d.ts +22 -0
- package/dist/display/chat-markdown/diff-blocks/StreamingDiffBlock.js +130 -0
- package/dist/display/chat-markdown/diff-blocks/diff-style-registry.d.ts +21 -0
- package/dist/display/chat-markdown/diff-blocks/diff-style-registry.js +91 -0
- package/dist/display/chat-markdown/diff-blocks/renderers/SearchReplaceDiffRenderer.d.ts +26 -0
- package/dist/display/chat-markdown/diff-blocks/renderers/SearchReplaceDiffRenderer.js +186 -0
- package/dist/display/chat-markdown/diff-blocks/types.d.ts +56 -0
- package/dist/display/chat-markdown/diff-blocks/types.js +0 -0
- package/dist/display/chat-markdown/internal-handlers/BlockFallback.d.ts +20 -0
- package/dist/display/chat-markdown/internal-handlers/BlockFallback.js +83 -0
- package/dist/display/chat-markdown/internal-handlers/InlineStatusIndicator.d.ts +4 -0
- package/dist/display/chat-markdown/internal-handlers/InlineStatusIndicator.js +16 -0
- package/dist/display/chat-markdown/internal-handlers/MarkdownErrorBoundary.d.ts +17 -0
- package/dist/display/chat-markdown/internal-handlers/MarkdownErrorBoundary.js +40 -0
- package/dist/display/chat-markdown/internal-handlers/PlainTextFallback.d.ts +8 -0
- package/dist/display/chat-markdown/internal-handlers/PlainTextFallback.js +91 -0
- package/dist/display/chat-markdown/internal-handlers/SafeBlockRenderer.d.ts +20 -0
- package/dist/display/chat-markdown/internal-handlers/SafeBlockRenderer.js +72 -0
- package/dist/display/chat-markdown/kind-source-view.d.ts +14 -0
- package/dist/display/chat-markdown/kind-source-view.js +14 -0
- package/dist/display/chat-markdown/matrx-variables/MatrxVariableInline.d.ts +28 -0
- package/dist/display/chat-markdown/matrx-variables/MatrxVariableInline.js +65 -0
- package/dist/display/chat-markdown/progressive-mount.d.ts +18 -0
- package/dist/display/chat-markdown/progressive-mount.js +90 -0
- package/dist/display/chat-markdown/render-block-to-content-block.d.ts +31 -0
- package/dist/display/chat-markdown/render-block-to-content-block.js +32 -0
- package/dist/display/chat-markdown/settle-stream-blocks.d.ts +50 -0
- package/dist/display/chat-markdown/settle-stream-blocks.js +26 -0
- package/dist/display/chat-markdown/stable-blocks.d.ts +15 -0
- package/dist/display/chat-markdown/stable-blocks.js +54 -0
- package/dist/display/chat-markdown/types.d.ts +11 -0
- package/dist/display/chat-markdown/types.js +26 -0
- package/dist/display/specimen/SpecimenContext.d.ts +26 -0
- package/dist/display/specimen/SpecimenContext.js +64 -0
- package/dist/display/tables/MarkdownTable.d.ts +23 -0
- package/dist/display/tables/MarkdownTable.js +769 -0
- package/dist/display/tables/MarkdownTableScrollArea.d.ts +12 -0
- package/dist/display/tables/MarkdownTableScrollArea.js +92 -0
- package/dist/display/tables/SendToGoogleSheetButton.d.ts +19 -0
- package/dist/display/tables/SendToGoogleSheetButton.js +93 -0
- package/dist/display/tables/SendToWorkbookButton.d.ts +24 -0
- package/dist/display/tables/SendToWorkbookButton.js +93 -0
- package/dist/display/tables/TableSaveToMenu.d.ts +16 -0
- package/dist/display/tables/TableSaveToMenu.js +98 -0
- package/dist/display/tables/TableWithSeparatedControls.d.ts +22 -0
- package/dist/display/tables/TableWithSeparatedControls.js +574 -0
- package/dist/display/tables/ViewTableModal.d.ts +14 -0
- package/dist/display/tables/ViewTableModal.js +67 -0
- package/dist/display/tables/editing/ColumnActionsMenu.d.ts +16 -0
- package/dist/display/tables/editing/ColumnActionsMenu.js +80 -0
- package/dist/display/tables/editing/RowActionsMenu.d.ts +16 -0
- package/dist/display/tables/editing/RowActionsMenu.js +80 -0
- package/dist/display/tables/editing/TableEditToolbar.d.ts +15 -0
- package/dist/display/tables/editing/TableEditToolbar.js +63 -0
- package/dist/display/tables/editing/tableMutations.d.ts +50 -0
- package/dist/display/tables/editing/tableMutations.js +148 -0
- package/dist/display/tables/editing/useDoubleClickEdit.d.ts +43 -0
- package/dist/display/tables/editing/useDoubleClickEdit.js +51 -0
- package/dist/display/tables/editing/useTableUndo.d.ts +25 -0
- package/dist/display/tables/editing/useTableUndo.js +17 -0
- package/dist/display/tables/table-action-row.d.ts +8 -0
- package/dist/display/tables/table-action-row.js +31 -0
- package/dist/display/tables/table-viewer.d.ts +13 -0
- package/dist/display/tables/table-viewer.js +18 -0
- package/dist/host/ErrorActions.d.ts +1 -1
- package/dist/host/ErrorNotice.d.ts +10 -0
- package/dist/host/ErrorNotice.js +19 -0
- package/dist/host/app-bindings.d.ts +155 -0
- package/dist/host/app-bindings.js +160 -0
- package/dist/host/diagnostics.d.ts +2 -2
- package/dist/host/diagnostics.js +2 -1
- package/dist/host/tables.d.ts +1 -6
- package/dist/host/types.d.ts +14 -7
- package/dist/levels/RichContent.d.ts +3 -0
- package/dist/levels/RichContent.js +102 -0
- package/dist/levels/RichContentInline.d.ts +28 -0
- package/dist/levels/RichContentInline.js +61 -0
- package/dist/levels/RichContentPreview.d.ts +12 -0
- package/dist/levels/RichContentPreview.js +39 -0
- package/dist/levels/RichContentStandardImpl.d.ts +12 -0
- package/dist/levels/RichContentStandardImpl.js +27 -0
- package/dist/levels/RichContentStaticProse.d.ts +46 -0
- package/dist/levels/RichContentStaticProse.js +100 -0
- package/dist/levels/depth.d.ts +18 -0
- package/dist/levels/depth.js +32 -0
- package/dist/levels/prose/inline-level-elements.d.ts +19 -0
- package/dist/levels/prose/inline-level-elements.js +103 -0
- package/dist/levels/prose/prose-block-elements.d.ts +25 -0
- package/dist/levels/prose/prose-block-elements.js +313 -0
- package/dist/levels/prose/prose-inline-elements.d.ts +13 -0
- package/dist/levels/prose/prose-inline-elements.js +143 -0
- package/dist/levels/prose/prose-prepare.d.ts +50 -0
- package/dist/levels/prose/prose-prepare.js +246 -0
- package/dist/levels/prose/remote-image-policy.d.ts +34 -0
- package/dist/levels/prose/remote-image-policy.js +153 -0
- package/dist/levels/prose/variant-root.d.ts +9 -0
- package/dist/levels/prose/variant-root.js +34 -0
- package/dist/levels/rich-content-types.d.ts +93 -0
- package/dist/levels/rich-content-types.js +4 -0
- package/dist/levels/server/DelimiterViolationReport.d.ts +7 -0
- package/dist/levels/server/DelimiterViolationReport.js +24 -0
- package/dist/levels/server/RichContentServer.d.ts +27 -0
- package/dist/levels/server/RichContentServer.js +97 -0
- package/dist/levels/standard/NestedRichContent.d.ts +7 -0
- package/dist/levels/standard/NestedRichContent.js +70 -0
- package/dist/levels/standard/StandardBlocks.d.ts +13 -0
- package/dist/levels/standard/StandardBlocks.js +239 -0
- package/dist/levels/standard/StandardKindRegion.d.ts +14 -0
- package/dist/levels/standard/StandardKindRegion.js +69 -0
- package/dist/levels/standard/standard-kind-region.d.ts +19 -0
- package/dist/levels/standard/standard-kind-region.js +21 -0
- package/dist/levels/standard/static-standard.d.ts +23 -0
- package/dist/levels/standard/static-standard.js +187 -0
- package/dist/levels/standard/stream-holdback.d.ts +2 -0
- package/dist/levels/standard/stream-holdback.js +77 -0
- package/dist/mermaid/MermaidFullscreen.d.ts +17 -0
- package/dist/mermaid/MermaidFullscreen.js +71 -0
- package/dist/mermaid/MermaidRenderer.d.ts +20 -0
- package/dist/mermaid/MermaidRenderer.js +267 -0
- package/dist/mermaid/MermaidView.d.ts +27 -0
- package/dist/mermaid/MermaidView.js +68 -0
- package/dist/mermaid/MermaidViewport.d.ts +75 -0
- package/dist/mermaid/MermaidViewport.js +286 -0
- package/dist/mermaid/adapters/er.d.ts +10 -0
- package/dist/mermaid/adapters/er.js +205 -0
- package/dist/mermaid/adapters/flowchart.d.ts +17 -0
- package/dist/mermaid/adapters/flowchart.js +634 -0
- package/dist/mermaid/adapters/journey.d.ts +9 -0
- package/dist/mermaid/adapters/journey.js +207 -0
- package/dist/mermaid/adapters/mindmap.d.ts +12 -0
- package/dist/mermaid/adapters/mindmap.js +252 -0
- package/dist/mermaid/adapters/pie.d.ts +7 -0
- package/dist/mermaid/adapters/pie.js +172 -0
- package/dist/mermaid/adapters/quadrant.d.ts +8 -0
- package/dist/mermaid/adapters/quadrant.js +231 -0
- package/dist/mermaid/adapters/register.d.ts +7 -0
- package/dist/mermaid/adapters/register.js +19 -0
- package/dist/mermaid/adapters/sequence.d.ts +8 -0
- package/dist/mermaid/adapters/sequence.js +251 -0
- package/dist/mermaid/adapters/state.d.ts +12 -0
- package/dist/mermaid/adapters/state.js +245 -0
- package/dist/mermaid/adapters/timeline.d.ts +8 -0
- package/dist/mermaid/adapters/timeline.js +245 -0
- package/dist/mermaid/catalog.d.ts +33 -0
- package/dist/mermaid/catalog.js +202 -0
- package/dist/mermaid/diagram-type.d.ts +39 -0
- package/dist/mermaid/diagram-type.js +89 -0
- package/dist/mermaid/export.d.ts +21 -0
- package/dist/mermaid/export.js +112 -0
- package/dist/mermaid/extract-fence.d.ts +15 -0
- package/dist/mermaid/extract-fence.js +22 -0
- package/dist/mermaid/lazy-draw.d.ts +40 -0
- package/dist/mermaid/lazy-draw.js +168 -0
- package/dist/mermaid/model/adapter.d.ts +28 -0
- package/dist/mermaid/model/adapter.js +16 -0
- package/dist/mermaid/model/ops.d.ts +282 -0
- package/dist/mermaid/model/ops.js +9 -0
- package/dist/mermaid/model/round-trip.d.ts +22 -0
- package/dist/mermaid/model/round-trip.js +45 -0
- package/dist/mermaid/model/types.d.ts +271 -0
- package/dist/mermaid/model/types.js +0 -0
- package/dist/mermaid/print-render.d.ts +9 -0
- package/dist/mermaid/print-render.js +39 -0
- package/dist/mermaid/runtime.d.ts +25 -0
- package/dist/mermaid/runtime.js +183 -0
- package/dist/mermaid/sanitize.d.ts +46 -0
- package/dist/mermaid/sanitize.js +234 -0
- package/dist/mermaid/types.d.ts +43 -0
- package/dist/mermaid/types.js +21 -0
- package/dist/mermaid/view/ViewModePane.d.ts +24 -0
- package/dist/mermaid/view/ViewModePane.js +9 -0
- package/dist/utils/client-lazy.d.ts +1 -1
- package/dist/utils/client-lazy.js +4 -1
- package/dist/utils/lifted/DiffView.d.ts +10 -0
- package/dist/utils/lifted/DiffView.js +26 -0
- package/dist/utils/lifted/IconButton.d.ts +24 -0
- package/dist/utils/lifted/IconButton.js +43 -0
- package/dist/utils/lifted/MatrxMiniLoader.d.ts +1 -0
- package/dist/utils/lifted/MatrxMiniLoader.js +8 -0
- package/dist/utils/lifted/ShimmerText.d.ts +5 -0
- package/dist/utils/lifted/ShimmerText.js +21 -0
- package/dist/utils/lifted/SuspenseLoader.d.ts +16 -0
- package/dist/utils/lifted/SuspenseLoader.js +42 -0
- package/dist/utils/lifted/Tooltip.d.ts +20 -0
- package/dist/utils/lifted/Tooltip.js +52 -0
- package/dist/utils/lifted/artifactId.d.ts +34 -0
- package/dist/utils/lifted/artifactId.js +15 -0
- package/dist/utils/lifted/canvasContent.d.ts +63 -0
- package/dist/utils/lifted/canvasContent.js +98 -0
- package/dist/utils/lifted/captureReactError.d.ts +24 -0
- package/dist/utils/lifted/captureReactError.js +28 -0
- package/dist/utils/lifted/chunk-load-recovery.d.ts +25 -0
- package/dist/utils/lifted/chunk-load-recovery.js +36 -0
- package/dist/utils/lifted/code-editor-agent-types.d.ts +6 -0
- package/dist/utils/lifted/code-editor-agent-types.js +0 -0
- package/dist/utils/lifted/code-editor-agents.d.ts +39 -0
- package/dist/utils/lifted/code-editor-agents.js +52 -0
- package/dist/utils/lifted/code-language-extension.d.ts +1 -0
- package/dist/utils/lifted/code-language-extension.js +60 -0
- package/dist/utils/lifted/custom-icons.d.ts +16 -0
- package/dist/utils/lifted/custom-icons.js +47 -0
- package/dist/utils/lifted/durability.d.ts +16 -0
- package/dist/utils/lifted/durability.js +45 -0
- package/dist/utils/lifted/errors.d.ts +30 -0
- package/dist/utils/lifted/errors.js +29 -0
- package/dist/utils/lifted/html-document.d.ts +1 -0
- package/dist/utils/lifted/html-document.js +12 -0
- package/dist/utils/lifted/languageOptions.d.ts +9 -0
- package/dist/utils/lifted/languageOptions.js +52 -0
- package/dist/utils/lifted/languages.d.ts +34 -0
- package/dist/utils/lifted/languages.js +175 -0
- package/dist/utils/lifted/loading-spinner.d.ts +18 -0
- package/dist/utils/lifted/loading-spinner.js +200 -0
- package/dist/utils/lifted/media-refs.d.ts +13 -0
- package/dist/utils/lifted/media-refs.js +27 -0
- package/dist/utils/lifted/scroll-root.d.ts +1 -0
- package/dist/utils/lifted/scroll-root.js +25 -0
- package/dist/utils/lifted/syntax-themes.d.ts +32 -0
- package/dist/utils/lifted/syntax-themes.js +100 -0
- package/dist/utils/lifted/url-utm.d.ts +24 -0
- package/dist/utils/lifted/url-utm.js +66 -0
- package/dist/utils/lifted/use-is-mounted.d.ts +24 -0
- package/dist/utils/lifted/use-is-mounted.js +21 -0
- package/dist/utils/lifted/useToastManager.d.ts +1 -0
- package/dist/utils/lifted/useToastManager.js +7 -0
- package/dist/utils/report-kind-at-raw-renderer.d.ts +19 -0
- package/dist/utils/report-kind-at-raw-renderer.js +32 -0
- package/package.json +32 -3
|
@@ -0,0 +1,649 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
3
|
+
import React from "react";
|
|
4
|
+
import MarkdownCore from "../../markdown-core/MarkdownCore.js";
|
|
5
|
+
import { cn } from "@ai-matrx/design-system";
|
|
6
|
+
import { Checkbox } from "@ai-matrx/design-system";
|
|
7
|
+
import { PencilIcon } from "lucide-react";
|
|
8
|
+
import { useState, useMemo, useEffect } from "react";
|
|
9
|
+
import {
|
|
10
|
+
guardMarkdownDelimiters,
|
|
11
|
+
reportDelimiterViolations
|
|
12
|
+
} from "@ai-matrx/kit/delimiter-guard";
|
|
13
|
+
import { captureError } from "../../host/diagnostics.js";
|
|
14
|
+
import { LinkComponent } from "../blocks/links/LinkComponent.js";
|
|
15
|
+
import { InlineCopyButton } from "../../host/app-bindings.js";
|
|
16
|
+
import {
|
|
17
|
+
useMediaBlob,
|
|
18
|
+
useMediaLoadRecovery
|
|
19
|
+
} from "@ai-matrx/media/core";
|
|
20
|
+
import { recognizeOurFileUrl } from "@ai-matrx/media/files/engine/media/our-file-sources";
|
|
21
|
+
import { detectTextDirection } from "../../levels/prose/prose-prepare.js";
|
|
22
|
+
import { RemoteImageGate, remoteImageHost, withImagePolicy } from "../../levels/prose/remote-image-policy.js";
|
|
23
|
+
import { fileSourceToMediaRef } from "../../utils/lifted/media-refs.js";
|
|
24
|
+
import { KindTextGate } from "./KindTextGate.js";
|
|
25
|
+
function DurableMarkdownImg(props) {
|
|
26
|
+
const src = typeof props.src === "string" ? props.src : "";
|
|
27
|
+
return /* @__PURE__ */ jsx(RemoteImageGate, { src, alt: props.alt, children: /* @__PURE__ */ jsx(DurableMarkdownImgImpl, { ...props }) });
|
|
28
|
+
}
|
|
29
|
+
function DurableMarkdownImgImpl({
|
|
30
|
+
src,
|
|
31
|
+
alt,
|
|
32
|
+
className,
|
|
33
|
+
...props
|
|
34
|
+
}) {
|
|
35
|
+
const raw = typeof src === "string" ? src : null;
|
|
36
|
+
const ourFile = raw ? recognizeOurFileUrl(raw) : null;
|
|
37
|
+
const fileRef = fileSourceToMediaRef(ourFile?.source);
|
|
38
|
+
const authenticatedBlob = useMediaBlob(fileRef);
|
|
39
|
+
const effectiveSrc = fileRef ? authenticatedBlob.url : raw;
|
|
40
|
+
const { retryKey, onLoadError: onError, failed } = useMediaLoadRecovery(
|
|
41
|
+
effectiveSrc,
|
|
42
|
+
{
|
|
43
|
+
// Owned images already crossed the authenticated byte boundary before
|
|
44
|
+
// they reach the element. A blob URL cannot be repaired by refreshing
|
|
45
|
+
// the file-session cookie; blob-read failures are captured by
|
|
46
|
+
// useMediaBlob itself.
|
|
47
|
+
recoverable: false,
|
|
48
|
+
failureRef: fileRef
|
|
49
|
+
}
|
|
50
|
+
);
|
|
51
|
+
if (!effectiveSrc || failed) return null;
|
|
52
|
+
return /* @__PURE__ */ jsx(
|
|
53
|
+
"img",
|
|
54
|
+
{
|
|
55
|
+
className,
|
|
56
|
+
...props,
|
|
57
|
+
src: effectiveSrc,
|
|
58
|
+
alt: alt || "Image",
|
|
59
|
+
referrerPolicy: remoteImageHost(effectiveSrc) ? "no-referrer" : props.referrerPolicy,
|
|
60
|
+
onError
|
|
61
|
+
},
|
|
62
|
+
retryKey
|
|
63
|
+
);
|
|
64
|
+
}
|
|
65
|
+
const DEFAULT_TYPOGRAPHY = {
|
|
66
|
+
fontFamily: "font-sans",
|
|
67
|
+
fontSizeLtr: "text-sm",
|
|
68
|
+
fontSizeRtl: "text-base",
|
|
69
|
+
tracking: "tracking-wide",
|
|
70
|
+
leading: "leading-relaxed"
|
|
71
|
+
};
|
|
72
|
+
const DEFAULT_COLORS = {
|
|
73
|
+
accent: "blue",
|
|
74
|
+
codeBgLight: "bg-blue-100",
|
|
75
|
+
codeTextLight: "text-blue-800",
|
|
76
|
+
codeBgDark: "dark:bg-blue-900/30",
|
|
77
|
+
codeTextDark: "dark:text-blue-300",
|
|
78
|
+
blockquoteBorderLight: "border-blue-200",
|
|
79
|
+
blockquoteBorderDark: "dark:border-blue-700",
|
|
80
|
+
blockquoteBgLight: "bg-blue-50",
|
|
81
|
+
blockquoteBgDark: "dark:bg-blue-950/20",
|
|
82
|
+
blockquoteTextLight: "text-gray-700",
|
|
83
|
+
blockquoteTextDark: "dark:text-gray-300",
|
|
84
|
+
emColorLight: "text-blue-600",
|
|
85
|
+
emColorDark: "dark:text-blue-400",
|
|
86
|
+
headingColor: "text-blue-500",
|
|
87
|
+
hrBorderLight: "border-gray-300",
|
|
88
|
+
hrBorderDark: "dark:border-gray-600",
|
|
89
|
+
checkboxBorderLight: "border-blue-400",
|
|
90
|
+
checkboxCheckedBgLight: "bg-blue-600",
|
|
91
|
+
editButtonColor: "text-gray-500",
|
|
92
|
+
editButtonHoverColor: "hover:text-gray-700"
|
|
93
|
+
};
|
|
94
|
+
const DEFAULT_SPACING = {
|
|
95
|
+
paragraphMb: "mb-2",
|
|
96
|
+
listMb: "mb-3",
|
|
97
|
+
listPl: "pl-6",
|
|
98
|
+
listItemMb: "mb-1",
|
|
99
|
+
blockquotePl: "pl-4",
|
|
100
|
+
blockquotePr: "pr-4",
|
|
101
|
+
blockquotePy: "py-3",
|
|
102
|
+
preMy: "my-3",
|
|
103
|
+
imgMy: "my-4",
|
|
104
|
+
hrMy: "my-3",
|
|
105
|
+
mathParagraphMb: "mb-4",
|
|
106
|
+
blankLineHeight: "h-[0.75em]",
|
|
107
|
+
wrapperMy: "my-2"
|
|
108
|
+
};
|
|
109
|
+
const DEFAULT_HEADINGS = {
|
|
110
|
+
h1: "text-2xl font-bold pt-2 mb-1 font-heading",
|
|
111
|
+
h2: "text-xl font-medium pt-1 mb-1 font-heading",
|
|
112
|
+
h3: "text-lg font-medium pt-1 mb-2 font-heading",
|
|
113
|
+
h4: "text-lg pt-2 font-medium mb-1 mt-3 font-heading"
|
|
114
|
+
};
|
|
115
|
+
function resolveConfig(partial) {
|
|
116
|
+
return {
|
|
117
|
+
typography: { ...DEFAULT_TYPOGRAPHY, ...partial?.typography },
|
|
118
|
+
colors: { ...DEFAULT_COLORS, ...partial?.colors },
|
|
119
|
+
spacing: { ...DEFAULT_SPACING, ...partial?.spacing },
|
|
120
|
+
headings: { ...DEFAULT_HEADINGS, ...partial?.headings },
|
|
121
|
+
wrapperClassName: partial?.wrapperClassName ?? ""
|
|
122
|
+
};
|
|
123
|
+
}
|
|
124
|
+
const getDirectionClasses = (direction) => direction === "rtl" ? "text-right rtl" : "text-left ltr";
|
|
125
|
+
const ConfigurableMarkdownContent = (props) => /* @__PURE__ */ jsx(
|
|
126
|
+
KindTextGate,
|
|
127
|
+
{
|
|
128
|
+
component: "ConfigurableMarkdownContent",
|
|
129
|
+
content: props.content,
|
|
130
|
+
isStreamActive: props.isStreamActive,
|
|
131
|
+
imagePolicy: props.imagePolicy,
|
|
132
|
+
showSource: props.showSource,
|
|
133
|
+
showCopyButton: props.showCopyButton ?? true,
|
|
134
|
+
children: /* @__PURE__ */ jsx(ConfigurableMarkdownContentBody, { ...props })
|
|
135
|
+
}
|
|
136
|
+
);
|
|
137
|
+
const ConfigurableMarkdownContentBody = ({
|
|
138
|
+
content,
|
|
139
|
+
isStreamActive,
|
|
140
|
+
onEditRequest,
|
|
141
|
+
messageId,
|
|
142
|
+
showCopyButton = true,
|
|
143
|
+
styleConfig,
|
|
144
|
+
componentOverrides,
|
|
145
|
+
imagePolicy
|
|
146
|
+
}) => {
|
|
147
|
+
const [isHovering, setIsHovering] = useState(false);
|
|
148
|
+
const { typography, colors, spacing, headings, wrapperClassName } = useMemo(
|
|
149
|
+
() => resolveConfig(styleConfig),
|
|
150
|
+
[styleConfig]
|
|
151
|
+
);
|
|
152
|
+
const textDirection = useMemo(() => detectTextDirection(content), [content]);
|
|
153
|
+
const directionClasses = getDirectionClasses(textDirection);
|
|
154
|
+
const getFontSize = (direction) => direction === "rtl" ? typography.fontSizeRtl : typography.fontSizeLtr;
|
|
155
|
+
const LinkWrapper = useMemo(() => {
|
|
156
|
+
if (componentOverrides?.a) return componentOverrides.a;
|
|
157
|
+
return ({ node, href, children, ...props }) => href ? /* @__PURE__ */ jsx(LinkComponent, { href, children }) : /* @__PURE__ */ jsx(Fragment, { children });
|
|
158
|
+
}, [componentOverrides?.a]);
|
|
159
|
+
const preprocessContent = (rawContent) => {
|
|
160
|
+
let processed = rawContent;
|
|
161
|
+
processed = processed.replace(/<(\/?[\w][\w-]*)([^>]*?)>/g, "<$1$2>");
|
|
162
|
+
processed = processed.replace(
|
|
163
|
+
/^( +)/gm,
|
|
164
|
+
(spaces) => "\xA0\xA0".repeat(spaces.length)
|
|
165
|
+
);
|
|
166
|
+
processed = processed.replace(
|
|
167
|
+
/\[(https?:\/\/[^\]\s]+)\](?!\()/g,
|
|
168
|
+
"[$1]($1)"
|
|
169
|
+
);
|
|
170
|
+
processed = processed.replace(/^(\s*)\*([ \t]+)/gm, "$1-$2");
|
|
171
|
+
processed = processed.replace(
|
|
172
|
+
/(^[ \t]*-[ \t]+[^\n]+)\n\n(\*\*\d)/gm,
|
|
173
|
+
"$1\n\n<!-- -->\n$2"
|
|
174
|
+
);
|
|
175
|
+
processed = processed.replace(/([^\n])\n---/g, "$1\n\n---");
|
|
176
|
+
processed = processed.replace(/(\*\*[^*]+\*\*)\n([^\n*\-])/g, "$1\n\n$2");
|
|
177
|
+
processed = processed.replace(
|
|
178
|
+
/([^\n])\n(\*[^*]+\*)\n([^\n])/g,
|
|
179
|
+
"$1\n\n$2\n\n$3"
|
|
180
|
+
);
|
|
181
|
+
processed = processed.replace(
|
|
182
|
+
/(\*\*[^*]+\*\*|\*[^*]+\*)\n([^\n*\s\-])/g,
|
|
183
|
+
"$1\n\n$2"
|
|
184
|
+
);
|
|
185
|
+
processed = processed.replace(
|
|
186
|
+
/(^|\n)(\s+[*-] .+)\n(?!\s*[*-]\s)([^\n\s\-#\d][^\n]*)/gm,
|
|
187
|
+
"$1$2\n\n$3"
|
|
188
|
+
);
|
|
189
|
+
processed = processed.replace(
|
|
190
|
+
/(^|\n)(- .+)\n(?!\s*[*-]\s)([^\n\s\-#\d][^\n]*)/gm,
|
|
191
|
+
"$1$2\n\n$3"
|
|
192
|
+
);
|
|
193
|
+
processed = processed.replace(
|
|
194
|
+
/(^|\n)(\d+\. .+)\n(?!\s*\d+[.)]\s)([^\n\s\-#\d][^\n]*)/gm,
|
|
195
|
+
"$1$2\n\n$3"
|
|
196
|
+
);
|
|
197
|
+
processed = processed.replace(
|
|
198
|
+
/(^|\n)(\d+\) .+)\n(?!\s*\d+[.)]\s)([^\n\s\-#\d][^\n]*)/gm,
|
|
199
|
+
"$1$2\n\n$3"
|
|
200
|
+
);
|
|
201
|
+
processed = processed.replace(/\n{2,}/g, (match) => {
|
|
202
|
+
const blankLines = Math.min(match.length - 1, 2);
|
|
203
|
+
return "\n\n" + " \n\n".repeat(blankLines);
|
|
204
|
+
});
|
|
205
|
+
return processed;
|
|
206
|
+
};
|
|
207
|
+
const { text: processedContent, violations: delimiterViolations } = guardMarkdownDelimiters(preprocessContent(content));
|
|
208
|
+
const delimiterViolationSignature = delimiterViolations.map((v) => `${v.reason}@${v.index}`).join("|");
|
|
209
|
+
useEffect(() => {
|
|
210
|
+
if (isStreamActive || !delimiterViolationSignature) return;
|
|
211
|
+
reportDelimiterViolations(delimiterViolations, {
|
|
212
|
+
renderPath: "ConfigurableMarkdownContent",
|
|
213
|
+
messageId,
|
|
214
|
+
capture: (input) => captureError({ ...input })
|
|
215
|
+
});
|
|
216
|
+
}, [delimiterViolationSignature, isStreamActive, messageId]);
|
|
217
|
+
const handleEdit = () => onEditRequest?.();
|
|
218
|
+
const handleMouseEnter = !isStreamActive ? () => setIsHovering(true) : void 0;
|
|
219
|
+
const handleMouseLeave = !isStreamActive ? () => setIsHovering(false) : void 0;
|
|
220
|
+
const components = useMemo(
|
|
221
|
+
() => {
|
|
222
|
+
const extractText = (children) => {
|
|
223
|
+
if (typeof children === "string") return children;
|
|
224
|
+
if (Array.isArray(children)) return children.map(extractText).join("");
|
|
225
|
+
if (children && typeof children === "object" && "props" in children && children.props && typeof children.props === "object" && "children" in children.props) {
|
|
226
|
+
return extractText(children.props.children);
|
|
227
|
+
}
|
|
228
|
+
return "";
|
|
229
|
+
};
|
|
230
|
+
return {
|
|
231
|
+
// ---- input (checkbox) ----
|
|
232
|
+
input: ({ node, type, checked, disabled, ...props }) => {
|
|
233
|
+
if (type === "checkbox") {
|
|
234
|
+
return /* @__PURE__ */ jsx(
|
|
235
|
+
Checkbox,
|
|
236
|
+
{
|
|
237
|
+
checked,
|
|
238
|
+
disabled,
|
|
239
|
+
className: "mr-2"
|
|
240
|
+
}
|
|
241
|
+
);
|
|
242
|
+
}
|
|
243
|
+
return /* @__PURE__ */ jsx("input", { type, ...props });
|
|
244
|
+
},
|
|
245
|
+
// ---- p ----
|
|
246
|
+
p: componentOverrides?.p ?? (({ node, children, ...props }) => {
|
|
247
|
+
const childArray = React.Children.toArray(children);
|
|
248
|
+
if (childArray.length === 1 && childArray[0] === "\xA0") {
|
|
249
|
+
return /* @__PURE__ */ jsx("div", { className: spacing.blankLineHeight });
|
|
250
|
+
}
|
|
251
|
+
let isMathOnly = false;
|
|
252
|
+
if (childArray.length === 1) {
|
|
253
|
+
const child = childArray[0];
|
|
254
|
+
if (child && typeof child === "object" && "props" in child && child.props && typeof child.props === "object" && "className" in child.props && typeof child.props.className === "string") {
|
|
255
|
+
isMathOnly = child.props.className.includes("katex");
|
|
256
|
+
}
|
|
257
|
+
}
|
|
258
|
+
const paragraphText = extractText(children);
|
|
259
|
+
const paragraphDirection = detectTextDirection(paragraphText);
|
|
260
|
+
const paragraphDirClasses = getDirectionClasses(paragraphDirection);
|
|
261
|
+
if (isMathOnly) {
|
|
262
|
+
return /* @__PURE__ */ jsx(
|
|
263
|
+
"p",
|
|
264
|
+
{
|
|
265
|
+
className: cn(
|
|
266
|
+
typography.fontFamily,
|
|
267
|
+
typography.tracking,
|
|
268
|
+
typography.leading,
|
|
269
|
+
"text-base text-center",
|
|
270
|
+
spacing.mathParagraphMb
|
|
271
|
+
),
|
|
272
|
+
...props,
|
|
273
|
+
children
|
|
274
|
+
}
|
|
275
|
+
);
|
|
276
|
+
}
|
|
277
|
+
return /* @__PURE__ */ jsx(
|
|
278
|
+
"p",
|
|
279
|
+
{
|
|
280
|
+
className: cn(
|
|
281
|
+
typography.fontFamily,
|
|
282
|
+
typography.tracking,
|
|
283
|
+
typography.leading,
|
|
284
|
+
getFontSize(paragraphDirection),
|
|
285
|
+
spacing.paragraphMb,
|
|
286
|
+
"pl-0 ml-0",
|
|
287
|
+
paragraphDirClasses
|
|
288
|
+
),
|
|
289
|
+
dir: paragraphDirection,
|
|
290
|
+
...props,
|
|
291
|
+
children
|
|
292
|
+
}
|
|
293
|
+
);
|
|
294
|
+
}),
|
|
295
|
+
// ---- strong ----
|
|
296
|
+
strong: componentOverrides?.strong ?? (({ node, children, ...props }) => {
|
|
297
|
+
const isInHeading = false;
|
|
298
|
+
const boldText = extractText(children);
|
|
299
|
+
const boldDirection = detectTextDirection(boldText);
|
|
300
|
+
return /* @__PURE__ */ jsx(
|
|
301
|
+
"strong",
|
|
302
|
+
{
|
|
303
|
+
className: cn(
|
|
304
|
+
isInHeading ? "" : "font-extrabold",
|
|
305
|
+
getDirectionClasses(boldDirection)
|
|
306
|
+
),
|
|
307
|
+
dir: boldDirection,
|
|
308
|
+
...props,
|
|
309
|
+
children
|
|
310
|
+
}
|
|
311
|
+
);
|
|
312
|
+
}),
|
|
313
|
+
// ---- em ----
|
|
314
|
+
em: componentOverrides?.em ?? (({ node, children, ...props }) => {
|
|
315
|
+
const isInHeading = false;
|
|
316
|
+
const italicText = extractText(children);
|
|
317
|
+
const italicDirection = detectTextDirection(italicText);
|
|
318
|
+
return /* @__PURE__ */ jsx(
|
|
319
|
+
"em",
|
|
320
|
+
{
|
|
321
|
+
className: cn(
|
|
322
|
+
"italic",
|
|
323
|
+
isInHeading ? "" : cn(colors.emColorLight, colors.emColorDark),
|
|
324
|
+
getDirectionClasses(italicDirection)
|
|
325
|
+
),
|
|
326
|
+
dir: italicDirection,
|
|
327
|
+
...props,
|
|
328
|
+
children
|
|
329
|
+
}
|
|
330
|
+
);
|
|
331
|
+
}),
|
|
332
|
+
// ---- blockquote ----
|
|
333
|
+
blockquote: componentOverrides?.blockquote ?? (({ node, children, ...props }) => {
|
|
334
|
+
const blockquoteText = extractText(children);
|
|
335
|
+
const blockquoteDirection = detectTextDirection(blockquoteText);
|
|
336
|
+
const isRtl = blockquoteDirection === "rtl";
|
|
337
|
+
return /* @__PURE__ */ jsx(
|
|
338
|
+
"blockquote",
|
|
339
|
+
{
|
|
340
|
+
className: cn(
|
|
341
|
+
isRtl ? cn(spacing.blockquotePr, "border-r-4") : cn(spacing.blockquotePl, "border-l-4"),
|
|
342
|
+
spacing.blockquotePy,
|
|
343
|
+
colors.blockquoteBorderLight,
|
|
344
|
+
colors.blockquoteBorderDark,
|
|
345
|
+
"italic",
|
|
346
|
+
colors.blockquoteTextLight,
|
|
347
|
+
colors.blockquoteTextDark,
|
|
348
|
+
colors.blockquoteBgLight,
|
|
349
|
+
colors.blockquoteBgDark,
|
|
350
|
+
getDirectionClasses(blockquoteDirection)
|
|
351
|
+
),
|
|
352
|
+
dir: blockquoteDirection,
|
|
353
|
+
...props,
|
|
354
|
+
children
|
|
355
|
+
}
|
|
356
|
+
);
|
|
357
|
+
}),
|
|
358
|
+
// ---- ul ----
|
|
359
|
+
ul: componentOverrides?.ul ?? (({ node, children, ...props }) => {
|
|
360
|
+
const listText = extractText(children);
|
|
361
|
+
const listDirection = detectTextDirection(listText);
|
|
362
|
+
return /* @__PURE__ */ jsx(
|
|
363
|
+
"ul",
|
|
364
|
+
{
|
|
365
|
+
className: cn(
|
|
366
|
+
// L1 disc, L2 hollow circle, L3+ dash (depth cascade).
|
|
367
|
+
"matrx-md-ul",
|
|
368
|
+
spacing.listMb,
|
|
369
|
+
typography.leading,
|
|
370
|
+
getFontSize(listDirection),
|
|
371
|
+
spacing.listPl,
|
|
372
|
+
getDirectionClasses(listDirection)
|
|
373
|
+
),
|
|
374
|
+
dir: listDirection,
|
|
375
|
+
...props,
|
|
376
|
+
children
|
|
377
|
+
}
|
|
378
|
+
);
|
|
379
|
+
}),
|
|
380
|
+
// ---- ol ----
|
|
381
|
+
ol: componentOverrides?.ol ?? (({ node, children, ...props }) => {
|
|
382
|
+
const listText = extractText(children);
|
|
383
|
+
const listDirection = detectTextDirection(listText);
|
|
384
|
+
return /* @__PURE__ */ jsx(
|
|
385
|
+
"ol",
|
|
386
|
+
{
|
|
387
|
+
className: cn(
|
|
388
|
+
// L1 decimal, L2 lower-roman, L3+ lower-alpha (depth cascade).
|
|
389
|
+
"matrx-md-ol",
|
|
390
|
+
spacing.listMb,
|
|
391
|
+
typography.leading,
|
|
392
|
+
getFontSize(listDirection),
|
|
393
|
+
spacing.listPl,
|
|
394
|
+
getDirectionClasses(listDirection)
|
|
395
|
+
),
|
|
396
|
+
dir: listDirection,
|
|
397
|
+
...props,
|
|
398
|
+
children
|
|
399
|
+
}
|
|
400
|
+
);
|
|
401
|
+
}),
|
|
402
|
+
// ---- li ----
|
|
403
|
+
li: componentOverrides?.li ?? (({ node, children, ...props }) => {
|
|
404
|
+
const itemText = extractText(children);
|
|
405
|
+
const itemDirection = detectTextDirection(itemText);
|
|
406
|
+
const nodeClassName = node?.properties?.className;
|
|
407
|
+
const isTaskItem = Array.isArray(nodeClassName) && nodeClassName.includes("task-list-item");
|
|
408
|
+
if (isTaskItem) {
|
|
409
|
+
return /* @__PURE__ */ jsx(
|
|
410
|
+
"li",
|
|
411
|
+
{
|
|
412
|
+
className: cn(
|
|
413
|
+
spacing.listItemMb,
|
|
414
|
+
"flex items-center",
|
|
415
|
+
getFontSize(itemDirection),
|
|
416
|
+
getDirectionClasses(itemDirection)
|
|
417
|
+
),
|
|
418
|
+
dir: itemDirection,
|
|
419
|
+
children
|
|
420
|
+
}
|
|
421
|
+
);
|
|
422
|
+
}
|
|
423
|
+
return /* @__PURE__ */ jsx(
|
|
424
|
+
"li",
|
|
425
|
+
{
|
|
426
|
+
className: cn(
|
|
427
|
+
spacing.listItemMb,
|
|
428
|
+
getFontSize(itemDirection),
|
|
429
|
+
getDirectionClasses(itemDirection)
|
|
430
|
+
),
|
|
431
|
+
dir: itemDirection,
|
|
432
|
+
children
|
|
433
|
+
}
|
|
434
|
+
);
|
|
435
|
+
}),
|
|
436
|
+
// ---- link ----
|
|
437
|
+
a: LinkWrapper,
|
|
438
|
+
// ---- headings ----
|
|
439
|
+
h1: componentOverrides?.h1 ?? (({ node, children, ...props }) => {
|
|
440
|
+
const headingText = extractText(children);
|
|
441
|
+
const headingDirection = detectTextDirection(headingText);
|
|
442
|
+
return /* @__PURE__ */ jsx(
|
|
443
|
+
"h1",
|
|
444
|
+
{
|
|
445
|
+
className: cn(
|
|
446
|
+
headings.h1,
|
|
447
|
+
colors.headingColor,
|
|
448
|
+
getDirectionClasses(headingDirection)
|
|
449
|
+
),
|
|
450
|
+
dir: headingDirection,
|
|
451
|
+
...props,
|
|
452
|
+
children
|
|
453
|
+
}
|
|
454
|
+
);
|
|
455
|
+
}),
|
|
456
|
+
h2: componentOverrides?.h2 ?? (({ node, children, ...props }) => {
|
|
457
|
+
const headingText = extractText(children);
|
|
458
|
+
const headingDirection = detectTextDirection(headingText);
|
|
459
|
+
return /* @__PURE__ */ jsx(
|
|
460
|
+
"h2",
|
|
461
|
+
{
|
|
462
|
+
className: cn(
|
|
463
|
+
headings.h2,
|
|
464
|
+
colors.headingColor,
|
|
465
|
+
getDirectionClasses(headingDirection)
|
|
466
|
+
),
|
|
467
|
+
dir: headingDirection,
|
|
468
|
+
...props,
|
|
469
|
+
children
|
|
470
|
+
}
|
|
471
|
+
);
|
|
472
|
+
}),
|
|
473
|
+
h3: componentOverrides?.h3 ?? (({ node, children, ...props }) => {
|
|
474
|
+
const headingText = extractText(children);
|
|
475
|
+
const headingDirection = detectTextDirection(headingText);
|
|
476
|
+
return /* @__PURE__ */ jsx(
|
|
477
|
+
"h3",
|
|
478
|
+
{
|
|
479
|
+
className: cn(
|
|
480
|
+
headings.h3,
|
|
481
|
+
colors.headingColor,
|
|
482
|
+
getDirectionClasses(headingDirection)
|
|
483
|
+
),
|
|
484
|
+
dir: headingDirection,
|
|
485
|
+
...props,
|
|
486
|
+
children
|
|
487
|
+
}
|
|
488
|
+
);
|
|
489
|
+
}),
|
|
490
|
+
h4: componentOverrides?.h4 ?? (({ node, children, ...props }) => {
|
|
491
|
+
const headingText = extractText(children);
|
|
492
|
+
const headingDirection = detectTextDirection(headingText);
|
|
493
|
+
return /* @__PURE__ */ jsx(
|
|
494
|
+
"h4",
|
|
495
|
+
{
|
|
496
|
+
className: cn(
|
|
497
|
+
headings.h4,
|
|
498
|
+
colors.headingColor,
|
|
499
|
+
getDirectionClasses(headingDirection)
|
|
500
|
+
),
|
|
501
|
+
dir: headingDirection,
|
|
502
|
+
...props,
|
|
503
|
+
children
|
|
504
|
+
}
|
|
505
|
+
);
|
|
506
|
+
}),
|
|
507
|
+
// ---- pre ----
|
|
508
|
+
pre: componentOverrides?.pre ?? (({ node, children, ...props }) => /* @__PURE__ */ jsx("pre", { className: spacing.preMy, ...props, children })),
|
|
509
|
+
// ---- code (inline only) ----
|
|
510
|
+
code: componentOverrides?.code ?? (({ node, className, children, ...props }) => {
|
|
511
|
+
const isCodeBlock = Array.isArray(children) && children.length === 1 && typeof children[0] === "string" && children[0] === "pygame";
|
|
512
|
+
if (!isCodeBlock) {
|
|
513
|
+
return /* @__PURE__ */ jsx(
|
|
514
|
+
"code",
|
|
515
|
+
{
|
|
516
|
+
className: cn(
|
|
517
|
+
"px-1.5 py-0 rounded font-mono text-sm font-medium",
|
|
518
|
+
colors.codeBgLight,
|
|
519
|
+
colors.codeTextLight,
|
|
520
|
+
colors.codeBgDark,
|
|
521
|
+
colors.codeTextDark,
|
|
522
|
+
className
|
|
523
|
+
),
|
|
524
|
+
style: { overflowWrap: "anywhere", wordBreak: "normal" },
|
|
525
|
+
...props,
|
|
526
|
+
children
|
|
527
|
+
}
|
|
528
|
+
);
|
|
529
|
+
}
|
|
530
|
+
return null;
|
|
531
|
+
}),
|
|
532
|
+
// ---- img ----
|
|
533
|
+
img: componentOverrides?.img ?? (({ node, ...props }) => /* @__PURE__ */ jsx(
|
|
534
|
+
DurableMarkdownImg,
|
|
535
|
+
{
|
|
536
|
+
className: cn("max-w-full h-auto rounded-md", spacing.imgMy),
|
|
537
|
+
...props,
|
|
538
|
+
alt: props.alt || "Image"
|
|
539
|
+
}
|
|
540
|
+
)),
|
|
541
|
+
// ---- hr ----
|
|
542
|
+
hr: componentOverrides?.hr ?? (({ node, ...props }) => /* @__PURE__ */ jsx(
|
|
543
|
+
"hr",
|
|
544
|
+
{
|
|
545
|
+
className: cn(
|
|
546
|
+
spacing.hrMy,
|
|
547
|
+
"border-t",
|
|
548
|
+
colors.hrBorderLight,
|
|
549
|
+
colors.hrBorderDark
|
|
550
|
+
),
|
|
551
|
+
...props
|
|
552
|
+
}
|
|
553
|
+
)),
|
|
554
|
+
// ---- br ----
|
|
555
|
+
br: ({ node, ...props }) => /* @__PURE__ */ jsx("br", {}),
|
|
556
|
+
// ---- div / span (pass-through) ----
|
|
557
|
+
div: ({ node, className, children, ...props }) => /* @__PURE__ */ jsx("div", { className, ...props, children }),
|
|
558
|
+
span: ({ node, className, children, ...props }) => /* @__PURE__ */ jsx("span", { className, ...props, children }),
|
|
559
|
+
// ---- tables (hidden by default, overridable) ----
|
|
560
|
+
table: componentOverrides?.table ?? (() => null),
|
|
561
|
+
thead: () => null,
|
|
562
|
+
tbody: () => null,
|
|
563
|
+
tr: () => null,
|
|
564
|
+
th: () => null,
|
|
565
|
+
td: () => null
|
|
566
|
+
};
|
|
567
|
+
},
|
|
568
|
+
// Re-derive when config or overrides change
|
|
569
|
+
[typography, colors, spacing, headings, componentOverrides, LinkWrapper]
|
|
570
|
+
);
|
|
571
|
+
const dynamicStyles = `
|
|
572
|
+
/* Center display math that appears after a line break */
|
|
573
|
+
.math-content-wrapper p > .block + .katex {
|
|
574
|
+
display: block;
|
|
575
|
+
text-align: center;
|
|
576
|
+
margin: 1em 0;
|
|
577
|
+
font-size: 1.5em;
|
|
578
|
+
}
|
|
579
|
+
/* Increase font size for standalone math paragraphs */
|
|
580
|
+
.math-content-wrapper p.text-center .katex {
|
|
581
|
+
font-size: 1.5em;
|
|
582
|
+
}
|
|
583
|
+
/* Override pre tags that contain inline code (indented text blocks) */
|
|
584
|
+
.math-content-wrapper pre:has(> code.${colors.codeBgLight.replace("bg-", "").replace("/", "\\/").replace("[", "\\[").replace("]", "\\]")}) {
|
|
585
|
+
white-space: pre-wrap;
|
|
586
|
+
word-wrap: break-word;
|
|
587
|
+
overflow-wrap: anywhere;
|
|
588
|
+
font-family: inherit;
|
|
589
|
+
background: transparent;
|
|
590
|
+
padding: 0;
|
|
591
|
+
margin: 0;
|
|
592
|
+
}
|
|
593
|
+
.math-content-wrapper pre:has(> code.${colors.codeBgLight.replace("bg-", "").replace("/", "\\/").replace("[", "\\[").replace("]", "\\]")}) > code {
|
|
594
|
+
white-space: normal;
|
|
595
|
+
display: inline;
|
|
596
|
+
overflow-wrap: anywhere;
|
|
597
|
+
word-break: normal;
|
|
598
|
+
}
|
|
599
|
+
`;
|
|
600
|
+
const rendered = /* @__PURE__ */ jsxs(
|
|
601
|
+
"div",
|
|
602
|
+
{
|
|
603
|
+
className: cn(
|
|
604
|
+
"relative group math-content-wrapper overflow-x-hidden min-w-0 break-words",
|
|
605
|
+
spacing.wrapperMy,
|
|
606
|
+
directionClasses,
|
|
607
|
+
wrapperClassName
|
|
608
|
+
),
|
|
609
|
+
dir: textDirection,
|
|
610
|
+
onMouseEnter: handleMouseEnter,
|
|
611
|
+
onMouseLeave: handleMouseLeave,
|
|
612
|
+
children: [
|
|
613
|
+
/* @__PURE__ */ jsx("style", { dangerouslySetInnerHTML: { __html: dynamicStyles } }),
|
|
614
|
+
/* @__PURE__ */ jsx(MarkdownCore, { preset: "rich", components, children: processedContent }),
|
|
615
|
+
!isStreamActive && isHovering && /* @__PURE__ */ jsxs("div", { className: "absolute top-0 right-0 p-1 opacity-0 group-hover:opacity-100 transition-opacity duration-200", children: [
|
|
616
|
+
showCopyButton && /* @__PURE__ */ jsx(
|
|
617
|
+
InlineCopyButton,
|
|
618
|
+
{
|
|
619
|
+
markdownContent: content,
|
|
620
|
+
position: "top-right",
|
|
621
|
+
className: "mt-1 mr-1",
|
|
622
|
+
isMarkdown: true
|
|
623
|
+
}
|
|
624
|
+
),
|
|
625
|
+
onEditRequest && /* @__PURE__ */ jsx(
|
|
626
|
+
"button",
|
|
627
|
+
{
|
|
628
|
+
onClick: handleEdit,
|
|
629
|
+
className: cn(
|
|
630
|
+
"p-1 pt-6 rounded-md ml-1",
|
|
631
|
+
colors.editButtonColor,
|
|
632
|
+
colors.editButtonHoverColor
|
|
633
|
+
),
|
|
634
|
+
title: "Edit content",
|
|
635
|
+
children: /* @__PURE__ */ jsx(PencilIcon, { className: "w-4 h-4" })
|
|
636
|
+
}
|
|
637
|
+
)
|
|
638
|
+
] })
|
|
639
|
+
]
|
|
640
|
+
}
|
|
641
|
+
);
|
|
642
|
+
return /* @__PURE__ */ jsx(Fragment, { children: withImagePolicy(imagePolicy, rendered) });
|
|
643
|
+
};
|
|
644
|
+
var ConfigurableMarkdownContent_default = ConfigurableMarkdownContent;
|
|
645
|
+
export {
|
|
646
|
+
ConfigurableMarkdownContent,
|
|
647
|
+
DurableMarkdownImg,
|
|
648
|
+
ConfigurableMarkdownContent_default as default
|
|
649
|
+
};
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
interface InlineCodeSnippetProps {
|
|
3
|
+
code: string;
|
|
4
|
+
language?: string;
|
|
5
|
+
className?: string;
|
|
6
|
+
/**
|
|
7
|
+
* When true, `{{variable_name}}` tokens inside the code block are rendered
|
|
8
|
+
* as interactive MatrxVariableInline pills instead of plain text.
|
|
9
|
+
* The raw `code` string is still copied verbatim — only the visual display changes.
|
|
10
|
+
* Defaults to false to preserve existing behaviour everywhere else.
|
|
11
|
+
*/
|
|
12
|
+
renderVariables?: boolean;
|
|
13
|
+
/** The text is still streaming — never decided as a kind here (the stream's gates own it). */
|
|
14
|
+
isStreamActive?: boolean;
|
|
15
|
+
/** A deliberate source view: kind JSON shows as code (as `CodeBlock`'s `showSource`). */
|
|
16
|
+
showSource?: boolean;
|
|
17
|
+
}
|
|
18
|
+
export declare const InlineCodeSnippet: React.FC<InlineCodeSnippetProps>;
|
|
19
|
+
export default InlineCodeSnippet;
|