@ctzhian/tiptap 0.4.0
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/README.md +43 -0
- package/dist/Editor/demo.d.ts +4 -0
- package/dist/Editor/demo.js +150 -0
- package/dist/Editor/index.d.ts +4 -0
- package/dist/Editor/index.js +21 -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 +286 -0
- package/dist/asset/css/index.css +161 -0
- package/dist/asset/images/disk.png +0 -0
- package/dist/asset/images/down.svg +3 -0
- package/dist/component/CustomBubbleMenu/SelectionText.d.ts +9 -0
- package/dist/component/CustomBubbleMenu/SelectionText.js +295 -0
- package/dist/component/CustomDragHandle/index.d.ts +9 -0
- package/dist/component/CustomDragHandle/index.js +1172 -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 +13 -0
- package/dist/component/FloatingPopover/index.js +104 -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-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/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/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/index.d.ts +110 -0
- package/dist/component/Icons/index.js +113 -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/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/ListHover/index.d.ts +7 -0
- package/dist/component/ListHover/index.js +367 -0
- package/dist/component/Menu/index.d.ts +4 -0
- package/dist/component/Menu/index.js +189 -0
- package/dist/component/Toolbar/EditorAlignSelect.d.ts +7 -0
- package/dist/component/Toolbar/EditorAlignSelect.js +176 -0
- package/dist/component/Toolbar/EditorCode.d.ts +7 -0
- package/dist/component/Toolbar/EditorCode.js +150 -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 +137 -0
- package/dist/component/Toolbar/EditorHeading.d.ts +7 -0
- package/dist/component/Toolbar/EditorHeading.js +174 -0
- package/dist/component/Toolbar/EditorInsert/index.d.ts +7 -0
- package/dist/component/Toolbar/EditorInsert/index.js +186 -0
- package/dist/component/Toolbar/EditorListSelect.d.ts +7 -0
- package/dist/component/Toolbar/EditorListSelect.js +163 -0
- package/dist/component/Toolbar/EditorMath.d.ts +7 -0
- package/dist/component/Toolbar/EditorMath.js +148 -0
- package/dist/component/Toolbar/EditorMore/NotificationDialog.d.ts +7 -0
- package/dist/component/Toolbar/EditorMore/NotificationDialog.js +72 -0
- package/dist/component/Toolbar/EditorMore/index.d.ts +7 -0
- package/dist/component/Toolbar/EditorMore/index.js +101 -0
- package/dist/component/Toolbar/EditorScript.d.ts +7 -0
- package/dist/component/Toolbar/EditorScript.js +150 -0
- package/dist/component/Toolbar/EditorVerticalAlignSelect.d.ts +7 -0
- package/dist/component/Toolbar/EditorVerticalAlignSelect.js +163 -0
- package/dist/component/Toolbar/Item.d.ts +15 -0
- package/dist/component/Toolbar/Item.js +69 -0
- package/dist/component/Toolbar/index.d.ts +13 -0
- package/dist/component/Toolbar/index.js +13 -0
- package/dist/component/index.d.ts +1 -0
- package/dist/component/index.js +1 -0
- package/dist/contants/enums.d.ts +30 -0
- package/dist/contants/enums.js +98 -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 +13 -0
- package/dist/contants/slash-commands.js +313 -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 +93 -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 +135 -0
- package/dist/extension/component/CodeBlock/index.d.ts +4 -0
- package/dist/extension/component/CodeBlock/index.js +296 -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/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 +52 -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 +102 -0
- package/dist/extension/component/Link/index.d.ts +12 -0
- package/dist/extension/component/Link/index.js +510 -0
- package/dist/extension/component/Mathematics/block/Readonly.d.ts +9 -0
- package/dist/extension/component/Mathematics/block/Readonly.js +36 -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 +34 -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/index.d.ts +4 -0
- package/dist/extension/component/SlashCommandsList/index.js +121 -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 +41 -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/index.d.ts +1 -0
- package/dist/extension/extension/index.js +1 -0
- package/dist/extension/index.d.ts +2 -0
- package/dist/extension/index.js +176 -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/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 +40 -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/Image.d.ts +3 -0
- package/dist/extension/node/Image.js +38 -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 +461 -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 +174 -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 +17 -0
- package/dist/extension/node/index.js +17 -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 +34 -0
- package/dist/extension/suggestion/slash.js +63 -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 +372 -0
- package/dist/index.d.ts +7 -0
- package/dist/index.js +7 -0
- package/dist/themes/color.d.ts +5 -0
- package/dist/themes/color.js +4 -0
- package/dist/themes/componentStyleOverrides.d.ts +396 -0
- package/dist/themes/componentStyleOverrides.js +431 -0
- package/dist/themes/custom.d.ts +5 -0
- package/dist/themes/custom.js +4 -0
- package/dist/themes/dark.d.ts +86 -0
- package/dist/themes/dark.js +86 -0
- package/dist/themes/index.d.ts +19 -0
- package/dist/themes/index.js +37 -0
- package/dist/themes/light.d.ts +86 -0
- package/dist/themes/light.js +86 -0
- package/dist/themes/palette.d.ts +94 -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 +112 -0
- package/dist/type/index.js +1 -0
- package/dist/types/images.d.ts +19 -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 +2 -0
- package/dist/util/floating.js +22 -0
- package/dist/util/index.d.ts +11 -0
- package/dist/util/index.js +39 -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 +62 -0
- package/dist/util/shortcutKey.d.ts +2 -0
- package/dist/util/shortcutKey.js +9 -0
- package/package.json +135 -0
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { EditorFnProps } from "../../../type";
|
|
2
|
+
import React from "react";
|
|
3
|
+
import { ImageAttributes } from ".";
|
|
4
|
+
import 'react-image-crop/dist/ReactCrop.css';
|
|
5
|
+
type CropImageProps = {
|
|
6
|
+
selected: boolean;
|
|
7
|
+
attrs: ImageAttributes;
|
|
8
|
+
onConfirm: (imageUrl: string) => void;
|
|
9
|
+
onCancel: () => void;
|
|
10
|
+
} & EditorFnProps;
|
|
11
|
+
declare const CropImage: ({ selected, attrs, onConfirm, onCancel, onUpload, onError }: CropImageProps) => React.JSX.Element;
|
|
12
|
+
export default CropImage;
|
|
@@ -0,0 +1,218 @@
|
|
|
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
|
+
function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
|
|
6
|
+
function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
|
|
7
|
+
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); }
|
|
8
|
+
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; }
|
|
9
|
+
function _iterableToArrayLimit(r, l) { var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (null != t) { var e, n, i, u, a = [], f = !0, o = !1; try { if (i = (t = t.call(r)).next, 0 === l) { if (Object(t) !== t) return; f = !1; } else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = !0); } catch (r) { o = !0, n = r; } finally { try { if (!f && null != t.return && (u = t.return(), Object(u) !== u)) return; } finally { if (o) throw n; } } return a; } }
|
|
10
|
+
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
|
11
|
+
import { Box, Button, Stack } from "@mui/material";
|
|
12
|
+
import { NodeViewWrapper } from "@tiptap/react";
|
|
13
|
+
import React, { useRef, useState } from "react";
|
|
14
|
+
import ReactCrop from 'react-image-crop';
|
|
15
|
+
import 'react-image-crop/dist/ReactCrop.css';
|
|
16
|
+
var CropImage = function CropImage(_ref) {
|
|
17
|
+
var selected = _ref.selected,
|
|
18
|
+
attrs = _ref.attrs,
|
|
19
|
+
onConfirm = _ref.onConfirm,
|
|
20
|
+
onCancel = _ref.onCancel,
|
|
21
|
+
onUpload = _ref.onUpload,
|
|
22
|
+
_onError = _ref.onError;
|
|
23
|
+
var _useState = useState({
|
|
24
|
+
unit: '%',
|
|
25
|
+
width: 100,
|
|
26
|
+
height: 100,
|
|
27
|
+
x: 0,
|
|
28
|
+
y: 0
|
|
29
|
+
}),
|
|
30
|
+
_useState2 = _slicedToArray(_useState, 2),
|
|
31
|
+
crop = _useState2[0],
|
|
32
|
+
setCrop = _useState2[1];
|
|
33
|
+
var _useState3 = useState(),
|
|
34
|
+
_useState4 = _slicedToArray(_useState3, 2),
|
|
35
|
+
completedCrop = _useState4[0],
|
|
36
|
+
setCompletedCrop = _useState4[1];
|
|
37
|
+
var _useState5 = useState(false),
|
|
38
|
+
_useState6 = _slicedToArray(_useState5, 2),
|
|
39
|
+
isUploading = _useState6[0],
|
|
40
|
+
setIsUploading = _useState6[1];
|
|
41
|
+
var imgRef = useRef(null);
|
|
42
|
+
var onImageLoad = function onImageLoad() {
|
|
43
|
+
setCrop({
|
|
44
|
+
unit: '%',
|
|
45
|
+
width: 100,
|
|
46
|
+
height: 100,
|
|
47
|
+
x: 0,
|
|
48
|
+
y: 0
|
|
49
|
+
});
|
|
50
|
+
};
|
|
51
|
+
var getCroppedFile = function getCroppedFile() {
|
|
52
|
+
return new Promise(function (resolve) {
|
|
53
|
+
if (!completedCrop || !imgRef.current) {
|
|
54
|
+
resolve(null);
|
|
55
|
+
return;
|
|
56
|
+
}
|
|
57
|
+
var canvas = document.createElement('canvas');
|
|
58
|
+
var ctx = canvas.getContext('2d');
|
|
59
|
+
if (!ctx) {
|
|
60
|
+
resolve(null);
|
|
61
|
+
return;
|
|
62
|
+
}
|
|
63
|
+
var image = imgRef.current;
|
|
64
|
+
var scaleX = image.naturalWidth / image.width;
|
|
65
|
+
var scaleY = image.naturalHeight / image.height;
|
|
66
|
+
canvas.width = completedCrop.width;
|
|
67
|
+
canvas.height = completedCrop.height;
|
|
68
|
+
ctx.drawImage(image, completedCrop.x * scaleX, completedCrop.y * scaleY, completedCrop.width * scaleX, completedCrop.height * scaleY, 0, 0, completedCrop.width, completedCrop.height);
|
|
69
|
+
canvas.toBlob(function (blob) {
|
|
70
|
+
if (blob) {
|
|
71
|
+
var file = new File([blob], 'cropped-image.jpg', {
|
|
72
|
+
type: 'image/jpeg'
|
|
73
|
+
});
|
|
74
|
+
resolve(file);
|
|
75
|
+
} else {
|
|
76
|
+
resolve(null);
|
|
77
|
+
}
|
|
78
|
+
}, 'image/jpeg', 0.95);
|
|
79
|
+
});
|
|
80
|
+
};
|
|
81
|
+
var getCroppedDataUrl = function getCroppedDataUrl() {
|
|
82
|
+
return new Promise(function (resolve) {
|
|
83
|
+
if (!completedCrop || !imgRef.current) {
|
|
84
|
+
resolve('');
|
|
85
|
+
return;
|
|
86
|
+
}
|
|
87
|
+
var canvas = document.createElement('canvas');
|
|
88
|
+
var ctx = canvas.getContext('2d');
|
|
89
|
+
if (!ctx) {
|
|
90
|
+
resolve('');
|
|
91
|
+
return;
|
|
92
|
+
}
|
|
93
|
+
var image = imgRef.current;
|
|
94
|
+
var scaleX = image.naturalWidth / image.width;
|
|
95
|
+
var scaleY = image.naturalHeight / image.height;
|
|
96
|
+
canvas.width = completedCrop.width;
|
|
97
|
+
canvas.height = completedCrop.height;
|
|
98
|
+
ctx.drawImage(image, completedCrop.x * scaleX, completedCrop.y * scaleY, completedCrop.width * scaleX, completedCrop.height * scaleY, 0, 0, completedCrop.width, completedCrop.height);
|
|
99
|
+
var dataUrl = canvas.toDataURL('image/jpeg', 0.95);
|
|
100
|
+
resolve(dataUrl);
|
|
101
|
+
});
|
|
102
|
+
};
|
|
103
|
+
var handleConfirm = /*#__PURE__*/function () {
|
|
104
|
+
var _ref2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {
|
|
105
|
+
var croppedFile, uploadedUrl, croppedDataUrl;
|
|
106
|
+
return _regeneratorRuntime().wrap(function _callee$(_context) {
|
|
107
|
+
while (1) switch (_context.prev = _context.next) {
|
|
108
|
+
case 0:
|
|
109
|
+
setIsUploading(true);
|
|
110
|
+
_context.prev = 1;
|
|
111
|
+
if (!onUpload) {
|
|
112
|
+
_context.next = 13;
|
|
113
|
+
break;
|
|
114
|
+
}
|
|
115
|
+
_context.next = 5;
|
|
116
|
+
return getCroppedFile();
|
|
117
|
+
case 5:
|
|
118
|
+
croppedFile = _context.sent;
|
|
119
|
+
if (!croppedFile) {
|
|
120
|
+
_context.next = 11;
|
|
121
|
+
break;
|
|
122
|
+
}
|
|
123
|
+
_context.next = 9;
|
|
124
|
+
return onUpload(croppedFile);
|
|
125
|
+
case 9:
|
|
126
|
+
uploadedUrl = _context.sent;
|
|
127
|
+
onConfirm(uploadedUrl);
|
|
128
|
+
case 11:
|
|
129
|
+
_context.next = 17;
|
|
130
|
+
break;
|
|
131
|
+
case 13:
|
|
132
|
+
_context.next = 15;
|
|
133
|
+
return getCroppedDataUrl();
|
|
134
|
+
case 15:
|
|
135
|
+
croppedDataUrl = _context.sent;
|
|
136
|
+
if (croppedDataUrl) {
|
|
137
|
+
onConfirm(croppedDataUrl);
|
|
138
|
+
}
|
|
139
|
+
case 17:
|
|
140
|
+
_context.next = 24;
|
|
141
|
+
break;
|
|
142
|
+
case 19:
|
|
143
|
+
_context.prev = 19;
|
|
144
|
+
_context.t0 = _context["catch"](1);
|
|
145
|
+
_onError === null || _onError === void 0 || _onError(_context.t0);
|
|
146
|
+
setIsUploading(false);
|
|
147
|
+
return _context.abrupt("return");
|
|
148
|
+
case 24:
|
|
149
|
+
setIsUploading(false);
|
|
150
|
+
case 25:
|
|
151
|
+
case "end":
|
|
152
|
+
return _context.stop();
|
|
153
|
+
}
|
|
154
|
+
}, _callee, null, [[1, 19]]);
|
|
155
|
+
}));
|
|
156
|
+
return function handleConfirm() {
|
|
157
|
+
return _ref2.apply(this, arguments);
|
|
158
|
+
};
|
|
159
|
+
}();
|
|
160
|
+
return /*#__PURE__*/React.createElement(NodeViewWrapper, {
|
|
161
|
+
className: "image-wrapper ".concat(selected ? 'ProseMirror-selectednode' : ''),
|
|
162
|
+
"data-drag-handle": true
|
|
163
|
+
}, /*#__PURE__*/React.createElement(Box, {
|
|
164
|
+
component: 'span',
|
|
165
|
+
sx: {
|
|
166
|
+
position: 'relative',
|
|
167
|
+
display: 'inline-block',
|
|
168
|
+
border: '1px solid',
|
|
169
|
+
borderColor: 'divider',
|
|
170
|
+
borderRadius: 'var(--mui-shape-borderRadius)',
|
|
171
|
+
p: '0.25rem',
|
|
172
|
+
bgcolor: 'background.paper',
|
|
173
|
+
maxWidth: '100%'
|
|
174
|
+
}
|
|
175
|
+
}, /*#__PURE__*/React.createElement(ReactCrop, {
|
|
176
|
+
crop: crop,
|
|
177
|
+
onChange: function onChange(c) {
|
|
178
|
+
return setCrop(c);
|
|
179
|
+
},
|
|
180
|
+
onComplete: function onComplete(c) {
|
|
181
|
+
return setCompletedCrop(c);
|
|
182
|
+
},
|
|
183
|
+
style: {
|
|
184
|
+
maxWidth: '100%'
|
|
185
|
+
}
|
|
186
|
+
}, /*#__PURE__*/React.createElement("img", {
|
|
187
|
+
ref: imgRef,
|
|
188
|
+
src: attrs.src,
|
|
189
|
+
width: attrs.width,
|
|
190
|
+
crossOrigin: "anonymous",
|
|
191
|
+
style: {
|
|
192
|
+
maxWidth: '100%',
|
|
193
|
+
height: 'auto'
|
|
194
|
+
},
|
|
195
|
+
onLoad: onImageLoad,
|
|
196
|
+
onError: function onError(e) {
|
|
197
|
+
_onError === null || _onError === void 0 || _onError(e);
|
|
198
|
+
}
|
|
199
|
+
})), /*#__PURE__*/React.createElement(Stack, {
|
|
200
|
+
direction: "row",
|
|
201
|
+
spacing: 1,
|
|
202
|
+
sx: {
|
|
203
|
+
mt: 1,
|
|
204
|
+
justifyContent: 'center'
|
|
205
|
+
}
|
|
206
|
+
}, /*#__PURE__*/React.createElement(Button, {
|
|
207
|
+
variant: "contained",
|
|
208
|
+
size: "small",
|
|
209
|
+
onClick: handleConfirm,
|
|
210
|
+
disabled: !completedCrop || isUploading
|
|
211
|
+
}, isUploading ? '上传中...' : '确认裁切'), /*#__PURE__*/React.createElement(Button, {
|
|
212
|
+
variant: "outlined",
|
|
213
|
+
size: "small",
|
|
214
|
+
onClick: onCancel,
|
|
215
|
+
disabled: isUploading
|
|
216
|
+
}, "\u53D6\u6D88"))));
|
|
217
|
+
};
|
|
218
|
+
export default CropImage;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { EditorFnProps } from "../../../type";
|
|
2
|
+
import React from "react";
|
|
3
|
+
import { ImageAttributes } from ".";
|
|
4
|
+
type InsertImageProps = {
|
|
5
|
+
selected: boolean;
|
|
6
|
+
attrs: ImageAttributes;
|
|
7
|
+
updateAttributes: (attrs: ImageAttributes) => void;
|
|
8
|
+
} & EditorFnProps;
|
|
9
|
+
declare const InsertImage: ({ selected, attrs, updateAttributes, onUpload, onError }: InsertImageProps) => React.JSX.Element;
|
|
10
|
+
export default InsertImage;
|
|
@@ -0,0 +1,309 @@
|
|
|
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 ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
3
|
+
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
4
|
+
function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
5
|
+
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : String(i); }
|
|
6
|
+
function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
|
|
7
|
+
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; }
|
|
8
|
+
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); } }
|
|
9
|
+
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); }); }; }
|
|
10
|
+
function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
|
|
11
|
+
function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
|
|
12
|
+
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); }
|
|
13
|
+
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; }
|
|
14
|
+
function _iterableToArrayLimit(r, l) { var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (null != t) { var e, n, i, u, a = [], f = !0, o = !1; try { if (i = (t = t.call(r)).next, 0 === l) { if (Object(t) !== t) return; f = !1; } else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = !0); } catch (r) { o = !0, n = r; } finally { try { if (!f && null != t.return && (u = t.return(), Object(u) !== u)) return; } finally { if (o) throw n; } } return a; } }
|
|
15
|
+
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
|
16
|
+
import { Box, Button, CircularProgress, Stack, Tab, Tabs, TextField } from "@mui/material";
|
|
17
|
+
import { NodeViewWrapper } from "@tiptap/react";
|
|
18
|
+
import { FloatingPopover } from "../../../component/FloatingPopover";
|
|
19
|
+
import { ImageLineIcon } from "../../../component/Icons";
|
|
20
|
+
import React, { useState } from "react";
|
|
21
|
+
import { getImageDimensions, getImageDimensionsFromFile } from ".";
|
|
22
|
+
var InsertImage = function InsertImage(_ref) {
|
|
23
|
+
var selected = _ref.selected,
|
|
24
|
+
attrs = _ref.attrs,
|
|
25
|
+
updateAttributes = _ref.updateAttributes,
|
|
26
|
+
onUpload = _ref.onUpload,
|
|
27
|
+
onError = _ref.onError;
|
|
28
|
+
var _useState = useState(attrs.src || ''),
|
|
29
|
+
_useState2 = _slicedToArray(_useState, 2),
|
|
30
|
+
editSrc = _useState2[0],
|
|
31
|
+
setEditSrc = _useState2[1];
|
|
32
|
+
var _useState3 = useState(onUpload ? 'upload' : 'link'),
|
|
33
|
+
_useState4 = _slicedToArray(_useState3, 2),
|
|
34
|
+
insertType = _useState4[0],
|
|
35
|
+
setInsertType = _useState4[1];
|
|
36
|
+
var _useState5 = useState(null),
|
|
37
|
+
_useState6 = _slicedToArray(_useState5, 2),
|
|
38
|
+
anchorEl = _useState6[0],
|
|
39
|
+
setAnchorEl = _useState6[1];
|
|
40
|
+
var _useState7 = useState(false),
|
|
41
|
+
_useState8 = _slicedToArray(_useState7, 2),
|
|
42
|
+
uploading = _useState8[0],
|
|
43
|
+
setUploading = _useState8[1];
|
|
44
|
+
var _useState9 = useState(0),
|
|
45
|
+
_useState10 = _slicedToArray(_useState9, 2),
|
|
46
|
+
uploadProgress = _useState10[0],
|
|
47
|
+
setUploadProgress = _useState10[1];
|
|
48
|
+
var handleShowPopover = function handleShowPopover(event) {
|
|
49
|
+
return setAnchorEl(event.currentTarget);
|
|
50
|
+
};
|
|
51
|
+
var handleClosePopover = function handleClosePopover() {
|
|
52
|
+
return setAnchorEl(null);
|
|
53
|
+
};
|
|
54
|
+
var handleChangeInsertType = function handleChangeInsertType(event, newValue) {
|
|
55
|
+
return setInsertType(newValue);
|
|
56
|
+
};
|
|
57
|
+
|
|
58
|
+
// 更新图片属性,包含自动获取的宽度
|
|
59
|
+
var updateImageAttributes = /*#__PURE__*/function () {
|
|
60
|
+
var _ref2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(src) {
|
|
61
|
+
var dimensions;
|
|
62
|
+
return _regeneratorRuntime().wrap(function _callee$(_context) {
|
|
63
|
+
while (1) switch (_context.prev = _context.next) {
|
|
64
|
+
case 0:
|
|
65
|
+
_context.prev = 0;
|
|
66
|
+
_context.next = 3;
|
|
67
|
+
return getImageDimensions(src);
|
|
68
|
+
case 3:
|
|
69
|
+
dimensions = _context.sent;
|
|
70
|
+
updateAttributes({
|
|
71
|
+
src: src,
|
|
72
|
+
width: dimensions.width
|
|
73
|
+
});
|
|
74
|
+
_context.next = 11;
|
|
75
|
+
break;
|
|
76
|
+
case 7:
|
|
77
|
+
_context.prev = 7;
|
|
78
|
+
_context.t0 = _context["catch"](0);
|
|
79
|
+
// 如果无法获取尺寸,使用默认宽度
|
|
80
|
+
console.warn('无法获取图片尺寸,使用默认宽度:', _context.t0);
|
|
81
|
+
updateAttributes({
|
|
82
|
+
src: src,
|
|
83
|
+
width: attrs.width || 400 // 默认宽度
|
|
84
|
+
});
|
|
85
|
+
case 11:
|
|
86
|
+
case "end":
|
|
87
|
+
return _context.stop();
|
|
88
|
+
}
|
|
89
|
+
}, _callee, null, [[0, 7]]);
|
|
90
|
+
}));
|
|
91
|
+
return function updateImageAttributes(_x) {
|
|
92
|
+
return _ref2.apply(this, arguments);
|
|
93
|
+
};
|
|
94
|
+
}();
|
|
95
|
+
var handleUploadImage = /*#__PURE__*/function () {
|
|
96
|
+
var _ref3 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2(event) {
|
|
97
|
+
var _event$target$files;
|
|
98
|
+
var file, dimensions, url;
|
|
99
|
+
return _regeneratorRuntime().wrap(function _callee2$(_context2) {
|
|
100
|
+
while (1) switch (_context2.prev = _context2.next) {
|
|
101
|
+
case 0:
|
|
102
|
+
file = (_event$target$files = event.target.files) === null || _event$target$files === void 0 ? void 0 : _event$target$files[0];
|
|
103
|
+
if (!(file && onUpload)) {
|
|
104
|
+
_context2.next = 23;
|
|
105
|
+
break;
|
|
106
|
+
}
|
|
107
|
+
setUploading(true);
|
|
108
|
+
setUploadProgress(0);
|
|
109
|
+
handleClosePopover();
|
|
110
|
+
_context2.prev = 5;
|
|
111
|
+
_context2.next = 8;
|
|
112
|
+
return getImageDimensionsFromFile(file);
|
|
113
|
+
case 8:
|
|
114
|
+
dimensions = _context2.sent;
|
|
115
|
+
_context2.next = 11;
|
|
116
|
+
return onUpload(file, function (event) {
|
|
117
|
+
setUploadProgress(Math.round(event.progress * 100));
|
|
118
|
+
});
|
|
119
|
+
case 11:
|
|
120
|
+
url = _context2.sent;
|
|
121
|
+
setEditSrc(url);
|
|
122
|
+
|
|
123
|
+
// 直接使用已获取的尺寸,无需再次加载图片
|
|
124
|
+
updateAttributes({
|
|
125
|
+
src: url,
|
|
126
|
+
width: dimensions.width
|
|
127
|
+
});
|
|
128
|
+
_context2.next = 19;
|
|
129
|
+
break;
|
|
130
|
+
case 16:
|
|
131
|
+
_context2.prev = 16;
|
|
132
|
+
_context2.t0 = _context2["catch"](5);
|
|
133
|
+
onError === null || onError === void 0 || onError(_context2.t0);
|
|
134
|
+
case 19:
|
|
135
|
+
_context2.prev = 19;
|
|
136
|
+
setUploading(false);
|
|
137
|
+
setUploadProgress(0);
|
|
138
|
+
return _context2.finish(19);
|
|
139
|
+
case 23:
|
|
140
|
+
case "end":
|
|
141
|
+
return _context2.stop();
|
|
142
|
+
}
|
|
143
|
+
}, _callee2, null, [[5, 16, 19, 23]]);
|
|
144
|
+
}));
|
|
145
|
+
return function handleUploadImage(_x2) {
|
|
146
|
+
return _ref3.apply(this, arguments);
|
|
147
|
+
};
|
|
148
|
+
}();
|
|
149
|
+
var handleInsertLink = /*#__PURE__*/function () {
|
|
150
|
+
var _ref4 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee3() {
|
|
151
|
+
return _regeneratorRuntime().wrap(function _callee3$(_context3) {
|
|
152
|
+
while (1) switch (_context3.prev = _context3.next) {
|
|
153
|
+
case 0:
|
|
154
|
+
if (editSrc.trim()) {
|
|
155
|
+
_context3.next = 2;
|
|
156
|
+
break;
|
|
157
|
+
}
|
|
158
|
+
return _context3.abrupt("return");
|
|
159
|
+
case 2:
|
|
160
|
+
_context3.next = 4;
|
|
161
|
+
return updateImageAttributes(editSrc.trim());
|
|
162
|
+
case 4:
|
|
163
|
+
handleClosePopover();
|
|
164
|
+
case 5:
|
|
165
|
+
case "end":
|
|
166
|
+
return _context3.stop();
|
|
167
|
+
}
|
|
168
|
+
}, _callee3);
|
|
169
|
+
}));
|
|
170
|
+
return function handleInsertLink() {
|
|
171
|
+
return _ref4.apply(this, arguments);
|
|
172
|
+
};
|
|
173
|
+
}();
|
|
174
|
+
return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(NodeViewWrapper, {
|
|
175
|
+
className: "image-wrapper",
|
|
176
|
+
"data-drag-handle": true
|
|
177
|
+
}, /*#__PURE__*/React.createElement(Stack, {
|
|
178
|
+
direction: 'row',
|
|
179
|
+
alignItems: 'center',
|
|
180
|
+
gap: 2,
|
|
181
|
+
onClick: !uploading ? handleShowPopover : undefined,
|
|
182
|
+
sx: _objectSpread({
|
|
183
|
+
border: '1px dashed',
|
|
184
|
+
borderColor: 'divider',
|
|
185
|
+
borderRadius: 'var(--mui-shape-borderRadius)',
|
|
186
|
+
px: 2,
|
|
187
|
+
py: 1.5,
|
|
188
|
+
minWidth: 200,
|
|
189
|
+
textAlign: 'center',
|
|
190
|
+
color: 'text.secondary',
|
|
191
|
+
bgcolor: 'action.default',
|
|
192
|
+
position: 'relative',
|
|
193
|
+
overflow: 'hidden'
|
|
194
|
+
}, !uploading ? {
|
|
195
|
+
cursor: 'pointer',
|
|
196
|
+
'&:hover': {
|
|
197
|
+
bgcolor: 'action.hover'
|
|
198
|
+
},
|
|
199
|
+
'&:active': {
|
|
200
|
+
bgcolor: 'action.selected'
|
|
201
|
+
}
|
|
202
|
+
} : {
|
|
203
|
+
"&::before": {
|
|
204
|
+
content: '""',
|
|
205
|
+
position: 'absolute',
|
|
206
|
+
top: 0,
|
|
207
|
+
left: 0,
|
|
208
|
+
height: '100%',
|
|
209
|
+
width: "".concat(uploadProgress, "%"),
|
|
210
|
+
bgcolor: 'primary.main',
|
|
211
|
+
opacity: 0.1,
|
|
212
|
+
transition: 'width 0.3s ease'
|
|
213
|
+
}
|
|
214
|
+
})
|
|
215
|
+
}, /*#__PURE__*/React.createElement(ImageLineIcon, {
|
|
216
|
+
sx: {
|
|
217
|
+
fontSize: '1rem',
|
|
218
|
+
position: 'relative',
|
|
219
|
+
flexShrink: 0
|
|
220
|
+
}
|
|
221
|
+
}), /*#__PURE__*/React.createElement(Box, {
|
|
222
|
+
sx: {
|
|
223
|
+
fontSize: '0.875rem',
|
|
224
|
+
position: 'relative',
|
|
225
|
+
flexGrow: 1,
|
|
226
|
+
textAlign: 'left'
|
|
227
|
+
}
|
|
228
|
+
}, uploading ? '图片上传中...' : '点击此处嵌入或粘贴图片链接'), uploading && /*#__PURE__*/React.createElement(Box, {
|
|
229
|
+
sx: {
|
|
230
|
+
fontSize: 12,
|
|
231
|
+
fontWeight: 'bold',
|
|
232
|
+
color: 'primary.main',
|
|
233
|
+
position: 'relative',
|
|
234
|
+
flexShrink: 0
|
|
235
|
+
}
|
|
236
|
+
}, uploadProgress, "%"))), /*#__PURE__*/React.createElement(FloatingPopover, {
|
|
237
|
+
open: Boolean(anchorEl),
|
|
238
|
+
anchorEl: anchorEl,
|
|
239
|
+
onClose: handleClosePopover,
|
|
240
|
+
placement: "bottom"
|
|
241
|
+
}, /*#__PURE__*/React.createElement(Stack, {
|
|
242
|
+
direction: 'row',
|
|
243
|
+
alignItems: 'center',
|
|
244
|
+
justifyContent: 'center',
|
|
245
|
+
sx: {
|
|
246
|
+
width: 350,
|
|
247
|
+
borderBottom: '1px solid',
|
|
248
|
+
borderColor: 'divider'
|
|
249
|
+
}
|
|
250
|
+
}, /*#__PURE__*/React.createElement(Tabs, {
|
|
251
|
+
value: insertType,
|
|
252
|
+
onChange: handleChangeInsertType,
|
|
253
|
+
sx: {
|
|
254
|
+
borderRadius: '0 !important',
|
|
255
|
+
height: 'auto !important',
|
|
256
|
+
padding: '0 !important'
|
|
257
|
+
}
|
|
258
|
+
}, /*#__PURE__*/React.createElement(Tab, {
|
|
259
|
+
label: "\u4E0A\u4F20",
|
|
260
|
+
value: "upload"
|
|
261
|
+
}), /*#__PURE__*/React.createElement(Tab, {
|
|
262
|
+
label: "\u5D4C\u5165\u94FE\u63A5",
|
|
263
|
+
value: "link"
|
|
264
|
+
}))), insertType === 'upload' ? /*#__PURE__*/React.createElement(Stack, {
|
|
265
|
+
alignItems: 'center',
|
|
266
|
+
gap: 2,
|
|
267
|
+
sx: {
|
|
268
|
+
p: 2
|
|
269
|
+
}
|
|
270
|
+
}, /*#__PURE__*/React.createElement(Button, {
|
|
271
|
+
variant: "contained",
|
|
272
|
+
component: "label",
|
|
273
|
+
disabled: !onUpload || uploading,
|
|
274
|
+
fullWidth: true,
|
|
275
|
+
startIcon: uploading ? /*#__PURE__*/React.createElement(CircularProgress, {
|
|
276
|
+
size: 20
|
|
277
|
+
}) : /*#__PURE__*/React.createElement(ImageLineIcon, {
|
|
278
|
+
sx: {
|
|
279
|
+
fontSize: 18
|
|
280
|
+
}
|
|
281
|
+
})
|
|
282
|
+
}, /*#__PURE__*/React.createElement("input", {
|
|
283
|
+
type: "file",
|
|
284
|
+
hidden: true,
|
|
285
|
+
multiple: false,
|
|
286
|
+
accept: "image/*",
|
|
287
|
+
onChange: handleUploadImage
|
|
288
|
+
}), uploading ? '图片上传中...' : '选择图片文件')) : /*#__PURE__*/React.createElement(Stack, {
|
|
289
|
+
gap: 2,
|
|
290
|
+
sx: {
|
|
291
|
+
p: 2
|
|
292
|
+
}
|
|
293
|
+
}, /*#__PURE__*/React.createElement(TextField, {
|
|
294
|
+
fullWidth: true,
|
|
295
|
+
size: "small",
|
|
296
|
+
value: editSrc,
|
|
297
|
+
onChange: function onChange(e) {
|
|
298
|
+
return setEditSrc(e.target.value);
|
|
299
|
+
},
|
|
300
|
+
placeholder: "\u8F93\u5165\u56FE\u7247\u7684 URL",
|
|
301
|
+
label: "\u56FE\u7247\u94FE\u63A5"
|
|
302
|
+
}), /*#__PURE__*/React.createElement(Button, {
|
|
303
|
+
variant: "contained",
|
|
304
|
+
fullWidth: true,
|
|
305
|
+
onClick: handleInsertLink,
|
|
306
|
+
disabled: !editSrc.trim()
|
|
307
|
+
}, "\u5D4C\u5165\u56FE\u7247"))));
|
|
308
|
+
};
|
|
309
|
+
export default InsertImage;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import { ImageAttributes } from ".";
|
|
3
|
+
import 'react-photo-view/dist/react-photo-view.css';
|
|
4
|
+
interface ReadonlyImageProps {
|
|
5
|
+
attrs: ImageAttributes;
|
|
6
|
+
}
|
|
7
|
+
declare const ReadonlyImage: ({ attrs, }: ReadonlyImageProps) => React.JSX.Element;
|
|
8
|
+
export default ReadonlyImage;
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
function _extends() { _extends = Object.assign ? Object.assign.bind() : function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
|
|
2
|
+
import { Box } from "@mui/material";
|
|
3
|
+
import { NodeViewWrapper } from "@tiptap/react";
|
|
4
|
+
import React from "react";
|
|
5
|
+
import { PhotoProvider, PhotoView } from "react-photo-view";
|
|
6
|
+
import 'react-photo-view/dist/react-photo-view.css';
|
|
7
|
+
var ReadonlyImage = function ReadonlyImage(_ref) {
|
|
8
|
+
var attrs = _ref.attrs;
|
|
9
|
+
return /*#__PURE__*/React.createElement(NodeViewWrapper, {
|
|
10
|
+
className: "image-wrapper",
|
|
11
|
+
"data-drag-handle": true
|
|
12
|
+
}, /*#__PURE__*/React.createElement(Box, {
|
|
13
|
+
component: 'span',
|
|
14
|
+
sx: {
|
|
15
|
+
position: 'relative',
|
|
16
|
+
display: 'inline-block',
|
|
17
|
+
border: '1px solid',
|
|
18
|
+
borderColor: 'divider',
|
|
19
|
+
borderRadius: 'var(--mui-shape-borderRadius)',
|
|
20
|
+
p: '0.25rem',
|
|
21
|
+
bgcolor: 'background.paper',
|
|
22
|
+
'&:hover .image-controls': {
|
|
23
|
+
opacity: 1
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
}, /*#__PURE__*/React.createElement(PhotoProvider, null, /*#__PURE__*/React.createElement(PhotoView, {
|
|
27
|
+
render: function render(props) {
|
|
28
|
+
return /*#__PURE__*/React.createElement("img", _extends({}, props.attrs, {
|
|
29
|
+
src: attrs.src,
|
|
30
|
+
style: {
|
|
31
|
+
transformOrigin: '0 0',
|
|
32
|
+
transform: 'translate(-50%, -50%)',
|
|
33
|
+
backgroundColor: 'hsl(0, 0%, 90%)',
|
|
34
|
+
maxWidth: '100%',
|
|
35
|
+
maxHeight: '90%'
|
|
36
|
+
}
|
|
37
|
+
}));
|
|
38
|
+
}
|
|
39
|
+
}, /*#__PURE__*/React.createElement("img", {
|
|
40
|
+
src: attrs.src,
|
|
41
|
+
width: attrs.width,
|
|
42
|
+
style: {
|
|
43
|
+
maxWidth: '100%',
|
|
44
|
+
height: 'auto',
|
|
45
|
+
cursor: 'pointer'
|
|
46
|
+
},
|
|
47
|
+
onError: function onError(e) {
|
|
48
|
+
console.error('Image load error:', e);
|
|
49
|
+
}
|
|
50
|
+
})))));
|
|
51
|
+
};
|
|
52
|
+
export default ReadonlyImage;
|