@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,55 +1,63 @@
|
|
|
1
1
|
import { generateCursorData } from '../cursor/helper';
|
|
2
2
|
import EventBus from '../utils/event-bus';
|
|
3
3
|
import SocketManager from './socket-manager';
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
4
|
+
const withSocketIO = (editor, options) => {
|
|
5
|
+
const {
|
|
6
|
+
onChange
|
|
7
|
+
} = editor;
|
|
8
|
+
const newEditor = editor;
|
|
9
|
+
let socketManager = null;
|
|
10
|
+
const {
|
|
11
|
+
user
|
|
12
|
+
} = options.config;
|
|
9
13
|
newEditor.user = user;
|
|
10
|
-
newEditor.openConnection =
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
+
newEditor.openConnection = () => {
|
|
15
|
+
const {
|
|
16
|
+
document,
|
|
17
|
+
config
|
|
18
|
+
} = options;
|
|
19
|
+
const cursorData = generateCursorData(options.config);
|
|
14
20
|
config['cursorData'] = cursorData;
|
|
15
21
|
socketManager = SocketManager.getInstance(newEditor, document, config);
|
|
16
22
|
};
|
|
17
|
-
newEditor.closeConnection =
|
|
23
|
+
newEditor.closeConnection = () => {
|
|
18
24
|
socketManager && socketManager.closeSocketConnect();
|
|
19
25
|
SocketManager.destroy();
|
|
20
26
|
};
|
|
21
|
-
newEditor.onChange =
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
27
|
+
newEditor.onChange = () => {
|
|
28
|
+
const {
|
|
29
|
+
document,
|
|
30
|
+
config
|
|
31
|
+
} = options;
|
|
32
|
+
let operations = newEditor.operations;
|
|
25
33
|
if (!newEditor.isRemote && operations.length > 0) {
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
});
|
|
29
|
-
var _socketManager = SocketManager.getInstance(newEditor, document, config);
|
|
34
|
+
const isAllSetSelection = operations.every(operation => operation.type === 'set_selection');
|
|
35
|
+
const socketManager = SocketManager.getInstance(newEditor, document, config);
|
|
30
36
|
if (!isAllSetSelection) {
|
|
31
37
|
// get update content value operations
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
});
|
|
35
|
-
_socketManager.onReceiveLocalOperations(updateOperations);
|
|
38
|
+
const updateOperations = operations.filter(operation => operation.type !== 'set_selection');
|
|
39
|
+
socketManager.onReceiveLocalOperations(updateOperations);
|
|
36
40
|
}
|
|
37
|
-
|
|
41
|
+
socketManager.sendCursorLocation(editor.selection);
|
|
38
42
|
}
|
|
39
43
|
|
|
40
44
|
// dispatch editor change event
|
|
41
|
-
|
|
45
|
+
const eventBus = EventBus.getInstance(newEditor, document, config);
|
|
42
46
|
eventBus.dispatch('change');
|
|
43
47
|
onChange();
|
|
44
48
|
};
|
|
45
|
-
newEditor.rebaseContent =
|
|
46
|
-
|
|
47
|
-
|
|
49
|
+
newEditor.rebaseContent = (document, originFileVersion) => {
|
|
50
|
+
const {
|
|
51
|
+
config
|
|
52
|
+
} = options;
|
|
53
|
+
const socketManager = SocketManager.getInstance(newEditor, document, config);
|
|
48
54
|
socketManager.sendRebaseContent(document, originFileVersion);
|
|
49
55
|
};
|
|
50
|
-
newEditor.updateDocumentVersion =
|
|
51
|
-
|
|
52
|
-
|
|
56
|
+
newEditor.updateDocumentVersion = document => {
|
|
57
|
+
const {
|
|
58
|
+
config
|
|
59
|
+
} = options;
|
|
60
|
+
const socketManager = SocketManager.getInstance(newEditor, document, config);
|
|
53
61
|
socketManager.updateDocumentVersion(document);
|
|
54
62
|
};
|
|
55
63
|
return newEditor;
|
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
import Debug from 'debug';
|
|
2
|
-
|
|
2
|
+
const stateDebug = Debug('sdoc:state-change');
|
|
3
3
|
stateDebug.enabled = true;
|
|
4
4
|
stateDebug.log = console.log;
|
|
5
|
-
|
|
5
|
+
const clientDebug = Debug('sdoc:socket-client');
|
|
6
6
|
clientDebug.enabled = true;
|
|
7
7
|
clientDebug.log = console.log;
|
|
8
|
-
|
|
8
|
+
const serverDebug = Debug('sdoc:socket-server');
|
|
9
9
|
serverDebug.enabled = true;
|
|
10
10
|
serverDebug.log = console.log;
|
|
11
|
-
|
|
11
|
+
const conflictDebug = Debug('sdoc:sdoc-conflict');
|
|
12
12
|
conflictDebug.enabled = true;
|
|
13
13
|
conflictDebug.log = console.log;
|
|
14
14
|
export { stateDebug, clientDebug, serverDebug, conflictDebug };
|
|
@@ -1,19 +1,17 @@
|
|
|
1
|
-
import _createClass from "@babel/runtime/helpers/esm/createClass";
|
|
2
|
-
import _classCallCheck from "@babel/runtime/helpers/esm/classCallCheck";
|
|
3
1
|
import ObjectUtils from './object-utils';
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
2
|
+
const buildValues = (diff, components, newString, oldString, valueType, useLongestToken) => {
|
|
3
|
+
let componentPos = 0;
|
|
4
|
+
let componentLen = components.length;
|
|
5
|
+
let newPos = 0;
|
|
6
|
+
let oldPos = 0;
|
|
9
7
|
for (; componentPos < componentLen; componentPos++) {
|
|
10
|
-
|
|
8
|
+
let component = components[componentPos];
|
|
11
9
|
if (!component.removed) {
|
|
12
10
|
if (!component.added && useLongestToken) {
|
|
13
|
-
|
|
11
|
+
let value = newString.slice(newPos, newPos + component.count);
|
|
14
12
|
// eslint-disable-next-line no-loop-func
|
|
15
|
-
value = value.map(
|
|
16
|
-
|
|
13
|
+
value = value.map((value, i) => {
|
|
14
|
+
let oldValue = oldString[oldPos + i];
|
|
17
15
|
return oldValue.length > value.length ? oldValue : value;
|
|
18
16
|
});
|
|
19
17
|
component.value = diff.join(value, valueType);
|
|
@@ -34,7 +32,7 @@ var buildValues = function buildValues(diff, components, newString, oldString, v
|
|
|
34
32
|
// The diffing algorithm is tied to add then remove output and this is the simplest
|
|
35
33
|
// route to get the desired output with minimal overhead.
|
|
36
34
|
if (componentPos && components[componentPos - 1].added) {
|
|
37
|
-
|
|
35
|
+
let tmp = components[componentPos - 1];
|
|
38
36
|
components[componentPos - 1] = components[componentPos];
|
|
39
37
|
components[componentPos] = tmp;
|
|
40
38
|
}
|
|
@@ -44,212 +42,212 @@ var buildValues = function buildValues(diff, components, newString, oldString, v
|
|
|
44
42
|
// Special case handle for when one terminal is ignored (i.e. whitespace).
|
|
45
43
|
// For this case we merge the terminal into the prior string and drop the change.
|
|
46
44
|
// This is only available for string mode.
|
|
47
|
-
|
|
45
|
+
let lastComponent = components[componentLen - 1];
|
|
48
46
|
if (componentLen > 1 && typeof lastComponent.value === 'string' && (lastComponent.added || lastComponent.removed) && diff.equals('', lastComponent.value)) {
|
|
49
47
|
components[componentLen - 2].value += lastComponent.value;
|
|
50
48
|
components.pop();
|
|
51
49
|
}
|
|
52
50
|
return components;
|
|
53
51
|
};
|
|
54
|
-
|
|
52
|
+
const clonePath = path => {
|
|
55
53
|
return {
|
|
56
54
|
newPos: path.newPos,
|
|
57
55
|
components: path.components.slice(0)
|
|
58
56
|
};
|
|
59
57
|
};
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
58
|
+
class DiffText {
|
|
59
|
+
constructor(oldValue, newValue) {
|
|
60
|
+
let options = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
|
|
61
|
+
this.done = value => {
|
|
62
|
+
if (this.callback) {
|
|
63
|
+
setTimeout(function () {
|
|
64
|
+
this.callback(undefined, value);
|
|
65
|
+
}, 0);
|
|
66
|
+
return true;
|
|
67
|
+
}
|
|
68
|
+
return value;
|
|
69
|
+
};
|
|
70
|
+
// Main worker method. checks all permutations of a given edit length for acceptance.
|
|
71
|
+
this.execCompareLength = bestPath => {
|
|
72
|
+
for (let diagonalPath = -1 * this.comparePath; diagonalPath <= this.comparePath; diagonalPath += 2) {
|
|
73
|
+
let basePath;
|
|
74
|
+
let addPath = bestPath[diagonalPath - 1];
|
|
75
|
+
let removePath = bestPath[diagonalPath + 1];
|
|
76
|
+
let oldPos = (removePath ? removePath.newPos : 0) - diagonalPath;
|
|
77
|
+
if (addPath) {
|
|
78
|
+
// No one else is going to attempt to use this value, clear it
|
|
79
|
+
bestPath[diagonalPath - 1] = undefined;
|
|
80
|
+
}
|
|
81
|
+
let canAdd = addPath && addPath.newPos + 1 < this.newLen;
|
|
82
|
+
let canRemove = removePath && 0 <= oldPos && oldPos < this.oldLen;
|
|
83
|
+
if (!canAdd && !canRemove) {
|
|
84
|
+
// If this path is a terminal then prune
|
|
85
|
+
bestPath[diagonalPath] = undefined;
|
|
86
|
+
continue;
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
// Select the diagonal that we want to branch from. We select the prior
|
|
90
|
+
// path whose position in the new string is the farthest from the origin
|
|
91
|
+
// and does not pass the bounds of the diff graph
|
|
92
|
+
if (!canAdd || canRemove && addPath.newPos < removePath.newPos) {
|
|
93
|
+
basePath = clonePath(removePath);
|
|
94
|
+
this.pushComponent(basePath.components, undefined, true);
|
|
95
|
+
} else {
|
|
96
|
+
basePath = addPath; // No need to clone, we've pulled it from the list
|
|
97
|
+
basePath.newPos++;
|
|
98
|
+
this.pushComponent(basePath.components, true, undefined);
|
|
99
|
+
}
|
|
100
|
+
oldPos = this.extractCommon(basePath, this.newValue, this.oldValue, diagonalPath);
|
|
101
|
+
|
|
102
|
+
// If we have hit the end of both strings, then we are done
|
|
103
|
+
if (basePath.newPos + 1 >= this.newLen && oldPos + 1 >= this.oldLen) {
|
|
104
|
+
return this.done(buildValues(this, basePath.components, this.newValue, this.oldValue, this.valueType, this.useLongestToken));
|
|
105
|
+
} else {
|
|
106
|
+
// Otherwise track this path as a potential candidate and continue.
|
|
107
|
+
bestPath[diagonalPath] = basePath;
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
this.comparePath++;
|
|
111
|
+
};
|
|
112
|
+
this.exec = bestPath => {
|
|
66
113
|
setTimeout(function () {
|
|
67
|
-
this.
|
|
114
|
+
if (this.comparePath > this.maxEditLength) {
|
|
115
|
+
return this.callback();
|
|
116
|
+
}
|
|
117
|
+
if (!this.execCompareLength(bestPath)) {
|
|
118
|
+
this.exec(bestPath);
|
|
119
|
+
}
|
|
68
120
|
}, 0);
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
121
|
+
};
|
|
122
|
+
this.pushComponent = (components, added, removed) => {
|
|
123
|
+
let last = components[components.length - 1];
|
|
124
|
+
if (last && last.added === added && last.removed === removed) {
|
|
125
|
+
// We need to clone here as the component clone operation is just
|
|
126
|
+
// as shallow array clone
|
|
127
|
+
components[components.length - 1] = {
|
|
128
|
+
count: last.count + 1,
|
|
129
|
+
added: added,
|
|
130
|
+
removed: removed
|
|
131
|
+
};
|
|
132
|
+
} else {
|
|
133
|
+
components.push({
|
|
134
|
+
count: 1,
|
|
135
|
+
added: added,
|
|
136
|
+
removed: removed
|
|
137
|
+
});
|
|
83
138
|
}
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
139
|
+
};
|
|
140
|
+
this.extractCommon = (basePath, newString, oldString, diagonalPath) => {
|
|
141
|
+
let newLen = newString.length;
|
|
142
|
+
let oldLen = oldString.length;
|
|
143
|
+
let newPos = basePath.newPos;
|
|
144
|
+
let oldPos = newPos - diagonalPath;
|
|
145
|
+
let commonCount = 0;
|
|
146
|
+
while (newPos + 1 < newLen && oldPos + 1 < oldLen && this.equals(newString[newPos + 1], oldString[oldPos + 1])) {
|
|
147
|
+
newPos++;
|
|
148
|
+
oldPos++;
|
|
149
|
+
commonCount++;
|
|
90
150
|
}
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
if (!canAdd || canRemove && addPath.newPos < removePath.newPos) {
|
|
96
|
-
basePath = clonePath(removePath);
|
|
97
|
-
_this.pushComponent(basePath.components, undefined, true);
|
|
98
|
-
} else {
|
|
99
|
-
basePath = addPath; // No need to clone, we've pulled it from the list
|
|
100
|
-
basePath.newPos++;
|
|
101
|
-
_this.pushComponent(basePath.components, true, undefined);
|
|
151
|
+
if (commonCount) {
|
|
152
|
+
basePath.components.push({
|
|
153
|
+
count: commonCount
|
|
154
|
+
});
|
|
102
155
|
}
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
156
|
+
basePath.newPos = newPos;
|
|
157
|
+
return oldPos;
|
|
158
|
+
};
|
|
159
|
+
this.equals = (left, right) => {
|
|
160
|
+
if (this.options.comparator) {
|
|
161
|
+
return this.options.comparator(left, right);
|
|
108
162
|
} else {
|
|
109
|
-
|
|
110
|
-
bestPath[diagonalPath] = basePath;
|
|
163
|
+
return left === right || this.options.ignoreCase && left.toLowerCase() === right.toLowerCase();
|
|
111
164
|
}
|
|
112
|
-
}
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
165
|
+
};
|
|
166
|
+
this.removeEmpty = (array, type) => {
|
|
167
|
+
if (type === 'Array') return array;
|
|
168
|
+
let ret = [];
|
|
169
|
+
for (let i = 0; i < array.length; i++) {
|
|
170
|
+
if (array[i]) {
|
|
171
|
+
ret.push(array[i]);
|
|
172
|
+
}
|
|
119
173
|
}
|
|
120
|
-
|
|
121
|
-
|
|
174
|
+
return ret;
|
|
175
|
+
};
|
|
176
|
+
this.tokenize = (value, valueType) => {
|
|
177
|
+
if (valueType === 'Array') return value.slice();
|
|
178
|
+
return value.split('');
|
|
179
|
+
};
|
|
180
|
+
this.join = (value, valueType) => {
|
|
181
|
+
if (valueType === 'Array') return value;
|
|
182
|
+
return value.join('');
|
|
183
|
+
};
|
|
184
|
+
this.getDiffs = () => {
|
|
185
|
+
if (!this.canCompare) {
|
|
186
|
+
return [{
|
|
187
|
+
value: this.oldValue,
|
|
188
|
+
removed: true
|
|
189
|
+
}, {
|
|
190
|
+
value: this.newValue,
|
|
191
|
+
added: true
|
|
192
|
+
}];
|
|
122
193
|
}
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
var last = components[components.length - 1];
|
|
127
|
-
if (last && last.added === added && last.removed === removed) {
|
|
128
|
-
// We need to clone here as the component clone operation is just
|
|
129
|
-
// as shallow array clone
|
|
130
|
-
components[components.length - 1] = {
|
|
131
|
-
count: last.count + 1,
|
|
132
|
-
added: added,
|
|
133
|
-
removed: removed
|
|
134
|
-
};
|
|
135
|
-
} else {
|
|
136
|
-
components.push({
|
|
137
|
-
count: 1,
|
|
138
|
-
added: added,
|
|
139
|
-
removed: removed
|
|
140
|
-
});
|
|
141
|
-
}
|
|
142
|
-
};
|
|
143
|
-
this.extractCommon = function (basePath, newString, oldString, diagonalPath) {
|
|
144
|
-
var newLen = newString.length;
|
|
145
|
-
var oldLen = oldString.length;
|
|
146
|
-
var newPos = basePath.newPos;
|
|
147
|
-
var oldPos = newPos - diagonalPath;
|
|
148
|
-
var commonCount = 0;
|
|
149
|
-
while (newPos + 1 < newLen && oldPos + 1 < oldLen && _this.equals(newString[newPos + 1], oldString[oldPos + 1])) {
|
|
150
|
-
newPos++;
|
|
151
|
-
oldPos++;
|
|
152
|
-
commonCount++;
|
|
153
|
-
}
|
|
154
|
-
if (commonCount) {
|
|
155
|
-
basePath.components.push({
|
|
156
|
-
count: commonCount
|
|
157
|
-
});
|
|
158
|
-
}
|
|
159
|
-
basePath.newPos = newPos;
|
|
160
|
-
return oldPos;
|
|
161
|
-
};
|
|
162
|
-
this.equals = function (left, right) {
|
|
163
|
-
if (_this.options.comparator) {
|
|
164
|
-
return _this.options.comparator(left, right);
|
|
165
|
-
} else {
|
|
166
|
-
return left === right || _this.options.ignoreCase && left.toLowerCase() === right.toLowerCase();
|
|
167
|
-
}
|
|
168
|
-
};
|
|
169
|
-
this.removeEmpty = function (array, type) {
|
|
170
|
-
if (type === 'Array') return array;
|
|
171
|
-
var ret = [];
|
|
172
|
-
for (var i = 0; i < array.length; i++) {
|
|
173
|
-
if (array[i]) {
|
|
174
|
-
ret.push(array[i]);
|
|
175
|
-
}
|
|
176
|
-
}
|
|
177
|
-
return ret;
|
|
178
|
-
};
|
|
179
|
-
this.tokenize = function (value, valueType) {
|
|
180
|
-
if (valueType === 'Array') return value.slice();
|
|
181
|
-
return value.split('');
|
|
182
|
-
};
|
|
183
|
-
this.join = function (value, valueType) {
|
|
184
|
-
if (valueType === 'Array') return value;
|
|
185
|
-
return value.join('');
|
|
186
|
-
};
|
|
187
|
-
this.getDiffs = function () {
|
|
188
|
-
if (!_this.canCompare) {
|
|
189
|
-
return [{
|
|
190
|
-
value: _this.oldValue,
|
|
191
|
-
removed: true
|
|
192
|
-
}, {
|
|
193
|
-
value: _this.newValue,
|
|
194
|
-
added: true
|
|
194
|
+
let bestPath = [{
|
|
195
|
+
newPos: -1,
|
|
196
|
+
components: []
|
|
195
197
|
}];
|
|
196
|
-
}
|
|
197
|
-
var bestPath = [{
|
|
198
|
-
newPos: -1,
|
|
199
|
-
components: []
|
|
200
|
-
}];
|
|
201
198
|
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
199
|
+
// Seed editLength = 0, i.e. the content starts with the same values
|
|
200
|
+
let oldPos = this.extractCommon(bestPath[0], this.newValue, this.oldValue, 0);
|
|
201
|
+
if (bestPath[0].newPos + 1 >= this.newLen && oldPos + 1 >= this.oldLen) {
|
|
202
|
+
// Identity per the equality and tokenizer
|
|
203
|
+
return this.done([{
|
|
204
|
+
value: this.join(this.newValue, this.valueType),
|
|
205
|
+
count: this.oldValue.length
|
|
206
|
+
}]);
|
|
207
|
+
}
|
|
211
208
|
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
209
|
+
// Performs the length of edit iteration. Is a bit fugly as this has to support the
|
|
210
|
+
// sync and async mode which is never fun. Loops over execCompareLength until a value
|
|
211
|
+
// is produced, or until the edit length exceeds options.maxEditLength (if given),
|
|
212
|
+
// in which case it will return undefined.
|
|
213
|
+
if (this.callback) {
|
|
214
|
+
this.exec(bestPath);
|
|
215
|
+
} else {
|
|
216
|
+
while (this.comparePath <= this.maxEditLength) {
|
|
217
|
+
let ret = this.execCompareLength(bestPath);
|
|
218
|
+
if (ret) {
|
|
219
|
+
return ret;
|
|
220
|
+
}
|
|
223
221
|
}
|
|
224
222
|
}
|
|
223
|
+
};
|
|
224
|
+
this.oldValue = oldValue;
|
|
225
|
+
this.newValue = newValue;
|
|
226
|
+
const oldValueType = ObjectUtils.getDataType(oldValue);
|
|
227
|
+
const newValueType = ObjectUtils.getDataType(newValue);
|
|
228
|
+
this.canCompare = true;
|
|
229
|
+
if (oldValueType !== newValueType) {
|
|
230
|
+
this.canCompare = false;
|
|
231
|
+
return;
|
|
232
|
+
}
|
|
233
|
+
this.valueType = newValueType;
|
|
234
|
+
this.callback = options.callback;
|
|
235
|
+
const optionsType = ObjectUtils.getDataType(options);
|
|
236
|
+
if (optionsType === 'function') {
|
|
237
|
+
this.callback = options;
|
|
238
|
+
this.options = {};
|
|
239
|
+
} else {
|
|
240
|
+
this.options = {};
|
|
241
|
+
}
|
|
242
|
+
this.comparePath = 1;
|
|
243
|
+
this.oldValue = this.removeEmpty(this.tokenize(oldValue, oldValueType), oldValueType);
|
|
244
|
+
this.oldLen = this.oldValue.length;
|
|
245
|
+
this.newValue = this.removeEmpty(this.tokenize(newValue, newValueType), newValueType);
|
|
246
|
+
this.newLen = this.newValue.length;
|
|
247
|
+
this.maxEditLength = this.newLen + this.oldLen;
|
|
248
|
+
if (this.options.maxEditLength) {
|
|
249
|
+
this.maxEditLength = Math.min(this.maxEditLength, this.options.maxEditLength);
|
|
225
250
|
}
|
|
226
|
-
};
|
|
227
|
-
this.oldValue = oldValue;
|
|
228
|
-
this.newValue = newValue;
|
|
229
|
-
var oldValueType = ObjectUtils.getDataType(oldValue);
|
|
230
|
-
var newValueType = ObjectUtils.getDataType(newValue);
|
|
231
|
-
this.canCompare = true;
|
|
232
|
-
if (oldValueType !== newValueType) {
|
|
233
|
-
this.canCompare = false;
|
|
234
|
-
return;
|
|
235
|
-
}
|
|
236
|
-
this.valueType = newValueType;
|
|
237
|
-
this.callback = options.callback;
|
|
238
|
-
var optionsType = ObjectUtils.getDataType(options);
|
|
239
|
-
if (optionsType === 'function') {
|
|
240
|
-
this.callback = options;
|
|
241
|
-
this.options = {};
|
|
242
|
-
} else {
|
|
243
|
-
this.options = {};
|
|
244
|
-
}
|
|
245
|
-
this.comparePath = 1;
|
|
246
|
-
this.oldValue = this.removeEmpty(this.tokenize(oldValue, oldValueType), oldValueType);
|
|
247
|
-
this.oldLen = this.oldValue.length;
|
|
248
|
-
this.newValue = this.removeEmpty(this.tokenize(newValue, newValueType), newValueType);
|
|
249
|
-
this.newLen = this.newValue.length;
|
|
250
|
-
this.maxEditLength = this.newLen + this.oldLen;
|
|
251
|
-
if (this.options.maxEditLength) {
|
|
252
|
-
this.maxEditLength = Math.min(this.maxEditLength, this.options.maxEditLength);
|
|
253
251
|
}
|
|
254
|
-
}
|
|
252
|
+
}
|
|
255
253
|
export default DiffText;
|