@ai-matrx/rich-content 0.2.4 → 0.2.7
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 +25 -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/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 +48 -10
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,29 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## 0.2.7
|
|
4
|
+
|
|
5
|
+
Automatic changed-only republish (docs/metadata drift since the last tag — see
|
|
6
|
+
`git diff npm/rich-content/v0.2.6..npm/rich-content/v0.2.7 -- apps/shared/rich-content`).
|
|
7
|
+
No source changes intended and no consumer action required.
|
|
8
|
+
|
|
9
|
+
## 0.2.6
|
|
10
|
+
|
|
11
|
+
The Mermaid runtime scheduling test now supplies Mermaid and ELK through the
|
|
12
|
+
documented rich-content host loaders. This keeps the test aligned with the
|
|
13
|
+
portable package contract: Mermaid remains a host-owned optional dependency,
|
|
14
|
+
rather than a direct package dependency.
|
|
15
|
+
|
|
16
|
+
### Consumer action
|
|
17
|
+
|
|
18
|
+
None. Hosts must continue registering `loadMermaid` (and optionally
|
|
19
|
+
`loadMermaidElk`) through `configureRichContent` when they render diagrams.
|
|
20
|
+
|
|
21
|
+
## 0.2.5
|
|
22
|
+
|
|
23
|
+
Automatic changed-only republish (docs/metadata drift since the last tag — see
|
|
24
|
+
`git diff npm/rich-content/v0.2.4..npm/rich-content/v0.2.5 -- apps/shared/rich-content`).
|
|
25
|
+
No source changes intended and no consumer action required.
|
|
26
|
+
|
|
3
27
|
## 0.2.4
|
|
4
28
|
|
|
5
29
|
`display/blocks/csv/CsvBlock`: Copy goes through `@ai-matrx/kit/clipboard` `useClipboard` with toast notices (carries matrx-frontend ALC-19 `b980571731`, which landed on the app copy as the app switched to this package).
|
|
@@ -82,3 +106,4 @@ held-back streaming text; the heal tests encode 1.3.1's behavior).
|
|
|
82
106
|
|
|
83
107
|
- matrx-frontend: call `configureRichContent` at the root (see README) and import from
|
|
84
108
|
`@ai-matrx/rich-content/<domain>/<module>`.
|
|
109
|
+
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import { type CodeBlockMenuItem } from "./CodeBlockHeader.js";
|
|
3
|
+
interface CodeBlockProps {
|
|
4
|
+
code: string;
|
|
5
|
+
language: string;
|
|
6
|
+
fontSize?: number;
|
|
7
|
+
showLineNumbers?: boolean;
|
|
8
|
+
wrapLines?: boolean;
|
|
9
|
+
className?: string;
|
|
10
|
+
onCodeChange?: (newCode: string) => void;
|
|
11
|
+
inline?: boolean;
|
|
12
|
+
isStreamActive?: boolean;
|
|
13
|
+
allowEdit?: boolean;
|
|
14
|
+
customBuiltinKeys?: string[];
|
|
15
|
+
/**
|
|
16
|
+
* Optional node rendered between the language display and the right-side
|
|
17
|
+
* action row. Used by language-specialized wrappers (e.g. `JsonBlock`) to
|
|
18
|
+
* add view-mode toggles without forking this component.
|
|
19
|
+
*/
|
|
20
|
+
headerLeftSlot?: React.ReactNode;
|
|
21
|
+
/**
|
|
22
|
+
* Extra items appended to the kebab menu. Use `category` on each item to
|
|
23
|
+
* place it in an existing section (View · Edit · Download · Save · AI) or
|
|
24
|
+
* introduce a new one (e.g. "Data" for tabular JSON actions).
|
|
25
|
+
*/
|
|
26
|
+
extraMenuItems?: CodeBlockMenuItem[];
|
|
27
|
+
/**
|
|
28
|
+
* The code fence's info string after the language (`title="app.tsx" {1,3-5}
|
|
29
|
+
* showLineNumbers`) — see components/markdown-core/fence-meta.ts. Sets the
|
|
30
|
+
* header title, highlighted lines and line numbering.
|
|
31
|
+
*/
|
|
32
|
+
meta?: string;
|
|
33
|
+
/**
|
|
34
|
+
* A deliberate source view (code editors, diff views, artifact and canvas
|
|
35
|
+
* source, a JSON card that already decided): kind JSON is shown as code.
|
|
36
|
+
* Default false — a settled json / jsonc / json5 / unlabelled block whose
|
|
37
|
+
* content is kind JSON is drawn as its kind (`KindDataGate`) and the caller
|
|
38
|
+
* is reported (Arman, 2026-09-30: a kind is never drawn as raw JSON).
|
|
39
|
+
*/
|
|
40
|
+
showSource?: boolean;
|
|
41
|
+
}
|
|
42
|
+
export type { CodeBlockProps };
|
|
43
|
+
declare const CodeBlock: React.FC<CodeBlockProps>;
|
|
44
|
+
export default CodeBlock;
|
|
@@ -0,0 +1,449 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
3
|
+
import { useClipboard } from "@ai-matrx/kit/clipboard";
|
|
4
|
+
import { useRef, useState, useEffect } from "react";
|
|
5
|
+
import { KindDataGate } from "../host/app-bindings.js";
|
|
6
|
+
import {
|
|
7
|
+
isKindJsonText,
|
|
8
|
+
valueCarriesKind
|
|
9
|
+
} from "@ai-matrx/content-ir/surfaces";
|
|
10
|
+
import { extractErrorMessage } from "../utils/lifted/errors.js";
|
|
11
|
+
import { cn } from "@ai-matrx/design-system";
|
|
12
|
+
import SmallCodeEditor from "./SmallCodeEditor.js";
|
|
13
|
+
import CodeBlockHeader from "./CodeBlockHeader.js";
|
|
14
|
+
import { useThemeMode } from "../host/app-bindings.js";
|
|
15
|
+
import StickyButtons from "./StickyButtons.js";
|
|
16
|
+
import { useIsMobile } from "@ai-matrx/kit/media-query";
|
|
17
|
+
import { hostHtmlPageService, useHostUser } from "../host/app-bindings.js";
|
|
18
|
+
import { isCompleteHtmlDocument } from "../utils/lifted/html-document.js";
|
|
19
|
+
import { codeLanguageToExtension } from "../utils/lifted/code-language-extension.js";
|
|
20
|
+
import { Globe, Loader2 } from "lucide-react";
|
|
21
|
+
import { useCanvas } from "../host/app-bindings.js";
|
|
22
|
+
import { toast } from "../host/toast.js";
|
|
23
|
+
import { ShikiCodeView } from "./highlight/ShikiCodeView.js";
|
|
24
|
+
import { parseFenceMeta } from "@ai-matrx/content-ir/source";
|
|
25
|
+
import { agentForPromptKey } from "../utils/lifted/code-editor-agents.js";
|
|
26
|
+
import { useOpenSmartCodeEditorWindow } from "../host/app-bindings.js";
|
|
27
|
+
import {
|
|
28
|
+
normalizeViewLanguage,
|
|
29
|
+
mapLanguageForMonaco,
|
|
30
|
+
getMonacoFileExtension
|
|
31
|
+
} from "../utils/lifted/languages.js";
|
|
32
|
+
const JSON_LANGUAGES = /* @__PURE__ */ new Set(["", "json", "jsonc", "json5"]);
|
|
33
|
+
function settledKindValue(props) {
|
|
34
|
+
if (props.showSource || props.isStreamActive || props.inline) return void 0;
|
|
35
|
+
if (!JSON_LANGUAGES.has((props.language ?? "").trim().toLowerCase())) return void 0;
|
|
36
|
+
if (!isKindJsonText(props.code)) return void 0;
|
|
37
|
+
try {
|
|
38
|
+
const value = JSON.parse(props.code);
|
|
39
|
+
return valueCarriesKind(value) ? value : void 0;
|
|
40
|
+
} catch {
|
|
41
|
+
return void 0;
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
const CodeBlock = (props) => {
|
|
45
|
+
const kindValue = settledKindValue(props);
|
|
46
|
+
const quoted = !JSON_LANGUAGES.has((props.language ?? "").trim().toLowerCase()) || props.showSource === true && !props.isStreamActive;
|
|
47
|
+
return /* @__PURE__ */ jsx(KindDataGate, { component: "CodeBlock", data: kindValue, children: quoted ? /* @__PURE__ */ jsx("div", { "data-kind-source": "explicit", className: "contents", children: /* @__PURE__ */ jsx(CodeBlockBody, { ...props }) }) : /* @__PURE__ */ jsx(CodeBlockBody, { ...props }) });
|
|
48
|
+
};
|
|
49
|
+
const CodeBlockBody = ({
|
|
50
|
+
code: initialCode,
|
|
51
|
+
language: rawLanguage = "text",
|
|
52
|
+
fontSize = 12,
|
|
53
|
+
showLineNumbers = false,
|
|
54
|
+
wrapLines = true,
|
|
55
|
+
className,
|
|
56
|
+
onCodeChange,
|
|
57
|
+
inline = false,
|
|
58
|
+
isStreamActive = false,
|
|
59
|
+
allowEdit = true,
|
|
60
|
+
customBuiltinKeys = [],
|
|
61
|
+
headerLeftSlot,
|
|
62
|
+
extraMenuItems,
|
|
63
|
+
meta
|
|
64
|
+
}) => {
|
|
65
|
+
const { copyText } = useClipboard({
|
|
66
|
+
notify: (message, kind) => kind === "error" ? toast.error(message) : toast.success(message)
|
|
67
|
+
});
|
|
68
|
+
const fence = parseFenceMeta(meta);
|
|
69
|
+
const viewLanguage = normalizeViewLanguage(rawLanguage);
|
|
70
|
+
const monacoLanguage = mapLanguageForMonaco(rawLanguage);
|
|
71
|
+
const monacoFileExtension = getMonacoFileExtension(rawLanguage);
|
|
72
|
+
const [editedCode, setEditedCode] = useState(null);
|
|
73
|
+
const [previousInitialCode, setPreviousInitialCode] = useState(initialCode);
|
|
74
|
+
if (previousInitialCode !== initialCode) {
|
|
75
|
+
setPreviousInitialCode(initialCode);
|
|
76
|
+
setEditedCode(initialCode);
|
|
77
|
+
}
|
|
78
|
+
const [isCopied, setIsCopied] = useState(false);
|
|
79
|
+
const [isFullScreen, setIsFullScreen] = useState(false);
|
|
80
|
+
const [isCollapsed, setIsCollapsed] = useState(false);
|
|
81
|
+
const [isEditing, setIsEditing] = useState(false);
|
|
82
|
+
const requestedLineNumbers = showLineNumbers || fence.showLineNumbers === true;
|
|
83
|
+
const [lineNumbers, setLineNumbers] = useState(requestedLineNumbers);
|
|
84
|
+
const [previousRequestedLineNumbers, setPreviousRequestedLineNumbers] = useState(requestedLineNumbers);
|
|
85
|
+
if (previousRequestedLineNumbers !== requestedLineNumbers) {
|
|
86
|
+
setPreviousRequestedLineNumbers(requestedLineNumbers);
|
|
87
|
+
setLineNumbers(requestedLineNumbers);
|
|
88
|
+
}
|
|
89
|
+
const [showWrapLines, setShowWrapLines] = useState(wrapLines);
|
|
90
|
+
const [minimapEnabled, setMinimapEnabled] = useState(false);
|
|
91
|
+
const [isTopInView, setIsTopInView] = useState(false);
|
|
92
|
+
const [isBottomInView, setIsBottomInView] = useState(false);
|
|
93
|
+
const [isCreatingPage, setIsCreatingPage] = useState(false);
|
|
94
|
+
const [formatTrigger, setFormatTrigger] = useState(0);
|
|
95
|
+
const openSmartCodeEditorWindow = useOpenSmartCodeEditorWindow();
|
|
96
|
+
const bottomRef = useRef(null);
|
|
97
|
+
const topRef = useRef(null);
|
|
98
|
+
const containerRef = useRef(null);
|
|
99
|
+
const editorRef = useRef(null);
|
|
100
|
+
const showStickyButtons = isBottomInView && !isTopInView && !isEditing;
|
|
101
|
+
const mode = useThemeMode();
|
|
102
|
+
const isMobile = useIsMobile();
|
|
103
|
+
const user = useHostUser();
|
|
104
|
+
const { open: openCanvas } = useCanvas();
|
|
105
|
+
const code = editedCode ?? initialCode;
|
|
106
|
+
const isCompleteHTMLDocument = (htmlCode) => viewLanguage === "html" && isCompleteHtmlDocument(htmlCode);
|
|
107
|
+
const handleViewHTML = async () => {
|
|
108
|
+
if (!user?.id) {
|
|
109
|
+
toast.error("You must be logged in to view HTML pages");
|
|
110
|
+
return;
|
|
111
|
+
}
|
|
112
|
+
setIsCreatingPage(true);
|
|
113
|
+
try {
|
|
114
|
+
const result = await hostHtmlPageService().createPage(
|
|
115
|
+
code,
|
|
116
|
+
"HTML Preview",
|
|
117
|
+
"Generated from code block",
|
|
118
|
+
user.id
|
|
119
|
+
);
|
|
120
|
+
openCanvas({
|
|
121
|
+
type: "iframe",
|
|
122
|
+
data: result.url,
|
|
123
|
+
metadata: {
|
|
124
|
+
title: "HTML Preview",
|
|
125
|
+
htmlPageId: result.pageId
|
|
126
|
+
}
|
|
127
|
+
});
|
|
128
|
+
} catch (error) {
|
|
129
|
+
console.error("Failed to create HTML page:", error);
|
|
130
|
+
toast.error(`Failed to create HTML page: ${extractErrorMessage(error)}`);
|
|
131
|
+
} finally {
|
|
132
|
+
setIsCreatingPage(false);
|
|
133
|
+
}
|
|
134
|
+
};
|
|
135
|
+
useEffect(() => {
|
|
136
|
+
const observerOptions = {
|
|
137
|
+
root: null,
|
|
138
|
+
rootMargin: "0px",
|
|
139
|
+
threshold: 0
|
|
140
|
+
};
|
|
141
|
+
const topObserver = new IntersectionObserver(
|
|
142
|
+
([entry]) => setIsTopInView(entry.isIntersecting),
|
|
143
|
+
observerOptions
|
|
144
|
+
);
|
|
145
|
+
const bottomObserver = new IntersectionObserver(
|
|
146
|
+
([entry]) => setIsBottomInView(entry.isIntersecting),
|
|
147
|
+
observerOptions
|
|
148
|
+
);
|
|
149
|
+
if (topRef.current) topObserver.observe(topRef.current);
|
|
150
|
+
if (bottomRef.current) bottomObserver.observe(bottomRef.current);
|
|
151
|
+
return () => {
|
|
152
|
+
if (topRef.current) topObserver.unobserve(topRef.current);
|
|
153
|
+
if (bottomRef.current) bottomObserver.unobserve(bottomRef.current);
|
|
154
|
+
topObserver.disconnect();
|
|
155
|
+
bottomObserver.disconnect();
|
|
156
|
+
};
|
|
157
|
+
}, [isFullScreen]);
|
|
158
|
+
useEffect(() => {
|
|
159
|
+
if (isFullScreen) {
|
|
160
|
+
document.body.style.overflow = "hidden";
|
|
161
|
+
} else {
|
|
162
|
+
document.body.style.overflow = "auto";
|
|
163
|
+
}
|
|
164
|
+
return () => {
|
|
165
|
+
document.body.style.overflow = "auto";
|
|
166
|
+
};
|
|
167
|
+
}, [isFullScreen]);
|
|
168
|
+
const handleCopy = async (e, withLineNumbers = false) => {
|
|
169
|
+
e.stopPropagation();
|
|
170
|
+
let textToCopy = code;
|
|
171
|
+
if (withLineNumbers) {
|
|
172
|
+
const lines = code.split("\n");
|
|
173
|
+
const firstLine = fence.startLine ?? 1;
|
|
174
|
+
const width = String(firstLine + lines.length - 1).length;
|
|
175
|
+
const paddedLines = lines.map((line, index) => {
|
|
176
|
+
const lineNumber = (firstLine + index).toString().padStart(width, " ");
|
|
177
|
+
return `${lineNumber} | ${line}`;
|
|
178
|
+
});
|
|
179
|
+
textToCopy = paddedLines.join("\n");
|
|
180
|
+
}
|
|
181
|
+
await copyText(textToCopy);
|
|
182
|
+
setIsCopied(true);
|
|
183
|
+
setTimeout(() => setIsCopied(false), 2e3);
|
|
184
|
+
};
|
|
185
|
+
const handleDownload = (e) => {
|
|
186
|
+
e.stopPropagation();
|
|
187
|
+
const blob = new Blob([code], { type: "text/plain" });
|
|
188
|
+
const url = window.URL.createObjectURL(blob);
|
|
189
|
+
const a = document.createElement("a");
|
|
190
|
+
a.href = url;
|
|
191
|
+
const titleFile = fence.title && /^[\w./-]+\.\w+$/.test(fence.title) ? fence.title.split("/").pop() : void 0;
|
|
192
|
+
const ext = codeLanguageToExtension(rawLanguage || "txt");
|
|
193
|
+
a.download = titleFile ?? `code${ext}`;
|
|
194
|
+
a.click();
|
|
195
|
+
window.URL.revokeObjectURL(url);
|
|
196
|
+
};
|
|
197
|
+
const toggleLineNumbers = (e) => {
|
|
198
|
+
e.stopPropagation();
|
|
199
|
+
setLineNumbers((prev) => !prev);
|
|
200
|
+
};
|
|
201
|
+
const toggleWrapLines = (e) => {
|
|
202
|
+
e.stopPropagation();
|
|
203
|
+
setShowWrapLines((prev) => !prev);
|
|
204
|
+
};
|
|
205
|
+
const toggleFullScreen = (e) => {
|
|
206
|
+
e.stopPropagation();
|
|
207
|
+
if (isFullScreen) {
|
|
208
|
+
document.body.style.overflow = "auto";
|
|
209
|
+
setTimeout(() => {
|
|
210
|
+
setIsFullScreen(false);
|
|
211
|
+
setIsCollapsed(false);
|
|
212
|
+
}, 150);
|
|
213
|
+
} else {
|
|
214
|
+
document.body.style.overflow = "hidden";
|
|
215
|
+
setIsFullScreen(true);
|
|
216
|
+
if (isCollapsed) setIsCollapsed(false);
|
|
217
|
+
}
|
|
218
|
+
};
|
|
219
|
+
const toggleCollapse = (e) => {
|
|
220
|
+
if (e) e.stopPropagation();
|
|
221
|
+
if (isEditing) return;
|
|
222
|
+
setIsCollapsed((prev) => !prev);
|
|
223
|
+
if (isFullScreen) setIsFullScreen(false);
|
|
224
|
+
};
|
|
225
|
+
const toggleEdit = (e) => {
|
|
226
|
+
e.stopPropagation();
|
|
227
|
+
setIsEditing(!isEditing);
|
|
228
|
+
if (!isEditing) {
|
|
229
|
+
setIsCollapsed(false);
|
|
230
|
+
}
|
|
231
|
+
};
|
|
232
|
+
const handleCodeChange = (newCode) => {
|
|
233
|
+
if (newCode) {
|
|
234
|
+
setEditedCode(newCode);
|
|
235
|
+
onCodeChange?.(newCode);
|
|
236
|
+
}
|
|
237
|
+
};
|
|
238
|
+
const handleFormat = (e) => {
|
|
239
|
+
e.stopPropagation();
|
|
240
|
+
if (!isEditing) return;
|
|
241
|
+
setFormatTrigger((prev) => prev + 1);
|
|
242
|
+
};
|
|
243
|
+
const handleReset = (e) => {
|
|
244
|
+
e.stopPropagation();
|
|
245
|
+
if (!isEditing) return;
|
|
246
|
+
setEditedCode(initialCode);
|
|
247
|
+
onCodeChange?.(initialCode);
|
|
248
|
+
};
|
|
249
|
+
const toggleMinimap = (e) => {
|
|
250
|
+
e.stopPropagation();
|
|
251
|
+
setMinimapEnabled((prev) => !prev);
|
|
252
|
+
};
|
|
253
|
+
const handleOpenAIModal = (config) => {
|
|
254
|
+
const agent = agentForPromptKey(config.mandateKey);
|
|
255
|
+
openSmartCodeEditorWindow({
|
|
256
|
+
agents: [agent],
|
|
257
|
+
defaultPickerMandateKey: agent.mandateKey,
|
|
258
|
+
initialCode: editedCode ?? initialCode ?? "",
|
|
259
|
+
language: monacoLanguage,
|
|
260
|
+
title: config.title,
|
|
261
|
+
onCodeChange: (event) => {
|
|
262
|
+
setEditedCode(event.code);
|
|
263
|
+
onCodeChange?.(event.code);
|
|
264
|
+
}
|
|
265
|
+
});
|
|
266
|
+
};
|
|
267
|
+
return /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
268
|
+
isFullScreen && /* @__PURE__ */ jsx(
|
|
269
|
+
"div",
|
|
270
|
+
{
|
|
271
|
+
className: "fixed inset-0 z-[9998] bg-black/50 backdrop-blur-sm",
|
|
272
|
+
onClick: (e) => {
|
|
273
|
+
e.stopPropagation();
|
|
274
|
+
document.body.style.overflow = "auto";
|
|
275
|
+
setTimeout(() => {
|
|
276
|
+
setIsFullScreen(false);
|
|
277
|
+
setIsCollapsed(false);
|
|
278
|
+
}, 150);
|
|
279
|
+
}
|
|
280
|
+
}
|
|
281
|
+
),
|
|
282
|
+
/* @__PURE__ */ jsxs(
|
|
283
|
+
"div",
|
|
284
|
+
{
|
|
285
|
+
ref: containerRef,
|
|
286
|
+
className: cn(
|
|
287
|
+
"w-full my-4 rounded-t-xl rounded-b-lg border border-neutral-200 dark:border-neutral-700",
|
|
288
|
+
// `overflow-clip` (NOT `overflow-hidden`) so this box still clips to
|
|
289
|
+
// its rounded corners without becoming a scroll container — an
|
|
290
|
+
// overflow-hidden ancestor would trap StickyButtons' `position:
|
|
291
|
+
// sticky` and disable it (D153).
|
|
292
|
+
!isFullScreen && "overflow-clip",
|
|
293
|
+
isFullScreen && "fixed w-[95vw] h-[90dvh] z-[9999] bg-textured flex flex-col shadow-2xl rounded-xl overflow-hidden",
|
|
294
|
+
className
|
|
295
|
+
),
|
|
296
|
+
style: isFullScreen ? {
|
|
297
|
+
top: "50%",
|
|
298
|
+
left: "50%",
|
|
299
|
+
transform: "translate(-50%, -50%)"
|
|
300
|
+
} : void 0,
|
|
301
|
+
children: [
|
|
302
|
+
/* @__PURE__ */ jsx(
|
|
303
|
+
CodeBlockHeader,
|
|
304
|
+
{
|
|
305
|
+
language: rawLanguage,
|
|
306
|
+
title: fence.title,
|
|
307
|
+
linesCount: code.split("\n").length,
|
|
308
|
+
isEditing,
|
|
309
|
+
isFullScreen,
|
|
310
|
+
isCollapsed,
|
|
311
|
+
code,
|
|
312
|
+
handleCopy,
|
|
313
|
+
handleDownload,
|
|
314
|
+
toggleEdit,
|
|
315
|
+
toggleFullScreen,
|
|
316
|
+
toggleCollapse,
|
|
317
|
+
toggleLineNumbers,
|
|
318
|
+
toggleWrapLines,
|
|
319
|
+
isCopied,
|
|
320
|
+
isMobile,
|
|
321
|
+
isCompleteHTML: isCompleteHTMLDocument(code),
|
|
322
|
+
handleViewHTML,
|
|
323
|
+
isCreatingPage,
|
|
324
|
+
showWrapLines,
|
|
325
|
+
handleFormat,
|
|
326
|
+
handleReset,
|
|
327
|
+
minimapEnabled,
|
|
328
|
+
toggleMinimap,
|
|
329
|
+
showLineNumbers: lineNumbers,
|
|
330
|
+
onAIEdit: handleOpenAIModal,
|
|
331
|
+
allowEdit,
|
|
332
|
+
customBuiltinKeys,
|
|
333
|
+
headerLeftSlot,
|
|
334
|
+
extraMenuItems
|
|
335
|
+
}
|
|
336
|
+
),
|
|
337
|
+
showStickyButtons && /* @__PURE__ */ jsx(
|
|
338
|
+
StickyButtons,
|
|
339
|
+
{
|
|
340
|
+
linesCount: code.split("\n").length,
|
|
341
|
+
isCollapsed,
|
|
342
|
+
isCopied,
|
|
343
|
+
handleCopy,
|
|
344
|
+
toggleCollapse
|
|
345
|
+
}
|
|
346
|
+
),
|
|
347
|
+
/* @__PURE__ */ jsx(
|
|
348
|
+
"div",
|
|
349
|
+
{
|
|
350
|
+
className: cn("relative", isFullScreen && "flex-1 overflow-hidden"),
|
|
351
|
+
children: isEditing ? /* @__PURE__ */ jsx("div", { className: "w-full", children: /* @__PURE__ */ jsx(
|
|
352
|
+
SmallCodeEditor,
|
|
353
|
+
{
|
|
354
|
+
language: monacoLanguage,
|
|
355
|
+
fileExtension: monacoFileExtension,
|
|
356
|
+
initialCode: code,
|
|
357
|
+
onChange: handleCodeChange,
|
|
358
|
+
mode,
|
|
359
|
+
height: isFullScreen ? "calc(100dvh - 15rem)" : `${Math.max(400, code.split("\n").length * 20 + 100)}px`,
|
|
360
|
+
showCopyButton: false,
|
|
361
|
+
showFormatButton: false,
|
|
362
|
+
showResetButton: false,
|
|
363
|
+
showWordWrapToggle: false,
|
|
364
|
+
showMinimapToggle: false,
|
|
365
|
+
formatTrigger,
|
|
366
|
+
controlledWordWrap: showWrapLines ? "on" : "off",
|
|
367
|
+
controlledMinimap: minimapEnabled
|
|
368
|
+
}
|
|
369
|
+
) }) : (
|
|
370
|
+
// Code View
|
|
371
|
+
/* @__PURE__ */ jsxs("div", { className: cn("relative", isFullScreen && "h-full"), children: [
|
|
372
|
+
/* @__PURE__ */ jsx("div", { ref: topRef, style: { height: "1px" } }),
|
|
373
|
+
/* @__PURE__ */ jsxs(
|
|
374
|
+
"div",
|
|
375
|
+
{
|
|
376
|
+
ref: bottomRef,
|
|
377
|
+
className: cn(
|
|
378
|
+
"transition-all duration-300 ease-in-out relative",
|
|
379
|
+
isCollapsed ? "max-h-[150px]" : "max-h-none",
|
|
380
|
+
isFullScreen ? "h-full overflow-auto" : "overflow-hidden",
|
|
381
|
+
showWrapLines && "overflow-x-hidden"
|
|
382
|
+
),
|
|
383
|
+
children: [
|
|
384
|
+
/* @__PURE__ */ jsx(
|
|
385
|
+
ShikiCodeView,
|
|
386
|
+
{
|
|
387
|
+
code,
|
|
388
|
+
language: rawLanguage,
|
|
389
|
+
mode: mode === "dark" ? "dark" : "light",
|
|
390
|
+
showLineNumbers: lineNumbers,
|
|
391
|
+
startLine: fence.startLine,
|
|
392
|
+
wrapLines: showWrapLines,
|
|
393
|
+
fontSize,
|
|
394
|
+
highlightLines: fence.highlightLines
|
|
395
|
+
}
|
|
396
|
+
),
|
|
397
|
+
isCompleteHTMLDocument(code) && !isCollapsed && /* @__PURE__ */ jsx(
|
|
398
|
+
"button",
|
|
399
|
+
{
|
|
400
|
+
onClick: handleViewHTML,
|
|
401
|
+
disabled: isCreatingPage,
|
|
402
|
+
className: cn(
|
|
403
|
+
"absolute bottom-4 right-4 z-20",
|
|
404
|
+
"flex items-center gap-2 px-4 py-2 rounded-full",
|
|
405
|
+
"bg-purple-600 hover:bg-purple-700 dark:bg-purple-700 dark:hover:bg-purple-600",
|
|
406
|
+
"text-white text-sm font-medium",
|
|
407
|
+
"shadow-lg hover:shadow-xl",
|
|
408
|
+
"transition-all duration-200 ease-in-out",
|
|
409
|
+
"transform hover:scale-105",
|
|
410
|
+
isCreatingPage && "opacity-50 cursor-not-allowed"
|
|
411
|
+
),
|
|
412
|
+
title: "Open HTML Preview in Canvas",
|
|
413
|
+
children: isCreatingPage ? /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
414
|
+
/* @__PURE__ */ jsx(Loader2, { className: "w-4 h-4 animate-spin" }),
|
|
415
|
+
/* @__PURE__ */ jsx("span", { children: "Creating..." })
|
|
416
|
+
] }) : /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
417
|
+
/* @__PURE__ */ jsx(Globe, { className: "w-4 h-4" }),
|
|
418
|
+
/* @__PURE__ */ jsx("span", { children: "Preview" })
|
|
419
|
+
] })
|
|
420
|
+
}
|
|
421
|
+
)
|
|
422
|
+
]
|
|
423
|
+
}
|
|
424
|
+
),
|
|
425
|
+
isCollapsed && /* @__PURE__ */ jsx(
|
|
426
|
+
"div",
|
|
427
|
+
{
|
|
428
|
+
className: "absolute bottom-0 left-0 right-0 h-24 bg-gradient-to-t from-background to-transparent opacity-80 cursor-pointer",
|
|
429
|
+
onClick: toggleCollapse,
|
|
430
|
+
children: /* @__PURE__ */ jsxs("div", { className: "absolute bottom-2 left-1/2 transform -translate-x-1/2 text-muted-foreground text-sm", children: [
|
|
431
|
+
"Click to expand ",
|
|
432
|
+
code.split("\n").length - 3,
|
|
433
|
+
" more lines"
|
|
434
|
+
] })
|
|
435
|
+
}
|
|
436
|
+
)
|
|
437
|
+
] })
|
|
438
|
+
)
|
|
439
|
+
}
|
|
440
|
+
)
|
|
441
|
+
]
|
|
442
|
+
}
|
|
443
|
+
)
|
|
444
|
+
] });
|
|
445
|
+
};
|
|
446
|
+
var CodeBlock_default = CodeBlock;
|
|
447
|
+
export {
|
|
448
|
+
CodeBlock_default as default
|
|
449
|
+
};
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
import type { MandateKey } from "@ai-matrx/agents/mandates";
|
|
2
|
+
import React from "react";
|
|
3
|
+
import { type MenuItem } from "../host/app-bindings.js";
|
|
4
|
+
type AIModalConfig = {
|
|
5
|
+
/** The editing job (mandate key) — the DB decides which agent runs it. */
|
|
6
|
+
mandateKey: MandateKey;
|
|
7
|
+
title: string;
|
|
8
|
+
};
|
|
9
|
+
/**
|
|
10
|
+
* Items that wrappers (e.g. `JsonBlock`) can append to the unified kebab menu.
|
|
11
|
+
* Use `category` to slot the item into one of the existing buckets — common
|
|
12
|
+
* choices: `"Data"`, `"Download"`, `"Save"`, `"AI"`, `"View"`. Any new category
|
|
13
|
+
* appears as its own section in the menu in the order it was first declared.
|
|
14
|
+
*/
|
|
15
|
+
export type CodeBlockMenuItem = MenuItem;
|
|
16
|
+
interface CodeBlockHeaderProps {
|
|
17
|
+
language: string;
|
|
18
|
+
/** Filename or caption from the fence (`title="app.tsx"`, ```ts:app.tsx). */
|
|
19
|
+
title?: string;
|
|
20
|
+
linesCount: number;
|
|
21
|
+
isEditing: boolean;
|
|
22
|
+
isFullScreen: boolean;
|
|
23
|
+
isCollapsed: boolean;
|
|
24
|
+
code: string;
|
|
25
|
+
handleCopy: (e: React.MouseEvent, withLineNumbers?: boolean) => void;
|
|
26
|
+
handleDownload: (e: React.MouseEvent) => void;
|
|
27
|
+
toggleEdit?: (e: React.MouseEvent) => void;
|
|
28
|
+
toggleFullScreen?: (e: React.MouseEvent) => void;
|
|
29
|
+
toggleCollapse?: (e?: React.MouseEvent) => void;
|
|
30
|
+
toggleLineNumbers?: (e: React.MouseEvent) => void;
|
|
31
|
+
toggleWrapLines?: (e: React.MouseEvent) => void;
|
|
32
|
+
isCopied: boolean;
|
|
33
|
+
isMobile: boolean;
|
|
34
|
+
isCompleteHTML?: boolean;
|
|
35
|
+
handleViewHTML?: () => void;
|
|
36
|
+
isCreatingPage?: boolean;
|
|
37
|
+
showWrapLines?: boolean;
|
|
38
|
+
handleFormat?: (e: React.MouseEvent) => void;
|
|
39
|
+
handleReset?: (e: React.MouseEvent) => void;
|
|
40
|
+
minimapEnabled?: boolean;
|
|
41
|
+
toggleMinimap?: (e: React.MouseEvent) => void;
|
|
42
|
+
showLineNumbers?: boolean;
|
|
43
|
+
onAIEdit?: (config: AIModalConfig) => void;
|
|
44
|
+
hideLanguageDisplay?: boolean;
|
|
45
|
+
allowEdit?: boolean;
|
|
46
|
+
customBuiltinKeys?: string[];
|
|
47
|
+
/** Rendered after the language display. Used by wrappers to inject
|
|
48
|
+
* view-mode toggles (e.g. JsonBlock's Code/Tree/Table/Path switcher). */
|
|
49
|
+
headerLeftSlot?: React.ReactNode;
|
|
50
|
+
/**
|
|
51
|
+
* Extra items appended to the kebab menu. Use `category` to control
|
|
52
|
+
* grouping inside the menu (the four section buckets the header already
|
|
53
|
+
* declares are: View · Edit · Download · Save · AI). New categories
|
|
54
|
+
* (e.g. "Data" from JsonBlock) appear as their own section.
|
|
55
|
+
*/
|
|
56
|
+
extraMenuItems?: CodeBlockMenuItem[];
|
|
57
|
+
}
|
|
58
|
+
export declare const CodeBlockHeader: React.FC<CodeBlockHeaderProps>;
|
|
59
|
+
export declare const EditButton: ({ isEditing, toggleEdit, }: {
|
|
60
|
+
isEditing: boolean;
|
|
61
|
+
toggleEdit?: (e: React.MouseEvent) => void;
|
|
62
|
+
}) => React.JSX.Element | null;
|
|
63
|
+
export default CodeBlockHeader;
|