adtec-core-package 3.0.0 → 3.0.2
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/auto-imports.d.ts +299 -0
- package/package.json +93 -49
- package/prebuilt/umo-editor/favicon.ico +0 -0
- package/prebuilt/umo-editor/umo-editor.css +1 -0
- package/prebuilt/umo-editor/umo-editor.js +86138 -0
- package/prebuilt/umo-editor/umo-editor.js.map +1 -0
- package/scripts/build-umo.mjs +47 -0
- package/scripts/generate-umo-entry.mjs +81 -0
- package/scripts/inject-umo-composable-imports.mjs +66 -0
- package/scripts/patch-es-drager-vue35.mjs +68 -0
- package/scripts/patch-tiptap-vue3.mjs +117 -0
- package/scripts/prepare-umo-source.mjs +122 -0
- package/src/components/RichTextEditor/RichTextEditor.vue +566 -398
- package/src/components/RichTextEditor/installUmoEditorApp.ts +31 -0
- package/src/components/RichTextEditor/richTextHtmlUtils.ts +151 -17
- package/src/components/RichTextEditor/umo-editor.d.ts +9 -0
- package/src/components/editor-main/src/assets/icons/align-center.svg +1 -0
- package/src/components/editor-main/src/assets/icons/align-distributed.svg +1 -0
- package/src/components/editor-main/src/assets/icons/align-justify.svg +1 -0
- package/src/components/editor-main/src/assets/icons/align-left.svg +1 -0
- package/src/components/editor-main/src/assets/icons/align-right.svg +1 -0
- package/src/components/editor-main/src/assets/icons/arrow-down.svg +1 -0
- package/src/components/editor-main/src/assets/icons/audio.svg +1 -0
- package/src/components/editor-main/src/assets/icons/auto-width.svg +1 -0
- package/src/components/editor-main/src/assets/icons/background-color.svg +1 -0
- package/src/components/editor-main/src/assets/icons/barcode.svg +1 -0
- package/src/components/editor-main/src/assets/icons/block-add.svg +1 -0
- package/src/components/editor-main/src/assets/icons/block-menu.svg +1 -0
- package/src/components/editor-main/src/assets/icons/bold.svg +1 -0
- package/src/components/editor-main/src/assets/icons/bookmark.svg +10 -0
- package/src/components/editor-main/src/assets/icons/border-none.svg +1 -0
- package/src/components/editor-main/src/assets/icons/border.svg +1 -0
- package/src/components/editor-main/src/assets/icons/break-marks.svg +1 -0
- package/src/components/editor-main/src/assets/icons/bullet-list-2.svg +1 -0
- package/src/components/editor-main/src/assets/icons/bullet-list-circle.svg +1 -0
- package/src/components/editor-main/src/assets/icons/bullet-list-disc.svg +1 -0
- package/src/components/editor-main/src/assets/icons/bullet-list-square.svg +1 -0
- package/src/components/editor-main/src/assets/icons/bullet-list.svg +1 -0
- package/src/components/editor-main/src/assets/icons/callout.svg +1 -0
- package/src/components/editor-main/src/assets/icons/check.svg +1 -0
- package/src/components/editor-main/src/assets/icons/checkbox.svg +1 -0
- package/src/components/editor-main/src/assets/icons/chinese-case.svg +1 -0
- package/src/components/editor-main/src/assets/icons/clear-cache.svg +1 -0
- package/src/components/editor-main/src/assets/icons/clear-format.svg +1 -0
- package/src/components/editor-main/src/assets/icons/clickable.svg +1 -0
- package/src/components/editor-main/src/assets/icons/close.svg +1 -0
- package/src/components/editor-main/src/assets/icons/code-block.svg +1 -0
- package/src/components/editor-main/src/assets/icons/code-line-number.svg +1 -0
- package/src/components/editor-main/src/assets/icons/code-word-wrap.svg +1 -0
- package/src/components/editor-main/src/assets/icons/code.svg +1 -0
- package/src/components/editor-main/src/assets/icons/color.svg +1 -0
- package/src/components/editor-main/src/assets/icons/columns.svg +1 -0
- package/src/components/editor-main/src/assets/icons/copy.svg +1 -0
- package/src/components/editor-main/src/assets/icons/copyright.svg +1 -0
- package/src/components/editor-main/src/assets/icons/date.svg +1 -0
- package/src/components/editor-main/src/assets/icons/details.svg +1 -0
- package/src/components/editor-main/src/assets/icons/diagrams.svg +1 -0
- package/src/components/editor-main/src/assets/icons/download.svg +1 -0
- package/src/components/editor-main/src/assets/icons/echarts.svg +1 -0
- package/src/components/editor-main/src/assets/icons/edit.svg +1 -0
- package/src/components/editor-main/src/assets/icons/embed.svg +1 -0
- package/src/components/editor-main/src/assets/icons/emoji.svg +1 -0
- package/src/components/editor-main/src/assets/icons/equal-proportion.svg +1 -0
- package/src/components/editor-main/src/assets/icons/exit.svg +1 -0
- package/src/components/editor-main/src/assets/icons/expand-down.svg +1 -0
- package/src/components/editor-main/src/assets/icons/file-view.svg +1 -0
- package/src/components/editor-main/src/assets/icons/file.svg +1 -0
- package/src/components/editor-main/src/assets/icons/font-size-decrease.svg +1 -0
- package/src/components/editor-main/src/assets/icons/font-size-increase.svg +1 -0
- package/src/components/editor-main/src/assets/icons/footnote.svg +1 -0
- package/src/components/editor-main/src/assets/icons/format-painter.svg +1 -0
- package/src/components/editor-main/src/assets/icons/format.svg +1 -0
- package/src/components/editor-main/src/assets/icons/full-screen-exit.svg +1 -0
- package/src/components/editor-main/src/assets/icons/full-screen.svg +1 -0
- package/src/components/editor-main/src/assets/icons/hand-drawn.svg +1 -0
- package/src/components/editor-main/src/assets/icons/hard-break.svg +1 -0
- package/src/components/editor-main/src/assets/icons/heading.svg +1 -0
- package/src/components/editor-main/src/assets/icons/help.svg +1 -0
- package/src/components/editor-main/src/assets/icons/hide-toolbar.svg +1 -0
- package/src/components/editor-main/src/assets/icons/highlight.svg +1 -0
- package/src/components/editor-main/src/assets/icons/hr.svg +1 -0
- package/src/components/editor-main/src/assets/icons/html5.svg +1 -0
- package/src/components/editor-main/src/assets/icons/image-draggable.svg +1 -0
- package/src/components/editor-main/src/assets/icons/image-failed.svg +1 -0
- package/src/components/editor-main/src/assets/icons/image-flip.svg +1 -0
- package/src/components/editor-main/src/assets/icons/image-inline.svg +1 -0
- package/src/components/editor-main/src/assets/icons/image-preview.svg +1 -0
- package/src/components/editor-main/src/assets/icons/image-remove-background.svg +1 -0
- package/src/components/editor-main/src/assets/icons/image-reset.svg +1 -0
- package/src/components/editor-main/src/assets/icons/image-rotate.svg +1 -0
- package/src/components/editor-main/src/assets/icons/image.svg +1 -0
- package/src/components/editor-main/src/assets/icons/indent.svg +1 -0
- package/src/components/editor-main/src/assets/icons/italic.svg +1 -0
- package/src/components/editor-main/src/assets/icons/laser-pointer.svg +1 -0
- package/src/components/editor-main/src/assets/icons/layout-page.svg +1 -0
- package/src/components/editor-main/src/assets/icons/layout-web.svg +1 -0
- package/src/components/editor-main/src/assets/icons/letter-spacing.svg +1 -0
- package/src/components/editor-main/src/assets/icons/line-height.svg +1 -0
- package/src/components/editor-main/src/assets/icons/line-number.svg +1 -0
- package/src/components/editor-main/src/assets/icons/link.svg +1 -0
- package/src/components/editor-main/src/assets/icons/loading.svg +1 -0
- package/src/components/editor-main/src/assets/icons/locale.svg +1 -0
- package/src/components/editor-main/src/assets/icons/margin.svg +1 -0
- package/src/components/editor-main/src/assets/icons/markdown.svg +1 -0
- package/src/components/editor-main/src/assets/icons/math.svg +1 -0
- package/src/components/editor-main/src/assets/icons/mention.svg +1 -0
- package/src/components/editor-main/src/assets/icons/menu.svg +1 -0
- package/src/components/editor-main/src/assets/icons/mermaid.svg +1 -0
- package/src/components/editor-main/src/assets/icons/mind-map.svg +1 -0
- package/src/components/editor-main/src/assets/icons/minus.svg +1 -0
- package/src/components/editor-main/src/assets/icons/new-window.svg +1 -0
- package/src/components/editor-main/src/assets/icons/node-add.svg +1 -0
- package/src/components/editor-main/src/assets/icons/node-clear-format.svg +1 -0
- package/src/components/editor-main/src/assets/icons/node-copy.svg +1 -0
- package/src/components/editor-main/src/assets/icons/node-cut.svg +2 -0
- package/src/components/editor-main/src/assets/icons/node-delete-2.svg +1 -0
- package/src/components/editor-main/src/assets/icons/node-delete.svg +1 -0
- package/src/components/editor-main/src/assets/icons/node-duplicate.svg +1 -0
- package/src/components/editor-main/src/assets/icons/node-switch.svg +1 -0
- package/src/components/editor-main/src/assets/icons/ordered-list-2.svg +1 -0
- package/src/components/editor-main/src/assets/icons/ordered-list-decimal-leading-zero.svg +1 -0
- package/src/components/editor-main/src/assets/icons/ordered-list-decimal.svg +1 -0
- package/src/components/editor-main/src/assets/icons/ordered-list-lower-latin.svg +1 -0
- package/src/components/editor-main/src/assets/icons/ordered-list-lower-roman.svg +1 -0
- package/src/components/editor-main/src/assets/icons/ordered-list-simp-chinese-formal.svg +12 -0
- package/src/components/editor-main/src/assets/icons/ordered-list-trad-chinese-informal.svg +12 -0
- package/src/components/editor-main/src/assets/icons/ordered-list-upper-latin.svg +1 -0
- package/src/components/editor-main/src/assets/icons/ordered-list-upper-roman.svg +1 -0
- package/src/components/editor-main/src/assets/icons/ordered-list.svg +1 -0
- package/src/components/editor-main/src/assets/icons/outdent.svg +1 -0
- package/src/components/editor-main/src/assets/icons/page-background.svg +1 -0
- package/src/components/editor-main/src/assets/icons/page-break.svg +1 -0
- package/src/components/editor-main/src/assets/icons/page-footer.svg +1 -0
- package/src/components/editor-main/src/assets/icons/page-header.svg +1 -0
- package/src/components/editor-main/src/assets/icons/page-margin.svg +1 -0
- package/src/components/editor-main/src/assets/icons/page-orientation.svg +1 -0
- package/src/components/editor-main/src/assets/icons/page-size.svg +1 -0
- package/src/components/editor-main/src/assets/icons/page.svg +1 -0
- package/src/components/editor-main/src/assets/icons/palette-color.svg +1 -0
- package/src/components/editor-main/src/assets/icons/paragraph.svg +1 -0
- package/src/components/editor-main/src/assets/icons/pdf.svg +1 -0
- package/src/components/editor-main/src/assets/icons/plus.svg +1 -0
- package/src/components/editor-main/src/assets/icons/preview.svg +1 -0
- package/src/components/editor-main/src/assets/icons/print.svg +1 -0
- package/src/components/editor-main/src/assets/icons/qrcode.svg +1 -0
- package/src/components/editor-main/src/assets/icons/quote.svg +1 -0
- package/src/components/editor-main/src/assets/icons/redo.svg +1 -0
- package/src/components/editor-main/src/assets/icons/register.js +47 -0
- package/src/components/editor-main/src/assets/icons/reload.svg +1 -0
- package/src/components/editor-main/src/assets/icons/remove.svg +1 -0
- package/src/components/editor-main/src/assets/icons/reply.svg +1 -0
- package/src/components/editor-main/src/assets/icons/search-replace.svg +1 -0
- package/src/components/editor-main/src/assets/icons/select-all.svg +1 -0
- package/src/components/editor-main/src/assets/icons/selected.svg +1 -0
- package/src/components/editor-main/src/assets/icons/setting.svg +1 -0
- package/src/components/editor-main/src/assets/icons/share.svg +1 -0
- package/src/components/editor-main/src/assets/icons/shortcut.svg +1 -0
- package/src/components/editor-main/src/assets/icons/signature.svg +1 -0
- package/src/components/editor-main/src/assets/icons/skin.svg +1 -0
- package/src/components/editor-main/src/assets/icons/spellcheck.svg +1 -0
- package/src/components/editor-main/src/assets/icons/strike.svg +1 -0
- package/src/components/editor-main/src/assets/icons/subscript.svg +1 -0
- package/src/components/editor-main/src/assets/icons/superscript.svg +1 -0
- package/src/components/editor-main/src/assets/icons/symbol.svg +1 -0
- package/src/components/editor-main/src/assets/icons/table-add-column-after.svg +1 -0
- package/src/components/editor-main/src/assets/icons/table-add-column-before.svg +1 -0
- package/src/components/editor-main/src/assets/icons/table-add-row-after.svg +1 -0
- package/src/components/editor-main/src/assets/icons/table-add-row-before.svg +1 -0
- package/src/components/editor-main/src/assets/icons/table-cells-align.svg +1 -0
- package/src/components/editor-main/src/assets/icons/table-cells-background.svg +1 -0
- package/src/components/editor-main/src/assets/icons/table-delete-column.svg +1 -0
- package/src/components/editor-main/src/assets/icons/table-delete-row.svg +1 -0
- package/src/components/editor-main/src/assets/icons/table-delete.svg +1 -0
- package/src/components/editor-main/src/assets/icons/table-fix.svg +1 -0
- package/src/components/editor-main/src/assets/icons/table-header-cell.svg +1 -0
- package/src/components/editor-main/src/assets/icons/table-header-column.svg +1 -0
- package/src/components/editor-main/src/assets/icons/table-header-row.svg +1 -0
- package/src/components/editor-main/src/assets/icons/table-merge-cell.svg +1 -0
- package/src/components/editor-main/src/assets/icons/table-next-cell.svg +1 -0
- package/src/components/editor-main/src/assets/icons/table-previous-cell.svg +1 -0
- package/src/components/editor-main/src/assets/icons/table-split-cell.svg +1 -0
- package/src/components/editor-main/src/assets/icons/table.svg +1 -0
- package/src/components/editor-main/src/assets/icons/tag.svg +1 -0
- package/src/components/editor-main/src/assets/icons/task-list-2.svg +1 -0
- package/src/components/editor-main/src/assets/icons/task-list.svg +1 -0
- package/src/components/editor-main/src/assets/icons/template.svg +1 -0
- package/src/components/editor-main/src/assets/icons/text-box.svg +1 -0
- package/src/components/editor-main/src/assets/icons/text.svg +1 -0
- package/src/components/editor-main/src/assets/icons/theme.svg +1 -0
- package/src/components/editor-main/src/assets/icons/time.svg +1 -0
- package/src/components/editor-main/src/assets/icons/toc.svg +1 -0
- package/src/components/editor-main/src/assets/icons/toolbar-classic.svg +1 -0
- package/src/components/editor-main/src/assets/icons/toolbar-ribbon.svg +1 -0
- package/src/components/editor-main/src/assets/icons/toolbar-source.svg +1 -0
- package/src/components/editor-main/src/assets/icons/underline.svg +1 -0
- package/src/components/editor-main/src/assets/icons/undo.svg +1 -0
- package/src/components/editor-main/src/assets/icons/unlink.svg +1 -0
- package/src/components/editor-main/src/assets/icons/video.svg +1 -0
- package/src/components/editor-main/src/assets/icons/view.svg +1 -0
- package/src/components/editor-main/src/assets/icons/watermark.svg +1 -0
- package/src/components/editor-main/src/assets/icons/web-page.svg +1 -0
- package/src/components/editor-main/src/assets/icons/word-wrap.svg +1 -0
- package/src/components/editor-main/src/assets/icons/word.svg +1 -0
- package/src/components/editor-main/src/assets/icons/writing-mode.svg +1 -0
- package/src/components/editor-main/src/assets/icons/zoom-1.svg +1 -0
- package/src/components/editor-main/src/assets/icons/zoom-auto.svg +1 -0
- package/src/components/editor-main/src/assets/icons/zoom.svg +1 -0
- package/src/components/editor-main/src/assets/images/avatar.svg +1 -0
- package/src/components/editor-main/src/assets/images/format-painter.svg +1 -0
- package/src/components/editor-main/src/assets/images/laser-pointer.svg +1 -0
- package/src/components/editor-main/src/assets/images/logo.svg +1 -0
- package/src/components/editor-main/src/assets/images/watermark-compact.png +0 -0
- package/src/components/editor-main/src/assets/images/watermark-spacious.png +0 -0
- package/src/components/editor-main/src/assets/styles/_mixins.less +150 -0
- package/src/components/editor-main/src/assets/styles/_variables.less +97 -0
- package/src/components/editor-main/src/assets/styles/drager.less +123 -0
- package/src/components/editor-main/src/assets/styles/editor.less +917 -0
- package/src/components/editor-main/src/assets/styles/index.less +19 -0
- package/src/components/editor-main/src/assets/styles/plyr.less +26 -0
- package/src/components/editor-main/src/assets/styles/tdesign.less +341 -0
- package/src/components/editor-main/src/components/container/page.vue +392 -0
- package/src/components/editor-main/src/components/container/print.vue +191 -0
- package/src/components/editor-main/src/components/container/search-replace.vue +264 -0
- package/src/components/editor-main/src/components/container/toc.vue +260 -0
- package/src/components/editor-main/src/components/editor/index.vue +213 -0
- package/src/components/editor-main/src/components/icon.vue +43 -0
- package/src/components/editor-main/src/components/index.js +22 -0
- package/src/components/editor-main/src/components/index.vue +1396 -0
- package/src/components/editor-main/src/components/menus/block/common.vue +127 -0
- package/src/components/editor-main/src/components/menus/block/index.vue +217 -0
- package/src/components/editor-main/src/components/menus/block/node.vue +183 -0
- package/src/components/editor-main/src/components/menus/bubble/callout/background.vue +39 -0
- package/src/components/editor-main/src/components/menus/bubble/callout/builtin.vue +90 -0
- package/src/components/editor-main/src/components/menus/bubble/callout/emoji-remove.vue +28 -0
- package/src/components/editor-main/src/components/menus/bubble/file/download.vue +30 -0
- package/src/components/editor-main/src/components/menus/bubble/file/width.vue +22 -0
- package/src/components/editor-main/src/components/menus/bubble/image/convert.vue +63 -0
- package/src/components/editor-main/src/components/menus/bubble/image/edit.vue +32 -0
- package/src/components/editor-main/src/components/menus/bubble/image/open.vue +27 -0
- package/src/components/editor-main/src/components/menus/bubble/image/preview.vue +24 -0
- package/src/components/editor-main/src/components/menus/bubble/image/proportion.vue +34 -0
- package/src/components/editor-main/src/components/menus/bubble/index.vue +55 -0
- package/src/components/editor-main/src/components/menus/bubble/link/copy.vue +29 -0
- package/src/components/editor-main/src/components/menus/bubble/link/open.vue +27 -0
- package/src/components/editor-main/src/components/menus/bubble/link/unlink.vue +19 -0
- package/src/components/editor-main/src/components/menus/bubble/math.vue +36 -0
- package/src/components/editor-main/src/components/menus/bubble/menus.vue +209 -0
- package/src/components/editor-main/src/components/menus/bubble/node/delete.vue +15 -0
- package/src/components/editor-main/src/components/menus/bubble/node/duplicate.vue +40 -0
- package/src/components/editor-main/src/components/menus/bubble/node/tofile.vue +31 -0
- package/src/components/editor-main/src/components/menus/bubble/tag/background.vue +36 -0
- package/src/components/editor-main/src/components/menus/bubble/tag/builtin.vue +88 -0
- package/src/components/editor-main/src/components/menus/bubble/tag/color.vue +36 -0
- package/src/components/editor-main/src/components/menus/bubble/tag/delete.vue +14 -0
- package/src/components/editor-main/src/components/menus/bubble/tag/input.vue +63 -0
- package/src/components/editor-main/src/components/menus/bubble/text-box/background.vue +37 -0
- package/src/components/editor-main/src/components/menus/bubble/text-box/border.vue +186 -0
- package/src/components/editor-main/src/components/menus/bubble/text-box/writing-mode.vue +42 -0
- package/src/components/editor-main/src/components/menus/bubble/webpage/clickable.vue +31 -0
- package/src/components/editor-main/src/components/menus/bubble/webpage/open.vue +29 -0
- package/src/components/editor-main/src/components/menus/button.vue +630 -0
- package/src/components/editor-main/src/components/menus/toolbar/base/align-center.vue +33 -0
- package/src/components/editor-main/src/components/menus/toolbar/base/align-distributed.vue +18 -0
- package/src/components/editor-main/src/components/menus/toolbar/base/align-dropdown.vue +56 -0
- package/src/components/editor-main/src/components/menus/toolbar/base/align-justify.vue +18 -0
- package/src/components/editor-main/src/components/menus/toolbar/base/align-left.vue +32 -0
- package/src/components/editor-main/src/components/menus/toolbar/base/align-right.vue +33 -0
- package/src/components/editor-main/src/components/menus/toolbar/base/background-color.vue +72 -0
- package/src/components/editor-main/src/components/menus/toolbar/base/bold.vue +18 -0
- package/src/components/editor-main/src/components/menus/toolbar/base/bullet-list.vue +110 -0
- package/src/components/editor-main/src/components/menus/toolbar/base/clear-format.vue +15 -0
- package/src/components/editor-main/src/components/menus/toolbar/base/code.vue +18 -0
- package/src/components/editor-main/src/components/menus/toolbar/base/color.vue +75 -0
- package/src/components/editor-main/src/components/menus/toolbar/base/font-family.vue +528 -0
- package/src/components/editor-main/src/components/menus/toolbar/base/font-size.vue +163 -0
- package/src/components/editor-main/src/components/menus/toolbar/base/format-painter.vue +27 -0
- package/src/components/editor-main/src/components/menus/toolbar/base/heading.vue +322 -0
- package/src/components/editor-main/src/components/menus/toolbar/base/highlight.vue +127 -0
- package/src/components/editor-main/src/components/menus/toolbar/base/indent.vue +17 -0
- package/src/components/editor-main/src/components/menus/toolbar/base/italic.vue +18 -0
- package/src/components/editor-main/src/components/menus/toolbar/base/letter-spacing.vue +113 -0
- package/src/components/editor-main/src/components/menus/toolbar/base/line-height.vue +40 -0
- package/src/components/editor-main/src/components/menus/toolbar/base/margin.vue +118 -0
- package/src/components/editor-main/src/components/menus/toolbar/base/markdown.vue +50 -0
- package/src/components/editor-main/src/components/menus/toolbar/base/ordered-list.vue +184 -0
- package/src/components/editor-main/src/components/menus/toolbar/base/outdent.vue +17 -0
- package/src/components/editor-main/src/components/menus/toolbar/base/print.vue +19 -0
- package/src/components/editor-main/src/components/menus/toolbar/base/quote.vue +18 -0
- package/src/components/editor-main/src/components/menus/toolbar/base/redo.vue +20 -0
- package/src/components/editor-main/src/components/menus/toolbar/base/search-replace.vue +16 -0
- package/src/components/editor-main/src/components/menus/toolbar/base/select-all.vue +16 -0
- package/src/components/editor-main/src/components/menus/toolbar/base/strike.vue +18 -0
- package/src/components/editor-main/src/components/menus/toolbar/base/subscript.vue +18 -0
- package/src/components/editor-main/src/components/menus/toolbar/base/superscript.vue +18 -0
- package/src/components/editor-main/src/components/menus/toolbar/base/task-list.vue +47 -0
- package/src/components/editor-main/src/components/menus/toolbar/base/underline.vue +18 -0
- package/src/components/editor-main/src/components/menus/toolbar/base/undo.vue +18 -0
- package/src/components/editor-main/src/components/menus/toolbar/base/word-wrap.vue +47 -0
- package/src/components/editor-main/src/components/menus/toolbar/export/embed.vue +67 -0
- package/src/components/editor-main/src/components/menus/toolbar/export/html.vue +27 -0
- package/src/components/editor-main/src/components/menus/toolbar/export/image.vue +66 -0
- package/src/components/editor-main/src/components/menus/toolbar/export/pdf.vue +8 -0
- package/src/components/editor-main/src/components/menus/toolbar/export/share.vue +63 -0
- package/src/components/editor-main/src/components/menus/toolbar/export/text.vue +32 -0
- package/src/components/editor-main/src/components/menus/toolbar/insert/audio.vue +23 -0
- package/src/components/editor-main/src/components/menus/toolbar/insert/bookmark.vue +206 -0
- package/src/components/editor-main/src/components/menus/toolbar/insert/callout.vue +15 -0
- package/src/components/editor-main/src/components/menus/toolbar/insert/chinese-date.vue +112 -0
- package/src/components/editor-main/src/components/menus/toolbar/insert/code-block.vue +16 -0
- package/src/components/editor-main/src/components/menus/toolbar/insert/columns.vue +97 -0
- package/src/components/editor-main/src/components/menus/toolbar/insert/details.vue +34 -0
- package/src/components/editor-main/src/components/menus/toolbar/insert/emoji.vue +103 -0
- package/src/components/editor-main/src/components/menus/toolbar/insert/file.vue +23 -0
- package/src/components/editor-main/src/components/menus/toolbar/insert/footnote.vue +15 -0
- package/src/components/editor-main/src/components/menus/toolbar/insert/hard-break.vue +16 -0
- package/src/components/editor-main/src/components/menus/toolbar/insert/hr.vue +141 -0
- package/src/components/editor-main/src/components/menus/toolbar/insert/image.vue +84 -0
- package/src/components/editor-main/src/components/menus/toolbar/insert/link.vue +121 -0
- package/src/components/editor-main/src/components/menus/toolbar/insert/mention.vue +15 -0
- package/src/components/editor-main/src/components/menus/toolbar/insert/option-box.vue +324 -0
- package/src/components/editor-main/src/components/menus/toolbar/insert/symbol.vue +88 -0
- package/src/components/editor-main/src/components/menus/toolbar/insert/tag.vue +15 -0
- package/src/components/editor-main/src/components/menus/toolbar/insert/template.vue +76 -0
- package/src/components/editor-main/src/components/menus/toolbar/insert/text-box.vue +15 -0
- package/src/components/editor-main/src/components/menus/toolbar/insert/toc.vue +15 -0
- package/src/components/editor-main/src/components/menus/toolbar/insert/video.vue +23 -0
- package/src/components/editor-main/src/components/menus/toolbar/insert/web-page.vue +173 -0
- package/src/components/editor-main/src/components/menus/toolbar/page/background.vue +138 -0
- package/src/components/editor-main/src/components/menus/toolbar/page/break-marks.vue +26 -0
- package/src/components/editor-main/src/components/menus/toolbar/page/break.vue +20 -0
- package/src/components/editor-main/src/components/menus/toolbar/page/footer.vue +15 -0
- package/src/components/editor-main/src/components/menus/toolbar/page/header.vue +15 -0
- package/src/components/editor-main/src/components/menus/toolbar/page/line-number.vue +16 -0
- package/src/components/editor-main/src/components/menus/toolbar/page/margin.vue +17 -0
- package/src/components/editor-main/src/components/menus/toolbar/page/orientation.vue +63 -0
- package/src/components/editor-main/src/components/menus/toolbar/page/size.vue +67 -0
- package/src/components/editor-main/src/components/menus/toolbar/page/watermark.vue +200 -0
- package/src/components/editor-main/src/components/menus/toolbar/table/add-column-after.vue +20 -0
- package/src/components/editor-main/src/components/menus/toolbar/table/add-column-before.vue +20 -0
- package/src/components/editor-main/src/components/menus/toolbar/table/add-row-after.vue +20 -0
- package/src/components/editor-main/src/components/menus/toolbar/table/add-row-before.vue +20 -0
- package/src/components/editor-main/src/components/menus/toolbar/table/border-color.vue +35 -0
- package/src/components/editor-main/src/components/menus/toolbar/table/cells-align.vue +41 -0
- package/src/components/editor-main/src/components/menus/toolbar/table/cells-background.vue +32 -0
- package/src/components/editor-main/src/components/menus/toolbar/table/delete-column.vue +44 -0
- package/src/components/editor-main/src/components/menus/toolbar/table/delete-row.vue +44 -0
- package/src/components/editor-main/src/components/menus/toolbar/table/delete.vue +40 -0
- package/src/components/editor-main/src/components/menus/toolbar/table/fix.vue +17 -0
- package/src/components/editor-main/src/components/menus/toolbar/table/insert.vue +137 -0
- package/src/components/editor-main/src/components/menus/toolbar/table/merge-cells.vue +20 -0
- package/src/components/editor-main/src/components/menus/toolbar/table/next-cell.vue +21 -0
- package/src/components/editor-main/src/components/menus/toolbar/table/previous-cell.vue +21 -0
- package/src/components/editor-main/src/components/menus/toolbar/table/split-cell.vue +20 -0
- package/src/components/editor-main/src/components/menus/toolbar/table/toggle-header-cell.vue +20 -0
- package/src/components/editor-main/src/components/menus/toolbar/table/toggle-header-column.vue +20 -0
- package/src/components/editor-main/src/components/menus/toolbar/table/toggle-header-row.vue +20 -0
- package/src/components/editor-main/src/components/menus/toolbar/tools/barcode.vue +441 -0
- package/src/components/editor-main/src/components/menus/toolbar/tools/chinese-case.vue +135 -0
- package/src/components/editor-main/src/components/menus/toolbar/tools/diagrams.vue +141 -0
- package/src/components/editor-main/src/components/menus/toolbar/tools/echarts.vue +718 -0
- package/src/components/editor-main/src/components/menus/toolbar/tools/math.vue +339 -0
- package/src/components/editor-main/src/components/menus/toolbar/tools/mermaid.vue +293 -0
- package/src/components/editor-main/src/components/menus/toolbar/tools/mind-map.vue +7 -0
- package/src/components/editor-main/src/components/menus/toolbar/tools/qrcode.vue +293 -0
- package/src/components/editor-main/src/components/menus/toolbar/tools/signature.vue +208 -0
- package/src/components/editor-main/src/components/menus/toolbar/view/fullscreen.vue +17 -0
- package/src/components/editor-main/src/components/menus/toolbar/view/locale.vue +40 -0
- package/src/components/editor-main/src/components/menus/toolbar/view/page.vue +16 -0
- package/src/components/editor-main/src/components/menus/toolbar/view/preview.vue +16 -0
- package/src/components/editor-main/src/components/menus/toolbar/view/skin.vue +43 -0
- package/src/components/editor-main/src/components/menus/toolbar/view/theme.vue +41 -0
- package/src/components/editor-main/src/components/menus/toolbar/view/toc.vue +15 -0
- package/src/components/editor-main/src/components/menus/toolbar/view/web.vue +16 -0
- package/src/components/editor-main/src/components/menus/toolbar/view/zoom-auto.vue +27 -0
- package/src/components/editor-main/src/components/menus/toolbar/view/zoom-original.vue +18 -0
- package/src/components/editor-main/src/components/menus/toolbar/view/zoom.vue +35 -0
- package/src/components/editor-main/src/components/modal.vue +22 -0
- package/src/components/editor-main/src/components/page-options.vue +392 -0
- package/src/components/editor-main/src/components/picker/color.vue +208 -0
- package/src/components/editor-main/src/components/statusbar/about.vue +37 -0
- package/src/components/editor-main/src/components/statusbar/countdown.vue +273 -0
- package/src/components/editor-main/src/components/statusbar/index.vue +753 -0
- package/src/components/editor-main/src/components/statusbar/shortcuts.vue +313 -0
- package/src/components/editor-main/src/components/toolbar/classic.vue +325 -0
- package/src/components/editor-main/src/components/toolbar/index.vue +369 -0
- package/src/components/editor-main/src/components/toolbar/ribbon.vue +398 -0
- package/src/components/editor-main/src/components/toolbar/scrollable.vue +205 -0
- package/src/components/editor-main/src/components/tooltip.vue +23 -0
- package/src/components/editor-main/src/composables/copy.js +24 -0
- package/src/components/editor-main/src/composables/dialog.js +25 -0
- package/src/components/editor-main/src/composables/hotkeys.js +14 -0
- package/src/components/editor-main/src/composables/i18n.js +19 -0
- package/src/components/editor-main/src/composables/popup.js +11 -0
- package/src/components/editor-main/src/composables/select.js +13 -0
- package/src/components/editor-main/src/composables/state.js +30 -0
- package/src/components/editor-main/src/composables/toolbarSelection.js +68 -0
- package/src/components/editor-main/src/extensions/audio/index.js +59 -0
- package/src/components/editor-main/src/extensions/audio/node-view.vue +141 -0
- package/src/components/editor-main/src/extensions/bookmark.js +110 -0
- package/src/components/editor-main/src/extensions/break-marks.js +19 -0
- package/src/components/editor-main/src/extensions/bullet-list.js +21 -0
- package/src/components/editor-main/src/extensions/callout/index.js +128 -0
- package/src/components/editor-main/src/extensions/callout/node-view.vue +130 -0
- package/src/components/editor-main/src/extensions/code-block/index.js +32 -0
- package/src/components/editor-main/src/extensions/code-block/node-view.vue +399 -0
- package/src/components/editor-main/src/extensions/columns/dom.js +142 -0
- package/src/components/editor-main/src/extensions/columns/index.js +77 -0
- package/src/components/editor-main/src/extensions/columns/keymap.js +62 -0
- package/src/components/editor-main/src/extensions/columns/resize.js +60 -0
- package/src/components/editor-main/src/extensions/columns/schema.js +47 -0
- package/src/components/editor-main/src/extensions/columns/state.js +26 -0
- package/src/components/editor-main/src/extensions/columns/utils.js +55 -0
- package/src/components/editor-main/src/extensions/datetime/index.js +55 -0
- package/src/components/editor-main/src/extensions/datetime/node-view.vue +116 -0
- package/src/components/editor-main/src/extensions/echarts/cal-service.js +142 -0
- package/src/components/editor-main/src/extensions/echarts/index.js +115 -0
- package/src/components/editor-main/src/extensions/echarts/node-view.vue +220 -0
- package/src/components/editor-main/src/extensions/file/index.js +254 -0
- package/src/components/editor-main/src/extensions/file/node-view.vue +333 -0
- package/src/components/editor-main/src/extensions/file-handler.js +93 -0
- package/src/components/editor-main/src/extensions/foonotes/footnote.js +152 -0
- package/src/components/editor-main/src/extensions/foonotes/footnotes.js +41 -0
- package/src/components/editor-main/src/extensions/foonotes/index.js +7 -0
- package/src/components/editor-main/src/extensions/foonotes/reference.js +211 -0
- package/src/components/editor-main/src/extensions/foonotes/rules.js +103 -0
- package/src/components/editor-main/src/extensions/foonotes/utils.js +171 -0
- package/src/components/editor-main/src/extensions/format-painter.js +104 -0
- package/src/components/editor-main/src/extensions/horizontal-rule.js +93 -0
- package/src/components/editor-main/src/extensions/iframe/index.js +54 -0
- package/src/components/editor-main/src/extensions/iframe/node-view.vue +106 -0
- package/src/components/editor-main/src/extensions/image/image-resizer.vue +349 -0
- package/src/components/editor-main/src/extensions/image/index.js +216 -0
- package/src/components/editor-main/src/extensions/image/node-view.vue +592 -0
- package/src/components/editor-main/src/extensions/indent.js +226 -0
- package/src/components/editor-main/src/extensions/index.js +341 -0
- package/src/components/editor-main/src/extensions/letter-spacing.js +66 -0
- package/src/components/editor-main/src/extensions/line-height.js +147 -0
- package/src/components/editor-main/src/extensions/margin.js +266 -0
- package/src/components/editor-main/src/extensions/mention/index.js +33 -0
- package/src/components/editor-main/src/extensions/mention/mentions.vue +180 -0
- package/src/components/editor-main/src/extensions/mention/suggestion.js +90 -0
- package/src/components/editor-main/src/extensions/node-align.js +164 -0
- package/src/components/editor-main/src/extensions/node-select.js +51 -0
- package/src/components/editor-main/src/extensions/office-paste/index.js +70 -0
- package/src/components/editor-main/src/extensions/office-paste/transform/bookmark.js +17 -0
- package/src/components/editor-main/src/extensions/office-paste/transform/excel.js +85 -0
- package/src/components/editor-main/src/extensions/office-paste/transform/html-classes.js +9 -0
- package/src/components/editor-main/src/extensions/office-paste/transform/line-number.js +10 -0
- package/src/components/editor-main/src/extensions/office-paste/transform/list.js +148 -0
- package/src/components/editor-main/src/extensions/office-paste/transform/style.js +24 -0
- package/src/components/editor-main/src/extensions/office-paste/utils.js +120 -0
- package/src/components/editor-main/src/extensions/option-box/index.js +77 -0
- package/src/components/editor-main/src/extensions/option-box/node-view.vue +194 -0
- package/src/components/editor-main/src/extensions/ordered-list.js +36 -0
- package/src/components/editor-main/src/extensions/page-break.js +42 -0
- package/src/components/editor-main/src/extensions/search-replace.js +304 -0
- package/src/components/editor-main/src/extensions/selection.js +38 -0
- package/src/components/editor-main/src/extensions/table.js +65 -0
- package/src/components/editor-main/src/extensions/tag/index.js +47 -0
- package/src/components/editor-main/src/extensions/tag/node-view.vue +51 -0
- package/src/components/editor-main/src/extensions/text-align.js +44 -0
- package/src/components/editor-main/src/extensions/text-box/index.js +78 -0
- package/src/components/editor-main/src/extensions/text-box/node-view.vue +141 -0
- package/src/components/editor-main/src/extensions/toc/index.js +48 -0
- package/src/components/editor-main/src/extensions/toc/node-view.vue +159 -0
- package/src/components/editor-main/src/extensions/type-writer.js +256 -0
- package/src/components/editor-main/src/extensions/video/index.js +65 -0
- package/src/components/editor-main/src/extensions/video/node-view.vue +211 -0
- package/src/components/editor-main/src/extensions/word-wrap.js +94 -0
- package/src/components/editor-main/src/i18n.js +15 -0
- package/src/components/editor-main/src/locales/bo.json +707 -0
- package/src/components/editor-main/src/locales/en-US.json +802 -0
- package/src/components/editor-main/src/locales/it-IT.json +721 -0
- package/src/components/editor-main/src/locales/ru-RU.json +779 -0
- package/src/components/editor-main/src/locales/zh-CN.json +804 -0
- package/src/components/editor-main/src/options/config/dicts.js +369 -0
- package/src/components/editor-main/src/options/config/index.js +203 -0
- package/src/components/editor-main/src/options/index.js +7 -0
- package/src/components/editor-main/src/options/schema.js +732 -0
- package/src/components/editor-main/src/utils/content-transform.js +12 -0
- package/src/components/editor-main/src/utils/copyright.js +4 -0
- package/src/components/editor-main/src/utils/diagram-editor.js +153 -0
- package/src/components/editor-main/src/utils/editor-scroll.js +75 -0
- package/src/components/editor-main/src/utils/file.js +177 -0
- package/src/components/editor-main/src/utils/history-record.js +135 -0
- package/src/components/editor-main/src/utils/load-resource.js +45 -0
- package/src/components/editor-main/src/utils/options.js +25 -0
- package/src/components/editor-main/src/utils/player.js +91 -0
- package/src/components/editor-main/src/utils/selection.js +39 -0
- package/src/components/editor-main/src/utils/short-id.js +4 -0
- package/src/components/editor-main/src/utils/shortcut.js +17 -0
- package/src/components/editor-main/src/utils/time-ago.js +8 -0
- package/src/components/editor-main/umo-build-entry.js +570 -0
- package/src/css/elementUI/col.scss +10 -2
- package/src/css/elementUI/mixins/_col.scss +10 -2
- package/vite/highlightJsLibVirtual.ts +98 -0
- package/vite/nodeModulesResolve.ts +175 -0
- package/vite/projectRoot.ts +17 -0
- package/vite/tiptapUmoResolve.ts +85 -0
- package/vite/tiptapVueRendererFix.ts +171 -0
- package/vite/umoCjsVirtual.ts +192 -0
- package/vite/umoIntegration.js +661 -0
- package/vite/umoIntegration.ts +56 -0
- package/vite/yjsPeerResolve.ts +46 -0
- package/vite.config.ts +8 -0
- package/vite.config.umo.ts +81 -0
- package/src/components/RichTextEditor/UmoRichTextEditor.vue +0 -257
- package/src/types/umoteam-editor.d.ts +0 -8
|
@@ -0,0 +1,164 @@
|
|
|
1
|
+
import { Extension } from '@tiptap/core'
|
|
2
|
+
import { NodeSelection } from '@tiptap/pm/state'
|
|
3
|
+
|
|
4
|
+
const findClosestTargetNode = (state, typeNames) => {
|
|
5
|
+
const { selection } = state
|
|
6
|
+
|
|
7
|
+
if (selection instanceof NodeSelection) {
|
|
8
|
+
const { node } = selection
|
|
9
|
+
if (node && typeNames.includes(node.type.name)) {
|
|
10
|
+
return { node, pos: selection.from }
|
|
11
|
+
}
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
const { $from } = selection
|
|
15
|
+
for (let { depth } = $from; depth > 0; depth -= 1) {
|
|
16
|
+
const node = $from.node(depth)
|
|
17
|
+
if (typeNames.includes(node.type.name)) {
|
|
18
|
+
return { node, pos: $from.before(depth) }
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
return null
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
export default Extension.create({
|
|
26
|
+
name: 'nodeAlign',
|
|
27
|
+
addOptions() {
|
|
28
|
+
return {
|
|
29
|
+
defaultAlignment: 'center',
|
|
30
|
+
alignments: ['flex-start', 'center', 'flex-end'],
|
|
31
|
+
types: ['image', 'video', 'audio', 'iframe', 'file', 'echarts'],
|
|
32
|
+
}
|
|
33
|
+
},
|
|
34
|
+
addGlobalAttributes() {
|
|
35
|
+
return [
|
|
36
|
+
{
|
|
37
|
+
types: this.options.types,
|
|
38
|
+
attributes: {
|
|
39
|
+
nodeAlign: {
|
|
40
|
+
default: this.options.defaultAlignment,
|
|
41
|
+
parseHTML: (element) => {
|
|
42
|
+
return (
|
|
43
|
+
element.style.justifyContent || this.options.defaultAlignment
|
|
44
|
+
)
|
|
45
|
+
},
|
|
46
|
+
renderHTML: (attributes) => {
|
|
47
|
+
const align = attributes.nodeAlign
|
|
48
|
+
return { style: `justify-content: ${align}` }
|
|
49
|
+
},
|
|
50
|
+
},
|
|
51
|
+
},
|
|
52
|
+
},
|
|
53
|
+
]
|
|
54
|
+
},
|
|
55
|
+
addCommands() {
|
|
56
|
+
return {
|
|
57
|
+
setNodeAlign:
|
|
58
|
+
(alignment) =>
|
|
59
|
+
({ editor, state, dispatch }) => {
|
|
60
|
+
if (!this.options.alignments.includes(alignment)) {
|
|
61
|
+
return false
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
const typeNames = this.options.types.filter(
|
|
65
|
+
(type) => editor.schema.nodes[type],
|
|
66
|
+
)
|
|
67
|
+
|
|
68
|
+
let { tr } = state
|
|
69
|
+
let updated = false
|
|
70
|
+
|
|
71
|
+
state.doc.nodesBetween(
|
|
72
|
+
state.selection.from,
|
|
73
|
+
state.selection.to,
|
|
74
|
+
(node, pos) => {
|
|
75
|
+
if (!typeNames.includes(node.type.name)) {
|
|
76
|
+
return
|
|
77
|
+
}
|
|
78
|
+
if (node.attrs.nodeAlign === alignment) {
|
|
79
|
+
updated = true
|
|
80
|
+
return
|
|
81
|
+
}
|
|
82
|
+
tr = tr.setNodeMarkup(pos, undefined, {
|
|
83
|
+
...node.attrs,
|
|
84
|
+
nodeAlign: alignment,
|
|
85
|
+
})
|
|
86
|
+
updated = true
|
|
87
|
+
},
|
|
88
|
+
)
|
|
89
|
+
|
|
90
|
+
if (!updated) {
|
|
91
|
+
const target = findClosestTargetNode(state, typeNames)
|
|
92
|
+
if (!target) {
|
|
93
|
+
return false
|
|
94
|
+
}
|
|
95
|
+
if (target.node.attrs.nodeAlign === alignment) {
|
|
96
|
+
return true
|
|
97
|
+
}
|
|
98
|
+
tr = tr.setNodeMarkup(target.pos, undefined, {
|
|
99
|
+
...target.node.attrs,
|
|
100
|
+
nodeAlign: alignment,
|
|
101
|
+
})
|
|
102
|
+
updated = true
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
if (dispatch && tr.docChanged) {
|
|
106
|
+
dispatch(tr)
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
return updated
|
|
110
|
+
},
|
|
111
|
+
unsetNodeAlign:
|
|
112
|
+
() =>
|
|
113
|
+
({ editor, state, dispatch }) => {
|
|
114
|
+
const { defaultAlignment } = this.options
|
|
115
|
+
const typeNames = this.options.types.filter(
|
|
116
|
+
(type) => editor.schema.nodes[type],
|
|
117
|
+
)
|
|
118
|
+
|
|
119
|
+
let { tr } = state
|
|
120
|
+
let updated = false
|
|
121
|
+
|
|
122
|
+
state.doc.nodesBetween(
|
|
123
|
+
state.selection.from,
|
|
124
|
+
state.selection.to,
|
|
125
|
+
(node, pos) => {
|
|
126
|
+
if (!typeNames.includes(node.type.name)) {
|
|
127
|
+
return
|
|
128
|
+
}
|
|
129
|
+
if (node.attrs.nodeAlign === defaultAlignment) {
|
|
130
|
+
updated = true
|
|
131
|
+
return
|
|
132
|
+
}
|
|
133
|
+
tr = tr.setNodeMarkup(pos, undefined, {
|
|
134
|
+
...node.attrs,
|
|
135
|
+
nodeAlign: defaultAlignment,
|
|
136
|
+
})
|
|
137
|
+
updated = true
|
|
138
|
+
},
|
|
139
|
+
)
|
|
140
|
+
|
|
141
|
+
if (!updated) {
|
|
142
|
+
const target = findClosestTargetNode(state, typeNames)
|
|
143
|
+
if (!target) {
|
|
144
|
+
return false
|
|
145
|
+
}
|
|
146
|
+
if (target.node.attrs.nodeAlign === defaultAlignment) {
|
|
147
|
+
return true
|
|
148
|
+
}
|
|
149
|
+
tr = tr.setNodeMarkup(target.pos, undefined, {
|
|
150
|
+
...target.node.attrs,
|
|
151
|
+
nodeAlign: defaultAlignment,
|
|
152
|
+
})
|
|
153
|
+
updated = true
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
if (dispatch && tr.docChanged) {
|
|
157
|
+
dispatch(tr)
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
return updated
|
|
161
|
+
},
|
|
162
|
+
}
|
|
163
|
+
},
|
|
164
|
+
})
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import { Extension } from '@tiptap/core'
|
|
2
|
+
import { NodeSelection, Plugin, PluginKey } from '@tiptap/pm/state'
|
|
3
|
+
|
|
4
|
+
// 点击节点时选中当前节点,主要是为了解决升级到 tiptap v3 后,点击节点无法选中当前节点的问题
|
|
5
|
+
export default Extension.create({
|
|
6
|
+
name: 'selectNode',
|
|
7
|
+
addOptions() {
|
|
8
|
+
return {
|
|
9
|
+
types: ['horizontalRule', 'pageBreak', 'blockMath', 'inlineMath'],
|
|
10
|
+
}
|
|
11
|
+
},
|
|
12
|
+
addProseMirrorPlugins() {
|
|
13
|
+
const { types } = this.options
|
|
14
|
+
|
|
15
|
+
return [
|
|
16
|
+
new Plugin({
|
|
17
|
+
key: new PluginKey('select-node'),
|
|
18
|
+
props: {
|
|
19
|
+
handleDOMEvents: {
|
|
20
|
+
click(view, event) {
|
|
21
|
+
const { state, dispatch } = view
|
|
22
|
+
|
|
23
|
+
const pos = view.posAtCoords({
|
|
24
|
+
left: event.clientX,
|
|
25
|
+
top: event.clientY,
|
|
26
|
+
})
|
|
27
|
+
|
|
28
|
+
if (!pos) return false
|
|
29
|
+
|
|
30
|
+
const resolvedPos = pos.inside >= 0 ? pos.inside : pos.pos
|
|
31
|
+
|
|
32
|
+
const node = state.doc.nodeAt(resolvedPos)
|
|
33
|
+
|
|
34
|
+
if (!node || !types.includes(node.type.name)) {
|
|
35
|
+
return false
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
const selection = NodeSelection.create(state.doc, resolvedPos)
|
|
39
|
+
|
|
40
|
+
dispatch(state.tr.setSelection(selection))
|
|
41
|
+
view.focus()
|
|
42
|
+
|
|
43
|
+
// 返回 true 表示事件已处理,阻止 PM 继续处理
|
|
44
|
+
return true
|
|
45
|
+
},
|
|
46
|
+
},
|
|
47
|
+
},
|
|
48
|
+
}),
|
|
49
|
+
]
|
|
50
|
+
},
|
|
51
|
+
})
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
import { Extension } from '@tiptap/core'
|
|
2
|
+
import { Plugin, PluginKey } from '@tiptap/pm/state'
|
|
3
|
+
import { useConfirm } from '../../composables/dialog'
|
|
4
|
+
import { t } from '../../composables/i18n'
|
|
5
|
+
|
|
6
|
+
import { transformRemoveBookmarks } from './transform/bookmark'
|
|
7
|
+
import { transformExcel } from './transform/excel'
|
|
8
|
+
import { transformMsoHtmlClasses } from './transform/html-classes'
|
|
9
|
+
import { transformRemoveLineNumberWrapper } from './transform/line-number'
|
|
10
|
+
import { transformLists } from './transform/list'
|
|
11
|
+
import { transformMsoStyles } from './transform/style'
|
|
12
|
+
import {
|
|
13
|
+
hasImageInPastePayload,
|
|
14
|
+
isOfficeHtml,
|
|
15
|
+
isOfficeLikeClipboardData,
|
|
16
|
+
replaceImageWithPlaceholder,
|
|
17
|
+
} from './utils'
|
|
18
|
+
|
|
19
|
+
// form https://www.npmjs.com/package/@intevation/tiptap-extension-office-paste
|
|
20
|
+
|
|
21
|
+
const createOfficePastePlugin = () =>
|
|
22
|
+
new Plugin({
|
|
23
|
+
key: new PluginKey('office-paste'),
|
|
24
|
+
props: {
|
|
25
|
+
transformPastedHTML(html) {
|
|
26
|
+
if (isOfficeHtml(html)) {
|
|
27
|
+
const imagePlaceholder = `<span style="color: var(--umo-error-color, #e34d59);">${t('officePaste.imagePlaceholder')}</span>`
|
|
28
|
+
html = transformLists(html)
|
|
29
|
+
html = transformRemoveBookmarks(html)
|
|
30
|
+
html = transformMsoStyles(html)
|
|
31
|
+
html = transformMsoHtmlClasses(html)
|
|
32
|
+
html = transformRemoveLineNumberWrapper(html)
|
|
33
|
+
html = replaceImageWithPlaceholder(html, imagePlaceholder)
|
|
34
|
+
}
|
|
35
|
+
return html
|
|
36
|
+
},
|
|
37
|
+
handlePaste(view, event) {
|
|
38
|
+
const clipboardData = event?.clipboardData
|
|
39
|
+
const html = clipboardData?.getData('text/html') || ''
|
|
40
|
+
const files = Array.from(clipboardData?.files || [])
|
|
41
|
+
const officeLike = isOfficeLikeClipboardData(clipboardData)
|
|
42
|
+
const hasImage = hasImageInPastePayload(files, html)
|
|
43
|
+
|
|
44
|
+
if (event && officeLike) {
|
|
45
|
+
if (hasImage) {
|
|
46
|
+
const dialog = useConfirm({
|
|
47
|
+
width: 400,
|
|
48
|
+
theme: 'warning',
|
|
49
|
+
header: t('officePaste.dialog.title'),
|
|
50
|
+
body: t('officePaste.dialog.body'),
|
|
51
|
+
onConfirm: () => {
|
|
52
|
+
dialog.destroy()
|
|
53
|
+
},
|
|
54
|
+
})
|
|
55
|
+
}
|
|
56
|
+
// 标记给 file-handler:当前粘贴交由 office-paste/默认流程处理
|
|
57
|
+
event.skipFileHandler = true
|
|
58
|
+
}
|
|
59
|
+
return transformExcel(view, event)
|
|
60
|
+
},
|
|
61
|
+
},
|
|
62
|
+
})
|
|
63
|
+
|
|
64
|
+
export default Extension.create({
|
|
65
|
+
priority: 99999,
|
|
66
|
+
name: 'officePaste',
|
|
67
|
+
addProseMirrorPlugins() {
|
|
68
|
+
return [createOfficePastePlugin()]
|
|
69
|
+
},
|
|
70
|
+
})
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { parseStyleAttribute, unwrapNode } from '../utils'
|
|
2
|
+
|
|
3
|
+
export const transformRemoveBookmarks = (html) => {
|
|
4
|
+
const parser = new DOMParser()
|
|
5
|
+
const doc = parser.parseFromString(html, `text/html`)
|
|
6
|
+
const bookmarks = doc.querySelectorAll(`[style*="mso-bookmark:"]`)
|
|
7
|
+
bookmarks.forEach((node) => {
|
|
8
|
+
const bookmark = parseStyleAttribute(node)[`mso-bookmark`]
|
|
9
|
+
const bookmarkLink = doc.querySelector(`a[name="${bookmark}"]`)
|
|
10
|
+
if (bookmarkLink) {
|
|
11
|
+
unwrapNode(bookmarkLink)
|
|
12
|
+
}
|
|
13
|
+
unwrapNode(node)
|
|
14
|
+
})
|
|
15
|
+
|
|
16
|
+
return doc.documentElement.outerHTML
|
|
17
|
+
}
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
import { DOMParser as ProseMirrorDOMParser } from '@tiptap/pm/model'
|
|
2
|
+
|
|
3
|
+
// 解析剪切板中 excel 的 CSS 规则(将 CSS 字符串转换为对象)
|
|
4
|
+
const parseCSS = (cssRules) => {
|
|
5
|
+
const results = {}
|
|
6
|
+
const rules = cssRules
|
|
7
|
+
.split(';')
|
|
8
|
+
.map((rule) => rule.trim())
|
|
9
|
+
.filter(Boolean)
|
|
10
|
+
rules.forEach((rule) => {
|
|
11
|
+
const [property, value] = rule.split(':').map((part) => part.trim())
|
|
12
|
+
if (property && value) {
|
|
13
|
+
results[property] = value
|
|
14
|
+
}
|
|
15
|
+
})
|
|
16
|
+
return results
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
// 提取样式规则的方法
|
|
20
|
+
const extractStyles = (styleText) => {
|
|
21
|
+
const regex = /\.(\w+)\s*\{([^}]+)\}/g
|
|
22
|
+
let match
|
|
23
|
+
const styles = {}
|
|
24
|
+
|
|
25
|
+
while ((match = regex.exec(styleText)) !== null) {
|
|
26
|
+
// const className = match[1]
|
|
27
|
+
// const cssRules = match[2]
|
|
28
|
+
const [, className, cssRules] = match
|
|
29
|
+
const parsedRules = parseCSS(cssRules)
|
|
30
|
+
styles[className] = parsedRules
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
return styles
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
export const transformExcel = (view, event) => {
|
|
37
|
+
if (!event) return false
|
|
38
|
+
const { clipboardData } = event
|
|
39
|
+
if (!clipboardData) return false
|
|
40
|
+
|
|
41
|
+
const html = clipboardData.getData('text/html')
|
|
42
|
+
if (!html) return false
|
|
43
|
+
|
|
44
|
+
const parser = new DOMParser()
|
|
45
|
+
const doc = parser.parseFromString(html, 'text/html')
|
|
46
|
+
const excel = doc
|
|
47
|
+
?.querySelector('html')
|
|
48
|
+
?.getAttribute('xmlns:x')
|
|
49
|
+
?.includes('office:excel')
|
|
50
|
+
if (!excel) {
|
|
51
|
+
return false
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
const table = doc.querySelector('table')
|
|
55
|
+
if (!table) return false
|
|
56
|
+
|
|
57
|
+
const styleText = Array.from(doc.head.querySelectorAll('style'))
|
|
58
|
+
.map((style) => style.textContent)
|
|
59
|
+
.join('\n')
|
|
60
|
+
|
|
61
|
+
// 提取所有样式规则
|
|
62
|
+
const styles = extractStyles(styleText)
|
|
63
|
+
|
|
64
|
+
// 添加单元格的样式
|
|
65
|
+
table.querySelectorAll('td, th').forEach((cell) => {
|
|
66
|
+
const style = styles[cell.getAttribute('class')]
|
|
67
|
+
if (style?.background) {
|
|
68
|
+
cell.style.background = style.background
|
|
69
|
+
}
|
|
70
|
+
if (style?.color) {
|
|
71
|
+
cell.style.color = style.color
|
|
72
|
+
}
|
|
73
|
+
if (style?.['text-align']) {
|
|
74
|
+
cell.setAttribute('align', style['text-align'])
|
|
75
|
+
}
|
|
76
|
+
})
|
|
77
|
+
|
|
78
|
+
// 使用 ProseMirror 的 DOMParser 将表格转换为 ProseMirror 节点
|
|
79
|
+
const { schema } = view.state
|
|
80
|
+
const fragment = ProseMirrorDOMParser.fromSchema(schema).parse(table)
|
|
81
|
+
const transaction = view.state.tr.replaceSelectionWith(fragment)
|
|
82
|
+
view.dispatch(transaction)
|
|
83
|
+
|
|
84
|
+
return true
|
|
85
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
export const transformMsoHtmlClasses = (html) => {
|
|
2
|
+
const parser = new DOMParser()
|
|
3
|
+
const doc = parser.parseFromString(html, `text/html`)
|
|
4
|
+
doc.querySelectorAll(`p[class*="MsoNormal"]`).forEach((node) => {
|
|
5
|
+
node.classList.remove(`MsoNormal`)
|
|
6
|
+
})
|
|
7
|
+
|
|
8
|
+
return doc.documentElement.outerHTML
|
|
9
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { unwrapNode } from '../utils'
|
|
2
|
+
|
|
3
|
+
export const transformRemoveLineNumberWrapper = (html) => {
|
|
4
|
+
const parser = new DOMParser()
|
|
5
|
+
const doc = parser.parseFromString(html, `text/html`)
|
|
6
|
+
const lineNumbers = doc.querySelectorAll(`[class*="MsoLineNumber"]`)
|
|
7
|
+
lineNumbers.forEach((node) => unwrapNode(node))
|
|
8
|
+
|
|
9
|
+
return doc.documentElement.outerHTML
|
|
10
|
+
}
|
|
@@ -0,0 +1,148 @@
|
|
|
1
|
+
import {
|
|
2
|
+
parseLetterNumber,
|
|
3
|
+
parseRomanNumber,
|
|
4
|
+
parseStyleAttribute,
|
|
5
|
+
} from '../utils'
|
|
6
|
+
|
|
7
|
+
export const transformLists = (html) => {
|
|
8
|
+
if (html.indexOf(`mso-list:`) === -1) {
|
|
9
|
+
return html
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
const parser = new DOMParser()
|
|
13
|
+
const doc = parser.parseFromString(html, `text/html`)
|
|
14
|
+
|
|
15
|
+
let listStack = []
|
|
16
|
+
let currentListId
|
|
17
|
+
const listElements = doc.querySelectorAll(`p[style*="mso-list:"]`)
|
|
18
|
+
listElements.forEach((node) => {
|
|
19
|
+
const el = node
|
|
20
|
+
const [msoListId, msoListLevel] = parseMsoListAttribute(
|
|
21
|
+
parseStyleAttribute(el)[`mso-list`],
|
|
22
|
+
)
|
|
23
|
+
|
|
24
|
+
// Check for start of a new list
|
|
25
|
+
if (
|
|
26
|
+
currentListId !== msoListId &&
|
|
27
|
+
(hasNonListItemSibling(el) || msoListLevel === 1)
|
|
28
|
+
) {
|
|
29
|
+
currentListId = msoListId
|
|
30
|
+
listStack = []
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
while (msoListLevel > listStack.length) {
|
|
34
|
+
const newList = createListElement(el)
|
|
35
|
+
|
|
36
|
+
if (listStack.length > 0) {
|
|
37
|
+
listStack[listStack.length - 1].appendChild(newList)
|
|
38
|
+
} else {
|
|
39
|
+
el.before(newList)
|
|
40
|
+
}
|
|
41
|
+
listStack.push(newList)
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
while (msoListLevel < listStack.length) {
|
|
45
|
+
listStack.pop()
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
// Remove list item numbers and create li
|
|
49
|
+
listStack[listStack.length - 1].appendChild(getListItemFromParagraph(el))
|
|
50
|
+
el.remove()
|
|
51
|
+
})
|
|
52
|
+
|
|
53
|
+
return doc.documentElement.outerHTML
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
const hasNonListItemSibling = (el) => {
|
|
57
|
+
return (
|
|
58
|
+
!el.previousElementSibling ||
|
|
59
|
+
!(
|
|
60
|
+
el.previousElementSibling.nodeName === `OL` ||
|
|
61
|
+
el.previousElementSibling.nodeName === `UL`
|
|
62
|
+
)
|
|
63
|
+
)
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
const getListItemFromParagraph = (el) => {
|
|
67
|
+
const li = document.createElement(`li`)
|
|
68
|
+
li.innerHTML = el.innerHTML.replace(listTypeRegex, ``)
|
|
69
|
+
|
|
70
|
+
return li
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
// Parses `mso-list` style attribute
|
|
74
|
+
const parseMsoListAttribute = (attr) => {
|
|
75
|
+
const msoListValue = attr
|
|
76
|
+
const msoListInfos = msoListValue.split(` `)
|
|
77
|
+
const msoListId = msoListInfos.find((e) => /l[0-9]+/.test(e)) || ``
|
|
78
|
+
const msoListLevel = +(
|
|
79
|
+
msoListInfos.find((e) => e.startsWith(`level`))?.substring(5) || 1
|
|
80
|
+
)
|
|
81
|
+
|
|
82
|
+
return [msoListId, msoListLevel]
|
|
83
|
+
}
|
|
84
|
+
// eslint-disable-next-line
|
|
85
|
+
const listTypeRegex = /<!--\[if \!supportLists\]-->((.|\n)*)<!--\[endif\]-->/m
|
|
86
|
+
const getListPrefix = (el) => {
|
|
87
|
+
const matches = el.innerHTML.match(listTypeRegex)
|
|
88
|
+
if (matches?.length) {
|
|
89
|
+
const parser = new DOMParser()
|
|
90
|
+
const doc = parser.parseFromString(matches[0], `text/html`)
|
|
91
|
+
return doc.body.querySelector(`span`)?.textContent || ``
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
return ``
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
const createListElement = (el) => {
|
|
98
|
+
const listInfo = getListInfo(getListPrefix(el))
|
|
99
|
+
const list = document.createElement(listInfo.type)
|
|
100
|
+
if (listInfo.countType) {
|
|
101
|
+
list.setAttribute(`type`, listInfo.countType)
|
|
102
|
+
}
|
|
103
|
+
if (listInfo.start > 1) {
|
|
104
|
+
list.setAttribute(`start`, listInfo.start.toString())
|
|
105
|
+
}
|
|
106
|
+
return list
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
const listOrderRegex = {
|
|
110
|
+
number: /[0-9]+\./,
|
|
111
|
+
romanLower: /(?=[mdclxvi])m*(c[md]|d?c*)(x[cl]|l?x*)(i[xv]|v?i*)\./,
|
|
112
|
+
romanUpper: /(?=[MDCLXVI])M*(C[MD]|D?C*)(X[CL]|L?X*)(I[XV]|V?I*)\./,
|
|
113
|
+
letterLower: /[a-z]+\./,
|
|
114
|
+
letterUpper: /[A-Z]+\./,
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
const getListInfo = (prefix) => {
|
|
118
|
+
let type = `ul`
|
|
119
|
+
let countType = null
|
|
120
|
+
let start = 1
|
|
121
|
+
let matches
|
|
122
|
+
if ((matches = prefix.match(listOrderRegex.number))) {
|
|
123
|
+
type = `ol`
|
|
124
|
+
start = +matches[0].replace(`.`, ``)
|
|
125
|
+
} else if ((matches = prefix.match(listOrderRegex.romanLower))) {
|
|
126
|
+
type = `ol`
|
|
127
|
+
countType = `i`
|
|
128
|
+
start = +parseRomanNumber(matches[0].replace(`.`, ``))
|
|
129
|
+
} else if ((matches = prefix.match(listOrderRegex.romanUpper))) {
|
|
130
|
+
type = `ol`
|
|
131
|
+
countType = `I`
|
|
132
|
+
start = +parseRomanNumber(matches[0].replace(`.`, ``))
|
|
133
|
+
} else if ((matches = prefix.match(listOrderRegex.letterLower))) {
|
|
134
|
+
type = `ol`
|
|
135
|
+
countType = `a`
|
|
136
|
+
start = +parseLetterNumber(matches[0].replace(`.`, ``))
|
|
137
|
+
} else if ((matches = prefix.match(listOrderRegex.letterUpper))) {
|
|
138
|
+
type = `ol`
|
|
139
|
+
countType = `A`
|
|
140
|
+
start = +parseLetterNumber(matches[0].replace(`.`, ``))
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
return {
|
|
144
|
+
type,
|
|
145
|
+
start,
|
|
146
|
+
countType,
|
|
147
|
+
}
|
|
148
|
+
}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { parseStyleAttribute } from '../utils'
|
|
2
|
+
|
|
3
|
+
export const transformMsoStyles = (html) => {
|
|
4
|
+
html = html.replace(/<o:p>(.*?)<\/o:p>/g, ``)
|
|
5
|
+
|
|
6
|
+
const parser = new DOMParser()
|
|
7
|
+
const doc = parser.parseFromString(html, `text/html`)
|
|
8
|
+
doc.querySelectorAll(`[style*="mso-"]`).forEach((node) => {
|
|
9
|
+
const styles = parseStyleAttribute(node)
|
|
10
|
+
const newStyles = []
|
|
11
|
+
for (const prop of Object.keys(styles)) {
|
|
12
|
+
if (prop && !prop.startsWith(`mso-`)) {
|
|
13
|
+
newStyles.push(`${prop}: ${styles[prop]}`)
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
node.setAttribute(`style`, newStyles.join(`;`))
|
|
17
|
+
})
|
|
18
|
+
|
|
19
|
+
doc.querySelectorAll(`[style*="color: black"]`).forEach((node) => {
|
|
20
|
+
node.style.removeProperty(`color`)
|
|
21
|
+
})
|
|
22
|
+
|
|
23
|
+
return doc.documentElement.outerHTML
|
|
24
|
+
}
|
|
@@ -0,0 +1,120 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Parses a roman number string into a number
|
|
3
|
+
*
|
|
4
|
+
* Example: a -> 1, ab -> 28, ...
|
|
5
|
+
*/
|
|
6
|
+
export function parseRomanNumber(roman) {
|
|
7
|
+
roman = roman.toUpperCase()
|
|
8
|
+
let value = 0
|
|
9
|
+
const values = { I: 1, V: 5, X: 10, L: 50, C: 100, D: 500, M: 1000 }
|
|
10
|
+
let i = roman.length
|
|
11
|
+
let lastVal = 0
|
|
12
|
+
while (i--) {
|
|
13
|
+
if (values[roman.charAt(i)] >= lastVal) {
|
|
14
|
+
value += values[roman.charAt(i)]
|
|
15
|
+
} else {
|
|
16
|
+
value -= values[roman.charAt(i)]
|
|
17
|
+
}
|
|
18
|
+
lastVal = values[roman.charAt(i)]
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
return value
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
/**
|
|
25
|
+
* Parses a list item index of letters.
|
|
26
|
+
*
|
|
27
|
+
* Example: a -> 1, ab -> 28, ...
|
|
28
|
+
*/
|
|
29
|
+
export function parseLetterNumber(str) {
|
|
30
|
+
const alphaVal = (s) => s.toLowerCase().charCodeAt(0) - 97 + 1
|
|
31
|
+
let value = 0
|
|
32
|
+
let i = str.length
|
|
33
|
+
while (i--) {
|
|
34
|
+
const factor = Math.pow(26, str.length - i - 1)
|
|
35
|
+
value += alphaVal(str.charAt(i)) * factor
|
|
36
|
+
}
|
|
37
|
+
return value
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
/**
|
|
41
|
+
* Removes the sourounding tag of a node
|
|
42
|
+
*
|
|
43
|
+
* @param {Node} node
|
|
44
|
+
* @returns {Node}
|
|
45
|
+
*/
|
|
46
|
+
export function unwrapNode(node) {
|
|
47
|
+
const parent = node.parentNode
|
|
48
|
+
while (node.firstChild) {
|
|
49
|
+
parent?.insertBefore(node.firstChild, node)
|
|
50
|
+
}
|
|
51
|
+
parent?.removeChild(node)
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
/**
|
|
55
|
+
* Parses arbitrary style properties of an element into an object
|
|
56
|
+
*
|
|
57
|
+
* @param {Element} el
|
|
58
|
+
* @returns {Object}
|
|
59
|
+
*/
|
|
60
|
+
export function parseStyleAttribute(el) {
|
|
61
|
+
const styleRaw = el?.attributes[`style`]?.value || ``
|
|
62
|
+
return Object.fromEntries(
|
|
63
|
+
styleRaw.split(`;`).map((line) => line.split(`:`).map((v) => v.trim())),
|
|
64
|
+
)
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
export function isOfficeHtml(html) {
|
|
68
|
+
if (!html) {
|
|
69
|
+
return false
|
|
70
|
+
}
|
|
71
|
+
const normalized = html.toLowerCase()
|
|
72
|
+
const hasMsOfficeSignature =
|
|
73
|
+
(normalized.includes('microsoft-com') && normalized.includes('office')) ||
|
|
74
|
+
normalized.includes('urn:schemas-microsoft-com:office') ||
|
|
75
|
+
normalized.includes('class=mso') ||
|
|
76
|
+
normalized.includes('class="mso') ||
|
|
77
|
+
normalized.includes('mso-') ||
|
|
78
|
+
normalized.includes('w:worddocument')
|
|
79
|
+
|
|
80
|
+
const hasWpsSignature =
|
|
81
|
+
normalized.includes('wps office') ||
|
|
82
|
+
normalized.includes('kingsoft') ||
|
|
83
|
+
normalized.includes('xmlns:wps') ||
|
|
84
|
+
normalized.includes('name="generator" content="wps')
|
|
85
|
+
|
|
86
|
+
return hasMsOfficeSignature || hasWpsSignature
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
export function hasImageInPastePayload(files, html) {
|
|
90
|
+
const hasImageFile = files.some((item) => item.type?.startsWith('image/'))
|
|
91
|
+
const hasImageTag = /<(img\b|v:imagedata\b)/i.test(html || '')
|
|
92
|
+
return hasImageFile || hasImageTag
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
export function replaceImageWithPlaceholder(html, placeholder = '[图片]') {
|
|
96
|
+
if (!html) {
|
|
97
|
+
return html
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
let nextHtml = html
|
|
101
|
+
nextHtml = nextHtml.replace(
|
|
102
|
+
/<v:shape\b[^>]*>[\s\S]*?<v:imagedata[\s\S]*?<\/v:shape>/gi,
|
|
103
|
+
placeholder,
|
|
104
|
+
)
|
|
105
|
+
nextHtml = nextHtml.replace(/<v:imagedata\b[^>]*\/?>/gi, placeholder)
|
|
106
|
+
nextHtml = nextHtml.replace(/<img\b[^>]*>/gi, placeholder)
|
|
107
|
+
return nextHtml
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
export function isOfficeLikeClipboardData(clipboardData) {
|
|
111
|
+
if (!clipboardData) {
|
|
112
|
+
return false
|
|
113
|
+
}
|
|
114
|
+
const html = clipboardData.getData('text/html') || ''
|
|
115
|
+
if (isOfficeHtml(html)) {
|
|
116
|
+
return true
|
|
117
|
+
}
|
|
118
|
+
const types = Array.from(clipboardData.types || [])
|
|
119
|
+
return types.includes('text/rtf') || types.includes('application/rtf')
|
|
120
|
+
}
|