@seafile/comment-editor 0.0.1 → 0.0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +2 -8
- package/dist/basic-sdk/constants/index.js +2 -91
- package/dist/basic-sdk/context.js +0 -191
- package/dist/basic-sdk/cursor/helper.js +2 -31
- package/dist/basic-sdk/decorates/index.js +1 -2
- package/dist/basic-sdk/extension/commons/index.js +1 -22
- package/dist/basic-sdk/extension/commons/insert-element-dialog/index.js +0 -136
- package/dist/basic-sdk/extension/commons/menu/menu-item.js +1 -6
- package/dist/basic-sdk/extension/constants/element-type.js +2 -36
- package/dist/basic-sdk/extension/constants/index.js +4 -421
- package/dist/basic-sdk/extension/constants/menus-config.js +2 -402
- package/dist/basic-sdk/extension/core/queries/index.js +0 -3
- package/dist/basic-sdk/extension/core/transforms/index.js +0 -11
- package/dist/basic-sdk/extension/index.js +3 -24
- package/dist/basic-sdk/extension/plugins/blockquote/helpers.js +1 -28
- package/dist/basic-sdk/extension/plugins/blockquote/plugin.js +2 -2
- package/dist/basic-sdk/extension/plugins/html/helper.js +0 -1
- package/dist/basic-sdk/extension/plugins/html/plugin.js +0 -24
- package/dist/basic-sdk/extension/plugins/html/rules/index.js +1 -4
- package/dist/basic-sdk/extension/plugins/image/helpers.js +2 -5
- package/dist/basic-sdk/extension/plugins/image/hover-menu/index.js +1 -1
- package/dist/basic-sdk/extension/plugins/image/plugin.js +0 -14
- package/dist/basic-sdk/extension/plugins/image/render-elem.js +0 -7
- package/dist/basic-sdk/extension/plugins/index.js +1 -102
- package/dist/basic-sdk/extension/plugins/link/helpers.js +2 -16
- package/dist/basic-sdk/extension/plugins/link/plugin.js +5 -13
- package/dist/basic-sdk/extension/plugins/list/helpers.js +0 -4
- package/dist/basic-sdk/extension/plugins/list/plugin/normalize-list.js +1 -1
- package/dist/basic-sdk/extension/plugins/list/transforms/move-list-item-sublist-to-list-item-sublist.js +2 -9
- package/dist/basic-sdk/extension/plugins/list/transforms/normalize-list-item.js +1 -1
- package/dist/basic-sdk/extension/plugins/markdown/plugin.js +1 -6
- package/dist/basic-sdk/extension/plugins/paragraph/render-elem.js +1 -9
- package/dist/basic-sdk/extension/plugins/text-style/helpers.js +0 -8
- package/dist/basic-sdk/extension/plugins/text-style/render-elem.js +0 -75
- package/dist/basic-sdk/extension/render/render-comment-editor-element.js +0 -7
- package/dist/basic-sdk/extension/utils/index.js +1 -51
- package/dist/basic-sdk/index.js +1 -40
- package/dist/basic-sdk/slate-convert/html-to-slate/constants.js +3 -18
- package/dist/basic-sdk/slate-convert/html-to-slate/index.js +0 -1
- package/dist/basic-sdk/slate-convert/html-to-slate/rules/index.js +1 -4
- package/dist/basic-sdk/slate-convert/md-to-slate/transform.js +1 -90
- package/dist/basic-sdk/slate-convert/slate-to-md/transform.js +0 -89
- package/dist/basic-sdk/utils/common-utils.js +1 -39
- package/dist/basic-sdk/utils/document-utils.js +2 -31
- package/dist/basic-sdk/utils/event-handler.js +2 -18
- package/dist/basic-sdk/utils/mouse-event.js +2 -57
- package/dist/constants/index.js +2 -59
- package/dist/pages/seafile-comment-editor.js +2 -4
- package/package.json +1 -14
- package/public/index.html +0 -1
- package/dist/assets/css/simple-editor.css +0 -9
- package/dist/assets/images/content-replaced.png +0 -0
- package/dist/assets/images/revision-avatar.png +0 -0
- package/dist/assets/images/sdoc-freezed.png +0 -0
- package/dist/basic-sdk/android/constants.js +0 -10
- package/dist/basic-sdk/android/js-bridge.js +0 -74
- package/dist/basic-sdk/android/outline-module.js +0 -29
- package/dist/basic-sdk/api/sdoc-server-api.js +0 -189
- package/dist/basic-sdk/api/seafile-api.js +0 -220
- package/dist/basic-sdk/assets/css/diff-viewer.css +0 -5
- package/dist/basic-sdk/assets/images/sdoc-ask-ai.png +0 -0
- package/dist/basic-sdk/components/file-loading/index.css +0 -57
- package/dist/basic-sdk/components/file-loading/index.js +0 -15
- package/dist/basic-sdk/constants/plugin.js +0 -10
- package/dist/basic-sdk/constants/z-index.js +0 -8
- package/dist/basic-sdk/extension/commons/color-menu/color-item.js +0 -33
- package/dist/basic-sdk/extension/commons/color-menu/index.css +0 -161
- package/dist/basic-sdk/extension/commons/color-menu/index.js +0 -210
- package/dist/basic-sdk/extension/commons/file-insert-dialog/index.js +0 -282
- package/dist/basic-sdk/extension/commons/file-insert-dialog/style.css +0 -91
- package/dist/basic-sdk/extension/commons/more-dropdown/index.js +0 -44
- package/dist/basic-sdk/extension/commons/search-list/index.css +0 -28
- package/dist/basic-sdk/extension/commons/search-list/index.js +0 -149
- package/dist/basic-sdk/extension/commons/select/_option.js +0 -39
- package/dist/basic-sdk/extension/commons/select/field-setting.js +0 -109
- package/dist/basic-sdk/extension/commons/select/index.js +0 -142
- package/dist/basic-sdk/extension/commons/select/menu/index.js +0 -11
- package/dist/basic-sdk/extension/commons/select/menu/item.js +0 -39
- package/dist/basic-sdk/extension/commons/select/menu/menu.js +0 -34
- package/dist/basic-sdk/extension/commons/select/menu/style.css +0 -43
- package/dist/basic-sdk/extension/commons/select/style.css +0 -149
- package/dist/basic-sdk/extension/commons/select-file-dialog/helpers.js +0 -54
- package/dist/basic-sdk/extension/commons/select-file-dialog/index.css +0 -135
- package/dist/basic-sdk/extension/commons/select-file-dialog/index.js +0 -207
- package/dist/basic-sdk/extension/commons/select-file-dialog/local-files/index.css +0 -114
- package/dist/basic-sdk/extension/commons/select-file-dialog/local-files/index.js +0 -193
- package/dist/basic-sdk/extension/commons/wiki-file-insert-dialog/index.js +0 -274
- package/dist/basic-sdk/extension/commons/wiki-file-insert-dialog/style.css +0 -116
- package/dist/basic-sdk/extension/constants/color.js +0 -282
- package/dist/basic-sdk/extension/constants/diff-view.js +0 -20
- package/dist/basic-sdk/extension/constants/font.js +0 -537
- package/dist/basic-sdk/extension/constants/keyboard.js +0 -45
- package/dist/basic-sdk/extension/core/transforms/update-parent-node.js +0 -34
- package/dist/basic-sdk/extension/plugins/ai/ai-icon/index.js +0 -26
- package/dist/basic-sdk/extension/plugins/ai/ai-icon/style.css +0 -22
- package/dist/basic-sdk/extension/plugins/ai/ai-menu/ai-context-menu.js +0 -41
- package/dist/basic-sdk/extension/plugins/ai/ai-menu/ai-dropdown-menu.js +0 -35
- package/dist/basic-sdk/extension/plugins/ai/ai-menu/index.js +0 -20
- package/dist/basic-sdk/extension/plugins/ai/ai-menu/menu-item.js +0 -58
- package/dist/basic-sdk/extension/plugins/ai/ai-menu/style.css +0 -12
- package/dist/basic-sdk/extension/plugins/ai/ai-module/adjust-sub-menu.js +0 -44
- package/dist/basic-sdk/extension/plugins/ai/ai-module/helpers.js +0 -72
- package/dist/basic-sdk/extension/plugins/ai/ai-module/index.js +0 -600
- package/dist/basic-sdk/extension/plugins/ai/ai-module/lang-sub-menu.js +0 -55
- package/dist/basic-sdk/extension/plugins/ai/ai-module/style.css +0 -148
- package/dist/basic-sdk/extension/plugins/ai/ai-module/tip-dialog.js +0 -41
- package/dist/basic-sdk/extension/plugins/ai/constants/index.js +0 -137
- package/dist/basic-sdk/extension/plugins/ai/index.js +0 -1
- package/dist/basic-sdk/extension/plugins/callout/constant.js +0 -58
- package/dist/basic-sdk/extension/plugins/callout/helper.js +0 -281
- package/dist/basic-sdk/extension/plugins/callout/index.js +0 -19
- package/dist/basic-sdk/extension/plugins/callout/menu/index.css +0 -16
- package/dist/basic-sdk/extension/plugins/callout/menu/index.js +0 -52
- package/dist/basic-sdk/extension/plugins/callout/plugin.js +0 -109
- package/dist/basic-sdk/extension/plugins/callout/render-elem/callout-color-selector/index.js +0 -65
- package/dist/basic-sdk/extension/plugins/callout/render-elem/callout-color-selector/style.css +0 -39
- package/dist/basic-sdk/extension/plugins/callout/render-elem/callout-hover-menu/index.js +0 -90
- package/dist/basic-sdk/extension/plugins/callout/render-elem/callout-hover-menu/style.css +0 -45
- package/dist/basic-sdk/extension/plugins/callout/render-elem/callout-icon/index.js +0 -45
- package/dist/basic-sdk/extension/plugins/callout/render-elem/callout-icon/style.css +0 -33
- package/dist/basic-sdk/extension/plugins/callout/render-elem/index.css +0 -52
- package/dist/basic-sdk/extension/plugins/callout/render-elem/index.js +0 -134
- package/dist/basic-sdk/extension/plugins/check-list/helpers.js +0 -121
- package/dist/basic-sdk/extension/plugins/check-list/index.js +0 -16
- package/dist/basic-sdk/extension/plugins/check-list/menu/index.js +0 -58
- package/dist/basic-sdk/extension/plugins/check-list/model.js +0 -17
- package/dist/basic-sdk/extension/plugins/check-list/plugin.js +0 -110
- package/dist/basic-sdk/extension/plugins/check-list/render-elem.js +0 -71
- package/dist/basic-sdk/extension/plugins/clear-format/helpers.js +0 -54
- package/dist/basic-sdk/extension/plugins/clear-format/menu/index.js +0 -35
- package/dist/basic-sdk/extension/plugins/code-block/helpers.js +0 -206
- package/dist/basic-sdk/extension/plugins/code-block/hover-menu/index.css +0 -148
- package/dist/basic-sdk/extension/plugins/code-block/hover-menu/index.js +0 -259
- package/dist/basic-sdk/extension/plugins/code-block/index.js +0 -19
- package/dist/basic-sdk/extension/plugins/code-block/menu/index.js +0 -35
- package/dist/basic-sdk/extension/plugins/code-block/model.js +0 -16
- package/dist/basic-sdk/extension/plugins/code-block/plugin.js +0 -229
- package/dist/basic-sdk/extension/plugins/code-block/prismjs.js +0 -189
- package/dist/basic-sdk/extension/plugins/code-block/render-elem.js +0 -182
- package/dist/basic-sdk/extension/plugins/file-link/constants/index.js +0 -26
- package/dist/basic-sdk/extension/plugins/file-link/helpers.js +0 -125
- package/dist/basic-sdk/extension/plugins/file-link/hover-menu/index.css +0 -89
- package/dist/basic-sdk/extension/plugins/file-link/hover-menu/index.js +0 -122
- package/dist/basic-sdk/extension/plugins/file-link/index.js +0 -18
- package/dist/basic-sdk/extension/plugins/file-link/menu/index.js +0 -38
- package/dist/basic-sdk/extension/plugins/file-link/plugin.js +0 -72
- package/dist/basic-sdk/extension/plugins/file-link/render-elem.css +0 -56
- package/dist/basic-sdk/extension/plugins/file-link/render-elem.js +0 -164
- package/dist/basic-sdk/extension/plugins/font/helpers.js +0 -173
- package/dist/basic-sdk/extension/plugins/font/index.js +0 -13
- package/dist/basic-sdk/extension/plugins/font/menu/font-family/font-item.js +0 -39
- package/dist/basic-sdk/extension/plugins/font/menu/font-family/index.css +0 -40
- package/dist/basic-sdk/extension/plugins/font/menu/font-family/index.js +0 -145
- package/dist/basic-sdk/extension/plugins/font/menu/font-size/font-size-scale.js +0 -38
- package/dist/basic-sdk/extension/plugins/font/menu/font-size/index.css +0 -40
- package/dist/basic-sdk/extension/plugins/font/menu/font-size/index.js +0 -103
- package/dist/basic-sdk/extension/plugins/font/menu/index.js +0 -24
- package/dist/basic-sdk/extension/plugins/font/plugin.js +0 -18
- package/dist/basic-sdk/extension/plugins/group/index.js +0 -13
- package/dist/basic-sdk/extension/plugins/group/render-elem.js +0 -25
- package/dist/basic-sdk/extension/plugins/header/helpers.js +0 -69
- package/dist/basic-sdk/extension/plugins/header/index.js +0 -17
- package/dist/basic-sdk/extension/plugins/header/menu/index.js +0 -153
- package/dist/basic-sdk/extension/plugins/header/menu/style.css +0 -79
- package/dist/basic-sdk/extension/plugins/header/plugin.js +0 -140
- package/dist/basic-sdk/extension/plugins/header/render-elem.js +0 -90
- package/dist/basic-sdk/extension/plugins/history/history-menu.js +0 -70
- package/dist/basic-sdk/extension/plugins/html/rules/check-list.js +0 -27
- package/dist/basic-sdk/extension/plugins/html/rules/code-block.js +0 -89
- package/dist/basic-sdk/extension/plugins/html/rules/header.js +0 -32
- package/dist/basic-sdk/extension/plugins/html/rules/table.js +0 -41
- package/dist/basic-sdk/extension/plugins/multi-column/constants/index.js +0 -7
- package/dist/basic-sdk/extension/plugins/multi-column/helper.js +0 -192
- package/dist/basic-sdk/extension/plugins/multi-column/index.js +0 -17
- package/dist/basic-sdk/extension/plugins/multi-column/plugin.js +0 -153
- package/dist/basic-sdk/extension/plugins/multi-column/render/index.css +0 -51
- package/dist/basic-sdk/extension/plugins/multi-column/render/index.js +0 -91
- package/dist/basic-sdk/extension/plugins/multi-column/render/multi-column-root.js +0 -23
- package/dist/basic-sdk/extension/plugins/multi-column/render/render-column.js +0 -46
- package/dist/basic-sdk/extension/plugins/multi-column/render-elem.js +0 -20
- package/dist/basic-sdk/extension/plugins/multi-column/resize-handlers/column-resize-handler.js +0 -28
- package/dist/basic-sdk/extension/plugins/multi-column/resize-handlers/index.js +0 -148
- package/dist/basic-sdk/extension/plugins/sdoc-link/constants/index.js +0 -26
- package/dist/basic-sdk/extension/plugins/sdoc-link/helpers.js +0 -291
- package/dist/basic-sdk/extension/plugins/sdoc-link/hover-menu/index.css +0 -89
- package/dist/basic-sdk/extension/plugins/sdoc-link/hover-menu/index.js +0 -121
- package/dist/basic-sdk/extension/plugins/sdoc-link/index.js +0 -19
- package/dist/basic-sdk/extension/plugins/sdoc-link/menu/index.js +0 -38
- package/dist/basic-sdk/extension/plugins/sdoc-link/plugin.js +0 -102
- package/dist/basic-sdk/extension/plugins/sdoc-link/render/render-elem.css +0 -68
- package/dist/basic-sdk/extension/plugins/sdoc-link/render/render-elem.js +0 -180
- package/dist/basic-sdk/extension/plugins/sdoc-link/render/render-file-link-temp-input.js +0 -34
- package/dist/basic-sdk/extension/plugins/search-replace/constant.js +0 -8
- package/dist/basic-sdk/extension/plugins/search-replace/helper.js +0 -355
- package/dist/basic-sdk/extension/plugins/search-replace/index.js +0 -17
- package/dist/basic-sdk/extension/plugins/search-replace/menu/index.css +0 -14
- package/dist/basic-sdk/extension/plugins/search-replace/menu/index.js +0 -89
- package/dist/basic-sdk/extension/plugins/search-replace/plugin.js +0 -28
- package/dist/basic-sdk/extension/plugins/search-replace/popover/index.css +0 -98
- package/dist/basic-sdk/extension/plugins/search-replace/popover/index.js +0 -238
- package/dist/basic-sdk/extension/plugins/search-replace/popover/replace-all-confirm-modal.js +0 -50
- package/dist/basic-sdk/extension/plugins/table/constants/index.js +0 -64
- package/dist/basic-sdk/extension/plugins/table/dialogs/custom-table-size-dialog/index.css +0 -7
- package/dist/basic-sdk/extension/plugins/table/dialogs/custom-table-size-dialog/index.js +0 -102
- package/dist/basic-sdk/extension/plugins/table/dialogs/custom-table-size-dialog/number-input.js +0 -31
- package/dist/basic-sdk/extension/plugins/table/dialogs/index.js +0 -20
- package/dist/basic-sdk/extension/plugins/table/dialogs/split-cell-setting-dialog.js +0 -115
- package/dist/basic-sdk/extension/plugins/table/helpers.js +0 -2124
- package/dist/basic-sdk/extension/plugins/table/index.js +0 -21
- package/dist/basic-sdk/extension/plugins/table/menu/active-table-menu/common-menu.js +0 -83
- package/dist/basic-sdk/extension/plugins/table/menu/color-selector-popover/color-item.js +0 -33
- package/dist/basic-sdk/extension/plugins/table/menu/color-selector-popover/index.js +0 -173
- package/dist/basic-sdk/extension/plugins/table/menu/color-selector-popover/style.css +0 -7
- package/dist/basic-sdk/extension/plugins/table/menu/horizontal-align-popover/index.js +0 -79
- package/dist/basic-sdk/extension/plugins/table/menu/index.js +0 -20
- package/dist/basic-sdk/extension/plugins/table/menu/table-context-menu/index.css +0 -40
- package/dist/basic-sdk/extension/plugins/table/menu/table-context-menu/index.js +0 -232
- package/dist/basic-sdk/extension/plugins/table/menu/table-context-menu/insert-table-element.js +0 -97
- package/dist/basic-sdk/extension/plugins/table/menu/table-menu/index.js +0 -40
- package/dist/basic-sdk/extension/plugins/table/menu/vertical-align-popover/index.js +0 -81
- package/dist/basic-sdk/extension/plugins/table/menu/vertical-align-popover/style.css +0 -24
- package/dist/basic-sdk/extension/plugins/table/model.js +0 -54
- package/dist/basic-sdk/extension/plugins/table/plugin.js +0 -621
- package/dist/basic-sdk/extension/plugins/table/popover/table-size-popover/index.css +0 -69
- package/dist/basic-sdk/extension/plugins/table/popover/table-size-popover/index.js +0 -265
- package/dist/basic-sdk/extension/plugins/table/popover/table-template/index.css +0 -43
- package/dist/basic-sdk/extension/plugins/table/popover/table-template/index.js +0 -129
- package/dist/basic-sdk/extension/plugins/table/popover/table-template/sample-table.js +0 -44
- package/dist/basic-sdk/extension/plugins/table/render/alternate-color.css +0 -37
- package/dist/basic-sdk/extension/plugins/table/render/drag-handlers/column-drag-handler.js +0 -24
- package/dist/basic-sdk/extension/plugins/table/render/drag-handlers/index.js +0 -53
- package/dist/basic-sdk/extension/plugins/table/render/drag-handlers/row-drag-handler.js +0 -24
- package/dist/basic-sdk/extension/plugins/table/render/hooks.js +0 -76
- package/dist/basic-sdk/extension/plugins/table/render/index.css +0 -169
- package/dist/basic-sdk/extension/plugins/table/render/index.js +0 -271
- package/dist/basic-sdk/extension/plugins/table/render/render-cell.js +0 -253
- package/dist/basic-sdk/extension/plugins/table/render/render-row.js +0 -15
- package/dist/basic-sdk/extension/plugins/table/render/resize-handlers/column-resize-handler.js +0 -114
- package/dist/basic-sdk/extension/plugins/table/render/resize-handlers/first-column-left-resize-handler.js +0 -100
- package/dist/basic-sdk/extension/plugins/table/render/resize-handlers/index.js +0 -74
- package/dist/basic-sdk/extension/plugins/table/render/resize-handlers/row-resize-handler.js +0 -90
- package/dist/basic-sdk/extension/plugins/table/render/resize-mask/index.js +0 -136
- package/dist/basic-sdk/extension/plugins/table/render/table-header/columns-header/column-header.js +0 -104
- package/dist/basic-sdk/extension/plugins/table/render/table-header/columns-header/index.js +0 -92
- package/dist/basic-sdk/extension/plugins/table/render/table-header/index.css +0 -84
- package/dist/basic-sdk/extension/plugins/table/render/table-header/index.js +0 -114
- package/dist/basic-sdk/extension/plugins/table/render/table-header/rows-columns-header.js +0 -32
- package/dist/basic-sdk/extension/plugins/table/render/table-header/rows-header/index.js +0 -90
- package/dist/basic-sdk/extension/plugins/table/render/table-header/rows-header/row-header.js +0 -126
- package/dist/basic-sdk/extension/plugins/table/render/table-root.js +0 -60
- package/dist/basic-sdk/extension/plugins/table/render-elem.js +0 -27
- package/dist/basic-sdk/extension/plugins/text-align/helpers.js +0 -51
- package/dist/basic-sdk/extension/plugins/text-align/index.js +0 -8
- package/dist/basic-sdk/extension/plugins/text-align/menu/index.css +0 -5
- package/dist/basic-sdk/extension/plugins/text-align/menu/index.js +0 -98
- package/dist/basic-sdk/extension/plugins/text-style/menu/index.js +0 -164
- package/dist/basic-sdk/extension/plugins/video/constants/index.js +0 -10
- package/dist/basic-sdk/extension/plugins/video/dialog/add-video-link-dialog/index.js +0 -108
- package/dist/basic-sdk/extension/plugins/video/helpers.js +0 -241
- package/dist/basic-sdk/extension/plugins/video/index.css +0 -73
- package/dist/basic-sdk/extension/plugins/video/index.js +0 -20
- package/dist/basic-sdk/extension/plugins/video/menu/index.js +0 -76
- package/dist/basic-sdk/extension/plugins/video/plugin.js +0 -52
- package/dist/basic-sdk/extension/plugins/video/render-elem.js +0 -154
- package/dist/basic-sdk/extension/plugins/wiki-link/helpers.js +0 -77
- package/dist/basic-sdk/extension/plugins/wiki-link/index.js +0 -16
- package/dist/basic-sdk/extension/render/helper.js +0 -64
- package/dist/basic-sdk/highlight/index.js +0 -26
- package/dist/basic-sdk/highlight/setNodeToDecorations.js +0 -83
- package/dist/basic-sdk/hooks/use-color-context.js +0 -49
- package/dist/basic-sdk/hooks/use-force-update.js +0 -15
- package/dist/basic-sdk/hooks/use-selection-element.js +0 -26
- package/dist/basic-sdk/hooks/use-selection-position.js +0 -68
- package/dist/basic-sdk/slate-convert/html-to-slate/rules/code-block.js +0 -90
- package/dist/basic-sdk/slate-convert/html-to-slate/rules/header.js +0 -24
- package/dist/basic-sdk/slate-convert/html-to-slate/rules/table.js +0 -45
- package/dist/basic-sdk/socket/helpers.js +0 -312
- package/dist/basic-sdk/utils/Kebab-to-camel.js +0 -10
- package/dist/basic-sdk/utils/debounce.js +0 -20
- package/dist/basic-sdk/utils/debug.js +0 -20
- package/dist/basic-sdk/utils/default-mode.js +0 -28
- package/dist/basic-sdk/utils/diff-text.js +0 -297
- package/dist/basic-sdk/utils/diff.js +0 -328
- package/dist/basic-sdk/utils/dom-utils.js +0 -57
- package/dist/basic-sdk/utils/full-width-mode.js +0 -36
- package/dist/basic-sdk/utils/local-storage-utils.js +0 -52
- package/dist/basic-sdk/utils/rebase.js +0 -309
- package/dist/components/error-boundary/error-page.css +0 -16
- package/dist/components/error-boundary/error-page.js +0 -36
- package/dist/components/error-boundary/index.js +0 -33
- package/dist/components/modal-header/index.css +0 -18
- package/dist/components/modal-header/index.js +0 -29
- package/dist/components/modal-portal/index.js +0 -26
- package/dist/components/tip-dialog/index.css +0 -48
- package/dist/components/tip-dialog/index.js +0 -115
- package/dist/utils/date-utils.js +0 -78
- package/dist/utils/index.js +0 -45
- package/public/media/dtable-font.css +0 -1568
- package/public/media/dtable-fonts/dtable-font.eot +0 -0
- package/public/media/dtable-fonts/dtable-font.svg +0 -793
- package/public/media/dtable-fonts/dtable-font.ttf +0 -0
- package/public/media/dtable-fonts/dtable-font.woff +0 -0
- package/public/media/dtable-fonts/dtable-font.woff2 +0 -0
- package/public/media/seafile-logo.png +0 -0
- /package/dist/basic-sdk/{extension/plugins/header → components/placeholder}/placeholder.js +0 -0
|
@@ -1,312 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
var _interopRequireWildcard = require("@babel/runtime/helpers/interopRequireWildcard").default;
|
|
4
|
-
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
|
|
5
|
-
Object.defineProperty(exports, "__esModule", {
|
|
6
|
-
value: true
|
|
7
|
-
});
|
|
8
|
-
exports.validateOperation = exports.syncRemoteOperations = exports.syncRemoteCursorLocation = exports.revertOperationList = exports.reExecRevertOperationList = exports.getRevertOperationList = exports.getNodePathById = void 0;
|
|
9
|
-
var _slate = require("@seafile/slate");
|
|
10
|
-
var _deepCopy = _interopRequireDefault(require("deep-copy"));
|
|
11
|
-
var _helper = require("../cursor/helper");
|
|
12
|
-
var _core = require("../extension/core");
|
|
13
|
-
var OPERATION = _interopRequireWildcard(require("../node-id/constants"));
|
|
14
|
-
const getNodePathById = function (rootNode, nodeId) {
|
|
15
|
-
let path = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : [];
|
|
16
|
-
if (rootNode.id === nodeId) return path;
|
|
17
|
-
const {
|
|
18
|
-
children = []
|
|
19
|
-
} = rootNode;
|
|
20
|
-
for (let i = 0; i < children.length; i++) {
|
|
21
|
-
const child = children[i];
|
|
22
|
-
path.push(i);
|
|
23
|
-
const nodePath = getNodePathById(child, nodeId, path);
|
|
24
|
-
if (nodePath) return nodePath;
|
|
25
|
-
path.pop();
|
|
26
|
-
}
|
|
27
|
-
return null;
|
|
28
|
-
};
|
|
29
|
-
exports.getNodePathById = getNodePathById;
|
|
30
|
-
const validateOperation = (editor, operation) => {
|
|
31
|
-
let isValid = false;
|
|
32
|
-
let newOperation = (0, _deepCopy.default)(operation);
|
|
33
|
-
const {
|
|
34
|
-
type
|
|
35
|
-
} = newOperation;
|
|
36
|
-
switch (type) {
|
|
37
|
-
case OPERATION.INSERT_TEXT:
|
|
38
|
-
case OPERATION.REMOVE_TEXT:
|
|
39
|
-
{
|
|
40
|
-
const {
|
|
41
|
-
node_id,
|
|
42
|
-
path
|
|
43
|
-
} = newOperation;
|
|
44
|
-
const node = (0, _core.getNode)(editor, path);
|
|
45
|
-
// node is exist and node path is not changed
|
|
46
|
-
if (node && node.id === node_id) {
|
|
47
|
-
isValid = true;
|
|
48
|
-
break;
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
// node is exist but node path is changed
|
|
52
|
-
const nodePath = getNodePathById(editor, node_id);
|
|
53
|
-
if (nodePath) {
|
|
54
|
-
isValid = true;
|
|
55
|
-
newOperation.path = nodePath;
|
|
56
|
-
break;
|
|
57
|
-
}
|
|
58
|
-
// node is not exist
|
|
59
|
-
isValid = false;
|
|
60
|
-
break;
|
|
61
|
-
}
|
|
62
|
-
case OPERATION.INSERT_NODE:
|
|
63
|
-
{
|
|
64
|
-
let {
|
|
65
|
-
parent_node_id,
|
|
66
|
-
path
|
|
67
|
-
} = newOperation;
|
|
68
|
-
const parentNodePath = getNodePathById(editor, parent_node_id);
|
|
69
|
-
if (!parentNodePath) {
|
|
70
|
-
isValid = false;
|
|
71
|
-
break;
|
|
72
|
-
}
|
|
73
|
-
const parentPath = path.slice(0, path.length - 1);
|
|
74
|
-
if (parentPath.join() === parentNodePath.join()) {
|
|
75
|
-
isValid = true;
|
|
76
|
-
break;
|
|
77
|
-
}
|
|
78
|
-
|
|
79
|
-
// reset insert node path
|
|
80
|
-
const parentNode = (0, _core.getNode)(editor, path);
|
|
81
|
-
if (parentNode) {
|
|
82
|
-
const childLength = parentNode.children.length;
|
|
83
|
-
const index = Math.min(path[path.length - 1], childLength);
|
|
84
|
-
newOperation.path = parentNodePath.concat([index]);
|
|
85
|
-
isValid = true;
|
|
86
|
-
}
|
|
87
|
-
break;
|
|
88
|
-
}
|
|
89
|
-
case OPERATION.REMOVE_NODE:
|
|
90
|
-
{
|
|
91
|
-
const {
|
|
92
|
-
node_id,
|
|
93
|
-
path
|
|
94
|
-
} = newOperation;
|
|
95
|
-
const node = (0, _core.getNode)(editor, path);
|
|
96
|
-
// node is exist and node path is not changed
|
|
97
|
-
if (node && node.id === node_id) {
|
|
98
|
-
isValid = true;
|
|
99
|
-
break;
|
|
100
|
-
}
|
|
101
|
-
|
|
102
|
-
// node is exist but node path is changed
|
|
103
|
-
const nodePath = getNodePathById(editor, node_id);
|
|
104
|
-
if (nodePath) {
|
|
105
|
-
isValid = true;
|
|
106
|
-
newOperation.path = nodePath;
|
|
107
|
-
break;
|
|
108
|
-
}
|
|
109
|
-
|
|
110
|
-
// node is not exist
|
|
111
|
-
isValid = false;
|
|
112
|
-
break;
|
|
113
|
-
}
|
|
114
|
-
case OPERATION.MERGE_NODE:
|
|
115
|
-
{
|
|
116
|
-
// merge next node into prev node
|
|
117
|
-
const {
|
|
118
|
-
node_id,
|
|
119
|
-
path
|
|
120
|
-
} = newOperation;
|
|
121
|
-
const node = (0, _core.getNode)(editor, path);
|
|
122
|
-
// node is exist and node path is not changed
|
|
123
|
-
if (node && node.id === node_id) {
|
|
124
|
-
isValid = true;
|
|
125
|
-
break;
|
|
126
|
-
}
|
|
127
|
-
|
|
128
|
-
// node is exist but node path is changed
|
|
129
|
-
const nodePath = getNodePathById(editor, node_id);
|
|
130
|
-
if (nodePath) {
|
|
131
|
-
isValid = true;
|
|
132
|
-
newOperation.path = nodePath;
|
|
133
|
-
break;
|
|
134
|
-
}
|
|
135
|
-
|
|
136
|
-
// node is not exist
|
|
137
|
-
isValid = false;
|
|
138
|
-
break;
|
|
139
|
-
}
|
|
140
|
-
case OPERATION.SPLIT_NODE:
|
|
141
|
-
{
|
|
142
|
-
const {
|
|
143
|
-
node_id,
|
|
144
|
-
path
|
|
145
|
-
} = newOperation;
|
|
146
|
-
const node = (0, _core.getNode)(editor, path);
|
|
147
|
-
// node is exist and node path is not changed
|
|
148
|
-
if (node && node.id === node_id) {
|
|
149
|
-
isValid = true;
|
|
150
|
-
break;
|
|
151
|
-
}
|
|
152
|
-
|
|
153
|
-
// node is exist but node path is changed
|
|
154
|
-
const nodePath = getNodePathById(editor, node_id);
|
|
155
|
-
if (nodePath) {
|
|
156
|
-
isValid = true;
|
|
157
|
-
newOperation.path = nodePath;
|
|
158
|
-
break;
|
|
159
|
-
}
|
|
160
|
-
|
|
161
|
-
// node is not exist
|
|
162
|
-
isValid = false;
|
|
163
|
-
break;
|
|
164
|
-
}
|
|
165
|
-
case OPERATION.SET_NODE:
|
|
166
|
-
{
|
|
167
|
-
const {
|
|
168
|
-
node_id,
|
|
169
|
-
path,
|
|
170
|
-
properties
|
|
171
|
-
} = newOperation;
|
|
172
|
-
const node = (0, _core.getNode)(editor, path);
|
|
173
|
-
// node is exist and node path is not changed
|
|
174
|
-
if (node && node.id === node_id) {
|
|
175
|
-
isValid = true;
|
|
176
|
-
newOperation.properties = {
|
|
177
|
-
...properties,
|
|
178
|
-
type: node.type
|
|
179
|
-
};
|
|
180
|
-
break;
|
|
181
|
-
}
|
|
182
|
-
|
|
183
|
-
// node is exist but node path is changed
|
|
184
|
-
const nodePath = getNodePathById(editor, node_id);
|
|
185
|
-
if (nodePath) {
|
|
186
|
-
isValid = true;
|
|
187
|
-
const node = (0, _core.getNode)(editor, nodePath);
|
|
188
|
-
newOperation.properties = {
|
|
189
|
-
...properties,
|
|
190
|
-
type: node.type
|
|
191
|
-
};
|
|
192
|
-
newOperation.path = nodePath;
|
|
193
|
-
break;
|
|
194
|
-
}
|
|
195
|
-
|
|
196
|
-
// node is not exist
|
|
197
|
-
isValid = false;
|
|
198
|
-
break;
|
|
199
|
-
}
|
|
200
|
-
case OPERATION.MOVE_NODE:
|
|
201
|
-
{
|
|
202
|
-
const {
|
|
203
|
-
node_id,
|
|
204
|
-
path
|
|
205
|
-
} = newOperation;
|
|
206
|
-
const node = (0, _core.getNode)(editor, path);
|
|
207
|
-
// node is exist and node path is not changed
|
|
208
|
-
if (node && node.id === node_id) {
|
|
209
|
-
isValid = true;
|
|
210
|
-
break;
|
|
211
|
-
}
|
|
212
|
-
|
|
213
|
-
// TODO: newPath can not calculate by nodePath
|
|
214
|
-
// node is exist but node path is changed
|
|
215
|
-
// const nodePath = getNodePathById(editor, node_id);
|
|
216
|
-
// if (nodePath) {}
|
|
217
|
-
|
|
218
|
-
// node is not exist
|
|
219
|
-
isValid = false;
|
|
220
|
-
break;
|
|
221
|
-
}
|
|
222
|
-
default:
|
|
223
|
-
{
|
|
224
|
-
// set_selection
|
|
225
|
-
break;
|
|
226
|
-
}
|
|
227
|
-
}
|
|
228
|
-
if (isValid) return newOperation;
|
|
229
|
-
return isValid;
|
|
230
|
-
};
|
|
231
|
-
exports.validateOperation = validateOperation;
|
|
232
|
-
const getRevertOperationList = operationList => {
|
|
233
|
-
if (operationList.length === 0) return [];
|
|
234
|
-
|
|
235
|
-
// Generate a duplicate operationList, The original value cannot be modified here
|
|
236
|
-
let revertOperationList = (0, _deepCopy.default)(operationList);
|
|
237
|
-
revertOperationList = revertOperationList.reverse();
|
|
238
|
-
return revertOperationList.map(operations => {
|
|
239
|
-
const ops = operations.reverse();
|
|
240
|
-
return ops.map(item => _slate.Operation.inverse(item));
|
|
241
|
-
});
|
|
242
|
-
};
|
|
243
|
-
exports.getRevertOperationList = getRevertOperationList;
|
|
244
|
-
const revertOperationList = (editor, operationList) => {
|
|
245
|
-
if (operationList.length === 0) return [];
|
|
246
|
-
const revertOperationList = getRevertOperationList(operationList);
|
|
247
|
-
|
|
248
|
-
// Cancel locale execute operations
|
|
249
|
-
for (let i = 0; i < revertOperationList.length; i++) {
|
|
250
|
-
const operations = revertOperationList[i];
|
|
251
|
-
_slate.Editor.withoutNormalizing(editor, () => {
|
|
252
|
-
for (let j = 0; j < operations.length; j++) {
|
|
253
|
-
const op = operations[j];
|
|
254
|
-
editor.apply(op);
|
|
255
|
-
}
|
|
256
|
-
});
|
|
257
|
-
}
|
|
258
|
-
};
|
|
259
|
-
exports.revertOperationList = revertOperationList;
|
|
260
|
-
const reExecRevertOperationList = (editor, revertOperationList) => {
|
|
261
|
-
if (revertOperationList.length === 0) return;
|
|
262
|
-
|
|
263
|
-
// Re-execute revert operations
|
|
264
|
-
for (let i = 0; i < revertOperationList.length; i++) {
|
|
265
|
-
const operations = revertOperationList[i];
|
|
266
|
-
_slate.Editor.withoutNormalizing(editor, () => {
|
|
267
|
-
for (let j = 0; j < operations.length; j++) {
|
|
268
|
-
const op = validateOperation(editor, operations[j]);
|
|
269
|
-
if (op) {
|
|
270
|
-
editor.apply(op);
|
|
271
|
-
}
|
|
272
|
-
}
|
|
273
|
-
});
|
|
274
|
-
}
|
|
275
|
-
};
|
|
276
|
-
exports.reExecRevertOperationList = reExecRevertOperationList;
|
|
277
|
-
const syncRemoteOperations = (editor, remoteOperations) => {
|
|
278
|
-
if (remoteOperations.length === 0) return;
|
|
279
|
-
_slate.Editor.withoutNormalizing(editor, () => {
|
|
280
|
-
for (let i = 0; i < remoteOperations.length; i++) {
|
|
281
|
-
const op = remoteOperations[i];
|
|
282
|
-
if (op.type === 'set_selection') {
|
|
283
|
-
continue;
|
|
284
|
-
}
|
|
285
|
-
editor.apply(op);
|
|
286
|
-
}
|
|
287
|
-
});
|
|
288
|
-
};
|
|
289
|
-
exports.syncRemoteOperations = syncRemoteOperations;
|
|
290
|
-
const syncRemoteCursorLocation = (editor, user, location, cursorData) => {
|
|
291
|
-
const currentUser = editor.user;
|
|
292
|
-
if (user && user.username !== currentUser.username) {
|
|
293
|
-
// Get front Point as cursor
|
|
294
|
-
const {
|
|
295
|
-
anchor,
|
|
296
|
-
focus
|
|
297
|
-
} = location;
|
|
298
|
-
let newLocation = location;
|
|
299
|
-
if (!_slate.Point.equals(anchor, focus)) {
|
|
300
|
-
const frontPoint = _slate.Editor.start(editor, location);
|
|
301
|
-
newLocation = {
|
|
302
|
-
anchor: frontPoint,
|
|
303
|
-
focus: frontPoint
|
|
304
|
-
};
|
|
305
|
-
}
|
|
306
|
-
(0, _helper.setCursor)(editor, user, newLocation, cursorData);
|
|
307
|
-
|
|
308
|
-
// sync cursor position
|
|
309
|
-
editor.onCursor && editor.onCursor(editor.cursors);
|
|
310
|
-
}
|
|
311
|
-
};
|
|
312
|
-
exports.syncRemoteCursorLocation = syncRemoteCursorLocation;
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.default = void 0;
|
|
7
|
-
const KebabToCamel = str => {
|
|
8
|
-
return str.replace(/(_[a-z])/g, match => `${match.slice(1).toUpperCase()}`);
|
|
9
|
-
};
|
|
10
|
-
var _default = exports.default = KebabToCamel;
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.default = void 0;
|
|
7
|
-
/**
|
|
8
|
-
* @param {Function} fn
|
|
9
|
-
* @param {Number} delay
|
|
10
|
-
*/
|
|
11
|
-
const debounce = (fn, delay) => {
|
|
12
|
-
let timeout = null;
|
|
13
|
-
return function () {
|
|
14
|
-
clearTimeout(timeout);
|
|
15
|
-
timeout = setTimeout(() => {
|
|
16
|
-
fn.apply(this, arguments);
|
|
17
|
-
}, delay);
|
|
18
|
-
};
|
|
19
|
-
};
|
|
20
|
-
var _default = exports.default = debounce;
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
|
|
4
|
-
Object.defineProperty(exports, "__esModule", {
|
|
5
|
-
value: true
|
|
6
|
-
});
|
|
7
|
-
exports.stateDebug = exports.serverDebug = exports.conflictDebug = exports.clientDebug = void 0;
|
|
8
|
-
var _debug = _interopRequireDefault(require("debug"));
|
|
9
|
-
const stateDebug = exports.stateDebug = (0, _debug.default)('sdoc:state-change');
|
|
10
|
-
stateDebug.enabled = true;
|
|
11
|
-
stateDebug.log = console.log;
|
|
12
|
-
const clientDebug = exports.clientDebug = (0, _debug.default)('sdoc:socket-client');
|
|
13
|
-
clientDebug.enabled = true;
|
|
14
|
-
clientDebug.log = console.log;
|
|
15
|
-
const serverDebug = exports.serverDebug = (0, _debug.default)('sdoc:socket-server');
|
|
16
|
-
serverDebug.enabled = true;
|
|
17
|
-
serverDebug.log = console.log;
|
|
18
|
-
const conflictDebug = exports.conflictDebug = (0, _debug.default)('sdoc:sdoc-conflict');
|
|
19
|
-
conflictDebug.enabled = true;
|
|
20
|
-
conflictDebug.log = console.log;
|
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
|
|
4
|
-
Object.defineProperty(exports, "__esModule", {
|
|
5
|
-
value: true
|
|
6
|
-
});
|
|
7
|
-
exports.getStyleByDefaultMode = void 0;
|
|
8
|
-
var _constants = require("../constants");
|
|
9
|
-
var _localStorageUtils = _interopRequireDefault(require("./local-storage-utils"));
|
|
10
|
-
const getStyleByDefaultMode = (scrollRef, editor) => {
|
|
11
|
-
const sdocStorage = _localStorageUtils.default.getItem(_constants.SDOC_STORAGE) || {};
|
|
12
|
-
const {
|
|
13
|
-
outlineOpen: isShowOutline
|
|
14
|
-
} = sdocStorage;
|
|
15
|
-
const containerStyle = {
|
|
16
|
-
width: _constants.ARTICLE_DEFAULT_WIDTH
|
|
17
|
-
};
|
|
18
|
-
|
|
19
|
-
// Has outline
|
|
20
|
-
if (isShowOutline && editor.editorType !== _constants.WIKI_EDITOR) {
|
|
21
|
-
const rect = scrollRef.current.getBoundingClientRect();
|
|
22
|
-
if ((rect.width - Number(_constants.ARTICLE_DEFAULT_WIDTH.slice(0, 3))) / 2 < 280) {
|
|
23
|
-
containerStyle['marginLeft'] = `${_constants.LEFT_OUTLINE_WIDTH}px`;
|
|
24
|
-
}
|
|
25
|
-
}
|
|
26
|
-
return containerStyle;
|
|
27
|
-
};
|
|
28
|
-
exports.getStyleByDefaultMode = getStyleByDefaultMode;
|
|
@@ -1,297 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
|
|
4
|
-
Object.defineProperty(exports, "__esModule", {
|
|
5
|
-
value: true
|
|
6
|
-
});
|
|
7
|
-
exports.default = void 0;
|
|
8
|
-
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/esm/defineProperty"));
|
|
9
|
-
var _objectUtils = _interopRequireDefault(require("./object-utils"));
|
|
10
|
-
const extendedWordChars = 'a-zA-Z\\u{C0}-\\u{FF}\\u{D8}-\\u{F6}\\u{F8}-\\u{2C6}\\u{2C8}-\\u{2D7}\\u{2DE}-\\u{2FF}\\u{1E00}-\\u{1EFF}\\u{4e00}-\\u{9fa5}';
|
|
11
|
-
const tokenizeIncludingWhitespace = new RegExp(`[${extendedWordChars}]+|\\s+|[^${extendedWordChars}]`, 'ug');
|
|
12
|
-
const buildValues = (diff, components, newString, oldString, valueType, useLongestToken) => {
|
|
13
|
-
let componentPos = 0;
|
|
14
|
-
let componentLen = components.length;
|
|
15
|
-
let newPos = 0;
|
|
16
|
-
let oldPos = 0;
|
|
17
|
-
for (; componentPos < componentLen; componentPos++) {
|
|
18
|
-
let component = components[componentPos];
|
|
19
|
-
if (!component.removed) {
|
|
20
|
-
if (!component.added && useLongestToken) {
|
|
21
|
-
let value = newString.slice(newPos, newPos + component.count);
|
|
22
|
-
// eslint-disable-next-line no-loop-func
|
|
23
|
-
value = value.map((value, i) => {
|
|
24
|
-
let oldValue = oldString[oldPos + i];
|
|
25
|
-
return oldValue.length > value.length ? oldValue : value;
|
|
26
|
-
});
|
|
27
|
-
component.value = diff.join(value, valueType);
|
|
28
|
-
} else {
|
|
29
|
-
component.value = diff.join(newString.slice(newPos, newPos + component.count), valueType);
|
|
30
|
-
}
|
|
31
|
-
newPos += component.count;
|
|
32
|
-
|
|
33
|
-
// Common case
|
|
34
|
-
if (!component.added) {
|
|
35
|
-
oldPos += component.count;
|
|
36
|
-
}
|
|
37
|
-
} else {
|
|
38
|
-
component.value = diff.join(oldString.slice(oldPos, oldPos + component.count), valueType);
|
|
39
|
-
oldPos += component.count;
|
|
40
|
-
|
|
41
|
-
// Reverse add and remove so removes are output first to match common convention
|
|
42
|
-
// The diffing algorithm is tied to add then remove output and this is the simplest
|
|
43
|
-
// route to get the desired output with minimal overhead.
|
|
44
|
-
if (componentPos && components[componentPos - 1].added) {
|
|
45
|
-
let tmp = components[componentPos - 1];
|
|
46
|
-
components[componentPos - 1] = components[componentPos];
|
|
47
|
-
components[componentPos] = tmp;
|
|
48
|
-
}
|
|
49
|
-
}
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
// Special case handle for when one terminal is ignored (i.e. whitespace).
|
|
53
|
-
// For this case we merge the terminal into the prior string and drop the change.
|
|
54
|
-
// This is only available for string mode.
|
|
55
|
-
let lastComponent = components[componentLen - 1];
|
|
56
|
-
if (componentLen > 1 && typeof lastComponent.value === 'string' && (lastComponent.added || lastComponent.removed) && diff.equals('', lastComponent.value)) {
|
|
57
|
-
components[componentLen - 2].value += lastComponent.value;
|
|
58
|
-
components.pop();
|
|
59
|
-
}
|
|
60
|
-
return components;
|
|
61
|
-
};
|
|
62
|
-
const clonePath = path => {
|
|
63
|
-
return {
|
|
64
|
-
newPos: path.newPos,
|
|
65
|
-
components: path.components.slice(0)
|
|
66
|
-
};
|
|
67
|
-
};
|
|
68
|
-
class DiffText {
|
|
69
|
-
constructor(oldValue, newValue) {
|
|
70
|
-
let options = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
|
|
71
|
-
(0, _defineProperty2.default)(this, "done", value => {
|
|
72
|
-
if (this.callback) {
|
|
73
|
-
setTimeout(function () {
|
|
74
|
-
this.callback(undefined, value);
|
|
75
|
-
}, 0);
|
|
76
|
-
return true;
|
|
77
|
-
}
|
|
78
|
-
return value;
|
|
79
|
-
});
|
|
80
|
-
// Main worker method. checks all permutations of a given edit length for acceptance.
|
|
81
|
-
(0, _defineProperty2.default)(this, "execCompareLength", bestPath => {
|
|
82
|
-
for (let diagonalPath = -1 * this.comparePath; diagonalPath <= this.comparePath; diagonalPath += 2) {
|
|
83
|
-
let basePath;
|
|
84
|
-
let addPath = bestPath[diagonalPath - 1];
|
|
85
|
-
let removePath = bestPath[diagonalPath + 1];
|
|
86
|
-
let oldPos = (removePath ? removePath.newPos : 0) - diagonalPath;
|
|
87
|
-
if (addPath) {
|
|
88
|
-
// No one else is going to attempt to use this value, clear it
|
|
89
|
-
bestPath[diagonalPath - 1] = undefined;
|
|
90
|
-
}
|
|
91
|
-
let canAdd = addPath && addPath.newPos + 1 < this.newLen;
|
|
92
|
-
let canRemove = removePath && 0 <= oldPos && oldPos < this.oldLen;
|
|
93
|
-
if (!canAdd && !canRemove) {
|
|
94
|
-
// If this path is a terminal then prune
|
|
95
|
-
bestPath[diagonalPath] = undefined;
|
|
96
|
-
continue;
|
|
97
|
-
}
|
|
98
|
-
|
|
99
|
-
// Select the diagonal that we want to branch from. We select the prior
|
|
100
|
-
// path whose position in the new string is the farthest from the origin
|
|
101
|
-
// and does not pass the bounds of the diff graph
|
|
102
|
-
if (!canAdd || canRemove && addPath.newPos < removePath.newPos) {
|
|
103
|
-
basePath = clonePath(removePath);
|
|
104
|
-
this.pushComponent(basePath.components, undefined, true);
|
|
105
|
-
} else {
|
|
106
|
-
basePath = addPath; // No need to clone, we've pulled it from the list
|
|
107
|
-
basePath.newPos++;
|
|
108
|
-
this.pushComponent(basePath.components, true, undefined);
|
|
109
|
-
}
|
|
110
|
-
oldPos = this.extractCommon(basePath, this.newValue, this.oldValue, diagonalPath);
|
|
111
|
-
|
|
112
|
-
// If we have hit the end of both strings, then we are done
|
|
113
|
-
if (basePath.newPos + 1 >= this.newLen && oldPos + 1 >= this.oldLen) {
|
|
114
|
-
return this.done(buildValues(this, basePath.components, this.newValue, this.oldValue, this.valueType, this.useLongestToken));
|
|
115
|
-
} else {
|
|
116
|
-
// Otherwise track this path as a potential candidate and continue.
|
|
117
|
-
bestPath[diagonalPath] = basePath;
|
|
118
|
-
}
|
|
119
|
-
}
|
|
120
|
-
this.comparePath++;
|
|
121
|
-
});
|
|
122
|
-
(0, _defineProperty2.default)(this, "exec", bestPath => {
|
|
123
|
-
setTimeout(function () {
|
|
124
|
-
if (this.comparePath > this.maxEditLength) {
|
|
125
|
-
return this.callback();
|
|
126
|
-
}
|
|
127
|
-
if (!this.execCompareLength(bestPath)) {
|
|
128
|
-
this.exec(bestPath);
|
|
129
|
-
}
|
|
130
|
-
}, 0);
|
|
131
|
-
});
|
|
132
|
-
(0, _defineProperty2.default)(this, "pushComponent", (components, added, removed) => {
|
|
133
|
-
let last = components[components.length - 1];
|
|
134
|
-
if (last && last.added === added && last.removed === removed) {
|
|
135
|
-
// We need to clone here as the component clone operation is just
|
|
136
|
-
// as shallow array clone
|
|
137
|
-
components[components.length - 1] = {
|
|
138
|
-
count: last.count + 1,
|
|
139
|
-
added: added,
|
|
140
|
-
removed: removed
|
|
141
|
-
};
|
|
142
|
-
} else {
|
|
143
|
-
components.push({
|
|
144
|
-
count: 1,
|
|
145
|
-
added: added,
|
|
146
|
-
removed: removed
|
|
147
|
-
});
|
|
148
|
-
}
|
|
149
|
-
});
|
|
150
|
-
(0, _defineProperty2.default)(this, "extractCommon", (basePath, newString, oldString, diagonalPath) => {
|
|
151
|
-
let newLen = newString.length;
|
|
152
|
-
let oldLen = oldString.length;
|
|
153
|
-
let newPos = basePath.newPos;
|
|
154
|
-
let oldPos = newPos - diagonalPath;
|
|
155
|
-
let commonCount = 0;
|
|
156
|
-
while (newPos + 1 < newLen && oldPos + 1 < oldLen && this.equals(newString[newPos + 1], oldString[oldPos + 1])) {
|
|
157
|
-
newPos++;
|
|
158
|
-
oldPos++;
|
|
159
|
-
commonCount++;
|
|
160
|
-
}
|
|
161
|
-
if (commonCount) {
|
|
162
|
-
basePath.components.push({
|
|
163
|
-
count: commonCount
|
|
164
|
-
});
|
|
165
|
-
}
|
|
166
|
-
basePath.newPos = newPos;
|
|
167
|
-
return oldPos;
|
|
168
|
-
});
|
|
169
|
-
(0, _defineProperty2.default)(this, "equals", (left, right) => {
|
|
170
|
-
if (this.options.ignoreCase) {
|
|
171
|
-
left = left.toLowerCase();
|
|
172
|
-
right = right.toLowerCase();
|
|
173
|
-
}
|
|
174
|
-
return left.trim() === right.trim();
|
|
175
|
-
});
|
|
176
|
-
(0, _defineProperty2.default)(this, "removeEmpty", (array, type) => {
|
|
177
|
-
if (type === 'Array') return array;
|
|
178
|
-
let ret = [];
|
|
179
|
-
for (let i = 0; i < array.length; i++) {
|
|
180
|
-
if (array[i]) {
|
|
181
|
-
ret.push(array[i]);
|
|
182
|
-
}
|
|
183
|
-
}
|
|
184
|
-
return ret;
|
|
185
|
-
});
|
|
186
|
-
(0, _defineProperty2.default)(this, "tokenize", (value, valueType) => {
|
|
187
|
-
if (valueType === 'Array') {
|
|
188
|
-
return value.slice();
|
|
189
|
-
}
|
|
190
|
-
let parts = value.match(tokenizeIncludingWhitespace) || [];
|
|
191
|
-
const tokens = [];
|
|
192
|
-
let prevPart = null;
|
|
193
|
-
parts.forEach(part => {
|
|
194
|
-
if (/\s/.test(part)) {
|
|
195
|
-
if (prevPart == null) {
|
|
196
|
-
tokens.push(part);
|
|
197
|
-
} else {
|
|
198
|
-
tokens.push(tokens.pop() + part);
|
|
199
|
-
}
|
|
200
|
-
} else if (/\s/.test(prevPart)) {
|
|
201
|
-
if (tokens[tokens.length - 1] === prevPart) {
|
|
202
|
-
tokens.push(tokens.pop() + part);
|
|
203
|
-
} else {
|
|
204
|
-
tokens.push(prevPart + part);
|
|
205
|
-
}
|
|
206
|
-
} else {
|
|
207
|
-
tokens.push(part);
|
|
208
|
-
}
|
|
209
|
-
prevPart = part;
|
|
210
|
-
});
|
|
211
|
-
return tokens;
|
|
212
|
-
});
|
|
213
|
-
(0, _defineProperty2.default)(this, "join", (value, valueType) => {
|
|
214
|
-
if (valueType === 'Array') return value;
|
|
215
|
-
// Tokens being joined here will always have appeared consecutively in the
|
|
216
|
-
// same text, so we can simply strip off the leading whitespace from all the
|
|
217
|
-
// tokens except the first (and except any whitespace-only tokens - but such
|
|
218
|
-
// a token will always be the first and only token anyway) and then join them
|
|
219
|
-
// and the whitespace around words and punctuation will end up correct.
|
|
220
|
-
return value.map((token, i) => {
|
|
221
|
-
if (i === 0) {
|
|
222
|
-
return token;
|
|
223
|
-
} else {
|
|
224
|
-
return token.replace(/^\s+/, '');
|
|
225
|
-
}
|
|
226
|
-
}).join('');
|
|
227
|
-
});
|
|
228
|
-
(0, _defineProperty2.default)(this, "getDiffs", () => {
|
|
229
|
-
if (!this.canCompare) {
|
|
230
|
-
return [{
|
|
231
|
-
value: this.oldValue,
|
|
232
|
-
removed: true
|
|
233
|
-
}, {
|
|
234
|
-
value: this.newValue,
|
|
235
|
-
added: true
|
|
236
|
-
}];
|
|
237
|
-
}
|
|
238
|
-
let bestPath = [{
|
|
239
|
-
newPos: -1,
|
|
240
|
-
components: []
|
|
241
|
-
}];
|
|
242
|
-
|
|
243
|
-
// Seed editLength = 0, i.e. the content starts with the same values
|
|
244
|
-
let oldPos = this.extractCommon(bestPath[0], this.newValue, this.oldValue, 0);
|
|
245
|
-
if (bestPath[0].newPos + 1 >= this.newLen && oldPos + 1 >= this.oldLen) {
|
|
246
|
-
// Identity per the equality and tokenizer
|
|
247
|
-
return this.done([{
|
|
248
|
-
value: this.join(this.newValue, this.valueType),
|
|
249
|
-
count: this.oldValue.length
|
|
250
|
-
}]);
|
|
251
|
-
}
|
|
252
|
-
|
|
253
|
-
// Performs the length of edit iteration. Is a bit fugly as this has to support the
|
|
254
|
-
// sync and async mode which is never fun. Loops over execCompareLength until a value
|
|
255
|
-
// is produced, or until the edit length exceeds options.maxEditLength (if given),
|
|
256
|
-
// in which case it will return undefined.
|
|
257
|
-
if (this.callback) {
|
|
258
|
-
this.exec(bestPath);
|
|
259
|
-
} else {
|
|
260
|
-
while (this.comparePath <= this.maxEditLength) {
|
|
261
|
-
let ret = this.execCompareLength(bestPath);
|
|
262
|
-
if (ret) {
|
|
263
|
-
return ret;
|
|
264
|
-
}
|
|
265
|
-
}
|
|
266
|
-
}
|
|
267
|
-
});
|
|
268
|
-
this.oldValue = oldValue;
|
|
269
|
-
this.newValue = newValue;
|
|
270
|
-
const oldValueType = _objectUtils.default.getDataType(oldValue);
|
|
271
|
-
const newValueType = _objectUtils.default.getDataType(newValue);
|
|
272
|
-
this.canCompare = true;
|
|
273
|
-
if (oldValueType !== newValueType) {
|
|
274
|
-
this.canCompare = false;
|
|
275
|
-
return;
|
|
276
|
-
}
|
|
277
|
-
this.valueType = newValueType;
|
|
278
|
-
this.callback = options.callback;
|
|
279
|
-
const optionsType = _objectUtils.default.getDataType(options);
|
|
280
|
-
if (optionsType === 'function') {
|
|
281
|
-
this.callback = options;
|
|
282
|
-
this.options = {};
|
|
283
|
-
} else {
|
|
284
|
-
this.options = {};
|
|
285
|
-
}
|
|
286
|
-
this.comparePath = 1;
|
|
287
|
-
this.oldValue = this.removeEmpty(this.tokenize(oldValue, oldValueType), oldValueType);
|
|
288
|
-
this.oldLen = this.oldValue.length;
|
|
289
|
-
this.newValue = this.removeEmpty(this.tokenize(newValue, newValueType), newValueType);
|
|
290
|
-
this.newLen = this.newValue.length;
|
|
291
|
-
this.maxEditLength = this.newLen + this.oldLen;
|
|
292
|
-
if (this.options.maxEditLength) {
|
|
293
|
-
this.maxEditLength = Math.min(this.maxEditLength, this.options.maxEditLength);
|
|
294
|
-
}
|
|
295
|
-
}
|
|
296
|
-
}
|
|
297
|
-
var _default = exports.default = DiffText;
|