@wordpress/editor 14.10.0 → 14.12.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 +8 -0
- package/README.md +2 -10
- package/build/bindings/post-meta.js +2 -1
- package/build/bindings/post-meta.js.map +1 -1
- package/build/components/collab-sidebar/add-comment.js +119 -0
- package/build/components/collab-sidebar/add-comment.js.map +1 -0
- package/build/components/collab-sidebar/comment-button-toolbar.js +37 -0
- package/build/components/collab-sidebar/comment-button-toolbar.js.map +1 -0
- package/build/components/collab-sidebar/comment-button.js +37 -0
- package/build/components/collab-sidebar/comment-button.js.map +1 -0
- package/build/components/collab-sidebar/comments.js +321 -0
- package/build/components/collab-sidebar/comments.js.map +1 -0
- package/build/components/collab-sidebar/constants.js +8 -0
- package/build/components/collab-sidebar/constants.js.map +1 -0
- package/build/components/collab-sidebar/index.js +274 -0
- package/build/components/collab-sidebar/index.js.map +1 -0
- package/build/components/collab-sidebar/utils.js +16 -0
- package/build/components/collab-sidebar/utils.js.map +1 -0
- package/build/components/commands/index.js +148 -40
- package/build/components/commands/index.js.map +1 -1
- package/build/components/create-template-part-modal/index.js +1 -0
- package/build/components/create-template-part-modal/index.js.map +1 -1
- package/build/components/document-bar/index.js +17 -10
- package/build/components/document-bar/index.js.map +1 -1
- package/build/components/document-tools/index.js +7 -7
- package/build/components/document-tools/index.js.map +1 -1
- package/build/components/editor-interface/index.js +4 -4
- package/build/components/editor-interface/index.js.map +1 -1
- package/build/components/entities-saved-states/index.js +1 -1
- package/build/components/entities-saved-states/index.js.map +1 -1
- package/build/components/global-keyboard-shortcuts/register-shortcuts.js +3 -3
- package/build/components/global-keyboard-shortcuts/register-shortcuts.js.map +1 -1
- package/build/components/global-styles-provider/index.js +25 -3
- package/build/components/global-styles-provider/index.js.map +1 -1
- package/build/components/header/index.js +12 -11
- package/build/components/header/index.js.map +1 -1
- package/build/components/inserter-sidebar/index.js +2 -2
- package/build/components/inserter-sidebar/index.js.map +1 -1
- package/build/components/more-menu/index.js +9 -7
- package/build/components/more-menu/index.js.map +1 -1
- package/build/components/page-attributes/parent.js +5 -5
- package/build/components/page-attributes/parent.js.map +1 -1
- package/build/components/plugin-more-menu-item/index.js +13 -11
- package/build/components/plugin-more-menu-item/index.js.map +1 -1
- package/build/components/plugin-preview-menu-item/index.js +15 -13
- package/build/components/plugin-preview-menu-item/index.js.map +1 -1
- package/build/components/plugin-sidebar/index.js +0 -15
- package/build/components/plugin-sidebar/index.js.map +1 -1
- package/build/components/post-actions/index.js +5 -5
- package/build/components/post-actions/index.js.map +1 -1
- package/build/components/post-author/panel.js +4 -4
- package/build/components/post-author/panel.js.map +1 -1
- package/build/components/post-card-panel/index.js +7 -36
- package/build/components/post-card-panel/index.js.map +1 -1
- package/build/components/post-content-information/index.js +1 -2
- package/build/components/post-content-information/index.js.map +1 -1
- package/build/components/post-featured-image/index.js +26 -7
- package/build/components/post-featured-image/index.js.map +1 -1
- package/build/components/post-last-revision/index.js +1 -1
- package/build/components/post-last-revision/index.js.map +1 -1
- package/build/components/post-schedule/label.js +1 -1
- package/build/components/post-schedule/label.js.map +1 -1
- package/build/components/post-taxonomies/flat-term-selector.js +11 -1
- package/build/components/post-taxonomies/flat-term-selector.js.map +1 -1
- package/build/components/post-taxonomies/hierarchical-term-selector.js +2 -2
- package/build/components/post-taxonomies/hierarchical-term-selector.js.map +1 -1
- package/build/components/post-template/swap-template-button.js +0 -3
- package/build/components/post-template/swap-template-button.js.map +1 -1
- package/build/components/post-transform-panel/index.js +0 -3
- package/build/components/post-transform-panel/index.js.map +1 -1
- package/build/components/post-url/index.js +1 -1
- package/build/components/post-url/index.js.map +1 -1
- package/build/components/post-url/panel.js +3 -3
- package/build/components/post-url/panel.js.map +1 -1
- package/build/components/preferences-modal/index.js +26 -22
- package/build/components/preferences-modal/index.js.map +1 -1
- package/build/components/preview-dropdown/index.js +23 -8
- package/build/components/preview-dropdown/index.js.map +1 -1
- package/build/components/provider/index.js +10 -12
- package/build/components/provider/index.js.map +1 -1
- package/build/components/provider/use-block-editor-settings.js +11 -10
- package/build/components/provider/use-block-editor-settings.js.map +1 -1
- package/build/components/sidebar/header.js +2 -1
- package/build/components/sidebar/header.js.map +1 -1
- package/build/components/sidebar/index.js +3 -3
- package/build/components/sidebar/index.js.map +1 -1
- package/build/components/sidebar/post-summary.js +2 -2
- package/build/components/sidebar/post-summary.js.map +1 -1
- package/build/components/start-page-options/index.js +0 -3
- package/build/components/start-page-options/index.js.map +1 -1
- package/build/components/start-template-options/index.js +0 -3
- package/build/components/start-template-options/index.js.map +1 -1
- package/build/components/time-to-read/index.js +2 -2
- package/build/components/time-to-read/index.js.map +1 -1
- package/build/components/visual-editor/index.js +30 -29
- package/build/components/visual-editor/index.js.map +1 -1
- package/build/components/visual-editor/use-zoom-out-mode-exit.js +52 -0
- package/build/components/visual-editor/use-zoom-out-mode-exit.js.map +1 -0
- package/build/components/zoom-out-toggle/index.js +37 -5
- package/build/components/zoom-out-toggle/index.js.map +1 -1
- package/build/dataviews/actions/duplicate-template-part.js +2 -2
- package/build/dataviews/actions/duplicate-template-part.js.map +1 -1
- package/build/store/actions.js +68 -18
- package/build/store/actions.js.map +1 -1
- package/build/store/constants.js +0 -2
- package/build/store/constants.js.map +1 -1
- package/build/store/index.js +0 -4
- package/build/store/index.js.map +1 -1
- package/build/store/private-actions.js +2 -2
- package/build/store/private-actions.js.map +1 -1
- package/build/store/selectors.js +5 -4
- package/build/store/selectors.js.map +1 -1
- package/build/utils/pageTypeBadge.js +51 -0
- package/build/utils/pageTypeBadge.js.map +1 -0
- package/build/utils/terms.js +2 -2
- package/build/utils/terms.js.map +1 -1
- package/build-module/bindings/post-meta.js +2 -1
- package/build-module/bindings/post-meta.js.map +1 -1
- package/build-module/components/collab-sidebar/add-comment.js +113 -0
- package/build-module/components/collab-sidebar/add-comment.js.map +1 -0
- package/build-module/components/collab-sidebar/comment-button-toolbar.js +30 -0
- package/build-module/components/collab-sidebar/comment-button-toolbar.js.map +1 -0
- package/build-module/components/collab-sidebar/comment-button.js +30 -0
- package/build-module/components/collab-sidebar/comment-button.js.map +1 -0
- package/build-module/components/collab-sidebar/comments.js +314 -0
- package/build-module/components/collab-sidebar/comments.js.map +1 -0
- package/build-module/components/collab-sidebar/constants.js +2 -0
- package/build-module/components/collab-sidebar/constants.js.map +1 -0
- package/build-module/components/collab-sidebar/index.js +266 -0
- package/build-module/components/collab-sidebar/index.js.map +1 -0
- package/build-module/components/collab-sidebar/utils.js +10 -0
- package/build-module/components/collab-sidebar/utils.js.map +1 -0
- package/build-module/components/commands/index.js +151 -44
- package/build-module/components/commands/index.js.map +1 -1
- package/build-module/components/create-template-part-modal/index.js +1 -0
- package/build-module/components/create-template-part-modal/index.js.map +1 -1
- package/build-module/components/document-bar/index.js +19 -12
- package/build-module/components/document-bar/index.js.map +1 -1
- package/build-module/components/document-tools/index.js +8 -8
- package/build-module/components/document-tools/index.js.map +1 -1
- package/build-module/components/editor-interface/index.js +4 -4
- package/build-module/components/editor-interface/index.js.map +1 -1
- package/build-module/components/entities-saved-states/index.js +1 -1
- package/build-module/components/entities-saved-states/index.js.map +1 -1
- package/build-module/components/global-keyboard-shortcuts/register-shortcuts.js +3 -3
- package/build-module/components/global-keyboard-shortcuts/register-shortcuts.js.map +1 -1
- package/build-module/components/global-styles-provider/index.js +25 -3
- package/build-module/components/global-styles-provider/index.js.map +1 -1
- package/build-module/components/header/index.js +12 -11
- package/build-module/components/header/index.js.map +1 -1
- package/build-module/components/inserter-sidebar/index.js +2 -2
- package/build-module/components/inserter-sidebar/index.js.map +1 -1
- package/build-module/components/more-menu/index.js +9 -7
- package/build-module/components/more-menu/index.js.map +1 -1
- package/build-module/components/page-attributes/parent.js +5 -5
- package/build-module/components/page-attributes/parent.js.map +1 -1
- package/build-module/components/plugin-more-menu-item/index.js +12 -10
- package/build-module/components/plugin-more-menu-item/index.js.map +1 -1
- package/build-module/components/plugin-preview-menu-item/index.js +14 -12
- package/build-module/components/plugin-preview-menu-item/index.js.map +1 -1
- package/build-module/components/plugin-sidebar/index.js +0 -15
- package/build-module/components/plugin-sidebar/index.js.map +1 -1
- package/build-module/components/post-actions/index.js +5 -5
- package/build-module/components/post-actions/index.js.map +1 -1
- package/build-module/components/post-author/panel.js +4 -4
- package/build-module/components/post-author/panel.js.map +1 -1
- package/build-module/components/post-card-panel/index.js +8 -36
- package/build-module/components/post-card-panel/index.js.map +1 -1
- package/build-module/components/post-content-information/index.js +1 -2
- package/build-module/components/post-content-information/index.js.map +1 -1
- package/build-module/components/post-featured-image/index.js +26 -7
- package/build-module/components/post-featured-image/index.js.map +1 -1
- package/build-module/components/post-last-revision/index.js +1 -1
- package/build-module/components/post-last-revision/index.js.map +1 -1
- package/build-module/components/post-schedule/label.js +1 -1
- package/build-module/components/post-schedule/label.js.map +1 -1
- package/build-module/components/post-taxonomies/flat-term-selector.js +14 -4
- package/build-module/components/post-taxonomies/flat-term-selector.js.map +1 -1
- package/build-module/components/post-taxonomies/hierarchical-term-selector.js +2 -2
- package/build-module/components/post-taxonomies/hierarchical-term-selector.js.map +1 -1
- package/build-module/components/post-template/swap-template-button.js +0 -3
- package/build-module/components/post-template/swap-template-button.js.map +1 -1
- package/build-module/components/post-transform-panel/index.js +0 -3
- package/build-module/components/post-transform-panel/index.js.map +1 -1
- package/build-module/components/post-url/index.js +1 -1
- package/build-module/components/post-url/index.js.map +1 -1
- package/build-module/components/post-url/panel.js +3 -3
- package/build-module/components/post-url/panel.js.map +1 -1
- package/build-module/components/preferences-modal/index.js +26 -22
- package/build-module/components/preferences-modal/index.js.map +1 -1
- package/build-module/components/preview-dropdown/index.js +24 -9
- package/build-module/components/preview-dropdown/index.js.map +1 -1
- package/build-module/components/provider/index.js +10 -12
- package/build-module/components/provider/index.js.map +1 -1
- package/build-module/components/provider/use-block-editor-settings.js +12 -11
- package/build-module/components/provider/use-block-editor-settings.js.map +1 -1
- package/build-module/components/sidebar/header.js +2 -1
- package/build-module/components/sidebar/header.js.map +1 -1
- package/build-module/components/sidebar/index.js +4 -4
- package/build-module/components/sidebar/index.js.map +1 -1
- package/build-module/components/sidebar/post-summary.js +2 -2
- package/build-module/components/sidebar/post-summary.js.map +1 -1
- package/build-module/components/start-page-options/index.js +0 -3
- package/build-module/components/start-page-options/index.js.map +1 -1
- package/build-module/components/start-template-options/index.js +0 -3
- package/build-module/components/start-template-options/index.js.map +1 -1
- package/build-module/components/time-to-read/index.js +2 -2
- package/build-module/components/time-to-read/index.js.map +1 -1
- package/build-module/components/visual-editor/index.js +31 -30
- package/build-module/components/visual-editor/index.js.map +1 -1
- package/build-module/components/visual-editor/use-zoom-out-mode-exit.js +46 -0
- package/build-module/components/visual-editor/use-zoom-out-mode-exit.js.map +1 -0
- package/build-module/components/zoom-out-toggle/index.js +37 -5
- package/build-module/components/zoom-out-toggle/index.js.map +1 -1
- package/build-module/dataviews/actions/duplicate-template-part.js +3 -3
- package/build-module/dataviews/actions/duplicate-template-part.js.map +1 -1
- package/build-module/store/actions.js +64 -16
- package/build-module/store/actions.js.map +1 -1
- package/build-module/store/constants.js +0 -2
- package/build-module/store/constants.js.map +1 -1
- package/build-module/store/index.js +0 -4
- package/build-module/store/index.js.map +1 -1
- package/build-module/store/private-actions.js +3 -3
- package/build-module/store/private-actions.js.map +1 -1
- package/build-module/store/selectors.js +5 -4
- package/build-module/store/selectors.js.map +1 -1
- package/build-module/utils/pageTypeBadge.js +45 -0
- package/build-module/utils/pageTypeBadge.js.map +1 -0
- package/build-module/utils/terms.js +2 -2
- package/build-module/utils/terms.js.map +1 -1
- package/build-style/style-rtl.css +118 -60
- package/build-style/style.css +118 -60
- package/build-types/bindings/post-meta.d.ts.map +1 -1
- package/build-types/components/collab-sidebar/add-comment.d.ts +15 -0
- package/build-types/components/collab-sidebar/add-comment.d.ts.map +1 -0
- package/build-types/components/collab-sidebar/comment-button-toolbar.d.ts +5 -0
- package/build-types/components/collab-sidebar/comment-button-toolbar.d.ts.map +1 -0
- package/build-types/components/collab-sidebar/comment-button.d.ts +5 -0
- package/build-types/components/collab-sidebar/comment-button.d.ts.map +1 -0
- package/build-types/components/collab-sidebar/comments.d.ts +19 -0
- package/build-types/components/collab-sidebar/comments.d.ts.map +1 -0
- package/build-types/components/collab-sidebar/constants.d.ts +2 -0
- package/build-types/components/collab-sidebar/constants.d.ts.map +1 -0
- package/build-types/components/collab-sidebar/index.d.ts +5 -0
- package/build-types/components/collab-sidebar/index.d.ts.map +1 -0
- package/build-types/components/collab-sidebar/utils.d.ts +8 -0
- package/build-types/components/collab-sidebar/utils.d.ts.map +1 -0
- package/build-types/components/commands/index.d.ts.map +1 -1
- package/build-types/components/create-template-part-modal/index.d.ts.map +1 -1
- package/build-types/components/document-bar/index.d.ts.map +1 -1
- package/build-types/components/document-tools/index.d.ts.map +1 -1
- package/build-types/components/global-styles-provider/index.d.ts.map +1 -1
- package/build-types/components/header/index.d.ts +1 -2
- package/build-types/components/header/index.d.ts.map +1 -1
- package/build-types/components/inserter-sidebar/index.d.ts.map +1 -1
- package/build-types/components/more-menu/index.d.ts.map +1 -1
- package/build-types/components/page-attributes/parent.d.ts.map +1 -1
- package/build-types/components/plugin-more-menu-item/index.d.ts +62 -2
- package/build-types/components/plugin-more-menu-item/index.d.ts.map +1 -1
- package/build-types/components/plugin-preview-menu-item/index.d.ts +41 -2
- package/build-types/components/plugin-preview-menu-item/index.d.ts.map +1 -1
- package/build-types/components/plugin-sidebar/index.d.ts.map +1 -1
- package/build-types/components/post-author/panel.d.ts.map +1 -1
- package/build-types/components/post-card-panel/index.d.ts.map +1 -1
- package/build-types/components/post-taxonomies/flat-term-selector.d.ts.map +1 -1
- package/build-types/components/post-template/hooks.d.ts +2 -2
- package/build-types/components/post-template/swap-template-button.d.ts.map +1 -1
- package/build-types/components/post-transform-panel/index.d.ts.map +1 -1
- package/build-types/components/preferences-modal/index.d.ts.map +1 -1
- package/build-types/components/preview-dropdown/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/sidebar/index.d.ts.map +1 -1
- package/build-types/components/start-page-options/index.d.ts.map +1 -1
- package/build-types/components/start-template-options/index.d.ts.map +1 -1
- package/build-types/components/visual-editor/index.d.ts.map +1 -1
- package/build-types/components/visual-editor/use-zoom-out-mode-exit.d.ts +5 -0
- package/build-types/components/visual-editor/use-zoom-out-mode-exit.d.ts.map +1 -0
- package/build-types/components/zoom-out-toggle/index.d.ts +3 -1
- package/build-types/components/zoom-out-toggle/index.d.ts.map +1 -1
- package/build-types/dataviews/store/reducer.d.ts +5 -2
- package/build-types/dataviews/store/reducer.d.ts.map +1 -1
- package/build-types/lock-unlock.d.ts +2 -2
- package/build-types/store/actions.d.ts +9 -1
- package/build-types/store/actions.d.ts.map +1 -1
- package/build-types/store/constants.d.ts +0 -2
- package/build-types/store/constants.d.ts.map +1 -1
- package/build-types/store/index.d.ts +9 -11
- package/build-types/store/index.d.ts.map +1 -1
- package/build-types/store/reducer.d.ts +24 -4
- package/build-types/store/reducer.d.ts.map +1 -1
- package/build-types/store/selectors.d.ts +3 -3
- package/build-types/store/selectors.d.ts.map +1 -1
- package/build-types/utils/pageTypeBadge.d.ts +5 -0
- package/build-types/utils/pageTypeBadge.d.ts.map +1 -0
- package/build-types/utils/terms.d.ts.map +1 -1
- package/package.json +39 -37
- package/src/bindings/post-meta.js +1 -0
- package/src/components/collab-sidebar/add-comment.js +121 -0
- package/src/components/collab-sidebar/comment-button-toolbar.js +29 -0
- package/src/components/collab-sidebar/comment-button.js +31 -0
- package/src/components/collab-sidebar/comments.js +404 -0
- package/src/components/collab-sidebar/constants.js +1 -0
- package/src/components/collab-sidebar/index.js +298 -0
- package/src/components/collab-sidebar/style.scss +111 -0
- package/src/components/collab-sidebar/utils.js +9 -0
- package/src/components/commands/index.js +390 -268
- package/src/components/create-template-part-modal/index.js +1 -0
- package/src/components/document-bar/index.js +25 -8
- package/src/components/document-bar/style.scss +13 -4
- package/src/components/document-tools/index.js +8 -8
- package/src/components/editor-interface/index.js +4 -4
- package/src/components/entities-saved-states/index.js +2 -2
- package/src/components/global-keyboard-shortcuts/register-shortcuts.js +3 -3
- package/src/components/global-styles-provider/index.js +32 -6
- package/src/components/header/index.js +20 -10
- package/src/components/inserter-sidebar/index.js +3 -6
- package/src/components/more-menu/index.js +12 -7
- package/src/components/page-attributes/parent.js +6 -4
- package/src/components/plugin-more-menu-item/index.js +12 -11
- package/src/components/plugin-post-publish-panel/test/__snapshots__/index.js.snap +1 -1
- package/src/components/plugin-preview-menu-item/index.js +14 -13
- package/src/components/plugin-sidebar/index.js +0 -13
- package/src/components/post-actions/index.js +8 -11
- package/src/components/post-author/panel.js +4 -2
- package/src/components/post-card-panel/index.js +9 -43
- package/src/components/post-card-panel/style.scss +1 -9
- package/src/components/post-content-information/index.js +1 -1
- package/src/components/post-featured-image/index.js +31 -16
- package/src/components/post-featured-image/style.scss +5 -2
- package/src/components/post-last-revision/index.js +1 -1
- package/src/components/post-schedule/label.js +1 -1
- package/src/components/post-sticky/test/index.js +6 -6
- package/src/components/post-taxonomies/flat-term-selector.js +15 -4
- package/src/components/post-taxonomies/hierarchical-term-selector.js +2 -2
- package/src/components/post-template/swap-template-button.js +0 -3
- package/src/components/post-transform-panel/index.js +0 -3
- package/src/components/post-url/index.js +1 -1
- package/src/components/post-url/panel.js +4 -2
- package/src/components/preferences-modal/index.js +26 -19
- package/src/components/preferences-modal/test/index.js +1 -1
- package/src/components/preview-dropdown/index.js +45 -18
- package/src/components/provider/index.js +31 -24
- package/src/components/provider/use-block-editor-settings.js +11 -10
- package/src/components/sidebar/header.js +3 -2
- package/src/components/sidebar/index.js +5 -3
- package/src/components/sidebar/post-summary.js +1 -1
- package/src/components/sidebar/style.scss +1 -3
- package/src/components/start-page-options/index.js +0 -3
- package/src/components/start-template-options/index.js +0 -3
- package/src/components/time-to-read/index.js +3 -3
- package/src/components/visual-editor/index.js +39 -42
- package/src/components/visual-editor/style.scss +11 -0
- package/src/components/visual-editor/use-zoom-out-mode-exit.js +49 -0
- package/src/components/zoom-out-toggle/index.js +39 -5
- package/src/dataviews/actions/duplicate-template-part.tsx +3 -3
- package/src/store/actions.js +113 -34
- package/src/store/constants.ts +0 -2
- package/src/store/index.js +0 -4
- package/src/store/private-actions.js +3 -3
- package/src/store/selectors.js +5 -4
- package/src/style.scss +1 -0
- package/src/utils/pageTypeBadge.js +41 -0
- package/src/utils/terms.js +4 -2
- package/src/utils/test/terms.js +3 -3
- package/tsconfig.tsbuildinfo +1 -1
|
@@ -0,0 +1,298 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* WordPress dependencies
|
|
3
|
+
*/
|
|
4
|
+
import { __ } from '@wordpress/i18n';
|
|
5
|
+
import { useSelect, useDispatch, resolveSelect } from '@wordpress/data';
|
|
6
|
+
import { useState, useMemo } from '@wordpress/element';
|
|
7
|
+
import { comment as commentIcon } from '@wordpress/icons';
|
|
8
|
+
import { addFilter } from '@wordpress/hooks';
|
|
9
|
+
import { store as noticesStore } from '@wordpress/notices';
|
|
10
|
+
import { store as coreStore } from '@wordpress/core-data';
|
|
11
|
+
import { store as blockEditorStore } from '@wordpress/block-editor';
|
|
12
|
+
import { store as interfaceStore } from '@wordpress/interface';
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
* Internal dependencies
|
|
16
|
+
*/
|
|
17
|
+
import PluginSidebar from '../plugin-sidebar';
|
|
18
|
+
import { collabSidebarName } from './constants';
|
|
19
|
+
import { Comments } from './comments';
|
|
20
|
+
import { AddComment } from './add-comment';
|
|
21
|
+
import { store as editorStore } from '../../store';
|
|
22
|
+
import AddCommentButton from './comment-button';
|
|
23
|
+
import AddCommentToolbarButton from './comment-button-toolbar';
|
|
24
|
+
|
|
25
|
+
const isBlockCommentExperimentEnabled =
|
|
26
|
+
window?.__experimentalEnableBlockComment;
|
|
27
|
+
const modifyBlockCommentAttributes = ( settings ) => {
|
|
28
|
+
if ( ! settings.attributes.blockCommentId ) {
|
|
29
|
+
settings.attributes = {
|
|
30
|
+
...settings.attributes,
|
|
31
|
+
blockCommentId: {
|
|
32
|
+
type: 'number',
|
|
33
|
+
},
|
|
34
|
+
};
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
return settings;
|
|
38
|
+
};
|
|
39
|
+
|
|
40
|
+
// Apply the filter to all core blocks
|
|
41
|
+
addFilter(
|
|
42
|
+
'blocks.registerBlockType',
|
|
43
|
+
'block-comment/modify-core-block-attributes',
|
|
44
|
+
modifyBlockCommentAttributes
|
|
45
|
+
);
|
|
46
|
+
|
|
47
|
+
function CollabSidebarContent( { showCommentBoard, setShowCommentBoard } ) {
|
|
48
|
+
const { createNotice } = useDispatch( noticesStore );
|
|
49
|
+
const { saveEntityRecord, deleteEntityRecord } = useDispatch( coreStore );
|
|
50
|
+
const { getEntityRecord } = resolveSelect( coreStore );
|
|
51
|
+
|
|
52
|
+
const { postId, threads } = useSelect( ( select ) => {
|
|
53
|
+
const { getCurrentPostId } = select( editorStore );
|
|
54
|
+
const _postId = getCurrentPostId();
|
|
55
|
+
const data = !! _postId
|
|
56
|
+
? select( coreStore ).getEntityRecords( 'root', 'comment', {
|
|
57
|
+
post: _postId,
|
|
58
|
+
type: 'block_comment',
|
|
59
|
+
status: 'any',
|
|
60
|
+
per_page: 100,
|
|
61
|
+
} )
|
|
62
|
+
: null;
|
|
63
|
+
|
|
64
|
+
return {
|
|
65
|
+
postId: _postId,
|
|
66
|
+
threads: data,
|
|
67
|
+
};
|
|
68
|
+
}, [] );
|
|
69
|
+
|
|
70
|
+
const { getSelectedBlockClientId } = useSelect( blockEditorStore );
|
|
71
|
+
const { updateBlockAttributes } = useDispatch( blockEditorStore );
|
|
72
|
+
|
|
73
|
+
// Process comments to build the tree structure
|
|
74
|
+
const resultComments = useMemo( () => {
|
|
75
|
+
// Create a compare to store the references to all objects by id
|
|
76
|
+
const compare = {};
|
|
77
|
+
const result = [];
|
|
78
|
+
|
|
79
|
+
const filteredComments = ( threads ?? [] ).filter(
|
|
80
|
+
( comment ) => comment.status !== 'trash'
|
|
81
|
+
);
|
|
82
|
+
|
|
83
|
+
// Initialize each object with an empty `reply` array
|
|
84
|
+
filteredComments.forEach( ( item ) => {
|
|
85
|
+
compare[ item.id ] = { ...item, reply: [] };
|
|
86
|
+
} );
|
|
87
|
+
|
|
88
|
+
// Iterate over the data to build the tree structure
|
|
89
|
+
filteredComments.forEach( ( item ) => {
|
|
90
|
+
if ( item.parent === 0 ) {
|
|
91
|
+
// If parent is 0, it's a root item, push it to the result array
|
|
92
|
+
result.push( compare[ item.id ] );
|
|
93
|
+
} else if ( compare[ item.parent ] ) {
|
|
94
|
+
// Otherwise, find its parent and push it to the parent's `reply` array
|
|
95
|
+
compare[ item.parent ].reply.push( compare[ item.id ] );
|
|
96
|
+
}
|
|
97
|
+
} );
|
|
98
|
+
|
|
99
|
+
return result;
|
|
100
|
+
}, [ threads ] );
|
|
101
|
+
|
|
102
|
+
// Function to save the comment.
|
|
103
|
+
const addNewComment = async ( comment, parentCommentId ) => {
|
|
104
|
+
const args = {
|
|
105
|
+
post: postId,
|
|
106
|
+
content: comment,
|
|
107
|
+
comment_type: 'block_comment',
|
|
108
|
+
comment_approved: 0,
|
|
109
|
+
};
|
|
110
|
+
|
|
111
|
+
// Create a new object, conditionally including the parent property
|
|
112
|
+
const updatedArgs = {
|
|
113
|
+
...args,
|
|
114
|
+
...( parentCommentId ? { parent: parentCommentId } : {} ),
|
|
115
|
+
};
|
|
116
|
+
|
|
117
|
+
const savedRecord = await saveEntityRecord(
|
|
118
|
+
'root',
|
|
119
|
+
'comment',
|
|
120
|
+
updatedArgs
|
|
121
|
+
);
|
|
122
|
+
|
|
123
|
+
if ( savedRecord ) {
|
|
124
|
+
// If it's a main comment, update the block attributes with the comment id.
|
|
125
|
+
if ( ! parentCommentId ) {
|
|
126
|
+
updateBlockAttributes( getSelectedBlockClientId(), {
|
|
127
|
+
blockCommentId: savedRecord?.id,
|
|
128
|
+
} );
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
createNotice(
|
|
132
|
+
'snackbar',
|
|
133
|
+
parentCommentId
|
|
134
|
+
? // translators: Reply added successfully
|
|
135
|
+
__( 'Reply added successfully.' )
|
|
136
|
+
: // translators: Comment added successfully
|
|
137
|
+
__( 'Comment added successfully.' ),
|
|
138
|
+
{
|
|
139
|
+
type: 'snackbar',
|
|
140
|
+
isDismissible: true,
|
|
141
|
+
}
|
|
142
|
+
);
|
|
143
|
+
} else {
|
|
144
|
+
onError();
|
|
145
|
+
}
|
|
146
|
+
};
|
|
147
|
+
|
|
148
|
+
const onCommentResolve = async ( commentId ) => {
|
|
149
|
+
const savedRecord = await saveEntityRecord( 'root', 'comment', {
|
|
150
|
+
id: commentId,
|
|
151
|
+
status: 'approved',
|
|
152
|
+
} );
|
|
153
|
+
|
|
154
|
+
if ( savedRecord ) {
|
|
155
|
+
// translators: Comment resolved successfully
|
|
156
|
+
createNotice( 'snackbar', __( 'Comment marked as resolved.' ), {
|
|
157
|
+
type: 'snackbar',
|
|
158
|
+
isDismissible: true,
|
|
159
|
+
} );
|
|
160
|
+
} else {
|
|
161
|
+
onError();
|
|
162
|
+
}
|
|
163
|
+
};
|
|
164
|
+
|
|
165
|
+
const onEditComment = async ( commentId, comment ) => {
|
|
166
|
+
const savedRecord = await saveEntityRecord( 'root', 'comment', {
|
|
167
|
+
id: commentId,
|
|
168
|
+
content: comment,
|
|
169
|
+
} );
|
|
170
|
+
|
|
171
|
+
if ( savedRecord ) {
|
|
172
|
+
createNotice(
|
|
173
|
+
'snackbar',
|
|
174
|
+
// translators: Comment edited successfully
|
|
175
|
+
__( 'Comment edited successfully.' ),
|
|
176
|
+
{
|
|
177
|
+
type: 'snackbar',
|
|
178
|
+
isDismissible: true,
|
|
179
|
+
}
|
|
180
|
+
);
|
|
181
|
+
} else {
|
|
182
|
+
onError();
|
|
183
|
+
}
|
|
184
|
+
};
|
|
185
|
+
|
|
186
|
+
const onError = () => {
|
|
187
|
+
createNotice(
|
|
188
|
+
'error',
|
|
189
|
+
// translators: Error message when comment submission fails
|
|
190
|
+
__(
|
|
191
|
+
'Something went wrong. Please try publishing the post, or you may have already submitted your comment earlier.'
|
|
192
|
+
),
|
|
193
|
+
{
|
|
194
|
+
isDismissible: true,
|
|
195
|
+
}
|
|
196
|
+
);
|
|
197
|
+
};
|
|
198
|
+
|
|
199
|
+
const onCommentDelete = async ( commentId ) => {
|
|
200
|
+
const childComment = await getEntityRecord(
|
|
201
|
+
'root',
|
|
202
|
+
'comment',
|
|
203
|
+
commentId
|
|
204
|
+
);
|
|
205
|
+
await deleteEntityRecord( 'root', 'comment', commentId );
|
|
206
|
+
|
|
207
|
+
if ( childComment && ! childComment.parent ) {
|
|
208
|
+
updateBlockAttributes( getSelectedBlockClientId(), {
|
|
209
|
+
blockCommentId: undefined,
|
|
210
|
+
} );
|
|
211
|
+
}
|
|
212
|
+
|
|
213
|
+
createNotice(
|
|
214
|
+
'snackbar',
|
|
215
|
+
// translators: Comment deleted successfully
|
|
216
|
+
__( 'Comment deleted successfully.' ),
|
|
217
|
+
{
|
|
218
|
+
type: 'snackbar',
|
|
219
|
+
isDismissible: true,
|
|
220
|
+
}
|
|
221
|
+
);
|
|
222
|
+
};
|
|
223
|
+
|
|
224
|
+
return (
|
|
225
|
+
<div className="editor-collab-sidebar-panel">
|
|
226
|
+
<AddComment
|
|
227
|
+
onSubmit={ addNewComment }
|
|
228
|
+
showCommentBoard={ showCommentBoard }
|
|
229
|
+
setShowCommentBoard={ setShowCommentBoard }
|
|
230
|
+
/>
|
|
231
|
+
<Comments
|
|
232
|
+
threads={ resultComments }
|
|
233
|
+
onEditComment={ onEditComment }
|
|
234
|
+
onAddReply={ addNewComment }
|
|
235
|
+
onCommentDelete={ onCommentDelete }
|
|
236
|
+
onCommentResolve={ onCommentResolve }
|
|
237
|
+
/>
|
|
238
|
+
</div>
|
|
239
|
+
);
|
|
240
|
+
}
|
|
241
|
+
|
|
242
|
+
/**
|
|
243
|
+
* Renders the Collab sidebar.
|
|
244
|
+
*/
|
|
245
|
+
export default function CollabSidebar() {
|
|
246
|
+
const [ showCommentBoard, setShowCommentBoard ] = useState( false );
|
|
247
|
+
const { enableComplementaryArea } = useDispatch( interfaceStore );
|
|
248
|
+
|
|
249
|
+
const { postStatus } = useSelect( ( select ) => {
|
|
250
|
+
return {
|
|
251
|
+
postStatus:
|
|
252
|
+
select( editorStore ).getEditedPostAttribute( 'status' ),
|
|
253
|
+
};
|
|
254
|
+
}, [] );
|
|
255
|
+
|
|
256
|
+
const { blockCommentId } = useSelect( ( select ) => {
|
|
257
|
+
const { getBlockAttributes, getSelectedBlockClientId } =
|
|
258
|
+
select( blockEditorStore );
|
|
259
|
+
const _clientId = getSelectedBlockClientId();
|
|
260
|
+
|
|
261
|
+
return {
|
|
262
|
+
blockCommentId: _clientId
|
|
263
|
+
? getBlockAttributes( _clientId )?.blockCommentId
|
|
264
|
+
: null,
|
|
265
|
+
};
|
|
266
|
+
}, [] );
|
|
267
|
+
|
|
268
|
+
const openCollabBoard = () => {
|
|
269
|
+
setShowCommentBoard( true );
|
|
270
|
+
enableComplementaryArea( 'core', 'edit-post/collab-sidebar' );
|
|
271
|
+
};
|
|
272
|
+
|
|
273
|
+
// Check if the experimental flag is enabled.
|
|
274
|
+
if ( ! isBlockCommentExperimentEnabled || postStatus === 'publish' ) {
|
|
275
|
+
return null; // or maybe return some message indicating no threads are available.
|
|
276
|
+
}
|
|
277
|
+
|
|
278
|
+
const AddCommentComponent = blockCommentId
|
|
279
|
+
? AddCommentToolbarButton
|
|
280
|
+
: AddCommentButton;
|
|
281
|
+
|
|
282
|
+
return (
|
|
283
|
+
<>
|
|
284
|
+
<AddCommentComponent onClick={ openCollabBoard } />
|
|
285
|
+
<PluginSidebar
|
|
286
|
+
identifier={ collabSidebarName }
|
|
287
|
+
// translators: Comments sidebar title
|
|
288
|
+
title={ __( 'Comments' ) }
|
|
289
|
+
icon={ commentIcon }
|
|
290
|
+
>
|
|
291
|
+
<CollabSidebarContent
|
|
292
|
+
showCommentBoard={ showCommentBoard }
|
|
293
|
+
setShowCommentBoard={ setShowCommentBoard }
|
|
294
|
+
/>
|
|
295
|
+
</PluginSidebar>
|
|
296
|
+
</>
|
|
297
|
+
);
|
|
298
|
+
}
|
|
@@ -0,0 +1,111 @@
|
|
|
1
|
+
.editor-collab-sidebar-panel {
|
|
2
|
+
padding: $grid-unit-20;
|
|
3
|
+
|
|
4
|
+
&__thread {
|
|
5
|
+
position: relative;
|
|
6
|
+
padding: $grid-unit-20;
|
|
7
|
+
border-radius: $radius-large;
|
|
8
|
+
border: 1px solid $gray-300;
|
|
9
|
+
background-color: $gray-100;
|
|
10
|
+
margin-bottom: $grid-unit-20;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
&__active-thread {
|
|
14
|
+
border: 1.5px solid #3858e9;
|
|
15
|
+
background-color: $white;
|
|
16
|
+
box-shadow: 0 5.5px 7.8px -0.3px rgba(0, 0, 0, 0.102);
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
&__comment-field {
|
|
20
|
+
flex: 1;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
&__child-thread {
|
|
24
|
+
margin-top: 15px;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
&__user-name {
|
|
28
|
+
font-size: 12px;
|
|
29
|
+
font-weight: 400;
|
|
30
|
+
line-height: 16px;
|
|
31
|
+
text-align: left;
|
|
32
|
+
color: $gray-700;
|
|
33
|
+
text-transform: capitalize;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
&__user-time {
|
|
37
|
+
font-size: 12px;
|
|
38
|
+
font-weight: 400;
|
|
39
|
+
line-height: 16px;
|
|
40
|
+
text-align: left;
|
|
41
|
+
color: $gray-700;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
&__user-comment {
|
|
45
|
+
font-size: 13px;
|
|
46
|
+
font-weight: 400;
|
|
47
|
+
line-height: 20px;
|
|
48
|
+
text-align: left;
|
|
49
|
+
color: $gray-900;
|
|
50
|
+
|
|
51
|
+
p {
|
|
52
|
+
margin-bottom: 0;
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
&__user-avatar {
|
|
57
|
+
border-radius: $radius-round;
|
|
58
|
+
flex-shrink: 0;
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
&__thread-overlay {
|
|
62
|
+
background-color: rgba(0, 0, 0, 0.7);
|
|
63
|
+
width: 100%;
|
|
64
|
+
height: 100%;
|
|
65
|
+
text-align: center;
|
|
66
|
+
position: absolute;
|
|
67
|
+
top: 0;
|
|
68
|
+
left: 0;
|
|
69
|
+
z-index: 1;
|
|
70
|
+
padding: 15px;
|
|
71
|
+
border-radius: $radius-large;
|
|
72
|
+
color: $white;
|
|
73
|
+
|
|
74
|
+
p {
|
|
75
|
+
margin-bottom: 15px;
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
button {
|
|
79
|
+
padding: 4px 10px;
|
|
80
|
+
color: $white;
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
&__comment-status {
|
|
85
|
+
margin-left: auto;
|
|
86
|
+
|
|
87
|
+
button {
|
|
88
|
+
&.has-icon:not(.has-text) {
|
|
89
|
+
min-width: 24px;
|
|
90
|
+
padding: 0;
|
|
91
|
+
width: 24px;
|
|
92
|
+
height: 24px;
|
|
93
|
+
flex-shrink: 0;
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
&__comment-dropdown-menu {
|
|
99
|
+
flex-shrink: 0;
|
|
100
|
+
|
|
101
|
+
button {
|
|
102
|
+
&.has-icon {
|
|
103
|
+
min-width: 24px;
|
|
104
|
+
padding: 0;
|
|
105
|
+
width: 24px;
|
|
106
|
+
height: 24px;
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Sanitizes a comment string by removing non-printable ASCII characters.
|
|
3
|
+
*
|
|
4
|
+
* @param {string} str - The comment string to sanitize.
|
|
5
|
+
* @return {string} - The sanitized comment string.
|
|
6
|
+
*/
|
|
7
|
+
export function sanitizeCommentString( str ) {
|
|
8
|
+
return str.trim();
|
|
9
|
+
}
|