@seafile/sdoc-editor 1.0.54 → 1.0.55
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/dist/api/sdoc-server-api.js +45 -38
- package/dist/api/seafile-api.js +18 -11
- package/dist/basic-sdk/comment/comment-decorate.js +11 -4
- package/dist/basic-sdk/comment/components/comment-all-participants/index.js +29 -21
- package/dist/basic-sdk/comment/components/comment-all-participants/participant-avatar.js +21 -13
- package/dist/basic-sdk/comment/components/comment-delete-popover.js +22 -15
- package/dist/basic-sdk/comment/components/comment-editor.js +58 -50
- package/dist/basic-sdk/comment/components/comment-item-content.js +59 -51
- package/dist/basic-sdk/comment/components/comment-item-reply.js +54 -46
- package/dist/basic-sdk/comment/components/comment-item-resolved-reply.js +22 -14
- package/dist/basic-sdk/comment/components/comment-item-wrapper.js +67 -59
- package/dist/basic-sdk/comment/components/comment-list.js +40 -32
- package/dist/basic-sdk/comment/components/comment-participants-editor/index.js +33 -25
- package/dist/basic-sdk/comment/components/comment-participants-editor/searched-collaborators.js +23 -16
- package/dist/basic-sdk/comment/components/comment-participants-editor/selected-participants.js +20 -13
- package/dist/basic-sdk/comment/components/editor-comment.js +40 -32
- package/dist/basic-sdk/comment/components/elements-comment-count/element-comment-count.js +29 -22
- package/dist/basic-sdk/comment/components/elements-comment-count/index.js +13 -6
- package/dist/basic-sdk/comment/components/global-comment/global-comment-body-header.js +37 -29
- package/dist/basic-sdk/comment/components/global-comment/global-comment-editor.js +15 -8
- package/dist/basic-sdk/comment/components/global-comment/global-comment-header.js +42 -34
- package/dist/basic-sdk/comment/components/global-comment/index.js +78 -70
- package/dist/basic-sdk/comment/components/index.js +21 -4
- package/dist/basic-sdk/comment/constants/index.js +15 -9
- package/dist/basic-sdk/comment/helper.js +25 -13
- package/dist/basic-sdk/comment/hooks/comment-hooks/use-comment-context.js +13 -5
- package/dist/basic-sdk/comment/hooks/comment-hooks/use-comment-list.js +19 -13
- package/dist/basic-sdk/comment/hooks/comment-hooks/use-comment-mount.js +21 -13
- package/dist/basic-sdk/comment/hooks/notification-hooks/index.js +25 -2
- package/dist/basic-sdk/comment/hooks/notification-hooks/use-notification-context.js +13 -5
- package/dist/basic-sdk/comment/hooks/notification-hooks/use-notification-mount.js +34 -26
- package/dist/basic-sdk/comment/hooks/use-participants.js +45 -35
- package/dist/basic-sdk/comment/index.js +26 -18
- package/dist/basic-sdk/comment/provider/comment-context-provider.js +16 -9
- package/dist/basic-sdk/comment/provider/index.js +13 -6
- package/dist/basic-sdk/comment/provider/notification-context-provider.js +15 -8
- package/dist/basic-sdk/comment/reducer/comment-reducer.js +23 -11
- package/dist/basic-sdk/comment/reducer/notification-reducer.js +23 -16
- package/dist/basic-sdk/comment/utils/index.js +51 -27
- package/dist/basic-sdk/comment/utils/notification-utils.js +20 -11
- package/dist/basic-sdk/constants/index.js +24 -17
- package/dist/basic-sdk/constants/z-index.js +8 -2
- package/dist/basic-sdk/cursor/helper.js +15 -6
- package/dist/basic-sdk/cursor/use-cursors.js +13 -6
- package/dist/basic-sdk/decorates/index.js +16 -8
- package/dist/basic-sdk/editor/comment-article.js +42 -34
- package/dist/basic-sdk/editor/editable-article.js +82 -74
- package/dist/basic-sdk/editor/revision-editor.js +28 -20
- package/dist/basic-sdk/editor/sdoc-comment-editor.js +53 -45
- package/dist/basic-sdk/editor/sdoc-editor.js +66 -58
- package/dist/basic-sdk/editor/wiki-editor.js +66 -58
- package/dist/basic-sdk/extension/commons/Inline-bug-fix-wrapper/index.js +10 -4
- package/dist/basic-sdk/extension/commons/color-menu/color-item.js +13 -6
- package/dist/basic-sdk/extension/commons/color-menu/index.js +75 -67
- package/dist/basic-sdk/extension/commons/dropdown-menu-item/index.js +25 -17
- package/dist/basic-sdk/extension/commons/element-popover/index.js +14 -7
- package/dist/basic-sdk/extension/commons/file-insert-dialog/index.js +85 -77
- package/dist/basic-sdk/extension/commons/index.js +47 -6
- package/dist/basic-sdk/extension/commons/insert-element-dialog/index.js +53 -45
- package/dist/basic-sdk/extension/commons/menu/index.js +21 -4
- package/dist/basic-sdk/extension/commons/menu/menu-group.js +13 -6
- package/dist/basic-sdk/extension/commons/menu/menu-item.js +22 -14
- package/dist/basic-sdk/extension/commons/menu-shortcut-indicator/index.js +15 -8
- package/dist/basic-sdk/extension/commons/more-dropdown/index.js +16 -9
- package/dist/basic-sdk/extension/commons/select/_option.js +17 -10
- package/dist/basic-sdk/extension/commons/select/field-setting.js +27 -20
- package/dist/basic-sdk/extension/commons/select/index.js +36 -29
- package/dist/basic-sdk/extension/commons/select/menu/index.js +11 -4
- package/dist/basic-sdk/extension/commons/select/menu/item.js +19 -12
- package/dist/basic-sdk/extension/commons/select/menu/menu.js +13 -6
- package/dist/basic-sdk/extension/commons/select-file-dialog/helpers.js +11 -4
- package/dist/basic-sdk/extension/commons/select-file-dialog/index.js +37 -29
- package/dist/basic-sdk/extension/commons/select-file-dialog/local-files/index.js +52 -44
- package/dist/basic-sdk/extension/constants/color.js +16 -10
- package/dist/basic-sdk/extension/constants/diff-view.js +9 -3
- package/dist/basic-sdk/extension/constants/element-type.js +44 -38
- package/dist/basic-sdk/extension/constants/font.js +13 -8
- package/dist/basic-sdk/extension/constants/index.js +473 -51
- package/dist/basic-sdk/extension/constants/keyboard.js +10 -4
- package/dist/basic-sdk/extension/constants/menus-config.js +113 -107
- package/dist/basic-sdk/extension/core/index.js +38 -3
- package/dist/basic-sdk/extension/core/queries/index.js +159 -110
- package/dist/basic-sdk/extension/core/transforms/focus-editor.js +15 -8
- package/dist/basic-sdk/extension/core/transforms/index.js +60 -5
- package/dist/basic-sdk/extension/core/transforms/move-children.js +16 -9
- package/dist/basic-sdk/extension/core/transforms/remove-node-children.js +12 -5
- package/dist/basic-sdk/extension/core/transforms/replace-node.js +21 -12
- package/dist/basic-sdk/extension/core/transforms/update-parent-node.js +21 -14
- package/dist/basic-sdk/extension/core/utils/index.js +28 -16
- package/dist/basic-sdk/extension/index.js +60 -20
- package/dist/basic-sdk/extension/plugins/blockquote/helpers.js +51 -38
- package/dist/basic-sdk/extension/plugins/blockquote/index.js +18 -11
- package/dist/basic-sdk/extension/plugins/blockquote/menu/index.js +22 -15
- package/dist/basic-sdk/extension/plugins/blockquote/model.js +9 -3
- package/dist/basic-sdk/extension/plugins/blockquote/plugin.js +55 -49
- package/dist/basic-sdk/extension/plugins/blockquote/render-elem.js +10 -3
- package/dist/basic-sdk/extension/plugins/callout/constant.js +10 -5
- package/dist/basic-sdk/extension/plugins/callout/helper.js +68 -50
- package/dist/basic-sdk/extension/plugins/callout/index.js +16 -9
- package/dist/basic-sdk/extension/plugins/callout/menu/index.js +30 -22
- package/dist/basic-sdk/extension/plugins/callout/plugin.js +46 -40
- package/dist/basic-sdk/extension/plugins/callout/render-elem/callout-color-selector/index.js +25 -18
- package/dist/basic-sdk/extension/plugins/callout/render-elem/callout-hover-menu/index.js +38 -30
- package/dist/basic-sdk/extension/plugins/callout/render-elem/callout-icon/index.js +23 -16
- package/dist/basic-sdk/extension/plugins/callout/render-elem/index.js +53 -44
- package/dist/basic-sdk/extension/plugins/check-list/helpers.js +43 -33
- package/dist/basic-sdk/extension/plugins/check-list/index.js +12 -5
- package/dist/basic-sdk/extension/plugins/check-list/menu/index.js +25 -18
- package/dist/basic-sdk/extension/plugins/check-list/model.js +9 -3
- package/dist/basic-sdk/extension/plugins/check-list/plugin.js +31 -24
- package/dist/basic-sdk/extension/plugins/check-list/render-elem.js +24 -16
- package/dist/basic-sdk/extension/plugins/clear-format/helpers.js +21 -13
- package/dist/basic-sdk/extension/plugins/clear-format/menu/index.js +17 -10
- package/dist/basic-sdk/extension/plugins/code-block/helpers.js +63 -48
- package/dist/basic-sdk/extension/plugins/code-block/hover-menu/index.js +66 -58
- package/dist/basic-sdk/extension/plugins/code-block/index.js +16 -9
- package/dist/basic-sdk/extension/plugins/code-block/menu/index.js +20 -12
- package/dist/basic-sdk/extension/plugins/code-block/model.js +9 -3
- package/dist/basic-sdk/extension/plugins/code-block/plugin.js +66 -59
- package/dist/basic-sdk/extension/plugins/code-block/prismjs.js +30 -21
- package/dist/basic-sdk/extension/plugins/code-block/render-elem.js +58 -50
- package/dist/basic-sdk/extension/plugins/file-link/constants/index.js +9 -3
- package/dist/basic-sdk/extension/plugins/file-link/helpers.js +52 -39
- package/dist/basic-sdk/extension/plugins/file-link/hover-menu/index.js +54 -46
- package/dist/basic-sdk/extension/plugins/file-link/index.js +16 -9
- package/dist/basic-sdk/extension/plugins/file-link/menu/index.js +21 -13
- package/dist/basic-sdk/extension/plugins/file-link/plugin.js +15 -9
- package/dist/basic-sdk/extension/plugins/file-link/render-elem.js +48 -40
- package/dist/basic-sdk/extension/plugins/font/helpers.js +72 -56
- package/dist/basic-sdk/extension/plugins/font/index.js +10 -3
- package/dist/basic-sdk/extension/plugins/font/menu/font-family/font-item.js +21 -14
- package/dist/basic-sdk/extension/plugins/font/menu/font-family/index.js +55 -47
- package/dist/basic-sdk/extension/plugins/font/menu/font-size/font-size-scale.js +14 -7
- package/dist/basic-sdk/extension/plugins/font/menu/font-size/index.js +40 -32
- package/dist/basic-sdk/extension/plugins/font/menu/index.js +13 -6
- package/dist/basic-sdk/extension/plugins/font/plugin.js +10 -4
- package/dist/basic-sdk/extension/plugins/header/helpers.js +30 -21
- package/dist/basic-sdk/extension/plugins/header/index.js +14 -7
- package/dist/basic-sdk/extension/plugins/header/menu/index.js +53 -45
- package/dist/basic-sdk/extension/plugins/header/plugin.js +33 -26
- package/dist/basic-sdk/extension/plugins/header/render-elem.js +29 -19
- package/dist/basic-sdk/extension/plugins/html/helper.js +32 -25
- package/dist/basic-sdk/extension/plugins/html/index.js +10 -3
- package/dist/basic-sdk/extension/plugins/html/plugin.js +17 -10
- package/dist/basic-sdk/extension/plugins/html/rules/blockquote.js +12 -5
- package/dist/basic-sdk/extension/plugins/html/rules/check-list.js +13 -6
- package/dist/basic-sdk/extension/plugins/html/rules/code-block.js +28 -21
- package/dist/basic-sdk/extension/plugins/html/rules/header.js +10 -3
- package/dist/basic-sdk/extension/plugins/html/rules/image.js +13 -6
- package/dist/basic-sdk/extension/plugins/html/rules/index.js +18 -11
- package/dist/basic-sdk/extension/plugins/html/rules/link.js +13 -6
- package/dist/basic-sdk/extension/plugins/html/rules/list.js +22 -15
- package/dist/basic-sdk/extension/plugins/html/rules/paragraph.js +12 -5
- package/dist/basic-sdk/extension/plugins/html/rules/table.js +16 -9
- package/dist/basic-sdk/extension/plugins/html/rules/text.js +16 -9
- package/dist/basic-sdk/extension/plugins/image/constants/index.js +15 -8
- package/dist/basic-sdk/extension/plugins/image/dialogs/image-previewer.js +22 -15
- package/dist/basic-sdk/extension/plugins/image/helpers.js +107 -87
- package/dist/basic-sdk/extension/plugins/image/hover-menu/index.js +94 -86
- package/dist/basic-sdk/extension/plugins/image/index.js +18 -11
- package/dist/basic-sdk/extension/plugins/image/menu/index.js +30 -22
- package/dist/basic-sdk/extension/plugins/image/model.js +9 -3
- package/dist/basic-sdk/extension/plugins/image/plugin.js +62 -55
- package/dist/basic-sdk/extension/plugins/image/render-elem.js +87 -78
- package/dist/basic-sdk/extension/plugins/index.js +173 -28
- package/dist/basic-sdk/extension/plugins/link/dialog/add-link-dialog/index.js +38 -31
- package/dist/basic-sdk/extension/plugins/link/helpers.js +70 -53
- package/dist/basic-sdk/extension/plugins/link/hover/index.js +25 -18
- package/dist/basic-sdk/extension/plugins/link/index.js +18 -11
- package/dist/basic-sdk/extension/plugins/link/menu/index.js +26 -18
- package/dist/basic-sdk/extension/plugins/link/model.js +9 -3
- package/dist/basic-sdk/extension/plugins/link/plugin.js +52 -45
- package/dist/basic-sdk/extension/plugins/link/render-elem.js +41 -34
- package/dist/basic-sdk/extension/plugins/list/helpers.js +38 -28
- package/dist/basic-sdk/extension/plugins/list/index.js +14 -7
- package/dist/basic-sdk/extension/plugins/list/menu/index.js +26 -19
- package/dist/basic-sdk/extension/plugins/list/model.js +23 -13
- package/dist/basic-sdk/extension/plugins/list/plugin/index.js +33 -27
- package/dist/basic-sdk/extension/plugins/list/plugin/insert-break-list.js +16 -9
- package/dist/basic-sdk/extension/plugins/list/plugin/insert-fragment-list.js +55 -46
- package/dist/basic-sdk/extension/plugins/list/plugin/normalize-list.js +32 -25
- package/dist/basic-sdk/extension/plugins/list/plugin/on-tab-handle.js +23 -15
- package/dist/basic-sdk/extension/plugins/list/plugin/shortcut.js +36 -30
- package/dist/basic-sdk/extension/plugins/list/queries/index.js +27 -17
- package/dist/basic-sdk/extension/plugins/list/render-elem.js +18 -9
- package/dist/basic-sdk/extension/plugins/list/transforms/index.js +76 -11
- package/dist/basic-sdk/extension/plugins/list/transforms/insert-list-item.js +40 -34
- package/dist/basic-sdk/extension/plugins/list/transforms/move-list-item-down.js +19 -12
- package/dist/basic-sdk/extension/plugins/list/transforms/move-list-item-up.js +37 -30
- package/dist/basic-sdk/extension/plugins/list/transforms/move-list-items-to-list.js +19 -12
- package/dist/basic-sdk/extension/plugins/list/transforms/move-list-items.js +28 -21
- package/dist/basic-sdk/extension/plugins/list/transforms/normalize-list-item.js +40 -33
- package/dist/basic-sdk/extension/plugins/list/transforms/normalize-nested-list.js +18 -11
- package/dist/basic-sdk/extension/plugins/list/transforms/remove-first-list-item.js +13 -6
- package/dist/basic-sdk/extension/plugins/list/transforms/toggle-list.js +50 -44
- package/dist/basic-sdk/extension/plugins/list/transforms/unwrap-list.js +22 -15
- package/dist/basic-sdk/extension/plugins/markdown/index.js +10 -3
- package/dist/basic-sdk/extension/plugins/markdown/plugin.js +45 -40
- package/dist/basic-sdk/extension/plugins/mention/helper.js +56 -42
- package/dist/basic-sdk/extension/plugins/mention/index.js +14 -7
- package/dist/basic-sdk/extension/plugins/mention/plugin.js +72 -65
- package/dist/basic-sdk/extension/plugins/mention/render-elem/comment-participant-item.js +21 -14
- package/dist/basic-sdk/extension/plugins/mention/render-elem/index.js +29 -19
- package/dist/basic-sdk/extension/plugins/mention/render-elem/participant-popover.js +82 -74
- package/dist/basic-sdk/extension/plugins/paragraph/helper.js +12 -5
- package/dist/basic-sdk/extension/plugins/paragraph/index.js +14 -7
- package/dist/basic-sdk/extension/plugins/paragraph/plugin/index.js +27 -20
- package/dist/basic-sdk/extension/plugins/paragraph/render-elem.js +27 -19
- package/dist/basic-sdk/extension/plugins/quick-insert/helper.js +27 -18
- package/dist/basic-sdk/extension/plugins/quick-insert/index.js +14 -7
- package/dist/basic-sdk/extension/plugins/quick-insert/plugin/index.js +44 -38
- package/dist/basic-sdk/extension/plugins/quick-insert/render-elem.js +42 -34
- package/dist/basic-sdk/extension/plugins/sdoc-link/constants/index.js +9 -3
- package/dist/basic-sdk/extension/plugins/sdoc-link/helpers.js +91 -70
- package/dist/basic-sdk/extension/plugins/sdoc-link/hover-menu/index.js +53 -45
- package/dist/basic-sdk/extension/plugins/sdoc-link/index.js +17 -10
- package/dist/basic-sdk/extension/plugins/sdoc-link/menu/index.js +21 -13
- package/dist/basic-sdk/extension/plugins/sdoc-link/plugin.js +37 -31
- package/dist/basic-sdk/extension/plugins/sdoc-link/render/render-elem.js +54 -46
- package/dist/basic-sdk/extension/plugins/sdoc-link/render/render-file-link-temp-input.js +20 -12
- package/dist/basic-sdk/extension/plugins/search-replace/constant.js +8 -2
- package/dist/basic-sdk/extension/plugins/search-replace/helper.js +42 -32
- package/dist/basic-sdk/extension/plugins/search-replace/index.js +14 -7
- package/dist/basic-sdk/extension/plugins/search-replace/menu/index.js +31 -23
- package/dist/basic-sdk/extension/plugins/search-replace/plugin.js +14 -7
- package/dist/basic-sdk/extension/plugins/search-replace/popover/index.js +83 -75
- package/dist/basic-sdk/extension/plugins/search-replace/popover/replace-all-confirm-modal.js +16 -9
- package/dist/basic-sdk/extension/plugins/seatable-column/constants/cell-types.js +35 -29
- package/dist/basic-sdk/extension/plugins/seatable-column/constants/column.js +10 -4
- package/dist/basic-sdk/extension/plugins/seatable-column/helpers.js +54 -40
- package/dist/basic-sdk/extension/plugins/seatable-column/index.js +14 -7
- package/dist/basic-sdk/extension/plugins/seatable-column/menu/column-list-menu.js +30 -23
- package/dist/basic-sdk/extension/plugins/seatable-column/menu/index.js +22 -14
- package/dist/basic-sdk/extension/plugins/seatable-column/model.js +9 -3
- package/dist/basic-sdk/extension/plugins/seatable-column/plugin.js +10 -4
- package/dist/basic-sdk/extension/plugins/seatable-column/render-elem.js +17 -10
- package/dist/basic-sdk/extension/plugins/seatable-tables/draggable/index.js +24 -18
- package/dist/basic-sdk/extension/plugins/seatable-tables/formatter/collaborator-wrapper.js +23 -17
- package/dist/basic-sdk/extension/plugins/seatable-tables/formatter/index.js +91 -83
- package/dist/basic-sdk/extension/plugins/seatable-tables/formatter/link-formatter/index.js +98 -91
- package/dist/basic-sdk/extension/plugins/seatable-tables/formatter/link-formatter/utils.js +20 -8
- package/dist/basic-sdk/extension/plugins/seatable-tables/helpers.js +48 -37
- package/dist/basic-sdk/extension/plugins/seatable-tables/index.js +18 -11
- package/dist/basic-sdk/extension/plugins/seatable-tables/menu/index.js +25 -17
- package/dist/basic-sdk/extension/plugins/seatable-tables/menu/seatable-list.js +16 -9
- package/dist/basic-sdk/extension/plugins/seatable-tables/model.js +9 -3
- package/dist/basic-sdk/extension/plugins/seatable-tables/op-menu/index.js +96 -88
- package/dist/basic-sdk/extension/plugins/seatable-tables/plugin.js +27 -21
- package/dist/basic-sdk/extension/plugins/seatable-tables/render-element/index.js +11 -4
- package/dist/basic-sdk/extension/plugins/seatable-tables/render-element/record-header.js +22 -14
- package/dist/basic-sdk/extension/plugins/seatable-tables/render-element/record-item.js +16 -9
- package/dist/basic-sdk/extension/plugins/seatable-tables/render-element/record-list.js +12 -5
- package/dist/basic-sdk/extension/plugins/seatable-tables/render-element/seatable-table.js +63 -55
- package/dist/basic-sdk/extension/plugins/seatable-tables/seatable-settings/common-add-tool/index.js +15 -8
- package/dist/basic-sdk/extension/plugins/seatable-tables/seatable-settings/custom-switch/index.js +12 -5
- package/dist/basic-sdk/extension/plugins/seatable-tables/seatable-settings/dtable-search-input/index.js +26 -18
- package/dist/basic-sdk/extension/plugins/seatable-tables/seatable-settings/filter-setter/filter-popover-widgets/calendar-filter/date-translate.js +7 -2
- package/dist/basic-sdk/extension/plugins/seatable-tables/seatable-settings/filter-setter/filter-popover-widgets/calendar-filter/dayjs.js +11 -4
- package/dist/basic-sdk/extension/plugins/seatable-tables/seatable-settings/filter-setter/filter-popover-widgets/calendar-filter/index.js +40 -32
- package/dist/basic-sdk/extension/plugins/seatable-tables/seatable-settings/filter-setter/filter-popover-widgets/collaborator-filter/index.js +35 -27
- package/dist/basic-sdk/extension/plugins/seatable-tables/seatable-settings/filter-setter/filter-popover-widgets/department-filter/_department-utils.js +12 -4
- package/dist/basic-sdk/extension/plugins/seatable-tables/seatable-settings/filter-setter/filter-popover-widgets/department-filter/department-multiple-select-filter.js +33 -25
- package/dist/basic-sdk/extension/plugins/seatable-tables/seatable-settings/filter-setter/filter-popover-widgets/department-filter/department-multiple-select.js +35 -27
- package/dist/basic-sdk/extension/plugins/seatable-tables/seatable-settings/filter-setter/filter-popover-widgets/department-filter/department-single-select-filter.js +35 -27
- package/dist/basic-sdk/extension/plugins/seatable-tables/seatable-settings/filter-setter/filter-popover-widgets/department-filter/department-single-select.js +58 -50
- package/dist/basic-sdk/extension/plugins/seatable-tables/seatable-settings/filter-setter/filter-popover-widgets/department-filter/index.js +20 -3
- package/dist/basic-sdk/extension/plugins/seatable-tables/seatable-settings/filter-setter/filter-popover-widgets/department-filter/selected-departments.js +35 -28
- package/dist/basic-sdk/extension/plugins/seatable-tables/seatable-settings/filter-setter/filter-popover-widgets/department-filter/use-click-outside.js +9 -3
- package/dist/basic-sdk/extension/plugins/seatable-tables/seatable-settings/filter-setter/filter-popover-widgets/filter-item-utils.js +26 -19
- package/dist/basic-sdk/extension/plugins/seatable-tables/seatable-settings/filter-setter/filter-popover-widgets/filter-item.js +146 -138
- package/dist/basic-sdk/extension/plugins/seatable-tables/seatable-settings/filter-setter/filter-popover-widgets/filters-list.js +36 -28
- package/dist/basic-sdk/extension/plugins/seatable-tables/seatable-settings/filter-setter/filter-popover-widgets/number-editor/index.js +39 -31
- package/dist/basic-sdk/extension/plugins/seatable-tables/seatable-settings/filter-setter/filter-popover-widgets/rate-item/index.js +21 -14
- package/dist/basic-sdk/extension/plugins/seatable-tables/seatable-settings/filter-setter/filter-popover.js +43 -36
- package/dist/basic-sdk/extension/plugins/seatable-tables/seatable-settings/filter-setter/filters-utils.js +127 -107
- package/dist/basic-sdk/extension/plugins/seatable-tables/seatable-settings/filter-setter/index.js +20 -13
- package/dist/basic-sdk/extension/plugins/seatable-tables/seatable-settings/hide-column-setter/hide-column-item.js +17 -10
- package/dist/basic-sdk/extension/plugins/seatable-tables/seatable-settings/hide-column-setter/hide-column-popover.js +38 -31
- package/dist/basic-sdk/extension/plugins/seatable-tables/seatable-settings/hide-column-setter/index.js +18 -10
- package/dist/basic-sdk/extension/plugins/seatable-tables/seatable-settings/index.js +48 -40
- package/dist/basic-sdk/extension/plugins/seatable-tables/seatable-settings/sort-setter/index.js +18 -10
- package/dist/basic-sdk/extension/plugins/seatable-tables/seatable-settings/sort-setter/sort-popover.js +72 -64
- package/dist/basic-sdk/extension/plugins/seatable-tables/seatable-settings/sort-setter/sort-utils.js +18 -9
- package/dist/basic-sdk/extension/plugins/seatable-tables/seatable-settings/table-setting/index.js +15 -8
- package/dist/basic-sdk/extension/plugins/seatable-tables/seatable-settings/utils/utils.js +21 -10
- package/dist/basic-sdk/extension/plugins/table/constants/index.js +30 -24
- package/dist/basic-sdk/extension/plugins/table/dialogs/custom-table-size-dialog/index.js +38 -30
- package/dist/basic-sdk/extension/plugins/table/dialogs/custom-table-size-dialog/number-input.js +11 -4
- package/dist/basic-sdk/extension/plugins/table/dialogs/index.js +20 -3
- package/dist/basic-sdk/extension/plugins/table/dialogs/split-cell-setting-dialog.js +32 -25
- package/dist/basic-sdk/extension/plugins/table/helpers.js +436 -365
- package/dist/basic-sdk/extension/plugins/table/index.js +18 -11
- package/dist/basic-sdk/extension/plugins/table/menu/active-table-menu/common-menu.js +26 -18
- package/dist/basic-sdk/extension/plugins/table/menu/color-selector-popover/color-item.js +13 -6
- package/dist/basic-sdk/extension/plugins/table/menu/color-selector-popover/index.js +66 -58
- package/dist/basic-sdk/extension/plugins/table/menu/horizontal-align-popover/index.js +39 -31
- package/dist/basic-sdk/extension/plugins/table/menu/index.js +20 -3
- package/dist/basic-sdk/extension/plugins/table/menu/table-context-menu/index.js +84 -77
- package/dist/basic-sdk/extension/plugins/table/menu/table-context-menu/insert-table-element.js +29 -21
- package/dist/basic-sdk/extension/plugins/table/menu/table-menu/index.js +23 -15
- package/dist/basic-sdk/extension/plugins/table/menu/vertical-align-popover/index.js +40 -32
- package/dist/basic-sdk/extension/plugins/table/model.js +15 -9
- package/dist/basic-sdk/extension/plugins/table/plugin.js +121 -114
- package/dist/basic-sdk/extension/plugins/table/popover/table-size-popover/index.js +37 -29
- package/dist/basic-sdk/extension/plugins/table/popover/table-template/index.js +21 -13
- package/dist/basic-sdk/extension/plugins/table/popover/table-template/sample-table.js +21 -13
- package/dist/basic-sdk/extension/plugins/table/render/drag-handlers/column-drag-handler.js +12 -5
- package/dist/basic-sdk/extension/plugins/table/render/drag-handlers/index.js +23 -15
- package/dist/basic-sdk/extension/plugins/table/render/drag-handlers/row-drag-handler.js +12 -5
- package/dist/basic-sdk/extension/plugins/table/render/hooks.js +38 -26
- package/dist/basic-sdk/extension/plugins/table/render/index.js +104 -96
- package/dist/basic-sdk/extension/plugins/table/render/render-cell.js +72 -64
- package/dist/basic-sdk/extension/plugins/table/render/render-row.js +10 -3
- package/dist/basic-sdk/extension/plugins/table/render/resize-handlers/column-resize-handler.js +36 -29
- package/dist/basic-sdk/extension/plugins/table/render/resize-handlers/first-column-left-resize-handler.js +34 -27
- package/dist/basic-sdk/extension/plugins/table/render/resize-handlers/index.js +25 -17
- package/dist/basic-sdk/extension/plugins/table/render/resize-handlers/row-resize-handler.js +37 -30
- package/dist/basic-sdk/extension/plugins/table/render/resize-mask/index.js +44 -36
- package/dist/basic-sdk/extension/plugins/table/render/table-header/columns-header/column-header.js +28 -20
- package/dist/basic-sdk/extension/plugins/table/render/table-header/columns-header/index.js +34 -26
- package/dist/basic-sdk/extension/plugins/table/render/table-header/index.js +36 -29
- package/dist/basic-sdk/extension/plugins/table/render/table-header/rows-columns-header.js +16 -9
- package/dist/basic-sdk/extension/plugins/table/render/table-header/rows-header/index.js +31 -23
- package/dist/basic-sdk/extension/plugins/table/render/table-header/rows-header/row-header.js +38 -30
- package/dist/basic-sdk/extension/plugins/table/render/table-root.js +27 -19
- package/dist/basic-sdk/extension/plugins/table/render-elem.js +27 -4
- package/dist/basic-sdk/extension/plugins/text-align/helpers.js +22 -13
- package/dist/basic-sdk/extension/plugins/text-align/index.js +7 -1
- package/dist/basic-sdk/extension/plugins/text-align/menu/index.js +41 -33
- package/dist/basic-sdk/extension/plugins/text-style/caret.js +12 -5
- package/dist/basic-sdk/extension/plugins/text-style/helpers.js +31 -21
- package/dist/basic-sdk/extension/plugins/text-style/index.js +12 -5
- package/dist/basic-sdk/extension/plugins/text-style/menu/comemnt-editor-menu.js +29 -22
- package/dist/basic-sdk/extension/plugins/text-style/menu/index.js +59 -51
- package/dist/basic-sdk/extension/plugins/text-style/plugin.js +15 -9
- package/dist/basic-sdk/extension/plugins/text-style/render-elem.js +45 -38
- package/dist/basic-sdk/extension/plugins/wiki-link/helpers.js +33 -23
- package/dist/basic-sdk/extension/plugins/wiki-link/index.js +14 -7
- package/dist/basic-sdk/extension/render/custom-element.js +88 -82
- package/dist/basic-sdk/extension/render/element-decorate/index.js +13 -2
- package/dist/basic-sdk/extension/render/element-decorate/rebase-decorate/index.js +23 -16
- package/dist/basic-sdk/extension/render/element-decorate/rebase-decorate/rebase-delete-modify-decorate.js +37 -30
- package/dist/basic-sdk/extension/render/element-decorate/rebase-decorate/rebase-modify-delete-decorate.js +37 -30
- package/dist/basic-sdk/extension/render/element-decorate/rebase-decorate/rebase-modify-modify-decorate.js +51 -43
- package/dist/basic-sdk/extension/render/helper.js +21 -13
- package/dist/basic-sdk/extension/render/render-comment-editor-element.js +37 -31
- package/dist/basic-sdk/extension/render/render-element.js +16 -9
- package/dist/basic-sdk/extension/render/render-leaf.js +14 -7
- package/dist/basic-sdk/extension/toolbar/comment-editor-toolbar/index.js +33 -26
- package/dist/basic-sdk/extension/toolbar/comment-editor-toolbar/post-comment/index.js +16 -8
- package/dist/basic-sdk/extension/toolbar/context-toolbar/index.js +34 -26
- package/dist/basic-sdk/extension/toolbar/header-toolbar/index.js +44 -37
- package/dist/basic-sdk/extension/toolbar/header-toolbar/insert-toolbar/index.js +42 -34
- package/dist/basic-sdk/extension/toolbar/header-toolbar/redo-undo.js +22 -15
- package/dist/basic-sdk/extension/toolbar/index.js +27 -4
- package/dist/basic-sdk/extension/toolbar/insert-element-toolbar/const.js +25 -19
- package/dist/basic-sdk/extension/toolbar/insert-element-toolbar/index.js +110 -102
- package/dist/basic-sdk/extension/toolbar/side-toolbar/event.js +28 -17
- package/dist/basic-sdk/extension/toolbar/side-toolbar/helpers.js +108 -88
- package/dist/basic-sdk/extension/toolbar/side-toolbar/index.js +103 -95
- package/dist/basic-sdk/extension/toolbar/side-toolbar/insert-below-menu.js +16 -9
- package/dist/basic-sdk/extension/toolbar/side-toolbar/insert-block-menu.js +81 -73
- package/dist/basic-sdk/extension/toolbar/side-toolbar/side-menu.js +61 -53
- package/dist/basic-sdk/extension/toolbar/side-toolbar/transform-menus.js +34 -26
- package/dist/basic-sdk/extension/utils/index.js +17 -7
- package/dist/basic-sdk/highlight/index.js +18 -6
- package/dist/basic-sdk/highlight/setNodeToDecorations.js +24 -16
- package/dist/basic-sdk/hooks/use-color-context.js +20 -11
- package/dist/basic-sdk/hooks/use-force-update.js +10 -4
- package/dist/basic-sdk/hooks/use-scroll-context.js +13 -5
- package/dist/basic-sdk/hooks/use-selection-element.js +14 -7
- package/dist/basic-sdk/hooks/use-selection-position.js +19 -11
- package/dist/basic-sdk/hooks/use-selection-update.js +13 -6
- package/dist/basic-sdk/index.js +59 -6
- package/dist/basic-sdk/layout/article-container.js +31 -23
- package/dist/basic-sdk/layout/editor-container.js +19 -12
- package/dist/basic-sdk/layout/editor-content.js +32 -24
- package/dist/basic-sdk/layout/index.js +27 -4
- package/dist/basic-sdk/node-id/constants.js +15 -9
- package/dist/basic-sdk/node-id/helpers.js +37 -26
- package/dist/basic-sdk/node-id/index.js +14 -8
- package/dist/basic-sdk/outline/index.js +39 -29
- package/dist/basic-sdk/outline/outline-item.js +17 -10
- package/dist/basic-sdk/socket/helpers.js +43 -28
- package/dist/basic-sdk/socket/index.js +20 -3
- package/dist/basic-sdk/socket/socket-client.js +66 -59
- package/dist/basic-sdk/socket/socket-manager.js +91 -85
- package/dist/basic-sdk/socket/with-socket-io.js +18 -11
- package/dist/basic-sdk/utils/Kebab-to-camel.js +8 -2
- package/dist/basic-sdk/utils/debounce.js +7 -1
- package/dist/basic-sdk/utils/debug.js +13 -7
- package/dist/basic-sdk/utils/diff-text.js +24 -17
- package/dist/basic-sdk/utils/diff.js +57 -46
- package/dist/basic-sdk/utils/document-utils.js +29 -18
- package/dist/basic-sdk/utils/dom-utils.js +15 -5
- package/dist/basic-sdk/utils/event-bus.js +7 -1
- package/dist/basic-sdk/utils/event-handler.js +40 -33
- package/dist/basic-sdk/utils/mouse-event.js +19 -7
- package/dist/basic-sdk/utils/object-utils.js +15 -8
- package/dist/basic-sdk/utils/rebase.js +73 -63
- package/dist/basic-sdk/views/index.js +41 -6
- package/dist/basic-sdk/views/published-revision-diff-viewer.js +22 -14
- package/dist/basic-sdk/views/readonly-article.js +23 -15
- package/dist/basic-sdk/views/revision-diff-viewer.js +26 -18
- package/dist/basic-sdk/views/sdoc-diff-viewer.js +23 -15
- package/dist/basic-sdk/views/sdoc-viewer.js +22 -15
- package/dist/basic-sdk/views/sdoc-wiki-viewer.js +28 -20
- package/dist/basic-sdk/wiki-outline/index.js +24 -16
- package/dist/basic-sdk/wiki-outline/outline-item.js +14 -6
- package/dist/components/common-loading/index.js +11 -4
- package/dist/components/doc-info/index.js +62 -54
- package/dist/components/doc-operations/collaborators-operation/collaborators-popover.js +22 -15
- package/dist/components/doc-operations/collaborators-operation/index.js +23 -15
- package/dist/components/doc-operations/comments-operation/index.js +24 -17
- package/dist/components/doc-operations/index.js +25 -18
- package/dist/components/doc-operations/more-operations.js +54 -46
- package/dist/components/doc-operations/revision-operations/changes-count/index.js +36 -28
- package/dist/components/doc-operations/revision-operations/index.js +87 -79
- package/dist/components/doc-operations/revision-operations/more-revision-operations/index.js +35 -27
- package/dist/components/doc-operations/revision-operations/publish-revision/index.js +14 -7
- package/dist/components/doc-operations/revision-operations/revisions/index.js +28 -20
- package/dist/components/doc-operations/revision-operations/revisions/revisions-dialog/index.js +81 -73
- package/dist/components/doc-operations/revision-operations/revisions/revisions-dialog/revision-operation/index.js +24 -16
- package/dist/components/doc-operations/revision-operations/view-changes/index.js +31 -23
- package/dist/components/doc-operations/share-operation/index.js +16 -9
- package/dist/components/draft-dropdown/index.js +26 -19
- package/dist/components/loading/index.js +14 -7
- package/dist/components/modal-portal/index.js +12 -5
- package/dist/components/switch/index.js +17 -10
- package/dist/components/tip-dialog/index.js +47 -39
- package/dist/components/tip-message/index.js +43 -36
- package/dist/components/toast/alert.js +19 -12
- package/dist/components/toast/index.js +10 -3
- package/dist/components/toast/toast.js +26 -18
- package/dist/components/toast/toastManager.js +22 -14
- package/dist/components/toast/toaster.js +25 -17
- package/dist/components/tooltip/index.js +14 -7
- package/dist/constants/index.js +23 -8
- package/dist/constants/key-codes.js +2 -0
- package/dist/constants/transfer-types.js +9 -3
- package/dist/context.js +21 -14
- package/dist/hooks/index.js +25 -3
- package/dist/hooks/use-collaborators.js +25 -15
- package/dist/hooks/use-document.js +22 -14
- package/dist/index.js +75 -10
- package/dist/layout/content.js +15 -6
- package/dist/layout/header.js +15 -6
- package/dist/layout/index.js +24 -6
- package/dist/layout/layout.js +22 -14
- package/dist/model/index.js +27 -4
- package/dist/model/notification.js +9 -3
- package/dist/model/revision.js +10 -4
- package/dist/model/user.js +7 -1
- package/dist/pages/diff-viewer.js +8 -2
- package/dist/pages/document-plugin-editor.js +37 -29
- package/dist/pages/error-boundary.js +14 -5
- package/dist/pages/error-page.js +19 -11
- package/dist/pages/published-revision-viewer.js +39 -31
- package/dist/pages/sdoc-wiki-editor.js +29 -21
- package/dist/pages/simple-editor.js +53 -45
- package/dist/pages/simple-viewer.js +40 -32
- package/dist/pages/wiki-viewer.js +15 -8
- package/dist/slate-convert/html-to-slate/constants.js +32 -26
- package/dist/slate-convert/html-to-slate/helper.js +9 -2
- package/dist/slate-convert/html-to-slate/index.js +30 -24
- package/dist/slate-convert/html-to-slate/rules/blockquote.js +12 -5
- package/dist/slate-convert/html-to-slate/rules/check-list.js +13 -6
- package/dist/slate-convert/html-to-slate/rules/code-block.js +28 -21
- package/dist/slate-convert/html-to-slate/rules/header.js +13 -6
- package/dist/slate-convert/html-to-slate/rules/image.js +13 -6
- package/dist/slate-convert/html-to-slate/rules/index.js +18 -11
- package/dist/slate-convert/html-to-slate/rules/link.js +13 -6
- package/dist/slate-convert/html-to-slate/rules/list.js +22 -15
- package/dist/slate-convert/html-to-slate/rules/paragraph.js +12 -5
- package/dist/slate-convert/html-to-slate/rules/table.js +16 -9
- package/dist/slate-convert/html-to-slate/rules/text.js +16 -9
- package/dist/slate-convert/index.js +34 -8
- package/dist/slate-convert/md-to-html/index.js +31 -26
- package/dist/slate-convert/md-to-html/sanitize-schema.js +11 -4
- package/dist/slate-convert/md-to-slate/index.js +18 -12
- package/dist/slate-convert/md-to-slate/transform.js +109 -83
- package/dist/slate-convert/slate-to-md/index.js +16 -10
- package/dist/slate-convert/slate-to-md/transform.js +18 -11
- package/dist/utils/base64-to-unit8array.js +7 -1
- package/dist/utils/date-utils.js +18 -12
- package/dist/utils/get-event-transfer.js +9 -3
- package/dist/utils/hotkey.js +32 -25
- package/dist/utils/index.js +54 -18
- package/dist/utils/is-punctuation-mark.js +7 -1
- package/dist/utils/local-storage-utils.js +7 -1
- package/package.json +1 -1
|
@@ -1,41 +1,48 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
|
|
4
|
+
Object.defineProperty(exports, "__esModule", {
|
|
5
|
+
value: true
|
|
6
|
+
});
|
|
7
|
+
exports.updateTableRowHeight = exports.updateColumnWidth = exports.splitCell = exports.setTableSelectedRange = exports.setTableFragmentData = exports.setCellStyle = exports.removeTableElement = exports.removeTable = exports.normalizeTableELement = exports.moveRows = exports.moveColumns = exports.isTableWidthFitScreen = exports.isTableMenuDisabled = exports.isTableLocation = exports.isSelectedAllCell = exports.isPreventResetTableSelectedRange = exports.isLastTableCell = exports.isInTable = exports.isHideDragHandlerLine = exports.isCursorAtCellStart = exports.isCursorAtCellEnd = exports.isCombineCellsDisabled = exports.isAllInTable = exports.insertTableRow = exports.insertTableElement = exports.insertTableColumn = exports.insertTableByTemplate = exports.insertTable = exports.insertMultipleRowsAndColumns = exports.handleInsertTable = exports.handleCombinedCellsBeforeDeleteTableRow = exports.handleCombinedCellsBeforeDeleteTableColumn = exports.handleCombinedCellsAfterInsertTableRow = exports.handleCombinedCellsAfterInsertTableColumn = exports.getTableSelectedRangeAfterDrag = exports.getTableRowSelectedRange = exports.getTableDragType = exports.getTableColumnsWidth = exports.getTableColumnsAfterInsertColumn = exports.getTableColumns = exports.getTableColumnSelectedRange = exports.getSelectedInfo = exports.getRowHeight = exports.getRowDomHeight = exports.getResizeMaskCellInfo = exports.getInsertPosition = exports.getHighlightClass = exports.getFirstTableCell = exports.getCellInheritStyles = exports.getCellHighlightClassName = exports.getCellColumn = exports.generateTableRow = exports.generateTableCell = exports.generateInheritStyle = exports.generateEmptyTable = exports.generateDragMoveElement = exports.focusClosestCellWhenJustifyCellSize = exports.focusCell = exports.fitTableColumnToScreen = exports.elementHasImage = exports.deleteTableRangeData = exports.deleteHandler = exports.combineCells = exports.colorBlend = exports.adjustCombinedCellRange = void 0;
|
|
8
|
+
var _slugid = _interopRequireDefault(require("slugid"));
|
|
9
|
+
var _slate = require("@seafile/slate");
|
|
10
|
+
var _slateReact = require("@seafile/slate-react");
|
|
11
|
+
var _deepCopy = _interopRequireDefault(require("deep-copy"));
|
|
12
|
+
var _core = require("../../core");
|
|
13
|
+
var _constants = require("../../constants");
|
|
14
|
+
var _constants2 = require("./constants");
|
|
15
|
+
var _eventBus = _interopRequireDefault(require("../../../utils/event-bus"));
|
|
16
|
+
var _constants3 = require("../../../constants");
|
|
17
|
+
var _objectUtils = _interopRequireDefault(require("../../../utils/object-utils"));
|
|
18
|
+
var _helpers = require("../../../node-id/helpers");
|
|
19
|
+
const isTableMenuDisabled = (editor, readonly) => {
|
|
13
20
|
if (readonly) return true;
|
|
14
21
|
const {
|
|
15
22
|
selection
|
|
16
23
|
} = editor;
|
|
17
24
|
if (selection === null) return true;
|
|
18
|
-
if (!Range.isCollapsed(selection)) return true;
|
|
19
|
-
const [match] = Editor.nodes(editor, {
|
|
25
|
+
if (!_slate.Range.isCollapsed(selection)) return true;
|
|
26
|
+
const [match] = _slate.Editor.nodes(editor, {
|
|
20
27
|
match: n => {
|
|
21
|
-
let type = getNodeType(n);
|
|
22
|
-
if (!type && isTextNode(n) && n.id) {
|
|
23
|
-
const parentNode = getParentNode(editor.children, n.id);
|
|
24
|
-
type = getNodeType(parentNode);
|
|
28
|
+
let type = (0, _core.getNodeType)(n);
|
|
29
|
+
if (!type && (0, _core.isTextNode)(n) && n.id) {
|
|
30
|
+
const parentNode = (0, _core.getParentNode)(editor.children, n.id);
|
|
31
|
+
type = (0, _core.getNodeType)(parentNode);
|
|
25
32
|
}
|
|
26
33
|
if (type.startsWith('header')) return true;
|
|
27
|
-
if (type === ELEMENT_TYPE.TITLE) return true;
|
|
28
|
-
if (type === ELEMENT_TYPE.SUBTITLE) return true;
|
|
29
|
-
if (type === ELEMENT_TYPE.CODE_BLOCK) return true;
|
|
30
|
-
if (type === ELEMENT_TYPE.ORDERED_LIST) return true;
|
|
31
|
-
if (type === ELEMENT_TYPE.UNORDERED_LIST) return true;
|
|
32
|
-
if (type === ELEMENT_TYPE.BLOCKQUOTE) return true;
|
|
33
|
-
if (type === ELEMENT_TYPE.LIST_ITEM) return true;
|
|
34
|
-
if (type === ELEMENT_TYPE.TABLE) return true;
|
|
35
|
-
if (type === ELEMENT_TYPE.TABLE_CELL) return true;
|
|
36
|
-
if (type === ELEMENT_TYPE.TABLE_ROW) return true;
|
|
37
|
-
if (type === ELEMENT_TYPE.CALL_OUT) return true;
|
|
38
|
-
if (Editor.isVoid(editor, n)) return true;
|
|
34
|
+
if (type === _constants.ELEMENT_TYPE.TITLE) return true;
|
|
35
|
+
if (type === _constants.ELEMENT_TYPE.SUBTITLE) return true;
|
|
36
|
+
if (type === _constants.ELEMENT_TYPE.CODE_BLOCK) return true;
|
|
37
|
+
if (type === _constants.ELEMENT_TYPE.ORDERED_LIST) return true;
|
|
38
|
+
if (type === _constants.ELEMENT_TYPE.UNORDERED_LIST) return true;
|
|
39
|
+
if (type === _constants.ELEMENT_TYPE.BLOCKQUOTE) return true;
|
|
40
|
+
if (type === _constants.ELEMENT_TYPE.LIST_ITEM) return true;
|
|
41
|
+
if (type === _constants.ELEMENT_TYPE.TABLE) return true;
|
|
42
|
+
if (type === _constants.ELEMENT_TYPE.TABLE_CELL) return true;
|
|
43
|
+
if (type === _constants.ELEMENT_TYPE.TABLE_ROW) return true;
|
|
44
|
+
if (type === _constants.ELEMENT_TYPE.CALL_OUT) return true;
|
|
45
|
+
if (_slate.Editor.isVoid(editor, n)) return true;
|
|
39
46
|
return false;
|
|
40
47
|
},
|
|
41
48
|
universal: true
|
|
@@ -43,48 +50,51 @@ export const isTableMenuDisabled = (editor, readonly) => {
|
|
|
43
50
|
if (match) return true;
|
|
44
51
|
return false;
|
|
45
52
|
};
|
|
46
|
-
|
|
53
|
+
exports.isTableMenuDisabled = isTableMenuDisabled;
|
|
54
|
+
const isCombineCellsDisabled = (editor, readonly) => {
|
|
47
55
|
if (readonly) return true;
|
|
48
56
|
const {
|
|
49
57
|
selection,
|
|
50
58
|
tableSelectedRange
|
|
51
59
|
} = editor;
|
|
52
60
|
if (!selection) return true;
|
|
53
|
-
if (!
|
|
61
|
+
if (!_objectUtils.default.isSameObject(tableSelectedRange, _constants2.EMPTY_SELECTED_RANGE)) {
|
|
54
62
|
return false;
|
|
55
63
|
}
|
|
56
64
|
return true;
|
|
57
65
|
};
|
|
58
|
-
|
|
66
|
+
exports.isCombineCellsDisabled = isCombineCellsDisabled;
|
|
67
|
+
const generateTableCell = (editor, rowIndex, cellIndex) => {
|
|
59
68
|
let style = {};
|
|
60
|
-
const tableNodeEntry = getSelectedNodeEntryByType(editor, ELEMENT_TYPE.TABLE);
|
|
69
|
+
const tableNodeEntry = (0, _core.getSelectedNodeEntryByType)(editor, _constants.ELEMENT_TYPE.TABLE);
|
|
61
70
|
if (tableNodeEntry && rowIndex !== undefined && cellIndex !== undefined) {
|
|
62
71
|
const [, tablePath] = tableNodeEntry;
|
|
63
72
|
style = getCellInheritStyles(editor, tablePath, rowIndex, cellIndex);
|
|
64
73
|
}
|
|
65
74
|
return {
|
|
66
|
-
id:
|
|
67
|
-
type: ELEMENT_TYPE.TABLE_CELL,
|
|
75
|
+
id: _slugid.default.nice(),
|
|
76
|
+
type: _constants.ELEMENT_TYPE.TABLE_CELL,
|
|
68
77
|
children: [{
|
|
69
78
|
text: '',
|
|
70
|
-
id:
|
|
79
|
+
id: _slugid.default.nice()
|
|
71
80
|
}],
|
|
72
81
|
style,
|
|
73
82
|
inherit_style: style
|
|
74
83
|
};
|
|
75
84
|
};
|
|
76
|
-
|
|
85
|
+
exports.generateTableCell = generateTableCell;
|
|
86
|
+
const generateTableRow = (editor, colsCount, rowIndex) => {
|
|
77
87
|
let children = [];
|
|
78
88
|
for (let i = 0; i < colsCount; i++) {
|
|
79
89
|
const tableCell = generateTableCell(editor, rowIndex, i);
|
|
80
90
|
children.push(tableCell);
|
|
81
91
|
}
|
|
82
92
|
return {
|
|
83
|
-
id:
|
|
84
|
-
type: ELEMENT_TYPE.TABLE_ROW,
|
|
93
|
+
id: _slugid.default.nice(),
|
|
94
|
+
type: _constants.ELEMENT_TYPE.TABLE_ROW,
|
|
85
95
|
children: children,
|
|
86
96
|
style: {
|
|
87
|
-
[TABLE_ROW_STYLE.MIN_HEIGHT]: TABLE_ROW_MIN_HEIGHT
|
|
97
|
+
[_constants2.TABLE_ROW_STYLE.MIN_HEIGHT]: _constants2.TABLE_ROW_MIN_HEIGHT
|
|
88
98
|
}
|
|
89
99
|
};
|
|
90
100
|
};
|
|
@@ -96,7 +106,8 @@ export const generateTableRow = (editor, colsCount, rowIndex) => {
|
|
|
96
106
|
* @param {Boolean} tableProps.alternate_highlight - is alternate highlight
|
|
97
107
|
* @param {string} tableProps.alternate_highlight_color - table alternate highlight color
|
|
98
108
|
*/
|
|
99
|
-
|
|
109
|
+
exports.generateTableRow = generateTableRow;
|
|
110
|
+
const generateEmptyTable = (editor, tableProps) => {
|
|
100
111
|
const {
|
|
101
112
|
size = [0, 0],
|
|
102
113
|
alternate_highlight = false,
|
|
@@ -109,7 +120,7 @@ export const generateEmptyTable = (editor, tableProps) => {
|
|
|
109
120
|
const tableRow = generateTableRow(editor, colsCount, i);
|
|
110
121
|
children.push(tableRow);
|
|
111
122
|
}
|
|
112
|
-
const columnWidth = Math.max(TABLE_CELL_MIN_WIDTH, parseInt(editor.width / colsCount));
|
|
123
|
+
const columnWidth = Math.max(_constants2.TABLE_CELL_MIN_WIDTH, parseInt(editor.width / colsCount));
|
|
113
124
|
let columns = [];
|
|
114
125
|
for (let i = 0; i < colsCount; i++) {
|
|
115
126
|
columns.push({
|
|
@@ -117,8 +128,8 @@ export const generateEmptyTable = (editor, tableProps) => {
|
|
|
117
128
|
});
|
|
118
129
|
}
|
|
119
130
|
return {
|
|
120
|
-
id:
|
|
121
|
-
type: ELEMENT_TYPE.TABLE,
|
|
131
|
+
id: _slugid.default.nice(),
|
|
132
|
+
type: _constants.ELEMENT_TYPE.TABLE,
|
|
122
133
|
children: children,
|
|
123
134
|
columns,
|
|
124
135
|
ui: {
|
|
@@ -126,73 +137,77 @@ export const generateEmptyTable = (editor, tableProps) => {
|
|
|
126
137
|
alternate_highlight_color
|
|
127
138
|
},
|
|
128
139
|
style: {
|
|
129
|
-
gridTemplateColumns:
|
|
130
|
-
gridAutoRows:
|
|
140
|
+
gridTemplateColumns: `repeat(${colsCount}, ${columnWidth}px)`,
|
|
141
|
+
gridAutoRows: `minmax(${_constants2.TABLE_ROW_MIN_HEIGHT}px, auto)`
|
|
131
142
|
}
|
|
132
143
|
};
|
|
133
144
|
};
|
|
134
|
-
|
|
135
|
-
|
|
145
|
+
exports.generateEmptyTable = generateEmptyTable;
|
|
146
|
+
const insertTable = function (editor, size, selection) {
|
|
147
|
+
let position = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : _constants.INSERT_POSITION.CURRENT;
|
|
136
148
|
if (!size) return;
|
|
137
|
-
if (position !== INSERT_POSITION.AFTER) {
|
|
149
|
+
if (position !== _constants.INSERT_POSITION.AFTER) {
|
|
138
150
|
if (isTableMenuDisabled(editor)) return;
|
|
139
151
|
}
|
|
140
152
|
const tableNode = generateEmptyTable(editor, {
|
|
141
153
|
size
|
|
142
154
|
});
|
|
143
155
|
const validSelection = selection || editor.selection;
|
|
144
|
-
const path = Editor.path(editor, validSelection);
|
|
156
|
+
const path = _slate.Editor.path(editor, validSelection);
|
|
145
157
|
handleInsertTable(editor, position, path, tableNode);
|
|
146
158
|
};
|
|
147
159
|
|
|
148
160
|
// tableSize [tableHeight, tableWidth]
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
const
|
|
152
|
-
const
|
|
153
|
-
const
|
|
161
|
+
exports.insertTable = insertTable;
|
|
162
|
+
const getSelectedInfo = editor => {
|
|
163
|
+
const currentTable = (0, _core.getSelectedNodeByType)(editor, _constants.ELEMENT_TYPE.TABLE);
|
|
164
|
+
const currentRow = (0, _core.getSelectedNodeByType)(editor, _constants.ELEMENT_TYPE.TABLE_ROW);
|
|
165
|
+
const currentCell = (0, _core.getSelectedNodeByType)(editor, _constants.ELEMENT_TYPE.TABLE_CELL);
|
|
166
|
+
const currentCellPath = (0, _core.findPath)(editor, currentCell);
|
|
154
167
|
return {
|
|
155
168
|
table: currentTable,
|
|
156
|
-
tablePath: findPath(editor, currentTable),
|
|
169
|
+
tablePath: (0, _core.findPath)(editor, currentTable),
|
|
157
170
|
tableSize: [currentTable.children.length, currentRow.children.length],
|
|
158
171
|
row: currentRow,
|
|
159
|
-
rowPath: findPath(editor, currentRow),
|
|
172
|
+
rowPath: (0, _core.findPath)(editor, currentRow),
|
|
160
173
|
rowIndex: currentCellPath[currentCellPath.length - 2],
|
|
161
174
|
cell: currentCell,
|
|
162
|
-
cellPath: findPath(editor, currentCell),
|
|
175
|
+
cellPath: (0, _core.findPath)(editor, currentCell),
|
|
163
176
|
cellIndex: currentCellPath[currentCellPath.length - 1]
|
|
164
177
|
};
|
|
165
178
|
};
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
179
|
+
exports.getSelectedInfo = getSelectedInfo;
|
|
180
|
+
const isInTable = editor => {
|
|
181
|
+
const selectedNodes = (0, _core.getSelectedElems)(editor);
|
|
182
|
+
if (!selectedNodes.some(node => node.type === _constants.ELEMENT_TYPE.TABLE)) return false;
|
|
169
183
|
const firstSelectedNode = selectedNodes[0];
|
|
170
|
-
return firstSelectedNode.type === ELEMENT_TYPE.TABLE;
|
|
184
|
+
return firstSelectedNode.type === _constants.ELEMENT_TYPE.TABLE;
|
|
171
185
|
};
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
186
|
+
exports.isInTable = isInTable;
|
|
187
|
+
const isAllInTable = editor => {
|
|
188
|
+
const selectedNodes = (0, _core.getSelectedElems)(editor);
|
|
189
|
+
if (!selectedNodes.some(node => node.type === _constants.ELEMENT_TYPE.TABLE)) return false;
|
|
175
190
|
const firstSelectedNode = selectedNodes[0];
|
|
176
|
-
if (firstSelectedNode.type !== ELEMENT_TYPE.TABLE) return false;
|
|
177
|
-
return selectedNodes.slice(1).every(node => [ELEMENT_TYPE.TABLE_ROW, ELEMENT_TYPE.TABLE_CELL].includes(node.type)); // same table element
|
|
191
|
+
if (firstSelectedNode.type !== _constants.ELEMENT_TYPE.TABLE) return false;
|
|
192
|
+
return selectedNodes.slice(1).every(node => [_constants.ELEMENT_TYPE.TABLE_ROW, _constants.ELEMENT_TYPE.TABLE_CELL].includes(node.type)); // same table element
|
|
178
193
|
};
|
|
179
|
-
|
|
180
|
-
|
|
194
|
+
exports.isAllInTable = isAllInTable;
|
|
195
|
+
const setCellStyle = (editor, style) => {
|
|
181
196
|
// Select single cell
|
|
182
|
-
if (
|
|
183
|
-
const selectedNodes = getSelectedElems(editor);
|
|
197
|
+
if (_objectUtils.default.isSameObject(editor.tableSelectedRange, _constants2.EMPTY_SELECTED_RANGE)) {
|
|
198
|
+
const selectedNodes = (0, _core.getSelectedElems)(editor);
|
|
184
199
|
let firstTableCellNodePath;
|
|
185
200
|
selectedNodes.forEach(node => {
|
|
186
|
-
if (node.type === ELEMENT_TYPE.TABLE_CELL) {
|
|
187
|
-
const path = findPath(editor, node);
|
|
201
|
+
if (node.type === _constants.ELEMENT_TYPE.TABLE_CELL) {
|
|
202
|
+
const path = (0, _core.findPath)(editor, node);
|
|
188
203
|
if (path) {
|
|
189
204
|
firstTableCellNodePath = firstTableCellNodePath ? firstTableCellNodePath : path;
|
|
190
|
-
Transforms.setNodes(editor, {
|
|
205
|
+
_slate.Transforms.setNodes(editor, {
|
|
191
206
|
style: {
|
|
192
207
|
...node.style,
|
|
193
208
|
...style
|
|
194
209
|
},
|
|
195
|
-
inherit_style: generateInheritStyle(INHERIT_CELL_STYLE_WHEN_SELECT_SINGLE, style, node)
|
|
210
|
+
inherit_style: generateInheritStyle(_constants2.INHERIT_CELL_STYLE_WHEN_SELECT_SINGLE, style, node)
|
|
196
211
|
}, {
|
|
197
212
|
at: path
|
|
198
213
|
});
|
|
@@ -200,13 +215,13 @@ export const setCellStyle = (editor, style) => {
|
|
|
200
215
|
}
|
|
201
216
|
});
|
|
202
217
|
if (firstTableCellNodePath) {
|
|
203
|
-
const start = Editor.start(editor, firstTableCellNodePath);
|
|
204
|
-
const end = Editor.end(editor, firstTableCellNodePath);
|
|
218
|
+
const start = _slate.Editor.start(editor, firstTableCellNodePath);
|
|
219
|
+
const end = _slate.Editor.end(editor, firstTableCellNodePath);
|
|
205
220
|
const newSelection = {
|
|
206
221
|
anchor: start,
|
|
207
222
|
focus: end
|
|
208
223
|
};
|
|
209
|
-
Transforms.select(editor, newSelection);
|
|
224
|
+
_slate.Transforms.select(editor, newSelection);
|
|
210
225
|
}
|
|
211
226
|
return;
|
|
212
227
|
}
|
|
@@ -223,39 +238,41 @@ export const setCellStyle = (editor, style) => {
|
|
|
223
238
|
for (let i = minRowIndex; i <= maxRowIndex; i++) {
|
|
224
239
|
for (let j = minColIndex; j <= maxColIndex; j++) {
|
|
225
240
|
const path = [...tablePath, i, j];
|
|
226
|
-
const node = getNode(editor, path);
|
|
227
|
-
Transforms.setNodes(editor, {
|
|
241
|
+
const node = (0, _core.getNode)(editor, path);
|
|
242
|
+
_slate.Transforms.setNodes(editor, {
|
|
228
243
|
style: {
|
|
229
244
|
...node.style,
|
|
230
245
|
...style
|
|
231
246
|
},
|
|
232
|
-
inherit_style: generateInheritStyle(INHERIT_CELL_STYLE_WHEN_SELECT_MULTIPLE, style, node)
|
|
247
|
+
inherit_style: generateInheritStyle(_constants2.INHERIT_CELL_STYLE_WHEN_SELECT_MULTIPLE, style, node)
|
|
233
248
|
}, {
|
|
234
249
|
at: path
|
|
235
250
|
});
|
|
236
251
|
}
|
|
237
252
|
}
|
|
238
253
|
};
|
|
239
|
-
|
|
240
|
-
|
|
254
|
+
exports.setCellStyle = setCellStyle;
|
|
255
|
+
const insertTableRow = function (editor, table, rowIndex) {
|
|
256
|
+
let position = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : _constants2.TABLE_ELEMENT_POSITION.AFTER;
|
|
241
257
|
const tableRowCount = table.children.length;
|
|
242
|
-
if (tableRowCount >= TABLE_MAX_ROWS) return;
|
|
258
|
+
if (tableRowCount >= _constants2.TABLE_MAX_ROWS) return;
|
|
243
259
|
const tableColumnCount = table.children[0].children.length;
|
|
244
260
|
const row = generateTableRow(editor, tableColumnCount, rowIndex);
|
|
245
|
-
const tablePath = findPath(editor, table);
|
|
246
|
-
const targetPath = position === TABLE_ELEMENT_POSITION.AFTER ? [...tablePath, rowIndex + 1] : [...tablePath, rowIndex];
|
|
247
|
-
Transforms.insertNodes(editor, row, {
|
|
261
|
+
const tablePath = (0, _core.findPath)(editor, table);
|
|
262
|
+
const targetPath = position === _constants2.TABLE_ELEMENT_POSITION.AFTER ? [...tablePath, rowIndex + 1] : [...tablePath, rowIndex];
|
|
263
|
+
_slate.Transforms.insertNodes(editor, row, {
|
|
248
264
|
at: targetPath
|
|
249
265
|
});
|
|
250
266
|
const focusPath = [...targetPath, 0];
|
|
251
|
-
focusEditor(editor, focusPath);
|
|
267
|
+
(0, _core.focusEditor)(editor, focusPath);
|
|
252
268
|
|
|
253
269
|
// handle cells with the rowspan > 1
|
|
254
|
-
if (position === TABLE_ELEMENT_POSITION.AFTER) {
|
|
270
|
+
if (position === _constants2.TABLE_ELEMENT_POSITION.AFTER) {
|
|
255
271
|
handleCombinedCellsAfterInsertTableRow(editor, tablePath, table, rowIndex);
|
|
256
272
|
}
|
|
257
273
|
};
|
|
258
|
-
|
|
274
|
+
exports.insertTableRow = insertTableRow;
|
|
275
|
+
const handleCombinedCellsAfterInsertTableRow = (editor, tablePath, table, rowIndex) => {
|
|
259
276
|
// important background info: the new row is inserted after rowIndex
|
|
260
277
|
const cells = table.children[rowIndex].children;
|
|
261
278
|
for (let i = 0, len = cells.length; i < len; i++) {
|
|
@@ -272,13 +289,13 @@ export const handleCombinedCellsAfterInsertTableRow = (editor, tablePath, table,
|
|
|
272
289
|
colspan: ri_colspan
|
|
273
290
|
} = table.children[ri].children[i];
|
|
274
291
|
if (!ri_is_combined && ri + ri_rowspan - 1 > rowIndex) {
|
|
275
|
-
Transforms.setNodes(editor, {
|
|
292
|
+
_slate.Transforms.setNodes(editor, {
|
|
276
293
|
rowspan: ri_rowspan + 1
|
|
277
294
|
}, {
|
|
278
295
|
at: [...tablePath, ri, i]
|
|
279
296
|
});
|
|
280
297
|
for (let j = 0; j < ri_colspan; j++) {
|
|
281
|
-
Transforms.setNodes(editor, {
|
|
298
|
+
_slate.Transforms.setNodes(editor, {
|
|
282
299
|
'is_combined': true
|
|
283
300
|
}, {
|
|
284
301
|
at: [...tablePath, rowIndex + 1, i + j]
|
|
@@ -289,13 +306,13 @@ export const handleCombinedCellsAfterInsertTableRow = (editor, tablePath, table,
|
|
|
289
306
|
}
|
|
290
307
|
} else {
|
|
291
308
|
if (rowspan > 1) {
|
|
292
|
-
Transforms.setNodes(editor, {
|
|
309
|
+
_slate.Transforms.setNodes(editor, {
|
|
293
310
|
rowspan: rowspan + 1
|
|
294
311
|
}, {
|
|
295
312
|
at: [...tablePath, rowIndex, i]
|
|
296
313
|
});
|
|
297
314
|
for (let j = 0; j < colspan; j++) {
|
|
298
|
-
Transforms.setNodes(editor, {
|
|
315
|
+
_slate.Transforms.setNodes(editor, {
|
|
299
316
|
'is_combined': true
|
|
300
317
|
}, {
|
|
301
318
|
at: [...tablePath, rowIndex + 1, i + j]
|
|
@@ -305,31 +322,33 @@ export const handleCombinedCellsAfterInsertTableRow = (editor, tablePath, table,
|
|
|
305
322
|
}
|
|
306
323
|
}
|
|
307
324
|
};
|
|
308
|
-
|
|
309
|
-
|
|
325
|
+
exports.handleCombinedCellsAfterInsertTableRow = handleCombinedCellsAfterInsertTableRow;
|
|
326
|
+
const insertTableColumn = function (editor, table, columnIndex) {
|
|
327
|
+
let position = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : _constants2.TABLE_ELEMENT_POSITION.AFTER;
|
|
310
328
|
const tableColumnCount = table.children[0].children.length;
|
|
311
|
-
if (tableColumnCount >= TABLE_MAX_COLUMNS) return;
|
|
312
|
-
const newCellIndex = position === TABLE_ELEMENT_POSITION.AFTER ? columnIndex + 1 : columnIndex;
|
|
329
|
+
if (tableColumnCount >= _constants2.TABLE_MAX_COLUMNS) return;
|
|
330
|
+
const newCellIndex = position === _constants2.TABLE_ELEMENT_POSITION.AFTER ? columnIndex + 1 : columnIndex;
|
|
313
331
|
const newColumns = getTableColumnsAfterInsertColumn(editor, table, newCellIndex, 1);
|
|
314
332
|
updateColumnWidth(editor, table, newColumns);
|
|
315
|
-
const tablePath = findPath(editor, table);
|
|
333
|
+
const tablePath = (0, _core.findPath)(editor, table);
|
|
316
334
|
const tableRowCount = table.children.length;
|
|
317
335
|
for (let i = 0; i < tableRowCount; i++) {
|
|
318
336
|
const newCellPath = [...tablePath, i, newCellIndex];
|
|
319
337
|
const newCell = generateTableCell(editor, i, columnIndex);
|
|
320
|
-
Transforms.insertNodes(editor, newCell, {
|
|
338
|
+
_slate.Transforms.insertNodes(editor, newCell, {
|
|
321
339
|
at: newCellPath
|
|
322
340
|
});
|
|
323
341
|
}
|
|
324
342
|
const focusPath = [...tablePath, 0, newCellIndex, 0];
|
|
325
|
-
focusEditor(editor, focusPath);
|
|
343
|
+
(0, _core.focusEditor)(editor, focusPath);
|
|
326
344
|
|
|
327
345
|
// handle cells with the colspan > 1
|
|
328
|
-
if (position === TABLE_ELEMENT_POSITION.AFTER) {
|
|
346
|
+
if (position === _constants2.TABLE_ELEMENT_POSITION.AFTER) {
|
|
329
347
|
handleCombinedCellsAfterInsertTableColumn(editor, tablePath, table, columnIndex);
|
|
330
348
|
}
|
|
331
349
|
};
|
|
332
|
-
|
|
350
|
+
exports.insertTableColumn = insertTableColumn;
|
|
351
|
+
const handleCombinedCellsAfterInsertTableColumn = (editor, tablePath, table, columnIndex) => {
|
|
333
352
|
// important background info: the new column is inserted after columnIndex
|
|
334
353
|
for (let i = 0, len = table.children.length; i < len; i++) {
|
|
335
354
|
const {
|
|
@@ -345,13 +364,13 @@ export const handleCombinedCellsAfterInsertTableColumn = (editor, tablePath, tab
|
|
|
345
364
|
colspan: ci_colspan
|
|
346
365
|
} = table.children[i].children[ci];
|
|
347
366
|
if (!ci_is_combined && ci + ci_colspan - 1 > columnIndex) {
|
|
348
|
-
Transforms.setNodes(editor, {
|
|
367
|
+
_slate.Transforms.setNodes(editor, {
|
|
349
368
|
colspan: ci_colspan + 1
|
|
350
369
|
}, {
|
|
351
370
|
at: [...tablePath, i, ci]
|
|
352
371
|
});
|
|
353
372
|
for (let j = 0; j < ci_rowspan; j++) {
|
|
354
|
-
Transforms.setNodes(editor, {
|
|
373
|
+
_slate.Transforms.setNodes(editor, {
|
|
355
374
|
'is_combined': true
|
|
356
375
|
}, {
|
|
357
376
|
at: [...tablePath, i + j, columnIndex + 1]
|
|
@@ -362,13 +381,13 @@ export const handleCombinedCellsAfterInsertTableColumn = (editor, tablePath, tab
|
|
|
362
381
|
}
|
|
363
382
|
} else {
|
|
364
383
|
if (colspan > 1) {
|
|
365
|
-
Transforms.setNodes(editor, {
|
|
384
|
+
_slate.Transforms.setNodes(editor, {
|
|
366
385
|
colspan: colspan + 1
|
|
367
386
|
}, {
|
|
368
387
|
at: [...tablePath, i, columnIndex]
|
|
369
388
|
});
|
|
370
389
|
for (let j = 0; j < rowspan; j++) {
|
|
371
|
-
Transforms.setNodes(editor, {
|
|
390
|
+
_slate.Transforms.setNodes(editor, {
|
|
372
391
|
'is_combined': true
|
|
373
392
|
}, {
|
|
374
393
|
at: [...tablePath, i + j, columnIndex + 1]
|
|
@@ -378,8 +397,9 @@ export const handleCombinedCellsAfterInsertTableColumn = (editor, tablePath, tab
|
|
|
378
397
|
}
|
|
379
398
|
}
|
|
380
399
|
};
|
|
381
|
-
|
|
382
|
-
|
|
400
|
+
exports.handleCombinedCellsAfterInsertTableColumn = handleCombinedCellsAfterInsertTableColumn;
|
|
401
|
+
const insertTableElement = function (editor, type) {
|
|
402
|
+
let position = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : _constants2.TABLE_ELEMENT_POSITION.AFTER;
|
|
383
403
|
let count = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : 1;
|
|
384
404
|
const {
|
|
385
405
|
table,
|
|
@@ -388,55 +408,56 @@ export const insertTableElement = function (editor, type) {
|
|
|
388
408
|
rowIndex,
|
|
389
409
|
cellIndex
|
|
390
410
|
} = getSelectedInfo(editor);
|
|
391
|
-
const eventBus =
|
|
392
|
-
eventBus.dispatch(INTERNAL_EVENT.CANCEL_TABLE_SELECT_RANGE);
|
|
393
|
-
if (type === TABLE_ELEMENT.ROW) {
|
|
394
|
-
if (tableSize[0] >= TABLE_MAX_ROWS) return;
|
|
395
|
-
const targetPath = position === TABLE_ELEMENT_POSITION.AFTER ? [...tablePath, rowIndex + 1] : [...tablePath, rowIndex];
|
|
396
|
-
const validCount = Math.min(TABLE_MAX_ROWS - tableSize[0], count);
|
|
411
|
+
const eventBus = _eventBus.default.getInstance();
|
|
412
|
+
eventBus.dispatch(_constants3.INTERNAL_EVENT.CANCEL_TABLE_SELECT_RANGE);
|
|
413
|
+
if (type === _constants2.TABLE_ELEMENT.ROW) {
|
|
414
|
+
if (tableSize[0] >= _constants2.TABLE_MAX_ROWS) return;
|
|
415
|
+
const targetPath = position === _constants2.TABLE_ELEMENT_POSITION.AFTER ? [...tablePath, rowIndex + 1] : [...tablePath, rowIndex];
|
|
416
|
+
const validCount = Math.min(_constants2.TABLE_MAX_ROWS - tableSize[0], count);
|
|
397
417
|
for (let i = 0; i < validCount; i++) {
|
|
398
418
|
const row = generateTableRow(editor, tableSize[1], rowIndex);
|
|
399
|
-
Transforms.insertNodes(editor, row, {
|
|
419
|
+
_slate.Transforms.insertNodes(editor, row, {
|
|
400
420
|
at: targetPath
|
|
401
421
|
});
|
|
402
422
|
// handle combined cells
|
|
403
|
-
if (!(rowIndex === 0 && position === TABLE_ELEMENT_POSITION.BEFORE)) {
|
|
404
|
-
const targetRowIndex = position === TABLE_ELEMENT_POSITION.AFTER ? rowIndex : rowIndex - 1;
|
|
405
|
-
const currentTable = getSelectedNodeByType(editor, ELEMENT_TYPE.TABLE);
|
|
423
|
+
if (!(rowIndex === 0 && position === _constants2.TABLE_ELEMENT_POSITION.BEFORE)) {
|
|
424
|
+
const targetRowIndex = position === _constants2.TABLE_ELEMENT_POSITION.AFTER ? rowIndex : rowIndex - 1;
|
|
425
|
+
const currentTable = (0, _core.getSelectedNodeByType)(editor, _constants.ELEMENT_TYPE.TABLE);
|
|
406
426
|
handleCombinedCellsAfterInsertTableRow(editor, tablePath, currentTable, targetRowIndex);
|
|
407
427
|
}
|
|
408
428
|
}
|
|
409
429
|
const focusPath = [...targetPath, cellIndex];
|
|
410
|
-
focusEditor(editor, focusPath);
|
|
430
|
+
(0, _core.focusEditor)(editor, focusPath);
|
|
411
431
|
return;
|
|
412
432
|
}
|
|
413
|
-
if (type === TABLE_ELEMENT.COLUMN) {
|
|
414
|
-
if (tableSize[1] >= TABLE_MAX_COLUMNS) return;
|
|
415
|
-
const newCellIndex = position === TABLE_ELEMENT_POSITION.AFTER ? cellIndex + 1 : cellIndex;
|
|
416
|
-
const validCount = Math.min(TABLE_MAX_COLUMNS - tableSize[1], count);
|
|
433
|
+
if (type === _constants2.TABLE_ELEMENT.COLUMN) {
|
|
434
|
+
if (tableSize[1] >= _constants2.TABLE_MAX_COLUMNS) return;
|
|
435
|
+
const newCellIndex = position === _constants2.TABLE_ELEMENT_POSITION.AFTER ? cellIndex + 1 : cellIndex;
|
|
436
|
+
const validCount = Math.min(_constants2.TABLE_MAX_COLUMNS - tableSize[1], count);
|
|
417
437
|
const newColumns = getTableColumnsAfterInsertColumn(editor, table, newCellIndex, validCount);
|
|
418
438
|
updateColumnWidth(editor, table, newColumns);
|
|
419
439
|
for (let j = 0; j < validCount; j++) {
|
|
420
440
|
for (let i = 0; i < tableSize[0]; i++) {
|
|
421
441
|
const newCellPath = [...tablePath, i, newCellIndex];
|
|
422
442
|
const newCell = generateTableCell(editor, i, cellIndex);
|
|
423
|
-
Transforms.insertNodes(editor, newCell, {
|
|
443
|
+
_slate.Transforms.insertNodes(editor, newCell, {
|
|
424
444
|
at: newCellPath
|
|
425
445
|
});
|
|
426
446
|
}
|
|
427
447
|
// handle combined cells
|
|
428
|
-
if (!(cellIndex === 0 && position === TABLE_ELEMENT_POSITION.BEFORE)) {
|
|
429
|
-
const targetColumnIndex = position === TABLE_ELEMENT_POSITION.AFTER ? cellIndex : cellIndex - 1;
|
|
430
|
-
const currentTable = getSelectedNodeByType(editor, ELEMENT_TYPE.TABLE);
|
|
448
|
+
if (!(cellIndex === 0 && position === _constants2.TABLE_ELEMENT_POSITION.BEFORE)) {
|
|
449
|
+
const targetColumnIndex = position === _constants2.TABLE_ELEMENT_POSITION.AFTER ? cellIndex : cellIndex - 1;
|
|
450
|
+
const currentTable = (0, _core.getSelectedNodeByType)(editor, _constants.ELEMENT_TYPE.TABLE);
|
|
431
451
|
handleCombinedCellsAfterInsertTableColumn(editor, tablePath, currentTable, targetColumnIndex);
|
|
432
452
|
}
|
|
433
453
|
}
|
|
434
454
|
const focusPath = [...tablePath, rowIndex, cellIndex + 1, 0];
|
|
435
|
-
focusEditor(editor, focusPath);
|
|
455
|
+
(0, _core.focusEditor)(editor, focusPath);
|
|
436
456
|
return;
|
|
437
457
|
}
|
|
438
458
|
};
|
|
439
|
-
|
|
459
|
+
exports.insertTableElement = insertTableElement;
|
|
460
|
+
const combineCells = editor => {
|
|
440
461
|
const {
|
|
441
462
|
tablePath
|
|
442
463
|
} = getSelectedInfo(editor);
|
|
@@ -450,11 +471,11 @@ export const combineCells = editor => {
|
|
|
450
471
|
for (let i = minRowIndex; i < maxRowIndex + 1; i++) {
|
|
451
472
|
for (let j = minColIndex; j < maxColIndex + 1; j++) {
|
|
452
473
|
let nodePath = [...tablePath, i, j];
|
|
453
|
-
let node = Editor.node(editor, nodePath);
|
|
474
|
+
let node = _slate.Editor.node(editor, nodePath);
|
|
454
475
|
if (node[0].is_combined) {
|
|
455
476
|
continue;
|
|
456
477
|
}
|
|
457
|
-
Transforms.setNodes(editor, {
|
|
478
|
+
_slate.Transforms.setNodes(editor, {
|
|
458
479
|
'is_combined': true
|
|
459
480
|
}, {
|
|
460
481
|
at: nodePath
|
|
@@ -468,19 +489,20 @@ export const combineCells = editor => {
|
|
|
468
489
|
newCell.rowspan = maxRowIndex - minRowIndex + 1;
|
|
469
490
|
newCell.colspan = maxColIndex - minColIndex + 1;
|
|
470
491
|
// keep row.children.length not changed
|
|
471
|
-
Transforms.removeNodes(editor, {
|
|
492
|
+
_slate.Transforms.removeNodes(editor, {
|
|
472
493
|
at: targetCellPath
|
|
473
494
|
});
|
|
474
|
-
Transforms.insertNodes(editor, newCell, {
|
|
495
|
+
_slate.Transforms.insertNodes(editor, newCell, {
|
|
475
496
|
at: targetCellPath
|
|
476
497
|
});
|
|
477
|
-
focusEditor(editor, targetCellPath);
|
|
498
|
+
(0, _core.focusEditor)(editor, targetCellPath);
|
|
478
499
|
|
|
479
500
|
// for clicking the 'combine cell' icon in the toolbar
|
|
480
|
-
const eventBus =
|
|
481
|
-
eventBus.dispatch(INTERNAL_EVENT.CANCEL_TABLE_SELECT_RANGE);
|
|
501
|
+
const eventBus = _eventBus.default.getInstance();
|
|
502
|
+
eventBus.dispatch(_constants3.INTERNAL_EVENT.CANCEL_TABLE_SELECT_RANGE);
|
|
482
503
|
};
|
|
483
|
-
|
|
504
|
+
exports.combineCells = combineCells;
|
|
505
|
+
const splitCell = (editor, rowNumber, columnNumber) => {
|
|
484
506
|
if (rowNumber === 1 && columnNumber === 1) {
|
|
485
507
|
return;
|
|
486
508
|
}
|
|
@@ -521,10 +543,10 @@ export const splitCell = (editor, rowNumber, columnNumber) => {
|
|
|
521
543
|
if (i === 0 && j === 0) {
|
|
522
544
|
firstNewCell = newCell;
|
|
523
545
|
} else {
|
|
524
|
-
Transforms.removeNodes(editor, {
|
|
546
|
+
_slate.Transforms.removeNodes(editor, {
|
|
525
547
|
at: targetCellPath
|
|
526
548
|
});
|
|
527
|
-
Transforms.insertNodes(editor, newCell, {
|
|
549
|
+
_slate.Transforms.insertNodes(editor, newCell, {
|
|
528
550
|
at: targetCellPath
|
|
529
551
|
});
|
|
530
552
|
}
|
|
@@ -532,14 +554,15 @@ export const splitCell = (editor, rowNumber, columnNumber) => {
|
|
|
532
554
|
}
|
|
533
555
|
rowspanSum += newRowSpan;
|
|
534
556
|
}
|
|
535
|
-
Transforms.removeNodes(editor, {
|
|
557
|
+
_slate.Transforms.removeNodes(editor, {
|
|
536
558
|
at: cellPath
|
|
537
559
|
});
|
|
538
|
-
Transforms.insertNodes(editor, firstNewCell, {
|
|
560
|
+
_slate.Transforms.insertNodes(editor, firstNewCell, {
|
|
539
561
|
at: cellPath
|
|
540
562
|
});
|
|
541
563
|
};
|
|
542
|
-
|
|
564
|
+
exports.splitCell = splitCell;
|
|
565
|
+
const removeTable = (editor, path) => {
|
|
543
566
|
let validPath = path;
|
|
544
567
|
if (!validPath) {
|
|
545
568
|
const {
|
|
@@ -548,11 +571,12 @@ export const removeTable = (editor, path) => {
|
|
|
548
571
|
validPath = tablePath;
|
|
549
572
|
}
|
|
550
573
|
editor.reSetTableSelectedRange();
|
|
551
|
-
Transforms.removeNodes(editor, {
|
|
574
|
+
_slate.Transforms.removeNodes(editor, {
|
|
552
575
|
at: validPath
|
|
553
576
|
});
|
|
554
577
|
};
|
|
555
|
-
|
|
578
|
+
exports.removeTable = removeTable;
|
|
579
|
+
const removeTableElement = (editor, type) => {
|
|
556
580
|
const {
|
|
557
581
|
table,
|
|
558
582
|
tablePath,
|
|
@@ -561,18 +585,18 @@ export const removeTableElement = (editor, type) => {
|
|
|
561
585
|
rowIndex,
|
|
562
586
|
cellIndex
|
|
563
587
|
} = getSelectedInfo(editor);
|
|
564
|
-
const eventBus =
|
|
565
|
-
eventBus.dispatch(INTERNAL_EVENT.CANCEL_TABLE_SELECT_RANGE);
|
|
566
|
-
if (type === TABLE_ELEMENT.TABLE) {
|
|
588
|
+
const eventBus = _eventBus.default.getInstance();
|
|
589
|
+
eventBus.dispatch(_constants3.INTERNAL_EVENT.CANCEL_TABLE_SELECT_RANGE);
|
|
590
|
+
if (type === _constants2.TABLE_ELEMENT.TABLE) {
|
|
567
591
|
removeTable(editor, tablePath);
|
|
568
592
|
return;
|
|
569
593
|
}
|
|
570
|
-
if (type === TABLE_ELEMENT.ROW) {
|
|
594
|
+
if (type === _constants2.TABLE_ELEMENT.ROW) {
|
|
571
595
|
if (tableSize[0] === 1) {
|
|
572
596
|
removeTable(editor, tablePath);
|
|
573
597
|
return;
|
|
574
598
|
}
|
|
575
|
-
if (!
|
|
599
|
+
if (!_objectUtils.default.isSameObject(editor.tableSelectedRange, _constants2.EMPTY_SELECTED_RANGE)) {
|
|
576
600
|
const {
|
|
577
601
|
minRowIndex,
|
|
578
602
|
maxRowIndex
|
|
@@ -583,30 +607,30 @@ export const removeTableElement = (editor, type) => {
|
|
|
583
607
|
}
|
|
584
608
|
for (let i = minRowIndex; i <= maxRowIndex; i++) {
|
|
585
609
|
queueMicrotask(() => {
|
|
586
|
-
Transforms.removeNodes(editor, {
|
|
610
|
+
_slate.Transforms.removeNodes(editor, {
|
|
587
611
|
at: [...tablePath, minRowIndex]
|
|
588
612
|
});
|
|
589
613
|
});
|
|
590
614
|
}
|
|
591
615
|
const focusPath = [...tablePath, minRowIndex === 0 ? 0 : minRowIndex - 1, cellIndex];
|
|
592
|
-
focusEditor(editor, focusPath);
|
|
616
|
+
(0, _core.focusEditor)(editor, focusPath);
|
|
593
617
|
return;
|
|
594
618
|
}
|
|
595
619
|
handleCombinedCellsBeforeDeleteTableRow(editor, tablePath, table, rowIndex);
|
|
596
|
-
Transforms.removeNodes(editor, {
|
|
620
|
+
_slate.Transforms.removeNodes(editor, {
|
|
597
621
|
at: rowPath
|
|
598
622
|
});
|
|
599
623
|
const focusRowIndex = rowIndex === tableSize[0] - 1 ? rowIndex - 1 : rowIndex;
|
|
600
624
|
const focusPath = [...tablePath, focusRowIndex, cellIndex];
|
|
601
|
-
focusEditor(editor, focusPath);
|
|
625
|
+
(0, _core.focusEditor)(editor, focusPath);
|
|
602
626
|
return;
|
|
603
627
|
}
|
|
604
|
-
if (type === TABLE_ELEMENT.COLUMN) {
|
|
628
|
+
if (type === _constants2.TABLE_ELEMENT.COLUMN) {
|
|
605
629
|
if (tableSize[1] === 1) {
|
|
606
630
|
removeTable(editor, tablePath);
|
|
607
631
|
return;
|
|
608
632
|
}
|
|
609
|
-
if (!
|
|
633
|
+
if (!_objectUtils.default.isSameObject(editor.tableSelectedRange, _constants2.EMPTY_SELECTED_RANGE)) {
|
|
610
634
|
const {
|
|
611
635
|
minColIndex,
|
|
612
636
|
maxColIndex
|
|
@@ -622,13 +646,13 @@ export const removeTableElement = (editor, type) => {
|
|
|
622
646
|
for (let j = minColIndex; j <= maxColIndex; j++) {
|
|
623
647
|
// count
|
|
624
648
|
const cellPath = [...tablePath, i, minColIndex];
|
|
625
|
-
Transforms.removeNodes(editor, {
|
|
649
|
+
_slate.Transforms.removeNodes(editor, {
|
|
626
650
|
at: cellPath
|
|
627
651
|
});
|
|
628
652
|
}
|
|
629
653
|
}
|
|
630
654
|
const focusPath = [...tablePath, rowIndex, minColIndex === 0 ? 0 : minColIndex - 1];
|
|
631
|
-
focusEditor(editor, focusPath);
|
|
655
|
+
(0, _core.focusEditor)(editor, focusPath);
|
|
632
656
|
return;
|
|
633
657
|
}
|
|
634
658
|
const columns = getTableColumns(editor, table);
|
|
@@ -638,19 +662,20 @@ export const removeTableElement = (editor, type) => {
|
|
|
638
662
|
handleCombinedCellsBeforeDeleteTableColumn(editor, tablePath, table, cellIndex);
|
|
639
663
|
for (let i = 0; i < tableSize[0]; i++) {
|
|
640
664
|
const cellPath = [...tablePath, i, cellIndex];
|
|
641
|
-
Transforms.removeNodes(editor, {
|
|
665
|
+
_slate.Transforms.removeNodes(editor, {
|
|
642
666
|
at: cellPath
|
|
643
667
|
});
|
|
644
668
|
}
|
|
645
669
|
const focusCellIndex = cellIndex === tableSize[1] - 1 ? cellIndex - 1 : cellIndex;
|
|
646
670
|
const focusPath = [...tablePath, rowIndex, focusCellIndex];
|
|
647
|
-
focusEditor(editor, focusPath);
|
|
671
|
+
(0, _core.focusEditor)(editor, focusPath);
|
|
648
672
|
return;
|
|
649
673
|
}
|
|
650
674
|
};
|
|
651
675
|
|
|
652
676
|
// handle combined cells before deleting a row
|
|
653
|
-
|
|
677
|
+
exports.removeTableElement = removeTableElement;
|
|
678
|
+
const handleCombinedCellsBeforeDeleteTableRow = (editor, tablePath, table, rowIndex) => {
|
|
654
679
|
const cells = table.children[rowIndex].children;
|
|
655
680
|
for (let i = 0, len = cells.length; i < len; i++) {
|
|
656
681
|
const {
|
|
@@ -665,7 +690,7 @@ export const handleCombinedCellsBeforeDeleteTableRow = (editor, tablePath, table
|
|
|
665
690
|
rowspan: ri_rowspan
|
|
666
691
|
} = table.children[ri].children[i];
|
|
667
692
|
if (!ri_is_combined && ri + ri_rowspan - 1 >= rowIndex) {
|
|
668
|
-
Transforms.setNodes(editor, {
|
|
693
|
+
_slate.Transforms.setNodes(editor, {
|
|
669
694
|
rowspan: ri_rowspan - 1
|
|
670
695
|
}, {
|
|
671
696
|
at: [...tablePath, ri, i]
|
|
@@ -679,10 +704,10 @@ export const handleCombinedCellsBeforeDeleteTableRow = (editor, tablePath, table
|
|
|
679
704
|
const newCell = generateTableCell(editor);
|
|
680
705
|
newCell.rowspan = rowspan - 1;
|
|
681
706
|
newCell.colspan = colspan;
|
|
682
|
-
Transforms.removeNodes(editor, {
|
|
707
|
+
_slate.Transforms.removeNodes(editor, {
|
|
683
708
|
at: targetCellPath
|
|
684
709
|
});
|
|
685
|
-
Transforms.insertNodes(editor, newCell, {
|
|
710
|
+
_slate.Transforms.insertNodes(editor, newCell, {
|
|
686
711
|
at: targetCellPath
|
|
687
712
|
});
|
|
688
713
|
}
|
|
@@ -691,7 +716,8 @@ export const handleCombinedCellsBeforeDeleteTableRow = (editor, tablePath, table
|
|
|
691
716
|
};
|
|
692
717
|
|
|
693
718
|
// handle combined cells before deleting a column
|
|
694
|
-
|
|
719
|
+
exports.handleCombinedCellsBeforeDeleteTableRow = handleCombinedCellsBeforeDeleteTableRow;
|
|
720
|
+
const handleCombinedCellsBeforeDeleteTableColumn = (editor, tablePath, table, columnIndex) => {
|
|
695
721
|
for (let i = 0, len = table.children.length; i < len; i++) {
|
|
696
722
|
const {
|
|
697
723
|
is_combined,
|
|
@@ -705,7 +731,7 @@ export const handleCombinedCellsBeforeDeleteTableColumn = (editor, tablePath, ta
|
|
|
705
731
|
colspan: ci_colspan
|
|
706
732
|
} = table.children[i].children[ci];
|
|
707
733
|
if (!ci_is_combined && ci + ci_colspan - 1 >= columnIndex) {
|
|
708
|
-
Transforms.setNodes(editor, {
|
|
734
|
+
_slate.Transforms.setNodes(editor, {
|
|
709
735
|
colspan: ci_colspan - 1
|
|
710
736
|
}, {
|
|
711
737
|
at: [...tablePath, i, ci]
|
|
@@ -719,53 +745,58 @@ export const handleCombinedCellsBeforeDeleteTableColumn = (editor, tablePath, ta
|
|
|
719
745
|
const newCell = generateTableCell(editor);
|
|
720
746
|
newCell.rowspan = rowspan;
|
|
721
747
|
newCell.colspan = colspan - 1;
|
|
722
|
-
Transforms.removeNodes(editor, {
|
|
748
|
+
_slate.Transforms.removeNodes(editor, {
|
|
723
749
|
at: targetCellPath
|
|
724
750
|
});
|
|
725
|
-
Transforms.insertNodes(editor, newCell, {
|
|
751
|
+
_slate.Transforms.insertNodes(editor, newCell, {
|
|
726
752
|
at: targetCellPath
|
|
727
753
|
});
|
|
728
754
|
}
|
|
729
755
|
}
|
|
730
756
|
}
|
|
731
757
|
};
|
|
732
|
-
|
|
758
|
+
exports.handleCombinedCellsBeforeDeleteTableColumn = handleCombinedCellsBeforeDeleteTableColumn;
|
|
759
|
+
const setTableSelectedRange = (editor, range) => {
|
|
733
760
|
if (range) {
|
|
734
761
|
editor.tableSelectedRange = range;
|
|
735
762
|
return;
|
|
736
763
|
}
|
|
737
|
-
editor.tableSelectedRange = EMPTY_SELECTED_RANGE;
|
|
764
|
+
editor.tableSelectedRange = _constants2.EMPTY_SELECTED_RANGE;
|
|
738
765
|
};
|
|
739
|
-
|
|
740
|
-
|
|
741
|
-
const
|
|
766
|
+
exports.setTableSelectedRange = setTableSelectedRange;
|
|
767
|
+
const updateTableRowHeight = (editor, element, rowHeight) => {
|
|
768
|
+
const path = (0, _core.findPath)(editor, element);
|
|
769
|
+
const targetNode = (0, _core.getNode)(editor, path);
|
|
742
770
|
const {
|
|
743
771
|
style = {}
|
|
744
772
|
} = targetNode;
|
|
745
|
-
if (style[TABLE_ROW_STYLE.MIN_HEIGHT] === rowHeight) return;
|
|
746
|
-
Transforms.setNodes(editor, {
|
|
773
|
+
if (style[_constants2.TABLE_ROW_STYLE.MIN_HEIGHT] === rowHeight) return;
|
|
774
|
+
_slate.Transforms.setNodes(editor, {
|
|
747
775
|
style: {
|
|
748
776
|
...style,
|
|
749
|
-
[TABLE_ROW_STYLE.MIN_HEIGHT]: rowHeight
|
|
777
|
+
[_constants2.TABLE_ROW_STYLE.MIN_HEIGHT]: rowHeight
|
|
750
778
|
}
|
|
751
779
|
}, {
|
|
752
780
|
at: path
|
|
753
781
|
});
|
|
754
782
|
};
|
|
755
|
-
|
|
756
|
-
|
|
757
|
-
|
|
783
|
+
exports.updateTableRowHeight = updateTableRowHeight;
|
|
784
|
+
const updateColumnWidth = (editor, element, columns) => {
|
|
785
|
+
const path = (0, _core.findPath)(editor, element);
|
|
786
|
+
_slate.Transforms.setNodes(editor, {
|
|
758
787
|
columns: columns
|
|
759
788
|
}, {
|
|
760
789
|
at: path
|
|
761
790
|
});
|
|
762
791
|
};
|
|
763
|
-
|
|
792
|
+
exports.updateColumnWidth = updateColumnWidth;
|
|
793
|
+
const getTableColumnsWidth = function () {
|
|
764
794
|
let columns = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : [];
|
|
765
795
|
if (!Array.isArray(columns) || columns.length === 0) return 0;
|
|
766
796
|
return columns.reduce((pre, cur) => pre + cur.width, 0);
|
|
767
797
|
};
|
|
768
|
-
|
|
798
|
+
exports.getTableColumnsWidth = getTableColumnsWidth;
|
|
799
|
+
const getTableColumnsAfterInsertColumn = (editor, element, targetColumnIndex, insertColumnCount) => {
|
|
769
800
|
const columns = getTableColumns(editor, element);
|
|
770
801
|
let newColumns = columns.slice(0);
|
|
771
802
|
let totalColumnsWidth = getTableColumnsWidth(columns);
|
|
@@ -798,17 +829,18 @@ export const getTableColumnsAfterInsertColumn = (editor, element, targetColumnIn
|
|
|
798
829
|
return newColumns.map(column => {
|
|
799
830
|
return {
|
|
800
831
|
...column,
|
|
801
|
-
width: Math.max(parseInt(column.width / proportion), TABLE_CELL_MIN_WIDTH)
|
|
832
|
+
width: Math.max(parseInt(column.width / proportion), _constants2.TABLE_CELL_MIN_WIDTH)
|
|
802
833
|
};
|
|
803
834
|
});
|
|
804
835
|
};
|
|
805
|
-
|
|
836
|
+
exports.getTableColumnsAfterInsertColumn = getTableColumnsAfterInsertColumn;
|
|
837
|
+
const getTableColumns = (editor, element) => {
|
|
806
838
|
if (!element) return [];
|
|
807
839
|
let tableElement = element;
|
|
808
|
-
if (element.type === ELEMENT_TYPE.TABLE_CELL) {
|
|
809
|
-
const cellPath = findPath(editor, element);
|
|
840
|
+
if (element.type === _constants.ELEMENT_TYPE.TABLE_CELL) {
|
|
841
|
+
const cellPath = (0, _core.findPath)(editor, element);
|
|
810
842
|
const tablePath = cellPath.slice(0, -2);
|
|
811
|
-
tableElement = getNode(editor, tablePath);
|
|
843
|
+
tableElement = (0, _core.getNode)(editor, tablePath);
|
|
812
844
|
}
|
|
813
845
|
const {
|
|
814
846
|
columns,
|
|
@@ -817,68 +849,73 @@ export const getTableColumns = (editor, element) => {
|
|
|
817
849
|
if (columns) return columns;
|
|
818
850
|
const columnsCount = children[0].children.length;
|
|
819
851
|
let initColumns = [];
|
|
820
|
-
const pageEditAreaWidth = editor.width || PAGE_EDIT_AREA_WIDTH;
|
|
852
|
+
const pageEditAreaWidth = editor.width || _constants3.PAGE_EDIT_AREA_WIDTH;
|
|
821
853
|
for (let i = 0; i < columnsCount; i++) {
|
|
822
854
|
const column = {
|
|
823
|
-
width: Math.max(TABLE_CELL_MIN_WIDTH, parseInt(pageEditAreaWidth / columnsCount))
|
|
855
|
+
width: Math.max(_constants2.TABLE_CELL_MIN_WIDTH, parseInt(pageEditAreaWidth / columnsCount))
|
|
824
856
|
};
|
|
825
857
|
initColumns.push(column);
|
|
826
858
|
}
|
|
827
859
|
return initColumns;
|
|
828
860
|
};
|
|
829
|
-
|
|
861
|
+
exports.getTableColumns = getTableColumns;
|
|
862
|
+
const getCellColumn = (editor, cellElement) => {
|
|
830
863
|
let column = {
|
|
831
|
-
width: TABLE_CELL_MIN_WIDTH
|
|
864
|
+
width: _constants2.TABLE_CELL_MIN_WIDTH
|
|
832
865
|
};
|
|
833
866
|
if (!editor || !cellElement) return column;
|
|
834
|
-
const cellPath = findPath(editor, cellElement);
|
|
867
|
+
const cellPath = (0, _core.findPath)(editor, cellElement);
|
|
835
868
|
if (!cellPath) return column;
|
|
836
869
|
const pathLength = cellPath.length;
|
|
837
870
|
const cellIndex = cellPath[pathLength - 1];
|
|
838
871
|
const tablePath = cellPath.slice(0, -2);
|
|
839
|
-
const tableElement = getNode(editor, tablePath);
|
|
872
|
+
const tableElement = (0, _core.getNode)(editor, tablePath);
|
|
840
873
|
const {
|
|
841
874
|
columns
|
|
842
875
|
} = tableElement;
|
|
843
876
|
const columnsCount = tableElement.children[0].children.length;
|
|
844
|
-
const pageEditAreaWidth = editor.width || PAGE_EDIT_AREA_WIDTH;
|
|
877
|
+
const pageEditAreaWidth = editor.width || _constants3.PAGE_EDIT_AREA_WIDTH;
|
|
845
878
|
if (columns) {
|
|
846
879
|
column = columns[cellIndex];
|
|
847
880
|
}
|
|
848
881
|
return column || {
|
|
849
|
-
width: Math.max(TABLE_CELL_MIN_WIDTH, parseInt(pageEditAreaWidth / columnsCount))
|
|
882
|
+
width: Math.max(_constants2.TABLE_CELL_MIN_WIDTH, parseInt(pageEditAreaWidth / columnsCount))
|
|
850
883
|
};
|
|
851
884
|
};
|
|
852
|
-
|
|
885
|
+
exports.getCellColumn = getCellColumn;
|
|
886
|
+
const getFirstTableCell = element => {
|
|
853
887
|
let tableCellElement = element;
|
|
854
888
|
while (tableCellElement && !(tableCellElement.hasAttribute('row-index') && tableCellElement.hasAttribute('cell-index'))) {
|
|
855
889
|
tableCellElement = tableCellElement.parentNode;
|
|
856
890
|
}
|
|
857
891
|
return tableCellElement;
|
|
858
892
|
};
|
|
859
|
-
|
|
893
|
+
exports.getFirstTableCell = getFirstTableCell;
|
|
894
|
+
const elementHasImage = element => {
|
|
860
895
|
if (!element) return false;
|
|
861
896
|
if (!Array.isArray(element.children) || element.children.length === 0) return false;
|
|
862
897
|
return element.children.some(child => {
|
|
863
|
-
if (child.type === ELEMENT_TYPE.IMAGE) return true;
|
|
864
|
-
if (
|
|
898
|
+
if (child.type === _constants.ELEMENT_TYPE.IMAGE) return true;
|
|
899
|
+
if (_objectUtils.default.hasProperty(child, 'children')) {
|
|
865
900
|
return elementHasImage(child);
|
|
866
901
|
}
|
|
867
902
|
return false;
|
|
868
903
|
});
|
|
869
904
|
};
|
|
870
|
-
|
|
905
|
+
exports.elementHasImage = elementHasImage;
|
|
906
|
+
const isSelectedAllCell = editor => {
|
|
871
907
|
const {
|
|
872
908
|
tableSize
|
|
873
909
|
} = getSelectedInfo(editor);
|
|
874
|
-
return
|
|
910
|
+
return _objectUtils.default.isSameObject(editor.tableSelectedRange, {
|
|
875
911
|
minColIndex: 0,
|
|
876
912
|
maxColIndex: tableSize[1] - 1,
|
|
877
913
|
minRowIndex: 0,
|
|
878
914
|
maxRowIndex: tableSize[0] - 1
|
|
879
915
|
});
|
|
880
916
|
};
|
|
881
|
-
|
|
917
|
+
exports.isSelectedAllCell = isSelectedAllCell;
|
|
918
|
+
const insertMultipleRowsAndColumns = (editor, rows, columns) => {
|
|
882
919
|
const {
|
|
883
920
|
table,
|
|
884
921
|
tablePath,
|
|
@@ -886,13 +923,13 @@ export const insertMultipleRowsAndColumns = (editor, rows, columns) => {
|
|
|
886
923
|
rowIndex,
|
|
887
924
|
cellIndex
|
|
888
925
|
} = getSelectedInfo(editor);
|
|
889
|
-
let newTable =
|
|
890
|
-
const eventBus =
|
|
891
|
-
eventBus.dispatch(INTERNAL_EVENT.CANCEL_TABLE_SELECT_RANGE);
|
|
926
|
+
let newTable = (0, _deepCopy.default)(table);
|
|
927
|
+
const eventBus = _eventBus.default.getInstance();
|
|
928
|
+
eventBus.dispatch(_constants3.INTERNAL_EVENT.CANCEL_TABLE_SELECT_RANGE);
|
|
892
929
|
const insertRows = rows.slice(tableSize[0] - rowIndex);
|
|
893
930
|
const insertColumns = columns.slice(tableSize[1] - cellIndex);
|
|
894
|
-
const validInsertRows = insertRows.slice(0, Math.min(TABLE_MAX_ROWS - tableSize[0], insertRows.length));
|
|
895
|
-
const validInsertColumns = insertColumns.slice(0, Math.min(TABLE_MAX_COLUMNS - tableSize[1], columns.length));
|
|
931
|
+
const validInsertRows = insertRows.slice(0, Math.min(_constants2.TABLE_MAX_ROWS - tableSize[0], insertRows.length));
|
|
932
|
+
const validInsertColumns = insertColumns.slice(0, Math.min(_constants2.TABLE_MAX_COLUMNS - tableSize[1], columns.length));
|
|
896
933
|
for (let i = 0; i < validInsertRows.length; i++) {
|
|
897
934
|
const insertRow = validInsertRows[i];
|
|
898
935
|
const row = generateTableRow(editor, tableSize[1], rowIndex);
|
|
@@ -908,35 +945,36 @@ export const insertMultipleRowsAndColumns = (editor, rows, columns) => {
|
|
|
908
945
|
newTable.children[i].children.push(newCell);
|
|
909
946
|
}
|
|
910
947
|
}
|
|
911
|
-
for (let i = rowIndex; i < Math.min(TABLE_MAX_ROWS, rowIndex + rows.length); i++) {
|
|
948
|
+
for (let i = rowIndex; i < Math.min(_constants2.TABLE_MAX_ROWS, rowIndex + rows.length); i++) {
|
|
912
949
|
const row = rows[i - rowIndex];
|
|
913
950
|
const cells = row.children;
|
|
914
|
-
for (let j = cellIndex; j < Math.min(TABLE_MAX_COLUMNS, cellIndex + columns.length); j++) {
|
|
951
|
+
for (let j = cellIndex; j < Math.min(_constants2.TABLE_MAX_COLUMNS, cellIndex + columns.length); j++) {
|
|
915
952
|
const replaceCellIndex = j - cellIndex;
|
|
916
953
|
const replaceCell = cells[replaceCellIndex];
|
|
917
|
-
newTable.children[i].children[j].children = replacePastedDataId(replaceCell.children);
|
|
954
|
+
newTable.children[i].children[j].children = (0, _helpers.replacePastedDataId)(replaceCell.children);
|
|
918
955
|
}
|
|
919
956
|
}
|
|
920
|
-
replaceNode(editor, {
|
|
957
|
+
(0, _core.replaceNode)(editor, {
|
|
921
958
|
at: tablePath,
|
|
922
959
|
nodes: newTable
|
|
923
960
|
});
|
|
924
|
-
focusEditor(editor, [...tablePath, rowIndex, cellIndex, 0]);
|
|
961
|
+
(0, _core.focusEditor)(editor, [...tablePath, rowIndex, cellIndex, 0]);
|
|
925
962
|
const {
|
|
926
963
|
focus: newFocus
|
|
927
964
|
} = editor.selection;
|
|
928
|
-
Transforms.select(editor, {
|
|
965
|
+
_slate.Transforms.select(editor, {
|
|
929
966
|
focus: newFocus,
|
|
930
967
|
anchor: newFocus
|
|
931
968
|
});
|
|
932
969
|
return;
|
|
933
970
|
};
|
|
934
|
-
|
|
935
|
-
|
|
971
|
+
exports.insertMultipleRowsAndColumns = insertMultipleRowsAndColumns;
|
|
972
|
+
const setTableFragmentData = (editor, dataTransfer) => {
|
|
973
|
+
const selectedNode = (0, _core.getSelectedNodeByType)(editor, _constants.ELEMENT_TYPE.TABLE);
|
|
936
974
|
const fragment = editor.getFragment();
|
|
937
975
|
const string = JSON.stringify(fragment);
|
|
938
976
|
const encoded = window.btoa(encodeURIComponent(string));
|
|
939
|
-
dataTransfer.setData(
|
|
977
|
+
dataTransfer.setData(`application/${_constants.CLIPBOARD_FORMAT_KEY}`, encoded);
|
|
940
978
|
const tableDom = document.createElement('table');
|
|
941
979
|
const {
|
|
942
980
|
minColIndex,
|
|
@@ -944,15 +982,15 @@ export const setTableFragmentData = (editor, dataTransfer) => {
|
|
|
944
982
|
minRowIndex,
|
|
945
983
|
maxRowIndex
|
|
946
984
|
} = editor.tableSelectedRange;
|
|
947
|
-
const tablePath = findPath(editor, selectedNode);
|
|
985
|
+
const tablePath = (0, _core.findPath)(editor, selectedNode);
|
|
948
986
|
for (let i = minRowIndex; i <= maxRowIndex; i++) {
|
|
949
987
|
const tr = document.createElement('tr');
|
|
950
988
|
for (let j = minColIndex; j <= maxColIndex; j++) {
|
|
951
989
|
const path = [...tablePath, i, j];
|
|
952
|
-
const node = getNode(editor, path);
|
|
990
|
+
const node = (0, _core.getNode)(editor, path);
|
|
953
991
|
const td = document.createElement('td');
|
|
954
992
|
const div = document.createElement('div');
|
|
955
|
-
div.innerHTML = ReactEditor.toDOMNode(editor, node).innerHTML;
|
|
993
|
+
div.innerHTML = _slateReact.ReactEditor.toDOMNode(editor, node).innerHTML;
|
|
956
994
|
td.appendChild(div);
|
|
957
995
|
tr.appendChild(td);
|
|
958
996
|
}
|
|
@@ -965,7 +1003,8 @@ export const setTableFragmentData = (editor, dataTransfer) => {
|
|
|
965
1003
|
dataTransfer.setData('text/plain', div.innerText);
|
|
966
1004
|
return dataTransfer;
|
|
967
1005
|
};
|
|
968
|
-
|
|
1006
|
+
exports.setTableFragmentData = setTableFragmentData;
|
|
1007
|
+
const deleteTableRangeData = editor => {
|
|
969
1008
|
const {
|
|
970
1009
|
tableSelectedRange
|
|
971
1010
|
} = editor;
|
|
@@ -982,12 +1021,12 @@ export const deleteTableRangeData = editor => {
|
|
|
982
1021
|
for (let i = minRowIndex; i <= maxRowIndex; i++) {
|
|
983
1022
|
for (let j = minColIndex; j <= maxColIndex; j++) {
|
|
984
1023
|
const path = [...tablePath, i, j];
|
|
985
|
-
const node = getNode(editor, path);
|
|
986
|
-
if (!forceCellPath && (Node.string(node) || elementHasImage(node))) {
|
|
1024
|
+
const node = (0, _core.getNode)(editor, path);
|
|
1025
|
+
if (!forceCellPath && (_slate.Node.string(node) || elementHasImage(node))) {
|
|
987
1026
|
forceCellPath = path;
|
|
988
1027
|
}
|
|
989
1028
|
const firstNode = node.children[0];
|
|
990
|
-
replaceNodeChildren(editor, {
|
|
1029
|
+
(0, _core.replaceNodeChildren)(editor, {
|
|
991
1030
|
at: path,
|
|
992
1031
|
nodes: {
|
|
993
1032
|
...firstNode,
|
|
@@ -997,58 +1036,60 @@ export const deleteTableRangeData = editor => {
|
|
|
997
1036
|
}
|
|
998
1037
|
}
|
|
999
1038
|
if (forceCellPath) {
|
|
1000
|
-
editor.tableSelectedRange = EMPTY_SELECTED_RANGE;
|
|
1001
|
-
const eventBus =
|
|
1002
|
-
eventBus.dispatch(INTERNAL_EVENT.CANCEL_TABLE_SELECT_RANGE);
|
|
1003
|
-
focusEditor(editor, forceCellPath);
|
|
1039
|
+
editor.tableSelectedRange = _constants2.EMPTY_SELECTED_RANGE;
|
|
1040
|
+
const eventBus = _eventBus.default.getInstance();
|
|
1041
|
+
eventBus.dispatch(_constants3.INTERNAL_EVENT.CANCEL_TABLE_SELECT_RANGE);
|
|
1042
|
+
(0, _core.focusEditor)(editor, forceCellPath);
|
|
1004
1043
|
const {
|
|
1005
1044
|
focus: newFocus
|
|
1006
1045
|
} = editor.selection;
|
|
1007
|
-
Transforms.select(editor, {
|
|
1046
|
+
_slate.Transforms.select(editor, {
|
|
1008
1047
|
focus: newFocus,
|
|
1009
1048
|
anchor: newFocus
|
|
1010
1049
|
});
|
|
1011
1050
|
}
|
|
1012
1051
|
};
|
|
1013
|
-
|
|
1052
|
+
exports.deleteTableRangeData = deleteTableRangeData;
|
|
1053
|
+
const deleteHandler = editor => {
|
|
1014
1054
|
const {
|
|
1015
1055
|
selection,
|
|
1016
1056
|
tableSelectedRange
|
|
1017
1057
|
} = editor;
|
|
1018
1058
|
if (selection == null) return '';
|
|
1019
|
-
if (!
|
|
1059
|
+
if (!_objectUtils.default.isSameObject(tableSelectedRange, _constants2.EMPTY_SELECTED_RANGE)) {
|
|
1020
1060
|
if (isSelectedAllCell(editor)) return 'table';
|
|
1021
1061
|
return 'range';
|
|
1022
1062
|
}
|
|
1023
|
-
const [cellNodeEntry] = Editor.nodes(editor, {
|
|
1063
|
+
const [cellNodeEntry] = _slate.Editor.nodes(editor, {
|
|
1024
1064
|
match: n => {
|
|
1025
|
-
let type = getNodeType(n);
|
|
1026
|
-
if (!type && isTextNode(n) && n.id) {
|
|
1027
|
-
const parentNode = getParentNode(editor.children, n.id);
|
|
1028
|
-
type = getNodeType(parentNode);
|
|
1065
|
+
let type = (0, _core.getNodeType)(n);
|
|
1066
|
+
if (!type && (0, _core.isTextNode)(n) && n.id) {
|
|
1067
|
+
const parentNode = (0, _core.getParentNode)(editor.children, n.id);
|
|
1068
|
+
type = (0, _core.getNodeType)(parentNode);
|
|
1029
1069
|
}
|
|
1030
|
-
return type === ELEMENT_TYPE.TABLE_CELL;
|
|
1070
|
+
return type === _constants.ELEMENT_TYPE.TABLE_CELL;
|
|
1031
1071
|
}
|
|
1032
1072
|
});
|
|
1033
1073
|
if (cellNodeEntry) {
|
|
1034
1074
|
const [, cellPath] = cellNodeEntry;
|
|
1035
|
-
const start = Editor.start(editor, cellPath);
|
|
1036
|
-
if (Point.equals(selection.anchor, start)) {
|
|
1075
|
+
const start = _slate.Editor.start(editor, cellPath);
|
|
1076
|
+
if (_slate.Point.equals(selection.anchor, start)) {
|
|
1037
1077
|
return 'default';
|
|
1038
1078
|
}
|
|
1039
1079
|
}
|
|
1040
1080
|
return '';
|
|
1041
1081
|
};
|
|
1042
|
-
|
|
1043
|
-
|
|
1082
|
+
exports.deleteHandler = deleteHandler;
|
|
1083
|
+
const isTableLocation = (editor, location) => {
|
|
1084
|
+
const tables = _slate.Editor.nodes(editor, {
|
|
1044
1085
|
at: location,
|
|
1045
1086
|
match: n => {
|
|
1046
|
-
let type = getNodeType(n);
|
|
1047
|
-
if (!type && isTextNode(n) && n.id) {
|
|
1048
|
-
const parentNode = getParentNode(editor.children, n.id);
|
|
1049
|
-
type = getNodeType(parentNode);
|
|
1087
|
+
let type = (0, _core.getNodeType)(n);
|
|
1088
|
+
if (!type && (0, _core.isTextNode)(n) && n.id) {
|
|
1089
|
+
const parentNode = (0, _core.getParentNode)(editor.children, n.id);
|
|
1090
|
+
type = (0, _core.getNodeType)(parentNode);
|
|
1050
1091
|
}
|
|
1051
|
-
return type === ELEMENT_TYPE.TABLE_CELL;
|
|
1092
|
+
return type === _constants.ELEMENT_TYPE.TABLE_CELL;
|
|
1052
1093
|
}
|
|
1053
1094
|
});
|
|
1054
1095
|
let hasTable = false;
|
|
@@ -1058,7 +1099,8 @@ export const isTableLocation = (editor, location) => {
|
|
|
1058
1099
|
}
|
|
1059
1100
|
return hasTable;
|
|
1060
1101
|
};
|
|
1061
|
-
|
|
1102
|
+
exports.isTableLocation = isTableLocation;
|
|
1103
|
+
const isCursorAtCellEnd = function (cell) {
|
|
1062
1104
|
let cursor = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 0;
|
|
1063
1105
|
if (!cell) return false;
|
|
1064
1106
|
const childrenCount = cell.children.length;
|
|
@@ -1066,11 +1108,13 @@ export const isCursorAtCellEnd = function (cell) {
|
|
|
1066
1108
|
const textCount = lastChildren.text.length;
|
|
1067
1109
|
return cursor === textCount;
|
|
1068
1110
|
};
|
|
1069
|
-
|
|
1111
|
+
exports.isCursorAtCellEnd = isCursorAtCellEnd;
|
|
1112
|
+
const isCursorAtCellStart = function () {
|
|
1070
1113
|
let cursor = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 0;
|
|
1071
1114
|
return cursor === 0;
|
|
1072
1115
|
};
|
|
1073
|
-
|
|
1116
|
+
exports.isCursorAtCellStart = isCursorAtCellStart;
|
|
1117
|
+
const focusCell = function (editor, event) {
|
|
1074
1118
|
let keyboardName = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : '';
|
|
1075
1119
|
const {
|
|
1076
1120
|
tableSize,
|
|
@@ -1087,25 +1131,25 @@ export const focusCell = function (editor, event) {
|
|
|
1087
1131
|
const {
|
|
1088
1132
|
focus
|
|
1089
1133
|
} = selection;
|
|
1090
|
-
if (keyboardName === KEYBOARD.UP) {
|
|
1134
|
+
if (keyboardName === _constants.KEYBOARD.UP) {
|
|
1091
1135
|
if (!isCursorAtCellStart(focus.offset)) {
|
|
1092
1136
|
setTimeout(() => {
|
|
1093
|
-
if (getSelectedNodeByType(editor, ELEMENT_TYPE.TABLE)) {
|
|
1137
|
+
if ((0, _core.getSelectedNodeByType)(editor, _constants.ELEMENT_TYPE.TABLE)) {
|
|
1094
1138
|
const {
|
|
1095
1139
|
cellIndex: newCellIndex
|
|
1096
1140
|
} = getSelectedInfo(editor);
|
|
1097
1141
|
if (Math.abs(newCellIndex - cellIndex) !== 0) {
|
|
1098
1142
|
if (rowIndex === 0) {
|
|
1099
1143
|
if (tableIndex !== 0) {
|
|
1100
|
-
focusEditor(editor, [...tableParentPath, tableIndex - 1]);
|
|
1144
|
+
(0, _core.focusEditor)(editor, [...tableParentPath, tableIndex - 1]);
|
|
1101
1145
|
}
|
|
1102
1146
|
return;
|
|
1103
1147
|
}
|
|
1104
|
-
focusEditor(editor, [...tableParentPath, tableIndex, rowIndex - 1, cellIndex]);
|
|
1148
|
+
(0, _core.focusEditor)(editor, [...tableParentPath, tableIndex, rowIndex - 1, cellIndex]);
|
|
1105
1149
|
const {
|
|
1106
1150
|
focus: newFocus
|
|
1107
1151
|
} = editor.selection;
|
|
1108
|
-
Transforms.select(editor, {
|
|
1152
|
+
_slate.Transforms.select(editor, {
|
|
1109
1153
|
focus: newFocus,
|
|
1110
1154
|
anchor: newFocus
|
|
1111
1155
|
});
|
|
@@ -1117,58 +1161,58 @@ export const focusCell = function (editor, event) {
|
|
|
1117
1161
|
event.preventDefault();
|
|
1118
1162
|
if (rowIndex === 0) {
|
|
1119
1163
|
if (tableIndex !== 0) {
|
|
1120
|
-
focusEditor(editor, [...tableParentPath, tableIndex - 1]);
|
|
1164
|
+
(0, _core.focusEditor)(editor, [...tableParentPath, tableIndex - 1]);
|
|
1121
1165
|
}
|
|
1122
1166
|
return;
|
|
1123
1167
|
}
|
|
1124
|
-
focusEditor(editor, [...tableParentPath, tableIndex, rowIndex - 1, cellIndex]);
|
|
1168
|
+
(0, _core.focusEditor)(editor, [...tableParentPath, tableIndex, rowIndex - 1, cellIndex]);
|
|
1125
1169
|
const {
|
|
1126
1170
|
focus: newFocus
|
|
1127
1171
|
} = editor.selection;
|
|
1128
|
-
Transforms.select(editor, {
|
|
1172
|
+
_slate.Transforms.select(editor, {
|
|
1129
1173
|
focus: newFocus,
|
|
1130
1174
|
anchor: newFocus
|
|
1131
1175
|
});
|
|
1132
1176
|
}
|
|
1133
|
-
if (keyboardName === KEYBOARD.RIGHT) {
|
|
1177
|
+
if (keyboardName === _constants.KEYBOARD.RIGHT) {
|
|
1134
1178
|
if (!isCursorAtCellEnd(cell, focus.offset)) return;
|
|
1135
1179
|
event.preventDefault();
|
|
1136
1180
|
if (rowIndex === tableSize[0] - 1 && cellIndex === tableSize[1] - 1) {
|
|
1137
|
-
focusEditor(editor, [...tableParentPath, tableIndex + 1]);
|
|
1181
|
+
(0, _core.focusEditor)(editor, [...tableParentPath, tableIndex + 1]);
|
|
1138
1182
|
return;
|
|
1139
1183
|
}
|
|
1140
1184
|
if (cellIndex === tableSize[1] - 1) {
|
|
1141
|
-
focusEditor(editor, [...tableParentPath, tableIndex, rowIndex + 1, 0]);
|
|
1185
|
+
(0, _core.focusEditor)(editor, [...tableParentPath, tableIndex, rowIndex + 1, 0]);
|
|
1142
1186
|
} else {
|
|
1143
|
-
focusEditor(editor, [...tableParentPath, tableIndex, rowIndex, cellIndex + 1]);
|
|
1187
|
+
(0, _core.focusEditor)(editor, [...tableParentPath, tableIndex, rowIndex, cellIndex + 1]);
|
|
1144
1188
|
}
|
|
1145
1189
|
const {
|
|
1146
1190
|
anchor: newAnchor
|
|
1147
1191
|
} = editor.selection;
|
|
1148
|
-
Transforms.select(editor, {
|
|
1192
|
+
_slate.Transforms.select(editor, {
|
|
1149
1193
|
focus: newAnchor,
|
|
1150
1194
|
anchor: newAnchor
|
|
1151
1195
|
});
|
|
1152
1196
|
}
|
|
1153
|
-
if (keyboardName === KEYBOARD.DOWN) {
|
|
1197
|
+
if (keyboardName === _constants.KEYBOARD.DOWN) {
|
|
1154
1198
|
if (!isCursorAtCellEnd(cell, focus.offset)) {
|
|
1155
1199
|
setTimeout(() => {
|
|
1156
|
-
if (getSelectedNodeByType(editor, ELEMENT_TYPE.TABLE)) {
|
|
1200
|
+
if ((0, _core.getSelectedNodeByType)(editor, _constants.ELEMENT_TYPE.TABLE)) {
|
|
1157
1201
|
const {
|
|
1158
1202
|
cellIndex: newCellIndex
|
|
1159
1203
|
} = getSelectedInfo(editor);
|
|
1160
1204
|
if (Math.abs(newCellIndex - cellIndex) !== 0) {
|
|
1161
1205
|
if (rowIndex === tableSize[0] - 1) {
|
|
1162
|
-
const nextNode = getNode(editor, [...tableParentPath, tableIndex + 1]);
|
|
1206
|
+
const nextNode = (0, _core.getNode)(editor, [...tableParentPath, tableIndex + 1]);
|
|
1163
1207
|
if (!nextNode) return;
|
|
1164
|
-
focusEditor(editor, [...tableParentPath, tableIndex + 1]);
|
|
1208
|
+
(0, _core.focusEditor)(editor, [...tableParentPath, tableIndex + 1]);
|
|
1165
1209
|
return;
|
|
1166
1210
|
}
|
|
1167
|
-
focusEditor(editor, [...tableParentPath, tableIndex, rowIndex + 1, cellIndex]);
|
|
1211
|
+
(0, _core.focusEditor)(editor, [...tableParentPath, tableIndex, rowIndex + 1, cellIndex]);
|
|
1168
1212
|
const {
|
|
1169
1213
|
anchor: newAnchor
|
|
1170
1214
|
} = editor.selection;
|
|
1171
|
-
Transforms.select(editor, {
|
|
1215
|
+
_slate.Transforms.select(editor, {
|
|
1172
1216
|
focus: newAnchor,
|
|
1173
1217
|
anchor: newAnchor
|
|
1174
1218
|
});
|
|
@@ -1179,45 +1223,46 @@ export const focusCell = function (editor, event) {
|
|
|
1179
1223
|
}
|
|
1180
1224
|
event.preventDefault();
|
|
1181
1225
|
if (rowIndex === tableSize[0] - 1) {
|
|
1182
|
-
const nextNode = getNode([...tableParentPath, tableIndex + 1]);
|
|
1226
|
+
const nextNode = (0, _core.getNode)([...tableParentPath, tableIndex + 1]);
|
|
1183
1227
|
if (!nextNode) return;
|
|
1184
|
-
focusEditor(editor, [...tableParentPath, tableIndex + 1]);
|
|
1228
|
+
(0, _core.focusEditor)(editor, [...tableParentPath, tableIndex + 1]);
|
|
1185
1229
|
return;
|
|
1186
1230
|
}
|
|
1187
|
-
focusEditor(editor, [...tableParentPath, tableIndex, rowIndex + 1, cellIndex]);
|
|
1231
|
+
(0, _core.focusEditor)(editor, [...tableParentPath, tableIndex, rowIndex + 1, cellIndex]);
|
|
1188
1232
|
const {
|
|
1189
1233
|
anchor: newAnchor
|
|
1190
1234
|
} = editor.selection;
|
|
1191
|
-
Transforms.select(editor, {
|
|
1235
|
+
_slate.Transforms.select(editor, {
|
|
1192
1236
|
focus: newAnchor,
|
|
1193
1237
|
anchor: newAnchor
|
|
1194
1238
|
});
|
|
1195
1239
|
}
|
|
1196
|
-
if (keyboardName === KEYBOARD.LEFT) {
|
|
1240
|
+
if (keyboardName === _constants.KEYBOARD.LEFT) {
|
|
1197
1241
|
if (!isCursorAtCellStart(focus.offset)) return;
|
|
1198
1242
|
event.preventDefault();
|
|
1199
1243
|
if (rowIndex === 0 && cellIndex === 0) {
|
|
1200
1244
|
if (tableIndex !== 0) {
|
|
1201
|
-
focusEditor(editor, [...tableParentPath, tableIndex - 1]);
|
|
1245
|
+
(0, _core.focusEditor)(editor, [...tableParentPath, tableIndex - 1]);
|
|
1202
1246
|
}
|
|
1203
1247
|
return;
|
|
1204
1248
|
}
|
|
1205
1249
|
if (cellIndex === 0) {
|
|
1206
|
-
focusEditor(editor, [...tableParentPath, tableIndex, rowIndex - 1, tableSize[1] - 1]);
|
|
1250
|
+
(0, _core.focusEditor)(editor, [...tableParentPath, tableIndex, rowIndex - 1, tableSize[1] - 1]);
|
|
1207
1251
|
} else {
|
|
1208
|
-
focusEditor(editor, [...tableParentPath, tableIndex, rowIndex, cellIndex - 1]);
|
|
1252
|
+
(0, _core.focusEditor)(editor, [...tableParentPath, tableIndex, rowIndex, cellIndex - 1]);
|
|
1209
1253
|
}
|
|
1210
1254
|
const {
|
|
1211
1255
|
focus: newFocus
|
|
1212
1256
|
} = editor.selection;
|
|
1213
|
-
Transforms.select(editor, {
|
|
1257
|
+
_slate.Transforms.select(editor, {
|
|
1214
1258
|
focus: newFocus,
|
|
1215
1259
|
anchor: newFocus
|
|
1216
1260
|
});
|
|
1217
1261
|
}
|
|
1218
1262
|
};
|
|
1219
|
-
|
|
1220
|
-
|
|
1263
|
+
exports.focusCell = focusCell;
|
|
1264
|
+
const isLastTableCell = (editor, cellNode) => {
|
|
1265
|
+
if (cellNode[0].type !== _constants.ELEMENT_TYPE.TABLE_CELL) return false;
|
|
1221
1266
|
const {
|
|
1222
1267
|
tableSize
|
|
1223
1268
|
} = getSelectedInfo(editor);
|
|
@@ -1227,12 +1272,13 @@ export const isLastTableCell = (editor, cellNode) => {
|
|
|
1227
1272
|
const cellNodePathDeep = cellNodePath.length;
|
|
1228
1273
|
return cellNodePath[cellNodePathDeep - 1] === lastColumnIndex && cellNodePath[cellNodePathDeep - 2] === lastRowIndex;
|
|
1229
1274
|
};
|
|
1275
|
+
exports.isLastTableCell = isLastTableCell;
|
|
1230
1276
|
const getValidColor = color => {
|
|
1231
1277
|
if (!color) return '';
|
|
1232
1278
|
const validColor = color.length === 4 ? '#' + color.slice(1, 4).repeat(2) : color;
|
|
1233
1279
|
return validColor.toUpperCase();
|
|
1234
1280
|
};
|
|
1235
|
-
|
|
1281
|
+
const colorBlend = (c1, c2, ratio) => {
|
|
1236
1282
|
const color1 = getValidColor(c1);
|
|
1237
1283
|
const color2 = getValidColor(c2);
|
|
1238
1284
|
if (!color1 && !color2) return 'unset';
|
|
@@ -1255,14 +1301,16 @@ export const colorBlend = (c1, c2, ratio) => {
|
|
|
1255
1301
|
b = ('0' + (b || 0).toString(16)).slice(-2);
|
|
1256
1302
|
return '#' + r + g + b;
|
|
1257
1303
|
};
|
|
1258
|
-
|
|
1304
|
+
exports.colorBlend = colorBlend;
|
|
1305
|
+
const getRowHeight = (element, rowIndex) => {
|
|
1259
1306
|
const {
|
|
1260
1307
|
style = {}
|
|
1261
1308
|
} = element;
|
|
1262
|
-
const rowHeight = style[TABLE_ROW_STYLE.MIN_HEIGHT] || TABLE_ROW_MIN_HEIGHT;
|
|
1309
|
+
const rowHeight = style[_constants2.TABLE_ROW_STYLE.MIN_HEIGHT] || _constants2.TABLE_ROW_MIN_HEIGHT;
|
|
1263
1310
|
return rowIndex === 0 ? rowHeight + 1 : rowHeight;
|
|
1264
1311
|
};
|
|
1265
|
-
|
|
1312
|
+
exports.getRowHeight = getRowHeight;
|
|
1313
|
+
const getRowDomHeight = (editor, row) => {
|
|
1266
1314
|
let height = 0;
|
|
1267
1315
|
for (const cell of row.children) {
|
|
1268
1316
|
const {
|
|
@@ -1272,7 +1320,7 @@ export const getRowDomHeight = (editor, row) => {
|
|
|
1272
1320
|
if (is_combined || rowspan > 1) continue;
|
|
1273
1321
|
let cellDom = null;
|
|
1274
1322
|
try {
|
|
1275
|
-
cellDom = ReactEditor.toDOMNode(editor, cell);
|
|
1323
|
+
cellDom = _slateReact.ReactEditor.toDOMNode(editor, cell);
|
|
1276
1324
|
} catch (error) {
|
|
1277
1325
|
if (!cellDom) break;
|
|
1278
1326
|
}
|
|
@@ -1281,16 +1329,17 @@ export const getRowDomHeight = (editor, row) => {
|
|
|
1281
1329
|
}
|
|
1282
1330
|
// if the row is empty, get the height from style
|
|
1283
1331
|
if (!height) {
|
|
1284
|
-
height = row.style[TABLE_ROW_STYLE.MIN_HEIGHT] || TABLE_ROW_MIN_HEIGHT;
|
|
1332
|
+
height = row.style[_constants2.TABLE_ROW_STYLE.MIN_HEIGHT] || _constants2.TABLE_ROW_MIN_HEIGHT;
|
|
1285
1333
|
}
|
|
1286
1334
|
return height;
|
|
1287
1335
|
};
|
|
1336
|
+
exports.getRowDomHeight = getRowDomHeight;
|
|
1288
1337
|
const normalizeTableCell = (editor, cell) => {
|
|
1289
1338
|
if (!cell) return generateTableCell(editor);
|
|
1290
1339
|
let newCell = {
|
|
1291
1340
|
children: [{
|
|
1292
1341
|
text: '',
|
|
1293
|
-
id:
|
|
1342
|
+
id: _slugid.default.nice()
|
|
1294
1343
|
}],
|
|
1295
1344
|
...cell
|
|
1296
1345
|
};
|
|
@@ -1299,7 +1348,7 @@ const normalizeTableCell = (editor, cell) => {
|
|
|
1299
1348
|
let newCellChildren = [];
|
|
1300
1349
|
newCell.children.forEach(cellChild => {
|
|
1301
1350
|
const cellChildType = cellChild.type;
|
|
1302
|
-
if (cellChildType === ELEMENT_TYPE.PARAGRAPH) {
|
|
1351
|
+
if (cellChildType === _constants.ELEMENT_TYPE.PARAGRAPH) {
|
|
1303
1352
|
newCellChildren.push(...cellChild.children);
|
|
1304
1353
|
} else {
|
|
1305
1354
|
newCellChildren.push(cellChild);
|
|
@@ -1333,8 +1382,8 @@ const normalizeTableCell = (editor, cell) => {
|
|
|
1333
1382
|
}
|
|
1334
1383
|
return newCell;
|
|
1335
1384
|
};
|
|
1336
|
-
|
|
1337
|
-
if (element.type !== ELEMENT_TYPE.TABLE) {
|
|
1385
|
+
const normalizeTableELement = (editor, element) => {
|
|
1386
|
+
if (element.type !== _constants.ELEMENT_TYPE.TABLE) {
|
|
1338
1387
|
const size = [element.children.length, element.children[0].children.length];
|
|
1339
1388
|
return generateEmptyTable(editor, {
|
|
1340
1389
|
size
|
|
@@ -1352,14 +1401,15 @@ export const normalizeTableELement = (editor, element) => {
|
|
|
1352
1401
|
}
|
|
1353
1402
|
return newElement;
|
|
1354
1403
|
};
|
|
1355
|
-
|
|
1404
|
+
exports.normalizeTableELement = normalizeTableELement;
|
|
1405
|
+
const insertTableByTemplate = (editor, alternateColor) => {
|
|
1356
1406
|
const size = [4, 4];
|
|
1357
1407
|
const tableNode = generateEmptyTable(editor, {
|
|
1358
1408
|
size,
|
|
1359
1409
|
alternate_highlight_color: alternateColor,
|
|
1360
1410
|
alternate_highlight: true
|
|
1361
1411
|
});
|
|
1362
|
-
const path = Editor.path(editor, editor.selection);
|
|
1412
|
+
const path = _slate.Editor.path(editor, editor.selection);
|
|
1363
1413
|
const insertPosition = getInsertPosition(editor);
|
|
1364
1414
|
handleInsertTable(editor, insertPosition, path, tableNode);
|
|
1365
1415
|
};
|
|
@@ -1371,46 +1421,49 @@ export const insertTableByTemplate = (editor, alternateColor) => {
|
|
|
1371
1421
|
* @param {Node} tableNode
|
|
1372
1422
|
* Insert table by insertPosition
|
|
1373
1423
|
*/
|
|
1374
|
-
|
|
1424
|
+
exports.insertTableByTemplate = insertTableByTemplate;
|
|
1425
|
+
const handleInsertTable = (editor, insertPosition, path, tableNode) => {
|
|
1375
1426
|
const {
|
|
1376
1427
|
selection
|
|
1377
1428
|
} = editor;
|
|
1378
|
-
if (insertPosition === INSERT_POSITION.BEFORE) {
|
|
1429
|
+
if (insertPosition === _constants.INSERT_POSITION.BEFORE) {
|
|
1379
1430
|
const insertPath = [path[0]];
|
|
1380
|
-
Transforms.insertNodes(editor, tableNode, {
|
|
1431
|
+
_slate.Transforms.insertNodes(editor, tableNode, {
|
|
1381
1432
|
at: insertPath
|
|
1382
1433
|
});
|
|
1383
|
-
} else if (insertPosition === INSERT_POSITION.AFTER) {
|
|
1434
|
+
} else if (insertPosition === _constants.INSERT_POSITION.AFTER) {
|
|
1384
1435
|
const insertPath = [path[0] + 1];
|
|
1385
|
-
Transforms.insertNodes(editor, tableNode, {
|
|
1436
|
+
_slate.Transforms.insertNodes(editor, tableNode, {
|
|
1386
1437
|
at: insertPath
|
|
1387
1438
|
});
|
|
1388
|
-
} else if (insertPosition === INSERT_POSITION.CURRENT) {
|
|
1389
|
-
Transforms.splitNodes(editor, {
|
|
1439
|
+
} else if (insertPosition === _constants.INSERT_POSITION.CURRENT) {
|
|
1440
|
+
_slate.Transforms.splitNodes(editor, {
|
|
1390
1441
|
at: selection,
|
|
1391
1442
|
always: true
|
|
1392
1443
|
});
|
|
1393
|
-
Transforms.insertNodes(editor, tableNode, {
|
|
1444
|
+
_slate.Transforms.insertNodes(editor, tableNode, {
|
|
1394
1445
|
at: selection.anchor
|
|
1395
1446
|
});
|
|
1396
1447
|
}
|
|
1397
|
-
ReactEditor.focus(editor);
|
|
1448
|
+
_slateReact.ReactEditor.focus(editor);
|
|
1398
1449
|
};
|
|
1399
|
-
|
|
1450
|
+
exports.handleInsertTable = handleInsertTable;
|
|
1451
|
+
const getInsertPosition = editor => {
|
|
1400
1452
|
const {
|
|
1401
1453
|
selection
|
|
1402
1454
|
} = editor;
|
|
1403
|
-
if (!selection) return INSERT_POSITION.CURRENT;
|
|
1404
|
-
if (!Range.isCollapsed(selection)) return INSERT_POSITION.CURRENT;
|
|
1405
|
-
const aboveNodeEntry = getAboveBlockNode(editor);
|
|
1406
|
-
if (!aboveNodeEntry) return INSERT_POSITION.CURRENT;
|
|
1407
|
-
const isAtStart = Editor.isStart(editor, selection.anchor, aboveNodeEntry[1]);
|
|
1408
|
-
if (isAtStart) return INSERT_POSITION.BEFORE;
|
|
1409
|
-
const isAtEnd = Editor.isEnd(editor, selection.anchor, aboveNodeEntry[1]);
|
|
1410
|
-
if (isAtEnd) return INSERT_POSITION.AFTER;
|
|
1411
|
-
return INSERT_POSITION.CURRENT;
|
|
1412
|
-
};
|
|
1413
|
-
|
|
1455
|
+
if (!selection) return _constants.INSERT_POSITION.CURRENT;
|
|
1456
|
+
if (!_slate.Range.isCollapsed(selection)) return _constants.INSERT_POSITION.CURRENT;
|
|
1457
|
+
const aboveNodeEntry = (0, _core.getAboveBlockNode)(editor);
|
|
1458
|
+
if (!aboveNodeEntry) return _constants.INSERT_POSITION.CURRENT;
|
|
1459
|
+
const isAtStart = _slate.Editor.isStart(editor, selection.anchor, aboveNodeEntry[1]);
|
|
1460
|
+
if (isAtStart) return _constants.INSERT_POSITION.BEFORE;
|
|
1461
|
+
const isAtEnd = _slate.Editor.isEnd(editor, selection.anchor, aboveNodeEntry[1]);
|
|
1462
|
+
if (isAtEnd) return _constants.INSERT_POSITION.AFTER;
|
|
1463
|
+
return _constants.INSERT_POSITION.CURRENT;
|
|
1464
|
+
};
|
|
1465
|
+
exports.getInsertPosition = getInsertPosition;
|
|
1466
|
+
const generateInheritStyle = (allowedInheritStyleList, style, cell) => {
|
|
1414
1467
|
const inheritStyle = {
|
|
1415
1468
|
...cell['inherit_style']
|
|
1416
1469
|
} || {};
|
|
@@ -1421,10 +1474,11 @@ export const generateInheritStyle = (allowedInheritStyleList, style, cell) => {
|
|
|
1421
1474
|
}
|
|
1422
1475
|
return inheritStyle;
|
|
1423
1476
|
};
|
|
1424
|
-
|
|
1477
|
+
exports.generateInheritStyle = generateInheritStyle;
|
|
1478
|
+
const getCellInheritStyles = (editor, tablePath, rowIndex, colIndex) => {
|
|
1425
1479
|
var _table$children$rowIn, _tableCell$inherit_st;
|
|
1426
|
-
const [tableNodeEntry] = Editor.nodes(editor, {
|
|
1427
|
-
match: n => n.type === ELEMENT_TYPE.TABLE,
|
|
1480
|
+
const [tableNodeEntry] = _slate.Editor.nodes(editor, {
|
|
1481
|
+
match: n => n.type === _constants.ELEMENT_TYPE.TABLE,
|
|
1428
1482
|
at: tablePath
|
|
1429
1483
|
});
|
|
1430
1484
|
if (!tableNodeEntry) return {};
|
|
@@ -1433,21 +1487,24 @@ export const getCellInheritStyles = (editor, tablePath, rowIndex, colIndex) => {
|
|
|
1433
1487
|
if (!tableCell) return {};
|
|
1434
1488
|
return (_tableCell$inherit_st = tableCell['inherit_style']) !== null && _tableCell$inherit_st !== void 0 ? _tableCell$inherit_st : {};
|
|
1435
1489
|
};
|
|
1436
|
-
|
|
1490
|
+
exports.getCellInheritStyles = getCellInheritStyles;
|
|
1491
|
+
const getCellHighlightClassName = (primaryColorClassName, rowIndex) => {
|
|
1437
1492
|
let className = '';
|
|
1438
1493
|
if (rowIndex === 0) {
|
|
1439
1494
|
className = primaryColorClassName;
|
|
1440
1495
|
} else if (rowIndex % 2 === 0) {
|
|
1441
|
-
className = TABLE_ALTERNATE_HIGHLIGHT_CLASS_MAP[primaryColorClassName];
|
|
1496
|
+
className = _constants2.TABLE_ALTERNATE_HIGHLIGHT_CLASS_MAP[primaryColorClassName];
|
|
1442
1497
|
}
|
|
1443
1498
|
return className;
|
|
1444
1499
|
};
|
|
1445
|
-
|
|
1446
|
-
|
|
1447
|
-
|
|
1500
|
+
exports.getCellHighlightClassName = getCellHighlightClassName;
|
|
1501
|
+
const focusClosestCellWhenJustifyCellSize = (editor, adjustingCell) => {
|
|
1502
|
+
const cellPath = _slateReact.ReactEditor.findPath(editor, adjustingCell);
|
|
1503
|
+
(0, _core.focusEditor)(editor, _slate.Editor.end(editor, cellPath));
|
|
1448
1504
|
};
|
|
1449
1505
|
|
|
1450
1506
|
// Search main cell of combined cell
|
|
1507
|
+
exports.focusClosestCellWhenJustifyCellSize = focusClosestCellWhenJustifyCellSize;
|
|
1451
1508
|
const searchCombinedMainCell = (table, startRowIndex, startColIndex) => {
|
|
1452
1509
|
for (let rowIndex = startRowIndex; rowIndex >= 0; rowIndex--) {
|
|
1453
1510
|
const row = table.children[rowIndex];
|
|
@@ -1470,7 +1527,7 @@ const searchCombinedMainCell = (table, startRowIndex, startColIndex) => {
|
|
|
1470
1527
|
}
|
|
1471
1528
|
}
|
|
1472
1529
|
};
|
|
1473
|
-
|
|
1530
|
+
const getResizeMaskCellInfo = (editor, table, rowIndex, cellIndex) => {
|
|
1474
1531
|
// The cell shown cursor as resize (mouse is on this cell)
|
|
1475
1532
|
const focusCellIndex = cellIndex;
|
|
1476
1533
|
let focusCell = table.children[rowIndex].children[cellIndex];
|
|
@@ -1484,7 +1541,7 @@ export const getResizeMaskCellInfo = (editor, table, rowIndex, cellIndex) => {
|
|
|
1484
1541
|
cell = targetCellInfo.currentCell;
|
|
1485
1542
|
}
|
|
1486
1543
|
const columns = table.columns;
|
|
1487
|
-
const focussedCell = ReactEditor.toDOMNode(editor, cell);
|
|
1544
|
+
const focussedCell = _slateReact.ReactEditor.toDOMNode(editor, cell);
|
|
1488
1545
|
const {
|
|
1489
1546
|
colspan,
|
|
1490
1547
|
rowspan
|
|
@@ -1503,7 +1560,7 @@ export const getResizeMaskCellInfo = (editor, table, rowIndex, cellIndex) => {
|
|
|
1503
1560
|
let index = rowIndex + 1;
|
|
1504
1561
|
while (index < rowIndex + rowspan) {
|
|
1505
1562
|
const currentCell = table.children[index].children[cellIndex];
|
|
1506
|
-
const currentHeight = ReactEditor.toDOMNode(editor, currentCell).getBoundingClientRect().height;
|
|
1563
|
+
const currentHeight = _slateReact.ReactEditor.toDOMNode(editor, currentCell).getBoundingClientRect().height;
|
|
1507
1564
|
height += currentHeight;
|
|
1508
1565
|
index++;
|
|
1509
1566
|
}
|
|
@@ -1521,11 +1578,12 @@ export const getResizeMaskCellInfo = (editor, table, rowIndex, cellIndex) => {
|
|
|
1521
1578
|
};
|
|
1522
1579
|
|
|
1523
1580
|
// Table alternate highlight
|
|
1524
|
-
|
|
1581
|
+
exports.getResizeMaskCellInfo = getResizeMaskCellInfo;
|
|
1582
|
+
const getHighlightClass = (editor, cellPath) => {
|
|
1525
1583
|
var _tableEntry$;
|
|
1526
|
-
const [tableEntry] = Editor.nodes(editor, {
|
|
1584
|
+
const [tableEntry] = _slate.Editor.nodes(editor, {
|
|
1527
1585
|
at: cellPath,
|
|
1528
|
-
match: n => n.type === ELEMENT_TYPE.TABLE
|
|
1586
|
+
match: n => n.type === _constants.ELEMENT_TYPE.TABLE
|
|
1529
1587
|
});
|
|
1530
1588
|
const {
|
|
1531
1589
|
alternate_highlight,
|
|
@@ -1538,7 +1596,8 @@ export const getHighlightClass = (editor, cellPath) => {
|
|
|
1538
1596
|
};
|
|
1539
1597
|
|
|
1540
1598
|
// Correct the selected range when combined cell are selected
|
|
1541
|
-
|
|
1599
|
+
exports.getHighlightClass = getHighlightClass;
|
|
1600
|
+
const adjustCombinedCellRange = (table, range) => {
|
|
1542
1601
|
const {
|
|
1543
1602
|
minRowIndex,
|
|
1544
1603
|
maxRowIndex,
|
|
@@ -1553,7 +1612,7 @@ export const adjustCombinedCellRange = (table, range) => {
|
|
|
1553
1612
|
if (rowspan > 1 || colspan > 1) {
|
|
1554
1613
|
const isRowCombined = minRowIndex + rowspan === maxRowIndex + 1;
|
|
1555
1614
|
const isColCombined = minColIndex + colspan === maxColIndex + 1;
|
|
1556
|
-
if (isRowCombined && isColCombined) return EMPTY_SELECTED_RANGE;
|
|
1615
|
+
if (isRowCombined && isColCombined) return _constants2.EMPTY_SELECTED_RANGE;
|
|
1557
1616
|
}
|
|
1558
1617
|
return range;
|
|
1559
1618
|
};
|
|
@@ -1563,7 +1622,8 @@ export const adjustCombinedCellRange = (table, range) => {
|
|
|
1563
1622
|
* @param {MouseEvent} event
|
|
1564
1623
|
* @returns {Boolean}
|
|
1565
1624
|
*/
|
|
1566
|
-
|
|
1625
|
+
exports.adjustCombinedCellRange = adjustCombinedCellRange;
|
|
1626
|
+
const isPreventResetTableSelectedRange = event => {
|
|
1567
1627
|
const {
|
|
1568
1628
|
target
|
|
1569
1629
|
} = event;
|
|
@@ -1578,15 +1638,17 @@ export const isPreventResetTableSelectedRange = event => {
|
|
|
1578
1638
|
/**
|
|
1579
1639
|
* Check drag type, column or row
|
|
1580
1640
|
*/
|
|
1581
|
-
|
|
1641
|
+
exports.isPreventResetTableSelectedRange = isPreventResetTableSelectedRange;
|
|
1642
|
+
const getTableDragType = (table, selectedRange) => {
|
|
1582
1643
|
const rowCount = table.children.length;
|
|
1583
1644
|
const {
|
|
1584
1645
|
minRowIndex,
|
|
1585
1646
|
maxRowIndex
|
|
1586
1647
|
} = selectedRange;
|
|
1587
1648
|
const isSelectColumn = minRowIndex === 0 && maxRowIndex === rowCount - 1;
|
|
1588
|
-
return isSelectColumn ? DRAG_HANDLER_COLUMN : DRAG_HANDLER_ROW;
|
|
1649
|
+
return isSelectColumn ? _constants2.DRAG_HANDLER_COLUMN : _constants2.DRAG_HANDLER_ROW;
|
|
1589
1650
|
};
|
|
1651
|
+
exports.getTableDragType = getTableDragType;
|
|
1590
1652
|
const updateTableColumns = (editor, table, targetColIndex, startColIndex, endColIndex) => {
|
|
1591
1653
|
const columns = [...table.columns];
|
|
1592
1654
|
const deleteCount = endColIndex - startColIndex + 1;
|
|
@@ -1594,7 +1656,7 @@ const updateTableColumns = (editor, table, targetColIndex, startColIndex, endCol
|
|
|
1594
1656
|
columns.splice(targetColIndex, 0, ...newColumns);
|
|
1595
1657
|
updateColumnWidth(editor, table, columns);
|
|
1596
1658
|
};
|
|
1597
|
-
|
|
1659
|
+
const moveColumns = (editor, targetColIndex, startColIndex, endColIndex) => {
|
|
1598
1660
|
// Get selected table information
|
|
1599
1661
|
const {
|
|
1600
1662
|
table,
|
|
@@ -1613,10 +1675,10 @@ export const moveColumns = (editor, targetColIndex, startColIndex, endColIndex)
|
|
|
1613
1675
|
// Move columns forward by inserting nodes
|
|
1614
1676
|
for (let insertIndex = endColIndex; insertIndex >= startColIndex; insertIndex--) {
|
|
1615
1677
|
const insertNode = row.children[insertIndex];
|
|
1616
|
-
Transforms.removeNodes(editor, {
|
|
1678
|
+
_slate.Transforms.removeNodes(editor, {
|
|
1617
1679
|
at: sourcePath
|
|
1618
1680
|
});
|
|
1619
|
-
Transforms.insertNodes(editor, insertNode, {
|
|
1681
|
+
_slate.Transforms.insertNodes(editor, insertNode, {
|
|
1620
1682
|
at: targetPath
|
|
1621
1683
|
});
|
|
1622
1684
|
}
|
|
@@ -1628,10 +1690,10 @@ export const moveColumns = (editor, targetColIndex, startColIndex, endColIndex)
|
|
|
1628
1690
|
// Move columns backward by inserting nodes
|
|
1629
1691
|
for (let insertIndex = startColIndex; insertIndex <= endColIndex; insertIndex++) {
|
|
1630
1692
|
const insertNode = row.children[insertIndex];
|
|
1631
|
-
Transforms.removeNodes(editor, {
|
|
1693
|
+
_slate.Transforms.removeNodes(editor, {
|
|
1632
1694
|
at: sourcePath
|
|
1633
1695
|
});
|
|
1634
|
-
Transforms.insertNodes(editor, insertNode, {
|
|
1696
|
+
_slate.Transforms.insertNodes(editor, insertNode, {
|
|
1635
1697
|
at: targetPath
|
|
1636
1698
|
});
|
|
1637
1699
|
}
|
|
@@ -1660,7 +1722,8 @@ export const moveColumns = (editor, targetColIndex, startColIndex, endColIndex)
|
|
|
1660
1722
|
* @param {number} endIndex - The index of the ending column or row before dragging.
|
|
1661
1723
|
* @returns {Object} - The new selected range after the drag operation.
|
|
1662
1724
|
*/
|
|
1663
|
-
|
|
1725
|
+
exports.moveColumns = moveColumns;
|
|
1726
|
+
const getTableSelectedRangeAfterDrag = (table, moveType, targetIndex, startIndex, endIndex) => {
|
|
1664
1727
|
// Calculate the total number of columns and rows in the table
|
|
1665
1728
|
const colCount = table.columns.length;
|
|
1666
1729
|
const rowCount = table.children.length;
|
|
@@ -1677,7 +1740,7 @@ export const getTableSelectedRangeAfterDrag = (table, moveType, targetIndex, sta
|
|
|
1677
1740
|
const isMoveToFroward = targetIndex < startIndex;
|
|
1678
1741
|
|
|
1679
1742
|
// Adjust selected range based on the type of drag operation
|
|
1680
|
-
if (moveType === DRAG_HANDLER_COLUMN) {
|
|
1743
|
+
if (moveType === _constants2.DRAG_HANDLER_COLUMN) {
|
|
1681
1744
|
if (isMoveToFroward) {
|
|
1682
1745
|
newSelectRange.minColIndex = targetIndex;
|
|
1683
1746
|
newSelectRange.maxColIndex = targetIndex + endIndex - startIndex;
|
|
@@ -1698,7 +1761,8 @@ export const getTableSelectedRangeAfterDrag = (table, moveType, targetIndex, sta
|
|
|
1698
1761
|
}
|
|
1699
1762
|
return newSelectRange;
|
|
1700
1763
|
};
|
|
1701
|
-
|
|
1764
|
+
exports.getTableSelectedRangeAfterDrag = getTableSelectedRangeAfterDrag;
|
|
1765
|
+
const moveRows = (editor, targetRowIndex, startRowIndex, endRowIndex) => {
|
|
1702
1766
|
const {
|
|
1703
1767
|
table,
|
|
1704
1768
|
tablePath
|
|
@@ -1709,20 +1773,20 @@ export const moveRows = (editor, targetRowIndex, startRowIndex, endRowIndex) =>
|
|
|
1709
1773
|
if (isMoveToFroward) {
|
|
1710
1774
|
for (let insertIndex = endRowIndex; insertIndex >= startRowIndex; insertIndex--) {
|
|
1711
1775
|
const insertNode = table.children[insertIndex];
|
|
1712
|
-
Transforms.removeNodes(editor, {
|
|
1776
|
+
_slate.Transforms.removeNodes(editor, {
|
|
1713
1777
|
at: sourcePath
|
|
1714
1778
|
});
|
|
1715
|
-
Transforms.insertNodes(editor, insertNode, {
|
|
1779
|
+
_slate.Transforms.insertNodes(editor, insertNode, {
|
|
1716
1780
|
at: targetPath
|
|
1717
1781
|
});
|
|
1718
1782
|
}
|
|
1719
1783
|
} else {
|
|
1720
1784
|
for (let insertIndex = startRowIndex; insertIndex <= endRowIndex; insertIndex++) {
|
|
1721
1785
|
const insertNode = table.children[insertIndex];
|
|
1722
|
-
Transforms.removeNodes(editor, {
|
|
1786
|
+
_slate.Transforms.removeNodes(editor, {
|
|
1723
1787
|
at: sourcePath
|
|
1724
1788
|
});
|
|
1725
|
-
Transforms.insertNodes(editor, insertNode, {
|
|
1789
|
+
_slate.Transforms.insertNodes(editor, insertNode, {
|
|
1726
1790
|
at: targetPath
|
|
1727
1791
|
});
|
|
1728
1792
|
}
|
|
@@ -1735,7 +1799,8 @@ export const moveRows = (editor, targetRowIndex, startRowIndex, endRowIndex) =>
|
|
|
1735
1799
|
};
|
|
1736
1800
|
setTableSelectedRange(editor, newSelectRange);
|
|
1737
1801
|
};
|
|
1738
|
-
|
|
1802
|
+
exports.moveRows = moveRows;
|
|
1803
|
+
const generateDragMoveElement = tipText => {
|
|
1739
1804
|
const canvasId = 'sdoc-drag-image';
|
|
1740
1805
|
let canvas = document.getElementById(canvasId);
|
|
1741
1806
|
if (!canvas) {
|
|
@@ -1767,28 +1832,29 @@ export const generateDragMoveElement = tipText => {
|
|
|
1767
1832
|
context.fillText(tipText, canvas.width / 2, canvas.height / 2);
|
|
1768
1833
|
return canvas;
|
|
1769
1834
|
};
|
|
1770
|
-
|
|
1835
|
+
exports.generateDragMoveElement = generateDragMoveElement;
|
|
1836
|
+
const isHideDragHandlerLine = (editor, displayType, table, cellPath, isDragOverCellHalf) => {
|
|
1771
1837
|
const pathLength = cellPath.length;
|
|
1772
1838
|
let rowIndex = cellPath[pathLength - 2];
|
|
1773
1839
|
let cellIndex = cellPath[pathLength - 1];
|
|
1774
1840
|
|
|
1775
1841
|
// Check is above cell selected
|
|
1776
|
-
let currentCellDom = ReactEditor.toDOMNode(editor, table.children[rowIndex].children[cellIndex]);
|
|
1777
|
-
let isCurrentCellSelected = currentCellDom.classList.contains(CELL_SELECTED);
|
|
1842
|
+
let currentCellDom = _slateReact.ReactEditor.toDOMNode(editor, table.children[rowIndex].children[cellIndex]);
|
|
1843
|
+
let isCurrentCellSelected = currentCellDom.classList.contains(_constants2.CELL_SELECTED);
|
|
1778
1844
|
if (isCurrentCellSelected) return true;
|
|
1779
1845
|
if (isDragOverCellHalf) {
|
|
1780
|
-
if (displayType === DRAG_HANDLER_COLUMN) {
|
|
1846
|
+
if (displayType === _constants2.DRAG_HANDLER_COLUMN) {
|
|
1781
1847
|
cellIndex = cellIndex + 1;
|
|
1782
1848
|
} else {
|
|
1783
1849
|
rowIndex = rowIndex + 1;
|
|
1784
1850
|
}
|
|
1785
1851
|
}
|
|
1786
|
-
const isEndOfRowOrColumn = displayType === DRAG_HANDLER_COLUMN && cellIndex === table.columns.length || displayType === DRAG_HANDLER_ROW && rowIndex === table.children.length;
|
|
1852
|
+
const isEndOfRowOrColumn = displayType === _constants2.DRAG_HANDLER_COLUMN && cellIndex === table.columns.length || displayType === _constants2.DRAG_HANDLER_ROW && rowIndex === table.children.length;
|
|
1787
1853
|
if (isEndOfRowOrColumn) return false;
|
|
1788
1854
|
let preCellDom = null;
|
|
1789
|
-
if (displayType === DRAG_HANDLER_COLUMN && cellIndex > 0) {
|
|
1855
|
+
if (displayType === _constants2.DRAG_HANDLER_COLUMN && cellIndex > 0) {
|
|
1790
1856
|
const prevCell = table.children[rowIndex].children[cellIndex - 1];
|
|
1791
|
-
preCellDom = ReactEditor.toDOMNode(editor, prevCell);
|
|
1857
|
+
preCellDom = _slateReact.ReactEditor.toDOMNode(editor, prevCell);
|
|
1792
1858
|
|
|
1793
1859
|
// Check if there are merged cells in the columns before and after the drag line
|
|
1794
1860
|
const beforeLineColumnHasCombined = table.children.find(item => {
|
|
@@ -1800,9 +1866,9 @@ export const isHideDragHandlerLine = (editor, displayType, table, cellPath, isDr
|
|
|
1800
1866
|
return (cell === null || cell === void 0 ? void 0 : cell.is_combined) === true;
|
|
1801
1867
|
});
|
|
1802
1868
|
if (beforeLineColumnHasCombined && afterLineColumnHasCombined) return true;
|
|
1803
|
-
} else if (displayType === DRAG_HANDLER_ROW && rowIndex > 0) {
|
|
1869
|
+
} else if (displayType === _constants2.DRAG_HANDLER_ROW && rowIndex > 0) {
|
|
1804
1870
|
const prevCell = table.children[rowIndex - 1].children[cellIndex];
|
|
1805
|
-
preCellDom = ReactEditor.toDOMNode(editor, prevCell);
|
|
1871
|
+
preCellDom = _slateReact.ReactEditor.toDOMNode(editor, prevCell);
|
|
1806
1872
|
|
|
1807
1873
|
// Check whether there are merged cells in the rows before and after the drag line
|
|
1808
1874
|
const beforeLineRow = table.children[rowIndex - 1];
|
|
@@ -1813,16 +1879,16 @@ export const isHideDragHandlerLine = (editor, displayType, table, cellPath, isDr
|
|
|
1813
1879
|
}
|
|
1814
1880
|
|
|
1815
1881
|
// Check is above cell selected
|
|
1816
|
-
currentCellDom = ReactEditor.toDOMNode(editor, table.children[rowIndex].children[cellIndex]);
|
|
1817
|
-
isCurrentCellSelected = currentCellDom.classList.contains(CELL_SELECTED);
|
|
1882
|
+
currentCellDom = _slateReact.ReactEditor.toDOMNode(editor, table.children[rowIndex].children[cellIndex]);
|
|
1883
|
+
isCurrentCellSelected = currentCellDom.classList.contains(_constants2.CELL_SELECTED);
|
|
1818
1884
|
if (isCurrentCellSelected) return true;
|
|
1819
1885
|
|
|
1820
1886
|
// Check if the previous cell is selected
|
|
1821
|
-
const isPrevCellSelected = preCellDom && preCellDom.classList.contains(CELL_SELECTED);
|
|
1887
|
+
const isPrevCellSelected = preCellDom && preCellDom.classList.contains(_constants2.CELL_SELECTED);
|
|
1822
1888
|
if (isPrevCellSelected) return true;
|
|
1823
1889
|
let isCombined = false;
|
|
1824
1890
|
// Check if the combined cell
|
|
1825
|
-
if (displayType === DRAG_HANDLER_COLUMN) {
|
|
1891
|
+
if (displayType === _constants2.DRAG_HANDLER_COLUMN) {
|
|
1826
1892
|
isCombined = table.children.some(row => row.children[cellIndex - isDragOverCellHalf].is_combined);
|
|
1827
1893
|
} else {
|
|
1828
1894
|
isCombined = table.children[rowIndex - isDragOverCellHalf].children.some(cell => cell.is_combined);
|
|
@@ -1830,12 +1896,13 @@ export const isHideDragHandlerLine = (editor, displayType, table, cellPath, isDr
|
|
|
1830
1896
|
if (isCombined) return true;
|
|
1831
1897
|
|
|
1832
1898
|
// Check is the last column
|
|
1833
|
-
if (displayType === DRAG_HANDLER_COLUMN) {
|
|
1899
|
+
if (displayType === _constants2.DRAG_HANDLER_COLUMN) {
|
|
1834
1900
|
const isLastColumn = cellIndex === table.columns.length - 1;
|
|
1835
1901
|
if (isLastColumn) return false;
|
|
1836
1902
|
}
|
|
1837
1903
|
};
|
|
1838
|
-
|
|
1904
|
+
exports.isHideDragHandlerLine = isHideDragHandlerLine;
|
|
1905
|
+
const getTableRowSelectedRange = (table, rowIndex) => {
|
|
1839
1906
|
const row = table.children[rowIndex];
|
|
1840
1907
|
const columnCount = row.children.length;
|
|
1841
1908
|
let minRowIndex = rowIndex;
|
|
@@ -1877,7 +1944,8 @@ export const getTableRowSelectedRange = (table, rowIndex) => {
|
|
|
1877
1944
|
maxColIndex
|
|
1878
1945
|
};
|
|
1879
1946
|
};
|
|
1880
|
-
|
|
1947
|
+
exports.getTableRowSelectedRange = getTableRowSelectedRange;
|
|
1948
|
+
const getTableColumnSelectedRange = (table, columnIndex) => {
|
|
1881
1949
|
let minRowIndex = 0;
|
|
1882
1950
|
let maxRowIndex = table.children.length - 1;
|
|
1883
1951
|
let minColIndex = columnIndex;
|
|
@@ -1917,11 +1985,12 @@ export const getTableColumnSelectedRange = (table, columnIndex) => {
|
|
|
1917
1985
|
maxColIndex
|
|
1918
1986
|
};
|
|
1919
1987
|
};
|
|
1920
|
-
|
|
1988
|
+
exports.getTableColumnSelectedRange = getTableColumnSelectedRange;
|
|
1989
|
+
const isTableWidthFitScreen = editor => {
|
|
1921
1990
|
const {
|
|
1922
1991
|
table
|
|
1923
1992
|
} = getSelectedInfo(editor);
|
|
1924
|
-
const tableNode = ReactEditor.toDOMNode(editor, table);
|
|
1993
|
+
const tableNode = _slateReact.ReactEditor.toDOMNode(editor, table);
|
|
1925
1994
|
if (!tableNode) return;
|
|
1926
1995
|
const tableDom = tableNode.querySelector('.sdoc-table-scroll-wrapper');
|
|
1927
1996
|
const {
|
|
@@ -1931,20 +2000,22 @@ export const isTableWidthFitScreen = editor => {
|
|
|
1931
2000
|
if (tableWidth >= sdocWidth) return true;
|
|
1932
2001
|
return false;
|
|
1933
2002
|
};
|
|
1934
|
-
|
|
2003
|
+
exports.isTableWidthFitScreen = isTableWidthFitScreen;
|
|
2004
|
+
const fitTableColumnToScreen = editor => {
|
|
1935
2005
|
const {
|
|
1936
2006
|
table,
|
|
1937
2007
|
tablePath
|
|
1938
2008
|
} = getSelectedInfo(editor);
|
|
1939
2009
|
const colCount = table.columns.length;
|
|
1940
|
-
const columnWidth = Math.max(TABLE_CELL_MIN_WIDTH, parseInt(editor.width / colCount));
|
|
2010
|
+
const columnWidth = Math.max(_constants2.TABLE_CELL_MIN_WIDTH, parseInt(editor.width / colCount));
|
|
1941
2011
|
const columns = table.columns.map(column => ({
|
|
1942
2012
|
...column,
|
|
1943
2013
|
width: columnWidth
|
|
1944
2014
|
}));
|
|
1945
|
-
Transforms.setNodes(editor, {
|
|
2015
|
+
_slate.Transforms.setNodes(editor, {
|
|
1946
2016
|
columns
|
|
1947
2017
|
}, {
|
|
1948
2018
|
at: tablePath
|
|
1949
2019
|
});
|
|
1950
|
-
};
|
|
2020
|
+
};
|
|
2021
|
+
exports.fitTableColumnToScreen = fitTableColumnToScreen;
|