@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,266 @@
|
|
|
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
|
+
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
25
|
+
const isBlockCommentExperimentEnabled = window?.__experimentalEnableBlockComment;
|
|
26
|
+
const modifyBlockCommentAttributes = settings => {
|
|
27
|
+
if (!settings.attributes.blockCommentId) {
|
|
28
|
+
settings.attributes = {
|
|
29
|
+
...settings.attributes,
|
|
30
|
+
blockCommentId: {
|
|
31
|
+
type: 'number'
|
|
32
|
+
}
|
|
33
|
+
};
|
|
34
|
+
}
|
|
35
|
+
return settings;
|
|
36
|
+
};
|
|
37
|
+
|
|
38
|
+
// Apply the filter to all core blocks
|
|
39
|
+
addFilter('blocks.registerBlockType', 'block-comment/modify-core-block-attributes', modifyBlockCommentAttributes);
|
|
40
|
+
function CollabSidebarContent({
|
|
41
|
+
showCommentBoard,
|
|
42
|
+
setShowCommentBoard
|
|
43
|
+
}) {
|
|
44
|
+
const {
|
|
45
|
+
createNotice
|
|
46
|
+
} = useDispatch(noticesStore);
|
|
47
|
+
const {
|
|
48
|
+
saveEntityRecord,
|
|
49
|
+
deleteEntityRecord
|
|
50
|
+
} = useDispatch(coreStore);
|
|
51
|
+
const {
|
|
52
|
+
getEntityRecord
|
|
53
|
+
} = resolveSelect(coreStore);
|
|
54
|
+
const {
|
|
55
|
+
postId,
|
|
56
|
+
threads
|
|
57
|
+
} = useSelect(select => {
|
|
58
|
+
const {
|
|
59
|
+
getCurrentPostId
|
|
60
|
+
} = select(editorStore);
|
|
61
|
+
const _postId = getCurrentPostId();
|
|
62
|
+
const data = !!_postId ? select(coreStore).getEntityRecords('root', 'comment', {
|
|
63
|
+
post: _postId,
|
|
64
|
+
type: 'block_comment',
|
|
65
|
+
status: 'any',
|
|
66
|
+
per_page: 100
|
|
67
|
+
}) : null;
|
|
68
|
+
return {
|
|
69
|
+
postId: _postId,
|
|
70
|
+
threads: data
|
|
71
|
+
};
|
|
72
|
+
}, []);
|
|
73
|
+
const {
|
|
74
|
+
getSelectedBlockClientId
|
|
75
|
+
} = useSelect(blockEditorStore);
|
|
76
|
+
const {
|
|
77
|
+
updateBlockAttributes
|
|
78
|
+
} = useDispatch(blockEditorStore);
|
|
79
|
+
|
|
80
|
+
// Process comments to build the tree structure
|
|
81
|
+
const resultComments = useMemo(() => {
|
|
82
|
+
// Create a compare to store the references to all objects by id
|
|
83
|
+
const compare = {};
|
|
84
|
+
const result = [];
|
|
85
|
+
const filteredComments = (threads !== null && threads !== void 0 ? threads : []).filter(comment => comment.status !== 'trash');
|
|
86
|
+
|
|
87
|
+
// Initialize each object with an empty `reply` array
|
|
88
|
+
filteredComments.forEach(item => {
|
|
89
|
+
compare[item.id] = {
|
|
90
|
+
...item,
|
|
91
|
+
reply: []
|
|
92
|
+
};
|
|
93
|
+
});
|
|
94
|
+
|
|
95
|
+
// Iterate over the data to build the tree structure
|
|
96
|
+
filteredComments.forEach(item => {
|
|
97
|
+
if (item.parent === 0) {
|
|
98
|
+
// If parent is 0, it's a root item, push it to the result array
|
|
99
|
+
result.push(compare[item.id]);
|
|
100
|
+
} else if (compare[item.parent]) {
|
|
101
|
+
// Otherwise, find its parent and push it to the parent's `reply` array
|
|
102
|
+
compare[item.parent].reply.push(compare[item.id]);
|
|
103
|
+
}
|
|
104
|
+
});
|
|
105
|
+
return result;
|
|
106
|
+
}, [threads]);
|
|
107
|
+
|
|
108
|
+
// Function to save the comment.
|
|
109
|
+
const addNewComment = async (comment, parentCommentId) => {
|
|
110
|
+
const args = {
|
|
111
|
+
post: postId,
|
|
112
|
+
content: comment,
|
|
113
|
+
comment_type: 'block_comment',
|
|
114
|
+
comment_approved: 0
|
|
115
|
+
};
|
|
116
|
+
|
|
117
|
+
// Create a new object, conditionally including the parent property
|
|
118
|
+
const updatedArgs = {
|
|
119
|
+
...args,
|
|
120
|
+
...(parentCommentId ? {
|
|
121
|
+
parent: parentCommentId
|
|
122
|
+
} : {})
|
|
123
|
+
};
|
|
124
|
+
const savedRecord = await saveEntityRecord('root', 'comment', updatedArgs);
|
|
125
|
+
if (savedRecord) {
|
|
126
|
+
// If it's a main comment, update the block attributes with the comment id.
|
|
127
|
+
if (!parentCommentId) {
|
|
128
|
+
updateBlockAttributes(getSelectedBlockClientId(), {
|
|
129
|
+
blockCommentId: savedRecord?.id
|
|
130
|
+
});
|
|
131
|
+
}
|
|
132
|
+
createNotice('snackbar', parentCommentId ?
|
|
133
|
+
// translators: Reply added successfully
|
|
134
|
+
__('Reply added successfully.') :
|
|
135
|
+
// translators: Comment added successfully
|
|
136
|
+
__('Comment added successfully.'), {
|
|
137
|
+
type: 'snackbar',
|
|
138
|
+
isDismissible: true
|
|
139
|
+
});
|
|
140
|
+
} else {
|
|
141
|
+
onError();
|
|
142
|
+
}
|
|
143
|
+
};
|
|
144
|
+
const onCommentResolve = async commentId => {
|
|
145
|
+
const savedRecord = await saveEntityRecord('root', 'comment', {
|
|
146
|
+
id: commentId,
|
|
147
|
+
status: 'approved'
|
|
148
|
+
});
|
|
149
|
+
if (savedRecord) {
|
|
150
|
+
// translators: Comment resolved successfully
|
|
151
|
+
createNotice('snackbar', __('Comment marked as resolved.'), {
|
|
152
|
+
type: 'snackbar',
|
|
153
|
+
isDismissible: true
|
|
154
|
+
});
|
|
155
|
+
} else {
|
|
156
|
+
onError();
|
|
157
|
+
}
|
|
158
|
+
};
|
|
159
|
+
const onEditComment = async (commentId, comment) => {
|
|
160
|
+
const savedRecord = await saveEntityRecord('root', 'comment', {
|
|
161
|
+
id: commentId,
|
|
162
|
+
content: comment
|
|
163
|
+
});
|
|
164
|
+
if (savedRecord) {
|
|
165
|
+
createNotice('snackbar',
|
|
166
|
+
// translators: Comment edited successfully
|
|
167
|
+
__('Comment edited successfully.'), {
|
|
168
|
+
type: 'snackbar',
|
|
169
|
+
isDismissible: true
|
|
170
|
+
});
|
|
171
|
+
} else {
|
|
172
|
+
onError();
|
|
173
|
+
}
|
|
174
|
+
};
|
|
175
|
+
const onError = () => {
|
|
176
|
+
createNotice('error',
|
|
177
|
+
// translators: Error message when comment submission fails
|
|
178
|
+
__('Something went wrong. Please try publishing the post, or you may have already submitted your comment earlier.'), {
|
|
179
|
+
isDismissible: true
|
|
180
|
+
});
|
|
181
|
+
};
|
|
182
|
+
const onCommentDelete = async commentId => {
|
|
183
|
+
const childComment = await getEntityRecord('root', 'comment', commentId);
|
|
184
|
+
await deleteEntityRecord('root', 'comment', commentId);
|
|
185
|
+
if (childComment && !childComment.parent) {
|
|
186
|
+
updateBlockAttributes(getSelectedBlockClientId(), {
|
|
187
|
+
blockCommentId: undefined
|
|
188
|
+
});
|
|
189
|
+
}
|
|
190
|
+
createNotice('snackbar',
|
|
191
|
+
// translators: Comment deleted successfully
|
|
192
|
+
__('Comment deleted successfully.'), {
|
|
193
|
+
type: 'snackbar',
|
|
194
|
+
isDismissible: true
|
|
195
|
+
});
|
|
196
|
+
};
|
|
197
|
+
return /*#__PURE__*/_jsxs("div", {
|
|
198
|
+
className: "editor-collab-sidebar-panel",
|
|
199
|
+
children: [/*#__PURE__*/_jsx(AddComment, {
|
|
200
|
+
onSubmit: addNewComment,
|
|
201
|
+
showCommentBoard: showCommentBoard,
|
|
202
|
+
setShowCommentBoard: setShowCommentBoard
|
|
203
|
+
}), /*#__PURE__*/_jsx(Comments, {
|
|
204
|
+
threads: resultComments,
|
|
205
|
+
onEditComment: onEditComment,
|
|
206
|
+
onAddReply: addNewComment,
|
|
207
|
+
onCommentDelete: onCommentDelete,
|
|
208
|
+
onCommentResolve: onCommentResolve
|
|
209
|
+
})]
|
|
210
|
+
});
|
|
211
|
+
}
|
|
212
|
+
|
|
213
|
+
/**
|
|
214
|
+
* Renders the Collab sidebar.
|
|
215
|
+
*/
|
|
216
|
+
export default function CollabSidebar() {
|
|
217
|
+
const [showCommentBoard, setShowCommentBoard] = useState(false);
|
|
218
|
+
const {
|
|
219
|
+
enableComplementaryArea
|
|
220
|
+
} = useDispatch(interfaceStore);
|
|
221
|
+
const {
|
|
222
|
+
postStatus
|
|
223
|
+
} = useSelect(select => {
|
|
224
|
+
return {
|
|
225
|
+
postStatus: select(editorStore).getEditedPostAttribute('status')
|
|
226
|
+
};
|
|
227
|
+
}, []);
|
|
228
|
+
const {
|
|
229
|
+
blockCommentId
|
|
230
|
+
} = useSelect(select => {
|
|
231
|
+
const {
|
|
232
|
+
getBlockAttributes,
|
|
233
|
+
getSelectedBlockClientId
|
|
234
|
+
} = select(blockEditorStore);
|
|
235
|
+
const _clientId = getSelectedBlockClientId();
|
|
236
|
+
return {
|
|
237
|
+
blockCommentId: _clientId ? getBlockAttributes(_clientId)?.blockCommentId : null
|
|
238
|
+
};
|
|
239
|
+
}, []);
|
|
240
|
+
const openCollabBoard = () => {
|
|
241
|
+
setShowCommentBoard(true);
|
|
242
|
+
enableComplementaryArea('core', 'edit-post/collab-sidebar');
|
|
243
|
+
};
|
|
244
|
+
|
|
245
|
+
// Check if the experimental flag is enabled.
|
|
246
|
+
if (!isBlockCommentExperimentEnabled || postStatus === 'publish') {
|
|
247
|
+
return null; // or maybe return some message indicating no threads are available.
|
|
248
|
+
}
|
|
249
|
+
const AddCommentComponent = blockCommentId ? AddCommentToolbarButton : AddCommentButton;
|
|
250
|
+
return /*#__PURE__*/_jsxs(_Fragment, {
|
|
251
|
+
children: [/*#__PURE__*/_jsx(AddCommentComponent, {
|
|
252
|
+
onClick: openCollabBoard
|
|
253
|
+
}), /*#__PURE__*/_jsx(PluginSidebar, {
|
|
254
|
+
identifier: collabSidebarName
|
|
255
|
+
// translators: Comments sidebar title
|
|
256
|
+
,
|
|
257
|
+
title: __('Comments'),
|
|
258
|
+
icon: commentIcon,
|
|
259
|
+
children: /*#__PURE__*/_jsx(CollabSidebarContent, {
|
|
260
|
+
showCommentBoard: showCommentBoard,
|
|
261
|
+
setShowCommentBoard: setShowCommentBoard
|
|
262
|
+
})
|
|
263
|
+
})]
|
|
264
|
+
});
|
|
265
|
+
}
|
|
266
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["__","useSelect","useDispatch","resolveSelect","useState","useMemo","comment","commentIcon","addFilter","store","noticesStore","coreStore","blockEditorStore","interfaceStore","PluginSidebar","collabSidebarName","Comments","AddComment","editorStore","AddCommentButton","AddCommentToolbarButton","jsx","_jsx","jsxs","_jsxs","Fragment","_Fragment","isBlockCommentExperimentEnabled","window","__experimentalEnableBlockComment","modifyBlockCommentAttributes","settings","attributes","blockCommentId","type","CollabSidebarContent","showCommentBoard","setShowCommentBoard","createNotice","saveEntityRecord","deleteEntityRecord","getEntityRecord","postId","threads","select","getCurrentPostId","_postId","data","getEntityRecords","post","status","per_page","getSelectedBlockClientId","updateBlockAttributes","resultComments","compare","result","filteredComments","filter","forEach","item","id","reply","parent","push","addNewComment","parentCommentId","args","content","comment_type","comment_approved","updatedArgs","savedRecord","isDismissible","onError","onCommentResolve","commentId","onEditComment","onCommentDelete","childComment","undefined","className","children","onSubmit","onAddReply","CollabSidebar","enableComplementaryArea","postStatus","getEditedPostAttribute","getBlockAttributes","_clientId","openCollabBoard","AddCommentComponent","onClick","identifier","title","icon"],"sources":["@wordpress/editor/src/components/collab-sidebar/index.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { __ } from '@wordpress/i18n';\nimport { useSelect, useDispatch, resolveSelect } from '@wordpress/data';\nimport { useState, useMemo } from '@wordpress/element';\nimport { comment as commentIcon } from '@wordpress/icons';\nimport { addFilter } from '@wordpress/hooks';\nimport { store as noticesStore } from '@wordpress/notices';\nimport { store as coreStore } from '@wordpress/core-data';\nimport { store as blockEditorStore } from '@wordpress/block-editor';\nimport { store as interfaceStore } from '@wordpress/interface';\n\n/**\n * Internal dependencies\n */\nimport PluginSidebar from '../plugin-sidebar';\nimport { collabSidebarName } from './constants';\nimport { Comments } from './comments';\nimport { AddComment } from './add-comment';\nimport { store as editorStore } from '../../store';\nimport AddCommentButton from './comment-button';\nimport AddCommentToolbarButton from './comment-button-toolbar';\n\nconst isBlockCommentExperimentEnabled =\n\twindow?.__experimentalEnableBlockComment;\nconst modifyBlockCommentAttributes = ( settings ) => {\n\tif ( ! settings.attributes.blockCommentId ) {\n\t\tsettings.attributes = {\n\t\t\t...settings.attributes,\n\t\t\tblockCommentId: {\n\t\t\t\ttype: 'number',\n\t\t\t},\n\t\t};\n\t}\n\n\treturn settings;\n};\n\n// Apply the filter to all core blocks\naddFilter(\n\t'blocks.registerBlockType',\n\t'block-comment/modify-core-block-attributes',\n\tmodifyBlockCommentAttributes\n);\n\nfunction CollabSidebarContent( { showCommentBoard, setShowCommentBoard } ) {\n\tconst { createNotice } = useDispatch( noticesStore );\n\tconst { saveEntityRecord, deleteEntityRecord } = useDispatch( coreStore );\n\tconst { getEntityRecord } = resolveSelect( coreStore );\n\n\tconst { postId, threads } = useSelect( ( select ) => {\n\t\tconst { getCurrentPostId } = select( editorStore );\n\t\tconst _postId = getCurrentPostId();\n\t\tconst data = !! _postId\n\t\t\t? select( coreStore ).getEntityRecords( 'root', 'comment', {\n\t\t\t\t\tpost: _postId,\n\t\t\t\t\ttype: 'block_comment',\n\t\t\t\t\tstatus: 'any',\n\t\t\t\t\tper_page: 100,\n\t\t\t } )\n\t\t\t: null;\n\n\t\treturn {\n\t\t\tpostId: _postId,\n\t\t\tthreads: data,\n\t\t};\n\t}, [] );\n\n\tconst { getSelectedBlockClientId } = useSelect( blockEditorStore );\n\tconst { updateBlockAttributes } = useDispatch( blockEditorStore );\n\n\t// Process comments to build the tree structure\n\tconst resultComments = useMemo( () => {\n\t\t// Create a compare to store the references to all objects by id\n\t\tconst compare = {};\n\t\tconst result = [];\n\n\t\tconst filteredComments = ( threads ?? [] ).filter(\n\t\t\t( comment ) => comment.status !== 'trash'\n\t\t);\n\n\t\t// Initialize each object with an empty `reply` array\n\t\tfilteredComments.forEach( ( item ) => {\n\t\t\tcompare[ item.id ] = { ...item, reply: [] };\n\t\t} );\n\n\t\t// Iterate over the data to build the tree structure\n\t\tfilteredComments.forEach( ( item ) => {\n\t\t\tif ( item.parent === 0 ) {\n\t\t\t\t// If parent is 0, it's a root item, push it to the result array\n\t\t\t\tresult.push( compare[ item.id ] );\n\t\t\t} else if ( compare[ item.parent ] ) {\n\t\t\t\t// Otherwise, find its parent and push it to the parent's `reply` array\n\t\t\t\tcompare[ item.parent ].reply.push( compare[ item.id ] );\n\t\t\t}\n\t\t} );\n\n\t\treturn result;\n\t}, [ threads ] );\n\n\t// Function to save the comment.\n\tconst addNewComment = async ( comment, parentCommentId ) => {\n\t\tconst args = {\n\t\t\tpost: postId,\n\t\t\tcontent: comment,\n\t\t\tcomment_type: 'block_comment',\n\t\t\tcomment_approved: 0,\n\t\t};\n\n\t\t// Create a new object, conditionally including the parent property\n\t\tconst updatedArgs = {\n\t\t\t...args,\n\t\t\t...( parentCommentId ? { parent: parentCommentId } : {} ),\n\t\t};\n\n\t\tconst savedRecord = await saveEntityRecord(\n\t\t\t'root',\n\t\t\t'comment',\n\t\t\tupdatedArgs\n\t\t);\n\n\t\tif ( savedRecord ) {\n\t\t\t// If it's a main comment, update the block attributes with the comment id.\n\t\t\tif ( ! parentCommentId ) {\n\t\t\t\tupdateBlockAttributes( getSelectedBlockClientId(), {\n\t\t\t\t\tblockCommentId: savedRecord?.id,\n\t\t\t\t} );\n\t\t\t}\n\n\t\t\tcreateNotice(\n\t\t\t\t'snackbar',\n\t\t\t\tparentCommentId\n\t\t\t\t\t? // translators: Reply added successfully\n\t\t\t\t\t __( 'Reply added successfully.' )\n\t\t\t\t\t: // translators: Comment added successfully\n\t\t\t\t\t __( 'Comment added successfully.' ),\n\t\t\t\t{\n\t\t\t\t\ttype: 'snackbar',\n\t\t\t\t\tisDismissible: true,\n\t\t\t\t}\n\t\t\t);\n\t\t} else {\n\t\t\tonError();\n\t\t}\n\t};\n\n\tconst onCommentResolve = async ( commentId ) => {\n\t\tconst savedRecord = await saveEntityRecord( 'root', 'comment', {\n\t\t\tid: commentId,\n\t\t\tstatus: 'approved',\n\t\t} );\n\n\t\tif ( savedRecord ) {\n\t\t\t// translators: Comment resolved successfully\n\t\t\tcreateNotice( 'snackbar', __( 'Comment marked as resolved.' ), {\n\t\t\t\ttype: 'snackbar',\n\t\t\t\tisDismissible: true,\n\t\t\t} );\n\t\t} else {\n\t\t\tonError();\n\t\t}\n\t};\n\n\tconst onEditComment = async ( commentId, comment ) => {\n\t\tconst savedRecord = await saveEntityRecord( 'root', 'comment', {\n\t\t\tid: commentId,\n\t\t\tcontent: comment,\n\t\t} );\n\n\t\tif ( savedRecord ) {\n\t\t\tcreateNotice(\n\t\t\t\t'snackbar',\n\t\t\t\t// translators: Comment edited successfully\n\t\t\t\t__( 'Comment edited successfully.' ),\n\t\t\t\t{\n\t\t\t\t\ttype: 'snackbar',\n\t\t\t\t\tisDismissible: true,\n\t\t\t\t}\n\t\t\t);\n\t\t} else {\n\t\t\tonError();\n\t\t}\n\t};\n\n\tconst onError = () => {\n\t\tcreateNotice(\n\t\t\t'error',\n\t\t\t// translators: Error message when comment submission fails\n\t\t\t__(\n\t\t\t\t'Something went wrong. Please try publishing the post, or you may have already submitted your comment earlier.'\n\t\t\t),\n\t\t\t{\n\t\t\t\tisDismissible: true,\n\t\t\t}\n\t\t);\n\t};\n\n\tconst onCommentDelete = async ( commentId ) => {\n\t\tconst childComment = await getEntityRecord(\n\t\t\t'root',\n\t\t\t'comment',\n\t\t\tcommentId\n\t\t);\n\t\tawait deleteEntityRecord( 'root', 'comment', commentId );\n\n\t\tif ( childComment && ! childComment.parent ) {\n\t\t\tupdateBlockAttributes( getSelectedBlockClientId(), {\n\t\t\t\tblockCommentId: undefined,\n\t\t\t} );\n\t\t}\n\n\t\tcreateNotice(\n\t\t\t'snackbar',\n\t\t\t// translators: Comment deleted successfully\n\t\t\t__( 'Comment deleted successfully.' ),\n\t\t\t{\n\t\t\t\ttype: 'snackbar',\n\t\t\t\tisDismissible: true,\n\t\t\t}\n\t\t);\n\t};\n\n\treturn (\n\t\t<div className=\"editor-collab-sidebar-panel\">\n\t\t\t<AddComment\n\t\t\t\tonSubmit={ addNewComment }\n\t\t\t\tshowCommentBoard={ showCommentBoard }\n\t\t\t\tsetShowCommentBoard={ setShowCommentBoard }\n\t\t\t/>\n\t\t\t<Comments\n\t\t\t\tthreads={ resultComments }\n\t\t\t\tonEditComment={ onEditComment }\n\t\t\t\tonAddReply={ addNewComment }\n\t\t\t\tonCommentDelete={ onCommentDelete }\n\t\t\t\tonCommentResolve={ onCommentResolve }\n\t\t\t/>\n\t\t</div>\n\t);\n}\n\n/**\n * Renders the Collab sidebar.\n */\nexport default function CollabSidebar() {\n\tconst [ showCommentBoard, setShowCommentBoard ] = useState( false );\n\tconst { enableComplementaryArea } = useDispatch( interfaceStore );\n\n\tconst { postStatus } = useSelect( ( select ) => {\n\t\treturn {\n\t\t\tpostStatus:\n\t\t\t\tselect( editorStore ).getEditedPostAttribute( 'status' ),\n\t\t};\n\t}, [] );\n\n\tconst { blockCommentId } = useSelect( ( select ) => {\n\t\tconst { getBlockAttributes, getSelectedBlockClientId } =\n\t\t\tselect( blockEditorStore );\n\t\tconst _clientId = getSelectedBlockClientId();\n\n\t\treturn {\n\t\t\tblockCommentId: _clientId\n\t\t\t\t? getBlockAttributes( _clientId )?.blockCommentId\n\t\t\t\t: null,\n\t\t};\n\t}, [] );\n\n\tconst openCollabBoard = () => {\n\t\tsetShowCommentBoard( true );\n\t\tenableComplementaryArea( 'core', 'edit-post/collab-sidebar' );\n\t};\n\n\t// Check if the experimental flag is enabled.\n\tif ( ! isBlockCommentExperimentEnabled || postStatus === 'publish' ) {\n\t\treturn null; // or maybe return some message indicating no threads are available.\n\t}\n\n\tconst AddCommentComponent = blockCommentId\n\t\t? AddCommentToolbarButton\n\t\t: AddCommentButton;\n\n\treturn (\n\t\t<>\n\t\t\t<AddCommentComponent onClick={ openCollabBoard } />\n\t\t\t<PluginSidebar\n\t\t\t\tidentifier={ collabSidebarName }\n\t\t\t\t// translators: Comments sidebar title\n\t\t\t\ttitle={ __( 'Comments' ) }\n\t\t\t\ticon={ commentIcon }\n\t\t\t>\n\t\t\t\t<CollabSidebarContent\n\t\t\t\t\tshowCommentBoard={ showCommentBoard }\n\t\t\t\t\tsetShowCommentBoard={ setShowCommentBoard }\n\t\t\t\t/>\n\t\t\t</PluginSidebar>\n\t\t</>\n\t);\n}\n"],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CAAC;EAEP,MAAM;IAAEvD;EAAe,CAAC,GAAGhC,SAAS,CAAI2C,MAAM,IAAM;IACnD,MAAM;MAAE6C,kBAAkB;MAAErC;IAAyB,CAAC,GACrDR,MAAM,CAAEhC,gBAAiB,CAAC;IAC3B,MAAM8E,SAAS,GAAGtC,wBAAwB,CAAC,CAAC;IAE5C,OAAO;MACNnB,cAAc,EAAEyD,SAAS,GACtBD,kBAAkB,CAAEC,SAAU,CAAC,EAAEzD,cAAc,GAC/C;IACJ,CAAC;EACF,CAAC,EAAE,EAAG,CAAC;EAEP,MAAM0D,eAAe,GAAGA,CAAA,KAAM;IAC7BtD,mBAAmB,CAAE,IAAK,CAAC;IAC3BiD,uBAAuB,CAAE,MAAM,EAAE,0BAA2B,CAAC;EAC9D,CAAC;;EAED;EACA,IAAK,CAAE3D,+BAA+B,IAAI4D,UAAU,KAAK,SAAS,EAAG;IACpE,OAAO,IAAI,CAAC,CAAC;EACd;EAEA,MAAMK,mBAAmB,GAAG3D,cAAc,GACvCb,uBAAuB,GACvBD,gBAAgB;EAEnB,oBACCK,KAAA,CAAAE,SAAA;IAAAwD,QAAA,gBACC5D,IAAA,CAACsE,mBAAmB;MAACC,OAAO,EAAGF;IAAiB,CAAE,CAAC,eACnDrE,IAAA,CAACR,aAAa;MACbgF,UAAU,EAAG/E;MACb;MAAA;MACAgF,KAAK,EAAG/F,EAAE,CAAE,UAAW,CAAG;MAC1BgG,IAAI,EAAGzF,WAAa;MAAA2E,QAAA,eAEpB5D,IAAA,CAACa,oBAAoB;QACpBC,gBAAgB,EAAGA,gBAAkB;QACrCC,mBAAmB,EAAGA;MAAqB,CAC3C;IAAC,CACY,CAAC;EAAA,CACf,CAAC;AAEL","ignoreList":[]}
|
|
@@ -0,0 +1,10 @@
|
|
|
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
|
+
}
|
|
10
|
+
//# sourceMappingURL=utils.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["sanitizeCommentString","str","trim"],"sources":["@wordpress/editor/src/components/collab-sidebar/utils.js"],"sourcesContent":["/**\n * Sanitizes a comment string by removing non-printable ASCII characters.\n *\n * @param {string} str - The comment string to sanitize.\n * @return {string} - The sanitized comment string.\n */\nexport function sanitizeCommentString( str ) {\n\treturn str.trim();\n}\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,SAASA,qBAAqBA,CAAEC,GAAG,EAAG;EAC5C,OAAOA,GAAG,CAACC,IAAI,CAAC,CAAC;AAClB","ignoreList":[]}
|
|
@@ -2,29 +2,31 @@
|
|
|
2
2
|
* WordPress dependencies
|
|
3
3
|
*/
|
|
4
4
|
import { useSelect, useDispatch } from '@wordpress/data';
|
|
5
|
-
import { __, isRTL } from '@wordpress/i18n';
|
|
6
|
-
import { blockDefault, code, drawerLeft, drawerRight, edit, formatListBullets, listView, external, keyboard, symbol } from '@wordpress/icons';
|
|
5
|
+
import { __, isRTL, sprintf } from '@wordpress/i18n';
|
|
6
|
+
import { blockDefault, code, drawerLeft, drawerRight, edit, formatListBullets, listView, external, keyboard, symbol, page, layout, rotateRight, rotateLeft } from '@wordpress/icons';
|
|
7
7
|
import { useCommandLoader } from '@wordpress/commands';
|
|
8
8
|
import { store as preferencesStore } from '@wordpress/preferences';
|
|
9
9
|
import { store as noticesStore } from '@wordpress/notices';
|
|
10
10
|
import { store as blockEditorStore } from '@wordpress/block-editor';
|
|
11
|
-
import { store as coreStore } from '@wordpress/core-data';
|
|
11
|
+
import { store as coreStore, useEntityRecord } from '@wordpress/core-data';
|
|
12
12
|
import { store as interfaceStore } from '@wordpress/interface';
|
|
13
|
+
import { decodeEntities } from '@wordpress/html-entities';
|
|
13
14
|
|
|
14
15
|
/**
|
|
15
16
|
* Internal dependencies
|
|
16
17
|
*/
|
|
18
|
+
import { unlock } from '../../lock-unlock';
|
|
17
19
|
import { store as editorStore } from '../../store';
|
|
18
|
-
import { PATTERN_POST_TYPE } from '../../store/constants';
|
|
20
|
+
import { PATTERN_POST_TYPE, TEMPLATE_PART_POST_TYPE, TEMPLATE_POST_TYPE } from '../../store/constants';
|
|
19
21
|
import { modalName as patternRenameModalName } from '../pattern-rename-modal';
|
|
20
22
|
import { modalName as patternDuplicateModalName } from '../pattern-duplicate-modal';
|
|
21
|
-
|
|
23
|
+
import isTemplateRevertable from '../../store/utils/is-template-revertable';
|
|
24
|
+
const getEditorCommandLoader = () => function useEditorCommandLoader() {
|
|
22
25
|
const {
|
|
23
26
|
editorMode,
|
|
24
27
|
isListViewOpen,
|
|
25
28
|
showBlockBreadcrumbs,
|
|
26
29
|
isDistractionFree,
|
|
27
|
-
isTopToolbar,
|
|
28
30
|
isFocusMode,
|
|
29
31
|
isPreviewMode,
|
|
30
32
|
isViewable,
|
|
@@ -53,8 +55,7 @@ function useEditorCommandLoader() {
|
|
|
53
55
|
showBlockBreadcrumbs: get('core', 'showBlockBreadcrumbs'),
|
|
54
56
|
isDistractionFree: get('core', 'distractionFree'),
|
|
55
57
|
isFocusMode: get('core', 'focusMode'),
|
|
56
|
-
|
|
57
|
-
isPreviewMode: getSettings().__unstableIsPreviewMode,
|
|
58
|
+
isPreviewMode: getSettings().isPreviewMode,
|
|
58
59
|
isViewable: (_getPostType$viewable = getPostType(getCurrentPostType())?.viewable) !== null && _getPostType$viewable !== void 0 ? _getPostType$viewable : false,
|
|
59
60
|
isCodeEditingEnabled: getEditorSettings().codeEditingEnabled,
|
|
60
61
|
isRichEditingEnabled: getEditorSettings().richEditingEnabled,
|
|
@@ -74,7 +75,9 @@ function useEditorCommandLoader() {
|
|
|
74
75
|
__unstableSaveForPreview,
|
|
75
76
|
setIsListViewOpened,
|
|
76
77
|
switchEditorMode,
|
|
77
|
-
toggleDistractionFree
|
|
78
|
+
toggleDistractionFree,
|
|
79
|
+
toggleSpotlightMode,
|
|
80
|
+
toggleTopToolbar
|
|
78
81
|
} = useDispatch(editorStore);
|
|
79
82
|
const {
|
|
80
83
|
openModal,
|
|
@@ -105,7 +108,7 @@ function useEditorCommandLoader() {
|
|
|
105
108
|
});
|
|
106
109
|
commands.push({
|
|
107
110
|
name: 'core/toggle-distraction-free',
|
|
108
|
-
label: isDistractionFree ? __('Exit Distraction
|
|
111
|
+
label: isDistractionFree ? __('Exit Distraction free') : __('Enter Distraction free'),
|
|
109
112
|
callback: ({
|
|
110
113
|
close
|
|
111
114
|
}) => {
|
|
@@ -125,22 +128,12 @@ function useEditorCommandLoader() {
|
|
|
125
128
|
});
|
|
126
129
|
commands.push({
|
|
127
130
|
name: 'core/toggle-spotlight-mode',
|
|
128
|
-
label: __('
|
|
131
|
+
label: isFocusMode ? __('Exit Spotlight mode') : __('Enter Spotlight mode'),
|
|
129
132
|
callback: ({
|
|
130
133
|
close
|
|
131
134
|
}) => {
|
|
132
|
-
|
|
135
|
+
toggleSpotlightMode();
|
|
133
136
|
close();
|
|
134
|
-
createInfoNotice(isFocusMode ? __('Spotlight off.') : __('Spotlight on.'), {
|
|
135
|
-
id: 'core/editor/toggle-spotlight-mode/notice',
|
|
136
|
-
type: 'snackbar',
|
|
137
|
-
actions: [{
|
|
138
|
-
label: __('Undo'),
|
|
139
|
-
onClick: () => {
|
|
140
|
-
toggle('core', 'focusMode');
|
|
141
|
-
}
|
|
142
|
-
}]
|
|
143
|
-
});
|
|
144
137
|
}
|
|
145
138
|
});
|
|
146
139
|
commands.push({
|
|
@@ -160,25 +153,12 @@ function useEditorCommandLoader() {
|
|
|
160
153
|
});
|
|
161
154
|
commands.push({
|
|
162
155
|
name: 'core/toggle-top-toolbar',
|
|
163
|
-
label: __('
|
|
156
|
+
label: __('Top toolbar'),
|
|
164
157
|
callback: ({
|
|
165
158
|
close
|
|
166
159
|
}) => {
|
|
167
|
-
|
|
168
|
-
if (isDistractionFree) {
|
|
169
|
-
toggleDistractionFree();
|
|
170
|
-
}
|
|
160
|
+
toggleTopToolbar();
|
|
171
161
|
close();
|
|
172
|
-
createInfoNotice(isTopToolbar ? __('Top toolbar off.') : __('Top toolbar on.'), {
|
|
173
|
-
id: 'core/editor/toggle-top-toolbar/notice',
|
|
174
|
-
type: 'snackbar',
|
|
175
|
-
actions: [{
|
|
176
|
-
label: __('Undo'),
|
|
177
|
-
onClick: () => {
|
|
178
|
-
toggle('core', 'fixedToolbar');
|
|
179
|
-
}
|
|
180
|
-
}]
|
|
181
|
-
});
|
|
182
162
|
}
|
|
183
163
|
});
|
|
184
164
|
if (allowSwitchEditorMode) {
|
|
@@ -210,7 +190,7 @@ function useEditorCommandLoader() {
|
|
|
210
190
|
});
|
|
211
191
|
commands.push({
|
|
212
192
|
name: 'core/open-settings-sidebar',
|
|
213
|
-
label: __('
|
|
193
|
+
label: __('Show or hide the Settings panel.'),
|
|
214
194
|
icon: isRTL() ? drawerLeft : drawerRight,
|
|
215
195
|
callback: ({
|
|
216
196
|
close
|
|
@@ -226,7 +206,7 @@ function useEditorCommandLoader() {
|
|
|
226
206
|
});
|
|
227
207
|
commands.push({
|
|
228
208
|
name: 'core/open-block-inspector',
|
|
229
|
-
label: __('
|
|
209
|
+
label: __('Show or hide the Block settings panel'),
|
|
230
210
|
icon: blockDefault,
|
|
231
211
|
callback: ({
|
|
232
212
|
close
|
|
@@ -274,8 +254,8 @@ function useEditorCommandLoader() {
|
|
|
274
254
|
commands,
|
|
275
255
|
isLoading: false
|
|
276
256
|
};
|
|
277
|
-
}
|
|
278
|
-
function useEditedEntityContextualCommands() {
|
|
257
|
+
};
|
|
258
|
+
const getEditedEntityContextualCommands = () => function useEditedEntityContextualCommands() {
|
|
279
259
|
const {
|
|
280
260
|
postType
|
|
281
261
|
} = useSelect(select => {
|
|
@@ -318,16 +298,143 @@ function useEditedEntityContextualCommands() {
|
|
|
318
298
|
isLoading: false,
|
|
319
299
|
commands
|
|
320
300
|
};
|
|
321
|
-
}
|
|
301
|
+
};
|
|
302
|
+
const getPageContentFocusCommands = () => function usePageContentFocusCommands() {
|
|
303
|
+
const {
|
|
304
|
+
onNavigateToEntityRecord,
|
|
305
|
+
goBack,
|
|
306
|
+
templateId,
|
|
307
|
+
isPreviewMode
|
|
308
|
+
} = useSelect(select => {
|
|
309
|
+
const {
|
|
310
|
+
getRenderingMode,
|
|
311
|
+
getEditorSettings: _getEditorSettings,
|
|
312
|
+
getCurrentTemplateId
|
|
313
|
+
} = unlock(select(editorStore));
|
|
314
|
+
const editorSettings = _getEditorSettings();
|
|
315
|
+
return {
|
|
316
|
+
isTemplateHidden: getRenderingMode() === 'post-only',
|
|
317
|
+
onNavigateToEntityRecord: editorSettings.onNavigateToEntityRecord,
|
|
318
|
+
getEditorSettings: _getEditorSettings,
|
|
319
|
+
goBack: editorSettings.onNavigateToPreviousEntityRecord,
|
|
320
|
+
templateId: getCurrentTemplateId(),
|
|
321
|
+
isPreviewMode: editorSettings.isPreviewMode
|
|
322
|
+
};
|
|
323
|
+
}, []);
|
|
324
|
+
const {
|
|
325
|
+
editedRecord: template,
|
|
326
|
+
hasResolved
|
|
327
|
+
} = useEntityRecord('postType', 'wp_template', templateId);
|
|
328
|
+
if (isPreviewMode) {
|
|
329
|
+
return {
|
|
330
|
+
isLoading: false,
|
|
331
|
+
commands: []
|
|
332
|
+
};
|
|
333
|
+
}
|
|
334
|
+
const commands = [];
|
|
335
|
+
if (templateId && hasResolved) {
|
|
336
|
+
commands.push({
|
|
337
|
+
name: 'core/switch-to-template-focus',
|
|
338
|
+
label: sprintf(/* translators: %s: template title */
|
|
339
|
+
__('Edit template: %s'), decodeEntities(template.title)),
|
|
340
|
+
icon: layout,
|
|
341
|
+
callback: ({
|
|
342
|
+
close
|
|
343
|
+
}) => {
|
|
344
|
+
onNavigateToEntityRecord({
|
|
345
|
+
postId: templateId,
|
|
346
|
+
postType: 'wp_template'
|
|
347
|
+
});
|
|
348
|
+
close();
|
|
349
|
+
}
|
|
350
|
+
});
|
|
351
|
+
}
|
|
352
|
+
if (!!goBack) {
|
|
353
|
+
commands.push({
|
|
354
|
+
name: 'core/switch-to-previous-entity',
|
|
355
|
+
label: __('Go back'),
|
|
356
|
+
icon: page,
|
|
357
|
+
callback: ({
|
|
358
|
+
close
|
|
359
|
+
}) => {
|
|
360
|
+
goBack();
|
|
361
|
+
close();
|
|
362
|
+
}
|
|
363
|
+
});
|
|
364
|
+
}
|
|
365
|
+
return {
|
|
366
|
+
isLoading: false,
|
|
367
|
+
commands
|
|
368
|
+
};
|
|
369
|
+
};
|
|
370
|
+
const getManipulateDocumentCommands = () => function useManipulateDocumentCommands() {
|
|
371
|
+
const {
|
|
372
|
+
postType,
|
|
373
|
+
postId
|
|
374
|
+
} = useSelect(select => {
|
|
375
|
+
const {
|
|
376
|
+
getCurrentPostId,
|
|
377
|
+
getCurrentPostType
|
|
378
|
+
} = select(editorStore);
|
|
379
|
+
return {
|
|
380
|
+
postType: getCurrentPostType(),
|
|
381
|
+
postId: getCurrentPostId()
|
|
382
|
+
};
|
|
383
|
+
}, []);
|
|
384
|
+
const {
|
|
385
|
+
editedRecord: template,
|
|
386
|
+
hasResolved
|
|
387
|
+
} = useEntityRecord('postType', postType, postId);
|
|
388
|
+
// eslint-disable-next-line @wordpress/no-unused-vars-before-return
|
|
389
|
+
const {
|
|
390
|
+
revertTemplate
|
|
391
|
+
} = unlock(useDispatch(editorStore));
|
|
392
|
+
if (!hasResolved || ![TEMPLATE_PART_POST_TYPE, TEMPLATE_POST_TYPE].includes(postType)) {
|
|
393
|
+
return {
|
|
394
|
+
isLoading: true,
|
|
395
|
+
commands: []
|
|
396
|
+
};
|
|
397
|
+
}
|
|
398
|
+
const commands = [];
|
|
399
|
+
if (isTemplateRevertable(template)) {
|
|
400
|
+
const label = template.type === TEMPLATE_POST_TYPE ? sprintf(/* translators: %s: template title */
|
|
401
|
+
__('Reset template: %s'), decodeEntities(template.title)) : sprintf(/* translators: %s: template part title */
|
|
402
|
+
__('Reset template part: %s'), decodeEntities(template.title));
|
|
403
|
+
commands.push({
|
|
404
|
+
name: 'core/reset-template',
|
|
405
|
+
label,
|
|
406
|
+
icon: isRTL() ? rotateRight : rotateLeft,
|
|
407
|
+
callback: ({
|
|
408
|
+
close
|
|
409
|
+
}) => {
|
|
410
|
+
revertTemplate(template);
|
|
411
|
+
close();
|
|
412
|
+
}
|
|
413
|
+
});
|
|
414
|
+
}
|
|
415
|
+
return {
|
|
416
|
+
isLoading: !hasResolved,
|
|
417
|
+
commands
|
|
418
|
+
};
|
|
419
|
+
};
|
|
322
420
|
export default function useCommands() {
|
|
323
421
|
useCommandLoader({
|
|
324
422
|
name: 'core/editor/edit-ui',
|
|
325
|
-
hook:
|
|
423
|
+
hook: getEditorCommandLoader()
|
|
326
424
|
});
|
|
327
425
|
useCommandLoader({
|
|
328
426
|
name: 'core/editor/contextual-commands',
|
|
329
|
-
hook:
|
|
427
|
+
hook: getEditedEntityContextualCommands(),
|
|
428
|
+
context: 'entity-edit'
|
|
429
|
+
});
|
|
430
|
+
useCommandLoader({
|
|
431
|
+
name: 'core/editor/page-content-focus',
|
|
432
|
+
hook: getPageContentFocusCommands(),
|
|
330
433
|
context: 'entity-edit'
|
|
331
434
|
});
|
|
435
|
+
useCommandLoader({
|
|
436
|
+
name: 'core/edit-site/manipulate-document',
|
|
437
|
+
hook: getManipulateDocumentCommands()
|
|
438
|
+
});
|
|
332
439
|
}
|
|
333
440
|
//# sourceMappingURL=index.js.map
|