@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
|
@@ -8,33 +8,38 @@ import EventBus from '../../utils/event-bus';
|
|
|
8
8
|
import { INTERNAL_EVENT } from '../../constants';
|
|
9
9
|
import { useParticipantsContext } from '../hooks/use-participants';
|
|
10
10
|
import CommentInput from './comment-input';
|
|
11
|
-
|
|
11
|
+
const getSubmitTip = (type, content) => {
|
|
12
12
|
if (content) return 'Save';
|
|
13
13
|
return type === 'comment' ? 'Comment' : 'Reply';
|
|
14
14
|
};
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
15
|
+
const CommentEditor = _ref => {
|
|
16
|
+
let {
|
|
17
|
+
type,
|
|
18
|
+
className,
|
|
19
|
+
content,
|
|
20
|
+
placeholder,
|
|
21
|
+
insertContent,
|
|
22
|
+
updateContent,
|
|
23
|
+
setIsEditing,
|
|
24
|
+
hiddenComment
|
|
25
|
+
} = _ref;
|
|
26
|
+
const commentInputRef = useRef();
|
|
27
|
+
const commentWrapperRef = useRef();
|
|
28
|
+
const {
|
|
29
|
+
t
|
|
30
|
+
} = useTranslation();
|
|
31
|
+
const scrollRef = useScrollContext();
|
|
32
|
+
const {
|
|
33
|
+
addParticipants
|
|
34
|
+
} = useParticipantsContext();
|
|
31
35
|
|
|
32
36
|
// onMount: set scrollLeft
|
|
33
|
-
useEffect(
|
|
37
|
+
useEffect(() => {
|
|
34
38
|
if (!commentWrapperRef.current) return;
|
|
35
|
-
|
|
36
|
-
right
|
|
37
|
-
width
|
|
39
|
+
const {
|
|
40
|
+
right,
|
|
41
|
+
width
|
|
42
|
+
} = commentWrapperRef.current.getBoundingClientRect();
|
|
38
43
|
if (right <= window.innerWidth) return;
|
|
39
44
|
if (!scrollRef.current) return;
|
|
40
45
|
scrollRef.current.scrollLeft = scrollRef.current.scrollLeft + width;
|
|
@@ -42,15 +47,15 @@ var CommentEditor = function CommentEditor(_ref) {
|
|
|
42
47
|
}, []);
|
|
43
48
|
|
|
44
49
|
// onMount: hidden comment
|
|
45
|
-
useEffect(
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
return
|
|
50
|
+
useEffect(() => {
|
|
51
|
+
const eventBus = EventBus.getInstance();
|
|
52
|
+
const unsubscribe = eventBus.subscribe(INTERNAL_EVENT.ARTICLE_CLICK, hiddenComment);
|
|
53
|
+
return () => {
|
|
49
54
|
unsubscribe();
|
|
50
55
|
};
|
|
51
56
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
52
57
|
}, []);
|
|
53
|
-
|
|
58
|
+
const updateValue = useCallback(value => {
|
|
54
59
|
if (!value || value.trim() === '') return;
|
|
55
60
|
if (!content) {
|
|
56
61
|
insertContent(value);
|
|
@@ -58,15 +63,15 @@ var CommentEditor = function CommentEditor(_ref) {
|
|
|
58
63
|
}
|
|
59
64
|
updateContent(value);
|
|
60
65
|
}, [content, insertContent, updateContent]);
|
|
61
|
-
|
|
66
|
+
const onSubmit = useCallback(event => {
|
|
62
67
|
event && event.stopPropagation();
|
|
63
|
-
|
|
68
|
+
const value = commentInputRef.current.getValue();
|
|
64
69
|
updateValue(value);
|
|
65
|
-
|
|
70
|
+
const userInfo = context.getUserInfo();
|
|
66
71
|
addParticipants(userInfo.username);
|
|
67
72
|
commentInputRef.current.setValue('');
|
|
68
73
|
}, [updateValue, addParticipants, commentInputRef]);
|
|
69
|
-
|
|
74
|
+
const onCancel = useCallback(event => {
|
|
70
75
|
event.stopPropagation();
|
|
71
76
|
commentInputRef.current.setValue('');
|
|
72
77
|
setIsEditing && setIsEditing(false);
|
|
@@ -74,10 +79,8 @@ var CommentEditor = function CommentEditor(_ref) {
|
|
|
74
79
|
|
|
75
80
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
76
81
|
}, [setIsEditing]);
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
}, [content, type]);
|
|
80
|
-
var userInfo = context.getUserInfo();
|
|
82
|
+
const submitTip = useMemo(() => getSubmitTip(type, content), [content, type]);
|
|
83
|
+
const userInfo = context.getUserInfo();
|
|
81
84
|
return /*#__PURE__*/React.createElement("div", {
|
|
82
85
|
className: classNames('comment-editor-wrapper', className),
|
|
83
86
|
ref: commentWrapperRef
|
|
@@ -1,22 +1,24 @@
|
|
|
1
1
|
import React, { useCallback, useEffect, useRef } from 'react';
|
|
2
2
|
import { eventStopPropagation } from '../../../utils/mouse-event';
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
3
|
+
const CommentParticipantItem = _ref => {
|
|
4
|
+
let {
|
|
5
|
+
participant,
|
|
6
|
+
setScrollTop,
|
|
7
|
+
onSelectParticipant,
|
|
8
|
+
participantIndex,
|
|
9
|
+
activeParticipantIndex
|
|
10
|
+
} = _ref;
|
|
11
|
+
const ref = useRef(null);
|
|
12
|
+
const oldValueRef = useRef({});
|
|
13
|
+
useEffect(() => {
|
|
12
14
|
oldValueRef.current.participantIndex = participantIndex;
|
|
13
15
|
oldValueRef.current.activeParticipantIndex = activeParticipantIndex;
|
|
14
16
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
15
17
|
}, []);
|
|
16
|
-
useEffect(
|
|
18
|
+
useEffect(() => {
|
|
17
19
|
if (activeParticipantIndex === participantIndex && activeParticipantIndex !== oldValueRef.current.activeParticipantIndex) {
|
|
18
|
-
|
|
19
|
-
|
|
20
|
+
const offsetHeight = ref.current.offsetHeight;
|
|
21
|
+
const offsetTop = ref.current.offsetTop;
|
|
20
22
|
if (activeParticipantIndex > oldValueRef.current.activeParticipantIndex) {
|
|
21
23
|
setScrollTop(offsetTop, offsetHeight, 'down');
|
|
22
24
|
} else {
|
|
@@ -25,11 +27,11 @@ var CommentParticipantItem = function CommentParticipantItem(_ref) {
|
|
|
25
27
|
}
|
|
26
28
|
oldValueRef.current.activeParticipantIndex = activeParticipantIndex;
|
|
27
29
|
}, [setScrollTop, participantIndex, activeParticipantIndex, ref, oldValueRef]);
|
|
28
|
-
|
|
30
|
+
const selectParticipant = useCallback(event => {
|
|
29
31
|
eventStopPropagation(event);
|
|
30
32
|
onSelectParticipant(participant);
|
|
31
33
|
}, [participant, onSelectParticipant]);
|
|
32
|
-
|
|
34
|
+
const active = participantIndex === activeParticipantIndex;
|
|
33
35
|
return /*#__PURE__*/React.createElement("div", {
|
|
34
36
|
className: "comment-participant-item ".concat(active ? 'active' : ''),
|
|
35
37
|
ref: ref,
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import _slicedToArray from "@babel/runtime/helpers/esm/slicedToArray";
|
|
2
1
|
import React, { useCallback, useEffect, useRef, useState, useImperativeHandle, forwardRef } from 'react';
|
|
3
2
|
import { useTranslation } from 'react-i18next';
|
|
4
3
|
import { useCollaborators } from '../../../../hooks';
|
|
@@ -11,87 +10,82 @@ import { eventStopPropagation } from '../../../utils/mouse-event';
|
|
|
11
10
|
import CommentParticipantItem from './comment-participant-item';
|
|
12
11
|
import { Hotkey, getSelectionCoords } from '../../../../utils';
|
|
13
12
|
import './index.css';
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
_useState6 = _slicedToArray(_useState5, 2),
|
|
38
|
-
activeCollaboratorIndex = _useState6[0],
|
|
39
|
-
setActiveCollaboratorIndex = _useState6[1];
|
|
40
|
-
var commentUtilities = new CommentUtilities();
|
|
13
|
+
const CommentInput = forwardRef((_ref, ref) => {
|
|
14
|
+
let {
|
|
15
|
+
placeholder,
|
|
16
|
+
content,
|
|
17
|
+
type,
|
|
18
|
+
onCancel,
|
|
19
|
+
onSubmit
|
|
20
|
+
} = _ref;
|
|
21
|
+
const commentRef = useRef();
|
|
22
|
+
const collaboratorsPopoverRef = useRef();
|
|
23
|
+
const {
|
|
24
|
+
t
|
|
25
|
+
} = useTranslation();
|
|
26
|
+
const {
|
|
27
|
+
collaborators
|
|
28
|
+
} = useCollaborators();
|
|
29
|
+
const {
|
|
30
|
+
addParticipants
|
|
31
|
+
} = useParticipantsContext();
|
|
32
|
+
const [range, setRange] = useState();
|
|
33
|
+
const [searchedCollaborators, setSearchedCollaborators] = useState([]);
|
|
34
|
+
const [activeCollaboratorIndex, setActiveCollaboratorIndex] = useState(-1);
|
|
35
|
+
const commentUtilities = new CommentUtilities();
|
|
41
36
|
|
|
42
37
|
// onMount: comment content
|
|
43
|
-
useEffect(
|
|
38
|
+
useEffect(() => {
|
|
44
39
|
if (!content) return;
|
|
45
40
|
commentRef.current.textContent = content;
|
|
46
41
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
47
42
|
}, []);
|
|
48
43
|
|
|
49
44
|
// onMount: set input focus
|
|
50
|
-
useEffect(
|
|
45
|
+
useEffect(() => {
|
|
51
46
|
if (type !== 'comment') return;
|
|
52
47
|
commentRef.current && commentRef.current.focus();
|
|
53
48
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
54
49
|
}, []);
|
|
55
50
|
|
|
56
51
|
// onMount: handleCommentPopover
|
|
57
|
-
useEffect(
|
|
52
|
+
useEffect(() => {
|
|
58
53
|
document.addEventListener('mousedown', handleCommentPopover);
|
|
59
|
-
return
|
|
54
|
+
return () => {
|
|
60
55
|
document.removeEventListener('mousedown', handleCommentPopover);
|
|
61
56
|
};
|
|
62
57
|
});
|
|
63
58
|
|
|
64
59
|
// The parent component can call the method of this component through ref
|
|
65
|
-
useImperativeHandle(ref,
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
}
|
|
60
|
+
useImperativeHandle(ref, () => ({
|
|
61
|
+
getValue: () => {
|
|
62
|
+
const comment = convertComment(commentRef.current.textContent);
|
|
63
|
+
return comment;
|
|
64
|
+
},
|
|
65
|
+
setValue: value => {
|
|
66
|
+
commentRef.current.textContent = value || '';
|
|
67
|
+
}
|
|
74
68
|
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
var hideCommentPopover = useCallback(function () {
|
|
69
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
70
|
+
}), [commentRef]);
|
|
71
|
+
const hideCommentPopover = useCallback(() => {
|
|
79
72
|
if (searchedCollaborators.length === 0) return;
|
|
80
73
|
setSearchedCollaborators([]);
|
|
81
74
|
setActiveCollaboratorIndex(-1);
|
|
82
75
|
}, [searchedCollaborators]);
|
|
83
|
-
|
|
76
|
+
const handleCommentPopover = useCallback(event => {
|
|
84
77
|
if (collaboratorsPopoverRef.current && event && !collaboratorsPopoverRef.current.contains(event.target)) {
|
|
85
78
|
hideCommentPopover();
|
|
86
79
|
}
|
|
87
80
|
}, [hideCommentPopover, collaboratorsPopoverRef]);
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
offsetHeight
|
|
91
|
-
scrollTop
|
|
81
|
+
const setScrollTop = useCallback((offsetTop, itemOffsetHeight, mouseDownType) => {
|
|
82
|
+
const {
|
|
83
|
+
offsetHeight,
|
|
84
|
+
scrollTop
|
|
85
|
+
} = collaboratorsPopoverRef.current;
|
|
92
86
|
if (mouseDownType === DOWN) {
|
|
93
87
|
if (offsetTop + itemOffsetHeight - scrollTop - offsetHeight + POPOVER_ADDING_HEIGHT > 0) {
|
|
94
|
-
|
|
88
|
+
let top = offsetTop + itemOffsetHeight - offsetHeight + POPOVER_ADDING_HEIGHT;
|
|
95
89
|
collaboratorsPopoverRef.current.scrollTop = top;
|
|
96
90
|
}
|
|
97
91
|
}
|
|
@@ -101,71 +95,81 @@ var CommentInput = forwardRef(function (_ref, ref) {
|
|
|
101
95
|
}
|
|
102
96
|
}
|
|
103
97
|
}, []);
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
height
|
|
107
|
-
width
|
|
108
|
-
|
|
98
|
+
const setCollaboratorsPopoverPosition = useCallback(caretPosition => {
|
|
99
|
+
const {
|
|
100
|
+
height,
|
|
101
|
+
width
|
|
102
|
+
} = collaboratorsPopoverRef.current.getBoundingClientRect();
|
|
103
|
+
const {
|
|
104
|
+
offsetHeight
|
|
105
|
+
} = collaboratorsPopoverRef.current;
|
|
109
106
|
|
|
110
107
|
// Whether the vertical direction exceeds the screen
|
|
111
|
-
|
|
108
|
+
const isVerticalDirectionBeyondScreen = height + caretPosition.y + LINE_HEIGHT > window.innerHeight;
|
|
112
109
|
|
|
113
110
|
// if the vertical direction exceeds the screen, collaboratorsPopoverRef appear above the cursor
|
|
114
|
-
|
|
111
|
+
const top = isVerticalDirectionBeyondScreen ? "".concat(caretPosition.y - offsetHeight + LINE_HEIGHT, "px") : "".concat(caretPosition.y + LINE_HEIGHT, "px");
|
|
115
112
|
collaboratorsPopoverRef.current.style.top = top;
|
|
116
113
|
|
|
117
114
|
// Whether the horizontal direction exceeds the screen
|
|
118
|
-
|
|
115
|
+
const isHorizontalDirectionBeyondScreen = caretPosition.x + FONT_SIZE_WIDTH + width > window.innerWidth;
|
|
119
116
|
|
|
120
117
|
// if the horizontal direction exceeds the screen, collaboratorsPopoverRef is displayed against the right side of the screen
|
|
121
|
-
|
|
118
|
+
const left = isHorizontalDirectionBeyondScreen ? "".concat(window.innerWidth - width, "px") : "".concat(caretPosition.x + FONT_SIZE_WIDTH, "px");
|
|
122
119
|
collaboratorsPopoverRef.current.style.left = left;
|
|
123
120
|
}, [collaboratorsPopoverRef]);
|
|
124
|
-
|
|
125
|
-
|
|
121
|
+
const getAtInfo = useCallback(event => {
|
|
122
|
+
const isValidOperation = checkMentionOperation(event);
|
|
126
123
|
if (!isValidOperation) return {
|
|
127
124
|
index: -1
|
|
128
125
|
};
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
126
|
+
const selection = window.getSelection();
|
|
127
|
+
const {
|
|
128
|
+
isCollapsed,
|
|
129
|
+
anchorNode,
|
|
130
|
+
anchorOffset
|
|
131
|
+
} = selection;
|
|
133
132
|
if (!isCollapsed || !anchorNode || !anchorNode.data) return {
|
|
134
133
|
index: -1
|
|
135
134
|
};
|
|
136
|
-
|
|
137
|
-
|
|
135
|
+
const text = anchorNode.data;
|
|
136
|
+
const index = commentUtilities.getAtIndexWithAnchorPosition(anchorOffset, text);
|
|
138
137
|
return {
|
|
139
|
-
index
|
|
140
|
-
text
|
|
141
|
-
selection
|
|
138
|
+
index,
|
|
139
|
+
text,
|
|
140
|
+
selection
|
|
142
141
|
};
|
|
143
142
|
}, [commentUtilities]);
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
143
|
+
const getSearchedCollaborators = useCallback(_ref2 => {
|
|
144
|
+
let {
|
|
145
|
+
atIndex,
|
|
146
|
+
text,
|
|
147
|
+
anchorOffset
|
|
148
|
+
} = _ref2;
|
|
148
149
|
if (atIndex !== 0 && text[atIndex - 1] !== ' ') return [];
|
|
149
150
|
if (atIndex === anchorOffset - 1) return collaborators;
|
|
150
|
-
|
|
151
|
+
const searchingText = text.substring(atIndex + 1);
|
|
151
152
|
if (searchingText) return searchCollaborators(collaborators, searchingText);
|
|
152
153
|
return [];
|
|
153
154
|
}, [collaborators]);
|
|
154
|
-
|
|
155
|
+
const handleInvolvedKeyUp = useCallback(event => {
|
|
155
156
|
// atIndex: Positional index of @
|
|
156
|
-
|
|
157
|
-
atIndex
|
|
158
|
-
text
|
|
159
|
-
selection
|
|
157
|
+
const {
|
|
158
|
+
index: atIndex,
|
|
159
|
+
text,
|
|
160
|
+
selection
|
|
161
|
+
} = getAtInfo(event);
|
|
160
162
|
if (atIndex === -1) {
|
|
161
163
|
hideCommentPopover();
|
|
162
164
|
return;
|
|
163
165
|
}
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
166
|
+
const {
|
|
167
|
+
anchorOffset
|
|
168
|
+
} = selection;
|
|
169
|
+
const searchedCollaborators = getSearchedCollaborators({
|
|
170
|
+
atIndex,
|
|
171
|
+
text,
|
|
172
|
+
anchorOffset
|
|
169
173
|
});
|
|
170
174
|
if (searchedCollaborators.length === 0) {
|
|
171
175
|
hideCommentPopover();
|
|
@@ -174,16 +178,16 @@ var CommentInput = forwardRef(function (_ref, ref) {
|
|
|
174
178
|
setActiveCollaboratorIndex(0);
|
|
175
179
|
setRange(selection.getRangeAt(0));
|
|
176
180
|
setSearchedCollaborators(searchedCollaborators);
|
|
177
|
-
setTimeout(
|
|
178
|
-
|
|
181
|
+
setTimeout(() => {
|
|
182
|
+
const caretPosition = getSelectionCoords();
|
|
179
183
|
setCollaboratorsPopoverPosition(caretPosition);
|
|
180
184
|
}, 1);
|
|
181
185
|
}, [getSearchedCollaborators, getAtInfo, hideCommentPopover, setCollaboratorsPopoverPosition]);
|
|
182
|
-
|
|
186
|
+
const handleSelectingCollaborator = useCallback((event, direction) => {
|
|
183
187
|
eventStopPropagation(event);
|
|
184
|
-
|
|
188
|
+
const collaboratorsLen = searchedCollaborators.length;
|
|
185
189
|
if (collaboratorsLen === 0) return;
|
|
186
|
-
|
|
190
|
+
let nextActiveCollaboratorIndex = activeCollaboratorIndex;
|
|
187
191
|
if (direction === DOWN) {
|
|
188
192
|
nextActiveCollaboratorIndex++;
|
|
189
193
|
if (nextActiveCollaboratorIndex >= collaboratorsLen) {
|
|
@@ -197,26 +201,26 @@ var CommentInput = forwardRef(function (_ref, ref) {
|
|
|
197
201
|
}
|
|
198
202
|
setActiveCollaboratorIndex(nextActiveCollaboratorIndex);
|
|
199
203
|
}, [searchedCollaborators, activeCollaboratorIndex]);
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
204
|
+
const onSelectCollaborator = useCallback(collaborator => {
|
|
205
|
+
const selection = window.getSelection();
|
|
206
|
+
const callBack = () => {
|
|
203
207
|
hideCommentPopover();
|
|
204
208
|
addParticipants(collaborator.username);
|
|
205
209
|
};
|
|
206
|
-
|
|
207
|
-
selection
|
|
208
|
-
range
|
|
210
|
+
const newRange = commentUtilities.onSelectParticipant({
|
|
211
|
+
selection,
|
|
212
|
+
range,
|
|
209
213
|
participant: collaborator,
|
|
210
|
-
callBack
|
|
214
|
+
callBack,
|
|
211
215
|
commentRef: commentRef
|
|
212
216
|
});
|
|
213
217
|
setRange(newRange);
|
|
214
218
|
}, [range, commentUtilities, hideCommentPopover, addParticipants]);
|
|
215
|
-
|
|
219
|
+
const handleSelectCollaborator = useCallback(event => {
|
|
216
220
|
if (searchedCollaborators.length === 0) return;
|
|
217
221
|
onSelectCollaborator(searchedCollaborators[activeCollaboratorIndex]);
|
|
218
222
|
}, [searchedCollaborators, activeCollaboratorIndex, onSelectCollaborator]);
|
|
219
|
-
|
|
223
|
+
const onKeyDown = useCallback(event => {
|
|
220
224
|
if (Hotkey.isModZ(event)) {
|
|
221
225
|
event.preventDefault();
|
|
222
226
|
event.stopPropagation();
|
|
@@ -245,8 +249,8 @@ var CommentInput = forwardRef(function (_ref, ref) {
|
|
|
245
249
|
}
|
|
246
250
|
}
|
|
247
251
|
}, [onCancel, onSubmit, searchedCollaborators, commentRef, hideCommentPopover]);
|
|
248
|
-
|
|
249
|
-
|
|
252
|
+
const onKeyUp = useCallback(event => {
|
|
253
|
+
const selection = window.getSelection();
|
|
250
254
|
setRange(selection.getRangeAt(0));
|
|
251
255
|
if (event.keyCode === KeyCodes.DownArrow) {
|
|
252
256
|
handleSelectingCollaborator(event, DOWN);
|
|
@@ -262,11 +266,11 @@ var CommentInput = forwardRef(function (_ref, ref) {
|
|
|
262
266
|
}
|
|
263
267
|
handleInvolvedKeyUp(event);
|
|
264
268
|
}, [handleSelectingCollaborator, handleInvolvedKeyUp, handleSelectCollaborator]);
|
|
265
|
-
|
|
266
|
-
|
|
269
|
+
const onMouseUp = useCallback(() => {
|
|
270
|
+
const selection = window.getSelection();
|
|
267
271
|
setRange(selection.getRangeAt(0));
|
|
268
272
|
}, []);
|
|
269
|
-
|
|
273
|
+
const onPaste = useCallback(event => {
|
|
270
274
|
commentUtilities.onPaste(event);
|
|
271
275
|
}, [commentUtilities]);
|
|
272
276
|
return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement("div", {
|
|
@@ -281,7 +285,7 @@ var CommentInput = forwardRef(function (_ref, ref) {
|
|
|
281
285
|
}), searchedCollaborators.length > 0 && /*#__PURE__*/React.createElement(ModalPortal, null, /*#__PURE__*/React.createElement("div", {
|
|
282
286
|
className: "sdoc-comment-caret-list",
|
|
283
287
|
ref: collaboratorsPopoverRef
|
|
284
|
-
}, searchedCollaborators.map(
|
|
288
|
+
}, searchedCollaborators.map((participant, index) => {
|
|
285
289
|
return /*#__PURE__*/React.createElement(CommentParticipantItem, {
|
|
286
290
|
key: participant.username,
|
|
287
291
|
participantIndex: index,
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import _objectSpread from "@babel/runtime/helpers/esm/objectSpread2";
|
|
2
|
-
import _slicedToArray from "@babel/runtime/helpers/esm/slicedToArray";
|
|
3
2
|
import React, { useCallback, useMemo, useState } from 'react';
|
|
4
3
|
import { withTranslation } from 'react-i18next';
|
|
5
4
|
import { Dropdown, DropdownItem, DropdownMenu, DropdownToggle } from 'reactstrap';
|
|
@@ -8,38 +7,35 @@ import CommentEditor from './comment-editor';
|
|
|
8
7
|
import Tooltip from '../../../components/tooltip';
|
|
9
8
|
import { textToHtml } from '../utils';
|
|
10
9
|
import { useNotificationContext } from '../hooks/notification-hooks';
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
var _useNotificationConte = useNotificationContext(),
|
|
28
|
-
notificationsInfo = _useNotificationConte.notificationsInfo;
|
|
29
|
-
var onEditToggle = useCallback(function (event) {
|
|
10
|
+
const CommentItem = _ref => {
|
|
11
|
+
let {
|
|
12
|
+
isActive,
|
|
13
|
+
container,
|
|
14
|
+
comment,
|
|
15
|
+
updateComment,
|
|
16
|
+
updateCommentState,
|
|
17
|
+
onDeleteComment,
|
|
18
|
+
t
|
|
19
|
+
} = _ref;
|
|
20
|
+
const [isDropdownOpen, setDropdownOpen] = useState(false);
|
|
21
|
+
const [isEditing, setIsEditing] = useState(false);
|
|
22
|
+
const {
|
|
23
|
+
notificationsInfo
|
|
24
|
+
} = useNotificationContext();
|
|
25
|
+
const onEditToggle = useCallback(event => {
|
|
30
26
|
event.stopPropagation();
|
|
31
27
|
setIsEditing(true);
|
|
32
28
|
}, []);
|
|
33
|
-
|
|
34
|
-
|
|
29
|
+
const isUnseen = notificationsInfo.notifications_map["sdoc_notification_".concat(comment.id)] ? true : false;
|
|
30
|
+
const onDeleteToggle = useCallback(event => {
|
|
35
31
|
event.stopPropagation();
|
|
36
32
|
onDeleteComment(true);
|
|
37
33
|
}, [onDeleteComment]);
|
|
38
|
-
|
|
39
|
-
|
|
34
|
+
const updateContent = useCallback(content => {
|
|
35
|
+
const commentId = comment.id;
|
|
40
36
|
if (comment.comment !== content) {
|
|
41
|
-
|
|
42
|
-
|
|
37
|
+
const time = dayjs().format('YYYY-MM-DD HH:mm:ss');
|
|
38
|
+
const newComment = {
|
|
43
39
|
comment: content,
|
|
44
40
|
detail: _objectSpread(_objectSpread({}, comment.detail), {}, {
|
|
45
41
|
comment: content
|
|
@@ -50,24 +46,22 @@ var CommentItem = function CommentItem(_ref) {
|
|
|
50
46
|
}
|
|
51
47
|
setIsEditing(false);
|
|
52
48
|
}, [comment, updateComment]);
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
49
|
+
const updateCommentResolved = useCallback(state => {
|
|
50
|
+
const commentId = comment.id;
|
|
51
|
+
const newComment = {
|
|
56
52
|
resolved: state
|
|
57
53
|
};
|
|
58
54
|
updateCommentState(commentId, newComment);
|
|
59
55
|
}, [comment.id, updateCommentState]);
|
|
60
|
-
|
|
56
|
+
const markAsResolved = useCallback(event => {
|
|
61
57
|
event.stopPropagation();
|
|
62
58
|
updateCommentResolved(true);
|
|
63
59
|
}, [updateCommentResolved]);
|
|
64
|
-
|
|
60
|
+
const resubmit = useCallback(event => {
|
|
65
61
|
event.stopPropagation();
|
|
66
62
|
updateCommentResolved(false);
|
|
67
63
|
}, [updateCommentResolved]);
|
|
68
|
-
|
|
69
|
-
return "comment_".concat(comment.id);
|
|
70
|
-
}, [comment]);
|
|
64
|
+
const menuId = useMemo(() => "comment_".concat(comment.id), [comment]);
|
|
71
65
|
return /*#__PURE__*/React.createElement("li", {
|
|
72
66
|
className: "comment-item"
|
|
73
67
|
}, /*#__PURE__*/React.createElement("div", {
|
|
@@ -101,9 +95,7 @@ var CommentItem = function CommentItem(_ref) {
|
|
|
101
95
|
target: "tooltip_".concat(menuId)
|
|
102
96
|
}, t('Resolved_tip'))), /*#__PURE__*/React.createElement(Dropdown, {
|
|
103
97
|
isOpen: isDropdownOpen,
|
|
104
|
-
toggle:
|
|
105
|
-
return setDropdownOpen(!isDropdownOpen);
|
|
106
|
-
}
|
|
98
|
+
toggle: () => setDropdownOpen(!isDropdownOpen)
|
|
107
99
|
}, /*#__PURE__*/React.createElement(DropdownToggle, {
|
|
108
100
|
tag: "div",
|
|
109
101
|
className: "comment-operation"
|