@qxs-bns/components 0.0.91 → 0.0.93
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/es/base/define.mjs +1 -1
- package/es/base/define.mjs.map +1 -1
- package/es/base/uid.mjs +1 -1
- package/es/base/uid.mjs.map +1 -1
- package/es/data-chart.mjs +15 -14
- package/es/data-chart.mjs.map +1 -1
- package/es/editor/blocksuite-editor.mjs +62 -51
- package/es/editor/blocksuite-editor.mjs.map +1 -1
- package/es/editor/content-format.mjs +8 -1
- package/es/editor/content-format.mjs.map +1 -1
- package/es/editor/index.mjs +1 -1
- package/es/editor/index.mjs.map +1 -1
- package/es/editor/toolbar.mjs +1 -1
- package/es/editor/toolbar.mjs.map +1 -1
- package/es/entry-data-chart.mjs +1 -1
- package/es/entry-editor.mjs +1 -1
- package/es/entry-file-upload.mjs +1 -1
- package/es/entry-fixed-action-bar.mjs +1 -1
- package/es/entry-icon.mjs +1 -1
- package/es/entry-image-upload.mjs +1 -1
- package/es/entry-photo-crop-tool.mjs +1 -1
- package/es/entry-subject.mjs +1 -1
- package/es/file-upload.mjs +25 -18
- package/es/file-upload.mjs.map +1 -1
- package/es/fixed-action-bar.mjs +5 -5
- package/es/fixed-action-bar.mjs.map +1 -1
- package/es/icon.mjs +7 -7
- package/es/icon.mjs.map +1 -1
- package/es/image-upload.mjs +26 -26
- package/es/image-upload.mjs.map +1 -1
- package/es/index.mjs +1 -1
- package/es/node_modules/.pnpm/marked@17.0.6/node_modules/marked/lib/marked.esm.mjs +59 -1
- package/es/node_modules/.pnpm/marked@17.0.6/node_modules/marked/lib/marked.esm.mjs.map +1 -1
- package/es/node_modules/.pnpm/turndown-plugin-gfm@1.0.2/node_modules/turndown-plugin-gfm/lib/turndown-plugin-gfm.es.mjs +16 -1
- package/es/node_modules/.pnpm/turndown-plugin-gfm@1.0.2/node_modules/turndown-plugin-gfm/lib/turndown-plugin-gfm.es.mjs.map +1 -1
- package/es/node_modules/.pnpm/turndown@7.2.4/node_modules/turndown/lib/turndown.browser.es.mjs +62 -0
- package/es/node_modules/.pnpm/turndown@7.2.4/node_modules/turndown/lib/turndown.browser.es.mjs.map +1 -0
- package/es/photo-crop-tool.mjs +12 -12
- package/es/photo-crop-tool.mjs.map +1 -1
- package/es/subject/action.mjs +58 -58
- package/es/subject/action.mjs.map +1 -1
- package/es/subject/blank-fill.mjs +80 -80
- package/es/subject/blank-fill.mjs.map +1 -1
- package/es/subject/draft.mjs +1 -1
- package/es/subject/draft.mjs.map +1 -1
- package/es/subject/layout.mjs +4 -4
- package/es/subject/layout.mjs.map +1 -1
- package/es/subject/page-end.mjs +5 -5
- package/es/subject/page-end.mjs.map +1 -1
- package/es/subject/pagination.mjs +1 -1
- package/es/subject/pagination.mjs.map +1 -1
- package/es/subject/runtime.mjs +1 -1
- package/es/subject/runtime.mjs.map +1 -1
- package/es/subject/scale.mjs +53 -50
- package/es/subject/scale.mjs.map +1 -1
- package/es/subject/shared-methods.mjs +1 -1
- package/es/subject/shared-methods.mjs.map +1 -1
- package/es/subject/shared-styles.mjs +53 -15
- package/es/subject/shared-styles.mjs.map +1 -1
- package/es/subject/single-interactions.mjs +2 -0
- package/es/subject/single-interactions.mjs.map +1 -0
- package/es/subject/single-model.mjs +2 -0
- package/es/subject/single-model.mjs.map +1 -0
- package/es/subject/single-state.mjs +2 -0
- package/es/subject/single-state.mjs.map +1 -0
- package/es/subject/single.mjs +177 -177
- package/es/subject/single.mjs.map +1 -1
- package/es/subject/sort-controller.mjs +1 -1
- package/es/subject/sort-controller.mjs.map +1 -1
- package/es/subject/sortable.mjs +13 -13
- package/es/subject/sortable.mjs.map +1 -1
- package/es/subject/sorting-card.mjs +12 -12
- package/es/subject/sorting-card.mjs.map +1 -1
- package/es/subject/subject-shared.mjs +2 -0
- package/es/subject/subject-shared.mjs.map +1 -0
- package/es/subject/text-fill.mjs +73 -73
- package/es/subject/text-fill.mjs.map +1 -1
- package/es/subject/title-prefix.mjs +1 -1
- package/es/subject/title-prefix.mjs.map +1 -1
- package/es/subject/types.mjs +1 -1
- package/es/subject/types.mjs.map +1 -1
- package/lib/base/define.cjs +1 -1
- package/lib/base/define.cjs.map +1 -1
- package/lib/base/uid.cjs +1 -1
- package/lib/base/uid.cjs.map +1 -1
- package/lib/data-chart.cjs +16 -15
- package/lib/data-chart.cjs.map +1 -1
- package/lib/editor/blocksuite-editor.cjs +62 -51
- package/lib/editor/blocksuite-editor.cjs.map +1 -1
- package/lib/editor/content-format.cjs +8 -1
- package/lib/editor/content-format.cjs.map +1 -1
- package/lib/editor/index.cjs +1 -1
- package/lib/editor/index.cjs.map +1 -1
- package/lib/editor/toolbar.cjs +1 -1
- package/lib/editor/toolbar.cjs.map +1 -1
- package/lib/entry-data-chart.cjs +1 -1
- package/lib/entry-editor.cjs +1 -1
- package/lib/entry-file-upload.cjs +1 -1
- package/lib/entry-fixed-action-bar.cjs +1 -1
- package/lib/entry-icon.cjs +1 -1
- package/lib/entry-image-upload.cjs +1 -1
- package/lib/entry-photo-crop-tool.cjs +1 -1
- package/lib/entry-subject.cjs +1 -1
- package/lib/file-upload.cjs +24 -17
- package/lib/file-upload.cjs.map +1 -1
- package/lib/fixed-action-bar.cjs +6 -6
- package/lib/fixed-action-bar.cjs.map +1 -1
- package/lib/icon.cjs +9 -9
- package/lib/icon.cjs.map +1 -1
- package/lib/image-upload.cjs +26 -26
- package/lib/image-upload.cjs.map +1 -1
- package/lib/index.cjs +1 -1
- package/lib/node_modules/.pnpm/marked@17.0.6/node_modules/marked/lib/marked.esm.cjs +59 -1
- package/lib/node_modules/.pnpm/marked@17.0.6/node_modules/marked/lib/marked.esm.cjs.map +1 -1
- package/lib/node_modules/.pnpm/turndown-plugin-gfm@1.0.2/node_modules/turndown-plugin-gfm/lib/turndown-plugin-gfm.es.cjs +16 -1
- package/lib/node_modules/.pnpm/turndown-plugin-gfm@1.0.2/node_modules/turndown-plugin-gfm/lib/turndown-plugin-gfm.es.cjs.map +1 -1
- package/lib/node_modules/.pnpm/turndown@7.2.4/node_modules/turndown/lib/turndown.browser.es.cjs +62 -0
- package/lib/node_modules/.pnpm/turndown@7.2.4/node_modules/turndown/lib/turndown.browser.es.cjs.map +1 -0
- package/lib/photo-crop-tool.cjs +11 -11
- package/lib/photo-crop-tool.cjs.map +1 -1
- package/lib/subject/action.cjs +42 -42
- package/lib/subject/action.cjs.map +1 -1
- package/lib/subject/blank-fill.cjs +80 -80
- package/lib/subject/blank-fill.cjs.map +1 -1
- package/lib/subject/draft.cjs +1 -1
- package/lib/subject/draft.cjs.map +1 -1
- package/lib/subject/layout.cjs +4 -4
- package/lib/subject/layout.cjs.map +1 -1
- package/lib/subject/page-end.cjs +4 -4
- package/lib/subject/page-end.cjs.map +1 -1
- package/lib/subject/pagination.cjs +1 -1
- package/lib/subject/pagination.cjs.map +1 -1
- package/lib/subject/runtime.cjs +1 -1
- package/lib/subject/runtime.cjs.map +1 -1
- package/lib/subject/scale.cjs +53 -50
- package/lib/subject/scale.cjs.map +1 -1
- package/lib/subject/shared-methods.cjs +1 -1
- package/lib/subject/shared-methods.cjs.map +1 -1
- package/lib/subject/shared-styles.cjs +54 -16
- package/lib/subject/shared-styles.cjs.map +1 -1
- package/lib/subject/single-interactions.cjs +2 -0
- package/lib/subject/single-interactions.cjs.map +1 -0
- package/lib/subject/single-model.cjs +2 -0
- package/lib/subject/single-model.cjs.map +1 -0
- package/lib/subject/single-state.cjs +2 -0
- package/lib/subject/single-state.cjs.map +1 -0
- package/lib/subject/single.cjs +177 -177
- package/lib/subject/single.cjs.map +1 -1
- package/lib/subject/sort-controller.cjs +1 -1
- package/lib/subject/sort-controller.cjs.map +1 -1
- package/lib/subject/sortable.cjs +15 -15
- package/lib/subject/sortable.cjs.map +1 -1
- package/lib/subject/sorting-card.cjs +12 -12
- package/lib/subject/sorting-card.cjs.map +1 -1
- package/lib/subject/subject-shared.cjs +2 -0
- package/lib/subject/subject-shared.cjs.map +1 -0
- package/lib/subject/text-fill.cjs +81 -81
- package/lib/subject/text-fill.cjs.map +1 -1
- package/lib/subject/title-prefix.cjs +1 -1
- package/lib/subject/title-prefix.cjs.map +1 -1
- package/lib/subject/types.cjs +1 -1
- package/lib/subject/types.cjs.map +1 -1
- package/package.json +5 -5
- package/types/editor/blocksuite-editor.d.ts +2 -0
- package/types/editor/toolbar.d.ts +1 -1
- package/types/file-upload.d.ts +2 -0
- package/types/subject/blank-fill.d.ts +1 -1
- package/types/subject/runtime.d.ts +1 -1
- package/types/subject/scale.d.ts +1 -1
- package/types/subject/single-interactions.d.ts +46 -0
- package/types/subject/single-model.d.ts +88 -0
- package/types/subject/single-state.d.ts +42 -0
- package/types/subject/single.d.ts +7 -85
- package/types/subject/sortable.d.ts +1 -1
- package/types/subject/subject-shared.d.ts +43 -0
- package/types/subject/text-fill.d.ts +1 -1
- package/README.md +0 -562
- package/es/node_modules/.pnpm/@iconify_vue@5.0.0_vue@3.5.18_typescript@5.9.2_/node_modules/@iconify/vue/dist/iconify.mjs +0 -2
- package/es/node_modules/.pnpm/@iconify_vue@5.0.0_vue@3.5.18_typescript@5.9.2_/node_modules/@iconify/vue/dist/iconify.mjs.map +0 -1
- package/es/node_modules/.pnpm/turndown@7.2.4/node_modules/turndown/lib/turndown.es.mjs +0 -2
- package/es/node_modules/.pnpm/turndown@7.2.4/node_modules/turndown/lib/turndown.es.mjs.map +0 -1
- package/es/package.json.mjs +0 -2
- package/es/package.json.mjs.map +0 -1
- package/es/src/alert/index.mjs +0 -2
- package/es/src/alert/index.mjs.map +0 -1
- package/es/src/alert/src/alert.mjs +0 -2
- package/es/src/alert/src/alert.mjs.map +0 -1
- package/es/src/components.mjs +0 -2
- package/es/src/components.mjs.map +0 -1
- package/es/src/data-chart/index.mjs +0 -2
- package/es/src/data-chart/index.mjs.map +0 -1
- package/es/src/defaults.mjs +0 -2
- package/es/src/defaults.mjs.map +0 -1
- package/es/src/dialog/src/dialog.mjs +0 -2
- package/es/src/dialog/src/dialog.mjs.map +0 -1
- package/es/src/feedback-plugin/index.mjs +0 -2
- package/es/src/feedback-plugin/index.mjs.map +0 -1
- package/es/src/file-upload/index.mjs +0 -2
- package/es/src/file-upload/index.mjs.map +0 -1
- package/es/src/icon/index.mjs +0 -2
- package/es/src/icon/index.mjs.map +0 -1
- package/es/src/icon/src/icon.mjs +0 -2
- package/es/src/icon/src/icon.mjs.map +0 -1
- package/es/src/image-upload/index.mjs +0 -2
- package/es/src/image-upload/index.mjs.map +0 -1
- package/es/src/make-installer.mjs +0 -2
- package/es/src/make-installer.mjs.map +0 -1
- package/es/src/message/src/message.mjs +0 -2
- package/es/src/message/src/message.mjs.map +0 -1
- package/es/src/photo-crop-tool/index.mjs +0 -2
- package/es/src/photo-crop-tool/index.mjs.map +0 -1
- package/es/src/tiny-mce-editor/index.mjs +0 -2
- package/es/src/tiny-mce-editor/index.mjs.map +0 -1
- package/es/src/tiny-mce-editor/src/tiny-mce-editor.vue.mjs +0 -2
- package/es/src/tiny-mce-editor/src/tiny-mce-editor.vue.mjs.map +0 -1
- package/es/src/tiny-mce-editor/src/tiny-mce-editor.vue2.mjs +0 -2
- package/es/src/tiny-mce-editor/src/tiny-mce-editor.vue2.mjs.map +0 -1
- package/es/src/ui/button/index.mjs +0 -2
- package/es/src/ui/button/index.mjs.map +0 -1
- package/es/src/ui/checkbox/index.mjs +0 -2
- package/es/src/ui/checkbox/index.mjs.map +0 -1
- package/es/src/ui/dialog/index.mjs +0 -2
- package/es/src/ui/dialog/index.mjs.map +0 -1
- package/es/src/ui/input/index.mjs +0 -2
- package/es/src/ui/input/index.mjs.map +0 -1
- package/es/src/ui/input-number/index.mjs +0 -2
- package/es/src/ui/input-number/index.mjs.map +0 -1
- package/es/src/ui/layout/index.mjs +0 -2
- package/es/src/ui/layout/index.mjs.map +0 -1
- package/es/src/ui/link/index.mjs +0 -2
- package/es/src/ui/link/index.mjs.map +0 -1
- package/es/src/ui/popover/index.mjs +0 -2
- package/es/src/ui/popover/index.mjs.map +0 -1
- package/es/src/ui/radio/index.mjs +0 -2
- package/es/src/ui/radio/index.mjs.map +0 -1
- package/es/src/ui/scrollbar/index.mjs +0 -2
- package/es/src/ui/scrollbar/index.mjs.map +0 -1
- package/es/src/ui/select/index.mjs +0 -2
- package/es/src/ui/select/index.mjs.map +0 -1
- package/es/src/ui/table/index.mjs +0 -2
- package/es/src/ui/table/index.mjs.map +0 -1
- package/es/src/ui/tag/index.mjs +0 -2
- package/es/src/ui/tag/index.mjs.map +0 -1
- package/es/src/wc-bridge.mjs +0 -2
- package/es/src/wc-bridge.mjs.map +0 -1
- package/es/src/withInstall.mjs +0 -2
- package/es/src/withInstall.mjs.map +0 -1
- package/lib/node_modules/.pnpm/@iconify_vue@5.0.0_vue@3.5.18_typescript@5.9.2_/node_modules/@iconify/vue/dist/iconify.cjs +0 -2
- package/lib/node_modules/.pnpm/@iconify_vue@5.0.0_vue@3.5.18_typescript@5.9.2_/node_modules/@iconify/vue/dist/iconify.cjs.map +0 -1
- package/lib/node_modules/.pnpm/turndown@7.2.4/node_modules/turndown/lib/turndown.es.cjs +0 -2
- package/lib/node_modules/.pnpm/turndown@7.2.4/node_modules/turndown/lib/turndown.es.cjs.map +0 -1
- package/lib/package.json.cjs +0 -2
- package/lib/package.json.cjs.map +0 -1
- package/lib/src/alert/index.cjs +0 -2
- package/lib/src/alert/index.cjs.map +0 -1
- package/lib/src/alert/src/alert.cjs +0 -2
- package/lib/src/alert/src/alert.cjs.map +0 -1
- package/lib/src/components.cjs +0 -2
- package/lib/src/components.cjs.map +0 -1
- package/lib/src/data-chart/index.cjs +0 -2
- package/lib/src/data-chart/index.cjs.map +0 -1
- package/lib/src/defaults.cjs +0 -2
- package/lib/src/defaults.cjs.map +0 -1
- package/lib/src/dialog/src/dialog.cjs +0 -2
- package/lib/src/dialog/src/dialog.cjs.map +0 -1
- package/lib/src/feedback-plugin/index.cjs +0 -2
- package/lib/src/feedback-plugin/index.cjs.map +0 -1
- package/lib/src/file-upload/index.cjs +0 -2
- package/lib/src/file-upload/index.cjs.map +0 -1
- package/lib/src/icon/index.cjs +0 -2
- package/lib/src/icon/index.cjs.map +0 -1
- package/lib/src/icon/src/icon.cjs +0 -2
- package/lib/src/icon/src/icon.cjs.map +0 -1
- package/lib/src/image-upload/index.cjs +0 -2
- package/lib/src/image-upload/index.cjs.map +0 -1
- package/lib/src/make-installer.cjs +0 -2
- package/lib/src/make-installer.cjs.map +0 -1
- package/lib/src/message/src/message.cjs +0 -2
- package/lib/src/message/src/message.cjs.map +0 -1
- package/lib/src/photo-crop-tool/index.cjs +0 -2
- package/lib/src/photo-crop-tool/index.cjs.map +0 -1
- package/lib/src/tiny-mce-editor/index.cjs +0 -2
- package/lib/src/tiny-mce-editor/index.cjs.map +0 -1
- package/lib/src/tiny-mce-editor/src/tiny-mce-editor.vue.cjs +0 -2
- package/lib/src/tiny-mce-editor/src/tiny-mce-editor.vue.cjs.map +0 -1
- package/lib/src/tiny-mce-editor/src/tiny-mce-editor.vue2.cjs +0 -2
- package/lib/src/tiny-mce-editor/src/tiny-mce-editor.vue2.cjs.map +0 -1
- package/lib/src/ui/button/index.cjs +0 -2
- package/lib/src/ui/button/index.cjs.map +0 -1
- package/lib/src/ui/checkbox/index.cjs +0 -2
- package/lib/src/ui/checkbox/index.cjs.map +0 -1
- package/lib/src/ui/dialog/index.cjs +0 -2
- package/lib/src/ui/dialog/index.cjs.map +0 -1
- package/lib/src/ui/input/index.cjs +0 -2
- package/lib/src/ui/input/index.cjs.map +0 -1
- package/lib/src/ui/input-number/index.cjs +0 -2
- package/lib/src/ui/input-number/index.cjs.map +0 -1
- package/lib/src/ui/layout/index.cjs +0 -2
- package/lib/src/ui/layout/index.cjs.map +0 -1
- package/lib/src/ui/link/index.cjs +0 -2
- package/lib/src/ui/link/index.cjs.map +0 -1
- package/lib/src/ui/popover/index.cjs +0 -2
- package/lib/src/ui/popover/index.cjs.map +0 -1
- package/lib/src/ui/radio/index.cjs +0 -2
- package/lib/src/ui/radio/index.cjs.map +0 -1
- package/lib/src/ui/scrollbar/index.cjs +0 -2
- package/lib/src/ui/scrollbar/index.cjs.map +0 -1
- package/lib/src/ui/select/index.cjs +0 -2
- package/lib/src/ui/select/index.cjs.map +0 -1
- package/lib/src/ui/table/index.cjs +0 -2
- package/lib/src/ui/table/index.cjs.map +0 -1
- package/lib/src/ui/tag/index.cjs +0 -2
- package/lib/src/ui/tag/index.cjs.map +0 -1
- package/lib/src/wc-bridge.cjs +0 -2
- package/lib/src/wc-bridge.cjs.map +0 -1
- package/lib/src/withInstall.cjs +0 -2
- package/lib/src/withInstall.cjs.map +0 -1
- package/types/index.d.ts.map +0 -1
- package/types/src/alert/index.d.ts +0 -66
- package/types/src/alert/index.d.ts.map +0 -1
- package/types/src/alert/src/alert.d.ts +0 -73
- package/types/src/alert/src/alert.d.ts.map +0 -1
- package/types/src/components.d.ts +0 -10
- package/types/src/components.d.ts.map +0 -1
- package/types/src/data-chart/index.d.ts +0 -13
- package/types/src/data-chart/index.d.ts.map +0 -1
- package/types/src/defaults.d.ts +0 -6
- package/types/src/defaults.d.ts.map +0 -1
- package/types/src/dialog/index.d.ts +0 -3
- package/types/src/dialog/index.d.ts.map +0 -1
- package/types/src/dialog/src/dialog.d.ts +0 -25
- package/types/src/dialog/src/dialog.d.ts.map +0 -1
- package/types/src/feedback-plugin/index.d.ts +0 -9
- package/types/src/feedback-plugin/index.d.ts.map +0 -1
- package/types/src/file-upload/index.d.ts +0 -12
- package/types/src/file-upload/index.d.ts.map +0 -1
- package/types/src/icon/index.d.ts +0 -56
- package/types/src/icon/index.d.ts.map +0 -1
- package/types/src/icon/src/icon.d.ts +0 -62
- package/types/src/icon/src/icon.d.ts.map +0 -1
- package/types/src/image-upload/index.d.ts +0 -12
- package/types/src/image-upload/index.d.ts.map +0 -1
- package/types/src/make-installer.d.ts +0 -6
- package/types/src/make-installer.d.ts.map +0 -1
- package/types/src/message/index.d.ts +0 -3
- package/types/src/message/index.d.ts.map +0 -1
- package/types/src/message/src/message.d.ts +0 -21
- package/types/src/message/src/message.d.ts.map +0 -1
- package/types/src/message/src/toaster.vue.d.ts +0 -3
- package/types/src/message/src/toaster.vue.d.ts.map +0 -1
- package/types/src/photo-crop-tool/index.d.ts +0 -12
- package/types/src/photo-crop-tool/index.d.ts.map +0 -1
- package/types/src/subject-action/index.d.ts +0 -93
- package/types/src/subject-action/index.d.ts.map +0 -1
- package/types/src/subject-action/src/subject-action.vue.d.ts +0 -92
- package/types/src/subject-action/src/subject-action.vue.d.ts.map +0 -1
- package/types/src/subject-layout/index.d.ts +0 -30
- package/types/src/subject-layout/index.d.ts.map +0 -1
- package/types/src/subject-layout/src/subject-layout.vue.d.ts +0 -20
- package/types/src/subject-layout/src/subject-layout.vue.d.ts.map +0 -1
- package/types/src/subject-list/index.d.ts +0 -20
- package/types/src/subject-list/index.d.ts.map +0 -1
- package/types/src/subject-list/src/components/SubjectPageEnd.vue.d.ts +0 -24
- package/types/src/subject-list/src/components/SubjectPageEnd.vue.d.ts.map +0 -1
- package/types/src/subject-list/src/components/subject-blank-fill.vue.d.ts +0 -32
- package/types/src/subject-list/src/components/subject-blank-fill.vue.d.ts.map +0 -1
- package/types/src/subject-list/src/components/subject-scale.vue.d.ts +0 -29
- package/types/src/subject-list/src/components/subject-scale.vue.d.ts.map +0 -1
- package/types/src/subject-list/src/components/subject-single.vue.d.ts +0 -37
- package/types/src/subject-list/src/components/subject-single.vue.d.ts.map +0 -1
- package/types/src/subject-list/src/components/subject-text-fill.vue.d.ts +0 -34
- package/types/src/subject-list/src/components/subject-text-fill.vue.d.ts.map +0 -1
- package/types/src/subject-list/src/subject-list.vue.d.ts +0 -21
- package/types/src/subject-list/src/subject-list.vue.d.ts.map +0 -1
- package/types/src/subject-type/index.d.ts +0 -8
- package/types/src/subject-type/index.d.ts.map +0 -1
- package/types/src/subject-type/src/subject-type.vue.d.ts +0 -7
- package/types/src/subject-type/src/subject-type.vue.d.ts.map +0 -1
- package/types/src/tiny-mce-editor/index.d.ts +0 -20
- package/types/src/tiny-mce-editor/index.d.ts.map +0 -1
- package/types/src/tiny-mce-editor/src/tiny-mce-editor.vue.d.ts +0 -32
- package/types/src/tiny-mce-editor/src/tiny-mce-editor.vue.d.ts.map +0 -1
- package/types/src/ui/button/index.d.ts +0 -96
- package/types/src/ui/button/index.d.ts.map +0 -1
- package/types/src/ui/checkbox/index.d.ts +0 -111
- package/types/src/ui/checkbox/index.d.ts.map +0 -1
- package/types/src/ui/dialog/index.d.ts +0 -134
- package/types/src/ui/dialog/index.d.ts.map +0 -1
- package/types/src/ui/index.d.ts +0 -16
- package/types/src/ui/index.d.ts.map +0 -1
- package/types/src/ui/input/index.d.ts +0 -132
- package/types/src/ui/input/index.d.ts.map +0 -1
- package/types/src/ui/input-number/index.d.ts +0 -106
- package/types/src/ui/input-number/index.d.ts.map +0 -1
- package/types/src/ui/layout/index.d.ts +0 -373
- package/types/src/ui/layout/index.d.ts.map +0 -1
- package/types/src/ui/link/index.d.ts +0 -57
- package/types/src/ui/link/index.d.ts.map +0 -1
- package/types/src/ui/popover/index.d.ts +0 -89
- package/types/src/ui/popover/index.d.ts.map +0 -1
- package/types/src/ui/radio/index.d.ts +0 -84
- package/types/src/ui/radio/index.d.ts.map +0 -1
- package/types/src/ui/scrollbar/index.d.ts +0 -35
- package/types/src/ui/scrollbar/index.d.ts.map +0 -1
- package/types/src/ui/select/index.d.ts +0 -113
- package/types/src/ui/select/index.d.ts.map +0 -1
- package/types/src/ui/table/index.d.ts +0 -152
- package/types/src/ui/table/index.d.ts.map +0 -1
- package/types/src/ui/tag/index.d.ts +0 -69
- package/types/src/ui/tag/index.d.ts.map +0 -1
- package/types/src/wc-bridge.d.ts +0 -23
- package/types/src/wc-bridge.d.ts.map +0 -1
- package/types/src/withInstall.d.ts +0 -4
- package/types/src/withInstall.d.ts.map +0 -1
- package/types/tsconfig.tsbuildinfo +0 -1
|
@@ -1,9 +1,11 @@
|
|
|
1
|
-
"use strict";
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const g=require("@tiptap/core"),A=require("@tiptap/extension-blockquote"),$=require("@tiptap/extension-bold"),R=require("@tiptap/extension-bullet-list"),P=require("@tiptap/extension-code"),q=require("@tiptap/extension-document"),V=require("@tiptap/extension-heading"),F=require("@tiptap/extension-history"),H=require("@tiptap/extension-horizontal-rule"),z=require("@tiptap/extension-image"),D=require("@tiptap/extension-italic"),O=require("@tiptap/extension-link"),j=require("@tiptap/extension-list-item"),Q=require("@tiptap/extension-ordered-list"),U=require("@tiptap/extension-paragraph"),N=require("@tiptap/extension-placeholder"),W=require("@tiptap/extension-strike"),G=require("@tiptap/extension-table"),K=require("@tiptap/extension-table-cell"),Y=require("@tiptap/extension-table-header"),X=require("@tiptap/extension-table-row"),J=require("@tiptap/extension-text"),Z=require("@tiptap/extension-text-align"),ee=require("@tiptap/extension-underline"),l=require("lit"),d=require("lit/decorators.js"),_=require("./content-format.cjs"),y=require("./toolbar.cjs"),te=require("../base/define.cjs");var ie=Object.defineProperty,oe=Object.getOwnPropertyDescriptor,a=(c,e,t,i)=>{for(var o=i>1?void 0:i?oe(e,t):e,r=c.length-1,n;r>=0;r--)(n=c[r])&&(o=(i?n(e,t,o):n(o))||o);return i&&o&&ie(e,t,o),o};const I=560,w=24,T="输入内容",M="输入 / 唤出快捷命令",S="80px",re={image:"插入图片",link:"插入链接"},ne=new Set(["bold","italic","underline","strike","code","link","image","bulletList","orderedList","taskList","blockquote","table"]),se=g.Node.create({name:"taskList",group:"block list",content:"taskItem+",defining:!0,parseHTML(){return[{tag:'ul[data-type="taskList"]'}]},renderHTML({HTMLAttributes:c}){return["ul",g.mergeAttributes(c,{"data-type":"taskList"}),0]},addCommands(){return{toggleTaskList:()=>({commands:c})=>c.toggleList(this.name,"taskItem")}}}),le=g.Node.create({name:"taskItem",defining:!0,content:"paragraph block*",addAttributes(){return{checked:{default:!1,parseHTML:c=>c.getAttribute("data-checked")==="true",renderHTML:c=>({"data-checked":String(!!c.checked)})}}},parseHTML(){return[{tag:'li[data-type="taskItem"]'}]},renderHTML({HTMLAttributes:c}){const e=!!c.checked;return["li",g.mergeAttributes(c,{"data-type":"taskItem"}),["label",{contenteditable:"false"},["input",{type:"checkbox",checked:e?"checked":null}],["span"]],["div",0]]},addKeyboardShortcuts(){return{Enter:()=>this.editor.commands.splitListItem(this.name),Tab:()=>this.editor.commands.sinkListItem(this.name),"Shift-Tab":()=>this.editor.commands.liftListItem(this.name)}}}),ae=j.extend({addKeyboardShortcuts(){return{Enter:()=>this.editor.commands.splitListItem(this.name),Tab:()=>this.editor.commands.sinkListItem(this.name),"Shift-Tab":()=>this.editor.commands.liftListItem(this.name)}}}),de=z.extend({addAttributes(){return{...this.parent?.(),width:{default:null,parseHTML:c=>{const e=c.getAttribute("width"),t=Number(e);return Number.isFinite(t)&&t>0?t:null},renderHTML:c=>c.width?{width:String(c.width)}:{}},align:{default:"left",parseHTML:c=>c.getAttribute("data-align")||"left",renderHTML:c=>c.align?{"data-align":String(c.align)}:{}}}},renderHTML({HTMLAttributes:c}){const e=Number(c.width),t=["max-width:100%","height:auto",Number.isFinite(e)&&e>0?`width:${e}px`:"",c.style||""].filter(Boolean).join(";");return["img",g.mergeAttributes(this.options.HTMLAttributes,c,{style:t})]}});exports.QxsBlocksuiteEditor=class extends l.LitElement{constructor(){super(...arguments),this.content="",this["model-value"]="",this.placeholder=T,this["toolbar-mode"]="header",this.toolbar="",this["toolbar-preset"]="full",this["header-toolbar-labels"]=re,this._lastInvalidHeaderToolbarLabelsSource=void 0,this["header-always-visible"]="true",this["use-model"]="false",this.readonly="false",this.preview="false",this.editable=null,this["min-height"]=S,this["max-height"]="",this["show-character-count"]="false",this["toolbar-position"]="top",this["custom-styles"]="",this["content-format"]="html",this["deserialize-content"]=null,this["serialize-content"]=null,this._injectedStyleEl=null,this["upload-image"]=async e=>new Promise((t,i)=>{const o=new FileReader;o.onload=r=>t(r.target?.result),o.onerror=i,o.readAsDataURL(e)}),this._editor=null,this._pendingContent=null,this._tableRows=3,this._tableCols=3,this._hoverRow=0,this._hoverCol=0,this._tableDropdownOpen=!1,this._tableCellToolbar={x:0,y:0,visible:!1,cellRow:0,cellCol:0},this._imageToolbar={x:0,y:0,visible:!1},this._linkEditor={x:0,y:0,visible:!1,url:"",label:""},this._isEditorFocused=!1,this._selectedImage=null,this._hasSlashCommand=!1,this._slashCommandRange=null,this._slashInlineMarkState=null,this._isComposingText=!1,this._isUpdating=!1,this._pendingImageInsertPos=null,this._linkSelection=null,this._preserveFocusOnInternalClick=!1,this._tableEdgeDetectionSetup=!1,this._handleCompositionStart=()=>{this._isComposingText=!0},this._handleCompositionEnd=()=>{this._isComposingText=!1,requestAnimationFrame(()=>{this._syncSlashInlineMarkState(),this._restoreSlashInlineMarkIfNeeded()})}}_injectCustomStyles(){const e=this.shadowRoot;if(!e||(this._injectedStyleEl&&(this._injectedStyleEl.remove(),this._injectedStyleEl=null),!this["custom-styles"]))return;const t=document.createElement("style");t.textContent=this["custom-styles"],e.appendChild(t),this._injectedStyleEl=t}get _useModelValue(){return this["use-model"]===!0||this["use-model"]==="true"||this["use-model"]===""||this.hasAttribute("use-model")}get _readonlyValue(){return this.readonly!==!1&&this.readonly!=="false"}get _previewValue(){return this.preview!==!1&&this.preview!=="false"}get _editableValue(){return this.editable===null||this.editable===void 0?null:this.editable!==!1&&this.editable!=="false"}get _isEditable(){return this._previewValue?!1:this._editableValue!==null?this._editableValue:!this._readonlyValue}get _toolbarModeValue(){return this["toolbar-mode"]==="header"?"header":"slash"}get _headerAlwaysVisibleValue(){return this["header-always-visible"]===!0||this["header-always-visible"]==="true"||this["header-always-visible"]===""||this.hasAttribute("header-always-visible")}get _toolbarPositionValue(){return this["toolbar-position"]==="bottom"?"bottom":"top"}get _toolbarPresetValue(){return this["toolbar-preset"]==="simple"?"simple":this["toolbar-preset"]==="none"?"none":"full"}get _contentFormatValue(){return this["content-format"]==="markdown"?"markdown":this["content-format"]==="custom"?"custom":"html"}get _showCharacterCountValue(){return this["show-character-count"]===!0||this["show-character-count"]==="true"||this["show-character-count"]===""||this.hasAttribute("show-character-count")}get _resolvedMinHeight(){return this["min-height"]?.trim()||S}get _resolvedMaxHeight(){return this["max-height"]?.trim()||"none"}get _wrapperStyleValue(){const e=this["max-height"]?.trim()?"auto":"visible";return[`--qxs-editor-min-height: ${this._resolvedMinHeight}`,`--qxs-editor-max-height: ${this._resolvedMaxHeight}`,`--qxs-editor-overflow-y: ${e}`].join("; ")}get _resolvedPlaceholder(){return this.placeholder&&this.placeholder!==T&&this.placeholder!==M?this.placeholder:this._toolbarModeValue==="header"?T:M}get _toolbarItemsValue(){return Array.isArray(this.toolbar)?y.parseEditorToolbarItems(this.toolbar):typeof this.toolbar=="string"&&this.toolbar.trim()?y.parseEditorToolbarItems(this.toolbar):this._toolbarPresetValue==="simple"?[...y.SIMPLE_EDITOR_TOOLBAR]:this._toolbarPresetValue==="none"?[]:[...y.DEFAULT_EDITOR_TOOLBAR]}_hasToolbarItem(e){return this._toolbarItemsValue.includes(e)}get _headerToolbarLabelsValue(){const e=this["header-toolbar-labels"];if(!e)return{};let t=e;if(typeof e=="string"){if(e==="[object Object]")return this._warnInvalidHeaderToolbarLabels(e,'received "[object Object]"; Vue hosts should pass object values with `.prop`, for example `:header-toolbar-labels.prop="headerToolbarLabels"`'),{};try{t=JSON.parse(e)}catch(o){return this._warnInvalidHeaderToolbarLabels(e,"parse failed, fallback to empty map",o),{}}}if(!t||typeof t!="object"||Array.isArray(t))return{};const i={};for(const[o,r]of Object.entries(t))ne.has(o)&&typeof r=="string"&&r.trim()&&(i[o]=r.trim());return i}_warnInvalidHeaderToolbarLabels(e,t,i){this._lastInvalidHeaderToolbarLabelsSource!==e&&(this._lastInvalidHeaderToolbarLabelsSource=e)}_getHeaderToolbarLabel(e){return this._toolbarModeValue!=="header"?"":this._headerToolbarLabelsValue[e]||""}_renderToolbarButton(e,t){const i=this._getHeaderToolbarLabel(e),o=["bubble-btn",t.active?"is-active":"",t.danger?"danger":"",i?"has-label":""].filter(Boolean).join(" ");return l.html`
|
|
2
2
|
<button class=${o} @click=${t.onClick} title=${t.title}>
|
|
3
3
|
${t.icon}
|
|
4
|
-
${i?
|
|
4
|
+
${i?l.html`<span class="bubble-btn__label">${i}</span>`:null}
|
|
5
5
|
</button>
|
|
6
|
-
`}_transformIncomingContent(e){const t=e||"",i=this["deserialize-content"];if(!i)return M.transformIncomingContentByFormat(t,this._contentFormatValue);try{return i(t)||M.EMPTY_EDITOR_HTML}catch(e){return M.transformIncomingContentByFormat(t,this._contentFormatValue)}}_transformOutgoingContent(e){const t=this["serialize-content"];if(!t)return M.transformOutgoingContentByFormat(e,this._contentFormatValue);try{return t(e)}catch(t){return M.transformOutgoingContentByFormat(e,this._contentFormatValue)}}_getEditorCharacterCount(){return this._editor?.getText().length??0}_initEditor(){if(this._editor)return;const d=this.shadowRoot?.querySelector(".editor-content");if(!d)return void requestAnimationFrame(()=>this._initEditor());for(;d.firstChild;)d.removeChild(d.firstChild);const T=this._useModelValue,C=this.getAttribute("model-value")??this["model-value"],M=this.content,I=T?this._transformIncomingContent(this._pendingContent??C):this._transformIncomingContent(this._pendingContent??M),S=[s,b,v,i,h,w,m,r,n.configure({levels:[1,2,3]}),o,u,P,V,p,t,a,l,F.configure({inline:!1,allowBase64:!0}),c.extend({inclusive:!1}).configure({openOnClick:!1,HTMLAttributes:{rel:"noopener noreferrer"}}),k.configure({types:["heading","paragraph"]}),_.Table.configure({resizable:!0}),y.TableRow,x.TableCell,f.TableHeader,g.configure({placeholder:this._resolvedPlaceholder})];this._editor=new e.Editor({element:d,extensions:S,editable:this._isEditable,content:I}),this._editor.view.dom.addEventListener("compositionstart",this._handleCompositionStart),this._editor.view.dom.addEventListener("compositionend",this._handleCompositionEnd),this._pendingContent=null,this._editor.on("selectionUpdate",()=>{this._syncSlashInlineMarkState(),this._restoreSlashInlineMarkIfNeeded(),"slash"===this._toolbarModeValue&&this._updateBubbleMenuPosition(),this._editor?.isActive("table")?this._showTableCellToolbar():this._hideTableCellToolbar(),this._syncImageSelectionState()}),this._editor.on("transaction",()=>{this._editor?.isActive("table")?this._showTableCellToolbar():this._hideTableCellToolbar(),this._checkSlashCommand(),this._syncSlashInlineMarkState(),this._restoreSlashInlineMarkIfNeeded(),this._setupTableEdgeDetection(),this._syncImageSelectionState()}),this._editor.on("update",()=>{this._emitContentChange()})}_toggleTaskItemChecked(e){const t=e.target,i=this._editor;if(!(t instanceof HTMLInputElement&&"checkbox"===t.type&&i))return;const o=t.closest('li[data-type="taskItem"]');if(!o)return;e.preventDefault(),e.stopPropagation();const r=i.view.posAtDOM(o,0),s=Math.max(0,r-2),n=Math.min(i.state.doc.content.size,r+2);let l=null;if(i.state.doc.nodesBetween(s,n,(e,t)=>{if("taskItem"===e.type.name)return l=t,!1}),null===l)return;const a=i.state.doc.nodeAt(l);a&&"taskItem"===a.type.name&&i.view.dispatch(i.state.tr.setNodeMarkup(l,void 0,{...a.attrs,checked:!a.attrs.checked}))}_emitContentChange(){if(!this._editor)return;const e=this.getContentSnapshot();this._showCharacterCountValue&&this.requestUpdate(),this.dispatchEvent(new CustomEvent("content-update",{detail:e,bubbles:!0,composed:!0})),this.dispatchEvent(new CustomEvent("content-change",{detail:e.value,bubbles:!0,composed:!0}))}_setupTableEdgeDetection(){const e=this.shadowRoot?.querySelector(".editor-content"),t=this.shadowRoot?.querySelector(".editor-wrapper");if(!e||this._tableEdgeDetectionSetup)return;this._tableEdgeDetectionSetup=!0;const i=e=>{this._toggleTaskItemChecked(e);const t=e.target;t instanceof Element&&t.closest(".editor-header, .bubble-menu, .table-cell-toolbar, .image-toolbar, .link-editor")||this._isEditable&&this._editor?.chain().focus().run()};e.addEventListener("click",i),t?.addEventListener("click",i)}_handleWrapperFocusIn(){this._preserveFocusOnInternalClick=!1,this._isEditorFocused=!0}_handleHeaderToolbarMouseDown(e){if(!this._isEditable)return;const t=e.target;t instanceof Element&&t.closest("button, .bubble-dropdown, .table-cell")&&(e.preventDefault(),this._preserveFocusOnInternalClick=!0,requestAnimationFrame(()=>{this._preserveFocusOnInternalClick=!1}))}_handleWrapperMouseDown(e){const t=e.target;this._isEditable&&t instanceof Element&&!t.closest(".editor-header, .bubble-menu, .table-cell-toolbar, .image-toolbar, .link-editor")&&(this._preserveFocusOnInternalClick=!0,requestAnimationFrame(()=>{this._preserveFocusOnInternalClick=!1}))}_handleWrapperFocusOut(e){const t=e.relatedTarget,i=this.shadowRoot?.querySelector(".editor-wrapper");this._preserveFocusOnInternalClick||t&&i?.contains(t)||(this._isEditorFocused=!1,this._tableDropdownOpen=!1,this._closeLinkEditor())}_isHeaderVisible(){return"header"===this._toolbarModeValue&&!this._previewValue&&(this._headerAlwaysVisibleValue||this._isEditorFocused||this._tableDropdownOpen||Boolean(this._selectedImage))}_getImageSelection(){const e=this._editor,t=e?.state.selection;return e&&t?.node&&"image"===t.node.type?.name?{pos:t.from,attrs:t.node.attrs??{}}:null}_getImageMaxWidth(){const e=this.shadowRoot?.querySelector(".editor-content"),t=(e?.clientWidth??560)-32;return Math.max(24,Math.min(560,t))}async _getImageNaturalWidth(e){return await new Promise(t=>{const i=URL.createObjectURL(e),o=new window.Image;o.onload=()=>{const e=o.naturalWidth;URL.revokeObjectURL(i),t(Number.isFinite(e)&&e>0?e:null)},o.onerror=()=>{URL.revokeObjectURL(i),t(null)},o.src=i})}_syncImageSelectionState(){const e=this._getImageSelection();if(!e)return this._selectedImage=null,void("slash"===this._toolbarModeValue&&this._hideImageToolbar());const t=Number(e.attrs.width),i=String(e.attrs.align||"left");if(this._selectedImage={pos:e.pos,width:Number.isFinite(t)&&t>0?t:this._getImageMaxWidth(),align:i},"slash"!==this._toolbarModeValue)return void this._hideImageToolbar();const o=this._editor,r=this.shadowRoot?.querySelector(".editor-wrapper")?.getBoundingClientRect();if(!o||!r)return;const s=o.view.coordsAtPos(e.pos),n=s.left-r.left+(s.right-s.left)/2,l=s.top-r.top-40;this._showImageToolbar({x:n,y:l})}_clearSlashCommandText(){if(!this._editor||!this._slashCommandRange)return;const{from:e,to:t}=this._slashCommandRange;this._editor.chain().focus().deleteRange({from:e,to:t}).run(),this._hasSlashCommand=!1,this._slashCommandRange=null}_checkSlashCommand(){if(!this._editor)return;const{selection:e}=this._editor.state;if(!e.empty)return this._hasSlashCommand=!1,void(this._slashCommandRange=null);const{$from:t}=e,i=t.parent.textBetween(0,t.parentOffset," "," "),o=/(?:^|\s)(\/\S*)$/.exec(i);if(!o)return this._hasSlashCommand=!1,void(this._slashCommandRange=null);const r=o[1];this._hasSlashCommand=!0,this._slashCommandRange={from:e.from-r.length,to:e.from}}firstUpdated(){this._injectCustomStyles(),queueMicrotask(()=>{this.isConnected&&this._initEditor()})}updated(e){if(e.has("custom-styles")&&this._injectCustomStyles(),this._editor){if(e.has("content")||e.has("model-value")&&this._useModelValue||e.has("deserialize-content")||e.has("content-format")){const e=this._transformIncomingContent(this._useModelValue?this["model-value"]:this.content);e!==this._editor.getHTML()&&this._editor.commands.setContent(e)}(e.has("readonly")||e.has("preview")||e.has("editable"))&&this._editor.setEditable(this._isEditable)}else e.has("content")&&(this._pendingContent=this.content),e.has("model-value")&&this._useModelValue&&(this._pendingContent=this["model-value"])}disconnectedCallback(){super.disconnectedCallback();const e=this._editor?.view?.dom;e?.removeEventListener("compositionstart",this._handleCompositionStart),e?.removeEventListener("compositionend",this._handleCompositionEnd),this._editor?.destroy(),this._editor=null}getContent(){return this.getContentSnapshot().value}getContentSnapshot(){const e=this._editor?.getHTML()??"",t=this._editor?.getText().trim()??"";return{value:e?this._transformOutgoingContent(e):"",html:e,text:t,format:this._contentFormatValue}}forceUpdate(){if(this.requestUpdate(),this._editor){const e=this._transformIncomingContent(this._useModelValue?this["model-value"]:this.content);e!==this._editor.getHTML()&&this._editor.commands.setContent(e)}}_applyFormat(e){this._clearSlashCommandText(),this._clearSlashInlineMarkState(!0),e()}_getCurrentLineStart(e){const{selection:t}=e.state;return t.empty?t.$from.start():null}_getSlashCommandContext(){const e=this._editor,t=this._slashCommandRange;if(!e||!t)return null;return{lineFrom:e.state.doc.resolve(t.from).start(),lineTo:t.from}}_clearSlashInlineMarkState(){let e=arguments.length>0&&void 0!==arguments[0]&&arguments[0];const t=this._editor,i=this._slashInlineMarkState;if(!t||!i)return;const{selection:o}=t.state,r=this._getCurrentLineStart(t);if(!e&&r===i.lineStart&&o.empty&&o.to>=i.startPos)return;this._slashInlineMarkState=null;const s=t.state.selection.to;let n=t.chain().focus().setTextSelection({from:s,to:s});switch(i.type){case"bold":n=n.unsetBold();break;case"italic":n=n.unsetItalic();break;case"underline":n=n.unsetUnderline();break;case"strike":n=n.unsetStrike();break;case"code":n=n.unsetCode()}n.run()}_runInlineMarkAction(e,t,i){switch(e){case"bold":return"set"===i?t.setBold():t.unsetBold();case"italic":return"set"===i?t.setItalic():t.unsetItalic();case"underline":return"set"===i?t.setUnderline():t.unsetUnderline();case"strike":return"set"===i?t.setStrike():t.unsetStrike();case"code":return"set"===i?t.setCode():t.unsetCode()}}_syncSlashInlineMarkState(){this._slashInlineMarkState&&this._editor&&(this._isComposingText||(this._shouldEndSlashInlineMarkAtCursor()?this._clearSlashInlineMarkState(!0):this._clearSlashInlineMarkState()))}_shouldEndSlashInlineMarkAtCursor(){const e=this._editor,t=this._slashInlineMarkState;if(!e||!t)return!1;const{selection:i}=e.state,o=this._getCurrentLineStart(e);if(!i.empty||o!==t.lineStart||i.to<=t.startPos)return!1;const r=e.state.doc.textBetween(i.to-1,i.to,"\n","\n");return/\s/.test(r)}_hasInlineMarkAtCursor(e){const t=this._editor;if(!t)return!1;const i=t.schema.marks[e];if(!i)return!1;const{selection:o,storedMarks:r}=t.state;if(!o.empty)return!1;return(r??o.$from.marks()).some(e=>e.type===i)}_restoreSlashInlineMarkIfNeeded(){const e=this._editor,t=this._slashInlineMarkState;if(!e||!t)return;const{selection:i}=e.state,o=this._getCurrentLineStart(e);if(!i.empty||o!==t.lineStart||i.to<t.startPos)return;if(this._hasInlineMarkAtCursor(t.type))return;const r=e.state.selection.to;this._runInlineMarkAction(t.type,e.chain().focus().setTextSelection({from:r,to:r}),"set").run()}_setInlineMarkState(e,t){const i=this._getCurrentLineStart(this._editor);this._slashInlineMarkState=null===i?null:{type:e,lineStart:i,startPos:t}}_applyInlineMarkToCurrentLine(e,t){const i=this._editor;if(!i)return!1;const{selection:o}=i.state;if(!o.empty)return this._runInlineMarkAction(e,i.chain().focus().setTextSelection({from:o.from,to:o.to}),t).run(),"unset"===t&&this._clearSlashInlineMarkState(!0),!0;const r=o.from,s=i.state.doc.resolve(r),n={from:s.start(),to:s.end()};return this._clearSlashInlineMarkState(!0),n.from<n.to&&this._runInlineMarkAction(e,i.chain().focus().setTextSelection(n),t).run(),this._runInlineMarkAction(e,i.chain().focus().setTextSelection({from:r,to:r}),t).run(),"set"===t&&this._setInlineMarkState(e,r),!0}_toggleToolbarInlineMark(e){return this._applyInlineMarkToCurrentLine(e,this._hasInlineMarkAtCursor(e)?"unset":"set")}_applySlashInlineMark(e){const t=this._editor,i=this._getSlashCommandContext();if(!t||!i)return!1;this._clearSlashCommandText(),this._clearSlashInlineMarkState(!0);const o=t.state.selection.to,r={from:i.lineFrom,to:t.state.doc.resolve(o).end()};return r.from<r.to&&this._runInlineMarkAction(e,t.chain().focus().setTextSelection(r),"set").run(),this._runInlineMarkAction(e,t.chain().focus().setTextSelection({from:o,to:o}),"set").run(),this._setInlineMarkState(e,o),!0}_applySlashLineBlock(e){const t=this._editor,i=this._getSlashCommandContext();return!(!t||!i)&&(this._clearSlashCommandText(),e(t.chain().focus().setTextSelection({from:i.lineFrom,to:i.lineTo})).run(),!0)}_toggleBold(){this._applySlashInlineMark("bold")||this._toggleToolbarInlineMark("bold")}_toggleItalic(){this._applySlashInlineMark("italic")||this._toggleToolbarInlineMark("italic")}_toggleUnderline(){this._applySlashInlineMark("underline")||this._toggleToolbarInlineMark("underline")}_toggleStrike(){this._applySlashInlineMark("strike")||this._toggleToolbarInlineMark("strike")}_toggleCode(){this._applySlashInlineMark("code")||this._toggleToolbarInlineMark("code")}_setHeading(e){this._applySlashLineBlock(t=>t.setHeading({level:e}))||this._applyFormat(()=>this._editor?.chain().focus().toggleHeading({level:e}).run())}_setParagraph(){this._applySlashLineBlock(e=>e.setParagraph())||this._applyFormat(()=>this._editor?.chain().focus().setParagraph().run())}_toggleBulletList(){this._applySlashLineBlock(e=>e.toggleBulletList())||this._applyFormat(()=>this._editor?.chain().focus().toggleBulletList().run())}_toggleOrderedList(){this._applySlashLineBlock(e=>e.toggleOrderedList())||this._applyFormat(()=>this._editor?.chain().focus().toggleOrderedList().run())}_toggleTaskList(){this._applySlashLineBlock(e=>e.toggleTaskList())||this._applyFormat(()=>this._editor?.chain().focus().toggleTaskList().run())}_toggleBlockquote(){this._applySlashLineBlock(e=>e.toggleBlockquote())||this._applyFormat(()=>this._editor?.chain().focus().toggleBlockquote().run())}_setTextAlign(e){this._applySlashLineBlock(t=>t.setTextAlign(e))||this._applyFormat(()=>this._editor?.chain().focus().setTextAlign(e).run())}_normalizeLinkUrl(e){const t=e.trim();return t?/^(https?:\/\/|mailto:|tel:|#|\/)/i.test(t)?t:`https://${t}`:""}_getLinkLabelFromRange(e){const t=this._editor;return!t||!e||e.from>=e.to?"":t.state.doc.textBetween(e.from,e.to,"")}_getLinkTargetRange(){const e=this._editor;if(!e)return null;const{selection:t}=e.state;if(!t.empty)return{from:t.from,to:t.to};if(e.isActive("link"))return e.chain().focus().extendMarkRange("link").run(),{from:e.state.selection.from,to:e.state.selection.to};const i=e.state.doc.resolve(t.from);return{from:i.start(),to:i.end()}}_setLink(e){const t=this._editor,i=this.shadowRoot?.querySelector(".editor-wrapper"),o=e.currentTarget instanceof HTMLElement?e.currentTarget:null;if(!t||!i||!o)return;const r=this._getLinkTargetRange();this._linkSelection=r;const s=i.getBoundingClientRect(),n=o.getBoundingClientRect(),l=Math.max(12,s.width-332),a=Math.min(Math.max(12,n.left-s.left),l),d=n.bottom-s.top+8,h=String(t.getAttributes("link").href||""),c=this._getLinkLabelFromRange(r);this._linkEditor={x:a,y:d,visible:!0,url:h,label:c},this.updateComplete.then(()=>{const e=this.shadowRoot?.querySelector('.link-editor__input[data-field="url"]');e?.focus(),e?.select()})}_closeLinkEditor(){this._linkEditor={...this._linkEditor,visible:!1}}_handleLinkEditorInput(e){const t=e.target,i="label"===t.dataset.field?"label":"url";this._linkEditor={...this._linkEditor,[i]:t.value}}_applyLink(){const e=this._editor,t=this._normalizeLinkUrl(this._linkEditor.url),i=this._linkEditor.label.trim()||t;if(!e||!t)return;this._clearSlashCommandText();const o=this._linkSelection??this._getLinkTargetRange()??e.state.selection,r=o.from+i.length;e.chain().focus().insertContentAt({from:o.from,to:o.to},{type:"text",text:i,marks:[{type:"link",attrs:{href:t}}]}).setTextSelection({from:r,to:r}).run(),this._closeLinkEditor()}_removeLink(){const e=this._editor;if(!e)return;const t=this._linkSelection??e.state.selection;let i=e.chain().focus();t.from!==t.to&&(i=i.setTextSelection(t)),i.extendMarkRange("link").unsetLink().run(),this._closeLinkEditor()}_handleLinkEditorKeydown(e){if("Enter"===e.key)return e.preventDefault(),void this._applyLink();"Escape"===e.key&&(e.preventDefault(),this._closeLinkEditor())}_insertTable(e,t){this._editor?.chain().focus().insertTable({rows:e??this._tableRows,cols:t??this._tableCols,withHeaderRow:!0}).run()}async _handleImageUpload(e){const t=e.target,i=t.files?.[0];if(i)try{const e=await this._getImageNaturalWidth(i),t=await this["upload-image"](i),o=e?Math.min(e,this._getImageMaxWidth()):this._getImageMaxWidth();this._clearSlashCommandText();const r=this._pendingImageInsertPos;this._pendingImageInsertPos=null,null!==r?this._insertImageAt(r,{src:t,width:o,align:"left"}):this._editor?.chain().focus().setImage({src:t,width:o,align:"left"}).run()}catch(e){const t=e instanceof Error?e:new Error("图片上传失败");this.dispatchEvent(new CustomEvent("image-upload-error",{detail:{file:i,error:t},bubbles:!0,composed:!0}))}t.value=""}_triggerImageUpload(){this._clearSlashCommandText();const e=this.shadowRoot?.querySelector(".image-input");e?.click()}_insertTableByClick(e,t){this._clearSlashCommandText(),this._tableRows=e,this._tableCols=t,this._insertTable(e,t)}_showTableCellToolbar(){if(!this._editor?.isActive("table"))return;const{state:e}=this._editor,{selection:t}=e,i=this._editor.view.coordsAtPos(t.from),o=this.shadowRoot?.querySelector(".editor-wrapper");if(!o)return;const r=o.getBoundingClientRect(),s=this._getTableCellRow(),n=this._getTableCellCol();(0===s||0===n)&&requestAnimationFrame(()=>{this._tableCellToolbar={x:i.left-r.left,y:i.bottom-r.top+8,visible:!0,cellRow:s,cellCol:n}})}_getTableCellRow(){if(!this._editor)return 0;const{selection:e}=this._editor.state,t=this._editor.state.doc.resolve(e.from);for(let e=t.depth;e>0;e--){if("tableCell"===t.node(e).type.name)return t.index(e-1)}return 0}_getTableCellCol(){if(!this._editor)return 0;const{selection:e}=this._editor.state,t=this._editor.state.doc.resolve(e.from);for(let e=t.depth;e>0;e--){if("tableCell"===t.node(e).type.name)return t.index(e)}return 0}_hideTableCellToolbar(){requestAnimationFrame(()=>{this._tableCellToolbar={...this._tableCellToolbar,visible:!1}})}_addTableRowAbove(){this._editor?.chain().focus().addRowBefore().run(),this._hideTableCellToolbar()}_addTableRowBelow(){this._editor?.chain().focus().addRowAfter().run(),this._hideTableCellToolbar()}_addTableColumnLeft(){this._editor?.chain().focus().addColumnBefore().run(),this._hideTableCellToolbar()}_addTableColumnRight(){this._editor?.chain().focus().addColumnAfter().run(),this._hideTableCellToolbar()}_deleteTableRow(){this._editor?.chain().focus().deleteRow().run(),this._hideTableCellToolbar()}_deleteTableColumn(){this._editor?.chain().focus().deleteColumn().run(),this._hideTableCellToolbar()}_deleteTable(){this._editor?.chain().focus().deleteTable().run(),this._hideTableCellToolbar()}_showImageToolbar(e){requestAnimationFrame(()=>{this._imageToolbar={x:e.x,y:e.y,visible:!0}})}_hideImageToolbar(){requestAnimationFrame(()=>{this._imageToolbar={...this._imageToolbar,visible:!1}})}_deleteImage(){const e=this._getSelectedImageNode();if(!e)return;const{editor:t,pos:i,node:o}=e;t.view.dispatch(t.state.tr.delete(i,i+o.nodeSize)),this._selectedImage=null,this._pendingImageInsertPos=null,this._hideImageToolbar()}_insertImageAfter(){const e=this._getSelectedImageNode();e?(this._pendingImageInsertPos=e.pos+e.node.nodeSize,this._triggerImageUpload()):this._triggerImageUpload()}_getSelectedImageNode(){const e=this._editor,t=this._selectedImage?.pos;if(!e||void 0===t)return null;const i=e.state.doc.nodeAt(t);return i&&"image"===i.type.name?{editor:e,pos:t,node:i}:null}_insertImageAt(e,t){const i=this._editor;if(!i)return;const o=Math.max(0,Math.min(e,i.state.doc.content.size));i.chain().insertContentAt(o,{type:"image",attrs:t}).setNodeSelection(o).run()}_updateSelectedImageAttributes(e){const t=this._getSelectedImageNode();if(!t)return;const{editor:i,pos:o,node:r}=t;i.view.dispatch(i.state.tr.setNodeMarkup(o,void 0,{...r.attrs,...e}))}_setImageWidth(e){const t=Math.max(24,Math.min(this._getImageMaxWidth(),Math.round(e)));this._updateSelectedImageAttributes({width:t})}_handleImageWidthInput(e){const t=e.target.value.trim();if(!t)return;const i=Number(t);Number.isFinite(i)&&this._setImageWidth(i)}_setImageAlignLeft(){this._updateSelectedImageAttributes({align:"left"})}_setImageAlignCenter(){this._updateSelectedImageAttributes({align:"center"})}_setImageAlignRight(){this._updateSelectedImageAttributes({align:"right"})}_getTextLabel(){const e=this._editor;return e?e.isActive("heading",{level:1})?"标题 1":e.isActive("heading",{level:2})?"标题 2":e.isActive("heading",{level:3})?"标题 3":"正文":"正文"}_getAlignLabel(){const e=this._editor;return e?e.isActive({textAlign:"center"})?"居中":e.isActive({textAlign:"right"})?"右对齐":"左对齐":"对齐"}_renderImageControls(){const e=this._selectedImage;return e?T.html`
|
|
6
|
+
`}_transformIncomingContent(e){const t=e||"",i=this["deserialize-content"];if(!i)return _.transformIncomingContentByFormat(t,this._contentFormatValue);try{return i(t)||_.EMPTY_EDITOR_HTML}catch{return _.transformIncomingContentByFormat(t,this._contentFormatValue)}}_transformOutgoingContent(e){const t=this["serialize-content"];if(!t)return _.transformOutgoingContentByFormat(e,this._contentFormatValue);try{return t(e)}catch{return _.transformOutgoingContentByFormat(e,this._contentFormatValue)}}_getEditorCharacterCount(){return this._editor?.getText().length??0}_initEditor(){if(this._editor)return;const e=this.shadowRoot?.querySelector(".editor-content");if(!e){requestAnimationFrame(()=>this._initEditor());return}for(;e.firstChild;)e.removeChild(e.firstChild);const t=this._useModelValue,i=this.getAttribute("model-value")??this["model-value"],o=this.content,r=t?this._transformIncomingContent(this._pendingContent??i):this._transformIncomingContent(this._pendingContent??o),n=[q,U,J,$,D,ee,W,P,V.configure({levels:[1,2,3]}),R,Q,se,le,ae,A,H,F,de.configure({inline:!1,allowBase64:!0}),O.extend({inclusive:!1}).configure({openOnClick:!1,HTMLAttributes:{rel:"noopener noreferrer"}}),Z.configure({types:["heading","paragraph"]}),G.Table.configure({resizable:!0}),X.TableRow,K.TableCell,Y.TableHeader,N.configure({placeholder:this._resolvedPlaceholder})];this._editor=new g.Editor({element:e,extensions:n,editable:this._isEditable,content:r}),this._editor.view.dom.addEventListener("compositionstart",this._handleCompositionStart),this._editor.view.dom.addEventListener("compositionend",this._handleCompositionEnd),this._pendingContent=null,this._editor.on("selectionUpdate",()=>{this._syncSlashInlineMarkState(),this._restoreSlashInlineMarkIfNeeded(),this._toolbarModeValue==="slash"&&this._updateBubbleMenuPosition(),this._editor?.isActive("table")?this._showTableCellToolbar():this._hideTableCellToolbar(),this._syncImageSelectionState()}),this._editor.on("transaction",()=>{this._editor?.isActive("table")?this._showTableCellToolbar():this._hideTableCellToolbar(),this._checkSlashCommand(),this._syncSlashInlineMarkState(),this._restoreSlashInlineMarkIfNeeded(),this._setupTableEdgeDetection(),this._syncImageSelectionState()}),this._editor.on("update",()=>{this._emitContentChange()})}_toggleTaskItemChecked(e){const t=e.target,i=this._editor;if(!(t instanceof HTMLInputElement)||t.type!=="checkbox"||!i)return;const o=t.closest('li[data-type="taskItem"]');if(!o)return;e.preventDefault(),e.stopPropagation();const r=i.view.posAtDOM(o,0),n=Math.max(0,r-2),s=Math.min(i.state.doc.content.size,r+2);let h=null;if(i.state.doc.nodesBetween(n,s,(b,p)=>{if(b.type.name==="taskItem")return h=p,!1}),h===null)return;const u=i.state.doc.nodeAt(h);!u||u.type.name!=="taskItem"||i.view.dispatch(i.state.tr.setNodeMarkup(h,void 0,{...u.attrs,checked:!u.attrs.checked}))}_emitContentChange(){if(!this._editor)return;const e=this.getContentSnapshot();this._showCharacterCountValue&&this.requestUpdate(),this.dispatchEvent(new CustomEvent("content-update",{detail:e,bubbles:!0,composed:!0})),this.dispatchEvent(new CustomEvent("content-change",{detail:e.value,bubbles:!0,composed:!0}))}_setupTableEdgeDetection(){const e=this.shadowRoot?.querySelector(".editor-content"),t=this.shadowRoot?.querySelector(".editor-wrapper");if(!e||this._tableEdgeDetectionSetup)return;this._tableEdgeDetectionSetup=!0;const i=o=>{this._toggleTaskItemChecked(o);const r=o.target;r instanceof Element&&r.closest(".editor-header, .bubble-menu, .table-cell-toolbar, .image-toolbar, .link-editor")||this._isEditable&&this._editor?.chain().focus().run()};e.addEventListener("click",i),t?.addEventListener("click",i)}_handleWrapperFocusIn(){this._preserveFocusOnInternalClick=!1,this._isEditorFocused=!0}_handleHeaderToolbarMouseDown(e){if(!this._isEditable)return;const t=e.target;!(t instanceof Element)||!t.closest("button, .bubble-dropdown, .table-cell")||(e.preventDefault(),this._preserveFocusOnInternalClick=!0,requestAnimationFrame(()=>{this._preserveFocusOnInternalClick=!1}))}_handleWrapperMouseDown(e){const t=e.target;!this._isEditable||!(t instanceof Element)||t.closest(".editor-header, .bubble-menu, .table-cell-toolbar, .image-toolbar, .link-editor")||(this._preserveFocusOnInternalClick=!0,requestAnimationFrame(()=>{this._preserveFocusOnInternalClick=!1}))}_handleWrapperFocusOut(e){const t=e.relatedTarget,i=this.shadowRoot?.querySelector(".editor-wrapper");this._preserveFocusOnInternalClick||t&&i?.contains(t)||(this._isEditorFocused=!1,this._tableDropdownOpen=!1,this._selectedImage=null,this._hideImageToolbar(),this._closeLinkEditor())}_isHeaderVisible(){return this._toolbarModeValue==="header"&&!this._previewValue&&(this._headerAlwaysVisibleValue||this._isEditorFocused||this._tableDropdownOpen||!!this._selectedImage)}_getImageSelection(){const e=this._editor,t=e?.state.selection;return!e||!t?.node||t.node.type?.name!=="image"?null:{pos:t.from,attrs:t.node.attrs??{}}}_getImageMaxWidth(){const t=(this.shadowRoot?.querySelector(".editor-content")?.clientWidth??I)-32;return Math.max(w,Math.min(I,t))}async _getImageNaturalWidth(e){return await new Promise(t=>{const i=URL.createObjectURL(e),o=new window.Image;o.onload=()=>{const r=o.naturalWidth;URL.revokeObjectURL(i),t(Number.isFinite(r)&&r>0?r:null)},o.onerror=()=>{URL.revokeObjectURL(i),t(null)},o.src=i})}_syncImageSelectionState(){const e=this._getImageSelection();if(!e){this._selectedImage=null,this._toolbarModeValue==="slash"&&this._hideImageToolbar();return}const t=Number(e.attrs.width),i=String(e.attrs.align||"left");if(this._selectedImage={pos:e.pos,width:Number.isFinite(t)&&t>0?t:this._getImageMaxWidth(),align:i},this._toolbarModeValue!=="slash"){this._hideImageToolbar();return}const o=this._editor,r=this.shadowRoot?.querySelector(".editor-wrapper")?.getBoundingClientRect();if(!o||!r)return;const n=o.view.coordsAtPos(e.pos),s=n.left-r.left+(n.right-n.left)/2,h=n.top-r.top-40;this._showImageToolbar({x:s,y:h})}_clearSlashCommandText(){if(!this._editor||!this._slashCommandRange)return;const{from:e,to:t}=this._slashCommandRange;this._editor.chain().focus().deleteRange({from:e,to:t}).run(),this._hasSlashCommand=!1,this._slashCommandRange=null}_checkSlashCommand(){if(!this._editor)return;const{selection:e}=this._editor.state;if(!e.empty){this._hasSlashCommand=!1,this._slashCommandRange=null;return}const{$from:t}=e,i=t.parent.textBetween(0,t.parentOffset," "," "),o=/(?:^|\s)(\/\S*)$/.exec(i);if(!o){this._hasSlashCommand=!1,this._slashCommandRange=null;return}const r=o[1];this._hasSlashCommand=!0,this._slashCommandRange={from:e.from-r.length,to:e.from}}firstUpdated(){this._injectCustomStyles(),queueMicrotask(()=>{this.isConnected&&this._initEditor()})}updated(e){if(e.has("custom-styles")&&this._injectCustomStyles(),this._editor){if(e.has("content")||e.has("model-value")&&this._useModelValue||e.has("deserialize-content")||e.has("content-format")){const t=this._useModelValue?this["model-value"]:this.content,i=this._transformIncomingContent(t);!(!(e.has("deserialize-content")||e.has("content-format"))&&(t??"")===this.getContent())&&i!==this._editor.getHTML()&&this._editor.commands.setContent(i)}(e.has("readonly")||e.has("preview")||e.has("editable"))&&this._editor.setEditable(this._isEditable);return}e.has("content")&&(this._pendingContent=this.content),e.has("model-value")&&this._useModelValue&&(this._pendingContent=this["model-value"])}disconnectedCallback(){super.disconnectedCallback();const e=this._editor?.view?.dom;e?.removeEventListener("compositionstart",this._handleCompositionStart),e?.removeEventListener("compositionend",this._handleCompositionEnd),this._editor?.destroy(),this._editor=null}getContent(){return this.getContentSnapshot().value}getContentSnapshot(){const e=this._editor?.getHTML()??"",t=this._editor?.getText().trim()??"";return{value:e?this._transformOutgoingContent(e):"",html:e,text:t,format:this._contentFormatValue}}forceUpdate(){if(this.requestUpdate(),this._editor){const e=this._transformIncomingContent(this._useModelValue?this["model-value"]:this.content);e!==this._editor.getHTML()&&this._editor.commands.setContent(e)}}_applyFormat(e){this._clearSlashCommandText(),this._clearSlashInlineMarkState(!0),e()}_getCurrentLineStart(e){const{selection:t}=e.state;return t.empty?t.$from.start():null}_getSlashCommandContext(){const e=this._editor,t=this._slashCommandRange;return!e||!t?null:{lineFrom:e.state.doc.resolve(t.from).start(),lineTo:t.from}}_clearSlashInlineMarkState(e=!1){const t=this._editor,i=this._slashInlineMarkState;if(!t||!i)return;const{selection:o}=t.state,r=this._getCurrentLineStart(t);if(!e&&r===i.lineStart&&o.empty&&o.to>=i.startPos)return;this._slashInlineMarkState=null;const n=t.state.selection.to;let s=t.chain().focus().setTextSelection({from:n,to:n});switch(i.type){case"bold":s=s.unsetBold();break;case"italic":s=s.unsetItalic();break;case"underline":s=s.unsetUnderline();break;case"strike":s=s.unsetStrike();break;case"code":s=s.unsetCode();break}s.run()}_runInlineMarkAction(e,t,i){switch(e){case"bold":return i==="set"?t.setBold():t.unsetBold();case"italic":return i==="set"?t.setItalic():t.unsetItalic();case"underline":return i==="set"?t.setUnderline():t.unsetUnderline();case"strike":return i==="set"?t.setStrike():t.unsetStrike();case"code":return i==="set"?t.setCode():t.unsetCode()}}_syncSlashInlineMarkState(){if(!(!this._slashInlineMarkState||!this._editor)&&!this._isComposingText){if(this._shouldEndSlashInlineMarkAtCursor()){this._clearSlashInlineMarkState(!0);return}this._clearSlashInlineMarkState()}}_shouldEndSlashInlineMarkAtCursor(){const e=this._editor,t=this._slashInlineMarkState;if(!e||!t)return!1;const{selection:i}=e.state,o=this._getCurrentLineStart(e);if(!i.empty||o!==t.lineStart||i.to<=t.startPos)return!1;const r=e.state.doc.textBetween(i.to-1,i.to,`
|
|
7
|
+
`,`
|
|
8
|
+
`);return/\s/.test(r)}_hasInlineMarkAtCursor(e){const t=this._editor;if(!t)return!1;const i=t.schema.marks[e];if(!i)return!1;const{selection:o,storedMarks:r}=t.state;return o.empty?(r??o.$from.marks()).some(s=>s.type===i):!1}_restoreSlashInlineMarkIfNeeded(){const e=this._editor,t=this._slashInlineMarkState;if(!e||!t)return;const{selection:i}=e.state,o=this._getCurrentLineStart(e);if(!i.empty||o!==t.lineStart||i.to<t.startPos||this._hasInlineMarkAtCursor(t.type))return;const r=e.state.selection.to;this._runInlineMarkAction(t.type,e.chain().focus().setTextSelection({from:r,to:r}),"set").run()}_setInlineMarkState(e,t){const i=this._getCurrentLineStart(this._editor);this._slashInlineMarkState=i===null?null:{type:e,lineStart:i,startPos:t}}_applyInlineMarkToCurrentLine(e,t){const i=this._editor;if(!i)return!1;const{selection:o}=i.state;if(!o.empty)return this._runInlineMarkAction(e,i.chain().focus().setTextSelection({from:o.from,to:o.to}),t).run(),t==="unset"&&this._clearSlashInlineMarkState(!0),!0;const r=o.from,n=i.state.doc.resolve(r),s={from:n.start(),to:n.end()};return this._clearSlashInlineMarkState(!0),s.from<s.to&&this._runInlineMarkAction(e,i.chain().focus().setTextSelection(s),t).run(),this._runInlineMarkAction(e,i.chain().focus().setTextSelection({from:r,to:r}),t).run(),t==="set"&&this._setInlineMarkState(e,r),!0}_toggleToolbarInlineMark(e){return this._applyInlineMarkToCurrentLine(e,this._hasInlineMarkAtCursor(e)?"unset":"set")}_applySlashInlineMark(e){const t=this._editor,i=this._getSlashCommandContext();if(!t||!i)return!1;this._clearSlashCommandText(),this._clearSlashInlineMarkState(!0);const o=t.state.selection.to,r={from:i.lineFrom,to:t.state.doc.resolve(o).end()};return r.from<r.to&&this._runInlineMarkAction(e,t.chain().focus().setTextSelection(r),"set").run(),this._runInlineMarkAction(e,t.chain().focus().setTextSelection({from:o,to:o}),"set").run(),this._setInlineMarkState(e,o),!0}_applySlashLineBlock(e){const t=this._editor,i=this._getSlashCommandContext();return!t||!i?!1:(this._clearSlashCommandText(),e(t.chain().focus().setTextSelection({from:i.lineFrom,to:i.lineTo})).run(),!0)}_toggleBold(){this._applySlashInlineMark("bold")||this._toggleToolbarInlineMark("bold")}_toggleItalic(){this._applySlashInlineMark("italic")||this._toggleToolbarInlineMark("italic")}_toggleUnderline(){this._applySlashInlineMark("underline")||this._toggleToolbarInlineMark("underline")}_toggleStrike(){this._applySlashInlineMark("strike")||this._toggleToolbarInlineMark("strike")}_toggleCode(){this._applySlashInlineMark("code")||this._toggleToolbarInlineMark("code")}_setHeading(e){this._applySlashLineBlock(t=>t.setHeading({level:e}))||this._applyFormat(()=>this._editor?.chain().focus().toggleHeading({level:e}).run())}_setParagraph(){this._applySlashLineBlock(e=>e.setParagraph())||this._applyFormat(()=>this._editor?.chain().focus().setParagraph().run())}_toggleBulletList(){this._applySlashLineBlock(e=>e.toggleBulletList())||this._applyFormat(()=>this._editor?.chain().focus().toggleBulletList().run())}_toggleOrderedList(){this._applySlashLineBlock(e=>e.toggleOrderedList())||this._applyFormat(()=>this._editor?.chain().focus().toggleOrderedList().run())}_toggleTaskList(){this._applySlashLineBlock(e=>e.toggleTaskList())||this._applyFormat(()=>this._editor?.chain().focus().toggleTaskList().run())}_toggleBlockquote(){this._applySlashLineBlock(e=>e.toggleBlockquote())||this._applyFormat(()=>this._editor?.chain().focus().toggleBlockquote().run())}_setTextAlign(e){this._applySlashLineBlock(t=>t.setTextAlign(e))||this._applyFormat(()=>this._editor?.chain().focus().setTextAlign(e).run())}_normalizeLinkUrl(e){const t=e.trim();return t?/^(https?:\/\/|mailto:|tel:|#|\/)/i.test(t)?t:`https://${t}`:""}_getLinkLabelFromRange(e){const t=this._editor;return!t||!e||e.from>=e.to?"":t.state.doc.textBetween(e.from,e.to,"")}_getLinkTargetRange(){const e=this._editor;if(!e)return null;const{selection:t}=e.state;if(!t.empty)return{from:t.from,to:t.to};if(e.isActive("link"))return e.chain().focus().extendMarkRange("link").run(),{from:e.state.selection.from,to:e.state.selection.to};const i=e.state.doc.resolve(t.from);return{from:i.start(),to:i.end()}}_setLink(e){const t=this._editor,i=this.shadowRoot?.querySelector(".editor-wrapper"),o=e.currentTarget instanceof HTMLElement?e.currentTarget:null;if(!t||!i||!o)return;const r=this._getLinkTargetRange();this._linkSelection=r;const n=i.getBoundingClientRect(),s=o.getBoundingClientRect(),h=Math.max(12,n.width-332),u=Math.min(Math.max(12,s.left-n.left),h),b=s.bottom-n.top+8,p=String(t.getAttributes("link").href||""),m=this._getLinkLabelFromRange(r);this._linkEditor={x:u,y:b,visible:!0,url:p,label:m},this.updateComplete.then(()=>{const f=this.shadowRoot?.querySelector('.link-editor__input[data-field="url"]');f?.focus(),f?.select()})}_closeLinkEditor(){this._linkEditor={...this._linkEditor,visible:!1}}_handleLinkEditorInput(e){const t=e.target,i=t.dataset.field==="label"?"label":"url";this._linkEditor={...this._linkEditor,[i]:t.value}}_applyLink(){const e=this._editor,t=this._normalizeLinkUrl(this._linkEditor.url),i=this._linkEditor.label.trim()||t;if(!e||!t)return;this._clearSlashCommandText();const o=this._linkSelection??this._getLinkTargetRange()??e.state.selection,r=o.from+i.length;e.chain().focus().insertContentAt({from:o.from,to:o.to},{type:"text",text:i,marks:[{type:"link",attrs:{href:t}}]}).setTextSelection({from:r,to:r}).run(),this._closeLinkEditor()}_removeLink(){const e=this._editor;if(!e)return;const t=this._linkSelection??e.state.selection;let i=e.chain().focus();t.from!==t.to&&(i=i.setTextSelection(t)),i.extendMarkRange("link").unsetLink().run(),this._closeLinkEditor()}_handleLinkEditorKeydown(e){if(e.key==="Enter"){e.preventDefault(),this._applyLink();return}e.key==="Escape"&&(e.preventDefault(),this._closeLinkEditor())}_insertTable(e,t){this._editor?.chain().focus().insertTable({rows:e??this._tableRows,cols:t??this._tableCols,withHeaderRow:!0}).run()}async _handleImageUpload(e){const t=e.target,i=Array.from(t.files??[]);if(!i.length){t.value="";return}this._clearSlashCommandText();let o=this._pendingImageInsertPos!==null?{from:this._pendingImageInsertPos,to:this._pendingImageInsertPos}:this._editor?{from:this._editor.state.selection.from,to:this._editor.state.selection.to}:null;this._pendingImageInsertPos=null;for(const r of i)try{const n=await this._getImageNaturalWidth(r),s=await this["upload-image"](r),h=n?Math.min(n,this._getImageMaxWidth()):this._getImageMaxWidth();if(!o&&this._editor&&(o={from:this._editor.state.selection.from,to:this._editor.state.selection.to}),!o)continue;const u=this._insertImageAt(o,{src:s,width:h,align:"left"});o={from:u,to:u}}catch(n){const s=n instanceof Error?n:new Error("图片上传失败");this.dispatchEvent(new CustomEvent("image-upload-error",{detail:{file:r,error:s},bubbles:!0,composed:!0}))}t.value=""}_triggerImageUpload(){this._clearSlashCommandText();const e=this.shadowRoot?.querySelector(".image-input");if(!e)return;e.value="";const t=e;if(typeof t.showPicker=="function")try{t.showPicker();return}catch{}e.click()}_insertTableByClick(e,t){this._clearSlashCommandText(),this._tableRows=e,this._tableCols=t,this._insertTable(e,t)}_showTableCellToolbar(){if(!this._editor?.isActive("table"))return;const{state:e}=this._editor,{selection:t}=e,i=this._editor.view.coordsAtPos(t.from),o=this.shadowRoot?.querySelector(".editor-wrapper");if(!o)return;const r=o.getBoundingClientRect(),n=this._getTableCellRow(),s=this._getTableCellCol();!(n===0)&&!(s===0)||requestAnimationFrame(()=>{this._tableCellToolbar={x:i.left-r.left,y:i.bottom-r.top+8,visible:!0,cellRow:n,cellCol:s}})}_getTableCellRow(){if(!this._editor)return 0;const{selection:e}=this._editor.state,t=this._editor.state.doc.resolve(e.from);for(let i=t.depth;i>0;i--)if(t.node(i).type.name==="tableCell")return t.index(i-1);return 0}_getTableCellCol(){if(!this._editor)return 0;const{selection:e}=this._editor.state,t=this._editor.state.doc.resolve(e.from);for(let i=t.depth;i>0;i--)if(t.node(i).type.name==="tableCell")return t.index(i);return 0}_hideTableCellToolbar(){requestAnimationFrame(()=>{this._tableCellToolbar={...this._tableCellToolbar,visible:!1}})}_addTableRowAbove(){this._editor?.chain().focus().addRowBefore().run(),this._hideTableCellToolbar()}_addTableRowBelow(){this._editor?.chain().focus().addRowAfter().run(),this._hideTableCellToolbar()}_addTableColumnLeft(){this._editor?.chain().focus().addColumnBefore().run(),this._hideTableCellToolbar()}_addTableColumnRight(){this._editor?.chain().focus().addColumnAfter().run(),this._hideTableCellToolbar()}_deleteTableRow(){this._editor?.chain().focus().deleteRow().run(),this._hideTableCellToolbar()}_deleteTableColumn(){this._editor?.chain().focus().deleteColumn().run(),this._hideTableCellToolbar()}_deleteTable(){this._editor?.chain().focus().deleteTable().run(),this._hideTableCellToolbar()}_showImageToolbar(e){requestAnimationFrame(()=>{this._imageToolbar={x:e.x,y:e.y,visible:!0}})}_hideImageToolbar(){requestAnimationFrame(()=>{this._imageToolbar={...this._imageToolbar,visible:!1}})}_deleteImage(){const e=this._getSelectedImageNode();if(!e)return;const{editor:t,pos:i,node:o}=e;t.view.dispatch(t.state.tr.delete(i,i+o.nodeSize)),this._selectedImage=null,this._pendingImageInsertPos=null,this._hideImageToolbar()}_insertImageAfter(){const e=this._getSelectedImageNode();if(!e){this._triggerImageUpload();return}this._pendingImageInsertPos=e.pos+e.node.nodeSize,this._triggerImageUpload()}_getSelectedImageNode(){const e=this._editor,t=this._selectedImage?.pos;if(!e||t===void 0)return null;const i=e.state.doc.nodeAt(t);return!i||i.type.name!=="image"?null:{editor:e,pos:t,node:i}}_insertImageAt(e,t){const i=this._editor;if(!i)return 0;const o=typeof e=="number"?{from:Math.max(0,Math.min(e,i.state.doc.content.size)),to:Math.max(0,Math.min(e,i.state.doc.content.size))}:{from:Math.max(0,Math.min(e.from,i.state.doc.content.size)),to:Math.max(0,Math.min(e.to,i.state.doc.content.size))},r=o.from,n=i.chain().focus();if(typeof n.insertContentAt=="function"){let s=n.insertContentAt(o,{type:"image",attrs:t});typeof s?.setNodeSelection=="function"&&(s=s.setNodeSelection(r)),s.run();const h=i.state.doc.nodeAt(r)?.nodeSize??1;return r+h}return typeof n.setImage=="function"?(n.setImage(t).run(),r+1):r}_updateSelectedImageAttributes(e){const t=this._getSelectedImageNode();if(!t)return;const{editor:i,pos:o,node:r}=t;i.view.dispatch(i.state.tr.setNodeMarkup(o,void 0,{...r.attrs,...e}))}_setImageWidth(e){const t=Math.max(w,Math.min(this._getImageMaxWidth(),Math.round(e)));this._updateSelectedImageAttributes({width:t})}_handleImageWidthInput(e){const t=e.target.value.trim();if(!t)return;const i=Number(t);Number.isFinite(i)&&this._setImageWidth(i)}_setImageAlignLeft(){this._updateSelectedImageAttributes({align:"left"})}_setImageAlignCenter(){this._updateSelectedImageAttributes({align:"center"})}_setImageAlignRight(){this._updateSelectedImageAttributes({align:"right"})}_getTextLabel(){const e=this._editor;return e?e.isActive("heading",{level:1})?"标题 1":e.isActive("heading",{level:2})?"标题 2":e.isActive("heading",{level:3})?"标题 3":"正文":"正文"}_getAlignLabel(){const e=this._editor;return e?e.isActive({textAlign:"center"})?"居中":e.isActive({textAlign:"right"})?"右对齐":"左对齐":"对齐"}_renderImageControls(){const e=this._selectedImage;return e?l.html`
|
|
7
9
|
<button class="bubble-btn danger" title="删除图片" @click=${this._deleteImage}>
|
|
8
10
|
<svg viewBox="0 0 24 24"><polyline points="3 6 5 6 21 6"/><path d="M19 6v14a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2V6m3 0V4a2 2 0 0 1 2-2h4a2 2 0 0 1 2 2v2"/></svg>
|
|
9
11
|
</button>
|
|
@@ -12,13 +14,13 @@
|
|
|
12
14
|
</button>
|
|
13
15
|
<div class="bubble-divider"></div>
|
|
14
16
|
<span class="image-control-label">对齐</span>
|
|
15
|
-
<button class="bubble-btn ${"left"
|
|
17
|
+
<button class="bubble-btn ${e.align==="left"?"is-active":""}" title="左对齐" @click=${this._setImageAlignLeft}>
|
|
16
18
|
<svg viewBox="0 0 24 24"><line x1="3" y1="6" x2="21" y2="6"/><line x1="3" y1="12" x2="15" y2="12"/><line x1="3" y1="18" x2="18" y2="18"/></svg>
|
|
17
19
|
</button>
|
|
18
|
-
<button class="bubble-btn ${"center"
|
|
20
|
+
<button class="bubble-btn ${e.align==="center"?"is-active":""}" title="居中" @click=${this._setImageAlignCenter}>
|
|
19
21
|
<svg viewBox="0 0 24 24"><line x1="3" y1="6" x2="21" y2="6"/><line x1="6" y1="12" x2="18" y2="12"/><line x1="4" y1="18" x2="20" y2="18"/></svg>
|
|
20
22
|
</button>
|
|
21
|
-
<button class="bubble-btn ${"right"
|
|
23
|
+
<button class="bubble-btn ${e.align==="right"?"is-active":""}" title="右对齐" @click=${this._setImageAlignRight}>
|
|
22
24
|
<svg viewBox="0 0 24 24"><line x1="3" y1="6" x2="21" y2="6"/><line x1="9" y1="12" x2="21" y2="12"/><line x1="6" y1="18" x2="21" y2="18"/></svg>
|
|
23
25
|
</button>
|
|
24
26
|
<div class="image-size-control">
|
|
@@ -26,18 +28,18 @@
|
|
|
26
28
|
<input
|
|
27
29
|
class="image-size-range"
|
|
28
30
|
type="number"
|
|
29
|
-
min="${
|
|
31
|
+
min="${w}"
|
|
30
32
|
max="${this._getImageMaxWidth()}"
|
|
31
33
|
.value=${String(e.width)}
|
|
32
34
|
@input=${this._handleImageWidthInput}
|
|
33
35
|
/>
|
|
34
36
|
</div>
|
|
35
|
-
`:""}_joinToolbarGroups(e){return e.flatMap((
|
|
36
|
-
${this._renderToolbarButton("bold",{title:"加粗",active:e?.isActive("bold"),onClick:this._toggleBold,icon:
|
|
37
|
-
${this._renderToolbarButton("italic",{title:"斜体",active:e?.isActive("italic"),onClick:this._toggleItalic,icon:
|
|
38
|
-
${this._renderToolbarButton("underline",{title:"下划线",active:e?.isActive("underline"),onClick:this._toggleUnderline,icon:
|
|
39
|
-
${this._renderToolbarButton("strike",{title:"删除线",active:e?.isActive("strike"),onClick:this._toggleStrike,icon:
|
|
40
|
-
`}_renderHeadingToolbarGroup(e){return
|
|
37
|
+
`:""}_joinToolbarGroups(e){return e.flatMap((t,i)=>i===0?[t]:[l.html`<div class="bubble-divider"></div>`,t])}_renderFormatToolbarGroup(e){return l.html`
|
|
38
|
+
${this._renderToolbarButton("bold",{title:"加粗",active:e?.isActive("bold"),onClick:this._toggleBold,icon:l.html`<svg viewBox="0 0 24 24"><path d="M6 4h8a4 4 0 0 1 4 4 4 4 0 0 1-4 4H6z"/><path d="M6 12h9a4 4 0 0 1 4 4 4 4 0 0 1-4 4H6z"/></svg>`})}
|
|
39
|
+
${this._renderToolbarButton("italic",{title:"斜体",active:e?.isActive("italic"),onClick:this._toggleItalic,icon:l.html`<svg viewBox="0 0 24 24"><line x1="19" y1="4" x2="10" y2="4"/><line x1="14" y1="20" x2="5" y2="20"/><line x1="15" y1="4" x2="9" y2="20"/></svg>`})}
|
|
40
|
+
${this._renderToolbarButton("underline",{title:"下划线",active:e?.isActive("underline"),onClick:this._toggleUnderline,icon:l.html`<svg viewBox="0 0 24 24"><path d="M6 3v7a6 6 0 0 0 6 6 6 6 0 0 0 6-6V3"/><line x1="4" y1="21" x2="20" y2="21"/></svg>`})}
|
|
41
|
+
${this._renderToolbarButton("strike",{title:"删除线",active:e?.isActive("strike"),onClick:this._toggleStrike,icon:l.html`<svg viewBox="0 0 24 24"><path d="M17.3 4.9c-2.3-.6-4.4-1-6.2-.9-2.7 0-5.3.7-5.3 3.6 0 1.5 1.8 3.3 5.3 3.9h.2m8.2 3.2c.3.4.4.8.4 1.3 0 2.9-2.7 3.6-6.2 3.6-2.3 0-4.4-.3-6.2-.9M4 12h16"/></svg>`})}
|
|
42
|
+
`}_renderHeadingToolbarGroup(e){return l.html`
|
|
41
43
|
<div class="bubble-dropdown">
|
|
42
44
|
<button class="bubble-dropdown-btn">
|
|
43
45
|
${this._getTextLabel()}
|
|
@@ -50,7 +52,7 @@
|
|
|
50
52
|
<button class="bubble-dropdown-item ${e?.isActive("heading",{level:3})?"is-active":""}" @click=${()=>this._setHeading(3)}>标题 3</button>
|
|
51
53
|
</div>
|
|
52
54
|
</div>
|
|
53
|
-
`}_renderAlignToolbarGroup(e){return
|
|
55
|
+
`}_renderAlignToolbarGroup(e){return l.html`
|
|
54
56
|
<div class="bubble-dropdown">
|
|
55
57
|
<button class="bubble-dropdown-btn">
|
|
56
58
|
${this._getAlignLabel()}
|
|
@@ -71,12 +73,12 @@
|
|
|
71
73
|
</button>
|
|
72
74
|
</div>
|
|
73
75
|
</div>
|
|
74
|
-
`}_renderCodeLinkImageToolbarGroup(e){return
|
|
75
|
-
${this._hasToolbarItem("code")?this._renderToolbarButton("code",{title:"行内代码",active:e?.isActive("code"),onClick:this._toggleCode,icon:
|
|
76
|
-
${this._hasToolbarItem("link")?this._renderToolbarButton("link",{title:"链接",active:e?.isActive("link"),onClick:this._setLink,icon:
|
|
77
|
-
${this._hasToolbarItem("image")?this._renderToolbarButton("image",{title:"图片",onClick:this._triggerImageUpload,icon:
|
|
78
|
-
`}_renderCodeToolbarButton(e){return this._renderToolbarButton("code",{title:"行内代码",active:e?.isActive("code"),onClick:this._toggleCode,icon:
|
|
79
|
-
${this._renderToolbarButton("bulletList",{title:"无序列表",active:e?.isActive("bulletList"),onClick:this._toggleBulletList,icon:
|
|
76
|
+
`}_renderCodeLinkImageToolbarGroup(e){return l.html`
|
|
77
|
+
${this._hasToolbarItem("code")?this._renderToolbarButton("code",{title:"行内代码",active:e?.isActive("code"),onClick:this._toggleCode,icon:l.html`<svg viewBox="0 0 24 24"><polyline points="16 18 22 12 16 6"/><polyline points="8 6 2 12 8 18"/></svg>`}):""}
|
|
78
|
+
${this._hasToolbarItem("link")?this._renderToolbarButton("link",{title:"链接",active:e?.isActive("link"),onClick:this._setLink,icon:l.html`<svg viewBox="0 0 24 24"><path d="M10 13a5 5 0 0 0 7.54.54l3-3a5 5 0 0 0-7.07-7.07l-1.72 1.71"/><path d="M14 11a5 5 0 0 0-7.54-.54l-3 3a5 5 0 0 0 7.07 7.07l1.71-1.71"/></svg>`}):""}
|
|
79
|
+
${this._hasToolbarItem("image")?this._renderToolbarButton("image",{title:"图片",onClick:this._triggerImageUpload,icon:l.html`<svg viewBox="0 0 24 24"><rect x="3" y="3" width="18" height="18" rx="2" ry="2"/><circle cx="8.5" cy="8.5" r="1.5"/><polyline points="21 15 16 10 5 21"/></svg>`}):""}
|
|
80
|
+
`}_renderCodeToolbarButton(e){return this._renderToolbarButton("code",{title:"行内代码",active:e?.isActive("code"),onClick:this._toggleCode,icon:l.html`<svg viewBox="0 0 24 24"><polyline points="16 18 22 12 16 6"/><polyline points="8 6 2 12 8 18"/></svg>`})}_renderLinkToolbarButton(e){return this._renderToolbarButton("link",{title:"链接",active:e?.isActive("link"),onClick:this._setLink,icon:l.html`<svg viewBox="0 0 24 24"><path d="M10 13a5 5 0 0 0 7.54.54l3-3a5 5 0 0 0-7.07-7.07l-1.72 1.71"/><path d="M14 11a5 5 0 0 0-7.54-.54l-3 3a5 5 0 0 0 7.07 7.07l1.71-1.71"/></svg>`})}_renderImageToolbarButton(){return this._renderToolbarButton("image",{title:"图片",onClick:this._triggerImageUpload,icon:l.html`<svg viewBox="0 0 24 24"><rect x="3" y="3" width="18" height="18" rx="2" ry="2"/><circle cx="8.5" cy="8.5" r="1.5"/><polyline points="21 15 16 10 5 21"/></svg>`})}_renderListToolbarGroup(e){return l.html`
|
|
81
|
+
${this._renderToolbarButton("bulletList",{title:"无序列表",active:e?.isActive("bulletList"),onClick:this._toggleBulletList,icon:l.html`<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">
|
|
80
82
|
<line x1="9" y1="6" x2="20" y2="6"/>
|
|
81
83
|
<line x1="9" y1="12" x2="20" y2="12"/>
|
|
82
84
|
<line x1="9" y1="18" x2="20" y2="18"/>
|
|
@@ -84,7 +86,7 @@
|
|
|
84
86
|
<circle cx="4" cy="12" r="0.5" fill="currentColor" stroke="none"/>
|
|
85
87
|
<circle cx="4" cy="18" r="0.5" fill="currentColor" stroke="none"/>
|
|
86
88
|
</svg>`})}
|
|
87
|
-
${this._renderToolbarButton("orderedList",{title:"有序列表",active:e?.isActive("orderedList"),onClick:this._toggleOrderedList,icon:
|
|
89
|
+
${this._renderToolbarButton("orderedList",{title:"有序列表",active:e?.isActive("orderedList"),onClick:this._toggleOrderedList,icon:l.html`<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">
|
|
88
90
|
<line x1="10" y1="6" x2="21" y2="6"/>
|
|
89
91
|
<line x1="10" y1="12" x2="21" y2="12"/>
|
|
90
92
|
<line x1="10" y1="18" x2="21" y2="18"/>
|
|
@@ -92,16 +94,16 @@
|
|
|
92
94
|
<path d="M4 10h2"/>
|
|
93
95
|
<path d="M6 18H4c0-1 2-2 2-3s-1-1.5-2-1.5"/>
|
|
94
96
|
</svg>`})}
|
|
95
|
-
${this._renderToolbarButton("taskList",{title:"待办列表",active:e?.isActive("taskList"),onClick:this._toggleTaskList,icon:
|
|
97
|
+
${this._renderToolbarButton("taskList",{title:"待办列表",active:e?.isActive("taskList"),onClick:this._toggleTaskList,icon:l.html`<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">
|
|
96
98
|
<rect x="3" y="5" width="4" height="4" rx="1"/>
|
|
97
99
|
<polyline points="4 7 5 8 6.5 6.5"/>
|
|
98
100
|
<line x1="10" y1="7" x2="21" y2="7"/>
|
|
99
101
|
<rect x="3" y="15" width="4" height="4" rx="1"/>
|
|
100
102
|
<line x1="10" y1="17" x2="21" y2="17"/>
|
|
101
103
|
</svg>`})}
|
|
102
|
-
`}_renderBlockquoteToolbarGroup(e){return
|
|
103
|
-
${this._renderToolbarButton("blockquote",{title:"引用",active:e?.isActive("blockquote"),onClick:this._toggleBlockquote,icon:
|
|
104
|
-
`}_renderTableToolbarGroup(){const e=this._getHeaderToolbarLabel("table");return
|
|
104
|
+
`}_renderBlockquoteToolbarGroup(e){return l.html`
|
|
105
|
+
${this._renderToolbarButton("blockquote",{title:"引用",active:e?.isActive("blockquote"),onClick:this._toggleBlockquote,icon:l.html`<svg viewBox="0 0 24 24"><path d="M3 21c3 0 7-1 7-8V5c0-1.25-.756-2.017-2-2H4c-1.25 0-2 .75-2 1.972V11c0 1.25.75 2 2 2 1 0 1 0 1 1v1c0 1-1 2-2 2s-1 .008-1 1.031V21z"/><path d="M15 21c3 0 7-1 7-8V5c0-1.25-.757-2.017-2-2h-4c-1.25 0-2 .75-2 1.972V11c0 1.25.75 2 2 2h.75c0 2.25.25 4-2.75 4v3c0 1 0 1 1 1z"/></svg>`})}
|
|
106
|
+
`}_renderTableToolbarGroup(){const e=this._getHeaderToolbarLabel("table");return l.html`
|
|
105
107
|
<div
|
|
106
108
|
class="bubble-dropdown ${this._tableDropdownOpen?"is-open":""}"
|
|
107
109
|
@mouseenter=${()=>{this._tableDropdownOpen=!0,this._hoverRow=0,this._hoverCol=0}}
|
|
@@ -109,7 +111,7 @@
|
|
|
109
111
|
>
|
|
110
112
|
<button class="bubble-dropdown-btn ${e?"has-label":""}" title="表格">
|
|
111
113
|
<svg viewBox="0 0 24 24" style="width:18px;height:18px;stroke:currentColor;stroke-width:2;fill:none;"><rect x="3" y="3" width="18" height="18" rx="2" ry="2"/><line x1="3" y1="9" x2="21" y2="9"/><line x1="3" y1="15" x2="21" y2="15"/><line x1="9" y1="3" x2="9" y2="21"/><line x1="15" y1="3" x2="15" y2="21"/></svg>
|
|
112
|
-
${e?
|
|
114
|
+
${e?l.html`<span class="bubble-dropdown-btn__label">${e}</span>`:null}
|
|
113
115
|
</button>
|
|
114
116
|
<div class="bubble-dropdown-menu">
|
|
115
117
|
<div class="table-grid-preview">
|
|
@@ -120,21 +122,21 @@
|
|
|
120
122
|
</div>
|
|
121
123
|
</div>
|
|
122
124
|
</div>
|
|
123
|
-
`}_getToolbarMergeKey(e){return"code"===
|
|
125
|
+
`}_getToolbarMergeKey(e){return e==="code"||e==="link"||e==="image"?"code-link-image":e}_renderToolbarItemByKey(e,t){switch(t){case"format":return this._renderFormatToolbarGroup(e);case"heading":return this._renderHeadingToolbarGroup(e);case"align":return this._renderAlignToolbarGroup(e);case"code":return this._renderCodeToolbarButton(e);case"link":return this._renderLinkToolbarButton(e);case"image":return this._renderImageToolbarButton();case"list":return this._renderListToolbarGroup(e);case"blockquote":return this._renderBlockquoteToolbarGroup(e);case"table":return this._renderTableToolbarGroup();default:return null}}_renderTextToolbar(e){const t=[];let i="",o=[];const r=()=>{o.length&&(t.push([...o]),o=[])};for(const n of this._toolbarItemsValue){const s=this._renderToolbarItemByKey(e,n);if(!s)continue;const h=this._getToolbarMergeKey(n);o.length&&h!==i&&r(),i=h,o.push(s)}return r(),this._joinToolbarGroups(t)}_updateBubbleMenuPosition(){this._toolbarModeValue==="slash"&&requestAnimationFrame(()=>{const e=this.shadowRoot?.querySelector(".bubble-menu"),t=this.shadowRoot?.querySelector(".ProseMirror"),i=this.shadowRoot?.querySelector(".editor-wrapper");if(!e||!t||!i)return;const o=this._editor,r=o?.isActive("table")??!1,{selection:n}=o?.state??{selection:null};if(r&&n&&!n.empty&&o){const{from:f,to:E}=n,x=o.state.doc.resolve(f),C=o.state.doc.resolve(E);let v=!1;for(let k=x.depth;k>=0;k--)if(x.node(k).type.name==="table"){v=!0;break}const L=x.node(x.depth),B=C.node(C.depth);if((L.type.name==="table"||B.type.name==="table")&&(v=!0),v){e.style.opacity="0",e.style.visibility="hidden";return}}if(!(n&&!n.empty)){if(!n||n.empty&&!this._hasSlashCommand){e.style.opacity="0",e.style.visibility="hidden";return}}const s=i.getBoundingClientRect(),h=e.getBoundingClientRect(),{from:u}=n,b=this._editor?.view.coordsAtPos(u);if(!b)return;let p=b.left-s.left,m=b.top-s.top-40;p+h.width>s.width&&(p=s.width-h.width-8),p<0&&(p=8),m<0&&(m=b.bottom-s.top+8),e.style.left=`${p}px`,e.style.top=`${m}px`,e.style.opacity="1",e.style.visibility="visible"})}render(){const e=this._editor,t=!this._previewValue&&this._toolbarModeValue==="header"?l.html`
|
|
124
126
|
<div class="editor-header ${this._isHeaderVisible()?"is-visible":""}">
|
|
125
127
|
<div class="editor-header__inner" @mousedown=${this._handleHeaderToolbarMouseDown}>
|
|
126
128
|
${this._selectedImage?this._renderImageControls():this._renderTextToolbar(e)}
|
|
127
129
|
</div>
|
|
128
130
|
</div>
|
|
129
|
-
|
|
131
|
+
`:null,i=this._showCharacterCountValue&&!this._previewValue;return l.html`
|
|
130
132
|
<div
|
|
131
|
-
class="editor-wrapper ${e?"":"loading"} ${this._previewValue?"preview":""} ${"bottom"
|
|
133
|
+
class="editor-wrapper ${e?"":"loading"} ${this._previewValue?"preview":""} ${this._toolbarPositionValue==="bottom"?"toolbar-bottom":""}"
|
|
132
134
|
style=${this._wrapperStyleValue}
|
|
133
135
|
@mousedown=${this._handleWrapperMouseDown}
|
|
134
136
|
@focusin=${this._handleWrapperFocusIn}
|
|
135
137
|
@focusout=${this._handleWrapperFocusOut}
|
|
136
138
|
>
|
|
137
|
-
${e?"":
|
|
139
|
+
${e?"":l.html`
|
|
138
140
|
<div class="loading-placeholder">
|
|
139
141
|
<div class="loading-spinner"></div>
|
|
140
142
|
<span>编辑器加载中...</span>
|
|
@@ -143,31 +145,32 @@
|
|
|
143
145
|
<input
|
|
144
146
|
type="file"
|
|
145
147
|
accept="image/*"
|
|
148
|
+
multiple
|
|
146
149
|
class="image-input"
|
|
147
150
|
@change=${this._handleImageUpload}
|
|
148
151
|
/>
|
|
149
152
|
|
|
150
|
-
${"top"
|
|
153
|
+
${this._toolbarPositionValue==="top"?t:null}
|
|
151
154
|
|
|
152
155
|
<!-- Bubble Menu (悬浮操作栏) -->
|
|
153
|
-
${this._previewValue
|
|
156
|
+
${!this._previewValue&&this._toolbarModeValue==="slash"?l.html`
|
|
154
157
|
<div class="bubble-menu">
|
|
155
158
|
${this._renderTextToolbar(e)}
|
|
156
159
|
</div>
|
|
157
|
-
|
|
160
|
+
`:""}
|
|
158
161
|
|
|
159
162
|
<div class="editor-content" data-empty-hint=${this._resolvedPlaceholder}></div>
|
|
160
163
|
|
|
161
|
-
${"bottom"
|
|
164
|
+
${this._toolbarPositionValue==="bottom"?t:null}
|
|
162
165
|
|
|
163
|
-
${i?
|
|
166
|
+
${i?l.html`<div class="editor-footer">${this._getEditorCharacterCount()} 字符</div>`:null}
|
|
164
167
|
|
|
165
|
-
${this._linkEditor.visible?
|
|
168
|
+
${this._linkEditor.visible?l.html`
|
|
166
169
|
<div
|
|
167
170
|
class="link-editor"
|
|
168
171
|
style="left: ${this._linkEditor.x}px; top: ${this._linkEditor.y}px;"
|
|
169
|
-
@mousedown=${
|
|
170
|
-
@click=${
|
|
172
|
+
@mousedown=${o=>o.stopPropagation()}
|
|
173
|
+
@click=${o=>o.stopPropagation()}
|
|
171
174
|
>
|
|
172
175
|
<div class="link-editor__field">
|
|
173
176
|
<span class="link-editor__label">链接地址</span>
|
|
@@ -196,19 +199,19 @@
|
|
|
196
199
|
<div class="link-editor__actions">
|
|
197
200
|
<button class="link-editor__action primary" title="应用链接" @click=${this._applyLink}>应用</button>
|
|
198
201
|
<button class="link-editor__action" title="取消链接编辑" @click=${this._closeLinkEditor}>取消</button>
|
|
199
|
-
${e?.isActive("link")||this._linkEditor.url?
|
|
202
|
+
${e?.isActive("link")||this._linkEditor.url?l.html`<button class="link-editor__action danger" title="移除链接" @click=${this._removeLink}>移除</button>`:""}
|
|
200
203
|
</div>
|
|
201
204
|
</div>
|
|
202
205
|
`:""}
|
|
203
206
|
|
|
204
207
|
<!-- Table Cell Toolbar -->
|
|
205
|
-
${this._tableCellToolbar.visible&&e?.isActive("table")?
|
|
208
|
+
${this._tableCellToolbar.visible&&e?.isActive("table")?l.html`
|
|
206
209
|
<div
|
|
207
210
|
class="table-cell-toolbar"
|
|
208
211
|
style="left: ${this._tableCellToolbar.x}px; top: ${this._tableCellToolbar.y}px;"
|
|
209
|
-
@mousedown=${
|
|
212
|
+
@mousedown=${o=>o.preventDefault()}
|
|
210
213
|
>
|
|
211
|
-
${
|
|
214
|
+
${this._tableCellToolbar.cellRow===0?l.html`
|
|
212
215
|
<button class="table-cell-toolbar-btn" title="上方添加行" @click=${this._addTableRowAbove}>
|
|
213
216
|
<svg viewBox="0 0 24 24" width="16" height="16" stroke="currentColor" stroke-width="2" fill="none"><rect x="4" y="8" width="16" height="8" rx="1"/><line x1="12" y1="3" x2="12" y2="7"/><line x1="10" y1="5" x2="14" y2="5"/></svg>
|
|
214
217
|
</button>
|
|
@@ -219,8 +222,8 @@
|
|
|
219
222
|
<svg viewBox="0 0 24 24" width="16" height="16" stroke="currentColor" stroke-width="2" fill="none"><rect x="4" y="8" width="16" height="8" rx="1"/><line x1="9" y1="10" x2="9" y2="14"/><line x1="15" y1="10" x2="15" y2="14"/></svg>
|
|
220
223
|
</button>
|
|
221
224
|
`:""}
|
|
222
|
-
${
|
|
223
|
-
${
|
|
225
|
+
${this._tableCellToolbar.cellCol===0?l.html`
|
|
226
|
+
${this._tableCellToolbar.cellRow!==0?l.html`<div style="width:1px;height:20px;background:#e3e3e3;margin:0 4px;"></div>`:""}
|
|
224
227
|
<button class="table-cell-toolbar-btn" title="左侧添加列" @click=${this._addTableColumnLeft}>
|
|
225
228
|
<svg viewBox="0 0 24 24" width="16" height="16" stroke="currentColor" stroke-width="2" fill="none"><rect x="8" y="4" width="8" height="16" rx="1"/><line x1="3" y1="12" x2="7" y2="12"/><line x1="5" y1="10" x2="5" y2="14"/></svg>
|
|
226
229
|
</button>
|
|
@@ -231,7 +234,7 @@
|
|
|
231
234
|
<svg viewBox="0 0 24 24" width="16" height="16" stroke="currentColor" stroke-width="2" fill="none"><rect x="8" y="4" width="8" height="16" rx="1"/><line x1="10" y1="9" x2="14" y2="9"/><line x1="10" y1="15" x2="14" y2="15"/></svg>
|
|
232
235
|
</button>
|
|
233
236
|
`:""}
|
|
234
|
-
${
|
|
237
|
+
${this._tableCellToolbar.cellRow===0&&this._tableCellToolbar.cellCol===0?l.html`
|
|
235
238
|
<div style="width:1px;height:20px;background:#e3e3e3;margin:0 4px;"></div>
|
|
236
239
|
<button class="table-cell-toolbar-btn danger" title="删除表格" @click=${this._deleteTable}>
|
|
237
240
|
<svg viewBox="0 0 24 24" width="16" height="16" stroke="currentColor" stroke-width="2" fill="none"><polyline points="3 6 5 6 21 6"/><path d="M19 6v14a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2V6m3 0V4a2 2 0 0 1 2-2h4a2 2 0 0 1 2 2v2"/></svg>
|
|
@@ -241,24 +244,24 @@
|
|
|
241
244
|
`:""}
|
|
242
245
|
|
|
243
246
|
<!-- Image Toolbar -->
|
|
244
|
-
${"slash"
|
|
247
|
+
${this._toolbarModeValue==="slash"&&this._imageToolbar.visible?l.html`
|
|
245
248
|
<div
|
|
246
249
|
class="image-toolbar"
|
|
247
250
|
style="left: ${this._imageToolbar.x}px; top: ${this._imageToolbar.y}px;"
|
|
248
|
-
@mousedown=${
|
|
251
|
+
@mousedown=${o=>o.preventDefault()}
|
|
249
252
|
>
|
|
250
253
|
${this._renderImageControls()}
|
|
251
254
|
</div>
|
|
252
255
|
`:""}
|
|
253
256
|
</div>
|
|
254
|
-
`}_renderTableGrid(){const e=[];for(let t=0;t<100;t++){const i=Math.floor(t/10)+1,o=t%10+1,r=this._hoverRow>0&&i<=this._hoverRow&&o<=this._hoverCol;e.push(
|
|
257
|
+
`}_renderTableGrid(){const e=[];for(let t=0;t<100;t++){const i=Math.floor(t/10)+1,o=t%10+1,r=this._hoverRow>0&&i<=this._hoverRow&&o<=this._hoverCol;e.push(l.html`
|
|
255
258
|
<div
|
|
256
259
|
class="table-cell ${r?"selected":""}"
|
|
257
260
|
@click=${()=>{this._insertTableByClick(i,o),this._tableDropdownOpen=!1}}
|
|
258
261
|
@mouseenter=${()=>{this._hoverRow=i,this._hoverCol=o}}
|
|
259
262
|
@mouseleave=${()=>{this._hoverRow=0,this._hoverCol=0}}
|
|
260
263
|
></div>
|
|
261
|
-
`)}return e}}
|
|
264
|
+
`)}return e}};exports.QxsBlocksuiteEditor.styles=l.css`
|
|
262
265
|
:host {
|
|
263
266
|
display: block;
|
|
264
267
|
font-family: inherit;
|
|
@@ -854,8 +857,16 @@
|
|
|
854
857
|
fill: none;
|
|
855
858
|
}
|
|
856
859
|
|
|
860
|
+
/* Keep the file input programmatically clickable inside shadow hosts. */
|
|
857
861
|
.image-input {
|
|
858
|
-
|
|
862
|
+
position: absolute;
|
|
863
|
+
inset: 0 auto auto 0;
|
|
864
|
+
width: 1px;
|
|
865
|
+
height: 1px;
|
|
866
|
+
padding: 0;
|
|
867
|
+
margin: 0;
|
|
868
|
+
opacity: 0;
|
|
869
|
+
pointer-events: none;
|
|
859
870
|
}
|
|
860
871
|
|
|
861
872
|
.table-grid-preview {
|
|
@@ -1111,5 +1122,5 @@
|
|
|
1111
1122
|
outline: 2px solid var(--qxs-color-primary, #3D61E3);
|
|
1112
1123
|
outline-offset: 2px;
|
|
1113
1124
|
}
|
|
1114
|
-
|
|
1125
|
+
`;a([d.property({type:String,attribute:"content"})],exports.QxsBlocksuiteEditor.prototype,"content",2);a([d.property({type:String,attribute:"model-value"})],exports.QxsBlocksuiteEditor.prototype,"model-value",2);a([d.property({type:String,attribute:"placeholder"})],exports.QxsBlocksuiteEditor.prototype,"placeholder",2);a([d.property({type:String,attribute:"toolbar-mode"})],exports.QxsBlocksuiteEditor.prototype,"toolbar-mode",2);a([d.property({attribute:"toolbar"})],exports.QxsBlocksuiteEditor.prototype,"toolbar",2);a([d.property({type:String,attribute:"toolbar-preset"})],exports.QxsBlocksuiteEditor.prototype,"toolbar-preset",2);a([d.property({attribute:"header-toolbar-labels"})],exports.QxsBlocksuiteEditor.prototype,"header-toolbar-labels",2);a([d.property({type:String,attribute:"header-always-visible"})],exports.QxsBlocksuiteEditor.prototype,"header-always-visible",2);a([d.property({type:String,attribute:"use-model"})],exports.QxsBlocksuiteEditor.prototype,"use-model",2);a([d.property({type:String,attribute:"readonly"})],exports.QxsBlocksuiteEditor.prototype,"readonly",2);a([d.property({type:String,attribute:"preview"})],exports.QxsBlocksuiteEditor.prototype,"preview",2);a([d.property({attribute:"editable"})],exports.QxsBlocksuiteEditor.prototype,"editable",2);a([d.property({type:String,attribute:"min-height"})],exports.QxsBlocksuiteEditor.prototype,"min-height",2);a([d.property({type:String,attribute:"max-height"})],exports.QxsBlocksuiteEditor.prototype,"max-height",2);a([d.property({type:String,attribute:"show-character-count"})],exports.QxsBlocksuiteEditor.prototype,"show-character-count",2);a([d.property({type:String,attribute:"toolbar-position"})],exports.QxsBlocksuiteEditor.prototype,"toolbar-position",2);a([d.property({type:String,attribute:"custom-styles"})],exports.QxsBlocksuiteEditor.prototype,"custom-styles",2);a([d.property({type:String,attribute:"content-format"})],exports.QxsBlocksuiteEditor.prototype,"content-format",2);a([d.property({type:Object,attribute:"deserialize-content"})],exports.QxsBlocksuiteEditor.prototype,"deserialize-content",2);a([d.property({type:Object,attribute:"serialize-content"})],exports.QxsBlocksuiteEditor.prototype,"serialize-content",2);a([d.property({type:Object,attribute:"upload-image"})],exports.QxsBlocksuiteEditor.prototype,"upload-image",2);a([d.state()],exports.QxsBlocksuiteEditor.prototype,"_editor",2);a([d.state()],exports.QxsBlocksuiteEditor.prototype,"_hoverRow",2);a([d.state()],exports.QxsBlocksuiteEditor.prototype,"_hoverCol",2);a([d.state()],exports.QxsBlocksuiteEditor.prototype,"_tableDropdownOpen",2);a([d.state()],exports.QxsBlocksuiteEditor.prototype,"_tableCellToolbar",2);a([d.state()],exports.QxsBlocksuiteEditor.prototype,"_imageToolbar",2);a([d.state()],exports.QxsBlocksuiteEditor.prototype,"_linkEditor",2);a([d.state()],exports.QxsBlocksuiteEditor.prototype,"_isEditorFocused",2);a([d.state()],exports.QxsBlocksuiteEditor.prototype,"_selectedImage",2);exports.QxsBlocksuiteEditor=a([te.safeCustomElement("qxs-blocksuite-editor")],exports.QxsBlocksuiteEditor);
|
|
1115
1126
|
//# sourceMappingURL=blocksuite-editor.cjs.map
|