@wordpress/edit-site 7.0.0 → 7.2.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 +0 -7
- package/build/components/add-new-pattern/index.cjs.map +2 -2
- package/build/components/add-new-post/index.cjs.map +2 -2
- package/build/components/add-new-template/add-custom-generic-template-modal-content.cjs.map +2 -2
- package/build/components/add-new-template/add-custom-template-modal-content.cjs.map +2 -2
- package/build/components/add-new-template/index.cjs.map +2 -2
- package/build/components/add-new-template/utils.cjs.map +2 -2
- package/build/components/add-new-template-legacy/add-custom-generic-template-modal-content.cjs.map +2 -2
- package/build/components/add-new-template-legacy/add-custom-template-modal-content.cjs.map +2 -2
- package/build/components/add-new-template-legacy/index.cjs.map +2 -2
- package/build/components/add-new-template-legacy/utils.cjs.map +2 -2
- package/build/components/app/index.cjs.map +2 -2
- package/build/components/block-editor/use-editor-iframe-props.cjs.map +2 -2
- package/build/components/block-editor/use-navigate-to-entity-record.cjs.map +2 -2
- package/build/components/block-editor/use-site-editor-settings.cjs.map +2 -2
- package/build/components/block-editor/use-viewport-sync.cjs.map +2 -2
- package/build/components/canvas-loader/index.cjs +8 -3
- package/build/components/canvas-loader/index.cjs.map +3 -3
- package/build/components/dataviews-actions/index.cjs.map +2 -2
- package/build/components/editor/index.cjs +6 -5
- package/build/components/editor/index.cjs.map +3 -3
- package/build/components/editor/site-preview.cjs.map +2 -2
- package/build/components/editor/use-adapt-editor-to-canvas.cjs.map +2 -2
- package/build/components/editor/use-editor-title.cjs +1 -2
- package/build/components/editor/use-editor-title.cjs.map +3 -3
- package/build/components/editor/use-resolve-edited-entity.cjs.map +2 -2
- package/build/components/editor/use-revisions-url-sync.cjs +122 -0
- package/build/components/editor/use-revisions-url-sync.cjs.map +7 -0
- package/build/components/layout/animation.cjs.map +2 -2
- package/build/components/layout/hooks.cjs.map +2 -2
- package/build/components/layout/index.cjs +0 -1
- package/build/components/layout/index.cjs.map +2 -2
- package/build/components/media/index.cjs.map +2 -2
- package/build/components/more-menu/index.cjs.map +2 -2
- package/build/components/more-menu/site-export.cjs.map +2 -2
- package/build/components/more-menu/welcome-guide-menu-item.cjs.map +2 -2
- package/build/components/page-patterns/actions.cjs.map +2 -2
- package/build/components/page-patterns/delete-category-menu-item.cjs.map +2 -2
- package/build/components/page-patterns/fields.cjs.map +2 -2
- package/build/components/page-patterns/index.cjs.map +2 -2
- package/build/components/page-patterns/rename-category-menu-item.cjs.map +2 -2
- package/build/components/page-patterns/search-items.cjs.map +2 -2
- package/build/components/page-patterns/use-pattern-settings.cjs.map +2 -2
- package/build/components/page-patterns/use-patterns.cjs.map +2 -2
- package/build/components/page-templates/fields.cjs.map +2 -2
- package/build/components/page-templates/hooks.cjs.map +2 -2
- package/build/components/page-templates/index-legacy.cjs.map +2 -2
- package/build/components/page-templates/index.cjs.map +2 -2
- package/build/components/pagination/index.cjs.map +2 -2
- package/build/components/plugin-template-setting-panel/index.cjs.map +2 -2
- package/build/components/post-list/index.cjs.map +2 -2
- package/build/components/post-list/quick-edit-modal.cjs.map +2 -2
- package/build/components/post-list/use-notes-count.cjs.map +2 -2
- package/build/components/resizable-frame/index.cjs.map +2 -2
- package/build/components/routes/use-title.cjs.map +2 -2
- package/build/components/save-button/index.cjs +3 -3
- package/build/components/save-button/index.cjs.map +3 -3
- package/build/components/save-hub/index.cjs.map +2 -2
- package/build/components/save-keyboard-shortcut/index.cjs.map +2 -2
- package/build/components/save-panel/index.cjs +7 -4
- package/build/components/save-panel/index.cjs.map +3 -3
- package/build/components/sidebar/index.cjs.map +2 -2
- package/build/components/sidebar-button/index.cjs.map +2 -2
- package/build/components/sidebar-dataviews/index.cjs.map +2 -2
- package/build/components/sidebar-global-styles/index.cjs.map +2 -2
- package/build/components/sidebar-identity/index.cjs +5 -2
- package/build/components/sidebar-identity/index.cjs.map +2 -2
- package/build/components/sidebar-navigation-item/index.cjs.map +2 -2
- package/build/components/sidebar-navigation-screen/index.cjs.map +2 -2
- package/build/components/sidebar-navigation-screen-details-footer/index.cjs.map +2 -2
- package/build/components/sidebar-navigation-screen-global-styles/content.cjs.map +2 -2
- package/build/components/sidebar-navigation-screen-global-styles/index.cjs.map +2 -2
- package/build/components/sidebar-navigation-screen-identity/index.cjs.map +2 -2
- package/build/components/sidebar-navigation-screen-main/index.cjs.map +2 -2
- package/build/components/sidebar-navigation-screen-navigation-menu/delete-confirm-dialog.cjs.map +2 -2
- package/build/components/sidebar-navigation-screen-navigation-menu/index.cjs.map +2 -2
- package/build/components/sidebar-navigation-screen-navigation-menu/more-menu.cjs.map +2 -2
- package/build/components/sidebar-navigation-screen-navigation-menu/navigation-menu-editor.cjs.map +2 -2
- package/build/components/sidebar-navigation-screen-navigation-menu/rename-modal.cjs.map +2 -2
- package/build/components/sidebar-navigation-screen-navigation-menu/single-navigation-menu.cjs.map +2 -2
- package/build/components/sidebar-navigation-screen-navigation-menu/use-navigation-menu-handlers.cjs.map +2 -2
- package/build/components/sidebar-navigation-screen-navigation-menus/build-navigation-label.cjs.map +2 -2
- package/build/components/sidebar-navigation-screen-navigation-menus/index.cjs.map +2 -2
- package/build/components/sidebar-navigation-screen-navigation-menus/leaf-more-menu.cjs +24 -25
- package/build/components/sidebar-navigation-screen-navigation-menus/leaf-more-menu.cjs.map +2 -2
- package/build/components/sidebar-navigation-screen-navigation-menus/navigation-menu-content.cjs.map +2 -2
- package/build/components/sidebar-navigation-screen-patterns/category-item.cjs.map +2 -2
- package/build/components/sidebar-navigation-screen-patterns/index.cjs +3 -2
- package/build/components/sidebar-navigation-screen-patterns/index.cjs.map +3 -3
- package/build/components/sidebar-navigation-screen-patterns/use-default-pattern-categories.cjs.map +2 -2
- package/build/components/sidebar-navigation-screen-patterns/use-pattern-categories.cjs.map +2 -2
- package/build/components/sidebar-navigation-screen-patterns/use-template-part-areas.cjs.map +2 -2
- package/build/components/sidebar-navigation-screen-patterns/use-theme-patterns.cjs.map +2 -2
- package/build/components/sidebar-navigation-screen-templates-browse/content-legacy.cjs.map +2 -2
- package/build/components/sidebar-navigation-screen-templates-browse/content.cjs +1 -1
- package/build/components/sidebar-navigation-screen-templates-browse/content.cjs.map +2 -2
- package/build/components/sidebar-navigation-screen-templates-browse/index.cjs.map +2 -2
- package/build/components/sidebar-navigation-screen-unsupported/index.cjs.map +2 -2
- package/build/components/site-editor-routes/home.cjs.map +2 -2
- package/build/components/site-editor-routes/identity.cjs.map +2 -2
- package/build/components/site-editor-routes/index.cjs.map +2 -2
- package/build/components/site-editor-routes/navigation-item.cjs.map +2 -2
- package/build/components/site-editor-routes/navigation.cjs.map +2 -2
- package/build/components/site-editor-routes/notfound.cjs.map +2 -2
- package/build/components/site-editor-routes/page-item.cjs.map +2 -2
- package/build/components/site-editor-routes/pages.cjs.map +2 -2
- package/build/components/site-editor-routes/pattern-item.cjs.map +2 -2
- package/build/components/site-editor-routes/patterns.cjs.map +2 -2
- package/build/components/site-editor-routes/stylebook.cjs.map +2 -2
- package/build/components/site-editor-routes/styles.cjs +17 -12
- package/build/components/site-editor-routes/styles.cjs.map +2 -2
- package/build/components/site-editor-routes/template-item.cjs.map +2 -2
- package/build/components/site-editor-routes/template-part-item.cjs.map +2 -2
- package/build/components/site-editor-routes/templates.cjs.map +2 -2
- package/build/components/site-hub/index.cjs.map +2 -2
- package/build/components/welcome-guide/editor.cjs.map +2 -2
- package/build/components/welcome-guide/index.cjs.map +2 -2
- package/build/components/welcome-guide/page.cjs.map +2 -2
- package/build/components/welcome-guide/template.cjs.map +2 -2
- package/build/deprecated.cjs.map +2 -2
- package/build/hooks/commands/use-common-commands.cjs.map +2 -2
- package/build/hooks/commands/use-set-command-context.cjs.map +2 -2
- package/build/index.cjs.map +2 -2
- package/build/lock-unlock.cjs.map +2 -2
- package/build/store/actions.cjs.map +2 -2
- package/build/store/index.cjs.map +2 -2
- package/build/store/reducer.cjs.map +2 -2
- package/build/store/selectors.cjs.map +2 -2
- package/build/utils/constants.cjs.map +2 -2
- package/build/utils/get-filtered-template-parts.cjs.map +2 -2
- package/build/utils/is-previewing-theme.cjs.map +2 -2
- package/build/utils/is-template-removable.cjs.map +2 -2
- package/build/utils/is-template-revertable.cjs.map +2 -2
- package/build/utils/use-activate-theme.cjs.map +2 -2
- package/build/utils/use-actual-current-theme.cjs.map +2 -2
- package/build-module/components/add-new-pattern/index.mjs.map +2 -2
- package/build-module/components/add-new-post/index.mjs.map +2 -2
- package/build-module/components/add-new-template/add-custom-generic-template-modal-content.mjs.map +2 -2
- package/build-module/components/add-new-template/add-custom-template-modal-content.mjs.map +2 -2
- package/build-module/components/add-new-template/index.mjs.map +2 -2
- package/build-module/components/add-new-template/utils.mjs.map +2 -2
- package/build-module/components/add-new-template-legacy/add-custom-generic-template-modal-content.mjs.map +2 -2
- package/build-module/components/add-new-template-legacy/add-custom-template-modal-content.mjs.map +2 -2
- package/build-module/components/add-new-template-legacy/index.mjs.map +2 -2
- package/build-module/components/add-new-template-legacy/utils.mjs.map +2 -2
- package/build-module/components/app/index.mjs.map +2 -2
- package/build-module/components/block-editor/use-editor-iframe-props.mjs.map +2 -2
- package/build-module/components/block-editor/use-navigate-to-entity-record.mjs.map +2 -2
- package/build-module/components/block-editor/use-site-editor-settings.mjs.map +2 -2
- package/build-module/components/block-editor/use-viewport-sync.mjs.map +2 -2
- package/build-module/components/canvas-loader/index.mjs +9 -7
- package/build-module/components/canvas-loader/index.mjs.map +2 -2
- package/build-module/components/dataviews-actions/index.mjs.map +2 -2
- package/build-module/components/editor/index.mjs +6 -5
- package/build-module/components/editor/index.mjs.map +2 -2
- package/build-module/components/editor/site-preview.mjs.map +2 -2
- package/build-module/components/editor/use-adapt-editor-to-canvas.mjs.map +2 -2
- package/build-module/components/editor/use-editor-title.mjs +5 -3
- package/build-module/components/editor/use-editor-title.mjs.map +2 -2
- package/build-module/components/editor/use-resolve-edited-entity.mjs.map +2 -2
- package/build-module/components/editor/use-revisions-url-sync.mjs +101 -0
- package/build-module/components/editor/use-revisions-url-sync.mjs.map +7 -0
- package/build-module/components/layout/animation.mjs.map +2 -2
- package/build-module/components/layout/hooks.mjs.map +2 -2
- package/build-module/components/layout/index.mjs +0 -1
- package/build-module/components/layout/index.mjs.map +2 -2
- package/build-module/components/media/index.mjs.map +2 -2
- package/build-module/components/more-menu/index.mjs.map +2 -2
- package/build-module/components/more-menu/site-export.mjs.map +2 -2
- package/build-module/components/more-menu/welcome-guide-menu-item.mjs.map +2 -2
- package/build-module/components/page-patterns/actions.mjs.map +2 -2
- package/build-module/components/page-patterns/delete-category-menu-item.mjs.map +2 -2
- package/build-module/components/page-patterns/fields.mjs.map +2 -2
- package/build-module/components/page-patterns/index.mjs.map +2 -2
- package/build-module/components/page-patterns/rename-category-menu-item.mjs.map +2 -2
- package/build-module/components/page-patterns/search-items.mjs.map +2 -2
- package/build-module/components/page-patterns/use-pattern-settings.mjs.map +2 -2
- package/build-module/components/page-patterns/use-patterns.mjs.map +2 -2
- package/build-module/components/page-templates/fields.mjs.map +2 -2
- package/build-module/components/page-templates/hooks.mjs.map +2 -2
- package/build-module/components/page-templates/index-legacy.mjs.map +2 -2
- package/build-module/components/page-templates/index.mjs.map +2 -2
- package/build-module/components/pagination/index.mjs.map +2 -2
- package/build-module/components/plugin-template-setting-panel/index.mjs.map +2 -2
- package/build-module/components/post-list/index.mjs.map +2 -2
- package/build-module/components/post-list/quick-edit-modal.mjs.map +2 -2
- package/build-module/components/post-list/use-notes-count.mjs.map +2 -2
- package/build-module/components/resizable-frame/index.mjs.map +2 -2
- package/build-module/components/routes/use-title.mjs.map +2 -2
- package/build-module/components/save-button/index.mjs +6 -6
- package/build-module/components/save-button/index.mjs.map +2 -2
- package/build-module/components/save-hub/index.mjs.map +2 -2
- package/build-module/components/save-keyboard-shortcut/index.mjs.map +2 -2
- package/build-module/components/save-panel/index.mjs +9 -7
- package/build-module/components/save-panel/index.mjs.map +2 -2
- package/build-module/components/sidebar/index.mjs.map +2 -2
- package/build-module/components/sidebar-button/index.mjs.map +2 -2
- package/build-module/components/sidebar-dataviews/index.mjs.map +2 -2
- package/build-module/components/sidebar-global-styles/index.mjs.map +2 -2
- package/build-module/components/sidebar-identity/index.mjs +5 -2
- package/build-module/components/sidebar-identity/index.mjs.map +2 -2
- package/build-module/components/sidebar-navigation-item/index.mjs.map +2 -2
- package/build-module/components/sidebar-navigation-screen/index.mjs.map +2 -2
- package/build-module/components/sidebar-navigation-screen-details-footer/index.mjs.map +2 -2
- package/build-module/components/sidebar-navigation-screen-global-styles/content.mjs.map +2 -2
- package/build-module/components/sidebar-navigation-screen-global-styles/index.mjs.map +2 -2
- package/build-module/components/sidebar-navigation-screen-identity/index.mjs.map +2 -2
- package/build-module/components/sidebar-navigation-screen-main/index.mjs.map +2 -2
- package/build-module/components/sidebar-navigation-screen-navigation-menu/delete-confirm-dialog.mjs.map +2 -2
- package/build-module/components/sidebar-navigation-screen-navigation-menu/index.mjs.map +2 -2
- package/build-module/components/sidebar-navigation-screen-navigation-menu/more-menu.mjs.map +2 -2
- package/build-module/components/sidebar-navigation-screen-navigation-menu/navigation-menu-editor.mjs.map +2 -2
- package/build-module/components/sidebar-navigation-screen-navigation-menu/rename-modal.mjs.map +2 -2
- package/build-module/components/sidebar-navigation-screen-navigation-menu/single-navigation-menu.mjs.map +2 -2
- package/build-module/components/sidebar-navigation-screen-navigation-menu/use-navigation-menu-handlers.mjs.map +2 -2
- package/build-module/components/sidebar-navigation-screen-navigation-menus/build-navigation-label.mjs.map +2 -2
- package/build-module/components/sidebar-navigation-screen-navigation-menus/index.mjs.map +2 -2
- package/build-module/components/sidebar-navigation-screen-navigation-menus/leaf-more-menu.mjs +24 -25
- package/build-module/components/sidebar-navigation-screen-navigation-menus/leaf-more-menu.mjs.map +2 -2
- package/build-module/components/sidebar-navigation-screen-navigation-menus/navigation-menu-content.mjs.map +2 -2
- package/build-module/components/sidebar-navigation-screen-patterns/category-item.mjs.map +2 -2
- package/build-module/components/sidebar-navigation-screen-patterns/index.mjs +2 -1
- package/build-module/components/sidebar-navigation-screen-patterns/index.mjs.map +2 -2
- package/build-module/components/sidebar-navigation-screen-patterns/use-default-pattern-categories.mjs.map +2 -2
- package/build-module/components/sidebar-navigation-screen-patterns/use-pattern-categories.mjs.map +2 -2
- package/build-module/components/sidebar-navigation-screen-patterns/use-template-part-areas.mjs.map +2 -2
- package/build-module/components/sidebar-navigation-screen-patterns/use-theme-patterns.mjs.map +2 -2
- package/build-module/components/sidebar-navigation-screen-templates-browse/content-legacy.mjs.map +2 -2
- package/build-module/components/sidebar-navigation-screen-templates-browse/content.mjs +1 -1
- package/build-module/components/sidebar-navigation-screen-templates-browse/content.mjs.map +2 -2
- package/build-module/components/sidebar-navigation-screen-templates-browse/index.mjs.map +2 -2
- package/build-module/components/sidebar-navigation-screen-unsupported/index.mjs.map +2 -2
- package/build-module/components/site-editor-routes/home.mjs.map +2 -2
- package/build-module/components/site-editor-routes/identity.mjs.map +2 -2
- package/build-module/components/site-editor-routes/index.mjs.map +2 -2
- package/build-module/components/site-editor-routes/navigation-item.mjs.map +2 -2
- package/build-module/components/site-editor-routes/navigation.mjs.map +2 -2
- package/build-module/components/site-editor-routes/notfound.mjs.map +2 -2
- package/build-module/components/site-editor-routes/page-item.mjs.map +2 -2
- package/build-module/components/site-editor-routes/pages.mjs.map +2 -2
- package/build-module/components/site-editor-routes/pattern-item.mjs.map +2 -2
- package/build-module/components/site-editor-routes/patterns.mjs.map +2 -2
- package/build-module/components/site-editor-routes/stylebook.mjs.map +2 -2
- package/build-module/components/site-editor-routes/styles.mjs +17 -12
- package/build-module/components/site-editor-routes/styles.mjs.map +2 -2
- package/build-module/components/site-editor-routes/template-item.mjs.map +2 -2
- package/build-module/components/site-editor-routes/template-part-item.mjs.map +2 -2
- package/build-module/components/site-editor-routes/templates.mjs.map +2 -2
- package/build-module/components/site-hub/index.mjs.map +2 -2
- package/build-module/components/welcome-guide/editor.mjs.map +2 -2
- package/build-module/components/welcome-guide/index.mjs.map +2 -2
- package/build-module/components/welcome-guide/page.mjs.map +2 -2
- package/build-module/components/welcome-guide/template.mjs.map +2 -2
- package/build-module/deprecated.mjs.map +2 -2
- package/build-module/hooks/commands/use-common-commands.mjs.map +2 -2
- package/build-module/hooks/commands/use-set-command-context.mjs.map +2 -2
- package/build-module/index.mjs.map +2 -2
- package/build-module/lock-unlock.mjs.map +2 -2
- package/build-module/store/actions.mjs.map +2 -2
- package/build-module/store/index.mjs.map +2 -2
- package/build-module/store/reducer.mjs.map +2 -2
- package/build-module/store/selectors.mjs.map +2 -2
- package/build-module/utils/constants.mjs.map +2 -2
- package/build-module/utils/get-filtered-template-parts.mjs.map +2 -2
- package/build-module/utils/is-previewing-theme.mjs.map +2 -2
- package/build-module/utils/is-template-removable.mjs.map +2 -2
- package/build-module/utils/is-template-revertable.mjs.map +2 -2
- package/build-module/utils/use-activate-theme.mjs.map +2 -2
- package/build-module/utils/use-actual-current-theme.mjs.map +2 -2
- package/build-style/style-rtl.css +79 -22
- package/build-style/style.css +79 -22
- package/package.json +48 -49
- package/src/components/add-new-pattern/index.js +0 -7
- package/src/components/add-new-post/index.js +0 -3
- package/src/components/add-new-template/add-custom-generic-template-modal-content.js +0 -7
- package/src/components/add-new-template/add-custom-template-modal-content.js +0 -7
- package/src/components/add-new-template/index.js +0 -15
- package/src/components/add-new-template/utils.js +0 -7
- package/src/components/add-new-template-legacy/add-custom-generic-template-modal-content.js +0 -7
- package/src/components/add-new-template-legacy/add-custom-template-modal-content.js +0 -7
- package/src/components/add-new-template-legacy/index.js +0 -15
- package/src/components/add-new-template-legacy/utils.js +0 -7
- package/src/components/app/index.js +0 -7
- package/src/components/block-editor/use-editor-iframe-props.js +0 -11
- package/src/components/block-editor/use-navigate-to-entity-record.js +0 -7
- package/src/components/block-editor/use-site-editor-settings.js +0 -7
- package/src/components/block-editor/use-viewport-sync.js +0 -7
- package/src/components/canvas-loader/index.js +6 -17
- package/src/components/canvas-loader/style.scss +3 -4
- package/src/components/dataviews-actions/index.js +0 -7
- package/src/components/editor/index.js +6 -12
- package/src/components/editor/site-preview.js +0 -3
- package/src/components/editor/use-adapt-editor-to-canvas.js +0 -7
- package/src/components/editor/use-editor-title.js +5 -10
- package/src/components/editor/use-resolve-edited-entity.js +0 -7
- package/src/components/editor/use-revisions-url-sync.js +132 -0
- package/src/components/layout/animation.js +0 -7
- package/src/components/layout/hooks.js +0 -3
- package/src/components/layout/index.js +0 -12
- package/src/components/media/index.js +0 -3
- package/src/components/more-menu/index.js +0 -7
- package/src/components/more-menu/site-export.js +0 -3
- package/src/components/more-menu/welcome-guide-menu-item.js +0 -3
- package/src/components/page-patterns/actions.js +0 -7
- package/src/components/page-patterns/delete-category-menu-item.js +0 -7
- package/src/components/page-patterns/fields.js +0 -7
- package/src/components/page-patterns/index.js +0 -7
- package/src/components/page-patterns/rename-category-menu-item.js +0 -10
- package/src/components/page-patterns/search-items.js +0 -12
- package/src/components/page-patterns/style.scss +3 -0
- package/src/components/page-patterns/use-pattern-settings.js +0 -7
- package/src/components/page-patterns/use-patterns.js +0 -7
- package/src/components/page-templates/fields.js +0 -11
- package/src/components/page-templates/hooks.js +0 -7
- package/src/components/page-templates/index-legacy.js +0 -7
- package/src/components/page-templates/index.js +0 -7
- package/src/components/pagination/index.js +0 -7
- package/src/components/plugin-template-setting-panel/index.js +0 -4
- package/src/components/post-list/index.js +0 -9
- package/src/components/post-list/quick-edit-modal.js +0 -7
- package/src/components/post-list/use-notes-count.js +0 -3
- package/src/components/resizable-frame/index.js +0 -11
- package/src/components/routes/use-title.js +0 -7
- package/src/components/save-button/index.js +6 -13
- package/src/components/save-hub/index.js +0 -7
- package/src/components/save-keyboard-shortcut/index.js +0 -7
- package/src/components/save-panel/index.js +9 -18
- package/src/components/sidebar/index.js +0 -7
- package/src/components/sidebar-button/index.js +0 -7
- package/src/components/sidebar-dataviews/index.js +0 -7
- package/src/components/sidebar-global-styles/index.js +0 -7
- package/src/components/sidebar-identity/index.js +3 -3
- package/src/components/sidebar-navigation-item/index.js +0 -11
- package/src/components/sidebar-navigation-item/style.scss +3 -10
- package/src/components/sidebar-navigation-screen/index.js +0 -11
- package/src/components/sidebar-navigation-screen-details-footer/index.js +0 -7
- package/src/components/sidebar-navigation-screen-global-styles/content.js +0 -7
- package/src/components/sidebar-navigation-screen-global-styles/index.js +0 -7
- package/src/components/sidebar-navigation-screen-identity/index.js +0 -7
- package/src/components/sidebar-navigation-screen-main/index.js +0 -7
- package/src/components/sidebar-navigation-screen-navigation-menu/delete-confirm-dialog.js +0 -3
- package/src/components/sidebar-navigation-screen-navigation-menu/index.js +0 -7
- package/src/components/sidebar-navigation-screen-navigation-menu/more-menu.js +0 -7
- package/src/components/sidebar-navigation-screen-navigation-menu/navigation-menu-editor.js +0 -7
- package/src/components/sidebar-navigation-screen-navigation-menu/rename-modal.js +0 -3
- package/src/components/sidebar-navigation-screen-navigation-menu/single-navigation-menu.js +0 -6
- package/src/components/sidebar-navigation-screen-navigation-menu/use-navigation-menu-handlers.js +0 -7
- package/src/components/sidebar-navigation-screen-navigation-menus/build-navigation-label.js +0 -3
- package/src/components/sidebar-navigation-screen-navigation-menus/index.js +0 -8
- package/src/components/sidebar-navigation-screen-navigation-menus/leaf-more-menu.js +38 -48
- package/src/components/sidebar-navigation-screen-navigation-menus/navigation-menu-content.js +0 -7
- package/src/components/sidebar-navigation-screen-patterns/category-item.js +0 -3
- package/src/components/sidebar-navigation-screen-patterns/index.js +2 -8
- package/src/components/sidebar-navigation-screen-patterns/use-default-pattern-categories.js +0 -7
- package/src/components/sidebar-navigation-screen-patterns/use-pattern-categories.js +0 -7
- package/src/components/sidebar-navigation-screen-patterns/use-template-part-areas.js +0 -7
- package/src/components/sidebar-navigation-screen-patterns/use-theme-patterns.js +0 -7
- package/src/components/sidebar-navigation-screen-templates-browse/content-legacy.js +0 -7
- package/src/components/sidebar-navigation-screen-templates-browse/content.js +1 -8
- package/src/components/sidebar-navigation-screen-templates-browse/index.js +0 -7
- package/src/components/sidebar-navigation-screen-unsupported/index.js +0 -3
- package/src/components/site-editor-routes/home.js +0 -3
- package/src/components/site-editor-routes/identity.js +0 -3
- package/src/components/site-editor-routes/index.js +0 -7
- package/src/components/site-editor-routes/navigation-item.js +0 -3
- package/src/components/site-editor-routes/navigation.js +0 -3
- package/src/components/site-editor-routes/notfound.js +0 -7
- package/src/components/site-editor-routes/page-item.js +0 -7
- package/src/components/site-editor-routes/pages.js +0 -7
- package/src/components/site-editor-routes/pattern-item.js +0 -3
- package/src/components/site-editor-routes/patterns.js +0 -3
- package/src/components/site-editor-routes/stylebook.js +0 -7
- package/src/components/site-editor-routes/styles.js +19 -18
- package/src/components/site-editor-routes/template-item.js +0 -3
- package/src/components/site-editor-routes/template-part-item.js +0 -3
- package/src/components/site-editor-routes/templates.js +0 -7
- package/src/components/site-hub/index.js +0 -7
- package/src/components/welcome-guide/editor.js +0 -7
- package/src/components/welcome-guide/index.js +0 -3
- package/src/components/welcome-guide/page.js +0 -3
- package/src/components/welcome-guide/template.js +0 -3
- package/src/deprecated.js +0 -3
- package/src/hooks/commands/use-common-commands.js +0 -7
- package/src/hooks/commands/use-set-command-context.js +0 -7
- package/src/index.js +0 -7
- package/src/lock-unlock.js +0 -3
- package/src/store/actions.js +0 -7
- package/src/store/index.js +0 -7
- package/src/store/reducer.js +0 -3
- package/src/store/selectors.js +0 -7
- package/src/utils/constants.js +0 -7
- package/src/utils/get-filtered-template-parts.js +0 -3
- package/src/utils/is-previewing-theme.js +0 -3
- package/src/utils/is-template-removable.js +0 -3
- package/src/utils/is-template-revertable.js +0 -3
- package/src/utils/test/get-filtered-template-parts.js +0 -3
- package/src/utils/use-activate-theme.js +0 -7
- package/src/utils/use-actual-current-theme.js +0 -3
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../src/components/add-new-template-legacy/utils.js"],
|
|
4
|
-
"sourcesContent": ["/**\n * WordPress dependencies\n */\nimport { useSelect } from '@wordpress/data';\nimport { store as coreStore } from '@wordpress/core-data';\nimport { decodeEntities } from '@wordpress/html-entities';\nimport { useMemo, useCallback } from '@wordpress/element';\nimport { __, _x, sprintf } from '@wordpress/i18n';\nimport { blockMeta, post, archive } from '@wordpress/icons';\nimport { safeDecodeURI } from '@wordpress/url';\n\n/**\n * Internal dependencies\n */\nimport { TEMPLATE_POST_TYPE } from '../../utils/constants';\n\nconst EMPTY_OBJECT = {};\n\n/**\n * @typedef IHasNameAndId\n * @property {string|number} id The entity's id.\n * @property {string} name The entity's name.\n */\n\nconst getValueFromObjectPath = ( object, path ) => {\n\tlet value = object;\n\tpath.split( '.' ).forEach( ( fieldName ) => {\n\t\tvalue = value?.[ fieldName ];\n\t} );\n\treturn value;\n};\n\n/**\n * Helper that adds a prefix to a post slug. The slug needs to be URL-decoded first,\n * so that we have raw Unicode characters there. The server will truncate the slug to\n * 200 characters, respecing Unicode char boundary. On the other hand, the server\n * doesn't detect urlencoded octet boundary and can possibly construct slugs that\n * are not valid urlencoded strings.\n * @param {string} prefix The prefix to add to the slug.\n * @param {string} slug The slug to add the prefix to.\n * @return {string} The slug with the prefix.\n */\nfunction prefixSlug( prefix, slug ) {\n\treturn `${ prefix }-${ safeDecodeURI( slug ) }`;\n}\n\n/**\n * Helper util to map records to add a `name` prop from a\n * provided path, in order to handle all entities in the same\n * fashion(implementing`IHasNameAndId` interface).\n *\n * @param {Object[]} entities The array of entities.\n * @param {string} path The path to map a `name` property from the entity.\n * @return {IHasNameAndId[]} An array of entities that now implement the `IHasNameAndId` interface.\n */\nexport const mapToIHasNameAndId = ( entities, path ) => {\n\treturn ( entities || [] ).map( ( entity ) => ( {\n\t\t...entity,\n\t\tname: decodeEntities( getValueFromObjectPath( entity, path ) ),\n\t} ) );\n};\n\n/**\n * @typedef {Object} EntitiesInfo\n * @property {boolean} hasEntities If an entity has available records(posts, terms, etc..).\n * @property {number[]} existingEntitiesIds An array of the existing entities ids.\n */\n\nexport const useExistingTemplates = () => {\n\treturn useSelect(\n\t\t( select ) =>\n\t\t\tselect( coreStore ).getEntityRecords(\n\t\t\t\t'postType',\n\t\t\t\tTEMPLATE_POST_TYPE,\n\t\t\t\t{\n\t\t\t\t\tper_page: -1,\n\t\t\t\t}\n\t\t\t),\n\t\t[]\n\t);\n};\n\nexport const useDefaultTemplateTypes = () => {\n\treturn useSelect(\n\t\t( select ) =>\n\t\t\tselect( coreStore ).getCurrentTheme()?.default_template_types || [],\n\t\t[]\n\t);\n};\n\nconst usePublicPostTypes = () => {\n\tconst postTypes = useSelect(\n\t\t( select ) => select( coreStore ).getPostTypes( { per_page: -1 } ),\n\t\t[]\n\t);\n\treturn useMemo( () => {\n\t\tconst excludedPostTypes = [ 'attachment' ];\n\t\treturn postTypes\n\t\t\t?.filter(\n\t\t\t\t( { viewable, slug } ) =>\n\t\t\t\t\tviewable && ! excludedPostTypes.includes( slug )\n\t\t\t)\n\t\t\t.sort( ( a, b ) => {\n\t\t\t\t// Sort post types alphabetically by name,\n\t\t\t\t// but exclude the built-in 'post' type from sorting.\n\t\t\t\tif ( a.slug === 'post' || b.slug === 'post' ) {\n\t\t\t\t\treturn 0;\n\t\t\t\t}\n\n\t\t\t\treturn a.name.localeCompare( b.name );\n\t\t\t} );\n\t}, [ postTypes ] );\n};\n\nconst usePublicTaxonomies = () => {\n\tconst taxonomies = useSelect(\n\t\t( select ) => select( coreStore ).getTaxonomies( { per_page: -1 } ),\n\t\t[]\n\t);\n\treturn useMemo( () => {\n\t\treturn taxonomies?.filter(\n\t\t\t( { visibility } ) => visibility?.publicly_queryable\n\t\t);\n\t}, [ taxonomies ] );\n};\n\nexport function usePostTypeArchiveMenuItems() {\n\tconst publicPostTypes = usePublicPostTypes();\n\tconst postTypesWithArchives = useMemo(\n\t\t() => publicPostTypes?.filter( ( postType ) => postType.has_archive ),\n\t\t[ publicPostTypes ]\n\t);\n\tconst existingTemplates = useExistingTemplates();\n\t// We need to keep track of naming conflicts. If a conflict\n\t// occurs, we need to add slug.\n\tconst postTypeLabels = useMemo(\n\t\t() =>\n\t\t\tpublicPostTypes?.reduce( ( accumulator, { labels } ) => {\n\t\t\t\tconst singularName = labels.singular_name.toLowerCase();\n\t\t\t\taccumulator[ singularName ] =\n\t\t\t\t\t( accumulator[ singularName ] || 0 ) + 1;\n\t\t\t\treturn accumulator;\n\t\t\t}, {} ),\n\t\t[ publicPostTypes ]\n\t);\n\tconst needsUniqueIdentifier = useCallback(\n\t\t( { labels, slug } ) => {\n\t\t\tconst singularName = labels.singular_name.toLowerCase();\n\t\t\treturn postTypeLabels[ singularName ] > 1 && singularName !== slug;\n\t\t},\n\t\t[ postTypeLabels ]\n\t);\n\treturn useMemo(\n\t\t() =>\n\t\t\tpostTypesWithArchives\n\t\t\t\t?.filter(\n\t\t\t\t\t( postType ) =>\n\t\t\t\t\t\t! ( existingTemplates || [] ).some(\n\t\t\t\t\t\t\t( existingTemplate ) =>\n\t\t\t\t\t\t\t\texistingTemplate.slug ===\n\t\t\t\t\t\t\t\t'archive-' + postType.slug\n\t\t\t\t\t\t)\n\t\t\t\t)\n\t\t\t\t.map( ( postType ) => {\n\t\t\t\t\tlet title;\n\t\t\t\t\tif ( needsUniqueIdentifier( postType ) ) {\n\t\t\t\t\t\ttitle = sprintf(\n\t\t\t\t\t\t\t// translators: %1s: Name of the post type e.g: \"Post\"; %2s: Slug of the post type e.g: \"book\".\n\t\t\t\t\t\t\t__( 'Archive: %1$s (%2$s)' ),\n\t\t\t\t\t\t\tpostType.labels.singular_name,\n\t\t\t\t\t\t\tpostType.slug\n\t\t\t\t\t\t);\n\t\t\t\t\t} else {\n\t\t\t\t\t\ttitle = sprintf(\n\t\t\t\t\t\t\t// translators: %s: Name of the post type e.g: \"Post\".\n\t\t\t\t\t\t\t__( 'Archive: %s' ),\n\t\t\t\t\t\t\tpostType.labels.singular_name\n\t\t\t\t\t\t);\n\t\t\t\t\t}\n\t\t\t\t\treturn {\n\t\t\t\t\t\tslug: 'archive-' + postType.slug,\n\t\t\t\t\t\tdescription: sprintf(\n\t\t\t\t\t\t\t// translators: %s: Name of the post type e.g: \"Post\".\n\t\t\t\t\t\t\t__(\n\t\t\t\t\t\t\t\t'Displays an archive with the latest posts of type: %s.'\n\t\t\t\t\t\t\t),\n\t\t\t\t\t\t\tpostType.labels.singular_name\n\t\t\t\t\t\t),\n\t\t\t\t\t\ttitle,\n\t\t\t\t\t\t// `icon` is the `menu_icon` property of a post type. We\n\t\t\t\t\t\t// only handle `dashicons` for now, even if the `menu_icon`\n\t\t\t\t\t\t// also supports urls and svg as values.\n\t\t\t\t\t\ticon:\n\t\t\t\t\t\t\ttypeof postType.icon === 'string' &&\n\t\t\t\t\t\t\tpostType.icon.startsWith( 'dashicons-' )\n\t\t\t\t\t\t\t\t? postType.icon.slice( 10 )\n\t\t\t\t\t\t\t\t: archive,\n\t\t\t\t\t\ttemplatePrefix: 'archive',\n\t\t\t\t\t};\n\t\t\t\t} ) || [],\n\t\t[ postTypesWithArchives, existingTemplates, needsUniqueIdentifier ]\n\t);\n}\n\nexport const usePostTypeMenuItems = ( onClickMenuItem ) => {\n\tconst publicPostTypes = usePublicPostTypes();\n\tconst existingTemplates = useExistingTemplates();\n\tconst defaultTemplateTypes = useDefaultTemplateTypes();\n\t// We need to keep track of naming conflicts. If a conflict\n\t// occurs, we need to add slug.\n\tconst templateLabels = useMemo(\n\t\t() =>\n\t\t\tpublicPostTypes?.reduce( ( accumulator, { labels } ) => {\n\t\t\t\tconst templateName = (\n\t\t\t\t\tlabels.template_name || labels.singular_name\n\t\t\t\t).toLowerCase();\n\t\t\t\taccumulator[ templateName ] =\n\t\t\t\t\t( accumulator[ templateName ] || 0 ) + 1;\n\t\t\t\treturn accumulator;\n\t\t\t}, {} ),\n\t\t[ publicPostTypes ]\n\t);\n\tconst needsUniqueIdentifier = useCallback(\n\t\t( { labels, slug } ) => {\n\t\t\tconst templateName = (\n\t\t\t\tlabels.template_name || labels.singular_name\n\t\t\t).toLowerCase();\n\t\t\treturn templateLabels[ templateName ] > 1 && templateName !== slug;\n\t\t},\n\t\t[ templateLabels ]\n\t);\n\n\t// `page`is a special case in template hierarchy.\n\tconst templatePrefixes = useMemo(\n\t\t() =>\n\t\t\tpublicPostTypes?.reduce( ( accumulator, { slug } ) => {\n\t\t\t\tlet suffix = slug;\n\t\t\t\tif ( slug !== 'page' ) {\n\t\t\t\t\tsuffix = `single-${ suffix }`;\n\t\t\t\t}\n\t\t\t\taccumulator[ slug ] = suffix;\n\t\t\t\treturn accumulator;\n\t\t\t}, {} ),\n\t\t[ publicPostTypes ]\n\t);\n\tconst postTypesInfo = useEntitiesInfo( 'postType', templatePrefixes );\n\tconst existingTemplateSlugs = ( existingTemplates || [] ).map(\n\t\t( { slug } ) => slug\n\t);\n\tconst menuItems = ( publicPostTypes || [] ).reduce(\n\t\t( accumulator, postType ) => {\n\t\t\tconst { slug, labels, icon } = postType;\n\t\t\t// We need to check if the general template is part of the\n\t\t\t// defaultTemplateTypes. If it is, just use that info and\n\t\t\t// augment it with the specific template functionality.\n\t\t\tconst generalTemplateSlug = templatePrefixes[ slug ];\n\t\t\tconst defaultTemplateType = defaultTemplateTypes?.find(\n\t\t\t\t( { slug: _slug } ) => _slug === generalTemplateSlug\n\t\t\t);\n\t\t\tconst hasGeneralTemplate =\n\t\t\t\texistingTemplateSlugs?.includes( generalTemplateSlug );\n\t\t\tconst _needsUniqueIdentifier = needsUniqueIdentifier( postType );\n\t\t\tlet menuItemTitle =\n\t\t\t\tlabels.template_name ||\n\t\t\t\tsprintf(\n\t\t\t\t\t// translators: %s: Name of the post type e.g: \"Post\".\n\t\t\t\t\t__( 'Single item: %s' ),\n\t\t\t\t\tlabels.singular_name\n\t\t\t\t);\n\t\t\tif ( _needsUniqueIdentifier ) {\n\t\t\t\tmenuItemTitle = labels.template_name\n\t\t\t\t\t? sprintf(\n\t\t\t\t\t\t\t// translators: 1: Name of the template e.g: \"Single Item: Post\". 2: Slug of the post type e.g: \"book\".\n\t\t\t\t\t\t\t_x( '%1$s (%2$s)', 'post type menu label' ),\n\t\t\t\t\t\t\tlabels.template_name,\n\t\t\t\t\t\t\tslug\n\t\t\t\t\t )\n\t\t\t\t\t: sprintf(\n\t\t\t\t\t\t\t// translators: 1: Name of the post type e.g: \"Post\". 2: Slug of the post type e.g: \"book\".\n\t\t\t\t\t\t\t_x(\n\t\t\t\t\t\t\t\t'Single item: %1$s (%2$s)',\n\t\t\t\t\t\t\t\t'post type menu label'\n\t\t\t\t\t\t\t),\n\t\t\t\t\t\t\tlabels.singular_name,\n\t\t\t\t\t\t\tslug\n\t\t\t\t\t );\n\t\t\t}\n\t\t\tconst menuItem = defaultTemplateType\n\t\t\t\t? {\n\t\t\t\t\t\t...defaultTemplateType,\n\t\t\t\t\t\ttemplatePrefix: templatePrefixes[ slug ],\n\t\t\t\t }\n\t\t\t\t: {\n\t\t\t\t\t\tslug: generalTemplateSlug,\n\t\t\t\t\t\ttitle: menuItemTitle,\n\t\t\t\t\t\tdescription: sprintf(\n\t\t\t\t\t\t\t// translators: %s: Name of the post type e.g: \"Post\".\n\t\t\t\t\t\t\t__( 'Displays a single item: %s.' ),\n\t\t\t\t\t\t\tlabels.singular_name\n\t\t\t\t\t\t),\n\t\t\t\t\t\t// `icon` is the `menu_icon` property of a post type. We\n\t\t\t\t\t\t// only handle `dashicons` for now, even if the `menu_icon`\n\t\t\t\t\t\t// also supports urls and svg as values.\n\t\t\t\t\t\ticon:\n\t\t\t\t\t\t\ttypeof icon === 'string' &&\n\t\t\t\t\t\t\ticon.startsWith( 'dashicons-' )\n\t\t\t\t\t\t\t\t? icon.slice( 10 )\n\t\t\t\t\t\t\t\t: post,\n\t\t\t\t\t\ttemplatePrefix: templatePrefixes[ slug ],\n\t\t\t\t };\n\t\t\tconst hasEntities = postTypesInfo?.[ slug ]?.hasEntities;\n\t\t\t// We have a different template creation flow only if they have entities.\n\t\t\tif ( hasEntities ) {\n\t\t\t\tmenuItem.onClick = ( template ) => {\n\t\t\t\t\tonClickMenuItem( {\n\t\t\t\t\t\ttype: 'postType',\n\t\t\t\t\t\tslug,\n\t\t\t\t\t\tconfig: {\n\t\t\t\t\t\t\trecordNamePath: 'title.rendered',\n\t\t\t\t\t\t\tqueryArgs: ( { search } ) => {\n\t\t\t\t\t\t\t\treturn {\n\t\t\t\t\t\t\t\t\t_fields: 'id,title,slug,link',\n\t\t\t\t\t\t\t\t\torderBy: search ? 'relevance' : 'modified',\n\t\t\t\t\t\t\t\t\texclude:\n\t\t\t\t\t\t\t\t\t\tpostTypesInfo[ slug ]\n\t\t\t\t\t\t\t\t\t\t\t.existingEntitiesIds,\n\t\t\t\t\t\t\t\t};\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\tgetSpecificTemplate: ( suggestion ) => {\n\t\t\t\t\t\t\t\tconst templateSlug = prefixSlug(\n\t\t\t\t\t\t\t\t\ttemplatePrefixes[ slug ],\n\t\t\t\t\t\t\t\t\tsuggestion.slug\n\t\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\t\treturn {\n\t\t\t\t\t\t\t\t\ttitle: templateSlug,\n\t\t\t\t\t\t\t\t\tslug: templateSlug,\n\t\t\t\t\t\t\t\t\ttemplatePrefix: templatePrefixes[ slug ],\n\t\t\t\t\t\t\t\t};\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t},\n\t\t\t\t\t\tlabels,\n\t\t\t\t\t\thasGeneralTemplate,\n\t\t\t\t\t\ttemplate,\n\t\t\t\t\t} );\n\t\t\t\t};\n\t\t\t}\n\t\t\t// We don't need to add the menu item if there are no\n\t\t\t// entities and the general template exists.\n\t\t\tif ( ! hasGeneralTemplate || hasEntities ) {\n\t\t\t\taccumulator.push( menuItem );\n\t\t\t}\n\t\t\treturn accumulator;\n\t\t},\n\t\t[]\n\t);\n\t// Split menu items into two groups: one for the default post types\n\t// and one for the rest.\n\tconst postTypesMenuItems = useMemo(\n\t\t() =>\n\t\t\tmenuItems.reduce(\n\t\t\t\t( accumulator, postType ) => {\n\t\t\t\t\tconst { slug } = postType;\n\t\t\t\t\tlet key = 'postTypesMenuItems';\n\t\t\t\t\tif ( slug === 'page' ) {\n\t\t\t\t\t\tkey = 'defaultPostTypesMenuItems';\n\t\t\t\t\t}\n\t\t\t\t\taccumulator[ key ].push( postType );\n\t\t\t\t\treturn accumulator;\n\t\t\t\t},\n\t\t\t\t{ defaultPostTypesMenuItems: [], postTypesMenuItems: [] }\n\t\t\t),\n\t\t[ menuItems ]\n\t);\n\treturn postTypesMenuItems;\n};\n\nexport const useTaxonomiesMenuItems = ( onClickMenuItem ) => {\n\tconst publicTaxonomies = usePublicTaxonomies();\n\tconst existingTemplates = useExistingTemplates();\n\tconst defaultTemplateTypes = useDefaultTemplateTypes();\n\t// `category` and `post_tag` are special cases in template hierarchy.\n\tconst templatePrefixes = useMemo(\n\t\t() =>\n\t\t\tpublicTaxonomies?.reduce( ( accumulator, { slug } ) => {\n\t\t\t\tlet suffix = slug;\n\t\t\t\tif ( ! [ 'category', 'post_tag' ].includes( slug ) ) {\n\t\t\t\t\tsuffix = `taxonomy-${ suffix }`;\n\t\t\t\t}\n\t\t\t\tif ( slug === 'post_tag' ) {\n\t\t\t\t\tsuffix = `tag`;\n\t\t\t\t}\n\t\t\t\taccumulator[ slug ] = suffix;\n\t\t\t\treturn accumulator;\n\t\t\t}, {} ),\n\t\t[ publicTaxonomies ]\n\t);\n\t// We need to keep track of naming conflicts. If a conflict\n\t// occurs, we need to add slug.\n\tconst taxonomyLabels = publicTaxonomies?.reduce(\n\t\t( accumulator, { labels } ) => {\n\t\t\tconst templateName = (\n\t\t\t\tlabels.template_name || labels.singular_name\n\t\t\t).toLowerCase();\n\t\t\taccumulator[ templateName ] =\n\t\t\t\t( accumulator[ templateName ] || 0 ) + 1;\n\t\t\treturn accumulator;\n\t\t},\n\t\t{}\n\t);\n\tconst needsUniqueIdentifier = ( labels, slug ) => {\n\t\tif ( [ 'category', 'post_tag' ].includes( slug ) ) {\n\t\t\treturn false;\n\t\t}\n\t\tconst templateName = (\n\t\t\tlabels.template_name || labels.singular_name\n\t\t).toLowerCase();\n\t\treturn taxonomyLabels[ templateName ] > 1 && templateName !== slug;\n\t};\n\tconst taxonomiesInfo = useEntitiesInfo( 'taxonomy', templatePrefixes );\n\tconst existingTemplateSlugs = ( existingTemplates || [] ).map(\n\t\t( { slug } ) => slug\n\t);\n\tconst menuItems = ( publicTaxonomies || [] ).reduce(\n\t\t( accumulator, taxonomy ) => {\n\t\t\tconst { slug, labels } = taxonomy;\n\t\t\t// We need to check if the general template is part of the\n\t\t\t// defaultTemplateTypes. If it is, just use that info and\n\t\t\t// augment it with the specific template functionality.\n\t\t\tconst generalTemplateSlug = templatePrefixes[ slug ];\n\t\t\tconst defaultTemplateType = defaultTemplateTypes?.find(\n\t\t\t\t( { slug: _slug } ) => _slug === generalTemplateSlug\n\t\t\t);\n\t\t\tconst hasGeneralTemplate =\n\t\t\t\texistingTemplateSlugs?.includes( generalTemplateSlug );\n\t\t\tconst _needsUniqueIdentifier = needsUniqueIdentifier(\n\t\t\t\tlabels,\n\t\t\t\tslug\n\t\t\t);\n\t\t\tlet menuItemTitle = labels.template_name || labels.singular_name;\n\t\t\tif ( _needsUniqueIdentifier ) {\n\t\t\t\tmenuItemTitle = labels.template_name\n\t\t\t\t\t? sprintf(\n\t\t\t\t\t\t\t// translators: 1: Name of the template e.g: \"Products by Category\". 2: Slug of the taxonomy e.g: \"product_cat\".\n\t\t\t\t\t\t\t_x( '%1$s (%2$s)', 'taxonomy template menu label' ),\n\t\t\t\t\t\t\tlabels.template_name,\n\t\t\t\t\t\t\tslug\n\t\t\t\t\t )\n\t\t\t\t\t: sprintf(\n\t\t\t\t\t\t\t// translators: 1: Name of the taxonomy e.g: \"Category\". 2: Slug of the taxonomy e.g: \"product_cat\".\n\t\t\t\t\t\t\t_x( '%1$s (%2$s)', 'taxonomy menu label' ),\n\t\t\t\t\t\t\tlabels.singular_name,\n\t\t\t\t\t\t\tslug\n\t\t\t\t\t );\n\t\t\t}\n\t\t\tconst menuItem = defaultTemplateType\n\t\t\t\t? {\n\t\t\t\t\t\t...defaultTemplateType,\n\t\t\t\t\t\ttemplatePrefix: templatePrefixes[ slug ],\n\t\t\t\t }\n\t\t\t\t: {\n\t\t\t\t\t\tslug: generalTemplateSlug,\n\t\t\t\t\t\ttitle: menuItemTitle,\n\t\t\t\t\t\tdescription: sprintf(\n\t\t\t\t\t\t\t// translators: %s: Name of the taxonomy e.g: \"Product Categories\".\n\t\t\t\t\t\t\t__( 'Displays taxonomy: %s.' ),\n\t\t\t\t\t\t\tlabels.singular_name\n\t\t\t\t\t\t),\n\t\t\t\t\t\ticon: blockMeta,\n\t\t\t\t\t\ttemplatePrefix: templatePrefixes[ slug ],\n\t\t\t\t };\n\t\t\tconst hasEntities = taxonomiesInfo?.[ slug ]?.hasEntities;\n\t\t\t// We have a different template creation flow only if they have entities.\n\t\t\tif ( hasEntities ) {\n\t\t\t\tmenuItem.onClick = ( template ) => {\n\t\t\t\t\tonClickMenuItem( {\n\t\t\t\t\t\ttype: 'taxonomy',\n\t\t\t\t\t\tslug,\n\t\t\t\t\t\tconfig: {\n\t\t\t\t\t\t\tqueryArgs: ( { search } ) => {\n\t\t\t\t\t\t\t\treturn {\n\t\t\t\t\t\t\t\t\t_fields: 'id,name,slug,link',\n\t\t\t\t\t\t\t\t\torderBy: search ? 'name' : 'count',\n\t\t\t\t\t\t\t\t\texclude:\n\t\t\t\t\t\t\t\t\t\ttaxonomiesInfo[ slug ]\n\t\t\t\t\t\t\t\t\t\t\t.existingEntitiesIds,\n\t\t\t\t\t\t\t\t};\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\tgetSpecificTemplate: ( suggestion ) => {\n\t\t\t\t\t\t\t\tconst templateSlug = prefixSlug(\n\t\t\t\t\t\t\t\t\ttemplatePrefixes[ slug ],\n\t\t\t\t\t\t\t\t\tsuggestion.slug\n\t\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\t\treturn {\n\t\t\t\t\t\t\t\t\ttitle: templateSlug,\n\t\t\t\t\t\t\t\t\tslug: templateSlug,\n\t\t\t\t\t\t\t\t\ttemplatePrefix: templatePrefixes[ slug ],\n\t\t\t\t\t\t\t\t};\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t},\n\t\t\t\t\t\tlabels,\n\t\t\t\t\t\thasGeneralTemplate,\n\t\t\t\t\t\ttemplate,\n\t\t\t\t\t} );\n\t\t\t\t};\n\t\t\t}\n\t\t\t// We don't need to add the menu item if there are no\n\t\t\t// entities and the general template exists.\n\t\t\tif ( ! hasGeneralTemplate || hasEntities ) {\n\t\t\t\taccumulator.push( menuItem );\n\t\t\t}\n\t\t\treturn accumulator;\n\t\t},\n\t\t[]\n\t);\n\t// Split menu items into two groups: one for the default taxonomies\n\t// and one for the rest.\n\tconst taxonomiesMenuItems = useMemo(\n\t\t() =>\n\t\t\tmenuItems.reduce(\n\t\t\t\t( accumulator, taxonomy ) => {\n\t\t\t\t\tconst { slug } = taxonomy;\n\t\t\t\t\tlet key = 'taxonomiesMenuItems';\n\t\t\t\t\tif ( [ 'category', 'tag' ].includes( slug ) ) {\n\t\t\t\t\t\tkey = 'defaultTaxonomiesMenuItems';\n\t\t\t\t\t}\n\t\t\t\t\taccumulator[ key ].push( taxonomy );\n\t\t\t\t\treturn accumulator;\n\t\t\t\t},\n\t\t\t\t{ defaultTaxonomiesMenuItems: [], taxonomiesMenuItems: [] }\n\t\t\t),\n\t\t[ menuItems ]\n\t);\n\treturn taxonomiesMenuItems;\n};\n\nconst USE_AUTHOR_MENU_ITEM_TEMPLATE_PREFIX = { user: 'author' };\nconst USE_AUTHOR_MENU_ITEM_QUERY_PARAMETERS = { user: { who: 'authors' } };\nexport function useAuthorMenuItem( onClickMenuItem ) {\n\tconst existingTemplates = useExistingTemplates();\n\tconst defaultTemplateTypes = useDefaultTemplateTypes();\n\tconst authorInfo = useEntitiesInfo(\n\t\t'root',\n\t\tUSE_AUTHOR_MENU_ITEM_TEMPLATE_PREFIX,\n\t\tUSE_AUTHOR_MENU_ITEM_QUERY_PARAMETERS\n\t);\n\tlet authorMenuItem = defaultTemplateTypes?.find(\n\t\t( { slug } ) => slug === 'author'\n\t);\n\tif ( ! authorMenuItem ) {\n\t\tauthorMenuItem = {\n\t\t\tdescription: __(\n\t\t\t\t'Displays latest posts written by a single author.'\n\t\t\t),\n\t\t\tslug: 'author',\n\t\t\ttitle: 'Author',\n\t\t};\n\t}\n\tconst hasGeneralTemplate = !! existingTemplates?.find(\n\t\t( { slug } ) => slug === 'author'\n\t);\n\tif ( authorInfo.user?.hasEntities ) {\n\t\tauthorMenuItem = { ...authorMenuItem, templatePrefix: 'author' };\n\t\tauthorMenuItem.onClick = ( template ) => {\n\t\t\tonClickMenuItem( {\n\t\t\t\ttype: 'root',\n\t\t\t\tslug: 'user',\n\t\t\t\tconfig: {\n\t\t\t\t\tqueryArgs: ( { search } ) => {\n\t\t\t\t\t\treturn {\n\t\t\t\t\t\t\t_fields: 'id,name,slug,link',\n\t\t\t\t\t\t\torderBy: search ? 'name' : 'registered_date',\n\t\t\t\t\t\t\texclude: authorInfo.user.existingEntitiesIds,\n\t\t\t\t\t\t\twho: 'authors',\n\t\t\t\t\t\t};\n\t\t\t\t\t},\n\t\t\t\t\tgetSpecificTemplate: ( suggestion ) => {\n\t\t\t\t\t\tconst templateSlug = prefixSlug(\n\t\t\t\t\t\t\t'author',\n\t\t\t\t\t\t\tsuggestion.slug\n\t\t\t\t\t\t);\n\t\t\t\t\t\treturn {\n\t\t\t\t\t\t\ttitle: templateSlug,\n\t\t\t\t\t\t\tslug: templateSlug,\n\t\t\t\t\t\t\ttemplatePrefix: 'author',\n\t\t\t\t\t\t};\n\t\t\t\t\t},\n\t\t\t\t},\n\t\t\t\tlabels: {\n\t\t\t\t\tsingular_name: __( 'Author' ),\n\t\t\t\t\tsearch_items: __( 'Search Authors' ),\n\t\t\t\t\tnot_found: __( 'No authors found.' ),\n\t\t\t\t\tall_items: __( 'All Authors' ),\n\t\t\t\t},\n\t\t\t\thasGeneralTemplate,\n\t\t\t\ttemplate,\n\t\t\t} );\n\t\t};\n\t}\n\tif ( ! hasGeneralTemplate || authorInfo.user?.hasEntities ) {\n\t\treturn authorMenuItem;\n\t}\n}\n\n/**\n * Helper hook that filters all the existing templates by the given\n * object with the entity's slug as key and the template prefix as value.\n *\n * Example:\n * `existingTemplates` is: [ { slug: 'tag-apple' }, { slug: 'page-about' }, { slug: 'tag' } ]\n * `templatePrefixes` is: { post_tag: 'tag' }\n * It will return: { post_tag: ['apple'] }\n *\n * Note: We append the `-` to the given template prefix in this function for our checks.\n *\n * @param {Record<string,string>} templatePrefixes An object with the entity's slug as key and the template prefix as value.\n * @return {Record<string,string[]>} An object with the entity's slug as key and an array with the existing template slugs as value.\n */\nconst useExistingTemplateSlugs = ( templatePrefixes ) => {\n\tconst existingTemplates = useExistingTemplates();\n\tconst existingSlugs = useMemo( () => {\n\t\treturn Object.entries( templatePrefixes || {} ).reduce(\n\t\t\t( accumulator, [ slug, prefix ] ) => {\n\t\t\t\tconst slugsWithTemplates = ( existingTemplates || [] ).reduce(\n\t\t\t\t\t( _accumulator, existingTemplate ) => {\n\t\t\t\t\t\tconst _prefix = `${ prefix }-`;\n\t\t\t\t\t\tif ( existingTemplate.slug.startsWith( _prefix ) ) {\n\t\t\t\t\t\t\t_accumulator.push(\n\t\t\t\t\t\t\t\texistingTemplate.slug.substring(\n\t\t\t\t\t\t\t\t\t_prefix.length\n\t\t\t\t\t\t\t\t)\n\t\t\t\t\t\t\t);\n\t\t\t\t\t\t}\n\t\t\t\t\t\treturn _accumulator;\n\t\t\t\t\t},\n\t\t\t\t\t[]\n\t\t\t\t);\n\t\t\t\tif ( slugsWithTemplates.length ) {\n\t\t\t\t\taccumulator[ slug ] = slugsWithTemplates;\n\t\t\t\t}\n\t\t\t\treturn accumulator;\n\t\t\t},\n\t\t\t{}\n\t\t);\n\t}, [ templatePrefixes, existingTemplates ] );\n\treturn existingSlugs;\n};\n\n/**\n * Helper hook that finds the existing records with an associated template,\n * as they need to be excluded from the template suggestions.\n *\n * @param {string} entityName The entity's name.\n * @param {Record<string,string>} templatePrefixes An object with the entity's slug as key and the template prefix as value.\n * @param {Record<string,Object>} additionalQueryParameters An object with the entity's slug as key and additional query parameters as value.\n * @return {Record<string,EntitiesInfo>} An object with the entity's slug as key and the existing records as value.\n */\nconst useTemplatesToExclude = (\n\tentityName,\n\ttemplatePrefixes,\n\tadditionalQueryParameters = {}\n) => {\n\tconst slugsToExcludePerEntity =\n\t\tuseExistingTemplateSlugs( templatePrefixes );\n\tconst recordsToExcludePerEntity = useSelect(\n\t\t( select ) => {\n\t\t\treturn Object.entries( slugsToExcludePerEntity || {} ).reduce(\n\t\t\t\t( accumulator, [ slug, slugsWithTemplates ] ) => {\n\t\t\t\t\tconst entitiesWithTemplates = select(\n\t\t\t\t\t\tcoreStore\n\t\t\t\t\t).getEntityRecords( entityName, slug, {\n\t\t\t\t\t\t_fields: 'id',\n\t\t\t\t\t\tcontext: 'view',\n\t\t\t\t\t\tslug: slugsWithTemplates,\n\t\t\t\t\t\t...additionalQueryParameters[ slug ],\n\t\t\t\t\t} );\n\t\t\t\t\tif ( entitiesWithTemplates?.length ) {\n\t\t\t\t\t\taccumulator[ slug ] = entitiesWithTemplates;\n\t\t\t\t\t}\n\t\t\t\t\treturn accumulator;\n\t\t\t\t},\n\t\t\t\t{}\n\t\t\t);\n\t\t},\n\t\t[ slugsToExcludePerEntity ]\n\t);\n\treturn recordsToExcludePerEntity;\n};\n\n/**\n * Helper hook that returns information about an entity having\n * records that we can create a specific template for.\n *\n * For example we can search for `terms` in `taxonomy` entity or\n * `posts` in `postType` entity.\n *\n * First we need to find the existing records with an associated template,\n * to query afterwards for any remaining record, by excluding them.\n *\n * @param {string} entityName The entity's name.\n * @param {Record<string,string>} templatePrefixes An object with the entity's slug as key and the template prefix as value.\n * @param {Record<string,Object>} additionalQueryParameters An object with the entity's slug as key and additional query parameters as value.\n * @return {Record<string,EntitiesInfo>} An object with the entity's slug as key and the EntitiesInfo as value.\n */\nconst useEntitiesInfo = (\n\tentityName,\n\ttemplatePrefixes,\n\tadditionalQueryParameters = EMPTY_OBJECT\n) => {\n\tconst recordsToExcludePerEntity = useTemplatesToExclude(\n\t\tentityName,\n\t\ttemplatePrefixes,\n\t\tadditionalQueryParameters\n\t);\n\tconst entitiesHasRecords = useSelect(\n\t\t( select ) => {\n\t\t\treturn Object.keys( templatePrefixes || {} ).reduce(\n\t\t\t\t( accumulator, slug ) => {\n\t\t\t\t\tconst existingEntitiesIds =\n\t\t\t\t\t\trecordsToExcludePerEntity?.[ slug ]?.map(\n\t\t\t\t\t\t\t( { id } ) => id\n\t\t\t\t\t\t) || [];\n\t\t\t\t\tconst records = select( coreStore ).getEntityRecords(\n\t\t\t\t\t\tentityName,\n\t\t\t\t\t\tslug,\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tper_page: 1,\n\t\t\t\t\t\t\t_fields: 'id',\n\t\t\t\t\t\t\tcontext: 'view',\n\t\t\t\t\t\t\texclude: existingEntitiesIds,\n\t\t\t\t\t\t\t...additionalQueryParameters[ slug ],\n\t\t\t\t\t\t}\n\t\t\t\t\t);\n\t\t\t\t\taccumulator[ slug ] =\n\t\t\t\t\t\trecords === null || records.length > 0;\n\t\t\t\t\treturn accumulator;\n\t\t\t\t},\n\t\t\t\t{}\n\t\t\t);\n\t\t},\n\t\t[\n\t\t\ttemplatePrefixes,\n\t\t\trecordsToExcludePerEntity,\n\t\t\tentityName,\n\t\t\tadditionalQueryParameters,\n\t\t]\n\t);\n\tconst entitiesInfo = useMemo( () => {\n\t\treturn Object.keys( templatePrefixes || {} ).reduce(\n\t\t\t( accumulator, slug ) => {\n\t\t\t\tconst existingEntitiesIds =\n\t\t\t\t\trecordsToExcludePerEntity?.[ slug ]?.map(\n\t\t\t\t\t\t( { id } ) => id\n\t\t\t\t\t) || [];\n\t\t\t\taccumulator[ slug ] = {\n\t\t\t\t\thasEntities: entitiesHasRecords[ slug ],\n\t\t\t\t\texistingEntitiesIds,\n\t\t\t\t};\n\t\t\t\treturn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AoB,CAAC,CAAE,EAAE;AAAA,QAC5C,CAAE,aAAa,SAAU;AACxB,gBAAM,sBACL,4BAA6B,IAAK,GAAG;AAAA,YACpC,CAAE,EAAE,GAAG,MAAO;AAAA,UACf,KAAK,CAAC;AACP,gBAAM,UAAU,OAAQ,SAAU,EAAE;AAAA,YACnC;AAAA,YACA;AAAA,YACA;AAAA,cACC,UAAU;AAAA,cACV,SAAS;AAAA,cACT,SAAS;AAAA,cACT,SAAS;AAAA,cACT,GAAG,0BAA2B,IAAK;AAAA,YACpC;AAAA,UACD;AACA,sBAAa,IAAK,IACjB,YAAY,QAAQ,QAAQ,SAAS;AACtC,iBAAO;AAAA,QACR;AAAA,QACA,CAAC;AAAA,MACF;AAAA,IACD;AAAA,IACA;AAAA,MACC;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,IACD;AAAA,EACD;AACA,QAAM,eAAe,QAAS,MAAM;AACnC,WAAO,OAAO,KAAM,oBAAoB,CAAC,CAAE,EAAE;AAAA,MAC5C,CAAE,aAAa,SAAU;AACxB,cAAM,sBACL,4BAA6B,IAAK,GAAG;AAAA,UACpC,CAAE,EAAE,GAAG,MAAO;AAAA,QACf,KAAK,CAAC;AACP,oBAAa,IAAK,IAAI;AAAA,UACrB,aAAa,mBAAoB,IAAK;AAAA,UACtC;AAAA,QACD;AACA,eAAO;AAAA,MACR;AAAA,MACA,CAAC;AAAA,IACF;AAAA,EACD,GAAG,CAAE,kBAAkB,2BAA2B,kBAAmB,CAAE;AACvE,SAAO;AACR;",
|
|
4
|
+
"sourcesContent": ["import { useSelect } from '@wordpress/data';\nimport { store as coreStore } from '@wordpress/core-data';\nimport { decodeEntities } from '@wordpress/html-entities';\nimport { useMemo, useCallback } from '@wordpress/element';\nimport { __, _x, sprintf } from '@wordpress/i18n';\nimport { blockMeta, post, archive } from '@wordpress/icons';\nimport { safeDecodeURI } from '@wordpress/url';\nimport { TEMPLATE_POST_TYPE } from '../../utils/constants';\n\nconst EMPTY_OBJECT = {};\n\n/**\n * @typedef IHasNameAndId\n * @property {string|number} id The entity's id.\n * @property {string} name The entity's name.\n */\n\nconst getValueFromObjectPath = ( object, path ) => {\n\tlet value = object;\n\tpath.split( '.' ).forEach( ( fieldName ) => {\n\t\tvalue = value?.[ fieldName ];\n\t} );\n\treturn value;\n};\n\n/**\n * Helper that adds a prefix to a post slug. The slug needs to be URL-decoded first,\n * so that we have raw Unicode characters there. The server will truncate the slug to\n * 200 characters, respecing Unicode char boundary. On the other hand, the server\n * doesn't detect urlencoded octet boundary and can possibly construct slugs that\n * are not valid urlencoded strings.\n * @param {string} prefix The prefix to add to the slug.\n * @param {string} slug The slug to add the prefix to.\n * @return {string} The slug with the prefix.\n */\nfunction prefixSlug( prefix, slug ) {\n\treturn `${ prefix }-${ safeDecodeURI( slug ) }`;\n}\n\n/**\n * Helper util to map records to add a `name` prop from a\n * provided path, in order to handle all entities in the same\n * fashion(implementing`IHasNameAndId` interface).\n *\n * @param {Object[]} entities The array of entities.\n * @param {string} path The path to map a `name` property from the entity.\n * @return {IHasNameAndId[]} An array of entities that now implement the `IHasNameAndId` interface.\n */\nexport const mapToIHasNameAndId = ( entities, path ) => {\n\treturn ( entities || [] ).map( ( entity ) => ( {\n\t\t...entity,\n\t\tname: decodeEntities( getValueFromObjectPath( entity, path ) ),\n\t} ) );\n};\n\n/**\n * @typedef {Object} EntitiesInfo\n * @property {boolean} hasEntities If an entity has available records(posts, terms, etc..).\n * @property {number[]} existingEntitiesIds An array of the existing entities ids.\n */\n\nexport const useExistingTemplates = () => {\n\treturn useSelect(\n\t\t( select ) =>\n\t\t\tselect( coreStore ).getEntityRecords(\n\t\t\t\t'postType',\n\t\t\t\tTEMPLATE_POST_TYPE,\n\t\t\t\t{\n\t\t\t\t\tper_page: -1,\n\t\t\t\t}\n\t\t\t),\n\t\t[]\n\t);\n};\n\nexport const useDefaultTemplateTypes = () => {\n\treturn useSelect(\n\t\t( select ) =>\n\t\t\tselect( coreStore ).getCurrentTheme()?.default_template_types || [],\n\t\t[]\n\t);\n};\n\nconst usePublicPostTypes = () => {\n\tconst postTypes = useSelect(\n\t\t( select ) => select( coreStore ).getPostTypes( { per_page: -1 } ),\n\t\t[]\n\t);\n\treturn useMemo( () => {\n\t\tconst excludedPostTypes = [ 'attachment' ];\n\t\treturn postTypes\n\t\t\t?.filter(\n\t\t\t\t( { viewable, slug } ) =>\n\t\t\t\t\tviewable && ! excludedPostTypes.includes( slug )\n\t\t\t)\n\t\t\t.sort( ( a, b ) => {\n\t\t\t\t// Sort post types alphabetically by name,\n\t\t\t\t// but exclude the built-in 'post' type from sorting.\n\t\t\t\tif ( a.slug === 'post' || b.slug === 'post' ) {\n\t\t\t\t\treturn 0;\n\t\t\t\t}\n\n\t\t\t\treturn a.name.localeCompare( b.name );\n\t\t\t} );\n\t}, [ postTypes ] );\n};\n\nconst usePublicTaxonomies = () => {\n\tconst taxonomies = useSelect(\n\t\t( select ) => select( coreStore ).getTaxonomies( { per_page: -1 } ),\n\t\t[]\n\t);\n\treturn useMemo( () => {\n\t\treturn taxonomies?.filter(\n\t\t\t( { visibility } ) => visibility?.publicly_queryable\n\t\t);\n\t}, [ taxonomies ] );\n};\n\nexport function usePostTypeArchiveMenuItems() {\n\tconst publicPostTypes = usePublicPostTypes();\n\tconst postTypesWithArchives = useMemo(\n\t\t() => publicPostTypes?.filter( ( postType ) => postType.has_archive ),\n\t\t[ publicPostTypes ]\n\t);\n\tconst existingTemplates = useExistingTemplates();\n\t// We need to keep track of naming conflicts. If a conflict\n\t// occurs, we need to add slug.\n\tconst postTypeLabels = useMemo(\n\t\t() =>\n\t\t\tpublicPostTypes?.reduce( ( accumulator, { labels } ) => {\n\t\t\t\tconst singularName = labels.singular_name.toLowerCase();\n\t\t\t\taccumulator[ singularName ] =\n\t\t\t\t\t( accumulator[ singularName ] || 0 ) + 1;\n\t\t\t\treturn accumulator;\n\t\t\t}, {} ),\n\t\t[ publicPostTypes ]\n\t);\n\tconst needsUniqueIdentifier = useCallback(\n\t\t( { labels, slug } ) => {\n\t\t\tconst singularName = labels.singular_name.toLowerCase();\n\t\t\treturn postTypeLabels[ singularName ] > 1 && singularName !== slug;\n\t\t},\n\t\t[ postTypeLabels ]\n\t);\n\treturn useMemo(\n\t\t() =>\n\t\t\tpostTypesWithArchives\n\t\t\t\t?.filter(\n\t\t\t\t\t( postType ) =>\n\t\t\t\t\t\t! ( existingTemplates || [] ).some(\n\t\t\t\t\t\t\t( existingTemplate ) =>\n\t\t\t\t\t\t\t\texistingTemplate.slug ===\n\t\t\t\t\t\t\t\t'archive-' + postType.slug\n\t\t\t\t\t\t)\n\t\t\t\t)\n\t\t\t\t.map( ( postType ) => {\n\t\t\t\t\tlet title;\n\t\t\t\t\tif ( needsUniqueIdentifier( postType ) ) {\n\t\t\t\t\t\ttitle = sprintf(\n\t\t\t\t\t\t\t// translators: %1s: Name of the post type e.g: \"Post\"; %2s: Slug of the post type e.g: \"book\".\n\t\t\t\t\t\t\t__( 'Archive: %1$s (%2$s)' ),\n\t\t\t\t\t\t\tpostType.labels.singular_name,\n\t\t\t\t\t\t\tpostType.slug\n\t\t\t\t\t\t);\n\t\t\t\t\t} else {\n\t\t\t\t\t\ttitle = sprintf(\n\t\t\t\t\t\t\t// translators: %s: Name of the post type e.g: \"Post\".\n\t\t\t\t\t\t\t__( 'Archive: %s' ),\n\t\t\t\t\t\t\tpostType.labels.singular_name\n\t\t\t\t\t\t);\n\t\t\t\t\t}\n\t\t\t\t\treturn {\n\t\t\t\t\t\tslug: 'archive-' + postType.slug,\n\t\t\t\t\t\tdescription: sprintf(\n\t\t\t\t\t\t\t// translators: %s: Name of the post type e.g: \"Post\".\n\t\t\t\t\t\t\t__(\n\t\t\t\t\t\t\t\t'Displays an archive with the latest posts of type: %s.'\n\t\t\t\t\t\t\t),\n\t\t\t\t\t\t\tpostType.labels.singular_name\n\t\t\t\t\t\t),\n\t\t\t\t\t\ttitle,\n\t\t\t\t\t\t// `icon` is the `menu_icon` property of a post type. We\n\t\t\t\t\t\t// only handle `dashicons` for now, even if the `menu_icon`\n\t\t\t\t\t\t// also supports urls and svg as values.\n\t\t\t\t\t\ticon:\n\t\t\t\t\t\t\ttypeof postType.icon === 'string' &&\n\t\t\t\t\t\t\tpostType.icon.startsWith( 'dashicons-' )\n\t\t\t\t\t\t\t\t? postType.icon.slice( 10 )\n\t\t\t\t\t\t\t\t: archive,\n\t\t\t\t\t\ttemplatePrefix: 'archive',\n\t\t\t\t\t};\n\t\t\t\t} ) || [],\n\t\t[ postTypesWithArchives, existingTemplates, needsUniqueIdentifier ]\n\t);\n}\n\nexport const usePostTypeMenuItems = ( onClickMenuItem ) => {\n\tconst publicPostTypes = usePublicPostTypes();\n\tconst existingTemplates = useExistingTemplates();\n\tconst defaultTemplateTypes = useDefaultTemplateTypes();\n\t// We need to keep track of naming conflicts. If a conflict\n\t// occurs, we need to add slug.\n\tconst templateLabels = useMemo(\n\t\t() =>\n\t\t\tpublicPostTypes?.reduce( ( accumulator, { labels } ) => {\n\t\t\t\tconst templateName = (\n\t\t\t\t\tlabels.template_name || labels.singular_name\n\t\t\t\t).toLowerCase();\n\t\t\t\taccumulator[ templateName ] =\n\t\t\t\t\t( accumulator[ templateName ] || 0 ) + 1;\n\t\t\t\treturn accumulator;\n\t\t\t}, {} ),\n\t\t[ publicPostTypes ]\n\t);\n\tconst needsUniqueIdentifier = useCallback(\n\t\t( { labels, slug } ) => {\n\t\t\tconst templateName = (\n\t\t\t\tlabels.template_name || labels.singular_name\n\t\t\t).toLowerCase();\n\t\t\treturn templateLabels[ templateName ] > 1 && templateName !== slug;\n\t\t},\n\t\t[ templateLabels ]\n\t);\n\n\t// `page`is a special case in template hierarchy.\n\tconst templatePrefixes = useMemo(\n\t\t() =>\n\t\t\tpublicPostTypes?.reduce( ( accumulator, { slug } ) => {\n\t\t\t\tlet suffix = slug;\n\t\t\t\tif ( slug !== 'page' ) {\n\t\t\t\t\tsuffix = `single-${ suffix }`;\n\t\t\t\t}\n\t\t\t\taccumulator[ slug ] = suffix;\n\t\t\t\treturn accumulator;\n\t\t\t}, {} ),\n\t\t[ publicPostTypes ]\n\t);\n\tconst postTypesInfo = useEntitiesInfo( 'postType', templatePrefixes );\n\tconst existingTemplateSlugs = ( existingTemplates || [] ).map(\n\t\t( { slug } ) => slug\n\t);\n\tconst menuItems = ( publicPostTypes || [] ).reduce(\n\t\t( accumulator, postType ) => {\n\t\t\tconst { slug, labels, icon } = postType;\n\t\t\t// We need to check if the general template is part of the\n\t\t\t// defaultTemplateTypes. If it is, just use that info and\n\t\t\t// augment it with the specific template functionality.\n\t\t\tconst generalTemplateSlug = templatePrefixes[ slug ];\n\t\t\tconst defaultTemplateType = defaultTemplateTypes?.find(\n\t\t\t\t( { slug: _slug } ) => _slug === generalTemplateSlug\n\t\t\t);\n\t\t\tconst hasGeneralTemplate =\n\t\t\t\texistingTemplateSlugs?.includes( generalTemplateSlug );\n\t\t\tconst _needsUniqueIdentifier = needsUniqueIdentifier( postType );\n\t\t\tlet menuItemTitle =\n\t\t\t\tlabels.template_name ||\n\t\t\t\tsprintf(\n\t\t\t\t\t// translators: %s: Name of the post type e.g: \"Post\".\n\t\t\t\t\t__( 'Single item: %s' ),\n\t\t\t\t\tlabels.singular_name\n\t\t\t\t);\n\t\t\tif ( _needsUniqueIdentifier ) {\n\t\t\t\tmenuItemTitle = labels.template_name\n\t\t\t\t\t? sprintf(\n\t\t\t\t\t\t\t// translators: 1: Name of the template e.g: \"Single Item: Post\". 2: Slug of the post type e.g: \"book\".\n\t\t\t\t\t\t\t_x( '%1$s (%2$s)', 'post type menu label' ),\n\t\t\t\t\t\t\tlabels.template_name,\n\t\t\t\t\t\t\tslug\n\t\t\t\t\t )\n\t\t\t\t\t: sprintf(\n\t\t\t\t\t\t\t// translators: 1: Name of the post type e.g: \"Post\". 2: Slug of the post type e.g: \"book\".\n\t\t\t\t\t\t\t_x(\n\t\t\t\t\t\t\t\t'Single item: %1$s (%2$s)',\n\t\t\t\t\t\t\t\t'post type menu label'\n\t\t\t\t\t\t\t),\n\t\t\t\t\t\t\tlabels.singular_name,\n\t\t\t\t\t\t\tslug\n\t\t\t\t\t );\n\t\t\t}\n\t\t\tconst menuItem = defaultTemplateType\n\t\t\t\t? {\n\t\t\t\t\t\t...defaultTemplateType,\n\t\t\t\t\t\ttemplatePrefix: templatePrefixes[ slug ],\n\t\t\t\t }\n\t\t\t\t: {\n\t\t\t\t\t\tslug: generalTemplateSlug,\n\t\t\t\t\t\ttitle: menuItemTitle,\n\t\t\t\t\t\tdescription: sprintf(\n\t\t\t\t\t\t\t// translators: %s: Name of the post type e.g: \"Post\".\n\t\t\t\t\t\t\t__( 'Displays a single item: %s.' ),\n\t\t\t\t\t\t\tlabels.singular_name\n\t\t\t\t\t\t),\n\t\t\t\t\t\t// `icon` is the `menu_icon` property of a post type. We\n\t\t\t\t\t\t// only handle `dashicons` for now, even if the `menu_icon`\n\t\t\t\t\t\t// also supports urls and svg as values.\n\t\t\t\t\t\ticon:\n\t\t\t\t\t\t\ttypeof icon === 'string' &&\n\t\t\t\t\t\t\ticon.startsWith( 'dashicons-' )\n\t\t\t\t\t\t\t\t? icon.slice( 10 )\n\t\t\t\t\t\t\t\t: post,\n\t\t\t\t\t\ttemplatePrefix: templatePrefixes[ slug ],\n\t\t\t\t };\n\t\t\tconst hasEntities = postTypesInfo?.[ slug ]?.hasEntities;\n\t\t\t// We have a different template creation flow only if they have entities.\n\t\t\tif ( hasEntities ) {\n\t\t\t\tmenuItem.onClick = ( template ) => {\n\t\t\t\t\tonClickMenuItem( {\n\t\t\t\t\t\ttype: 'postType',\n\t\t\t\t\t\tslug,\n\t\t\t\t\t\tconfig: {\n\t\t\t\t\t\t\trecordNamePath: 'title.rendered',\n\t\t\t\t\t\t\tqueryArgs: ( { search } ) => {\n\t\t\t\t\t\t\t\treturn {\n\t\t\t\t\t\t\t\t\t_fields: 'id,title,slug,link',\n\t\t\t\t\t\t\t\t\torderBy: search ? 'relevance' : 'modified',\n\t\t\t\t\t\t\t\t\texclude:\n\t\t\t\t\t\t\t\t\t\tpostTypesInfo[ slug ]\n\t\t\t\t\t\t\t\t\t\t\t.existingEntitiesIds,\n\t\t\t\t\t\t\t\t};\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\tgetSpecificTemplate: ( suggestion ) => {\n\t\t\t\t\t\t\t\tconst templateSlug = prefixSlug(\n\t\t\t\t\t\t\t\t\ttemplatePrefixes[ slug ],\n\t\t\t\t\t\t\t\t\tsuggestion.slug\n\t\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\t\treturn {\n\t\t\t\t\t\t\t\t\ttitle: templateSlug,\n\t\t\t\t\t\t\t\t\tslug: templateSlug,\n\t\t\t\t\t\t\t\t\ttemplatePrefix: templatePrefixes[ slug ],\n\t\t\t\t\t\t\t\t};\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t},\n\t\t\t\t\t\tlabels,\n\t\t\t\t\t\thasGeneralTemplate,\n\t\t\t\t\t\ttemplate,\n\t\t\t\t\t} );\n\t\t\t\t};\n\t\t\t}\n\t\t\t// We don't need to add the menu item if there are no\n\t\t\t// entities and the general template exists.\n\t\t\tif ( ! hasGeneralTemplate || hasEntities ) {\n\t\t\t\taccumulator.push( menuItem );\n\t\t\t}\n\t\t\treturn accumulator;\n\t\t},\n\t\t[]\n\t);\n\t// Split menu items into two groups: one for the default post types\n\t// and one for the rest.\n\tconst postTypesMenuItems = useMemo(\n\t\t() =>\n\t\t\tmenuItems.reduce(\n\t\t\t\t( accumulator, postType ) => {\n\t\t\t\t\tconst { slug } = postType;\n\t\t\t\t\tlet key = 'postTypesMenuItems';\n\t\t\t\t\tif ( slug === 'page' ) {\n\t\t\t\t\t\tkey = 'defaultPostTypesMenuItems';\n\t\t\t\t\t}\n\t\t\t\t\taccumulator[ key ].push( postType );\n\t\t\t\t\treturn accumulator;\n\t\t\t\t},\n\t\t\t\t{ defaultPostTypesMenuItems: [], postTypesMenuItems: [] }\n\t\t\t),\n\t\t[ menuItems ]\n\t);\n\treturn postTypesMenuItems;\n};\n\nexport const useTaxonomiesMenuItems = ( onClickMenuItem ) => {\n\tconst publicTaxonomies = usePublicTaxonomies();\n\tconst existingTemplates = useExistingTemplates();\n\tconst defaultTemplateTypes = useDefaultTemplateTypes();\n\t// `category` and `post_tag` are special cases in template hierarchy.\n\tconst templatePrefixes = useMemo(\n\t\t() =>\n\t\t\tpublicTaxonomies?.reduce( ( accumulator, { slug } ) => {\n\t\t\t\tlet suffix = slug;\n\t\t\t\tif ( ! [ 'category', 'post_tag' ].includes( slug ) ) {\n\t\t\t\t\tsuffix = `taxonomy-${ suffix }`;\n\t\t\t\t}\n\t\t\t\tif ( slug === 'post_tag' ) {\n\t\t\t\t\tsuffix = `tag`;\n\t\t\t\t}\n\t\t\t\taccumulator[ slug ] = suffix;\n\t\t\t\treturn accumulator;\n\t\t\t}, {} ),\n\t\t[ publicTaxonomies ]\n\t);\n\t// We need to keep track of naming conflicts. If a conflict\n\t// occurs, we need to add slug.\n\tconst taxonomyLabels = publicTaxonomies?.reduce(\n\t\t( accumulator, { labels } ) => {\n\t\t\tconst templateName = (\n\t\t\t\tlabels.template_name || labels.singular_name\n\t\t\t).toLowerCase();\n\t\t\taccumulator[ templateName ] =\n\t\t\t\t( accumulator[ templateName ] || 0 ) + 1;\n\t\t\treturn accumulator;\n\t\t},\n\t\t{}\n\t);\n\tconst needsUniqueIdentifier = ( labels, slug ) => {\n\t\tif ( [ 'category', 'post_tag' ].includes( slug ) ) {\n\t\t\treturn false;\n\t\t}\n\t\tconst templateName = (\n\t\t\tlabels.template_name || labels.singular_name\n\t\t).toLowerCase();\n\t\treturn taxonomyLabels[ templateName ] > 1 && templateName !== slug;\n\t};\n\tconst taxonomiesInfo = useEntitiesInfo( 'taxonomy', templatePrefixes );\n\tconst existingTemplateSlugs = ( existingTemplates || [] ).map(\n\t\t( { slug } ) => slug\n\t);\n\tconst menuItems = ( publicTaxonomies || [] ).reduce(\n\t\t( accumulator, taxonomy ) => {\n\t\t\tconst { slug, labels } = taxonomy;\n\t\t\t// We need to check if the general template is part of the\n\t\t\t// defaultTemplateTypes. If it is, just use that info and\n\t\t\t// augment it with the specific template functionality.\n\t\t\tconst generalTemplateSlug = templatePrefixes[ slug ];\n\t\t\tconst defaultTemplateType = defaultTemplateTypes?.find(\n\t\t\t\t( { slug: _slug } ) => _slug === generalTemplateSlug\n\t\t\t);\n\t\t\tconst hasGeneralTemplate =\n\t\t\t\texistingTemplateSlugs?.includes( generalTemplateSlug );\n\t\t\tconst _needsUniqueIdentifier = needsUniqueIdentifier(\n\t\t\t\tlabels,\n\t\t\t\tslug\n\t\t\t);\n\t\t\tlet menuItemTitle = labels.template_name || labels.singular_name;\n\t\t\tif ( _needsUniqueIdentifier ) {\n\t\t\t\tmenuItemTitle = labels.template_name\n\t\t\t\t\t? sprintf(\n\t\t\t\t\t\t\t// translators: 1: Name of the template e.g: \"Products by Category\". 2: Slug of the taxonomy e.g: \"product_cat\".\n\t\t\t\t\t\t\t_x( '%1$s (%2$s)', 'taxonomy template menu label' ),\n\t\t\t\t\t\t\tlabels.template_name,\n\t\t\t\t\t\t\tslug\n\t\t\t\t\t )\n\t\t\t\t\t: sprintf(\n\t\t\t\t\t\t\t// translators: 1: Name of the taxonomy e.g: \"Category\". 2: Slug of the taxonomy e.g: \"product_cat\".\n\t\t\t\t\t\t\t_x( '%1$s (%2$s)', 'taxonomy menu label' ),\n\t\t\t\t\t\t\tlabels.singular_name,\n\t\t\t\t\t\t\tslug\n\t\t\t\t\t );\n\t\t\t}\n\t\t\tconst menuItem = defaultTemplateType\n\t\t\t\t? {\n\t\t\t\t\t\t...defaultTemplateType,\n\t\t\t\t\t\ttemplatePrefix: templatePrefixes[ slug ],\n\t\t\t\t }\n\t\t\t\t: {\n\t\t\t\t\t\tslug: generalTemplateSlug,\n\t\t\t\t\t\ttitle: menuItemTitle,\n\t\t\t\t\t\tdescription: sprintf(\n\t\t\t\t\t\t\t// translators: %s: Name of the taxonomy e.g: \"Product Categories\".\n\t\t\t\t\t\t\t__( 'Displays taxonomy: %s.' ),\n\t\t\t\t\t\t\tlabels.singular_name\n\t\t\t\t\t\t),\n\t\t\t\t\t\ticon: blockMeta,\n\t\t\t\t\t\ttemplatePrefix: templatePrefixes[ slug ],\n\t\t\t\t };\n\t\t\tconst hasEntities = taxonomiesInfo?.[ slug ]?.hasEntities;\n\t\t\t// We have a different template creation flow only if they have entities.\n\t\t\tif ( hasEntities ) {\n\t\t\t\tmenuItem.onClick = ( template ) => {\n\t\t\t\t\tonClickMenuItem( {\n\t\t\t\t\t\ttype: 'taxonomy',\n\t\t\t\t\t\tslug,\n\t\t\t\t\t\tconfig: {\n\t\t\t\t\t\t\tqueryArgs: ( { search } ) => {\n\t\t\t\t\t\t\t\treturn {\n\t\t\t\t\t\t\t\t\t_fields: 'id,name,slug,link',\n\t\t\t\t\t\t\t\t\torderBy: search ? 'name' : 'count',\n\t\t\t\t\t\t\t\t\texclude:\n\t\t\t\t\t\t\t\t\t\ttaxonomiesInfo[ slug ]\n\t\t\t\t\t\t\t\t\t\t\t.existingEntitiesIds,\n\t\t\t\t\t\t\t\t};\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\tgetSpecificTemplate: ( suggestion ) => {\n\t\t\t\t\t\t\t\tconst templateSlug = prefixSlug(\n\t\t\t\t\t\t\t\t\ttemplatePrefixes[ slug ],\n\t\t\t\t\t\t\t\t\tsuggestion.slug\n\t\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\t\treturn {\n\t\t\t\t\t\t\t\t\ttitle: templateSlug,\n\t\t\t\t\t\t\t\t\tslug: templateSlug,\n\t\t\t\t\t\t\t\t\ttemplatePrefix: templatePrefixes[ slug ],\n\t\t\t\t\t\t\t\t};\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t},\n\t\t\t\t\t\tlabels,\n\t\t\t\t\t\thasGeneralTemplate,\n\t\t\t\t\t\ttemplate,\n\t\t\t\t\t} );\n\t\t\t\t};\n\t\t\t}\n\t\t\t// We don't need to add the menu item if there are no\n\t\t\t// entities and the general template exists.\n\t\t\tif ( ! hasGeneralTemplate || hasEntities ) {\n\t\t\t\taccumulator.push( menuItem );\n\t\t\t}\n\t\t\treturn accumulator;\n\t\t},\n\t\t[]\n\t);\n\t// Split menu items into two groups: one for the default taxonomies\n\t// and one for the rest.\n\tconst taxonomiesMenuItems = useMemo(\n\t\t() =>\n\t\t\tmenuItems.reduce(\n\t\t\t\t( accumulator, taxonomy ) => {\n\t\t\t\t\tconst { slug } = taxonomy;\n\t\t\t\t\tlet key = 'taxonomiesMenuItems';\n\t\t\t\t\tif ( [ 'category', 'tag' ].includes( slug ) ) {\n\t\t\t\t\t\tkey = 'defaultTaxonomiesMenuItems';\n\t\t\t\t\t}\n\t\t\t\t\taccumulator[ key ].push( taxonomy );\n\t\t\t\t\treturn accumulator;\n\t\t\t\t},\n\t\t\t\t{ defaultTaxonomiesMenuItems: [], taxonomiesMenuItems: [] }\n\t\t\t),\n\t\t[ menuItems ]\n\t);\n\treturn taxonomiesMenuItems;\n};\n\nconst USE_AUTHOR_MENU_ITEM_TEMPLATE_PREFIX = { user: 'author' };\nconst USE_AUTHOR_MENU_ITEM_QUERY_PARAMETERS = { user: { who: 'authors' } };\nexport function useAuthorMenuItem( onClickMenuItem ) {\n\tconst existingTemplates = useExistingTemplates();\n\tconst defaultTemplateTypes = useDefaultTemplateTypes();\n\tconst authorInfo = useEntitiesInfo(\n\t\t'root',\n\t\tUSE_AUTHOR_MENU_ITEM_TEMPLATE_PREFIX,\n\t\tUSE_AUTHOR_MENU_ITEM_QUERY_PARAMETERS\n\t);\n\tlet authorMenuItem = defaultTemplateTypes?.find(\n\t\t( { slug } ) => slug === 'author'\n\t);\n\tif ( ! authorMenuItem ) {\n\t\tauthorMenuItem = {\n\t\t\tdescription: __(\n\t\t\t\t'Displays latest posts written by a single author.'\n\t\t\t),\n\t\t\tslug: 'author',\n\t\t\ttitle: 'Author',\n\t\t};\n\t}\n\tconst hasGeneralTemplate = !! existingTemplates?.find(\n\t\t( { slug } ) => slug === 'author'\n\t);\n\tif ( authorInfo.user?.hasEntities ) {\n\t\tauthorMenuItem = { ...authorMenuItem, templatePrefix: 'author' };\n\t\tauthorMenuItem.onClick = ( template ) => {\n\t\t\tonClickMenuItem( {\n\t\t\t\ttype: 'root',\n\t\t\t\tslug: 'user',\n\t\t\t\tconfig: {\n\t\t\t\t\tqueryArgs: ( { search } ) => {\n\t\t\t\t\t\treturn {\n\t\t\t\t\t\t\t_fields: 'id,name,slug,link',\n\t\t\t\t\t\t\torderBy: search ? 'name' : 'registered_date',\n\t\t\t\t\t\t\texclude: authorInfo.user.existingEntitiesIds,\n\t\t\t\t\t\t\twho: 'authors',\n\t\t\t\t\t\t};\n\t\t\t\t\t},\n\t\t\t\t\tgetSpecificTemplate: ( suggestion ) => {\n\t\t\t\t\t\tconst templateSlug = prefixSlug(\n\t\t\t\t\t\t\t'author',\n\t\t\t\t\t\t\tsuggestion.slug\n\t\t\t\t\t\t);\n\t\t\t\t\t\treturn {\n\t\t\t\t\t\t\ttitle: templateSlug,\n\t\t\t\t\t\t\tslug: templateSlug,\n\t\t\t\t\t\t\ttemplatePrefix: 'author',\n\t\t\t\t\t\t};\n\t\t\t\t\t},\n\t\t\t\t},\n\t\t\t\tlabels: {\n\t\t\t\t\tsingular_name: __( 'Author' ),\n\t\t\t\t\tsearch_items: __( 'Search Authors' ),\n\t\t\t\t\tnot_found: __( 'No authors found.' ),\n\t\t\t\t\tall_items: __( 'All Authors' ),\n\t\t\t\t},\n\t\t\t\thasGeneralTemplate,\n\t\t\t\ttemplate,\n\t\t\t} );\n\t\t};\n\t}\n\tif ( ! hasGeneralTemplate || authorInfo.user?.hasEntities ) {\n\t\treturn authorMenuItem;\n\t}\n}\n\n/**\n * Helper hook that filters all the existing templates by the given\n * object with the entity's slug as key and the template prefix as value.\n *\n * Example:\n * `existingTemplates` is: [ { slug: 'tag-apple' }, { slug: 'page-about' }, { slug: 'tag' } ]\n * `templatePrefixes` is: { post_tag: 'tag' }\n * It will return: { post_tag: ['apple'] }\n *\n * Note: We append the `-` to the given template prefix in this function for our checks.\n *\n * @param {Record<string,string>} templatePrefixes An object with the entity's slug as key and the template prefix as value.\n * @return {Record<string,string[]>} An object with the entity's slug as key and an array with the existing template slugs as value.\n */\nconst useExistingTemplateSlugs = ( templatePrefixes ) => {\n\tconst existingTemplates = useExistingTemplates();\n\tconst existingSlugs = useMemo( () => {\n\t\treturn Object.entries( templatePrefixes || {} ).reduce(\n\t\t\t( accumulator, [ slug, prefix ] ) => {\n\t\t\t\tconst slugsWithTemplates = ( existingTemplates || [] ).reduce(\n\t\t\t\t\t( _accumulator, existingTemplate ) => {\n\t\t\t\t\t\tconst _prefix = `${ prefix }-`;\n\t\t\t\t\t\tif ( existingTemplate.slug.startsWith( _prefix ) ) {\n\t\t\t\t\t\t\t_accumulator.push(\n\t\t\t\t\t\t\t\texistingTemplate.slug.substring(\n\t\t\t\t\t\t\t\t\t_prefix.length\n\t\t\t\t\t\t\t\t)\n\t\t\t\t\t\t\t);\n\t\t\t\t\t\t}\n\t\t\t\t\t\treturn _accumulator;\n\t\t\t\t\t},\n\t\t\t\t\t[]\n\t\t\t\t);\n\t\t\t\tif ( slugsWithTemplates.length ) {\n\t\t\t\t\taccumulator[ slug ] = slugsWithTemplates;\n\t\t\t\t}\n\t\t\t\treturn accumulator;\n\t\t\t},\n\t\t\t{}\n\t\t);\n\t}, [ templatePrefixes, existingTemplates ] );\n\treturn existingSlugs;\n};\n\n/**\n * Helper hook that finds the existing records with an associated template,\n * as they need to be excluded from the template suggestions.\n *\n * @param {string} entityName The entity's name.\n * @param {Record<string,string>} templatePrefixes An object with the entity's slug as key and the template prefix as value.\n * @param {Record<string,Object>} additionalQueryParameters An object with the entity's slug as key and additional query parameters as value.\n * @return {Record<string,EntitiesInfo>} An object with the entity's slug as key and the existing records as value.\n */\nconst useTemplatesToExclude = (\n\tentityName,\n\ttemplatePrefixes,\n\tadditionalQueryParameters = {}\n) => {\n\tconst slugsToExcludePerEntity =\n\t\tuseExistingTemplateSlugs( templatePrefixes );\n\tconst recordsToExcludePerEntity = useSelect(\n\t\t( select ) => {\n\t\t\treturn Object.entries( slugsToExcludePerEntity || {} ).reduce(\n\t\t\t\t( accumulator, [ slug, slugsWithTemplates ] ) => {\n\t\t\t\t\tconst entitiesWithTemplates = select(\n\t\t\t\t\t\tcoreStore\n\t\t\t\t\t).getEntityRecords( entityName, slug, {\n\t\t\t\t\t\t_fields: 'id',\n\t\t\t\t\t\tcontext: 'view',\n\t\t\t\t\t\tslug: slugsWithTemplates,\n\t\t\t\t\t\t...additionalQueryParameters[ slug ],\n\t\t\t\t\t} );\n\t\t\t\t\tif ( entitiesWithTemplates?.length ) {\n\t\t\t\t\t\taccumulator[ slug ] = entitiesWithTemplates;\n\t\t\t\t\t}\n\t\t\t\t\treturn accumulator;\n\t\t\t\t},\n\t\t\t\t{}\n\t\t\t);\n\t\t},\n\t\t[ slugsToExcludePerEntity ]\n\t);\n\treturn recordsToExcludePerEntity;\n};\n\n/**\n * Helper hook that returns information about an entity having\n * records that we can create a specific template for.\n *\n * For example we can search for `terms` in `taxonomy` entity or\n * `posts` in `postType` entity.\n *\n * First we need to find the existing records with an associated template,\n * to query afterwards for any remaining record, by excluding them.\n *\n * @param {string} entityName The entity's name.\n * @param {Record<string,string>} templatePrefixes An object with the entity's slug as key and the template prefix as value.\n * @param {Record<string,Object>} additionalQueryParameters An object with the entity's slug as key and additional query parameters as value.\n * @return {Record<string,EntitiesInfo>} An object with the entity's slug as key and the EntitiesInfo as value.\n */\nconst useEntitiesInfo = (\n\tentityName,\n\ttemplatePrefixes,\n\tadditionalQueryParameters = EMPTY_OBJECT\n) => {\n\tconst recordsToExcludePerEntity = useTemplatesToExclude(\n\t\tentityName,\n\t\ttemplatePrefixes,\n\t\tadditionalQueryParameters\n\t);\n\tconst entitiesHasRecords = useSelect(\n\t\t( select ) => {\n\t\t\treturn Object.keys( templatePrefixes || {} ).reduce(\n\t\t\t\t( accumulator, slug ) => {\n\t\t\t\t\tconst existingEntitiesIds =\n\t\t\t\t\t\trecordsToExcludePerEntity?.[ slug ]?.map(\n\t\t\t\t\t\t\t( { id } ) => id\n\t\t\t\t\t\t) || [];\n\t\t\t\t\tconst records = select( coreStore ).getEntityRecords(\n\t\t\t\t\t\tentityName,\n\t\t\t\t\t\tslug,\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tper_page: 1,\n\t\t\t\t\t\t\t_fields: 'id',\n\t\t\t\t\t\t\tcontext: 'view',\n\t\t\t\t\t\t\texclude: existingEntitiesIds,\n\t\t\t\t\t\t\t...additionalQueryParameters[ slug ],\n\t\t\t\t\t\t}\n\t\t\t\t\t);\n\t\t\t\t\taccumulator[ slug ] =\n\t\t\t\t\t\trecords === null || records.length > 0;\n\t\t\t\t\treturn accumulator;\n\t\t\t\t},\n\t\t\t\t{}\n\t\t\t);\n\t\t},\n\t\t[\n\t\t\ttemplatePrefixes,\n\t\t\trecordsToExcludePerEntity,\n\t\t\tentityName,\n\t\t\tadditionalQueryParameters,\n\t\t]\n\t);\n\tconst entitiesInfo = useMemo( () => {\n\t\treturn Object.keys( templatePrefixes || {} ).reduce(\n\t\t\t( accumulator, slug ) => {\n\t\t\t\tconst existingEntitiesIds =\n\t\t\t\t\trecordsToExcludePerEntity?.[ slug ]?.map(\n\t\t\t\t\t\t( { id } ) => id\n\t\t\t\t\t) || [];\n\t\t\t\taccumulator[ slug ] = {\n\t\t\t\t\thasEntities: entitiesHasRecords[ slug ],\n\t\t\t\t\texistingEntitiesIds,\n\t\t\t\t};\n\t\t\t\treturn accumulator;\n\t\t\t},\n\t\t\t{}\n\t\t);\n\t}, [ templatePrefixes, recordsToExcludePerEntity, entitiesHasRecords ] );\n\treturn entitiesInfo;\n};\n"],
|
|
5
|
+
"mappings": ";AAAA,SAAS,iBAAiB;AAC1B,SAAS,SAAS,iBAAiB;AACnC,SAAS,sBAAsB;AAC/B,SAAS,SAAS,mBAAmB;AACrC,S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AU;AAAA,cACV,SAAS;AAAA,cACT,SAAS;AAAA,cACT,SAAS;AAAA,cACT,GAAG,0BAA2B,IAAK;AAAA,YACpC;AAAA,UACD;AACA,sBAAa,IAAK,IACjB,YAAY,QAAQ,QAAQ,SAAS;AACtC,iBAAO;AAAA,QACR;AAAA,QACA,CAAC;AAAA,MACF;AAAA,IACD;AAAA,IACA;AAAA,MACC;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,IACD;AAAA,EACD;AACA,QAAM,eAAe,QAAS,MAAM;AACnC,WAAO,OAAO,KAAM,oBAAoB,CAAC,CAAE,EAAE;AAAA,MAC5C,CAAE,aAAa,SAAU;AACxB,cAAM,sBACL,4BAA6B,IAAK,GAAG;AAAA,UACpC,CAAE,EAAE,GAAG,MAAO;AAAA,QACf,KAAK,CAAC;AACP,oBAAa,IAAK,IAAI;AAAA,UACrB,aAAa,mBAAoB,IAAK;AAAA,UACtC;AAAA,QACD;AACA,eAAO;AAAA,MACR;AAAA,MACA,CAAC;AAAA,IACF;AAAA,EACD,GAAG,CAAE,kBAAkB,2BAA2B,kBAAmB,CAAE;AACvE,SAAO;AACR;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../src/components/app/index.js"],
|
|
4
|
-
"sourcesContent": ["
|
|
5
|
-
"mappings": ";
|
|
4
|
+
"sourcesContent": ["import { useSelect } from '@wordpress/data';\nimport { privateApis as routerPrivateApis } from '@wordpress/router';\nimport { useCallback, useMemo } from '@wordpress/element';\nimport { store as coreStore } from '@wordpress/core-data';\nimport Layout from '../layout';\nimport { unlock } from '../../lock-unlock';\nimport { store as editSiteStore } from '../../store';\nimport { useCommonCommands } from '../../hooks/commands/use-common-commands';\nimport useSetCommandContext from '../../hooks/commands/use-set-command-context';\nimport { useRegisterSiteEditorRoutes } from '../site-editor-routes';\nimport {\n\tcurrentlyPreviewingTheme,\n\tisPreviewingTheme,\n} from '../../utils/is-previewing-theme';\n\nconst { RouterProvider } = unlock( routerPrivateApis );\n\nfunction AppLayout() {\n\tuseCommonCommands();\n\tuseSetCommandContext();\n\n\treturn <Layout />;\n}\n\nexport default function App() {\n\tuseRegisterSiteEditorRoutes();\n\tconst { routes, currentTheme, editorSettings } = useSelect( ( select ) => {\n\t\treturn {\n\t\t\troutes: unlock( select( editSiteStore ) ).getRoutes(),\n\t\t\tcurrentTheme: select( coreStore ).getCurrentTheme(),\n\t\t\t// This is a temp solution until the has_theme_json value is available for the current theme.\n\t\t\teditorSettings: select( editSiteStore ).getSettings(),\n\t\t};\n\t}, [] );\n\n\tconst beforeNavigate = useCallback( ( { path, query } ) => {\n\t\tif ( ! isPreviewingTheme() ) {\n\t\t\treturn { path, query };\n\t\t}\n\n\t\treturn {\n\t\t\tpath,\n\t\t\tquery: {\n\t\t\t\t...query,\n\t\t\t\twp_theme_preview:\n\t\t\t\t\t'wp_theme_preview' in query\n\t\t\t\t\t\t? query.wp_theme_preview\n\t\t\t\t\t\t: currentlyPreviewingTheme(),\n\t\t\t},\n\t\t};\n\t}, [] );\n\n\tconst matchResolverArgsValue = useMemo(\n\t\t() => ( {\n\t\t\tsiteData: { currentTheme, editorSettings },\n\t\t} ),\n\t\t[ currentTheme, editorSettings ]\n\t);\n\n\treturn (\n\t\t<RouterProvider\n\t\t\troutes={ routes }\n\t\t\tpathArg=\"p\"\n\t\t\tbeforeNavigate={ beforeNavigate }\n\t\t\tmatchResolverArgs={ matchResolverArgsValue }\n\t\t>\n\t\t\t<AppLayout />\n\t\t</RouterProvider>\n\t);\n}\n"],
|
|
5
|
+
"mappings": ";AAAA,SAAS,iBAAiB;AAC1B,SAAS,eAAe,yBAAyB;AACjD,SAAS,aAAa,eAAe;AACrC,SAAS,SAAS,iBAAiB;AACnC,OAAO,YAAY;AACnB,SAAS,cAAc;AACvB,SAAS,SAAS,qBAAqB;AACvC,SAAS,yBAAyB;AAClC,OAAO,0BAA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
|
|
5
|
-
"mappings": ";
|
|
4
|
+
"sourcesContent": ["import clsx from 'clsx';\nimport { useSelect } from '@wordpress/data';\nimport { ENTER, SPACE } from '@wordpress/keycodes';\nimport { useState, useEffect } from '@wordpress/element';\nimport { __ } from '@wordpress/i18n';\nimport { store as editorStore } from '@wordpress/editor';\nimport { privateApis as routerPrivateApis } from '@wordpress/router';\nimport { addQueryArgs } from '@wordpress/url';\nimport { unlock } from '../../lock-unlock';\n\nconst { useLocation, useHistory } = unlock( routerPrivateApis );\n\nexport default function useEditorIframeProps() {\n\tconst { query, path } = useLocation();\n\tconst history = useHistory();\n\tconst { canvas = 'view' } = query;\n\tconst currentPostIsTrashed = useSelect( ( select ) => {\n\t\treturn (\n\t\t\tselect( editorStore ).getCurrentPostAttribute( 'status' ) ===\n\t\t\t'trash'\n\t\t);\n\t}, [] );\n\tconst [ isFocused, setIsFocused ] = useState( false );\n\n\tuseEffect( () => {\n\t\tif ( canvas === 'edit' ) {\n\t\t\tsetIsFocused( false );\n\t\t}\n\t}, [ canvas ] );\n\n\t// In view mode, make the canvas iframe be perceived and behave as a button\n\t// to switch to edit mode, with a meaningful label and no title attribute.\n\tconst viewModeIframeProps = {\n\t\t'aria-label': __( 'Edit' ),\n\t\t'aria-disabled': currentPostIsTrashed,\n\t\ttitle: null,\n\t\trole: 'button',\n\t\ttabIndex: 0,\n\t\tonFocus: () => setIsFocused( true ),\n\t\tonBlur: () => setIsFocused( false ),\n\t\tonKeyDown: ( event ) => {\n\t\t\tconst { keyCode } = event;\n\t\t\tif (\n\t\t\t\t( keyCode === ENTER || keyCode === SPACE ) &&\n\t\t\t\t! currentPostIsTrashed\n\t\t\t) {\n\t\t\t\tevent.preventDefault();\n\t\t\t\thistory.navigate( addQueryArgs( path, { canvas: 'edit' } ), {\n\t\t\t\t\ttransition: 'canvas-mode-edit-transition',\n\t\t\t\t} );\n\t\t\t}\n\t\t},\n\t\tonClick: () =>\n\t\t\thistory.navigate( addQueryArgs( path, { canvas: 'edit' } ), {\n\t\t\t\ttransition: 'canvas-mode-edit-transition',\n\t\t\t} ),\n\t\tonClickCapture: ( event ) => {\n\t\t\tif ( currentPostIsTrashed ) {\n\t\t\t\tevent.preventDefault();\n\t\t\t\tevent.stopPropagation();\n\t\t\t}\n\t\t},\n\t\treadonly: true,\n\t};\n\n\treturn {\n\t\tclassName: clsx( 'edit-site-visual-editor__editor-canvas', {\n\t\t\t'is-focused': isFocused && canvas === 'view',\n\t\t} ),\n\t\t...( canvas === 'view' ? viewModeIframeProps : {} ),\n\t};\n}\n"],
|
|
5
|
+
"mappings": ";AAAA,OAAO,UAAU;AACjB,SAAS,iBAAiB;AAC1B,SAAS,OAAO,aAAa;AAC7B,SAAS,UAAU,iBAAiB;AACpC,SAAS,UAAU;AACnB,SAAS,SAAS,mBAAmB;AACrC,SAAS,eAAe,yBAAyB;AACjD,SAAS,oBAAoB;AAC7B,SAAS,cAAc;AAEvB,IAAM,EAAE,aAAa,WAAW,IAAI,OAAQ,iBAAkB;AAE/C,SAAR,uBAAwC;AAC9C,QAAM,EAAE,OAAO,KAAK,IAAI,YAAY;AACpC,QAAM,UAAU,WAAW;AAC3B,QAAM,EAAE,SAAS,OAAO,IAAI;AAC5B,QAAM,uBAAuB,UAAW,CAAE,WAAY;AACrD,WACC,OAAQ,WAAY,EAAE,wBAAyB,QAAS,MACxD;AAAA,EAEF,GAAG,CAAC,CAAE;AACN,QAAM,CAAE,WAAW,YAAa,IAAI,SAAU,KAAM;AAEpD,YAAW,MAAM;AAChB,QAAK,WAAW,QAAS;AACxB,mBAAc,KAAM;AAAA,IACrB;AAAA,EACD,GAAG,CAAE,MAAO,CAAE;AAId,QAAM,sBAAsB;AAAA,IAC3B,cAAc,GAAI,MAAO;AAAA,IACzB,iBAAiB;AAAA,IACjB,OAAO;AAAA,IACP,MAAM;AAAA,IACN,UAAU;AAAA,IACV,SAAS,MAAM,aAAc,IAAK;AAAA,IAClC,QAAQ,MAAM,aAAc,KAAM;AAAA,IAClC,WAAW,CAAE,UAAW;AACvB,YAAM,EAAE,QAAQ,IAAI;AACpB,WACG,YAAY,SAAS,YAAY,UACnC,CAAE,sBACD;AACD,cAAM,eAAe;AACrB,gBAAQ,SAAU,aAAc,MAAM,EAAE,QAAQ,OAAO,CAAE,GAAG;AAAA,UAC3D,YAAY;AAAA,QACb,CAAE;AAAA,MACH;AAAA,IACD;AAAA,IACA,SAAS,MACR,QAAQ,SAAU,aAAc,MAAM,EAAE,QAAQ,OAAO,CAAE,GAAG;AAAA,MAC3D,YAAY;AAAA,IACb,CAAE;AAAA,IACH,gBAAgB,CAAE,UAAW;AAC5B,UAAK,sBAAuB;AAC3B,cAAM,eAAe;AACrB,cAAM,gBAAgB;AAAA,MACvB;AAAA,IACD;AAAA,IACA,UAAU;AAAA,EACX;AAEA,SAAO;AAAA,IACN,WAAW,KAAM,0CAA0C;AAAA,MAC1D,cAAc,aAAa,WAAW;AAAA,IACvC,CAAE;AAAA,IACF,GAAK,WAAW,SAAS,sBAAsB,CAAC;AAAA,EACjD;AACD;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../src/components/block-editor/use-navigate-to-entity-record.js"],
|
|
4
|
-
"sourcesContent": ["
|
|
5
|
-
"mappings": ";
|
|
4
|
+
"sourcesContent": ["import { useSelect, useRegistry } from '@wordpress/data';\nimport { privateApis as routerPrivateApis } from '@wordpress/router';\nimport { useCallback } from '@wordpress/element';\nimport { addQueryArgs } from '@wordpress/url';\nimport { store as coreStore } from '@wordpress/core-data';\nimport { store as editorStore } from '@wordpress/editor';\nimport { unlock } from '../../lock-unlock';\nimport { DEFAULT_DEVICE_TYPE } from './use-viewport-sync';\n\nconst { useHistory, useLocation } = unlock( routerPrivateApis );\n\nconst VALID_VIEWPORTS = [ 'desktop', 'tablet', 'mobile' ];\n/**\n * Hook to handle navigation to entity records.\n *\n * @return {Function} Function to navigate to an entity record.\n */\nexport default function useNavigateToEntityRecord() {\n\tconst history = useHistory();\n\tconst location = useLocation();\n\tconst { query, path } = location;\n\tconst registry = useRegistry();\n\tconst currentDeviceType = useSelect(\n\t\t( select ) => select( editorStore ).getDeviceType(),\n\t\t[]\n\t);\n\n\tconst onNavigateToEntityRecord = useCallback(\n\t\t( params ) => {\n\t\t\t// Read entity selection (already has external IDs from onChangeSelection)\n\t\t\tconst currentPostType = registry\n\t\t\t\t.select( editorStore )\n\t\t\t\t.getCurrentPostType();\n\t\t\tconst currentPostId = registry\n\t\t\t\t.select( editorStore )\n\t\t\t\t.getCurrentPostId();\n\t\t\tconst entityEdits = registry\n\t\t\t\t.select( coreStore )\n\t\t\t\t.getEntityRecordEdits(\n\t\t\t\t\t'postType',\n\t\t\t\t\tcurrentPostType,\n\t\t\t\t\tcurrentPostId\n\t\t\t\t);\n\t\t\tconst externalClientId =\n\t\t\t\tentityEdits?.selection?.selectionStart?.clientId;\n\n\t\t\tconst urlUpdates = { ...query };\n\n\t\t\t// Store the selected block in the URL for restoration when navigating back.\n\t\t\tif ( externalClientId ) {\n\t\t\t\turlUpdates.selectedBlock = externalClientId;\n\t\t\t}\n\n\t\t\t// Save the current viewport for when we navigate back (e.g. from overlay editor).\n\t\t\t// Omit viewport from URL when it's the default to keep URLs clean.\n\t\t\tconst requestedViewport =\n\t\t\t\ttypeof params.viewport === 'string'\n\t\t\t\t\t? params.viewport.toLowerCase()\n\t\t\t\t\t: undefined;\n\t\t\tconst isValidRequestedViewport =\n\t\t\t\tVALID_VIEWPORTS.includes( requestedViewport );\n\n\t\t\tif ( isValidRequestedViewport ) {\n\t\t\t\tconst currentViewportLower = (\n\t\t\t\t\tcurrentDeviceType || DEFAULT_DEVICE_TYPE\n\t\t\t\t).toLowerCase();\n\t\t\t\tif (\n\t\t\t\t\tcurrentViewportLower === DEFAULT_DEVICE_TYPE.toLowerCase()\n\t\t\t\t) {\n\t\t\t\t\tdelete urlUpdates.viewport;\n\t\t\t\t} else {\n\t\t\t\t\turlUpdates.viewport = currentViewportLower;\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tconst hasUpdatesToSave =\n\t\t\t\texternalClientId || isValidRequestedViewport;\n\t\t\tif ( hasUpdatesToSave ) {\n\t\t\t\thistory.navigate( addQueryArgs( path, urlUpdates ), {\n\t\t\t\t\treplace: true,\n\t\t\t\t} );\n\t\t\t}\n\n\t\t\t// Navigate to the new entity record\n\t\t\tconst queryArgs = {\n\t\t\t\tcanvas: 'edit',\n\t\t\t\tfocusMode: true,\n\t\t\t};\n\t\t\tif ( isValidRequestedViewport ) {\n\t\t\t\tqueryArgs.viewport = requestedViewport;\n\t\t\t}\n\t\t\tconst url = addQueryArgs(\n\t\t\t\t`/${ params.postType }/${ params.postId }`,\n\t\t\t\tqueryArgs\n\t\t\t);\n\n\t\t\thistory.navigate( url );\n\t\t},\n\t\t[ history, path, query, registry, currentDeviceType ]\n\t);\n\n\treturn onNavigateToEntityRecord;\n}\n"],
|
|
5
|
+
"mappings": ";AAAA,SAAS,WAAW,mBAAmB;AACvC,SAAS,eAAe,yBAAyB;AACjD,SAAS,mBAAmB;AAC5B,SAAS,oBAAoB;AAC7B,SAAS,SAAS,iBAAiB;AACnC,SAAS,SAAS,mBAAmB;AACrC,SAAS,cAAc;AACvB,SAAS,2BAA2B;AAEpC,IAAM,EAAE,YAAY,YAAY,IAAI,OAAQ,iBAAkB;AAE9D,IAAM,kBAAkB,CAAE,WAAW,UAAU,QAAS;AAMzC,SAAR,4BAA6C;AACnD,QAAM,UAAU,WAAW;AAC3B,QAAM,WAAW,YAAY;AAC7B,QAAM,EAAE,OAAO,KAAK,IAAI;AACxB,QAAM,WAAW,YAAY;AAC7B,QAAM,oBAAoB;AAAA,IACzB,CAAE,WAAY,OAAQ,WAAY,EAAE,cAAc;AAAA,IAClD,CAAC;AAAA,EACF;AAEA,QAAM,2BAA2B;AAAA,IAChC,CAAE,WAAY;AAEb,YAAM,kBAAkB,SACtB,OAAQ,WAAY,EACpB,mBAAmB;AACrB,YAAM,gBAAgB,SACpB,OAAQ,WAAY,EACpB,iBAAiB;AACnB,YAAM,cAAc,SAClB,OAAQ,SAAU,EAClB;AAAA,QACA;AAAA,QACA;AAAA,QACA;AAAA,MACD;AACD,YAAM,mBACL,aAAa,WAAW,gBAAgB;AAEzC,YAAM,aAAa,EAAE,GAAG,MAAM;AAG9B,UAAK,kBAAmB;AACvB,mBAAW,gBAAgB;AAAA,MAC5B;AAIA,YAAM,oBACL,OAAO,OAAO,aAAa,WACxB,OAAO,SAAS,YAAY,IAC5B;AACJ,YAAM,2BACL,gBAAgB,SAAU,iBAAkB;AAE7C,UAAK,0BAA2B;AAC/B,cAAM,wBACL,qBAAqB,qBACpB,YAAY;AACd,YACC,yBAAyB,oBAAoB,YAAY,GACxD;AACD,iBAAO,WAAW;AAAA,QACnB,OAAO;AACN,qBAAW,WAAW;AAAA,QACvB;AAAA,MACD;AAEA,YAAM,mBACL,oBAAoB;AACrB,UAAK,kBAAmB;AACvB,gBAAQ,SAAU,aAAc,MAAM,UAAW,GAAG;AAAA,UACnD,SAAS;AAAA,QACV,CAAE;AAAA,MACH;AAGA,YAAM,YAAY;AAAA,QACjB,QAAQ;AAAA,QACR,WAAW;AAAA,MACZ;AACA,UAAK,0BAA2B;AAC/B,kBAAU,WAAW;AAAA,MACtB;AACA,YAAM,MAAM;AAAA,QACX,IAAK,OAAO,QAAS,IAAK,OAAO,MAAO;AAAA,QACxC;AAAA,MACD;AAEA,cAAQ,SAAU,GAAI;AAAA,IACvB;AAAA,IACA,CAAE,SAAS,MAAM,OAAO,UAAU,iBAAkB;AAAA,EACrD;AAEA,SAAO;AACR;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../src/components/block-editor/use-site-editor-settings.js"],
|
|
4
|
-
"sourcesContent": ["
|
|
5
|
-
"mappings": ";
|
|
4
|
+
"sourcesContent": ["import { useSelect } from '@wordpress/data';\nimport { useMemo } from '@wordpress/element';\nimport { privateApis as routerPrivateApis } from '@wordpress/router';\nimport { usePrevious } from '@wordpress/compose';\nimport {\n\tstore as editorStore,\n\tprivateApis as editorPrivateApis,\n} from '@wordpress/editor';\nimport { generateGlobalStyles } from '@wordpress/global-styles-engine';\nimport { store as editSiteStore } from '../../store';\nimport { unlock } from '../../lock-unlock';\nimport useNavigateToEntityRecord from './use-navigate-to-entity-record';\nimport { FOCUSABLE_ENTITIES } from '../../utils/constants';\n\nconst { useLocation, useHistory } = unlock( routerPrivateApis );\nconst { useGlobalStyles } = unlock( editorPrivateApis );\n\nfunction useNavigateToPreviousEntityRecord() {\n\tconst location = useLocation();\n\tconst previousCanvas = usePrevious( location.query.canvas );\n\tconst history = useHistory();\n\tconst goBack = useMemo( () => {\n\t\tconst isFocusMode =\n\t\t\tlocation.query.focusMode ||\n\t\t\t( location?.params?.postId &&\n\t\t\t\tFOCUSABLE_ENTITIES.includes( location?.params?.postType ) );\n\t\tconst didComeFromEditorCanvas = previousCanvas === 'edit';\n\t\tconst showBackButton = isFocusMode && didComeFromEditorCanvas;\n\t\treturn showBackButton ? () => history.back() : undefined;\n\t}, [ location, history, previousCanvas ] );\n\treturn goBack;\n}\n\nexport function useSpecificEditorSettings() {\n\tconst { query } = useLocation();\n\tconst { canvas = 'view' } = query;\n\tconst onNavigateToEntityRecord = useNavigateToEntityRecord();\n\n\t/*\n\t * Generate global styles directly to avoid circular dependency with GlobalStylesRenderer\n\t * (which runs inside ExperimentalEditorProvider after this hook).\n\t * GlobalStylesRenderer updates editorStore, but reading from it here would cause infinite\n\t * loops. Reading config from useGlobalStyles and generating CSS directly keeps us in sync.\n\t * See: https://github.com/WordPress/gutenberg/issues/73350\n\t */\n\tconst { merged: mergedConfig } = useGlobalStyles();\n\n\tconst { settings, currentPostIsTrashed } = useSelect( ( select ) => {\n\t\tconst { getSettings } = select( editSiteStore );\n\t\tconst { getCurrentPostAttribute } = select( editorStore );\n\t\treturn {\n\t\t\tsettings: getSettings(),\n\t\t\tcurrentPostIsTrashed:\n\t\t\t\tgetCurrentPostAttribute( 'status' ) === 'trash',\n\t\t};\n\t}, [] );\n\n\tconst onNavigateToPreviousEntityRecord =\n\t\tuseNavigateToPreviousEntityRecord();\n\n\tconst [ globalStyles, globalSettings ] = useMemo( () => {\n\t\treturn generateGlobalStyles( mergedConfig, [], {\n\t\t\tdisableRootPadding: false,\n\t\t} );\n\t}, [ mergedConfig ] );\n\n\tconst defaultEditorSettings = useMemo( () => {\n\t\t// Preserve non-global styles from settings.styles (e.g., editor styles from add_editor_style)\n\t\tconst nonGlobalStyles = ( settings?.styles ?? [] ).filter(\n\t\t\t( style ) => ! style.isGlobalStyles\n\t\t);\n\n\t\treturn {\n\t\t\t...settings,\n\t\t\tstyles: [\n\t\t\t\t...nonGlobalStyles,\n\t\t\t\t...globalStyles,\n\t\t\t\t{\n\t\t\t\t\t// Forming a \"block formatting context\" to prevent margin collapsing.\n\t\t\t\t\t// @see https://developer.mozilla.org/en-US/docs/Web/Guide/CSS/Block_formatting_context\n\t\t\t\t\tcss:\n\t\t\t\t\t\tcanvas === 'view'\n\t\t\t\t\t\t\t? `body{min-height: 100vh; ${\n\t\t\t\t\t\t\t\t\tcurrentPostIsTrashed\n\t\t\t\t\t\t\t\t\t\t? ''\n\t\t\t\t\t\t\t\t\t\t: 'cursor: pointer;'\n\t\t\t\t\t\t\t }}`\n\t\t\t\t\t\t\t: undefined,\n\t\t\t\t},\n\t\t\t],\n\t\t\t__experimentalFeatures: globalSettings,\n\t\t\trichEditingEnabled: true,\n\t\t\tsupportsTemplateMode: true,\n\t\t\tfocusMode: canvas !== 'view',\n\t\t\tonNavigateToEntityRecord,\n\t\t\tonNavigateToPreviousEntityRecord,\n\t\t\tisPreviewMode: canvas === 'view',\n\t\t};\n\t}, [\n\t\tsettings,\n\t\tglobalStyles,\n\t\tglobalSettings,\n\t\tcanvas,\n\t\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AAA,MACtB,sBACC,wBAAyB,QAAS,MAAM;AAAA,IAC1C;AAAA,EACD,GAAG,CAAC,CAAE;AAEN,QAAM,mCACL,kCAAkC;AAEnC,QAAM,CAAE,cAAc,cAAe,IAAI,QAAS,MAAM;AACvD,WAAO,qBAAsB,cAAc,CAAC,GAAG;AAAA,MAC9C,oBAAoB;AAAA,IACrB,CAAE;AAAA,EACH,GAAG,CAAE,YAAa,CAAE;AAEpB,QAAM,wBAAwB,QAAS,MAAM;AAE5C,UAAM,mBAAoB,UAAU,UAAU,CAAC,GAAI;AAAA,MAClD,CAAE,UAAW,CAAE,MAAM;AAAA,IACtB;AAEA,WAAO;AAAA,MACN,GAAG;AAAA,MACH,QAAQ;AAAA,QACP,GAAG;AAAA,QACH,GAAG;AAAA,QACH;AAAA;AAAA;AAAA,UAGC,KACC,WAAW,SACR,2BACA,uBACG,KACA,kBACH,MACA;AAAA,QACL;AAAA,MACD;AAAA,MACA,wBAAwB;AAAA,MACxB,oBAAoB;AAAA,MACpB,sBAAsB;AAAA,MACtB,WAAW,WAAW;AAAA,MACtB;AAAA,MACA;AAAA,MACA,eAAe,WAAW;AAAA,IAC3B;AAAA,EACD,GAAG;AAAA,IACF;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,EACD,CAAE;AAEF,SAAO;AACR;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../src/components/block-editor/use-viewport-sync.js"],
|
|
4
|
-
"sourcesContent": ["
|
|
5
|
-
"mappings": ";
|
|
4
|
+
"sourcesContent": ["import { useEffect } from '@wordpress/element';\nimport { useDispatch } from '@wordpress/data';\nimport { privateApis as routerPrivateApis } from '@wordpress/router';\nimport { store as editorStore } from '@wordpress/editor';\nimport { unlock } from '../../lock-unlock';\n\nconst { useLocation } = unlock( routerPrivateApis );\n\nexport const DEFAULT_DEVICE_TYPE = 'Desktop';\n\n// Lowercase values for URL params. Duplicated from block-editor block-visibility constants\n// and editor preview-dropdown choices. See those files when adding new viewport types.\nconst VALID_DEVICE_TYPES = [ 'desktop', 'tablet', 'mobile' ];\n\n// URL viewport params are lowercase; the editor store uses PascalCase.\nconst capitalize = ( str ) => str.charAt( 0 ).toUpperCase() + str.slice( 1 );\n\n/**\n * Syncs the editor's device type with the `viewport` URL query param.\n *\n * Intentionally responds to ongoing URL changes (not just initial load) so that\n * viewport is restored correctly when navigating back (e.g. from overlay template\n * part editor to the previous entity).\n */\nexport default function useViewportSync() {\n\tconst { query } = useLocation();\n\tconst { setDeviceType } = useDispatch( editorStore );\n\n\tuseEffect( () => {\n\t\tconst viewport = query?.viewport?.toLowerCase();\n\t\tconst isValid = VALID_DEVICE_TYPES.includes( viewport );\n\n\t\tsetDeviceType( isValid ? capitalize( viewport ) : DEFAULT_DEVICE_TYPE );\n\t}, [ query?.viewport, setDeviceType ] );\n}\n\n/**\n * Component wrapper that runs the viewport sync hook.\n * Renders nothing; used to run the hook inside the Editor tree (inside EditorProvider).\n */\nexport function ViewportSync() {\n\tuseViewportSync();\n\treturn null;\n}\n"],
|
|
5
|
+
"mappings": ";AAAA,SAAS,iBAAiB;AAC1B,SAAS,mBAAmB;AAC5B,SAAS,eAAe,yBAAyB;AACjD,SAAS,SAAS,mBAAmB;AACrC,SAAS,cAAc;AAEvB,IAAM,EAAE,YAAY,IAAI,OAAQ,iBAAkB;AAE3C,IAAM,sBAAsB;AAInC,IAAM,qBAAqB,CAAE,WAAW,UAAU,QAAS;AAG3D,IAAM,aAAa,CAAE,QAAS,IAAI,OAAQ,CAAE,EAAE,YAAY,IAAI,IAAI,MAAO,CAAE;AAS5D,SAAR,kBAAmC;AACzC,QAAM,EAAE,MAAM,IAAI,YAAY;AAC9B,QAAM,EAAE,cAAc,IAAI,YAAa,WAAY;AAEnD,YAAW,MAAM;AAChB,UAAM,WAAW,OAAO,UAAU,YAAY;AAC9C,UAAM,UAAU,mBAAmB,SAAU,QAAS;AAEtD,kBAAe,UAAU,WAAY,QAAS,IAAI,mBAAoB;AAAA,EACvE,GAAG,CAAE,OAAO,UAAU,aAAc,CAAE;AACvC;AAMO,SAAS,eAAe;AAC9B,kBAAgB;AAChB,SAAO;AACR;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -1,18 +1,13 @@
|
|
|
1
1
|
// packages/edit-site/src/components/canvas-loader/index.js
|
|
2
|
-
import {
|
|
3
|
-
privateApis as componentsPrivateApis,
|
|
4
|
-
ProgressBar
|
|
5
|
-
} from "@wordpress/components";
|
|
2
|
+
import { ProgressBar } from "@wordpress/components";
|
|
6
3
|
import { store as coreStore } from "@wordpress/core-data";
|
|
7
4
|
import { useSelect } from "@wordpress/data";
|
|
8
5
|
import { privateApis as editorPrivateApis } from "@wordpress/editor";
|
|
9
6
|
import { unlock } from "../../lock-unlock.mjs";
|
|
10
7
|
import { jsx } from "react/jsx-runtime";
|
|
11
|
-
var { Theme } = unlock(componentsPrivateApis);
|
|
12
8
|
var { useStyle } = unlock(editorPrivateApis);
|
|
13
9
|
function CanvasLoader({ id }) {
|
|
14
10
|
const textColor = useStyle("color.text");
|
|
15
|
-
const backgroundColor = useStyle("color.background");
|
|
16
11
|
const { elapsed, total } = useSelect((select) => {
|
|
17
12
|
const selectorsByStatus = select(coreStore).countSelectorsByStatus();
|
|
18
13
|
const resolving = selectorsByStatus.resolving ?? 0;
|
|
@@ -22,7 +17,14 @@ function CanvasLoader({ id }) {
|
|
|
22
17
|
total: finished + resolving
|
|
23
18
|
};
|
|
24
19
|
}, []);
|
|
25
|
-
return /* @__PURE__ */ jsx(
|
|
20
|
+
return /* @__PURE__ */ jsx(
|
|
21
|
+
"div",
|
|
22
|
+
{
|
|
23
|
+
className: "edit-site-canvas-loader",
|
|
24
|
+
style: textColor ? { "--color": textColor } : void 0,
|
|
25
|
+
children: /* @__PURE__ */ jsx(ProgressBar, { id, max: total, value: elapsed })
|
|
26
|
+
}
|
|
27
|
+
);
|
|
26
28
|
}
|
|
27
29
|
export {
|
|
28
30
|
CanvasLoader as default
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../src/components/canvas-loader/index.js"],
|
|
4
|
-
"sourcesContent": ["
|
|
5
|
-
"mappings": ";
|
|
4
|
+
"sourcesContent": ["import { ProgressBar } from '@wordpress/components';\nimport { store as coreStore } from '@wordpress/core-data';\nimport { useSelect } from '@wordpress/data';\nimport { privateApis as editorPrivateApis } from '@wordpress/editor';\nimport { unlock } from '../../lock-unlock';\n\nconst { useStyle } = unlock( editorPrivateApis );\n\nexport default function CanvasLoader( { id } ) {\n\tconst textColor = useStyle( 'color.text' );\n\tconst { elapsed, total } = useSelect( ( select ) => {\n\t\tconst selectorsByStatus = select( coreStore ).countSelectorsByStatus();\n\t\tconst resolving = selectorsByStatus.resolving ?? 0;\n\t\tconst finished = selectorsByStatus.finished ?? 0;\n\t\treturn {\n\t\t\telapsed: finished,\n\t\t\ttotal: finished + resolving,\n\t\t};\n\t}, [] );\n\n\treturn (\n\t\t<div\n\t\t\tclassName=\"edit-site-canvas-loader\"\n\t\t\tstyle={ textColor ? { '--color': textColor } : undefined }\n\t\t>\n\t\t\t<ProgressBar id={ id } max={ total } value={ elapsed } />\n\t\t</div>\n\t);\n}\n"],
|
|
5
|
+
"mappings": ";AAAA,SAAS,mBAAmB;AAC5B,SAAS,SAAS,iBAAiB;AACnC,SAAS,iBAAiB;AAC1B,SAAS,eAAe,yBAAyB;AACjD,SAAS,cAAc;AAqBpB;AAnBH,IAAM,EAAE,SAAS,IAAI,OAAQ,iBAAkB;AAEhC,SAAR,aAA+B,EAAE,GAAG,GAAI;AAC9C,QAAM,YAAY,SAAU,YAAa;AACzC,QAAM,EAAE,SAAS,MAAM,IAAI,UAAW,CAAE,WAAY;AACnD,UAAM,oBAAoB,OAAQ,SAAU,EAAE,uBAAuB;AACrE,UAAM,YAAY,kBAAkB,aAAa;AACjD,UAAM,WAAW,kBAAkB,YAAY;AAC/C,WAAO;AAAA,MACN,SAAS;AAAA,MACT,OAAO,WAAW;AAAA,IACnB;AAAA,EACD,GAAG,CAAC,CAAE;AAEN,SACC;AAAA,IAAC;AAAA;AAAA,MACA,WAAU;AAAA,MACV,OAAQ,YAAY,EAAE,WAAW,UAAU,IAAI;AAAA,MAE/C,8BAAC,eAAY,IAAU,KAAM,OAAQ,OAAQ,SAAU;AAAA;AAAA,EACxD;AAEF;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../src/components/dataviews-actions/index.js"],
|
|
4
|
-
"sourcesContent": ["
|
|
5
|
-
"mappings": ";
|
|
4
|
+
"sourcesContent": ["import { __ } from '@wordpress/i18n';\nimport { pencil, drawerRight } from '@wordpress/icons';\nimport { useMemo } from '@wordpress/element';\nimport { privateApis as routerPrivateApis } from '@wordpress/router';\nimport { useDispatch, useSelect } from '@wordpress/data';\nimport { store as coreStore } from '@wordpress/core-data';\nimport { addQueryArgs } from '@wordpress/url';\nimport { PATTERN_TYPES } from '../../utils/constants';\nimport { unlock } from '../../lock-unlock';\n\nconst { useLocation, useHistory } = unlock( routerPrivateApis );\n\nexport const useSetActiveTemplateAction = () => {\n\tconst activeTheme = useSelect( ( select ) =>\n\t\tselect( coreStore ).getCurrentTheme()\n\t);\n\tconst { getEntityRecord } = useSelect( coreStore );\n\tconst { editEntityRecord, saveEditedEntityRecord } =\n\t\tuseDispatch( coreStore );\n\treturn useMemo(\n\t\t() => ( {\n\t\t\tid: 'set-active-template',\n\t\t\tlabel( items ) {\n\t\t\t\treturn items.some( ( item ) => item._isActive )\n\t\t\t\t\t? __( 'Deactivate' )\n\t\t\t\t\t: __( 'Activate' );\n\t\t\t},\n\t\t\tisPrimary: true,\n\t\t\ticon: pencil,\n\t\t\tisEligible( item ) {\n\t\t\t\tif ( item.theme !== activeTheme.stylesheet ) {\n\t\t\t\t\treturn false;\n\t\t\t\t}\n\n\t\t\t\t// If it's not a created template but a registered template,\n\t\t\t\t// only allow activating (so when it's inactive).\n\t\t\t\tif ( typeof item.id !== 'number' ) {\n\t\t\t\t\treturn item._isActive === false;\n\t\t\t\t}\n\n\t\t\t\treturn true;\n\t\t\t},\n\t\t\tasync callback( items ) {\n\t\t\t\tconst deactivate = items.some( ( item ) => item._isActive );\n\t\t\t\t// current active templates\n\t\t\t\tconst activeTemplates = {\n\t\t\t\t\t...( ( await getEntityRecord( 'root', 'site' )\n\t\t\t\t\t\t.active_templates ) ?? {} ),\n\t\t\t\t};\n\t\t\t\tfor ( const item of items ) {\n\t\t\t\t\tif ( deactivate ) {\n\t\t\t\t\t\tdelete activeTemplates[ item.slug ];\n\t\t\t\t\t} else {\n\t\t\t\t\t\tactiveTemplates[ item.slug ] = item.id;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tawait editEntityRecord( 'root', 'site', undefined, {\n\t\t\t\t\tactive_templates: activeTemplates,\n\t\t\t\t} );\n\t\t\t\tawait saveEditedEntityRecord( 'root', 'site' );\n\t\t\t},\n\t\t} ),\n\t\t[\n\t\t\teditEntityRecord,\n\t\t\tsaveEditedEntityRecord,\n\t\t\tgetEntityRecord,\n\t\t\tactiveTheme,\n\t\t]\n\t);\n};\n\nexport const useEditPostAction = () => {\n\tconst history = useHistory();\n\treturn useMemo(\n\t\t() => ( {\n\t\t\tid: 'edit-post',\n\t\t\tlabel: __( 'Edit' ),\n\t\t\ticon: pencil,\n\t\t\tisEligible( post ) {\n\t\t\t\tif ( post.status === 'trash' ) {\n\t\t\t\t\treturn false;\n\t\t\t\t}\n\t\t\t\t// It's eligible for all post types except theme patterns.\n\t\t\t\treturn post.type !== PATTERN_TYPES.theme;\n\t\t\t},\n\t\t\tcallback( items ) {\n\t\t\t\tconst post = items[ 0 ];\n\t\t\t\thistory.navigate( `/${ post.type }/${ post.id }?canvas=edit` );\n\t\t\t},\n\t\t} ),\n\t\t[ history ]\n\t);\n};\n\nexport const useQuickEditPostAction = () => {\n\tconst history = useHistory();\n\tconst { path, query } = useLocation();\n\treturn useMemo(\n\t\t() => ( {\n\t\t\tid: 'quick-edit',\n\t\t\tlabel: __( 'Quick Edit' ),\n\t\t\ticon: drawerRight,\n\t\t\tisPrimary: true,\n\t\t\tsupportsBulk: true,\n\t\t\tisEligible( post ) {\n\t\t\t\tif ( post.status === 'trash' ) {\n\t\t\t\t\treturn false;\n\t\t\t\t}\n\n\t\t\t\treturn post.type === 'page';\n\t\t\t},\n\t\t\tcallback( items ) {\n\t\t\t\thistory.navigate(\n\t\t\t\t\taddQueryArgs( path, {\n\t\t\t\t\t\t...query,\n\t\t\t\t\t\tquickEdit: true,\n\t\t\t\t\t\tpostId: items.map( ( item ) => item.id ).join( ',' ),\n\t\t\t\t\t} )\n\t\t\t\t);\n\t\t\t},\n\t\t} ),\n\t\t[ history, path, query ]\n\t);\n};\n"],
|
|
5
|
+
"mappings": ";AAAA,SAAS,UAAU;AACnB,SAAS,QAAQ,mBAAmB;AACpC,SAAS,eAAe;AACxB,SAAS,eAAe,yBAAyB;AACjD,SAAS,aAAa,iBAAiB;AACvC,SAAS,SAAS,iBAAiB;AACnC,SAAS,oBAAoB;AAC7B,SAAS,qBAAqB;AAC9B,SAAS,cAAc;AAEvB,IAAM,EAAE,aAAa,WAAW,IAAI,OAAQ,iBAAkB;AAEvD,IAAM,6BAA6B,MAAM;AAC/C,QAAM,cAAc;AAAA,IAAW,CAAE,WAChC,OAAQ,SAAU,EAAE,gBAAgB;AAAA,EACrC;AACA,QAAM,EAAE,gBAAgB,IAAI,UAAW,SAAU;AACjD,QAAM,EAAE,kBAAkB,uBAAuB,IAChD,YAAa,SAAU;AACxB,SAAO;AAAA,IACN,OAAQ;AAAA,MACP,IAAI;AAAA,MACJ,MAAO,OAAQ;AACd,eAAO,MAAM,KAAM,CAAE,SAAU,KAA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AA,IACD;AAAA,IACA,CAAE,OAAQ;AAAA,EACX;AACD;AAEO,IAAM,yBAAyB,MAAM;AAC3C,QAAM,UAAU,WAAW;AAC3B,QAAM,EAAE,MAAM,MAAM,IAAI,YAAY;AACpC,SAAO;AAAA,IACN,OAAQ;AAAA,MACP,IAAI;AAAA,MACJ,OAAO,GAAI,YAAa;AAAA,MACxB,MAAM;AAAA,MACN,WAAW;AAAA,MACX,cAAc;AAAA,MACd,WAAY,MAAO;AAClB,YAAK,KAAK,WAAW,SAAU;AAC9B,iBAAO;AAAA,QACR;AAEA,eAAO,KAAK,SAAS;AAAA,MACtB;AAAA,MACA,SAAU,OAAQ;AACjB,gBAAQ;AAAA,UACP,aAAc,MAAM;AAAA,YACnB,GAAG;AAAA,YACH,WAAW;AAAA,YACX,QAAQ,MAAM,IAAK,CAAE,SAAU,KAAK,EAAG,EAAE,KAAM,GAAI;AAAA,UACpD,CAAE;AAAA,QACH;AAAA,MACD;AAAA,IACD;AAAA,IACA,CAAE,SAAS,MAAM,KAAM;AAAA,EACxB;AACD;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -29,6 +29,7 @@ import SiteEditorMoreMenu from "../more-menu/index.mjs";
|
|
|
29
29
|
import useEditorIframeProps from "../block-editor/use-editor-iframe-props.mjs";
|
|
30
30
|
import { ViewportSync } from "../block-editor/use-viewport-sync.mjs";
|
|
31
31
|
import useEditorTitle from "./use-editor-title.mjs";
|
|
32
|
+
import useRevisionsURLSync from "./use-revisions-url-sync.mjs";
|
|
32
33
|
import { useIsSiteEditorLoading } from "../layout/hooks.mjs";
|
|
33
34
|
import { useAdaptEditorToCanvas } from "./use-adapt-editor-to-canvas.mjs";
|
|
34
35
|
import {
|
|
@@ -69,7 +70,7 @@ function getNavigationPath(location, postType) {
|
|
|
69
70
|
].includes(name)) {
|
|
70
71
|
return getListPathForPostType(postType);
|
|
71
72
|
}
|
|
72
|
-
return addQueryArgs(path, { canvas: void 0 });
|
|
73
|
+
return addQueryArgs(path, { canvas: void 0, revision: void 0 });
|
|
73
74
|
}
|
|
74
75
|
function EditSiteEditor({ isHomeRoute = false }) {
|
|
75
76
|
const location = useLocation();
|
|
@@ -85,13 +86,13 @@ function EditSiteEditor({ isHomeRoute = false }) {
|
|
|
85
86
|
[]
|
|
86
87
|
);
|
|
87
88
|
const postWithTemplate = !!context?.postId;
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
);
|
|
89
|
+
const editorPostType = postWithTemplate ? context.postType : postType;
|
|
90
|
+
const editorPostId = postWithTemplate ? context.postId : postId;
|
|
91
|
+
useEditorTitle(editorPostType, editorPostId);
|
|
92
92
|
const _isPreviewingTheme = isPreviewingTheme();
|
|
93
93
|
const iframeProps = useEditorIframeProps();
|
|
94
94
|
const isEditMode = canvas === "edit";
|
|
95
|
+
useRevisionsURLSync(isEditMode, editorPostType, editorPostId);
|
|
95
96
|
const loadingProgressId = useInstanceId(
|
|
96
97
|
CanvasLoader,
|
|
97
98
|
"edit-site-editor__loading-progress"
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../src/components/editor/index.js"],
|
|
4
|
-
"sourcesContent": ["
|
|
5
|
-
"mappings": ";
|
|
4
|
+
"sourcesContent": ["import { useDispatch, useSelect } from '@wordpress/data';\nimport { Button } from '@wordpress/components';\nimport { useInstanceId } from '@wordpress/compose';\nimport {\n\tEditorKeyboardShortcutsRegister,\n\tprivateApis as editorPrivateApis,\n\tstore as editorStore,\n} from '@wordpress/editor';\nimport { __, isRTL, sprintf } from '@wordpress/i18n';\nimport { store as coreDataStore } from '@wordpress/core-data';\nimport { privateApis as blockLibraryPrivateApis } from '@wordpress/block-library';\nimport { useCallback } from '@wordpress/element';\nimport { store as noticesStore } from '@wordpress/notices';\nimport { privateApis as routerPrivateApis } from '@wordpress/router';\nimport { decodeEntities } from '@wordpress/html-entities';\nimport { chevronLeft, chevronRight } from '@wordpress/icons';\nimport { store as blockEditorStore } from '@wordpress/block-editor';\nimport { addQueryArgs } from '@wordpress/url';\nimport WelcomeGuide from '../welcome-guide';\nimport CanvasLoader from '../canvas-loader';\nimport { unlock } from '../../lock-unlock';\nimport { useSpecificEditorSettings } from '../block-editor/use-site-editor-settings';\nimport PluginTemplateSettingPanel from '../plugin-template-setting-panel';\nimport { isPreviewingTheme } from '../../utils/is-previewing-theme';\nimport SaveButton from '../save-button';\nimport SavePanel from '../save-panel';\nimport SiteEditorMoreMenu from '../more-menu';\nimport useEditorIframeProps from '../block-editor/use-editor-iframe-props';\nimport { ViewportSync } from '../block-editor/use-viewport-sync';\nimport useEditorTitle from './use-editor-title';\nimport useRevisionsURLSync from './use-revisions-url-sync';\nimport { useIsSiteEditorLoading } from '../layout/hooks';\nimport { useAdaptEditorToCanvas } from './use-adapt-editor-to-canvas';\nimport {\n\tuseResolveEditedEntity,\n\tuseSyncDeprecatedEntityIntoState,\n} from './use-resolve-edited-entity';\nimport SitePreview from './site-preview';\n\nconst { Editor, BackButton } = unlock( editorPrivateApis );\nconst { useHistory, useLocation } = unlock( routerPrivateApis );\nconst { BlockKeyboardShortcuts } = unlock( blockLibraryPrivateApis );\n\nfunction getListPathForPostType( postType ) {\n\tswitch ( postType ) {\n\t\tcase 'navigation':\n\t\t\treturn '/navigation';\n\t\tcase 'wp_block':\n\t\t\treturn '/pattern?postType=wp_block';\n\t\tcase 'wp_template_part':\n\t\t\treturn '/pattern?postType=wp_template_part';\n\t\tcase 'wp_template':\n\t\t\treturn '/template';\n\t\tcase 'page':\n\t\t\treturn '/page';\n\t\tcase 'post':\n\t\t\treturn '/';\n\t}\n\tthrow 'Unknown post type';\n}\n\nfunction getNavigationPath( location, postType ) {\n\tconst { path, name } = location;\n\tif (\n\t\t[\n\t\t\t'pattern-item',\n\t\t\t'template-part-item',\n\t\t\t'page-item',\n\t\t\t'template-item',\n\t\t\t'static-template-item',\n\t\t\t'post-item',\n\t\t].includes( name )\n\t) {\n\t\treturn getListPathForPostType( postType );\n\t}\n\treturn addQueryArgs( path, { canvas: undefined, revision: undefined } );\n}\n\nexport default function EditSiteEditor( { isHomeRoute = false } ) {\n\tconst location = useLocation();\n\tconst history = useHistory();\n\tconst { canvas = 'view' } = location.query;\n\tconst isLoading = useIsSiteEditorLoading();\n\tuseAdaptEditorToCanvas( canvas );\n\tconst entity = useResolveEditedEntity();\n\t// deprecated sync state with url\n\tuseSyncDeprecatedEntityIntoState( entity );\n\tconst { postType, postId, context } = entity;\n\tconst isBlockBasedTheme = useSelect(\n\t\t( select ) => select( coreDataStore ).getCurrentTheme()?.is_block_theme,\n\t\t[]\n\t);\n\tconst postWithTemplate = !! context?.postId;\n\tconst editorPostType = postWithTemplate ? context.postType : postType;\n\tconst editorPostId = postWithTemplate ? context.postId : postId;\n\tuseEditorTitle( editorPostType, editorPostId );\n\tconst _isPreviewingTheme = isPreviewingTheme();\n\tconst iframeProps = useEditorIframeProps();\n\tconst isEditMode = canvas === 'edit';\n\tuseRevisionsURLSync( isEditMode, editorPostType, editorPostId );\n\tconst loadingProgressId = useInstanceId(\n\t\tCanvasLoader,\n\t\t'edit-site-editor__loading-progress'\n\t);\n\n\tconst editorSettings = useSpecificEditorSettings();\n\tconst { resetZoomLevel } = unlock( useDispatch( blockEditorStore ) );\n\tconst { setCurrentRevisionId } = unlock( useDispatch( editorStore ) );\n\tconst { createSuccessNotice } = useDispatch( noticesStore );\n\tconst onActionPerformed = useCallback(\n\t\t( actionId, items ) => {\n\t\t\tswitch ( actionId ) {\n\t\t\t\tcase 'move-to-trash':\n\t\t\t\tcase 'delete-post':\n\t\t\t\t\t{\n\t\t\t\t\t\thistory.navigate(\n\t\t\t\t\t\t\tgetListPathForPostType(\n\t\t\t\t\t\t\t\tpostWithTemplate ? context.postType : postType\n\t\t\t\t\t\t\t)\n\t\t\t\t\t\t);\n\t\t\t\t\t}\n\t\t\t\t\tbreak;\n\t\t\t\tcase 'duplicate-post':\n\t\t\t\t\t{\n\t\t\t\t\t\tconst newItem = items[ 0 ];\n\t\t\t\t\t\tconst _title =\n\t\t\t\t\t\t\ttypeof newItem.title === 'string'\n\t\t\t\t\t\t\t\t? newItem.title\n\t\t\t\t\t\t\t\t: newItem.title?.rendered;\n\t\t\t\t\t\tcreateSuccessNotice(\n\t\t\t\t\t\t\tsprintf(\n\t\t\t\t\t\t\t\t// translators: %s: Title of the created post or template, e.g: \"Hello world\".\n\t\t\t\t\t\t\t\t__( '\"%s\" successfully created.' ),\n\t\t\t\t\t\t\t\tdecodeEntities( _title ) || __( '(no title)' )\n\t\t\t\t\t\t\t),\n\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\ttype: 'snackbar',\n\t\t\t\t\t\t\t\tid: 'duplicate-post-action',\n\t\t\t\t\t\t\t\tactions: [\n\t\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\t\tlabel: __( 'Edit' ),\n\t\t\t\t\t\t\t\t\t\tonClick: () => {\n\t\t\t\t\t\t\t\t\t\t\thistory.navigate(\n\t\t\t\t\t\t\t\t\t\t\t\t`/${ newItem.type }/${ newItem.id }?canvas=edit`\n\t\t\t\t\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t],\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t);\n\t\t\t\t\t}\n\t\t\t\t\tbreak;\n\t\t\t}\n\t\t},\n\t\t[\n\t\t\tpostType,\n\t\t\tcontext?.postType,\n\t\t\tpostWithTemplate,\n\t\t\thistory,\n\t\t\tcreateSuccessNotice,\n\t\t]\n\t);\n\n\tconst isReady = ! isLoading;\n\n\treturn ! isBlockBasedTheme && isHomeRoute ? (\n\t\t<SitePreview />\n\t) : (\n\t\t<>\n\t\t\t<EditorKeyboardShortcutsRegister />\n\t\t\t{ isEditMode && <BlockKeyboardShortcuts /> }\n\t\t\t{ ! isReady ? <CanvasLoader id={ loadingProgressId } /> : null }\n\t\t\t{ isEditMode && isReady && (\n\t\t\t\t<WelcomeGuide\n\t\t\t\t\tpostType={ postWithTemplate ? context.postType : postType }\n\t\t\t\t/>\n\t\t\t) }\n\t\t\t{ isReady && (\n\t\t\t\t<Editor\n\t\t\t\t\tpostType={ postWithTemplate ? context.postType : postType }\n\t\t\t\t\tpostId={ postWithTemplate ? context.postId : postId }\n\t\t\t\t\ttemplateId={ postWithTemplate ? postId : undefined }\n\t\t\t\t\tsettings={ editorSettings }\n\t\t\t\t\tclassName=\"edit-site-editor__editor-interface\"\n\t\t\t\t\tcustomSaveButton={\n\t\t\t\t\t\t_isPreviewingTheme && <SaveButton size=\"compact\" />\n\t\t\t\t\t}\n\t\t\t\t\tcustomSavePanel={ _isPreviewingTheme && <SavePanel /> }\n\t\t\t\t\tiframeProps={ iframeProps }\n\t\t\t\t\tonActionPerformed={ onActionPerformed }\n\t\t\t\t\textraSidebarPanels={\n\t\t\t\t\t\t! postWithTemplate && (\n\t\t\t\t\t\t\t<PluginTemplateSettingPanel.Slot />\n\t\t\t\t\t\t)\n\t\t\t\t\t}\n\t\t\t\t>\n\t\t\t\t\t{ isEditMode && <ViewportSync /> }\n\t\t\t\t\t{ isEditMode && (\n\t\t\t\t\t\t<BackButton>\n\t\t\t\t\t\t\t{ ( { length } ) =>\n\t\t\t\t\t\t\t\tlength <= 1 && (\n\t\t\t\t\t\t\t\t\t<Button\n\t\t\t\t\t\t\t\t\t\tsize=\"compact\"\n\t\t\t\t\t\t\t\t\t\tlabel={ __( 'Open Navigation' ) }\n\t\t\t\t\t\t\t\t\t\tshowTooltip\n\t\t\t\t\t\t\t\t\t\ttooltipPosition=\"middle right\"\n\t\t\t\t\t\t\t\t\t\tonClick={ () => {\n\t\t\t\t\t\t\t\t\t\t\tresetZoomLevel();\n\t\t\t\t\t\t\t\t\t\t\tsetCurrentRevisionId( null );\n\t\t\t\t\t\t\t\t\t\t\thistory.navigate(\n\t\t\t\t\t\t\t\t\t\t\t\tgetNavigationPath(\n\t\t\t\t\t\t\t\t\t\t\t\t\tlocation,\n\t\t\t\t\t\t\t\t\t\t\t\t\tpostWithTemplate\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t? context.postType\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t: postType\n\t\t\t\t\t\t\t\t\t\t\t\t),\n\t\t\t\t\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\t\t\t\t\ttransition:\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t'canvas-mode-view-transition',\n\t\t\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\t\t\t\t} }\n\t\t\t\t\t\t\t\t\t\ticon={\n\t\t\t\t\t\t\t\t\t\t\tisRTL() ? chevronRight : chevronLeft\n\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t\t)\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t</BackButton>\n\t\t\t\t\t) }\n\t\t\t\t\t<SiteEditorMoreMenu />\n\t\t\t\t</Editor>\n\t\t\t) }\n\t\t</>\n\t);\n}\n"],
|
|
5
|
+
"mappings": ";AAAA,SAAS,aAAa,iBAAiB;AACvC,SAAS,cAAc;AACvB,SAAS,qBAAqB;AAC9B;AAAA,EACC;AAAA,EACA,eAAe;AAAA,EACf,SAAS;AAAA,OACH;AACP,SAAS,IAAI,OAAO,eAAe;AACnC,SAAS,SAAS,qBAAqB;AACvC,SAAS,eAAe,+BAA+B;AACvD,SAAS,mBAAmB;AAC5B,SAAS,SAAS,oBAAoB;AACtC,SAAS,eAAe,yBAAyB;AACjD,SAAS,sBAAsB;AAC/B,SAAS,aAAa,oBAAoB;AAC1C,SAAS,SAAS,wBAAwB;AAC1C,SAAS,oBAAoB;AAC7B,OAAO,kBAAkB;AACzB,OAAO,kBAAkB;AACzB,SAAS,cAAc;AACvB,SAAS,iCAAiC;AAC1C,OAAO,gCAAgC;AACvC,SAAS,yBAAyB;AAClC,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A;AAAA,oBACC,YACC;AAAA,kBACF;AAAA,gBACD;AAAA,cACD;AAAA,cACA,MACC,MAAM,IAAI,eAAe;AAAA;AAAA,UAE3B,GAGH;AAAA,UAED,oBAAC,sBAAmB;AAAA;AAAA;AAAA,IACrB;AAAA,KAEF;AAEF;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../src/components/editor/site-preview.js"],
|
|
4
|
-
"sourcesContent": ["
|
|
5
|
-
"mappings": ";
|
|
4
|
+
"sourcesContent": ["import { __ } from '@wordpress/i18n';\nimport { useSelect } from '@wordpress/data';\nimport { store as coreStore } from '@wordpress/core-data';\nimport { focus } from '@wordpress/dom';\nimport { addQueryArgs } from '@wordpress/url';\n\nexport default function SitePreview() {\n\tconst siteUrl = useSelect( ( select ) => {\n\t\tconst { getEntityRecord } = select( coreStore );\n\t\tconst siteData = getEntityRecord( 'root', '__unstableBase' );\n\t\treturn siteData?.home;\n\t}, [] );\n\n\treturn (\n\t\t<iframe\n\t\t\tsrc={ addQueryArgs( siteUrl, {\n\t\t\t\t// Parameter for hiding the admin bar.\n\t\t\t\twp_site_preview: 1,\n\t\t\t} ) }\n\t\t\ttitle={ __( 'Site Preview' ) }\n\t\t\tstyle={ {\n\t\t\t\tdisplay: 'block',\n\t\t\t\twidth: '100%',\n\t\t\t\theight: '100%',\n\t\t\t\tbackgroundColor: '#fff',\n\t\t\t} }\n\t\t\tonLoad={ ( event ) => {\n\t\t\t\t// Make interactive elements unclickable.\n\t\t\t\tconst document = event.target.contentDocument;\n\t\t\t\tconst focusableElements = focus.focusable.find( document );\n\t\t\t\tfocusableElements.forEach( ( element ) => {\n\t\t\t\t\telement.style.pointerEvents = 'none';\n\t\t\t\t\telement.tabIndex = -1;\n\t\t\t\t\telement.setAttribute( 'aria-hidden', 'true' );\n\t\t\t\t} );\n\t\t\t} }\n\t\t/>\n\t);\n}\n"],
|
|
5
|
+
"mappings": ";AAAA,SAAS,UAAU;AACnB,SAAS,iBAAiB;AAC1B,SAAS,SAAS,iBAAiB;AACnC,SAAS,aAAa;AACtB,SAAS,oBAAoB;AAU3B;AARa,SAAR,cAA+B;AACrC,QAAM,UAAU,UAAW,CAAE,WAAY;AACxC,UAAM,EAAE,gBAAgB,IAAI,OAAQ,SAAU;AAC9C,UAAM,WAAW,gBAAiB,QAAQ,gBAAiB;AAC3D,WAAO,UAAU;AAAA,EAClB,GAAG,CAAC,CAAE;AAEN,SACC;AAAA,IAAC;AAAA;AAAA,MACA,KAAM,aAAc,SAAS;AAAA;AAAA,QAE5B,iBAAiB;AAAA,MAClB,CAAE;AAAA,MACF,OAAQ,GAAI,cAAe;AAAA,MAC3B,OAAQ;AAAA,QACP,SAAS;AAAA,QACT,OAAO;AAAA,QACP,QAAQ;AAAA,QACR,iBAAiB;AAAA,MAClB;AAAA,MACA,QAAS,CAAE,UAAW;AAErB,cAAM,WAAW,MAAM,OAAO;AAC9B,cAAM,oBAAoB,MAAM,UAAU,KAAM,QAAS;AACzD,0BAAkB,QAAS,CAAE,YAAa;AACzC,kBAAQ,MAAM,gBAAgB;AAC9B,kBAAQ,WAAW;AACnB,kBAAQ,aAAc,eAAe,MAAO;AAAA,QAC7C,CAAE;AAAA,MACH;AAAA;AAAA,EACD;AAEF;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../src/components/editor/use-adapt-editor-to-canvas.js"],
|
|
4
|
-
"sourcesContent": ["
|
|
5
|
-
"mappings": ";
|
|
4
|
+
"sourcesContent": ["import { useDispatch, useSelect, useRegistry } from '@wordpress/data';\nimport { store as blockEditorStore } from '@wordpress/block-editor';\nimport { store as editorStore } from '@wordpress/editor';\nimport { useLayoutEffect } from '@wordpress/element';\nimport { store as preferencesStore } from '@wordpress/preferences';\nimport { DEFAULT_DEVICE_TYPE } from '../block-editor/use-viewport-sync';\n\nexport function useAdaptEditorToCanvas( canvas ) {\n\tconst { clearSelectedBlock } = useDispatch( blockEditorStore );\n\tconst {\n\t\teditPost,\n\t\tsetDeviceType,\n\t\tclosePublishSidebar,\n\t\tsetIsListViewOpened,\n\t\tsetIsInserterOpened,\n\t} = useDispatch( editorStore );\n\tconst { get: getPreference } = useSelect( preferencesStore );\n\tconst { getCurrentPost } = useSelect( editorStore );\n\tconst registry = useRegistry();\n\tuseLayoutEffect( () => {\n\t\tconst isMediumOrBigger =\n\t\t\twindow.matchMedia( '(min-width: 782px)' ).matches;\n\t\tregistry.batch( () => {\n\t\t\tclearSelectedBlock();\n\t\t\tif ( getCurrentPost()?.type ) {\n\t\t\t\teditPost( { selection: undefined }, { undoIgnore: true } );\n\t\t\t}\n\t\t\tsetDeviceType( DEFAULT_DEVICE_TYPE );\n\t\t\tclosePublishSidebar();\n\t\t\tsetIsInserterOpened( false );\n\n\t\t\t// Check if the block list view should be open by default.\n\t\t\t// If `distractionFree` mode is enabled, the block list view should not be open.\n\t\t\t// This behavior is disabled for small viewports.\n\t\t\tif (\n\t\t\t\tisMediumOrBigger &&\n\t\t\t\tcanvas === 'edit' &&\n\t\t\t\tgetPreference( 'core', 'showListViewByDefault' ) &&\n\t\t\t\t! getPreference( 'core', 'distractionFree' )\n\t\t\t) {\n\t\t\t\tsetIsListViewOpened( true );\n\t\t\t} else {\n\t\t\t\tsetIsListViewOpened( false );\n\t\t\t}\n\t\t} );\n\t}, [\n\t\tcanvas,\n\t\tregistry,\n\t\tclearSelectedBlock,\n\t\teditPost,\n\t\tsetDeviceType,\n\t\tclosePublishSidebar,\n\t\tsetIsInserterOpened,\n\t\tsetIsListViewOpened,\n\t\tgetPreference,\n\t\tgetCurrentPost,\n\t] );\n}\n"],
|
|
5
|
+
"mappings": ";AAAA,SAAS,aAAa,WAAW,mBAAmB;AACpD,SAAS,SAAS,wBAAwB;AAC1C,SAAS,SAAS,mBAAmB;AACrC,SAAS,uBAAuB;AAChC,SAAS,SAAS,wBAAwB;AAC1C,SAAS,2BAA2B;AAE7B,SAAS,uBAAwB,QAAS;AAChD,QAAM,EAAE,mBAAmB,IAAI,YAAa,gBAAiB;AAC7D,QAAM;AAAA,IACL;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,EACD,IAAI,YAAa,WAAY;AAC7B,QAAM,EAAE,KAAK,cAAc,IAAI,UAAW,gBAAiB;AAC3D,QAAM,EAAE,eAAe,IAAI,UAAW,WAAY;AAClD,QAAM,WAAW,YAAY;AAC7B,kBAAiB,MAAM;AACtB,UAAM,mBACL,OAAO,WAAY,oBAAqB,EAAE;AAC3C,aAAS,MAAO,MAAM;AACrB,yBAAmB;AACnB,UAAK,eAAe,GAAG,MAAO;AAC7B,iBAAU,EAAE,WAAW,OAAU,GAAG,EAAE,YAAY,KAAK,CAAE;AAAA,MAC1D;AACA,oBAAe,mBAAoB;AACnC,0BAAoB;AACpB,0BAAqB,KAAM;AAK3B,UACC,oBACA,WAAW,UACX,cAAe,QAAQ,uBAAwB,KAC/C,CAAE,cAAe,QAAQ,iBAAkB,GAC1C;AACD,4BAAqB,IAAK;AAAA,MAC3B,OAAO;AACN,4BAAqB,KAAM;AAAA,MAC5B;AAAA,IACD,CAAE;AAAA,EACH,GAAG;AAAA,IACF;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,EACD,CAAE;AACH;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|