wendang-react 0.0.0-stage → 0.5.5
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/LICENSE +21 -0
- package/NOTICE.md +381 -0
- package/README.md +469 -2
- package/dist/bindings/yjs.js +5 -0
- package/dist/chunks/AnchoredPanel-D3nte06T.js +68 -0
- package/dist/chunks/MindMapCanvas-VWrxTy5Q.js +2070 -0
- package/dist/chunks/MindMapViewer-DqKu_Kuz.js +180 -0
- package/dist/chunks/SpreadsheetViewer-DN_QQGud.js +157 -0
- package/dist/chunks/code-highlight-BmaqTe1m.js +30 -0
- package/dist/chunks/code-highlight-engine-BFDzDPzy.js +40 -0
- package/dist/chunks/comment-hint-DN7LKJAn.js +296 -0
- package/dist/chunks/composition-state-Bl-U1R_2.js +40 -0
- package/dist/chunks/extensions-B-CVVQhp.js +4210 -0
- package/dist/chunks/fuzzy-match-DYQR-4w2.js +89 -0
- package/dist/chunks/hooks-C53Dp0pr.js +35 -0
- package/dist/chunks/host-C-V688Rq.js +197 -0
- package/dist/chunks/index-Ii536CFG.js +720 -0
- package/dist/chunks/katex-WjrodtTU.js +71 -0
- package/dist/chunks/mind-map-controller-B6SxK3GZ.js +479 -0
- package/dist/chunks/mind-map-delete-CVsxdXfs.js +31 -0
- package/dist/chunks/mind-map-input-CEWRz_t6.js +43 -0
- package/dist/chunks/mind-topic-text-BBNTbFSe.js +446 -0
- package/dist/chunks/nodes-iKqTGr_N.js +291 -0
- package/dist/chunks/popover-placement-D3xVYdkt.js +47 -0
- package/dist/chunks/worksheet-engine-TJ54m0KC.js +125 -0
- package/dist/chunks/worksheet-preview-DsDVWxIM.js +129 -0
- package/dist/document/viewer.js +287 -0
- package/dist/document.js +3620 -0
- package/dist/index.js +8 -0
- package/dist/mindmap/viewer.js +6 -0
- package/dist/mindmap.js +123 -0
- package/dist/shared.js +52 -0
- package/dist/spreadsheet/viewer.js +5 -0
- package/dist/spreadsheet/xlsx.js +299 -0
- package/dist/spreadsheet.js +120 -0
- package/dist/styles/callout.css +34 -0
- package/dist/styles/code-block.css +58 -0
- package/dist/styles/content-style.css +619 -0
- package/dist/styles/editor-interaction.css +621 -0
- package/dist/styles/file-video.css +12 -0
- package/dist/styles/image-preview.css +103 -0
- package/dist/styles/mind-map-block.css +14 -0
- package/dist/styles/mind-map-canvas.css +80 -0
- package/dist/styles/mind-map-comments.css +93 -0
- package/dist/styles/mind-map-details.css +7 -0
- package/dist/styles/mind-map-preview.css +7 -0
- package/dist/styles/mind-map-topic.css +112 -0
- package/dist/styles/page-picker.css +47 -0
- package/dist/styles/renderer.css +45 -0
- package/dist/styles/spreadsheet-editor.css +3 -0
- package/dist/styles/tokens.css +153 -0
- package/dist/styles/video-dialog.css +41 -0
- package/dist/styles/video-embed.css +35 -0
- package/dist/styles.css +2614 -0
- package/dist/types/bindings/yjs.d.ts +3 -0
- package/dist/types/document/viewer.d.ts +3 -0
- package/dist/types/document.d.ts +7 -0
- package/dist/types/editor/BlockAffordance.d.ts +47 -0
- package/dist/types/editor/CalloutView.d.ts +2 -0
- package/dist/types/editor/CodeBlockView.d.ts +9 -0
- package/dist/types/editor/DocumentColorPanel.d.ts +8 -0
- package/dist/types/editor/DocumentEditor.d.ts +71 -0
- package/dist/types/editor/ImagePreview.d.ts +10 -0
- package/dist/types/editor/LinkPopover.d.ts +21 -0
- package/dist/types/editor/PagePicker.d.ts +7 -0
- package/dist/types/editor/SelectionToolbar.d.ts +11 -0
- package/dist/types/editor/SlashMenu.d.ts +30 -0
- package/dist/types/editor/TableControls.d.ts +9 -0
- package/dist/types/editor/VideoEmbedDialog.d.ts +6 -0
- package/dist/types/editor/document-gestures.d.ts +13 -0
- package/dist/types/editor/extensions.d.ts +29 -0
- package/dist/types/editor/nodes.d.ts +20 -0
- package/dist/types/editor/same-document.d.ts +2 -0
- package/dist/types/engine/collab/presence.d.ts +1 -0
- package/dist/types/engine/editor/block-commands.d.ts +35 -0
- package/dist/types/engine/editor/block-conversion.d.ts +12 -0
- package/dist/types/engine/editor/block-drag.d.ts +16 -0
- package/dist/types/engine/editor/block-menu-placement.d.ts +16 -0
- package/dist/types/engine/editor/callout-commands.d.ts +4 -0
- package/dist/types/engine/editor/collab-change-origin.d.ts +2 -0
- package/dist/types/engine/editor/delete-block.d.ts +2 -0
- package/dist/types/engine/editor/extensions/block-format.d.ts +19 -0
- package/dist/types/engine/editor/extensions/block-handle.d.ts +17 -0
- package/dist/types/engine/editor/extensions/block-menu-highlight.d.ts +4 -0
- package/dist/types/engine/editor/extensions/block-selection.d.ts +117 -0
- package/dist/types/engine/editor/extensions/code-highlight.d.ts +2 -0
- package/dist/types/engine/editor/extensions/collab-cursor.d.ts +13 -0
- package/dist/types/engine/editor/extensions/ime-guard.d.ts +8 -0
- package/dist/types/engine/editor/extensions/inline-comments.d.ts +15 -0
- package/dist/types/engine/editor/extensions/paste-sanitizer.d.ts +4 -0
- package/dist/types/engine/editor/extensions/slash.d.ts +16 -0
- package/dist/types/engine/editor/extensions/table-interaction.d.ts +9 -0
- package/dist/types/engine/editor/extensions/upload-placeholder.d.ts +48 -0
- package/dist/types/engine/editor/image-preview-gesture.d.ts +3 -0
- package/dist/types/engine/editor/ime/composition-state.d.ts +9 -0
- package/dist/types/engine/editor/insert-block.d.ts +6 -0
- package/dist/types/engine/editor/insert-picker-logic.d.ts +13 -0
- package/dist/types/engine/editor/link-edit.d.ts +10 -0
- package/dist/types/engine/editor/mind-map-controller.d.ts +63 -0
- package/dist/types/engine/editor/mind-map-delete.d.ts +7 -0
- package/dist/types/engine/editor/mind-map-drag.d.ts +16 -0
- package/dist/types/engine/editor/mind-map-input.d.ts +16 -0
- package/dist/types/engine/editor/mind-map-selection.d.ts +11 -0
- package/dist/types/engine/editor/nodes/columns.d.ts +6 -0
- package/dist/types/engine/editor/nodes/file-nodeview.d.ts +4 -0
- package/dist/types/engine/editor/nodes/file.d.ts +2 -0
- package/dist/types/engine/editor/nodes/image-gallery.d.ts +2 -0
- package/dist/types/engine/editor/nodes/image-nodeview.d.ts +4 -0
- package/dist/types/engine/editor/nodes/image.d.ts +1 -0
- package/dist/types/engine/editor/nodes/inline-style.d.ts +4 -0
- package/dist/types/engine/editor/nodes/math-nodeview.d.ts +2 -0
- package/dist/types/engine/editor/nodes/math.d.ts +3 -0
- package/dist/types/engine/editor/nodes/mention.d.ts +2 -0
- package/dist/types/engine/editor/nodes/mind-map-schema.d.ts +6 -0
- package/dist/types/engine/editor/nodes/page-link.d.ts +2 -0
- package/dist/types/engine/editor/nodes/table-cell.d.ts +4 -0
- package/dist/types/engine/editor/nodes/video-embed-schema.d.ts +2 -0
- package/dist/types/engine/editor/popover-placement.d.ts +35 -0
- package/dist/types/engine/editor/table-clipboard.d.ts +3 -0
- package/dist/types/engine/editor/table-commands.d.ts +20 -0
- package/dist/types/engine/editor/table-geometry.d.ts +34 -0
- package/dist/types/engine/editor/table-menu-placement.d.ts +30 -0
- package/dist/types/engine/editor/tracked-target.d.ts +8 -0
- package/dist/types/engine/editor/trailing-paragraph.d.ts +2 -0
- package/dist/types/engine/host.d.ts +2 -0
- package/dist/types/engine/renderer/attachments.d.ts +11 -0
- package/dist/types/engine/renderer/katex.d.ts +7 -0
- package/dist/types/engine/renderer/lazy-visible.d.ts +11 -0
- package/dist/types/engine/shared/callout.d.ts +1 -0
- package/dist/types/engine/shared/code-block.d.ts +1 -0
- package/dist/types/engine/shared/code-highlight-engine.d.ts +2 -0
- package/dist/types/engine/shared/code-highlight.d.ts +8 -0
- package/dist/types/engine/shared/comment-hint-position.d.ts +20 -0
- package/dist/types/engine/shared/comment-hint.d.ts +2 -0
- package/dist/types/engine/shared/document-colors.d.ts +1 -0
- package/dist/types/engine/shared/fuzzy-match.d.ts +13 -0
- package/dist/types/engine/shared/image-gallery.d.ts +1 -0
- package/dist/types/engine/shared/inline-comments.d.ts +1 -0
- package/dist/types/engine/shared/mind-map-phase2.d.ts +1 -0
- package/dist/types/engine/shared/mind-map.d.ts +1 -0
- package/dist/types/engine/shared/mind-topic-text.d.ts +1 -0
- package/dist/types/engine/shared/modal-stack.d.ts +6 -0
- package/dist/types/engine/shared/page-candidates.d.ts +6 -0
- package/dist/types/engine/shared/pinyin.d.ts +6 -0
- package/dist/types/engine/shared/preview-items.d.ts +10 -0
- package/dist/types/engine/shared/safe-href.d.ts +1 -0
- package/dist/types/engine/shared/table-cell-format.d.ts +1 -0
- package/dist/types/engine/shared/table-layout.d.ts +1 -0
- package/dist/types/engine/shared/video-embed.d.ts +1 -0
- package/dist/types/engine/shared/video-feedback.d.ts +1 -0
- package/dist/types/engine/shared/workbook.d.ts +1 -0
- package/dist/types/engine/worksheets/worksheet-engine.d.ts +16 -0
- package/dist/types/engine/worksheets/worksheet-format.d.ts +20 -0
- package/dist/types/engine/worksheets/worksheet-preview.d.ts +17 -0
- package/dist/types/engine/worksheets/worksheet-xlsx.d.ts +21 -0
- package/dist/types/engine/wui/core/dialog.d.ts +5 -0
- package/dist/types/engine/wui/core/listbox.d.ts +8 -0
- package/dist/types/engine/wui/core/placement.d.ts +40 -0
- package/dist/types/hooks.d.ts +7 -0
- package/dist/types/host-types.d.ts +58 -0
- package/dist/types/host.d.ts +24 -0
- package/dist/types/index.d.ts +5 -0
- package/dist/types/mindmap/Comments.d.ts +9 -0
- package/dist/types/mindmap/Details.d.ts +13 -0
- package/dist/types/mindmap/Field.d.ts +10 -0
- package/dist/types/mindmap/MindMapCanvas.d.ts +19 -0
- package/dist/types/mindmap/MindMapEditor.d.ts +30 -0
- package/dist/types/mindmap/MindMapViewer.d.ts +23 -0
- package/dist/types/mindmap/TopicLabel.d.ts +4 -0
- package/dist/types/mindmap/viewer.d.ts +2 -0
- package/dist/types/mindmap.d.ts +4 -0
- package/dist/types/renderer/CodeToolbar.d.ts +10 -0
- package/dist/types/renderer/DocumentViewer.d.ts +23 -0
- package/dist/types/renderer/media.d.ts +33 -0
- package/dist/types/shared.d.ts +12 -0
- package/dist/types/spreadsheet/SpreadsheetEditor.d.ts +23 -0
- package/dist/types/spreadsheet/SpreadsheetViewer.d.ts +13 -0
- package/dist/types/spreadsheet/viewer.d.ts +2 -0
- package/dist/types/spreadsheet/xlsx.d.ts +2 -0
- package/dist/types/spreadsheet.d.ts +3 -0
- package/dist/types/wui/AnchoredPanel.d.ts +14 -0
- package/dist/types/wui/Dropdown.d.ts +18 -0
- package/dist/types/wui/Icon.d.ts +7 -0
- package/dist/types/wui/Tooltip.d.ts +5 -0
- package/dist/types/wui/index.d.ts +69 -0
- package/package.json +122 -3
- package/third-party-notices/@fast-csv__format@4.3.5-LICENSE.txt +21 -0
- package/third-party-notices/@fast-csv__parse@4.3.6-LICENSE.txt +21 -0
- package/third-party-notices/@flatten-js__interval-tree@1.1.3-LICENSE.txt +21 -0
- package/third-party-notices/@floating-ui__core@1.8.0-LICENSE.txt +20 -0
- package/third-party-notices/@floating-ui__dom@1.8.0-LICENSE.txt +20 -0
- package/third-party-notices/@floating-ui__react-dom@2.1.9-LICENSE.txt +20 -0
- package/third-party-notices/@floating-ui__utils@0.2.12-LICENSE.txt +20 -0
- package/third-party-notices/@grpc__grpc-js@1.14.6-LICENSE.txt +201 -0
- package/third-party-notices/@grpc__proto-loader@0.8.1-LICENSE.txt +201 -0
- package/third-party-notices/@js-sdsl__ordered-map@4.4.2-LICENSE.txt +21 -0
- package/third-party-notices/@protobufjs__aspromise@1.1.2-LICENSE.txt +26 -0
- package/third-party-notices/@protobufjs__base64@1.1.2-LICENSE.txt +26 -0
- package/third-party-notices/@protobufjs__codegen@2.0.5-LICENSE.txt +26 -0
- package/third-party-notices/@protobufjs__eventemitter@1.1.1-LICENSE.txt +26 -0
- package/third-party-notices/@protobufjs__fetch@1.1.1-LICENSE.txt +26 -0
- package/third-party-notices/@protobufjs__float@1.0.2-LICENSE.txt +26 -0
- package/third-party-notices/@protobufjs__path@1.1.2-LICENSE.txt +26 -0
- package/third-party-notices/@protobufjs__pool@1.1.0-LICENSE.txt +26 -0
- package/third-party-notices/@protobufjs__utf8@1.1.2-LICENSE.txt +26 -0
- package/third-party-notices/@radix-ui__primitive@1.2.0-LICENSE.txt +21 -0
- package/third-party-notices/@radix-ui__react-arrow@1.1.17-LICENSE.txt +21 -0
- package/third-party-notices/@radix-ui__react-collection@1.2.0-LICENSE.txt +21 -0
- package/third-party-notices/@radix-ui__react-compose-refs@1.1.5-LICENSE.txt +21 -0
- package/third-party-notices/@radix-ui__react-context@1.3.0-LICENSE.txt +21 -0
- package/third-party-notices/@radix-ui__react-dialog@1.3.1-LICENSE.txt +21 -0
- package/third-party-notices/@radix-ui__react-direction@1.2.0-LICENSE.txt +21 -0
- package/third-party-notices/@radix-ui__react-dismissable-layer@1.2.1-LICENSE.txt +21 -0
- package/third-party-notices/@radix-ui__react-dropdown-menu@2.2.1-LICENSE.txt +21 -0
- package/third-party-notices/@radix-ui__react-focus-guards@1.2.0-LICENSE.txt +21 -0
- package/third-party-notices/@radix-ui__react-focus-scope@1.3.1-LICENSE.txt +21 -0
- package/third-party-notices/@radix-ui__react-hover-card@1.2.1-LICENSE.txt +21 -0
- package/third-party-notices/@radix-ui__react-id@1.1.4-LICENSE.txt +21 -0
- package/third-party-notices/@radix-ui__react-menu@2.2.1-LICENSE.txt +21 -0
- package/third-party-notices/@radix-ui__react-popover@1.3.1-LICENSE.txt +21 -0
- package/third-party-notices/@radix-ui__react-popper@1.4.0-LICENSE.txt +21 -0
- package/third-party-notices/@radix-ui__react-portal@1.2.0-LICENSE.txt +21 -0
- package/third-party-notices/@radix-ui__react-presence@1.1.11-LICENSE.txt +21 -0
- package/third-party-notices/@radix-ui__react-primitive@2.2.0-LICENSE.txt +21 -0
- package/third-party-notices/@radix-ui__react-roving-focus@1.2.1-LICENSE.txt +21 -0
- package/third-party-notices/@radix-ui__react-separator@1.2.0-LICENSE.txt +21 -0
- package/third-party-notices/@radix-ui__react-slot@1.5.0-LICENSE.txt +21 -0
- package/third-party-notices/@radix-ui__react-use-callback-ref@1.1.5-LICENSE.txt +21 -0
- package/third-party-notices/@radix-ui__react-use-controllable-state@1.3.0-LICENSE.txt +21 -0
- package/third-party-notices/@radix-ui__react-use-effect-event@0.0.5-LICENSE.txt +21 -0
- package/third-party-notices/@radix-ui__react-use-is-hydrated@0.1.3-LICENSE.txt +21 -0
- package/third-party-notices/@radix-ui__react-use-layout-effect@1.1.4-LICENSE.txt +21 -0
- package/third-party-notices/@radix-ui__react-use-rect@1.1.4-LICENSE.txt +21 -0
- package/third-party-notices/@radix-ui__react-use-size@1.1.5-LICENSE.txt +21 -0
- package/third-party-notices/@radix-ui__rect@1.1.3-LICENSE.txt +21 -0
- package/third-party-notices/@tiptap__core@3.31.4-LICENSE.md.txt +21 -0
- package/third-party-notices/@tiptap__extension-blockquote@3.31.4-LICENSE.md.txt +21 -0
- package/third-party-notices/@tiptap__extension-bold@3.31.4-LICENSE.md.txt +21 -0
- package/third-party-notices/@tiptap__extension-bullet-list@3.31.4-LICENSE.md.txt +21 -0
- package/third-party-notices/@tiptap__extension-code-block@3.31.4-LICENSE.md.txt +21 -0
- package/third-party-notices/@tiptap__extension-code@3.31.4-LICENSE.md.txt +21 -0
- package/third-party-notices/@tiptap__extension-collaboration@3.31.4-LICENSE.md.txt +21 -0
- package/third-party-notices/@tiptap__extension-document@3.31.4-LICENSE.md.txt +21 -0
- package/third-party-notices/@tiptap__extension-dropcursor@3.31.4-LICENSE.md.txt +21 -0
- package/third-party-notices/@tiptap__extension-gapcursor@3.31.4-LICENSE.md.txt +21 -0
- package/third-party-notices/@tiptap__extension-hard-break@3.31.4-LICENSE.md.txt +21 -0
- package/third-party-notices/@tiptap__extension-heading@3.31.4-LICENSE.md.txt +21 -0
- package/third-party-notices/@tiptap__extension-horizontal-rule@3.31.4-LICENSE.md.txt +21 -0
- package/third-party-notices/@tiptap__extension-image@3.31.4-LICENSE.md.txt +21 -0
- package/third-party-notices/@tiptap__extension-italic@3.31.4-LICENSE.md.txt +21 -0
- package/third-party-notices/@tiptap__extension-link@3.31.4-LICENSE.md.txt +21 -0
- package/third-party-notices/@tiptap__extension-list-item@3.31.4-LICENSE.md.txt +21 -0
- package/third-party-notices/@tiptap__extension-list-keymap@3.31.4-LICENSE.md.txt +21 -0
- package/third-party-notices/@tiptap__extension-list@3.31.4-LICENSE.md.txt +21 -0
- package/third-party-notices/@tiptap__extension-ordered-list@3.31.4-LICENSE.md.txt +21 -0
- package/third-party-notices/@tiptap__extension-paragraph@3.31.4-LICENSE.md.txt +21 -0
- package/third-party-notices/@tiptap__extension-placeholder@3.31.4-LICENSE.md.txt +21 -0
- package/third-party-notices/@tiptap__extension-strike@3.31.4-LICENSE.md.txt +21 -0
- package/third-party-notices/@tiptap__extension-table-cell@3.31.4-LICENSE.md.txt +21 -0
- package/third-party-notices/@tiptap__extension-table-header@3.31.4-LICENSE.md.txt +21 -0
- package/third-party-notices/@tiptap__extension-table-row@3.31.4-LICENSE.md.txt +21 -0
- package/third-party-notices/@tiptap__extension-table@3.31.4-LICENSE.md.txt +21 -0
- package/third-party-notices/@tiptap__extension-task-item@3.31.4-LICENSE.md.txt +21 -0
- package/third-party-notices/@tiptap__extension-task-list@3.31.4-LICENSE.md.txt +21 -0
- package/third-party-notices/@tiptap__extension-text@3.31.4-LICENSE.md.txt +21 -0
- package/third-party-notices/@tiptap__extension-underline@3.31.4-LICENSE.md.txt +21 -0
- package/third-party-notices/@tiptap__extensions@3.31.4-LICENSE.md.txt +21 -0
- package/third-party-notices/@tiptap__pm@3.31.4-LICENSE.txt +21 -0
- package/third-party-notices/@tiptap__starter-kit@3.31.4-LICENSE.md.txt +21 -0
- package/third-party-notices/@tiptap__y-tiptap@3.0.7-LICENSE.txt +22 -0
- package/third-party-notices/@types__hast@3.0.5-LICENSE.txt +21 -0
- package/third-party-notices/@types__node@14.18.63-LICENSE.txt +21 -0
- package/third-party-notices/@types__node@26.6.2-LICENSE.txt +21 -0
- package/third-party-notices/@types__react-dom@19.3.0-LICENSE.txt +21 -0
- package/third-party-notices/@types__react@19.3.0-LICENSE.txt +21 -0
- package/third-party-notices/@types__unist@3.0.3-LICENSE.txt +21 -0
- package/third-party-notices/@univerjs__core@1.1.0-LICENSE.txt +176 -0
- package/third-party-notices/@univerjs__design@1.1.0-LICENSE.txt +176 -0
- package/third-party-notices/@univerjs__docs-ui@1.1.0-LICENSE.txt +176 -0
- package/third-party-notices/@univerjs__docs@1.1.0-LICENSE.txt +176 -0
- package/third-party-notices/@univerjs__drawing@1.1.0-LICENSE.txt +176 -0
- package/third-party-notices/@univerjs__engine-formula@1.1.0-LICENSE.txt +176 -0
- package/third-party-notices/@univerjs__engine-render@1.1.0-LICENSE.txt +176 -0
- package/third-party-notices/@univerjs__icons@1.46.0-LICENSE.txt +21 -0
- package/third-party-notices/@univerjs__network@1.1.0-LICENSE.txt +176 -0
- package/third-party-notices/@univerjs__preset-sheets-core@1.1.0-LICENSE.txt +176 -0
- package/third-party-notices/@univerjs__preset-sheets-filter@1.1.0-LICENSE.txt +176 -0
- package/third-party-notices/@univerjs__preset-sheets-sort@1.1.0-LICENSE.txt +176 -0
- package/third-party-notices/@univerjs__presets@1.1.0-LICENSE.txt +176 -0
- package/third-party-notices/@univerjs__rpc@1.1.0-LICENSE.txt +176 -0
- package/third-party-notices/@univerjs__sheets-filter-ui@1.1.0-LICENSE.txt +176 -0
- package/third-party-notices/@univerjs__sheets-filter@1.1.0-LICENSE.txt +176 -0
- package/third-party-notices/@univerjs__sheets-formula-ui@1.1.0-LICENSE.txt +176 -0
- package/third-party-notices/@univerjs__sheets-formula@1.1.0-LICENSE.txt +176 -0
- package/third-party-notices/@univerjs__sheets-numfmt-ui@1.1.0-LICENSE.txt +176 -0
- package/third-party-notices/@univerjs__sheets-numfmt@1.1.0-LICENSE.txt +176 -0
- package/third-party-notices/@univerjs__sheets-sort-ui@1.1.0-LICENSE.txt +176 -0
- package/third-party-notices/@univerjs__sheets-sort@1.1.0-LICENSE.txt +176 -0
- package/third-party-notices/@univerjs__sheets-ui@1.1.0-LICENSE.txt +176 -0
- package/third-party-notices/@univerjs__sheets@1.1.0-LICENSE.txt +176 -0
- package/third-party-notices/@univerjs__telemetry@1.1.0-LICENSE.txt +176 -0
- package/third-party-notices/@univerjs__themes@1.1.0-LICENSE.txt +176 -0
- package/third-party-notices/@univerjs__ui@1.1.0-LICENSE.txt +176 -0
- package/third-party-notices/@wendellhu__redi@1.1.3-LICENSE.txt +7 -0
- package/third-party-notices/ansi-regex@5.0.1-license.txt +9 -0
- package/third-party-notices/ansi-styles@4.3.0-license.txt +9 -0
- package/third-party-notices/archiver-utils@2.1.0-LICENSE.txt +22 -0
- package/third-party-notices/archiver-utils@3.0.4-LICENSE.txt +22 -0
- package/third-party-notices/archiver@5.3.2-LICENSE.txt +22 -0
- package/third-party-notices/aria-hidden@1.2.6-LICENSE.txt +21 -0
- package/third-party-notices/array-buffer-byte-length@1.0.2-LICENSE.txt +21 -0
- package/third-party-notices/arraybuffer.prototype.slice@1.0.4-LICENSE.txt +21 -0
- package/third-party-notices/async-function@1.0.0-LICENSE.txt +21 -0
- package/third-party-notices/async-lock@1.4.1-LICENSE.txt +22 -0
- package/third-party-notices/async@3.2.6-LICENSE.txt +19 -0
- package/third-party-notices/available-typed-arrays@1.0.7-LICENSE.txt +21 -0
- package/third-party-notices/balanced-match@1.0.2-LICENSE.md.txt +21 -0
- package/third-party-notices/base64-js@1.5.1-LICENSE.txt +21 -0
- package/third-party-notices/big-integer@1.6.52-LICENSE.txt +24 -0
- package/third-party-notices/bl@4.1.0-LICENSE.md.txt +13 -0
- package/third-party-notices/bluebird@3.4.7-LICENSE.txt +21 -0
- package/third-party-notices/brace-expansion@1.1.21-LICENSE.txt +21 -0
- package/third-party-notices/brace-expansion@2.1.7-LICENSE.txt +21 -0
- package/third-party-notices/buffer-crc32@0.2.13-LICENSE.txt +19 -0
- package/third-party-notices/buffer-indexof-polyfill@1.0.2-LICENSE.txt +22 -0
- package/third-party-notices/buffer@5.7.1-LICENSE.txt +21 -0
- package/third-party-notices/call-bind-apply-helpers@1.0.2-LICENSE.txt +21 -0
- package/third-party-notices/call-bind@1.0.9-LICENSE.txt +21 -0
- package/third-party-notices/call-bound@1.0.4-LICENSE.txt +21 -0
- package/third-party-notices/class-variance-authority@0.7.1-LICENSE.txt +190 -0
- package/third-party-notices/cliui@8.0.1-LICENSE.txt.txt +14 -0
- package/third-party-notices/clsx@2.1.1-license.txt +9 -0
- package/third-party-notices/cmdk@1.1.1-LICENSE.md.txt +21 -0
- package/third-party-notices/collapse-white-space@2.1.0-license.txt +22 -0
- package/third-party-notices/color-convert@2.0.1-LICENSE.txt +21 -0
- package/third-party-notices/color-name@1.1.4-LICENSE.txt +8 -0
- package/third-party-notices/commander@15.0.0-LICENSE.txt +22 -0
- package/third-party-notices/compress-commons@4.1.2-LICENSE.txt +22 -0
- package/third-party-notices/concat-map@0.0.1-LICENSE.txt +18 -0
- package/third-party-notices/core-util-is@1.0.3-LICENSE.txt +19 -0
- package/third-party-notices/crc-32@1.2.2-LICENSE.txt +201 -0
- package/third-party-notices/crc32-stream@4.0.3-LICENSE.txt +22 -0
- package/third-party-notices/csstype@3.2.3-LICENSE.txt +19 -0
- package/third-party-notices/data-view-buffer@1.0.2-LICENSE.txt +21 -0
- package/third-party-notices/data-view-byte-length@1.0.2-LICENSE.txt +21 -0
- package/third-party-notices/data-view-byte-offset@1.0.1-LICENSE.txt +21 -0
- package/third-party-notices/dayjs@1.11.23-LICENSE.txt +21 -0
- package/third-party-notices/decimal.js@10.6.0-LICENCE.md.txt +23 -0
- package/third-party-notices/define-data-property@1.1.4-LICENSE.txt +21 -0
- package/third-party-notices/define-properties@1.2.1-LICENSE.txt +21 -0
- package/third-party-notices/dequal@2.0.3-license.txt +21 -0
- package/third-party-notices/detect-node-es@1.1.0-LICENSE.txt +21 -0
- package/third-party-notices/devlop@1.1.0-license.txt +22 -0
- package/third-party-notices/dunder-proto@1.0.1-LICENSE.txt +21 -0
- package/third-party-notices/duplexer2@0.1.4-LICENSE.md.txt +26 -0
- package/third-party-notices/end-of-stream@1.4.5-LICENSE.txt +21 -0
- package/third-party-notices/es-abstract-get@1.0.0-LICENSE.txt +21 -0
- package/third-party-notices/es-abstract@1.24.2-LICENSE.txt +21 -0
- package/third-party-notices/es-define-property@1.0.1-LICENSE.txt +21 -0
- package/third-party-notices/es-errors@1.3.0-LICENSE.txt +21 -0
- package/third-party-notices/es-object-atoms@1.1.2-LICENSE.txt +21 -0
- package/third-party-notices/es-set-tostringtag@2.1.0-LICENSE.txt +21 -0
- package/third-party-notices/es-to-primitive@1.3.4-LICENSE.txt +22 -0
- package/third-party-notices/escalade@3.2.0-license.txt +9 -0
- package/third-party-notices/exceljs@4.4.0-LICENSE.txt +22 -0
- package/third-party-notices/fast-csv@4.3.6-LICENSE.txt +21 -0
- package/third-party-notices/fast-diff@1.3.0-LICENSE.txt +201 -0
- package/third-party-notices/for-each@0.3.5-LICENSE.txt +22 -0
- package/third-party-notices/fs-constants@1.0.0-LICENSE.txt +21 -0
- package/third-party-notices/fs.realpath@1.0.0-LICENSE.txt +43 -0
- package/third-party-notices/fstream@1.0.12-LICENSE.txt +15 -0
- package/third-party-notices/function-bind@1.1.2-LICENSE.txt +20 -0
- package/third-party-notices/function.prototype.name@1.2.0-LICENSE.txt +21 -0
- package/third-party-notices/functions-have-names@1.2.3-LICENSE.txt +21 -0
- package/third-party-notices/generator-function@2.0.1-LICENSE.md.txt +7 -0
- package/third-party-notices/get-caller-file@2.0.5-LICENSE.md.txt +6 -0
- package/third-party-notices/get-intrinsic@1.3.0-LICENSE.txt +21 -0
- package/third-party-notices/get-nonce@1.0.1-LICENSE.txt +21 -0
- package/third-party-notices/get-proto@1.0.1-LICENSE.txt +21 -0
- package/third-party-notices/get-symbol-description@1.1.0-LICENSE.txt +21 -0
- package/third-party-notices/glob@7.2.3-LICENSE.txt +21 -0
- package/third-party-notices/globalthis@1.0.4-LICENSE.txt +21 -0
- package/third-party-notices/gopd@1.2.0-LICENSE.txt +21 -0
- package/third-party-notices/graceful-fs@4.2.11-LICENSE.txt +15 -0
- package/third-party-notices/has-bigints@1.1.0-LICENSE.txt +21 -0
- package/third-party-notices/has-property-descriptors@1.0.2-LICENSE.txt +21 -0
- package/third-party-notices/has-proto@1.2.0-LICENSE.txt +21 -0
- package/third-party-notices/has-symbols@1.1.0-LICENSE.txt +21 -0
- package/third-party-notices/has-tostringtag@1.0.2-LICENSE.txt +21 -0
- package/third-party-notices/hasown@2.0.4-LICENSE.txt +21 -0
- package/third-party-notices/highlight.js@11.11.2-LICENSE.txt +29 -0
- package/third-party-notices/ieee754@1.2.1-LICENSE.txt +11 -0
- package/third-party-notices/immediate@3.0.6-LICENSE.txt.txt +20 -0
- package/third-party-notices/inflight@1.0.6-LICENSE.txt +15 -0
- package/third-party-notices/inherits@2.0.4-LICENSE.txt +16 -0
- package/third-party-notices/internal-slot@1.1.0-LICENSE.txt +21 -0
- package/third-party-notices/is-array-buffer@3.0.5-LICENSE.txt +21 -0
- package/third-party-notices/is-async-function@2.1.1-LICENSE.txt +20 -0
- package/third-party-notices/is-bigint@1.1.0-LICENSE.txt +21 -0
- package/third-party-notices/is-boolean-object@1.2.2-LICENSE.txt +22 -0
- package/third-party-notices/is-callable@1.2.7-LICENSE.txt +22 -0
- package/third-party-notices/is-data-view@1.0.2-LICENSE.txt +21 -0
- package/third-party-notices/is-date-object@1.1.0-LICENSE.txt +22 -0
- package/third-party-notices/is-document.all@1.0.0-LICENSE.txt +21 -0
- package/third-party-notices/is-finalizationregistry@1.1.1-LICENSE.txt +21 -0
- package/third-party-notices/is-fullwidth-code-point@3.0.0-license.txt +9 -0
- package/third-party-notices/is-generator-function@1.1.2-LICENSE.txt +20 -0
- package/third-party-notices/is-map@2.0.3-LICENSE.txt +21 -0
- package/third-party-notices/is-negative-zero@2.0.3-LICENSE.txt +20 -0
- package/third-party-notices/is-number-object@1.1.1-LICENSE.txt +22 -0
- package/third-party-notices/is-regex@1.2.1-LICENSE.txt +20 -0
- package/third-party-notices/is-set@2.0.3-LICENSE.txt +21 -0
- package/third-party-notices/is-shared-array-buffer@1.0.4-LICENSE.txt +21 -0
- package/third-party-notices/is-string@1.1.1-LICENSE.txt +22 -0
- package/third-party-notices/is-symbol@1.1.1-LICENSE.txt +22 -0
- package/third-party-notices/is-typed-array@1.1.15-LICENSE.txt +22 -0
- package/third-party-notices/is-weakmap@2.0.2-LICENSE.txt +21 -0
- package/third-party-notices/is-weakref@1.1.1-LICENSE.txt +21 -0
- package/third-party-notices/is-weakset@2.0.4-LICENSE.txt +21 -0
- package/third-party-notices/isarray@2.0.5-LICENSE.txt +21 -0
- package/third-party-notices/isomorphic.js@0.2.5-LICENSE.txt +21 -0
- package/third-party-notices/jszip@3.10.2-LICENSE.markdown.txt +651 -0
- package/third-party-notices/katex@0.18.9-LICENSE.txt +21 -0
- package/third-party-notices/kdbush@4.1.0-LICENSE.txt +15 -0
- package/third-party-notices/lazystream@1.0.1-LICENSE.txt +23 -0
- package/third-party-notices/lib0@0.2.119-LICENSE.txt +21 -0
- package/third-party-notices/lie@3.3.0-license.md.txt +7 -0
- package/third-party-notices/linkifyjs@4.3.3-LICENSE.txt +19 -0
- package/third-party-notices/listenercount@1.0.1-LICENSE.md.txt +5 -0
- package/third-party-notices/lodash-es@4.18.1-LICENSE.txt +47 -0
- package/third-party-notices/lodash.camelcase@4.3.0-LICENSE.txt +47 -0
- package/third-party-notices/lodash.defaults@4.2.0-LICENSE.txt +47 -0
- package/third-party-notices/lodash.difference@4.5.0-LICENSE.txt +47 -0
- package/third-party-notices/lodash.escaperegexp@4.1.2-LICENSE.txt +47 -0
- package/third-party-notices/lodash.flatten@4.4.0-LICENSE.txt +47 -0
- package/third-party-notices/lodash.groupby@4.6.0-LICENSE.txt +47 -0
- package/third-party-notices/lodash.isboolean@3.0.3-LICENSE.txt +22 -0
- package/third-party-notices/lodash.isequal@4.5.0-LICENSE.txt +47 -0
- package/third-party-notices/lodash.isfunction@3.0.9-LICENSE.txt +47 -0
- package/third-party-notices/lodash.isnil@4.0.0-LICENSE.txt +22 -0
- package/third-party-notices/lodash.isplainobject@4.0.6-LICENSE.txt +47 -0
- package/third-party-notices/lodash.isundefined@3.0.1-LICENSE.txt.txt +22 -0
- package/third-party-notices/lodash.union@4.6.0-LICENSE.txt +47 -0
- package/third-party-notices/lodash.uniq@4.5.0-LICENSE.txt +47 -0
- package/third-party-notices/long@5.3.2-LICENSE.txt +202 -0
- package/third-party-notices/lowlight@3.3.0-license.txt +22 -0
- package/third-party-notices/math-intrinsics@1.1.0-LICENSE.txt +21 -0
- package/third-party-notices/minimatch@3.1.5-LICENSE.txt +15 -0
- package/third-party-notices/minimatch@5.1.9-LICENSE.txt +15 -0
- package/third-party-notices/minimist@1.2.8-LICENSE.txt +18 -0
- package/third-party-notices/mkdirp@0.5.6-LICENSE.txt +21 -0
- package/third-party-notices/n-gram@2.0.2-license.txt +22 -0
- package/third-party-notices/normalize-path@3.0.0-LICENSE.txt +21 -0
- package/third-party-notices/numfmt@4.0.1-LICENSE.txt +19 -0
- package/third-party-notices/object-inspect@1.13.4-LICENSE.txt +21 -0
- package/third-party-notices/object-keys@1.1.1-LICENSE.txt +21 -0
- package/third-party-notices/object.assign@4.1.7-LICENSE.txt +21 -0
- package/third-party-notices/once@1.4.0-LICENSE.txt +15 -0
- package/third-party-notices/orderedmap@2.1.1-LICENSE.txt +19 -0
- package/third-party-notices/own-keys@1.0.2-LICENSE.txt +21 -0
- package/third-party-notices/pako@1.0.11-LICENSE.txt +21 -0
- package/third-party-notices/path-is-absolute@1.0.1-license.txt +21 -0
- package/third-party-notices/possible-typed-array-names@1.1.0-LICENSE.txt +21 -0
- package/third-party-notices/process-nextick-args@2.0.1-license.md.txt +19 -0
- package/third-party-notices/prosemirror-changeset@2.4.4-LICENSE.txt +19 -0
- package/third-party-notices/prosemirror-commands@1.7.2-LICENSE.txt +19 -0
- package/third-party-notices/prosemirror-dropcursor@1.8.4-LICENSE.txt +19 -0
- package/third-party-notices/prosemirror-gapcursor@1.4.1-LICENSE.txt +19 -0
- package/third-party-notices/prosemirror-history@1.5.1-LICENSE.txt +19 -0
- package/third-party-notices/prosemirror-inputrules@1.5.1-LICENSE.txt +19 -0
- package/third-party-notices/prosemirror-keymap@1.2.3-LICENSE.txt +19 -0
- package/third-party-notices/prosemirror-model@1.25.12-LICENSE.txt +19 -0
- package/third-party-notices/prosemirror-schema-list@1.5.1-LICENSE.txt +19 -0
- package/third-party-notices/prosemirror-state@1.4.4-LICENSE.txt +19 -0
- package/third-party-notices/prosemirror-tables@1.8.5-LICENSE.txt +19 -0
- package/third-party-notices/prosemirror-transform@1.12.2-LICENSE.txt +19 -0
- package/third-party-notices/prosemirror-view@1.42.6-LICENSE.txt +19 -0
- package/third-party-notices/protobufjs@7.6.6-LICENSE.txt +39 -0
- package/third-party-notices/quickselect@3.0.0-LICENSE.txt +15 -0
- package/third-party-notices/rbush@4.0.1-LICENSE.txt +21 -0
- package/third-party-notices/react-dom@19.3.1-LICENSE.txt +21 -0
- package/third-party-notices/react-remove-scroll@2.7.2-LICENSE.txt +21 -0
- package/third-party-notices/react-style-singleton@2.2.3-LICENSE.txt +21 -0
- package/third-party-notices/react@19.3.1-LICENSE.txt +21 -0
- package/third-party-notices/readable-stream@2.3.8-LICENSE.txt +47 -0
- package/third-party-notices/readable-stream@3.6.2-LICENSE.txt +47 -0
- package/third-party-notices/readdir-glob@1.1.3-LICENSE.txt +201 -0
- package/third-party-notices/reflect.getprototypeof@1.0.10-LICENSE.txt +21 -0
- package/third-party-notices/regexp.prototype.flags@1.5.4-LICENSE.txt +22 -0
- package/third-party-notices/require-directory@2.1.1-LICENSE.txt +22 -0
- package/third-party-notices/rimraf@2.7.1-LICENSE.txt +15 -0
- package/third-party-notices/rope-sequence@1.3.4-LICENSE.txt +19 -0
- package/third-party-notices/rxjs@7.8.2-LICENSE.txt.txt +202 -0
- package/third-party-notices/safe-array-concat@1.1.4-LICENSE.txt +21 -0
- package/third-party-notices/safe-buffer@5.1.2-LICENSE.txt +21 -0
- package/third-party-notices/safe-buffer@5.2.1-LICENSE.txt +21 -0
- package/third-party-notices/safe-push-apply@1.0.0-LICENSE.txt +21 -0
- package/third-party-notices/safe-regex-test@1.1.0-LICENSE.txt +21 -0
- package/third-party-notices/scheduler@0.28.0-LICENSE.txt +21 -0
- package/third-party-notices/set-function-length@1.2.2-LICENSE.txt +21 -0
- package/third-party-notices/set-function-name@2.0.2-LICENSE.txt +21 -0
- package/third-party-notices/set-proto@1.0.0-LICENSE.txt +21 -0
- package/third-party-notices/setimmediate@1.0.5-LICENSE.txt.txt +20 -0
- package/third-party-notices/side-channel-list@1.0.1-LICENSE.txt +21 -0
- package/third-party-notices/side-channel-map@1.0.1-LICENSE.txt +21 -0
- package/third-party-notices/side-channel-weakmap@1.0.2-LICENSE.txt +21 -0
- package/third-party-notices/side-channel@1.1.1-LICENSE.txt +21 -0
- package/third-party-notices/sonner@2.0.8-LICENSE.md.txt +21 -0
- package/third-party-notices/stop-iteration-iterator@1.1.0-LICENSE.txt +21 -0
- package/third-party-notices/string-width@4.2.3-license.txt +9 -0
- package/third-party-notices/string.prototype.trim@1.2.11-LICENSE.txt +21 -0
- package/third-party-notices/string.prototype.trimend@1.0.10-LICENSE.txt +21 -0
- package/third-party-notices/string.prototype.trimstart@1.0.8-LICENSE.txt +21 -0
- package/third-party-notices/string_decoder@1.1.1-LICENSE.txt +48 -0
- package/third-party-notices/string_decoder@1.3.0-LICENSE.txt +48 -0
- package/third-party-notices/strip-ansi@6.0.1-license.txt +9 -0
- package/third-party-notices/tar-stream@2.2.0-LICENSE.txt +21 -0
- package/third-party-notices/tiny-pinyin@1.3.2-LICENSE.txt +21 -0
- package/third-party-notices/tmp@0.2.7-LICENSE.txt +21 -0
- package/third-party-notices/traverse@0.3.10-LICENSE.txt +21 -0
- package/third-party-notices/trigram-utils@2.0.1-license.txt +22 -0
- package/third-party-notices/tslib@2.8.1-LICENSE.txt.txt +12 -0
- package/third-party-notices/typed-array-buffer@1.0.3-LICENSE.txt +21 -0
- package/third-party-notices/typed-array-byte-length@1.0.3-LICENSE.txt +21 -0
- package/third-party-notices/typed-array-byte-offset@1.0.5-LICENSE.txt +21 -0
- package/third-party-notices/typed-array-length@1.0.8-LICENSE.txt +21 -0
- package/third-party-notices/typedarray.prototype.slice@1.0.6-LICENSE.txt +21 -0
- package/third-party-notices/unbox-primitive@1.1.0-LICENSE.txt +21 -0
- package/third-party-notices/undici-types@8.9.0-LICENSE.txt +21 -0
- package/third-party-notices/unzipper@0.10.14-LICENSE.txt +25 -0
- package/third-party-notices/use-callback-ref@1.3.3-LICENSE.txt +21 -0
- package/third-party-notices/use-sidecar@1.1.3-LICENSE.txt +21 -0
- package/third-party-notices/util-deprecate@1.0.2-LICENSE.txt +24 -0
- package/third-party-notices/uuid@8.3.2-LICENSE.md.txt +9 -0
- package/third-party-notices/w3c-keyname@2.2.8-LICENSE.txt +19 -0
- package/third-party-notices/which-boxed-primitive@1.1.1-LICENSE.txt +21 -0
- package/third-party-notices/which-builtin-type@1.2.1-LICENSE.txt +21 -0
- package/third-party-notices/which-collection@1.0.2-LICENSE.txt +21 -0
- package/third-party-notices/which-typed-array@1.1.24-LICENSE.txt +22 -0
- package/third-party-notices/wrap-ansi@7.0.0-license.txt +9 -0
- package/third-party-notices/wrappy@1.0.2-LICENSE.txt +15 -0
- package/third-party-notices/xmlchars@2.2.0-LICENSE.txt +18 -0
- package/third-party-notices/y-protocols@1.0.7-LICENSE.txt +21 -0
- package/third-party-notices/y18n@5.0.8-LICENSE.txt +13 -0
- package/third-party-notices/yargs-parser@21.1.1-LICENSE.txt.txt +14 -0
- package/third-party-notices/yargs@17.7.3-LICENSE.txt +21 -0
- package/third-party-notices/yjs@13.6.33-LICENSE.txt +23 -0
- package/third-party-notices/zip-stream@4.1.1-LICENSE.txt +22 -0
|
@@ -0,0 +1,180 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
3
|
+
import { useState, useEffect, Suspense, useRef, lazy } from "react";
|
|
4
|
+
import { readMindMap, mindMapOutline, MIND_MAP_PALETTE, layoutMindMap, mindRelationPaths } from "wendang/mindmap";
|
|
5
|
+
import { MIND_TOPIC_FONT, mindTopicLineHeight, readableTextColor } from "wendang/shared";
|
|
6
|
+
import { b as useContentHost } from "./host-C-V688Rq.js";
|
|
7
|
+
import { W as WButton } from "./index-Ii536CFG.js";
|
|
8
|
+
import { T as TopicLabel, A as AttachmentImage } from "./mind-topic-text-BBNTbFSe.js";
|
|
9
|
+
const Canvas = lazy(() => import("./MindMapCanvas-VWrxTy5Q.js").then((module) => ({ default: module.MindMapCanvas })));
|
|
10
|
+
function MindMapViewer({ value, modelValue, height, fetchAttachment }) {
|
|
11
|
+
var _a;
|
|
12
|
+
const model = value ?? modelValue;
|
|
13
|
+
const root = useRef(null), [width, setWidth] = useState(900);
|
|
14
|
+
useEffect(() => {
|
|
15
|
+
const node = root.current;
|
|
16
|
+
if (!node || typeof ResizeObserver === "undefined") return;
|
|
17
|
+
setWidth(node.clientWidth || 900);
|
|
18
|
+
const observer = new ResizeObserver((entries) => {
|
|
19
|
+
var _a2;
|
|
20
|
+
return setWidth(((_a2 = entries[0]) == null ? void 0 : _a2.contentRect.width) || 900);
|
|
21
|
+
});
|
|
22
|
+
observer.observe(node);
|
|
23
|
+
return () => observer.disconnect();
|
|
24
|
+
}, []);
|
|
25
|
+
if (!model) return /* @__PURE__ */ jsx("p", { role: "alert", children: "思维导图格式无效" });
|
|
26
|
+
const drawing = layoutMindMap(model), relations = mindRelationPaths(model, drawing);
|
|
27
|
+
const color = MIND_MAP_PALETTE[model.theme];
|
|
28
|
+
const previewHeight = height ?? model.height;
|
|
29
|
+
const scale = Math.min(1, (previewHeight - 30) / drawing.bounds.height, Math.max(100, width - 24) / drawing.bounds.width);
|
|
30
|
+
return /* @__PURE__ */ jsx(
|
|
31
|
+
"div",
|
|
32
|
+
{
|
|
33
|
+
ref: root,
|
|
34
|
+
className: "mind-preview-wrap",
|
|
35
|
+
style: { height: previewHeight },
|
|
36
|
+
role: "group",
|
|
37
|
+
"aria-label": ((_a = model.topics.find((topic) => topic.id === model.rootId)) == null ? void 0 : _a.text) || "思维导图",
|
|
38
|
+
children: /* @__PURE__ */ jsx("div", { className: "mind-preview-sized", style: { width: drawing.bounds.width * scale, height: drawing.bounds.height * scale }, children: /* @__PURE__ */ jsxs("div", { className: "mind-preview-scene", style: { width: drawing.bounds.width, height: drawing.bounds.height, transform: `scale(${scale})` }, children: [
|
|
39
|
+
/* @__PURE__ */ jsxs(
|
|
40
|
+
"svg",
|
|
41
|
+
{
|
|
42
|
+
className: "mind-preview-lines",
|
|
43
|
+
width: drawing.bounds.width,
|
|
44
|
+
height: drawing.bounds.height,
|
|
45
|
+
viewBox: `${drawing.bounds.x} ${drawing.bounds.y} ${drawing.bounds.width} ${drawing.bounds.height}`,
|
|
46
|
+
children: [
|
|
47
|
+
drawing.edges.map((edge) => /* @__PURE__ */ jsx("path", { d: edge.path, fill: "none", stroke: color, strokeWidth: 2 }, edge.id)),
|
|
48
|
+
relations.map((relation) => /* @__PURE__ */ jsxs("g", { children: [
|
|
49
|
+
/* @__PURE__ */ jsx("path", { d: relation.path, fill: "none", stroke: "#9a68d4", strokeWidth: 2, strokeDasharray: "6 4" }),
|
|
50
|
+
/* @__PURE__ */ jsx("text", { x: relation.x, y: relation.y, fontSize: 12, fill: "#9a68d4", children: relation.label || { related: "相关", depends: "依赖", reference: "参考" }[relation.kind] })
|
|
51
|
+
] }, relation.id))
|
|
52
|
+
]
|
|
53
|
+
}
|
|
54
|
+
),
|
|
55
|
+
drawing.nodes.map((topic) => /* @__PURE__ */ jsxs(
|
|
56
|
+
"div",
|
|
57
|
+
{
|
|
58
|
+
className: `mind-preview-topic ${topic.id === model.rootId ? "root" : ""} ${topic.shape === "text" ? "text" : ""}`,
|
|
59
|
+
style: {
|
|
60
|
+
left: topic.x - drawing.bounds.x,
|
|
61
|
+
top: topic.y - drawing.bounds.y,
|
|
62
|
+
width: topic.width,
|
|
63
|
+
minHeight: topic.height,
|
|
64
|
+
fontFamily: MIND_TOPIC_FONT,
|
|
65
|
+
borderRadius: topic.shape === "pill" ? 28 : void 0,
|
|
66
|
+
background: topic.shape === "text" ? "transparent" : topic.background || void 0,
|
|
67
|
+
color: topic.color || (topic.shape === "text" ? "var(--color-text)" : topic.background ? readableTextColor(topic.background) : void 0),
|
|
68
|
+
fontSize: topic.fontSize || 14,
|
|
69
|
+
textAlign: topic.align || "center",
|
|
70
|
+
"--mind-color": color
|
|
71
|
+
},
|
|
72
|
+
children: [
|
|
73
|
+
(topic.icon || topic.done) && /* @__PURE__ */ jsxs("span", { className: "mind-preview-icon", children: [
|
|
74
|
+
topic.done ? "☑ " : "",
|
|
75
|
+
topic.icon
|
|
76
|
+
] }),
|
|
77
|
+
/* @__PURE__ */ jsx("span", { className: "mind-preview-title", style: { minHeight: topic.lines.length * mindTopicLineHeight(topic.fontSize || 14), lineHeight: `${mindTopicLineHeight(topic.fontSize || 14)}px` }, children: /* @__PURE__ */ jsx(TopicLabel, { topic }) }),
|
|
78
|
+
topic.description && /* @__PURE__ */ jsx("span", { className: "mind-preview-description", children: topic.description }),
|
|
79
|
+
topic.note && /* @__PURE__ */ jsx("span", { className: "mind-preview-note", title: topic.note, children: "▤ 备注" }),
|
|
80
|
+
topic.attachmentId && /* @__PURE__ */ jsx("div", { className: "mind-preview-image", children: /* @__PURE__ */ jsx(AttachmentImage, { id: topic.attachmentId, alt: "主题图片", fetcher: fetchAttachment }) })
|
|
81
|
+
]
|
|
82
|
+
},
|
|
83
|
+
topic.id
|
|
84
|
+
))
|
|
85
|
+
] }) })
|
|
86
|
+
}
|
|
87
|
+
);
|
|
88
|
+
}
|
|
89
|
+
function MindMapBlock(props) {
|
|
90
|
+
const host = useContentHost(), c = props.controller;
|
|
91
|
+
const [open, setOpen] = useState(false), [outline, setOutline] = useState(false), [openComments, setOpenComments] = useState(false), [, update] = useState(0);
|
|
92
|
+
const node = props.node ?? props.value ?? props.modelValue;
|
|
93
|
+
const model = c ? c.snapshot() : node ? readMindMap(node) : null;
|
|
94
|
+
const editable = (c == null ? void 0 : c.editable()) ?? false;
|
|
95
|
+
const rows = model ? mindMapOutline(model) : [];
|
|
96
|
+
function show() {
|
|
97
|
+
if (model) {
|
|
98
|
+
setOpen(true);
|
|
99
|
+
if (c == null ? void 0 : c.context.viewState) c.context.viewState.openId = model.id;
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
function close() {
|
|
103
|
+
setOpen(false);
|
|
104
|
+
setOpenComments(false);
|
|
105
|
+
const state = c == null ? void 0 : c.context.viewState;
|
|
106
|
+
if (state && state.openId === (model == null ? void 0 : model.id)) state.openId = null;
|
|
107
|
+
}
|
|
108
|
+
useEffect(() => {
|
|
109
|
+
const stop = c == null ? void 0 : c.subscribe(() => {
|
|
110
|
+
update((value) => value + 1);
|
|
111
|
+
if (!c.snapshot()) setOpen(false);
|
|
112
|
+
});
|
|
113
|
+
return () => {
|
|
114
|
+
stop == null ? void 0 : stop();
|
|
115
|
+
};
|
|
116
|
+
}, [c]);
|
|
117
|
+
useEffect(() => {
|
|
118
|
+
var _a;
|
|
119
|
+
if (((_a = c == null ? void 0 : c.context.viewState) == null ? void 0 : _a.openId) === (model == null ? void 0 : model.id)) show();
|
|
120
|
+
if (!host.location || !model) return;
|
|
121
|
+
const linked = () => {
|
|
122
|
+
const params = new URLSearchParams(host.location.current().replace(/^#/, ""));
|
|
123
|
+
if (params.get("mind") === model.id && params.has("topic")) show();
|
|
124
|
+
};
|
|
125
|
+
linked();
|
|
126
|
+
return host.location.subscribe(linked);
|
|
127
|
+
}, [host.location, model == null ? void 0 : model.id, c]);
|
|
128
|
+
if (!model) return /* @__PURE__ */ jsx("p", { role: "alert", children: "思维导图格式无效" });
|
|
129
|
+
return /* @__PURE__ */ jsxs(
|
|
130
|
+
"section",
|
|
131
|
+
{
|
|
132
|
+
className: "mind-map-block",
|
|
133
|
+
"aria-label": "思维导图",
|
|
134
|
+
style: { "--mind-color": MIND_MAP_PALETTE[model.theme] },
|
|
135
|
+
onDoubleClick: (event) => {
|
|
136
|
+
event.stopPropagation();
|
|
137
|
+
show();
|
|
138
|
+
},
|
|
139
|
+
children: [
|
|
140
|
+
/* @__PURE__ */ jsxs("header", { className: "mind-map-block-header", children: [
|
|
141
|
+
/* @__PURE__ */ jsxs("span", { className: "mind-map-block-label", children: [
|
|
142
|
+
/* @__PURE__ */ jsx("span", { "aria-hidden": "true", children: "⌘" }),
|
|
143
|
+
" 思维导图 ",
|
|
144
|
+
/* @__PURE__ */ jsxs("span", { className: "mind-map-topic-count", children: [
|
|
145
|
+
model.topics.length,
|
|
146
|
+
" 个主题"
|
|
147
|
+
] })
|
|
148
|
+
] }),
|
|
149
|
+
/* @__PURE__ */ jsxs("div", { className: "mind-map-block-actions", children: [
|
|
150
|
+
host.comments && props.pageId && /* @__PURE__ */ jsx(WButton, { variant: "text", onClick: () => {
|
|
151
|
+
setOpenComments(true);
|
|
152
|
+
show();
|
|
153
|
+
}, children: editable ? "讨论" : "查看讨论" }),
|
|
154
|
+
/* @__PURE__ */ jsx(WButton, { variant: "text", onClick: () => setOutline(!outline), children: outline ? "查看导图" : "文字大纲" }),
|
|
155
|
+
/* @__PURE__ */ jsx(WButton, { variant: "text", onClick: show, children: editable ? "编辑导图" : "放大查看" })
|
|
156
|
+
] })
|
|
157
|
+
] }),
|
|
158
|
+
outline ? /* @__PURE__ */ jsx("div", { className: "mind-map-preview-outline", style: { maxHeight: model.height }, children: rows.map((row) => /* @__PURE__ */ jsx("div", { style: { paddingLeft: Math.min(row.depth, 20) * 18 }, children: row.text || "未命名主题" }, row.id)) }) : /* @__PURE__ */ jsx(MindMapViewer, { value: model, fetchAttachment: props.fetchAttachment ?? (c == null ? void 0 : c.context.fetchAttachment) }),
|
|
159
|
+
open && /* @__PURE__ */ jsx(Suspense, { fallback: /* @__PURE__ */ jsx("p", { role: "status", children: "正在加载导图…" }), children: /* @__PURE__ */ jsx(
|
|
160
|
+
Canvas,
|
|
161
|
+
{
|
|
162
|
+
model,
|
|
163
|
+
controller: c,
|
|
164
|
+
pageId: props.pageId,
|
|
165
|
+
canComment: props.canComment,
|
|
166
|
+
allowExport: props.allowExport,
|
|
167
|
+
fetchAttachment: props.fetchAttachment,
|
|
168
|
+
openComments,
|
|
169
|
+
onCommentsChanged: props.onCommentsChanged,
|
|
170
|
+
onClose: close
|
|
171
|
+
}
|
|
172
|
+
) })
|
|
173
|
+
]
|
|
174
|
+
}
|
|
175
|
+
);
|
|
176
|
+
}
|
|
177
|
+
export {
|
|
178
|
+
MindMapBlock as M,
|
|
179
|
+
MindMapViewer as a
|
|
180
|
+
};
|
|
@@ -0,0 +1,157 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
3
|
+
import { useState, useEffect, useMemo } from "react";
|
|
4
|
+
import { validateWorkbook } from "wendang/spreadsheet";
|
|
5
|
+
import { p as previewAxes, a as previewMerges, c as columnName, b as cellStyleData, d as cellDisplay, s as safeColor } from "./worksheet-preview-DsDVWxIM.js";
|
|
6
|
+
import { W as WButton } from "./index-Ii536CFG.js";
|
|
7
|
+
function SpreadsheetViewer({ value, modelValue, allowExport = false, standalone = false, exportSnapshot }) {
|
|
8
|
+
const [sheetId, setSheetId] = useState(""), [row, setRow] = useState(0), [column, setColumn] = useState(0), [showAll, setShowAll] = useState(false), [error, setError] = useState("");
|
|
9
|
+
const [exporting, setExporting] = useState(false);
|
|
10
|
+
useEffect(() => {
|
|
11
|
+
setRow(0);
|
|
12
|
+
setColumn(0);
|
|
13
|
+
}, [value, modelValue, showAll, sheetId]);
|
|
14
|
+
const parsed = useMemo(() => {
|
|
15
|
+
try {
|
|
16
|
+
return { doc: validateWorkbook(value ?? modelValue), error: "" };
|
|
17
|
+
} catch (error2) {
|
|
18
|
+
return { doc: null, error: String(error2) };
|
|
19
|
+
}
|
|
20
|
+
}, [value, modelValue]);
|
|
21
|
+
if (!parsed.doc) return /* @__PURE__ */ jsx("p", { role: "alert", children: parsed.error });
|
|
22
|
+
const doc = parsed.doc, allIds = doc.workbook.sheetOrder, ids = allIds.filter((id) => {
|
|
23
|
+
var _a;
|
|
24
|
+
return showAll || !((_a = doc.workbook.sheets[id]) == null ? void 0 : _a.hidden);
|
|
25
|
+
});
|
|
26
|
+
const sheet = doc.workbook.sheets[ids.includes(sheetId) ? sheetId : ids[0]];
|
|
27
|
+
if (!sheet) return /* @__PURE__ */ jsx("section", { className: "worksheet-preview", "aria-label": "工作表只读预览", children: /* @__PURE__ */ jsxs("nav", { className: "sheet-tabs", "aria-label": "工作表页", children: [
|
|
28
|
+
/* @__PURE__ */ jsx("span", { className: "sheet-note", children: "没有可见工作表" }),
|
|
29
|
+
/* @__PURE__ */ jsx(WButton, { "aria-pressed": showAll, onClick: () => setShowAll(true), children: "查看全部行列表页" })
|
|
30
|
+
] }) });
|
|
31
|
+
const axes = previewAxes(doc, sheet, showAll);
|
|
32
|
+
const pageRows = 100, pageColumns = 50;
|
|
33
|
+
const rowStart = Math.min(row, Math.floor(Math.max(0, axes.rows.length - 1) / pageRows) * pageRows);
|
|
34
|
+
const colStart = Math.min(column, Math.floor(Math.max(0, axes.columns.length - 1) / pageColumns) * pageColumns);
|
|
35
|
+
const rows = axes.rows.slice(rowStart, rowStart + pageRows), columns = axes.columns.slice(colStart, colStart + pageColumns), merges = previewMerges(sheet, rows, columns);
|
|
36
|
+
const dimension = (raw, fallback, upper = 600) => {
|
|
37
|
+
const value2 = Number(raw);
|
|
38
|
+
return Number.isFinite(value2) && value2 > 0 ? Math.min(Math.max(value2, 12), upper) : fallback;
|
|
39
|
+
};
|
|
40
|
+
const cellStyle = (r, c) => {
|
|
41
|
+
var _a, _b;
|
|
42
|
+
const merge = merges.get(`${r}:${c}`), rr = (merge == null ? void 0 : merge.sourceRow) ?? r, cc = (merge == null ? void 0 : merge.sourceColumn) ?? c;
|
|
43
|
+
const style = cellStyleData(doc, sheet, rr, cc);
|
|
44
|
+
const border = (side) => {
|
|
45
|
+
var _a2;
|
|
46
|
+
const raw = (_a2 = style.bd) == null ? void 0 : _a2[side];
|
|
47
|
+
if (!(raw == null ? void 0 : raw.s)) return void 0;
|
|
48
|
+
const line = raw.s === 7 ? "double" : [3, 4, 5, 6, 9, 10, 11, 12].includes(raw.s) ? "dashed" : "solid";
|
|
49
|
+
return `${raw.s === 13 ? 3 : raw.s >= 7 ? 2 : 1}px ${line} ${safeColor(raw.cl) ?? "currentColor"}`;
|
|
50
|
+
};
|
|
51
|
+
return {
|
|
52
|
+
color: safeColor(style.cl),
|
|
53
|
+
backgroundColor: safeColor(style.bg),
|
|
54
|
+
fontWeight: style.bl === 1 ? "bold" : void 0,
|
|
55
|
+
fontStyle: style.it === 1 ? "italic" : void 0,
|
|
56
|
+
fontSize: typeof style.fs === "number" ? `${dimension(style.fs, 11, 72)}pt` : void 0,
|
|
57
|
+
textDecoration: [((_a = style.ul) == null ? void 0 : _a.s) === 1 ? "underline" : "", ((_b = style.st) == null ? void 0 : _b.s) === 1 ? "line-through" : ""].filter(Boolean).join(" ") || void 0,
|
|
58
|
+
textAlign: style.ht === 2 ? "center" : style.ht === 3 ? "right" : void 0,
|
|
59
|
+
verticalAlign: style.vt === 2 ? "middle" : style.vt === 3 ? "bottom" : "top",
|
|
60
|
+
whiteSpace: style.tb === 3 ? "pre-wrap" : "pre",
|
|
61
|
+
borderTop: border("t"),
|
|
62
|
+
borderBottom: border("b"),
|
|
63
|
+
borderLeft: border("l"),
|
|
64
|
+
borderRight: border("r")
|
|
65
|
+
};
|
|
66
|
+
};
|
|
67
|
+
async function exportFile() {
|
|
68
|
+
if (!allowExport || exporting) return;
|
|
69
|
+
setExporting(true);
|
|
70
|
+
setError("");
|
|
71
|
+
try {
|
|
72
|
+
const snapshot = exportSnapshot ? await exportSnapshot() : { title: doc.workbook.name, doc };
|
|
73
|
+
const { exportXlsx } = await import("../spreadsheet/xlsx.js");
|
|
74
|
+
const bytes = await exportXlsx(snapshot.doc);
|
|
75
|
+
const url = URL.createObjectURL(new Blob([new Uint8Array(bytes)]));
|
|
76
|
+
const a = document.createElement("a");
|
|
77
|
+
a.href = url;
|
|
78
|
+
a.download = `${snapshot.title || "工作表"}.xlsx`;
|
|
79
|
+
a.click();
|
|
80
|
+
setTimeout(() => URL.revokeObjectURL(url), 1e3);
|
|
81
|
+
} catch (error2) {
|
|
82
|
+
setError(String(error2));
|
|
83
|
+
} finally {
|
|
84
|
+
setExporting(false);
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
return /* @__PURE__ */ jsxs("section", { className: `worksheet-preview${standalone ? " worksheet-preview-standalone" : ""}`, "aria-label": "工作表只读预览", children: [
|
|
88
|
+
/* @__PURE__ */ jsxs("nav", { className: "sheet-tabs", "aria-label": "工作表页", children: [
|
|
89
|
+
ids.map((id) => /* @__PURE__ */ jsxs(
|
|
90
|
+
WButton,
|
|
91
|
+
{
|
|
92
|
+
role: "tab",
|
|
93
|
+
variant: sheet.id === id ? "primary" : "text",
|
|
94
|
+
"aria-selected": sheet.id === id,
|
|
95
|
+
onClick: () => {
|
|
96
|
+
setSheetId(id);
|
|
97
|
+
setRow(0);
|
|
98
|
+
setColumn(0);
|
|
99
|
+
},
|
|
100
|
+
children: [
|
|
101
|
+
doc.workbook.sheets[id].name,
|
|
102
|
+
doc.workbook.sheets[id].hidden ? "(隐藏)" : ""
|
|
103
|
+
]
|
|
104
|
+
},
|
|
105
|
+
id
|
|
106
|
+
)),
|
|
107
|
+
/* @__PURE__ */ jsx("span", { className: "sheet-note", children: "只读预览" }),
|
|
108
|
+
/* @__PURE__ */ jsx(WButton, { "aria-pressed": showAll, onClick: () => setShowAll(!showAll), children: showAll ? "恢复保存视图" : "查看全部行列表页" }),
|
|
109
|
+
allowExport && /* @__PURE__ */ jsx(WButton, { loading: exporting, onClick: () => void exportFile(), children: "导出 XLSX" })
|
|
110
|
+
] }),
|
|
111
|
+
error && /* @__PURE__ */ jsx("p", { role: "alert", children: error }),
|
|
112
|
+
(axes.hasFilter || axes.hasHidden) && /* @__PURE__ */ jsx("p", { className: "sheet-view-note", role: "status", children: showAll ? "正在查看全部内容;仅改变本次预览。" : `按保存的隐藏与筛选状态显示${axes.filtered ? `,筛除 ${axes.filtered} 行` : ""}。` }),
|
|
113
|
+
/* @__PURE__ */ jsx("div", { className: "sheet-table", tabIndex: 0, children: /* @__PURE__ */ jsxs("table", { children: [
|
|
114
|
+
/* @__PURE__ */ jsxs("colgroup", { children: [
|
|
115
|
+
/* @__PURE__ */ jsx("col", { style: { width: 40 } }),
|
|
116
|
+
columns.map((c) => {
|
|
117
|
+
var _a, _b;
|
|
118
|
+
return /* @__PURE__ */ jsx("col", { style: { width: dimension((_b = (_a = sheet.columnData) == null ? void 0 : _a[c]) == null ? void 0 : _b.w, dimension(sheet.defaultColumnWidth, 100, 600), 600) } }, c);
|
|
119
|
+
})
|
|
120
|
+
] }),
|
|
121
|
+
/* @__PURE__ */ jsx("thead", { children: /* @__PURE__ */ jsxs("tr", { children: [
|
|
122
|
+
/* @__PURE__ */ jsx("th", { "aria-label": "行号" }),
|
|
123
|
+
columns.map((c) => /* @__PURE__ */ jsx("th", { children: columnName(c) }, c))
|
|
124
|
+
] }) }),
|
|
125
|
+
/* @__PURE__ */ jsx("tbody", { children: rows.map((r) => {
|
|
126
|
+
var _a, _b, _c, _d;
|
|
127
|
+
return /* @__PURE__ */ jsxs("tr", { style: { height: dimension(((_b = (_a = sheet.rowData) == null ? void 0 : _a[r]) == null ? void 0 : _b.h) ?? ((_d = (_c = sheet.rowData) == null ? void 0 : _c[r]) == null ? void 0 : _d.ah), dimension(sheet.defaultRowHeight, 30, 600), 600) }, children: [
|
|
128
|
+
/* @__PURE__ */ jsx("th", { children: r + 1 }),
|
|
129
|
+
columns.map((c) => {
|
|
130
|
+
var _a2, _b2;
|
|
131
|
+
const merge = merges.get(`${r}:${c}`);
|
|
132
|
+
if (merge == null ? void 0 : merge.hidden) return null;
|
|
133
|
+
const rr = (merge == null ? void 0 : merge.sourceRow) ?? r, cc = (merge == null ? void 0 : merge.sourceColumn) ?? c, style = cellStyleData(doc, sheet, rr, cc);
|
|
134
|
+
const display = cellDisplay((_b2 = (_a2 = sheet.cellData) == null ? void 0 : _a2[rr]) == null ? void 0 : _b2[cc], style);
|
|
135
|
+
return /* @__PURE__ */ jsx("td", { rowSpan: merge == null ? void 0 : merge.rowspan, colSpan: merge == null ? void 0 : merge.colspan, title: display.note, style: cellStyle(r, c), children: display.text }, c);
|
|
136
|
+
})
|
|
137
|
+
] }, r);
|
|
138
|
+
}) })
|
|
139
|
+
] }) }),
|
|
140
|
+
/* @__PURE__ */ jsxs("div", { className: "sheet-paging", children: [
|
|
141
|
+
/* @__PURE__ */ jsxs("span", { children: [
|
|
142
|
+
"第 ",
|
|
143
|
+
rows.length ? `${rows[0] + 1}–${rows[rows.length - 1] + 1}` : "—",
|
|
144
|
+
" 行 · ",
|
|
145
|
+
columns.length ? `${columnName(columns[0])}–${columnName(columns[columns.length - 1])}` : "—",
|
|
146
|
+
" 列 · 公式显示最近保存结果"
|
|
147
|
+
] }),
|
|
148
|
+
/* @__PURE__ */ jsx(WButton, { disabled: rowStart === 0, onClick: () => setRow(Math.max(0, rowStart - pageRows)), children: "上一页行" }),
|
|
149
|
+
/* @__PURE__ */ jsx(WButton, { disabled: rowStart + pageRows >= axes.rows.length, onClick: () => setRow(rowStart + pageRows), children: "下一页行" }),
|
|
150
|
+
/* @__PURE__ */ jsx(WButton, { disabled: colStart === 0, onClick: () => setColumn(Math.max(0, colStart - pageColumns)), children: "上一页列" }),
|
|
151
|
+
/* @__PURE__ */ jsx(WButton, { disabled: colStart + pageColumns >= axes.columns.length, onClick: () => setColumn(colStart + pageColumns), children: "下一页列" })
|
|
152
|
+
] })
|
|
153
|
+
] });
|
|
154
|
+
}
|
|
155
|
+
export {
|
|
156
|
+
SpreadsheetViewer as S
|
|
157
|
+
};
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
let highlight = null;
|
|
3
|
+
let loading = null;
|
|
4
|
+
const cache = /* @__PURE__ */ new Map();
|
|
5
|
+
const MAX_HIGHLIGHT_LENGTH = 32e3;
|
|
6
|
+
function ensureCodeHighlight() {
|
|
7
|
+
if (highlight) return Promise.resolve(true);
|
|
8
|
+
return loading ?? (loading = import("./code-highlight-engine-BFDzDPzy.js").then((engine) => {
|
|
9
|
+
highlight = engine.highlightCode;
|
|
10
|
+
return true;
|
|
11
|
+
}).catch(() => {
|
|
12
|
+
loading = null;
|
|
13
|
+
return false;
|
|
14
|
+
}));
|
|
15
|
+
}
|
|
16
|
+
function codeTokens(text, language) {
|
|
17
|
+
if (!highlight || !text || text.length > MAX_HIGHLIGHT_LENGTH) return [];
|
|
18
|
+
const key = `${language ?? ""}\0${text}`;
|
|
19
|
+
const found = cache.get(key);
|
|
20
|
+
if (found) return found;
|
|
21
|
+
const tokens = highlight(text, language ?? "");
|
|
22
|
+
if (cache.size >= 64) cache.delete(cache.keys().next().value);
|
|
23
|
+
cache.set(key, tokens);
|
|
24
|
+
return tokens;
|
|
25
|
+
}
|
|
26
|
+
export {
|
|
27
|
+
MAX_HIGHLIGHT_LENGTH as M,
|
|
28
|
+
codeTokens as c,
|
|
29
|
+
ensureCodeHighlight as e
|
|
30
|
+
};
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { createLowlight, common } from "lowlight";
|
|
3
|
+
const lowlight = createLowlight(common);
|
|
4
|
+
const aliases = {
|
|
5
|
+
jsx: "javascript",
|
|
6
|
+
tsx: "typescript",
|
|
7
|
+
html: "xml",
|
|
8
|
+
sh: "bash",
|
|
9
|
+
shell: "bash",
|
|
10
|
+
ini: "ini"
|
|
11
|
+
};
|
|
12
|
+
const autoLanguages = ["javascript", "typescript", "json", "python", "bash", "sql", "css", "xml", "yaml", "java", "go", "rust", "cpp"];
|
|
13
|
+
function highlightCode(text, language) {
|
|
14
|
+
const normalized = language.toLowerCase().replace(/^language-/, "");
|
|
15
|
+
if (["text", "txt", "plaintext", "plain"].includes(normalized)) return [];
|
|
16
|
+
const name = aliases[normalized] ?? normalized;
|
|
17
|
+
if (name && !lowlight.registered(name)) return [];
|
|
18
|
+
try {
|
|
19
|
+
const tree = name ? lowlight.highlight(name, text) : lowlight.highlightAuto(text, { subset: autoLanguages });
|
|
20
|
+
const tokens = [];
|
|
21
|
+
let offset = 0;
|
|
22
|
+
const walk = (node, classes) => {
|
|
23
|
+
if (node.type === "text") {
|
|
24
|
+
const to = offset + node.value.length;
|
|
25
|
+
if (to > offset && classes.length) tokens.push({ from: offset, to, classes: classes.join(" ") });
|
|
26
|
+
offset = to;
|
|
27
|
+
} else if ("children" in node) {
|
|
28
|
+
const own = node.type === "element" && Array.isArray(node.properties.className) ? node.properties.className.filter((value) => typeof value === "string" && /^[\w-]+$/.test(value)) : [];
|
|
29
|
+
for (const child of node.children) walk(child, [...classes, ...own]);
|
|
30
|
+
}
|
|
31
|
+
};
|
|
32
|
+
walk(tree, []);
|
|
33
|
+
return offset === text.length ? tokens : [];
|
|
34
|
+
} catch {
|
|
35
|
+
return [];
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
export {
|
|
39
|
+
highlightCode
|
|
40
|
+
};
|