@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
|
@@ -164,40 +164,47 @@ export const ExperimentalEditorProvider = withRegistryProvider(
|
|
|
164
164
|
BlockEditorProviderComponent = ExperimentalBlockEditorProvider,
|
|
165
165
|
__unstableTemplate: template,
|
|
166
166
|
} ) => {
|
|
167
|
-
const { editorSettings, selection, isReady, mode,
|
|
168
|
-
useSelect(
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
167
|
+
const { editorSettings, selection, isReady, mode, postTypeEntities } =
|
|
168
|
+
useSelect(
|
|
169
|
+
( select ) => {
|
|
170
|
+
const {
|
|
171
|
+
getEditorSettings,
|
|
172
|
+
getEditorSelection,
|
|
173
|
+
getRenderingMode,
|
|
174
|
+
__unstableIsEditorReady,
|
|
175
|
+
} = select( editorStore );
|
|
176
|
+
const { getEntitiesConfig } = select( coreStore );
|
|
176
177
|
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
178
|
+
return {
|
|
179
|
+
editorSettings: getEditorSettings(),
|
|
180
|
+
isReady: __unstableIsEditorReady(),
|
|
181
|
+
mode: getRenderingMode(),
|
|
182
|
+
selection: getEditorSelection(),
|
|
183
|
+
postTypeEntities:
|
|
184
|
+
post.type === 'wp_template'
|
|
185
|
+
? getEntitiesConfig( 'postType' )
|
|
186
|
+
: null,
|
|
187
|
+
};
|
|
188
|
+
},
|
|
189
|
+
[ post.type ]
|
|
190
|
+
);
|
|
185
191
|
const shouldRenderTemplate = !! template && mode !== 'post-only';
|
|
186
192
|
const rootLevelPost = shouldRenderTemplate ? template : post;
|
|
187
193
|
const defaultBlockContext = useMemo( () => {
|
|
188
194
|
const postContext = {};
|
|
189
|
-
// If it is a template, try to inherit the post type from the
|
|
195
|
+
// If it is a template, try to inherit the post type from the name.
|
|
190
196
|
if ( post.type === 'wp_template' ) {
|
|
191
197
|
if ( post.slug === 'page' ) {
|
|
192
198
|
postContext.postType = 'page';
|
|
193
199
|
} else if ( post.slug === 'single' ) {
|
|
194
200
|
postContext.postType = 'post';
|
|
195
201
|
} else if ( post.slug.split( '-' )[ 0 ] === 'single' ) {
|
|
196
|
-
// If the slug is single-{postType}, infer the post type from the
|
|
197
|
-
const
|
|
198
|
-
|
|
202
|
+
// If the slug is single-{postType}, infer the post type from the name.
|
|
203
|
+
const postTypeNames =
|
|
204
|
+
postTypeEntities?.map( ( entity ) => entity.name ) ||
|
|
205
|
+
[];
|
|
199
206
|
const match = post.slug.match(
|
|
200
|
-
`^single-(${
|
|
207
|
+
`^single-(${ postTypeNames.join( '|' ) })(?:-.+)?$`
|
|
201
208
|
);
|
|
202
209
|
if ( match ) {
|
|
203
210
|
postContext.postType = match[ 1 ];
|
|
@@ -225,7 +232,7 @@ export const ExperimentalEditorProvider = withRegistryProvider(
|
|
|
225
232
|
post.slug,
|
|
226
233
|
rootLevelPost.type,
|
|
227
234
|
rootLevelPost.slug,
|
|
228
|
-
|
|
235
|
+
postTypeEntities,
|
|
229
236
|
] );
|
|
230
237
|
const { id, type } = rootLevelPost;
|
|
231
238
|
const blockEditorSettings = useBlockEditorSettings(
|
|
@@ -323,7 +330,7 @@ export const ExperimentalEditorProvider = withRegistryProvider(
|
|
|
323
330
|
useSubRegistry={ false }
|
|
324
331
|
>
|
|
325
332
|
{ children }
|
|
326
|
-
{ ! settings.
|
|
333
|
+
{ ! settings.isPreviewMode && (
|
|
327
334
|
<>
|
|
328
335
|
<PatternsMenuItems />
|
|
329
336
|
<TemplatePartMenuItems />
|
|
@@ -7,6 +7,7 @@ import {
|
|
|
7
7
|
store as coreStore,
|
|
8
8
|
__experimentalFetchLinkSuggestions as fetchLinkSuggestions,
|
|
9
9
|
__experimentalFetchUrlData as fetchUrlData,
|
|
10
|
+
privateApis as coreDataPrivateApis,
|
|
10
11
|
} from '@wordpress/core-data';
|
|
11
12
|
import { __ } from '@wordpress/i18n';
|
|
12
13
|
import { store as preferencesStore } from '@wordpress/preferences';
|
|
@@ -29,17 +30,12 @@ import { useGlobalStylesContext } from '../global-styles-provider';
|
|
|
29
30
|
const EMPTY_OBJECT = {};
|
|
30
31
|
|
|
31
32
|
function __experimentalReusableBlocksSelect( select ) {
|
|
32
|
-
const {
|
|
33
|
-
const
|
|
33
|
+
const { RECEIVE_INTERMEDIATE_RESULTS } = unlock( coreDataPrivateApis );
|
|
34
|
+
const { getEntityRecords } = select( coreStore );
|
|
35
|
+
return getEntityRecords( 'postType', 'wp_block', {
|
|
34
36
|
per_page: -1,
|
|
37
|
+
[ RECEIVE_INTERMEDIATE_RESULTS ]: true,
|
|
35
38
|
} );
|
|
36
|
-
return hasFinishedResolution( 'getEntityRecords', [
|
|
37
|
-
'postType',
|
|
38
|
-
'wp_block',
|
|
39
|
-
{ per_page: -1 },
|
|
40
|
-
] )
|
|
41
|
-
? reusableBlocks
|
|
42
|
-
: undefined;
|
|
43
39
|
}
|
|
44
40
|
|
|
45
41
|
const BLOCK_EDITOR_SETTINGS = [
|
|
@@ -74,6 +70,7 @@ const BLOCK_EDITOR_SETTINGS = [
|
|
|
74
70
|
'imageDimensions',
|
|
75
71
|
'imageEditing',
|
|
76
72
|
'imageSizes',
|
|
73
|
+
'isPreviewMode',
|
|
77
74
|
'isRTL',
|
|
78
75
|
'locale',
|
|
79
76
|
'maxWidth',
|
|
@@ -85,7 +82,6 @@ const BLOCK_EDITOR_SETTINGS = [
|
|
|
85
82
|
'supportsLayout',
|
|
86
83
|
'widgetTypesToHideFromLegacyWidgetBlock',
|
|
87
84
|
'__unstableHasCustomAppender',
|
|
88
|
-
'__unstableIsPreviewMode',
|
|
89
85
|
'__unstableResolvedAssets',
|
|
90
86
|
'__unstableIsBlockBasedTheme',
|
|
91
87
|
];
|
|
@@ -332,6 +328,10 @@ function useBlockEditorSettings( settings, postType, postId, renderingMode ) {
|
|
|
332
328
|
: settings.template,
|
|
333
329
|
__experimentalSetIsInserterOpened: setIsInserterOpened,
|
|
334
330
|
[ sectionRootClientIdKey ]: sectionRootClientId,
|
|
331
|
+
editorTool:
|
|
332
|
+
renderingMode === 'post-only' && postType !== 'wp_template'
|
|
333
|
+
? 'edit'
|
|
334
|
+
: undefined,
|
|
335
335
|
};
|
|
336
336
|
|
|
337
337
|
return blockEditorSettings;
|
|
@@ -359,6 +359,7 @@ function useBlockEditorSettings( settings, postType, postId, renderingMode ) {
|
|
|
359
359
|
sectionRootClientId,
|
|
360
360
|
globalStylesData,
|
|
361
361
|
globalStylesLinksData,
|
|
362
|
+
renderingMode,
|
|
362
363
|
] );
|
|
363
364
|
}
|
|
364
365
|
|
|
@@ -20,8 +20,9 @@ const SidebarHeader = ( _, ref ) => {
|
|
|
20
20
|
const { getPostTypeLabel } = select( editorStore );
|
|
21
21
|
|
|
22
22
|
return {
|
|
23
|
-
|
|
24
|
-
|
|
23
|
+
documentLabel:
|
|
24
|
+
// translators: Default label for the Document sidebar tab, not selected.
|
|
25
|
+
getPostTypeLabel() || _x( 'Document', 'noun, sidebar' ),
|
|
25
26
|
};
|
|
26
27
|
}, [] );
|
|
27
28
|
|
|
@@ -13,7 +13,7 @@ import {
|
|
|
13
13
|
useEffect,
|
|
14
14
|
useRef,
|
|
15
15
|
} from '@wordpress/element';
|
|
16
|
-
import { isRTL, __ } from '@wordpress/i18n';
|
|
16
|
+
import { isRTL, __, _x } from '@wordpress/i18n';
|
|
17
17
|
import { drawerLeft, drawerRight } from '@wordpress/icons';
|
|
18
18
|
import { store as keyboardShortcutsStore } from '@wordpress/keyboard-shortcuts';
|
|
19
19
|
import { privateApis as componentsPrivateApis } from '@wordpress/components';
|
|
@@ -101,8 +101,10 @@ const SidebarContent = ( {
|
|
|
101
101
|
// see https://github.com/WordPress/gutenberg/pull/55360#pullrequestreview-1737671049
|
|
102
102
|
className="editor-sidebar__panel"
|
|
103
103
|
headerClassName="editor-sidebar__panel-tabs"
|
|
104
|
-
|
|
105
|
-
|
|
104
|
+
title={
|
|
105
|
+
/* translators: button label text should, if possible, be under 16 characters. */
|
|
106
|
+
_x( 'Settings', 'sidebar button label' )
|
|
107
|
+
}
|
|
106
108
|
toggleShortcut={ keyboardShortcut }
|
|
107
109
|
icon={ isRTL() ? drawerLeft : drawerRight }
|
|
108
110
|
isActiveByDefault={ SIDEBAR_ACTIVE_BY_DEFAULT }
|
|
@@ -87,11 +87,11 @@ export default function PostSummary( { onActionPerformed } ) {
|
|
|
87
87
|
<PostsPerPage />
|
|
88
88
|
<SiteDiscussion />
|
|
89
89
|
<PostFormatPanel />
|
|
90
|
+
{ fills }
|
|
90
91
|
</VStack>
|
|
91
92
|
<PostTrash
|
|
92
93
|
onActionPerformed={ onActionPerformed }
|
|
93
94
|
/>
|
|
94
|
-
{ fills }
|
|
95
95
|
</VStack>
|
|
96
96
|
) }
|
|
97
97
|
</VStack>
|
|
@@ -1,11 +1,9 @@
|
|
|
1
1
|
.components-panel__header.editor-sidebar__panel-tabs {
|
|
2
2
|
padding-left: 0;
|
|
3
|
-
padding-right: $grid-unit-
|
|
3
|
+
padding-right: $grid-unit-10;
|
|
4
4
|
|
|
5
5
|
.components-button.has-icon {
|
|
6
6
|
padding: 0;
|
|
7
|
-
min-width: $icon-size;
|
|
8
|
-
height: $icon-size;
|
|
9
7
|
|
|
10
8
|
@include break-medium() {
|
|
11
9
|
display: flex;
|
|
@@ -9,7 +9,6 @@ import {
|
|
|
9
9
|
__experimentalBlockPatternsList as BlockPatternsList,
|
|
10
10
|
} from '@wordpress/block-editor';
|
|
11
11
|
import { useSelect, useDispatch } from '@wordpress/data';
|
|
12
|
-
import { useAsyncList } from '@wordpress/compose';
|
|
13
12
|
import { store as coreStore } from '@wordpress/core-data';
|
|
14
13
|
import { __unstableSerializeAndClean } from '@wordpress/blocks';
|
|
15
14
|
import { store as preferencesStore } from '@wordpress/preferences';
|
|
@@ -66,7 +65,6 @@ export function useStartPatterns() {
|
|
|
66
65
|
}
|
|
67
66
|
|
|
68
67
|
function PatternSelection( { blockPatterns, onChoosePattern } ) {
|
|
69
|
-
const shownBlockPatterns = useAsyncList( blockPatterns );
|
|
70
68
|
const { editEntityRecord } = useDispatch( coreStore );
|
|
71
69
|
const { postType, postId } = useSelect( ( select ) => {
|
|
72
70
|
const { getCurrentPostType, getCurrentPostId } = select( editorStore );
|
|
@@ -79,7 +77,6 @@ function PatternSelection( { blockPatterns, onChoosePattern } ) {
|
|
|
79
77
|
return (
|
|
80
78
|
<BlockPatternsList
|
|
81
79
|
blockPatterns={ blockPatterns }
|
|
82
|
-
shownPatterns={ shownBlockPatterns }
|
|
83
80
|
onClickPattern={ ( _pattern, blocks ) => {
|
|
84
81
|
editEntityRecord( 'postType', postType, postId, {
|
|
85
82
|
blocks,
|
|
@@ -6,7 +6,6 @@ import { __ } from '@wordpress/i18n';
|
|
|
6
6
|
import { useState, useMemo, useEffect } from '@wordpress/element';
|
|
7
7
|
import { __experimentalBlockPatternsList as BlockPatternsList } from '@wordpress/block-editor';
|
|
8
8
|
import { useSelect } from '@wordpress/data';
|
|
9
|
-
import { useAsyncList } from '@wordpress/compose';
|
|
10
9
|
import { parse } from '@wordpress/blocks';
|
|
11
10
|
import { store as coreStore, useEntityBlockEditor } from '@wordpress/core-data';
|
|
12
11
|
|
|
@@ -111,11 +110,9 @@ function useStartPatterns( fallbackContent ) {
|
|
|
111
110
|
function PatternSelection( { fallbackContent, onChoosePattern, postType } ) {
|
|
112
111
|
const [ , , onChange ] = useEntityBlockEditor( 'postType', postType );
|
|
113
112
|
const blockPatterns = useStartPatterns( fallbackContent );
|
|
114
|
-
const shownBlockPatterns = useAsyncList( blockPatterns );
|
|
115
113
|
return (
|
|
116
114
|
<BlockPatternsList
|
|
117
115
|
blockPatterns={ blockPatterns }
|
|
118
|
-
shownPatterns={ shownBlockPatterns }
|
|
119
116
|
onClickPattern={ ( pattern, blocks ) => {
|
|
120
117
|
onChange( blocks, { selection: undefined } );
|
|
121
118
|
onChoosePattern();
|
|
@@ -47,10 +47,10 @@ export default function TimeToRead() {
|
|
|
47
47
|
} )
|
|
48
48
|
: createInterpolateElement(
|
|
49
49
|
sprintf(
|
|
50
|
-
/* translators: %s
|
|
50
|
+
/* translators: %s: the number of minutes to read the post. */
|
|
51
51
|
_n(
|
|
52
|
-
'<span>%
|
|
53
|
-
'<span>%
|
|
52
|
+
'<span>%s</span> minute',
|
|
53
|
+
'<span>%s</span> minutes',
|
|
54
54
|
minutesToRead
|
|
55
55
|
),
|
|
56
56
|
minutesToRead
|
|
@@ -16,7 +16,7 @@ import {
|
|
|
16
16
|
privateApis as blockEditorPrivateApis,
|
|
17
17
|
__experimentalUseResizeCanvas as useResizeCanvas,
|
|
18
18
|
} from '@wordpress/block-editor';
|
|
19
|
-
import { useEffect, useRef, useMemo } from '@wordpress/element';
|
|
19
|
+
import { useEffect, useRef, useMemo, useState } from '@wordpress/element';
|
|
20
20
|
import { useSelect } from '@wordpress/data';
|
|
21
21
|
import { parse } from '@wordpress/blocks';
|
|
22
22
|
import { store as coreStore } from '@wordpress/core-data';
|
|
@@ -41,6 +41,7 @@ import {
|
|
|
41
41
|
TEMPLATE_PART_POST_TYPE,
|
|
42
42
|
TEMPLATE_POST_TYPE,
|
|
43
43
|
} from '../../store/constants';
|
|
44
|
+
import { useZoomOutModeExit } from './use-zoom-out-mode-exit';
|
|
44
45
|
|
|
45
46
|
const {
|
|
46
47
|
LayoutStyle,
|
|
@@ -48,7 +49,6 @@ const {
|
|
|
48
49
|
useLayoutStyles,
|
|
49
50
|
ExperimentalBlockCanvas: BlockCanvas,
|
|
50
51
|
useFlashEditableBlocks,
|
|
51
|
-
useZoomOutModeExit,
|
|
52
52
|
} = unlock( blockEditorPrivateApis );
|
|
53
53
|
|
|
54
54
|
/**
|
|
@@ -106,9 +106,11 @@ function VisualEditor( {
|
|
|
106
106
|
contentRef,
|
|
107
107
|
className,
|
|
108
108
|
} ) {
|
|
109
|
-
const [
|
|
109
|
+
const [ contentHeight, setContentHeight ] = useState( '' );
|
|
110
|
+
const effectContentHeight = useResizeObserver( ( [ entry ] ) => {
|
|
111
|
+
setContentHeight( entry.borderBoxSize[ 0 ].blockSize );
|
|
112
|
+
} );
|
|
110
113
|
const isMobileViewport = useViewportMatch( 'small', '<' );
|
|
111
|
-
const isTabletViewport = useViewportMatch( 'medium', '<' );
|
|
112
114
|
const {
|
|
113
115
|
renderingMode,
|
|
114
116
|
postContentAttributes,
|
|
@@ -167,7 +169,7 @@ function VisualEditor( {
|
|
|
167
169
|
deviceType: getDeviceType(),
|
|
168
170
|
isFocusedEntity: !! editorSettings.onNavigateToPreviousEntityRecord,
|
|
169
171
|
postType: postTypeSlug,
|
|
170
|
-
isPreview: editorSettings.
|
|
172
|
+
isPreview: editorSettings.isPreviewMode,
|
|
171
173
|
};
|
|
172
174
|
}, [] );
|
|
173
175
|
const { isCleanNewPost } = useSelect( editorStore );
|
|
@@ -324,29 +326,6 @@ function VisualEditor( {
|
|
|
324
326
|
.is-root-container.alignfull { max-width: none; margin-left: auto; margin-right: auto;}
|
|
325
327
|
.is-root-container.alignfull:where(.is-layout-flow) > :not(.alignleft):not(.alignright) { max-width: none;}`;
|
|
326
328
|
|
|
327
|
-
const localRef = useRef();
|
|
328
|
-
const typewriterRef = useTypewriter();
|
|
329
|
-
contentRef = useMergeRefs( [
|
|
330
|
-
localRef,
|
|
331
|
-
contentRef,
|
|
332
|
-
renderingMode === 'post-only' ? typewriterRef : null,
|
|
333
|
-
useFlashEditableBlocks( {
|
|
334
|
-
isEnabled: renderingMode === 'template-locked',
|
|
335
|
-
} ),
|
|
336
|
-
useSelectNearestEditableBlock( {
|
|
337
|
-
isEnabled: renderingMode === 'template-locked',
|
|
338
|
-
} ),
|
|
339
|
-
useZoomOutModeExit(),
|
|
340
|
-
] );
|
|
341
|
-
|
|
342
|
-
const zoomOutProps =
|
|
343
|
-
isZoomedOut && ! isTabletViewport
|
|
344
|
-
? {
|
|
345
|
-
scale: 'default',
|
|
346
|
-
frameSize: '40px',
|
|
347
|
-
}
|
|
348
|
-
: {};
|
|
349
|
-
|
|
350
329
|
const forceFullHeight = postType === NAVIGATION_POST_TYPE;
|
|
351
330
|
const enableResizing =
|
|
352
331
|
[
|
|
@@ -360,14 +339,15 @@ function VisualEditor( {
|
|
|
360
339
|
! isMobileViewport &&
|
|
361
340
|
// Dsiable resizing in zoomed-out mode.
|
|
362
341
|
! isZoomedOut;
|
|
363
|
-
const shouldIframe =
|
|
364
|
-
! disableIframe || [ 'Tablet', 'Mobile' ].includes( deviceType );
|
|
365
342
|
|
|
366
343
|
const iframeStyles = useMemo( () => {
|
|
367
344
|
return [
|
|
368
345
|
...( styles ?? [] ),
|
|
369
346
|
{
|
|
370
|
-
|
|
347
|
+
// Ensures margins of children are contained so that the body background paints behind them.
|
|
348
|
+
// Otherwise, the background of html (when zoomed out) would show there and appear broken. It’s
|
|
349
|
+
// important mostly for post-only views yet conceivably an issue in templated views too.
|
|
350
|
+
css: `:where(.block-editor-iframe__body){display:flow-root;}.is-root-container{display:flow-root;${
|
|
371
351
|
// Some themes will have `min-height: 100vh` for the root container,
|
|
372
352
|
// which isn't a requirement in auto resize mode.
|
|
373
353
|
enableResizing ? 'min-height:0!important;' : ''
|
|
@@ -376,6 +356,24 @@ function VisualEditor( {
|
|
|
376
356
|
];
|
|
377
357
|
}, [ styles, enableResizing ] );
|
|
378
358
|
|
|
359
|
+
const localRef = useRef();
|
|
360
|
+
const typewriterRef = useTypewriter();
|
|
361
|
+
contentRef = useMergeRefs( [
|
|
362
|
+
localRef,
|
|
363
|
+
contentRef,
|
|
364
|
+
renderingMode === 'post-only' ? typewriterRef : null,
|
|
365
|
+
useFlashEditableBlocks( {
|
|
366
|
+
isEnabled: renderingMode === 'template-locked',
|
|
367
|
+
} ),
|
|
368
|
+
useSelectNearestEditableBlock( {
|
|
369
|
+
isEnabled: renderingMode === 'template-locked',
|
|
370
|
+
} ),
|
|
371
|
+
useZoomOutModeExit(),
|
|
372
|
+
// Avoid resize listeners when not needed, these will trigger
|
|
373
|
+
// unnecessary re-renders when animating the iframe width.
|
|
374
|
+
enableResizing ? effectContentHeight : null,
|
|
375
|
+
] );
|
|
376
|
+
|
|
379
377
|
return (
|
|
380
378
|
<div
|
|
381
379
|
className={ clsx(
|
|
@@ -386,24 +384,23 @@ function VisualEditor( {
|
|
|
386
384
|
{
|
|
387
385
|
'has-padding': isFocusedEntity || enableResizing,
|
|
388
386
|
'is-resizable': enableResizing,
|
|
389
|
-
'is-iframed':
|
|
387
|
+
'is-iframed': ! disableIframe,
|
|
390
388
|
}
|
|
391
389
|
) }
|
|
392
390
|
>
|
|
393
391
|
<ResizableEditor
|
|
394
392
|
enableResizing={ enableResizing }
|
|
395
393
|
height={
|
|
396
|
-
|
|
394
|
+
contentHeight && ! forceFullHeight ? contentHeight : '100%'
|
|
397
395
|
}
|
|
398
396
|
>
|
|
399
397
|
<BlockCanvas
|
|
400
|
-
shouldIframe={
|
|
398
|
+
shouldIframe={ ! disableIframe }
|
|
401
399
|
contentRef={ contentRef }
|
|
402
400
|
styles={ iframeStyles }
|
|
403
401
|
height="100%"
|
|
404
402
|
iframeProps={ {
|
|
405
403
|
...iframeProps,
|
|
406
|
-
...zoomOutProps,
|
|
407
404
|
style: {
|
|
408
405
|
...iframeProps?.style,
|
|
409
406
|
...deviceStyles,
|
|
@@ -465,7 +462,13 @@ function VisualEditor( {
|
|
|
465
462
|
renderingMode !== 'post-only' ||
|
|
466
463
|
isDesignPostType
|
|
467
464
|
? 'wp-site-blocks'
|
|
468
|
-
: `${ blockListLayoutClass } wp-block-post-content
|
|
465
|
+
: `${ blockListLayoutClass } wp-block-post-content`, // Ensure root level blocks receive default/flow blockGap styling rules.
|
|
466
|
+
{
|
|
467
|
+
'has-global-padding':
|
|
468
|
+
renderingMode === 'post-only' &&
|
|
469
|
+
! isDesignPostType &&
|
|
470
|
+
hasRootPaddingAwareAlignments,
|
|
471
|
+
}
|
|
469
472
|
) }
|
|
470
473
|
layout={ blockListLayout }
|
|
471
474
|
dropZoneElement={
|
|
@@ -488,12 +491,6 @@ function VisualEditor( {
|
|
|
488
491
|
/>
|
|
489
492
|
) }
|
|
490
493
|
</RecursionProvider>
|
|
491
|
-
{
|
|
492
|
-
// Avoid resize listeners when not needed,
|
|
493
|
-
// these will trigger unnecessary re-renders
|
|
494
|
-
// when animating the iframe width.
|
|
495
|
-
enableResizing && resizeObserver
|
|
496
|
-
}
|
|
497
494
|
</BlockCanvas>
|
|
498
495
|
</ResizableEditor>
|
|
499
496
|
</div>
|
|
@@ -1,8 +1,19 @@
|
|
|
1
1
|
.editor-visual-editor {
|
|
2
2
|
position: relative;
|
|
3
3
|
display: flex;
|
|
4
|
+
|
|
5
|
+
// This duplicates the iframe background but it's necessary in some situations
|
|
6
|
+
// when the iframe doesn't cover the whole canvas
|
|
7
|
+
// like the "focused entities".
|
|
4
8
|
background-color: $gray-300;
|
|
5
9
|
|
|
10
|
+
// This overrides the iframe background since it's applied again here
|
|
11
|
+
// It also prevents some style glitches if `editor-visual-editor`
|
|
12
|
+
// like when hovering the preview in the site editor.
|
|
13
|
+
iframe[name="editor-canvas"] {
|
|
14
|
+
background-color: transparent;
|
|
15
|
+
}
|
|
16
|
+
|
|
6
17
|
// Centralize the editor horizontally (flex-direction is column).
|
|
7
18
|
align-items: center;
|
|
8
19
|
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* WordPress dependencies
|
|
3
|
+
*/
|
|
4
|
+
import { useSelect, useDispatch } from '@wordpress/data';
|
|
5
|
+
import { useRefEffect } from '@wordpress/compose';
|
|
6
|
+
import { store as blockEditorStore } from '@wordpress/block-editor';
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* Internal dependencies
|
|
10
|
+
*/
|
|
11
|
+
import { unlock } from '../../lock-unlock';
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* Allows Zoom Out mode to be exited by double clicking in the selected block.
|
|
15
|
+
*/
|
|
16
|
+
export function useZoomOutModeExit() {
|
|
17
|
+
const { getSettings, isZoomOut } = unlock( useSelect( blockEditorStore ) );
|
|
18
|
+
const { resetZoomLevel } = unlock( useDispatch( blockEditorStore ) );
|
|
19
|
+
|
|
20
|
+
return useRefEffect(
|
|
21
|
+
( node ) => {
|
|
22
|
+
function onDoubleClick( event ) {
|
|
23
|
+
if ( ! isZoomOut() ) {
|
|
24
|
+
return;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
if ( ! event.defaultPrevented ) {
|
|
28
|
+
event.preventDefault();
|
|
29
|
+
|
|
30
|
+
const { __experimentalSetIsInserterOpened } = getSettings();
|
|
31
|
+
|
|
32
|
+
if (
|
|
33
|
+
typeof __experimentalSetIsInserterOpened === 'function'
|
|
34
|
+
) {
|
|
35
|
+
__experimentalSetIsInserterOpened( false );
|
|
36
|
+
}
|
|
37
|
+
resetZoomLevel();
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
node.addEventListener( 'dblclick', onDoubleClick );
|
|
42
|
+
|
|
43
|
+
return () => {
|
|
44
|
+
node.removeEventListener( 'dblclick', onDoubleClick );
|
|
45
|
+
};
|
|
46
|
+
},
|
|
47
|
+
[ getSettings, isZoomOut, resetZoomLevel ]
|
|
48
|
+
);
|
|
49
|
+
}
|
|
@@ -3,18 +3,23 @@
|
|
|
3
3
|
*/
|
|
4
4
|
import { Button } from '@wordpress/components';
|
|
5
5
|
import { __ } from '@wordpress/i18n';
|
|
6
|
-
|
|
6
|
+
import { useEffect } from '@wordpress/element';
|
|
7
7
|
import { useDispatch, useSelect } from '@wordpress/data';
|
|
8
8
|
import { store as blockEditorStore } from '@wordpress/block-editor';
|
|
9
9
|
import { square as zoomOutIcon } from '@wordpress/icons';
|
|
10
10
|
import { store as preferencesStore } from '@wordpress/preferences';
|
|
11
|
+
import {
|
|
12
|
+
useShortcut,
|
|
13
|
+
store as keyboardShortcutsStore,
|
|
14
|
+
} from '@wordpress/keyboard-shortcuts';
|
|
15
|
+
import { isAppleOS } from '@wordpress/keycodes';
|
|
11
16
|
|
|
12
17
|
/**
|
|
13
18
|
* Internal dependencies
|
|
14
19
|
*/
|
|
15
20
|
import { unlock } from '../../lock-unlock';
|
|
16
21
|
|
|
17
|
-
const ZoomOutToggle = () => {
|
|
22
|
+
const ZoomOutToggle = ( { disabled } ) => {
|
|
18
23
|
const { isZoomOut, showIconLabels } = useSelect( ( select ) => ( {
|
|
19
24
|
isZoomOut: unlock( select( blockEditorStore ) ).isZoomOut(),
|
|
20
25
|
showIconLabels: select( preferencesStore ).get(
|
|
@@ -23,21 +28,50 @@ const ZoomOutToggle = () => {
|
|
|
23
28
|
),
|
|
24
29
|
} ) );
|
|
25
30
|
|
|
26
|
-
const { resetZoomLevel, setZoomLevel
|
|
31
|
+
const { resetZoomLevel, setZoomLevel } = unlock(
|
|
27
32
|
useDispatch( blockEditorStore )
|
|
28
33
|
);
|
|
34
|
+
const { registerShortcut, unregisterShortcut } = useDispatch(
|
|
35
|
+
keyboardShortcutsStore
|
|
36
|
+
);
|
|
37
|
+
|
|
38
|
+
useEffect( () => {
|
|
39
|
+
registerShortcut( {
|
|
40
|
+
name: 'core/editor/zoom',
|
|
41
|
+
category: 'global',
|
|
42
|
+
description: __( 'Enter or exit zoom out.' ),
|
|
43
|
+
keyCombination: {
|
|
44
|
+
// `primaryShift+0` (`ctrl+shift+0`) is the shortcut for switching
|
|
45
|
+
// to input mode in Windows, so apply a different key combination.
|
|
46
|
+
modifier: isAppleOS() ? 'primaryShift' : 'secondary',
|
|
47
|
+
character: '0',
|
|
48
|
+
},
|
|
49
|
+
} );
|
|
50
|
+
return () => {
|
|
51
|
+
unregisterShortcut( 'core/editor/zoom' );
|
|
52
|
+
};
|
|
53
|
+
}, [ registerShortcut, unregisterShortcut ] );
|
|
54
|
+
|
|
55
|
+
useShortcut( 'core/editor/zoom', () => {
|
|
56
|
+
if ( isZoomOut ) {
|
|
57
|
+
resetZoomLevel();
|
|
58
|
+
} else {
|
|
59
|
+
setZoomLevel( 'auto-scaled' );
|
|
60
|
+
}
|
|
61
|
+
} );
|
|
29
62
|
|
|
30
63
|
const handleZoomOut = () => {
|
|
31
64
|
if ( isZoomOut ) {
|
|
32
65
|
resetZoomLevel();
|
|
33
66
|
} else {
|
|
34
|
-
setZoomLevel(
|
|
67
|
+
setZoomLevel( 'auto-scaled' );
|
|
35
68
|
}
|
|
36
|
-
__unstableSetEditorMode( isZoomOut ? 'edit' : 'zoom-out' );
|
|
37
69
|
};
|
|
38
70
|
|
|
39
71
|
return (
|
|
40
72
|
<Button
|
|
73
|
+
accessibleWhenDisabled
|
|
74
|
+
disabled={ disabled }
|
|
41
75
|
onClick={ handleZoomOut }
|
|
42
76
|
icon={ zoomOutIcon }
|
|
43
77
|
label={ __( 'Zoom Out' ) }
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
* WordPress dependencies
|
|
3
3
|
*/
|
|
4
4
|
import { useDispatch } from '@wordpress/data';
|
|
5
|
-
import {
|
|
5
|
+
import { _x, sprintf } from '@wordpress/i18n';
|
|
6
6
|
import { store as noticesStore } from '@wordpress/notices';
|
|
7
7
|
import { useMemo } from '@wordpress/element';
|
|
8
8
|
// @ts-ignore
|
|
@@ -42,7 +42,7 @@ const duplicateTemplatePart: Action< TemplatePart > = {
|
|
|
42
42
|
createSuccessNotice(
|
|
43
43
|
sprintf(
|
|
44
44
|
// translators: %s: The new template part's title e.g. 'Call to action (copy)'.
|
|
45
|
-
|
|
45
|
+
_x( '"%s" duplicated.', 'template part' ),
|
|
46
46
|
getItemTitle( item )
|
|
47
47
|
),
|
|
48
48
|
{ type: 'snackbar', id: 'edit-site-patterns-success' }
|
|
@@ -55,7 +55,7 @@ const duplicateTemplatePart: Action< TemplatePart > = {
|
|
|
55
55
|
defaultArea={ item.area }
|
|
56
56
|
defaultTitle={ sprintf(
|
|
57
57
|
/* translators: %s: Existing template part title */
|
|
58
|
-
|
|
58
|
+
_x( '%s (Copy)', 'template part' ),
|
|
59
59
|
getItemTitle( item )
|
|
60
60
|
) }
|
|
61
61
|
onCreate={ onTemplatePartSuccess }
|