@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,17 +1,19 @@
|
|
|
1
1
|
import React, { useEffect, useRef } from 'react';
|
|
2
2
|
import CommentEditor from '../comment-editor';
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
3
|
+
const GlobalCommentEditor = _ref => {
|
|
4
|
+
let {
|
|
5
|
+
insertDocComment,
|
|
6
|
+
hiddenCommentEditor
|
|
7
|
+
} = _ref;
|
|
8
|
+
const ref = useRef(null);
|
|
9
|
+
useEffect(() => {
|
|
10
|
+
const hidden = event => {
|
|
9
11
|
if (!ref.current.contains(event.target)) {
|
|
10
12
|
hiddenCommentEditor();
|
|
11
13
|
}
|
|
12
14
|
};
|
|
13
15
|
document.addEventListener('click', hidden);
|
|
14
|
-
return
|
|
16
|
+
return () => {
|
|
15
17
|
document.removeEventListener('click', hidden);
|
|
16
18
|
};
|
|
17
19
|
|
|
@@ -1,12 +1,15 @@
|
|
|
1
1
|
import React, { useCallback } from 'react';
|
|
2
2
|
import { useTranslation } from 'react-i18next';
|
|
3
3
|
import { eventStopPropagation } from '../../../utils/mouse-event';
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
4
|
+
const GlobalCommentHeader = _ref => {
|
|
5
|
+
let {
|
|
6
|
+
toggle,
|
|
7
|
+
toggleGlobalCommentEditor
|
|
8
|
+
} = _ref;
|
|
9
|
+
const {
|
|
10
|
+
t
|
|
11
|
+
} = useTranslation();
|
|
12
|
+
const toggleADDComment = useCallback(event => {
|
|
10
13
|
eventStopPropagation(event);
|
|
11
14
|
toggleGlobalCommentEditor();
|
|
12
15
|
}, [toggleGlobalCommentEditor]);
|
|
@@ -1,7 +1,4 @@
|
|
|
1
1
|
import _objectSpread from "@babel/runtime/helpers/esm/objectSpread2";
|
|
2
|
-
import _asyncToGenerator from "@babel/runtime/helpers/esm/asyncToGenerator";
|
|
3
|
-
import _slicedToArray from "@babel/runtime/helpers/esm/slicedToArray";
|
|
4
|
-
function _regeneratorRuntime() { "use strict"; /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */ _regeneratorRuntime = function _regeneratorRuntime() { return e; }; var t, e = {}, r = Object.prototype, n = r.hasOwnProperty, o = Object.defineProperty || function (t, e, r) { t[e] = r.value; }, i = "function" == typeof Symbol ? Symbol : {}, a = i.iterator || "@@iterator", c = i.asyncIterator || "@@asyncIterator", u = i.toStringTag || "@@toStringTag"; function define(t, e, r) { return Object.defineProperty(t, e, { value: r, enumerable: !0, configurable: !0, writable: !0 }), t[e]; } try { define({}, ""); } catch (t) { define = function define(t, e, r) { return t[e] = r; }; } function wrap(t, e, r, n) { var i = e && e.prototype instanceof Generator ? e : Generator, a = Object.create(i.prototype), c = new Context(n || []); return o(a, "_invoke", { value: makeInvokeMethod(t, r, c) }), a; } function tryCatch(t, e, r) { try { return { type: "normal", arg: t.call(e, r) }; } catch (t) { return { type: "throw", arg: t }; } } e.wrap = wrap; var h = "suspendedStart", l = "suspendedYield", f = "executing", s = "completed", y = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} var p = {}; define(p, a, function () { return this; }); var d = Object.getPrototypeOf, v = d && d(d(values([]))); v && v !== r && n.call(v, a) && (p = v); var g = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(p); function defineIteratorMethods(t) { ["next", "throw", "return"].forEach(function (e) { define(t, e, function (t) { return this._invoke(e, t); }); }); } function AsyncIterator(t, e) { function invoke(r, o, i, a) { var c = tryCatch(t[r], t, o); if ("throw" !== c.type) { var u = c.arg, h = u.value; return h && "object" == typeof h && n.call(h, "__await") ? e.resolve(h.__await).then(function (t) { invoke("next", t, i, a); }, function (t) { invoke("throw", t, i, a); }) : e.resolve(h).then(function (t) { u.value = t, i(u); }, function (t) { return invoke("throw", t, i, a); }); } a(c.arg); } var r; o(this, "_invoke", { value: function value(t, n) { function callInvokeWithMethodAndArg() { return new e(function (e, r) { invoke(t, n, e, r); }); } return r = r ? r.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg(); } }); } function makeInvokeMethod(e, r, n) { var o = h; return function (i, a) { if (o === f) throw new Error("Generator is already running"); if (o === s) { if ("throw" === i) throw a; return { value: t, done: !0 }; } for (n.method = i, n.arg = a;;) { var c = n.delegate; if (c) { var u = maybeInvokeDelegate(c, n); if (u) { if (u === y) continue; return u; } } if ("next" === n.method) n.sent = n._sent = n.arg;else if ("throw" === n.method) { if (o === h) throw o = s, n.arg; n.dispatchException(n.arg); } else "return" === n.method && n.abrupt("return", n.arg); o = f; var p = tryCatch(e, r, n); if ("normal" === p.type) { if (o = n.done ? s : l, p.arg === y) continue; return { value: p.arg, done: n.done }; } "throw" === p.type && (o = s, n.method = "throw", n.arg = p.arg); } }; } function maybeInvokeDelegate(e, r) { var n = r.method, o = e.iterator[n]; if (o === t) return r.delegate = null, "throw" === n && e.iterator.return && (r.method = "return", r.arg = t, maybeInvokeDelegate(e, r), "throw" === r.method) || "return" !== n && (r.method = "throw", r.arg = new TypeError("The iterator does not provide a '" + n + "' method")), y; var i = tryCatch(o, e.iterator, r.arg); if ("throw" === i.type) return r.method = "throw", r.arg = i.arg, r.delegate = null, y; var a = i.arg; return a ? a.done ? (r[e.resultName] = a.value, r.next = e.nextLoc, "return" !== r.method && (r.method = "next", r.arg = t), r.delegate = null, y) : a : (r.method = "throw", r.arg = new TypeError("iterator result is not an object"), r.delegate = null, y); } function pushTryEntry(t) { var e = { tryLoc: t[0] }; 1 in t && (e.catchLoc = t[1]), 2 in t && (e.finallyLoc = t[2], e.afterLoc = t[3]), this.tryEntries.push(e); } function resetTryEntry(t) { var e = t.completion || {}; e.type = "normal", delete e.arg, t.completion = e; } function Context(t) { this.tryEntries = [{ tryLoc: "root" }], t.forEach(pushTryEntry, this), this.reset(!0); } function values(e) { if (e || "" === e) { var r = e[a]; if (r) return r.call(e); if ("function" == typeof e.next) return e; if (!isNaN(e.length)) { var o = -1, i = function next() { for (; ++o < e.length;) if (n.call(e, o)) return next.value = e[o], next.done = !1, next; return next.value = t, next.done = !0, next; }; return i.next = i; } } throw new TypeError(typeof e + " is not iterable"); } return GeneratorFunction.prototype = GeneratorFunctionPrototype, o(g, "constructor", { value: GeneratorFunctionPrototype, configurable: !0 }), o(GeneratorFunctionPrototype, "constructor", { value: GeneratorFunction, configurable: !0 }), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, u, "GeneratorFunction"), e.isGeneratorFunction = function (t) { var e = "function" == typeof t && t.constructor; return !!e && (e === GeneratorFunction || "GeneratorFunction" === (e.displayName || e.name)); }, e.mark = function (t) { return Object.setPrototypeOf ? Object.setPrototypeOf(t, GeneratorFunctionPrototype) : (t.__proto__ = GeneratorFunctionPrototype, define(t, u, "GeneratorFunction")), t.prototype = Object.create(g), t; }, e.awrap = function (t) { return { __await: t }; }, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, c, function () { return this; }), e.AsyncIterator = AsyncIterator, e.async = function (t, r, n, o, i) { void 0 === i && (i = Promise); var a = new AsyncIterator(wrap(t, r, n, o), i); return e.isGeneratorFunction(r) ? a : a.next().then(function (t) { return t.done ? t.value : a.next(); }); }, defineIteratorMethods(g), define(g, u, "Generator"), define(g, a, function () { return this; }), define(g, "toString", function () { return "[object Generator]"; }), e.keys = function (t) { var e = Object(t), r = []; for (var n in e) r.push(n); return r.reverse(), function next() { for (; r.length;) { var t = r.pop(); if (t in e) return next.value = t, next.done = !1, next; } return next.done = !0, next; }; }, e.values = values, Context.prototype = { constructor: Context, reset: function reset(e) { if (this.prev = 0, this.next = 0, this.sent = this._sent = t, this.done = !1, this.delegate = null, this.method = "next", this.arg = t, this.tryEntries.forEach(resetTryEntry), !e) for (var r in this) "t" === r.charAt(0) && n.call(this, r) && !isNaN(+r.slice(1)) && (this[r] = t); }, stop: function stop() { this.done = !0; var t = this.tryEntries[0].completion; if ("throw" === t.type) throw t.arg; return this.rval; }, dispatchException: function dispatchException(e) { if (this.done) throw e; var r = this; function handle(n, o) { return a.type = "throw", a.arg = e, r.next = n, o && (r.method = "next", r.arg = t), !!o; } for (var o = this.tryEntries.length - 1; o >= 0; --o) { var i = this.tryEntries[o], a = i.completion; if ("root" === i.tryLoc) return handle("end"); if (i.tryLoc <= this.prev) { var c = n.call(i, "catchLoc"), u = n.call(i, "finallyLoc"); if (c && u) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } else if (c) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); } else { if (!u) throw new Error("try statement without catch or finally"); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } } } }, abrupt: function abrupt(t, e) { for (var r = this.tryEntries.length - 1; r >= 0; --r) { var o = this.tryEntries[r]; if (o.tryLoc <= this.prev && n.call(o, "finallyLoc") && this.prev < o.finallyLoc) { var i = o; break; } } i && ("break" === t || "continue" === t) && i.tryLoc <= e && e <= i.finallyLoc && (i = null); var a = i ? i.completion : {}; return a.type = t, a.arg = e, i ? (this.method = "next", this.next = i.finallyLoc, y) : this.complete(a); }, complete: function complete(t, e) { if ("throw" === t.type) throw t.arg; return "break" === t.type || "continue" === t.type ? this.next = t.arg : "return" === t.type ? (this.rval = this.arg = t.arg, this.method = "return", this.next = "end") : "normal" === t.type && e && (this.next = e), y; }, finish: function finish(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.finallyLoc === t) return this.complete(r.completion, r.afterLoc), resetTryEntry(r), y; } }, catch: function _catch(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.tryLoc === t) { var n = r.completion; if ("throw" === n.type) { var o = n.arg; resetTryEntry(r); } return o; } } throw new Error("illegal catch attempt"); }, delegateYield: function delegateYield(e, r, n) { return this.delegate = { iterator: values(e), resultName: r, nextLoc: n }, "next" === this.method && (this.arg = t), y; } }, e; }
|
|
5
2
|
import React, { useCallback, useEffect, useRef, useState } from 'react';
|
|
6
3
|
import dayjs from 'dayjs';
|
|
7
4
|
import { useSlateStatic } from '@seafile/slate-react';
|
|
@@ -18,28 +15,22 @@ import GlobalCommentEditor from './global-comment-editor';
|
|
|
18
15
|
import { INTERNAL_EVENT } from '../../../constants';
|
|
19
16
|
import { getNodeById } from '../../../extension/core';
|
|
20
17
|
import './index.css';
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
var _useState5 = useState(false),
|
|
38
|
-
_useState6 = _slicedToArray(_useState5, 2),
|
|
39
|
-
showEditor = _useState6[0],
|
|
40
|
-
setShowEditor = _useState6[1];
|
|
41
|
-
var editor = useSlateStatic();
|
|
42
|
-
var toggle = useCallback(function () {
|
|
18
|
+
const GlobalComment = _ref => {
|
|
19
|
+
let {
|
|
20
|
+
deleteUnseenNotifications
|
|
21
|
+
} = _ref;
|
|
22
|
+
const [activeComment, setActiveComment] = useState(null);
|
|
23
|
+
const commentRef = useRef(null);
|
|
24
|
+
const contentRef = useRef(null);
|
|
25
|
+
const {
|
|
26
|
+
commentList,
|
|
27
|
+
commentType,
|
|
28
|
+
setCommentType
|
|
29
|
+
} = useCommentList();
|
|
30
|
+
const [isShowCommentList, setShowCommentList] = useState(false);
|
|
31
|
+
const [showEditor, setShowEditor] = useState(false);
|
|
32
|
+
const editor = useSlateStatic();
|
|
33
|
+
const toggle = useCallback(() => {
|
|
43
34
|
if (isShowCommentList) {
|
|
44
35
|
setActiveComment(null);
|
|
45
36
|
setShowCommentList(false);
|
|
@@ -48,83 +39,69 @@ var GlobalComment = function GlobalComment(_ref) {
|
|
|
48
39
|
}
|
|
49
40
|
setShowCommentList(true);
|
|
50
41
|
}, [isShowCommentList]);
|
|
51
|
-
useEffect(
|
|
42
|
+
useEffect(() => {
|
|
52
43
|
if (!isShowCommentList) return;
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
44
|
+
const toggleOuterSide = e => {
|
|
45
|
+
const commentWrapper = commentRef.current;
|
|
46
|
+
const clickIsInComment = commentWrapper && commentWrapper.contains(e.target) && commentWrapper !== e.target;
|
|
56
47
|
if (clickIsInComment) return;
|
|
57
48
|
toggle();
|
|
58
49
|
};
|
|
59
50
|
document.addEventListener('click', toggleOuterSide);
|
|
60
|
-
return
|
|
51
|
+
return () => {
|
|
61
52
|
document.removeEventListener('click', toggleOuterSide);
|
|
62
53
|
};
|
|
63
54
|
}, [isShowCommentList, toggle]);
|
|
64
|
-
useEffect(
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
return
|
|
55
|
+
useEffect(() => {
|
|
56
|
+
const eventBus = EventBus.getInstance();
|
|
57
|
+
const unsubscribe = eventBus.subscribe(INTERNAL_EVENT.COMMENT_LIST_CLICK, toggle);
|
|
58
|
+
return () => {
|
|
68
59
|
unsubscribe();
|
|
69
60
|
};
|
|
70
61
|
}, [toggle]);
|
|
71
|
-
|
|
72
|
-
|
|
62
|
+
const updateScrollPosition = useCallback(() => {
|
|
63
|
+
const resolvedDom = document.querySelector('.sdoc-resolved');
|
|
73
64
|
contentRef.current.scrollTo({
|
|
74
65
|
top: resolvedDom.offsetTop,
|
|
75
66
|
behavior: 'smooth'
|
|
76
67
|
});
|
|
77
68
|
}, []);
|
|
78
|
-
|
|
69
|
+
const hiddenComment = useCallback(() => {
|
|
79
70
|
setActiveComment(null);
|
|
80
71
|
}, []);
|
|
81
|
-
|
|
72
|
+
const onCommentClick = useCallback(comment => {
|
|
82
73
|
if (activeComment && activeComment.id === comment.id) return;
|
|
83
74
|
setActiveComment(comment);
|
|
84
75
|
deleteUnseenNotifications && deleteUnseenNotifications(comment);
|
|
85
76
|
}, [activeComment, deleteUnseenNotifications]);
|
|
86
|
-
|
|
87
|
-
dispatch
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
case "end":
|
|
115
|
-
return _context.stop();
|
|
116
|
-
}
|
|
117
|
-
}, _callee);
|
|
118
|
-
}));
|
|
119
|
-
return function (_x, _x2) {
|
|
120
|
-
return _ref2.apply(this, arguments);
|
|
121
|
-
};
|
|
122
|
-
}(), [dispatch]);
|
|
123
|
-
var insertDocComment = useCallback(function (commentDetail) {
|
|
124
|
-
var user = context.getUserInfo();
|
|
125
|
-
var elementId = DOC_COMMENT_ELEMENT_ID;
|
|
126
|
-
var time = dayjs().format('YYYY-MM-DD HH:mm:ss');
|
|
127
|
-
var comment = {
|
|
77
|
+
const {
|
|
78
|
+
dispatch
|
|
79
|
+
} = useCommentContext();
|
|
80
|
+
const insertComment = useCallback(async (elementId, comment) => {
|
|
81
|
+
const res = await context.insertComment(comment);
|
|
82
|
+
const {
|
|
83
|
+
comment: returnComment
|
|
84
|
+
} = res.data;
|
|
85
|
+
const newComment = _objectSpread(_objectSpread({}, comment), {}, {
|
|
86
|
+
id: returnComment.id,
|
|
87
|
+
user_name: returnComment.user_name,
|
|
88
|
+
avatar_url: returnComment.avatar_url,
|
|
89
|
+
replies: []
|
|
90
|
+
});
|
|
91
|
+
dispatch({
|
|
92
|
+
type: 'INSERT_COMMENT',
|
|
93
|
+
payload: {
|
|
94
|
+
element_id: elementId,
|
|
95
|
+
comment: newComment
|
|
96
|
+
}
|
|
97
|
+
});
|
|
98
|
+
setShowEditor(false);
|
|
99
|
+
}, [dispatch]);
|
|
100
|
+
const insertDocComment = useCallback(commentDetail => {
|
|
101
|
+
const user = context.getUserInfo();
|
|
102
|
+
const elementId = DOC_COMMENT_ELEMENT_ID;
|
|
103
|
+
const time = dayjs().format('YYYY-MM-DD HH:mm:ss');
|
|
104
|
+
const comment = {
|
|
128
105
|
comment: commentDetail,
|
|
129
106
|
detail: {
|
|
130
107
|
element_id: elementId,
|
|
@@ -135,11 +112,11 @@ var GlobalComment = function GlobalComment(_ref) {
|
|
|
135
112
|
};
|
|
136
113
|
insertComment(elementId, comment);
|
|
137
114
|
}, [insertComment]);
|
|
138
|
-
|
|
115
|
+
const toggleGlobalCommentEditor = useCallback(() => {
|
|
139
116
|
setShowEditor(!showEditor);
|
|
140
117
|
setActiveComment(null);
|
|
141
118
|
}, [showEditor]);
|
|
142
|
-
|
|
119
|
+
const hiddenCommentEditor = useCallback(() => {
|
|
143
120
|
setShowEditor(false);
|
|
144
121
|
}, []);
|
|
145
122
|
if (!isShowCommentList) return null;
|
|
@@ -163,11 +140,11 @@ var GlobalComment = function GlobalComment(_ref) {
|
|
|
163
140
|
}, /*#__PURE__*/React.createElement("div", {
|
|
164
141
|
id: "global-comment-list-container",
|
|
165
142
|
className: "sdoc-comment-list-container"
|
|
166
|
-
}, commentList.map(
|
|
167
|
-
|
|
168
|
-
|
|
143
|
+
}, commentList.map(comment => {
|
|
144
|
+
const elementId = comment.detail.element_id;
|
|
145
|
+
const element = getNodeById(editor.children, elementId);
|
|
169
146
|
if (!element && elementId !== DOC_COMMENT_ELEMENT_ID) return null;
|
|
170
|
-
|
|
147
|
+
const isActive = activeComment && activeComment.id === comment.id;
|
|
171
148
|
return /*#__PURE__*/React.createElement(CommentItemWrapper, {
|
|
172
149
|
key: comment.id,
|
|
173
150
|
container: "global-comment-list-container",
|
|
@@ -1,17 +1,17 @@
|
|
|
1
|
-
export
|
|
1
|
+
export const COMMENT_TYPES = {
|
|
2
2
|
DOC: 'Doc_comments',
|
|
3
3
|
ALL: 'All_comments',
|
|
4
4
|
RESOLVED: 'Resolved_comments',
|
|
5
5
|
UNRESOLVED: 'Unresolved_comments'
|
|
6
6
|
};
|
|
7
|
-
export
|
|
8
|
-
export
|
|
9
|
-
export
|
|
10
|
-
export
|
|
11
|
-
export
|
|
12
|
-
export
|
|
13
|
-
export
|
|
14
|
-
export
|
|
7
|
+
export const DOWN = 'down';
|
|
8
|
+
export const UP = 'up';
|
|
9
|
+
export const FONT_SIZE_WIDTH = 15;
|
|
10
|
+
export const LINE_HEIGHT = 22;
|
|
11
|
+
export const POPOVER_ADDING_HEIGHT = 10;
|
|
12
|
+
export const COMMENT_URL_CLASSNAME = 'sdoc-comment-url';
|
|
13
|
+
export const DOC_COMMENT_ELEMENT_ID = '0';
|
|
14
|
+
export const DOC_NOTIFICATION_REDUCER_TYPE = {
|
|
15
15
|
FETCHING: 'fetching',
|
|
16
16
|
FETCHED: 'fetched',
|
|
17
17
|
FETCH_ERROR: 'error',
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { ReactEditor } from '@seafile/slate-react';
|
|
2
2
|
import context from '../../context';
|
|
3
3
|
import { useScrollContext } from '../hooks/use-scroll-context';
|
|
4
|
-
export
|
|
4
|
+
export const getSelectionRange = () => {
|
|
5
5
|
if (window.getSelection) {
|
|
6
|
-
|
|
6
|
+
const sel = window.getSelection();
|
|
7
7
|
if (sel.getRangeAt && sel.rangeCount) {
|
|
8
8
|
return sel.getRangeAt(0);
|
|
9
9
|
}
|
|
@@ -12,13 +12,13 @@ export var getSelectionRange = function getSelectionRange() {
|
|
|
12
12
|
}
|
|
13
13
|
return null;
|
|
14
14
|
};
|
|
15
|
-
export
|
|
16
|
-
|
|
15
|
+
export const getCursorPosition = () => {
|
|
16
|
+
let x = 0,
|
|
17
17
|
y = 0;
|
|
18
|
-
|
|
18
|
+
let range = getSelectionRange();
|
|
19
19
|
if (range) {
|
|
20
|
-
|
|
21
|
-
|
|
20
|
+
const rect = range.getBoundingClientRect();
|
|
21
|
+
const headerHeight = 100;
|
|
22
22
|
x = rect.x || 0;
|
|
23
23
|
y = rect.y - headerHeight + (rect.height - 24) / 2 || 0;
|
|
24
24
|
}
|
|
@@ -27,34 +27,35 @@ export var getCursorPosition = function getCursorPosition() {
|
|
|
27
27
|
y: y
|
|
28
28
|
};
|
|
29
29
|
};
|
|
30
|
-
export
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
30
|
+
export const useCursorPosition = () => {
|
|
31
|
+
const scrollRef = useScrollContext();
|
|
32
|
+
const {
|
|
33
|
+
scrollTop = 0
|
|
34
|
+
} = scrollRef.current || {};
|
|
35
|
+
let position = getCursorPosition();
|
|
36
36
|
if (position.y !== 0) {
|
|
37
37
|
position.y = position.y + scrollTop;
|
|
38
38
|
}
|
|
39
39
|
return position;
|
|
40
40
|
};
|
|
41
|
-
export
|
|
42
|
-
|
|
43
|
-
|
|
41
|
+
export const getAvatarUrl = () => {
|
|
42
|
+
const server = context.getSetting('serviceUrl');
|
|
43
|
+
const avatarUrl = "".concat(server, "/media/avatars/default.png");
|
|
44
44
|
return avatarUrl;
|
|
45
45
|
};
|
|
46
|
-
export
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
children.forEach(
|
|
50
|
-
|
|
46
|
+
export const getElementCommentCountTop = (editor, element, scrollTop) => {
|
|
47
|
+
let minY;
|
|
48
|
+
const children = element.children || [];
|
|
49
|
+
children.forEach(child => {
|
|
50
|
+
const childDom = ReactEditor.toDOMNode(editor, child);
|
|
51
51
|
|
|
52
52
|
// use child real dom
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
y
|
|
53
|
+
const childRealDom = childDom.childNodes[0];
|
|
54
|
+
const {
|
|
55
|
+
y
|
|
56
|
+
} = childRealDom ? childRealDom.getBoundingClientRect() : {
|
|
57
|
+
y: 0
|
|
58
|
+
};
|
|
58
59
|
if (!minY) minY = y;
|
|
59
60
|
minY = Math.min(minY, y);
|
|
60
61
|
});
|
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
import React, { useContext } from 'react';
|
|
2
|
-
export
|
|
3
|
-
export
|
|
4
|
-
|
|
5
|
-
commentsInfo
|
|
6
|
-
dispatch
|
|
2
|
+
export const CommentContext = React.createContext();
|
|
3
|
+
export const useCommentContext = () => {
|
|
4
|
+
const {
|
|
5
|
+
commentsInfo,
|
|
6
|
+
dispatch
|
|
7
|
+
} = useContext(CommentContext);
|
|
7
8
|
return {
|
|
8
|
-
commentsInfo
|
|
9
|
-
dispatch
|
|
9
|
+
commentsInfo,
|
|
10
|
+
dispatch
|
|
10
11
|
};
|
|
11
12
|
};
|
|
@@ -1,44 +1,33 @@
|
|
|
1
|
-
import _slicedToArray from "@babel/runtime/helpers/esm/slicedToArray";
|
|
2
1
|
import { useEffect, useState } from 'react';
|
|
3
2
|
import { useCommentContext } from './use-comment-context';
|
|
4
3
|
import { COMMENT_TYPES, DOC_COMMENT_ELEMENT_ID } from '../../constants';
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
commentsInfo
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
_useState4 = _slicedToArray(_useState3, 2),
|
|
16
|
-
commentList = _useState4[0],
|
|
17
|
-
setCommentList = _useState4[1];
|
|
18
|
-
useEffect(function () {
|
|
4
|
+
const useCommentList = () => {
|
|
5
|
+
const {
|
|
6
|
+
commentsInfo
|
|
7
|
+
} = useCommentContext();
|
|
8
|
+
const {
|
|
9
|
+
comment_list
|
|
10
|
+
} = commentsInfo || [];
|
|
11
|
+
const [commentType, setCommentType] = useState(COMMENT_TYPES.ALL);
|
|
12
|
+
const [commentList, setCommentList] = useState([comment_list]);
|
|
13
|
+
useEffect(() => {
|
|
19
14
|
if (commentType === COMMENT_TYPES.ALL) {
|
|
20
15
|
setCommentList(comment_list);
|
|
21
16
|
} else if (commentType === COMMENT_TYPES.RESOLVED) {
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
});
|
|
25
|
-
setCommentList(_commentList);
|
|
17
|
+
const commentList = comment_list.filter(item => item.resolved);
|
|
18
|
+
setCommentList(commentList);
|
|
26
19
|
} else if (commentType === COMMENT_TYPES.UNRESOLVED) {
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
});
|
|
30
|
-
setCommentList(_commentList2);
|
|
20
|
+
const commentList = comment_list.filter(item => !item.resolved);
|
|
21
|
+
setCommentList(commentList);
|
|
31
22
|
} else if (commentType === COMMENT_TYPES.DOC) {
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
});
|
|
35
|
-
setCommentList(_commentList3);
|
|
23
|
+
const commentList = comment_list.filter(comment => comment.detail.element_id === DOC_COMMENT_ELEMENT_ID);
|
|
24
|
+
setCommentList(commentList);
|
|
36
25
|
}
|
|
37
26
|
}, [commentType, comment_list]);
|
|
38
27
|
return {
|
|
39
|
-
commentList
|
|
40
|
-
commentType
|
|
41
|
-
setCommentType
|
|
28
|
+
commentList,
|
|
29
|
+
commentType,
|
|
30
|
+
setCommentType
|
|
42
31
|
};
|
|
43
32
|
};
|
|
44
33
|
export default useCommentList;
|
|
@@ -1,79 +1,49 @@
|
|
|
1
|
-
import _asyncToGenerator from "@babel/runtime/helpers/esm/asyncToGenerator";
|
|
2
|
-
function _regeneratorRuntime() { "use strict"; /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */ _regeneratorRuntime = function _regeneratorRuntime() { return e; }; var t, e = {}, r = Object.prototype, n = r.hasOwnProperty, o = Object.defineProperty || function (t, e, r) { t[e] = r.value; }, i = "function" == typeof Symbol ? Symbol : {}, a = i.iterator || "@@iterator", c = i.asyncIterator || "@@asyncIterator", u = i.toStringTag || "@@toStringTag"; function define(t, e, r) { return Object.defineProperty(t, e, { value: r, enumerable: !0, configurable: !0, writable: !0 }), t[e]; } try { define({}, ""); } catch (t) { define = function define(t, e, r) { return t[e] = r; }; } function wrap(t, e, r, n) { var i = e && e.prototype instanceof Generator ? e : Generator, a = Object.create(i.prototype), c = new Context(n || []); return o(a, "_invoke", { value: makeInvokeMethod(t, r, c) }), a; } function tryCatch(t, e, r) { try { return { type: "normal", arg: t.call(e, r) }; } catch (t) { return { type: "throw", arg: t }; } } e.wrap = wrap; var h = "suspendedStart", l = "suspendedYield", f = "executing", s = "completed", y = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} var p = {}; define(p, a, function () { return this; }); var d = Object.getPrototypeOf, v = d && d(d(values([]))); v && v !== r && n.call(v, a) && (p = v); var g = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(p); function defineIteratorMethods(t) { ["next", "throw", "return"].forEach(function (e) { define(t, e, function (t) { return this._invoke(e, t); }); }); } function AsyncIterator(t, e) { function invoke(r, o, i, a) { var c = tryCatch(t[r], t, o); if ("throw" !== c.type) { var u = c.arg, h = u.value; return h && "object" == typeof h && n.call(h, "__await") ? e.resolve(h.__await).then(function (t) { invoke("next", t, i, a); }, function (t) { invoke("throw", t, i, a); }) : e.resolve(h).then(function (t) { u.value = t, i(u); }, function (t) { return invoke("throw", t, i, a); }); } a(c.arg); } var r; o(this, "_invoke", { value: function value(t, n) { function callInvokeWithMethodAndArg() { return new e(function (e, r) { invoke(t, n, e, r); }); } return r = r ? r.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg(); } }); } function makeInvokeMethod(e, r, n) { var o = h; return function (i, a) { if (o === f) throw new Error("Generator is already running"); if (o === s) { if ("throw" === i) throw a; return { value: t, done: !0 }; } for (n.method = i, n.arg = a;;) { var c = n.delegate; if (c) { var u = maybeInvokeDelegate(c, n); if (u) { if (u === y) continue; return u; } } if ("next" === n.method) n.sent = n._sent = n.arg;else if ("throw" === n.method) { if (o === h) throw o = s, n.arg; n.dispatchException(n.arg); } else "return" === n.method && n.abrupt("return", n.arg); o = f; var p = tryCatch(e, r, n); if ("normal" === p.type) { if (o = n.done ? s : l, p.arg === y) continue; return { value: p.arg, done: n.done }; } "throw" === p.type && (o = s, n.method = "throw", n.arg = p.arg); } }; } function maybeInvokeDelegate(e, r) { var n = r.method, o = e.iterator[n]; if (o === t) return r.delegate = null, "throw" === n && e.iterator.return && (r.method = "return", r.arg = t, maybeInvokeDelegate(e, r), "throw" === r.method) || "return" !== n && (r.method = "throw", r.arg = new TypeError("The iterator does not provide a '" + n + "' method")), y; var i = tryCatch(o, e.iterator, r.arg); if ("throw" === i.type) return r.method = "throw", r.arg = i.arg, r.delegate = null, y; var a = i.arg; return a ? a.done ? (r[e.resultName] = a.value, r.next = e.nextLoc, "return" !== r.method && (r.method = "next", r.arg = t), r.delegate = null, y) : a : (r.method = "throw", r.arg = new TypeError("iterator result is not an object"), r.delegate = null, y); } function pushTryEntry(t) { var e = { tryLoc: t[0] }; 1 in t && (e.catchLoc = t[1]), 2 in t && (e.finallyLoc = t[2], e.afterLoc = t[3]), this.tryEntries.push(e); } function resetTryEntry(t) { var e = t.completion || {}; e.type = "normal", delete e.arg, t.completion = e; } function Context(t) { this.tryEntries = [{ tryLoc: "root" }], t.forEach(pushTryEntry, this), this.reset(!0); } function values(e) { if (e || "" === e) { var r = e[a]; if (r) return r.call(e); if ("function" == typeof e.next) return e; if (!isNaN(e.length)) { var o = -1, i = function next() { for (; ++o < e.length;) if (n.call(e, o)) return next.value = e[o], next.done = !1, next; return next.value = t, next.done = !0, next; }; return i.next = i; } } throw new TypeError(typeof e + " is not iterable"); } return GeneratorFunction.prototype = GeneratorFunctionPrototype, o(g, "constructor", { value: GeneratorFunctionPrototype, configurable: !0 }), o(GeneratorFunctionPrototype, "constructor", { value: GeneratorFunction, configurable: !0 }), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, u, "GeneratorFunction"), e.isGeneratorFunction = function (t) { var e = "function" == typeof t && t.constructor; return !!e && (e === GeneratorFunction || "GeneratorFunction" === (e.displayName || e.name)); }, e.mark = function (t) { return Object.setPrototypeOf ? Object.setPrototypeOf(t, GeneratorFunctionPrototype) : (t.__proto__ = GeneratorFunctionPrototype, define(t, u, "GeneratorFunction")), t.prototype = Object.create(g), t; }, e.awrap = function (t) { return { __await: t }; }, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, c, function () { return this; }), e.AsyncIterator = AsyncIterator, e.async = function (t, r, n, o, i) { void 0 === i && (i = Promise); var a = new AsyncIterator(wrap(t, r, n, o), i); return e.isGeneratorFunction(r) ? a : a.next().then(function (t) { return t.done ? t.value : a.next(); }); }, defineIteratorMethods(g), define(g, u, "Generator"), define(g, a, function () { return this; }), define(g, "toString", function () { return "[object Generator]"; }), e.keys = function (t) { var e = Object(t), r = []; for (var n in e) r.push(n); return r.reverse(), function next() { for (; r.length;) { var t = r.pop(); if (t in e) return next.value = t, next.done = !1, next; } return next.done = !0, next; }; }, e.values = values, Context.prototype = { constructor: Context, reset: function reset(e) { if (this.prev = 0, this.next = 0, this.sent = this._sent = t, this.done = !1, this.delegate = null, this.method = "next", this.arg = t, this.tryEntries.forEach(resetTryEntry), !e) for (var r in this) "t" === r.charAt(0) && n.call(this, r) && !isNaN(+r.slice(1)) && (this[r] = t); }, stop: function stop() { this.done = !0; var t = this.tryEntries[0].completion; if ("throw" === t.type) throw t.arg; return this.rval; }, dispatchException: function dispatchException(e) { if (this.done) throw e; var r = this; function handle(n, o) { return a.type = "throw", a.arg = e, r.next = n, o && (r.method = "next", r.arg = t), !!o; } for (var o = this.tryEntries.length - 1; o >= 0; --o) { var i = this.tryEntries[o], a = i.completion; if ("root" === i.tryLoc) return handle("end"); if (i.tryLoc <= this.prev) { var c = n.call(i, "catchLoc"), u = n.call(i, "finallyLoc"); if (c && u) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } else if (c) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); } else { if (!u) throw new Error("try statement without catch or finally"); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } } } }, abrupt: function abrupt(t, e) { for (var r = this.tryEntries.length - 1; r >= 0; --r) { var o = this.tryEntries[r]; if (o.tryLoc <= this.prev && n.call(o, "finallyLoc") && this.prev < o.finallyLoc) { var i = o; break; } } i && ("break" === t || "continue" === t) && i.tryLoc <= e && e <= i.finallyLoc && (i = null); var a = i ? i.completion : {}; return a.type = t, a.arg = e, i ? (this.method = "next", this.next = i.finallyLoc, y) : this.complete(a); }, complete: function complete(t, e) { if ("throw" === t.type) throw t.arg; return "break" === t.type || "continue" === t.type ? this.next = t.arg : "return" === t.type ? (this.rval = this.arg = t.arg, this.method = "return", this.next = "end") : "normal" === t.type && e && (this.next = e), y; }, finish: function finish(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.finallyLoc === t) return this.complete(r.completion, r.afterLoc), resetTryEntry(r), y; } }, catch: function _catch(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.tryLoc === t) { var n = r.completion; if ("throw" === n.type) { var o = n.arg; resetTryEntry(r); } return o; } } throw new Error("illegal catch attempt"); }, delegateYield: function delegateYield(e, r, n) { return this.delegate = { iterator: values(e), resultName: r, nextLoc: n }, "next" === this.method && (this.arg = t), y; } }, e; }
|
|
3
1
|
import { useCallback, useEffect } from 'react';
|
|
4
2
|
import context from '../../../../context';
|
|
5
3
|
import EventBus from '../../../utils/event-bus';
|
|
6
4
|
import { EXTERNAL_EVENT } from '../../../../constants';
|
|
7
|
-
export
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
case 0:
|
|
46
|
-
dispatch({
|
|
47
|
-
type: 'REFETCHING_STATE'
|
|
48
|
-
});
|
|
49
|
-
_context2.prev = 1;
|
|
50
|
-
_context2.next = 4;
|
|
51
|
-
return context.listComments();
|
|
52
|
-
case 4:
|
|
53
|
-
res = _context2.sent;
|
|
54
|
-
comments = res.data.comments;
|
|
55
|
-
dispatch({
|
|
56
|
-
type: 'RECEIVE_STATE',
|
|
57
|
-
payload: comments
|
|
58
|
-
});
|
|
59
|
-
_context2.next = 12;
|
|
60
|
-
break;
|
|
61
|
-
case 9:
|
|
62
|
-
_context2.prev = 9;
|
|
63
|
-
_context2.t0 = _context2["catch"](1);
|
|
64
|
-
console.log(_context2.t0);
|
|
65
|
-
// dispatch({type: 'FETCHING_ERROR'});
|
|
66
|
-
case 12:
|
|
67
|
-
case "end":
|
|
68
|
-
return _context2.stop();
|
|
69
|
-
}
|
|
70
|
-
}, _callee2, null, [[1, 9]]);
|
|
71
|
-
})), []);
|
|
72
|
-
useEffect(function () {
|
|
5
|
+
export const useCommentsMount = dispatch => {
|
|
6
|
+
const request = useCallback(async () => {
|
|
7
|
+
dispatch({
|
|
8
|
+
type: 'FETCHING_STATE'
|
|
9
|
+
});
|
|
10
|
+
try {
|
|
11
|
+
const res = await context.listComments();
|
|
12
|
+
const comments = res.data.comments;
|
|
13
|
+
dispatch({
|
|
14
|
+
type: 'RECEIVE_STATE',
|
|
15
|
+
payload: comments
|
|
16
|
+
});
|
|
17
|
+
} catch (error) {
|
|
18
|
+
console.log(error);
|
|
19
|
+
dispatch({
|
|
20
|
+
type: 'FETCHING_ERROR'
|
|
21
|
+
});
|
|
22
|
+
}
|
|
23
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
24
|
+
}, []);
|
|
25
|
+
const reRequest = useCallback(async () => {
|
|
26
|
+
dispatch({
|
|
27
|
+
type: 'REFETCHING_STATE'
|
|
28
|
+
});
|
|
29
|
+
try {
|
|
30
|
+
const res = await context.listComments();
|
|
31
|
+
const comments = res.data.comments;
|
|
32
|
+
dispatch({
|
|
33
|
+
type: 'RECEIVE_STATE',
|
|
34
|
+
payload: comments
|
|
35
|
+
});
|
|
36
|
+
} catch (error) {
|
|
37
|
+
console.log(error);
|
|
38
|
+
// dispatch({type: 'FETCHING_ERROR'});
|
|
39
|
+
}
|
|
40
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
41
|
+
}, []);
|
|
42
|
+
useEffect(() => {
|
|
73
43
|
request();
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
return
|
|
44
|
+
const eventBus = EventBus.getInstance();
|
|
45
|
+
const unsubscribeNewNotification = eventBus.subscribe(EXTERNAL_EVENT.NEW_NOTIFICATION, reRequest);
|
|
46
|
+
return () => {
|
|
77
47
|
unsubscribeNewNotification();
|
|
78
48
|
};
|
|
79
49
|
}, [request, reRequest]);
|
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
import React, { useContext } from 'react';
|
|
2
|
-
export
|
|
3
|
-
export
|
|
4
|
-
|
|
5
|
-
notificationsInfo
|
|
6
|
-
dispatch
|
|
2
|
+
export const NotificationContext = React.createContext();
|
|
3
|
+
export const useNotificationContext = () => {
|
|
4
|
+
const {
|
|
5
|
+
notificationsInfo,
|
|
6
|
+
dispatch
|
|
7
|
+
} = useContext(NotificationContext);
|
|
7
8
|
return {
|
|
8
|
-
notificationsInfo
|
|
9
|
-
dispatch
|
|
9
|
+
notificationsInfo,
|
|
10
|
+
dispatch
|
|
10
11
|
};
|
|
11
12
|
};
|