@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,6 +1,3 @@
|
|
|
1
|
-
import _toConsumableArray from "@babel/runtime/helpers/esm/toConsumableArray";
|
|
2
|
-
import _createClass from "@babel/runtime/helpers/esm/createClass";
|
|
3
|
-
import _classCallCheck from "@babel/runtime/helpers/esm/classCallCheck";
|
|
4
1
|
var _class;
|
|
5
2
|
import EventBus from '../utils/event-bus';
|
|
6
3
|
import { syncRemoteOperations, reExecRevertOperationList, revertOperationList, syncRemoteCursorLocation } from './helpers';
|
|
@@ -13,326 +10,348 @@ import { EXTERNAL_EVENT } from '../../constants';
|
|
|
13
10
|
// --> conflict --> idle
|
|
14
11
|
// --> disconnect --> conflict --> idle
|
|
15
12
|
// --> idle
|
|
16
|
-
|
|
13
|
+
const STATE = {
|
|
17
14
|
IDLE: 'idle',
|
|
18
15
|
SENDING: 'sending',
|
|
19
16
|
CONFLICT: 'conflict',
|
|
20
17
|
DISCONNECT: 'disconnect',
|
|
21
18
|
NEED_RELOAD: 'need_reload'
|
|
22
19
|
};
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
20
|
+
class SocketManager {
|
|
21
|
+
constructor(editor, _document, config) {
|
|
22
|
+
this.getDocumentVersion = () => {
|
|
23
|
+
const {
|
|
24
|
+
version
|
|
25
|
+
} = this.document;
|
|
26
|
+
return version;
|
|
27
|
+
};
|
|
28
|
+
this.updateDocumentVersion = document => {
|
|
29
|
+
this.document['version'] = document.version;
|
|
30
|
+
};
|
|
31
|
+
this.receivePublishDocument = () => {
|
|
32
|
+
this.eventBus.dispatch(EXTERNAL_EVENT.PUBLISH_DOCUMENT);
|
|
33
|
+
};
|
|
34
|
+
this.receivePublishDocumentError = () => {
|
|
35
|
+
this.eventBus.dispatch(EXTERNAL_EVENT.PUBLISH_DOCUMENT_ERROR);
|
|
36
|
+
};
|
|
37
|
+
this.receiveRemoveDocument = () => {
|
|
38
|
+
this.eventBus.dispatch(EXTERNAL_EVENT.REMOVE_DOCUMENT);
|
|
39
|
+
};
|
|
40
|
+
this.receiveRemoveDocumentError = () => {
|
|
41
|
+
this.eventBus.dispatch(EXTERNAL_EVENT.REMOVE_DOCUMENT_ERROR);
|
|
42
|
+
};
|
|
43
|
+
this.receiveDocumentReplaced = () => {
|
|
44
|
+
this.eventBus.dispatch(EXTERNAL_EVENT.DOCUMENT_REPLACED);
|
|
45
|
+
};
|
|
46
|
+
this.receiveDocumentReplacedError = () => {
|
|
47
|
+
this.eventBus.dispatch(EXTERNAL_EVENT.DOCUMENT_REPLACED_ERROR);
|
|
48
|
+
};
|
|
49
|
+
this.receiveNewNotification = notification => {
|
|
50
|
+
this.eventBus.dispatch(EXTERNAL_EVENT.NEW_NOTIFICATION, notification);
|
|
51
|
+
};
|
|
52
|
+
this.onReceiveLocalOperations = operations => {
|
|
53
|
+
this.pendingOperationList.push(operations);
|
|
54
|
+
const lastOpBeginTime = new Date().getTime();
|
|
55
|
+
this.pendingOperationBeginTimeList.push(lastOpBeginTime);
|
|
56
|
+
const firstOpBeginTime = this.pendingOperationBeginTimeList[0];
|
|
57
|
+
const isExceedExecuteTime = (lastOpBeginTime - firstOpBeginTime) / 1000 > 30 ? true : false;
|
|
58
|
+
if (isExceedExecuteTime || this.pendingOperationList.length > 50) {
|
|
59
|
+
this.dispatchConnectState('pending_operations_exceed_limit');
|
|
60
|
+
}
|
|
61
|
+
this.sendOperations();
|
|
62
|
+
};
|
|
63
|
+
this.sendOperations = () => {
|
|
64
|
+
if (this.state !== STATE.IDLE) return;
|
|
65
|
+
stateDebug("State changed: ".concat(this.state, " -> ").concat(STATE.SENDING));
|
|
66
|
+
this.state = STATE.SENDING;
|
|
67
|
+
this.sendNextOperations();
|
|
68
|
+
};
|
|
69
|
+
this.sendNextOperations = () => {
|
|
70
|
+
if (this.state !== STATE.SENDING) return;
|
|
71
|
+
if (this.pendingOperationList.length === 0) {
|
|
72
|
+
stateDebug("State Changed: ".concat(this.state, " -> ").concat(STATE.IDLE));
|
|
73
|
+
this.state = STATE.IDLE;
|
|
74
|
+
return;
|
|
75
|
+
}
|
|
76
|
+
this.dispatchConnectState('is-saving');
|
|
77
|
+
const version = this.document.version;
|
|
78
|
+
const operations = this.pendingOperationList.shift();
|
|
79
|
+
const selection = this.editor.selection;
|
|
80
|
+
this._sendingOperations = operations;
|
|
81
|
+
this.socketClient.sendOperations(operations, version, selection, this.sendOperationsCallback);
|
|
82
|
+
};
|
|
83
|
+
this.sendOperationsCallback = result => {
|
|
84
|
+
if (result && result.success) {
|
|
85
|
+
const {
|
|
86
|
+
version: serverVersion
|
|
87
|
+
} = result;
|
|
88
|
+
this.document['version'] = serverVersion;
|
|
89
|
+
const lastSavedAt = new Date().getTime();
|
|
90
|
+
this.dispatchConnectState('saved', lastSavedAt);
|
|
91
91
|
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
92
|
+
// send next operations
|
|
93
|
+
this.pendingOperationBeginTimeList.shift(); // remove current operation's begin time
|
|
94
|
+
this._sendingOperations = null;
|
|
95
|
+
this.sendNextOperations();
|
|
96
|
+
return;
|
|
97
|
+
}
|
|
98
98
|
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
99
|
+
// Operations are execute failure
|
|
100
|
+
const {
|
|
101
|
+
error_type
|
|
102
|
+
} = result;
|
|
103
|
+
if (error_type === 'load_document_content_error' || error_type === 'save_operations_to_database_error') {
|
|
104
|
+
// load_document_content_error: After a short-term reconnection, the content of the document fails to load
|
|
105
|
+
// save_operation_to_database_error: Save operation to database error
|
|
106
|
+
this.dispatchConnectState(error_type);
|
|
105
107
|
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
108
|
+
// reset sending control
|
|
109
|
+
stateDebug("State Changed: ".concat(this.state, " -> ").concat(STATE.NEED_RELOAD));
|
|
110
|
+
this.state = STATE.NEED_RELOAD;
|
|
111
|
+
this._sendingOperations = null;
|
|
112
|
+
} else if (error_type === 'version_behind_server') {
|
|
113
|
+
// Put the failed operation into the pending list and re-execute it
|
|
114
|
+
this.pendingOperationList.unshift([...this._sendingOperations]);
|
|
115
|
+
stateDebug("State Changed: ".concat(this.state, " -> ").concat(STATE.CONFLICT));
|
|
116
|
+
this.state = STATE.CONFLICT;
|
|
117
|
+
const {
|
|
118
|
+
lose_operations
|
|
119
|
+
} = result;
|
|
120
|
+
this.resolveConflicting(lose_operations);
|
|
121
|
+
} else if (error_type === 'execute_client_operations_error') {
|
|
122
|
+
this.editor.isRemote = true;
|
|
123
|
+
const dupSendingOperations = [...this._sendingOperations];
|
|
124
|
+
revertOperationList(this.editor, [dupSendingOperations]);
|
|
121
125
|
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
126
|
+
// Update the save time after revert
|
|
127
|
+
const lastSavedAt = new Date().getTime();
|
|
128
|
+
this.dispatchConnectState('saved', lastSavedAt);
|
|
125
129
|
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
+
// Set isRemote to false must be in Promise.resolve function, make sure the modification of isRemote is later than the onChange event
|
|
131
|
+
Promise.resolve().then(_ => {
|
|
132
|
+
this.editor.isRemote = false;
|
|
133
|
+
this.dispatchConnectState(error_type);
|
|
130
134
|
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
135
|
+
// send next operations
|
|
136
|
+
this._sendingOperations = null;
|
|
137
|
+
this.sendNextOperations();
|
|
138
|
+
});
|
|
139
|
+
}
|
|
140
|
+
};
|
|
141
|
+
this.onReceiveRemoteOperations = params => {
|
|
142
|
+
// if this.disconnect is true, Then the message sent by the remote end cannot be received
|
|
143
|
+
if (this.state !== STATE.IDLE) return;
|
|
144
|
+
const {
|
|
145
|
+
version: serverVersion
|
|
146
|
+
} = params;
|
|
147
|
+
const {
|
|
148
|
+
version: clientVersion
|
|
149
|
+
} = this.document;
|
|
150
|
+
if (serverVersion === clientVersion + 1) {
|
|
151
|
+
// update execute remote operations flag
|
|
152
|
+
this.editor.isRemote = true;
|
|
153
|
+
const {
|
|
154
|
+
operations
|
|
155
|
+
} = params;
|
|
156
|
+
// Update content & version
|
|
157
|
+
serverDebug('execute remote operations: %O', operations);
|
|
158
|
+
try {
|
|
159
|
+
syncRemoteOperations(this.editor, operations);
|
|
160
|
+
} catch (error) {
|
|
161
|
+
stateDebug("State Changed: ".concat(this.state, " -> ").concat(STATE.CONFLICT));
|
|
162
|
+
this.state = STATE.CONFLICT;
|
|
163
|
+
this.dispatchConnectState('sync_server_operations_error');
|
|
164
|
+
return;
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
// Update document
|
|
168
|
+
this.document.version = serverVersion;
|
|
169
|
+
this.document.children = this.editor.children;
|
|
170
|
+
Promise.resolve().then(() => {
|
|
171
|
+
this.editor.isRemote = false;
|
|
172
|
+
this.revertOperationList = [];
|
|
173
|
+
});
|
|
174
|
+
} else {
|
|
175
|
+
// isConflict
|
|
176
|
+
this.onConflictHappen();
|
|
177
|
+
}
|
|
178
|
+
};
|
|
179
|
+
this.onReconnect = result => {
|
|
180
|
+
const {
|
|
181
|
+
version: serverVersion
|
|
182
|
+
} = result;
|
|
183
|
+
const clientVersion = this.getDocumentVersion();
|
|
184
|
+
// The client version is inconsistent with the server version, and the latest operations performed by the server need to be loaded
|
|
185
|
+
if (serverVersion !== clientVersion) {
|
|
186
|
+
this.onConflictHappen();
|
|
154
187
|
return;
|
|
155
188
|
}
|
|
156
189
|
|
|
157
|
-
//
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
190
|
+
// The version consistency indicates that there is no conflict and no processing is required
|
|
191
|
+
stateDebug("State Changed: ".concat(this.state, " -> ").concat(STATE.IDLE));
|
|
192
|
+
this.state = STATE.IDLE;
|
|
193
|
+
if (this.pendingOperationList.length > 0) {
|
|
194
|
+
clientDebug('After reconnection, manually trigger the execution of ops.');
|
|
195
|
+
stateDebug("State Changed: ".concat(this.state, " -> ").concat(STATE.SENDING));
|
|
196
|
+
this.state = STATE.SENDING;
|
|
197
|
+
this.sendNextOperations();
|
|
198
|
+
}
|
|
199
|
+
};
|
|
200
|
+
this.onConflictHappen = () => {
|
|
201
|
+
stateDebug("State Changed: ".concat(this.state, " -> ").concat(STATE.CONFLICT));
|
|
202
|
+
this.state = STATE.CONFLICT;
|
|
203
|
+
this.socketClient.getRecentOperations();
|
|
204
|
+
};
|
|
205
|
+
this.onGetRecentOperations = result => {
|
|
206
|
+
const {
|
|
207
|
+
mode,
|
|
208
|
+
content
|
|
209
|
+
} = result;
|
|
210
|
+
conflictDebug('Start conflict resolution');
|
|
211
|
+
// sync document
|
|
212
|
+
if (mode === 'document') {
|
|
213
|
+
const {
|
|
214
|
+
version,
|
|
215
|
+
children
|
|
216
|
+
} = content;
|
|
217
|
+
// 1. update document
|
|
218
|
+
conflictDebug('Update local document to remote document');
|
|
219
|
+
this.document.children = children;
|
|
220
|
+
this.document.version = version;
|
|
221
|
+
this.editor.children = children;
|
|
222
|
+
this.editor.isRemote = true;
|
|
223
|
+
this.editor.onChange();
|
|
224
|
+
stateDebug("State Changed: ".concat(this.state, " -> ").concat(STATE.IDLE));
|
|
225
|
+
this.editor.isRemote = false;
|
|
226
|
+
this.state = STATE.IDLE;
|
|
227
|
+
this._sendingOperations = null;
|
|
177
228
|
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
if (_this.pendingOperationList.length > 0) {
|
|
182
|
-
clientDebug('After reconnection, manually trigger the execution of ops.');
|
|
183
|
-
stateDebug("State Changed: ".concat(_this.state, " -> ").concat(STATE.SENDING));
|
|
184
|
-
_this.state = STATE.SENDING;
|
|
185
|
-
_this.sendNextOperations();
|
|
186
|
-
}
|
|
187
|
-
};
|
|
188
|
-
this.onConflictHappen = function () {
|
|
189
|
-
stateDebug("State Changed: ".concat(_this.state, " -> ").concat(STATE.CONFLICT));
|
|
190
|
-
_this.state = STATE.CONFLICT;
|
|
191
|
-
_this.socketClient.getRecentOperations();
|
|
192
|
-
};
|
|
193
|
-
this.onGetRecentOperations = function (result) {
|
|
194
|
-
var mode = result.mode,
|
|
195
|
-
content = result.content;
|
|
196
|
-
conflictDebug('Start conflict resolution');
|
|
197
|
-
// sync document
|
|
198
|
-
if (mode === 'document') {
|
|
199
|
-
var version = content.version,
|
|
200
|
-
children = content.children;
|
|
201
|
-
// 1. update document
|
|
202
|
-
conflictDebug('Update local document to remote document');
|
|
203
|
-
_this.document.children = children;
|
|
204
|
-
_this.document.version = version;
|
|
205
|
-
_this.editor.children = children;
|
|
206
|
-
_this.editor.isRemote = true;
|
|
207
|
-
_this.editor.onChange();
|
|
208
|
-
stateDebug("State Changed: ".concat(_this.state, " -> ").concat(STATE.IDLE));
|
|
209
|
-
_this.editor.isRemote = false;
|
|
210
|
-
_this.state = STATE.IDLE;
|
|
211
|
-
_this._sendingOperations = null;
|
|
229
|
+
// 2. exec client operationList
|
|
230
|
+
const pendingOperationList = this.pendingOperationList.slice();
|
|
231
|
+
this.pendingOperationList = [];
|
|
212
232
|
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
233
|
+
// need resend this operations to server
|
|
234
|
+
conflictDebug('Re-execute local unsynchronized operations: %o', pendingOperationList);
|
|
235
|
+
reExecRevertOperationList(this.editor, pendingOperationList);
|
|
236
|
+
return;
|
|
237
|
+
}
|
|
216
238
|
|
|
217
|
-
//
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
}
|
|
239
|
+
// mode os operations: sync operations
|
|
240
|
+
// content is [{version, operations}, {version, operations}, ...]
|
|
241
|
+
const loseOperations = content;
|
|
242
|
+
this.resolveConflicting(loseOperations);
|
|
243
|
+
};
|
|
244
|
+
this.resolveConflicting = loseOperations => {
|
|
245
|
+
conflictDebug('resolve conflicts');
|
|
246
|
+
this.editor.isRemote = true;
|
|
247
|
+
if (this.pendingOperationList.length !== 0) {
|
|
248
|
+
// 1. Revert operations
|
|
249
|
+
// 1.1 record reverted operationList & clear pendingOperationList
|
|
250
|
+
this.revertOperationList = this.pendingOperationList.slice();
|
|
251
|
+
this.pendingOperationList = [];
|
|
222
252
|
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
253
|
+
// 1.2 Revert operationList
|
|
254
|
+
conflictDebug('revert locale operations: %O', this.revertOperationList);
|
|
255
|
+
revertOperationList(this.editor, this.revertOperationList);
|
|
256
|
+
}
|
|
257
|
+
loseOperations = loseOperations.sort((prev, next) => prev.version - next.version);
|
|
258
|
+
conflictDebug('lose operations length: %s', loseOperations.length);
|
|
259
|
+
while (loseOperations.length > 0) {
|
|
260
|
+
const operationParams = loseOperations.shift();
|
|
261
|
+
// 2. execute operations
|
|
262
|
+
const {
|
|
263
|
+
operations,
|
|
264
|
+
version: serverVersion
|
|
265
|
+
} = operationParams;
|
|
266
|
+
// 2.1 Update content & version
|
|
267
|
+
conflictDebug('execute lose operations: %O', operations);
|
|
268
|
+
try {
|
|
269
|
+
syncRemoteOperations(this.editor, operations);
|
|
270
|
+
} catch (error) {
|
|
271
|
+
stateDebug("State Changed: ".concat(this.state, " -> ").concat(STATE.CONFLICT));
|
|
272
|
+
this.state = STATE.CONFLICT;
|
|
273
|
+
this.dispatchConnectState('sync_server_operations_error');
|
|
274
|
+
return;
|
|
275
|
+
}
|
|
236
276
|
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
serverVersion = operationParams.version;
|
|
250
|
-
// 2.1 Update content & version
|
|
251
|
-
conflictDebug('execute lose operations: %O', operations);
|
|
252
|
-
try {
|
|
253
|
-
syncRemoteOperations(_this.editor, operations);
|
|
254
|
-
} catch (error) {
|
|
255
|
-
stateDebug("State Changed: ".concat(_this.state, " -> ").concat(STATE.CONFLICT));
|
|
256
|
-
_this.state = STATE.CONFLICT;
|
|
257
|
-
_this.dispatchConnectState('sync_server_operations_error');
|
|
277
|
+
// 2.2 Update document
|
|
278
|
+
this.document.version = serverVersion;
|
|
279
|
+
this.document.children = this.editor.children;
|
|
280
|
+
}
|
|
281
|
+
if (this.revertOperationList.length === 0) {
|
|
282
|
+
Promise.resolve().then(() => {
|
|
283
|
+
this.editor.isRemote = false;
|
|
284
|
+
stateDebug("State Changed: ".concat(this.state, " -> ").concat(STATE.IDLE));
|
|
285
|
+
this.state = STATE.IDLE;
|
|
286
|
+
this._sendingOperations = null;
|
|
287
|
+
this.revertOperationList = [];
|
|
288
|
+
});
|
|
258
289
|
return;
|
|
259
290
|
}
|
|
260
291
|
|
|
261
|
-
//
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
stateDebug("State Changed: ".concat(_this.state, " -> ").concat(STATE.IDLE));
|
|
269
|
-
_this.state = STATE.IDLE;
|
|
270
|
-
_this._sendingOperations = null;
|
|
271
|
-
_this.revertOperationList = [];
|
|
272
|
-
});
|
|
273
|
-
return;
|
|
274
|
-
}
|
|
275
|
-
|
|
276
|
-
// Set isRemote to false must be in Promise.resolve function, make sure the modification of isRemote is later than the onChange event
|
|
277
|
-
Promise.resolve().then(function () {
|
|
278
|
-
// reset execute remote operations flag
|
|
279
|
-
_this.editor.isRemote = false;
|
|
280
|
-
stateDebug("State Changed: ".concat(_this.state, " -> ").concat(STATE.IDLE));
|
|
281
|
-
_this.state = STATE.IDLE;
|
|
282
|
-
_this._sendingOperations = null;
|
|
292
|
+
// Set isRemote to false must be in Promise.resolve function, make sure the modification of isRemote is later than the onChange event
|
|
293
|
+
Promise.resolve().then(() => {
|
|
294
|
+
// reset execute remote operations flag
|
|
295
|
+
this.editor.isRemote = false;
|
|
296
|
+
stateDebug("State Changed: ".concat(this.state, " -> ").concat(STATE.IDLE));
|
|
297
|
+
this.state = STATE.IDLE;
|
|
298
|
+
this._sendingOperations = null;
|
|
283
299
|
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
300
|
+
// 3. Execute pending operations
|
|
301
|
+
// 3.1 Re-execute operations
|
|
302
|
+
conflictDebug('Editor isRemote is false: %s', this.editor.isRemote);
|
|
303
|
+
conflictDebug('Re-execute pending operations, %O', this.revertOperationList);
|
|
304
|
+
reExecRevertOperationList(this.editor, this.revertOperationList);
|
|
289
305
|
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
if (
|
|
313
|
-
|
|
314
|
-
|
|
306
|
+
// 3.2 Clear revert operationList
|
|
307
|
+
this.revertOperationList = [];
|
|
308
|
+
conflictDebug('Complete conflict resolution');
|
|
309
|
+
});
|
|
310
|
+
};
|
|
311
|
+
this.sendCursorLocation = location => {
|
|
312
|
+
this.socketClient.sendCursorLocation(location);
|
|
313
|
+
};
|
|
314
|
+
this.receiveCursorLocation = params => {
|
|
315
|
+
const {
|
|
316
|
+
user,
|
|
317
|
+
location,
|
|
318
|
+
cursor_data: cursorData
|
|
319
|
+
} = params;
|
|
320
|
+
syncRemoteCursorLocation(this.editor, user, location, cursorData);
|
|
321
|
+
return;
|
|
322
|
+
};
|
|
323
|
+
this.dispatchConnectState = (type, message) => {
|
|
324
|
+
if (type === 'leave-room') {
|
|
325
|
+
deleteCursor(this.editor, message);
|
|
326
|
+
this.editor.onCursor && this.editor.onCursor(this.editor.cursors);
|
|
327
|
+
}
|
|
328
|
+
if (type === 'disconnect') {
|
|
329
|
+
// current state is sending
|
|
330
|
+
if (this._sendingOperations) {
|
|
331
|
+
this.pendingOperationList.unshift(this._sendingOperations.slice());
|
|
332
|
+
this._sendingOperations = null;
|
|
333
|
+
}
|
|
334
|
+
stateDebug("State Changed: ".concat(this.state, " -> ").concat(STATE.DISCONNECT));
|
|
335
|
+
this.state = STATE.DISCONNECT;
|
|
315
336
|
}
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
this.state = STATE.IDLE;
|
|
333
|
-
});
|
|
337
|
+
this.eventBus.dispatch(type, message);
|
|
338
|
+
};
|
|
339
|
+
this.closeSocketConnect = () => {
|
|
340
|
+
this.socketClient.disconnectWithServer();
|
|
341
|
+
};
|
|
342
|
+
this.editor = editor;
|
|
343
|
+
this.document = _document;
|
|
344
|
+
this.socketClient = new SocketClient(config);
|
|
345
|
+
this.pendingOperationList = []; // Two-dimensional arrays: [operations, operations, ...]
|
|
346
|
+
this.pendingOperationBeginTimeList = [];
|
|
347
|
+
this.remoteOperationsList = []; // Same with pending operations
|
|
348
|
+
this.revertOperationList = [];
|
|
349
|
+
this.eventBus = EventBus.getInstance();
|
|
350
|
+
this.state = STATE.IDLE;
|
|
351
|
+
}
|
|
352
|
+
}
|
|
334
353
|
_class = SocketManager;
|
|
335
|
-
SocketManager.getInstance =
|
|
354
|
+
SocketManager.getInstance = (editor, document, socketConfig) => {
|
|
336
355
|
if (_class.instance) {
|
|
337
356
|
return _class.instance;
|
|
338
357
|
}
|
|
@@ -342,7 +361,7 @@ SocketManager.getInstance = function (editor, document, socketConfig) {
|
|
|
342
361
|
_class.instance = new _class(editor, document, socketConfig);
|
|
343
362
|
return _class.instance;
|
|
344
363
|
};
|
|
345
|
-
SocketManager.destroy =
|
|
364
|
+
SocketManager.destroy = () => {
|
|
346
365
|
_class.instance = null;
|
|
347
366
|
};
|
|
348
367
|
export default SocketManager;
|