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,2070 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { jsxs, jsx, Fragment } from "react/jsx-runtime";
|
|
3
|
+
import { useState, useRef, useEffect, useMemo } from "react";
|
|
4
|
+
import { textDifference, mindMapTree, layoutMindMap, MIND_MAP_PALETTE, mindMapDescendants as mindMapDescendants$1, projectMindSideMove, mindMapBranchSides, mindMapOutline, mindRelationPaths, mindMapMarkdown, mindMapSvg, mindMapToJson, MIND_MAP_MAX_TOPICS } from "wendang/mindmap";
|
|
5
|
+
import { TEXT_COLORS, HIGHLIGHT_COLORS, mindTopicLineHeight, MIND_TOPIC_FONT, readableTextColor } from "wendang/shared";
|
|
6
|
+
import { MIND_ICONS, MIND_COLORS, MIND_BACKGROUNDS, branchModel, searchMindMap, parseMindMapImport, importBranch, mindMapTemplate, parseMindBranch, ancestorIds } from "wendang/internal/mind-map-phase2";
|
|
7
|
+
import { normalizeMindFolds, firstLevelMindFolds } from "wendang/internal/mind-map-folding";
|
|
8
|
+
import { p as planMindTopicDeletion } from "./mind-map-delete-CVsxdXfs.js";
|
|
9
|
+
import { mindMapDescendants } from "wendang/internal/mind-map";
|
|
10
|
+
import { m as mindCanvasShortcut, s as selectMindTopic } from "./mind-map-input-CEWRz_t6.js";
|
|
11
|
+
import { b as useContentHost, a as useContentContext } from "./host-C-V688Rq.js";
|
|
12
|
+
import { createPortal } from "react-dom";
|
|
13
|
+
import { u as useLatest } from "./hooks-C53Dp0pr.js";
|
|
14
|
+
import { W as WButton, c as WDialog, a as WSelect, d as WAlert } from "./index-Ii536CFG.js";
|
|
15
|
+
import { T as TopicLabel, A as AttachmentImage } from "./mind-topic-text-BBNTbFSe.js";
|
|
16
|
+
import { A as AnchoredPanel } from "./AnchoredPanel-D3nte06T.js";
|
|
17
|
+
function mindMapDrop(model, drawing, id, point, allowSide = true) {
|
|
18
|
+
const source = drawing.nodes.find((t) => t.id === id), root = drawing.nodes.find((t) => t.id === model.rootId);
|
|
19
|
+
if (!source || !root || id === model.rootId) return null;
|
|
20
|
+
const excluded = mindMapDescendants(model, id), { x, y } = point;
|
|
21
|
+
const candidates = drawing.nodes.filter((t) => !excluded.has(t.id)).map((t) => ({
|
|
22
|
+
t,
|
|
23
|
+
distance: Math.hypot(x - t.x - t.width / 2, y - t.y - t.height / 2)
|
|
24
|
+
})).sort((a, b) => a.distance - b.distance);
|
|
25
|
+
const best = candidates[0];
|
|
26
|
+
const side = x < root.x + root.width / 2 - 24 ? -1 : x > root.x + root.width / 2 + 24 ? 1 : null;
|
|
27
|
+
const crossing = allowSide && model.layout !== "down" && side !== null && side !== source.side;
|
|
28
|
+
const nearNode = best && best.t.id !== root.id && x >= best.t.x - 18 && x <= best.t.x + best.t.width + 18 && y >= best.t.y - 18 && y <= best.t.y + best.t.height + 18;
|
|
29
|
+
if (nearNode || !crossing && best && best.distance < Math.max(best.t.width, 130)) {
|
|
30
|
+
return { kind: "node", id: best.t.id, mode: best.t.id === root.id ? "child" : y < best.t.y + 10 ? "before" : y > best.t.y + best.t.height - 10 ? "after" : "child" };
|
|
31
|
+
}
|
|
32
|
+
if (allowSide && model.layout !== "down" && side !== null && (crossing || source.parentId === root.id && model.layout === "both")) {
|
|
33
|
+
const before = drawing.nodes.filter((t) => t.parentId === root.id && t.id !== id && t.side === side).find((t) => y < t.y + t.height / 2);
|
|
34
|
+
return { kind: "side", id: root.id, mode: "side", side, ...before ? { beforeId: before.id } : {} };
|
|
35
|
+
}
|
|
36
|
+
return null;
|
|
37
|
+
}
|
|
38
|
+
function topicsInMarquee(topics, rect, previous = []) {
|
|
39
|
+
const visible = new Set(topics.map((topic) => topic.id));
|
|
40
|
+
const selected = new Set([...previous].filter((id) => visible.has(id)));
|
|
41
|
+
if (rect.width <= 0 || rect.height <= 0) return selected;
|
|
42
|
+
for (const topic of topics) {
|
|
43
|
+
if (topic.x < rect.x + rect.width && topic.x + topic.width > rect.x && topic.y < rect.y + rect.height && topic.y + topic.height > rect.y) selected.add(topic.id);
|
|
44
|
+
}
|
|
45
|
+
return selected;
|
|
46
|
+
}
|
|
47
|
+
function MindMapComments({ pageId, blockId, topicId, topicLabel, canComment, onClose, onChanged }) {
|
|
48
|
+
const host = useContentHost(), [items, setItems] = useState([]), [draft, setDraft] = useState(""), [error, setError] = useState(""), [busy, setBusy] = useState(false), [loading, setLoading] = useState(true);
|
|
49
|
+
const [composer, setComposer] = useState(null), [confirmId, setConfirmId] = useState(null), [epoch, setEpoch] = useState(0);
|
|
50
|
+
const alive = useRef(true), running = useRef(false);
|
|
51
|
+
useEffect(() => {
|
|
52
|
+
alive.current = true;
|
|
53
|
+
return () => {
|
|
54
|
+
alive.current = false;
|
|
55
|
+
};
|
|
56
|
+
}, []);
|
|
57
|
+
useEffect(() => {
|
|
58
|
+
let active = true;
|
|
59
|
+
setDraft("");
|
|
60
|
+
setComposer(null);
|
|
61
|
+
setConfirmId(null);
|
|
62
|
+
setError("");
|
|
63
|
+
setLoading(true);
|
|
64
|
+
if (!host.comments) {
|
|
65
|
+
setLoading(false);
|
|
66
|
+
return;
|
|
67
|
+
}
|
|
68
|
+
void host.comments.list(pageId).then((result) => {
|
|
69
|
+
if (active) setItems(result.items.filter((item) => {
|
|
70
|
+
var _a, _b;
|
|
71
|
+
return ((_a = item.anchor) == null ? void 0 : _a.prefix) === `mind:${blockId}` && ((_b = item.anchor) == null ? void 0 : _b.suffix) === topicId;
|
|
72
|
+
}));
|
|
73
|
+
}).catch((error2) => {
|
|
74
|
+
if (active) setError(String(error2));
|
|
75
|
+
}).finally(() => {
|
|
76
|
+
if (active) setLoading(false);
|
|
77
|
+
});
|
|
78
|
+
return () => {
|
|
79
|
+
active = false;
|
|
80
|
+
};
|
|
81
|
+
}, [host.comments, pageId, blockId, topicId, epoch]);
|
|
82
|
+
async function perform(action) {
|
|
83
|
+
if (running.current) return;
|
|
84
|
+
running.current = true;
|
|
85
|
+
setBusy(true);
|
|
86
|
+
setError("");
|
|
87
|
+
try {
|
|
88
|
+
await action();
|
|
89
|
+
onChanged == null ? void 0 : onChanged();
|
|
90
|
+
if (alive.current) {
|
|
91
|
+
setDraft("");
|
|
92
|
+
setComposer(null);
|
|
93
|
+
setEpoch((value) => value + 1);
|
|
94
|
+
}
|
|
95
|
+
} catch (error2) {
|
|
96
|
+
if (alive.current) setError(String(error2));
|
|
97
|
+
} finally {
|
|
98
|
+
running.current = false;
|
|
99
|
+
if (alive.current) setBusy(false);
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
const title = topicLabel.trim() ? `「${topicLabel.trim()}」` : "当前主题";
|
|
103
|
+
const time = (value) => {
|
|
104
|
+
const date = new Date(value);
|
|
105
|
+
return Number.isNaN(date.getTime()) ? "" : date.toLocaleString();
|
|
106
|
+
};
|
|
107
|
+
function compose(item) {
|
|
108
|
+
if (!composer || composer.id !== item.id) return null;
|
|
109
|
+
const editing = composer.kind === "edit";
|
|
110
|
+
return /* @__PURE__ */ jsxs("form", { className: "mind-comment__compose", onSubmit: (event) => {
|
|
111
|
+
event.preventDefault();
|
|
112
|
+
if (!composer.text.trim() || !editing && !canComment) return;
|
|
113
|
+
void perform(() => editing ? host.comments.update(composer.id, composer.text.trim()) : host.comments.create(pageId, composer.text.trim(), composer.id));
|
|
114
|
+
}, children: [
|
|
115
|
+
/* @__PURE__ */ jsx("label", { className: "mind-comment__label", children: editing ? "正在编辑评论" : `回复 ${item.authorName}` }),
|
|
116
|
+
/* @__PURE__ */ jsx("textarea", { "aria-label": editing ? "编辑主题讨论" : "回复主题讨论", rows: editing ? 3 : 2, maxLength: 5e3, value: composer.text, onChange: (event) => setComposer({ ...composer, text: event.target.value }) }),
|
|
117
|
+
/* @__PURE__ */ jsxs("div", { className: "mind-comment__actions", children: [
|
|
118
|
+
/* @__PURE__ */ jsx(WButton, { variant: "primary", loading: busy, disabled: !composer.text.trim(), htmlType: "submit", children: editing ? "保存" : "发表回复" }),
|
|
119
|
+
/* @__PURE__ */ jsx(WButton, { onClick: () => setComposer(null), children: "取消" })
|
|
120
|
+
] })
|
|
121
|
+
] });
|
|
122
|
+
}
|
|
123
|
+
function comment(item, reply = false) {
|
|
124
|
+
var _a, _b;
|
|
125
|
+
const editing = (composer == null ? void 0 : composer.kind) === "edit" && composer.id === item.id;
|
|
126
|
+
return /* @__PURE__ */ jsxs("article", { className: reply ? "mind-comment__reply" : "mind-comment", children: [
|
|
127
|
+
/* @__PURE__ */ jsxs("header", { className: "mind-comment__head", children: [
|
|
128
|
+
/* @__PURE__ */ jsx("strong", { children: item.authorName || "用户" }),
|
|
129
|
+
/* @__PURE__ */ jsxs("span", { children: [
|
|
130
|
+
time(item.createdAt),
|
|
131
|
+
item.resolved ? " · 已解决" : ""
|
|
132
|
+
] })
|
|
133
|
+
] }),
|
|
134
|
+
editing ? compose(item) : /* @__PURE__ */ jsx("p", { className: "mind-comment__body", children: item.deleted ? reply ? "回复已删除" : "评论已删除" : item.body }),
|
|
135
|
+
!editing && /* @__PURE__ */ jsxs("div", { className: "mind-comment__actions", children: [
|
|
136
|
+
item.canResolve && !reply && /* @__PURE__ */ jsx(WButton, { variant: "text", disabled: busy, onClick: () => void perform(() => host.comments.resolve(item.id, !item.resolved)), children: item.resolved ? "重新打开" : "标记解决" }),
|
|
137
|
+
canComment && !item.deleted && !reply && /* @__PURE__ */ jsx(WButton, { variant: "text", onClick: () => setComposer({ kind: "reply", id: item.id, text: "" }), children: "回复" }),
|
|
138
|
+
((_a = host.comments) == null ? void 0 : _a.update) && item.canEdit && /* @__PURE__ */ jsx(WButton, { variant: "text", onClick: () => setComposer({ kind: "edit", id: item.id, text: item.body }), children: "编辑" }),
|
|
139
|
+
item.canDelete && /* @__PURE__ */ jsx(WButton, { variant: "text", disabled: busy, onClick: () => setConfirmId(item.id), children: "删除" })
|
|
140
|
+
] }),
|
|
141
|
+
!reply && ((_b = item.replies) == null ? void 0 : _b.map((child) => comment(child, true))),
|
|
142
|
+
!editing && compose(item)
|
|
143
|
+
] }, item.id);
|
|
144
|
+
}
|
|
145
|
+
return /* @__PURE__ */ jsxs("aside", { className: "mind-comments", "aria-label": "主题讨论", children: [
|
|
146
|
+
/* @__PURE__ */ jsxs("header", { className: "mind-comments__head", children: [
|
|
147
|
+
/* @__PURE__ */ jsxs("div", { className: "mind-comments__intro", children: [
|
|
148
|
+
/* @__PURE__ */ jsxs("strong", { children: [
|
|
149
|
+
title,
|
|
150
|
+
"的讨论"
|
|
151
|
+
] }),
|
|
152
|
+
/* @__PURE__ */ jsx("p", { children: "讨论跟随这个主题移动;复制分支时不会复制。" })
|
|
153
|
+
] }),
|
|
154
|
+
/* @__PURE__ */ jsxs("div", { className: "mind-comments__head-actions", children: [
|
|
155
|
+
/* @__PURE__ */ jsx(WButton, { variant: "text", disabled: busy, onClick: () => setEpoch((value) => value + 1), children: "刷新" }),
|
|
156
|
+
/* @__PURE__ */ jsx(WButton, { variant: "text", onClick: onClose, children: "关闭" })
|
|
157
|
+
] })
|
|
158
|
+
] }),
|
|
159
|
+
error && /* @__PURE__ */ jsx("p", { className: "mind-comments__error", role: "alert", children: error }),
|
|
160
|
+
/* @__PURE__ */ jsxs("div", { className: "mind-comments__list", children: [
|
|
161
|
+
loading && /* @__PURE__ */ jsx("p", { role: "status", children: "正在加载讨论…" }),
|
|
162
|
+
!loading && !error && !items.length && /* @__PURE__ */ jsxs("p", { className: "mind-comments__empty", children: [
|
|
163
|
+
"这个主题还没有讨论。",
|
|
164
|
+
canComment ? "在下方写下第一条即可。" : ""
|
|
165
|
+
] }),
|
|
166
|
+
items.map((item) => comment(item))
|
|
167
|
+
] }),
|
|
168
|
+
canComment ? /* @__PURE__ */ jsxs("form", { className: "mind-comments__compose", onSubmit: (event) => {
|
|
169
|
+
event.preventDefault();
|
|
170
|
+
if (!draft.trim()) return;
|
|
171
|
+
void perform(() => host.comments.create(pageId, draft.trim(), void 0, { blockId, topicId }));
|
|
172
|
+
}, children: [
|
|
173
|
+
/* @__PURE__ */ jsxs("label", { className: "mind-comment__label", children: [
|
|
174
|
+
"对",
|
|
175
|
+
title,
|
|
176
|
+
"发表讨论"
|
|
177
|
+
] }),
|
|
178
|
+
/* @__PURE__ */ jsx("textarea", { "aria-label": "主题评论内容", rows: 3, maxLength: 5e3, placeholder: "写下你的想法…", value: draft, onChange: (event) => setDraft(event.target.value) }),
|
|
179
|
+
/* @__PURE__ */ jsx("div", { className: "mind-comment__actions", children: /* @__PURE__ */ jsx(WButton, { variant: "primary", loading: busy, disabled: !draft.trim(), htmlType: "submit", children: "发表讨论" }) })
|
|
180
|
+
] }) : /* @__PURE__ */ jsx("p", { className: "mind-comments__empty", children: "你没有在这个空间发表讨论的权限。" }),
|
|
181
|
+
confirmId && /* @__PURE__ */ jsxs(WDialog, { title: "删除评论", onClose: () => setConfirmId(null), children: [
|
|
182
|
+
/* @__PURE__ */ jsx("p", { children: "确定删除这条评论?" }),
|
|
183
|
+
/* @__PURE__ */ jsxs("div", { className: "wr-toolbar", children: [
|
|
184
|
+
/* @__PURE__ */ jsx(WButton, { onClick: () => setConfirmId(null), children: "取消" }),
|
|
185
|
+
/* @__PURE__ */ jsx(WButton, { variant: "primary", onClick: () => {
|
|
186
|
+
const id = confirmId;
|
|
187
|
+
setConfirmId(null);
|
|
188
|
+
void perform(() => host.comments.remove(id));
|
|
189
|
+
}, children: "删除" })
|
|
190
|
+
] })
|
|
191
|
+
] })
|
|
192
|
+
] });
|
|
193
|
+
}
|
|
194
|
+
function MindMapField({ id, field, value, controller, label, onFocus, onCommand }) {
|
|
195
|
+
const input = useRef(null), composing = useRef(false), focused = useRef(false);
|
|
196
|
+
const [draft, setDraft] = useState(value), draftRef = useRef(value);
|
|
197
|
+
draftRef.current = draft;
|
|
198
|
+
useEffect(() => {
|
|
199
|
+
if (composing.current || draftRef.current === value) return;
|
|
200
|
+
const el = input.current, start = (el == null ? void 0 : el.selectionStart) ?? 0, end = (el == null ? void 0 : el.selectionEnd) ?? start;
|
|
201
|
+
const diff = textDifference(draftRef.current, value), shift = diff.text.length - diff.to + diff.from;
|
|
202
|
+
const map = (pos) => pos <= diff.from ? pos : pos >= diff.to ? pos + shift : diff.from + diff.text.length;
|
|
203
|
+
setDraft(value);
|
|
204
|
+
if (focused.current) queueMicrotask(() => el == null ? void 0 : el.setSelectionRange(map(start), map(end)));
|
|
205
|
+
}, [value]);
|
|
206
|
+
useEffect(() => () => {
|
|
207
|
+
controller == null ? void 0 : controller.composition(false);
|
|
208
|
+
controller == null ? void 0 : controller.endText(id, field);
|
|
209
|
+
}, [controller, id, field]);
|
|
210
|
+
function apply(next) {
|
|
211
|
+
if (controller == null ? void 0 : controller.text(id, next, field)) setDraft(next);
|
|
212
|
+
}
|
|
213
|
+
return /* @__PURE__ */ jsx(
|
|
214
|
+
"textarea",
|
|
215
|
+
{
|
|
216
|
+
ref: input,
|
|
217
|
+
"aria-label": label,
|
|
218
|
+
value: draft,
|
|
219
|
+
readOnly: !(controller == null ? void 0 : controller.editable()),
|
|
220
|
+
maxLength: field === "title" ? 2e3 : 4e3,
|
|
221
|
+
rows: field === "title" ? 1 : field === "note" ? 4 : 3,
|
|
222
|
+
onFocus: () => {
|
|
223
|
+
focused.current = true;
|
|
224
|
+
controller == null ? void 0 : controller.beginText(id, field);
|
|
225
|
+
onFocus == null ? void 0 : onFocus();
|
|
226
|
+
},
|
|
227
|
+
onBlur: () => {
|
|
228
|
+
focused.current = false;
|
|
229
|
+
controller == null ? void 0 : controller.composition(false);
|
|
230
|
+
controller == null ? void 0 : controller.endText(id, field);
|
|
231
|
+
},
|
|
232
|
+
onChange: (event) => apply(event.target.value),
|
|
233
|
+
onCompositionStart: () => {
|
|
234
|
+
composing.current = true;
|
|
235
|
+
controller == null ? void 0 : controller.composition(true);
|
|
236
|
+
},
|
|
237
|
+
onCompositionEnd: (event) => {
|
|
238
|
+
apply(event.currentTarget.value);
|
|
239
|
+
composing.current = false;
|
|
240
|
+
controller == null ? void 0 : controller.composition(false);
|
|
241
|
+
controller == null ? void 0 : controller.beginText(id, field);
|
|
242
|
+
},
|
|
243
|
+
onKeyDown: (event) => {
|
|
244
|
+
event.stopPropagation();
|
|
245
|
+
if (event.nativeEvent.isComposing || composing.current || event.keyCode === 229) return;
|
|
246
|
+
if ((event.metaKey || event.ctrlKey) && ["z", "y"].includes(event.key.toLowerCase())) {
|
|
247
|
+
event.preventDefault();
|
|
248
|
+
event.shiftKey || event.key.toLowerCase() === "y" ? controller == null ? void 0 : controller.redo() : controller == null ? void 0 : controller.undo();
|
|
249
|
+
} else onCommand == null ? void 0 : onCommand(event);
|
|
250
|
+
}
|
|
251
|
+
}
|
|
252
|
+
);
|
|
253
|
+
}
|
|
254
|
+
const COLORS = MIND_COLORS.map((value, index) => ({ value, label: ["默认", "深灰", "白色", "蓝色", "青绿", "紫色", "棕色", "红色"][index] }));
|
|
255
|
+
const BACKGROUNDS = MIND_BACKGROUNDS.map((value, index) => ({ value, label: ["默认", "浅灰", "浅蓝", "浅绿", "浅紫", "浅黄", "浅红", "深蓝"][index] }));
|
|
256
|
+
function MindMapDetails({ model, id, controller, range, onClose, onNotice }) {
|
|
257
|
+
var _a;
|
|
258
|
+
const topic = model.topics.find((item) => item.id === id);
|
|
259
|
+
const writable = (controller == null ? void 0 : controller.editable()) ?? false;
|
|
260
|
+
const [href, setHref] = useState(""), [busy, setBusy] = useState(false);
|
|
261
|
+
const [relationTarget, setRelationTarget] = useState(""), [relationLabel, setRelationLabel] = useState("");
|
|
262
|
+
const [relationKind, setRelationKind] = useState("related");
|
|
263
|
+
const [relationId, setRelationId] = useState(void 0);
|
|
264
|
+
const imageInput = useRef(null);
|
|
265
|
+
if (!topic) return null;
|
|
266
|
+
const patch = (key, value) => {
|
|
267
|
+
if (writable) controller == null ? void 0 : controller.patch(id, { [key]: value || null });
|
|
268
|
+
};
|
|
269
|
+
function format(mark, attrs) {
|
|
270
|
+
const from = range.from, to = range.to;
|
|
271
|
+
if (to <= from) {
|
|
272
|
+
onNotice == null ? void 0 : onNotice("请先在主题文字中选中要设置格式的文字。");
|
|
273
|
+
return;
|
|
274
|
+
}
|
|
275
|
+
if (mark === "link" && attrs && !attrs.href) {
|
|
276
|
+
controller == null ? void 0 : controller.clearFormat(id, from, to, ["link"]);
|
|
277
|
+
return;
|
|
278
|
+
}
|
|
279
|
+
controller == null ? void 0 : controller.format(id, from, to, mark, attrs);
|
|
280
|
+
}
|
|
281
|
+
async function upload(file) {
|
|
282
|
+
var _a2;
|
|
283
|
+
if (!file || !(controller == null ? void 0 : controller.context.uploadImage) || !writable) return;
|
|
284
|
+
if (!["image/png", "image/jpeg", "image/webp", "image/gif"].includes(file.type)) {
|
|
285
|
+
onNotice == null ? void 0 : onNotice("请选择 PNG、JPEG、WebP 或 GIF 图片");
|
|
286
|
+
return;
|
|
287
|
+
}
|
|
288
|
+
setBusy(true);
|
|
289
|
+
try {
|
|
290
|
+
const uploaded = await controller.context.uploadImage(file);
|
|
291
|
+
if (controller.editable() && ((_a2 = controller.snapshot()) == null ? void 0 : _a2.topics.some((item) => item.id === id))) controller.patch(id, { attachmentId: uploaded.id });
|
|
292
|
+
} catch (error) {
|
|
293
|
+
onNotice == null ? void 0 : onNotice(error instanceof Error ? error.message : "图片上传失败");
|
|
294
|
+
} finally {
|
|
295
|
+
setBusy(false);
|
|
296
|
+
if (imageInput.current) imageInput.current.value = "";
|
|
297
|
+
}
|
|
298
|
+
}
|
|
299
|
+
function addRelation() {
|
|
300
|
+
if (controller == null ? void 0 : controller.relation({ id: relationId, source: id, target: relationTarget, kind: relationKind, label: relationLabel })) {
|
|
301
|
+
setRelationLabel("");
|
|
302
|
+
setRelationId(void 0);
|
|
303
|
+
onNotice == null ? void 0 : onNotice("已保存主题关系");
|
|
304
|
+
} else onNotice == null ? void 0 : onNotice("请选择不同的目标主题");
|
|
305
|
+
}
|
|
306
|
+
const relations = ((_a = model.relations) == null ? void 0 : _a.filter((relation) => relation.source === id || relation.target === id)) ?? [];
|
|
307
|
+
return /* @__PURE__ */ jsxs("aside", { className: "mind-details", "aria-label": "主题属性", children: [
|
|
308
|
+
/* @__PURE__ */ jsxs("header", { children: [
|
|
309
|
+
/* @__PURE__ */ jsx("strong", { children: "主题属性" }),
|
|
310
|
+
/* @__PURE__ */ jsx(WButton, { size: "small", variant: "text", onClick: onClose, children: "关闭" })
|
|
311
|
+
] }),
|
|
312
|
+
/* @__PURE__ */ jsx("p", { className: "mind-details-title", children: topic.text || "未命名主题" }),
|
|
313
|
+
writable && /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
314
|
+
/* @__PURE__ */ jsxs("fieldset", { children: [
|
|
315
|
+
/* @__PURE__ */ jsx("legend", { children: "选中文字格式" }),
|
|
316
|
+
/* @__PURE__ */ jsxs("div", { className: "mind-format-buttons", onMouseDown: (event) => event.preventDefault(), children: [
|
|
317
|
+
/* @__PURE__ */ jsx(WButton, { size: "small", "aria-label": "主题文字加粗", onClick: () => format("bold"), children: /* @__PURE__ */ jsx("b", { children: "B" }) }),
|
|
318
|
+
/* @__PURE__ */ jsx(WButton, { size: "small", "aria-label": "主题文字斜体", onClick: () => format("italic"), children: /* @__PURE__ */ jsx("i", { children: "I" }) }),
|
|
319
|
+
/* @__PURE__ */ jsx(WButton, { size: "small", "aria-label": "主题文字删除线", onClick: () => format("strike"), children: /* @__PURE__ */ jsx("s", { children: "S" }) })
|
|
320
|
+
] }),
|
|
321
|
+
/* @__PURE__ */ jsx("span", { children: "选区文字色" }),
|
|
322
|
+
/* @__PURE__ */ jsx("div", { className: "mind-color-grid", onMouseDown: (event) => event.preventDefault(), children: TEXT_COLORS.filter((color) => color.value).map((color) => /* @__PURE__ */ jsx(
|
|
323
|
+
WButton,
|
|
324
|
+
{
|
|
325
|
+
size: "small",
|
|
326
|
+
variant: "outline",
|
|
327
|
+
narrow: true,
|
|
328
|
+
"aria-label": `选区字体:${color.name}`,
|
|
329
|
+
title: color.name,
|
|
330
|
+
onClick: () => format("textStyle", { color: color.value }),
|
|
331
|
+
children: /* @__PURE__ */ jsx("span", { style: { color: color.value }, children: "A" })
|
|
332
|
+
},
|
|
333
|
+
color.value
|
|
334
|
+
)) }),
|
|
335
|
+
/* @__PURE__ */ jsx("span", { children: "选区高亮" }),
|
|
336
|
+
/* @__PURE__ */ jsx("div", { className: "mind-color-grid", onMouseDown: (event) => event.preventDefault(), children: HIGHLIGHT_COLORS.filter((color) => color.value).map((color) => /* @__PURE__ */ jsx(
|
|
337
|
+
WButton,
|
|
338
|
+
{
|
|
339
|
+
size: "small",
|
|
340
|
+
variant: "outline",
|
|
341
|
+
narrow: true,
|
|
342
|
+
"aria-label": `选区高亮:${color.name}`,
|
|
343
|
+
title: color.name,
|
|
344
|
+
style: { background: color.value },
|
|
345
|
+
onClick: () => format("highlight", { color: color.value })
|
|
346
|
+
},
|
|
347
|
+
color.value
|
|
348
|
+
)) }),
|
|
349
|
+
/* @__PURE__ */ jsxs("label", { children: [
|
|
350
|
+
"选区链接",
|
|
351
|
+
/* @__PURE__ */ jsx("input", { value: href, type: "url", placeholder: "https://… 或站内路径", "aria-label": "主题选区链接", onChange: (event) => setHref(event.target.value) })
|
|
352
|
+
] }),
|
|
353
|
+
/* @__PURE__ */ jsx(WButton, { size: "small", onClick: () => format("link", { href }), children: "应用链接" }),
|
|
354
|
+
/* @__PURE__ */ jsx(WButton, { size: "small", onClick: () => controller == null ? void 0 : controller.clearFormat(id, range.from, range.to), children: "清除选区格式" })
|
|
355
|
+
] }),
|
|
356
|
+
/* @__PURE__ */ jsxs("fieldset", { children: [
|
|
357
|
+
/* @__PURE__ */ jsx("legend", { children: "外观" }),
|
|
358
|
+
/* @__PURE__ */ jsxs("label", { children: [
|
|
359
|
+
"形状",
|
|
360
|
+
/* @__PURE__ */ jsx(
|
|
361
|
+
WSelect,
|
|
362
|
+
{
|
|
363
|
+
label: "主题形状",
|
|
364
|
+
ariaLabel: "主题形状",
|
|
365
|
+
value: topic.shape ?? "round",
|
|
366
|
+
onChange: (value) => patch("shape", value),
|
|
367
|
+
options: [{ value: "round", label: "圆角矩形" }, { value: "pill", label: "胶囊" }, { value: "text", label: "文本" }]
|
|
368
|
+
}
|
|
369
|
+
)
|
|
370
|
+
] }),
|
|
371
|
+
/* @__PURE__ */ jsxs("label", { children: [
|
|
372
|
+
"字号",
|
|
373
|
+
/* @__PURE__ */ jsx(
|
|
374
|
+
WSelect,
|
|
375
|
+
{
|
|
376
|
+
label: "主题字号",
|
|
377
|
+
ariaLabel: "主题字号",
|
|
378
|
+
value: topic.fontSize ?? 14,
|
|
379
|
+
onChange: (value) => patch("fontSize", Number(value)),
|
|
380
|
+
options: [12, 14, 16, 18, 20].map((value) => ({ value, label: String(value) }))
|
|
381
|
+
}
|
|
382
|
+
)
|
|
383
|
+
] }),
|
|
384
|
+
/* @__PURE__ */ jsxs("label", { children: [
|
|
385
|
+
"对齐",
|
|
386
|
+
/* @__PURE__ */ jsx(
|
|
387
|
+
WSelect,
|
|
388
|
+
{
|
|
389
|
+
label: "主题对齐",
|
|
390
|
+
ariaLabel: "主题对齐",
|
|
391
|
+
value: topic.align ?? "center",
|
|
392
|
+
onChange: (value) => patch("align", value),
|
|
393
|
+
options: [{ value: "left", label: "左对齐" }, { value: "center", label: "居中" }, { value: "right", label: "右对齐" }]
|
|
394
|
+
}
|
|
395
|
+
)
|
|
396
|
+
] }),
|
|
397
|
+
/* @__PURE__ */ jsx("span", { children: "节点文字色" }),
|
|
398
|
+
/* @__PURE__ */ jsx("div", { className: "mind-color-grid", onMouseDown: (event) => event.preventDefault(), children: COLORS.map((color) => /* @__PURE__ */ jsx(
|
|
399
|
+
WButton,
|
|
400
|
+
{
|
|
401
|
+
size: "small",
|
|
402
|
+
variant: "outline",
|
|
403
|
+
narrow: true,
|
|
404
|
+
"aria-label": `节点字体:${color.label}`,
|
|
405
|
+
title: color.label,
|
|
406
|
+
onClick: () => patch("color", color.value),
|
|
407
|
+
children: /* @__PURE__ */ jsx("span", { style: color.value ? { color: color.value } : void 0, children: "A" })
|
|
408
|
+
},
|
|
409
|
+
color.label
|
|
410
|
+
)) }),
|
|
411
|
+
/* @__PURE__ */ jsx("span", { children: "节点背景" }),
|
|
412
|
+
/* @__PURE__ */ jsx("div", { className: "mind-color-grid", onMouseDown: (event) => event.preventDefault(), children: BACKGROUNDS.map((color) => /* @__PURE__ */ jsx(
|
|
413
|
+
WButton,
|
|
414
|
+
{
|
|
415
|
+
size: "small",
|
|
416
|
+
variant: "outline",
|
|
417
|
+
narrow: true,
|
|
418
|
+
"aria-label": `节点背景:${color.label}`,
|
|
419
|
+
title: color.label,
|
|
420
|
+
style: color.value ? { background: color.value } : void 0,
|
|
421
|
+
onClick: () => patch("background", color.value),
|
|
422
|
+
children: color.value ? "" : "/"
|
|
423
|
+
},
|
|
424
|
+
color.label
|
|
425
|
+
)) }),
|
|
426
|
+
/* @__PURE__ */ jsxs("label", { children: [
|
|
427
|
+
"图标",
|
|
428
|
+
/* @__PURE__ */ jsx(
|
|
429
|
+
WSelect,
|
|
430
|
+
{
|
|
431
|
+
label: "主题图标",
|
|
432
|
+
ariaLabel: "主题图标",
|
|
433
|
+
value: topic.icon ?? "",
|
|
434
|
+
onChange: (value) => patch("icon", value),
|
|
435
|
+
options: MIND_ICONS.map((value) => ({ value, label: value || "无图标" }))
|
|
436
|
+
}
|
|
437
|
+
)
|
|
438
|
+
] }),
|
|
439
|
+
/* @__PURE__ */ jsx(WButton, { size: "small", onClick: () => controller == null ? void 0 : controller.patch(id, { done: !topic.done }), children: topic.done ? "取消完成" : "标记完成" })
|
|
440
|
+
] })
|
|
441
|
+
] }),
|
|
442
|
+
/* @__PURE__ */ jsxs("fieldset", { children: [
|
|
443
|
+
/* @__PURE__ */ jsx("legend", { children: "描述" }),
|
|
444
|
+
/* @__PURE__ */ jsx(MindMapField, { id, field: "description", value: topic.description ?? "", controller, label: "主题描述" })
|
|
445
|
+
] }),
|
|
446
|
+
/* @__PURE__ */ jsxs("fieldset", { children: [
|
|
447
|
+
/* @__PURE__ */ jsx("legend", { children: "备注" }),
|
|
448
|
+
/* @__PURE__ */ jsx(MindMapField, { id, field: "note", value: topic.note ?? "", controller, label: "主题备注" })
|
|
449
|
+
] }),
|
|
450
|
+
writable && (controller == null ? void 0 : controller.context.uploadImage) && /* @__PURE__ */ jsxs("fieldset", { children: [
|
|
451
|
+
/* @__PURE__ */ jsx("legend", { children: "节点图片" }),
|
|
452
|
+
/* @__PURE__ */ jsx("input", { ref: imageInput, hidden: true, type: "file", accept: "image/png,image/jpeg,image/webp,image/gif", onChange: (event) => {
|
|
453
|
+
var _a2;
|
|
454
|
+
return void upload((_a2 = event.target.files) == null ? void 0 : _a2[0]);
|
|
455
|
+
} }),
|
|
456
|
+
/* @__PURE__ */ jsx(WButton, { size: "small", loading: busy, onClick: () => {
|
|
457
|
+
var _a2;
|
|
458
|
+
return (_a2 = imageInput.current) == null ? void 0 : _a2.click();
|
|
459
|
+
}, children: topic.attachmentId ? "替换图片" : "添加图片" }),
|
|
460
|
+
topic.attachmentId && /* @__PURE__ */ jsx(WButton, { size: "small", onClick: () => patch("attachmentId", null), children: "移除图片" })
|
|
461
|
+
] }),
|
|
462
|
+
/* @__PURE__ */ jsxs("fieldset", { children: [
|
|
463
|
+
/* @__PURE__ */ jsx("legend", { children: "主题关系" }),
|
|
464
|
+
relations.map((relation) => {
|
|
465
|
+
var _a2;
|
|
466
|
+
return /* @__PURE__ */ jsxs("div", { className: "mind-relation-item", children: [
|
|
467
|
+
/* @__PURE__ */ jsxs("span", { children: [
|
|
468
|
+
relation.label || { related: "相关", depends: "依赖", reference: "参考" }[relation.kind],
|
|
469
|
+
" → ",
|
|
470
|
+
((_a2 = model.topics.find((item) => item.id === (relation.source === id ? relation.target : relation.source))) == null ? void 0 : _a2.text) || "已移除主题"
|
|
471
|
+
] }),
|
|
472
|
+
writable && relation.source === id && /* @__PURE__ */ jsx(WButton, { variant: "text", size: "small", onClick: () => {
|
|
473
|
+
setRelationId(relation.id);
|
|
474
|
+
setRelationTarget(relation.target);
|
|
475
|
+
setRelationKind(relation.kind);
|
|
476
|
+
setRelationLabel(relation.label);
|
|
477
|
+
}, children: "编辑" }),
|
|
478
|
+
writable && /* @__PURE__ */ jsx(WButton, { variant: "text", size: "small", onClick: () => controller == null ? void 0 : controller.deleteRelation(relation.id), children: "删除" })
|
|
479
|
+
] }, relation.id);
|
|
480
|
+
}),
|
|
481
|
+
writable && /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
482
|
+
/* @__PURE__ */ jsx(
|
|
483
|
+
WSelect,
|
|
484
|
+
{
|
|
485
|
+
label: "关系目标主题",
|
|
486
|
+
ariaLabel: "关系目标主题",
|
|
487
|
+
value: relationTarget,
|
|
488
|
+
onChange: setRelationTarget,
|
|
489
|
+
options: model.topics.filter((item) => item.id !== id).map((item) => ({ value: item.id, label: item.text || "未命名主题" })),
|
|
490
|
+
searchable: true
|
|
491
|
+
}
|
|
492
|
+
),
|
|
493
|
+
/* @__PURE__ */ jsx(
|
|
494
|
+
WSelect,
|
|
495
|
+
{
|
|
496
|
+
label: "主题关系类型",
|
|
497
|
+
ariaLabel: "主题关系类型",
|
|
498
|
+
value: relationKind,
|
|
499
|
+
onChange: (value) => setRelationKind(value),
|
|
500
|
+
options: [{ value: "related", label: "相关" }, { value: "depends", label: "依赖" }, { value: "reference", label: "参考" }]
|
|
501
|
+
}
|
|
502
|
+
),
|
|
503
|
+
/* @__PURE__ */ jsx("input", { "aria-label": "关系说明", placeholder: "关系说明(可选)", maxLength: 200, value: relationLabel, onChange: (event) => setRelationLabel(event.target.value) }),
|
|
504
|
+
/* @__PURE__ */ jsx(WButton, { size: "small", disabled: !relationTarget, onClick: addRelation, children: relationId ? "保存关系" : "添加关系" })
|
|
505
|
+
] })
|
|
506
|
+
] })
|
|
507
|
+
] });
|
|
508
|
+
}
|
|
509
|
+
function WDropdown({ label, groups, onSelect, buttonProps }) {
|
|
510
|
+
const [open, setOpen] = useState(false), trigger = useRef(null), menu = useRef(null);
|
|
511
|
+
function keydown(event) {
|
|
512
|
+
var _a, _b;
|
|
513
|
+
if (!open || event.nativeEvent.isComposing) return;
|
|
514
|
+
const items = Array.from(((_a = menu.current) == null ? void 0 : _a.querySelectorAll('[role="menuitem"]:not([aria-disabled="true"])')) ?? []);
|
|
515
|
+
const index = items.indexOf(document.activeElement);
|
|
516
|
+
if (["ArrowDown", "ArrowUp", "Home", "End"].includes(event.key) && items.length) {
|
|
517
|
+
event.preventDefault();
|
|
518
|
+
event.stopPropagation();
|
|
519
|
+
(_b = items[event.key === "Home" ? 0 : event.key === "End" ? items.length - 1 : index < 0 ? event.key === "ArrowUp" ? items.length - 1 : 0 : (index + (event.key === "ArrowUp" ? -1 : 1) + items.length) % items.length]) == null ? void 0 : _b.focus();
|
|
520
|
+
}
|
|
521
|
+
}
|
|
522
|
+
function select(item) {
|
|
523
|
+
if (!item.disabled) {
|
|
524
|
+
setOpen(false);
|
|
525
|
+
onSelect(item.value);
|
|
526
|
+
}
|
|
527
|
+
}
|
|
528
|
+
return /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
529
|
+
/* @__PURE__ */ jsx(WButton, { ...buttonProps, ref: trigger, "aria-haspopup": "menu", "aria-expanded": open, onClick: () => setOpen(!open), onKeyDown: keydown, children: label }),
|
|
530
|
+
open && /* @__PURE__ */ jsx(
|
|
531
|
+
AnchoredPanel,
|
|
532
|
+
{
|
|
533
|
+
anchor: trigger.current,
|
|
534
|
+
align: "center",
|
|
535
|
+
gap: 6,
|
|
536
|
+
role: "menu",
|
|
537
|
+
className: "mind-dropdown-popup",
|
|
538
|
+
label: typeof label === "string" ? label : void 0,
|
|
539
|
+
onClose: () => setOpen(false),
|
|
540
|
+
onKeyDown: keydown,
|
|
541
|
+
children: /* @__PURE__ */ jsx("div", { ref: menu, className: "w-dropdown", children: groups.map((group, index) => /* @__PURE__ */ jsxs("div", { className: "w-dropdown-group", role: "group", "aria-label": group.title, children: [
|
|
542
|
+
group.title && /* @__PURE__ */ jsx("div", { className: "w-dropdown-group__title", children: group.title }),
|
|
543
|
+
group.items.map((item) => /* @__PURE__ */ jsxs(
|
|
544
|
+
"div",
|
|
545
|
+
{
|
|
546
|
+
className: `w-dropdown-option${item.disabled ? " is-disabled" : ""}`,
|
|
547
|
+
role: "menuitem",
|
|
548
|
+
tabIndex: item.disabled ? void 0 : -1,
|
|
549
|
+
"aria-disabled": item.disabled || void 0,
|
|
550
|
+
onClick: () => select(item),
|
|
551
|
+
onKeyDown: (event) => {
|
|
552
|
+
if (event.key === "Enter" || event.key === " ") {
|
|
553
|
+
event.preventDefault();
|
|
554
|
+
select(item);
|
|
555
|
+
}
|
|
556
|
+
},
|
|
557
|
+
children: [
|
|
558
|
+
item.label,
|
|
559
|
+
item.shortcut && /* @__PURE__ */ jsx("span", { className: "mind-menu-key", children: item.shortcut })
|
|
560
|
+
]
|
|
561
|
+
},
|
|
562
|
+
item.value
|
|
563
|
+
))
|
|
564
|
+
] }, index)) })
|
|
565
|
+
}
|
|
566
|
+
)
|
|
567
|
+
] });
|
|
568
|
+
}
|
|
569
|
+
function WTooltip({ children, content }) {
|
|
570
|
+
var _a;
|
|
571
|
+
const [open, setOpen] = useState(false), anchor = useRef(null), timer = useRef(void 0);
|
|
572
|
+
function close() {
|
|
573
|
+
clearTimeout(timer.current);
|
|
574
|
+
setOpen(false);
|
|
575
|
+
}
|
|
576
|
+
function show() {
|
|
577
|
+
clearTimeout(timer.current);
|
|
578
|
+
timer.current = setTimeout(() => setOpen(true), 200);
|
|
579
|
+
}
|
|
580
|
+
useEffect(() => () => clearTimeout(timer.current), []);
|
|
581
|
+
useEffect(() => {
|
|
582
|
+
if (!open) return;
|
|
583
|
+
window.addEventListener("scroll", close, true);
|
|
584
|
+
return () => window.removeEventListener("scroll", close, true);
|
|
585
|
+
}, [open]);
|
|
586
|
+
return /* @__PURE__ */ jsxs("span", { ref: anchor, style: { display: "contents" }, onMouseEnter: show, onMouseLeave: close, onFocus: show, onBlur: close, children: [
|
|
587
|
+
children,
|
|
588
|
+
open && /* @__PURE__ */ jsx(AnchoredPanel, { anchor: ((_a = anchor.current) == null ? void 0 : _a.firstElementChild) ?? null, align: "center", prefer: "above", gap: 8, role: "tooltip", onClose: close, className: "code-tooltip-popup", children: /* @__PURE__ */ jsx("div", { className: "w-tooltip", children: content }) })
|
|
589
|
+
] });
|
|
590
|
+
}
|
|
591
|
+
function MindMapCanvas(props) {
|
|
592
|
+
var _a, _b, _c, _d, _e, _f, _g;
|
|
593
|
+
const { host, portal } = useContentContext(), c = props.controller, [, update] = useState(0);
|
|
594
|
+
useEffect(() => {
|
|
595
|
+
const unsubscribe = c == null ? void 0 : c.subscribe(() => update((value) => value + 1));
|
|
596
|
+
return () => {
|
|
597
|
+
unsubscribe == null ? void 0 : unsubscribe();
|
|
598
|
+
};
|
|
599
|
+
}, [c]);
|
|
600
|
+
const model = (c == null ? void 0 : c.snapshot()) ?? props.model, editable = (c == null ? void 0 : c.editable()) ?? false;
|
|
601
|
+
const saved = useRef((_a = c == null ? void 0 : c.context.viewState) == null ? void 0 : _a.maps[model.id]).current;
|
|
602
|
+
const [selected, setSelected] = useState(() => new Set((saved == null ? void 0 : saved.selectedIds) ?? [(saved == null ? void 0 : saved.selectedId) ?? model.rootId]));
|
|
603
|
+
const [active, setActive] = useState((saved == null ? void 0 : saved.selectedId) ?? model.rootId);
|
|
604
|
+
const [editing, setEditing] = useState(null), [text, setText] = useState("");
|
|
605
|
+
const composing = useRef(false);
|
|
606
|
+
const [folds, setFolds] = useState(() => normalizeMindFolds(model, (saved == null ? void 0 : saved.collapsed) ?? []));
|
|
607
|
+
const [zoom, setZoom] = useState(((_b = saved == null ? void 0 : saved.viewport) == null ? void 0 : _b.zoom) ?? 1);
|
|
608
|
+
const [origin, setPan] = useState({ x: ((_c = saved == null ? void 0 : saved.viewport) == null ? void 0 : _c.x) ?? 0, y: ((_d = saved == null ? void 0 : saved.viewport) == null ? void 0 : _d.y) ?? 0 });
|
|
609
|
+
const [moving, setMoving] = useState((saved == null ? void 0 : saved.panMode) ?? false), space = useRef(false), [outline, setOutline] = useState(false), [grid, setGrid] = useState((saved == null ? void 0 : saved.showGrid) ?? true);
|
|
610
|
+
const [spaceHeld, setSpaceHeld] = useState(false);
|
|
611
|
+
const [quickControls, setQuickControls] = useState((saved == null ? void 0 : saved.showQuickControls) ?? true);
|
|
612
|
+
const [settingsOpen, setSettingsOpen] = useState(false), settingsTrigger = useRef(null);
|
|
613
|
+
const [busy, setBusy] = useState(false), exportRunning = useRef(false);
|
|
614
|
+
const [showSearch, setShowSearch] = useState(false), [query, setQuery] = useState(""), [replacement, setReplacement] = useState("");
|
|
615
|
+
const [hitIndex, setHitIndex] = useState(0), [following, setFollowing] = useState(null);
|
|
616
|
+
const [details, setDetails] = useState(false), [comments, setComments] = useState(!!props.openComments);
|
|
617
|
+
const [selectedRange, setSelectedRange] = useState({ from: 0, to: 0 });
|
|
618
|
+
const [notice, setNotice] = useState(""), [focusId, setFocusId] = useState(null);
|
|
619
|
+
const [confirmDelete, setConfirmDelete] = useState(null);
|
|
620
|
+
const deletionSelection = useRef([]), deletionActive = useRef(active);
|
|
621
|
+
const [importOpen, setImportOpen] = useState(false), [importText, setImportText] = useState(""), [importError, setImportError] = useState("");
|
|
622
|
+
const [exportBranch, setExportBranch] = useState(false), [transparent, setTransparent] = useState(false), [imageScale, setImageScale] = useState(2);
|
|
623
|
+
const [box, setBox] = useState(null), [drop, setDrop] = useState(null);
|
|
624
|
+
const [contextMenu, setContextMenu] = useState(null);
|
|
625
|
+
const menuRef = useRef(null);
|
|
626
|
+
const [dragPreview, setDragPreview] = useState(null);
|
|
627
|
+
const [pasting, setPasting] = useState(false), pastingRef = useRef(false), alive = useRef(true);
|
|
628
|
+
const root = useRef(null), stage = useRef(null), input = useRef(null);
|
|
629
|
+
const gesture = useRef(null), copied = useRef([]), [size, setSize] = useState({ width: 0, height: 0 });
|
|
630
|
+
const tree = mindMapTree(model), current = tree.find((topic) => topic.id === active) ?? tree[0];
|
|
631
|
+
const viewModel = focusId && tree.some((topic) => topic.id === focusId) ? branchModel(model, focusId) : model;
|
|
632
|
+
const drawing = layoutMindMap(viewModel, normalizeMindFolds(viewModel, folds)), color = MIND_MAP_PALETTE[model.theme];
|
|
633
|
+
const currentRef = useLatest({ model, editable, c, active });
|
|
634
|
+
const draggedIds = dragPreview ? mindMapDescendants$1(model, dragPreview.id) : /* @__PURE__ */ new Set();
|
|
635
|
+
const projected = (drop == null ? void 0 : drop.kind) === "side" && dragPreview ? projectMindSideMove(model, dragPreview.id, drop.side, drop.beforeId) : null;
|
|
636
|
+
const projection = projected ? layoutMindMap(projected, folds) : null;
|
|
637
|
+
const hits = query ? searchMindMap(model, query) : [];
|
|
638
|
+
const importPreview = useMemo(() => {
|
|
639
|
+
try {
|
|
640
|
+
return importText.trim() ? parseMindMapImport(importText) : null;
|
|
641
|
+
} catch {
|
|
642
|
+
return null;
|
|
643
|
+
}
|
|
644
|
+
}, [importText]);
|
|
645
|
+
const status = props.saveStatus ?? (c == null ? void 0 : c.status()) ?? "", pageId = props.pageId ?? (c == null ? void 0 : c.context.pageId);
|
|
646
|
+
const canExport = c ? c.canExport() : props.allowExport === true;
|
|
647
|
+
const title = ((_e = model.topics.find((topic) => topic.id === model.rootId)) == null ? void 0 : _e.text) || "思维导图";
|
|
648
|
+
useEffect(() => {
|
|
649
|
+
const node = stage.current;
|
|
650
|
+
if (!node) return;
|
|
651
|
+
const observer = new ResizeObserver(() => setSize({ width: node.clientWidth, height: node.clientHeight }));
|
|
652
|
+
const wheel = (event) => event.preventDefault();
|
|
653
|
+
node.addEventListener("wheel", wheel, { passive: false });
|
|
654
|
+
observer.observe(node);
|
|
655
|
+
return () => {
|
|
656
|
+
observer.disconnect();
|
|
657
|
+
node.removeEventListener("wheel", wheel);
|
|
658
|
+
};
|
|
659
|
+
}, []);
|
|
660
|
+
useEffect(() => {
|
|
661
|
+
const keyup = (event) => {
|
|
662
|
+
if (event.code === "Space") {
|
|
663
|
+
space.current = false;
|
|
664
|
+
setSpaceHeld(false);
|
|
665
|
+
}
|
|
666
|
+
};
|
|
667
|
+
const blur = () => {
|
|
668
|
+
cancelGesture();
|
|
669
|
+
space.current = false;
|
|
670
|
+
setSpaceHeld(false);
|
|
671
|
+
setContextMenu(null);
|
|
672
|
+
};
|
|
673
|
+
window.addEventListener("keyup", keyup);
|
|
674
|
+
window.addEventListener("blur", blur);
|
|
675
|
+
return () => {
|
|
676
|
+
window.removeEventListener("keyup", keyup);
|
|
677
|
+
window.removeEventListener("blur", blur);
|
|
678
|
+
};
|
|
679
|
+
}, []);
|
|
680
|
+
useEffect(() => {
|
|
681
|
+
alive.current = true;
|
|
682
|
+
return () => {
|
|
683
|
+
alive.current = false;
|
|
684
|
+
c == null ? void 0 : c.composition(false);
|
|
685
|
+
};
|
|
686
|
+
}, [c]);
|
|
687
|
+
useEffect(() => {
|
|
688
|
+
const close = (event) => {
|
|
689
|
+
var _a2;
|
|
690
|
+
if (!((_a2 = menuRef.current) == null ? void 0 : _a2.contains(event.target))) setContextMenu(null);
|
|
691
|
+
};
|
|
692
|
+
const key = (event) => {
|
|
693
|
+
var _a2;
|
|
694
|
+
if (event.isComposing || event.key !== "Escape") return;
|
|
695
|
+
if (gesture.current || contextMenu) {
|
|
696
|
+
event.preventDefault();
|
|
697
|
+
event.stopImmediatePropagation();
|
|
698
|
+
cancelGesture();
|
|
699
|
+
setContextMenu(null);
|
|
700
|
+
(_a2 = stage.current) == null ? void 0 : _a2.focus();
|
|
701
|
+
}
|
|
702
|
+
};
|
|
703
|
+
document.addEventListener("pointerdown", close, true);
|
|
704
|
+
window.addEventListener("keydown", key, true);
|
|
705
|
+
return () => {
|
|
706
|
+
document.removeEventListener("pointerdown", close, true);
|
|
707
|
+
window.removeEventListener("keydown", key, true);
|
|
708
|
+
};
|
|
709
|
+
}, [contextMenu]);
|
|
710
|
+
useEffect(() => {
|
|
711
|
+
const menu = menuRef.current;
|
|
712
|
+
if (!menu || !contextMenu) return;
|
|
713
|
+
const rect = menu.getBoundingClientRect();
|
|
714
|
+
menu.style.left = `${Math.max(8, Math.min(contextMenu.x, innerWidth - rect.width - 8))}px`;
|
|
715
|
+
menu.style.top = `${Math.max(8, Math.min(contextMenu.y, innerHeight - rect.height - 8))}px`;
|
|
716
|
+
menu.focus();
|
|
717
|
+
}, [contextMenu, portal]);
|
|
718
|
+
useEffect(() => {
|
|
719
|
+
const g = gesture.current;
|
|
720
|
+
if (g && (g.doc !== JSON.stringify(model) || !editable && g.kind === "node")) cancelGesture();
|
|
721
|
+
}, [model, editable]);
|
|
722
|
+
useEffect(() => {
|
|
723
|
+
var _a2, _b2;
|
|
724
|
+
if (editing) {
|
|
725
|
+
(_a2 = input.current) == null ? void 0 : _a2.focus();
|
|
726
|
+
(_b2 = input.current) == null ? void 0 : _b2.select();
|
|
727
|
+
}
|
|
728
|
+
}, [editing]);
|
|
729
|
+
useEffect(() => {
|
|
730
|
+
if (!editing) return;
|
|
731
|
+
const topic = model.topics.find((topic2) => topic2.id === editing), element = input.current;
|
|
732
|
+
if (!topic || !editable) {
|
|
733
|
+
c == null ? void 0 : c.endText(editing);
|
|
734
|
+
setEditing(null);
|
|
735
|
+
return;
|
|
736
|
+
}
|
|
737
|
+
if (composing.current || topic.text === text) return;
|
|
738
|
+
const start = (element == null ? void 0 : element.selectionStart) ?? 0, end = (element == null ? void 0 : element.selectionEnd) ?? start, diff = textDifference(text, topic.text);
|
|
739
|
+
const shift = diff.text.length - diff.to + diff.from;
|
|
740
|
+
const map = (pos) => pos <= diff.from ? pos : pos >= diff.to ? pos + shift : diff.from + diff.text.length;
|
|
741
|
+
setText(topic.text);
|
|
742
|
+
queueMicrotask(() => {
|
|
743
|
+
if (element === document.activeElement) element == null ? void 0 : element.setSelectionRange(map(start), map(end));
|
|
744
|
+
});
|
|
745
|
+
}, [model, editable, editing]);
|
|
746
|
+
useEffect(() => {
|
|
747
|
+
const element = input.current;
|
|
748
|
+
if (!editing || !element) return;
|
|
749
|
+
element.style.height = "0px";
|
|
750
|
+
element.style.height = `${Math.max(mindTopicLineHeight(current.fontSize || 14), element.scrollHeight)}px`;
|
|
751
|
+
}, [editing, text, current.fontSize]);
|
|
752
|
+
useEffect(() => {
|
|
753
|
+
const ids = new Set(drawing.nodes.map((topic) => topic.id));
|
|
754
|
+
setSelected((previous) => {
|
|
755
|
+
const next = new Set([...previous].filter((id) => ids.has(id)));
|
|
756
|
+
return next.size === previous.size ? previous : next;
|
|
757
|
+
});
|
|
758
|
+
if (!ids.has(active)) setActive(model.rootId);
|
|
759
|
+
}, [model, active, focusId, folds]);
|
|
760
|
+
const viewStateRef = useRef({ zoom, pan: origin, grid, quickControls, moving, folds, active, selected });
|
|
761
|
+
viewStateRef.current = { zoom, pan: origin, grid, quickControls, moving, folds, active, selected };
|
|
762
|
+
useEffect(() => () => {
|
|
763
|
+
const state = c == null ? void 0 : c.context.viewState;
|
|
764
|
+
if (!state) return;
|
|
765
|
+
const current2 = viewStateRef.current;
|
|
766
|
+
state.maps[model.id] = {
|
|
767
|
+
selectedId: current2.active,
|
|
768
|
+
selectedIds: [...current2.selected],
|
|
769
|
+
showGrid: current2.grid,
|
|
770
|
+
showQuickControls: current2.quickControls,
|
|
771
|
+
panMode: current2.moving,
|
|
772
|
+
collapsed: [...current2.folds],
|
|
773
|
+
viewport: { x: current2.pan.x, y: current2.pan.y, zoom: current2.zoom }
|
|
774
|
+
};
|
|
775
|
+
}, [c, model.id]);
|
|
776
|
+
const awareness = c == null ? void 0 : c.context.awareness;
|
|
777
|
+
const [peerEpoch, bumpPeers] = useState(0);
|
|
778
|
+
useEffect(() => {
|
|
779
|
+
if (!awareness) return;
|
|
780
|
+
const change = () => bumpPeers((value) => value + 1);
|
|
781
|
+
awareness.on("change", change);
|
|
782
|
+
return () => {
|
|
783
|
+
awareness.off("change", change);
|
|
784
|
+
};
|
|
785
|
+
}, [awareness]);
|
|
786
|
+
useEffect(() => {
|
|
787
|
+
var _a2;
|
|
788
|
+
const local = (_a2 = awareness == null ? void 0 : awareness.getLocalState()) == null ? void 0 : _a2.mindMap;
|
|
789
|
+
if (awareness && ((local == null ? void 0 : local.blockId) === model.id || !local)) {
|
|
790
|
+
awareness.setLocalStateField("mindMap", { blockId: model.id, topicId: active, editing: !!editing, viewport: { ...origin, zoom } });
|
|
791
|
+
}
|
|
792
|
+
}, [awareness, model.id, active, editing, origin.x, origin.y, zoom]);
|
|
793
|
+
useEffect(() => () => {
|
|
794
|
+
var _a2, _b2;
|
|
795
|
+
if (((_b2 = (_a2 = awareness == null ? void 0 : awareness.getLocalState()) == null ? void 0 : _a2.mindMap) == null ? void 0 : _b2.blockId) === model.id) awareness.setLocalStateField("mindMap", null);
|
|
796
|
+
}, [awareness, model.id]);
|
|
797
|
+
useEffect(() => {
|
|
798
|
+
var _a2;
|
|
799
|
+
if (!awareness || following === null) return;
|
|
800
|
+
const peer = (_a2 = awareness.getStates().get(following)) == null ? void 0 : _a2.mindMap;
|
|
801
|
+
if ((peer == null ? void 0 : peer.blockId) !== model.id || !peer.viewport || ![peer.viewport.x, peer.viewport.y, peer.viewport.zoom].every(Number.isFinite)) return;
|
|
802
|
+
const nextZoom = Math.min(2.5, Math.max(5e-3, peer.viewport.zoom));
|
|
803
|
+
setPan({ x: peer.viewport.x, y: peer.viewport.y });
|
|
804
|
+
setZoom(nextZoom);
|
|
805
|
+
}, [awareness, following, model.id, peerEpoch]);
|
|
806
|
+
const peers = useMemo(() => {
|
|
807
|
+
return Array.from((awareness == null ? void 0 : awareness.getStates().entries()) ?? []).flatMap(([client, state]) => {
|
|
808
|
+
var _a2, _b2;
|
|
809
|
+
const data = state.mindMap;
|
|
810
|
+
if (client === (awareness == null ? void 0 : awareness.clientID) || (data == null ? void 0 : data.blockId) !== model.id) return [];
|
|
811
|
+
return [{ client, name: String(((_a2 = state.user) == null ? void 0 : _a2.name) || ((_b2 = state.user) == null ? void 0 : _b2.displayName) || "协作者"), topicId: String(data.topicId || ""), editing: !!data.editing }];
|
|
812
|
+
});
|
|
813
|
+
}, [awareness, model.id, peerEpoch]);
|
|
814
|
+
function fit(target = viewModel) {
|
|
815
|
+
var _a2, _b2;
|
|
816
|
+
const bounds = layoutMindMap(target, normalizeMindFolds(target, folds)).bounds;
|
|
817
|
+
const width = ((_a2 = stage.current) == null ? void 0 : _a2.clientWidth) ?? size.width, height = ((_b2 = stage.current) == null ? void 0 : _b2.clientHeight) ?? size.height;
|
|
818
|
+
const nextZoom = Math.min(1.15, Math.max(5e-3, Math.min((width - 110) / bounds.width, (height - 150) / bounds.height)));
|
|
819
|
+
setZoom(nextZoom);
|
|
820
|
+
setPan({ x: width / 2 - (bounds.x + bounds.width / 2) * nextZoom, y: height / 2 - (bounds.y + bounds.height / 2) * nextZoom });
|
|
821
|
+
}
|
|
822
|
+
const autoFitted = useRef(false);
|
|
823
|
+
const lastLayout = useRef(model.layout), lastPanels = useRef({ details, comments, outline });
|
|
824
|
+
useEffect(() => {
|
|
825
|
+
const panels = lastPanels.current;
|
|
826
|
+
if (autoFitted.current && (lastLayout.current !== model.layout || panels.details !== details || panels.comments !== comments || panels.outline !== outline) && following === null) fit();
|
|
827
|
+
lastLayout.current = model.layout;
|
|
828
|
+
lastPanels.current = { details, comments, outline };
|
|
829
|
+
}, [model.layout, details, comments, outline, size.width, size.height]);
|
|
830
|
+
useEffect(() => {
|
|
831
|
+
if (autoFitted.current) return;
|
|
832
|
+
if (!size.width || !size.height || !stage.current) return;
|
|
833
|
+
autoFitted.current = true;
|
|
834
|
+
if (saved == null ? void 0 : saved.viewport) {
|
|
835
|
+
setPan({ x: saved.viewport.x, y: saved.viewport.y });
|
|
836
|
+
} else fit();
|
|
837
|
+
}, [size.width, size.height]);
|
|
838
|
+
const point = (x, y) => {
|
|
839
|
+
const rect = stage.current.getBoundingClientRect();
|
|
840
|
+
return { x: (x - rect.left - origin.x) / zoom, y: (y - rect.top - origin.y) / zoom };
|
|
841
|
+
};
|
|
842
|
+
function select(id, additive = false) {
|
|
843
|
+
var _a2;
|
|
844
|
+
const next = selectMindTopic(selected, id, additive);
|
|
845
|
+
setFollowing(null);
|
|
846
|
+
setSelected(next);
|
|
847
|
+
setActive(next.has(id) ? id : [...next].at(-1) ?? model.rootId);
|
|
848
|
+
(_a2 = stage.current) == null ? void 0 : _a2.focus();
|
|
849
|
+
}
|
|
850
|
+
function locateHit(hit) {
|
|
851
|
+
locate(hit.id);
|
|
852
|
+
if (hit.field !== "title") {
|
|
853
|
+
setDetails(true);
|
|
854
|
+
setComments(false);
|
|
855
|
+
}
|
|
856
|
+
}
|
|
857
|
+
function locate(id) {
|
|
858
|
+
const live = (c == null ? void 0 : c.snapshot()) ?? model;
|
|
859
|
+
if (!live.topics.some((topic2) => topic2.id === id)) return;
|
|
860
|
+
const next = new Set(folds);
|
|
861
|
+
for (const ancestor of ancestorIds(live, id)) next.delete(ancestor);
|
|
862
|
+
const drawing2 = layoutMindMap(live, next), topic = drawing2.nodes.find((topic2) => topic2.id === id);
|
|
863
|
+
setFolds(next);
|
|
864
|
+
setFocusId(null);
|
|
865
|
+
select(id);
|
|
866
|
+
if (topic) setPan({ x: size.width / 2 - (topic.x + topic.width / 2) * zoom, y: size.height / 2 - (topic.y + topic.height / 2) * zoom });
|
|
867
|
+
}
|
|
868
|
+
useEffect(() => {
|
|
869
|
+
setSelectedRange({ from: 0, to: 0 });
|
|
870
|
+
}, [active]);
|
|
871
|
+
useEffect(() => {
|
|
872
|
+
if (!host.location) return;
|
|
873
|
+
const linked = () => {
|
|
874
|
+
const params = new URLSearchParams(host.location.current().replace(/^#/, ""));
|
|
875
|
+
const id = params.get("topic");
|
|
876
|
+
if (params.get("mind") === model.id && id) locate(id);
|
|
877
|
+
};
|
|
878
|
+
linked();
|
|
879
|
+
return host.location.subscribe(linked);
|
|
880
|
+
}, [host.location, model.id]);
|
|
881
|
+
function jumpHit(delta) {
|
|
882
|
+
if (!hits.length) return;
|
|
883
|
+
const next = (hitIndex + delta + hits.length) % hits.length;
|
|
884
|
+
setHitIndex(next);
|
|
885
|
+
locateHit(hits[next]);
|
|
886
|
+
}
|
|
887
|
+
function edit(id) {
|
|
888
|
+
if (id && editable) {
|
|
889
|
+
const topic = model.topics.find((topic2) => topic2.id === id);
|
|
890
|
+
if (!topic) return;
|
|
891
|
+
setActive(id);
|
|
892
|
+
setSelected(/* @__PURE__ */ new Set([id]));
|
|
893
|
+
c == null ? void 0 : c.beginText(id);
|
|
894
|
+
setText(topic.text);
|
|
895
|
+
setEditing(id);
|
|
896
|
+
} else {
|
|
897
|
+
if (editing) c == null ? void 0 : c.endText(editing);
|
|
898
|
+
setEditing(null);
|
|
899
|
+
queueMicrotask(() => {
|
|
900
|
+
var _a2;
|
|
901
|
+
return (_a2 = stage.current) == null ? void 0 : _a2.focus();
|
|
902
|
+
});
|
|
903
|
+
}
|
|
904
|
+
}
|
|
905
|
+
function add(kind, side, targetId = active) {
|
|
906
|
+
if (!c || !editable) return;
|
|
907
|
+
if (model.topics.length >= MIND_MAP_MAX_TOPICS) {
|
|
908
|
+
setNotice("单张导图最多支持 500 个主题。");
|
|
909
|
+
return;
|
|
910
|
+
}
|
|
911
|
+
const id = kind === "parent" ? c.addParent(targetId) : side !== void 0 && targetId === model.rootId ? c.addRootChild(side) : kind === "sibling" ? c.addSibling(targetId, "after") : c.add(targetId);
|
|
912
|
+
if (id) {
|
|
913
|
+
setFolds((previous) => {
|
|
914
|
+
const next = new Set(previous);
|
|
915
|
+
next.delete(targetId);
|
|
916
|
+
return next;
|
|
917
|
+
});
|
|
918
|
+
setSelected(/* @__PURE__ */ new Set([id]));
|
|
919
|
+
setActive(id);
|
|
920
|
+
c.beginText(id);
|
|
921
|
+
setText("新主题");
|
|
922
|
+
setEditing(id);
|
|
923
|
+
}
|
|
924
|
+
}
|
|
925
|
+
function addSiblingAt(id, placement) {
|
|
926
|
+
if (!c || !editable) return;
|
|
927
|
+
if (model.topics.length >= MIND_MAP_MAX_TOPICS) {
|
|
928
|
+
setNotice("单张导图最多支持 500 个主题。");
|
|
929
|
+
return;
|
|
930
|
+
}
|
|
931
|
+
const next = c.addSibling(id, placement);
|
|
932
|
+
if (next) {
|
|
933
|
+
setFolds((previous) => {
|
|
934
|
+
const nextFolds = new Set(previous);
|
|
935
|
+
nextFolds.delete(id);
|
|
936
|
+
return nextFolds;
|
|
937
|
+
});
|
|
938
|
+
setSelected(/* @__PURE__ */ new Set([next]));
|
|
939
|
+
setActive(next);
|
|
940
|
+
c.beginText(next);
|
|
941
|
+
setText("新主题");
|
|
942
|
+
setEditing(next);
|
|
943
|
+
}
|
|
944
|
+
}
|
|
945
|
+
function remove(targetId = active, targetSelection = selected) {
|
|
946
|
+
if (!c || !editable) return;
|
|
947
|
+
const plan = planMindTopicDeletion(model, targetSelection, targetId);
|
|
948
|
+
if (!plan) return;
|
|
949
|
+
deletionSelection.current = [...targetSelection];
|
|
950
|
+
deletionActive.current = targetId;
|
|
951
|
+
if (plan.ids.size > plan.roots.length) setConfirmDelete(plan);
|
|
952
|
+
else performDelete(plan, targetId);
|
|
953
|
+
}
|
|
954
|
+
function performDelete(plan, targetId = deletionActive.current) {
|
|
955
|
+
const next = planMindTopicDeletion((c == null ? void 0 : c.snapshot()) ?? model, deletionSelection.current, targetId);
|
|
956
|
+
if (!next || next.ids.size !== plan.ids.size || [...next.ids].some((id) => !plan.ids.has(id)) || !(c == null ? void 0 : c.removeMany(deletionSelection.current))) {
|
|
957
|
+
setNotice("主题或权限已变化,请重新选择");
|
|
958
|
+
return;
|
|
959
|
+
}
|
|
960
|
+
setSelected(/* @__PURE__ */ new Set([next.nextId]));
|
|
961
|
+
setActive(next.nextId);
|
|
962
|
+
setEditing(null);
|
|
963
|
+
setConfirmDelete(null);
|
|
964
|
+
setNotice(`已删除 ${plan.ids.size} 个主题,可撤销。`);
|
|
965
|
+
queueMicrotask(() => {
|
|
966
|
+
var _a2;
|
|
967
|
+
return (_a2 = stage.current) == null ? void 0 : _a2.focus();
|
|
968
|
+
});
|
|
969
|
+
}
|
|
970
|
+
function fold(id) {
|
|
971
|
+
if (!mindMapDescendants$1(model, id).size || id === model.rootId) return;
|
|
972
|
+
setFolds((previous) => {
|
|
973
|
+
const next = new Set(previous);
|
|
974
|
+
if (next.has(id)) next.delete(id);
|
|
975
|
+
else next.add(id);
|
|
976
|
+
return next;
|
|
977
|
+
});
|
|
978
|
+
}
|
|
979
|
+
function copy(targetId = active) {
|
|
980
|
+
var _a2;
|
|
981
|
+
if (!c) return;
|
|
982
|
+
copied.current = c.copyBranch(targetId);
|
|
983
|
+
setNotice("分支已复制,选择目标主题后粘贴。");
|
|
984
|
+
if (canExport) void ((_a2 = navigator.clipboard) == null ? void 0 : _a2.writeText(`YWIKI_MINDMAP_BRANCH_V1
|
|
985
|
+
${JSON.stringify(copied.current)}`).catch(() => {
|
|
986
|
+
}));
|
|
987
|
+
}
|
|
988
|
+
async function materializeImages(source) {
|
|
989
|
+
var _a2, _b2;
|
|
990
|
+
const prepared = structuredClone(source);
|
|
991
|
+
const known = new Set(model.topics.flatMap((topic) => topic.attachmentId ? [topic.attachmentId] : []));
|
|
992
|
+
const clones = /* @__PURE__ */ new Map();
|
|
993
|
+
for (const node of prepared) {
|
|
994
|
+
const id = (_a2 = node.attrs) == null ? void 0 : _a2.attachmentId;
|
|
995
|
+
if (typeof id !== "string" || !id || known.has(id)) continue;
|
|
996
|
+
if (!(c == null ? void 0 : c.context.uploadImage)) throw new Error("当前文档不支持图片复制,请移除图片后导入");
|
|
997
|
+
if (!clones.has(id)) {
|
|
998
|
+
const fetcher = c.context.fetchAttachment ?? props.fetchAttachment ?? ((_b2 = host.attachments) == null ? void 0 : _b2.fetch);
|
|
999
|
+
if (!fetcher) throw new Error("当前文档未配置图片读取服务");
|
|
1000
|
+
const blob = await fetcher(id);
|
|
1001
|
+
const uploaded = await c.context.uploadImage(new File([blob], "导图主题图片.png", { type: blob.type || "image/png" }));
|
|
1002
|
+
clones.set(id, uploaded.id);
|
|
1003
|
+
}
|
|
1004
|
+
node.attrs.attachmentId = clones.get(id);
|
|
1005
|
+
}
|
|
1006
|
+
return prepared;
|
|
1007
|
+
}
|
|
1008
|
+
async function paste(targetId = active) {
|
|
1009
|
+
if (!editable || !c || pastingRef.current) return;
|
|
1010
|
+
pastingRef.current = true;
|
|
1011
|
+
setPasting(true);
|
|
1012
|
+
try {
|
|
1013
|
+
let value = copied.current;
|
|
1014
|
+
if (canExport) try {
|
|
1015
|
+
const raw = await Promise.race([navigator.clipboard.readText(), new Promise((_, reject) => setTimeout(() => reject(new Error("剪贴板读取超时")), 1500))]);
|
|
1016
|
+
if (raw.length < 2e6 && raw.startsWith("YWIKI_MINDMAP_BRANCH_V1\n")) value = parseMindBranch(raw);
|
|
1017
|
+
} catch {
|
|
1018
|
+
}
|
|
1019
|
+
await insertBranch(value, targetId);
|
|
1020
|
+
} catch (error) {
|
|
1021
|
+
if (alive.current) setNotice(error instanceof Error ? error.message : "图片复制失败");
|
|
1022
|
+
} finally {
|
|
1023
|
+
pastingRef.current = false;
|
|
1024
|
+
if (alive.current) setPasting(false);
|
|
1025
|
+
}
|
|
1026
|
+
}
|
|
1027
|
+
async function insertBranch(value, targetId) {
|
|
1028
|
+
var _a2;
|
|
1029
|
+
if (value.filter((node) => node.type === "mindMapTopic").length + model.topics.length > MIND_MAP_MAX_TOPICS) throw new Error("粘贴后主题超过 500 个,本次未修改");
|
|
1030
|
+
const prepared = await materializeImages(value), live = currentRef.current;
|
|
1031
|
+
if (!alive.current || live.c !== c || !live.editable || live.model.id !== model.id) return;
|
|
1032
|
+
if (!((_a2 = c == null ? void 0 : c.snapshot()) == null ? void 0 : _a2.topics.some((topic) => topic.id === targetId))) throw new Error("目标主题已移除,请重新选择");
|
|
1033
|
+
const id = c.pasteBranch(targetId, prepared);
|
|
1034
|
+
if (!id) throw new Error("没有可粘贴的分支,或主题容量超过上限");
|
|
1035
|
+
setNotice("已粘贴分支。");
|
|
1036
|
+
setFolds((previous) => {
|
|
1037
|
+
const next = new Set(previous);
|
|
1038
|
+
next.delete(targetId);
|
|
1039
|
+
return next;
|
|
1040
|
+
});
|
|
1041
|
+
locate(id);
|
|
1042
|
+
}
|
|
1043
|
+
async function nativePaste(event) {
|
|
1044
|
+
var _a2;
|
|
1045
|
+
if (!editable || event.target.closest('input,textarea,[contenteditable="true"]')) return;
|
|
1046
|
+
const raw = ((_a2 = event.clipboardData) == null ? void 0 : _a2.getData("text/plain")) ?? "";
|
|
1047
|
+
if (!raw.startsWith("YWIKI_MINDMAP_BRANCH_V1\n")) return;
|
|
1048
|
+
event.preventDefault();
|
|
1049
|
+
event.stopPropagation();
|
|
1050
|
+
try {
|
|
1051
|
+
if (pastingRef.current) return;
|
|
1052
|
+
pastingRef.current = true;
|
|
1053
|
+
setPasting(true);
|
|
1054
|
+
await insertBranch(parseMindBranch(raw), active);
|
|
1055
|
+
} catch (error) {
|
|
1056
|
+
setNotice(error instanceof Error ? error.message : "分支格式无效");
|
|
1057
|
+
} finally {
|
|
1058
|
+
pastingRef.current = false;
|
|
1059
|
+
if (alive.current) setPasting(false);
|
|
1060
|
+
}
|
|
1061
|
+
}
|
|
1062
|
+
function moveSide(side, targetId = active) {
|
|
1063
|
+
var _a2;
|
|
1064
|
+
if (c == null ? void 0 : c.moveToSide(targetId, side)) {
|
|
1065
|
+
setNotice(`已移到${side === -1 ? "左" : "右"}侧`);
|
|
1066
|
+
(_a2 = stage.current) == null ? void 0 : _a2.focus();
|
|
1067
|
+
}
|
|
1068
|
+
}
|
|
1069
|
+
function openContextMenu(id, event) {
|
|
1070
|
+
event.preventDefault();
|
|
1071
|
+
event.stopPropagation();
|
|
1072
|
+
if (id) select(id);
|
|
1073
|
+
setContextMenu({ id, x: event.clientX, y: event.clientY });
|
|
1074
|
+
}
|
|
1075
|
+
function menuKeydown(event) {
|
|
1076
|
+
var _a2, _b2;
|
|
1077
|
+
const items = Array.from(((_a2 = menuRef.current) == null ? void 0 : _a2.querySelectorAll('[role="menuitem"]:not([aria-disabled="true"])')) ?? []);
|
|
1078
|
+
if (!items.length || !["ArrowDown", "ArrowUp", "Home", "End"].includes(event.key)) return;
|
|
1079
|
+
event.preventDefault();
|
|
1080
|
+
event.stopPropagation();
|
|
1081
|
+
const index = items.indexOf(document.activeElement);
|
|
1082
|
+
(_b2 = items[event.key === "Home" ? 0 : event.key === "End" ? items.length - 1 : index < 0 ? event.key === "ArrowUp" ? items.length - 1 : 0 : (index + (event.key === "ArrowUp" ? -1 : 1) + items.length) % items.length]) == null ? void 0 : _b2.focus();
|
|
1083
|
+
}
|
|
1084
|
+
function contextAction(action) {
|
|
1085
|
+
const id = (contextMenu == null ? void 0 : contextMenu.id) ?? active;
|
|
1086
|
+
setContextMenu(null);
|
|
1087
|
+
if (!id) return;
|
|
1088
|
+
setActive(id);
|
|
1089
|
+
if (action === "child" || action === "sibling" || action === "parent") add(action, void 0, id);
|
|
1090
|
+
else if (action === "rename") edit(id);
|
|
1091
|
+
else if (action === "properties") {
|
|
1092
|
+
setDetails(true);
|
|
1093
|
+
setComments(false);
|
|
1094
|
+
} else if (action === "fold") fold(id);
|
|
1095
|
+
else if (action === "focus") {
|
|
1096
|
+
setFocusId(id);
|
|
1097
|
+
fit(branchModel(model, id));
|
|
1098
|
+
} else if (action === "left") moveSide(-1, id);
|
|
1099
|
+
else if (action === "right") moveSide(1, id);
|
|
1100
|
+
else if (action === "copy") copy(id);
|
|
1101
|
+
else if (action === "paste") void paste((contextMenu == null ? void 0 : contextMenu.id) ? id : selected.size === 1 ? active : viewModel.rootId);
|
|
1102
|
+
else if (action === "delete") remove(id, /* @__PURE__ */ new Set([id]));
|
|
1103
|
+
else paneCommand(action);
|
|
1104
|
+
}
|
|
1105
|
+
function paneCommand(action) {
|
|
1106
|
+
var _a2;
|
|
1107
|
+
setFollowing(null);
|
|
1108
|
+
if (action === "quick") setQuickControls((value) => !value);
|
|
1109
|
+
else if (action === "grid") setGrid((value) => !value);
|
|
1110
|
+
else if (action === "comments") {
|
|
1111
|
+
setComments((value) => !value);
|
|
1112
|
+
setDetails(false);
|
|
1113
|
+
} else if (action === "zoom-in") zoomTo(zoom * 1.2);
|
|
1114
|
+
else if (action === "zoom-out") zoomTo(zoom / 1.2);
|
|
1115
|
+
else if (action === "reset-zoom") zoomTo(1);
|
|
1116
|
+
else if (action === "fit") fit();
|
|
1117
|
+
(_a2 = stage.current) == null ? void 0 : _a2.focus();
|
|
1118
|
+
}
|
|
1119
|
+
function followPeer(client) {
|
|
1120
|
+
cancelGesture();
|
|
1121
|
+
edit(null);
|
|
1122
|
+
setFollowing(client);
|
|
1123
|
+
}
|
|
1124
|
+
function zoomTo(value, at = { x: size.width / 2, y: size.height / 2 }) {
|
|
1125
|
+
const next = Math.max(5e-3, Math.min(2.5, value)), ratio = next / zoom;
|
|
1126
|
+
const x = at.x - (at.x - origin.x) * ratio, y = at.y - (at.y - origin.y) * ratio;
|
|
1127
|
+
setZoom(next);
|
|
1128
|
+
setPan({ x, y });
|
|
1129
|
+
}
|
|
1130
|
+
async function copyTopicLink() {
|
|
1131
|
+
var _a2, _b2;
|
|
1132
|
+
const link = (_b2 = (_a2 = host.location) == null ? void 0 : _a2.createLink) == null ? void 0 : _b2.call(_a2, { blockId: model.id, topicId: active });
|
|
1133
|
+
if (!link) {
|
|
1134
|
+
setNotice("宿主未提供主题定位链接");
|
|
1135
|
+
return;
|
|
1136
|
+
}
|
|
1137
|
+
try {
|
|
1138
|
+
await navigator.clipboard.writeText(link);
|
|
1139
|
+
setNotice("已复制主题定位链接");
|
|
1140
|
+
} catch {
|
|
1141
|
+
setNotice(link);
|
|
1142
|
+
}
|
|
1143
|
+
}
|
|
1144
|
+
function keydown(event) {
|
|
1145
|
+
var _a2, _b2, _c2, _d2;
|
|
1146
|
+
if (!((_a2 = root.current) == null ? void 0 : _a2.contains(event.target)) || event.defaultPrevented || event.nativeEvent.isComposing || event.keyCode === 229 || event.target.closest("input,textarea,[contenteditable=true]")) return;
|
|
1147
|
+
const command = event.ctrlKey || event.metaKey;
|
|
1148
|
+
const view = mindCanvasShortcut(event);
|
|
1149
|
+
if (event.target.closest("button,select,[role=combobox]") && !view && !command) return;
|
|
1150
|
+
if (event.code === "Space") {
|
|
1151
|
+
event.preventDefault();
|
|
1152
|
+
space.current = true;
|
|
1153
|
+
setSpaceHeld(true);
|
|
1154
|
+
return;
|
|
1155
|
+
}
|
|
1156
|
+
if (event.key === "Escape") {
|
|
1157
|
+
if (!props.inline && !details && !comments && !showSearch) return;
|
|
1158
|
+
event.preventDefault();
|
|
1159
|
+
event.stopPropagation();
|
|
1160
|
+
cancelGesture();
|
|
1161
|
+
setContextMenu(null);
|
|
1162
|
+
setSelected(/* @__PURE__ */ new Set());
|
|
1163
|
+
setDetails(false);
|
|
1164
|
+
setComments(false);
|
|
1165
|
+
setShowSearch(false);
|
|
1166
|
+
return;
|
|
1167
|
+
}
|
|
1168
|
+
if (command && event.key.toLowerCase() === "z" && editable) {
|
|
1169
|
+
event.preventDefault();
|
|
1170
|
+
event.shiftKey ? c == null ? void 0 : c.redo() : c == null ? void 0 : c.undo();
|
|
1171
|
+
return;
|
|
1172
|
+
}
|
|
1173
|
+
if (command && event.key.toLowerCase() === "y" && editable) {
|
|
1174
|
+
event.preventDefault();
|
|
1175
|
+
c == null ? void 0 : c.redo();
|
|
1176
|
+
return;
|
|
1177
|
+
}
|
|
1178
|
+
if (command && event.key.toLowerCase() === "f") {
|
|
1179
|
+
event.preventDefault();
|
|
1180
|
+
setShowSearch(true);
|
|
1181
|
+
return;
|
|
1182
|
+
}
|
|
1183
|
+
if (command && event.key.toLowerCase() === "c" && editable && selected.size === 1) {
|
|
1184
|
+
event.preventDefault();
|
|
1185
|
+
copy();
|
|
1186
|
+
return;
|
|
1187
|
+
}
|
|
1188
|
+
if (command && event.key.toLowerCase() === "v" && editable) {
|
|
1189
|
+
event.preventDefault();
|
|
1190
|
+
void paste();
|
|
1191
|
+
return;
|
|
1192
|
+
}
|
|
1193
|
+
if ((command || event.altKey) && event.key === ".") {
|
|
1194
|
+
event.preventDefault();
|
|
1195
|
+
fold(active);
|
|
1196
|
+
return;
|
|
1197
|
+
}
|
|
1198
|
+
if (view) {
|
|
1199
|
+
event.preventDefault();
|
|
1200
|
+
paneCommand(view);
|
|
1201
|
+
return;
|
|
1202
|
+
}
|
|
1203
|
+
if ((event.key === "Delete" || event.key === "Backspace") && editable && !command && !event.altKey && selected.size) {
|
|
1204
|
+
event.preventDefault();
|
|
1205
|
+
if (!event.repeat) remove();
|
|
1206
|
+
return;
|
|
1207
|
+
}
|
|
1208
|
+
if (!editable || selected.size !== 1) return;
|
|
1209
|
+
if (event.key === "Tab") {
|
|
1210
|
+
event.preventDefault();
|
|
1211
|
+
add(event.shiftKey ? "parent" : "child");
|
|
1212
|
+
} else if (event.key === "Enter") {
|
|
1213
|
+
event.preventDefault();
|
|
1214
|
+
add("sibling");
|
|
1215
|
+
} else if (event.key === "F2") {
|
|
1216
|
+
event.preventDefault();
|
|
1217
|
+
edit(active);
|
|
1218
|
+
} else if (event.altKey && ["ArrowUp", "ArrowDown"].includes(event.key)) {
|
|
1219
|
+
const siblings = tree.filter((topic) => topic.parentId === current.parentId), index = siblings.findIndex((topic) => topic.id === active), target = siblings[index + (event.key === "ArrowUp" ? -1 : 1)];
|
|
1220
|
+
if (target) c == null ? void 0 : c.move(active, target.id, event.key === "ArrowUp" ? "before" : "after");
|
|
1221
|
+
event.preventDefault();
|
|
1222
|
+
} else if (event.key.startsWith("Arrow")) {
|
|
1223
|
+
event.preventDefault();
|
|
1224
|
+
const branchSide = ((_b2 = drawing.nodes.find((topic) => topic.id === active)) == null ? void 0 : _b2.side) ?? 1;
|
|
1225
|
+
const inward = model.layout === "down" ? "ArrowUp" : branchSide === 1 ? "ArrowLeft" : "ArrowRight";
|
|
1226
|
+
const outward = model.layout === "down" ? "ArrowDown" : branchSide === 1 ? "ArrowRight" : "ArrowLeft";
|
|
1227
|
+
const siblings = drawing.nodes.filter((topic) => topic.parentId === current.parentId), index = siblings.findIndex((topic) => topic.id === active);
|
|
1228
|
+
const target = event.key === inward ? current.parentId : event.key === outward ? (_c2 = drawing.nodes.find((topic) => topic.parentId === active)) == null ? void 0 : _c2.id : (_d2 = siblings[index + (event.key === "ArrowUp" || event.key === "ArrowLeft" ? -1 : 1)]) == null ? void 0 : _d2.id;
|
|
1229
|
+
if (target) select(target);
|
|
1230
|
+
}
|
|
1231
|
+
}
|
|
1232
|
+
function cancelGesture(restore = true) {
|
|
1233
|
+
const current2 = gesture.current;
|
|
1234
|
+
if (restore && (current2 == null ? void 0 : current2.kind) === "box") {
|
|
1235
|
+
setSelected(current2.selected);
|
|
1236
|
+
setActive(current2.active);
|
|
1237
|
+
}
|
|
1238
|
+
gesture.current = null;
|
|
1239
|
+
setBox(null);
|
|
1240
|
+
setDrop(null);
|
|
1241
|
+
setDragPreview(null);
|
|
1242
|
+
}
|
|
1243
|
+
function pointerDown(event, id) {
|
|
1244
|
+
var _a2, _b2, _c2;
|
|
1245
|
+
if (!((_a2 = stage.current) == null ? void 0 : _a2.contains(event.target))) return;
|
|
1246
|
+
if (event.target.closest("button,input,textarea,a")) return;
|
|
1247
|
+
setFollowing(null);
|
|
1248
|
+
setContextMenu(null);
|
|
1249
|
+
const base = { x: event.clientX, y: event.clientY, lastX: event.clientX, lastY: event.clientY, doc: JSON.stringify(model), count: selected.size, selected: new Set(selected), active };
|
|
1250
|
+
if (id && event.button === 0 && !moving && !space.current) {
|
|
1251
|
+
const additive = event.shiftKey || event.metaKey || event.ctrlKey;
|
|
1252
|
+
const next = selected.has(id) && selected.size > 1 && !additive ? selected : selectMindTopic(selected, id, additive);
|
|
1253
|
+
setSelected(next);
|
|
1254
|
+
setActive(next.has(id) ? id : [...next].at(-1) ?? model.rootId);
|
|
1255
|
+
gesture.current = { ...base, kind: "node", id, count: next.size, additive };
|
|
1256
|
+
} else if (event.button === 1 || event.button === 0 && (moving || space.current)) gesture.current = { ...base, kind: "pan" };
|
|
1257
|
+
else if (!id && event.button === 0) {
|
|
1258
|
+
gesture.current = { ...base, kind: "box", additive: event.shiftKey || event.metaKey || event.ctrlKey };
|
|
1259
|
+
if (!gesture.current.additive) setSelected(/* @__PURE__ */ new Set());
|
|
1260
|
+
} else return;
|
|
1261
|
+
(_b2 = stage.current) == null ? void 0 : _b2.setPointerCapture(event.pointerId);
|
|
1262
|
+
(_c2 = stage.current) == null ? void 0 : _c2.focus();
|
|
1263
|
+
event.preventDefault();
|
|
1264
|
+
}
|
|
1265
|
+
function pointerMove(event) {
|
|
1266
|
+
const g = gesture.current;
|
|
1267
|
+
if (!g) return;
|
|
1268
|
+
if (g.doc !== JSON.stringify(currentRef.current.model)) {
|
|
1269
|
+
cancelGesture();
|
|
1270
|
+
return;
|
|
1271
|
+
}
|
|
1272
|
+
if (g.kind === "pan") setPan((previous) => ({ x: previous.x + event.clientX - g.lastX, y: previous.y + event.clientY - g.lastY }));
|
|
1273
|
+
else if (g.kind === "box") {
|
|
1274
|
+
const from = point(g.x, g.y), to = point(event.clientX, event.clientY);
|
|
1275
|
+
g.box = { x: Math.min(from.x, to.x), y: Math.min(from.y, to.y), w: Math.abs(to.x - from.x), h: Math.abs(to.y - from.y) };
|
|
1276
|
+
setBox(g.box);
|
|
1277
|
+
setSelected(topicsInMarquee(drawing.nodes, { x: g.box.x, y: g.box.y, width: g.box.w, height: g.box.h }, g.additive ? g.selected : []));
|
|
1278
|
+
} else if (editable && g.id && g.id !== model.rootId && g.count === 1 && Math.hypot(event.clientX - g.x, event.clientY - g.y) > 8) {
|
|
1279
|
+
g.drop = mindMapDrop(viewModel, drawing, g.id, point(event.clientX, event.clientY), !focusId);
|
|
1280
|
+
setDrop(g.drop);
|
|
1281
|
+
setDragPreview({ id: g.id, dx: (event.clientX - g.x) / zoom, dy: (event.clientY - g.y) / zoom });
|
|
1282
|
+
}
|
|
1283
|
+
g.lastX = event.clientX;
|
|
1284
|
+
g.lastY = event.clientY;
|
|
1285
|
+
}
|
|
1286
|
+
function pointerUp() {
|
|
1287
|
+
const g = gesture.current;
|
|
1288
|
+
if (!g) return;
|
|
1289
|
+
cancelGesture(false);
|
|
1290
|
+
if (g.doc !== JSON.stringify(currentRef.current.model)) return;
|
|
1291
|
+
const bounds = g.box;
|
|
1292
|
+
if (g.kind === "box" && bounds) {
|
|
1293
|
+
const ids = topicsInMarquee(drawing.nodes, { x: bounds.x, y: bounds.y, width: bounds.w, height: bounds.h }, g.additive ? g.selected : []);
|
|
1294
|
+
setSelected(ids);
|
|
1295
|
+
if (ids.size) setActive([...ids].at(-1));
|
|
1296
|
+
} else if (g.kind === "node" && g.id && g.drop && editable) {
|
|
1297
|
+
if (g.drop.kind === "side") c == null ? void 0 : c.moveToSide(g.id, g.drop.side, g.drop.beforeId);
|
|
1298
|
+
else c == null ? void 0 : c.move(g.id, g.drop.id, g.drop.mode);
|
|
1299
|
+
} else if (g.kind === "node" && g.id && g.count > 1 && !g.additive && Math.hypot(g.lastX - g.x, g.lastY - g.y) < 8) {
|
|
1300
|
+
setSelected(/* @__PURE__ */ new Set([g.id]));
|
|
1301
|
+
setActive(g.id);
|
|
1302
|
+
}
|
|
1303
|
+
}
|
|
1304
|
+
async function exportAs(kind) {
|
|
1305
|
+
var _a2, _b2;
|
|
1306
|
+
if (!canExport || exportRunning.current) return;
|
|
1307
|
+
exportRunning.current = true;
|
|
1308
|
+
setBusy(true);
|
|
1309
|
+
const target = exportBranch ? branchModel(model, active) : model;
|
|
1310
|
+
const printWindow = kind === "print" ? window.open("", "_blank") : null;
|
|
1311
|
+
try {
|
|
1312
|
+
if (kind === "copy") {
|
|
1313
|
+
await navigator.clipboard.writeText(mindMapMarkdown(target));
|
|
1314
|
+
return;
|
|
1315
|
+
}
|
|
1316
|
+
const images = {};
|
|
1317
|
+
for (const topic of target.topics) if (topic.attachmentId) {
|
|
1318
|
+
const fetcher = props.fetchAttachment ?? (c == null ? void 0 : c.context.fetchAttachment) ?? ((_a2 = host.attachments) == null ? void 0 : _a2.fetch);
|
|
1319
|
+
if (!fetcher) throw new Error("未配置主题图片读取服务");
|
|
1320
|
+
const blob = await fetcher(topic.attachmentId);
|
|
1321
|
+
images[topic.attachmentId] = await new Promise((resolve, reject) => {
|
|
1322
|
+
const reader = new FileReader();
|
|
1323
|
+
reader.onload = () => resolve(String(reader.result));
|
|
1324
|
+
reader.onerror = reject;
|
|
1325
|
+
reader.readAsDataURL(blob);
|
|
1326
|
+
});
|
|
1327
|
+
}
|
|
1328
|
+
const svg = mindMapSvg(target, { transparent, images }), download = (blob, ext) => {
|
|
1329
|
+
const url = URL.createObjectURL(blob), a = document.createElement("a");
|
|
1330
|
+
a.href = url;
|
|
1331
|
+
a.download = `思维导图.${ext}`;
|
|
1332
|
+
a.click();
|
|
1333
|
+
setTimeout(() => URL.revokeObjectURL(url), 1e3);
|
|
1334
|
+
};
|
|
1335
|
+
if (kind === "svg") download(new Blob([svg], { type: "image/svg+xml" }), "svg");
|
|
1336
|
+
else if (kind === "md") download(new Blob([mindMapMarkdown(target)], { type: "text/markdown" }), "md");
|
|
1337
|
+
else if (kind === "json") download(new Blob([JSON.stringify(mindMapToJson(target), null, 2)], { type: "application/json" }), "json");
|
|
1338
|
+
else if (kind === "png" || kind === "copy-image" || kind === "print") {
|
|
1339
|
+
const image = new Image(), url = URL.createObjectURL(new Blob([svg], { type: "image/svg+xml" }));
|
|
1340
|
+
try {
|
|
1341
|
+
await new Promise((resolve, reject) => {
|
|
1342
|
+
image.onload = () => resolve();
|
|
1343
|
+
image.onerror = reject;
|
|
1344
|
+
image.src = url;
|
|
1345
|
+
});
|
|
1346
|
+
const canvas = document.createElement("canvas");
|
|
1347
|
+
canvas.width = image.width * imageScale;
|
|
1348
|
+
canvas.height = image.height * imageScale;
|
|
1349
|
+
(_b2 = canvas.getContext("2d")) == null ? void 0 : _b2.drawImage(image, 0, 0, canvas.width, canvas.height);
|
|
1350
|
+
const blob = await new Promise((resolve, reject) => canvas.toBlob((value) => value ? resolve(value) : reject(new Error("图片生成失败"))));
|
|
1351
|
+
if (kind === "copy-image") await navigator.clipboard.write([new ClipboardItem({ "image/png": blob })]);
|
|
1352
|
+
else if (kind === "print") {
|
|
1353
|
+
if (!printWindow) throw new Error("打印窗口被浏览器拦截");
|
|
1354
|
+
const img = printWindow.document.createElement("img");
|
|
1355
|
+
img.src = canvas.toDataURL();
|
|
1356
|
+
img.style.maxWidth = "100%";
|
|
1357
|
+
printWindow.document.body.append(img);
|
|
1358
|
+
img.onload = () => printWindow.print();
|
|
1359
|
+
} else download(blob, "png");
|
|
1360
|
+
} finally {
|
|
1361
|
+
URL.revokeObjectURL(url);
|
|
1362
|
+
}
|
|
1363
|
+
}
|
|
1364
|
+
} catch (error) {
|
|
1365
|
+
printWindow == null ? void 0 : printWindow.close();
|
|
1366
|
+
setNotice(String(error));
|
|
1367
|
+
} finally {
|
|
1368
|
+
exportRunning.current = false;
|
|
1369
|
+
if (alive.current) setBusy(false);
|
|
1370
|
+
}
|
|
1371
|
+
}
|
|
1372
|
+
const directions = mindMapBranchSides(model), firstLevel = current.parentId === model.rootId;
|
|
1373
|
+
const menuTopic = tree.find((topic) => topic.id === (contextMenu == null ? void 0 : contextMenu.id));
|
|
1374
|
+
const modifier = typeof navigator !== "undefined" && /Mac|iPhone|iPad/.test(navigator.platform) ? "⌘" : "Ctrl";
|
|
1375
|
+
const contextGroups = (contextMenu == null ? void 0 : contextMenu.id) ? [{ items: [
|
|
1376
|
+
...editable ? [
|
|
1377
|
+
{ value: "child", label: "添加子主题" },
|
|
1378
|
+
{ value: "sibling", label: "添加同级主题" },
|
|
1379
|
+
...contextMenu.id !== model.rootId ? [{ value: "parent", label: "插入父主题" }] : [],
|
|
1380
|
+
{ value: "rename", label: "修改文字" }
|
|
1381
|
+
] : [],
|
|
1382
|
+
{ value: "properties", label: "主题属性" },
|
|
1383
|
+
...contextMenu.id !== model.rootId && mindMapDescendants$1(model, contextMenu.id).size > 1 ? [{ value: "fold", label: folds.has(contextMenu.id) ? "展开分支" : "收起分支" }] : [],
|
|
1384
|
+
...editable && (menuTopic == null ? void 0 : menuTopic.parentId) === model.rootId && model.layout !== "down" ? [
|
|
1385
|
+
{ value: "left", label: "移到左侧", disabled: directions.get(contextMenu.id) === -1 },
|
|
1386
|
+
{ value: "right", label: "移到右侧", disabled: directions.get(contextMenu.id) === 1 }
|
|
1387
|
+
] : [],
|
|
1388
|
+
{ value: "focus", label: "聚焦分支" },
|
|
1389
|
+
...editable ? [
|
|
1390
|
+
{ value: "copy", label: "复制分支" },
|
|
1391
|
+
{ value: "paste", label: "粘贴分支", disabled: pasting },
|
|
1392
|
+
...contextMenu.id !== model.rootId ? [{ value: "delete", label: "删除分支" }] : []
|
|
1393
|
+
] : []
|
|
1394
|
+
] }] : [
|
|
1395
|
+
...editable ? [{ items: [{ value: "paste", label: "粘贴", disabled: pasting, shortcut: "⌘ / Ctrl+V" }] }] : [],
|
|
1396
|
+
{ items: [
|
|
1397
|
+
...pageId ? [{ value: "comments", label: comments ? "隐藏评论" : "显示评论", shortcut: "Shift+C" }] : [],
|
|
1398
|
+
...editable ? [{ value: "quick", label: quickControls ? "隐藏快捷创建" : "显示快捷创建", shortcut: "Shift+Q" }] : [],
|
|
1399
|
+
{ value: "grid", label: grid ? "隐藏网格" : "显示网格", shortcut: "Shift+G" }
|
|
1400
|
+
] },
|
|
1401
|
+
{ items: [
|
|
1402
|
+
{ value: "zoom-in", label: "放大", shortcut: `${modifier} + +` },
|
|
1403
|
+
{ value: "zoom-out", label: "缩小", shortcut: `${modifier} + −` },
|
|
1404
|
+
{ value: "reset-zoom", label: "缩放至 100%", shortcut: `${modifier} + 0` },
|
|
1405
|
+
{ value: "fit", label: "画布全览", shortcut: "Shift+1" }
|
|
1406
|
+
] }
|
|
1407
|
+
];
|
|
1408
|
+
const workspace = /* @__PURE__ */ jsxs("div", { className: "mind-map-workspace", ref: root, onKeyDown: keydown, onPaste: nativePaste, style: { "--mind-color": color }, children: [
|
|
1409
|
+
editable && !status && props.showSaveHint !== false && /* @__PURE__ */ jsx(WAlert, { closable: true, closeLabel: "关闭保存提示", className: "mind-save-hint", children: "编辑完成后,请确认已保存再离开。" }),
|
|
1410
|
+
/* @__PURE__ */ jsxs("header", { className: "mind-canvas-toolbar", children: [
|
|
1411
|
+
/* @__PURE__ */ jsxs("div", { className: "mind-canvas-tools", children: [
|
|
1412
|
+
!props.inline && props.onClose && /* @__PURE__ */ jsx(WButton, { onClick: props.onClose, children: "返回文档" }),
|
|
1413
|
+
/* @__PURE__ */ jsx(
|
|
1414
|
+
WDropdown,
|
|
1415
|
+
{
|
|
1416
|
+
label: "展开与收起",
|
|
1417
|
+
groups: [{ items: [{ value: "expand", label: "全部展开" }, { value: "first-level", label: "收起至一级" }] }],
|
|
1418
|
+
onSelect: (value) => setFolds(value === "expand" ? /* @__PURE__ */ new Set() : firstLevelMindFolds(viewModel))
|
|
1419
|
+
}
|
|
1420
|
+
),
|
|
1421
|
+
/* @__PURE__ */ jsx(WButton, { ref: settingsTrigger, "aria-expanded": settingsOpen, onClick: () => setSettingsOpen(!settingsOpen), children: "视图与导出设置" }),
|
|
1422
|
+
settingsOpen && /* @__PURE__ */ jsx(AnchoredPanel, { anchor: settingsTrigger.current, onClose: () => setSettingsOpen(false), align: "center", gap: 6, label: "视图与导出设置", className: "mind-dropdown-popup", children: /* @__PURE__ */ jsxs("div", { className: "mind-settings-menu", children: [
|
|
1423
|
+
peers.map((peer) => {
|
|
1424
|
+
var _a2, _b2;
|
|
1425
|
+
return /* @__PURE__ */ jsxs("span", { className: "mind-peer", children: [
|
|
1426
|
+
/* @__PURE__ */ jsxs("span", { children: [
|
|
1427
|
+
peer.name,
|
|
1428
|
+
peer.editing ? " 正在编辑" : " 正在查看",
|
|
1429
|
+
" ",
|
|
1430
|
+
(_b2 = (_a2 = model.topics.find((topic) => topic.id === peer.topicId)) == null ? void 0 : _a2.text) == null ? void 0 : _b2.slice(0, 12)
|
|
1431
|
+
] }),
|
|
1432
|
+
/* @__PURE__ */ jsx(WButton, { variant: "text", onClick: () => followPeer(peer.client), children: "跟随" })
|
|
1433
|
+
] }, peer.client);
|
|
1434
|
+
}),
|
|
1435
|
+
following !== null && /* @__PURE__ */ jsx(WButton, { onClick: () => followPeer(null), children: "停止跟随" }),
|
|
1436
|
+
/* @__PURE__ */ jsx(WButton, { variant: "text", onClick: () => {
|
|
1437
|
+
const id = focusId ? null : active;
|
|
1438
|
+
setFocusId(id);
|
|
1439
|
+
fit(id ? branchModel(model, id) : model);
|
|
1440
|
+
}, children: focusId ? "返回全图" : "聚焦分支" }),
|
|
1441
|
+
/* @__PURE__ */ jsx(WButton, { variant: "text", onClick: () => void copyTopicLink(), children: "复制主题链接" }),
|
|
1442
|
+
editable && /* @__PURE__ */ jsx(WSelect, { label: "分支线型", ariaLabel: "分支线型", width: 95, value: model.branchStyle ?? "curve", onChange: (value) => c == null ? void 0 : c.settings({ branchStyle: value }), options: ["curve", "straight", "step"].map((value, i) => ({ value, label: ["曲线", "直线", "折线"][i] })) }),
|
|
1443
|
+
canExport && /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
1444
|
+
/* @__PURE__ */ jsxs("label", { children: [
|
|
1445
|
+
/* @__PURE__ */ jsx("input", { type: "checkbox", checked: exportBranch, onChange: (event) => setExportBranch(event.target.checked) }),
|
|
1446
|
+
"仅导出选中分支"
|
|
1447
|
+
] }),
|
|
1448
|
+
/* @__PURE__ */ jsxs("label", { children: [
|
|
1449
|
+
/* @__PURE__ */ jsx("input", { type: "checkbox", checked: transparent, onChange: (event) => setTransparent(event.target.checked) }),
|
|
1450
|
+
"透明背景"
|
|
1451
|
+
] }),
|
|
1452
|
+
/* @__PURE__ */ jsx(WSelect, { label: "图片分辨率", ariaLabel: "图片分辨率", width: 90, value: imageScale, onChange: (value) => setImageScale(Number(value)), options: [1, 2, 3].map((value) => ({ value, label: `${value} 倍图片` })) })
|
|
1453
|
+
] }),
|
|
1454
|
+
canExport && /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
1455
|
+
/* @__PURE__ */ jsx(WButton, { variant: "text", onClick: () => void exportAs("copy-image"), children: "复制图片" }),
|
|
1456
|
+
/* @__PURE__ */ jsx(WButton, { variant: "text", onClick: () => void exportAs("print"), children: "打印 / PDF" })
|
|
1457
|
+
] })
|
|
1458
|
+
] }) }),
|
|
1459
|
+
peers.length > 0 && /* @__PURE__ */ jsx(
|
|
1460
|
+
WDropdown,
|
|
1461
|
+
{
|
|
1462
|
+
label: `协作(${peers.length})`,
|
|
1463
|
+
buttonProps: { variant: "text" },
|
|
1464
|
+
groups: [{ items: peers.map((peer) => ({ value: String(peer.client), label: `${peer.name}${peer.editing ? " 正在编辑" : " 正在查看"} · 跟随` })) }],
|
|
1465
|
+
onSelect: (value) => followPeer(Number(value))
|
|
1466
|
+
}
|
|
1467
|
+
)
|
|
1468
|
+
] }),
|
|
1469
|
+
/* @__PURE__ */ jsxs("div", { className: "mind-canvas-tools mind-canvas-options", children: [
|
|
1470
|
+
status || !editable ? /* @__PURE__ */ jsx("span", { className: "mind-canvas-status", role: "status", "aria-label": "保存状态", children: status || "只读" }) : null,
|
|
1471
|
+
editable && /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
1472
|
+
/* @__PURE__ */ jsx(WSelect, { label: "导图布局", ariaLabel: "导图布局", width: 94, value: model.layout, onChange: (value) => c == null ? void 0 : c.settings({ layout: value }), options: ["right", "left", "both", "down"].map((value, i) => ({ value, label: ["向右", "向左", "双侧", "向下"][i] })) }),
|
|
1473
|
+
/* @__PURE__ */ jsx(WSelect, { label: "导图主题", ariaLabel: "导图主题", width: 94, value: model.theme, onChange: (value) => c == null ? void 0 : c.settings({ theme: value }), options: ["blue", "teal", "violet", "amber"].map((value, i) => ({ value, label: ["靛蓝", "青绿", "紫藤", "琥珀"][i] })) }),
|
|
1474
|
+
/* @__PURE__ */ jsx(WSelect, { label: "正文预览高度", ariaLabel: "正文预览高度", width: 114, value: model.height, onChange: (value) => c == null ? void 0 : c.settings({ height: Number(value) }), options: [280, 380, 520].map((value, index) => ({ value, label: ["预览 · 紧凑", "预览 · 标准", "预览 · 宽松"][index] })) })
|
|
1475
|
+
] }),
|
|
1476
|
+
/* @__PURE__ */ jsx(WButton, { onClick: () => setShowSearch(!showSearch), children: "查找替换" }),
|
|
1477
|
+
!editable && host.comments && pageId && /* @__PURE__ */ jsx(WButton, { variant: comments ? "primary" : "default", "aria-pressed": comments, onClick: () => {
|
|
1478
|
+
setComments(!comments);
|
|
1479
|
+
setDetails(false);
|
|
1480
|
+
}, children: comments ? "收起讨论" : "查看讨论" }),
|
|
1481
|
+
/* @__PURE__ */ jsx(WDropdown, { label: "更多", groups: [{ items: [
|
|
1482
|
+
{ value: "outline", label: outline ? "隐藏文字大纲" : "显示文字大纲" },
|
|
1483
|
+
{ value: "details", label: "主题属性" },
|
|
1484
|
+
...host.comments && pageId ? [{ value: "comments", label: comments ? "隐藏主题讨论" : "主题讨论" }] : [],
|
|
1485
|
+
...editable ? [{ value: "import", label: "导入" }] : []
|
|
1486
|
+
] }], onSelect: (value) => {
|
|
1487
|
+
if (value === "outline") setOutline(!outline);
|
|
1488
|
+
else if (value === "details") {
|
|
1489
|
+
setDetails(!details);
|
|
1490
|
+
setComments(false);
|
|
1491
|
+
} else if (value === "comments") {
|
|
1492
|
+
setComments(!comments);
|
|
1493
|
+
setDetails(false);
|
|
1494
|
+
} else if (value === "import") setImportOpen(true);
|
|
1495
|
+
} }),
|
|
1496
|
+
canExport && /* @__PURE__ */ jsx(
|
|
1497
|
+
WSelect,
|
|
1498
|
+
{
|
|
1499
|
+
label: "导出",
|
|
1500
|
+
ariaLabel: "导出思维导图",
|
|
1501
|
+
width: 105,
|
|
1502
|
+
value: "",
|
|
1503
|
+
disabled: busy,
|
|
1504
|
+
onChange: (value) => void exportAs(value),
|
|
1505
|
+
options: [{ value: "png", label: "PNG 图片" }, { value: "svg", label: "SVG 图片" }, { value: "md", label: "文字大纲" }, { value: "json", label: "结构 JSON" }]
|
|
1506
|
+
}
|
|
1507
|
+
)
|
|
1508
|
+
] })
|
|
1509
|
+
] }),
|
|
1510
|
+
showSearch && /* @__PURE__ */ jsxs("div", { className: "mind-search", "aria-label": "图内查找替换", children: [
|
|
1511
|
+
/* @__PURE__ */ jsx("input", { "aria-label": "查找导图文字", placeholder: "查找主题、描述和备注", value: query, onChange: (event) => {
|
|
1512
|
+
setQuery(event.target.value);
|
|
1513
|
+
setHitIndex(0);
|
|
1514
|
+
}, onKeyDown: (event) => {
|
|
1515
|
+
if (event.key === "Enter") {
|
|
1516
|
+
event.preventDefault();
|
|
1517
|
+
jumpHit(1);
|
|
1518
|
+
}
|
|
1519
|
+
} }),
|
|
1520
|
+
/* @__PURE__ */ jsxs("span", { children: [
|
|
1521
|
+
hits.length > 5e3 ? "5000+" : hits.length,
|
|
1522
|
+
" 处"
|
|
1523
|
+
] }),
|
|
1524
|
+
/* @__PURE__ */ jsx(WButton, { disabled: !hits.length, onClick: () => jumpHit(-1), children: "上一处" }),
|
|
1525
|
+
/* @__PURE__ */ jsx(WButton, { disabled: !hits.length, onClick: () => jumpHit(1), children: "下一处" }),
|
|
1526
|
+
hits.length > 0 && /* @__PURE__ */ jsx(
|
|
1527
|
+
WSelect,
|
|
1528
|
+
{
|
|
1529
|
+
label: "导图搜索结果",
|
|
1530
|
+
ariaLabel: "导图搜索结果",
|
|
1531
|
+
width: 180,
|
|
1532
|
+
value: hitIndex,
|
|
1533
|
+
options: hits.slice(0, 500).map((hit, index) => {
|
|
1534
|
+
var _a2, _b2;
|
|
1535
|
+
return { value: index, label: `${index + 1}. ${((_b2 = (_a2 = tree.find((topic) => topic.id === hit.id)) == null ? void 0 : _a2.text) == null ? void 0 : _b2.slice(0, 24)) ?? ""} · ${hit.field === "title" ? "标题" : hit.field === "note" ? "备注" : "描述"}` };
|
|
1536
|
+
}),
|
|
1537
|
+
onChange: (value) => {
|
|
1538
|
+
const index = Number(value);
|
|
1539
|
+
const hit = hits[index];
|
|
1540
|
+
if (hit) {
|
|
1541
|
+
setHitIndex(index);
|
|
1542
|
+
locateHit(hit);
|
|
1543
|
+
}
|
|
1544
|
+
}
|
|
1545
|
+
}
|
|
1546
|
+
),
|
|
1547
|
+
editable && /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
1548
|
+
/* @__PURE__ */ jsx("input", { "aria-label": "替换为", placeholder: "替换为", value: replacement, onChange: (event) => setReplacement(event.target.value) }),
|
|
1549
|
+
/* @__PURE__ */ jsx(WButton, { disabled: !hits.length, onClick: () => {
|
|
1550
|
+
const count = c == null ? void 0 : c.replace(query, replacement, hits[hitIndex]);
|
|
1551
|
+
setNotice(count === -1 ? "匹配超过 5000 处,请缩小查找范围" : count === -2 ? "替换后文字超过上限,本次未修改" : `已替换 ${count ?? 0} 处`);
|
|
1552
|
+
}, children: "替换当前" }),
|
|
1553
|
+
/* @__PURE__ */ jsx(WButton, { disabled: !hits.length, onClick: () => {
|
|
1554
|
+
const count = c == null ? void 0 : c.replace(query, replacement);
|
|
1555
|
+
setNotice(count === -1 ? "匹配超过 5000 处,请缩小查找范围" : count === -2 ? "替换后文字超过上限,本次未修改" : `已替换 ${count ?? 0} 处`);
|
|
1556
|
+
}, children: "全部替换" })
|
|
1557
|
+
] }),
|
|
1558
|
+
/* @__PURE__ */ jsx(WButton, { variant: "text", onClick: () => setShowSearch(false), children: "关闭" })
|
|
1559
|
+
] }),
|
|
1560
|
+
/* @__PURE__ */ jsxs("div", { className: "mind-canvas-body", children: [
|
|
1561
|
+
outline && /* @__PURE__ */ jsx("aside", { className: "mind-canvas-outline", "aria-label": "导图文字大纲", children: mindMapOutline(model).map((topic) => /* @__PURE__ */ jsxs("div", { className: `mind-outline-row${topic.id === active ? " current" : ""}`, style: { paddingLeft: 8 + Math.min(12, topic.depth) * 14 }, children: [
|
|
1562
|
+
editable ? /* @__PURE__ */ jsx(
|
|
1563
|
+
MindMapField,
|
|
1564
|
+
{
|
|
1565
|
+
id: topic.id,
|
|
1566
|
+
field: "title",
|
|
1567
|
+
value: topic.text,
|
|
1568
|
+
controller: c,
|
|
1569
|
+
label: `大纲主题 ${topic.text || "未命名"}`,
|
|
1570
|
+
onFocus: () => {
|
|
1571
|
+
setActive(topic.id);
|
|
1572
|
+
setSelected(/* @__PURE__ */ new Set([topic.id]));
|
|
1573
|
+
},
|
|
1574
|
+
onCommand: (event) => {
|
|
1575
|
+
if (event.key === "Tab") {
|
|
1576
|
+
event.preventDefault();
|
|
1577
|
+
c == null ? void 0 : c.indent(topic.id, event.shiftKey);
|
|
1578
|
+
} else if (event.key === "Enter" && !event.shiftKey) {
|
|
1579
|
+
event.preventDefault();
|
|
1580
|
+
add("sibling", void 0, topic.id);
|
|
1581
|
+
}
|
|
1582
|
+
}
|
|
1583
|
+
}
|
|
1584
|
+
) : /* @__PURE__ */ jsx("button", { type: "button", onClick: () => locate(topic.id), children: topic.text }),
|
|
1585
|
+
/* @__PURE__ */ jsx("button", { type: "button", title: "定位主题", "aria-label": `定位大纲主题:${topic.text}`, onClick: () => locate(topic.id), children: "⌖" })
|
|
1586
|
+
] }, topic.id)) }),
|
|
1587
|
+
/* @__PURE__ */ jsxs(
|
|
1588
|
+
"div",
|
|
1589
|
+
{
|
|
1590
|
+
ref: stage,
|
|
1591
|
+
tabIndex: 0,
|
|
1592
|
+
"aria-label": "思维导图画布",
|
|
1593
|
+
className: `mind-canvas-stage${grid ? "" : " mind-grid-hidden"}${moving || spaceHeld ? " mind-space-pan" : ""}`,
|
|
1594
|
+
onPointerDown: (event) => pointerDown(event),
|
|
1595
|
+
onPointerMove: pointerMove,
|
|
1596
|
+
onPointerUp: pointerUp,
|
|
1597
|
+
onPointerCancel: () => cancelGesture(),
|
|
1598
|
+
onLostPointerCapture: () => cancelGesture(),
|
|
1599
|
+
onContextMenu: (event) => {
|
|
1600
|
+
var _a2;
|
|
1601
|
+
const id = ((_a2 = event.target.closest("[data-topic-id]")) == null ? void 0 : _a2.dataset.topicId) ?? null;
|
|
1602
|
+
openContextMenu(id, event);
|
|
1603
|
+
},
|
|
1604
|
+
onWheel: (event) => {
|
|
1605
|
+
setFollowing(null);
|
|
1606
|
+
if (event.ctrlKey || event.metaKey) {
|
|
1607
|
+
const rect = stage.current.getBoundingClientRect();
|
|
1608
|
+
zoomTo(zoom * Math.exp(-event.deltaY * 2e-3), { x: event.clientX - rect.left, y: event.clientY - rect.top });
|
|
1609
|
+
} else setPan((value) => ({ x: value.x - event.deltaX, y: value.y - event.deltaY }));
|
|
1610
|
+
},
|
|
1611
|
+
children: [
|
|
1612
|
+
/* @__PURE__ */ jsx("div", { className: "mind-canvas-surface", children: /* @__PURE__ */ jsxs("div", { className: "mind-canvas-layers", style: { transform: `translate(${origin.x}px,${origin.y}px) scale(${zoom})` }, children: [
|
|
1613
|
+
/* @__PURE__ */ jsxs("svg", { className: "mind-canvas-edges", children: [
|
|
1614
|
+
drawing.edges.map((edge) => /* @__PURE__ */ jsx("path", { d: edge.path, className: draggedIds.has(edge.target) ? "mind-drag-branch-edge" : void 0, stroke: color, strokeWidth: 2, fill: "none" }, edge.id)),
|
|
1615
|
+
mindRelationPaths(model, drawing).map((relation) => /* @__PURE__ */ jsxs("g", { children: [
|
|
1616
|
+
/* @__PURE__ */ jsx("path", { d: relation.path, stroke: "#9a68d4", strokeWidth: 2, strokeDasharray: "6 4", fill: "none" }),
|
|
1617
|
+
/* @__PURE__ */ jsx("text", { x: relation.x, y: relation.y, fill: "var(--color-text)", fontSize: 12, children: relation.label || { related: "相关", depends: "依赖", reference: "参考" }[relation.kind] })
|
|
1618
|
+
] }, relation.id)),
|
|
1619
|
+
projection && /* @__PURE__ */ jsxs("g", { className: "mind-side-projection", children: [
|
|
1620
|
+
projection.edges.filter((edge) => draggedIds.has(edge.source) || draggedIds.has(edge.target)).map((edge) => /* @__PURE__ */ jsx("path", { d: edge.path, stroke: color, fill: "none", strokeWidth: 2, strokeDasharray: "5 4" }, edge.id)),
|
|
1621
|
+
projection.nodes.filter((topic) => draggedIds.has(topic.id)).map((topic) => /* @__PURE__ */ jsxs("g", { children: [
|
|
1622
|
+
/* @__PURE__ */ jsx("rect", { x: topic.x, y: topic.y, width: topic.width, height: topic.height, rx: 8, fill: "var(--color-accent-soft)", stroke: color, strokeDasharray: "5 4" }),
|
|
1623
|
+
/* @__PURE__ */ jsx("text", { x: topic.x + topic.width / 2, y: topic.y + topic.height / 2 + 5, textAnchor: "middle", fontSize: 14, fill: "var(--color-text)", children: topic.text.slice(0, 24) })
|
|
1624
|
+
] }, topic.id))
|
|
1625
|
+
] })
|
|
1626
|
+
] }),
|
|
1627
|
+
drawing.nodes.map((topic) => {
|
|
1628
|
+
const hasChildren = tree.some((child) => child.parentId === topic.id);
|
|
1629
|
+
const quick = quickControls && !moving && !spaceHeld && !dragPreview && !box && editable && selected.has(topic.id) && selected.size === 1 && editing !== topic.id;
|
|
1630
|
+
const side = topic.side ?? 1;
|
|
1631
|
+
const grows = model.layout === "down" ? "grows-down" : side === -1 ? "grows-left" : "";
|
|
1632
|
+
return /* @__PURE__ */ jsxs(
|
|
1633
|
+
"div",
|
|
1634
|
+
{
|
|
1635
|
+
"data-topic-id": topic.id,
|
|
1636
|
+
className: `mind-topic-shell${topic.id === model.rootId ? " root" : ""}${selected.has(topic.id) ? " is-selected" : ""}${hasChildren ? " has-children" : ""}${grows ? ` ${grows}` : ""}${folds.has(topic.id) ? " is-collapsed" : ""}`,
|
|
1637
|
+
style: { position: "absolute", left: topic.x, top: topic.y, width: topic.width, height: topic.height, transform: dragPreview && draggedIds.has(topic.id) ? `translate(${dragPreview.dx}px,${dragPreview.dy}px)` : void 0, opacity: dragPreview && draggedIds.has(topic.id) ? 0.35 : void 0 },
|
|
1638
|
+
children: [
|
|
1639
|
+
/* @__PURE__ */ jsxs(
|
|
1640
|
+
"div",
|
|
1641
|
+
{
|
|
1642
|
+
className: `mind-topic${topic.id === model.rootId ? " root" : ""}${selected.has(topic.id) ? " active" : ""}${editing === topic.id ? " editing" : ""}${grows ? ` ${grows}` : ""}${(drop == null ? void 0 : drop.id) === topic.id ? ` drop mind-drop-${drop.mode}` : ""}`,
|
|
1643
|
+
style: {
|
|
1644
|
+
width: "100%",
|
|
1645
|
+
minHeight: topic.height,
|
|
1646
|
+
fontFamily: MIND_TOPIC_FONT,
|
|
1647
|
+
"--mind-topic-line-height": `${mindTopicLineHeight(topic.fontSize || 14)}px`,
|
|
1648
|
+
color: topic.color || (topic.shape === "text" ? "var(--color-text)" : topic.background ? readableTextColor(topic.background) : void 0),
|
|
1649
|
+
background: topic.shape === "text" ? "transparent" : topic.background || void 0,
|
|
1650
|
+
borderRadius: topic.shape === "pill" ? 28 : void 0,
|
|
1651
|
+
border: topic.shape === "text" ? 0 : void 0,
|
|
1652
|
+
fontSize: topic.fontSize || 14,
|
|
1653
|
+
textAlign: topic.align || "center"
|
|
1654
|
+
},
|
|
1655
|
+
onPointerDown: (event) => {
|
|
1656
|
+
event.stopPropagation();
|
|
1657
|
+
pointerDown(event, topic.id);
|
|
1658
|
+
},
|
|
1659
|
+
onDoubleClick: () => edit(topic.id),
|
|
1660
|
+
onContextMenu: (event) => openContextMenu(topic.id, event),
|
|
1661
|
+
children: [
|
|
1662
|
+
(topic.icon || topic.done) && /* @__PURE__ */ jsxs("span", { className: "mind-topic-icon", children: [
|
|
1663
|
+
topic.done ? "☑ " : "",
|
|
1664
|
+
topic.icon
|
|
1665
|
+
] }),
|
|
1666
|
+
editing === topic.id ? /* @__PURE__ */ jsx(
|
|
1667
|
+
"textarea",
|
|
1668
|
+
{
|
|
1669
|
+
ref: input,
|
|
1670
|
+
className: "mind-topic-input",
|
|
1671
|
+
"aria-label": "主题文字",
|
|
1672
|
+
rows: Math.max(1, topic.lines.length),
|
|
1673
|
+
maxLength: 2e3,
|
|
1674
|
+
value: text,
|
|
1675
|
+
onChange: (event) => {
|
|
1676
|
+
if (c == null ? void 0 : c.text(topic.id, event.target.value)) setText(event.target.value);
|
|
1677
|
+
},
|
|
1678
|
+
onSelect: (event) => {
|
|
1679
|
+
const target = event.currentTarget;
|
|
1680
|
+
setSelectedRange({ from: target.selectionStart ?? 0, to: target.selectionEnd ?? 0 });
|
|
1681
|
+
},
|
|
1682
|
+
onKeyUp: (event) => {
|
|
1683
|
+
const target = event.currentTarget;
|
|
1684
|
+
setSelectedRange({ from: target.selectionStart ?? 0, to: target.selectionEnd ?? 0 });
|
|
1685
|
+
},
|
|
1686
|
+
onCompositionStart: () => {
|
|
1687
|
+
composing.current = true;
|
|
1688
|
+
c == null ? void 0 : c.composition(true);
|
|
1689
|
+
},
|
|
1690
|
+
onCompositionEnd: (event) => {
|
|
1691
|
+
c == null ? void 0 : c.text(topic.id, event.currentTarget.value);
|
|
1692
|
+
composing.current = false;
|
|
1693
|
+
c == null ? void 0 : c.composition(false);
|
|
1694
|
+
c == null ? void 0 : c.beginText(topic.id);
|
|
1695
|
+
},
|
|
1696
|
+
onKeyDown: (event) => {
|
|
1697
|
+
event.stopPropagation();
|
|
1698
|
+
if (event.nativeEvent.isComposing || composing.current || event.keyCode === 229) return;
|
|
1699
|
+
if ((event.metaKey || event.ctrlKey) && ["z", "y"].includes(event.key.toLowerCase())) {
|
|
1700
|
+
event.preventDefault();
|
|
1701
|
+
event.shiftKey || event.key.toLowerCase() === "y" ? c == null ? void 0 : c.redo() : c == null ? void 0 : c.undo();
|
|
1702
|
+
return;
|
|
1703
|
+
}
|
|
1704
|
+
if (event.key === "Escape" || event.key === "Enter" && !event.shiftKey) {
|
|
1705
|
+
event.preventDefault();
|
|
1706
|
+
edit(null);
|
|
1707
|
+
} else if (event.key === "Tab") {
|
|
1708
|
+
event.preventDefault();
|
|
1709
|
+
c == null ? void 0 : c.endText(topic.id);
|
|
1710
|
+
add("child", void 0, topic.id);
|
|
1711
|
+
}
|
|
1712
|
+
},
|
|
1713
|
+
onBlur: () => {
|
|
1714
|
+
c == null ? void 0 : c.composition(false);
|
|
1715
|
+
c == null ? void 0 : c.endText(topic.id);
|
|
1716
|
+
setEditing(null);
|
|
1717
|
+
}
|
|
1718
|
+
}
|
|
1719
|
+
) : /* @__PURE__ */ jsx("div", { className: "mind-topic-label", style: { textAlign: topic.align || "center", minHeight: topic.lines.length * mindTopicLineHeight(topic.fontSize || 14) }, children: /* @__PURE__ */ jsx(TopicLabel, { topic }) }),
|
|
1720
|
+
topic.description && /* @__PURE__ */ jsx("div", { className: "mind-topic-description", style: topic.shape === "text" ? { color: "var(--color-text-muted)" } : topic.background ? { color: readableTextColor(topic.background) } : void 0, children: topic.description }),
|
|
1721
|
+
topic.note && /* @__PURE__ */ jsx("div", { className: "mind-topic-note", title: "此主题有备注", onClick: (event) => {
|
|
1722
|
+
event.stopPropagation();
|
|
1723
|
+
select(topic.id);
|
|
1724
|
+
setDetails(true);
|
|
1725
|
+
}, children: "▤ 备注" }),
|
|
1726
|
+
topic.attachmentId && /* @__PURE__ */ jsx("div", { className: "mind-topic-image", children: /* @__PURE__ */ jsx(AttachmentImage, { id: topic.attachmentId, alt: "主题图片", fetcher: props.fetchAttachment }) }),
|
|
1727
|
+
peers.filter((peer) => peer.topicId === topic.id).map((peer) => /* @__PURE__ */ jsx("span", { className: "mind-peer-badge", title: `${peer.name}${peer.editing ? " 正在编辑" : ""}`, "aria-label": `${peer.name}${peer.editing ? " 正在编辑此主题" : " 正在查看此主题"}`, children: peer.name.slice(0, 2) }, peer.client))
|
|
1728
|
+
]
|
|
1729
|
+
}
|
|
1730
|
+
),
|
|
1731
|
+
quick && topic.id !== model.rootId && /* @__PURE__ */ jsx(
|
|
1732
|
+
"button",
|
|
1733
|
+
{
|
|
1734
|
+
type: "button",
|
|
1735
|
+
className: "mind-topic-sibling before",
|
|
1736
|
+
"aria-label": model.layout === "down" ? "在左侧添加同级主题" : "在上方添加同级主题",
|
|
1737
|
+
title: model.layout === "down" ? "在左侧添加同级主题" : "在上方添加同级主题",
|
|
1738
|
+
onPointerDown: (event) => event.stopPropagation(),
|
|
1739
|
+
onClick: (event) => {
|
|
1740
|
+
event.stopPropagation();
|
|
1741
|
+
addSiblingAt(topic.id, "before");
|
|
1742
|
+
},
|
|
1743
|
+
children: /* @__PURE__ */ jsx("span", { "aria-hidden": "true", children: "+" })
|
|
1744
|
+
}
|
|
1745
|
+
),
|
|
1746
|
+
quick && topic.id === model.rootId && model.layout !== "down" && /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
1747
|
+
/* @__PURE__ */ jsx(
|
|
1748
|
+
"button",
|
|
1749
|
+
{
|
|
1750
|
+
type: "button",
|
|
1751
|
+
className: "mind-topic-add root-left",
|
|
1752
|
+
"aria-label": "在中心主题左侧添加子主题",
|
|
1753
|
+
title: "在左侧添加子主题",
|
|
1754
|
+
onPointerDown: (event) => event.stopPropagation(),
|
|
1755
|
+
onClick: (event) => {
|
|
1756
|
+
event.stopPropagation();
|
|
1757
|
+
add("child", -1);
|
|
1758
|
+
},
|
|
1759
|
+
children: "+"
|
|
1760
|
+
}
|
|
1761
|
+
),
|
|
1762
|
+
/* @__PURE__ */ jsx(
|
|
1763
|
+
"button",
|
|
1764
|
+
{
|
|
1765
|
+
type: "button",
|
|
1766
|
+
className: "mind-topic-add root-right",
|
|
1767
|
+
"aria-label": "在中心主题右侧添加子主题",
|
|
1768
|
+
title: "在右侧添加子主题",
|
|
1769
|
+
onPointerDown: (event) => event.stopPropagation(),
|
|
1770
|
+
onClick: (event) => {
|
|
1771
|
+
event.stopPropagation();
|
|
1772
|
+
add("child", 1);
|
|
1773
|
+
},
|
|
1774
|
+
children: "+"
|
|
1775
|
+
}
|
|
1776
|
+
)
|
|
1777
|
+
] }),
|
|
1778
|
+
quick && (topic.id !== model.rootId || model.layout === "down") && /* @__PURE__ */ jsx(
|
|
1779
|
+
"button",
|
|
1780
|
+
{
|
|
1781
|
+
type: "button",
|
|
1782
|
+
className: "mind-topic-add",
|
|
1783
|
+
"aria-label": "为当前主题添加子主题",
|
|
1784
|
+
title: "添加子主题",
|
|
1785
|
+
onPointerDown: (event) => event.stopPropagation(),
|
|
1786
|
+
onClick: (event) => {
|
|
1787
|
+
event.stopPropagation();
|
|
1788
|
+
add("child");
|
|
1789
|
+
},
|
|
1790
|
+
children: "+"
|
|
1791
|
+
}
|
|
1792
|
+
),
|
|
1793
|
+
quick && topic.id !== model.rootId && /* @__PURE__ */ jsx(
|
|
1794
|
+
"button",
|
|
1795
|
+
{
|
|
1796
|
+
type: "button",
|
|
1797
|
+
className: "mind-topic-sibling after",
|
|
1798
|
+
"aria-label": model.layout === "down" ? "在右侧添加同级主题" : "在下方添加同级主题",
|
|
1799
|
+
title: model.layout === "down" ? "在右侧添加同级主题" : "在下方添加同级主题",
|
|
1800
|
+
onPointerDown: (event) => event.stopPropagation(),
|
|
1801
|
+
onClick: (event) => {
|
|
1802
|
+
event.stopPropagation();
|
|
1803
|
+
addSiblingAt(topic.id, "after");
|
|
1804
|
+
},
|
|
1805
|
+
children: /* @__PURE__ */ jsx("span", { "aria-hidden": "true", children: "+" })
|
|
1806
|
+
}
|
|
1807
|
+
),
|
|
1808
|
+
hasChildren && topic.id !== model.rootId && editing !== topic.id && /* @__PURE__ */ jsx(
|
|
1809
|
+
"button",
|
|
1810
|
+
{
|
|
1811
|
+
type: "button",
|
|
1812
|
+
className: "mind-topic-fold",
|
|
1813
|
+
"aria-label": folds.has(topic.id) ? `展开分支:${topic.text}(隐藏 ${mindMapDescendants$1(model, topic.id).size - 1} 个主题)` : `收起分支:${topic.text}`,
|
|
1814
|
+
title: folds.has(topic.id) ? `展开分支,共 ${mindMapDescendants$1(model, topic.id).size - 1} 个后代主题` : "收起子分支",
|
|
1815
|
+
"aria-expanded": !folds.has(topic.id),
|
|
1816
|
+
onClick: (event) => {
|
|
1817
|
+
event.stopPropagation();
|
|
1818
|
+
fold(topic.id);
|
|
1819
|
+
},
|
|
1820
|
+
children: folds.has(topic.id) ? /* @__PURE__ */ jsx("span", { className: "mind-fold-count", children: mindMapDescendants$1(model, topic.id).size - 1 }) : /* @__PURE__ */ jsx("svg", { className: "mind-fold-chevron", width: "14", height: "14", viewBox: "0 0 16 16", fill: "none", "aria-hidden": "true", children: /* @__PURE__ */ jsx("path", { d: "m10 4-4 4 4 4", stroke: "currentColor", strokeWidth: "1.8", strokeLinecap: "round", strokeLinejoin: "round" }) })
|
|
1821
|
+
}
|
|
1822
|
+
)
|
|
1823
|
+
]
|
|
1824
|
+
},
|
|
1825
|
+
topic.id
|
|
1826
|
+
);
|
|
1827
|
+
})
|
|
1828
|
+
] }) }),
|
|
1829
|
+
box && /* @__PURE__ */ jsx("div", { className: "mind-marquee", "aria-hidden": "true", style: {
|
|
1830
|
+
left: origin.x + box.x * zoom,
|
|
1831
|
+
top: origin.y + box.y * zoom,
|
|
1832
|
+
width: box.w * zoom,
|
|
1833
|
+
height: box.h * zoom
|
|
1834
|
+
} }),
|
|
1835
|
+
editable && selected.size === 1 && !editing && !dragPreview && !box && /* @__PURE__ */ jsxs("div", { className: "mind-node-actions", "aria-label": "主题操作", children: [
|
|
1836
|
+
/* @__PURE__ */ jsx(WButton, { variant: "primary", onClick: () => add("child"), children: "+ 子主题" }),
|
|
1837
|
+
/* @__PURE__ */ jsx(WButton, { onClick: () => add("sibling"), children: "同级主题" }),
|
|
1838
|
+
/* @__PURE__ */ jsx(WButton, { disabled: active === model.rootId, onClick: () => add("parent"), children: "父主题" }),
|
|
1839
|
+
/* @__PURE__ */ jsx(WDropdown, { label: "调整层级", groups: [
|
|
1840
|
+
{ items: [{ value: "out", label: "提升一级" }, { value: "in", label: "缩进一级" }] },
|
|
1841
|
+
...firstLevel && model.layout !== "down" ? [{ title: "分支方向", items: [
|
|
1842
|
+
{ value: "left", label: "移到左侧", disabled: directions.get(active) === -1 },
|
|
1843
|
+
{ value: "right", label: "移到右侧", disabled: directions.get(active) === 1 }
|
|
1844
|
+
] }] : []
|
|
1845
|
+
], onSelect: (value) => value === "left" ? moveSide(-1) : value === "right" ? moveSide(1) : c == null ? void 0 : c.indent(active, value === "out") }),
|
|
1846
|
+
/* @__PURE__ */ jsx(WButton, { onClick: () => edit(active), children: "改名" }),
|
|
1847
|
+
/* @__PURE__ */ jsx(WButton, { onClick: () => copy(), children: "复制" }),
|
|
1848
|
+
/* @__PURE__ */ jsx(WButton, { loading: pasting, onClick: () => void paste(), children: "粘贴" }),
|
|
1849
|
+
host.comments && pageId && /* @__PURE__ */ jsx(WButton, { variant: comments ? "primary" : "default", "aria-pressed": comments, "aria-label": "主题讨论", onClick: () => {
|
|
1850
|
+
setComments(!comments);
|
|
1851
|
+
setDetails(false);
|
|
1852
|
+
}, children: "讨论" }),
|
|
1853
|
+
/* @__PURE__ */ jsx(WButton, { disabled: active === model.rootId, title: "删除主题(Delete / Backspace)", onClick: () => remove(), children: "删除" })
|
|
1854
|
+
] }),
|
|
1855
|
+
selected.size > 1 && /* @__PURE__ */ jsxs("div", { className: "mind-selection-summary", role: "status", children: [
|
|
1856
|
+
"已选择 ",
|
|
1857
|
+
selected.size,
|
|
1858
|
+
" 个主题",
|
|
1859
|
+
editable && /* @__PURE__ */ jsx(WButton, { title: "删除所选主题(Delete / Backspace)", onClick: () => remove(), children: "删除所选" }),
|
|
1860
|
+
/* @__PURE__ */ jsx(WButton, { variant: "text", onClick: () => setSelected(/* @__PURE__ */ new Set()), children: "取消选择" })
|
|
1861
|
+
] }),
|
|
1862
|
+
/* @__PURE__ */ jsxs("div", { className: "mind-canvas-bottom", children: [
|
|
1863
|
+
/* @__PURE__ */ jsxs("span", { className: "mind-canvas-hint", children: [
|
|
1864
|
+
moving ? "移动模式:左键拖动画布" : "选择模式:左键选择 / 空白处框选",
|
|
1865
|
+
" · 中键或空格+拖动平移 · 双指平移 / 捏合缩放 · 右键菜单"
|
|
1866
|
+
] }),
|
|
1867
|
+
/* @__PURE__ */ jsxs("div", { className: "mind-canvas-viewport", children: [
|
|
1868
|
+
editable && /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
1869
|
+
/* @__PURE__ */ jsx(WButton, { disabled: !(c == null ? void 0 : c.canUndo()), onClick: () => c == null ? void 0 : c.undo(), children: "撤销" }),
|
|
1870
|
+
/* @__PURE__ */ jsx(WButton, { disabled: !(c == null ? void 0 : c.canRedo()), onClick: () => c == null ? void 0 : c.redo(), children: "重做" })
|
|
1871
|
+
] }),
|
|
1872
|
+
/* @__PURE__ */ jsx("span", { className: "mind-viewport-divider", "aria-hidden": "true" }),
|
|
1873
|
+
/* @__PURE__ */ jsx(WTooltip, { content: /* @__PURE__ */ jsxs("span", { className: "mind-viewport-tip", children: [
|
|
1874
|
+
moving ? "切换为选择模式,左键点选或拖动框选" : "切换为移动模式,左键拖动画布",
|
|
1875
|
+
/* @__PURE__ */ jsx("kbd", { children: "中键拖动" }),
|
|
1876
|
+
/* @__PURE__ */ jsx("kbd", { children: "空格+拖动" }),
|
|
1877
|
+
/* @__PURE__ */ jsx("kbd", { children: "双指平移" })
|
|
1878
|
+
] }), children: /* @__PURE__ */ jsx(WButton, { variant: moving ? "primary" : "text", "aria-pressed": moving, "aria-label": moving ? "切换为选择模式" : "切换为移动模式", onClick: () => {
|
|
1879
|
+
var _a2;
|
|
1880
|
+
setMoving(!moving);
|
|
1881
|
+
edit(null);
|
|
1882
|
+
cancelGesture();
|
|
1883
|
+
setFollowing(null);
|
|
1884
|
+
(_a2 = stage.current) == null ? void 0 : _a2.focus();
|
|
1885
|
+
}, children: moving ? /* @__PURE__ */ jsx("svg", { width: "18", height: "18", viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "1.7", strokeLinecap: "round", strokeLinejoin: "round", "aria-hidden": "true", children: /* @__PURE__ */ jsx("path", { d: "M8 12V5a1.5 1.5 0 0 1 3 0v6-8a1.5 1.5 0 0 1 3 0v8-6a1.5 1.5 0 0 1 3 0v7-4a1.5 1.5 0 0 1 3 0v7c0 5-3 7-7 7-3 0-5-2-7-5l-3-5a1.5 1.5 0 0 1 2.5-1.6L8 14" }) }) : /* @__PURE__ */ jsx("svg", { width: "18", height: "18", viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "1.7", strokeLinejoin: "round", "aria-hidden": "true", children: /* @__PURE__ */ jsx("path", { d: "m5 3 14 10-7 1-3 7z" }) }) }) }),
|
|
1886
|
+
/* @__PURE__ */ jsx(WTooltip, { content: /* @__PURE__ */ jsxs("span", { className: "mind-viewport-tip", children: [
|
|
1887
|
+
"缩小 ",
|
|
1888
|
+
/* @__PURE__ */ jsxs("kbd", { children: [
|
|
1889
|
+
modifier,
|
|
1890
|
+
" −"
|
|
1891
|
+
] }),
|
|
1892
|
+
/* @__PURE__ */ jsxs("kbd", { children: [
|
|
1893
|
+
modifier,
|
|
1894
|
+
"+鼠标滚轮"
|
|
1895
|
+
] }),
|
|
1896
|
+
/* @__PURE__ */ jsx("kbd", { children: "捏合手势" })
|
|
1897
|
+
] }), children: /* @__PURE__ */ jsx(WButton, { "aria-label": "缩小导图", onClick: () => paneCommand("zoom-out"), children: "−" }) }),
|
|
1898
|
+
/* @__PURE__ */ jsx(WTooltip, { content: /* @__PURE__ */ jsxs("span", { className: "mind-viewport-tip", children: [
|
|
1899
|
+
"缩放至 100% ",
|
|
1900
|
+
/* @__PURE__ */ jsxs("kbd", { children: [
|
|
1901
|
+
modifier,
|
|
1902
|
+
" 0"
|
|
1903
|
+
] })
|
|
1904
|
+
] }), children: /* @__PURE__ */ jsxs(WButton, { variant: "text", "aria-label": "缩放至 100%", className: "mind-zoom-percent", onClick: () => paneCommand("reset-zoom"), children: [
|
|
1905
|
+
Math.round(zoom * 100),
|
|
1906
|
+
"%"
|
|
1907
|
+
] }) }),
|
|
1908
|
+
/* @__PURE__ */ jsx(WTooltip, { content: /* @__PURE__ */ jsxs("span", { className: "mind-viewport-tip", children: [
|
|
1909
|
+
"放大 ",
|
|
1910
|
+
/* @__PURE__ */ jsxs("kbd", { children: [
|
|
1911
|
+
modifier,
|
|
1912
|
+
" +"
|
|
1913
|
+
] }),
|
|
1914
|
+
/* @__PURE__ */ jsxs("kbd", { children: [
|
|
1915
|
+
modifier,
|
|
1916
|
+
"+鼠标滚轮"
|
|
1917
|
+
] }),
|
|
1918
|
+
/* @__PURE__ */ jsx("kbd", { children: "捏合手势" })
|
|
1919
|
+
] }), children: /* @__PURE__ */ jsx(WButton, { "aria-label": "放大导图", onClick: () => paneCommand("zoom-in"), children: "+" }) }),
|
|
1920
|
+
/* @__PURE__ */ jsx(WTooltip, { content: /* @__PURE__ */ jsxs("span", { className: "mind-viewport-tip", children: [
|
|
1921
|
+
"画布全览 ",
|
|
1922
|
+
/* @__PURE__ */ jsx("kbd", { children: "Shift+1" })
|
|
1923
|
+
] }), children: /* @__PURE__ */ jsx(WButton, { onClick: () => paneCommand("fit"), children: "适应画布" }) })
|
|
1924
|
+
] })
|
|
1925
|
+
] }),
|
|
1926
|
+
(notice || drop) && /* @__PURE__ */ jsx("p", { className: "mind-canvas-notice", role: "status", children: drop ? drop.kind === "side" ? `松开后移到中心主题${drop.side === -1 ? "左" : "右"}侧,保留整条子分支` : `松开后${drop.mode === "child" ? "移入目标主题" : drop.mode === "before" ? "放到目标上方" : "放到目标下方"}` : notice })
|
|
1927
|
+
]
|
|
1928
|
+
}
|
|
1929
|
+
),
|
|
1930
|
+
comments && pageId && host.comments && /* @__PURE__ */ jsx(
|
|
1931
|
+
MindMapComments,
|
|
1932
|
+
{
|
|
1933
|
+
pageId,
|
|
1934
|
+
blockId: model.id,
|
|
1935
|
+
topicId: active,
|
|
1936
|
+
topicLabel: current.text,
|
|
1937
|
+
canComment: props.canComment ?? ((_g = c == null ? void 0 : (_f = c.context).canComment) == null ? void 0 : _g.call(_f)),
|
|
1938
|
+
onClose: () => setComments(false),
|
|
1939
|
+
onChanged: props.onCommentsChanged
|
|
1940
|
+
},
|
|
1941
|
+
`${pageId}:${model.id}:${active}`
|
|
1942
|
+
),
|
|
1943
|
+
details && /* @__PURE__ */ jsx(MindMapDetails, { model, id: active, controller: c, range: selectedRange, onClose: () => setDetails(false), onNotice: setNotice }, active)
|
|
1944
|
+
] }),
|
|
1945
|
+
contextMenu && portal && createPortal(/* @__PURE__ */ jsx("div", { ref: menuRef, className: "mind-context-menu", role: "menu", tabIndex: -1, "aria-label": contextMenu.id ? "主题操作菜单" : "画布操作菜单", onKeyDown: menuKeydown, style: { left: contextMenu.x, top: contextMenu.y }, children: /* @__PURE__ */ jsx("div", { className: "w-dropdown", children: contextGroups.map((group, index) => /* @__PURE__ */ jsxs("div", { className: "w-dropdown-group", role: "group", "aria-label": group.title, children: [
|
|
1946
|
+
group.title && /* @__PURE__ */ jsx("div", { className: "w-dropdown-group__title", children: group.title }),
|
|
1947
|
+
group.items.map((item) => /* @__PURE__ */ jsxs(
|
|
1948
|
+
"div",
|
|
1949
|
+
{
|
|
1950
|
+
role: "menuitem",
|
|
1951
|
+
tabIndex: item.disabled ? void 0 : -1,
|
|
1952
|
+
"aria-disabled": item.disabled || void 0,
|
|
1953
|
+
className: `w-dropdown-option${item.disabled ? " is-disabled" : ""}`,
|
|
1954
|
+
onClick: () => {
|
|
1955
|
+
if (!item.disabled) contextAction(item.value);
|
|
1956
|
+
},
|
|
1957
|
+
onKeyDown: (event) => {
|
|
1958
|
+
if (!item.disabled && (event.key === "Enter" || event.key === " ")) {
|
|
1959
|
+
event.preventDefault();
|
|
1960
|
+
contextAction(item.value);
|
|
1961
|
+
}
|
|
1962
|
+
},
|
|
1963
|
+
children: [
|
|
1964
|
+
item.label,
|
|
1965
|
+
item.shortcut && /* @__PURE__ */ jsx("span", { className: "mind-menu-key", children: item.shortcut })
|
|
1966
|
+
]
|
|
1967
|
+
},
|
|
1968
|
+
item.value
|
|
1969
|
+
))
|
|
1970
|
+
] }, index)) }) }), portal),
|
|
1971
|
+
confirmDelete && /* @__PURE__ */ jsxs(WDialog, { title: "删除分支", onClose: () => {
|
|
1972
|
+
var _a2;
|
|
1973
|
+
setConfirmDelete(null);
|
|
1974
|
+
(_a2 = stage.current) == null ? void 0 : _a2.focus();
|
|
1975
|
+
}, children: [
|
|
1976
|
+
/* @__PURE__ */ jsxs("p", { children: [
|
|
1977
|
+
"将删除 ",
|
|
1978
|
+
confirmDelete.ids.size,
|
|
1979
|
+
" 个主题(包含子主题),可以撤销。中心主题保留。"
|
|
1980
|
+
] }),
|
|
1981
|
+
/* @__PURE__ */ jsxs("div", { className: "wr-toolbar", children: [
|
|
1982
|
+
/* @__PURE__ */ jsx(WButton, { onClick: () => {
|
|
1983
|
+
var _a2;
|
|
1984
|
+
setConfirmDelete(null);
|
|
1985
|
+
(_a2 = stage.current) == null ? void 0 : _a2.focus();
|
|
1986
|
+
}, children: "取消" }),
|
|
1987
|
+
/* @__PURE__ */ jsx(WButton, { variant: "primary", onClick: () => performDelete(confirmDelete), children: "删除分支" })
|
|
1988
|
+
] })
|
|
1989
|
+
] }),
|
|
1990
|
+
importOpen && /* @__PURE__ */ jsxs(WDialog, { title: "导入导图或列表", onClose: () => setImportOpen(false), footer: /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
1991
|
+
/* @__PURE__ */ jsx(WButton, { onClick: () => setImportOpen(false), children: "取消" }),
|
|
1992
|
+
/* @__PURE__ */ jsx(WButton, { variant: "primary", loading: pasting, disabled: !importPreview, onClick: () => {
|
|
1993
|
+
if (pastingRef.current || !importPreview) return;
|
|
1994
|
+
pastingRef.current = true;
|
|
1995
|
+
setPasting(true);
|
|
1996
|
+
setImportError("");
|
|
1997
|
+
void (async () => {
|
|
1998
|
+
try {
|
|
1999
|
+
await insertBranch(importBranch(importPreview), active);
|
|
2000
|
+
if (alive.current) setImportOpen(false);
|
|
2001
|
+
} catch (error) {
|
|
2002
|
+
if (alive.current) setImportError(error instanceof Error ? error.message : "导入失败");
|
|
2003
|
+
} finally {
|
|
2004
|
+
pastingRef.current = false;
|
|
2005
|
+
if (alive.current) setPasting(false);
|
|
2006
|
+
}
|
|
2007
|
+
})();
|
|
2008
|
+
}, children: "导入分支" })
|
|
2009
|
+
] }), children: [
|
|
2010
|
+
/* @__PURE__ */ jsx("p", { className: "mind-import-hint", children: "导入为当前主题的子分支;支持 JSON 和缩进列表。不会替换现有导图。" }),
|
|
2011
|
+
/* @__PURE__ */ jsx("input", { "aria-label": "选择导图文件", type: "file", accept: ".json,.md,.txt", onChange: (event) => {
|
|
2012
|
+
var _a2;
|
|
2013
|
+
const file = (_a2 = event.target.files) == null ? void 0 : _a2[0];
|
|
2014
|
+
if (!file) return;
|
|
2015
|
+
if (file.size > 2e6) {
|
|
2016
|
+
setImportError("文件超过 2 MB");
|
|
2017
|
+
return;
|
|
2018
|
+
}
|
|
2019
|
+
void file.text().then((value) => {
|
|
2020
|
+
if (alive.current) {
|
|
2021
|
+
setImportText(value);
|
|
2022
|
+
setImportError("");
|
|
2023
|
+
}
|
|
2024
|
+
}).catch(() => {
|
|
2025
|
+
if (alive.current) setImportError("文件读取失败");
|
|
2026
|
+
});
|
|
2027
|
+
} }),
|
|
2028
|
+
/* @__PURE__ */ jsx("textarea", { "aria-label": "导入内容", rows: 10, placeholder: "粘贴缩进列表或导图 JSON", style: { marginTop: 12 }, value: importText, onChange: (event) => {
|
|
2029
|
+
setImportText(event.target.value);
|
|
2030
|
+
setImportError("");
|
|
2031
|
+
} }),
|
|
2032
|
+
importPreview && /* @__PURE__ */ jsxs("p", { children: [
|
|
2033
|
+
"识别到 ",
|
|
2034
|
+
importPreview.topics.length,
|
|
2035
|
+
" 个主题"
|
|
2036
|
+
] }),
|
|
2037
|
+
importError && /* @__PURE__ */ jsx("p", { role: "alert", children: importError }),
|
|
2038
|
+
/* @__PURE__ */ jsx("div", { className: "wr-toolbar", children: ["project", "meeting", "knowledge"].map((kind, index) => /* @__PURE__ */ jsx(WButton, { onClick: () => {
|
|
2039
|
+
const id = c == null ? void 0 : c.pasteBranch(active, importBranch(mindMapTemplate(kind)));
|
|
2040
|
+
if (id) {
|
|
2041
|
+
select(id);
|
|
2042
|
+
setImportOpen(false);
|
|
2043
|
+
}
|
|
2044
|
+
}, children: ["项目模板", "会议模板", "知识模板"][index] }, kind)) })
|
|
2045
|
+
] })
|
|
2046
|
+
] });
|
|
2047
|
+
return props.inline ? /* @__PURE__ */ jsx("section", { className: "mind-canvas-shell mind-inline", children: workspace }) : /* @__PURE__ */ jsx(
|
|
2048
|
+
WDialog,
|
|
2049
|
+
{
|
|
2050
|
+
workspace: true,
|
|
2051
|
+
fullscreen: true,
|
|
2052
|
+
hideFooter: true,
|
|
2053
|
+
className: "mind-canvas-shell mind-canvas-fullscreen",
|
|
2054
|
+
ariaLabel: "思维导图",
|
|
2055
|
+
title: /* @__PURE__ */ jsxs("span", { className: "mind-canvas-title", children: [
|
|
2056
|
+
"思维导图 ",
|
|
2057
|
+
/* @__PURE__ */ jsx("span", { children: title })
|
|
2058
|
+
] }),
|
|
2059
|
+
escToClose: !editing && !contextMenu && !settingsOpen && !importOpen && !confirmDelete,
|
|
2060
|
+
onClose: () => {
|
|
2061
|
+
var _a2;
|
|
2062
|
+
return (_a2 = props.onClose) == null ? void 0 : _a2.call(props);
|
|
2063
|
+
},
|
|
2064
|
+
children: workspace
|
|
2065
|
+
}
|
|
2066
|
+
);
|
|
2067
|
+
}
|
|
2068
|
+
export {
|
|
2069
|
+
MindMapCanvas
|
|
2070
|
+
};
|