@opentiny/fluent-editor 3.19.0 → 3.19.1-alpha.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +97 -96
- package/es/config/base64-image.es.js +9 -0
- package/es/config/base64-image.es.js.map +1 -0
- package/es/config/editor.config.es.js +86 -0
- package/es/config/editor.config.es.js.map +1 -0
- package/es/config/editor.utils.es.js +141 -0
- package/es/config/editor.utils.es.js.map +1 -0
- package/es/config/i18n/en-us.es.js +90 -0
- package/es/config/i18n/en-us.es.js.map +1 -0
- package/es/config/i18n/zh-cn.es.js +90 -0
- package/es/config/i18n/zh-cn.es.js.map +1 -0
- package/es/config/icons.config.es.js +301 -0
- package/es/config/icons.config.es.js.map +1 -0
- package/es/config/types/additional-toolbar-item.interface.es.js +2 -0
- package/es/config/types/additional-toolbar-item.interface.es.js.map +1 -0
- package/es/config/types/content-change.interface.es.js +2 -0
- package/es/config/types/content-change.interface.es.js.map +1 -0
- package/es/config/types/content-save.interface.es.js +2 -0
- package/es/config/types/content-save.interface.es.js.map +1 -0
- package/es/config/types/counter-option.interface.es.js +2 -0
- package/es/config/types/counter-option.interface.es.js.map +1 -0
- package/es/config/types/editor-config.interface.es.js +2 -0
- package/es/config/types/editor-config.interface.es.js.map +1 -0
- package/es/config/types/editor-modules.interface.es.js +2 -0
- package/es/config/types/editor-modules.interface.es.js.map +1 -0
- package/es/config/types/file-operation.interface.es.js +2 -0
- package/es/config/types/file-operation.interface.es.js.map +1 -0
- package/es/config/types/focus-change.interface.es.js +2 -0
- package/es/config/types/focus-change.interface.es.js.map +1 -0
- package/es/config/types/fullscreen-module.interface.es.js +2 -0
- package/es/config/types/fullscreen-module.interface.es.js.map +1 -0
- package/es/config/types/help-panel-item.interface.es.js +2 -0
- package/es/config/types/help-panel-item.interface.es.js.map +1 -0
- package/es/config/types/help-panel-option.interface.es.js +2 -0
- package/es/config/types/help-panel-option.interface.es.js.map +1 -0
- package/es/config/types/image-module.interface.es.js +2 -0
- package/es/config/types/image-module.interface.es.js.map +1 -0
- package/es/config/types/image-upload.interface.es.js +2 -0
- package/es/config/types/image-upload.interface.es.js.map +1 -0
- package/es/config/types/index.es.js +23 -0
- package/es/config/types/index.es.js.map +1 -0
- package/es/config/types/load-on-demand-module.interface.es.js +2 -0
- package/es/config/types/load-on-demand-module.interface.es.js.map +1 -0
- package/es/config/types/mention-module.interface.es.js +2 -0
- package/es/config/types/mention-module.interface.es.js.map +1 -0
- package/es/config/types/paste-change.interface.es.js +2 -0
- package/es/config/types/paste-change.interface.es.js.map +1 -0
- package/es/config/types/quick-menu-module.interface.es.js +2 -0
- package/es/config/types/quick-menu-module.interface.es.js.map +1 -0
- package/es/config/types/range.interface.es.js +2 -0
- package/es/config/types/range.interface.es.js.map +1 -0
- package/es/config/types/registry-options.interface.es.js +2 -0
- package/es/config/types/registry-options.interface.es.js.map +1 -0
- package/es/config/types/selection-change.interface.es.js +2 -0
- package/es/config/types/selection-change.interface.es.js.map +1 -0
- package/es/config/types/toolbar-item.interface.es.js +2 -0
- package/es/config/types/toolbar-item.interface.es.js.map +1 -0
- package/es/config/types/type.es.js +2 -0
- package/es/config/types/type.es.js.map +1 -0
- package/es/config/types/validate-error.interface.es.js +2 -0
- package/es/config/types/validate-error.interface.es.js.map +1 -0
- package/es/config.es.js +168 -0
- package/es/config.es.js.map +1 -0
- package/es/counter/index.es.js +60 -0
- package/es/counter/index.es.js.map +1 -0
- package/es/custom-clipboard.es.js +469 -0
- package/es/custom-clipboard.es.js.map +1 -0
- package/es/custom-image/BlotFormatter.es.js +136 -0
- package/es/custom-image/BlotFormatter.es.js.map +1 -0
- package/es/custom-image/Options.es.js +95 -0
- package/es/custom-image/Options.es.js.map +1 -0
- package/es/custom-image/actions/Action.es.js +15 -0
- package/es/custom-image/actions/Action.es.js.map +1 -0
- package/es/custom-image/actions/CustomResizeAction.es.js +158 -0
- package/es/custom-image/actions/CustomResizeAction.es.js.map +1 -0
- package/es/custom-image/actions/DeleteAction.es.js +31 -0
- package/es/custom-image/actions/DeleteAction.es.js.map +1 -0
- package/es/custom-image/image.es.js +95 -0
- package/es/custom-image/image.es.js.map +1 -0
- package/es/custom-image/specs/BlotSpec.es.js +27 -0
- package/es/custom-image/specs/BlotSpec.es.js.map +1 -0
- package/es/custom-image/specs/CustomImageSpec.es.js +117 -0
- package/es/custom-image/specs/CustomImageSpec.es.js.map +1 -0
- package/es/custom-image/specs/ImageSpec.es.js +29 -0
- package/es/custom-image/specs/ImageSpec.es.js.map +1 -0
- package/es/custom-uploader.es.js +161 -0
- package/es/custom-uploader.es.js.map +1 -0
- package/es/emoji/emoji-list/index.es.js +5 -0
- package/es/emoji/emoji-list/index.es.js.map +1 -0
- package/es/emoji/emoji-list/people.es.js +114 -0
- package/es/emoji/emoji-list/people.es.js.map +1 -0
- package/es/emoji/emoji-list.es.js +9 -0
- package/es/emoji/emoji-list.es.js.map +1 -0
- package/es/emoji/emoji-map.es.js +9 -0
- package/es/emoji/emoji-map.es.js.map +1 -0
- package/es/emoji/formats/emoji-blot.es.js +41 -0
- package/es/emoji/formats/emoji-blot.es.js.map +1 -0
- package/es/emoji/index.es.js +8 -0
- package/es/emoji/index.es.js.map +1 -0
- package/es/emoji/modules/emoji.es.js +248 -0
- package/es/emoji/modules/emoji.es.js.map +1 -0
- package/es/emoji/modules/toolbar-emoji.es.js +153 -0
- package/es/emoji/modules/toolbar-emoji.es.js.map +1 -0
- package/es/emoji/utils.es.js +19 -0
- package/es/emoji/utils.es.js.map +1 -0
- package/es/file/formats/file.es.js +56 -0
- package/es/file/formats/file.es.js.map +1 -0
- package/es/file/index.es.js +32 -0
- package/es/file/index.es.js.map +1 -0
- package/es/file/modules/file-bar.es.js +123 -0
- package/es/file/modules/file-bar.es.js.map +1 -0
- package/es/fluent-editor.es.js +163 -0
- package/es/fluent-editor.es.js.map +1 -0
- package/es/format-painter/index.es.js +66 -0
- package/es/format-painter/index.es.js.map +1 -0
- package/es/global-link/constants.es.js +9 -0
- package/es/global-link/constants.es.js.map +1 -0
- package/es/global-link/formats/customer-widget-link.es.js +28 -0
- package/es/global-link/formats/customer-widget-link.es.js.map +1 -0
- package/es/global-link/formats/doc-link.es.js +42 -0
- package/es/global-link/formats/doc-link.es.js.map +1 -0
- package/es/global-link/formats/wiki-link.es.js +34 -0
- package/es/global-link/formats/wiki-link.es.js.map +1 -0
- package/es/global-link/formats/work-item-link.es.js +36 -0
- package/es/global-link/formats/work-item-link.es.js.map +1 -0
- package/es/global-link/global-link-panel.es.js +2 -0
- package/es/global-link/global-link-panel.es.js.map +1 -0
- package/es/global-link/index.es.js +139 -0
- package/es/global-link/index.es.js.map +1 -0
- package/es/global-link/utils/createTable.es.js +50 -0
- package/es/global-link/utils/createTable.es.js.map +1 -0
- package/es/index.es.js +5 -0
- package/es/index.es.js.map +1 -0
- package/es/lineheight.es.js +11 -0
- package/es/lineheight.es.js.map +1 -0
- package/es/link/formats/link.es.js +34 -0
- package/es/link/formats/link.es.js.map +1 -0
- package/es/link/index.es.js +32 -0
- package/es/link/index.es.js.map +1 -0
- package/es/link/modules/tooltip.es.js +275 -0
- package/es/link/modules/tooltip.es.js.map +1 -0
- package/es/mention/Mention.es.js +329 -0
- package/es/mention/Mention.es.js.map +1 -0
- package/es/mention/MentionLink.es.js +37 -0
- package/es/mention/MentionLink.es.js.map +1 -0
- package/es/mention/constants.es.js +9 -0
- package/es/mention/constants.es.js.map +1 -0
- package/es/quick-menu/index.es.js +82 -0
- package/es/quick-menu/index.es.js.map +1 -0
- package/es/screenshot/index.es.js +147 -0
- package/es/screenshot/index.es.js.map +1 -0
- package/es/soft-break/index.es.js +23 -0
- package/es/soft-break/index.es.js.map +1 -0
- package/es/strike/index.es.js +12 -0
- package/es/strike/index.es.js.map +1 -0
- package/es/syntax/index.es.js +30 -0
- package/es/syntax/index.es.js.map +1 -0
- package/es/table/better-table.es.js +434 -0
- package/es/table/better-table.es.js.map +1 -0
- package/es/table/formats/header.es.js +94 -0
- package/es/table/formats/header.es.js.map +1 -0
- package/es/table/formats/list.es.js +163 -0
- package/es/table/formats/list.es.js.map +1 -0
- package/es/table/formats/table.es.js +970 -0
- package/es/table/formats/table.es.js.map +1 -0
- package/es/table/modules/table-column-tool.es.js +400 -0
- package/es/table/modules/table-column-tool.es.js.map +1 -0
- package/es/table/modules/table-operation-menu.es.js +457 -0
- package/es/table/modules/table-operation-menu.es.js.map +1 -0
- package/es/table/modules/table-scroll-bar.es.js +190 -0
- package/es/table/modules/table-scroll-bar.es.js.map +1 -0
- package/es/table/modules/table-selection.es.js +306 -0
- package/es/table/modules/table-selection.es.js.map +1 -0
- package/es/table/table-config.es.js +74 -0
- package/es/table/table-config.es.js.map +1 -0
- package/es/table/utils/index.es.js +54 -0
- package/es/table/utils/index.es.js.map +1 -0
- package/es/table/utils/node-matchers.es.js +292 -0
- package/es/table/utils/node-matchers.es.js.map +1 -0
- package/es/toolbar/better-picker.es.js +307 -0
- package/es/toolbar/better-picker.es.js.map +1 -0
- package/es/toolbar/index.es.js +139 -0
- package/es/toolbar/index.es.js.map +1 -0
- package/es/types/vue.d.es.js +2 -0
- package/es/types/vue.d.es.js.map +1 -0
- package/es/utils/debounce.es.js +112 -0
- package/es/utils/debounce.es.js.map +1 -0
- package/es/utils/method.es.js +68 -0
- package/es/utils/method.es.js.map +1 -0
- package/es/video/index.es.js +49 -0
- package/es/video/index.es.js.map +1 -0
- package/lib/config/base64-image.cjs.js +9 -0
- package/lib/config/base64-image.cjs.js.map +1 -0
- package/lib/config/editor.config.cjs.js +86 -0
- package/lib/config/editor.config.cjs.js.map +1 -0
- package/lib/config/editor.utils.cjs.js +141 -0
- package/lib/config/editor.utils.cjs.js.map +1 -0
- package/lib/config/i18n/en-us.cjs.js +90 -0
- package/lib/config/i18n/en-us.cjs.js.map +1 -0
- package/lib/config/i18n/zh-cn.cjs.js +90 -0
- package/lib/config/i18n/zh-cn.cjs.js.map +1 -0
- package/lib/config/icons.config.cjs.js +301 -0
- package/lib/config/icons.config.cjs.js.map +1 -0
- package/lib/config/types/additional-toolbar-item.interface.cjs.js +2 -0
- package/lib/config/types/additional-toolbar-item.interface.cjs.js.map +1 -0
- package/lib/config/types/content-change.interface.cjs.js +2 -0
- package/lib/config/types/content-change.interface.cjs.js.map +1 -0
- package/lib/config/types/content-save.interface.cjs.js +2 -0
- package/lib/config/types/content-save.interface.cjs.js.map +1 -0
- package/lib/config/types/counter-option.interface.cjs.js +2 -0
- package/lib/config/types/counter-option.interface.cjs.js.map +1 -0
- package/lib/config/types/editor-config.interface.cjs.js +2 -0
- package/lib/config/types/editor-config.interface.cjs.js.map +1 -0
- package/lib/config/types/editor-modules.interface.cjs.js +2 -0
- package/lib/config/types/editor-modules.interface.cjs.js.map +1 -0
- package/lib/config/types/file-operation.interface.cjs.js +2 -0
- package/lib/config/types/file-operation.interface.cjs.js.map +1 -0
- package/lib/config/types/focus-change.interface.cjs.js +2 -0
- package/lib/config/types/focus-change.interface.cjs.js.map +1 -0
- package/lib/config/types/fullscreen-module.interface.cjs.js +2 -0
- package/lib/config/types/fullscreen-module.interface.cjs.js.map +1 -0
- package/lib/config/types/help-panel-item.interface.cjs.js +2 -0
- package/lib/config/types/help-panel-item.interface.cjs.js.map +1 -0
- package/lib/config/types/help-panel-option.interface.cjs.js +2 -0
- package/lib/config/types/help-panel-option.interface.cjs.js.map +1 -0
- package/lib/config/types/image-module.interface.cjs.js +2 -0
- package/lib/config/types/image-module.interface.cjs.js.map +1 -0
- package/lib/config/types/image-upload.interface.cjs.js +2 -0
- package/lib/config/types/image-upload.interface.cjs.js.map +1 -0
- package/lib/config/types/index.cjs.js +24 -0
- package/lib/config/types/index.cjs.js.map +1 -0
- package/lib/config/types/load-on-demand-module.interface.cjs.js +2 -0
- package/lib/config/types/load-on-demand-module.interface.cjs.js.map +1 -0
- package/lib/config/types/mention-module.interface.cjs.js +2 -0
- package/lib/config/types/mention-module.interface.cjs.js.map +1 -0
- package/lib/config/types/paste-change.interface.cjs.js +2 -0
- package/lib/config/types/paste-change.interface.cjs.js.map +1 -0
- package/lib/config/types/quick-menu-module.interface.cjs.js +2 -0
- package/lib/config/types/quick-menu-module.interface.cjs.js.map +1 -0
- package/lib/config/types/range.interface.cjs.js +2 -0
- package/lib/config/types/range.interface.cjs.js.map +1 -0
- package/lib/config/types/registry-options.interface.cjs.js +2 -0
- package/lib/config/types/registry-options.interface.cjs.js.map +1 -0
- package/lib/config/types/selection-change.interface.cjs.js +2 -0
- package/lib/config/types/selection-change.interface.cjs.js.map +1 -0
- package/lib/config/types/toolbar-item.interface.cjs.js +2 -0
- package/lib/config/types/toolbar-item.interface.cjs.js.map +1 -0
- package/lib/config/types/type.cjs.js +2 -0
- package/lib/config/types/type.cjs.js.map +1 -0
- package/lib/config/types/validate-error.interface.cjs.js +2 -0
- package/lib/config/types/validate-error.interface.cjs.js.map +1 -0
- package/lib/config.cjs.js +168 -0
- package/lib/config.cjs.js.map +1 -0
- package/lib/counter/index.cjs.js +60 -0
- package/lib/counter/index.cjs.js.map +1 -0
- package/lib/custom-clipboard.cjs.js +469 -0
- package/lib/custom-clipboard.cjs.js.map +1 -0
- package/lib/custom-image/BlotFormatter.cjs.js +136 -0
- package/lib/custom-image/BlotFormatter.cjs.js.map +1 -0
- package/lib/custom-image/Options.cjs.js +95 -0
- package/lib/custom-image/Options.cjs.js.map +1 -0
- package/lib/custom-image/actions/Action.cjs.js +15 -0
- package/lib/custom-image/actions/Action.cjs.js.map +1 -0
- package/lib/custom-image/actions/CustomResizeAction.cjs.js +158 -0
- package/lib/custom-image/actions/CustomResizeAction.cjs.js.map +1 -0
- package/lib/custom-image/actions/DeleteAction.cjs.js +31 -0
- package/lib/custom-image/actions/DeleteAction.cjs.js.map +1 -0
- package/lib/custom-image/image.cjs.js +95 -0
- package/lib/custom-image/image.cjs.js.map +1 -0
- package/lib/custom-image/specs/BlotSpec.cjs.js +27 -0
- package/lib/custom-image/specs/BlotSpec.cjs.js.map +1 -0
- package/lib/custom-image/specs/CustomImageSpec.cjs.js +117 -0
- package/lib/custom-image/specs/CustomImageSpec.cjs.js.map +1 -0
- package/lib/custom-image/specs/ImageSpec.cjs.js +29 -0
- package/lib/custom-image/specs/ImageSpec.cjs.js.map +1 -0
- package/lib/custom-uploader.cjs.js +161 -0
- package/lib/custom-uploader.cjs.js.map +1 -0
- package/lib/emoji/emoji-list/index.cjs.js +5 -0
- package/lib/emoji/emoji-list/index.cjs.js.map +1 -0
- package/lib/emoji/emoji-list/people.cjs.js +114 -0
- package/lib/emoji/emoji-list/people.cjs.js.map +1 -0
- package/lib/emoji/emoji-list.cjs.js +9 -0
- package/lib/emoji/emoji-list.cjs.js.map +1 -0
- package/lib/emoji/emoji-map.cjs.js +9 -0
- package/lib/emoji/emoji-map.cjs.js.map +1 -0
- package/lib/emoji/formats/emoji-blot.cjs.js +41 -0
- package/lib/emoji/formats/emoji-blot.cjs.js.map +1 -0
- package/lib/emoji/index.cjs.js +8 -0
- package/lib/emoji/index.cjs.js.map +1 -0
- package/lib/emoji/modules/emoji.cjs.js +248 -0
- package/lib/emoji/modules/emoji.cjs.js.map +1 -0
- package/lib/emoji/modules/toolbar-emoji.cjs.js +153 -0
- package/lib/emoji/modules/toolbar-emoji.cjs.js.map +1 -0
- package/lib/emoji/utils.cjs.js +19 -0
- package/lib/emoji/utils.cjs.js.map +1 -0
- package/lib/file/formats/file.cjs.js +56 -0
- package/lib/file/formats/file.cjs.js.map +1 -0
- package/lib/file/index.cjs.js +32 -0
- package/lib/file/index.cjs.js.map +1 -0
- package/lib/file/modules/file-bar.cjs.js +123 -0
- package/lib/file/modules/file-bar.cjs.js.map +1 -0
- package/lib/fluent-editor.cjs.js +163 -0
- package/lib/fluent-editor.cjs.js.map +1 -0
- package/lib/format-painter/index.cjs.js +66 -0
- package/lib/format-painter/index.cjs.js.map +1 -0
- package/lib/global-link/constants.cjs.js +9 -0
- package/lib/global-link/constants.cjs.js.map +1 -0
- package/lib/global-link/formats/customer-widget-link.cjs.js +28 -0
- package/lib/global-link/formats/customer-widget-link.cjs.js.map +1 -0
- package/lib/global-link/formats/doc-link.cjs.js +42 -0
- package/lib/global-link/formats/doc-link.cjs.js.map +1 -0
- package/lib/global-link/formats/wiki-link.cjs.js +34 -0
- package/lib/global-link/formats/wiki-link.cjs.js.map +1 -0
- package/lib/global-link/formats/work-item-link.cjs.js +36 -0
- package/lib/global-link/formats/work-item-link.cjs.js.map +1 -0
- package/lib/global-link/global-link-panel.cjs.js +2 -0
- package/lib/global-link/global-link-panel.cjs.js.map +1 -0
- package/lib/global-link/index.cjs.js +139 -0
- package/lib/global-link/index.cjs.js.map +1 -0
- package/lib/global-link/utils/createTable.cjs.js +50 -0
- package/lib/global-link/utils/createTable.cjs.js.map +1 -0
- package/lib/index.cjs.js +5 -0
- package/lib/index.cjs.js.map +1 -0
- package/lib/lineheight.cjs.js +11 -0
- package/lib/lineheight.cjs.js.map +1 -0
- package/lib/link/formats/link.cjs.js +34 -0
- package/lib/link/formats/link.cjs.js.map +1 -0
- package/lib/link/index.cjs.js +32 -0
- package/lib/link/index.cjs.js.map +1 -0
- package/lib/link/modules/tooltip.cjs.js +275 -0
- package/lib/link/modules/tooltip.cjs.js.map +1 -0
- package/lib/mention/Mention.cjs.js +329 -0
- package/lib/mention/Mention.cjs.js.map +1 -0
- package/lib/mention/MentionLink.cjs.js +37 -0
- package/lib/mention/MentionLink.cjs.js.map +1 -0
- package/lib/mention/constants.cjs.js +9 -0
- package/lib/mention/constants.cjs.js.map +1 -0
- package/lib/quick-menu/index.cjs.js +82 -0
- package/lib/quick-menu/index.cjs.js.map +1 -0
- package/lib/screenshot/index.cjs.js +147 -0
- package/lib/screenshot/index.cjs.js.map +1 -0
- package/lib/soft-break/index.cjs.js +23 -0
- package/lib/soft-break/index.cjs.js.map +1 -0
- package/lib/strike/index.cjs.js +12 -0
- package/lib/strike/index.cjs.js.map +1 -0
- package/lib/syntax/index.cjs.js +30 -0
- package/lib/syntax/index.cjs.js.map +1 -0
- package/lib/table/better-table.cjs.js +434 -0
- package/lib/table/better-table.cjs.js.map +1 -0
- package/lib/table/formats/header.cjs.js +94 -0
- package/lib/table/formats/header.cjs.js.map +1 -0
- package/lib/table/formats/list.cjs.js +163 -0
- package/lib/table/formats/list.cjs.js.map +1 -0
- package/lib/table/formats/table.cjs.js +970 -0
- package/lib/table/formats/table.cjs.js.map +1 -0
- package/lib/table/modules/table-column-tool.cjs.js +400 -0
- package/lib/table/modules/table-column-tool.cjs.js.map +1 -0
- package/lib/table/modules/table-operation-menu.cjs.js +457 -0
- package/lib/table/modules/table-operation-menu.cjs.js.map +1 -0
- package/lib/table/modules/table-scroll-bar.cjs.js +190 -0
- package/lib/table/modules/table-scroll-bar.cjs.js.map +1 -0
- package/lib/table/modules/table-selection.cjs.js +306 -0
- package/lib/table/modules/table-selection.cjs.js.map +1 -0
- package/lib/table/table-config.cjs.js +74 -0
- package/lib/table/table-config.cjs.js.map +1 -0
- package/lib/table/utils/index.cjs.js +54 -0
- package/lib/table/utils/index.cjs.js.map +1 -0
- package/lib/table/utils/node-matchers.cjs.js +292 -0
- package/lib/table/utils/node-matchers.cjs.js.map +1 -0
- package/lib/toolbar/better-picker.cjs.js +308 -0
- package/lib/toolbar/better-picker.cjs.js.map +1 -0
- package/lib/toolbar/index.cjs.js +139 -0
- package/lib/toolbar/index.cjs.js.map +1 -0
- package/lib/types/vue.d.cjs.js +2 -0
- package/lib/types/vue.d.cjs.js.map +1 -0
- package/lib/utils/debounce.cjs.js +112 -0
- package/lib/utils/debounce.cjs.js.map +1 -0
- package/lib/utils/method.cjs.js +68 -0
- package/lib/utils/method.cjs.js.map +1 -0
- package/lib/video/index.cjs.js +49 -0
- package/lib/video/index.cjs.js.map +1 -0
- package/package.json +63 -65
- package/theme/index.css +4742 -0
- package/index.cjs.js +0 -374
- package/index.cjs.js.map +0 -1
- package/index.es.js +0 -51095
- package/index.es.js.map +0 -1
- package/style.css +0 -7
|
@@ -0,0 +1,970 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
3
|
+
const Quill = require("quill");
|
|
4
|
+
const method = require("../../utils/method.cjs.js");
|
|
5
|
+
const editor_utils = require("../../config/editor.utils.cjs.js");
|
|
6
|
+
const tableConfig = require("../table-config.cjs.js");
|
|
7
|
+
const index = require("../utils/index.cjs.js");
|
|
8
|
+
const header = require("./header.cjs.js");
|
|
9
|
+
const list = require("./list.cjs.js");
|
|
10
|
+
const Break = Quill.imports["blots/break"];
|
|
11
|
+
const Block = Quill.imports["blots/block"];
|
|
12
|
+
const Container = Quill.imports["blots/container"];
|
|
13
|
+
class TableCellLine extends Block {
|
|
14
|
+
static create(value) {
|
|
15
|
+
const node = super.create(value);
|
|
16
|
+
if (value.tdBgColor) {
|
|
17
|
+
node.setAttribute(`data-parent-bg`, value.tdBgColor);
|
|
18
|
+
delete value.tdBgColor;
|
|
19
|
+
}
|
|
20
|
+
tableConfig.CELL_IDENTITY_KEYS.forEach((key) => {
|
|
21
|
+
const identityMaker = key === "row" ? rowId : cellId;
|
|
22
|
+
node.setAttribute(`data-${key}`, value[key] || identityMaker());
|
|
23
|
+
});
|
|
24
|
+
tableConfig.CELL_ATTRIBUTES.forEach((attrName) => {
|
|
25
|
+
const keyValue = value[attrName] || tableConfig.CELL_DEFAULT[attrName];
|
|
26
|
+
keyValue && node.setAttribute(`data-${attrName}`, keyValue);
|
|
27
|
+
});
|
|
28
|
+
if (value.height) {
|
|
29
|
+
node.setAttribute("height", value.height);
|
|
30
|
+
}
|
|
31
|
+
return node;
|
|
32
|
+
}
|
|
33
|
+
static formats(domNode) {
|
|
34
|
+
const formats = {};
|
|
35
|
+
if (formats["list"]) {
|
|
36
|
+
formats["list"] = domNode.classList.item(0);
|
|
37
|
+
}
|
|
38
|
+
return reduceFormats(domNode, formats);
|
|
39
|
+
}
|
|
40
|
+
toggleAttribute(name, value) {
|
|
41
|
+
if (value) {
|
|
42
|
+
this.domNode.setAttribute(name, value);
|
|
43
|
+
} else {
|
|
44
|
+
this.domNode.removeAttribute(name);
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
formatChildren(name, value) {
|
|
48
|
+
this.children.forEach((child) => {
|
|
49
|
+
child.format && child.format(name, value);
|
|
50
|
+
if (!child.domNode.style) {
|
|
51
|
+
return;
|
|
52
|
+
}
|
|
53
|
+
if (child.domNode.tagName === "SPAN" && value) {
|
|
54
|
+
child.domNode.style.backgroundColor = value;
|
|
55
|
+
} else {
|
|
56
|
+
child.domNode.style.backgroundColor = "initial";
|
|
57
|
+
}
|
|
58
|
+
});
|
|
59
|
+
}
|
|
60
|
+
format(name, value) {
|
|
61
|
+
if ([...tableConfig.CELL_ATTRIBUTES, ...tableConfig.CELL_IDENTITY_KEYS, "parent-bg"].indexOf(name) > -1) {
|
|
62
|
+
if (value) {
|
|
63
|
+
this.domNode.setAttribute(`data-${name}`, value);
|
|
64
|
+
} else {
|
|
65
|
+
this.domNode.removeAttribute(`data-${name}`);
|
|
66
|
+
}
|
|
67
|
+
} else if (name === "header") {
|
|
68
|
+
if (!value) {
|
|
69
|
+
return;
|
|
70
|
+
}
|
|
71
|
+
const { row, cell, rowspan, colspan } = TableCellLine.formats(this.domNode);
|
|
72
|
+
super.format(name, {
|
|
73
|
+
value,
|
|
74
|
+
row,
|
|
75
|
+
cell,
|
|
76
|
+
rowspan,
|
|
77
|
+
colspan
|
|
78
|
+
});
|
|
79
|
+
} else {
|
|
80
|
+
super.format(name, value);
|
|
81
|
+
}
|
|
82
|
+
switch (true) {
|
|
83
|
+
case name === "cell-bg": {
|
|
84
|
+
this.toggleAttribute("data-cell-bg", value);
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
optimize(context) {
|
|
89
|
+
super.optimize(context);
|
|
90
|
+
const { row, cell, rowspan, colspan, cellBg } = this.domNode.dataset;
|
|
91
|
+
const formats = TableCellLine.formats(this.domNode);
|
|
92
|
+
const parentFormats = this.parent.formats();
|
|
93
|
+
if (this.statics.requiredContainer && !(this.parent instanceof this.statics.requiredContainer)) {
|
|
94
|
+
this.wrap(this.statics.requiredContainer.blotName, { row, cell, rowspan, colspan, cellBg });
|
|
95
|
+
} else if (!method.compare(formats, parentFormats)) {
|
|
96
|
+
this.parent.format("row", formats.row);
|
|
97
|
+
this.parent.format("cell", formats.cell);
|
|
98
|
+
this.parent.format("rowspan", formats.rowspan);
|
|
99
|
+
this.parent.format("colspan", formats.colspan);
|
|
100
|
+
formats["cell-bg"] && this.parent.setCellBg(formats["cell-bg"]);
|
|
101
|
+
}
|
|
102
|
+
const parentHeight = this.domNode.getAttribute("height");
|
|
103
|
+
if (parentHeight) {
|
|
104
|
+
this.parent.domNode.style.height = parentHeight;
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
tableCell() {
|
|
108
|
+
return this.parent;
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
TableCellLine.blotName = "table-cell-line";
|
|
112
|
+
TableCellLine.className = "qlbt-cell-line";
|
|
113
|
+
TableCellLine.tagName = "DIV";
|
|
114
|
+
class TableCell extends Container {
|
|
115
|
+
static create(value = { row: rowId() }) {
|
|
116
|
+
const node = super.create(value);
|
|
117
|
+
tableConfig.CELL_IDENTITY_KEYS.forEach((key) => {
|
|
118
|
+
node.setAttribute(`data-${key}`, value[key]);
|
|
119
|
+
});
|
|
120
|
+
tableConfig.CELL_ATTRIBUTES.forEach((attrName) => {
|
|
121
|
+
if (value[attrName]) {
|
|
122
|
+
node.setAttribute(attrName, value[attrName]);
|
|
123
|
+
}
|
|
124
|
+
});
|
|
125
|
+
return node;
|
|
126
|
+
}
|
|
127
|
+
static formats(domNode) {
|
|
128
|
+
const formats = {
|
|
129
|
+
height: void 0,
|
|
130
|
+
row: void 0
|
|
131
|
+
};
|
|
132
|
+
formats.height = domNode.getAttribute("height") || void 0;
|
|
133
|
+
if (domNode.hasAttribute("data-row")) {
|
|
134
|
+
formats.row = domNode.getAttribute("data-row");
|
|
135
|
+
}
|
|
136
|
+
if (domNode.hasAttribute("data-cell-bg")) {
|
|
137
|
+
formats["cell-bg"] = domNode.getAttribute("data-cell-bg") || void 0;
|
|
138
|
+
}
|
|
139
|
+
return tableConfig.CELL_ATTRIBUTES.reduce((formats2, attribute) => {
|
|
140
|
+
if (domNode.hasAttribute(attribute)) {
|
|
141
|
+
formats2[attribute] = domNode.getAttribute(attribute);
|
|
142
|
+
}
|
|
143
|
+
return formats2;
|
|
144
|
+
}, formats);
|
|
145
|
+
}
|
|
146
|
+
checkMerge() {
|
|
147
|
+
if (super.checkMerge() && !editor_utils.isNullOrUndefined(this.next.children.head)) {
|
|
148
|
+
const getCellId = (node) => {
|
|
149
|
+
return node.formats && node.formats()[node.statics.blotName] || {
|
|
150
|
+
cell: node.domNode.getAttribute("data-cell")
|
|
151
|
+
};
|
|
152
|
+
};
|
|
153
|
+
const thisHead = getCellId(this.children.head);
|
|
154
|
+
const thisTail = getCellId(this.children.tail);
|
|
155
|
+
const nextHead = getCellId(this.next.children.head);
|
|
156
|
+
const nextTail = getCellId(this.next.children.tail);
|
|
157
|
+
return thisHead.cell === thisTail.cell && thisHead.cell === nextHead.cell && thisHead.cell === nextTail.cell;
|
|
158
|
+
}
|
|
159
|
+
return false;
|
|
160
|
+
}
|
|
161
|
+
cellOffset() {
|
|
162
|
+
if (this.parent) {
|
|
163
|
+
return this.parent.children.indexOf(this);
|
|
164
|
+
}
|
|
165
|
+
return -1;
|
|
166
|
+
}
|
|
167
|
+
formats() {
|
|
168
|
+
const formats = {};
|
|
169
|
+
if (this.domNode.hasAttribute("data-row")) {
|
|
170
|
+
formats["row"] = this.domNode.getAttribute("data-row");
|
|
171
|
+
}
|
|
172
|
+
if (this.domNode.hasAttribute("data-cell")) {
|
|
173
|
+
formats["cell"] = this.domNode.getAttribute("data-cell");
|
|
174
|
+
}
|
|
175
|
+
return tableConfig.CELL_ATTRIBUTES.reduce((tableFormats, attribute) => {
|
|
176
|
+
if (this.domNode.hasAttribute(attribute)) {
|
|
177
|
+
tableFormats[attribute] = this.domNode.getAttribute(attribute);
|
|
178
|
+
}
|
|
179
|
+
return tableFormats;
|
|
180
|
+
}, formats);
|
|
181
|
+
}
|
|
182
|
+
toggleAttribute(name, value) {
|
|
183
|
+
if (value) {
|
|
184
|
+
this.domNode.setAttribute(name, value);
|
|
185
|
+
} else {
|
|
186
|
+
this.domNode.removeAttribute(name);
|
|
187
|
+
}
|
|
188
|
+
}
|
|
189
|
+
formatChildren(name, value) {
|
|
190
|
+
this.children.forEach((child) => {
|
|
191
|
+
child.format(name, value);
|
|
192
|
+
});
|
|
193
|
+
}
|
|
194
|
+
/** this method is for TableCellLine to change cell background color
|
|
195
|
+
* if use `format('cell-bg', value)` will loop trigger
|
|
196
|
+
* TableCellLine.optimize -> TableCell.format -> TableCellLine.optimize ...
|
|
197
|
+
*/
|
|
198
|
+
setCellBg(value) {
|
|
199
|
+
if (value) {
|
|
200
|
+
this.domNode.style.backgroundColor = value;
|
|
201
|
+
} else {
|
|
202
|
+
this.domNode.style.backgroundColor = "initial";
|
|
203
|
+
}
|
|
204
|
+
}
|
|
205
|
+
format(name, value) {
|
|
206
|
+
const quill = Quill.find(this.scroll.domNode.parentNode);
|
|
207
|
+
switch (true) {
|
|
208
|
+
case tableConfig.CELL_ATTRIBUTES.indexOf(name) > -1:
|
|
209
|
+
this.toggleAttribute(name, value);
|
|
210
|
+
break;
|
|
211
|
+
case ["row", "cell"].indexOf(name) > -1:
|
|
212
|
+
this.toggleAttribute(`data-${name}`, value);
|
|
213
|
+
break;
|
|
214
|
+
case name === "background": {
|
|
215
|
+
const hasBgColor = this.domNode.querySelectorAll("div.qlbt-cell-line[data-parent-bg]");
|
|
216
|
+
hasBgColor.forEach((child) => child.removeAttribute("data-parent-bg"));
|
|
217
|
+
this.domNode.style.background = "";
|
|
218
|
+
this.domNode.style.backgroundColor = value;
|
|
219
|
+
this.children.head.format("parent-bg", value);
|
|
220
|
+
break;
|
|
221
|
+
}
|
|
222
|
+
case name === "size": {
|
|
223
|
+
const start = quill.getIndex(this.children.head);
|
|
224
|
+
const total = quill.getIndex(this.children.tail) + this.children.tail.length();
|
|
225
|
+
const length = total - start > 0 ? total - start : 0;
|
|
226
|
+
quill.setSelection(start, length, Quill.sources.USER);
|
|
227
|
+
quill.format(name, value, Quill.sources.USER);
|
|
228
|
+
quill.setSelection(start);
|
|
229
|
+
}
|
|
230
|
+
case name === "cell-bg": {
|
|
231
|
+
this.toggleAttribute("data-cell-bg", value);
|
|
232
|
+
this.toggleAttribute("data-parent-bg", value);
|
|
233
|
+
this.formatChildren(name, value);
|
|
234
|
+
this.setCellBg(value);
|
|
235
|
+
}
|
|
236
|
+
}
|
|
237
|
+
}
|
|
238
|
+
optimize(context) {
|
|
239
|
+
const hasBg = Array.from(this.domNode.childNodes).find((item) => item.getAttribute("data-parent-bg"));
|
|
240
|
+
const bgColor = hasBg && hasBg.getAttribute("data-parent-bg");
|
|
241
|
+
if (bgColor && bgColor !== this.domNode.style.backgroundColor) {
|
|
242
|
+
this.domNode.style.backgroundColor = bgColor;
|
|
243
|
+
}
|
|
244
|
+
const rId = this.domNode.getAttribute("data-row");
|
|
245
|
+
if (this.statics.requiredContainer && !(this.parent instanceof this.statics.requiredContainer)) {
|
|
246
|
+
this.wrap(this.statics.requiredContainer.blotName, {
|
|
247
|
+
row: rId
|
|
248
|
+
});
|
|
249
|
+
} else if (rId !== this.parent.formats().row) {
|
|
250
|
+
this.parent.format("row", rId);
|
|
251
|
+
}
|
|
252
|
+
this.children.forEach((child) => {
|
|
253
|
+
if (editor_utils.isNullOrUndefined(child.next)) {
|
|
254
|
+
return;
|
|
255
|
+
}
|
|
256
|
+
const childFormats = this.getFormat(child.domNode);
|
|
257
|
+
const nextFormats = this.getFormat(child.next.domNode);
|
|
258
|
+
if (childFormats.cell !== nextFormats.cell) {
|
|
259
|
+
const next = this.splitAfter(child);
|
|
260
|
+
if (next) {
|
|
261
|
+
next.optimize();
|
|
262
|
+
}
|
|
263
|
+
if (this.prev) {
|
|
264
|
+
this.prev.optimize();
|
|
265
|
+
}
|
|
266
|
+
}
|
|
267
|
+
});
|
|
268
|
+
super.optimize(context);
|
|
269
|
+
}
|
|
270
|
+
// 兼容读取TableCell中的子blot,包括table-cell-line、line、head
|
|
271
|
+
getFormat(domNode) {
|
|
272
|
+
const formats = {};
|
|
273
|
+
const firstChild = domNode.childNodes[0];
|
|
274
|
+
if (firstChild && domNode.tagName === "OL") {
|
|
275
|
+
formats["list"] = firstChild.classList.item(0);
|
|
276
|
+
}
|
|
277
|
+
return reduceFormats(domNode, formats);
|
|
278
|
+
}
|
|
279
|
+
row() {
|
|
280
|
+
return this.parent;
|
|
281
|
+
}
|
|
282
|
+
rowOffset() {
|
|
283
|
+
if (this.row()) {
|
|
284
|
+
return -1;
|
|
285
|
+
}
|
|
286
|
+
return this.row().rowOffset();
|
|
287
|
+
}
|
|
288
|
+
table() {
|
|
289
|
+
return this.row() && this.row().table();
|
|
290
|
+
}
|
|
291
|
+
}
|
|
292
|
+
TableCell.blotName = "table";
|
|
293
|
+
TableCell.tagName = "TD";
|
|
294
|
+
class TableRow extends Container {
|
|
295
|
+
static create(value) {
|
|
296
|
+
const node = super.create(value);
|
|
297
|
+
if (value.row) {
|
|
298
|
+
node.setAttribute("data-row", value.row);
|
|
299
|
+
}
|
|
300
|
+
return node;
|
|
301
|
+
}
|
|
302
|
+
checkMerge() {
|
|
303
|
+
if (super.checkMerge() && !editor_utils.isNullOrUndefined(this.next.children.head)) {
|
|
304
|
+
const thisHead = this.children.head.formats();
|
|
305
|
+
const thisTail = this.children.tail.formats();
|
|
306
|
+
const nextHead = this.next.children.head.formats();
|
|
307
|
+
const nextTail = this.next.children.tail.formats();
|
|
308
|
+
return thisHead.row === thisTail.row && thisHead.row === nextHead.row && thisHead.row === nextTail.row;
|
|
309
|
+
}
|
|
310
|
+
return false;
|
|
311
|
+
}
|
|
312
|
+
formats() {
|
|
313
|
+
return ["row"].reduce((formats, attrName) => {
|
|
314
|
+
if (this.domNode.hasAttribute(`data-${attrName}`)) {
|
|
315
|
+
formats[attrName] = this.domNode.getAttribute(`data-${attrName}`);
|
|
316
|
+
}
|
|
317
|
+
return formats;
|
|
318
|
+
}, {});
|
|
319
|
+
}
|
|
320
|
+
format(key, value) {
|
|
321
|
+
this.domNode.setAttribute(`data-${key}`, value);
|
|
322
|
+
}
|
|
323
|
+
optimize(context) {
|
|
324
|
+
if (this.statics.requiredContainer && !(this.parent instanceof this.statics.requiredContainer)) {
|
|
325
|
+
this.wrap(this.statics.requiredContainer.blotName);
|
|
326
|
+
}
|
|
327
|
+
this.children.forEach((child) => {
|
|
328
|
+
if (editor_utils.isNullOrUndefined(child.next)) {
|
|
329
|
+
return;
|
|
330
|
+
}
|
|
331
|
+
const childFormats = child.formats();
|
|
332
|
+
const nextFormats = child.next.formats();
|
|
333
|
+
if (childFormats.row !== nextFormats.row) {
|
|
334
|
+
const next = this.splitAfter(child);
|
|
335
|
+
if (next) {
|
|
336
|
+
next.optimize();
|
|
337
|
+
}
|
|
338
|
+
if (this.prev) {
|
|
339
|
+
this.prev.optimize();
|
|
340
|
+
}
|
|
341
|
+
}
|
|
342
|
+
});
|
|
343
|
+
super.optimize(context);
|
|
344
|
+
}
|
|
345
|
+
rowOffset() {
|
|
346
|
+
if (!this.parent) {
|
|
347
|
+
return -1;
|
|
348
|
+
}
|
|
349
|
+
return this.parent.children.indexOf(this);
|
|
350
|
+
}
|
|
351
|
+
table() {
|
|
352
|
+
return this.parent && this.parent.parent;
|
|
353
|
+
}
|
|
354
|
+
}
|
|
355
|
+
TableRow.blotName = "table-row";
|
|
356
|
+
TableRow.tagName = "TR";
|
|
357
|
+
class TableBody extends Container {
|
|
358
|
+
}
|
|
359
|
+
TableBody.blotName = "table-body";
|
|
360
|
+
TableBody.tagName = "TBODY";
|
|
361
|
+
class TableCol extends Block {
|
|
362
|
+
static create(value) {
|
|
363
|
+
const node = super.create(value);
|
|
364
|
+
tableConfig.COL_ATTRIBUTES.forEach((attrName) => {
|
|
365
|
+
node.setAttribute(`${attrName}`, value[attrName] || tableConfig.COL_DEFAULT[attrName]);
|
|
366
|
+
});
|
|
367
|
+
return node;
|
|
368
|
+
}
|
|
369
|
+
static formats(domNode) {
|
|
370
|
+
return tableConfig.COL_ATTRIBUTES.reduce((formats, attribute) => {
|
|
371
|
+
if (domNode.hasAttribute(`${attribute}`)) {
|
|
372
|
+
formats[attribute] = domNode.getAttribute(`${attribute}`) || void 0;
|
|
373
|
+
}
|
|
374
|
+
return formats;
|
|
375
|
+
}, {});
|
|
376
|
+
}
|
|
377
|
+
format(name, value) {
|
|
378
|
+
if (tableConfig.COL_ATTRIBUTES.indexOf(name) > -1) {
|
|
379
|
+
this.domNode.setAttribute(`${name}`, value || tableConfig.COL_DEFAULT[name]);
|
|
380
|
+
} else {
|
|
381
|
+
super.format(name, value);
|
|
382
|
+
}
|
|
383
|
+
}
|
|
384
|
+
html() {
|
|
385
|
+
return this.domNode.outerHTML;
|
|
386
|
+
}
|
|
387
|
+
}
|
|
388
|
+
TableCol.blotName = "table-col";
|
|
389
|
+
TableCol.tagName = "col";
|
|
390
|
+
class TableColGroup extends Container {
|
|
391
|
+
optimize(context) {
|
|
392
|
+
super.optimize(context);
|
|
393
|
+
if (this.parent && this.statics.requiredContainer && this.parent instanceof this.statics.requiredContainer) {
|
|
394
|
+
this.parent.updateTableWidth();
|
|
395
|
+
}
|
|
396
|
+
if (this.parent.parent.domNode.className === "quill-better-table-wrapper" && this.parent.parent.domNode.tagName === "DIV" && this.parent.domNode.children.length >= 2 && this.parent.domNode.children[0].tagName === "COLGROUP" && this.parent.domNode.children[1].tagName === "TBODY") {
|
|
397
|
+
let trId = "";
|
|
398
|
+
let colSpan = 0;
|
|
399
|
+
let colgroupNumber = 0;
|
|
400
|
+
for (let i = 0; i < this.parent.domNode.children.length; i++) {
|
|
401
|
+
if (this.parent.domNode.children[i].tagName === "TBODY") {
|
|
402
|
+
if (trId === "") {
|
|
403
|
+
trId = this.parent.domNode.children[i].children[0].getAttribute("data-row");
|
|
404
|
+
}
|
|
405
|
+
colSpan = this.findTdColspanInTbody(this.parent.domNode.children[i], trId);
|
|
406
|
+
} else if (this.parent.domNode.children[i].tagName === "COLGROUP") {
|
|
407
|
+
colgroupNumber = this.parent.domNode.children[i].children.length;
|
|
408
|
+
}
|
|
409
|
+
}
|
|
410
|
+
let elementSibling = this.parent.domNode.nextElementSibling;
|
|
411
|
+
while (elementSibling && elementSibling.tagName === "TABLE") {
|
|
412
|
+
for (let i = 0; i < elementSibling.children.length; i++) {
|
|
413
|
+
if (elementSibling.children[i].tagName === "TBODY") {
|
|
414
|
+
colSpan += this.findTdColspanInTbody(elementSibling.children[i], trId);
|
|
415
|
+
}
|
|
416
|
+
}
|
|
417
|
+
elementSibling = elementSibling.nextElementSibling;
|
|
418
|
+
}
|
|
419
|
+
if (colgroupNumber < colSpan) {
|
|
420
|
+
const length = colSpan - colgroupNumber;
|
|
421
|
+
for (let i = 0; i < length; i++) {
|
|
422
|
+
const newCol = document.createElement("col");
|
|
423
|
+
newCol.width = this.parent.domNode.children[0].children[this.parent.domNode.children[0].children.length - 1].width;
|
|
424
|
+
const newBr = document.createElement("br");
|
|
425
|
+
newCol.appendChild(newBr);
|
|
426
|
+
this.parent.domNode.children[0].appendChild(newCol);
|
|
427
|
+
this.parent.domNode.style.width += newCol.width;
|
|
428
|
+
}
|
|
429
|
+
}
|
|
430
|
+
}
|
|
431
|
+
}
|
|
432
|
+
// this.parent.domNode.children[1].children[0].children[0].colSpan
|
|
433
|
+
findTdColspanInTbody(tbody, trId) {
|
|
434
|
+
let colSpan = 0;
|
|
435
|
+
for (let i = 0; i < tbody.children.length; i++) {
|
|
436
|
+
if (tbody.children[i].getAttribute("data-row") !== trId) {
|
|
437
|
+
return colSpan;
|
|
438
|
+
}
|
|
439
|
+
for (let j = 0; j < tbody.children[i].children.length; j++) {
|
|
440
|
+
if (tbody.children[i].children[j].colSpan) {
|
|
441
|
+
colSpan += tbody.children[i].children[j].colSpan;
|
|
442
|
+
}
|
|
443
|
+
}
|
|
444
|
+
}
|
|
445
|
+
return colSpan;
|
|
446
|
+
}
|
|
447
|
+
}
|
|
448
|
+
TableColGroup.blotName = "table-col-group";
|
|
449
|
+
TableColGroup.tagName = "colgroup";
|
|
450
|
+
class TableContainer extends Container {
|
|
451
|
+
static create() {
|
|
452
|
+
const node = super.create();
|
|
453
|
+
return node;
|
|
454
|
+
}
|
|
455
|
+
constructor(scroll, domNode) {
|
|
456
|
+
super(scroll, domNode);
|
|
457
|
+
domNode.setAttribute("contenteditable", false);
|
|
458
|
+
this.updateTableWidth();
|
|
459
|
+
}
|
|
460
|
+
updateTableWidth() {
|
|
461
|
+
let colGroup = this.colGroup();
|
|
462
|
+
if (!colGroup) {
|
|
463
|
+
if (this.parent && this.parent.children.head && this.domNode.hasAttribute("style")) {
|
|
464
|
+
colGroup = this.parent.children.head.children.head;
|
|
465
|
+
this.domNode = this.parent.children.head.domNode;
|
|
466
|
+
} else if (this.domNode.tagName === "TABLE") {
|
|
467
|
+
return;
|
|
468
|
+
} else {
|
|
469
|
+
return;
|
|
470
|
+
}
|
|
471
|
+
}
|
|
472
|
+
const tableWidth = colGroup.children.reduce((sumWidth, col) => {
|
|
473
|
+
const tableCol = col.formats()[TableCol.blotName];
|
|
474
|
+
let tableColWidth = tableConfig.COL_DEFAULT.width;
|
|
475
|
+
if (tableCol && tableCol.width) {
|
|
476
|
+
tableColWidth = parseInt(tableCol.width, 10);
|
|
477
|
+
}
|
|
478
|
+
sumWidth = sumWidth + tableColWidth;
|
|
479
|
+
return sumWidth;
|
|
480
|
+
}, 0);
|
|
481
|
+
this.domNode.removeAttribute("style");
|
|
482
|
+
this.domNode.style.width = `${tableWidth}px`;
|
|
483
|
+
if (colGroup.next) {
|
|
484
|
+
setTimeout(() => {
|
|
485
|
+
let tdIndex = 0;
|
|
486
|
+
let maxTds;
|
|
487
|
+
const colNum = colGroup.children.length;
|
|
488
|
+
const tableRows = this.descendants(TableRow);
|
|
489
|
+
for (let i = 0; i < tableRows.length; i++) {
|
|
490
|
+
const tds = tableRows[i].domNode.querySelectorAll("td");
|
|
491
|
+
if (tds.length === colNum) {
|
|
492
|
+
maxTds = tds;
|
|
493
|
+
break;
|
|
494
|
+
}
|
|
495
|
+
}
|
|
496
|
+
colGroup.children.forEach((col) => {
|
|
497
|
+
if (maxTds && col.domNode.width === "auto") {
|
|
498
|
+
const width = getComputedStyle(maxTds[tdIndex])["width"];
|
|
499
|
+
const num = parseInt(width, 10);
|
|
500
|
+
col.domNode.width = num < tableConfig.COL_DEFAULT.width && tableConfig.COL_DEFAULT.width || num;
|
|
501
|
+
}
|
|
502
|
+
tdIndex++;
|
|
503
|
+
});
|
|
504
|
+
});
|
|
505
|
+
}
|
|
506
|
+
}
|
|
507
|
+
cells(column) {
|
|
508
|
+
return this.rows().map((row) => row.children.at(column));
|
|
509
|
+
}
|
|
510
|
+
colGroup() {
|
|
511
|
+
return this.children.head;
|
|
512
|
+
}
|
|
513
|
+
deleteColumns(compareRect, delIndexes = [], editorWrapper) {
|
|
514
|
+
const [body] = this.descendants(TableBody);
|
|
515
|
+
if (editor_utils.isNullOrUndefined(body) || editor_utils.isNullOrUndefined(body.children.head)) {
|
|
516
|
+
return;
|
|
517
|
+
}
|
|
518
|
+
const tableCells = this.descendants(TableCell);
|
|
519
|
+
const removedCells = [];
|
|
520
|
+
const modifiedCells = [];
|
|
521
|
+
tableCells.forEach((cell) => {
|
|
522
|
+
const cellRect = index.getRelativeRect(cell.domNode.getBoundingClientRect(), editorWrapper);
|
|
523
|
+
if (cellRect.x + tableConfig.ERROR_LIMIT > compareRect.x && cellRect.x1 - tableConfig.ERROR_LIMIT < compareRect.x1) {
|
|
524
|
+
removedCells.push(cell);
|
|
525
|
+
} else if (cellRect.x < compareRect.x + tableConfig.ERROR_LIMIT && cellRect.x1 > compareRect.x1 - tableConfig.ERROR_LIMIT) {
|
|
526
|
+
modifiedCells.push(cell);
|
|
527
|
+
}
|
|
528
|
+
});
|
|
529
|
+
if (removedCells.length === tableCells.length) {
|
|
530
|
+
this.tableDestroy();
|
|
531
|
+
return true;
|
|
532
|
+
}
|
|
533
|
+
delIndexes.forEach(() => {
|
|
534
|
+
const col = this.colGroup().children.at(delIndexes[0]);
|
|
535
|
+
if (!col || this.colGroup().children.at(delIndexes[0]).domNode !== this.colGroup().domNode.children[delIndexes[0]]) {
|
|
536
|
+
this.colGroup().domNode.removeChild(this.colGroup().domNode.children[delIndexes[0]]);
|
|
537
|
+
} else {
|
|
538
|
+
col.remove();
|
|
539
|
+
}
|
|
540
|
+
});
|
|
541
|
+
removedCells.forEach((cell) => {
|
|
542
|
+
cell.remove();
|
|
543
|
+
});
|
|
544
|
+
modifiedCells.forEach((cell) => {
|
|
545
|
+
const cellColspan = parseInt(cell.formats().colspan, 10);
|
|
546
|
+
cell.format("colspan", cellColspan - delIndexes.length);
|
|
547
|
+
});
|
|
548
|
+
this.updateTableWidth();
|
|
549
|
+
}
|
|
550
|
+
deleteRow(compareRect, editorWrapper) {
|
|
551
|
+
const [body] = this.descendants(TableBody);
|
|
552
|
+
if (editor_utils.isNullOrUndefined(body) || editor_utils.isNullOrUndefined(body.children.head)) {
|
|
553
|
+
return;
|
|
554
|
+
}
|
|
555
|
+
const tableCells = this.descendants(TableCell);
|
|
556
|
+
const tableRows = this.descendants(TableRow);
|
|
557
|
+
const removedCells = [];
|
|
558
|
+
const modifiedCells = [];
|
|
559
|
+
const fallCells = [];
|
|
560
|
+
tableCells.forEach((cell) => {
|
|
561
|
+
const cellRect = index.getRelativeRect(cell.domNode.getBoundingClientRect(), editorWrapper);
|
|
562
|
+
if (cellRect.y > compareRect.y - tableConfig.ERROR_LIMIT && cellRect.y1 < compareRect.y1 + tableConfig.ERROR_LIMIT) {
|
|
563
|
+
removedCells.push(cell);
|
|
564
|
+
} else if (cellRect.y < compareRect.y + tableConfig.ERROR_LIMIT && cellRect.y1 > compareRect.y1 - tableConfig.ERROR_LIMIT) {
|
|
565
|
+
modifiedCells.push(cell);
|
|
566
|
+
if (Math.abs(cellRect.y - compareRect.y) < tableConfig.ERROR_LIMIT) {
|
|
567
|
+
fallCells.push(cell);
|
|
568
|
+
}
|
|
569
|
+
}
|
|
570
|
+
});
|
|
571
|
+
if (removedCells.length === tableCells.length) {
|
|
572
|
+
this.tableDestroy();
|
|
573
|
+
return;
|
|
574
|
+
}
|
|
575
|
+
const removedRowsLength = this.rows().reduce((sum, row) => {
|
|
576
|
+
const rowRect = index.getRelativeRect(row.domNode.getBoundingClientRect(), editorWrapper);
|
|
577
|
+
if (rowRect.y > compareRect.y - tableConfig.ERROR_LIMIT && rowRect.y1 < compareRect.y1 + tableConfig.ERROR_LIMIT) {
|
|
578
|
+
sum += 1;
|
|
579
|
+
}
|
|
580
|
+
return sum;
|
|
581
|
+
}, 0);
|
|
582
|
+
fallCells.forEach((cell) => {
|
|
583
|
+
const cellRect = index.getRelativeRect(cell.domNode.getBoundingClientRect(), editorWrapper);
|
|
584
|
+
const nextRow = cell.parent.next;
|
|
585
|
+
const cellsInNextRow = nextRow.children;
|
|
586
|
+
const refCell = cellsInNextRow.reduce((ref, compareCell) => {
|
|
587
|
+
const compareCellRect = index.getRelativeRect(compareCell.domNode.getBoundingClientRect(), editorWrapper);
|
|
588
|
+
if (cellRect.x1 - compareCellRect.x < tableConfig.ERROR_LIMIT) {
|
|
589
|
+
ref = compareCell;
|
|
590
|
+
}
|
|
591
|
+
return ref;
|
|
592
|
+
}, null);
|
|
593
|
+
nextRow.insertBefore(cell, refCell);
|
|
594
|
+
const curRowId = nextRow.formats().row;
|
|
595
|
+
cell.format("row", curRowId);
|
|
596
|
+
cell.children.forEach((cellLine) => {
|
|
597
|
+
cellLine.format("row", curRowId);
|
|
598
|
+
});
|
|
599
|
+
});
|
|
600
|
+
modifiedCells.forEach((cell) => {
|
|
601
|
+
const cellRowspan = parseInt(cell.formats().rowspan, 10);
|
|
602
|
+
const curRowspan = cellRowspan - removedRowsLength;
|
|
603
|
+
cell.domNode.removeAttribute("style");
|
|
604
|
+
cell.format("rowspan", curRowspan);
|
|
605
|
+
cell.children.forEach((cellLine) => {
|
|
606
|
+
cellLine.format("rowspan", curRowspan);
|
|
607
|
+
});
|
|
608
|
+
});
|
|
609
|
+
removedCells.forEach((cell) => {
|
|
610
|
+
cell.remove();
|
|
611
|
+
});
|
|
612
|
+
tableRows.forEach((row) => {
|
|
613
|
+
if (row.children.length === 0) {
|
|
614
|
+
row.remove();
|
|
615
|
+
}
|
|
616
|
+
});
|
|
617
|
+
}
|
|
618
|
+
tableDestroy() {
|
|
619
|
+
const quill = Quill.find(this.scroll.domNode.parentNode);
|
|
620
|
+
const tableModule = quill.getModule("better-table");
|
|
621
|
+
this.remove();
|
|
622
|
+
tableModule.hideTableTools();
|
|
623
|
+
quill.update(Quill.sources.USER);
|
|
624
|
+
}
|
|
625
|
+
insertCell(tableRow, ref, bg = "") {
|
|
626
|
+
const id = cellId();
|
|
627
|
+
const rId = tableRow.formats().row;
|
|
628
|
+
const tableCell = this.scroll.create(
|
|
629
|
+
TableCell.blotName,
|
|
630
|
+
{ ...tableConfig.CELL_DEFAULT, row: rId }
|
|
631
|
+
);
|
|
632
|
+
tableCell.domNode.style.backgroundColor = bg;
|
|
633
|
+
const cellLine = this.scroll.create(TableCellLine.blotName, {
|
|
634
|
+
row: rId,
|
|
635
|
+
cell: id
|
|
636
|
+
});
|
|
637
|
+
tableCell.appendChild(cellLine);
|
|
638
|
+
if (ref) {
|
|
639
|
+
tableRow.insertBefore(tableCell, ref);
|
|
640
|
+
} else {
|
|
641
|
+
tableRow.appendChild(tableCell);
|
|
642
|
+
}
|
|
643
|
+
}
|
|
644
|
+
insertColumn(compareRect, colIndex, isRight = true, editorWrapper) {
|
|
645
|
+
const [body] = this.descendants(TableBody);
|
|
646
|
+
const [tableColGroup] = this.descendants(TableColGroup);
|
|
647
|
+
const tableCols = this.descendants(TableCol);
|
|
648
|
+
const addAsideCells = [];
|
|
649
|
+
const modifiedCells = [];
|
|
650
|
+
const affectedCells = [];
|
|
651
|
+
if (editor_utils.isNullOrUndefined(body) || editor_utils.isNullOrUndefined(body.children.head)) {
|
|
652
|
+
return;
|
|
653
|
+
}
|
|
654
|
+
const tableCells = this.descendants(TableCell);
|
|
655
|
+
tableCells.forEach((cell) => {
|
|
656
|
+
const cellRect = index.getRelativeRect(cell.domNode.getBoundingClientRect(), editorWrapper);
|
|
657
|
+
if (isRight) {
|
|
658
|
+
if (Math.abs(cellRect.x1 - compareRect.x1) < tableConfig.ERROR_LIMIT) {
|
|
659
|
+
addAsideCells.push(cell);
|
|
660
|
+
} else if (compareRect.x1 - cellRect.x > tableConfig.ERROR_LIMIT && compareRect.x1 - cellRect.x1 < -tableConfig.ERROR_LIMIT) {
|
|
661
|
+
modifiedCells.push(cell);
|
|
662
|
+
}
|
|
663
|
+
} else {
|
|
664
|
+
if (Math.abs(cellRect.x - compareRect.x) < tableConfig.ERROR_LIMIT) {
|
|
665
|
+
addAsideCells.push(cell);
|
|
666
|
+
} else if (compareRect.x - cellRect.x > tableConfig.ERROR_LIMIT && compareRect.x - cellRect.x1 < -tableConfig.ERROR_LIMIT) {
|
|
667
|
+
modifiedCells.push(cell);
|
|
668
|
+
}
|
|
669
|
+
}
|
|
670
|
+
});
|
|
671
|
+
addAsideCells.forEach((cell) => {
|
|
672
|
+
const ref = isRight ? cell.next : cell;
|
|
673
|
+
const id = cellId();
|
|
674
|
+
const tableRow = cell.parent;
|
|
675
|
+
const rId = tableRow.formats().row;
|
|
676
|
+
const cellFormats = cell.formats();
|
|
677
|
+
const tableCell = this.scroll.create(
|
|
678
|
+
TableCell.blotName,
|
|
679
|
+
{
|
|
680
|
+
...tableConfig.CELL_DEFAULT,
|
|
681
|
+
row: rId,
|
|
682
|
+
rowspan: cellFormats.rowspan
|
|
683
|
+
}
|
|
684
|
+
);
|
|
685
|
+
const cellLine = this.scroll.create(TableCellLine.blotName, {
|
|
686
|
+
row: rId,
|
|
687
|
+
cell: id,
|
|
688
|
+
rowspan: cellFormats.rowspan
|
|
689
|
+
});
|
|
690
|
+
tableCell.appendChild(cellLine);
|
|
691
|
+
if (ref) {
|
|
692
|
+
tableRow.insertBefore(tableCell, ref);
|
|
693
|
+
} else {
|
|
694
|
+
tableRow.appendChild(tableCell);
|
|
695
|
+
}
|
|
696
|
+
affectedCells.push(tableCell);
|
|
697
|
+
});
|
|
698
|
+
const tableCol = this.scroll.create(TableCol.blotName, true);
|
|
699
|
+
let colRef;
|
|
700
|
+
if (isRight) {
|
|
701
|
+
colRef = tableCols[colIndex] && tableCols[colIndex].next;
|
|
702
|
+
} else {
|
|
703
|
+
colRef = tableCols[colIndex];
|
|
704
|
+
}
|
|
705
|
+
if (colRef) {
|
|
706
|
+
tableColGroup.insertBefore(tableCol, colRef);
|
|
707
|
+
} else {
|
|
708
|
+
tableColGroup.appendChild(tableCol);
|
|
709
|
+
}
|
|
710
|
+
modifiedCells.forEach((cell) => {
|
|
711
|
+
const cellColspan = cell.formats().colspan;
|
|
712
|
+
cell.format("colspan", parseInt(cellColspan, 10) + 1);
|
|
713
|
+
affectedCells.push(cell);
|
|
714
|
+
});
|
|
715
|
+
affectedCells.sort((cellA, cellB) => {
|
|
716
|
+
const y1 = cellA.domNode.getBoundingClientRect().y;
|
|
717
|
+
const y2 = cellB.domNode.getBoundingClientRect().y;
|
|
718
|
+
return y1 - y2;
|
|
719
|
+
});
|
|
720
|
+
this.updateTableWidth();
|
|
721
|
+
return affectedCells;
|
|
722
|
+
}
|
|
723
|
+
insertRow(compareRect, isDown, editorWrapper) {
|
|
724
|
+
const [body] = this.descendants(TableBody);
|
|
725
|
+
if (editor_utils.isNullOrUndefined(body) || editor_utils.isNullOrUndefined(body.children.head)) {
|
|
726
|
+
return;
|
|
727
|
+
}
|
|
728
|
+
const tableCells = this.descendants(TableCell);
|
|
729
|
+
const rId = rowId();
|
|
730
|
+
const newRow = this.scroll.create(TableRow.blotName, {
|
|
731
|
+
row: rId
|
|
732
|
+
});
|
|
733
|
+
const addBelowCells = [];
|
|
734
|
+
const modifiedCells = [];
|
|
735
|
+
const affectedCells = [];
|
|
736
|
+
tableCells.forEach((cell) => {
|
|
737
|
+
const cellRect = index.getRelativeRect(cell.domNode.getBoundingClientRect(), editorWrapper);
|
|
738
|
+
if (isDown) {
|
|
739
|
+
if (Math.abs(cellRect.y1 - compareRect.y1) < tableConfig.ERROR_LIMIT) {
|
|
740
|
+
addBelowCells.push(cell);
|
|
741
|
+
} else if (compareRect.y1 - cellRect.y > tableConfig.ERROR_LIMIT && compareRect.y1 - cellRect.y1 < -tableConfig.ERROR_LIMIT) {
|
|
742
|
+
modifiedCells.push(cell);
|
|
743
|
+
}
|
|
744
|
+
} else {
|
|
745
|
+
if (Math.abs(cellRect.y - compareRect.y) < tableConfig.ERROR_LIMIT) {
|
|
746
|
+
addBelowCells.push(cell);
|
|
747
|
+
} else if (compareRect.y - cellRect.y > tableConfig.ERROR_LIMIT && compareRect.y - cellRect.y1 < -tableConfig.ERROR_LIMIT) {
|
|
748
|
+
modifiedCells.push(cell);
|
|
749
|
+
}
|
|
750
|
+
}
|
|
751
|
+
});
|
|
752
|
+
const sortFunc = (cellA, cellB) => {
|
|
753
|
+
const x1 = cellA.domNode.getBoundingClientRect().x;
|
|
754
|
+
const x2 = cellB.domNode.getBoundingClientRect().x;
|
|
755
|
+
return x1 - x2;
|
|
756
|
+
};
|
|
757
|
+
addBelowCells.sort(sortFunc);
|
|
758
|
+
addBelowCells.forEach((cell) => {
|
|
759
|
+
const cId = cellId();
|
|
760
|
+
const cellFormats = cell.formats();
|
|
761
|
+
const tableCell = this.scroll.create(
|
|
762
|
+
TableCell.blotName,
|
|
763
|
+
{ ...tableConfig.CELL_DEFAULT, row: rId, cell: cId, colspan: cellFormats.colspan }
|
|
764
|
+
);
|
|
765
|
+
const cellLine = this.scroll.create(TableCellLine.blotName, {
|
|
766
|
+
row: rId,
|
|
767
|
+
cell: cId,
|
|
768
|
+
colspan: cellFormats.colspan
|
|
769
|
+
});
|
|
770
|
+
const empty = this.scroll.create(Break.blotName);
|
|
771
|
+
cellLine.appendChild(empty);
|
|
772
|
+
tableCell.appendChild(cellLine);
|
|
773
|
+
newRow.appendChild(tableCell);
|
|
774
|
+
affectedCells.push(tableCell);
|
|
775
|
+
});
|
|
776
|
+
modifiedCells.forEach((cell) => {
|
|
777
|
+
const cellRowspan = parseInt(cell.formats().rowspan, 10);
|
|
778
|
+
cell.format("rowspan", cellRowspan + 1);
|
|
779
|
+
affectedCells.push(cell);
|
|
780
|
+
});
|
|
781
|
+
const refRow = this.rows().find((row) => {
|
|
782
|
+
const rowRect = index.getRelativeRect(row.domNode.getBoundingClientRect(), editorWrapper);
|
|
783
|
+
if (isDown) {
|
|
784
|
+
return Math.abs(rowRect.y - compareRect.y - compareRect.height) < tableConfig.ERROR_LIMIT;
|
|
785
|
+
} else {
|
|
786
|
+
return Math.abs(rowRect.y - compareRect.y) < tableConfig.ERROR_LIMIT;
|
|
787
|
+
}
|
|
788
|
+
});
|
|
789
|
+
body.insertBefore(newRow, refRow);
|
|
790
|
+
affectedCells.sort(sortFunc);
|
|
791
|
+
return affectedCells;
|
|
792
|
+
}
|
|
793
|
+
mergeCells(_compareRect, mergingCells, rowspan, colspan, _editorWrapper) {
|
|
794
|
+
const mergedCell = mergingCells.reduce((result, tableCell, index2) => {
|
|
795
|
+
if (index2 !== 0) {
|
|
796
|
+
if (result) {
|
|
797
|
+
tableCell.moveChildren(result);
|
|
798
|
+
}
|
|
799
|
+
tableCell.remove();
|
|
800
|
+
} else {
|
|
801
|
+
tableCell.format("colspan", colspan);
|
|
802
|
+
tableCell.format("rowspan", rowspan);
|
|
803
|
+
result = tableCell;
|
|
804
|
+
if (rowspan > 1) {
|
|
805
|
+
const minHeight = tableConfig.CELL_MIN_HEIGHT * rowspan + rowspan - 1;
|
|
806
|
+
const cellHeight = parseInt(tableCell.domNode.style.height, 10) || 0;
|
|
807
|
+
if (cellHeight < minHeight) {
|
|
808
|
+
tableCell.domNode.style.height = `${minHeight}px`;
|
|
809
|
+
}
|
|
810
|
+
}
|
|
811
|
+
}
|
|
812
|
+
return result;
|
|
813
|
+
}, null);
|
|
814
|
+
const rId = mergedCell.domNode.getAttribute("data-row");
|
|
815
|
+
const cId = mergedCell.children.head.domNode.getAttribute("data-cell");
|
|
816
|
+
mergedCell.children.forEach((cellLine) => {
|
|
817
|
+
cellLine.domNode.setAttribute("data-parent-bg", mergedCell.domNode.style.backgroundColor);
|
|
818
|
+
if (cellLine.children["head"].domNode.style) {
|
|
819
|
+
cellLine.children["head"].domNode.style.backgroundColor = mergedCell.domNode.style.backgroundColor;
|
|
820
|
+
}
|
|
821
|
+
if (!cellLine.prev || cellLine.domNode.innerText.trim()) {
|
|
822
|
+
cellLine.format("cell", cId);
|
|
823
|
+
cellLine.format("row", rId);
|
|
824
|
+
cellLine.format("colspan", colspan);
|
|
825
|
+
cellLine.format("rowspan", rowspan);
|
|
826
|
+
} else {
|
|
827
|
+
cellLine.remove();
|
|
828
|
+
}
|
|
829
|
+
});
|
|
830
|
+
return mergedCell;
|
|
831
|
+
}
|
|
832
|
+
unmergeCells(unmergingCells, editorWrapper) {
|
|
833
|
+
let cellFormats = {};
|
|
834
|
+
let cellRowspan = 1;
|
|
835
|
+
let cellColspan = 1;
|
|
836
|
+
unmergingCells.forEach((tableCell) => {
|
|
837
|
+
const tableCellBgColor = tableCell.domNode.style.backgroundColor;
|
|
838
|
+
cellFormats = tableCell.formats();
|
|
839
|
+
cellRowspan = cellFormats.rowspan;
|
|
840
|
+
cellColspan = cellFormats.colspan;
|
|
841
|
+
if (cellColspan > 1) {
|
|
842
|
+
const ref = tableCell.next;
|
|
843
|
+
const row = tableCell.row();
|
|
844
|
+
tableCell.format("colspan", 1);
|
|
845
|
+
if (tableCell.domNode.children && tableCell.domNode.children[0].tagName === "DIV" && tableCell.domNode.children[0].getAttribute("data-colspan")) {
|
|
846
|
+
tableCell.domNode.children[0].setAttribute("data-colspan", 1);
|
|
847
|
+
}
|
|
848
|
+
for (let colspanIndex = cellColspan; colspanIndex > 1; colspanIndex--) {
|
|
849
|
+
this.insertCell(row, ref, tableCellBgColor);
|
|
850
|
+
}
|
|
851
|
+
}
|
|
852
|
+
if (cellRowspan > 1) {
|
|
853
|
+
let rowspanIndex = cellRowspan;
|
|
854
|
+
let nextRow = tableCell.row().next;
|
|
855
|
+
while (rowspanIndex > 1) {
|
|
856
|
+
const refInNextRow = nextRow.children.reduce((result, cell) => {
|
|
857
|
+
const compareRect = index.getRelativeRect(tableCell.domNode.getBoundingClientRect(), editorWrapper);
|
|
858
|
+
const cellRect = index.getRelativeRect(cell.domNode.getBoundingClientRect(), editorWrapper);
|
|
859
|
+
if (Math.abs(compareRect.x1 - cellRect.x) < tableConfig.ERROR_LIMIT) {
|
|
860
|
+
result = cell;
|
|
861
|
+
}
|
|
862
|
+
return result;
|
|
863
|
+
}, null);
|
|
864
|
+
for (let colspanIndex = cellColspan; colspanIndex > 0; colspanIndex--) {
|
|
865
|
+
this.insertCell(nextRow, refInNextRow, tableCellBgColor);
|
|
866
|
+
}
|
|
867
|
+
rowspanIndex -= 1;
|
|
868
|
+
nextRow = nextRow.next;
|
|
869
|
+
}
|
|
870
|
+
tableCell.domNode.removeAttribute("style");
|
|
871
|
+
if (tableCell.domNode.children && tableCell.domNode.children[0].tagName === "DIV" && tableCell.domNode.children[0].getAttribute("data-rowspan")) {
|
|
872
|
+
tableCell.domNode.children[0].setAttribute("data-rowspan", 1);
|
|
873
|
+
}
|
|
874
|
+
tableCell.format("rowspan", 1);
|
|
875
|
+
}
|
|
876
|
+
});
|
|
877
|
+
}
|
|
878
|
+
emptyCells(selectedTds) {
|
|
879
|
+
selectedTds.forEach((selectedTd) => {
|
|
880
|
+
const cellFormats = selectedTd.formats();
|
|
881
|
+
const cellLine = this.scroll.create(TableCellLine.blotName, {
|
|
882
|
+
row: cellFormats.row || rowId(),
|
|
883
|
+
cell: cellFormats.cell || cellId(),
|
|
884
|
+
rowspan: cellFormats.rowspan,
|
|
885
|
+
colspan: cellFormats.colspan
|
|
886
|
+
});
|
|
887
|
+
const empty = this.scroll.create(Break.blotName);
|
|
888
|
+
cellLine.appendChild(empty);
|
|
889
|
+
selectedTd.domNode.innerHTML = "";
|
|
890
|
+
selectedTd.appendChild(cellLine);
|
|
891
|
+
});
|
|
892
|
+
}
|
|
893
|
+
rows() {
|
|
894
|
+
const body = this.children.tail;
|
|
895
|
+
if (editor_utils.isNullOrUndefined(body)) {
|
|
896
|
+
return [];
|
|
897
|
+
}
|
|
898
|
+
return body.children.map((row) => row);
|
|
899
|
+
}
|
|
900
|
+
}
|
|
901
|
+
TableContainer.blotName = "ql-table-container";
|
|
902
|
+
TableContainer.className = "quill-better-table";
|
|
903
|
+
TableContainer.tagName = "TABLE";
|
|
904
|
+
class TableViewWrapper extends Container {
|
|
905
|
+
constructor(scroll, domNode) {
|
|
906
|
+
super(scroll, domNode);
|
|
907
|
+
const quill = Quill.find(scroll.domNode.parentNode);
|
|
908
|
+
if (quill.options.readOnly) {
|
|
909
|
+
domNode.style.overflow = "auto";
|
|
910
|
+
}
|
|
911
|
+
domNode.addEventListener(
|
|
912
|
+
"scroll",
|
|
913
|
+
(e) => {
|
|
914
|
+
const tableModule = quill.getModule("better-table");
|
|
915
|
+
if (tableModule.columnTool) {
|
|
916
|
+
tableModule.columnTool.domNode.scrollLeft = e.target.scrollLeft;
|
|
917
|
+
}
|
|
918
|
+
if (tableModule.tableSelection && tableModule.tableSelection.selectedTds.length > 0) {
|
|
919
|
+
tableModule.tableSelection.repositionHelpLines();
|
|
920
|
+
}
|
|
921
|
+
},
|
|
922
|
+
false
|
|
923
|
+
);
|
|
924
|
+
}
|
|
925
|
+
}
|
|
926
|
+
TableViewWrapper.blotName = "table-view";
|
|
927
|
+
TableViewWrapper.className = "quill-better-table-wrapper";
|
|
928
|
+
TableViewWrapper.tagName = "DIV";
|
|
929
|
+
TableViewWrapper.allowedChildren = [TableContainer];
|
|
930
|
+
TableContainer.requiredContainer = TableViewWrapper;
|
|
931
|
+
TableContainer.allowedChildren = [TableBody, TableColGroup];
|
|
932
|
+
TableBody.requiredContainer = TableContainer;
|
|
933
|
+
TableBody.allowedChildren = [TableRow];
|
|
934
|
+
TableRow.requiredContainer = TableBody;
|
|
935
|
+
TableRow.allowedChildren = [TableCell];
|
|
936
|
+
TableCell.requiredContainer = TableRow;
|
|
937
|
+
TableCell.allowedChildren = [TableCellLine, header.default, list.default, list.ListContainer];
|
|
938
|
+
TableCellLine.requiredContainer = TableCell;
|
|
939
|
+
TableColGroup.allowedChildren = [TableCol];
|
|
940
|
+
TableColGroup.requiredContainer = TableContainer;
|
|
941
|
+
TableCol.requiredContainer = TableColGroup;
|
|
942
|
+
function rowId() {
|
|
943
|
+
const id = Math.random().toString(36).slice(2, 6);
|
|
944
|
+
return `row-${id}`;
|
|
945
|
+
}
|
|
946
|
+
function cellId() {
|
|
947
|
+
const id = Math.random().toString(36).slice(2, 6);
|
|
948
|
+
return `cell-${id}`;
|
|
949
|
+
}
|
|
950
|
+
function reduceFormats(domNode, formats) {
|
|
951
|
+
return [...tableConfig.CELL_ATTRIBUTES, ...tableConfig.CELL_IDENTITY_KEYS].reduce((tableFormats, attribute) => {
|
|
952
|
+
if (domNode.hasAttribute(`data-${attribute}`)) {
|
|
953
|
+
tableFormats[attribute] = domNode.getAttribute(`data-${attribute}`) || void 0;
|
|
954
|
+
}
|
|
955
|
+
return tableFormats;
|
|
956
|
+
}, formats);
|
|
957
|
+
}
|
|
958
|
+
exports.CELL_ATTRIBUTES = tableConfig.CELL_ATTRIBUTES;
|
|
959
|
+
exports.CELL_IDENTITY_KEYS = tableConfig.CELL_IDENTITY_KEYS;
|
|
960
|
+
exports.TableBody = TableBody;
|
|
961
|
+
exports.TableCell = TableCell;
|
|
962
|
+
exports.TableCellLine = TableCellLine;
|
|
963
|
+
exports.TableCol = TableCol;
|
|
964
|
+
exports.TableColGroup = TableColGroup;
|
|
965
|
+
exports.TableContainer = TableContainer;
|
|
966
|
+
exports.TableRow = TableRow;
|
|
967
|
+
exports.TableViewWrapper = TableViewWrapper;
|
|
968
|
+
exports.cellId = cellId;
|
|
969
|
+
exports.rowId = rowId;
|
|
970
|
+
//# sourceMappingURL=table.cjs.js.map
|