@seafile/sdoc-editor 0.3.6 → 0.3.7
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 +165 -170
- package/dist/api/seafile-api.js +180 -246
- package/dist/basic-sdk/comment/comment-decorate.js +23 -30
- package/dist/basic-sdk/comment/components/comment-all-participants/index.js +18 -18
- package/dist/basic-sdk/comment/components/comment-all-participants/participant-avatar.js +13 -13
- package/dist/basic-sdk/comment/components/comment-delete-shadow.js +11 -9
- package/dist/basic-sdk/comment/components/comment-editor.js +37 -34
- package/dist/basic-sdk/comment/components/comment-input/comment-participant-item.js +16 -14
- package/dist/basic-sdk/comment/components/comment-input/index.js +110 -106
- package/dist/basic-sdk/comment/components/comment-item-content.js +29 -37
- package/dist/basic-sdk/comment/components/comment-item-reply.js +24 -33
- package/dist/basic-sdk/comment/components/comment-item-resolved-reply.js +5 -3
- package/dist/basic-sdk/comment/components/comment-item-wrapper.js +190 -285
- package/dist/basic-sdk/comment/components/comment-list.js +52 -72
- package/dist/basic-sdk/comment/components/comment-participants-editor/index.js +23 -30
- package/dist/basic-sdk/comment/components/comment-participants-editor/searched-collaborators.js +21 -19
- package/dist/basic-sdk/comment/components/comment-participants-editor/selected-participants.js +16 -14
- package/dist/basic-sdk/comment/components/editor-comment.js +23 -32
- package/dist/basic-sdk/comment/components/elements-comment-count/element-comment-count.js +18 -20
- package/dist/basic-sdk/comment/components/elements-comment-count/index.js +8 -8
- package/dist/basic-sdk/comment/components/global-comment/global-comment-body-header.js +23 -25
- package/dist/basic-sdk/comment/components/global-comment/global-comment-editor.js +9 -7
- package/dist/basic-sdk/comment/components/global-comment/global-comment-header.js +9 -6
- package/dist/basic-sdk/comment/components/global-comment/index.js +63 -86
- package/dist/basic-sdk/comment/constants/index.js +9 -9
- package/dist/basic-sdk/comment/helper.js +27 -26
- package/dist/basic-sdk/comment/hooks/comment-hooks/use-comment-context.js +8 -7
- package/dist/basic-sdk/comment/hooks/comment-hooks/use-comment-list.js +19 -30
- package/dist/basic-sdk/comment/hooks/comment-hooks/use-comment-mount.js +41 -71
- package/dist/basic-sdk/comment/hooks/notification-hooks/use-notification-context.js +8 -7
- package/dist/basic-sdk/comment/hooks/notification-hooks/use-notification-mount.js +45 -64
- package/dist/basic-sdk/comment/hooks/use-participants.js +46 -53
- package/dist/basic-sdk/comment/index.js +22 -19
- package/dist/basic-sdk/comment/provider/comment-context-provider.js +9 -11
- package/dist/basic-sdk/comment/provider/index.js +4 -2
- package/dist/basic-sdk/comment/provider/notification-context-provider.js +9 -11
- package/dist/basic-sdk/comment/reducer/comment-reducer.js +151 -137
- package/dist/basic-sdk/comment/reducer/notification-reducer.js +20 -15
- package/dist/basic-sdk/comment/utils/index.js +180 -173
- package/dist/basic-sdk/comment/utils/notification-utils.js +15 -14
- package/dist/basic-sdk/constants/index.js +9 -9
- package/dist/basic-sdk/cursor/helper.js +13 -9
- package/dist/basic-sdk/cursor/use-cursors.js +9 -13
- package/dist/basic-sdk/decorates/index.js +8 -9
- package/dist/basic-sdk/editor/editable-article.js +63 -57
- package/dist/basic-sdk/editor/sdoc-editor.js +42 -47
- package/dist/basic-sdk/extension/commons/color-menu/color-item.js +6 -4
- package/dist/basic-sdk/extension/commons/color-menu/index.js +40 -50
- package/dist/basic-sdk/extension/commons/dropdown-menu-item/index.js +17 -16
- package/dist/basic-sdk/extension/commons/element-popover/index.js +27 -45
- package/dist/basic-sdk/extension/commons/insert-element-dialog/index.js +46 -59
- package/dist/basic-sdk/extension/commons/menu/menu-group.js +7 -21
- package/dist/basic-sdk/extension/commons/menu/menu-item.js +17 -14
- package/dist/basic-sdk/extension/commons/more-dropdown/index.js +9 -7
- package/dist/basic-sdk/extension/commons/select-file-dialog/helpers.js +3 -3
- package/dist/basic-sdk/extension/commons/select-file-dialog/index.js +26 -23
- package/dist/basic-sdk/extension/commons/select-file-dialog/local-files/index.js +49 -80
- package/dist/basic-sdk/extension/constants/color.js +10 -10
- package/dist/basic-sdk/extension/constants/diff-view.js +3 -3
- package/dist/basic-sdk/extension/constants/element-type.js +29 -29
- package/dist/basic-sdk/extension/constants/font.js +44 -37
- package/dist/basic-sdk/extension/constants/index.js +27 -16
- package/dist/basic-sdk/extension/constants/keyboard.js +4 -4
- package/dist/basic-sdk/extension/constants/menus-config.js +234 -203
- package/dist/basic-sdk/extension/core/queries/index.js +185 -285
- package/dist/basic-sdk/extension/core/transforms/focus-editor.js +2 -2
- package/dist/basic-sdk/extension/core/transforms/move-children.js +14 -14
- package/dist/basic-sdk/extension/core/transforms/remove-node-children.js +6 -18
- package/dist/basic-sdk/extension/core/transforms/replace-node.js +22 -19
- package/dist/basic-sdk/extension/core/transforms/update-parent-node.js +6 -8
- package/dist/basic-sdk/extension/core/utils/index.js +12 -12
- package/dist/basic-sdk/extension/index.js +6 -6
- package/dist/basic-sdk/extension/plugins/blockquote/helpers.js +39 -54
- package/dist/basic-sdk/extension/plugins/blockquote/index.js +1 -1
- package/dist/basic-sdk/extension/plugins/blockquote/menu/index.js +34 -44
- package/dist/basic-sdk/extension/plugins/blockquote/model.js +8 -9
- package/dist/basic-sdk/extension/plugins/blockquote/plugin.js +36 -37
- package/dist/basic-sdk/extension/plugins/blockquote/render-elem.js +7 -5
- package/dist/basic-sdk/extension/plugins/check-list/helpers.js +15 -25
- package/dist/basic-sdk/extension/plugins/check-list/index.js +1 -1
- package/dist/basic-sdk/extension/plugins/check-list/menu/index.js +35 -45
- package/dist/basic-sdk/extension/plugins/check-list/model.js +9 -10
- package/dist/basic-sdk/extension/plugins/check-list/plugin.js +16 -10
- package/dist/basic-sdk/extension/plugins/check-list/render-elem.js +42 -56
- package/dist/basic-sdk/extension/plugins/clear-format/helpers.js +21 -36
- package/dist/basic-sdk/extension/plugins/clear-format/menu/index.js +12 -10
- package/dist/basic-sdk/extension/plugins/code-block/helpers.js +40 -58
- package/dist/basic-sdk/extension/plugins/code-block/hover-menu/index.js +38 -46
- package/dist/basic-sdk/extension/plugins/code-block/index.js +1 -1
- package/dist/basic-sdk/extension/plugins/code-block/menu/index.js +9 -7
- package/dist/basic-sdk/extension/plugins/code-block/model.js +8 -9
- package/dist/basic-sdk/extension/plugins/code-block/plugin.js +44 -51
- package/dist/basic-sdk/extension/plugins/code-block/prismjs.js +27 -27
- package/dist/basic-sdk/extension/plugins/code-block/render-elem.js +62 -58
- package/dist/basic-sdk/extension/plugins/file-link/constants/index.js +16 -14
- package/dist/basic-sdk/extension/plugins/file-link/helpers.js +34 -36
- package/dist/basic-sdk/extension/plugins/file-link/hover-menu/index.js +19 -23
- package/dist/basic-sdk/extension/plugins/file-link/index.js +1 -1
- package/dist/basic-sdk/extension/plugins/file-link/menu/index.js +10 -8
- package/dist/basic-sdk/extension/plugins/file-link/plugin.js +17 -11
- package/dist/basic-sdk/extension/plugins/file-link/render-elem.js +34 -38
- package/dist/basic-sdk/extension/plugins/font/helpers.js +75 -78
- package/dist/basic-sdk/extension/plugins/font/index.js +1 -1
- package/dist/basic-sdk/extension/plugins/font/menu/font-family/font-item.js +14 -13
- package/dist/basic-sdk/extension/plugins/font/menu/font-family/index.js +38 -55
- package/dist/basic-sdk/extension/plugins/font/menu/font-size/font-size-scale.js +12 -10
- package/dist/basic-sdk/extension/plugins/font/menu/font-size/index.js +29 -31
- package/dist/basic-sdk/extension/plugins/font/menu/index.js +5 -3
- package/dist/basic-sdk/extension/plugins/font/plugin.js +4 -4
- package/dist/basic-sdk/extension/plugins/header/helpers.js +32 -38
- package/dist/basic-sdk/extension/plugins/header/index.js +1 -1
- package/dist/basic-sdk/extension/plugins/header/menu/index.js +101 -107
- package/dist/basic-sdk/extension/plugins/header/plugin.js +41 -44
- package/dist/basic-sdk/extension/plugins/header/render-elem.js +28 -20
- package/dist/basic-sdk/extension/plugins/html/helper.js +30 -28
- package/dist/basic-sdk/extension/plugins/html/index.js +1 -1
- package/dist/basic-sdk/extension/plugins/html/plugin.js +12 -10
- package/dist/basic-sdk/extension/plugins/html/rules/blockquote.js +5 -3
- package/dist/basic-sdk/extension/plugins/html/rules/check-list.js +4 -2
- package/dist/basic-sdk/extension/plugins/html/rules/code-block.js +20 -24
- package/dist/basic-sdk/extension/plugins/html/rules/header.js +7 -5
- package/dist/basic-sdk/extension/plugins/html/rules/image.js +4 -2
- package/dist/basic-sdk/extension/plugins/html/rules/index.js +1 -1
- package/dist/basic-sdk/extension/plugins/html/rules/link.js +5 -3
- package/dist/basic-sdk/extension/plugins/html/rules/list.js +6 -4
- package/dist/basic-sdk/extension/plugins/html/rules/paragraph.js +5 -3
- package/dist/basic-sdk/extension/plugins/html/rules/table.js +5 -3
- package/dist/basic-sdk/extension/plugins/html/rules/text.js +5 -3
- package/dist/basic-sdk/extension/plugins/image/constants/index.js +2 -2
- package/dist/basic-sdk/extension/plugins/image/dialogs/image-previewer.js +59 -75
- package/dist/basic-sdk/extension/plugins/image/helpers.js +74 -98
- package/dist/basic-sdk/extension/plugins/image/hover-menu/index.js +49 -62
- package/dist/basic-sdk/extension/plugins/image/index.js +1 -1
- package/dist/basic-sdk/extension/plugins/image/menu/index.js +12 -9
- package/dist/basic-sdk/extension/plugins/image/model.js +11 -12
- package/dist/basic-sdk/extension/plugins/image/plugin.js +43 -35
- package/dist/basic-sdk/extension/plugins/image/render-elem.js +73 -91
- package/dist/basic-sdk/extension/plugins/index.js +1 -1
- package/dist/basic-sdk/extension/plugins/link/dialog/add-link-dialog/index.js +30 -39
- package/dist/basic-sdk/extension/plugins/link/helpers.js +76 -100
- package/dist/basic-sdk/extension/plugins/link/hover/index.js +12 -9
- package/dist/basic-sdk/extension/plugins/link/index.js +1 -1
- package/dist/basic-sdk/extension/plugins/link/menu/index.js +10 -8
- package/dist/basic-sdk/extension/plugins/link/model.js +10 -11
- package/dist/basic-sdk/extension/plugins/link/plugin.js +28 -31
- package/dist/basic-sdk/extension/plugins/link/render-elem.js +66 -74
- package/dist/basic-sdk/extension/plugins/list/helpers.js +45 -57
- package/dist/basic-sdk/extension/plugins/list/index.js +1 -1
- package/dist/basic-sdk/extension/plugins/list/menu/index.js +37 -49
- package/dist/basic-sdk/extension/plugins/list/model.js +11 -12
- package/dist/basic-sdk/extension/plugins/list/plugin/index.js +16 -12
- package/dist/basic-sdk/extension/plugins/list/plugin/insert-break-list.js +4 -4
- package/dist/basic-sdk/extension/plugins/list/plugin/insert-fragment-list.js +54 -70
- package/dist/basic-sdk/extension/plugins/list/plugin/normalize-list.js +16 -20
- package/dist/basic-sdk/extension/plugins/list/plugin/on-tab-handle.js +19 -14
- package/dist/basic-sdk/extension/plugins/list/plugin/shortcut.js +20 -28
- package/dist/basic-sdk/extension/plugins/list/queries/index.js +16 -18
- package/dist/basic-sdk/extension/plugins/list/render-elem.js +23 -15
- package/dist/basic-sdk/extension/plugins/list/transforms/insert-list-item.js +20 -24
- package/dist/basic-sdk/extension/plugins/list/transforms/move-list-item-down.js +16 -19
- package/dist/basic-sdk/extension/plugins/list/transforms/move-list-item-up.js +31 -35
- package/dist/basic-sdk/extension/plugins/list/transforms/move-list-items-to-list.js +18 -18
- package/dist/basic-sdk/extension/plugins/list/transforms/move-list-items.js +23 -24
- package/dist/basic-sdk/extension/plugins/list/transforms/normalize-list-item.js +38 -55
- package/dist/basic-sdk/extension/plugins/list/transforms/normalize-nested-list.js +11 -13
- package/dist/basic-sdk/extension/plugins/list/transforms/remove-first-list-item.js +8 -8
- package/dist/basic-sdk/extension/plugins/list/transforms/toggle-list.js +42 -50
- package/dist/basic-sdk/extension/plugins/list/transforms/unwrap-list.js +11 -14
- package/dist/basic-sdk/extension/plugins/markdown/index.js +1 -1
- package/dist/basic-sdk/extension/plugins/markdown/plugin.js +59 -52
- package/dist/basic-sdk/extension/plugins/paragraph/index.js +1 -1
- package/dist/basic-sdk/extension/plugins/paragraph/render-elem.js +12 -10
- package/dist/basic-sdk/extension/plugins/sdoc-link/constants/index.js +16 -14
- package/dist/basic-sdk/extension/plugins/sdoc-link/helpers.js +66 -65
- package/dist/basic-sdk/extension/plugins/sdoc-link/hover-menu/index.js +19 -23
- package/dist/basic-sdk/extension/plugins/sdoc-link/index.js +1 -1
- package/dist/basic-sdk/extension/plugins/sdoc-link/menu/index.js +10 -8
- package/dist/basic-sdk/extension/plugins/sdoc-link/plugin.js +23 -15
- package/dist/basic-sdk/extension/plugins/sdoc-link/render-elem.js +35 -39
- package/dist/basic-sdk/extension/plugins/table/constants/index.js +16 -14
- package/dist/basic-sdk/extension/plugins/table/dialog/custom-table-size-dialog/index.js +17 -24
- package/dist/basic-sdk/extension/plugins/table/dialog/custom-table-size-dialog/number-input.js +9 -7
- package/dist/basic-sdk/extension/plugins/table/helpers.js +466 -440
- package/dist/basic-sdk/extension/plugins/table/index.js +1 -1
- package/dist/basic-sdk/extension/plugins/table/menu/active-table-menu/cell-bg-color-menu.js +16 -13
- package/dist/basic-sdk/extension/plugins/table/menu/active-table-menu/cell-text-align-menu.js +16 -18
- package/dist/basic-sdk/extension/plugins/table/menu/active-table-menu/common-menu.js +58 -65
- package/dist/basic-sdk/extension/plugins/table/menu/active-table-menu/index.js +7 -5
- package/dist/basic-sdk/extension/plugins/table/menu/active-table-menu/remove-table-menu.js +11 -9
- package/dist/basic-sdk/extension/plugins/table/menu/active-table-menu/table-column-menu.js +13 -14
- package/dist/basic-sdk/extension/plugins/table/menu/active-table-menu/table-row-menu.js +13 -14
- package/dist/basic-sdk/extension/plugins/table/menu/table-context-menu/index.js +92 -105
- package/dist/basic-sdk/extension/plugins/table/menu/table-context-menu/insert-table-element.js +62 -66
- package/dist/basic-sdk/extension/plugins/table/menu/table-menu/index.js +9 -7
- package/dist/basic-sdk/extension/plugins/table/model.js +14 -15
- package/dist/basic-sdk/extension/plugins/table/plugin.js +130 -112
- package/dist/basic-sdk/extension/plugins/table/popover/table-size-popover/index.js +31 -45
- package/dist/basic-sdk/extension/plugins/table/popover/table-template/index.js +12 -14
- package/dist/basic-sdk/extension/plugins/table/popover/table-template/sample-table.js +15 -19
- package/dist/basic-sdk/extension/plugins/table/render/hooks.js +25 -32
- package/dist/basic-sdk/extension/plugins/table/render/index.js +57 -67
- package/dist/basic-sdk/extension/plugins/table/render/render-cell.js +42 -36
- package/dist/basic-sdk/extension/plugins/table/render/render-row.js +44 -49
- package/dist/basic-sdk/extension/plugins/table/render/resize-handlers/first-column-left-resize-handler.js +36 -45
- package/dist/basic-sdk/extension/plugins/table/render/resize-handlers/index.js +10 -8
- package/dist/basic-sdk/extension/plugins/table/render/resize-handlers/resize-handler.js +41 -50
- package/dist/basic-sdk/extension/plugins/table/render/table-header/columns-header/column-header.js +30 -29
- package/dist/basic-sdk/extension/plugins/table/render/table-header/columns-header/index.js +21 -33
- package/dist/basic-sdk/extension/plugins/table/render/table-header/index.js +17 -15
- package/dist/basic-sdk/extension/plugins/table/render/table-header/rows-columns-header.js +7 -5
- package/dist/basic-sdk/extension/plugins/table/render/table-header/rows-header/index.js +22 -32
- package/dist/basic-sdk/extension/plugins/table/render/table-header/rows-header/row-header.js +41 -43
- package/dist/basic-sdk/extension/plugins/table/render/table-root.js +16 -20
- package/dist/basic-sdk/extension/plugins/text-align/helpers.js +19 -24
- package/dist/basic-sdk/extension/plugins/text-align/index.js +1 -1
- package/dist/basic-sdk/extension/plugins/text-align/menu/index.js +20 -26
- package/dist/basic-sdk/extension/plugins/text-style/caret.js +9 -7
- package/dist/basic-sdk/extension/plugins/text-style/helpers.js +17 -24
- package/dist/basic-sdk/extension/plugins/text-style/index.js +1 -1
- package/dist/basic-sdk/extension/plugins/text-style/menu/index.js +38 -37
- package/dist/basic-sdk/extension/plugins/text-style/plugin.js +6 -6
- package/dist/basic-sdk/extension/plugins/text-style/render-elem.js +14 -10
- package/dist/basic-sdk/extension/render/custom-element.js +30 -49
- package/dist/basic-sdk/extension/render/element-decorate/rebase-decorate/index.js +6 -4
- package/dist/basic-sdk/extension/render/element-decorate/rebase-decorate/rebase-delete-modify-decorate.js +13 -10
- package/dist/basic-sdk/extension/render/element-decorate/rebase-decorate/rebase-modify-delete-decorate.js +13 -10
- package/dist/basic-sdk/extension/render/element-decorate/rebase-decorate/rebase-modify-modify-decorate.js +21 -19
- package/dist/basic-sdk/extension/render/render-element.js +5 -3
- package/dist/basic-sdk/extension/render/render-leaf.js +4 -6
- package/dist/basic-sdk/extension/toolbar/context-toolbar/index.js +18 -16
- package/dist/basic-sdk/extension/toolbar/header-toolbar/index.js +5 -3
- package/dist/basic-sdk/extension/toolbar/header-toolbar/insert-toolbar/index.js +29 -29
- package/dist/basic-sdk/extension/toolbar/header-toolbar/redo-undo.js +45 -53
- package/dist/basic-sdk/extension/toolbar/side-toolbar/event.js +8 -8
- package/dist/basic-sdk/extension/toolbar/side-toolbar/helpers.js +45 -49
- package/dist/basic-sdk/extension/toolbar/side-toolbar/index.js +50 -72
- package/dist/basic-sdk/extension/toolbar/side-toolbar/insert-below-menu.js +5 -3
- package/dist/basic-sdk/extension/toolbar/side-toolbar/insert-block-menu.js +25 -26
- package/dist/basic-sdk/extension/toolbar/side-toolbar/side-menu.js +24 -26
- package/dist/basic-sdk/extension/toolbar/side-toolbar/transform-menus.js +14 -16
- package/dist/basic-sdk/extension/utils/index.js +4 -4
- package/dist/basic-sdk/highlight/index.js +8 -13
- package/dist/basic-sdk/highlight/setNodeToDecorations.js +43 -73
- package/dist/basic-sdk/hooks/use-color-context.js +27 -35
- package/dist/basic-sdk/hooks/use-scroll-context.js +6 -4
- package/dist/basic-sdk/hooks/use-selection-element.js +5 -7
- package/dist/basic-sdk/hooks/use-selection-position.js +13 -15
- package/dist/basic-sdk/hooks/use-selection-update.js +6 -11
- package/dist/basic-sdk/layout/article-container.js +20 -23
- package/dist/basic-sdk/layout/editor-container.js +6 -4
- package/dist/basic-sdk/layout/editor-content.js +15 -15
- package/dist/basic-sdk/node-id/constants.js +9 -9
- package/dist/basic-sdk/node-id/helpers.js +44 -29
- package/dist/basic-sdk/node-id/index.js +13 -11
- package/dist/basic-sdk/outline/index.js +24 -27
- package/dist/basic-sdk/outline/outline-item.js +39 -44
- package/dist/basic-sdk/socket/helpers.js +99 -90
- package/dist/basic-sdk/socket/socket-client.js +175 -171
- package/dist/basic-sdk/socket/socket-manager.js +316 -297
- package/dist/basic-sdk/socket/with-socket-io.js +38 -30
- package/dist/basic-sdk/utils/debug.js +4 -4
- package/dist/basic-sdk/utils/diff-text.js +191 -193
- package/dist/basic-sdk/utils/diff.js +115 -106
- package/dist/basic-sdk/utils/document-utils.js +10 -13
- package/dist/basic-sdk/utils/dom-utils.js +18 -16
- package/dist/basic-sdk/utils/event-bus.js +26 -39
- package/dist/basic-sdk/utils/event-handler.js +81 -79
- package/dist/basic-sdk/utils/mouse-event.js +29 -27
- package/dist/basic-sdk/utils/object-utils.js +35 -53
- package/dist/basic-sdk/utils/rebase.js +101 -76
- package/dist/basic-sdk/views/published-revision-diff-viewer.js +19 -22
- package/dist/basic-sdk/views/readonly-article.js +7 -5
- package/dist/basic-sdk/views/revision-diff-viewer.js +15 -18
- package/dist/basic-sdk/views/sdoc-diff-viewer.js +8 -6
- package/dist/basic-sdk/views/sdoc-viewer.js +9 -7
- package/dist/components/common-loading/index.js +1 -1
- package/dist/components/doc-info/index.js +25 -23
- package/dist/components/doc-operations/collaborators-operation/collaborators-popover.js +36 -49
- package/dist/components/doc-operations/collaborators-operation/index.js +58 -76
- package/dist/components/doc-operations/comments-operation/index.js +7 -13
- package/dist/components/doc-operations/history-operation.js +5 -5
- package/dist/components/doc-operations/index.js +10 -9
- package/dist/components/doc-operations/more-operations.js +15 -21
- package/dist/components/doc-operations/revision-operations/changes-count/index.js +15 -16
- package/dist/components/doc-operations/revision-operations/index.js +65 -71
- package/dist/components/doc-operations/revision-operations/more-revision-operations/index.js +13 -17
- package/dist/components/doc-operations/revision-operations/publish-revision/index.js +8 -5
- package/dist/components/doc-operations/revision-operations/revisions/index.js +13 -19
- package/dist/components/doc-operations/revision-operations/revisions/revisions-dialog/index.js +56 -87
- package/dist/components/doc-operations/revision-operations/revisions/revisions-dialog/revision-operation/index.js +14 -16
- package/dist/components/doc-operations/revision-operations/view-changes/index.js +25 -32
- package/dist/components/doc-operations/share-operation/index.js +2 -2
- package/dist/components/doc-operations/tag-operation/constans.js +1 -1
- package/dist/components/doc-operations/tag-operation/file-tag-quick-view/index.js +26 -42
- package/dist/components/doc-operations/tag-operation/index.js +1 -1
- package/dist/components/doc-operations/tag-operation/tag-popover/index.js +95 -175
- package/dist/components/doc-operations/tag-operation/utils.js +2 -6
- package/dist/components/draft-dropdown/index.js +44 -53
- package/dist/components/loading/index.js +8 -22
- package/dist/components/modal-portal/index.js +15 -32
- package/dist/components/switch/index.js +8 -6
- package/dist/components/tip-dialog/index.js +21 -23
- package/dist/components/tip-message/index.js +93 -92
- package/dist/components/toast/alert.js +73 -88
- package/dist/components/toast/index.js +1 -1
- package/dist/components/toast/toast.js +76 -103
- package/dist/components/toast/toastManager.js +55 -89
- package/dist/components/toast/toaster.js +54 -56
- package/dist/components/tooltip/index.js +15 -16
- package/dist/constants/index.js +26 -6
- package/dist/constants/transfer-types.js +3 -3
- package/dist/context.js +242 -339
- package/dist/hooks/use-collaborators.js +18 -20
- package/dist/hooks/use-document.js +33 -45
- package/dist/layout/content.js +13 -26
- package/dist/layout/header.js +13 -26
- package/dist/layout/layout.js +11 -9
- package/dist/model/notification.js +10 -11
- package/dist/model/revision.js +27 -28
- package/dist/model/user.js +10 -11
- package/dist/pages/error-boundary.js +18 -36
- package/dist/pages/error-page.js +14 -26
- package/dist/pages/published-revision-viewer.js +23 -35
- package/dist/pages/simple-editor.js +39 -46
- package/dist/pages/simple-viewer.js +70 -104
- package/dist/utils/date-utils.js +67 -81
- package/dist/utils/get-event-transfer.js +13 -15
- package/dist/utils/hotkey.js +24 -24
- package/dist/utils/index.js +20 -20
- package/dist/utils/local-storage-utils.js +41 -58
- package/package.json +10 -10
- package/public/locales/cs/sdoc-editor.json +3 -1
- package/public/locales/de/sdoc-editor.json +3 -1
- package/public/locales/en/sdoc-editor.json +1 -0
- package/public/locales/es/sdoc-editor.json +3 -1
- package/public/locales/fr/sdoc-editor.json +3 -1
- package/public/locales/it/sdoc-editor.json +3 -1
- package/public/locales/ru/sdoc-editor.json +3 -1
- package/public/locales/zh_CN/sdoc-editor.json +1 -0
|
@@ -1,9 +1,6 @@
|
|
|
1
1
|
import _objectWithoutProperties from "@babel/runtime/helpers/esm/objectWithoutProperties";
|
|
2
|
-
import _toConsumableArray from "@babel/runtime/helpers/esm/toConsumableArray";
|
|
3
|
-
import _createForOfIteratorHelper from "@babel/runtime/helpers/esm/createForOfIteratorHelper";
|
|
4
|
-
import _slicedToArray from "@babel/runtime/helpers/esm/slicedToArray";
|
|
5
2
|
import _objectSpread from "@babel/runtime/helpers/esm/objectSpread2";
|
|
6
|
-
|
|
3
|
+
const _excluded = ["at"];
|
|
7
4
|
import { Editor, Text, Path, Span, Element, Node, Range } from '@seafile/slate';
|
|
8
5
|
import { ReactEditor } from '@seafile/slate-react';
|
|
9
6
|
import { match } from '../utils';
|
|
@@ -11,30 +8,30 @@ import ObjectUtils from '../../../utils/object-utils';
|
|
|
11
8
|
import { CODE_LINE } from '../../constants';
|
|
12
9
|
|
|
13
10
|
// options
|
|
14
|
-
export
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
11
|
+
export const getQueryOptions = (editor, options) => {
|
|
12
|
+
const {
|
|
13
|
+
match: _match,
|
|
14
|
+
block
|
|
15
|
+
} = options;
|
|
16
|
+
let newMatch = undefined;
|
|
18
17
|
if (_match || block) {
|
|
19
|
-
newMatch =
|
|
20
|
-
return match(n, path, _match) && (!block || Editor.isBlock(editor, n));
|
|
21
|
-
};
|
|
18
|
+
newMatch = (n, path) => match(n, path, _match) && (!block || Editor.isBlock(editor, n));
|
|
22
19
|
}
|
|
23
20
|
return _objectSpread(_objectSpread({}, options), {}, {
|
|
24
21
|
match: newMatch
|
|
25
22
|
});
|
|
26
23
|
};
|
|
27
|
-
export
|
|
24
|
+
export const findPath = (editor, node, defaultPath) => {
|
|
28
25
|
try {
|
|
29
26
|
return ReactEditor.findPath(editor, node);
|
|
30
|
-
} catch
|
|
27
|
+
} catch {
|
|
31
28
|
return defaultPath;
|
|
32
29
|
}
|
|
33
30
|
};
|
|
34
31
|
|
|
35
32
|
// get node
|
|
36
|
-
export
|
|
37
|
-
|
|
33
|
+
export const getNode = (editor, path) => {
|
|
34
|
+
let node = null;
|
|
38
35
|
try {
|
|
39
36
|
node = Node.get(editor, path);
|
|
40
37
|
} catch (err) {
|
|
@@ -42,22 +39,22 @@ export var getNode = function getNode(editor, path) {
|
|
|
42
39
|
}
|
|
43
40
|
return node;
|
|
44
41
|
};
|
|
45
|
-
export
|
|
42
|
+
export const getNodeType = node => {
|
|
46
43
|
return Element.isElement(node) ? node.type : '';
|
|
47
44
|
};
|
|
48
|
-
export
|
|
49
|
-
|
|
50
|
-
for (
|
|
51
|
-
|
|
45
|
+
export const getNodeById = (nodes, nodeId) => {
|
|
46
|
+
let node;
|
|
47
|
+
for (let i = 0; i < nodes.length; i++) {
|
|
48
|
+
const currentNode = nodes[i];
|
|
52
49
|
if (currentNode.id === nodeId) {
|
|
53
50
|
node = currentNode;
|
|
54
51
|
break;
|
|
55
52
|
}
|
|
56
|
-
|
|
53
|
+
const {
|
|
54
|
+
children: childrenNodes
|
|
55
|
+
} = currentNode;
|
|
57
56
|
if (!Array.isArray(childrenNodes)) continue;
|
|
58
|
-
|
|
59
|
-
return node.id === nodeId;
|
|
60
|
-
});
|
|
57
|
+
let childNode = childrenNodes.find(node => node.id === nodeId);
|
|
61
58
|
if (childNode) {
|
|
62
59
|
node = childNode;
|
|
63
60
|
break;
|
|
@@ -69,19 +66,19 @@ export var getNodeById = function getNodeById(nodes, nodeId) {
|
|
|
69
66
|
}
|
|
70
67
|
return node;
|
|
71
68
|
};
|
|
72
|
-
export
|
|
69
|
+
export const isTextNode = node => {
|
|
73
70
|
if (!node) return false;
|
|
74
71
|
if (!ObjectUtils.hasProperty(node, 'children') && ObjectUtils.hasProperty(node, 'text')) return true;
|
|
75
72
|
};
|
|
76
|
-
export
|
|
77
|
-
|
|
78
|
-
for (
|
|
79
|
-
|
|
80
|
-
|
|
73
|
+
export const getParentNode = (nodes, nodeId) => {
|
|
74
|
+
let parentNode;
|
|
75
|
+
for (let i = 0; i < nodes.length; i++) {
|
|
76
|
+
const node = nodes[i];
|
|
77
|
+
const {
|
|
78
|
+
children: childrenNodes
|
|
79
|
+
} = node;
|
|
81
80
|
if (!Array.isArray(childrenNodes)) continue;
|
|
82
|
-
if (childrenNodes.find(
|
|
83
|
-
return node.id === nodeId;
|
|
84
|
-
})) {
|
|
81
|
+
if (childrenNodes.find(node => node.id === nodeId)) {
|
|
85
82
|
parentNode = node;
|
|
86
83
|
} else {
|
|
87
84
|
parentNode = getParentNode(childrenNodes, nodeId);
|
|
@@ -91,52 +88,40 @@ export var getParentNode = function getParentNode(nodes, nodeId) {
|
|
|
91
88
|
}
|
|
92
89
|
return parentNode;
|
|
93
90
|
};
|
|
94
|
-
export
|
|
91
|
+
export const getNodes = (node, options) => {
|
|
95
92
|
return Node.nodes(node, options);
|
|
96
93
|
};
|
|
97
|
-
export
|
|
94
|
+
export const getCommonNode = (root, path, ancestor) => {
|
|
98
95
|
return Node.common(root, path, ancestor);
|
|
99
96
|
};
|
|
100
|
-
export
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
universal: true
|
|
107
|
-
}),
|
|
108
|
-
_Editor$nodes2 = _slicedToArray(_Editor$nodes, 1),
|
|
109
|
-
nodeEntry = _Editor$nodes2[0];
|
|
97
|
+
export const getSelectedNodeByType = (editor, type) => {
|
|
98
|
+
const match = n => getNodeType(n) === type;
|
|
99
|
+
const [nodeEntry] = Editor.nodes(editor, {
|
|
100
|
+
match,
|
|
101
|
+
universal: true
|
|
102
|
+
});
|
|
110
103
|
return nodeEntry ? nodeEntry[0] : null;
|
|
111
104
|
};
|
|
112
|
-
export
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
universal: true
|
|
119
|
-
}),
|
|
120
|
-
_Editor$nodes4 = _slicedToArray(_Editor$nodes3, 1),
|
|
121
|
-
nodeEntry = _Editor$nodes4[0];
|
|
105
|
+
export const getSelectedNodeByTypes = (editor, types) => {
|
|
106
|
+
const match = n => types.includes(getNodeType(n));
|
|
107
|
+
const [nodeEntry] = Editor.nodes(editor, {
|
|
108
|
+
match,
|
|
109
|
+
universal: true
|
|
110
|
+
});
|
|
122
111
|
return nodeEntry ? nodeEntry[0] : null;
|
|
123
112
|
};
|
|
124
|
-
export
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
universal: false
|
|
131
|
-
}),
|
|
132
|
-
_Editor$nodes6 = _slicedToArray(_Editor$nodes5, 1),
|
|
133
|
-
nodeEntry = _Editor$nodes6[0];
|
|
113
|
+
export const getSelectedNodeEntryByType = (editor, type) => {
|
|
114
|
+
const match = n => getNodeType(n) === type;
|
|
115
|
+
const [nodeEntry] = Editor.nodes(editor, {
|
|
116
|
+
match,
|
|
117
|
+
universal: false
|
|
118
|
+
});
|
|
134
119
|
return nodeEntry ? nodeEntry : null;
|
|
135
120
|
};
|
|
136
|
-
export
|
|
121
|
+
export const getNodeEntries = (editor, options) => {
|
|
137
122
|
return Editor.nodes(editor, getQueryOptions(editor, options));
|
|
138
123
|
};
|
|
139
|
-
export
|
|
124
|
+
export const getEditorString = (editor, at, options) => {
|
|
140
125
|
if (!at) return '';
|
|
141
126
|
try {
|
|
142
127
|
return Editor.string(editor, at, options);
|
|
@@ -146,98 +131,77 @@ export var getEditorString = function getEditorString(editor, at, options) {
|
|
|
146
131
|
};
|
|
147
132
|
|
|
148
133
|
// children & child
|
|
149
|
-
export
|
|
150
|
-
|
|
151
|
-
node = _nodeEntry[0],
|
|
152
|
-
path = _nodeEntry[1];
|
|
134
|
+
export const getChildren = nodeEntry => {
|
|
135
|
+
const [node, path] = nodeEntry;
|
|
153
136
|
if (Element.isAncestor(node)) {
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
137
|
+
const {
|
|
138
|
+
children
|
|
139
|
+
} = node;
|
|
140
|
+
return children.map((child, index) => {
|
|
141
|
+
const childPath = path.concat([index]);
|
|
157
142
|
return [child, childPath];
|
|
158
143
|
});
|
|
159
144
|
}
|
|
160
145
|
return [];
|
|
161
146
|
};
|
|
162
|
-
export
|
|
163
|
-
|
|
164
|
-
node = _nodeEntry2[0],
|
|
165
|
-
path = _nodeEntry2[1];
|
|
147
|
+
export const getLastChild = nodeEntry => {
|
|
148
|
+
const [node, path] = nodeEntry;
|
|
166
149
|
if (Text.isText(node)) return null;
|
|
167
150
|
if (!node.children.length) return null;
|
|
168
|
-
|
|
151
|
+
const children = node.children;
|
|
169
152
|
return [children[children.length - 1], path.concat([children.length - 1])];
|
|
170
153
|
};
|
|
171
|
-
export
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
} else {
|
|
184
|
-
inlineChildren.push(child);
|
|
185
|
-
}
|
|
154
|
+
export const getDeepInlineChildren = (editor, _ref) => {
|
|
155
|
+
let {
|
|
156
|
+
children
|
|
157
|
+
} = _ref;
|
|
158
|
+
const inlineChildren = [];
|
|
159
|
+
for (let child of children) {
|
|
160
|
+
if (Editor.isBlock(editor, child[0])) {
|
|
161
|
+
inlineChildren.push(...getDeepInlineChildren(editor, {
|
|
162
|
+
children: getChildren(child)
|
|
163
|
+
}));
|
|
164
|
+
} else {
|
|
165
|
+
inlineChildren.push(child);
|
|
186
166
|
}
|
|
187
|
-
} catch (err) {
|
|
188
|
-
_iterator.e(err);
|
|
189
|
-
} finally {
|
|
190
|
-
_iterator.f();
|
|
191
167
|
}
|
|
192
168
|
return inlineChildren;
|
|
193
169
|
};
|
|
194
|
-
export
|
|
195
|
-
|
|
170
|
+
export const getLastChildPath = nodeEntry => {
|
|
171
|
+
const lastChild = getLastChild(nodeEntry);
|
|
196
172
|
if (!lastChild) return nodeEntry[1].concat([-1]);
|
|
197
173
|
return lastChild[1];
|
|
198
174
|
};
|
|
199
|
-
export
|
|
175
|
+
export const getPreviousPath = path => {
|
|
200
176
|
if (path.length === 0) return;
|
|
201
|
-
|
|
177
|
+
const last = path[path.length - 1];
|
|
202
178
|
if (last <= 0) return;
|
|
203
179
|
return path.slice(0, -1).concat(last - 1);
|
|
204
180
|
};
|
|
205
|
-
export
|
|
206
|
-
|
|
181
|
+
export const isLastChild = (nodeEntry, childPath) => {
|
|
182
|
+
const lastChildPath = getLastChildPath(nodeEntry);
|
|
207
183
|
return Path.equals(lastChildPath, childPath);
|
|
208
184
|
};
|
|
209
|
-
export
|
|
210
|
-
|
|
211
|
-
|
|
185
|
+
export const getSelectedElems = editor => {
|
|
186
|
+
const elems = [];
|
|
187
|
+
const nodeEntries = Editor.nodes(editor, {
|
|
212
188
|
universal: true
|
|
213
189
|
});
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
for (_iterator2.s(); !(_step2 = _iterator2.n()).done;) {
|
|
218
|
-
var nodeEntry = _step2.value;
|
|
219
|
-
var _nodeEntry3 = _slicedToArray(nodeEntry, 1),
|
|
220
|
-
node = _nodeEntry3[0];
|
|
221
|
-
if (Element.isElement(node)) elems.push(node);
|
|
222
|
-
}
|
|
223
|
-
} catch (err) {
|
|
224
|
-
_iterator2.e(err);
|
|
225
|
-
} finally {
|
|
226
|
-
_iterator2.f();
|
|
190
|
+
for (let nodeEntry of nodeEntries) {
|
|
191
|
+
const [node] = nodeEntry;
|
|
192
|
+
if (Element.isElement(node)) elems.push(node);
|
|
227
193
|
}
|
|
228
194
|
return elems;
|
|
229
195
|
};
|
|
230
196
|
|
|
231
197
|
// siblings
|
|
232
|
-
export
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
var siblings = [];
|
|
238
|
-
var ancestorChildren = ancestor.children;
|
|
198
|
+
export const getNextSiblingNodes = (ancestorEntry, path) => {
|
|
199
|
+
const [ancestor, ancestorPath] = ancestorEntry;
|
|
200
|
+
const leafIndex = path[ancestorPath.length];
|
|
201
|
+
const siblings = [];
|
|
202
|
+
const ancestorChildren = ancestor.children;
|
|
239
203
|
if (leafIndex + 1 < ancestor.children.length) {
|
|
240
|
-
for (
|
|
204
|
+
for (let i = leafIndex + 1; i < ancestor.children.length; i++) {
|
|
241
205
|
siblings.push(ancestorChildren[i]);
|
|
242
206
|
}
|
|
243
207
|
}
|
|
@@ -245,40 +209,28 @@ export var getNextSiblingNodes = function getNextSiblingNodes(ancestorEntry, pat
|
|
|
245
209
|
};
|
|
246
210
|
|
|
247
211
|
// parent
|
|
248
|
-
export
|
|
212
|
+
export const getAboveNode = (editor, options) => {
|
|
249
213
|
return Editor.above(editor, getQueryOptions(editor, options));
|
|
250
214
|
};
|
|
251
|
-
export
|
|
215
|
+
export const getAboveBlockNode = (editor, options) => {
|
|
252
216
|
return getAboveNode(editor, _objectSpread(_objectSpread({}, options), {}, {
|
|
253
217
|
block: true
|
|
254
218
|
}));
|
|
255
219
|
};
|
|
256
|
-
export
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
var _getAboveNode3 = getAboveNode(editor, {
|
|
267
|
-
mode: 'highest',
|
|
268
|
-
match: function match(n) {
|
|
269
|
-
return Element.isElement(n) && Editor.isBlock(editor, n);
|
|
270
|
-
}
|
|
271
|
-
}),
|
|
272
|
-
_getAboveNode4 = _slicedToArray(_getAboveNode3, 2),
|
|
273
|
-
heightNode = _getAboveNode4[0],
|
|
274
|
-
heightPath = _getAboveNode4[1];
|
|
275
|
-
var prevNode = null;
|
|
220
|
+
export const getPrevNode = editor => {
|
|
221
|
+
const [lowerNode, lowerPath] = getAboveNode(editor, {
|
|
222
|
+
mode: 'lowest',
|
|
223
|
+
match: n => Element.isElement(n) && Editor.isBlock(editor, n)
|
|
224
|
+
});
|
|
225
|
+
const [heightNode, heightPath] = getAboveNode(editor, {
|
|
226
|
+
mode: 'highest',
|
|
227
|
+
match: n => Element.isElement(n) && Editor.isBlock(editor, n)
|
|
228
|
+
});
|
|
229
|
+
let prevNode = null;
|
|
276
230
|
try {
|
|
277
231
|
prevNode = Editor.previous(editor, {
|
|
278
232
|
at: lowerPath,
|
|
279
|
-
match:
|
|
280
|
-
return Element.isElement(n) && Editor.isBlock(editor, n);
|
|
281
|
-
}
|
|
233
|
+
match: n => Element.isElement(n) && Editor.isBlock(editor, n)
|
|
282
234
|
});
|
|
283
235
|
} catch (error) {
|
|
284
236
|
prevNode = null;
|
|
@@ -287,9 +239,7 @@ export var getPrevNode = function getPrevNode(editor) {
|
|
|
287
239
|
try {
|
|
288
240
|
prevNode = Editor.previous(editor, {
|
|
289
241
|
at: heightPath,
|
|
290
|
-
match:
|
|
291
|
-
return Element.isElement(n) && Editor.isBlock(editor, n);
|
|
292
|
-
}
|
|
242
|
+
match: n => Element.isElement(n) && Editor.isBlock(editor, n)
|
|
293
243
|
});
|
|
294
244
|
} catch (error) {
|
|
295
245
|
prevNode = null;
|
|
@@ -297,32 +247,20 @@ export var getPrevNode = function getPrevNode(editor) {
|
|
|
297
247
|
}
|
|
298
248
|
return prevNode;
|
|
299
249
|
};
|
|
300
|
-
export
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
var _getAboveNode7 = getAboveNode(editor, {
|
|
311
|
-
mode: 'highest',
|
|
312
|
-
match: function match(n) {
|
|
313
|
-
return Element.isElement(n) && Editor.isBlock(editor, n);
|
|
314
|
-
}
|
|
315
|
-
}),
|
|
316
|
-
_getAboveNode8 = _slicedToArray(_getAboveNode7, 2),
|
|
317
|
-
heightNode = _getAboveNode8[0],
|
|
318
|
-
heightPath = _getAboveNode8[1];
|
|
319
|
-
var nextNode = null;
|
|
250
|
+
export const getNextNode = editor => {
|
|
251
|
+
const [lowerNode, lowerPath] = getAboveNode(editor, {
|
|
252
|
+
mode: 'lowest',
|
|
253
|
+
match: n => Element.isElement(n) && Editor.isBlock(editor, n)
|
|
254
|
+
});
|
|
255
|
+
const [heightNode, heightPath] = getAboveNode(editor, {
|
|
256
|
+
mode: 'highest',
|
|
257
|
+
match: n => Element.isElement(n) && Editor.isBlock(editor, n)
|
|
258
|
+
});
|
|
259
|
+
let nextNode = null;
|
|
320
260
|
try {
|
|
321
261
|
nextNode = Editor.next(editor, {
|
|
322
262
|
at: lowerPath,
|
|
323
|
-
match:
|
|
324
|
-
return Element.isElement(n) && Editor.isBlock(editor, n);
|
|
325
|
-
}
|
|
263
|
+
match: n => Element.isElement(n) && Editor.isBlock(editor, n)
|
|
326
264
|
});
|
|
327
265
|
} catch (error) {
|
|
328
266
|
nextNode = null;
|
|
@@ -331,9 +269,7 @@ export var getNextNode = function getNextNode(editor) {
|
|
|
331
269
|
try {
|
|
332
270
|
nextNode = Editor.next(editor, {
|
|
333
271
|
at: heightPath,
|
|
334
|
-
match:
|
|
335
|
-
return Element.isElement(n) && Editor.isBlock(editor, n);
|
|
336
|
-
}
|
|
272
|
+
match: n => Element.isElement(n) && Editor.isBlock(editor, n)
|
|
337
273
|
});
|
|
338
274
|
} catch (error) {
|
|
339
275
|
nextNode = null;
|
|
@@ -343,181 +279,145 @@ export var getNextNode = function getNextNode(editor) {
|
|
|
343
279
|
};
|
|
344
280
|
|
|
345
281
|
// find node
|
|
346
|
-
export
|
|
347
|
-
|
|
282
|
+
export const findNode = (editor, options) => {
|
|
283
|
+
const nodeEntries = Editor.nodes(editor, _objectSpread({
|
|
348
284
|
at: editor.selection || []
|
|
349
285
|
}, getQueryOptions(editor, options)));
|
|
350
|
-
|
|
286
|
+
const _nodeEntries = Array.from(nodeEntries);
|
|
351
287
|
if (_nodeEntries[0]) {
|
|
352
288
|
return _nodeEntries[0];
|
|
353
289
|
}
|
|
354
290
|
return undefined;
|
|
355
291
|
};
|
|
356
|
-
export
|
|
357
|
-
|
|
358
|
-
at =
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
_match = options.match;
|
|
292
|
+
export const findDescendant = (editor, options) => {
|
|
293
|
+
const {
|
|
294
|
+
at = editor.selection,
|
|
295
|
+
reverse = false,
|
|
296
|
+
voids = false,
|
|
297
|
+
match: _match
|
|
298
|
+
} = options;
|
|
364
299
|
if (!at) return;
|
|
365
|
-
|
|
366
|
-
|
|
300
|
+
let from;
|
|
301
|
+
let to;
|
|
367
302
|
if (Span.isSpan(at)) {
|
|
368
|
-
|
|
369
|
-
from = _at[0];
|
|
370
|
-
to = _at[1];
|
|
303
|
+
[from, to] = at;
|
|
371
304
|
} else if (Range.isRange(at)) {
|
|
372
|
-
|
|
373
|
-
|
|
305
|
+
const first = Editor.first(editor, at);
|
|
306
|
+
const last = Editor.last(editor, at);
|
|
374
307
|
from = reverse ? last : first;
|
|
375
308
|
to = reverse ? first : last;
|
|
376
309
|
}
|
|
377
|
-
|
|
310
|
+
let root = [editor, []];
|
|
378
311
|
if (Path.isPath(at)) {
|
|
379
312
|
root = Editor.node(editor, at);
|
|
380
313
|
}
|
|
381
|
-
|
|
382
|
-
from
|
|
383
|
-
to
|
|
384
|
-
reverse
|
|
385
|
-
pass:
|
|
386
|
-
|
|
387
|
-
n = _ref3[0];
|
|
314
|
+
const nodeEntries = Node.descendants(root[0], {
|
|
315
|
+
from,
|
|
316
|
+
to,
|
|
317
|
+
reverse,
|
|
318
|
+
pass: _ref2 => {
|
|
319
|
+
let [n] = _ref2;
|
|
388
320
|
return voids ? false : Editor.isVoid(editor, n);
|
|
389
321
|
}
|
|
390
322
|
});
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
for (_iterator3.s(); !(_step3 = _iterator3.n()).done;) {
|
|
395
|
-
var _step3$value = _slicedToArray(_step3.value, 2),
|
|
396
|
-
node = _step3$value[0],
|
|
397
|
-
path = _step3$value[1];
|
|
398
|
-
if (match(node, path, _match)) {
|
|
399
|
-
return [node, at.concat(path)];
|
|
400
|
-
}
|
|
323
|
+
for (const [node, path] of nodeEntries) {
|
|
324
|
+
if (match(node, path, _match)) {
|
|
325
|
+
return [node, at.concat(path)];
|
|
401
326
|
}
|
|
402
|
-
} catch (err) {
|
|
403
|
-
_iterator3.e(err);
|
|
404
|
-
} finally {
|
|
405
|
-
_iterator3.f();
|
|
406
327
|
}
|
|
407
328
|
return undefined;
|
|
408
329
|
};
|
|
409
330
|
|
|
410
331
|
// is
|
|
411
|
-
export
|
|
332
|
+
export const isStartPoint = (editor, point, at) => {
|
|
412
333
|
return !!point && Editor.isStart(editor, point, at);
|
|
413
334
|
};
|
|
414
|
-
export
|
|
335
|
+
export const isEndPoint = (editor, point, at) => {
|
|
415
336
|
return !!point && Editor.isEnd(editor, point, at);
|
|
416
337
|
};
|
|
417
|
-
export
|
|
338
|
+
export const isBlockTextEmptyAfterSelection = editor => {
|
|
418
339
|
if (!editor.selection) return false;
|
|
419
|
-
|
|
340
|
+
const blockAbove = Editor.above(editor, {
|
|
420
341
|
block: true
|
|
421
342
|
});
|
|
422
343
|
if (!blockAbove) return false;
|
|
423
|
-
|
|
424
|
-
|
|
344
|
+
const cursor = editor.selection.focus;
|
|
345
|
+
const selectionParentEntry = Editor.parent(editor, editor.selection);
|
|
425
346
|
if (!selectionParentEntry) return false;
|
|
426
|
-
|
|
427
|
-
selectionParentPath = _selectionParentEntry[1];
|
|
347
|
+
const [, selectionParentPath] = selectionParentEntry;
|
|
428
348
|
if (!isEndPoint(editor, cursor, selectionParentPath)) return false;
|
|
429
|
-
|
|
349
|
+
const siblingNodes = getNextSiblingNodes(blockAbove, cursor.path);
|
|
430
350
|
if (siblingNodes.length) {
|
|
431
351
|
// 子节点包含 文本节点
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
for (_iterator4.s(); !(_step4 = _iterator4.n()).done;) {
|
|
436
|
-
var siblingNode = _step4.value;
|
|
437
|
-
if (Text.isText(siblingNode) && siblingNode.text) {
|
|
438
|
-
return false;
|
|
439
|
-
}
|
|
352
|
+
for (const siblingNode of siblingNodes) {
|
|
353
|
+
if (Text.isText(siblingNode) && siblingNode.text) {
|
|
354
|
+
return false;
|
|
440
355
|
}
|
|
441
|
-
} catch (err) {
|
|
442
|
-
_iterator4.e(err);
|
|
443
|
-
} finally {
|
|
444
|
-
_iterator4.f();
|
|
445
356
|
}
|
|
446
357
|
} else {
|
|
447
358
|
return isEndPoint(editor, cursor, blockAbove[1]);
|
|
448
359
|
}
|
|
449
360
|
return true;
|
|
450
361
|
};
|
|
451
|
-
export
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
362
|
+
export const isRangeAcrossBlocks = function (editor) {
|
|
363
|
+
let _ref3 = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
364
|
+
let {
|
|
365
|
+
at
|
|
366
|
+
} = _ref3,
|
|
367
|
+
options = _objectWithoutProperties(_ref3, _excluded);
|
|
455
368
|
if (!at) at = editor.selection;
|
|
456
369
|
if (!at) return;
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
start = _Range$edges2[0],
|
|
460
|
-
end = _Range$edges2[1];
|
|
461
|
-
var startBlock = getAboveBlockNode(editor, _objectSpread({
|
|
370
|
+
const [start, end] = Range.edges(at);
|
|
371
|
+
const startBlock = getAboveBlockNode(editor, _objectSpread({
|
|
462
372
|
at: start
|
|
463
373
|
}, options));
|
|
464
|
-
|
|
374
|
+
const endBlock = getAboveBlockNode(editor, _objectSpread({
|
|
465
375
|
at: end
|
|
466
376
|
}, options));
|
|
467
377
|
if (!startBlock && !endBlock) return;
|
|
468
378
|
if (!startBlock || !endBlock) return true;
|
|
469
379
|
return !Path.equals(startBlock[1], endBlock[1]);
|
|
470
380
|
};
|
|
471
|
-
export
|
|
472
|
-
return !Node.string(node) && !node.children.some(
|
|
473
|
-
return Editor.isInline(editor, n);
|
|
474
|
-
});
|
|
381
|
+
export const isAncestorEmpty = (editor, node) => {
|
|
382
|
+
return !Node.string(node) && !node.children.some(n => Editor.isInline(editor, n));
|
|
475
383
|
};
|
|
476
|
-
export
|
|
384
|
+
export const isBlockAboveEmpty = editor => {
|
|
477
385
|
var _getAboveBlockNode;
|
|
478
|
-
|
|
386
|
+
const block = (_getAboveBlockNode = getAboveBlockNode(editor)) === null || _getAboveBlockNode === void 0 ? void 0 : _getAboveBlockNode[0];
|
|
479
387
|
if (!block) return false;
|
|
480
388
|
return isAncestorEmpty(editor, block);
|
|
481
389
|
};
|
|
482
|
-
export
|
|
483
|
-
|
|
390
|
+
export const isSelectionAtBlockStart = (editor, options) => {
|
|
391
|
+
const {
|
|
392
|
+
selection
|
|
393
|
+
} = editor;
|
|
484
394
|
if (!selection) return false;
|
|
485
|
-
|
|
486
|
-
|
|
395
|
+
const nodeEntry = getAboveBlockNode(editor, options);
|
|
396
|
+
let path = nodeEntry === null || nodeEntry === void 0 ? void 0 : nodeEntry[1];
|
|
487
397
|
if ((nodeEntry === null || nodeEntry === void 0 ? void 0 : nodeEntry[0].type) === CODE_LINE) {
|
|
488
398
|
path = [path[0]];
|
|
489
399
|
}
|
|
490
400
|
if (!path) return false;
|
|
491
401
|
return isStartPoint(editor, selection.focus, path) || Range.isExpanded(editor.selection) && isStartPoint(editor, selection.anchor, path);
|
|
492
402
|
};
|
|
493
|
-
export
|
|
403
|
+
export const isSelectionAtBlockEnd = (editor, options) => {
|
|
494
404
|
var _getAboveBlockNode2, _editor$selection;
|
|
495
|
-
|
|
405
|
+
const path = (_getAboveBlockNode2 = getAboveBlockNode(editor, options)) === null || _getAboveBlockNode2 === void 0 ? void 0 : _getAboveBlockNode2[1];
|
|
496
406
|
return !!path && isEndPoint(editor, (_editor$selection = editor.selection) === null || _editor$selection === void 0 ? void 0 : _editor$selection.focus, path);
|
|
497
407
|
};
|
|
498
|
-
export
|
|
499
|
-
|
|
500
|
-
|
|
408
|
+
export const isLastNode = (editor, node) => {
|
|
409
|
+
const editorChildren = editor.children || [];
|
|
410
|
+
const editorChildrenLength = editorChildren.length;
|
|
501
411
|
return editorChildren[editorChildrenLength - 1] === node;
|
|
502
412
|
};
|
|
503
|
-
export
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
for (_iterator5.s(); !(_step5 = _iterator5.n()).done;) {
|
|
511
|
-
var _step5$value = _slicedToArray(_step5.value, 1),
|
|
512
|
-
node = _step5$value[0];
|
|
513
|
-
if ((node === null || node === void 0 ? void 0 : node.type) === 'image') {
|
|
514
|
-
hasImg = true;
|
|
515
|
-
}
|
|
413
|
+
export const isHasImg = editor => {
|
|
414
|
+
let hasImg = false;
|
|
415
|
+
for (const [node] of Editor.nodes(editor, {
|
|
416
|
+
at: editor.selection
|
|
417
|
+
})) {
|
|
418
|
+
if ((node === null || node === void 0 ? void 0 : node.type) === 'image') {
|
|
419
|
+
hasImg = true;
|
|
516
420
|
}
|
|
517
|
-
} catch (err) {
|
|
518
|
-
_iterator5.e(err);
|
|
519
|
-
} finally {
|
|
520
|
-
_iterator5.f();
|
|
521
421
|
}
|
|
522
422
|
return hasImg;
|
|
523
423
|
};
|