wendang-react 0.0.0-stage → 0.5.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/NOTICE.md +381 -0
- package/README.md +478 -2
- package/dist/bindings/yjs.js +5 -0
- package/dist/chunks/AnchoredPanel-D3nte06T.js +68 -0
- package/dist/chunks/MindMapCanvas-D5XwjVH1.js +2072 -0
- package/dist/chunks/MindMapViewer-CQTQAgNq.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 +154 -0
- package/dist/styles/video-dialog.css +41 -0
- package/dist/styles/video-embed.css +35 -0
- package/dist/styles.css +2615 -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
package/README.md
CHANGED
|
@@ -1,3 +1,479 @@
|
|
|
1
|
-
#
|
|
1
|
+
# Wendang React
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
在 React 应用中编辑和展示文档、工作表与思维导图,支持表格、图片、代码、公式、附件、评论和文档协同。
|
|
4
|
+
|
|
5
|
+
[在线演示](https://doc.yjmf.com) · [Vue 版本](https://www.npmjs.com/package/wendang-vue) · [数据工具与服务端校验](https://www.npmjs.com/package/wendang) · [源码](https://gitee.com/ztes/wendang)
|
|
6
|
+
|
|
7
|
+
## 安装
|
|
8
|
+
|
|
9
|
+
在 React **18.3+ 或 19** 应用中安装:
|
|
10
|
+
|
|
11
|
+
```sh
|
|
12
|
+
npm install wendang wendang-react yjs y-protocols
|
|
13
|
+
```
|
|
14
|
+
|
|
15
|
+
项目需已有 `react` 和 `react-dom`。使用 TypeScript 时安装对应的 `@types/react` 和 `@types/react-dom`。
|
|
16
|
+
构建环境使用 Node.js **20.19+**,页面在现代浏览器中运行。应用入口引入一次 `wendang-react/styles.css`。
|
|
17
|
+
|
|
18
|
+
### 版本兼容
|
|
19
|
+
|
|
20
|
+
版本号采用 `主版本.次版本.修订版本`。`wendang-react` 与 `wendang` 的主版本号、
|
|
21
|
+
次版本号应保持一致;升级这两位版本时,请同步升级应用中使用的相关包。
|
|
22
|
+
修订版本用于兼容性修复,修订号可以不同,可按需单独升级。
|
|
23
|
+
|
|
24
|
+
例如,`wendang-react@0.5.6` 可搭配 `wendang@0.5.5`。
|
|
25
|
+
核心包的具体版本要求以 `wendang-react` 声明的依赖为准。
|
|
26
|
+
|
|
27
|
+
## 先运行:编辑、预览和本地保存
|
|
28
|
+
|
|
29
|
+
把下面内容放入 `App.tsx`。不需要后端或额外 UI 组件库:可以输入文字、切换预览、保存到本机,刷新后恢复。
|
|
30
|
+
附件上传、页面搜索和讨论需要接入下文的宿主服务。
|
|
31
|
+
|
|
32
|
+
```tsx
|
|
33
|
+
import { useEffect, useRef, useState } from 'react'
|
|
34
|
+
import { ContentProvider } from 'wendang-react'
|
|
35
|
+
import { DocumentEditor, type DocumentEditorHandle } from 'wendang-react/document'
|
|
36
|
+
import { DocumentViewer } from 'wendang-react/document/viewer'
|
|
37
|
+
import { ContentSchemaService, SCHEMA_VERSION, requiredSchemaVersion } from 'wendang/schema'
|
|
38
|
+
import type { ProseMirrorDoc } from 'wendang/types'
|
|
39
|
+
import 'wendang-react/styles.css'
|
|
40
|
+
|
|
41
|
+
const storageKey = 'wendang:demo:document'
|
|
42
|
+
const initialDoc: ProseMirrorDoc = {
|
|
43
|
+
type: 'doc', content: [{ type: 'paragraph', content: [{ type: 'text', text: '开始写作,在空行输入 / 插入内容。' }] }],
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
export default function App() {
|
|
47
|
+
const editor = useRef<DocumentEditorHandle>(null)
|
|
48
|
+
const [doc, setDoc] = useState(initialDoc)
|
|
49
|
+
const [schemaVersion, setSchemaVersion] = useState(SCHEMA_VERSION)
|
|
50
|
+
const [loaded, setLoaded] = useState(false)
|
|
51
|
+
const [ready, setReady] = useState(false)
|
|
52
|
+
const [editing, setEditing] = useState(true)
|
|
53
|
+
const [status, setStatus] = useState('尚未保存')
|
|
54
|
+
const [error, setError] = useState('')
|
|
55
|
+
|
|
56
|
+
useEffect(() => {
|
|
57
|
+
try {
|
|
58
|
+
const raw = localStorage.getItem(storageKey)
|
|
59
|
+
if (raw) {
|
|
60
|
+
const stored: { doc: ProseMirrorDoc; schemaVersion: number } = JSON.parse(raw)
|
|
61
|
+
new ContentSchemaService().validate(stored.doc, stored.schemaVersion)
|
|
62
|
+
setDoc(stored.doc)
|
|
63
|
+
setSchemaVersion(requiredSchemaVersion(stored.doc, stored.schemaVersion))
|
|
64
|
+
setStatus('已载入本机内容')
|
|
65
|
+
}
|
|
66
|
+
setLoaded(true)
|
|
67
|
+
} catch (failure) {
|
|
68
|
+
setError(`读取失败,原始数据仍保留:${String(failure)}`)
|
|
69
|
+
}
|
|
70
|
+
}, [])
|
|
71
|
+
|
|
72
|
+
async function save() {
|
|
73
|
+
if (!editor.current?.isReady()) return
|
|
74
|
+
try {
|
|
75
|
+
const snapshot = await editor.current.prepareSnapshot()
|
|
76
|
+
localStorage.setItem(storageKey, JSON.stringify(snapshot))
|
|
77
|
+
setSchemaVersion(snapshot.schemaVersion)
|
|
78
|
+
setError('')
|
|
79
|
+
setStatus('已保存到本机')
|
|
80
|
+
} catch (failure) { setError(String(failure)) }
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
return <main data-block-select-band style={{ maxWidth: 960, margin: '32px auto', padding: '0 56px' }}>
|
|
84
|
+
<div style={{ display: 'flex', gap: 12, marginBottom: 24 }}>
|
|
85
|
+
<button disabled={!loaded} onClick={() => { setReady(false); setEditing(!editing) }}>{editing ? '预览' : '继续编辑'}</button>
|
|
86
|
+
<button disabled={!ready || !editing} onClick={() => void save()}>保存到本机</button>
|
|
87
|
+
<span role="status">{status}</span>
|
|
88
|
+
</div>
|
|
89
|
+
{error && <p role="alert">{error}</p>}
|
|
90
|
+
{loaded && <ContentProvider theme="light">
|
|
91
|
+
{editing ? <DocumentEditor ref={editor} value={doc} schemaVersion={schemaVersion}
|
|
92
|
+
onChange={value => { setDoc(value); setStatus('有未保存的修改') }}
|
|
93
|
+
onReady={() => setReady(true)} onError={failure => setError(failure.message)}
|
|
94
|
+
onNotice={setError} /> : <DocumentViewer value={doc} />}
|
|
95
|
+
</ContentProvider>}
|
|
96
|
+
</main>
|
|
97
|
+
}
|
|
98
|
+
```
|
|
99
|
+
|
|
100
|
+
**布局要点:** 正文左侧需由应用留出约 **56px** 空间,用于空行「+」、块菜单和表格入口。
|
|
101
|
+
`data-block-select-band` 声明可从留白开始框选的范围。不要在编辑器内部额外缩进正文。
|
|
102
|
+
工作表和独立导图还需要明确的容器高度,示例见下文。
|
|
103
|
+
|
|
104
|
+
### 编辑操作
|
|
105
|
+
|
|
106
|
+
| 想做什么 | 操作 |
|
|
107
|
+
| --- | --- |
|
|
108
|
+
| 插入标题、表格、图片、代码等 | 空行输入 `/`,或悬停空行后点左侧蓝色「+」;表格先选行列数 |
|
|
109
|
+
| 修改文字格式 | 选中文字,在浮动工具栏中选择格式、链接或颜色 |
|
|
110
|
+
| 转换、移动一个块 | 悬停块左侧,点类型图标或抓手打开菜单;按住抓手拖动 |
|
|
111
|
+
| 移动多个块 | 从正文两侧留白拖动框选,再拖动选中区域;Esc 取消,撤销恢复 |
|
|
112
|
+
| 调整表格 | 点表格左上入口、行列选择条或单元格工具栏;支持拖选、合并、底色、对齐和列宽 |
|
|
113
|
+
| 操作图片 | 先点选图片,再用工具条对齐、编辑图注、预览或删除;图片行可重排和调整相对宽度 |
|
|
114
|
+
| 查看大图 | 阅读态点图片;编辑态点选后再次点击,或点「查看大图」;支持缩放、旋转、拖动与同行翻页 |
|
|
115
|
+
| 编辑公式 | 点击公式,在输入框中修改;Enter 确认,Esc 取消 |
|
|
116
|
+
| 设置代码显示 | 工具栏选择语言、折叠、行号、配色与高度;显示设置不改变正文 |
|
|
117
|
+
|
|
118
|
+
## 对接服务端:加载与保存
|
|
119
|
+
|
|
120
|
+
建议保存格式为 `{ doc, schemaVersion }`。`DocumentEditor.prepareSnapshot()` 返回的就是这个结构。
|
|
121
|
+
调用时可能因上传、公式编辑、组合输入或未完成的插入操作而拒绝;提示用户完成操作后重试。
|
|
122
|
+
|
|
123
|
+
```ts
|
|
124
|
+
import type { DocumentEditorHandle } from 'wendang-react/document'
|
|
125
|
+
import type { ProseMirrorDoc } from 'wendang/types'
|
|
126
|
+
import { ContentSchemaService } from 'wendang/schema'
|
|
127
|
+
|
|
128
|
+
export interface StoredDocument { doc: ProseMirrorDoc; schemaVersion: number }
|
|
129
|
+
|
|
130
|
+
export async function loadDocument(id: string): Promise<StoredDocument> {
|
|
131
|
+
const response = await fetch(`/api/documents/${encodeURIComponent(id)}`, { credentials: 'include' })
|
|
132
|
+
if (!response.ok) throw new Error(`读取失败:${response.status}`)
|
|
133
|
+
const stored: StoredDocument = await response.json()
|
|
134
|
+
new ContentSchemaService().validate(stored.doc, stored.schemaVersion)
|
|
135
|
+
return stored
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
export async function saveDocument(id: string, editor: Pick<DocumentEditorHandle, 'prepareSnapshot'>) {
|
|
139
|
+
const snapshot = await editor.prepareSnapshot()
|
|
140
|
+
const response = await fetch(`/api/documents/${encodeURIComponent(id)}`, {
|
|
141
|
+
method: 'PUT', credentials: 'include',
|
|
142
|
+
headers: { 'Content-Type': 'application/json' }, body: JSON.stringify(snapshot),
|
|
143
|
+
})
|
|
144
|
+
if (!response.ok) throw new Error(`保存失败:${response.status}`)
|
|
145
|
+
return snapshot
|
|
146
|
+
}
|
|
147
|
+
```
|
|
148
|
+
|
|
149
|
+
`/api/*` 是应用实现的接口,下文示例同样如此。服务端应再次校验正文和资源权限后入库。
|
|
150
|
+
把加载结果分别传给 `value` 和 `schemaVersion`;切换文档时用 `<DocumentEditor key={documentId} ... />` 重建实例。
|
|
151
|
+
|
|
152
|
+
`onChange` 更新本地状态,不能代表服务端已经保存。收到保存成功响应后再显示「已保存」;
|
|
153
|
+
失败保留当前内容。自动保存需串行提交或使用服务端版本校验,避免旧请求覆盖新内容。
|
|
154
|
+
不需要受控状态时,可改用 `defaultValue`;同一个实例不要同时使用两种初始化方式。
|
|
155
|
+
|
|
156
|
+
### 文档 API
|
|
157
|
+
|
|
158
|
+
| Props / 回调 | 用途 |
|
|
159
|
+
| --- | --- |
|
|
160
|
+
| `value`、`onChange(doc, meta?)` | 受控内容;`meta.remote` 标识远端同步 |
|
|
161
|
+
| `defaultValue` | 不受控实例的初始内容 |
|
|
162
|
+
| `schemaVersion` | 加载内容的数据版本 |
|
|
163
|
+
| `disabled`、`placeholder` | 编辑开关和空内容提示 |
|
|
164
|
+
| `allowExport`、`canComment` | 导出操作、评论入口开关,默认关闭 |
|
|
165
|
+
| `pageId`、`spaceId` | 资源标识和引用搜索上下文 |
|
|
166
|
+
| `uploadImage`、`uploadFile` | 上传回调;也可通过 Provider 的 `host` 提供 |
|
|
167
|
+
| `inlineComments`、`activeCommentId` | 评论列表及当前高亮讨论 |
|
|
168
|
+
| `onReady`、`onError`、`onNotice`、`onBlur` | 就绪、错误、提示和失焦 |
|
|
169
|
+
| `onRequestComment`、`onInlineMarkClick`、`onCommentsChanged` | 创建行内评论、点评论标记、导图讨论变化 |
|
|
170
|
+
| `onSharePage`、`onConvertToSubpage`、`onSaveAsTemplate` | 应用菜单动作;后两者接收块 JSON,由应用处理 |
|
|
171
|
+
| `collabDoc`、`collabAwareness` | 文档协同,见下文 |
|
|
172
|
+
|
|
173
|
+
实例方法:
|
|
174
|
+
|
|
175
|
+
| 方法 | 返回 / 用途 |
|
|
176
|
+
| --- | --- |
|
|
177
|
+
| `isReady()` / `whenReady()` | 查询就绪 / 等待初始化;销毁也会结束等待,之后先检查 `isReady()` |
|
|
178
|
+
| `prepareSnapshot()` | `Promise<{ doc, schemaVersion }>`,保存时优先使用 |
|
|
179
|
+
| `getJSON()` / `getSnapshot()` | 立即读取正文,不等待未完成操作 |
|
|
180
|
+
| `setContent(doc)` | 明确替换内容,协同模式不使用 |
|
|
181
|
+
| `hasPendingTasks()` | 是否存在未完成的上传、输入或插入 |
|
|
182
|
+
| `focus()` / `undo()` / `redo()` | 聚焦、撤销、重做 |
|
|
183
|
+
| `hasSelection()` / `setSelection(from, to?)` | 查询 / 恢复 ProseMirror 文本选区 |
|
|
184
|
+
| `getSelectionForAnchor()` | 评论锚点 `{ quote, prefix, suffix, start }`,无文字返回 `null` |
|
|
185
|
+
| `getSelectionRect()` | 选区首行的视口矩形,无选区返回 `null` |
|
|
186
|
+
|
|
187
|
+
只读页面用 `DocumentViewer`,主要 Props 为 `value`、`inlineComments`、`activeCommentId`、
|
|
188
|
+
`onMarkClick`、`attachmentFetcher`、`resolvePageLink`、`pageId`、`canComment`、`allowExport`。
|
|
189
|
+
`sameDocument(a,b)` 可从 `wendang-react/document` 导入,用于比较归一化后的正文。
|
|
190
|
+
|
|
191
|
+
## 宿主服务:附件、页面引用和评论
|
|
192
|
+
|
|
193
|
+
先建立一个稳定的 `host` 对象,传给 `<ContentProvider host={host}>`。下面可以保存为 `content-host.ts`;
|
|
194
|
+
示例使用 Cookie 登录,改用 Bearer token 时在请求函数中添加应用的认证头。
|
|
195
|
+
|
|
196
|
+
```ts
|
|
197
|
+
import type { ContentHost } from 'wendang-react'
|
|
198
|
+
import type { CommentItem } from 'wendang/types'
|
|
199
|
+
|
|
200
|
+
async function json<T>(url: string, init: RequestInit = {}): Promise<T> {
|
|
201
|
+
const response = await fetch(url, { credentials: 'include', ...init })
|
|
202
|
+
if (!response.ok) throw new Error(`请求失败:${response.status}`)
|
|
203
|
+
return await response.json()
|
|
204
|
+
}
|
|
205
|
+
async function write(url: string, method: string, data?: unknown): Promise<void> {
|
|
206
|
+
const response = await fetch(url, {
|
|
207
|
+
method, credentials: 'include', headers: { 'Content-Type': 'application/json' },
|
|
208
|
+
...(data === undefined ? {} : { body: JSON.stringify(data) }),
|
|
209
|
+
})
|
|
210
|
+
if (!response.ok) throw new Error(`操作失败:${response.status}`)
|
|
211
|
+
}
|
|
212
|
+
|
|
213
|
+
export function createContentHost(scope: string): ContentHost {
|
|
214
|
+
return {
|
|
215
|
+
scope,
|
|
216
|
+
attachments: {
|
|
217
|
+
async fetch(id) {
|
|
218
|
+
const response = await fetch(`/api/attachments/${encodeURIComponent(id)}/content`, { credentials: 'include' })
|
|
219
|
+
if (!response.ok) throw new Error('附件读取失败')
|
|
220
|
+
return await response.blob()
|
|
221
|
+
},
|
|
222
|
+
async uploadImage(file) {
|
|
223
|
+
const form = new FormData(); form.append('file', file)
|
|
224
|
+
return await json<{ id: string; alt: string }>('/api/attachments/images', { method: 'POST', body: form })
|
|
225
|
+
},
|
|
226
|
+
async uploadFile(file) {
|
|
227
|
+
const form = new FormData(); form.append('file', file)
|
|
228
|
+
return await json<{ id: string; filename: string; mimeType: string; size: number }>('/api/attachments/files', { method: 'POST', body: form })
|
|
229
|
+
},
|
|
230
|
+
},
|
|
231
|
+
references: {
|
|
232
|
+
async search(query, context) {
|
|
233
|
+
const params = new URLSearchParams({ q: query })
|
|
234
|
+
if (context.spaceId) params.set('spaceId', context.spaceId)
|
|
235
|
+
if (context.excludeId) params.set('excludeId', context.excludeId)
|
|
236
|
+
return await json<Array<{ id: string; title: string }>>(`/api/pages/search?${params}`)
|
|
237
|
+
},
|
|
238
|
+
resolve: id => ({ href: `/pages/${encodeURIComponent(id)}` }),
|
|
239
|
+
navigate: href => { window.location.assign(href) },
|
|
240
|
+
},
|
|
241
|
+
comments: {
|
|
242
|
+
list: id => json<{ items: CommentItem[] }>(`/api/documents/${encodeURIComponent(id)}/comments`),
|
|
243
|
+
create: (id, body, parentId, target) => write(`/api/documents/${encodeURIComponent(id)}/comments`, 'POST', { body, parentId, target }),
|
|
244
|
+
update: (id, body) => write(`/api/comments/${encodeURIComponent(id)}`, 'PATCH', { body }),
|
|
245
|
+
resolve: (id, resolved) => write(`/api/comments/${encodeURIComponent(id)}/resolve`, 'PATCH', { resolved }),
|
|
246
|
+
remove: id => write(`/api/comments/${encodeURIComponent(id)}`, 'DELETE'),
|
|
247
|
+
},
|
|
248
|
+
}
|
|
249
|
+
}
|
|
250
|
+
```
|
|
251
|
+
|
|
252
|
+
在 React 中用 `useMemo(() => createContentHost(scope), [scope])` 创建并传入 Provider。
|
|
253
|
+
`scope` 应包含应用、租户、账号及权限上下文,例如 `app:tenant:user:permissionVersion`;
|
|
254
|
+
它变化时内容实例会重建。切换前先处理未保存内容;同页不同权限实例使用不同 scope。
|
|
255
|
+
|
|
256
|
+
| 服务 | 应用需返回什么 |
|
|
257
|
+
| --- | --- |
|
|
258
|
+
| `attachments.fetch(id)` | 附件原始 `Blob`,按当前用户鉴权 |
|
|
259
|
+
| `uploadImage(file)` | `{ id, alt }`,`id` 为稳定附件 UUID |
|
|
260
|
+
| `uploadFile(file)` | `{ id, filename, mimeType, size }`,大小单位为字节 |
|
|
261
|
+
| `references.search(query, context)` | 当前用户可见的 `{ id, title }[]`,支持空查询 |
|
|
262
|
+
| `references.resolve(id, label)` | `{ href, external? }`;不可见返回 `null`,页面降级为纯文本 |
|
|
263
|
+
| `references.navigate(href)` | 可选;SPA 可在这里调用自己的 router |
|
|
264
|
+
| `comments.list(resourceId)` | `{ items: CommentItem[] }`,回复放在父评论 `replies` 中 |
|
|
265
|
+
| `comments.create(resourceId, body, parentId?, target?)` | 创建成功后 resolve;`target` 为导图的 `{ blockId, topicId }` |
|
|
266
|
+
| `comments.update / resolve / remove` | 正文修改 / 解决状态 / 删除成功后 resolve;`update` 可选 |
|
|
267
|
+
|
|
268
|
+
可选 `preferences.get(key) / set(key,value)` 存储展示偏好,例如代码主题键 `code-theme`。
|
|
269
|
+
可选 `location.current() / subscribe(listener) / createLink({blockId,topicId})` 对接导图深链;
|
|
270
|
+
`current()` 返回含 `mind` 和 `topic` 参数的 hash,`subscribe` 返回取消监听函数。
|
|
271
|
+
|
|
272
|
+
**后端对应规则:** 上传返回稳定 ID,JSON 不存临时下载地址;列表和下载接口按用户鉴权。
|
|
273
|
+
导图评论由后端把 `target` 写入 `anchor.prefix = 'mind:' + blockId`、`anchor.suffix = topicId`;
|
|
274
|
+
普通行内评论则保存下面获取的文字锚点。编辑权限来自 `CommentItem.canEdit`,删除来自 `canDelete`,解决来自 `canResolve`。
|
|
275
|
+
|
|
276
|
+
### 行内评论怎么接
|
|
277
|
+
|
|
278
|
+
给编辑器传 `canComment`、`inlineComments={comments}`,并处理 `onRequestComment`。
|
|
279
|
+
在用户点击评论入口时读取 `editor.current.getSelectionForAnchor()`,没有锚点就不创建。
|
|
280
|
+
将 `{ ...anchor, seq: null }` 与评论正文交给应用的评论 API;保存后重新读取列表。
|
|
281
|
+
|
|
282
|
+
阅读器传相同的 `inlineComments`,通过 `onMarkClick(id)` 打开讨论。
|
|
283
|
+
编辑器用 `onInlineMarkClick(id)`;`activeCommentId` 控制当前讨论高亮。
|
|
284
|
+
行内评论的输入面板由应用提供,主题讨论面板在导图内提供。
|
|
285
|
+
|
|
286
|
+
## 工作表与 XLSX
|
|
287
|
+
|
|
288
|
+
工作表编辑容器必须有明确高度。以下组件可直接挂到应用中,保存内容为 `WorkbookDocument`:
|
|
289
|
+
|
|
290
|
+
```tsx
|
|
291
|
+
import { useRef, useState } from 'react'
|
|
292
|
+
import { ContentProvider } from 'wendang-react'
|
|
293
|
+
import { SpreadsheetEditor, type SpreadsheetEditorHandle } from 'wendang-react/spreadsheet'
|
|
294
|
+
import { SpreadsheetViewer } from 'wendang-react/spreadsheet/viewer'
|
|
295
|
+
import { emptyWorkbook } from 'wendang/spreadsheet'
|
|
296
|
+
import { WORKBOOK_SCHEMA_VERSION } from 'wendang/schema'
|
|
297
|
+
import 'wendang-react/styles.css'
|
|
298
|
+
|
|
299
|
+
export default function WorkbookExample() {
|
|
300
|
+
const editor = useRef<SpreadsheetEditorHandle>(null)
|
|
301
|
+
const [book, setBook] = useState(() => emptyWorkbook('sales'))
|
|
302
|
+
const [savedBook, setSavedBook] = useState(book)
|
|
303
|
+
const [message, setMessage] = useState('')
|
|
304
|
+
const [ready, setReady] = useState(false)
|
|
305
|
+
async function save() {
|
|
306
|
+
try {
|
|
307
|
+
if (!editor.current?.isReady()) return
|
|
308
|
+
const doc = await editor.current.prepareSnapshot()
|
|
309
|
+
localStorage.setItem('wendang:demo:workbook', JSON.stringify({ doc, schemaVersion: WORKBOOK_SCHEMA_VERSION }))
|
|
310
|
+
setSavedBook(doc)
|
|
311
|
+
setMessage('工作表已保存到本机')
|
|
312
|
+
} catch (error) { setMessage(String(error)) }
|
|
313
|
+
}
|
|
314
|
+
return <ContentProvider>
|
|
315
|
+
<button disabled={!ready} onClick={() => void save()}>保存工作表</button><p role="status">{message}</p>
|
|
316
|
+
<div style={{ height: 640 }}><SpreadsheetEditor ref={editor} value={book} onChange={setBook}
|
|
317
|
+
onReady={() => setReady(true)} onError={error => setMessage(error.message)} /></div>
|
|
318
|
+
<p>最近保存的工作表预览</p><SpreadsheetViewer value={savedBook} allowExport />
|
|
319
|
+
</ContentProvider>
|
|
320
|
+
}
|
|
321
|
+
```
|
|
322
|
+
|
|
323
|
+
服务端保存时用 `WORKBOOK_SCHEMA_VERSION`,不要使用正文 `SCHEMA_VERSION`。
|
|
324
|
+
阅读器显示最近保存的公式结果,不会重新计算。上面预览使用 `prepareSnapshot()` 的结果,
|
|
325
|
+
避免公式计算尚未完成时就把编辑事件里的中间值拿去显示。
|
|
326
|
+
|
|
327
|
+
XLSX 文件输入框得到 `File` 后调用导入;告警应先展示给用户,再替换当前工作表:
|
|
328
|
+
|
|
329
|
+
```ts
|
|
330
|
+
import type { SpreadsheetEditorHandle } from 'wendang-react/spreadsheet'
|
|
331
|
+
|
|
332
|
+
export async function importWorkbook(file: File, editor: SpreadsheetEditorHandle) {
|
|
333
|
+
const { importXlsx } = await import('wendang-react/spreadsheet/xlsx')
|
|
334
|
+
const result = await importXlsx(file)
|
|
335
|
+
if (result.warnings.length && !window.confirm(result.warnings.join('\n') + '\n继续导入?')) return
|
|
336
|
+
editor.replace(result.doc)
|
|
337
|
+
return result.inspection
|
|
338
|
+
}
|
|
339
|
+
|
|
340
|
+
export async function downloadWorkbook(editor: SpreadsheetEditorHandle) {
|
|
341
|
+
const { exportXlsx } = await import('wendang-react/spreadsheet/xlsx')
|
|
342
|
+
const doc = await editor.prepareSnapshot()
|
|
343
|
+
const bytes = await exportXlsx(doc)
|
|
344
|
+
const url = URL.createObjectURL(new Blob([new Uint8Array(bytes)]))
|
|
345
|
+
const link = document.createElement('a')
|
|
346
|
+
link.href = url; link.download = '工作表.xlsx'; link.click()
|
|
347
|
+
setTimeout(() => URL.revokeObjectURL(url), 10000)
|
|
348
|
+
}
|
|
349
|
+
```
|
|
350
|
+
|
|
351
|
+
支持 `.xlsx`,文件最大 5 MiB,展开后最大 20 MiB;不支持宏文件。
|
|
352
|
+
图片、图表、绘图、透视等未转换内容会通过 `warnings` 提示。
|
|
353
|
+
`replace()` 用于明确导入或切换内容,不要在每次 `onChange` 后调用。
|
|
354
|
+
|
|
355
|
+
| 工作表接口 | 用途 |
|
|
356
|
+
| --- | --- |
|
|
357
|
+
| `value / onChange`、`disabled`、`theme` | 内容、编辑权限、可选主题 |
|
|
358
|
+
| `onReady / onError` | 初始化成功与失败 |
|
|
359
|
+
| `prepareSnapshot()` | 完成单元格编辑、等待计算并返回校验后的工作簿 |
|
|
360
|
+
| `getSnapshot() / snapshot()`、`replace(doc)` | 立即取快照、替换工作簿 |
|
|
361
|
+
| `isEditing() / finishEditing() / settleCalculation()` | 查询输入状态、完成输入、等待计算 |
|
|
362
|
+
| `dispose()` | 主动销毁;正常组件卸载会自动清理 |
|
|
363
|
+
|
|
364
|
+
`SpreadsheetViewer` 可传 `standalone` 填满容器、`allowExport` 显示导出、
|
|
365
|
+
`exportSnapshot: () => Promise<{ title, doc }>` 提供当前有权导出的版本。
|
|
366
|
+
|
|
367
|
+
## 思维导图
|
|
368
|
+
|
|
369
|
+
```tsx
|
|
370
|
+
import { useRef, useState } from 'react'
|
|
371
|
+
import { ContentProvider } from 'wendang-react'
|
|
372
|
+
import { MindMapEditor, type MindMapEditorHandle } from 'wendang-react/mindmap'
|
|
373
|
+
import { MindMapViewer } from 'wendang-react/mindmap/viewer'
|
|
374
|
+
import { createMindMap, readMindMap } from 'wendang/mindmap'
|
|
375
|
+
import 'wendang-react/styles.css'
|
|
376
|
+
|
|
377
|
+
export default function MindMapExample() {
|
|
378
|
+
const editor = useRef<MindMapEditorHandle>(null)
|
|
379
|
+
const [map, setMap] = useState(() => createMindMap('both'))
|
|
380
|
+
const [message, setMessage] = useState(''), [ready, setReady] = useState(false)
|
|
381
|
+
const model = readMindMap(map)
|
|
382
|
+
async function save() {
|
|
383
|
+
try {
|
|
384
|
+
if (!editor.current?.isReady()) return
|
|
385
|
+
localStorage.setItem('wendang:demo:mindmap', JSON.stringify(await editor.current.prepareSnapshot()))
|
|
386
|
+
setMessage('导图已保存到本机')
|
|
387
|
+
} catch (error) { setMessage(String(error)) }
|
|
388
|
+
}
|
|
389
|
+
return <ContentProvider>
|
|
390
|
+
<button disabled={!ready} onClick={() => void save()}>保存导图</button><p role="status">{message}</p>
|
|
391
|
+
<div style={{ height: 640 }}><MindMapEditor ref={editor} value={map} onChange={setMap} allowExport
|
|
392
|
+
onReady={() => setReady(true)} onError={error => setMessage(error.message)} /></div>
|
|
393
|
+
{model && <MindMapViewer value={model} />}
|
|
394
|
+
</ContentProvider>
|
|
395
|
+
}
|
|
396
|
+
```
|
|
397
|
+
|
|
398
|
+
保存 `MindMapJson`,其中包含 `formatVersion`;从服务器加载后先用 `readMindMap` 检查,再传给 `value`。
|
|
399
|
+
上面工作表和导图例子演示写入本机;恢复时读取相应 storage key、检查内容后初始化状态即可。
|
|
400
|
+
|
|
401
|
+
点击主题选中,Tab 添加子主题,Enter 添加同级,F2 / 双击改名;Delete 删除,含子主题先确认。
|
|
402
|
+
Shift / Ctrl / ⌘ 点击可多选,空白处拖动框选;拖动中实时显示命中,Esc 取消。
|
|
403
|
+
空格或中键拖动平移,Ctrl / ⌘ + 滚轮缩放。分支可拖到目标或中心另一侧,操作支持撤销。
|
|
404
|
+
|
|
405
|
+
| Props / 接口 | 用途 |
|
|
406
|
+
| --- | --- |
|
|
407
|
+
| `value / onChange`、`disabled`、`allowExport` | 导图 JSON、编辑权限、导出开关 |
|
|
408
|
+
| `resourceId / canComment / openComments` | 讨论资源、发表评论权限、初始展开讨论 |
|
|
409
|
+
| `saveStatus / showSaveHint` | 应用的真实保存状态;关闭默认保存提醒 |
|
|
410
|
+
| `collabAwareness / viewState` | 在线用户状态、视口/折叠/选中状态 |
|
|
411
|
+
| `onReady / onError / onCommentsChanged` | 就绪、失败、讨论更新 |
|
|
412
|
+
| `prepareSnapshot() / getSnapshot()` | 保存快照 / 立即读取;主题输入未完成时先结束输入 |
|
|
413
|
+
| `undo() / redo() / focus()` | 撤销、重做、聚焦 |
|
|
414
|
+
|
|
415
|
+
更多菜单提供大纲、属性、讨论、导入;布局、配色和预览高度可在工具栏调整,分支线型在视图设置中。
|
|
416
|
+
导出支持 PNG / SVG / Markdown / JSON。独立导图是快照编辑;`collabAwareness` 仅提供在线状态,不同步内容。
|
|
417
|
+
正文内插入的导图随整篇文档保存。
|
|
418
|
+
|
|
419
|
+
## 文档协同接入
|
|
420
|
+
|
|
421
|
+
文档可以接收应用维护的 `Y.Doc` 和 `Awareness`,连接与认证由应用选择的 Yjs provider 提供。
|
|
422
|
+
以下组件接收已建立连接的实例;切换资源时给组件设置不同 `key`,不要同时传 `value` 初始化内容。
|
|
423
|
+
|
|
424
|
+
```tsx
|
|
425
|
+
import { ContentProvider } from 'wendang-react'
|
|
426
|
+
import { DocumentEditor } from 'wendang-react/document'
|
|
427
|
+
import type { CollaborationDocument, Awareness } from 'wendang-react/bindings/yjs'
|
|
428
|
+
import 'wendang-react/styles.css'
|
|
429
|
+
|
|
430
|
+
export default function CollaborativeDocument({ doc, awareness, canEdit }: {
|
|
431
|
+
doc: CollaborationDocument; awareness: Awareness; canEdit: boolean
|
|
432
|
+
}) {
|
|
433
|
+
return <ContentProvider>
|
|
434
|
+
<div style={{ padding: '0 56px' }}><DocumentEditor collabDoc={doc} collabAwareness={awareness}
|
|
435
|
+
disabled={!canEdit} onChange={(_value, meta) => { console.log(meta?.remote ? '收到远端更新' : '本地编辑') }} /></div>
|
|
436
|
+
</ContentProvider>
|
|
437
|
+
}
|
|
438
|
+
```
|
|
439
|
+
|
|
440
|
+
正文使用 Y.Doc 的 `default` XmlFragment。服务端/协同 provider 负责初始化及持久化 Yjs 更新;
|
|
441
|
+
不要对已同步文档再次 `setContent` 灌入初始 JSON。连接关闭、撤权、重连和卸载由应用管理。
|
|
442
|
+
工作表与独立导图使用快照保存;它们不通过 `collabDoc` 同步。
|
|
443
|
+
|
|
444
|
+
## 主题、按需导入和接入规范
|
|
445
|
+
|
|
446
|
+
`ContentProvider` 支持 `theme="light" | "dark"`、`accent="#2f6feb"`、`host` 和 `unstyled`。
|
|
447
|
+
每个 Provider 可使用不同主题;`unstyled` 需由应用提供颜色和排版变量。
|
|
448
|
+
`allowExport` 默认关闭,控制导出和下载入口;后端仍需验证下载权限。
|
|
449
|
+
|
|
450
|
+
| 入口 | 主要组件 / API |
|
|
451
|
+
| --- | --- |
|
|
452
|
+
| `wendang-react` | `ContentProvider`、宿主服务类型 |
|
|
453
|
+
| `wendang-react/document` | `DocumentEditor`、ref 类型、`sameDocument`、定位工具 |
|
|
454
|
+
| `wendang-react/document/viewer` | `DocumentViewer` |
|
|
455
|
+
| `wendang-react/spreadsheet`、`spreadsheet/viewer` | 工作表编辑 / 阅读 |
|
|
456
|
+
| `wendang-react/spreadsheet/xlsx` | `importXlsx / exportXlsx` |
|
|
457
|
+
| `wendang-react/mindmap`、`mindmap/viewer` | 导图编辑 / 预览、`MindMapBlock` |
|
|
458
|
+
| `wendang-react/bindings/yjs` | 协同字段常量及类型 |
|
|
459
|
+
| `wendang-react/shared` | 宿主通用工具 |
|
|
460
|
+
|
|
461
|
+
SSR / Next.js 中将交互编辑组件放入带 `'use client'` 的客户端组件;
|
|
462
|
+
访问 localStorage、window、网络连接的初始化放在 effect 中。全局样式在应用根入口引入。
|
|
463
|
+
同一实例编辑时保持 ref、host 和资源 key 稳定;只有明确切换内容或身份才重建。
|
|
464
|
+
|
|
465
|
+
## 常见问题
|
|
466
|
+
|
|
467
|
+
- **没有样式或工具条被裁掉:** 引入 `styles.css`,正文外留 56px;父级不要裁掉操作轨道。
|
|
468
|
+
- **工作表或导图为空白:** 容器需有明确高度,如 `640px`;检查 `onError` 和浏览器网络。
|
|
469
|
+
- **图片/文件无法上传或显示:** 接入 `host.attachments`,fetch 返回 Blob,上传返回稳定 UUID。
|
|
470
|
+
- **无法选页面或发表评论:** 接入 `references / comments`,并传 `pageId / resourceId` 与 `canComment`。
|
|
471
|
+
- **快照准备失败:** 完成上传、公式或主题输入,关闭未完成的插入对话框后重试;不要用空内容覆盖草稿。
|
|
472
|
+
- **导出按钮没出现:** 显式传 `allowExport`,并确保后端允许导出该资源。
|
|
473
|
+
- **切换账号还显示旧内容:** 更新 `host.scope` 并重新加载该账号有权访问的数据。
|
|
474
|
+
|
|
475
|
+
## 联系与许可
|
|
476
|
+
|
|
477
|
+
联系我们请发邮件:[yjmf@ztes.com](mailto:yjmf@ztes.com)。问题反馈:[Gitee Issues](https://gitee.com/ztes/wendang/issues)。
|
|
478
|
+
|
|
479
|
+
采用随包附带的 [MIT 许可](LICENSE)。第三方声明见 `NOTICE.md` 与 `third-party-notices/`。
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { jsx } from "react/jsx-runtime";
|
|
3
|
+
import { useRef, useState, useLayoutEffect } from "react";
|
|
4
|
+
import { createPortal } from "react-dom";
|
|
5
|
+
import { a as useContentContext } from "./host-C-V688Rq.js";
|
|
6
|
+
import { p as placeAnchoredPopover } from "./popover-placement-D3xVYdkt.js";
|
|
7
|
+
import { u as useLayer, L as LayerProvider, p as placePanel } from "./index-Ii536CFG.js";
|
|
8
|
+
function AnchoredPanel({ anchor, onClose, align = "start", prefer = "below", gap = 8, label, role = "dialog", className = "", portal: portalOverride, children, onKeyDown }) {
|
|
9
|
+
const context = useContentContext();
|
|
10
|
+
const portal = typeof portalOverride === "function" ? portalOverride() : portalOverride !== void 0 ? portalOverride : context.portal;
|
|
11
|
+
const panel = useRef(null);
|
|
12
|
+
const trigger = useRef(anchor);
|
|
13
|
+
trigger.current = anchor;
|
|
14
|
+
const layer = useLayer(trigger, panel, true, onClose);
|
|
15
|
+
const [position, setPosition] = useState(null);
|
|
16
|
+
useLayoutEffect(() => {
|
|
17
|
+
const measure = () => {
|
|
18
|
+
var _a;
|
|
19
|
+
const rect = anchor == null ? void 0 : anchor.getBoundingClientRect(), card = (_a = panel.current) == null ? void 0 : _a.getBoundingClientRect();
|
|
20
|
+
if (!rect || !card) return;
|
|
21
|
+
const placed = align === "end" ? placePanel({
|
|
22
|
+
trigger: rect,
|
|
23
|
+
panel: card,
|
|
24
|
+
position: prefer === "above" ? "tr" : "br",
|
|
25
|
+
gap,
|
|
26
|
+
viewport: { width: innerWidth, height: innerHeight }
|
|
27
|
+
}) : placeAnchoredPopover({
|
|
28
|
+
align,
|
|
29
|
+
prefer,
|
|
30
|
+
anchor: { left: rect.left, top: rect.top, width: rect.width, height: rect.height },
|
|
31
|
+
host: { left: 0, top: 0 },
|
|
32
|
+
card: { width: card.width, height: card.height },
|
|
33
|
+
bounds: { left: 0, top: 0, width: window.innerWidth, height: window.innerHeight },
|
|
34
|
+
gap
|
|
35
|
+
});
|
|
36
|
+
setPosition({ left: placed.left, top: placed.top });
|
|
37
|
+
};
|
|
38
|
+
measure();
|
|
39
|
+
const observer = typeof ResizeObserver === "undefined" ? null : new ResizeObserver(measure);
|
|
40
|
+
if (panel.current) observer == null ? void 0 : observer.observe(panel.current);
|
|
41
|
+
window.addEventListener("resize", measure);
|
|
42
|
+
window.addEventListener("scroll", measure, true);
|
|
43
|
+
return () => {
|
|
44
|
+
observer == null ? void 0 : observer.disconnect();
|
|
45
|
+
window.removeEventListener("resize", measure);
|
|
46
|
+
window.removeEventListener("scroll", measure, true);
|
|
47
|
+
};
|
|
48
|
+
}, [anchor, align, prefer, gap]);
|
|
49
|
+
if (!portal) return null;
|
|
50
|
+
return /* @__PURE__ */ jsx(LayerProvider, { layer, children: createPortal(/* @__PURE__ */ jsx(
|
|
51
|
+
"div",
|
|
52
|
+
{
|
|
53
|
+
ref: panel,
|
|
54
|
+
className: `w-popover w-popover--flush${className ? ` ${className}` : ""}`,
|
|
55
|
+
role,
|
|
56
|
+
"aria-label": label,
|
|
57
|
+
onKeyDown,
|
|
58
|
+
onPointerDown: (event) => event.stopPropagation(),
|
|
59
|
+
onWheel: (event) => event.stopPropagation(),
|
|
60
|
+
onContextMenu: (event) => event.stopPropagation(),
|
|
61
|
+
style: { position: "fixed", left: (position == null ? void 0 : position.left) ?? -9999, top: (position == null ? void 0 : position.top) ?? -9999 },
|
|
62
|
+
children
|
|
63
|
+
}
|
|
64
|
+
), portal) });
|
|
65
|
+
}
|
|
66
|
+
export {
|
|
67
|
+
AnchoredPanel as A
|
|
68
|
+
};
|