@wordpress/editor 14.44.1-next.v.202604201441.0 → 14.45.0
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/CHANGELOG.md +2 -0
- package/build/components/collab-sidebar/{comment-menu-item.cjs → add-note-menu-item.cjs} +17 -14
- package/build/components/collab-sidebar/add-note-menu-item.cjs.map +7 -0
- package/build/components/collab-sidebar/{add-comment.cjs → add-note.cjs} +28 -41
- package/build/components/collab-sidebar/add-note.cjs.map +7 -0
- package/build/components/collab-sidebar/board-store.cjs +3 -0
- package/build/components/collab-sidebar/board-store.cjs.map +2 -2
- package/build/components/collab-sidebar/floating-container.cjs +4 -3
- package/build/components/collab-sidebar/floating-container.cjs.map +3 -3
- package/build/components/collab-sidebar/hooks.cjs +92 -135
- package/build/components/collab-sidebar/hooks.cjs.map +3 -3
- package/build/components/collab-sidebar/index.cjs +28 -79
- package/build/components/collab-sidebar/index.cjs.map +3 -3
- package/build/components/collab-sidebar/{comment-author-info.cjs → note-byline.cjs} +13 -9
- package/build/components/collab-sidebar/note-byline.cjs.map +7 -0
- package/build/components/collab-sidebar/note-card.cjs +58 -0
- package/build/components/collab-sidebar/note-card.cjs.map +7 -0
- package/build/components/collab-sidebar/{comment-form.cjs → note-form.cjs} +45 -36
- package/build/components/collab-sidebar/note-form.cjs.map +7 -0
- package/build/components/collab-sidebar/{comment-indicator-toolbar.cjs → note-indicator-toolbar.cjs} +31 -27
- package/build/components/collab-sidebar/note-indicator-toolbar.cjs.map +7 -0
- package/build/components/collab-sidebar/note-thread.cjs +321 -0
- package/build/components/collab-sidebar/note-thread.cjs.map +7 -0
- package/build/components/collab-sidebar/note.cjs +207 -0
- package/build/components/collab-sidebar/note.cjs.map +7 -0
- package/build/components/collab-sidebar/notes.cjs +237 -0
- package/build/components/collab-sidebar/notes.cjs.map +7 -0
- package/build/components/collab-sidebar/utils.cjs +23 -25
- package/build/components/collab-sidebar/utils.cjs.map +2 -2
- package/build/components/document-bar/index.cjs.map +3 -3
- package/build/components/error-boundary/index.cjs.map +3 -3
- package/build/components/list-view-sidebar/list-view-outline.cjs.map +3 -3
- package/build/components/media/media-editor-modal.cjs +93 -0
- package/build/components/media/media-editor-modal.cjs.map +7 -0
- package/build/components/more-menu/index.cjs +3 -2
- package/build/components/more-menu/index.cjs.map +2 -2
- package/build/components/post-actions/set-as-homepage.cjs.map +3 -3
- package/build/components/post-actions/set-as-posts-page.cjs.map +3 -3
- package/build/components/post-card-panel/index.cjs +2 -2
- package/build/components/post-card-panel/index.cjs.map +3 -3
- package/build/components/post-content-information/index.cjs.map +3 -3
- package/build/components/post-excerpt/panel.cjs.map +3 -3
- package/build/components/post-last-edited-panel/index.cjs.map +3 -3
- package/build/components/post-preview-button/index.cjs +3 -2
- package/build/components/post-preview-button/index.cjs.map +2 -2
- package/build/components/post-publish-button/index.cjs +2 -2
- package/build/components/post-publish-button/index.cjs.map +2 -2
- package/build/components/post-publish-button/label.cjs +4 -2
- package/build/components/post-publish-button/label.cjs.map +2 -2
- package/build/components/post-publish-panel/postpublish.cjs +3 -2
- package/build/components/post-publish-panel/postpublish.cjs.map +2 -2
- package/build/components/post-revisions-panel/index.cjs +2 -2
- package/build/components/post-revisions-panel/index.cjs.map +2 -2
- package/build/components/post-revisions-preview/diff-markers.cjs +1 -1
- package/build/components/post-revisions-preview/diff-markers.cjs.map +2 -2
- package/build/components/post-revisions-preview/revisions-slider.cjs +1 -0
- package/build/components/post-revisions-preview/revisions-slider.cjs.map +2 -2
- package/build/components/post-saved-state/index.cjs +4 -1
- package/build/components/post-saved-state/index.cjs.map +2 -2
- package/build/components/post-text-editor/index.cjs +3 -4
- package/build/components/post-text-editor/index.cjs.map +2 -2
- package/build/components/preview-dropdown/index.cjs +3 -2
- package/build/components/preview-dropdown/index.cjs.map +2 -2
- package/build/components/provider/index.cjs +3 -1
- package/build/components/provider/index.cjs.map +3 -3
- package/build/components/provider/use-block-editor-settings.cjs +7 -1
- package/build/components/provider/use-block-editor-settings.cjs.map +3 -3
- package/build/components/provider/use-upload-save-lock.cjs +2 -12
- package/build/components/provider/use-upload-save-lock.cjs.map +2 -2
- package/build/components/resizable-editor/resize-handle.cjs +2 -1
- package/build/components/resizable-editor/resize-handle.cjs.map +2 -2
- package/build/components/revision-created-panel/index.cjs.map +3 -3
- package/build/components/site-discussion/index.cjs.map +2 -2
- package/build/components/template-actions-panel/classic-theme-content.cjs.map +2 -2
- package/build/components/template-part-menu-items/convert-to-regular.cjs +54 -11
- package/build/components/template-part-menu-items/convert-to-regular.cjs.map +3 -3
- package/build/components/visual-editor/index.cjs +5 -22
- package/build/components/visual-editor/index.cjs.map +2 -2
- package/build/store/private-actions.cjs +0 -8
- package/build/store/private-actions.cjs.map +2 -2
- package/build/store/private-selectors.cjs +0 -5
- package/build/store/private-selectors.cjs.map +2 -2
- package/build/store/reducer.cjs +0 -10
- package/build/store/reducer.cjs.map +2 -2
- package/build/utils/media-finalize/index.cjs +3 -2
- package/build/utils/media-finalize/index.cjs.map +2 -2
- package/build/utils/media-upload/index.cjs +14 -25
- package/build/utils/media-upload/index.cjs.map +2 -2
- package/build-module/components/collab-sidebar/{comment-menu-item.mjs → add-note-menu-item.mjs} +10 -11
- package/build-module/components/collab-sidebar/add-note-menu-item.mjs.map +7 -0
- package/build-module/components/collab-sidebar/{add-comment.mjs → add-note.mjs} +26 -29
- package/build-module/components/collab-sidebar/add-note.mjs.map +7 -0
- package/build-module/components/collab-sidebar/board-store.mjs +3 -0
- package/build-module/components/collab-sidebar/board-store.mjs.map +2 -2
- package/build-module/components/collab-sidebar/floating-container.mjs +4 -3
- package/build-module/components/collab-sidebar/floating-container.mjs.map +2 -2
- package/build-module/components/collab-sidebar/hooks.mjs +91 -137
- package/build-module/components/collab-sidebar/hooks.mjs.map +2 -2
- package/build-module/components/collab-sidebar/index.mjs +29 -84
- package/build-module/components/collab-sidebar/index.mjs.map +2 -2
- package/build-module/components/collab-sidebar/{comment-author-info.mjs → note-byline.mjs} +7 -7
- package/build-module/components/collab-sidebar/note-byline.mjs.map +7 -0
- package/build-module/components/collab-sidebar/note-card.mjs +33 -0
- package/build-module/components/collab-sidebar/note-card.mjs.map +7 -0
- package/build-module/components/collab-sidebar/note-form.mjs +84 -0
- package/build-module/components/collab-sidebar/note-form.mjs.map +7 -0
- package/build-module/components/collab-sidebar/{comment-indicator-toolbar.mjs → note-indicator-toolbar.mjs} +25 -29
- package/build-module/components/collab-sidebar/note-indicator-toolbar.mjs.map +7 -0
- package/build-module/components/collab-sidebar/note-thread.mjs +289 -0
- package/build-module/components/collab-sidebar/note-thread.mjs.map +7 -0
- package/build-module/components/collab-sidebar/note.mjs +176 -0
- package/build-module/components/collab-sidebar/note.mjs.map +7 -0
- package/build-module/components/collab-sidebar/notes.mjs +215 -0
- package/build-module/components/collab-sidebar/notes.mjs.map +7 -0
- package/build-module/components/collab-sidebar/utils.mjs +19 -21
- package/build-module/components/collab-sidebar/utils.mjs.map +2 -2
- package/build-module/components/document-bar/index.mjs +3 -3
- package/build-module/components/document-bar/index.mjs.map +2 -2
- package/build-module/components/error-boundary/index.mjs +2 -2
- package/build-module/components/error-boundary/index.mjs.map +2 -2
- package/build-module/components/list-view-sidebar/list-view-outline.mjs +5 -5
- package/build-module/components/list-view-sidebar/list-view-outline.mjs.map +2 -2
- package/build-module/components/media/media-editor-modal.mjs +62 -0
- package/build-module/components/media/media-editor-modal.mjs.map +7 -0
- package/build-module/components/more-menu/index.mjs +3 -7
- package/build-module/components/more-menu/index.mjs.map +2 -2
- package/build-module/components/post-actions/set-as-homepage.mjs +2 -2
- package/build-module/components/post-actions/set-as-homepage.mjs.map +2 -2
- package/build-module/components/post-actions/set-as-posts-page.mjs +2 -2
- package/build-module/components/post-actions/set-as-posts-page.mjs.map +2 -2
- package/build-module/components/post-card-panel/index.mjs +5 -5
- package/build-module/components/post-card-panel/index.mjs.map +2 -2
- package/build-module/components/post-content-information/index.mjs +2 -2
- package/build-module/components/post-content-information/index.mjs.map +2 -2
- package/build-module/components/post-excerpt/panel.mjs +2 -2
- package/build-module/components/post-excerpt/panel.mjs.map +2 -2
- package/build-module/components/post-last-edited-panel/index.mjs +2 -2
- package/build-module/components/post-last-edited-panel/index.mjs.map +2 -2
- package/build-module/components/post-preview-button/index.mjs +3 -2
- package/build-module/components/post-preview-button/index.mjs.map +2 -2
- package/build-module/components/post-publish-button/index.mjs +2 -2
- package/build-module/components/post-publish-button/index.mjs.map +2 -2
- package/build-module/components/post-publish-button/label.mjs +4 -2
- package/build-module/components/post-publish-button/label.mjs.map +2 -2
- package/build-module/components/post-publish-panel/postpublish.mjs +3 -3
- package/build-module/components/post-publish-panel/postpublish.mjs.map +2 -2
- package/build-module/components/post-revisions-panel/index.mjs +2 -2
- package/build-module/components/post-revisions-panel/index.mjs.map +2 -2
- package/build-module/components/post-revisions-preview/diff-markers.mjs +1 -1
- package/build-module/components/post-revisions-preview/diff-markers.mjs.map +2 -2
- package/build-module/components/post-revisions-preview/revisions-slider.mjs +1 -0
- package/build-module/components/post-revisions-preview/revisions-slider.mjs.map +2 -2
- package/build-module/components/post-saved-state/index.mjs +4 -1
- package/build-module/components/post-saved-state/index.mjs.map +2 -2
- package/build-module/components/post-text-editor/index.mjs +2 -3
- package/build-module/components/post-text-editor/index.mjs.map +2 -2
- package/build-module/components/preview-dropdown/index.mjs +2 -2
- package/build-module/components/preview-dropdown/index.mjs.map +2 -2
- package/build-module/components/provider/index.mjs +3 -1
- package/build-module/components/provider/index.mjs.map +2 -2
- package/build-module/components/provider/use-block-editor-settings.mjs +7 -1
- package/build-module/components/provider/use-block-editor-settings.mjs.map +2 -2
- package/build-module/components/provider/use-upload-save-lock.mjs +2 -12
- package/build-module/components/provider/use-upload-save-lock.mjs.map +2 -2
- package/build-module/components/resizable-editor/resize-handle.mjs +2 -5
- package/build-module/components/resizable-editor/resize-handle.mjs.map +2 -2
- package/build-module/components/revision-created-panel/index.mjs +2 -2
- package/build-module/components/revision-created-panel/index.mjs.map +2 -2
- package/build-module/components/site-discussion/index.mjs +2 -2
- package/build-module/components/site-discussion/index.mjs.map +2 -2
- package/build-module/components/template-actions-panel/classic-theme-content.mjs +2 -2
- package/build-module/components/template-actions-panel/classic-theme-content.mjs.map +2 -2
- package/build-module/components/template-part-menu-items/convert-to-regular.mjs +60 -14
- package/build-module/components/template-part-menu-items/convert-to-regular.mjs.map +2 -2
- package/build-module/components/visual-editor/index.mjs +5 -22
- package/build-module/components/visual-editor/index.mjs.map +2 -2
- package/build-module/store/private-actions.mjs +0 -7
- package/build-module/store/private-actions.mjs.map +2 -2
- package/build-module/store/private-selectors.mjs +0 -4
- package/build-module/store/private-selectors.mjs.map +2 -2
- package/build-module/store/reducer.mjs +0 -9
- package/build-module/store/reducer.mjs.map +2 -2
- package/build-module/utils/media-finalize/index.mjs +3 -2
- package/build-module/utils/media-finalize/index.mjs.map +2 -2
- package/build-module/utils/media-upload/index.mjs +14 -25
- package/build-module/utils/media-upload/index.mjs.map +2 -2
- package/build-style/style-rtl.css +386 -142
- package/build-style/style.css +386 -142
- package/build-types/components/collab-sidebar/add-note-menu-item.d.ts +5 -0
- package/build-types/components/collab-sidebar/add-note-menu-item.d.ts.map +1 -0
- package/build-types/components/collab-sidebar/add-note.d.ts +6 -0
- package/build-types/components/collab-sidebar/add-note.d.ts.map +1 -0
- package/build-types/components/collab-sidebar/board-store.d.ts +1 -0
- package/build-types/components/collab-sidebar/board-store.d.ts.map +1 -1
- package/build-types/components/collab-sidebar/floating-container.d.ts.map +1 -1
- package/build-types/components/collab-sidebar/hooks.d.ts +8 -21
- package/build-types/components/collab-sidebar/hooks.d.ts.map +1 -1
- package/build-types/components/collab-sidebar/index.d.ts.map +1 -1
- package/build-types/components/collab-sidebar/note-byline.d.ts +7 -0
- package/build-types/components/collab-sidebar/note-byline.d.ts.map +1 -0
- package/build-types/components/collab-sidebar/note-card.d.ts +8 -0
- package/build-types/components/collab-sidebar/note-card.d.ts.map +1 -0
- package/build-types/components/collab-sidebar/note-form.d.ts +7 -0
- package/build-types/components/collab-sidebar/note-form.d.ts.map +1 -0
- package/build-types/components/collab-sidebar/note-indicator-toolbar.d.ts +5 -0
- package/build-types/components/collab-sidebar/note-indicator-toolbar.d.ts.map +1 -0
- package/build-types/components/collab-sidebar/note-thread.d.ts +11 -0
- package/build-types/components/collab-sidebar/note-thread.d.ts.map +1 -0
- package/build-types/components/collab-sidebar/note.d.ts +9 -0
- package/build-types/components/collab-sidebar/note.d.ts.map +1 -0
- package/build-types/components/collab-sidebar/notes.d.ts +7 -0
- package/build-types/components/collab-sidebar/notes.d.ts.map +1 -0
- package/build-types/components/collab-sidebar/utils.d.ts +21 -20
- package/build-types/components/collab-sidebar/utils.d.ts.map +1 -1
- package/build-types/components/media/media-editor-modal.d.ts +11 -0
- package/build-types/components/media/media-editor-modal.d.ts.map +1 -0
- package/build-types/components/more-menu/index.d.ts.map +1 -1
- package/build-types/components/post-preview-button/index.d.ts.map +1 -1
- package/build-types/components/post-publish-button/index.d.ts.map +1 -1
- package/build-types/components/post-publish-button/label.d.ts.map +1 -1
- package/build-types/components/post-revisions-preview/revisions-slider.d.ts.map +1 -1
- package/build-types/components/post-saved-state/index.d.ts.map +1 -1
- package/build-types/components/provider/index.d.ts.map +1 -1
- package/build-types/components/provider/use-block-editor-settings.d.ts.map +1 -1
- package/build-types/components/provider/use-upload-save-lock.d.ts +0 -2
- package/build-types/components/provider/use-upload-save-lock.d.ts.map +1 -1
- package/build-types/components/resizable-editor/resize-handle.d.ts.map +1 -1
- package/build-types/components/template-part-menu-items/convert-to-regular.d.ts.map +1 -1
- package/build-types/components/visual-editor/index.d.ts.map +1 -1
- package/build-types/store/private-actions.d.ts +0 -7
- package/build-types/store/private-actions.d.ts.map +1 -1
- package/build-types/store/private-selectors.d.ts +0 -7
- package/build-types/store/private-selectors.d.ts.map +1 -1
- package/build-types/store/reducer.d.ts +0 -10
- package/build-types/store/reducer.d.ts.map +1 -1
- package/build-types/utils/media-finalize/index.d.ts +1 -1
- package/build-types/utils/media-finalize/index.d.ts.map +1 -1
- package/build-types/utils/media-upload/index.d.ts.map +1 -1
- package/package.json +46 -46
- package/src/components/collab-sidebar/README.md +117 -0
- package/src/components/collab-sidebar/{comment-menu-item.js → add-note-menu-item.js} +8 -10
- package/src/components/collab-sidebar/{add-comment.js → add-note.js} +20 -21
- package/src/components/collab-sidebar/board-store.js +4 -2
- package/src/components/collab-sidebar/floating-container.js +5 -4
- package/src/components/collab-sidebar/hooks.js +115 -175
- package/src/components/collab-sidebar/index.js +35 -95
- package/src/components/collab-sidebar/{comment-author-info.js → note-byline.js} +5 -6
- package/src/components/collab-sidebar/note-card.js +36 -0
- package/src/components/collab-sidebar/{comment-form.js → note-form.js} +25 -27
- package/src/components/collab-sidebar/{comment-indicator-toolbar.js → note-indicator-toolbar.js} +29 -32
- package/src/components/collab-sidebar/note-thread.js +331 -0
- package/src/components/collab-sidebar/note.js +209 -0
- package/src/components/collab-sidebar/notes.js +276 -0
- package/src/components/collab-sidebar/style.scss +21 -11
- package/src/components/collab-sidebar/test/utils.js +65 -63
- package/src/components/collab-sidebar/utils.js +33 -35
- package/src/components/document-bar/index.js +4 -4
- package/src/components/error-boundary/index.js +3 -3
- package/src/components/list-view-sidebar/list-view-outline.js +6 -6
- package/src/components/media/media-editor-modal.js +95 -0
- package/src/components/more-menu/index.js +3 -7
- package/src/components/post-actions/set-as-homepage.js +2 -2
- package/src/components/post-actions/set-as-posts-page.js +2 -2
- package/src/components/post-card-panel/index.js +7 -7
- package/src/components/post-content-information/index.js +3 -3
- package/src/components/post-excerpt/panel.js +3 -3
- package/src/components/post-last-edited-panel/index.js +3 -3
- package/src/components/post-preview-button/index.js +3 -2
- package/src/components/post-publish-button/index.js +6 -5
- package/src/components/post-publish-button/label.js +3 -1
- package/src/components/post-publish-panel/postpublish.js +2 -2
- package/src/components/post-publish-panel/test/__snapshots__/index.js.snap +8 -14
- package/src/components/post-revisions-panel/index.js +3 -3
- package/src/components/post-revisions-preview/diff-markers.js +1 -1
- package/src/components/post-revisions-preview/revisions-slider.js +1 -0
- package/src/components/post-saved-state/index.js +4 -1
- package/src/components/post-saved-state/test/__snapshots__/index.js.snap +0 -1
- package/src/components/post-text-editor/index.js +3 -3
- package/src/components/preview-dropdown/index.js +2 -2
- package/src/components/provider/index.js +4 -0
- package/src/components/provider/use-block-editor-settings.js +10 -0
- package/src/components/provider/use-upload-save-lock.js +2 -17
- package/src/components/resizable-editor/resize-handle.js +2 -5
- package/src/components/revision-created-panel/index.js +3 -3
- package/src/components/site-discussion/index.js +3 -3
- package/src/components/template-actions-panel/classic-theme-content.js +3 -3
- package/src/components/template-part-menu-items/convert-to-regular.js +74 -12
- package/src/components/visual-editor/index.js +2 -29
- package/src/store/private-actions.js +0 -13
- package/src/store/private-selectors.js +0 -10
- package/src/store/reducer.js +0 -16
- package/src/utils/media-finalize/index.js +2 -1
- package/src/utils/media-finalize/test/index.js +25 -1
- package/src/utils/media-upload/index.js +26 -29
- package/build/components/collab-sidebar/add-comment.cjs.map +0 -7
- package/build/components/collab-sidebar/comment-author-info.cjs.map +0 -7
- package/build/components/collab-sidebar/comment-form.cjs.map +0 -7
- package/build/components/collab-sidebar/comment-indicator-toolbar.cjs.map +0 -7
- package/build/components/collab-sidebar/comment-menu-item.cjs.map +0 -7
- package/build/components/collab-sidebar/comments.cjs +0 -696
- package/build/components/collab-sidebar/comments.cjs.map +0 -7
- package/build-module/components/collab-sidebar/add-comment.mjs.map +0 -7
- package/build-module/components/collab-sidebar/comment-author-info.mjs.map +0 -7
- package/build-module/components/collab-sidebar/comment-form.mjs +0 -82
- package/build-module/components/collab-sidebar/comment-form.mjs.map +0 -7
- package/build-module/components/collab-sidebar/comment-indicator-toolbar.mjs.map +0 -7
- package/build-module/components/collab-sidebar/comment-menu-item.mjs.map +0 -7
- package/build-module/components/collab-sidebar/comments.mjs +0 -678
- package/build-module/components/collab-sidebar/comments.mjs.map +0 -7
- package/build-types/components/collab-sidebar/add-comment.d.ts +0 -6
- package/build-types/components/collab-sidebar/add-comment.d.ts.map +0 -1
- package/build-types/components/collab-sidebar/comment-author-info.d.ts +0 -8
- package/build-types/components/collab-sidebar/comment-author-info.d.ts.map +0 -1
- package/build-types/components/collab-sidebar/comment-form.d.ts +0 -9
- package/build-types/components/collab-sidebar/comment-form.d.ts.map +0 -1
- package/build-types/components/collab-sidebar/comment-indicator-toolbar.d.ts +0 -6
- package/build-types/components/collab-sidebar/comment-indicator-toolbar.d.ts.map +0 -1
- package/build-types/components/collab-sidebar/comment-menu-item.d.ts +0 -6
- package/build-types/components/collab-sidebar/comment-menu-item.d.ts.map +0 -1
- package/build-types/components/collab-sidebar/comments.d.ts +0 -10
- package/build-types/components/collab-sidebar/comments.d.ts.map +0 -1
- package/src/components/collab-sidebar/comments.js +0 -812
|
@@ -0,0 +1,289 @@
|
|
|
1
|
+
// packages/editor/src/components/collab-sidebar/note-thread.js
|
|
2
|
+
import clsx from "clsx";
|
|
3
|
+
import { useEffect, useRef } from "@wordpress/element";
|
|
4
|
+
import { Button } from "@wordpress/components";
|
|
5
|
+
import { Stack } from "@wordpress/ui";
|
|
6
|
+
import { useDebounce } from "@wordpress/compose";
|
|
7
|
+
import { __, _n, sprintf } from "@wordpress/i18n";
|
|
8
|
+
import { useDispatch } from "@wordpress/data";
|
|
9
|
+
import { __unstableStripHTML as stripHTML } from "@wordpress/dom";
|
|
10
|
+
import {
|
|
11
|
+
store as blockEditorStore,
|
|
12
|
+
privateApis as blockEditorPrivateApis
|
|
13
|
+
} from "@wordpress/block-editor";
|
|
14
|
+
import { AddNote } from "./add-note.mjs";
|
|
15
|
+
import { Note } from "./note.mjs";
|
|
16
|
+
import { NoteCard } from "./note-card.mjs";
|
|
17
|
+
import { NoteForm } from "./note-form.mjs";
|
|
18
|
+
import { FloatingContainer } from "./floating-container.mjs";
|
|
19
|
+
import { focusNoteThread, getNoteExcerpt } from "./utils.mjs";
|
|
20
|
+
import { store as editorStore } from "../../store/index.mjs";
|
|
21
|
+
import { unlock } from "../../lock-unlock.mjs";
|
|
22
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
23
|
+
var { useBlockElement } = unlock(blockEditorPrivateApis);
|
|
24
|
+
function NoteThread({
|
|
25
|
+
note,
|
|
26
|
+
onEditNote,
|
|
27
|
+
onAddReply,
|
|
28
|
+
onDeleteNote,
|
|
29
|
+
isSelected,
|
|
30
|
+
sidebarRef,
|
|
31
|
+
floating,
|
|
32
|
+
onKeyDown
|
|
33
|
+
}) {
|
|
34
|
+
const isFloating = !!floating;
|
|
35
|
+
const { toggleBlockHighlight, selectBlock, toggleBlockSpotlight } = unlock(
|
|
36
|
+
useDispatch(blockEditorStore)
|
|
37
|
+
);
|
|
38
|
+
const { selectNote } = unlock(useDispatch(editorStore));
|
|
39
|
+
const relatedBlockElement = useBlockElement(note.blockClientId);
|
|
40
|
+
const debouncedToggleBlockHighlight = useDebounce(
|
|
41
|
+
toggleBlockHighlight,
|
|
42
|
+
50
|
|
43
|
+
);
|
|
44
|
+
const floatingRef = useRef(null);
|
|
45
|
+
const isKeyboardTabbingRef = useRef(false);
|
|
46
|
+
const registerThread = floating?.registerThread;
|
|
47
|
+
const unregisterThread = floating?.unregisterThread;
|
|
48
|
+
useEffect(() => {
|
|
49
|
+
const floatingEl = floatingRef.current;
|
|
50
|
+
if (floatingEl && registerThread) {
|
|
51
|
+
registerThread(note.id, relatedBlockElement, floatingEl);
|
|
52
|
+
}
|
|
53
|
+
return () => unregisterThread?.(note.id);
|
|
54
|
+
}, [relatedBlockElement, note.id, registerThread, unregisterThread]);
|
|
55
|
+
const onMouseEnter = () => {
|
|
56
|
+
debouncedToggleBlockHighlight(note.blockClientId, true);
|
|
57
|
+
};
|
|
58
|
+
const onMouseLeave = () => {
|
|
59
|
+
debouncedToggleBlockHighlight(note.blockClientId, false);
|
|
60
|
+
};
|
|
61
|
+
const onFocus = () => {
|
|
62
|
+
toggleBlockHighlight(note.blockClientId, true);
|
|
63
|
+
};
|
|
64
|
+
const onBlur = (event) => {
|
|
65
|
+
if (!document.hasFocus()) {
|
|
66
|
+
return;
|
|
67
|
+
}
|
|
68
|
+
const isNoteFocused = event.relatedTarget?.closest(
|
|
69
|
+
".editor-collab-sidebar-panel__thread"
|
|
70
|
+
);
|
|
71
|
+
const isDialogFocused = event.relatedTarget?.closest('[role="dialog"]');
|
|
72
|
+
const isTabbing = isKeyboardTabbingRef.current;
|
|
73
|
+
if (isNoteFocused && !isTabbing) {
|
|
74
|
+
return;
|
|
75
|
+
}
|
|
76
|
+
if (isDialogFocused) {
|
|
77
|
+
return;
|
|
78
|
+
}
|
|
79
|
+
if (isTabbing && event.currentTarget.contains(event.relatedTarget)) {
|
|
80
|
+
return;
|
|
81
|
+
}
|
|
82
|
+
toggleBlockHighlight(note.blockClientId, false);
|
|
83
|
+
unselectNote();
|
|
84
|
+
};
|
|
85
|
+
const handleNoteSelect = () => {
|
|
86
|
+
selectNote(note.id);
|
|
87
|
+
toggleBlockSpotlight(note.blockClientId, true);
|
|
88
|
+
if (!!note.blockClientId) {
|
|
89
|
+
selectBlock(note.blockClientId, null);
|
|
90
|
+
}
|
|
91
|
+
};
|
|
92
|
+
const unselectNote = () => {
|
|
93
|
+
selectNote(void 0);
|
|
94
|
+
toggleBlockSpotlight(note.blockClientId, false);
|
|
95
|
+
};
|
|
96
|
+
const handleResolve = () => {
|
|
97
|
+
onEditNote({ id: note.id, status: "approved" });
|
|
98
|
+
unselectNote();
|
|
99
|
+
if (isFloating) {
|
|
100
|
+
relatedBlockElement?.focus();
|
|
101
|
+
} else {
|
|
102
|
+
focusNoteThread(note.id, sidebarRef.current);
|
|
103
|
+
}
|
|
104
|
+
};
|
|
105
|
+
const allReplies = note?.reply || [];
|
|
106
|
+
const lastReply = allReplies.length > 0 ? allReplies[allReplies.length - 1] : void 0;
|
|
107
|
+
const restReplies = allReplies.length > 0 ? allReplies.slice(0, -1) : [];
|
|
108
|
+
const noteExcerpt = getNoteExcerpt(
|
|
109
|
+
stripHTML(note.content?.rendered),
|
|
110
|
+
10
|
|
111
|
+
);
|
|
112
|
+
const ariaLabel = !!note.blockClientId ? sprintf(
|
|
113
|
+
// translators: %s: note excerpt
|
|
114
|
+
__("Note: %s"),
|
|
115
|
+
noteExcerpt
|
|
116
|
+
) : sprintf(
|
|
117
|
+
// translators: %s: note excerpt
|
|
118
|
+
__("Original block deleted. Note: %s"),
|
|
119
|
+
noteExcerpt
|
|
120
|
+
);
|
|
121
|
+
if (isFloating && note.id === "new") {
|
|
122
|
+
return /* @__PURE__ */ jsx(
|
|
123
|
+
AddNote,
|
|
124
|
+
{
|
|
125
|
+
onSubmit: onAddReply,
|
|
126
|
+
sidebarRef,
|
|
127
|
+
floating: { y: floating.y, ref: floatingRef }
|
|
128
|
+
}
|
|
129
|
+
);
|
|
130
|
+
}
|
|
131
|
+
return /* @__PURE__ */ jsxs(
|
|
132
|
+
FloatingContainer,
|
|
133
|
+
{
|
|
134
|
+
floating: isFloating ? { y: floating.y, ref: floatingRef } : void 0,
|
|
135
|
+
className: clsx("editor-collab-sidebar-panel__thread", {
|
|
136
|
+
"is-selected": isSelected
|
|
137
|
+
}),
|
|
138
|
+
id: `note-thread-${note.id}`,
|
|
139
|
+
gap: "md",
|
|
140
|
+
onClick: handleNoteSelect,
|
|
141
|
+
onMouseEnter,
|
|
142
|
+
onMouseLeave,
|
|
143
|
+
onFocus,
|
|
144
|
+
onBlur,
|
|
145
|
+
onKeyUp: (event) => {
|
|
146
|
+
if (event.key === "Tab") {
|
|
147
|
+
isKeyboardTabbingRef.current = false;
|
|
148
|
+
}
|
|
149
|
+
},
|
|
150
|
+
onKeyDown: (event) => {
|
|
151
|
+
if (event.key === "Tab") {
|
|
152
|
+
isKeyboardTabbingRef.current = true;
|
|
153
|
+
} else {
|
|
154
|
+
onKeyDown(event);
|
|
155
|
+
}
|
|
156
|
+
},
|
|
157
|
+
tabIndex: 0,
|
|
158
|
+
role: "treeitem",
|
|
159
|
+
"aria-label": ariaLabel,
|
|
160
|
+
"aria-expanded": isSelected,
|
|
161
|
+
children: [
|
|
162
|
+
/* @__PURE__ */ jsx(
|
|
163
|
+
Button,
|
|
164
|
+
{
|
|
165
|
+
className: "editor-collab-sidebar-panel__skip-to-note",
|
|
166
|
+
variant: "secondary",
|
|
167
|
+
size: "compact",
|
|
168
|
+
onClick: () => {
|
|
169
|
+
focusNoteThread(note.id, sidebarRef.current, "textarea");
|
|
170
|
+
},
|
|
171
|
+
children: __("Add new reply")
|
|
172
|
+
}
|
|
173
|
+
),
|
|
174
|
+
!note.blockClientId && /* @__PURE__ */ jsx("p", { className: "editor-collab-sidebar-panel__deleted-block-notice", children: __("Original block deleted.") }),
|
|
175
|
+
/* @__PURE__ */ jsx(
|
|
176
|
+
Note,
|
|
177
|
+
{
|
|
178
|
+
note,
|
|
179
|
+
isSelected,
|
|
180
|
+
onEditNote,
|
|
181
|
+
onDeleteNote,
|
|
182
|
+
onResolve: handleResolve
|
|
183
|
+
}
|
|
184
|
+
),
|
|
185
|
+
isSelected && allReplies.map((reply) => /* @__PURE__ */ jsx(
|
|
186
|
+
Note,
|
|
187
|
+
{
|
|
188
|
+
note: reply,
|
|
189
|
+
parentNote: note,
|
|
190
|
+
isSelected,
|
|
191
|
+
onEditNote,
|
|
192
|
+
onDeleteNote
|
|
193
|
+
},
|
|
194
|
+
reply.id
|
|
195
|
+
)),
|
|
196
|
+
!isSelected && restReplies.length > 0 && /* @__PURE__ */ jsx(
|
|
197
|
+
Stack,
|
|
198
|
+
{
|
|
199
|
+
direction: "row",
|
|
200
|
+
align: "center",
|
|
201
|
+
justify: "space-between",
|
|
202
|
+
className: "editor-collab-sidebar-panel__more-reply-separator",
|
|
203
|
+
children: /* @__PURE__ */ jsx(
|
|
204
|
+
Button,
|
|
205
|
+
{
|
|
206
|
+
size: "compact",
|
|
207
|
+
variant: "tertiary",
|
|
208
|
+
className: "editor-collab-sidebar-panel__more-reply-button",
|
|
209
|
+
onClick: () => {
|
|
210
|
+
selectNote(note.id);
|
|
211
|
+
focusNoteThread(note.id, sidebarRef.current);
|
|
212
|
+
},
|
|
213
|
+
children: sprintf(
|
|
214
|
+
// translators: %s: number of replies.
|
|
215
|
+
_n(
|
|
216
|
+
"%s more reply",
|
|
217
|
+
"%s more replies",
|
|
218
|
+
restReplies.length
|
|
219
|
+
),
|
|
220
|
+
restReplies.length
|
|
221
|
+
)
|
|
222
|
+
}
|
|
223
|
+
)
|
|
224
|
+
}
|
|
225
|
+
),
|
|
226
|
+
!isSelected && lastReply && /* @__PURE__ */ jsx(
|
|
227
|
+
Note,
|
|
228
|
+
{
|
|
229
|
+
note: lastReply,
|
|
230
|
+
parentNote: note,
|
|
231
|
+
isSelected: false,
|
|
232
|
+
onEditNote,
|
|
233
|
+
onDeleteNote
|
|
234
|
+
}
|
|
235
|
+
),
|
|
236
|
+
isSelected && /* @__PURE__ */ jsx(NoteCard, { role: "treeitem", children: /* @__PURE__ */ jsx(
|
|
237
|
+
NoteForm,
|
|
238
|
+
{
|
|
239
|
+
onSubmit: (inputComment) => {
|
|
240
|
+
if ("approved" === note.status) {
|
|
241
|
+
onEditNote({
|
|
242
|
+
id: note.id,
|
|
243
|
+
status: "hold",
|
|
244
|
+
content: inputComment
|
|
245
|
+
});
|
|
246
|
+
} else {
|
|
247
|
+
onAddReply({
|
|
248
|
+
content: inputComment,
|
|
249
|
+
parent: note.id
|
|
250
|
+
});
|
|
251
|
+
}
|
|
252
|
+
},
|
|
253
|
+
onCancel: (event) => {
|
|
254
|
+
event.stopPropagation();
|
|
255
|
+
unselectNote();
|
|
256
|
+
focusNoteThread(note.id, sidebarRef.current);
|
|
257
|
+
},
|
|
258
|
+
labels: {
|
|
259
|
+
submit: "approved" === note.status ? __("Reopen & Reply") : __("Reply"),
|
|
260
|
+
input: sprintf(
|
|
261
|
+
// translators: %1$s: note identifier, %2$s: author name
|
|
262
|
+
__("Reply to note %1$s by %2$s"),
|
|
263
|
+
note.id,
|
|
264
|
+
note.author_name
|
|
265
|
+
)
|
|
266
|
+
}
|
|
267
|
+
}
|
|
268
|
+
) }),
|
|
269
|
+
!!note.blockClientId && /* @__PURE__ */ jsx(
|
|
270
|
+
Button,
|
|
271
|
+
{
|
|
272
|
+
className: "editor-collab-sidebar-panel__skip-to-block",
|
|
273
|
+
variant: "secondary",
|
|
274
|
+
size: "compact",
|
|
275
|
+
onClick: (event) => {
|
|
276
|
+
event.stopPropagation();
|
|
277
|
+
relatedBlockElement?.focus();
|
|
278
|
+
},
|
|
279
|
+
children: __("Back to block")
|
|
280
|
+
}
|
|
281
|
+
)
|
|
282
|
+
]
|
|
283
|
+
}
|
|
284
|
+
);
|
|
285
|
+
}
|
|
286
|
+
export {
|
|
287
|
+
NoteThread
|
|
288
|
+
};
|
|
289
|
+
//# sourceMappingURL=note-thread.mjs.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../src/components/collab-sidebar/note-thread.js"],
|
|
4
|
+
"sourcesContent": ["/**\n * External dependencies\n */\nimport clsx from 'clsx';\n\n/**\n * WordPress dependencies\n */\nimport { useEffect, useRef } from '@wordpress/element';\nimport { Button } from '@wordpress/components';\nimport { Stack } from '@wordpress/ui';\nimport { useDebounce } from '@wordpress/compose';\nimport { __, _n, sprintf } from '@wordpress/i18n';\nimport { useDispatch } from '@wordpress/data';\nimport { __unstableStripHTML as stripHTML } from '@wordpress/dom';\nimport {\n\tstore as blockEditorStore,\n\tprivateApis as blockEditorPrivateApis,\n} from '@wordpress/block-editor';\n\n/**\n * Internal dependencies\n */\nimport { AddNote } from './add-note';\nimport { Note } from './note';\nimport { NoteCard } from './note-card';\nimport { NoteForm } from './note-form';\nimport { FloatingContainer } from './floating-container';\nimport { focusNoteThread, getNoteExcerpt } from './utils';\nimport { store as editorStore } from '../../store';\nimport { unlock } from '../../lock-unlock';\n\nconst { useBlockElement } = unlock( blockEditorPrivateApis );\n\nexport function NoteThread( {\n\tnote,\n\tonEditNote,\n\tonAddReply,\n\tonDeleteNote,\n\tisSelected,\n\tsidebarRef,\n\tfloating,\n\tonKeyDown,\n} ) {\n\tconst isFloating = !! floating;\n\tconst { toggleBlockHighlight, selectBlock, toggleBlockSpotlight } = unlock(\n\t\tuseDispatch( blockEditorStore )\n\t);\n\tconst { selectNote } = unlock( useDispatch( editorStore ) );\n\tconst relatedBlockElement = useBlockElement( note.blockClientId );\n\tconst debouncedToggleBlockHighlight = useDebounce(\n\t\ttoggleBlockHighlight,\n\t\t50\n\t);\n\tconst floatingRef = useRef( null );\n\tconst isKeyboardTabbingRef = useRef( false );\n\n\tconst registerThread = floating?.registerThread;\n\tconst unregisterThread = floating?.unregisterThread;\n\n\t// Register block + floating elements with the board.\n\t// The board's ResizeObserver and autoUpdate track changes automatically.\n\tuseEffect( () => {\n\t\tconst floatingEl = floatingRef.current;\n\t\tif ( floatingEl && registerThread ) {\n\t\t\tregisterThread( note.id, relatedBlockElement, floatingEl );\n\t\t}\n\t\treturn () => unregisterThread?.( note.id );\n\t}, [ relatedBlockElement, note.id, registerThread, unregisterThread ] );\n\n\tconst onMouseEnter = () => {\n\t\tdebouncedToggleBlockHighlight( note.blockClientId, true );\n\t};\n\n\tconst onMouseLeave = () => {\n\t\tdebouncedToggleBlockHighlight( note.blockClientId, false );\n\t};\n\n\tconst onFocus = () => {\n\t\ttoggleBlockHighlight( note.blockClientId, true );\n\t};\n\n\tconst onBlur = ( event ) => {\n\t\t// Don't deselect notes when the browser window/tab loses focus.\n\t\tif ( ! document.hasFocus() ) {\n\t\t\treturn;\n\t\t}\n\n\t\tconst isNoteFocused = event.relatedTarget?.closest(\n\t\t\t'.editor-collab-sidebar-panel__thread'\n\t\t);\n\t\tconst isDialogFocused =\n\t\t\tevent.relatedTarget?.closest( '[role=\"dialog\"]' );\n\t\tconst isTabbing = isKeyboardTabbingRef.current;\n\n\t\t// When another note is clicked, do nothing because the current note is automatically closed.\n\t\tif ( isNoteFocused && ! isTabbing ) {\n\t\t\treturn;\n\t\t}\n\t\t// When deleting a note, a dialog appears, but the note should not be collapsed.\n\t\tif ( isDialogFocused ) {\n\t\t\treturn;\n\t\t}\n\t\t// When tabbing, do nothing if the focus is within the current note.\n\t\tif (\n\t\t\tisTabbing &&\n\t\t\tevent.currentTarget.contains( event.relatedTarget )\n\t\t) {\n\t\t\treturn;\n\t\t}\n\n\t\t// Closes a note that has lost focus when any of the following conditions are met:\n\t\t// - An element other than a note is clicked.\n\t\t// - Focus was lost by tabbing.\n\t\ttoggleBlockHighlight( note.blockClientId, false );\n\t\tunselectNote();\n\t};\n\n\tconst handleNoteSelect = () => {\n\t\tselectNote( note.id );\n\t\ttoggleBlockSpotlight( note.blockClientId, true );\n\t\tif ( !! note.blockClientId ) {\n\t\t\t// Pass `null` as the second parameter to prevent focusing the block.\n\t\t\tselectBlock( note.blockClientId, null );\n\t\t}\n\t};\n\n\tconst unselectNote = () => {\n\t\tselectNote( undefined );\n\t\ttoggleBlockSpotlight( note.blockClientId, false );\n\t};\n\n\tconst handleResolve = () => {\n\t\tonEditNote( { id: note.id, status: 'approved' } );\n\t\tunselectNote();\n\t\tif ( isFloating ) {\n\t\t\trelatedBlockElement?.focus();\n\t\t} else {\n\t\t\tfocusNoteThread( note.id, sidebarRef.current );\n\t\t}\n\t};\n\n\tconst allReplies = note?.reply || [];\n\tconst lastReply =\n\t\tallReplies.length > 0 ? allReplies[ allReplies.length - 1 ] : undefined;\n\tconst restReplies = allReplies.length > 0 ? allReplies.slice( 0, -1 ) : [];\n\n\tconst noteExcerpt = getNoteExcerpt(\n\t\tstripHTML( note.content?.rendered ),\n\t\t10\n\t);\n\tconst ariaLabel = !! note.blockClientId\n\t\t? sprintf(\n\t\t\t\t// translators: %s: note excerpt\n\t\t\t\t__( 'Note: %s' ),\n\t\t\t\tnoteExcerpt\n\t\t )\n\t\t: sprintf(\n\t\t\t\t// translators: %s: note excerpt\n\t\t\t\t__( 'Original block deleted. Note: %s' ),\n\t\t\t\tnoteExcerpt\n\t\t );\n\n\tif ( isFloating && note.id === 'new' ) {\n\t\treturn (\n\t\t\t<AddNote\n\t\t\t\tonSubmit={ onAddReply }\n\t\t\t\tsidebarRef={ sidebarRef }\n\t\t\t\tfloating={ { y: floating.y, ref: floatingRef } }\n\t\t\t/>\n\t\t);\n\t}\n\n\treturn (\n\t\t<FloatingContainer\n\t\t\tfloating={\n\t\t\t\tisFloating ? { y: floating.y, ref: floatingRef } : undefined\n\t\t\t}\n\t\t\tclassName={ clsx( 'editor-collab-sidebar-panel__thread', {\n\t\t\t\t'is-selected': isSelected,\n\t\t\t} ) }\n\t\t\tid={ `note-thread-${ note.id }` }\n\t\t\tgap=\"md\"\n\t\t\tonClick={ handleNoteSelect }\n\t\t\tonMouseEnter={ onMouseEnter }\n\t\t\tonMouseLeave={ onMouseLeave }\n\t\t\tonFocus={ onFocus }\n\t\t\tonBlur={ onBlur }\n\t\t\tonKeyUp={ ( event ) => {\n\t\t\t\tif ( event.key === 'Tab' ) {\n\t\t\t\t\tisKeyboardTabbingRef.current = false;\n\t\t\t\t}\n\t\t\t} }\n\t\t\tonKeyDown={ ( event ) => {\n\t\t\t\tif ( event.key === 'Tab' ) {\n\t\t\t\t\tisKeyboardTabbingRef.current = true;\n\t\t\t\t} else {\n\t\t\t\t\tonKeyDown( event );\n\t\t\t\t}\n\t\t\t} }\n\t\t\ttabIndex={ 0 }\n\t\t\trole=\"treeitem\"\n\t\t\taria-label={ ariaLabel }\n\t\t\taria-expanded={ isSelected }\n\t\t>\n\t\t\t<Button\n\t\t\t\tclassName=\"editor-collab-sidebar-panel__skip-to-note\"\n\t\t\t\tvariant=\"secondary\"\n\t\t\t\tsize=\"compact\"\n\t\t\t\tonClick={ () => {\n\t\t\t\t\tfocusNoteThread( note.id, sidebarRef.current, 'textarea' );\n\t\t\t\t} }\n\t\t\t>\n\t\t\t\t{ __( 'Add new reply' ) }\n\t\t\t</Button>\n\t\t\t{ ! note.blockClientId && (\n\t\t\t\t<p className=\"editor-collab-sidebar-panel__deleted-block-notice\">\n\t\t\t\t\t{ __( 'Original block deleted.' ) }\n\t\t\t\t</p>\n\t\t\t) }\n\t\t\t<Note\n\t\t\t\tnote={ note }\n\t\t\t\tisSelected={ isSelected }\n\t\t\t\tonEditNote={ onEditNote }\n\t\t\t\tonDeleteNote={ onDeleteNote }\n\t\t\t\tonResolve={ handleResolve }\n\t\t\t/>\n\t\t\t{ isSelected &&\n\t\t\t\tallReplies.map( ( reply ) => (\n\t\t\t\t\t<Note\n\t\t\t\t\t\tkey={ reply.id }\n\t\t\t\t\t\tnote={ reply }\n\t\t\t\t\t\tparentNote={ note }\n\t\t\t\t\t\tisSelected={ isSelected }\n\t\t\t\t\t\tonEditNote={ onEditNote }\n\t\t\t\t\t\tonDeleteNote={ onDeleteNote }\n\t\t\t\t\t/>\n\t\t\t\t) ) }\n\t\t\t{ ! isSelected && restReplies.length > 0 && (\n\t\t\t\t<Stack\n\t\t\t\t\tdirection=\"row\"\n\t\t\t\t\talign=\"center\"\n\t\t\t\t\tjustify=\"space-between\"\n\t\t\t\t\tclassName=\"editor-collab-sidebar-panel__more-reply-separator\"\n\t\t\t\t>\n\t\t\t\t\t<Button\n\t\t\t\t\t\tsize=\"compact\"\n\t\t\t\t\t\tvariant=\"tertiary\"\n\t\t\t\t\t\tclassName=\"editor-collab-sidebar-panel__more-reply-button\"\n\t\t\t\t\t\tonClick={ () => {\n\t\t\t\t\t\t\tselectNote( note.id );\n\t\t\t\t\t\t\tfocusNoteThread( note.id, sidebarRef.current );\n\t\t\t\t\t\t} }\n\t\t\t\t\t>\n\t\t\t\t\t\t{ sprintf(\n\t\t\t\t\t\t\t// translators: %s: number of replies.\n\t\t\t\t\t\t\t_n(\n\t\t\t\t\t\t\t\t'%s more reply',\n\t\t\t\t\t\t\t\t'%s more replies',\n\t\t\t\t\t\t\t\trestReplies.length\n\t\t\t\t\t\t\t),\n\t\t\t\t\t\t\trestReplies.length\n\t\t\t\t\t\t) }\n\t\t\t\t\t</Button>\n\t\t\t\t</Stack>\n\t\t\t) }\n\t\t\t{ ! isSelected && lastReply && (\n\t\t\t\t<Note\n\t\t\t\t\tnote={ lastReply }\n\t\t\t\t\tparentNote={ note }\n\t\t\t\t\tisSelected={ false }\n\t\t\t\t\tonEditNote={ onEditNote }\n\t\t\t\t\tonDeleteNote={ onDeleteNote }\n\t\t\t\t/>\n\t\t\t) }\n\t\t\t{ isSelected && (\n\t\t\t\t<NoteCard role=\"treeitem\">\n\t\t\t\t\t<NoteForm\n\t\t\t\t\t\tonSubmit={ ( inputComment ) => {\n\t\t\t\t\t\t\tif ( 'approved' === note.status ) {\n\t\t\t\t\t\t\t\t// For reopening, include the content in the reopen action.\n\t\t\t\t\t\t\t\tonEditNote( {\n\t\t\t\t\t\t\t\t\tid: note.id,\n\t\t\t\t\t\t\t\t\tstatus: 'hold',\n\t\t\t\t\t\t\t\t\tcontent: inputComment,\n\t\t\t\t\t\t\t\t} );\n\t\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\t\t// For regular replies, add as separate comment.\n\t\t\t\t\t\t\t\tonAddReply( {\n\t\t\t\t\t\t\t\t\tcontent: inputComment,\n\t\t\t\t\t\t\t\t\tparent: note.id,\n\t\t\t\t\t\t\t\t} );\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t} }\n\t\t\t\t\t\tonCancel={ ( event ) => {\n\t\t\t\t\t\t\t// Prevent the parent onClick from being triggered.\n\t\t\t\t\t\t\tevent.stopPropagation();\n\t\t\t\t\t\t\tunselectNote();\n\t\t\t\t\t\t\tfocusNoteThread( note.id, sidebarRef.current );\n\t\t\t\t\t\t} }\n\t\t\t\t\t\tlabels={ {\n\t\t\t\t\t\t\tsubmit:\n\t\t\t\t\t\t\t\t'approved' === note.status\n\t\t\t\t\t\t\t\t\t? __( 'Reopen & Reply' )\n\t\t\t\t\t\t\t\t\t: __( 'Reply' ),\n\t\t\t\t\t\t\tinput: sprintf(\n\t\t\t\t\t\t\t\t// translators: %1$s: note identifier, %2$s: author name\n\t\t\t\t\t\t\t\t__( 'Reply to note %1$s by %2$s' ),\n\t\t\t\t\t\t\t\tnote.id,\n\t\t\t\t\t\t\t\tnote.author_name\n\t\t\t\t\t\t\t),\n\t\t\t\t\t\t} }\n\t\t\t\t\t/>\n\t\t\t\t</NoteCard>\n\t\t\t) }\n\t\t\t{ !! note.blockClientId && (\n\t\t\t\t<Button\n\t\t\t\t\tclassName=\"editor-collab-sidebar-panel__skip-to-block\"\n\t\t\t\t\tvariant=\"secondary\"\n\t\t\t\t\tsize=\"compact\"\n\t\t\t\t\tonClick={ ( event ) => {\n\t\t\t\t\t\tevent.stopPropagation();\n\t\t\t\t\t\trelatedBlockElement?.focus();\n\t\t\t\t\t} }\n\t\t\t\t>\n\t\t\t\t\t{ __( 'Back to block' ) }\n\t\t\t\t</Button>\n\t\t\t) }\n\t\t</FloatingContainer>\n\t);\n}\n"],
|
|
5
|
+
"mappings": ";AAGA,OAAO,UAAU;AAKjB,SAAS,WAAW,cAAc;AAClC,SAAS,cAAc;AACvB,SAAS,aAAa;AACtB,SAAS,mBAAmB;AAC5B,SAAS,IAAI,IAAI,eAAe;AAChC,SAAS,mBAAmB;AAC5B,SAAS,uBAAuB,iBAAiB;AACjD;AAAA,EACC,SAAS;AAAA,EACT,eAAe;AAAA,OACT;AAKP,SAAS,eAAe;AACxB,SAAS,YAAY;AACrB,SAAS,gBAAgB;AACzB,SAAS,gBAAgB;AACzB,SAAS,yBAAyB;AAClC,SAAS,iBAAiB,sBAAsB;AAChD,SAAS,SAAS,mBAAmB;AACrC,SAAS,cAAc;AAuIpB,cASD,YATC;AArIH,IAAM,EAAE,gBAAgB,IAAI,OAAQ,sBAAuB;AAEpD,SAAS,WAAY;AAAA,EAC3B;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACD,GAAI;AACH,QAAM,aAAa,CAAC,CAAE;AACtB,QAAM,EAAE,sBAAsB,aAAa,qBAAqB,IAAI;AAAA,IACnE,YAAa,gBAAiB;AAAA,EAC/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,0 +1,176 @@
|
|
|
1
|
+
// packages/editor/src/components/collab-sidebar/note.js
|
|
2
|
+
import clsx from "clsx";
|
|
3
|
+
import { RawHTML, useRef, useState } from "@wordpress/element";
|
|
4
|
+
import {
|
|
5
|
+
__experimentalConfirmDialog as ConfirmDialog,
|
|
6
|
+
Button,
|
|
7
|
+
privateApis as componentsPrivateApis
|
|
8
|
+
} from "@wordpress/components";
|
|
9
|
+
import { __, _x, sprintf } from "@wordpress/i18n";
|
|
10
|
+
import { moreVertical, published } from "@wordpress/icons";
|
|
11
|
+
import { NoteCard } from "./note-card.mjs";
|
|
12
|
+
import { NoteForm } from "./note-form.mjs";
|
|
13
|
+
import { unlock } from "../../lock-unlock.mjs";
|
|
14
|
+
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
15
|
+
var { Menu } = unlock(componentsPrivateApis);
|
|
16
|
+
function NoteActionsMenu({ items, buttonRef }) {
|
|
17
|
+
return /* @__PURE__ */ jsxs(Menu, { placement: "bottom-end", children: [
|
|
18
|
+
/* @__PURE__ */ jsx(
|
|
19
|
+
Menu.TriggerButton,
|
|
20
|
+
{
|
|
21
|
+
render: /* @__PURE__ */ jsx(
|
|
22
|
+
Button,
|
|
23
|
+
{
|
|
24
|
+
ref: buttonRef,
|
|
25
|
+
size: "small",
|
|
26
|
+
icon: moreVertical,
|
|
27
|
+
label: __("Actions"),
|
|
28
|
+
disabled: !items.length,
|
|
29
|
+
accessibleWhenDisabled: true
|
|
30
|
+
}
|
|
31
|
+
)
|
|
32
|
+
}
|
|
33
|
+
),
|
|
34
|
+
/* @__PURE__ */ jsx(
|
|
35
|
+
Menu.Popover,
|
|
36
|
+
{
|
|
37
|
+
modal: false,
|
|
38
|
+
children: items.map((item) => /* @__PURE__ */ jsx(Menu.Item, { onClick: item.onClick, children: /* @__PURE__ */ jsx(Menu.ItemLabel, { children: item.title }) }, item.id))
|
|
39
|
+
}
|
|
40
|
+
)
|
|
41
|
+
] });
|
|
42
|
+
}
|
|
43
|
+
function Note({
|
|
44
|
+
note,
|
|
45
|
+
parentNote,
|
|
46
|
+
isSelected,
|
|
47
|
+
onEditNote,
|
|
48
|
+
onDeleteNote,
|
|
49
|
+
onResolve
|
|
50
|
+
}) {
|
|
51
|
+
const [actionState, setActionState] = useState(null);
|
|
52
|
+
const actionButtonRef = useRef(null);
|
|
53
|
+
const canResolve = note.parent === 0;
|
|
54
|
+
const isResolutionNote = note.type === "note" && note.meta && (note.meta._wp_note_status === "resolved" || note.meta._wp_note_status === "reopen");
|
|
55
|
+
const menuItems = [
|
|
56
|
+
{
|
|
57
|
+
id: "edit",
|
|
58
|
+
title: __("Edit"),
|
|
59
|
+
isEligible: ({ status }) => status !== "approved",
|
|
60
|
+
onClick: () => setActionState("edit")
|
|
61
|
+
},
|
|
62
|
+
{
|
|
63
|
+
id: "reopen",
|
|
64
|
+
title: _x("Reopen", "Reopen note"),
|
|
65
|
+
isEligible: ({ status }) => status === "approved",
|
|
66
|
+
onClick: () => onEditNote({ id: note.id, status: "hold" })
|
|
67
|
+
},
|
|
68
|
+
{
|
|
69
|
+
id: "delete",
|
|
70
|
+
title: __("Delete"),
|
|
71
|
+
isEligible: () => true,
|
|
72
|
+
onClick: () => setActionState("delete")
|
|
73
|
+
}
|
|
74
|
+
];
|
|
75
|
+
const availableItems = parentNote?.status !== "approved" ? menuItems.filter((item) => item.isEligible(note)) : [];
|
|
76
|
+
const deleteConfirmMessage = note.parent === 0 ? __(
|
|
77
|
+
"Are you sure you want to delete this note? This will also delete all of this note's replies."
|
|
78
|
+
) : __("Are you sure you want to delete this reply?");
|
|
79
|
+
const handleCancel = () => {
|
|
80
|
+
setActionState(null);
|
|
81
|
+
actionButtonRef.current?.focus();
|
|
82
|
+
};
|
|
83
|
+
let body;
|
|
84
|
+
if (actionState === "edit") {
|
|
85
|
+
body = /* @__PURE__ */ jsx(
|
|
86
|
+
NoteForm,
|
|
87
|
+
{
|
|
88
|
+
onSubmit: (value) => {
|
|
89
|
+
onEditNote({ id: note.id, content: value });
|
|
90
|
+
setActionState(null);
|
|
91
|
+
actionButtonRef.current?.focus();
|
|
92
|
+
},
|
|
93
|
+
onCancel: handleCancel,
|
|
94
|
+
note,
|
|
95
|
+
labels: {
|
|
96
|
+
submit: _x("Update", "verb"),
|
|
97
|
+
input: sprintf(
|
|
98
|
+
// translators: %1$s: note identifier, %2$s: author name.
|
|
99
|
+
__("Edit note %1$s by %2$s"),
|
|
100
|
+
note.id,
|
|
101
|
+
note.author_name
|
|
102
|
+
)
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
);
|
|
106
|
+
} else if (isResolutionNote) {
|
|
107
|
+
const actionText = note.meta._wp_note_status === "resolved" ? __("Marked as resolved") : __("Reopened");
|
|
108
|
+
const raw = note?.content?.raw;
|
|
109
|
+
const text = raw && typeof raw === "string" && raw.trim() !== "" ? sprintf(
|
|
110
|
+
// translators: %1$s: action label ("Marked as resolved" or "Reopened"); %2$s: note text.
|
|
111
|
+
__("%1$s: %2$s"),
|
|
112
|
+
actionText,
|
|
113
|
+
raw
|
|
114
|
+
) : actionText;
|
|
115
|
+
body = /* @__PURE__ */ jsx(
|
|
116
|
+
RawHTML,
|
|
117
|
+
{
|
|
118
|
+
className: clsx(
|
|
119
|
+
"editor-collab-sidebar-panel__note-content",
|
|
120
|
+
"editor-collab-sidebar-panel__resolution-text"
|
|
121
|
+
),
|
|
122
|
+
children: text
|
|
123
|
+
}
|
|
124
|
+
);
|
|
125
|
+
} else {
|
|
126
|
+
body = /* @__PURE__ */ jsx(RawHTML, { className: "editor-collab-sidebar-panel__note-content", children: note?.content?.rendered });
|
|
127
|
+
}
|
|
128
|
+
const actions = isSelected ? /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
129
|
+
canResolve && onResolve && /* @__PURE__ */ jsx(
|
|
130
|
+
Button,
|
|
131
|
+
{
|
|
132
|
+
label: _x("Resolve", "Mark note as resolved"),
|
|
133
|
+
size: "small",
|
|
134
|
+
icon: published,
|
|
135
|
+
disabled: note.status === "approved",
|
|
136
|
+
accessibleWhenDisabled: note.status === "approved",
|
|
137
|
+
onClick: onResolve
|
|
138
|
+
}
|
|
139
|
+
),
|
|
140
|
+
/* @__PURE__ */ jsx(
|
|
141
|
+
NoteActionsMenu,
|
|
142
|
+
{
|
|
143
|
+
items: availableItems,
|
|
144
|
+
buttonRef: actionButtonRef
|
|
145
|
+
}
|
|
146
|
+
)
|
|
147
|
+
] }) : null;
|
|
148
|
+
return /* @__PURE__ */ jsxs(
|
|
149
|
+
NoteCard,
|
|
150
|
+
{
|
|
151
|
+
note,
|
|
152
|
+
actions,
|
|
153
|
+
role: note.parent !== 0 ? "treeitem" : void 0,
|
|
154
|
+
children: [
|
|
155
|
+
body,
|
|
156
|
+
actionState === "delete" && /* @__PURE__ */ jsx(
|
|
157
|
+
ConfirmDialog,
|
|
158
|
+
{
|
|
159
|
+
isOpen: true,
|
|
160
|
+
onConfirm: () => {
|
|
161
|
+
onDeleteNote(note);
|
|
162
|
+
setActionState(null);
|
|
163
|
+
},
|
|
164
|
+
onCancel: handleCancel,
|
|
165
|
+
confirmButtonText: __("Delete"),
|
|
166
|
+
children: deleteConfirmMessage
|
|
167
|
+
}
|
|
168
|
+
)
|
|
169
|
+
]
|
|
170
|
+
}
|
|
171
|
+
);
|
|
172
|
+
}
|
|
173
|
+
export {
|
|
174
|
+
Note
|
|
175
|
+
};
|
|
176
|
+
//# sourceMappingURL=note.mjs.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../src/components/collab-sidebar/note.js"],
|
|
4
|
+
"sourcesContent": ["/**\n * External dependencies\n */\nimport clsx from 'clsx';\n\n/**\n * WordPress dependencies\n */\nimport { RawHTML, useRef, useState } from '@wordpress/element';\nimport {\n\t__experimentalConfirmDialog as ConfirmDialog,\n\tButton,\n\tprivateApis as componentsPrivateApis,\n} from '@wordpress/components';\nimport { __, _x, sprintf } from '@wordpress/i18n';\nimport { moreVertical, published } from '@wordpress/icons';\n\n/**\n * Internal dependencies\n */\nimport { NoteCard } from './note-card';\nimport { NoteForm } from './note-form';\nimport { unlock } from '../../lock-unlock';\n\nconst { Menu } = unlock( componentsPrivateApis );\n\nfunction NoteActionsMenu( { items, buttonRef } ) {\n\treturn (\n\t\t<Menu placement=\"bottom-end\">\n\t\t\t<Menu.TriggerButton\n\t\t\t\trender={\n\t\t\t\t\t<Button\n\t\t\t\t\t\tref={ buttonRef }\n\t\t\t\t\t\tsize=\"small\"\n\t\t\t\t\t\ticon={ moreVertical }\n\t\t\t\t\t\tlabel={ __( 'Actions' ) }\n\t\t\t\t\t\tdisabled={ ! items.length }\n\t\t\t\t\t\taccessibleWhenDisabled\n\t\t\t\t\t/>\n\t\t\t\t}\n\t\t\t/>\n\t\t\t<Menu.Popover\n\t\t\t\t// The menu popover is rendered in a portal, which causes focus to be\n\t\t\t\t// lost and the note to be collapsed unintentionally. To prevent this,\n\t\t\t\t// the popover should be rendered as an inline.\n\t\t\t\tmodal={ false }\n\t\t\t>\n\t\t\t\t{ items.map( ( item ) => (\n\t\t\t\t\t<Menu.Item key={ item.id } onClick={ item.onClick }>\n\t\t\t\t\t\t<Menu.ItemLabel>{ item.title }</Menu.ItemLabel>\n\t\t\t\t\t</Menu.Item>\n\t\t\t\t) ) }\n\t\t\t</Menu.Popover>\n\t\t</Menu>\n\t);\n}\n\nexport function Note( {\n\tnote,\n\tparentNote,\n\tisSelected,\n\tonEditNote,\n\tonDeleteNote,\n\tonResolve,\n} ) {\n\tconst [ actionState, setActionState ] = useState( null );\n\tconst actionButtonRef = useRef( null );\n\n\tconst canResolve = note.parent === 0;\n\tconst isResolutionNote =\n\t\tnote.type === 'note' &&\n\t\tnote.meta &&\n\t\t( note.meta._wp_note_status === 'resolved' ||\n\t\t\tnote.meta._wp_note_status === 'reopen' );\n\n\tconst menuItems = [\n\t\t{\n\t\t\tid: 'edit',\n\t\t\ttitle: __( 'Edit' ),\n\t\t\tisEligible: ( { status } ) => status !== 'approved',\n\t\t\tonClick: () => setActionState( 'edit' ),\n\t\t},\n\t\t{\n\t\t\tid: 'reopen',\n\t\t\ttitle: _x( 'Reopen', 'Reopen note' ),\n\t\t\tisEligible: ( { status } ) => status === 'approved',\n\t\t\tonClick: () => onEditNote( { id: note.id, status: 'hold' } ),\n\t\t},\n\t\t{\n\t\t\tid: 'delete',\n\t\t\ttitle: __( 'Delete' ),\n\t\t\tisEligible: () => true,\n\t\t\tonClick: () => setActionState( 'delete' ),\n\t\t},\n\t];\n\tconst availableItems =\n\t\tparentNote?.status !== 'approved'\n\t\t\t? menuItems.filter( ( item ) => item.isEligible( note ) )\n\t\t\t: [];\n\n\tconst deleteConfirmMessage =\n\t\tnote.parent === 0\n\t\t\t? __(\n\t\t\t\t\t\"Are you sure you want to delete this note? This will also delete all of this note's replies.\"\n\t\t\t )\n\t\t\t: __( 'Are you sure you want to delete this reply?' );\n\n\tconst handleCancel = () => {\n\t\tsetActionState( null );\n\t\tactionButtonRef.current?.focus();\n\t};\n\n\tlet body;\n\tif ( actionState === 'edit' ) {\n\t\tbody = (\n\t\t\t<NoteForm\n\t\t\t\tonSubmit={ ( value ) => {\n\t\t\t\t\tonEditNote( { id: note.id, content: value } );\n\t\t\t\t\tsetActionState( null );\n\t\t\t\t\tactionButtonRef.current?.focus();\n\t\t\t\t} }\n\t\t\t\tonCancel={ handleCancel }\n\t\t\t\tnote={ note }\n\t\t\t\tlabels={ {\n\t\t\t\t\tsubmit: _x( 'Update', 'verb' ),\n\t\t\t\t\tinput: sprintf(\n\t\t\t\t\t\t// translators: %1$s: note identifier, %2$s: author name.\n\t\t\t\t\t\t__( 'Edit note %1$s by %2$s' ),\n\t\t\t\t\t\tnote.id,\n\t\t\t\t\t\tnote.author_name\n\t\t\t\t\t),\n\t\t\t\t} }\n\t\t\t/>\n\t\t);\n\t} else if ( isResolutionNote ) {\n\t\tconst actionText =\n\t\t\tnote.meta._wp_note_status === 'resolved'\n\t\t\t\t? __( 'Marked as resolved' )\n\t\t\t\t: __( 'Reopened' );\n\t\tconst raw = note?.content?.raw;\n\t\tconst text =\n\t\t\traw && typeof raw === 'string' && raw.trim() !== ''\n\t\t\t\t? sprintf(\n\t\t\t\t\t\t// translators: %1$s: action label (\"Marked as resolved\" or \"Reopened\"); %2$s: note text.\n\t\t\t\t\t\t__( '%1$s: %2$s' ),\n\t\t\t\t\t\tactionText,\n\t\t\t\t\t\traw\n\t\t\t\t )\n\t\t\t\t: actionText;\n\t\tbody = (\n\t\t\t<RawHTML\n\t\t\t\tclassName={ clsx(\n\t\t\t\t\t'editor-collab-sidebar-panel__note-content',\n\t\t\t\t\t'editor-collab-sidebar-panel__resolution-text'\n\t\t\t\t) }\n\t\t\t>\n\t\t\t\t{ text }\n\t\t\t</RawHTML>\n\t\t);\n\t} else {\n\t\tbody = (\n\t\t\t<RawHTML className=\"editor-collab-sidebar-panel__note-content\">\n\t\t\t\t{ note?.content?.rendered }\n\t\t\t</RawHTML>\n\t\t);\n\t}\n\n\tconst actions = isSelected ? (\n\t\t<>\n\t\t\t{ canResolve && onResolve && (\n\t\t\t\t<Button\n\t\t\t\t\tlabel={ _x( 'Resolve', 'Mark note as resolved' ) }\n\t\t\t\t\tsize=\"small\"\n\t\t\t\t\ticon={ published }\n\t\t\t\t\tdisabled={ note.status === 'approved' }\n\t\t\t\t\taccessibleWhenDisabled={ note.status === 'approved' }\n\t\t\t\t\tonClick={ onResolve }\n\t\t\t\t/>\n\t\t\t) }\n\t\t\t<NoteActionsMenu\n\t\t\t\titems={ availableItems }\n\t\t\t\tbuttonRef={ actionButtonRef }\n\t\t\t/>\n\t\t</>\n\t) : null;\n\n\treturn (\n\t\t<NoteCard\n\t\t\tnote={ note }\n\t\t\tactions={ actions }\n\t\t\trole={ note.parent !== 0 ? 'treeitem' : undefined }\n\t\t>\n\t\t\t{ body }\n\t\t\t{ actionState === 'delete' && (\n\t\t\t\t<ConfirmDialog\n\t\t\t\t\tisOpen\n\t\t\t\t\tonConfirm={ () => {\n\t\t\t\t\t\tonDeleteNote( note );\n\t\t\t\t\t\tsetActionState( null );\n\t\t\t\t\t} }\n\t\t\t\t\tonCancel={ handleCancel }\n\t\t\t\t\tconfirmButtonText={ __( 'Delete' ) }\n\t\t\t\t>\n\t\t\t\t\t{ deleteConfirmMessage }\n\t\t\t\t</ConfirmDialog>\n\t\t\t) }\n\t\t</NoteCard>\n\t);\n}\n"],
|
|
5
|
+
"mappings": ";AAGA,OAAO,UAAU;AAKjB,SAAS,SAAS,QAAQ,gBAAgB;AAC1C;AAAA,EACC,+BAA+B;AAAA,EAC/B;AAAA,EACA,eAAe;AAAA,OACT;AACP,SAAS,IAAI,IAAI,eAAe;AAChC,SAAS,cAAc,iBAAiB;AAKxC,SAAS,gBAAgB;AACzB,SAAS,gBAAgB;AACzB,SAAS,cAAc;AAMrB,SA4IA,UAzIG,KAHH;AAJF,IAAM,EAAE,KAAK,IAAI,OAAQ,qBAAsB;AAE/C,SAAS,gBAAiB,EAAE,OAAO,UAAU,GAAI;AAChD,SACC,qBAAC,QAAK,WAAU,cACf;AAAA;AAAA,MAAC,KAAK;AAAA,MAAL;AAAA,QACA,QACC;AAAA,UAAC;AAAA;AAAA,YACA,KAAM;AAAA,YACN,MAAK;AAAA,YACL,MAAO;AAAA,YACP,OAAQ,GAAI,SAAU;AAAA,YACtB,UAAW,CAAE,MAAM;AAAA,YACnB,wBAAsB;AAAA;AAAA,QACvB;AAAA;AAAA,IAEF;AAAA,IACA;AAAA,MAAC,KAAK;AAAA,MAAL;AAAA,QAIA,OAAQ;AAAA,QAEN,gBAAM,IAAK,CAAE,SACd,oBAAC,KAAK,MAAL,EAA0B,SAAU,KAAK,SACzC,8BAAC,KAAK,WAAL,EAAiB,eAAK,OAAO,KADd,KAAK,EAEtB,CACC;AAAA;AAAA,IACH;AAAA,KACD;AAEF;AAEO,SAAS,KAAM;AAAA,EACrB;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAC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