@ctzhian/tiptap 1.5.2 → 1.5.3
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/dist/Editor/demo.d.ts +4 -0
- package/dist/Editor/demo.js +153 -0
- package/dist/Editor/index.d.ts +4 -0
- package/dist/Editor/index.js +21 -0
- package/dist/EditorDiff/demo.d.ts +4 -0
- package/dist/EditorDiff/demo.js +12 -0
- package/dist/EditorDiff/index.d.ts +7 -0
- package/dist/EditorDiff/index.js +24 -0
- package/dist/EditorThemeProvider/index.d.ts +11 -0
- package/dist/EditorThemeProvider/index.js +90 -0
- package/dist/EditorToolbar/index.d.ts +9 -0
- package/dist/EditorToolbar/index.js +325 -0
- package/dist/asset/css/index.css +165 -0
- package/dist/asset/images/disk.png +0 -0
- package/dist/component/CustomBubbleMenu/SelectionText.d.ts +9 -0
- package/dist/component/CustomBubbleMenu/SelectionText.js +292 -0
- package/dist/component/CustomDragHandle/index.d.ts +9 -0
- package/dist/component/CustomDragHandle/index.js +1407 -0
- package/dist/component/CustomFloatingMenu/index.d.ts +0 -0
- package/dist/component/CustomFloatingMenu/index.js +85 -0
- package/dist/component/FloatingPopover/index.d.ts +15 -0
- package/dist/component/FloatingPopover/index.js +113 -0
- package/dist/component/Icons/add-line-icon.d.ts +6 -0
- package/dist/component/Icons/add-line-icon.js +13 -0
- package/dist/component/Icons/ai-generate-2-icon.d.ts +6 -0
- package/dist/component/Icons/ai-generate-2-icon.js +13 -0
- package/dist/component/Icons/ai-generate-text-icon.d.ts +6 -0
- package/dist/component/Icons/ai-generate-text-icon.js +13 -0
- package/dist/component/Icons/align-bottom-icon.d.ts +6 -0
- package/dist/component/Icons/align-bottom-icon.js +13 -0
- package/dist/component/Icons/align-center-icon.d.ts +6 -0
- package/dist/component/Icons/align-center-icon.js +13 -0
- package/dist/component/Icons/align-justify-icon.d.ts +6 -0
- package/dist/component/Icons/align-justify-icon.js +13 -0
- package/dist/component/Icons/align-left-icon.d.ts +6 -0
- package/dist/component/Icons/align-left-icon.js +13 -0
- package/dist/component/Icons/align-right-icon.d.ts +6 -0
- package/dist/component/Icons/align-right-icon.js +13 -0
- package/dist/component/Icons/align-top-icon.d.ts +6 -0
- package/dist/component/Icons/align-top-icon.js +13 -0
- package/dist/component/Icons/align-vertically-icon.d.ts +6 -0
- package/dist/component/Icons/align-vertically-icon.js +13 -0
- package/dist/component/Icons/anticlockwise-line-icon.d.ts +6 -0
- package/dist/component/Icons/anticlockwise-line-icon.js +13 -0
- package/dist/component/Icons/arrow-down-s-line-icon.d.ts +6 -0
- package/dist/component/Icons/arrow-down-s-line-icon.js +13 -0
- package/dist/component/Icons/arrow-go-back-line-icon.d.ts +6 -0
- package/dist/component/Icons/arrow-go-back-line-icon.js +13 -0
- package/dist/component/Icons/arrow-go-forward-line-icon.d.ts +6 -0
- package/dist/component/Icons/arrow-go-forward-line-icon.js +13 -0
- package/dist/component/Icons/arrow-left-wide-line-icon.d.ts +6 -0
- package/dist/component/Icons/arrow-left-wide-line-icon.js +13 -0
- package/dist/component/Icons/at-line-icon.d.ts +6 -0
- package/dist/component/Icons/at-line-icon.js +13 -0
- package/dist/component/Icons/attachment-2-icon.d.ts +6 -0
- package/dist/component/Icons/attachment-2-icon.js +13 -0
- package/dist/component/Icons/attachment-line-icon.d.ts +6 -0
- package/dist/component/Icons/attachment-line-icon.js +13 -0
- package/dist/component/Icons/bold-icon.d.ts +6 -0
- package/dist/component/Icons/bold-icon.js +13 -0
- package/dist/component/Icons/brush-line-icon.d.ts +6 -0
- package/dist/component/Icons/brush-line-icon.js +13 -0
- package/dist/component/Icons/carousel-view-icon.d.ts +6 -0
- package/dist/component/Icons/carousel-view-icon.js +13 -0
- package/dist/component/Icons/checkbox-blank-circle-line-icon.d.ts +6 -0
- package/dist/component/Icons/checkbox-blank-circle-line-icon.js +13 -0
- package/dist/component/Icons/checkbox-circle-fill-icon.d.ts +6 -0
- package/dist/component/Icons/checkbox-circle-fill-icon.js +13 -0
- package/dist/component/Icons/checkbox-circle-line-icon.d.ts +6 -0
- package/dist/component/Icons/checkbox-circle-line-icon.js +13 -0
- package/dist/component/Icons/clockwise-line-icon.d.ts +6 -0
- package/dist/component/Icons/clockwise-line-icon.js +13 -0
- package/dist/component/Icons/close-circle-fill-icon.d.ts +6 -0
- package/dist/component/Icons/close-circle-fill-icon.js +13 -0
- package/dist/component/Icons/code-box-line-icon.d.ts +6 -0
- package/dist/component/Icons/code-box-line-icon.js +13 -0
- package/dist/component/Icons/code-line-icon.d.ts +6 -0
- package/dist/component/Icons/code-line-icon.js +13 -0
- package/dist/component/Icons/code-s-slash-line-icon.d.ts +6 -0
- package/dist/component/Icons/code-s-slash-line-icon.js +13 -0
- package/dist/component/Icons/copy-icon.d.ts +6 -0
- package/dist/component/Icons/copy-icon.js +13 -0
- package/dist/component/Icons/custom-size-icon.d.ts +6 -0
- package/dist/component/Icons/custom-size-icon.js +13 -0
- package/dist/component/Icons/delete-column-icon.d.ts +6 -0
- package/dist/component/Icons/delete-column-icon.js +13 -0
- package/dist/component/Icons/delete-line-icon.d.ts +6 -0
- package/dist/component/Icons/delete-line-icon.js +13 -0
- package/dist/component/Icons/delete-row-icon.d.ts +6 -0
- package/dist/component/Icons/delete-row-icon.js +13 -0
- package/dist/component/Icons/double-quotes-l-icon.d.ts +6 -0
- package/dist/component/Icons/double-quotes-l-icon.js +13 -0
- package/dist/component/Icons/download-line-icon.d.ts +6 -0
- package/dist/component/Icons/download-line-icon.js +13 -0
- package/dist/component/Icons/draggable-icon.d.ts +6 -0
- package/dist/component/Icons/draggable-icon.js +13 -0
- package/dist/component/Icons/edit-box-line-icon.d.ts +6 -0
- package/dist/component/Icons/edit-box-line-icon.js +13 -0
- package/dist/component/Icons/error-warning-fill-icon.d.ts +6 -0
- package/dist/component/Icons/error-warning-fill-icon.js +13 -0
- package/dist/component/Icons/export-line-icon.d.ts +6 -0
- package/dist/component/Icons/export-line-icon.js +13 -0
- package/dist/component/Icons/file-copy-line-icon.d.ts +6 -0
- package/dist/component/Icons/file-copy-line-icon.js +13 -0
- package/dist/component/Icons/file-upload-line-icon.d.ts +6 -0
- package/dist/component/Icons/file-upload-line-icon.js +13 -0
- package/dist/component/Icons/flow-chart-icon.d.ts +6 -0
- package/dist/component/Icons/flow-chart-icon.js +13 -0
- package/dist/component/Icons/font-color-icon.d.ts +6 -0
- package/dist/component/Icons/font-color-icon.js +13 -0
- package/dist/component/Icons/font-family-icon.d.ts +6 -0
- package/dist/component/Icons/font-family-icon.js +13 -0
- package/dist/component/Icons/font-size-icon.d.ts +6 -0
- package/dist/component/Icons/font-size-icon.js +13 -0
- package/dist/component/Icons/format-clear-icon.d.ts +6 -0
- package/dist/component/Icons/format-clear-icon.js +13 -0
- package/dist/component/Icons/formula-icon.d.ts +6 -0
- package/dist/component/Icons/formula-icon.js +13 -0
- package/dist/component/Icons/fullscreen-exit-line-icon.d.ts +6 -0
- package/dist/component/Icons/fullscreen-exit-line-icon.js +13 -0
- package/dist/component/Icons/fullscreen-line-icon.d.ts +6 -0
- package/dist/component/Icons/fullscreen-line-icon.js +13 -0
- package/dist/component/Icons/functions-icon.d.ts +6 -0
- package/dist/component/Icons/functions-icon.js +13 -0
- package/dist/component/Icons/game-line-icon.d.ts +6 -0
- package/dist/component/Icons/game-line-icon.js +13 -0
- package/dist/component/Icons/h-1-icon.d.ts +6 -0
- package/dist/component/Icons/h-1-icon.js +13 -0
- package/dist/component/Icons/h-2-icon.d.ts +6 -0
- package/dist/component/Icons/h-2-icon.js +13 -0
- package/dist/component/Icons/h-3-icon.d.ts +6 -0
- package/dist/component/Icons/h-3-icon.js +13 -0
- package/dist/component/Icons/h-4-icon.d.ts +6 -0
- package/dist/component/Icons/h-4-icon.js +13 -0
- package/dist/component/Icons/h-5-icon.d.ts +6 -0
- package/dist/component/Icons/h-5-icon.js +13 -0
- package/dist/component/Icons/h-6-icon.d.ts +6 -0
- package/dist/component/Icons/h-6-icon.js +13 -0
- package/dist/component/Icons/heading-icon.d.ts +6 -0
- package/dist/component/Icons/heading-icon.js +13 -0
- package/dist/component/Icons/image-add-line-icon.d.ts +6 -0
- package/dist/component/Icons/image-add-line-icon.js +13 -0
- package/dist/component/Icons/image-line-icon.d.ts +6 -0
- package/dist/component/Icons/image-line-icon.js +13 -0
- package/dist/component/Icons/import-line-icon.d.ts +6 -0
- package/dist/component/Icons/import-line-icon.js +13 -0
- package/dist/component/Icons/indent-decrease-icon.d.ts +6 -0
- package/dist/component/Icons/indent-decrease-icon.js +13 -0
- package/dist/component/Icons/indent-increase-icon.d.ts +6 -0
- package/dist/component/Icons/indent-increase-icon.js +13 -0
- package/dist/component/Icons/index.d.ts +120 -0
- package/dist/component/Icons/index.js +123 -0
- package/dist/component/Icons/information-2-fill-icon.d.ts +6 -0
- package/dist/component/Icons/information-2-fill-icon.js +13 -0
- package/dist/component/Icons/information-2-line-icon.d.ts +6 -0
- package/dist/component/Icons/information-2-line-icon.js +13 -0
- package/dist/component/Icons/insert-column-left-icon.d.ts +6 -0
- package/dist/component/Icons/insert-column-left-icon.js +13 -0
- package/dist/component/Icons/insert-column-right-icon.d.ts +6 -0
- package/dist/component/Icons/insert-column-right-icon.js +13 -0
- package/dist/component/Icons/insert-row-bottom-icon.d.ts +6 -0
- package/dist/component/Icons/insert-row-bottom-icon.js +13 -0
- package/dist/component/Icons/insert-row-top-icon.d.ts +6 -0
- package/dist/component/Icons/insert-row-top-icon.js +13 -0
- package/dist/component/Icons/italic-icon.d.ts +6 -0
- package/dist/component/Icons/italic-icon.js +13 -0
- package/dist/component/Icons/layout-left-2-line-icon.d.ts +6 -0
- package/dist/component/Icons/layout-left-2-line-icon.js +13 -0
- package/dist/component/Icons/layout-top-2-line-icon.d.ts +6 -0
- package/dist/component/Icons/layout-top-2-line-icon.js +13 -0
- package/dist/component/Icons/link-icon.d.ts +6 -0
- package/dist/component/Icons/link-icon.js +13 -0
- package/dist/component/Icons/link-unlink-icon.d.ts +6 -0
- package/dist/component/Icons/link-unlink-icon.js +13 -0
- package/dist/component/Icons/list-check-2-icon.d.ts +6 -0
- package/dist/component/Icons/list-check-2-icon.js +13 -0
- package/dist/component/Icons/list-check-3-icon.d.ts +6 -0
- package/dist/component/Icons/list-check-3-icon.js +13 -0
- package/dist/component/Icons/list-ordered-2-icon.d.ts +6 -0
- package/dist/component/Icons/list-ordered-2-icon.js +13 -0
- package/dist/component/Icons/list-unordered-icon.d.ts +6 -0
- package/dist/component/Icons/list-unordered-icon.js +13 -0
- package/dist/component/Icons/markdown-line-icon.d.ts +6 -0
- package/dist/component/Icons/markdown-line-icon.js +13 -0
- package/dist/component/Icons/markup-line-icon.d.ts +6 -0
- package/dist/component/Icons/markup-line-icon.js +13 -0
- package/dist/component/Icons/menu-fold-2-fill-icon.d.ts +6 -0
- package/dist/component/Icons/menu-fold-2-fill-icon.js +13 -0
- package/dist/component/Icons/merge-cells-horizontal-icon.d.ts +6 -0
- package/dist/component/Icons/merge-cells-horizontal-icon.js +13 -0
- package/dist/component/Icons/merge-cells-vertical-icon.d.ts +6 -0
- package/dist/component/Icons/merge-cells-vertical-icon.js +13 -0
- package/dist/component/Icons/mind-map-icon.d.ts +6 -0
- package/dist/component/Icons/mind-map-icon.js +13 -0
- package/dist/component/Icons/more-line-icon.d.ts +6 -0
- package/dist/component/Icons/more-line-icon.js +13 -0
- package/dist/component/Icons/movie-line-icon.d.ts +6 -0
- package/dist/component/Icons/movie-line-icon.js +13 -0
- package/dist/component/Icons/music-2-line-icon.d.ts +6 -0
- package/dist/component/Icons/music-2-line-icon.js +13 -0
- package/dist/component/Icons/node-tree-icon.d.ts +6 -0
- package/dist/component/Icons/node-tree-icon.js +13 -0
- package/dist/component/Icons/notification-3-line-icon.d.ts +6 -0
- package/dist/component/Icons/notification-3-line-icon.js +13 -0
- package/dist/component/Icons/organization-chart-icon.d.ts +6 -0
- package/dist/component/Icons/organization-chart-icon.js +13 -0
- package/dist/component/Icons/pause-line-icon.d.ts +6 -0
- package/dist/component/Icons/pause-line-icon.js +13 -0
- package/dist/component/Icons/play-line-icon.d.ts +6 -0
- package/dist/component/Icons/play-line-icon.js +13 -0
- package/dist/component/Icons/question-fill-icon.d.ts +6 -0
- package/dist/component/Icons/question-fill-icon.js +13 -0
- package/dist/component/Icons/quote-text-icon.d.ts +6 -0
- package/dist/component/Icons/quote-text-icon.js +13 -0
- package/dist/component/Icons/repeat-2-line-icon.d.ts +6 -0
- package/dist/component/Icons/repeat-2-line-icon.js +13 -0
- package/dist/component/Icons/reset-left-fill-icon.d.ts +6 -0
- package/dist/component/Icons/reset-left-fill-icon.js +13 -0
- package/dist/component/Icons/scissors-cut-line-icon.d.ts +6 -0
- package/dist/component/Icons/scissors-cut-line-icon.js +13 -0
- package/dist/component/Icons/screenshot-line-icon.d.ts +6 -0
- package/dist/component/Icons/screenshot-line-icon.js +13 -0
- package/dist/component/Icons/scroll-to-bottom-line-icon.d.ts +6 -0
- package/dist/component/Icons/scroll-to-bottom-line-icon.js +13 -0
- package/dist/component/Icons/separator-icon.d.ts +6 -0
- package/dist/component/Icons/separator-icon.js +13 -0
- package/dist/component/Icons/share-box-line-icon.d.ts +6 -0
- package/dist/component/Icons/share-box-line-icon.js +13 -0
- package/dist/component/Icons/slash-commands-2-icon.d.ts +3 -0
- package/dist/component/Icons/slash-commands-2-icon.js +13 -0
- package/dist/component/Icons/speed-line-icon.d.ts +6 -0
- package/dist/component/Icons/speed-line-icon.js +13 -0
- package/dist/component/Icons/split-cells-horizontal-icon.d.ts +6 -0
- package/dist/component/Icons/split-cells-horizontal-icon.js +13 -0
- package/dist/component/Icons/split-cells-vertical-icon.d.ts +6 -0
- package/dist/component/Icons/split-cells-vertical-icon.js +13 -0
- package/dist/component/Icons/square-root-icon.d.ts +6 -0
- package/dist/component/Icons/square-root-icon.js +13 -0
- package/dist/component/Icons/strikethrough-icon.d.ts +6 -0
- package/dist/component/Icons/strikethrough-icon.js +13 -0
- package/dist/component/Icons/subscript-icon.d.ts +6 -0
- package/dist/component/Icons/subscript-icon.js +13 -0
- package/dist/component/Icons/superscript-icon.d.ts +6 -0
- package/dist/component/Icons/superscript-icon.js +13 -0
- package/dist/component/Icons/table-2-icon.d.ts +6 -0
- package/dist/component/Icons/table-2-icon.js +13 -0
- package/dist/component/Icons/text-icon.d.ts +6 -0
- package/dist/component/Icons/text-icon.js +13 -0
- package/dist/component/Icons/text-wrap-icon.d.ts +6 -0
- package/dist/component/Icons/text-wrap-icon.js +13 -0
- package/dist/component/Icons/title-icon.d.ts +6 -0
- package/dist/component/Icons/title-icon.js +13 -0
- package/dist/component/Icons/underline-icon.d.ts +6 -0
- package/dist/component/Icons/underline-icon.js +13 -0
- package/dist/component/Icons/upload-cloud-2-line-icon.d.ts +6 -0
- package/dist/component/Icons/upload-cloud-2-line-icon.js +13 -0
- package/dist/component/Icons/upload-icon.d.ts +6 -0
- package/dist/component/Icons/upload-icon.js +13 -0
- package/dist/component/Icons/volume-mute-line-icon.d.ts +6 -0
- package/dist/component/Icons/volume-mute-line-icon.js +13 -0
- package/dist/component/Icons/volume-up-line-icon.d.ts +6 -0
- package/dist/component/Icons/volume-up-line-icon.js +13 -0
- package/dist/component/Icons/window-fill-icon.d.ts +6 -0
- package/dist/component/Icons/window-fill-icon.js +13 -0
- package/dist/component/Menu/NestedList.d.ts +14 -0
- package/dist/component/Menu/NestedList.js +151 -0
- package/dist/component/Menu/index.d.ts +4 -0
- package/dist/component/Menu/index.js +84 -0
- package/dist/component/Toolbar/EditorAlignSelect.d.ts +7 -0
- package/dist/component/Toolbar/EditorAlignSelect.js +187 -0
- package/dist/component/Toolbar/EditorCode.d.ts +7 -0
- package/dist/component/Toolbar/EditorCode.js +161 -0
- package/dist/component/Toolbar/EditorFontBgColor.d.ts +7 -0
- package/dist/component/Toolbar/EditorFontBgColor.js +244 -0
- package/dist/component/Toolbar/EditorFontColor.d.ts +7 -0
- package/dist/component/Toolbar/EditorFontColor.js +246 -0
- package/dist/component/Toolbar/EditorFontSize.d.ts +7 -0
- package/dist/component/Toolbar/EditorFontSize.js +149 -0
- package/dist/component/Toolbar/EditorHeading.d.ts +7 -0
- package/dist/component/Toolbar/EditorHeading.js +185 -0
- package/dist/component/Toolbar/EditorInsert/index.d.ts +7 -0
- package/dist/component/Toolbar/EditorInsert/index.js +197 -0
- package/dist/component/Toolbar/EditorListSelect.d.ts +7 -0
- package/dist/component/Toolbar/EditorListSelect.js +174 -0
- package/dist/component/Toolbar/EditorMath.d.ts +7 -0
- package/dist/component/Toolbar/EditorMath.js +159 -0
- package/dist/component/Toolbar/EditorMore/NotificationDialog.d.ts +7 -0
- package/dist/component/Toolbar/EditorMore/NotificationDialog.js +73 -0
- package/dist/component/Toolbar/EditorMore/index.d.ts +7 -0
- package/dist/component/Toolbar/EditorMore/index.js +112 -0
- package/dist/component/Toolbar/EditorScript.d.ts +7 -0
- package/dist/component/Toolbar/EditorScript.js +161 -0
- package/dist/component/Toolbar/EditorVerticalAlignSelect.d.ts +7 -0
- package/dist/component/Toolbar/EditorVerticalAlignSelect.js +174 -0
- package/dist/component/Toolbar/Item.d.ts +16 -0
- package/dist/component/Toolbar/Item.js +74 -0
- package/dist/component/Toolbar/TableSizePicker.d.ts +5 -0
- package/dist/component/Toolbar/TableSizePicker.js +80 -0
- package/dist/component/Toolbar/index.d.ts +13 -0
- package/dist/component/Toolbar/index.js +13 -0
- package/dist/component/index.d.ts +3 -0
- package/dist/component/index.js +3 -0
- package/dist/contants/enums.d.ts +32 -0
- package/dist/contants/enums.js +108 -0
- package/dist/contants/highlight.d.ts +4 -0
- package/dist/contants/highlight.js +580 -0
- package/dist/contants/placeholder.d.ts +16 -0
- package/dist/contants/placeholder.js +16 -0
- package/dist/contants/shortcut-key.d.ts +48 -0
- package/dist/contants/shortcut-key.js +224 -0
- package/dist/contants/slash-commands.d.ts +14 -0
- package/dist/contants/slash-commands.js +370 -0
- package/dist/extension/component/Alert/index.d.ts +9 -0
- package/dist/extension/component/Alert/index.js +204 -0
- package/dist/extension/component/Attachment/Insert.d.ts +13 -0
- package/dist/extension/component/Attachment/Insert.js +222 -0
- package/dist/extension/component/Attachment/Readonly.d.ts +9 -0
- package/dist/extension/component/Attachment/Readonly.js +92 -0
- package/dist/extension/component/Attachment/index.d.ts +13 -0
- package/dist/extension/component/Attachment/index.js +317 -0
- package/dist/extension/component/Audio/Insert.d.ts +10 -0
- package/dist/extension/component/Audio/Insert.js +351 -0
- package/dist/extension/component/Audio/Readonly.d.ts +8 -0
- package/dist/extension/component/Audio/Readonly.js +428 -0
- package/dist/extension/component/Audio/index.d.ts +14 -0
- package/dist/extension/component/Audio/index.js +740 -0
- package/dist/extension/component/CodeBlock/Readonly.d.ts +4 -0
- package/dist/extension/component/CodeBlock/Readonly.js +133 -0
- package/dist/extension/component/CodeBlock/index.d.ts +4 -0
- package/dist/extension/component/CodeBlock/index.js +291 -0
- package/dist/extension/component/CustomLink/Insert.d.ts +0 -0
- package/dist/extension/component/CustomLink/Insert.js +176 -0
- package/dist/extension/component/CustomLink/Readonly.d.ts +0 -0
- package/dist/extension/component/CustomLink/Readonly.js +106 -0
- package/dist/extension/component/CustomLink/index.d.ts +0 -0
- package/dist/extension/component/CustomLink/index.js +440 -0
- package/dist/extension/component/EmojiList/index.d.ts +14 -0
- package/dist/extension/component/EmojiList/index.js +104 -0
- package/dist/extension/component/Iframe/Insert.d.ts +14 -0
- package/dist/extension/component/Iframe/Insert.js +112 -0
- package/dist/extension/component/Iframe/Readonly.d.ts +10 -0
- package/dist/extension/component/Iframe/Readonly.js +14 -0
- package/dist/extension/component/Iframe/index.d.ts +5 -0
- package/dist/extension/component/Iframe/index.js +290 -0
- package/dist/extension/component/Image/Crop.d.ts +12 -0
- package/dist/extension/component/Image/Crop.js +218 -0
- package/dist/extension/component/Image/Insert.d.ts +10 -0
- package/dist/extension/component/Image/Insert.js +309 -0
- package/dist/extension/component/Image/Readonly.d.ts +8 -0
- package/dist/extension/component/Image/Readonly.js +51 -0
- package/dist/extension/component/Image/index.d.ts +21 -0
- package/dist/extension/component/Image/index.js +372 -0
- package/dist/extension/component/Link/Insert.d.ts +10 -0
- package/dist/extension/component/Link/Insert.js +253 -0
- package/dist/extension/component/Link/Readonly.d.ts +8 -0
- package/dist/extension/component/Link/Readonly.js +111 -0
- package/dist/extension/component/Link/index.d.ts +12 -0
- package/dist/extension/component/Link/index.js +515 -0
- package/dist/extension/component/Mathematics/block/Readonly.d.ts +9 -0
- package/dist/extension/component/Mathematics/block/Readonly.js +35 -0
- package/dist/extension/component/Mathematics/block/index.d.ts +8 -0
- package/dist/extension/component/Mathematics/block/index.js +149 -0
- package/dist/extension/component/Mathematics/index.d.ts +3 -0
- package/dist/extension/component/Mathematics/index.js +3 -0
- package/dist/extension/component/Mathematics/inline/Readonly.d.ts +9 -0
- package/dist/extension/component/Mathematics/inline/Readonly.js +33 -0
- package/dist/extension/component/Mathematics/inline/index.d.ts +8 -0
- package/dist/extension/component/Mathematics/inline/index.js +148 -0
- package/dist/extension/component/MentionList/index.d.ts +13 -0
- package/dist/extension/component/MentionList/index.js +92 -0
- package/dist/extension/component/SlashCommandsList/Overlay.d.ts +10 -0
- package/dist/extension/component/SlashCommandsList/Overlay.js +26 -0
- package/dist/extension/component/SlashCommandsList/index.d.ts +4 -0
- package/dist/extension/component/SlashCommandsList/index.js +266 -0
- package/dist/extension/component/Table/ContextMenu.d.ts +10 -0
- package/dist/extension/component/Table/ContextMenu.js +228 -0
- package/dist/extension/component/Table/TableContextMenuPlugin.d.ts +9 -0
- package/dist/extension/component/Table/TableContextMenuPlugin.js +272 -0
- package/dist/extension/component/Table/index.d.ts +2 -0
- package/dist/extension/component/Table/index.js +2 -0
- package/dist/extension/component/UploadProgress/index.d.ts +10 -0
- package/dist/extension/component/UploadProgress/index.js +103 -0
- package/dist/extension/component/Video/Insert.d.ts +10 -0
- package/dist/extension/component/Video/Insert.js +257 -0
- package/dist/extension/component/Video/Readonly.d.ts +8 -0
- package/dist/extension/component/Video/Readonly.js +40 -0
- package/dist/extension/component/Video/index.d.ts +14 -0
- package/dist/extension/component/Video/index.js +166 -0
- package/dist/extension/extension/SlashCommands.d.ts +3 -0
- package/dist/extension/extension/SlashCommands.js +25 -0
- package/dist/extension/extension/StructuredDiff.d.ts +18 -0
- package/dist/extension/extension/StructuredDiff.js +131 -0
- package/dist/extension/extension/index.d.ts +2 -0
- package/dist/extension/extension/index.js +2 -0
- package/dist/extension/index.d.ts +2 -0
- package/dist/extension/index.js +146 -0
- package/dist/extension/mark/Code.d.ts +2 -0
- package/dist/extension/mark/Code.js +9 -0
- package/dist/extension/mark/Link.d.ts +0 -0
- package/dist/extension/mark/Link.js +58 -0
- package/dist/extension/mark/index.d.ts +0 -0
- package/dist/extension/mark/index.js +1 -0
- package/dist/extension/node/Alert.d.ts +33 -0
- package/dist/extension/node/Alert.js +116 -0
- package/dist/extension/node/Attachment.d.ts +28 -0
- package/dist/extension/node/Attachment.js +227 -0
- package/dist/extension/node/Audio.d.ts +23 -0
- package/dist/extension/node/Audio.js +194 -0
- package/dist/extension/node/CodeBlockLowlight.d.ts +1 -0
- package/dist/extension/node/CodeBlockLowlight.js +42 -0
- package/dist/extension/node/Details.d.ts +3 -0
- package/dist/extension/node/Details.js +39 -0
- package/dist/extension/node/Emoji.d.ts +1 -0
- package/dist/extension/node/Emoji.js +7 -0
- package/dist/extension/node/FileHandler.d.ts +4 -0
- package/dist/extension/node/FileHandler.js +294 -0
- package/dist/extension/node/Iframe.d.ts +16 -0
- package/dist/extension/node/Iframe.js +120 -0
- package/dist/extension/node/Image.d.ts +3 -0
- package/dist/extension/node/Image.js +38 -0
- package/dist/extension/node/Indent.d.ts +17 -0
- package/dist/extension/node/Indent.js +103 -0
- package/dist/extension/node/Link/helpers/autolink.d.ts +15 -0
- package/dist/extension/node/Link/helpers/autolink.js +162 -0
- package/dist/extension/node/Link/helpers/clickHandler.d.ts +10 -0
- package/dist/extension/node/Link/helpers/clickHandler.js +46 -0
- package/dist/extension/node/Link/helpers/pasteHandler.d.ts +10 -0
- package/dist/extension/node/Link/helpers/pasteHandler.js +32 -0
- package/dist/extension/node/Link/helpers/whitespace.d.ts +4 -0
- package/dist/extension/node/Link/helpers/whitespace.js +6 -0
- package/dist/extension/node/Link/index.d.ts +162 -0
- package/dist/extension/node/Link/index.js +462 -0
- package/dist/extension/node/ListKit.d.ts +2 -0
- package/dist/extension/node/ListKit.js +23 -0
- package/dist/extension/node/Mathematics.d.ts +27 -0
- package/dist/extension/node/Mathematics.js +97 -0
- package/dist/extension/node/Mention.d.ts +2 -0
- package/dist/extension/node/Mention.js +10 -0
- package/dist/extension/node/Table.d.ts +5 -0
- package/dist/extension/node/Table.js +283 -0
- package/dist/extension/node/TableOfContents/index.d.ts +9 -0
- package/dist/extension/node/TableOfContents/index.js +391 -0
- package/dist/extension/node/TableOfContents/plugin.d.ts +6 -0
- package/dist/extension/node/TableOfContents/plugin.js +58 -0
- package/dist/extension/node/TableOfContents/type.d.ts +45 -0
- package/dist/extension/node/TableOfContents/type.js +1 -0
- package/dist/extension/node/TableOfContents/utils.d.ts +6 -0
- package/dist/extension/node/TableOfContents/utils.js +70 -0
- package/dist/extension/node/UploadProgress.d.ts +21 -0
- package/dist/extension/node/UploadProgress.js +135 -0
- package/dist/extension/node/VerticalAlign.d.ts +49 -0
- package/dist/extension/node/VerticalAlign.js +88 -0
- package/dist/extension/node/Video.d.ts +23 -0
- package/dist/extension/node/Video.js +195 -0
- package/dist/extension/node/Youtube.d.ts +3 -0
- package/dist/extension/node/Youtube.js +14 -0
- package/dist/extension/node/index.d.ts +20 -0
- package/dist/extension/node/index.js +20 -0
- package/dist/extension/suggestion/emoji.d.ts +3 -0
- package/dist/extension/suggestion/emoji.js +57 -0
- package/dist/extension/suggestion/mention.d.ts +4 -0
- package/dist/extension/suggestion/mention.js +88 -0
- package/dist/extension/suggestion/slash.d.ts +39 -0
- package/dist/extension/suggestion/slash.js +94 -0
- package/dist/hook/fn.d.ts +13 -0
- package/dist/hook/fn.js +37 -0
- package/dist/hook/index.d.ts +4 -0
- package/dist/hook/index.js +110 -0
- package/dist/index.css +555 -0
- package/dist/index.d.ts +8 -0
- package/dist/index.js +8 -0
- package/dist/themes/color.d.ts +5 -0
- package/dist/themes/color.js +4 -0
- package/dist/themes/componentStyleOverrides.d.ts +365 -0
- package/dist/themes/componentStyleOverrides.js +392 -0
- package/dist/themes/custom.d.ts +5 -0
- package/dist/themes/custom.js +4 -0
- package/dist/themes/dark.d.ts +84 -0
- package/dist/themes/dark.js +84 -0
- package/dist/themes/index.d.ts +19 -0
- package/dist/themes/index.js +37 -0
- package/dist/themes/light.d.ts +84 -0
- package/dist/themes/light.js +84 -0
- package/dist/themes/palette.d.ts +92 -0
- package/dist/themes/palette.js +24 -0
- package/dist/themes/shadows.d.ts +2 -0
- package/dist/themes/shadows.js +3 -0
- package/dist/themes/themeContext.d.ts +8 -0
- package/dist/themes/themeContext.js +3 -0
- package/dist/themes/typography.d.ts +6 -0
- package/dist/themes/typography.js +8 -0
- package/dist/type/index.d.ts +121 -0
- package/dist/type/index.js +1 -0
- package/dist/types/images.d.ts +19 -0
- package/dist/util/decorations.d.ts +22 -0
- package/dist/util/decorations.js +302 -0
- package/dist/util/fileDownload.d.ts +16 -0
- package/dist/util/fileDownload.js +268 -0
- package/dist/util/fileHandler.d.ts +7 -0
- package/dist/util/fileHandler.js +79 -0
- package/dist/util/floating.d.ts +3 -0
- package/dist/util/floating.js +23 -0
- package/dist/util/index.d.ts +12 -0
- package/dist/util/index.js +40 -0
- package/dist/util/linewiseConvert.d.ts +40 -0
- package/dist/util/linewiseConvert.js +221 -0
- package/dist/util/migrateMathStrings.d.ts +73 -0
- package/dist/util/migrateMathStrings.js +192 -0
- package/dist/util/resourceExtractor.d.ts +15 -0
- package/dist/util/resourceExtractor.js +61 -0
- package/dist/util/shortcutKey.d.ts +2 -0
- package/dist/util/shortcutKey.js +9 -0
- package/dist/util/structuredDiff.d.ts +59 -0
- package/dist/util/structuredDiff.js +550 -0
- package/package.json +1 -1
|
@@ -0,0 +1,302 @@
|
|
|
1
|
+
function _createForOfIteratorHelper(o, allowArrayLike) { var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"]; if (!it) { if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") { if (it) o = it; var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e) { throw _e; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var normalCompletion = true, didErr = false, err; return { s: function s() { it = it.call(o); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e2) { didErr = true; err = _e2; }, f: function f() { try { if (!normalCompletion && it.return != null) it.return(); } finally { if (didErr) throw err; } } }; }
|
|
2
|
+
function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
|
|
3
|
+
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
|
|
4
|
+
import { Decoration, DecorationSet } from '@tiptap/pm/view';
|
|
5
|
+
import { pathToPos } from "./structuredDiff";
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* 创建插入内容的装饰
|
|
9
|
+
* @param {number} from - 开始位置
|
|
10
|
+
* @param {number} to - 结束位置
|
|
11
|
+
* @returns {Decoration} 装饰对象
|
|
12
|
+
*/
|
|
13
|
+
function createInsertDecoration(from, to) {
|
|
14
|
+
return Decoration.inline(from, to, {
|
|
15
|
+
class: 'diff-insert-highlight',
|
|
16
|
+
style: 'background-color: #d4edda; color: #28a745; padding: 2px 4px; border-radius: 3px; margin: 0 1px; border: 1px dashed #28a745;'
|
|
17
|
+
});
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
/**
|
|
21
|
+
* 创建修改内容的装饰
|
|
22
|
+
* @param {number} from - 开始位置
|
|
23
|
+
* @param {number} to - 结束位置
|
|
24
|
+
* @returns {Decoration} 装饰对象
|
|
25
|
+
*/
|
|
26
|
+
function createModifyDecoration(from, to) {
|
|
27
|
+
return Decoration.inline(from, to, {
|
|
28
|
+
class: 'diff-modify-highlight',
|
|
29
|
+
style: 'background-color: #fff3cd; color: #856404; padding: 2px 4px; border-radius: 3px; margin: 0 1px; border: 1px dashed #856404;'
|
|
30
|
+
});
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
/**
|
|
34
|
+
* 创建删除内容的widget装饰
|
|
35
|
+
* @param {number} pos - 插入位置
|
|
36
|
+
* @param {Object} deletedNode - 被删除的节点
|
|
37
|
+
* @returns {Decoration} widget装饰对象
|
|
38
|
+
*/
|
|
39
|
+
function createDeleteWidget(pos, deletedNode) {
|
|
40
|
+
var widget = document.createElement('span');
|
|
41
|
+
widget.className = 'diff-delete-widget';
|
|
42
|
+
widget.style.cssText = "\n background-color: rgba(220, 53, 69, 0.1);\n color: #dc3545;\n text-decoration: line-through;\n padding: 2px 4px;\n border-radius: 3px;\n margin: 0 1px;\n border: 1px dashed #dc3545;\n font-style: italic;\n ";
|
|
43
|
+
|
|
44
|
+
// 提取删除内容的文本
|
|
45
|
+
var deletedText = extractTextFromNode(deletedNode);
|
|
46
|
+
widget.textContent = deletedText || '[已删除]';
|
|
47
|
+
|
|
48
|
+
// 添加工具提示
|
|
49
|
+
widget.title = "\u5220\u9664\u7684\u5185\u5BB9: ".concat(deletedText);
|
|
50
|
+
return Decoration.widget(pos, widget, {
|
|
51
|
+
side: 1
|
|
52
|
+
});
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
/**
|
|
56
|
+
* 从节点中提取文本内容
|
|
57
|
+
* @param {Object} node - ProseMirror节点
|
|
58
|
+
* @returns {string} 提取的文本
|
|
59
|
+
*/
|
|
60
|
+
function extractTextFromNode(node) {
|
|
61
|
+
if (!node) return '';
|
|
62
|
+
if (node.type === 'text') {
|
|
63
|
+
return node.text || '';
|
|
64
|
+
}
|
|
65
|
+
if (node.content && Array.isArray(node.content)) {
|
|
66
|
+
return node.content.map(function (child) {
|
|
67
|
+
return extractTextFromNode(child);
|
|
68
|
+
}).join('');
|
|
69
|
+
}
|
|
70
|
+
return '';
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
/**
|
|
74
|
+
* 根据差异数组创建装饰集合
|
|
75
|
+
* @param {Array} diffs - 差异数组
|
|
76
|
+
* @param {Object} doc - ProseMirror文档
|
|
77
|
+
* @returns {DecorationSet} 装饰集合
|
|
78
|
+
*/
|
|
79
|
+
export function createDecorationsFromDiffs(diffs, doc) {
|
|
80
|
+
var decorations = [];
|
|
81
|
+
diffs.forEach(function (diff) {
|
|
82
|
+
try {
|
|
83
|
+
var pos = pathToPos(diff.path, doc);
|
|
84
|
+
var pmNodeAtPath = getPMNodeAtPath(diff.path, doc);
|
|
85
|
+
switch (diff.type) {
|
|
86
|
+
case 'insert':
|
|
87
|
+
if (diff.textDiff) {
|
|
88
|
+
// 文本级别的插入
|
|
89
|
+
var base = adjustBaseForInline(pmNodeAtPath, pos);
|
|
90
|
+
var from = base + mapInlineOffsetToPM(pmNodeAtPath, diff.textDiff.offset);
|
|
91
|
+
var to = base + mapInlineOffsetToPM(pmNodeAtPath, diff.textDiff.offset + diff.textDiff.length);
|
|
92
|
+
decorations.push(createInsertDecoration(from, to));
|
|
93
|
+
} else if (diff.node) {
|
|
94
|
+
// 节点级别的插入
|
|
95
|
+
if (pmNodeAtPath) {
|
|
96
|
+
var _text;
|
|
97
|
+
if (pmNodeAtPath.isText && (((_text = pmNodeAtPath.text) === null || _text === void 0 ? void 0 : _text.length) || 0) > 0) {
|
|
98
|
+
var _text2;
|
|
99
|
+
var _from = pos;
|
|
100
|
+
var _to = pos + (((_text2 = pmNodeAtPath.text) === null || _text2 === void 0 ? void 0 : _text2.length) || 0);
|
|
101
|
+
decorations.push(createInsertDecoration(_from, _to));
|
|
102
|
+
} else {
|
|
103
|
+
var _from2 = pos;
|
|
104
|
+
var _to2 = pos + pmNodeAtPath.nodeSize;
|
|
105
|
+
decorations.push(Decoration.node(_from2, _to2, {
|
|
106
|
+
class: 'diff-insert-highlight',
|
|
107
|
+
style: 'background-color: rgba(40,167,69,0.12); border-radius: 3px; border: 1px dashed #28a745;'
|
|
108
|
+
}));
|
|
109
|
+
}
|
|
110
|
+
} else {
|
|
111
|
+
// 回退到基于 JSON 节点的估算
|
|
112
|
+
var nodeSize = getNodeSize(diff.node);
|
|
113
|
+
var _from3 = pos + 1;
|
|
114
|
+
var _to3 = pos + nodeSize - 1;
|
|
115
|
+
if (_to3 > _from3) {
|
|
116
|
+
decorations.push(createInsertDecoration(_from3, _to3));
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
break;
|
|
121
|
+
case 'delete':
|
|
122
|
+
if (diff.textDiff) {
|
|
123
|
+
// 文本级别的删除 - 使用widget显示
|
|
124
|
+
var _base = adjustBaseForInline(pmNodeAtPath, pos);
|
|
125
|
+
var widgetPos = _base + mapInlineOffsetToPM(pmNodeAtPath, diff.textDiff.offset);
|
|
126
|
+
decorations.push(createDeleteWidget(widgetPos, {
|
|
127
|
+
type: 'text',
|
|
128
|
+
text: diff.textDiff.text
|
|
129
|
+
}));
|
|
130
|
+
} else if (diff.node) {
|
|
131
|
+
// 节点级别的删除 - 使用widget显示
|
|
132
|
+
decorations.push(createDeleteWidget(pos, diff.node));
|
|
133
|
+
}
|
|
134
|
+
break;
|
|
135
|
+
case 'modify':
|
|
136
|
+
if (diff.attrChange) {
|
|
137
|
+
// 基于 marks 的区间高亮
|
|
138
|
+
if (diff.attrChange.key === 'marks' && typeof diff.attrChange.fromOffset === 'number' && typeof diff.attrChange.toOffset === 'number') {
|
|
139
|
+
var _base2 = adjustBaseForInline(pmNodeAtPath, pos);
|
|
140
|
+
var _from4 = _base2 + mapInlineOffsetToPM(pmNodeAtPath, diff.attrChange.fromOffset);
|
|
141
|
+
var _to4 = _base2 + mapInlineOffsetToPM(pmNodeAtPath, diff.attrChange.toOffset);
|
|
142
|
+
if (_to4 > _from4) {
|
|
143
|
+
decorations.push(createModifyDecoration(_from4, _to4));
|
|
144
|
+
}
|
|
145
|
+
} else if (diff.attrChange.key === 'marks' && pmNodeAtPath && pmNodeAtPath.isText) {
|
|
146
|
+
var textLength = pmNodeAtPath.text ? pmNodeAtPath.text.length : 0;
|
|
147
|
+
if (textLength > 0) {
|
|
148
|
+
var _base3 = adjustBaseForInline(pmNodeAtPath, pos);
|
|
149
|
+
decorations.push(createModifyDecoration(_base3, _base3 + textLength));
|
|
150
|
+
}
|
|
151
|
+
} else {
|
|
152
|
+
var _type;
|
|
153
|
+
// 其他属性修改 - 节点级高亮
|
|
154
|
+
var nodeName = (pmNodeAtPath === null || pmNodeAtPath === void 0 || (_type = pmNodeAtPath.type) === null || _type === void 0 ? void 0 : _type.name) || '';
|
|
155
|
+
var isDetailsFamily = nodeName === 'details' || nodeName === 'detailsSummary' || nodeName === 'detailsContent';
|
|
156
|
+
if (!isDetailsFamily) {
|
|
157
|
+
var _nodeSize = getPMNodeSizeAtPath(diff.path, doc);
|
|
158
|
+
var _from5 = pos;
|
|
159
|
+
var _to5 = pos + _nodeSize;
|
|
160
|
+
decorations.push(Decoration.node(_from5, _to5, {
|
|
161
|
+
class: 'diff-modify-highlight',
|
|
162
|
+
style: 'background-color: rgba(255,193,7,0.12); border-radius: 3px; border: 1px dashed #856404;'
|
|
163
|
+
}));
|
|
164
|
+
}
|
|
165
|
+
}
|
|
166
|
+
}
|
|
167
|
+
break;
|
|
168
|
+
}
|
|
169
|
+
} catch (error) {
|
|
170
|
+
console.warn('创建装饰时出错:', error, diff);
|
|
171
|
+
}
|
|
172
|
+
});
|
|
173
|
+
return DecorationSet.create(doc, decorations);
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
/**
|
|
177
|
+
* 获取指定路径节点的大小
|
|
178
|
+
* @param {Array} path - 节点路径
|
|
179
|
+
* @param {Object} doc - ProseMirror文档
|
|
180
|
+
* @returns {number} 节点大小
|
|
181
|
+
*/
|
|
182
|
+
function getNodeSizeAtPath(path, doc) {
|
|
183
|
+
var currentNode = doc;
|
|
184
|
+
var _iterator = _createForOfIteratorHelper(path),
|
|
185
|
+
_step;
|
|
186
|
+
try {
|
|
187
|
+
for (_iterator.s(); !(_step = _iterator.n()).done;) {
|
|
188
|
+
var index = _step.value;
|
|
189
|
+
if (currentNode.content && currentNode.content[index]) {
|
|
190
|
+
currentNode = currentNode.content[index];
|
|
191
|
+
} else {
|
|
192
|
+
return 1; // 默认大小
|
|
193
|
+
}
|
|
194
|
+
}
|
|
195
|
+
} catch (err) {
|
|
196
|
+
_iterator.e(err);
|
|
197
|
+
} finally {
|
|
198
|
+
_iterator.f();
|
|
199
|
+
}
|
|
200
|
+
return getNodeSize(currentNode);
|
|
201
|
+
}
|
|
202
|
+
function getPMNodeAtPath(path, doc) {
|
|
203
|
+
var current = doc;
|
|
204
|
+
var _iterator2 = _createForOfIteratorHelper(path),
|
|
205
|
+
_step2;
|
|
206
|
+
try {
|
|
207
|
+
for (_iterator2.s(); !(_step2 = _iterator2.n()).done;) {
|
|
208
|
+
var _childCount;
|
|
209
|
+
var index = _step2.value;
|
|
210
|
+
if (!current) return null;
|
|
211
|
+
var childCount = (_childCount = current.childCount) !== null && _childCount !== void 0 ? _childCount : 0;
|
|
212
|
+
if (index >= childCount) return null;
|
|
213
|
+
current = current.child(index);
|
|
214
|
+
}
|
|
215
|
+
} catch (err) {
|
|
216
|
+
_iterator2.e(err);
|
|
217
|
+
} finally {
|
|
218
|
+
_iterator2.f();
|
|
219
|
+
}
|
|
220
|
+
return current;
|
|
221
|
+
}
|
|
222
|
+
function getPMNodeSizeAtPath(path, doc) {
|
|
223
|
+
var node = getPMNodeAtPath(path, doc);
|
|
224
|
+
return node ? node.nodeSize : 1;
|
|
225
|
+
}
|
|
226
|
+
|
|
227
|
+
// 对内联文本容器(paragraph/heading)的字符偏移,基于容器内容起点(跳过开标签)
|
|
228
|
+
function adjustBaseForInline(pmNodeAtPath, absolutePos) {
|
|
229
|
+
if (!pmNodeAtPath) return absolutePos;
|
|
230
|
+
// 如果路径对应的是容器本身(非文本子节点),字符偏移应从内容起点计算
|
|
231
|
+
// 但此处无法直接判断路径是否止于容器。我们采用经验:
|
|
232
|
+
// - 若 pmNodeAtPath 不是 text,则偏移从 absolutePos + 1 开始(跳过开标签)
|
|
233
|
+
// - 若是 text,则 absolutePos 已指向文本起点
|
|
234
|
+
if (pmNodeAtPath.isText) return absolutePos;
|
|
235
|
+
return absolutePos + 1;
|
|
236
|
+
}
|
|
237
|
+
|
|
238
|
+
// 将“内联字符偏移”映射到 PM 位置(计入文本节点间的边界)
|
|
239
|
+
function mapInlineOffsetToPM(pmNodeAtPath, inlineOffset) {
|
|
240
|
+
var _childCount2;
|
|
241
|
+
if (!pmNodeAtPath) return inlineOffset;
|
|
242
|
+
// 如果当前就是文本节点,offset 等同
|
|
243
|
+
if (pmNodeAtPath.isText) return inlineOffset;
|
|
244
|
+
// 若是段落/标题容器,则 inlineOffset 是按合并后的字符序列统计,需要遍历其子 text 节点求对应 PM 偏移
|
|
245
|
+
var remaining = inlineOffset;
|
|
246
|
+
var acc = 0;
|
|
247
|
+
var childCount = (_childCount2 = pmNodeAtPath.childCount) !== null && _childCount2 !== void 0 ? _childCount2 : 0;
|
|
248
|
+
for (var i = 0; i < childCount; i++) {
|
|
249
|
+
var _child$text;
|
|
250
|
+
var child = pmNodeAtPath.child(i);
|
|
251
|
+
var size = child.isText ? ((_child$text = child.text) === null || _child$text === void 0 ? void 0 : _child$text.length) || 0 : child.nodeSize; // 非文本节点视作整体
|
|
252
|
+
if (child.isText) {
|
|
253
|
+
if (remaining <= size) {
|
|
254
|
+
acc += remaining;
|
|
255
|
+
return acc;
|
|
256
|
+
}
|
|
257
|
+
acc += size;
|
|
258
|
+
remaining -= size;
|
|
259
|
+
} else {
|
|
260
|
+
// 跳过非文本节点的整体大小
|
|
261
|
+
acc += size;
|
|
262
|
+
}
|
|
263
|
+
}
|
|
264
|
+
// 超出则落在末尾
|
|
265
|
+
return acc;
|
|
266
|
+
}
|
|
267
|
+
|
|
268
|
+
/**
|
|
269
|
+
* 创建空的装饰集合
|
|
270
|
+
* @param {Object} doc - ProseMirror文档
|
|
271
|
+
* @returns {DecorationSet} 空装饰集合
|
|
272
|
+
*/
|
|
273
|
+
export function createEmptyDecorationSet(doc) {
|
|
274
|
+
return DecorationSet.create(doc, []);
|
|
275
|
+
}
|
|
276
|
+
|
|
277
|
+
/**
|
|
278
|
+
* 获取节点大小(包含子节点)
|
|
279
|
+
* @param {Object} node - ProseMirror节点
|
|
280
|
+
* @returns {number} 节点大小
|
|
281
|
+
*/
|
|
282
|
+
export function getNodeSize(node) {
|
|
283
|
+
if (node.type === 'text') {
|
|
284
|
+
return node.text ? node.text.length : 0;
|
|
285
|
+
}
|
|
286
|
+
var size = 2; // 开始和结束标记
|
|
287
|
+
if (node.content && Array.isArray(node.content)) {
|
|
288
|
+
var _iterator3 = _createForOfIteratorHelper(node.content),
|
|
289
|
+
_step3;
|
|
290
|
+
try {
|
|
291
|
+
for (_iterator3.s(); !(_step3 = _iterator3.n()).done;) {
|
|
292
|
+
var child = _step3.value;
|
|
293
|
+
size += getNodeSize(child);
|
|
294
|
+
}
|
|
295
|
+
} catch (err) {
|
|
296
|
+
_iterator3.e(err);
|
|
297
|
+
} finally {
|
|
298
|
+
_iterator3.f();
|
|
299
|
+
}
|
|
300
|
+
}
|
|
301
|
+
return size;
|
|
302
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
export interface FileInfo {
|
|
2
|
+
src: string;
|
|
3
|
+
filename?: string;
|
|
4
|
+
}
|
|
5
|
+
/**
|
|
6
|
+
* 下载单个文件
|
|
7
|
+
*/
|
|
8
|
+
export declare const downloadSingleFile: (fileInfo: FileInfo, type?: string) => Promise<void>;
|
|
9
|
+
/**
|
|
10
|
+
* 批量下载多个图片并打包为 ZIP
|
|
11
|
+
*/
|
|
12
|
+
export declare const downloadFilesAsZip: (files: FileInfo[], type?: string) => Promise<void>;
|
|
13
|
+
/**
|
|
14
|
+
* 智能下载图片 - 单张直接下载,多张打包下载
|
|
15
|
+
*/
|
|
16
|
+
export declare const downloadFiles: (files: FileInfo[], type?: string) => Promise<void>;
|
|
@@ -0,0 +1,268 @@
|
|
|
1
|
+
function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
|
|
2
|
+
function _regeneratorRuntime() { "use strict"; /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */ _regeneratorRuntime = function _regeneratorRuntime() { return e; }; var t, e = {}, r = Object.prototype, n = r.hasOwnProperty, o = Object.defineProperty || function (t, e, r) { t[e] = r.value; }, i = "function" == typeof Symbol ? Symbol : {}, a = i.iterator || "@@iterator", c = i.asyncIterator || "@@asyncIterator", u = i.toStringTag || "@@toStringTag"; function define(t, e, r) { return Object.defineProperty(t, e, { value: r, enumerable: !0, configurable: !0, writable: !0 }), t[e]; } try { define({}, ""); } catch (t) { define = function define(t, e, r) { return t[e] = r; }; } function wrap(t, e, r, n) { var i = e && e.prototype instanceof Generator ? e : Generator, a = Object.create(i.prototype), c = new Context(n || []); return o(a, "_invoke", { value: makeInvokeMethod(t, r, c) }), a; } function tryCatch(t, e, r) { try { return { type: "normal", arg: t.call(e, r) }; } catch (t) { return { type: "throw", arg: t }; } } e.wrap = wrap; var h = "suspendedStart", l = "suspendedYield", f = "executing", s = "completed", y = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} var p = {}; define(p, a, function () { return this; }); var d = Object.getPrototypeOf, v = d && d(d(values([]))); v && v !== r && n.call(v, a) && (p = v); var g = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(p); function defineIteratorMethods(t) { ["next", "throw", "return"].forEach(function (e) { define(t, e, function (t) { return this._invoke(e, t); }); }); } function AsyncIterator(t, e) { function invoke(r, o, i, a) { var c = tryCatch(t[r], t, o); if ("throw" !== c.type) { var u = c.arg, h = u.value; return h && "object" == _typeof(h) && n.call(h, "__await") ? e.resolve(h.__await).then(function (t) { invoke("next", t, i, a); }, function (t) { invoke("throw", t, i, a); }) : e.resolve(h).then(function (t) { u.value = t, i(u); }, function (t) { return invoke("throw", t, i, a); }); } a(c.arg); } var r; o(this, "_invoke", { value: function value(t, n) { function callInvokeWithMethodAndArg() { return new e(function (e, r) { invoke(t, n, e, r); }); } return r = r ? r.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg(); } }); } function makeInvokeMethod(e, r, n) { var o = h; return function (i, a) { if (o === f) throw new Error("Generator is already running"); if (o === s) { if ("throw" === i) throw a; return { value: t, done: !0 }; } for (n.method = i, n.arg = a;;) { var c = n.delegate; if (c) { var u = maybeInvokeDelegate(c, n); if (u) { if (u === y) continue; return u; } } if ("next" === n.method) n.sent = n._sent = n.arg;else if ("throw" === n.method) { if (o === h) throw o = s, n.arg; n.dispatchException(n.arg); } else "return" === n.method && n.abrupt("return", n.arg); o = f; var p = tryCatch(e, r, n); if ("normal" === p.type) { if (o = n.done ? s : l, p.arg === y) continue; return { value: p.arg, done: n.done }; } "throw" === p.type && (o = s, n.method = "throw", n.arg = p.arg); } }; } function maybeInvokeDelegate(e, r) { var n = r.method, o = e.iterator[n]; if (o === t) return r.delegate = null, "throw" === n && e.iterator.return && (r.method = "return", r.arg = t, maybeInvokeDelegate(e, r), "throw" === r.method) || "return" !== n && (r.method = "throw", r.arg = new TypeError("The iterator does not provide a '" + n + "' method")), y; var i = tryCatch(o, e.iterator, r.arg); if ("throw" === i.type) return r.method = "throw", r.arg = i.arg, r.delegate = null, y; var a = i.arg; return a ? a.done ? (r[e.resultName] = a.value, r.next = e.nextLoc, "return" !== r.method && (r.method = "next", r.arg = t), r.delegate = null, y) : a : (r.method = "throw", r.arg = new TypeError("iterator result is not an object"), r.delegate = null, y); } function pushTryEntry(t) { var e = { tryLoc: t[0] }; 1 in t && (e.catchLoc = t[1]), 2 in t && (e.finallyLoc = t[2], e.afterLoc = t[3]), this.tryEntries.push(e); } function resetTryEntry(t) { var e = t.completion || {}; e.type = "normal", delete e.arg, t.completion = e; } function Context(t) { this.tryEntries = [{ tryLoc: "root" }], t.forEach(pushTryEntry, this), this.reset(!0); } function values(e) { if (e || "" === e) { var r = e[a]; if (r) return r.call(e); if ("function" == typeof e.next) return e; if (!isNaN(e.length)) { var o = -1, i = function next() { for (; ++o < e.length;) if (n.call(e, o)) return next.value = e[o], next.done = !1, next; return next.value = t, next.done = !0, next; }; return i.next = i; } } throw new TypeError(_typeof(e) + " is not iterable"); } return GeneratorFunction.prototype = GeneratorFunctionPrototype, o(g, "constructor", { value: GeneratorFunctionPrototype, configurable: !0 }), o(GeneratorFunctionPrototype, "constructor", { value: GeneratorFunction, configurable: !0 }), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, u, "GeneratorFunction"), e.isGeneratorFunction = function (t) { var e = "function" == typeof t && t.constructor; return !!e && (e === GeneratorFunction || "GeneratorFunction" === (e.displayName || e.name)); }, e.mark = function (t) { return Object.setPrototypeOf ? Object.setPrototypeOf(t, GeneratorFunctionPrototype) : (t.__proto__ = GeneratorFunctionPrototype, define(t, u, "GeneratorFunction")), t.prototype = Object.create(g), t; }, e.awrap = function (t) { return { __await: t }; }, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, c, function () { return this; }), e.AsyncIterator = AsyncIterator, e.async = function (t, r, n, o, i) { void 0 === i && (i = Promise); var a = new AsyncIterator(wrap(t, r, n, o), i); return e.isGeneratorFunction(r) ? a : a.next().then(function (t) { return t.done ? t.value : a.next(); }); }, defineIteratorMethods(g), define(g, u, "Generator"), define(g, a, function () { return this; }), define(g, "toString", function () { return "[object Generator]"; }), e.keys = function (t) { var e = Object(t), r = []; for (var n in e) r.push(n); return r.reverse(), function next() { for (; r.length;) { var t = r.pop(); if (t in e) return next.value = t, next.done = !1, next; } return next.done = !0, next; }; }, e.values = values, Context.prototype = { constructor: Context, reset: function reset(e) { if (this.prev = 0, this.next = 0, this.sent = this._sent = t, this.done = !1, this.delegate = null, this.method = "next", this.arg = t, this.tryEntries.forEach(resetTryEntry), !e) for (var r in this) "t" === r.charAt(0) && n.call(this, r) && !isNaN(+r.slice(1)) && (this[r] = t); }, stop: function stop() { this.done = !0; var t = this.tryEntries[0].completion; if ("throw" === t.type) throw t.arg; return this.rval; }, dispatchException: function dispatchException(e) { if (this.done) throw e; var r = this; function handle(n, o) { return a.type = "throw", a.arg = e, r.next = n, o && (r.method = "next", r.arg = t), !!o; } for (var o = this.tryEntries.length - 1; o >= 0; --o) { var i = this.tryEntries[o], a = i.completion; if ("root" === i.tryLoc) return handle("end"); if (i.tryLoc <= this.prev) { var c = n.call(i, "catchLoc"), u = n.call(i, "finallyLoc"); if (c && u) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } else if (c) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); } else { if (!u) throw new Error("try statement without catch or finally"); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } } } }, abrupt: function abrupt(t, e) { for (var r = this.tryEntries.length - 1; r >= 0; --r) { var o = this.tryEntries[r]; if (o.tryLoc <= this.prev && n.call(o, "finallyLoc") && this.prev < o.finallyLoc) { var i = o; break; } } i && ("break" === t || "continue" === t) && i.tryLoc <= e && e <= i.finallyLoc && (i = null); var a = i ? i.completion : {}; return a.type = t, a.arg = e, i ? (this.method = "next", this.next = i.finallyLoc, y) : this.complete(a); }, complete: function complete(t, e) { if ("throw" === t.type) throw t.arg; return "break" === t.type || "continue" === t.type ? this.next = t.arg : "return" === t.type ? (this.rval = this.arg = t.arg, this.method = "return", this.next = "end") : "normal" === t.type && e && (this.next = e), y; }, finish: function finish(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.finallyLoc === t) return this.complete(r.completion, r.afterLoc), resetTryEntry(r), y; } }, catch: function _catch(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.tryLoc === t) { var n = r.completion; if ("throw" === n.type) { var o = n.arg; resetTryEntry(r); } return o; } } throw new Error("illegal catch attempt"); }, delegateYield: function delegateYield(e, r, n) { return this.delegate = { iterator: values(e), resultName: r, nextLoc: n }, "next" === this.method && (this.arg = t), y; } }, e; }
|
|
3
|
+
function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { Promise.resolve(value).then(_next, _throw); } }
|
|
4
|
+
function _asyncToGenerator(fn) { return function () { var self = this, args = arguments; return new Promise(function (resolve, reject) { var gen = fn.apply(self, args); function _next(value) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value); } function _throw(err) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err); } _next(undefined); }); }; }
|
|
5
|
+
import JSZip from 'jszip';
|
|
6
|
+
/**
|
|
7
|
+
* 原生下载函数,使用 a 标签的 download 属性
|
|
8
|
+
*/
|
|
9
|
+
var downloadFile = function downloadFile(blob, filename) {
|
|
10
|
+
var url = URL.createObjectURL(blob);
|
|
11
|
+
var a = document.createElement('a');
|
|
12
|
+
a.href = url;
|
|
13
|
+
a.download = filename;
|
|
14
|
+
a.style.display = 'none';
|
|
15
|
+
document.body.appendChild(a);
|
|
16
|
+
a.click();
|
|
17
|
+
document.body.removeChild(a);
|
|
18
|
+
URL.revokeObjectURL(url);
|
|
19
|
+
};
|
|
20
|
+
|
|
21
|
+
// 支持的文件类型
|
|
22
|
+
|
|
23
|
+
// 文件类型对应的默认扩展名
|
|
24
|
+
var DEFAULT_EXTENSIONS = {
|
|
25
|
+
img: '.jpg',
|
|
26
|
+
video: '.mp4',
|
|
27
|
+
audio: '.mp3',
|
|
28
|
+
attachment: '.bin'
|
|
29
|
+
};
|
|
30
|
+
|
|
31
|
+
// 文件类型对应的默认文件名前缀
|
|
32
|
+
var DEFAULT_NAME_PREFIXES = {
|
|
33
|
+
img: 'image',
|
|
34
|
+
video: 'video',
|
|
35
|
+
audio: 'audio',
|
|
36
|
+
attachment: 'attachment'
|
|
37
|
+
};
|
|
38
|
+
var getFilenameFromUrl = function getFilenameFromUrl(url, type) {
|
|
39
|
+
var pathname = '';
|
|
40
|
+
try {
|
|
41
|
+
// 尝试解析为完整URL
|
|
42
|
+
var urlObj = new URL(url);
|
|
43
|
+
pathname = urlObj.pathname;
|
|
44
|
+
} catch (_unused) {
|
|
45
|
+
// 如果URL解析失败,可能是相对路径,直接使用原始字符串
|
|
46
|
+
pathname = url;
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
// 从路径中提取文件名(处理绝对路径和相对路径)
|
|
50
|
+
var filename = pathname.split('/').pop() || '';
|
|
51
|
+
|
|
52
|
+
// 如果文件名为空或没有扩展名,且提供了类型信息,添加对应扩展名
|
|
53
|
+
if ((!filename || !filename.includes('.')) && type && type in DEFAULT_EXTENSIONS) {
|
|
54
|
+
var extension = DEFAULT_EXTENSIONS[type];
|
|
55
|
+
var baseName = filename || 'file';
|
|
56
|
+
return "".concat(baseName).concat(extension);
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
// 如果文件名为空,生成默认文件名
|
|
60
|
+
if (!filename) {
|
|
61
|
+
var timestamp = Date.now();
|
|
62
|
+
if (type && type in DEFAULT_EXTENSIONS) {
|
|
63
|
+
var prefix = DEFAULT_NAME_PREFIXES[type];
|
|
64
|
+
var _extension = DEFAULT_EXTENSIONS[type];
|
|
65
|
+
return "".concat(prefix, "_").concat(timestamp).concat(_extension);
|
|
66
|
+
}
|
|
67
|
+
return "file_".concat(timestamp);
|
|
68
|
+
}
|
|
69
|
+
return filename;
|
|
70
|
+
};
|
|
71
|
+
|
|
72
|
+
/**
|
|
73
|
+
* 下载单个文件
|
|
74
|
+
*/
|
|
75
|
+
export var downloadSingleFile = /*#__PURE__*/function () {
|
|
76
|
+
var _ref = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(fileInfo, type) {
|
|
77
|
+
var response, blob, filename;
|
|
78
|
+
return _regeneratorRuntime().wrap(function _callee$(_context) {
|
|
79
|
+
while (1) switch (_context.prev = _context.next) {
|
|
80
|
+
case 0:
|
|
81
|
+
_context.prev = 0;
|
|
82
|
+
_context.next = 3;
|
|
83
|
+
return fetch(fileInfo.src);
|
|
84
|
+
case 3:
|
|
85
|
+
response = _context.sent;
|
|
86
|
+
if (response.ok) {
|
|
87
|
+
_context.next = 6;
|
|
88
|
+
break;
|
|
89
|
+
}
|
|
90
|
+
throw new Error("HTTP error! status: ".concat(response.status));
|
|
91
|
+
case 6:
|
|
92
|
+
_context.next = 8;
|
|
93
|
+
return response.blob();
|
|
94
|
+
case 8:
|
|
95
|
+
blob = _context.sent;
|
|
96
|
+
filename = fileInfo.filename || getFilenameFromUrl(fileInfo.src, type);
|
|
97
|
+
downloadFile(blob, filename);
|
|
98
|
+
_context.next = 17;
|
|
99
|
+
break;
|
|
100
|
+
case 13:
|
|
101
|
+
_context.prev = 13;
|
|
102
|
+
_context.t0 = _context["catch"](0);
|
|
103
|
+
console.error('下载文件失败:', _context.t0);
|
|
104
|
+
throw new Error('下载文件失败,请检查文件链接是否有效');
|
|
105
|
+
case 17:
|
|
106
|
+
case "end":
|
|
107
|
+
return _context.stop();
|
|
108
|
+
}
|
|
109
|
+
}, _callee, null, [[0, 13]]);
|
|
110
|
+
}));
|
|
111
|
+
return function downloadSingleFile(_x, _x2) {
|
|
112
|
+
return _ref.apply(this, arguments);
|
|
113
|
+
};
|
|
114
|
+
}();
|
|
115
|
+
|
|
116
|
+
/**
|
|
117
|
+
* 批量下载多个图片并打包为 ZIP
|
|
118
|
+
*/
|
|
119
|
+
export var downloadFilesAsZip = /*#__PURE__*/function () {
|
|
120
|
+
var _ref2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee3(files, type) {
|
|
121
|
+
var zipFilename, zip, usedFilenames, downloadPromises, results, successfulDownloads, zipBlob, failedCount;
|
|
122
|
+
return _regeneratorRuntime().wrap(function _callee3$(_context3) {
|
|
123
|
+
while (1) switch (_context3.prev = _context3.next) {
|
|
124
|
+
case 0:
|
|
125
|
+
zipFilename = "".concat(type, "s_").concat(Date.now(), ".zip");
|
|
126
|
+
if (!(files.length === 0)) {
|
|
127
|
+
_context3.next = 3;
|
|
128
|
+
break;
|
|
129
|
+
}
|
|
130
|
+
throw new Error('没有要下载的文件');
|
|
131
|
+
case 3:
|
|
132
|
+
_context3.prev = 3;
|
|
133
|
+
zip = new JSZip();
|
|
134
|
+
usedFilenames = new Set();
|
|
135
|
+
downloadPromises = files.map( /*#__PURE__*/function () {
|
|
136
|
+
var _ref3 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2(fileInfo) {
|
|
137
|
+
var response, blob, filename, counter, originalFilename, extension, baseName;
|
|
138
|
+
return _regeneratorRuntime().wrap(function _callee2$(_context2) {
|
|
139
|
+
while (1) switch (_context2.prev = _context2.next) {
|
|
140
|
+
case 0:
|
|
141
|
+
_context2.prev = 0;
|
|
142
|
+
_context2.next = 3;
|
|
143
|
+
return fetch(fileInfo.src);
|
|
144
|
+
case 3:
|
|
145
|
+
response = _context2.sent;
|
|
146
|
+
if (response.ok) {
|
|
147
|
+
_context2.next = 7;
|
|
148
|
+
break;
|
|
149
|
+
}
|
|
150
|
+
console.warn("\u6587\u4EF6\u4E0B\u8F7D\u5931\u8D25 (".concat(response.status, "): ").concat(fileInfo.src));
|
|
151
|
+
return _context2.abrupt("return", null);
|
|
152
|
+
case 7:
|
|
153
|
+
_context2.next = 9;
|
|
154
|
+
return response.blob();
|
|
155
|
+
case 9:
|
|
156
|
+
blob = _context2.sent;
|
|
157
|
+
filename = fileInfo.filename || getFilenameFromUrl(fileInfo.src, type);
|
|
158
|
+
counter = 1;
|
|
159
|
+
originalFilename = filename;
|
|
160
|
+
while (usedFilenames.has(filename)) {
|
|
161
|
+
extension = originalFilename.split('.').pop() || '';
|
|
162
|
+
baseName = extension ? originalFilename.replace(".".concat(extension), '') : originalFilename;
|
|
163
|
+
filename = "".concat(baseName, "_").concat(counter).concat(extension ? ".".concat(extension) : '');
|
|
164
|
+
counter++;
|
|
165
|
+
}
|
|
166
|
+
usedFilenames.add(filename);
|
|
167
|
+
return _context2.abrupt("return", {
|
|
168
|
+
filename: filename,
|
|
169
|
+
blob: blob
|
|
170
|
+
});
|
|
171
|
+
case 18:
|
|
172
|
+
_context2.prev = 18;
|
|
173
|
+
_context2.t0 = _context2["catch"](0);
|
|
174
|
+
console.warn("\u4E0B\u8F7D\u6587\u4EF6\u5931\u8D25: ".concat(fileInfo.src), _context2.t0);
|
|
175
|
+
return _context2.abrupt("return", null);
|
|
176
|
+
case 22:
|
|
177
|
+
case "end":
|
|
178
|
+
return _context2.stop();
|
|
179
|
+
}
|
|
180
|
+
}, _callee2, null, [[0, 18]]);
|
|
181
|
+
}));
|
|
182
|
+
return function (_x5) {
|
|
183
|
+
return _ref3.apply(this, arguments);
|
|
184
|
+
};
|
|
185
|
+
}());
|
|
186
|
+
_context3.next = 9;
|
|
187
|
+
return Promise.all(downloadPromises);
|
|
188
|
+
case 9:
|
|
189
|
+
results = _context3.sent;
|
|
190
|
+
successfulDownloads = results.filter(function (result) {
|
|
191
|
+
return result !== null;
|
|
192
|
+
});
|
|
193
|
+
if (!(successfulDownloads.length === 0)) {
|
|
194
|
+
_context3.next = 13;
|
|
195
|
+
break;
|
|
196
|
+
}
|
|
197
|
+
throw new Error('所有文件下载失败');
|
|
198
|
+
case 13:
|
|
199
|
+
successfulDownloads.forEach(function (result) {
|
|
200
|
+
if (result) {
|
|
201
|
+
zip.file(result.filename, result.blob);
|
|
202
|
+
}
|
|
203
|
+
});
|
|
204
|
+
_context3.next = 16;
|
|
205
|
+
return zip.generateAsync({
|
|
206
|
+
type: 'blob'
|
|
207
|
+
});
|
|
208
|
+
case 16:
|
|
209
|
+
zipBlob = _context3.sent;
|
|
210
|
+
downloadFile(zipBlob, zipFilename);
|
|
211
|
+
if (successfulDownloads.length < files.length) {
|
|
212
|
+
failedCount = files.length - successfulDownloads.length;
|
|
213
|
+
console.warn("\u6210\u529F\u4E0B\u8F7D ".concat(successfulDownloads.length, " \u5F20\u6587\u4EF6\uFF0C").concat(failedCount, " \u5F20\u6587\u4EF6\u4E0B\u8F7D\u5931\u8D25"));
|
|
214
|
+
}
|
|
215
|
+
_context3.next = 25;
|
|
216
|
+
break;
|
|
217
|
+
case 21:
|
|
218
|
+
_context3.prev = 21;
|
|
219
|
+
_context3.t0 = _context3["catch"](3);
|
|
220
|
+
console.error('打包下载失败:', _context3.t0);
|
|
221
|
+
throw new Error('打包下载失败,请重试');
|
|
222
|
+
case 25:
|
|
223
|
+
case "end":
|
|
224
|
+
return _context3.stop();
|
|
225
|
+
}
|
|
226
|
+
}, _callee3, null, [[3, 21]]);
|
|
227
|
+
}));
|
|
228
|
+
return function downloadFilesAsZip(_x3, _x4) {
|
|
229
|
+
return _ref2.apply(this, arguments);
|
|
230
|
+
};
|
|
231
|
+
}();
|
|
232
|
+
|
|
233
|
+
/**
|
|
234
|
+
* 智能下载图片 - 单张直接下载,多张打包下载
|
|
235
|
+
*/
|
|
236
|
+
export var downloadFiles = /*#__PURE__*/function () {
|
|
237
|
+
var _ref4 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee4(files, type) {
|
|
238
|
+
return _regeneratorRuntime().wrap(function _callee4$(_context4) {
|
|
239
|
+
while (1) switch (_context4.prev = _context4.next) {
|
|
240
|
+
case 0:
|
|
241
|
+
if (!(files.length === 0)) {
|
|
242
|
+
_context4.next = 2;
|
|
243
|
+
break;
|
|
244
|
+
}
|
|
245
|
+
return _context4.abrupt("return");
|
|
246
|
+
case 2:
|
|
247
|
+
if (!(files.length === 1)) {
|
|
248
|
+
_context4.next = 7;
|
|
249
|
+
break;
|
|
250
|
+
}
|
|
251
|
+
_context4.next = 5;
|
|
252
|
+
return downloadSingleFile(files[0], type);
|
|
253
|
+
case 5:
|
|
254
|
+
_context4.next = 9;
|
|
255
|
+
break;
|
|
256
|
+
case 7:
|
|
257
|
+
_context4.next = 9;
|
|
258
|
+
return downloadFilesAsZip(files, type);
|
|
259
|
+
case 9:
|
|
260
|
+
case "end":
|
|
261
|
+
return _context4.stop();
|
|
262
|
+
}
|
|
263
|
+
}, _callee4);
|
|
264
|
+
}));
|
|
265
|
+
return function downloadFiles(_x6, _x7) {
|
|
266
|
+
return _ref4.apply(this, arguments);
|
|
267
|
+
};
|
|
268
|
+
}();
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { Editor } from '@tiptap/react';
|
|
2
|
+
export declare const getFileType: (file: File) => 'image' | 'video' | 'other';
|
|
3
|
+
export declare const formatFileSize: (bytes: number) => string;
|
|
4
|
+
export declare const getFileIcon: (fileName: string) => string;
|
|
5
|
+
export declare const insertImageContent: (editor: Editor, url: string, pos: number) => void;
|
|
6
|
+
export declare const insertVideoContent: (editor: Editor, url: string, pos: number) => void;
|
|
7
|
+
export declare const insertAttachmentContent: (editor: Editor, url: string, fileName: string, fileSize: number, pos: number) => void;
|