@opentiny/fluent-editor 4.0.0-alpha.0 → 4.0.0-alpha.10
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/README.md +88 -105
- package/es/attributors/line-height.es.js.map +1 -1
- package/es/config/base64-image.es.js.map +1 -1
- package/es/config/editor.config.es.js +0 -7
- package/es/config/editor.config.es.js.map +1 -1
- package/es/config/editor.utils.es.js +0 -2
- package/es/config/editor.utils.es.js.map +1 -1
- package/es/config/i18n/en-us.es.js +0 -13
- package/es/config/i18n/en-us.es.js.map +1 -1
- package/es/config/i18n/zh-cn.es.js +0 -13
- package/es/config/i18n/zh-cn.es.js.map +1 -1
- package/es/config/index.es.js +8 -13
- package/es/config/index.es.js.map +1 -1
- package/es/config/types/index.es.js +0 -20
- package/es/config/types/index.es.js.map +1 -1
- package/es/core/fluent-editor.es.js +7 -5
- package/es/core/fluent-editor.es.js.map +1 -1
- package/es/fluent-editor.es.js +38 -22
- package/es/fluent-editor.es.js.map +1 -1
- package/es/formats/emoji.es.js +14 -0
- package/es/formats/emoji.es.js.map +1 -0
- package/es/formats/index.es.js +11 -0
- package/es/formats/index.es.js.map +1 -0
- package/es/formats/soft-break.es.js +12 -5
- package/es/formats/soft-break.es.js.map +1 -1
- package/es/formats/strike.es.js +8 -5
- package/es/formats/strike.es.js.map +1 -1
- package/es/formats/video.es.js +14 -10
- package/es/formats/video.es.js.map +1 -1
- package/es/index.es.js +94 -32
- package/es/index.es.js.map +1 -1
- package/es/modules/ai/constants.es.js +50 -0
- package/es/modules/ai/constants.es.js.map +1 -0
- package/es/modules/ai/icons.es.js +319 -0
- package/es/modules/ai/icons.es.js.map +1 -0
- package/es/modules/ai/index.es.js +670 -0
- package/es/modules/ai/index.es.js.map +1 -0
- package/es/modules/collaborative-editing/awareness/awareness.es.js +93 -0
- package/es/modules/collaborative-editing/awareness/awareness.es.js.map +1 -0
- package/es/modules/collaborative-editing/awareness/index.es.js +8 -0
- package/es/modules/{emoji/emoji-list → collaborative-editing/awareness}/index.es.js.map +1 -1
- package/es/modules/collaborative-editing/awareness/y-indexeddb.es.js +12 -0
- package/es/modules/collaborative-editing/awareness/y-indexeddb.es.js.map +1 -0
- package/es/modules/collaborative-editing/collaborative-editing.es.js +105 -0
- package/es/modules/collaborative-editing/collaborative-editing.es.js.map +1 -0
- package/es/modules/collaborative-editing/index.es.js +6 -0
- package/es/modules/collaborative-editing/index.es.js.map +1 -0
- package/es/modules/collaborative-editing/module.es.js +35 -0
- package/es/modules/collaborative-editing/module.es.js.map +1 -0
- package/es/modules/collaborative-editing/provider/providerRegistry.es.js +28 -0
- package/es/modules/collaborative-editing/provider/providerRegistry.es.js.map +1 -0
- package/es/modules/collaborative-editing/provider/webrtc.es.js +99 -0
- package/es/modules/collaborative-editing/provider/webrtc.es.js.map +1 -0
- package/es/modules/collaborative-editing/provider/websocket.es.js +111 -0
- package/es/modules/collaborative-editing/provider/websocket.es.js.map +1 -0
- package/es/modules/collaborative-editing/types.es.js +2 -0
- package/es/modules/collaborative-editing/types.es.js.map +1 -0
- package/es/modules/counter.es.js +8 -3
- package/es/modules/counter.es.js.map +1 -1
- package/es/modules/custom-clipboard.es.js +23 -27
- package/es/modules/custom-clipboard.es.js.map +1 -1
- package/es/modules/custom-image/actions/action.es.js +19 -0
- package/es/modules/custom-image/actions/action.es.js.map +1 -0
- package/es/modules/custom-image/actions/{CustomResizeAction.es.js → custom-resize-action.es.js} +24 -11
- package/es/modules/custom-image/actions/custom-resize-action.es.js.map +1 -0
- package/es/modules/custom-image/actions/{DeleteAction.es.js → delete-action.es.js} +8 -5
- package/es/modules/custom-image/actions/delete-action.es.js.map +1 -0
- package/es/modules/custom-image/actions/image-toolbar-buttons.es.js +137 -0
- package/es/modules/custom-image/actions/image-toolbar-buttons.es.js.map +1 -0
- package/es/modules/custom-image/actions/index.es.js +18 -0
- package/es/modules/custom-image/actions/index.es.js.map +1 -0
- package/es/modules/custom-image/actions/toolbar-action.es.js +33 -0
- package/es/modules/custom-image/actions/toolbar-action.es.js.map +1 -0
- package/es/modules/custom-image/actions/toolbar.es.js +110 -0
- package/es/modules/custom-image/actions/toolbar.es.js.map +1 -0
- package/es/modules/custom-image/{BlotFormatter.es.js → blot-formatter.es.js} +27 -50
- package/es/modules/custom-image/blot-formatter.es.js.map +1 -0
- package/es/modules/custom-image/image.es.js +41 -21
- package/es/modules/custom-image/image.es.js.map +1 -1
- package/es/modules/custom-image/index.es.js +9 -0
- package/es/modules/custom-image/index.es.js.map +1 -0
- package/es/modules/custom-image/options.es.js +88 -0
- package/es/modules/custom-image/options.es.js.map +1 -0
- package/es/modules/custom-image/specs/blot-spec.es.js +33 -0
- package/es/modules/custom-image/specs/blot-spec.es.js.map +1 -0
- package/es/modules/custom-image/specs/{CustomImageSpec.es.js → custom-image-spec.es.js} +13 -14
- package/es/modules/custom-image/specs/custom-image-spec.es.js.map +1 -0
- package/es/modules/custom-image/specs/image-spec.es.js +32 -0
- package/es/modules/custom-image/specs/image-spec.es.js.map +1 -0
- package/es/modules/custom-image/specs/index.es.js +9 -0
- package/es/modules/custom-image/specs/index.es.js.map +1 -0
- package/es/modules/custom-uploader.es.js +63 -194
- package/es/modules/custom-uploader.es.js.map +1 -1
- package/es/modules/divider.es.js +8 -7
- package/es/modules/divider.es.js.map +1 -1
- package/es/modules/emoji.es.js +167 -0
- package/es/modules/emoji.es.js.map +1 -0
- package/es/modules/file/formats/file.es.js +13 -13
- package/es/modules/file/formats/file.es.js.map +1 -1
- package/es/modules/file/index.es.js +6 -29
- package/es/modules/file/index.es.js.map +1 -1
- package/es/modules/file/modules/file-bar.es.js +11 -3
- package/es/modules/file/modules/file-bar.es.js.map +1 -1
- package/es/modules/file/modules/file-module.es.js +35 -0
- package/es/modules/file/modules/file-module.es.js.map +1 -0
- package/es/modules/i18n.es.js +33 -11
- package/es/modules/i18n.es.js.map +1 -1
- package/es/modules/index.es.js +27 -0
- package/es/modules/index.es.js.map +1 -0
- package/es/modules/link/formats/link.es.js +14 -10
- package/es/modules/link/formats/link.es.js.map +1 -1
- package/es/modules/link/index.es.js +4 -12
- package/es/modules/link/index.es.js.map +1 -1
- package/es/modules/link/modules/tooltip.es.js +31 -21
- package/es/modules/link/modules/tooltip.es.js.map +1 -1
- package/es/modules/mathlive/formats.es.js +10 -7
- package/es/modules/mathlive/formats.es.js.map +1 -1
- package/es/modules/mathlive/index.es.js +6 -30
- package/es/modules/mathlive/index.es.js.map +1 -1
- package/es/modules/mathlive/module.es.js +40 -0
- package/es/modules/mathlive/module.es.js.map +1 -0
- package/es/modules/mathlive/tooltip.es.js +9 -5
- package/es/modules/mathlive/tooltip.es.js.map +1 -1
- package/es/modules/mention/constants.es.js.map +1 -1
- package/es/modules/mention/index.es.js +7 -0
- package/es/modules/mention/index.es.js.map +1 -0
- package/es/modules/mention/{MentionLink.es.js → mention-link.es.js} +14 -6
- package/es/modules/mention/mention-link.es.js.map +1 -0
- package/es/modules/mention/{Mention.es.js → mention.es.js} +28 -20
- package/es/modules/mention/mention.es.js.map +1 -0
- package/es/modules/shortcut-key/index.es.js +17 -1
- package/es/modules/shortcut-key/index.es.js.map +1 -1
- package/es/modules/syntax.es.js +4 -0
- package/es/modules/syntax.es.js.map +1 -1
- package/es/modules/table-up/index.es.js +21 -8
- package/es/modules/table-up/index.es.js.map +1 -1
- package/es/modules/toolbar/better-picker.es.js +5 -0
- package/es/modules/toolbar/better-picker.es.js.map +1 -1
- package/es/modules/toolbar/better-toolbar.es.js +138 -0
- package/es/modules/toolbar/better-toolbar.es.js.map +1 -0
- package/es/modules/toolbar/index.es.js +5 -135
- package/es/modules/toolbar/index.es.js.map +1 -1
- package/es/modules/toolbar/toolbar-tip.es.js +6 -1
- package/es/modules/toolbar/toolbar-tip.es.js.map +1 -1
- package/es/themes/snow.es.js +32 -15
- package/es/themes/snow.es.js.map +1 -1
- package/es/tools/format-painter.es.js +8 -2
- package/es/tools/format-painter.es.js.map +1 -1
- package/es/tools/fullscreen.es.js.map +1 -1
- package/es/tools/screenshot.es.js.map +1 -1
- package/es/ui/icons.config.es.js +53 -0
- package/es/ui/icons.config.es.js.map +1 -1
- package/es/ui/icons.es.js +2 -1
- package/es/ui/icons.es.js.map +1 -1
- package/es/utils/debounce.es.js.map +1 -1
- package/es/utils/is.es.js +4 -0
- package/es/utils/is.es.js.map +1 -1
- package/es/utils/method.es.js.map +1 -1
- package/lib/attributors/line-height.cjs.js.map +1 -1
- package/lib/config/base64-image.cjs.js.map +1 -1
- package/lib/config/editor.config.cjs.js +0 -7
- package/lib/config/editor.config.cjs.js.map +1 -1
- package/lib/config/editor.utils.cjs.js +0 -2
- package/lib/config/editor.utils.cjs.js.map +1 -1
- package/lib/config/i18n/en-us.cjs.js +0 -13
- package/lib/config/i18n/en-us.cjs.js.map +1 -1
- package/lib/config/i18n/zh-cn.cjs.js +0 -13
- package/lib/config/i18n/zh-cn.cjs.js.map +1 -1
- package/lib/config/index.cjs.js +6 -11
- package/lib/config/index.cjs.js.map +1 -1
- package/lib/config/types/index.cjs.js +0 -20
- package/lib/config/types/index.cjs.js.map +1 -1
- package/lib/core/fluent-editor.cjs.js +6 -4
- package/lib/core/fluent-editor.cjs.js.map +1 -1
- package/lib/fluent-editor.cjs.js +46 -30
- package/lib/fluent-editor.cjs.js.map +1 -1
- package/lib/formats/emoji.cjs.js +14 -0
- package/lib/formats/emoji.cjs.js.map +1 -0
- package/lib/formats/index.cjs.js +11 -0
- package/lib/formats/index.cjs.js.map +1 -0
- package/lib/formats/soft-break.cjs.js +13 -6
- package/lib/formats/soft-break.cjs.js.map +1 -1
- package/lib/formats/strike.cjs.js +9 -6
- package/lib/formats/strike.cjs.js.map +1 -1
- package/lib/formats/video.cjs.js +15 -11
- package/lib/formats/video.cjs.js.map +1 -1
- package/lib/index.cjs.js +114 -34
- package/lib/index.cjs.js.map +1 -1
- package/lib/modules/ai/constants.cjs.js +50 -0
- package/lib/modules/ai/constants.cjs.js.map +1 -0
- package/lib/modules/ai/icons.cjs.js +319 -0
- package/lib/modules/ai/icons.cjs.js.map +1 -0
- package/lib/modules/ai/index.cjs.js +670 -0
- package/lib/modules/ai/index.cjs.js.map +1 -0
- package/lib/modules/collaborative-editing/awareness/awareness.cjs.js +110 -0
- package/lib/modules/collaborative-editing/awareness/awareness.cjs.js.map +1 -0
- package/lib/modules/collaborative-editing/awareness/index.cjs.js +8 -0
- package/lib/modules/collaborative-editing/awareness/index.cjs.js.map +1 -0
- package/lib/modules/collaborative-editing/awareness/y-indexeddb.cjs.js +12 -0
- package/lib/modules/collaborative-editing/awareness/y-indexeddb.cjs.js.map +1 -0
- package/lib/modules/collaborative-editing/collaborative-editing.cjs.js +122 -0
- package/lib/modules/collaborative-editing/collaborative-editing.cjs.js.map +1 -0
- package/lib/modules/collaborative-editing/index.cjs.js +6 -0
- package/lib/modules/{emoji/emoji-list → collaborative-editing}/index.cjs.js.map +1 -1
- package/lib/modules/collaborative-editing/module.cjs.js +35 -0
- package/lib/modules/collaborative-editing/module.cjs.js.map +1 -0
- package/lib/modules/collaborative-editing/provider/providerRegistry.cjs.js +28 -0
- package/lib/modules/collaborative-editing/provider/providerRegistry.cjs.js.map +1 -0
- package/lib/modules/collaborative-editing/provider/webrtc.cjs.js +116 -0
- package/lib/modules/collaborative-editing/provider/webrtc.cjs.js.map +1 -0
- package/lib/modules/collaborative-editing/provider/websocket.cjs.js +128 -0
- package/lib/modules/collaborative-editing/provider/websocket.cjs.js.map +1 -0
- package/lib/modules/collaborative-editing/types.cjs.js +2 -0
- package/lib/modules/collaborative-editing/types.cjs.js.map +1 -0
- package/lib/modules/counter.cjs.js +8 -3
- package/lib/modules/counter.cjs.js.map +1 -1
- package/lib/modules/custom-clipboard.cjs.js +23 -27
- package/lib/modules/custom-clipboard.cjs.js.map +1 -1
- package/lib/modules/custom-image/actions/action.cjs.js +19 -0
- package/lib/modules/custom-image/actions/action.cjs.js.map +1 -0
- package/lib/modules/custom-image/actions/{CustomResizeAction.cjs.js → custom-resize-action.cjs.js} +26 -13
- package/lib/modules/custom-image/actions/custom-resize-action.cjs.js.map +1 -0
- package/lib/modules/custom-image/actions/{DeleteAction.cjs.js → delete-action.cjs.js} +10 -7
- package/lib/modules/custom-image/actions/delete-action.cjs.js.map +1 -0
- package/lib/modules/custom-image/actions/image-toolbar-buttons.cjs.js +137 -0
- package/lib/modules/custom-image/actions/image-toolbar-buttons.cjs.js.map +1 -0
- package/lib/modules/custom-image/actions/index.cjs.js +18 -0
- package/lib/modules/custom-image/actions/index.cjs.js.map +1 -0
- package/lib/modules/custom-image/actions/toolbar-action.cjs.js +33 -0
- package/lib/modules/custom-image/actions/toolbar-action.cjs.js.map +1 -0
- package/lib/modules/custom-image/actions/toolbar.cjs.js +110 -0
- package/lib/modules/custom-image/actions/toolbar.cjs.js.map +1 -0
- package/lib/modules/custom-image/{BlotFormatter.cjs.js → blot-formatter.cjs.js} +28 -51
- package/lib/modules/custom-image/blot-formatter.cjs.js.map +1 -0
- package/lib/modules/custom-image/image.cjs.js +42 -22
- package/lib/modules/custom-image/image.cjs.js.map +1 -1
- package/lib/modules/custom-image/index.cjs.js +9 -0
- package/lib/modules/custom-image/index.cjs.js.map +1 -0
- package/lib/modules/custom-image/options.cjs.js +88 -0
- package/lib/modules/custom-image/options.cjs.js.map +1 -0
- package/lib/modules/custom-image/specs/blot-spec.cjs.js +33 -0
- package/lib/modules/custom-image/specs/blot-spec.cjs.js.map +1 -0
- package/lib/modules/custom-image/specs/{CustomImageSpec.cjs.js → custom-image-spec.cjs.js} +14 -15
- package/lib/modules/custom-image/specs/custom-image-spec.cjs.js.map +1 -0
- package/lib/modules/custom-image/specs/image-spec.cjs.js +32 -0
- package/lib/modules/custom-image/specs/image-spec.cjs.js.map +1 -0
- package/lib/modules/custom-image/specs/index.cjs.js +9 -0
- package/lib/modules/custom-image/specs/index.cjs.js.map +1 -0
- package/lib/modules/custom-uploader.cjs.js +64 -195
- package/lib/modules/custom-uploader.cjs.js.map +1 -1
- package/lib/modules/divider.cjs.js +9 -8
- package/lib/modules/divider.cjs.js.map +1 -1
- package/lib/modules/emoji.cjs.js +167 -0
- package/lib/modules/emoji.cjs.js.map +1 -0
- package/lib/modules/file/formats/file.cjs.js +14 -14
- package/lib/modules/file/formats/file.cjs.js.map +1 -1
- package/lib/modules/file/index.cjs.js +5 -28
- package/lib/modules/file/index.cjs.js.map +1 -1
- package/lib/modules/file/modules/file-bar.cjs.js +12 -4
- package/lib/modules/file/modules/file-bar.cjs.js.map +1 -1
- package/lib/modules/file/modules/file-module.cjs.js +35 -0
- package/lib/modules/file/modules/file-module.cjs.js.map +1 -0
- package/lib/modules/i18n.cjs.js +32 -10
- package/lib/modules/i18n.cjs.js.map +1 -1
- package/lib/modules/index.cjs.js +27 -0
- package/lib/modules/index.cjs.js.map +1 -0
- package/lib/modules/link/formats/link.cjs.js +15 -11
- package/lib/modules/link/formats/link.cjs.js.map +1 -1
- package/lib/modules/link/index.cjs.js +4 -12
- package/lib/modules/link/index.cjs.js.map +1 -1
- package/lib/modules/link/modules/tooltip.cjs.js +30 -20
- package/lib/modules/link/modules/tooltip.cjs.js.map +1 -1
- package/lib/modules/mathlive/formats.cjs.js +11 -8
- package/lib/modules/mathlive/formats.cjs.js.map +1 -1
- package/lib/modules/mathlive/index.cjs.js +5 -29
- package/lib/modules/mathlive/index.cjs.js.map +1 -1
- package/lib/modules/mathlive/module.cjs.js +40 -0
- package/lib/modules/mathlive/module.cjs.js.map +1 -0
- package/lib/modules/mathlive/tooltip.cjs.js +10 -6
- package/lib/modules/mathlive/tooltip.cjs.js.map +1 -1
- package/lib/modules/mention/constants.cjs.js.map +1 -1
- package/lib/modules/mention/index.cjs.js +7 -0
- package/lib/modules/mention/index.cjs.js.map +1 -0
- package/lib/modules/mention/{MentionLink.cjs.js → mention-link.cjs.js} +15 -7
- package/lib/modules/mention/mention-link.cjs.js.map +1 -0
- package/lib/modules/mention/{Mention.cjs.js → mention.cjs.js} +30 -22
- package/lib/modules/mention/mention.cjs.js.map +1 -0
- package/lib/modules/shortcut-key/index.cjs.js +16 -0
- package/lib/modules/shortcut-key/index.cjs.js.map +1 -1
- package/lib/modules/syntax.cjs.js +4 -0
- package/lib/modules/syntax.cjs.js.map +1 -1
- package/lib/modules/table-up/index.cjs.js +21 -8
- package/lib/modules/table-up/index.cjs.js.map +1 -1
- package/lib/modules/toolbar/better-picker.cjs.js +5 -0
- package/lib/modules/toolbar/better-picker.cjs.js.map +1 -1
- package/lib/modules/toolbar/better-toolbar.cjs.js +138 -0
- package/lib/modules/toolbar/better-toolbar.cjs.js.map +1 -0
- package/lib/modules/toolbar/index.cjs.js +6 -136
- package/lib/modules/toolbar/index.cjs.js.map +1 -1
- package/lib/modules/toolbar/toolbar-tip.cjs.js +6 -1
- package/lib/modules/toolbar/toolbar-tip.cjs.js.map +1 -1
- package/lib/themes/snow.cjs.js +33 -16
- package/lib/themes/snow.cjs.js.map +1 -1
- package/lib/tools/format-painter.cjs.js +8 -2
- package/lib/tools/format-painter.cjs.js.map +1 -1
- package/lib/tools/fullscreen.cjs.js.map +1 -1
- package/lib/tools/screenshot.cjs.js.map +1 -1
- package/lib/ui/icons.cjs.js +1 -0
- package/lib/ui/icons.cjs.js.map +1 -1
- package/lib/ui/icons.config.cjs.js +53 -0
- package/lib/ui/icons.config.cjs.js.map +1 -1
- package/lib/utils/debounce.cjs.js.map +1 -1
- package/lib/utils/is.cjs.js +4 -0
- package/lib/utils/is.cjs.js.map +1 -1
- package/lib/utils/method.cjs.js.map +1 -1
- package/package.json +68 -59
- package/style.css +2359 -2251
- package/types/attributors/font-size.d.ts +1 -1
- package/types/attributors/font-style.d.ts +1 -1
- package/types/attributors/index.d.ts +4 -4
- package/types/attributors/line-height.d.ts +1 -1
- package/types/attributors/text-indent.d.ts +1 -1
- package/types/config/base64-image.d.ts +2 -2
- package/types/config/editor.config.d.ts +11 -285
- package/types/config/editor.utils.d.ts +40 -41
- package/types/config/i18n/en-us.d.ts +123 -136
- package/types/config/i18n/zh-cn.d.ts +123 -136
- package/types/config/index.d.ts +7 -6
- package/types/config/types/editor-config.interface.d.ts +11 -35
- package/types/config/types/editor-modules.interface.d.ts +41 -31
- package/types/config/types/index.d.ts +3 -23
- package/types/config/types/type.d.ts +2 -6
- package/types/core/fluent-editor.d.ts +11 -11
- package/types/fluent-editor.d.ts +1 -2
- package/types/formats/emoji.d.ts +8 -0
- package/types/formats/index.d.ts +4 -0
- package/types/formats/soft-break.d.ts +12 -14
- package/types/formats/strike.d.ts +8 -7
- package/types/formats/video.d.ts +13 -16
- package/types/index.d.ts +7 -6
- package/types/modules/ai/constants.d.ts +30 -0
- package/types/modules/ai/icons.d.ts +21 -0
- package/types/modules/ai/index.d.ts +96 -0
- package/types/modules/ai/types.d.ts +16 -0
- package/types/modules/collaborative-editing/awareness/awareness.d.ts +28 -0
- package/types/modules/collaborative-editing/awareness/index.d.ts +2 -0
- package/types/modules/collaborative-editing/awareness/y-indexeddb.d.ts +2 -0
- package/types/modules/collaborative-editing/collaborative-editing.d.ts +24 -0
- package/types/modules/collaborative-editing/index.d.ts +2 -0
- package/types/modules/collaborative-editing/module.d.ts +11 -0
- package/types/modules/collaborative-editing/provider/index.d.ts +3 -0
- package/types/modules/collaborative-editing/provider/providerRegistry.d.ts +25 -0
- package/types/modules/collaborative-editing/provider/webrtc.d.ts +36 -0
- package/types/modules/collaborative-editing/provider/websocket.d.ts +40 -0
- package/types/modules/collaborative-editing/types.d.ts +37 -0
- package/types/modules/counter.d.ts +22 -16
- package/types/modules/custom-clipboard.d.ts +23 -27
- package/types/modules/custom-image/actions/action.d.ts +8 -0
- package/types/modules/custom-image/actions/{CustomResizeAction.d.ts → custom-resize-action.d.ts} +23 -24
- package/types/modules/custom-image/actions/delete-action.d.ts +6 -0
- package/types/modules/custom-image/actions/image-toolbar-buttons.d.ts +16 -0
- package/types/modules/custom-image/actions/index.d.ts +6 -0
- package/types/modules/custom-image/actions/toolbar-action.d.ts +11 -0
- package/types/modules/custom-image/actions/toolbar.d.ts +19 -0
- package/types/modules/custom-image/blot-formatter.d.ts +23 -0
- package/types/modules/custom-image/image.d.ts +28 -28
- package/types/modules/custom-image/index.d.ts +4 -0
- package/types/modules/custom-image/options.d.ts +47 -0
- package/types/modules/custom-image/specs/blot-spec.d.ts +12 -0
- package/types/modules/custom-image/specs/{CustomImageSpec.d.ts → custom-image-spec.d.ts} +17 -21
- package/types/modules/custom-image/specs/image-spec.d.ts +8 -0
- package/types/modules/custom-image/specs/index.d.ts +3 -0
- package/types/modules/custom-uploader.d.ts +40 -31
- package/types/modules/divider.d.ts +8 -7
- package/types/modules/emoji.d.ts +39 -0
- package/types/modules/file/formats/file.d.ts +18 -15
- package/types/modules/file/index.d.ts +3 -11
- package/types/modules/file/modules/file-bar.d.ts +14 -14
- package/types/modules/file/modules/file-module.d.ts +9 -0
- package/types/modules/i18n.d.ts +13 -15
- package/types/modules/index.d.ts +16 -0
- package/types/modules/link/formats/link.d.ts +14 -15
- package/types/modules/link/index.d.ts +2 -6
- package/types/modules/link/modules/tooltip.d.ts +26 -32
- package/types/modules/mathlive/formats.d.ts +20 -21
- package/types/modules/mathlive/index.d.ts +3 -9
- package/types/modules/mathlive/module.d.ts +9 -0
- package/types/modules/mathlive/tooltip.d.ts +14 -15
- package/types/modules/mention/constants.d.ts +3 -3
- package/types/modules/mention/index.d.ts +2 -0
- package/types/modules/mention/{MentionLink.d.ts → mention-link.d.ts} +15 -15
- package/types/modules/mention/{Mention.d.ts → mention.d.ts} +52 -54
- package/types/modules/shortcut-key/index.d.ts +67 -93
- package/types/modules/syntax.d.ts +12 -13
- package/types/modules/table-up/index.d.ts +32 -64
- package/types/modules/toolbar/better-picker.d.ts +13 -14
- package/types/modules/toolbar/better-toolbar.d.ts +7 -0
- package/types/modules/toolbar/index.d.ts +3 -9
- package/types/modules/toolbar/toolbar-tip.d.ts +7 -8
- package/types/themes/snow.d.ts +9 -10
- package/types/tools/format-painter.d.ts +12 -14
- package/types/tools/fullscreen.d.ts +6 -3
- package/types/tools/screenshot.d.ts +17 -18
- package/types/ui/icons.config.d.ts +38 -36
- package/types/ui/icons.d.ts +6 -6
- package/types/utils/debounce.d.ts +6 -6
- package/types/utils/image.d.ts +1 -1
- package/types/utils/is.d.ts +6 -4
- package/types/utils/method.d.ts +6 -6
- package/types/utils/scroll-lock.d.ts +6 -6
- package/es/config/types/additional-toolbar-item.interface.es.js +0 -2
- package/es/config/types/additional-toolbar-item.interface.es.js.map +0 -1
- package/es/config/types/content-change.interface.es.js +0 -2
- package/es/config/types/content-change.interface.es.js.map +0 -1
- package/es/config/types/content-save.interface.es.js +0 -2
- package/es/config/types/content-save.interface.es.js.map +0 -1
- package/es/config/types/counter-option.interface.es.js +0 -2
- package/es/config/types/counter-option.interface.es.js.map +0 -1
- package/es/config/types/editor-toolbar.interface.es.js +0 -2
- package/es/config/types/editor-toolbar.interface.es.js.map +0 -1
- package/es/config/types/file-operation.interface.es.js +0 -2
- package/es/config/types/file-operation.interface.es.js.map +0 -1
- package/es/config/types/focus-change.interface.es.js +0 -2
- package/es/config/types/focus-change.interface.es.js.map +0 -1
- package/es/config/types/fullscreen-module.interface.es.js +0 -2
- package/es/config/types/fullscreen-module.interface.es.js.map +0 -1
- package/es/config/types/help-panel-item.interface.es.js +0 -2
- package/es/config/types/help-panel-item.interface.es.js.map +0 -1
- package/es/config/types/help-panel-option.interface.es.js +0 -2
- package/es/config/types/help-panel-option.interface.es.js.map +0 -1
- package/es/config/types/image-module.interface.es.js +0 -2
- package/es/config/types/image-module.interface.es.js.map +0 -1
- package/es/config/types/image-upload.interface.es.js +0 -2
- package/es/config/types/image-upload.interface.es.js.map +0 -1
- package/es/config/types/load-on-demand-module.interface.es.js +0 -2
- package/es/config/types/load-on-demand-module.interface.es.js.map +0 -1
- package/es/config/types/mention-module.interface.es.js +0 -2
- package/es/config/types/mention-module.interface.es.js.map +0 -1
- package/es/config/types/paste-change.interface.es.js +0 -2
- package/es/config/types/paste-change.interface.es.js.map +0 -1
- package/es/config/types/quick-menu-module.interface.es.js +0 -2
- package/es/config/types/quick-menu-module.interface.es.js.map +0 -1
- package/es/config/types/range.interface.es.js +0 -2
- package/es/config/types/range.interface.es.js.map +0 -1
- package/es/config/types/registry-options.interface.es.js +0 -2
- package/es/config/types/registry-options.interface.es.js.map +0 -1
- package/es/config/types/selection-change.interface.es.js +0 -2
- package/es/config/types/selection-change.interface.es.js.map +0 -1
- package/es/config/types/toolbar-item.interface.es.js +0 -2
- package/es/config/types/toolbar-item.interface.es.js.map +0 -1
- package/es/config/types/validate-error.interface.es.js +0 -2
- package/es/config/types/validate-error.interface.es.js.map +0 -1
- package/es/modules/custom-image/BlotFormatter.es.js.map +0 -1
- package/es/modules/custom-image/Options.es.js +0 -95
- package/es/modules/custom-image/Options.es.js.map +0 -1
- package/es/modules/custom-image/actions/Action.es.js +0 -15
- package/es/modules/custom-image/actions/Action.es.js.map +0 -1
- package/es/modules/custom-image/actions/CustomResizeAction.es.js.map +0 -1
- package/es/modules/custom-image/actions/DeleteAction.es.js.map +0 -1
- package/es/modules/custom-image/image-bar.es.js +0 -127
- package/es/modules/custom-image/image-bar.es.js.map +0 -1
- package/es/modules/custom-image/specs/BlotSpec.es.js +0 -27
- package/es/modules/custom-image/specs/BlotSpec.es.js.map +0 -1
- package/es/modules/custom-image/specs/CustomImageSpec.es.js.map +0 -1
- package/es/modules/custom-image/specs/ImageSpec.es.js +0 -29
- package/es/modules/custom-image/specs/ImageSpec.es.js.map +0 -1
- package/es/modules/emoji/emoji-list/index.es.js +0 -5
- package/es/modules/emoji/emoji-list/people.es.js +0 -114
- package/es/modules/emoji/emoji-list/people.es.js.map +0 -1
- package/es/modules/emoji/emoji-list.es.js +0 -9
- package/es/modules/emoji/emoji-list.es.js.map +0 -1
- package/es/modules/emoji/emoji-map.es.js +0 -9
- package/es/modules/emoji/emoji-map.es.js.map +0 -1
- package/es/modules/emoji/emoji-sprite.es.js +0 -5
- package/es/modules/emoji/emoji-sprite.es.js.map +0 -1
- package/es/modules/emoji/formats/emoji-blot.es.js +0 -41
- package/es/modules/emoji/formats/emoji-blot.es.js.map +0 -1
- package/es/modules/emoji/index.es.js +0 -8
- package/es/modules/emoji/index.es.js.map +0 -1
- package/es/modules/emoji/modules/emoji.es.js +0 -248
- package/es/modules/emoji/modules/emoji.es.js.map +0 -1
- package/es/modules/emoji/modules/toolbar-emoji.es.js +0 -153
- package/es/modules/emoji/modules/toolbar-emoji.es.js.map +0 -1
- package/es/modules/emoji/utils.es.js +0 -19
- package/es/modules/emoji/utils.es.js.map +0 -1
- package/es/modules/mention/Mention.es.js.map +0 -1
- package/es/modules/mention/MentionLink.es.js.map +0 -1
- package/lib/config/types/additional-toolbar-item.interface.cjs.js +0 -2
- package/lib/config/types/additional-toolbar-item.interface.cjs.js.map +0 -1
- package/lib/config/types/content-change.interface.cjs.js +0 -2
- package/lib/config/types/content-change.interface.cjs.js.map +0 -1
- package/lib/config/types/content-save.interface.cjs.js +0 -2
- package/lib/config/types/content-save.interface.cjs.js.map +0 -1
- package/lib/config/types/counter-option.interface.cjs.js +0 -2
- package/lib/config/types/counter-option.interface.cjs.js.map +0 -1
- package/lib/config/types/editor-toolbar.interface.cjs.js +0 -2
- package/lib/config/types/editor-toolbar.interface.cjs.js.map +0 -1
- package/lib/config/types/file-operation.interface.cjs.js +0 -2
- package/lib/config/types/file-operation.interface.cjs.js.map +0 -1
- package/lib/config/types/focus-change.interface.cjs.js +0 -2
- package/lib/config/types/focus-change.interface.cjs.js.map +0 -1
- package/lib/config/types/fullscreen-module.interface.cjs.js +0 -2
- package/lib/config/types/fullscreen-module.interface.cjs.js.map +0 -1
- package/lib/config/types/help-panel-item.interface.cjs.js +0 -2
- package/lib/config/types/help-panel-item.interface.cjs.js.map +0 -1
- package/lib/config/types/help-panel-option.interface.cjs.js +0 -2
- package/lib/config/types/help-panel-option.interface.cjs.js.map +0 -1
- package/lib/config/types/image-module.interface.cjs.js +0 -2
- package/lib/config/types/image-module.interface.cjs.js.map +0 -1
- package/lib/config/types/image-upload.interface.cjs.js +0 -2
- package/lib/config/types/image-upload.interface.cjs.js.map +0 -1
- package/lib/config/types/load-on-demand-module.interface.cjs.js +0 -2
- package/lib/config/types/load-on-demand-module.interface.cjs.js.map +0 -1
- package/lib/config/types/mention-module.interface.cjs.js +0 -2
- package/lib/config/types/mention-module.interface.cjs.js.map +0 -1
- package/lib/config/types/paste-change.interface.cjs.js +0 -2
- package/lib/config/types/paste-change.interface.cjs.js.map +0 -1
- package/lib/config/types/quick-menu-module.interface.cjs.js +0 -2
- package/lib/config/types/quick-menu-module.interface.cjs.js.map +0 -1
- package/lib/config/types/range.interface.cjs.js +0 -2
- package/lib/config/types/range.interface.cjs.js.map +0 -1
- package/lib/config/types/registry-options.interface.cjs.js +0 -2
- package/lib/config/types/registry-options.interface.cjs.js.map +0 -1
- package/lib/config/types/selection-change.interface.cjs.js +0 -2
- package/lib/config/types/selection-change.interface.cjs.js.map +0 -1
- package/lib/config/types/toolbar-item.interface.cjs.js +0 -2
- package/lib/config/types/toolbar-item.interface.cjs.js.map +0 -1
- package/lib/config/types/validate-error.interface.cjs.js +0 -2
- package/lib/config/types/validate-error.interface.cjs.js.map +0 -1
- package/lib/modules/custom-image/BlotFormatter.cjs.js.map +0 -1
- package/lib/modules/custom-image/Options.cjs.js +0 -95
- package/lib/modules/custom-image/Options.cjs.js.map +0 -1
- package/lib/modules/custom-image/actions/Action.cjs.js +0 -15
- package/lib/modules/custom-image/actions/Action.cjs.js.map +0 -1
- package/lib/modules/custom-image/actions/CustomResizeAction.cjs.js.map +0 -1
- package/lib/modules/custom-image/actions/DeleteAction.cjs.js.map +0 -1
- package/lib/modules/custom-image/image-bar.cjs.js +0 -127
- package/lib/modules/custom-image/image-bar.cjs.js.map +0 -1
- package/lib/modules/custom-image/specs/BlotSpec.cjs.js +0 -27
- package/lib/modules/custom-image/specs/BlotSpec.cjs.js.map +0 -1
- package/lib/modules/custom-image/specs/CustomImageSpec.cjs.js.map +0 -1
- package/lib/modules/custom-image/specs/ImageSpec.cjs.js +0 -29
- package/lib/modules/custom-image/specs/ImageSpec.cjs.js.map +0 -1
- package/lib/modules/emoji/emoji-list/index.cjs.js +0 -5
- package/lib/modules/emoji/emoji-list/people.cjs.js +0 -114
- package/lib/modules/emoji/emoji-list/people.cjs.js.map +0 -1
- package/lib/modules/emoji/emoji-list.cjs.js +0 -9
- package/lib/modules/emoji/emoji-list.cjs.js.map +0 -1
- package/lib/modules/emoji/emoji-map.cjs.js +0 -9
- package/lib/modules/emoji/emoji-map.cjs.js.map +0 -1
- package/lib/modules/emoji/emoji-sprite.cjs.js +0 -5
- package/lib/modules/emoji/emoji-sprite.cjs.js.map +0 -1
- package/lib/modules/emoji/formats/emoji-blot.cjs.js +0 -41
- package/lib/modules/emoji/formats/emoji-blot.cjs.js.map +0 -1
- package/lib/modules/emoji/index.cjs.js +0 -8
- package/lib/modules/emoji/index.cjs.js.map +0 -1
- package/lib/modules/emoji/modules/emoji.cjs.js +0 -248
- package/lib/modules/emoji/modules/emoji.cjs.js.map +0 -1
- package/lib/modules/emoji/modules/toolbar-emoji.cjs.js +0 -153
- package/lib/modules/emoji/modules/toolbar-emoji.cjs.js.map +0 -1
- package/lib/modules/emoji/utils.cjs.js +0 -19
- package/lib/modules/emoji/utils.cjs.js.map +0 -1
- package/lib/modules/mention/Mention.cjs.js.map +0 -1
- package/lib/modules/mention/MentionLink.cjs.js.map +0 -1
- package/types/config/types/additional-toolbar-item.interface.d.ts +0 -8
- package/types/config/types/content-change.interface.d.ts +0 -13
- package/types/config/types/content-save.interface.d.ts +0 -6
- package/types/config/types/counter-option.interface.d.ts +0 -9
- package/types/config/types/editor-toolbar.interface.d.ts +0 -6
- package/types/config/types/file-operation.interface.d.ts +0 -12
- package/types/config/types/focus-change.interface.d.ts +0 -4
- package/types/config/types/fullscreen-module.interface.d.ts +0 -4
- package/types/config/types/help-panel-item.interface.d.ts +0 -5
- package/types/config/types/help-panel-option.interface.d.ts +0 -7
- package/types/config/types/image-module.interface.d.ts +0 -3
- package/types/config/types/image-upload.interface.d.ts +0 -7
- package/types/config/types/load-on-demand-module.interface.d.ts +0 -5
- package/types/config/types/mention-module.interface.d.ts +0 -8
- package/types/config/types/paste-change.interface.d.ts +0 -6
- package/types/config/types/quick-menu-module.interface.d.ts +0 -3
- package/types/config/types/range.interface.d.ts +0 -4
- package/types/config/types/registry-options.interface.d.ts +0 -5
- package/types/config/types/selection-change.interface.d.ts +0 -8
- package/types/config/types/toolbar-item.interface.d.ts +0 -13
- package/types/config/types/validate-error.interface.d.ts +0 -13
- package/types/modules/custom-image/BlotFormatter.d.ts +0 -29
- package/types/modules/custom-image/Options.d.ts +0 -36
- package/types/modules/custom-image/actions/Action.d.ts +0 -7
- package/types/modules/custom-image/actions/DeleteAction.d.ts +0 -7
- package/types/modules/custom-image/image-bar.d.ts +0 -15
- package/types/modules/custom-image/specs/BlotSpec.d.ts +0 -13
- package/types/modules/custom-image/specs/ImageSpec.d.ts +0 -10
- package/types/modules/emoji/emoji-list/index.d.ts +0 -1
- package/types/modules/emoji/emoji-list/people.d.ts +0 -1
- package/types/modules/emoji/emoji-list.d.ts +0 -2
- package/types/modules/emoji/emoji-map.d.ts +0 -2
- package/types/modules/emoji/emoji-sprite.d.ts +0 -1
- package/types/modules/emoji/formats/emoji-blot.d.ts +0 -13
- package/types/modules/emoji/index.d.ts +0 -10
- package/types/modules/emoji/modules/emoji.d.ts +0 -38
- package/types/modules/emoji/modules/toolbar-emoji.d.ts +0 -8
- package/types/modules/emoji/utils.d.ts +0 -1
|
@@ -0,0 +1,167 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
4
|
+
var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
5
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
6
|
+
const lodashEs = require("lodash-es");
|
|
7
|
+
const DEFAULT_OPTIONS = {
|
|
8
|
+
// @ts-ignore
|
|
9
|
+
emojiData: window.emojiData,
|
|
10
|
+
// @ts-ignore
|
|
11
|
+
EmojiPicker: window.EmojiPicker,
|
|
12
|
+
// @ts-ignore
|
|
13
|
+
emojiPickerPosition: window.emojiPickerPosition,
|
|
14
|
+
theme: "light",
|
|
15
|
+
set: "native",
|
|
16
|
+
skinTonePosition: "none",
|
|
17
|
+
previewPosition: "bottom",
|
|
18
|
+
searchPosition: "sticky",
|
|
19
|
+
categories: ["frequent", "people", "nature", "foods", "activity", "places", "objects", "symbols", "flags"],
|
|
20
|
+
maxFrequentRows: 2,
|
|
21
|
+
perLine: 8,
|
|
22
|
+
navPosition: "top",
|
|
23
|
+
noCountryFlags: false,
|
|
24
|
+
dynamicWidth: false
|
|
25
|
+
};
|
|
26
|
+
const PICKER_DOM_ID = "emoji-picker";
|
|
27
|
+
const LOCALE_MAP = {
|
|
28
|
+
"zh-CN": "zh",
|
|
29
|
+
"en-US": "en"
|
|
30
|
+
};
|
|
31
|
+
class EmojiModule {
|
|
32
|
+
constructor(quill, options = {}) {
|
|
33
|
+
__publicField(this, "quill");
|
|
34
|
+
__publicField(this, "options");
|
|
35
|
+
__publicField(this, "picker", null);
|
|
36
|
+
__publicField(this, "isPickerVisible", false);
|
|
37
|
+
__publicField(this, "cleanupResizeObserver", null);
|
|
38
|
+
this.quill = quill;
|
|
39
|
+
this.options = { ...DEFAULT_OPTIONS, ...options };
|
|
40
|
+
const toolbar = this.quill.getModule("toolbar");
|
|
41
|
+
if (toolbar) {
|
|
42
|
+
toolbar.addHandler("emoji", () => {
|
|
43
|
+
if (this.isPickerVisible) {
|
|
44
|
+
this.closeDialog();
|
|
45
|
+
} else {
|
|
46
|
+
this.openDialog();
|
|
47
|
+
}
|
|
48
|
+
});
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
getEmojiButton() {
|
|
52
|
+
return document.querySelector(".ql-emoji");
|
|
53
|
+
}
|
|
54
|
+
async updatePickerPosition() {
|
|
55
|
+
const button = this.getEmojiButton();
|
|
56
|
+
const pickerElement = document.getElementById(PICKER_DOM_ID);
|
|
57
|
+
if (!button || !this.picker || !pickerElement) {
|
|
58
|
+
return;
|
|
59
|
+
}
|
|
60
|
+
const { emojiPickerPosition } = this.options;
|
|
61
|
+
try {
|
|
62
|
+
const { x, y } = await emojiPickerPosition(button, pickerElement);
|
|
63
|
+
this.picker.style.top = `${y}px`;
|
|
64
|
+
this.picker.style.left = `${x}px`;
|
|
65
|
+
} catch (error) {
|
|
66
|
+
console.warn("Failed to compute picker position:", error);
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
// 监听容器大小变化,更新表情选择弹窗位置
|
|
70
|
+
setupContainerResizeObserver() {
|
|
71
|
+
const container = this.quill.root.parentElement;
|
|
72
|
+
if (!container) {
|
|
73
|
+
return null;
|
|
74
|
+
}
|
|
75
|
+
const debouncedUpdate = lodashEs.debounce(() => {
|
|
76
|
+
this.updatePickerPosition();
|
|
77
|
+
}, 100);
|
|
78
|
+
const resizeObserver = new ResizeObserver(() => {
|
|
79
|
+
debouncedUpdate();
|
|
80
|
+
});
|
|
81
|
+
resizeObserver.observe(container);
|
|
82
|
+
return () => {
|
|
83
|
+
resizeObserver.disconnect();
|
|
84
|
+
debouncedUpdate.cancel();
|
|
85
|
+
};
|
|
86
|
+
}
|
|
87
|
+
// 创建表情选择弹窗
|
|
88
|
+
createPicker() {
|
|
89
|
+
const { EmojiPicker, emojiData, ...options } = this.options;
|
|
90
|
+
const pickerConfig = {
|
|
91
|
+
// emoji-mart 与 tiny-editor 国际化的的 locale 不一致使用 LOCALE_MAP 转换
|
|
92
|
+
locale: LOCALE_MAP[this.quill.lang] ?? "en",
|
|
93
|
+
data: emojiData,
|
|
94
|
+
...options,
|
|
95
|
+
onEmojiSelect: this.handleEmojiSelect.bind(this),
|
|
96
|
+
onClickOutside: this.handleClickOutside.bind(this)
|
|
97
|
+
};
|
|
98
|
+
const picker = new EmojiPicker(pickerConfig);
|
|
99
|
+
picker.id = PICKER_DOM_ID;
|
|
100
|
+
picker.style.position = "absolute";
|
|
101
|
+
picker.style.zIndex = "1000";
|
|
102
|
+
return picker;
|
|
103
|
+
}
|
|
104
|
+
// 打开表情弹窗
|
|
105
|
+
openDialog() {
|
|
106
|
+
if (this.picker) {
|
|
107
|
+
return;
|
|
108
|
+
}
|
|
109
|
+
try {
|
|
110
|
+
this.picker = this.createPicker();
|
|
111
|
+
document.body.appendChild(this.picker);
|
|
112
|
+
this.updatePickerPosition();
|
|
113
|
+
this.cleanupResizeObserver = this.setupContainerResizeObserver();
|
|
114
|
+
this.isPickerVisible = true;
|
|
115
|
+
} catch (error) {
|
|
116
|
+
console.error("Failed to open emoji picker:", error);
|
|
117
|
+
this.closeDialog();
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
// 关闭表情弹窗
|
|
121
|
+
closeDialog() {
|
|
122
|
+
var _a;
|
|
123
|
+
if (!this.picker) {
|
|
124
|
+
return;
|
|
125
|
+
}
|
|
126
|
+
this.isPickerVisible = false;
|
|
127
|
+
this.picker.remove();
|
|
128
|
+
this.picker = null;
|
|
129
|
+
(_a = this.cleanupResizeObserver) == null ? void 0 : _a.call(this);
|
|
130
|
+
this.cleanupResizeObserver = null;
|
|
131
|
+
}
|
|
132
|
+
// 处理表情选择事件
|
|
133
|
+
handleEmojiSelect(emoji) {
|
|
134
|
+
const selection = this.quill.getSelection(true);
|
|
135
|
+
if (!selection) {
|
|
136
|
+
console.warn("No selection available for emoji insertion");
|
|
137
|
+
return;
|
|
138
|
+
}
|
|
139
|
+
try {
|
|
140
|
+
const insertIndex = selection.index;
|
|
141
|
+
this.quill.insertText(insertIndex, emoji.native, "user");
|
|
142
|
+
this.closeDialog();
|
|
143
|
+
this.quill.setSelection(insertIndex + emoji.native.length);
|
|
144
|
+
} catch (error) {
|
|
145
|
+
console.error("Failed to insert emoji:", error);
|
|
146
|
+
}
|
|
147
|
+
}
|
|
148
|
+
// 处理外部点击事件
|
|
149
|
+
handleClickOutside(event) {
|
|
150
|
+
const button = this.getEmojiButton();
|
|
151
|
+
const target = event.target;
|
|
152
|
+
const isClickOnButton = target === button || target instanceof Element && (button == null ? void 0 : button.contains(target));
|
|
153
|
+
if (isClickOnButton) {
|
|
154
|
+
return;
|
|
155
|
+
}
|
|
156
|
+
this.closeDialog();
|
|
157
|
+
}
|
|
158
|
+
// 销毁模块,清理资源
|
|
159
|
+
destroy() {
|
|
160
|
+
var _a;
|
|
161
|
+
(_a = this.cleanupResizeObserver) == null ? void 0 : _a.call(this);
|
|
162
|
+
this.cleanupResizeObserver = null;
|
|
163
|
+
this.closeDialog();
|
|
164
|
+
}
|
|
165
|
+
}
|
|
166
|
+
exports.EmojiModule = EmojiModule;
|
|
167
|
+
//# sourceMappingURL=emoji.cjs.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"emoji.cjs.js","sources":["../../../src/modules/emoji.ts"],"sourcesContent":["import type { EmojiMartData } from '@emoji-mart/data'\nimport type { computePosition } from '@floating-ui/dom'\nimport type { Picker } from 'emoji-mart'\nimport type TypeToolbar from 'quill/modules/toolbar'\nimport type FluentEditor from '../fluent-editor'\nimport { debounce } from 'lodash-es'\n\nexport interface EmojiModuleOptions {\n emojiData?: EmojiMartData\n EmojiPicker?: new (props: any) => Picker\n emojiPickerPosition?: typeof computePosition\n theme?: string\n locale?: string\n set?: string\n skinTonePosition?: string\n previewPosition?: string\n searchPosition?: string\n categories?: string[]\n maxFrequentRows?: number\n perLine?: number\n navPosition?: string\n noCountryFlags?: boolean\n dynamicWidth?: boolean\n}\n\nconst DEFAULT_OPTIONS: EmojiModuleOptions = {\n // @ts-ignore\n emojiData: window.emojiData,\n // @ts-ignore\n EmojiPicker: window.EmojiPicker,\n // @ts-ignore\n emojiPickerPosition: window.emojiPickerPosition,\n theme: 'light',\n set: 'native',\n skinTonePosition: 'none',\n previewPosition: 'bottom',\n searchPosition: 'sticky',\n categories: ['frequent', 'people', 'nature', 'foods', 'activity', 'places', 'objects', 'symbols', 'flags'],\n maxFrequentRows: 2,\n perLine: 8,\n navPosition: 'top',\n noCountryFlags: false,\n dynamicWidth: false,\n}\n\nconst PICKER_DOM_ID = 'emoji-picker'\n\nconst LOCALE_MAP = {\n 'zh-CN': 'zh',\n 'en-US': 'en',\n} as const\n\nclass EmojiModule {\n private readonly quill: FluentEditor\n private readonly options: EmojiModuleOptions\n private picker: HTMLElement | null = null\n private isPickerVisible = false\n private cleanupResizeObserver: (() => void) | null = null\n\n constructor(quill: FluentEditor, options: EmojiModuleOptions = {}) {\n this.quill = quill\n\n this.options = { ...DEFAULT_OPTIONS, ...options }\n\n const toolbar = this.quill.getModule('toolbar') as TypeToolbar\n\n if (toolbar) {\n toolbar.addHandler('emoji', () => {\n if (this.isPickerVisible) {\n this.closeDialog()\n }\n else {\n this.openDialog()\n }\n })\n }\n }\n\n private getEmojiButton() {\n return document.querySelector('.ql-emoji') as HTMLElement | null\n }\n\n private async updatePickerPosition() {\n const button = this.getEmojiButton()\n const pickerElement = document.getElementById(PICKER_DOM_ID)\n\n if (!button || !this.picker || !pickerElement) {\n return\n }\n\n const { emojiPickerPosition } = this.options\n\n try {\n const { x, y } = await emojiPickerPosition(button, pickerElement)\n this.picker.style.top = `${y}px`\n this.picker.style.left = `${x}px`\n }\n catch (error) {\n console.warn('Failed to compute picker position:', error)\n }\n }\n\n // 监听容器大小变化,更新表情选择弹窗位置\n private setupContainerResizeObserver() {\n const container = this.quill.root.parentElement\n if (!container) {\n return null\n }\n\n const debouncedUpdate = debounce(() => {\n this.updatePickerPosition()\n }, 100)\n\n const resizeObserver = new ResizeObserver(() => {\n debouncedUpdate()\n })\n\n resizeObserver.observe(container)\n\n return () => {\n resizeObserver.disconnect()\n debouncedUpdate.cancel()\n }\n }\n\n // 创建表情选择弹窗\n private createPicker() {\n const { EmojiPicker, emojiData, ...options } = this.options\n\n const pickerConfig = {\n // emoji-mart 与 tiny-editor 国际化的的 locale 不一致使用 LOCALE_MAP 转换\n locale: LOCALE_MAP[this.quill.lang] ?? 'en',\n data: emojiData,\n ...options,\n onEmojiSelect: this.handleEmojiSelect.bind(this),\n onClickOutside: this.handleClickOutside.bind(this),\n }\n\n const picker = new EmojiPicker(pickerConfig) as unknown as HTMLElement\n\n // 设置样式和属性\n picker.id = PICKER_DOM_ID\n picker.style.position = 'absolute'\n picker.style.zIndex = '1000'\n\n return picker\n }\n\n // 打开表情弹窗\n public openDialog() {\n if (this.picker) {\n return\n }\n\n try {\n this.picker = this.createPicker()\n document.body.appendChild(this.picker)\n\n this.updatePickerPosition()\n this.cleanupResizeObserver = this.setupContainerResizeObserver()\n this.isPickerVisible = true\n }\n catch (error) {\n console.error('Failed to open emoji picker:', error)\n this.closeDialog()\n }\n }\n\n // 关闭表情弹窗\n public closeDialog() {\n if (!this.picker) {\n return\n }\n\n this.isPickerVisible = false\n this.picker.remove()\n this.picker = null\n\n this.cleanupResizeObserver?.()\n this.cleanupResizeObserver = null\n }\n\n // 处理表情选择事件\n private handleEmojiSelect(emoji: { native: string }) {\n const selection = this.quill.getSelection(true)\n if (!selection) {\n console.warn('No selection available for emoji insertion')\n return\n }\n\n try {\n // 记录插入位置\n const insertIndex = selection.index\n this.quill.insertText(insertIndex, emoji.native, 'user')\n\n this.closeDialog()\n\n // 设置光标到表情符号后面\n this.quill.setSelection(insertIndex + emoji.native.length)\n }\n catch (error) {\n console.error('Failed to insert emoji:', error)\n }\n }\n\n // 处理外部点击事件\n private handleClickOutside(event: MouseEvent) {\n const button = this.getEmojiButton()\n\n const target = event.target\n\n const isClickOnButton = target === button || (target instanceof Element && button?.contains(target))\n\n // 如果点击的是表情符号按钮或其子元素,则不关闭选择器\n if (isClickOnButton) {\n return\n }\n\n this.closeDialog()\n }\n\n // 销毁模块,清理资源\n public destroy() {\n this.cleanupResizeObserver?.()\n this.cleanupResizeObserver = null\n this.closeDialog()\n }\n}\n\nexport { EmojiModule }\n"],"names":["debounce"],"mappings":";;;;;;AAyBA,MAAM,kBAAsC;AAAA;AAAA,EAE1C,WAAW,OAAO;AAAA;AAAA,EAElB,aAAa,OAAO;AAAA;AAAA,EAEpB,qBAAqB,OAAO;AAAA,EAC5B,OAAO;AAAA,EACP,KAAK;AAAA,EACL,kBAAkB;AAAA,EAClB,iBAAiB;AAAA,EACjB,gBAAgB;AAAA,EAChB,YAAY,CAAC,YAAY,UAAU,UAAU,SAAS,YAAY,UAAU,WAAW,WAAW,OAAO;AAAA,EACzG,iBAAiB;AAAA,EACjB,SAAS;AAAA,EACT,aAAa;AAAA,EACb,gBAAgB;AAAA,EAChB,cAAc;AAChB;AAEA,MAAM,gBAAgB;AAEtB,MAAM,aAAa;AAAA,EACjB,SAAS;AAAA,EACT,SAAS;AACX;AAEA,MAAM,YAAY;AAAA,EAOhB,YAAY,OAAqB,UAA8B,IAAI;AANlD;AACA;AACT,kCAA6B;AAC7B,2CAAkB;AAClB,iDAA6C;AAGnD,SAAK,QAAQ;AAEb,SAAK,UAAU,EAAE,GAAG,iBAAiB,GAAG,QAAQ;AAEhD,UAAM,UAAU,KAAK,MAAM,UAAU,SAAS;AAE9C,QAAI,SAAS;AACH,cAAA,WAAW,SAAS,MAAM;AAChC,YAAI,KAAK,iBAAiB;AACxB,eAAK,YAAY;AAAA,QAAA,OAEd;AACH,eAAK,WAAW;AAAA,QAAA;AAAA,MAClB,CACD;AAAA,IAAA;AAAA,EACH;AAAA,EAGM,iBAAiB;AAChB,WAAA,SAAS,cAAc,WAAW;AAAA,EAAA;AAAA,EAG3C,MAAc,uBAAuB;AAC7B,UAAA,SAAS,KAAK,eAAe;AAC7B,UAAA,gBAAgB,SAAS,eAAe,aAAa;AAE3D,QAAI,CAAC,UAAU,CAAC,KAAK,UAAU,CAAC,eAAe;AAC7C;AAAA,IAAA;AAGI,UAAA,EAAE,wBAAwB,KAAK;AAEjC,QAAA;AACF,YAAM,EAAE,GAAG,EAAA,IAAM,MAAM,oBAAoB,QAAQ,aAAa;AAChE,WAAK,OAAO,MAAM,MAAM,GAAG,CAAC;AAC5B,WAAK,OAAO,MAAM,OAAO,GAAG,CAAC;AAAA,aAExB,OAAO;AACJ,cAAA,KAAK,sCAAsC,KAAK;AAAA,IAAA;AAAA,EAC1D;AAAA;AAAA,EAIM,+BAA+B;AAC/B,UAAA,YAAY,KAAK,MAAM,KAAK;AAClC,QAAI,CAAC,WAAW;AACP,aAAA;AAAA,IAAA;AAGH,UAAA,kBAAkBA,SAAAA,SAAS,MAAM;AACrC,WAAK,qBAAqB;AAAA,OACzB,GAAG;AAEA,UAAA,iBAAiB,IAAI,eAAe,MAAM;AAC9B,sBAAA;AAAA,IAAA,CACjB;AAED,mBAAe,QAAQ,SAAS;AAEhC,WAAO,MAAM;AACX,qBAAe,WAAW;AAC1B,sBAAgB,OAAO;AAAA,IACzB;AAAA,EAAA;AAAA;AAAA,EAIM,eAAe;AACrB,UAAM,EAAE,aAAa,WAAW,GAAG,YAAY,KAAK;AAEpD,UAAM,eAAe;AAAA;AAAA,MAEnB,QAAQ,WAAW,KAAK,MAAM,IAAI,KAAK;AAAA,MACvC,MAAM;AAAA,MACN,GAAG;AAAA,MACH,eAAe,KAAK,kBAAkB,KAAK,IAAI;AAAA,MAC/C,gBAAgB,KAAK,mBAAmB,KAAK,IAAI;AAAA,IACnD;AAEM,UAAA,SAAS,IAAI,YAAY,YAAY;AAG3C,WAAO,KAAK;AACZ,WAAO,MAAM,WAAW;AACxB,WAAO,MAAM,SAAS;AAEf,WAAA;AAAA,EAAA;AAAA;AAAA,EAIF,aAAa;AAClB,QAAI,KAAK,QAAQ;AACf;AAAA,IAAA;AAGE,QAAA;AACG,WAAA,SAAS,KAAK,aAAa;AACvB,eAAA,KAAK,YAAY,KAAK,MAAM;AAErC,WAAK,qBAAqB;AACrB,WAAA,wBAAwB,KAAK,6BAA6B;AAC/D,WAAK,kBAAkB;AAAA,aAElB,OAAO;AACJ,cAAA,MAAM,gCAAgC,KAAK;AACnD,WAAK,YAAY;AAAA,IAAA;AAAA,EACnB;AAAA;AAAA,EAIK,cAAc;;AACf,QAAA,CAAC,KAAK,QAAQ;AAChB;AAAA,IAAA;AAGF,SAAK,kBAAkB;AACvB,SAAK,OAAO,OAAO;AACnB,SAAK,SAAS;AAEd,eAAK,0BAAL;AACA,SAAK,wBAAwB;AAAA,EAAA;AAAA;AAAA,EAIvB,kBAAkB,OAA2B;AACnD,UAAM,YAAY,KAAK,MAAM,aAAa,IAAI;AAC9C,QAAI,CAAC,WAAW;AACd,cAAQ,KAAK,4CAA4C;AACzD;AAAA,IAAA;AAGE,QAAA;AAEF,YAAM,cAAc,UAAU;AAC9B,WAAK,MAAM,WAAW,aAAa,MAAM,QAAQ,MAAM;AAEvD,WAAK,YAAY;AAGjB,WAAK,MAAM,aAAa,cAAc,MAAM,OAAO,MAAM;AAAA,aAEpD,OAAO;AACJ,cAAA,MAAM,2BAA2B,KAAK;AAAA,IAAA;AAAA,EAChD;AAAA;AAAA,EAIM,mBAAmB,OAAmB;AACtC,UAAA,SAAS,KAAK,eAAe;AAEnC,UAAM,SAAS,MAAM;AAErB,UAAM,kBAAkB,WAAW,UAAW,kBAAkB,YAAW,iCAAQ,SAAS;AAG5F,QAAI,iBAAiB;AACnB;AAAA,IAAA;AAGF,SAAK,YAAY;AAAA,EAAA;AAAA;AAAA,EAIZ,UAAU;;AACf,eAAK,0BAAL;AACA,SAAK,wBAAwB;AAC7B,SAAK,YAAY;AAAA,EAAA;AAErB;;"}
|
|
@@ -1,8 +1,11 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
4
|
+
var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
5
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
3
6
|
const Quill = require("quill");
|
|
4
7
|
const editor_utils = require("../../../config/editor.utils.cjs.js");
|
|
5
|
-
const Embed = Quill.
|
|
8
|
+
const Embed = Quill.import("blots/embed");
|
|
6
9
|
const FILE_ATTRIBUTES = ["id", "title", "size", "lastModified"];
|
|
7
10
|
class File extends Embed {
|
|
8
11
|
static create(value) {
|
|
@@ -10,10 +13,10 @@ class File extends Embed {
|
|
|
10
13
|
const size = value.size / 1024;
|
|
11
14
|
const fixSize = !size ? 0 : size < 1 ? 1 : size.toFixed(0);
|
|
12
15
|
node.classList.add("icon-file");
|
|
13
|
-
node.setAttribute("contenteditable", false);
|
|
16
|
+
node.setAttribute("contenteditable", "false");
|
|
14
17
|
const fileSvg = '<svg viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" width="16" height="16"><path d="M854.6 288.6L639.4 73.4c-6-6-14.1-9.4-22.6-9.4H192c-17.7 0-32 14.3-32 32v832c0 17.7 14.3 32 32 32h640c17.7 0 32-14.3 32-32V311.3c0-8.5-3.4-16.7-9.4-22.7zM790.2 326H602V137.8L790.2 326z m1.8 562H232V136h302v216c0 23.2 18.8 42 42 42h216v494z" p-id="2307"></path></svg>';
|
|
15
18
|
node.innerHTML = `${fileSvg} ${value.title} (${fixSize} KB)`;
|
|
16
|
-
const src =
|
|
19
|
+
const src = this.sanitize(value.src);
|
|
17
20
|
if (src) {
|
|
18
21
|
node.href = src;
|
|
19
22
|
node.target = "_blank";
|
|
@@ -26,14 +29,11 @@ class File extends Embed {
|
|
|
26
29
|
return node;
|
|
27
30
|
}
|
|
28
31
|
static value(domNode) {
|
|
29
|
-
return
|
|
30
|
-
}
|
|
31
|
-
static formats(domNode) {
|
|
32
|
-
return File.getFormats(domNode);
|
|
32
|
+
return this.getFormats(domNode);
|
|
33
33
|
}
|
|
34
34
|
static getFormats(domNode) {
|
|
35
35
|
const formats = {};
|
|
36
|
-
const href =
|
|
36
|
+
const href = this.sanitize(domNode.href);
|
|
37
37
|
if (href) {
|
|
38
38
|
formats.src = href;
|
|
39
39
|
}
|
|
@@ -48,9 +48,9 @@ class File extends Embed {
|
|
|
48
48
|
return editor_utils.sanitize(url, this.PROTOCOL_WHITELIST) && url || "";
|
|
49
49
|
}
|
|
50
50
|
}
|
|
51
|
-
File
|
|
52
|
-
File
|
|
53
|
-
File
|
|
54
|
-
File
|
|
55
|
-
exports.
|
|
51
|
+
__publicField(File, "blotName", "file");
|
|
52
|
+
__publicField(File, "tagName", "A");
|
|
53
|
+
__publicField(File, "className", "ql-file-item");
|
|
54
|
+
__publicField(File, "PROTOCOL_WHITELIST", ["http", "https", "blob"]);
|
|
55
|
+
exports.File = File;
|
|
56
56
|
//# sourceMappingURL=file.cjs.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"file.cjs.js","sources":["../../../../../src/modules/file/formats/file.ts"],"sourcesContent":["import Quill from 'quill'\
|
|
1
|
+
{"version":3,"file":"file.cjs.js","sources":["../../../../../src/modules/file/formats/file.ts"],"sourcesContent":["import type TypeEmbed from 'quill/blots/embed'\nimport Quill from 'quill'\nimport { sanitize } from '../../../config/editor.utils'\n\nconst Embed = Quill.import('blots/embed') as typeof TypeEmbed\nconst FILE_ATTRIBUTES = ['id', 'title', 'size', 'lastModified']\n\nexport interface FileValue {\n size: number\n src: string\n title: string\n}\nexport class File extends Embed {\n static blotName = 'file'\n static tagName = 'A'\n static className = 'ql-file-item'\n static PROTOCOL_WHITELIST = ['http', 'https', 'blob']\n\n static create(value: FileValue) {\n const node = super.create(value) as HTMLAnchorElement\n const size = value.size / 1024\n const fixSize = !size ? 0 : size < 1 ? 1 : size.toFixed(0)\n node.classList.add('icon-file')\n node.setAttribute('contenteditable', 'false')\n const fileSvg = '<svg viewBox=\"0 0 1024 1024\" version=\"1.1\" xmlns=\"http://www.w3.org/2000/svg\" width=\"16\" height=\"16\"><path d=\"M854.6 288.6L639.4 73.4c-6-6-14.1-9.4-22.6-9.4H192c-17.7 0-32 14.3-32 32v832c0 17.7 14.3 32 32 32h640c17.7 0 32-14.3 32-32V311.3c0-8.5-3.4-16.7-9.4-22.7zM790.2 326H602V137.8L790.2 326z m1.8 562H232V136h302v216c0 23.2 18.8 42 42 42h216v494z\" p-id=\"2307\"></path></svg>'\n node.innerHTML = `${fileSvg} ${value.title} (${fixSize} KB)`\n const src = this.sanitize(value.src)\n if (src) {\n node.href = src\n node.target = '_blank'\n }\n FILE_ATTRIBUTES.forEach((key) => {\n if (value[key]) {\n node.dataset[key] = value[key]\n }\n })\n return node\n }\n\n static value(domNode: HTMLAnchorElement) {\n return this.getFormats(domNode)\n }\n\n static getFormats(domNode: HTMLAnchorElement) {\n const formats: Record<string, string> = {}\n const href = this.sanitize(domNode.href)\n if (href) {\n formats.src = href\n }\n FILE_ATTRIBUTES.forEach((key) => {\n if (domNode.dataset[key]) {\n formats[key] = domNode.dataset[key]\n }\n })\n return formats\n }\n\n static sanitize(url: string) {\n return (sanitize(url, this.PROTOCOL_WHITELIST) && url) || ''\n }\n}\n"],"names":["sanitize"],"mappings":";;;;;;;AAIA,MAAM,QAAQ,MAAM,OAAO,aAAa;AACxC,MAAM,kBAAkB,CAAC,MAAM,SAAS,QAAQ,cAAc;AAOvD,MAAM,aAAa,MAAM;AAAA,EAM9B,OAAO,OAAO,OAAkB;AACxB,UAAA,OAAO,MAAM,OAAO,KAAK;AACzB,UAAA,OAAO,MAAM,OAAO;AACpB,UAAA,UAAU,CAAC,OAAO,IAAI,OAAO,IAAI,IAAI,KAAK,QAAQ,CAAC;AACpD,SAAA,UAAU,IAAI,WAAW;AACzB,SAAA,aAAa,mBAAmB,OAAO;AAC5C,UAAM,UAAU;AAChB,SAAK,YAAY,GAAG,OAAO,IAAI,MAAM,KAAK,KAAK,OAAO;AACtD,UAAM,MAAM,KAAK,SAAS,MAAM,GAAG;AACnC,QAAI,KAAK;AACP,WAAK,OAAO;AACZ,WAAK,SAAS;AAAA,IAAA;AAEA,oBAAA,QAAQ,CAAC,QAAQ;AAC3B,UAAA,MAAM,GAAG,GAAG;AACd,aAAK,QAAQ,GAAG,IAAI,MAAM,GAAG;AAAA,MAAA;AAAA,IAC/B,CACD;AACM,WAAA;AAAA,EAAA;AAAA,EAGT,OAAO,MAAM,SAA4B;AAChC,WAAA,KAAK,WAAW,OAAO;AAAA,EAAA;AAAA,EAGhC,OAAO,WAAW,SAA4B;AAC5C,UAAM,UAAkC,CAAC;AACzC,UAAM,OAAO,KAAK,SAAS,QAAQ,IAAI;AACvC,QAAI,MAAM;AACR,cAAQ,MAAM;AAAA,IAAA;AAEA,oBAAA,QAAQ,CAAC,QAAQ;AAC3B,UAAA,QAAQ,QAAQ,GAAG,GAAG;AACxB,gBAAQ,GAAG,IAAI,QAAQ,QAAQ,GAAG;AAAA,MAAA;AAAA,IACpC,CACD;AACM,WAAA;AAAA,EAAA;AAAA,EAGT,OAAO,SAAS,KAAa;AAC3B,WAAQA,aAAAA,SAAS,KAAK,KAAK,kBAAkB,KAAK,OAAQ;AAAA,EAAA;AAE9D;AA/CE,cADW,MACJ,YAAW;AAClB,cAFW,MAEJ,WAAU;AACjB,cAHW,MAGJ,aAAY;AACnB,cAJW,MAIJ,sBAAqB,CAAC,QAAQ,SAAS,MAAM;;"}
|
|
@@ -1,32 +1,9 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
Object.
|
|
3
|
-
const Quill = require("quill");
|
|
2
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
4
3
|
const file = require("./formats/file.cjs.js");
|
|
5
4
|
const fileBar = require("./modules/file-bar.cjs.js");
|
|
6
|
-
const
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
}
|
|
11
|
-
constructor(quill, options) {
|
|
12
|
-
super(quill, options);
|
|
13
|
-
this.quill = quill;
|
|
14
|
-
quill.root.addEventListener("click", (event) => this.clickEvent(event), false);
|
|
15
|
-
}
|
|
16
|
-
clickEvent(event) {
|
|
17
|
-
event.preventDefault();
|
|
18
|
-
const target = event.target;
|
|
19
|
-
const fileDom = target.closest("a.ql-file-item");
|
|
20
|
-
if (fileDom) {
|
|
21
|
-
if (this.fileBar) {
|
|
22
|
-
this.fileBar.destroy();
|
|
23
|
-
}
|
|
24
|
-
this.fileBar = new fileBar.default(this.quill, fileDom);
|
|
25
|
-
} else if (this.fileBar && !target.closest(".ql-file-bar")) {
|
|
26
|
-
this.fileBar.destroy();
|
|
27
|
-
this.fileBar = null;
|
|
28
|
-
}
|
|
29
|
-
}
|
|
30
|
-
}
|
|
31
|
-
exports.default = FileModule;
|
|
5
|
+
const fileModule = require("./modules/file-module.cjs.js");
|
|
6
|
+
exports.File = file.File;
|
|
7
|
+
exports.FileBar = fileBar.FileBar;
|
|
8
|
+
exports.FileModule = fileModule.FileModule;
|
|
32
9
|
//# sourceMappingURL=index.cjs.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.cjs.js","sources":[
|
|
1
|
+
{"version":3,"file":"index.cjs.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;"}
|
|
@@ -1,17 +1,25 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
4
|
+
var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
5
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
3
6
|
const Quill = require("quill");
|
|
4
7
|
const selection = require("quill/core/selection");
|
|
5
8
|
const method = require("../../../utils/method.cjs.js");
|
|
6
9
|
const file = require("../formats/file.cjs.js");
|
|
7
|
-
const Delta = Quill.
|
|
10
|
+
const Delta = Quill.import("delta");
|
|
8
11
|
class FileBar {
|
|
9
12
|
constructor(quill, target) {
|
|
13
|
+
__publicField(this, "quill");
|
|
14
|
+
__publicField(this, "file");
|
|
15
|
+
__publicField(this, "domNode");
|
|
16
|
+
__publicField(this, "fileRange");
|
|
17
|
+
__publicField(this, "template");
|
|
10
18
|
this.quill = quill;
|
|
11
19
|
this.file = target;
|
|
12
20
|
const fileBlot = Quill.find(target);
|
|
13
21
|
const index = this.quill.getIndex(fileBlot);
|
|
14
|
-
const [fileItem, offset] = this.quill.scroll.descendant(file.
|
|
22
|
+
const [fileItem, offset] = this.quill.scroll.descendant(file.File, index);
|
|
15
23
|
const length = fileItem && fileItem.length();
|
|
16
24
|
this.fileRange = new selection.Range(index - offset, length);
|
|
17
25
|
const timestamp = Number(this.file.dataset.lastModified);
|
|
@@ -121,5 +129,5 @@ class FileBar {
|
|
|
121
129
|
return Number.isNaN(year) ? "--" : `${year}/${month}/${day} ${hour}:${minute}`;
|
|
122
130
|
}
|
|
123
131
|
}
|
|
124
|
-
exports.
|
|
132
|
+
exports.FileBar = FileBar;
|
|
125
133
|
//# sourceMappingURL=file-bar.cjs.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"file-bar.cjs.js","sources":["../../../../../src/modules/file/modules/file-bar.ts"],"sourcesContent":["import Quill from 'quill'\
|
|
1
|
+
{"version":3,"file":"file-bar.cjs.js","sources":["../../../../../src/modules/file/modules/file-bar.ts"],"sourcesContent":["import Quill from 'quill'\nimport { Range } from 'quill/core/selection'\nimport { unshiftString } from '../../../utils/method'\nimport { File } from '../formats/file'\n\nconst Delta = Quill.import('delta')\n\nexport class FileBar {\n quill: any\n file: any\n domNode: HTMLElement\n fileRange: any\n template: string\n\n constructor(quill, target) {\n this.quill = quill\n this.file = target\n const fileBlot = Quill.find(target)\n const index = this.quill.getIndex(fileBlot)\n const [fileItem, offset] = this.quill.scroll.descendant(File, index)\n const length = fileItem && fileItem.length()\n this.fileRange = new Range(index - offset, length)\n\n const timestamp = Number(this.file.dataset.lastModified)\n const _lastModifiedDate = this.formatDate(timestamp)\n this.template = [\n // `<a class=\"ql-last-modified-date\" href=\"${this.file.href}\" target=\"_blank\">${this.file.href}</a>`,\n // '<span class=\"ql-split\"></span>',\n // `<a class=\"ql-file-preview\"><i class=\"icon-preview\"></i></a>`,\n `<a class=\"ql-file-download\"><i class=\"icon-download\"></i></a>`,\n '<a class=\"ql-file-delete\"><i class=\"icon-delete\"></i></a>',\n ].join('')\n\n this.createFileBar()\n }\n\n createFileBar() {\n this.domNode = document.createElement('div')\n this.domNode.className = 'ql-file-bar'\n this.domNode.innerHTML = this.template\n // 查看文件\n const filePreview = this.domNode.querySelector('a.ql-file-preview')\n if (filePreview) {\n filePreview.addEventListener('click', (event) => {\n this.operateFile(event, 'view')\n })\n }\n // 下载文件\n const fileDownload = this.domNode.querySelector('a.ql-file-download')\n if (fileDownload) {\n fileDownload.addEventListener('click', (event) => {\n this.operateFile(event, 'download')\n })\n }\n // 删除文件\n const fileDelete = this.domNode.querySelector('a.ql-file-delete')\n if (fileDelete) {\n fileDelete.addEventListener('click', (event) => {\n this.operateFile(event, 'delete')\n const delta = new Delta()\n .retain(this.fileRange.index)\n .delete(this.fileRange.length)\n this.quill.updateContents(delta, Quill.sources.USER)\n this.quill.setSelection(this.fileRange.index)\n })\n }\n\n this.setPosition()\n this.quill.root.parentNode.appendChild(this.domNode)\n }\n\n destroy() {\n if (this.domNode) {\n this.domNode.remove()\n this.domNode = null\n this.file = null\n }\n }\n\n operateFile(event, operate) {\n event.preventDefault()\n const fileId = this.file.dataset.id || ''\n const fileName = this.file.dataset.title || ''\n const fileDownloadUrl = this.file.href || ''\n if (fileId) {\n this.quill.emitter.emit('file-change', {\n operation: operate,\n data: { fileId, fileDownloadUrl },\n })\n }\n if (operate === 'download') {\n const a = document.createElement('a')\n a.href = fileDownloadUrl\n a.target = '_blank'\n a.id = 'exppub'\n a.download = fileName\n document.body.appendChild(a)\n const alink = document.getElementById('exppub')\n alink.click()\n alink.parentNode.removeChild(a)\n }\n this.destroy()\n }\n\n setPosition() {\n if (this.domNode && this.file) {\n const parent = this.quill.root.parentNode\n const child = this.file.querySelector('span')\n const containerRect = parent.getBoundingClientRect()\n const fileRect = child.getBoundingClientRect()\n this.css(this.domNode, {\n left: `${fileRect.left - containerRect.left}px`,\n top: `${fileRect.top - containerRect.top + 10}px`,\n })\n }\n }\n\n css(domNode, rules) {\n if (typeof rules === 'object') {\n for (const prop in rules) {\n if (prop) {\n if (Array.isArray(rules[prop])) {\n // 兼容IE11浏览器\n rules[prop].forEach((val) => {\n domNode.style[prop] = val\n })\n }\n else {\n domNode.style[prop] = rules[prop]\n }\n }\n }\n }\n }\n\n formatDate(timestamp) {\n const date = new Date(timestamp)\n const year = date.getFullYear()\n // TODO\n const month = unshiftString(`${date.getMonth() + 1}`, 2, '0')\n const day = unshiftString(`${date.getDate()}`, 2, '0')\n const hour = unshiftString(`${date.getHours()}`, 2, '0')\n const minute = unshiftString(`${date.getMinutes()}`, 2, '0')\n return Number.isNaN(year) ? '--' : `${year}/${month}/${day} ${hour}:${minute}`\n }\n}\n"],"names":["File","Range","unshiftString"],"mappings":"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"}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
4
|
+
var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
5
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
6
|
+
const Quill = require("quill");
|
|
7
|
+
const file = require("../formats/file.cjs.js");
|
|
8
|
+
const fileBar = require("./file-bar.cjs.js");
|
|
9
|
+
class FileModule {
|
|
10
|
+
constructor(quill) {
|
|
11
|
+
__publicField(this, "fileBar");
|
|
12
|
+
this.quill = quill;
|
|
13
|
+
this.quill = quill;
|
|
14
|
+
quill.root.addEventListener("click", (event) => this.clickEvent(event), false);
|
|
15
|
+
}
|
|
16
|
+
static register() {
|
|
17
|
+
Quill.register("formats/file", file.File, true);
|
|
18
|
+
}
|
|
19
|
+
clickEvent(event) {
|
|
20
|
+
event.preventDefault();
|
|
21
|
+
const target = event.target;
|
|
22
|
+
const fileDom = target.closest("a.ql-file-item");
|
|
23
|
+
if (fileDom) {
|
|
24
|
+
if (this.fileBar) {
|
|
25
|
+
this.fileBar.destroy();
|
|
26
|
+
}
|
|
27
|
+
this.fileBar = new fileBar.FileBar(this.quill, fileDom);
|
|
28
|
+
} else if (this.fileBar && !target.closest(".ql-file-bar")) {
|
|
29
|
+
this.fileBar.destroy();
|
|
30
|
+
this.fileBar = null;
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
exports.FileModule = FileModule;
|
|
35
|
+
//# sourceMappingURL=file-module.cjs.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"file-module.cjs.js","sources":["../../../../../src/modules/file/modules/file-module.ts"],"sourcesContent":["import type FluentEditor from '../../../core/fluent-editor'\nimport Quill from 'quill'\nimport { File } from '../formats/file'\nimport { FileBar } from './file-bar'\n\nexport class FileModule {\n fileBar: FileBar\n\n static register() {\n Quill.register('formats/file', File, true)\n }\n\n constructor(public quill: FluentEditor) {\n this.quill = quill\n quill.root.addEventListener('click', event => this.clickEvent(event), false)\n }\n\n clickEvent(event: MouseEvent) {\n event.preventDefault()\n const target = event.target as HTMLElement\n const fileDom = target.closest('a.ql-file-item')\n if (fileDom) {\n if (this.fileBar) {\n this.fileBar.destroy()\n }\n this.fileBar = new FileBar(this.quill, fileDom)\n }\n else if (this.fileBar && !target.closest('.ql-file-bar')) {\n this.fileBar.destroy()\n this.fileBar = null\n }\n }\n}\n"],"names":["File","FileBar"],"mappings":";;;;;;;;AAKO,MAAM,WAAW;AAAA,EAOtB,YAAmB,OAAqB;AANxC;AAMmB,SAAA,QAAA;AACjB,SAAK,QAAQ;AACP,UAAA,KAAK,iBAAiB,SAAS,CAAA,UAAS,KAAK,WAAW,KAAK,GAAG,KAAK;AAAA,EAAA;AAAA,EAN7E,OAAO,WAAW;AACV,UAAA,SAAS,gBAAgBA,KAAAA,MAAM,IAAI;AAAA,EAAA;AAAA,EAQ3C,WAAW,OAAmB;AAC5B,UAAM,eAAe;AACrB,UAAM,SAAS,MAAM;AACf,UAAA,UAAU,OAAO,QAAQ,gBAAgB;AAC/C,QAAI,SAAS;AACX,UAAI,KAAK,SAAS;AAChB,aAAK,QAAQ,QAAQ;AAAA,MAAA;AAEvB,WAAK,UAAU,IAAIC,QAAAA,QAAQ,KAAK,OAAO,OAAO;AAAA,IAAA,WAEvC,KAAK,WAAW,CAAC,OAAO,QAAQ,cAAc,GAAG;AACxD,WAAK,QAAQ,QAAQ;AACrB,WAAK,UAAU;AAAA,IAAA;AAAA,EACjB;AAEJ;;"}
|
package/lib/modules/i18n.cjs.js
CHANGED
|
@@ -1,30 +1,52 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
4
|
+
var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
2
5
|
Object.defineProperties(exports, { __esModule: { value: true }, [Symbol.toStringTag]: { value: "Module" } });
|
|
3
6
|
require("../config/index.cjs.js");
|
|
4
7
|
const is = require("../utils/is.cjs.js");
|
|
5
8
|
const editor_config = require("../config/editor.config.cjs.js");
|
|
9
|
+
const langs = {};
|
|
6
10
|
class I18N {
|
|
7
11
|
constructor(quill, options) {
|
|
12
|
+
__publicField(this, "options", {
|
|
13
|
+
lang: ""
|
|
14
|
+
});
|
|
8
15
|
this.quill = quill;
|
|
9
|
-
this.isFullscreen = false;
|
|
10
|
-
this.options = {
|
|
11
|
-
lang: "en-US",
|
|
12
|
-
langText: editor_config.LANG_CONF["en-US"]
|
|
13
|
-
};
|
|
14
16
|
this.options = Object.assign({}, options, this.resolveLanguageOption(options || {}));
|
|
15
17
|
Promise.resolve().then(() => this.changeLanguage(this.options, true));
|
|
16
18
|
}
|
|
19
|
+
static register(inputLangs, isCover = true) {
|
|
20
|
+
for (const lang in inputLangs) {
|
|
21
|
+
const texts = inputLangs[lang];
|
|
22
|
+
if (isCover) {
|
|
23
|
+
langs[lang] = texts;
|
|
24
|
+
} else {
|
|
25
|
+
if (!langs[lang]) langs[lang] = {};
|
|
26
|
+
Object.assign(langs[lang], texts);
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
static parserText(text, lang) {
|
|
31
|
+
var _a;
|
|
32
|
+
const i18nPattern = /^_i18n"([^"]*)"/;
|
|
33
|
+
const match = text.match(i18nPattern);
|
|
34
|
+
let key = text;
|
|
35
|
+
if (match) {
|
|
36
|
+
key = match[1];
|
|
37
|
+
}
|
|
38
|
+
return ((_a = langs[lang]) == null ? void 0 : _a[key]) || key;
|
|
39
|
+
}
|
|
17
40
|
resolveLanguageOption(options) {
|
|
18
41
|
if (is.isUndefined(options.lang)) {
|
|
19
42
|
options.lang = editor_config.defaultLanguage;
|
|
20
43
|
}
|
|
21
|
-
if (!(options.lang in
|
|
44
|
+
if (!(options.lang in langs)) {
|
|
22
45
|
console.warn(`The language ${options.lang} is not supported. Use the default language: ${editor_config.defaultLanguage}`);
|
|
23
46
|
options.lang = editor_config.defaultLanguage;
|
|
24
47
|
}
|
|
25
48
|
return {
|
|
26
|
-
lang: options.lang
|
|
27
|
-
langText: Object.assign({}, editor_config.LANG_CONF[options.lang], options.langText || {})
|
|
49
|
+
lang: options.lang
|
|
28
50
|
};
|
|
29
51
|
}
|
|
30
52
|
changeLanguage(options, force = false) {
|
|
@@ -32,9 +54,9 @@ class I18N {
|
|
|
32
54
|
const langOps = this.resolveLanguageOption(options);
|
|
33
55
|
if (langOps.lang === currentLang && !force) return;
|
|
34
56
|
this.options.lang = langOps.lang;
|
|
35
|
-
this.options.
|
|
36
|
-
this.quill.emitter.emit(editor_config.CHANGE_LANGUAGE_EVENT, this.options.lang, this.options.langText);
|
|
57
|
+
this.quill.emitter.emit(editor_config.CHANGE_LANGUAGE_EVENT, this.options.lang, langs[langOps.lang]);
|
|
37
58
|
}
|
|
38
59
|
}
|
|
60
|
+
exports.I18N = I18N;
|
|
39
61
|
exports.default = I18N;
|
|
40
62
|
//# sourceMappingURL=i18n.cjs.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"i18n.cjs.js","sources":["../../../src/modules/i18n.ts"],"sourcesContent":["import type FluentEditor from '../fluent-editor'\r\nimport { CHANGE_LANGUAGE_EVENT, defaultLanguage
|
|
1
|
+
{"version":3,"file":"i18n.cjs.js","sources":["../../../src/modules/i18n.ts"],"sourcesContent":["import type FluentEditor from '../fluent-editor'\r\nimport { CHANGE_LANGUAGE_EVENT, defaultLanguage } from '../config'\r\nimport { isUndefined } from '../utils/is'\r\n\r\nconst langs: Record<string, Record<string, string>> = {}\r\n\r\nexport interface I18NOptions {\r\n lang: string\r\n}\r\nexport class I18N {\r\n static register(inputLangs: Record<string, Record<string, string>>, isCover: boolean = true) {\r\n for (const lang in inputLangs) {\r\n const texts = inputLangs[lang]\r\n if (isCover) {\r\n langs[lang] = texts\r\n }\r\n else {\r\n if (!langs[lang]) langs[lang] = {}\r\n Object.assign(langs[lang], texts)\r\n }\r\n }\r\n }\r\n\r\n static parserText(text: string, lang: string): string {\r\n const i18nPattern = /^_i18n\"([^\"]*)\"/\r\n const match = text.match(i18nPattern)\r\n let key = text\r\n if (match) {\r\n key = match[1]\r\n }\r\n return langs[lang]?.[key] || key\r\n }\r\n\r\n options: I18NOptions = {\r\n lang: '',\r\n }\r\n\r\n constructor(public quill: FluentEditor, options: Partial<I18NOptions>) {\r\n this.options = Object.assign({}, options, this.resolveLanguageOption(options || {}))\r\n // wait until all module registed\r\n Promise.resolve().then(() => this.changeLanguage(this.options, true))\r\n }\r\n\r\n resolveLanguageOption(options: Partial<I18NOptions>): I18NOptions {\r\n if (isUndefined(options.lang)) {\r\n options.lang = defaultLanguage\r\n }\r\n if (!(options.lang in langs)) {\r\n console.warn(`The language ${options.lang} is not supported. Use the default language: ${defaultLanguage}`)\r\n options.lang = defaultLanguage\r\n }\r\n return {\r\n lang: options.lang,\r\n }\r\n }\r\n\r\n changeLanguage(options: Partial<I18NOptions>, force: boolean = false) {\r\n const currentLang = this.options.lang\r\n const langOps = this.resolveLanguageOption(options)\r\n if (langOps.lang === currentLang && !force) return\r\n this.options.lang = langOps.lang\r\n this.quill.emitter.emit(CHANGE_LANGUAGE_EVENT, this.options.lang, langs[langOps.lang])\r\n }\r\n}\r\n\r\nexport default I18N\r\n"],"names":["isUndefined","defaultLanguage","CHANGE_LANGUAGE_EVENT"],"mappings":";;;;;;;;AAIA,MAAM,QAAgD,CAAC;AAKhD,MAAM,KAAK;AAAA,EA4BhB,YAAmB,OAAqB,SAA+B;AAJvE,mCAAuB;AAAA,MACrB,MAAM;AAAA,IACR;AAEmB,SAAA,QAAA;AACZ,SAAA,UAAU,OAAO,OAAO,CAAC,GAAG,SAAS,KAAK,sBAAsB,WAAW,CAAA,CAAE,CAAC;AAE3E,YAAA,UAAU,KAAK,MAAM,KAAK,eAAe,KAAK,SAAS,IAAI,CAAC;AAAA,EAAA;AAAA,EA9BtE,OAAO,SAAS,YAAoD,UAAmB,MAAM;AAC3F,eAAW,QAAQ,YAAY;AACvB,YAAA,QAAQ,WAAW,IAAI;AAC7B,UAAI,SAAS;AACX,cAAM,IAAI,IAAI;AAAA,MAAA,OAEX;AACH,YAAI,CAAC,MAAM,IAAI,EAAS,OAAA,IAAI,IAAI,CAAC;AACjC,eAAO,OAAO,MAAM,IAAI,GAAG,KAAK;AAAA,MAAA;AAAA,IAClC;AAAA,EACF;AAAA,EAGF,OAAO,WAAW,MAAc,MAAsB;;AACpD,UAAM,cAAc;AACd,UAAA,QAAQ,KAAK,MAAM,WAAW;AACpC,QAAI,MAAM;AACV,QAAI,OAAO;AACT,YAAM,MAAM,CAAC;AAAA,IAAA;AAEf,aAAO,WAAM,IAAI,MAAV,mBAAc,SAAQ;AAAA,EAAA;AAAA,EAa/B,sBAAsB,SAA4C;AAC5D,QAAAA,GAAA,YAAY,QAAQ,IAAI,GAAG;AAC7B,cAAQ,OAAOC,cAAA;AAAA,IAAA;AAEb,QAAA,EAAE,QAAQ,QAAQ,QAAQ;AAC5B,cAAQ,KAAK,gBAAgB,QAAQ,IAAI,gDAAgDA,cAAe,eAAA,EAAE;AAC1G,cAAQ,OAAOA,cAAA;AAAA,IAAA;AAEV,WAAA;AAAA,MACL,MAAM,QAAQ;AAAA,IAChB;AAAA,EAAA;AAAA,EAGF,eAAe,SAA+B,QAAiB,OAAO;AAC9D,UAAA,cAAc,KAAK,QAAQ;AAC3B,UAAA,UAAU,KAAK,sBAAsB,OAAO;AAClD,QAAI,QAAQ,SAAS,eAAe,CAAC,MAAO;AACvC,SAAA,QAAQ,OAAO,QAAQ;AACvB,SAAA,MAAM,QAAQ,KAAKC,cAAAA,uBAAuB,KAAK,QAAQ,MAAM,MAAM,QAAQ,IAAI,CAAC;AAAA,EAAA;AAEzF;;;"}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
3
|
+
require("./collaborative-editing/index.cjs.js");
|
|
4
|
+
require("./counter.cjs.js");
|
|
5
|
+
const customClipboard = require("./custom-clipboard.cjs.js");
|
|
6
|
+
require("./custom-image/index.cjs.js");
|
|
7
|
+
const customUploader = require("./custom-uploader.cjs.js");
|
|
8
|
+
const divider = require("./divider.cjs.js");
|
|
9
|
+
const emoji = require("./emoji.cjs.js");
|
|
10
|
+
require("./file/index.cjs.js");
|
|
11
|
+
const i18n = require("./i18n.cjs.js");
|
|
12
|
+
require("./link/index.cjs.js");
|
|
13
|
+
require("./mathlive/index.cjs.js");
|
|
14
|
+
require("./mention/index.cjs.js");
|
|
15
|
+
const index = require("./shortcut-key/index.cjs.js");
|
|
16
|
+
require("./syntax.cjs.js");
|
|
17
|
+
const index$1 = require("./table-up/index.cjs.js");
|
|
18
|
+
require("./toolbar/index.cjs.js");
|
|
19
|
+
exports.CustomClipboard = customClipboard.CustomClipboard;
|
|
20
|
+
exports.FileUploader = customUploader.FileUploader;
|
|
21
|
+
exports.DividerBlot = divider.DividerBlot;
|
|
22
|
+
exports.EmojiModule = emoji.EmojiModule;
|
|
23
|
+
exports.I18N = i18n.I18N;
|
|
24
|
+
exports.ShortCutKey = index.ShortCutKey;
|
|
25
|
+
exports.shortKey = index.shortKey;
|
|
26
|
+
exports.generateTableUp = index$1.generateTableUp;
|
|
27
|
+
//# sourceMappingURL=index.cjs.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.cjs.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;"}
|
|
@@ -1,10 +1,12 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var
|
|
3
|
-
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
4
|
+
var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
5
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
4
6
|
const Quill = require("quill");
|
|
5
7
|
const editor_utils = require("../../../config/editor.utils.cjs.js");
|
|
6
8
|
const Inline = Quill.import("blots/inline");
|
|
7
|
-
|
|
9
|
+
const _LinkBlot = class _LinkBlot extends Inline {
|
|
8
10
|
static create(value) {
|
|
9
11
|
const node = super.create(value);
|
|
10
12
|
let href = value;
|
|
@@ -26,14 +28,16 @@ let Link$1 = (_a = class extends Inline {
|
|
|
26
28
|
if (name !== this.statics.blotName || [false, null].includes(value)) {
|
|
27
29
|
super.format(name, value);
|
|
28
30
|
} else {
|
|
29
|
-
this.domNode.setAttribute("href",
|
|
31
|
+
this.domNode.setAttribute("href", _LinkBlot.sanitize(value));
|
|
30
32
|
}
|
|
31
33
|
}
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
34
|
+
};
|
|
35
|
+
__publicField(_LinkBlot, "blotName", "link");
|
|
36
|
+
__publicField(_LinkBlot, "tagName", "A");
|
|
37
|
+
__publicField(_LinkBlot, "SANITIZED_URL", "about:blank");
|
|
38
|
+
__publicField(_LinkBlot, "PROTOCOL_WHITELIST", ["http", "https", "mailto", "tel"]);
|
|
39
|
+
__publicField(_LinkBlot, "className", "ql-normal-link");
|
|
40
|
+
__publicField(_LinkBlot, "autoProtocol", "");
|
|
41
|
+
let LinkBlot = _LinkBlot;
|
|
42
|
+
exports.LinkBlot = LinkBlot;
|
|
39
43
|
//# sourceMappingURL=link.cjs.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"link.cjs.js","sources":["../../../../../src/modules/link/formats/link.ts"],"sourcesContent":["import type TypeInline from 'quill/blots/inline'\
|
|
1
|
+
{"version":3,"file":"link.cjs.js","sources":["../../../../../src/modules/link/formats/link.ts"],"sourcesContent":["import type TypeInline from 'quill/blots/inline'\nimport Quill from 'quill'\nimport { hadProtocol, sanitize } from '../../../config/editor.utils'\n\nconst Inline = Quill.import('blots/inline') as typeof TypeInline\n\nexport class LinkBlot extends Inline {\n static blotName = 'link'\n static tagName = 'A'\n static SANITIZED_URL = 'about:blank'\n static PROTOCOL_WHITELIST = ['http', 'https', 'mailto', 'tel']\n static className = 'ql-normal-link'\n\n static autoProtocol: string = ''\n static create(value: string) {\n const node = super.create(value)\n let href = value\n if (!hadProtocol(href) && this.autoProtocol) {\n href = `${this.autoProtocol}://${value}`\n }\n href = this.sanitize(href)\n node.setAttribute('href', href)\n node.setAttribute('target', '_blank')\n return node\n }\n\n static formats(domNode: HTMLElement): string | null {\n return domNode.getAttribute('href')\n }\n\n static sanitize(url: string) {\n return sanitize(url, this.PROTOCOL_WHITELIST) ? url : this.SANITIZED_URL\n }\n\n format(name: string, value: any) {\n if (name !== this.statics.blotName || [false, null].includes(value)) {\n super.format(name, value)\n }\n else {\n this.domNode.setAttribute('href', LinkBlot.sanitize(value))\n }\n }\n}\n"],"names":["hadProtocol","sanitize"],"mappings":";;;;;;;AAIA,MAAM,SAAS,MAAM,OAAO,cAAc;AAEnC,MAAM,YAAN,MAAM,kBAAiB,OAAO;AAAA,EAQnC,OAAO,OAAO,OAAe;AACrB,UAAA,OAAO,MAAM,OAAO,KAAK;AAC/B,QAAI,OAAO;AACX,QAAI,CAACA,aAAAA,YAAY,IAAI,KAAK,KAAK,cAAc;AAC3C,aAAO,GAAG,KAAK,YAAY,MAAM,KAAK;AAAA,IAAA;AAEjC,WAAA,KAAK,SAAS,IAAI;AACpB,SAAA,aAAa,QAAQ,IAAI;AACzB,SAAA,aAAa,UAAU,QAAQ;AAC7B,WAAA;AAAA,EAAA;AAAA,EAGT,OAAO,QAAQ,SAAqC;AAC3C,WAAA,QAAQ,aAAa,MAAM;AAAA,EAAA;AAAA,EAGpC,OAAO,SAAS,KAAa;AAC3B,WAAOC,aAAAA,SAAS,KAAK,KAAK,kBAAkB,IAAI,MAAM,KAAK;AAAA,EAAA;AAAA,EAG7D,OAAO,MAAc,OAAY;AAC3B,QAAA,SAAS,KAAK,QAAQ,YAAY,CAAC,OAAO,IAAI,EAAE,SAAS,KAAK,GAAG;AAC7D,YAAA,OAAO,MAAM,KAAK;AAAA,IAAA,OAErB;AACH,WAAK,QAAQ,aAAa,QAAQ,UAAS,SAAS,KAAK,CAAC;AAAA,IAAA;AAAA,EAC5D;AAEJ;AAnCE,cADW,WACJ,YAAW;AAClB,cAFW,WAEJ,WAAU;AACjB,cAHW,WAGJ,iBAAgB;AACvB,cAJW,WAIJ,sBAAqB,CAAC,QAAQ,SAAS,UAAU,KAAK;AAC7D,cALW,WAKJ,aAAY;AAEnB,cAPW,WAOJ,gBAAuB;AAPzB,IAAM,WAAN;;"}
|