@wordpress/edit-site 6.11.0 → 6.12.1-next.082ed6819.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +2 -0
- package/build/components/add-new-template/utils.js +1 -2
- package/build/components/add-new-template/utils.js.map +1 -1
- package/build/components/app/index.js +0 -5
- package/build/components/app/index.js.map +1 -1
- package/build/components/block-editor/use-editor-iframe-props.js +6 -8
- package/build/components/block-editor/use-editor-iframe-props.js.map +1 -1
- package/build/components/block-editor/use-site-editor-settings.js +4 -12
- package/build/components/block-editor/use-site-editor-settings.js.map +1 -1
- package/build/components/editor/index.js +23 -27
- package/build/components/editor/index.js.map +1 -1
- package/build/components/editor/use-editor-title.js +37 -12
- package/build/components/editor/use-editor-title.js.map +1 -1
- package/build/components/editor/use-resolve-edited-entity.js +133 -0
- package/build/components/editor/use-resolve-edited-entity.js.map +1 -0
- package/build/components/editor-canvas-container/index.js +1 -1
- package/build/components/editor-canvas-container/index.js.map +1 -1
- package/build/components/global-styles/block-preview-panel.js +8 -10
- package/build/components/global-styles/block-preview-panel.js.map +1 -1
- package/build/components/global-styles/screen-block.js +18 -5
- package/build/components/global-styles/screen-block.js.map +1 -1
- package/build/components/global-styles/screen-revisions/revisions-buttons.js +24 -22
- package/build/components/global-styles/screen-revisions/revisions-buttons.js.map +1 -1
- package/build/components/global-styles/screen-style-variations.js +11 -5
- package/build/components/global-styles/screen-style-variations.js.map +1 -1
- package/build/components/global-styles/shadows-edit-panel.js +2 -3
- package/build/components/global-styles/shadows-edit-panel.js.map +1 -1
- package/build/components/global-styles/ui.js +42 -2
- package/build/components/global-styles/ui.js.map +1 -1
- package/build/components/global-styles-renderer/index.js +6 -8
- package/build/components/global-styles-renderer/index.js.map +1 -1
- package/build/components/global-styles-sidebar/index.js +17 -1
- package/build/components/global-styles-sidebar/index.js.map +1 -1
- package/build/components/layout/hooks.js +1 -10
- package/build/components/layout/hooks.js.map +1 -1
- package/build/components/layout/index.js +1 -0
- package/build/components/layout/index.js.map +1 -1
- package/build/components/page-patterns/fields.js +3 -7
- package/build/components/page-patterns/fields.js.map +1 -1
- package/build/components/page-patterns/header.js +2 -2
- package/build/components/page-patterns/header.js.map +1 -1
- package/build/components/page-patterns/use-patterns.js +4 -8
- package/build/components/page-patterns/use-patterns.js.map +1 -1
- package/build/components/page-templates/fields.js +1 -2
- package/build/components/page-templates/fields.js.map +1 -1
- package/build/components/post-edit/index.js +15 -11
- package/build/components/post-edit/index.js.map +1 -1
- package/build/components/post-list/index.js +13 -3
- package/build/components/post-list/index.js.map +1 -1
- package/build/components/posts-app/index.js +3 -4
- package/build/components/posts-app/index.js.map +1 -1
- package/build/components/posts-app-routes/home.js +48 -0
- package/build/components/posts-app-routes/home.js.map +1 -0
- package/build/components/posts-app-routes/index.js +37 -0
- package/build/components/posts-app-routes/index.js.map +1 -0
- package/build/components/posts-app-routes/posts-edit.js +44 -0
- package/build/components/posts-app-routes/posts-edit.js.map +1 -0
- package/build/components/posts-app-routes/posts-list-view-quick-edit.js +63 -0
- package/build/components/posts-app-routes/posts-list-view-quick-edit.js.map +1 -0
- package/build/components/posts-app-routes/posts-list-view.js +48 -0
- package/build/components/posts-app-routes/posts-list-view.js.map +1 -0
- package/build/components/posts-app-routes/posts-view-quick-edit.js +60 -0
- package/build/components/posts-app-routes/posts-view-quick-edit.js.map +1 -0
- package/build/components/posts-app-routes/posts-view.js +41 -0
- package/build/components/posts-app-routes/posts-view.js.map +1 -0
- package/build/components/sidebar/index.js +11 -3
- package/build/components/sidebar/index.js.map +1 -1
- package/build/components/sidebar-global-styles-wrapper/index.js +129 -0
- package/build/components/sidebar-global-styles-wrapper/index.js.map +1 -0
- package/build/components/sidebar-navigation-screen-details-footer/index.js +17 -23
- package/build/components/sidebar-navigation-screen-details-footer/index.js.map +1 -1
- package/build/components/sidebar-navigation-screen-global-styles/index.js +18 -90
- package/build/components/sidebar-navigation-screen-global-styles/index.js.map +1 -1
- package/build/components/sidebar-navigation-screen-main/index.js +43 -42
- package/build/components/sidebar-navigation-screen-main/index.js.map +1 -1
- package/build/components/sidebar-navigation-screen-patterns/use-pattern-categories.js +1 -1
- package/build/components/sidebar-navigation-screen-patterns/use-pattern-categories.js.map +1 -1
- package/build/components/sidebar-navigation-screen-patterns/use-template-part-areas.js +2 -3
- package/build/components/sidebar-navigation-screen-patterns/use-template-part-areas.js.map +1 -1
- package/build/components/site-editor-routes/index.js +1 -2
- package/build/components/site-editor-routes/index.js.map +1 -1
- package/build/components/site-editor-routes/styles-view.js +8 -2
- package/build/components/site-editor-routes/styles-view.js.map +1 -1
- package/build/components/site-hub/index.js +19 -6
- package/build/components/site-hub/index.js.map +1 -1
- package/build/components/style-book/constants.js +10 -3
- package/build/components/style-book/constants.js.map +1 -1
- package/build/components/style-book/examples.js +94 -2
- package/build/components/style-book/examples.js.map +1 -1
- package/build/components/style-book/index.js +70 -11
- package/build/components/style-book/index.js.map +1 -1
- package/build/components/welcome-guide/index.js +4 -2
- package/build/components/welcome-guide/index.js.map +1 -1
- package/build/components/welcome-guide/page.js +1 -9
- package/build/components/welcome-guide/page.js.map +1 -1
- package/build/components/welcome-guide/template.js +1 -12
- package/build/components/welcome-guide/template.js.map +1 -1
- package/build/hooks/commands/use-common-commands.js +15 -15
- package/build/hooks/commands/use-common-commands.js.map +1 -1
- package/build/index.js +1 -9
- package/build/index.js.map +1 -1
- package/build/posts.js +1 -0
- package/build/posts.js.map +1 -1
- package/build/store/actions.js +13 -0
- package/build/store/actions.js.map +1 -1
- package/build/store/selectors.js +21 -1
- package/build/store/selectors.js.map +1 -1
- package/build-module/components/add-new-template/utils.js +1 -2
- package/build-module/components/add-new-template/utils.js.map +1 -1
- package/build-module/components/app/index.js +0 -5
- package/build-module/components/app/index.js.map +1 -1
- package/build-module/components/block-editor/use-editor-iframe-props.js +6 -8
- package/build-module/components/block-editor/use-editor-iframe-props.js.map +1 -1
- package/build-module/components/block-editor/use-site-editor-settings.js +4 -12
- package/build-module/components/block-editor/use-site-editor-settings.js.map +1 -1
- package/build-module/components/editor/index.js +23 -27
- package/build-module/components/editor/index.js.map +1 -1
- package/build-module/components/editor/use-editor-title.js +37 -12
- package/build-module/components/editor/use-editor-title.js.map +1 -1
- package/build-module/components/editor/use-resolve-edited-entity.js +125 -0
- package/build-module/components/editor/use-resolve-edited-entity.js.map +1 -0
- package/build-module/components/editor-canvas-container/index.js +1 -1
- package/build-module/components/editor-canvas-container/index.js.map +1 -1
- package/build-module/components/global-styles/block-preview-panel.js +8 -10
- package/build-module/components/global-styles/block-preview-panel.js.map +1 -1
- package/build-module/components/global-styles/screen-block.js +18 -5
- package/build-module/components/global-styles/screen-block.js.map +1 -1
- package/build-module/components/global-styles/screen-revisions/revisions-buttons.js +25 -23
- package/build-module/components/global-styles/screen-revisions/revisions-buttons.js.map +1 -1
- package/build-module/components/global-styles/screen-style-variations.js +11 -5
- package/build-module/components/global-styles/screen-style-variations.js.map +1 -1
- package/build-module/components/global-styles/shadows-edit-panel.js +2 -3
- package/build-module/components/global-styles/shadows-edit-panel.js.map +1 -1
- package/build-module/components/global-styles/ui.js +42 -2
- package/build-module/components/global-styles/ui.js.map +1 -1
- package/build-module/components/global-styles-renderer/index.js +6 -8
- package/build-module/components/global-styles-renderer/index.js.map +1 -1
- package/build-module/components/global-styles-sidebar/index.js +18 -2
- package/build-module/components/global-styles-sidebar/index.js.map +1 -1
- package/build-module/components/layout/hooks.js +1 -9
- package/build-module/components/layout/hooks.js.map +1 -1
- package/build-module/components/layout/index.js +1 -0
- package/build-module/components/layout/index.js.map +1 -1
- package/build-module/components/page-patterns/fields.js +4 -8
- package/build-module/components/page-patterns/fields.js.map +1 -1
- package/build-module/components/page-patterns/header.js +2 -2
- package/build-module/components/page-patterns/header.js.map +1 -1
- package/build-module/components/page-patterns/use-patterns.js +4 -8
- package/build-module/components/page-patterns/use-patterns.js.map +1 -1
- package/build-module/components/page-templates/fields.js +1 -2
- package/build-module/components/page-templates/fields.js.map +1 -1
- package/build-module/components/post-edit/index.js +14 -10
- package/build-module/components/post-edit/index.js.map +1 -1
- package/build-module/components/post-list/index.js +13 -3
- package/build-module/components/post-list/index.js.map +1 -1
- package/build-module/components/posts-app/index.js +3 -4
- package/build-module/components/posts-app/index.js.map +1 -1
- package/build-module/components/posts-app-routes/home.js +40 -0
- package/build-module/components/posts-app-routes/home.js.map +1 -0
- package/build-module/components/posts-app-routes/index.js +30 -0
- package/build-module/components/posts-app-routes/index.js.map +1 -0
- package/build-module/components/posts-app-routes/posts-edit.js +36 -0
- package/build-module/components/posts-app-routes/posts-edit.js.map +1 -0
- package/build-module/components/posts-app-routes/posts-list-view-quick-edit.js +55 -0
- package/build-module/components/posts-app-routes/posts-list-view-quick-edit.js.map +1 -0
- package/build-module/components/posts-app-routes/posts-list-view.js +40 -0
- package/build-module/components/posts-app-routes/posts-list-view.js.map +1 -0
- package/build-module/components/posts-app-routes/posts-view-quick-edit.js +52 -0
- package/build-module/components/posts-app-routes/posts-view-quick-edit.js.map +1 -0
- package/build-module/components/posts-app-routes/posts-view.js +33 -0
- package/build-module/components/posts-app-routes/posts-view.js.map +1 -0
- package/build-module/components/sidebar/index.js +11 -3
- package/build-module/components/sidebar/index.js.map +1 -1
- package/build-module/components/sidebar-global-styles-wrapper/index.js +121 -0
- package/build-module/components/sidebar-global-styles-wrapper/index.js.map +1 -0
- package/build-module/components/sidebar-navigation-screen-details-footer/index.js +20 -26
- package/build-module/components/sidebar-navigation-screen-details-footer/index.js.map +1 -1
- package/build-module/components/sidebar-navigation-screen-global-styles/index.js +19 -91
- package/build-module/components/sidebar-navigation-screen-global-styles/index.js.map +1 -1
- package/build-module/components/sidebar-navigation-screen-main/index.js +43 -43
- package/build-module/components/sidebar-navigation-screen-main/index.js.map +1 -1
- package/build-module/components/sidebar-navigation-screen-patterns/use-pattern-categories.js +1 -1
- package/build-module/components/sidebar-navigation-screen-patterns/use-pattern-categories.js.map +1 -1
- package/build-module/components/sidebar-navigation-screen-patterns/use-template-part-areas.js +3 -4
- package/build-module/components/sidebar-navigation-screen-patterns/use-template-part-areas.js.map +1 -1
- package/build-module/components/site-editor-routes/index.js +1 -2
- package/build-module/components/site-editor-routes/index.js.map +1 -1
- package/build-module/components/site-editor-routes/styles-view.js +8 -2
- package/build-module/components/site-editor-routes/styles-view.js.map +1 -1
- package/build-module/components/site-hub/index.js +19 -6
- package/build-module/components/site-hub/index.js.map +1 -1
- package/build-module/components/style-book/constants.js +10 -3
- package/build-module/components/style-book/constants.js.map +1 -1
- package/build-module/components/style-book/examples.js +94 -2
- package/build-module/components/style-book/examples.js.map +1 -1
- package/build-module/components/style-book/index.js +71 -12
- package/build-module/components/style-book/index.js.map +1 -1
- package/build-module/components/welcome-guide/index.js +4 -2
- package/build-module/components/welcome-guide/index.js.map +1 -1
- package/build-module/components/welcome-guide/page.js +1 -9
- package/build-module/components/welcome-guide/page.js.map +1 -1
- package/build-module/components/welcome-guide/template.js +1 -11
- package/build-module/components/welcome-guide/template.js.map +1 -1
- package/build-module/hooks/commands/use-common-commands.js +15 -15
- package/build-module/hooks/commands/use-common-commands.js.map +1 -1
- package/build-module/index.js +2 -10
- package/build-module/index.js.map +1 -1
- package/build-module/posts.js +1 -0
- package/build-module/posts.js.map +1 -1
- package/build-module/store/actions.js +13 -0
- package/build-module/store/actions.js.map +1 -1
- package/build-module/store/selectors.js +21 -1
- package/build-module/store/selectors.js.map +1 -1
- package/build-style/posts-rtl.css +106 -16
- package/build-style/posts.css +106 -16
- package/build-style/style-rtl.css +176 -78
- package/build-style/style.css +176 -78
- package/package.json +39 -40
- package/src/components/add-new-template/utils.js +2 -2
- package/src/components/app/index.js +0 -5
- package/src/components/block-editor/use-editor-iframe-props.js +2 -3
- package/src/components/block-editor/use-site-editor-settings.js +7 -21
- package/src/components/editor/index.js +31 -30
- package/src/components/editor/use-editor-title.js +50 -13
- package/src/components/editor/use-resolve-edited-entity.js +132 -0
- package/src/components/editor-canvas-container/index.js +1 -1
- package/src/components/editor-canvas-container/style.scss +0 -1
- package/src/components/global-styles/block-preview-panel.js +10 -10
- package/src/components/global-styles/screen-block.js +26 -8
- package/src/components/global-styles/screen-revisions/revisions-buttons.js +28 -31
- package/src/components/global-styles/screen-revisions/style.scss +11 -17
- package/src/components/global-styles/screen-style-variations.js +14 -5
- package/src/components/global-styles/shadows-edit-panel.js +4 -2
- package/src/components/global-styles/ui.js +41 -1
- package/src/components/global-styles-renderer/index.js +4 -10
- package/src/components/global-styles-sidebar/index.js +16 -2
- package/src/components/layout/hooks.js +1 -7
- package/src/components/layout/index.js +6 -1
- package/src/components/page-patterns/fields.js +6 -12
- package/src/components/page-patterns/header.js +3 -2
- package/src/components/page-patterns/style.scss +0 -5
- package/src/components/page-patterns/use-patterns.js +9 -7
- package/src/components/page-templates/fields.js +2 -3
- package/src/components/page-templates/style.scss +1 -0
- package/src/components/post-edit/index.js +37 -32
- package/src/components/post-edit/style.scss +7 -0
- package/src/components/post-list/index.js +10 -5
- package/src/components/post-list/style.scss +29 -3
- package/src/components/posts-app/index.js +3 -4
- package/src/components/posts-app-routes/home.js +36 -0
- package/src/components/posts-app-routes/index.js +36 -0
- package/src/components/posts-app-routes/posts-edit.js +31 -0
- package/src/components/posts-app-routes/posts-list-view-quick-edit.js +52 -0
- package/src/components/posts-app-routes/posts-list-view.js +40 -0
- package/src/components/posts-app-routes/posts-view-quick-edit.js +49 -0
- package/src/components/posts-app-routes/posts-view.js +35 -0
- package/src/components/sidebar/index.js +23 -7
- package/src/components/sidebar-global-styles-wrapper/index.js +150 -0
- package/src/components/sidebar-global-styles-wrapper/style.scss +35 -0
- package/src/components/sidebar-navigation-item/style.scss +2 -2
- package/src/components/sidebar-navigation-screen/style.scss +7 -2
- package/src/components/sidebar-navigation-screen-details-footer/index.js +27 -38
- package/src/components/sidebar-navigation-screen-details-footer/style.scss +0 -4
- package/src/components/sidebar-navigation-screen-global-styles/index.js +19 -103
- package/src/components/sidebar-navigation-screen-main/index.js +46 -45
- package/src/components/sidebar-navigation-screen-navigation-menus/style.scss +8 -0
- package/src/components/sidebar-navigation-screen-patterns/use-pattern-categories.js +1 -1
- package/src/components/sidebar-navigation-screen-patterns/use-template-part-areas.js +4 -4
- package/src/components/site-editor-routes/README.md +2 -2
- package/src/components/site-editor-routes/index.js +0 -2
- package/src/components/site-editor-routes/styles-view.js +11 -1
- package/src/components/site-hub/index.js +33 -16
- package/src/components/site-hub/style.scss +1 -1
- package/src/components/site-icon/style.scss +16 -0
- package/src/components/style-book/constants.ts +11 -3
- package/src/components/style-book/examples.tsx +128 -2
- package/src/components/style-book/index.js +86 -8
- package/src/components/welcome-guide/index.js +3 -3
- package/src/components/welcome-guide/page.js +1 -7
- package/src/components/welcome-guide/template.js +1 -8
- package/src/hooks/commands/use-common-commands.js +253 -246
- package/src/index.js +2 -13
- package/src/posts.js +1 -0
- package/src/store/actions.js +15 -0
- package/src/store/selectors.js +24 -1
- package/src/style.scss +2 -5
- package/build/components/async/index.js +0 -51
- package/build/components/async/index.js.map +0 -1
- package/build/components/post-fields/index.js +0 -290
- package/build/components/post-fields/index.js.map +0 -1
- package/build/components/posts-app/router.js +0 -85
- package/build/components/posts-app/router.js.map +0 -1
- package/build/components/sidebar-navigation-screen-details-panel/index.js +0 -54
- package/build/components/sidebar-navigation-screen-details-panel/index.js.map +0 -1
- package/build/components/sidebar-navigation-screen-details-panel/sidebar-navigation-screen-details-panel-label.js +0 -21
- package/build/components/sidebar-navigation-screen-details-panel/sidebar-navigation-screen-details-panel-label.js.map +0 -1
- package/build/components/sidebar-navigation-screen-details-panel/sidebar-navigation-screen-details-panel-row.js +0 -33
- package/build/components/sidebar-navigation-screen-details-panel/sidebar-navigation-screen-details-panel-row.js.map +0 -1
- package/build/components/sidebar-navigation-screen-details-panel/sidebar-navigation-screen-details-panel-value.js +0 -21
- package/build/components/sidebar-navigation-screen-details-panel/sidebar-navigation-screen-details-panel-value.js.map +0 -1
- package/build/components/site-editor-routes/styles-edit.js +0 -28
- package/build/components/site-editor-routes/styles-edit.js.map +0 -1
- package/build/components/sync-state-with-url/use-init-edited-entity-from-url.js +0 -219
- package/build/components/sync-state-with-url/use-init-edited-entity-from-url.js.map +0 -1
- package/build/components/use-edited-entity-record/index.js +0 -60
- package/build/components/use-edited-entity-record/index.js.map +0 -1
- package/build/hooks/commands/use-edit-mode-commands.js +0 -179
- package/build/hooks/commands/use-edit-mode-commands.js.map +0 -1
- package/build-module/components/async/index.js +0 -44
- package/build-module/components/async/index.js.map +0 -1
- package/build-module/components/post-fields/index.js +0 -283
- package/build-module/components/post-fields/index.js.map +0 -1
- package/build-module/components/posts-app/router.js +0 -77
- package/build-module/components/posts-app/router.js.map +0 -1
- package/build-module/components/sidebar-navigation-screen-details-panel/index.js +0 -29
- package/build-module/components/sidebar-navigation-screen-details-panel/index.js.map +0 -1
- package/build-module/components/sidebar-navigation-screen-details-panel/sidebar-navigation-screen-details-panel-label.js +0 -14
- package/build-module/components/sidebar-navigation-screen-details-panel/sidebar-navigation-screen-details-panel-label.js.map +0 -1
- package/build-module/components/sidebar-navigation-screen-details-panel/sidebar-navigation-screen-details-panel-row.js +0 -25
- package/build-module/components/sidebar-navigation-screen-details-panel/sidebar-navigation-screen-details-panel-row.js.map +0 -1
- package/build-module/components/sidebar-navigation-screen-details-panel/sidebar-navigation-screen-details-panel-value.js +0 -14
- package/build-module/components/sidebar-navigation-screen-details-panel/sidebar-navigation-screen-details-panel-value.js.map +0 -1
- package/build-module/components/site-editor-routes/styles-edit.js +0 -20
- package/build-module/components/site-editor-routes/styles-edit.js.map +0 -1
- package/build-module/components/sync-state-with-url/use-init-edited-entity-from-url.js +0 -212
- package/build-module/components/sync-state-with-url/use-init-edited-entity-from-url.js.map +0 -1
- package/build-module/components/use-edited-entity-record/index.js +0 -53
- package/build-module/components/use-edited-entity-record/index.js.map +0 -1
- package/build-module/hooks/commands/use-edit-mode-commands.js +0 -171
- package/build-module/hooks/commands/use-edit-mode-commands.js.map +0 -1
- package/src/components/async/index.js +0 -43
- package/src/components/post-fields/index.js +0 -361
- package/src/components/post-fields/style.scss +0 -3
- package/src/components/posts-app/router.js +0 -69
- package/src/components/sidebar-navigation-screen-details-panel/index.js +0 -40
- package/src/components/sidebar-navigation-screen-details-panel/sidebar-navigation-screen-details-panel-label.js +0 -14
- package/src/components/sidebar-navigation-screen-details-panel/sidebar-navigation-screen-details-panel-row.js +0 -31
- package/src/components/sidebar-navigation-screen-details-panel/sidebar-navigation-screen-details-panel-value.js +0 -14
- package/src/components/sidebar-navigation-screen-details-panel/style.scss +0 -26
- package/src/components/site-editor-routes/styles-edit.js +0 -17
- package/src/components/sync-state-with-url/use-init-edited-entity-from-url.js +0 -267
- package/src/components/use-edited-entity-record/index.js +0 -58
- package/src/hooks/commands/use-edit-mode-commands.js +0 -168
- package/src/store/test/actions.js +0 -83
- package/src/store/test/reducer.js +0 -69
- package/src/store/test/selectors.js +0 -41
|
@@ -1,212 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* WordPress dependencies
|
|
3
|
-
*/
|
|
4
|
-
import { useEffect, useMemo } from '@wordpress/element';
|
|
5
|
-
import { useSelect, useDispatch } from '@wordpress/data';
|
|
6
|
-
import { store as coreDataStore } from '@wordpress/core-data';
|
|
7
|
-
import { privateApis as routerPrivateApis } from '@wordpress/router';
|
|
8
|
-
import { store as blockEditorStore } from '@wordpress/block-editor';
|
|
9
|
-
|
|
10
|
-
/**
|
|
11
|
-
* Internal dependencies
|
|
12
|
-
*/
|
|
13
|
-
import { store as editSiteStore } from '../../store';
|
|
14
|
-
import { unlock } from '../../lock-unlock';
|
|
15
|
-
import { TEMPLATE_POST_TYPE, TEMPLATE_PART_POST_TYPE, NAVIGATION_POST_TYPE, PATTERN_TYPES } from '../../utils/constants';
|
|
16
|
-
const {
|
|
17
|
-
useLocation
|
|
18
|
-
} = unlock(routerPrivateApis);
|
|
19
|
-
const postTypesWithoutParentTemplate = [TEMPLATE_POST_TYPE, TEMPLATE_PART_POST_TYPE, NAVIGATION_POST_TYPE, PATTERN_TYPES.user];
|
|
20
|
-
const authorizedPostTypes = ['page', 'post'];
|
|
21
|
-
function useResolveEditedEntityAndContext({
|
|
22
|
-
postId,
|
|
23
|
-
postType
|
|
24
|
-
}) {
|
|
25
|
-
const {
|
|
26
|
-
hasLoadedAllDependencies,
|
|
27
|
-
homepageId,
|
|
28
|
-
postsPageId,
|
|
29
|
-
url,
|
|
30
|
-
frontPageTemplateId
|
|
31
|
-
} = useSelect(select => {
|
|
32
|
-
const {
|
|
33
|
-
getEntityRecord,
|
|
34
|
-
getEntityRecords
|
|
35
|
-
} = select(coreDataStore);
|
|
36
|
-
const siteData = getEntityRecord('root', 'site');
|
|
37
|
-
const base = getEntityRecord('root', '__unstableBase');
|
|
38
|
-
const templates = getEntityRecords('postType', TEMPLATE_POST_TYPE, {
|
|
39
|
-
per_page: -1
|
|
40
|
-
});
|
|
41
|
-
const _homepageId = siteData?.show_on_front === 'page' && ['number', 'string'].includes(typeof siteData.page_on_front) && !!+siteData.page_on_front // We also need to check if it's not zero(`0`).
|
|
42
|
-
? siteData.page_on_front.toString() : null;
|
|
43
|
-
const _postsPageId = siteData?.show_on_front === 'page' && ['number', 'string'].includes(typeof siteData.page_for_posts) ? siteData.page_for_posts.toString() : null;
|
|
44
|
-
let _frontPageTemplateId;
|
|
45
|
-
if (templates) {
|
|
46
|
-
const frontPageTemplate = templates.find(t => t.slug === 'front-page');
|
|
47
|
-
_frontPageTemplateId = frontPageTemplate ? frontPageTemplate.id : false;
|
|
48
|
-
}
|
|
49
|
-
return {
|
|
50
|
-
hasLoadedAllDependencies: !!base && !!siteData,
|
|
51
|
-
homepageId: _homepageId,
|
|
52
|
-
postsPageId: _postsPageId,
|
|
53
|
-
url: base?.home,
|
|
54
|
-
frontPageTemplateId: _frontPageTemplateId
|
|
55
|
-
};
|
|
56
|
-
}, []);
|
|
57
|
-
|
|
58
|
-
/**
|
|
59
|
-
* This is a hook that recreates the logic to resolve a template for a given WordPress postID postTypeId
|
|
60
|
-
* in order to match the frontend as closely as possible in the site editor.
|
|
61
|
-
*
|
|
62
|
-
* It is not possible to rely on the server logic because there maybe unsaved changes that impact the template resolution.
|
|
63
|
-
*/
|
|
64
|
-
const resolvedTemplateId = useSelect(select => {
|
|
65
|
-
// If we're rendering a post type that doesn't have a template
|
|
66
|
-
// no need to resolve its template.
|
|
67
|
-
if (postTypesWithoutParentTemplate.includes(postType) && postId) {
|
|
68
|
-
return undefined;
|
|
69
|
-
}
|
|
70
|
-
|
|
71
|
-
// Don't trigger resolution for multi-selected posts.
|
|
72
|
-
if (postId && postId.includes(',')) {
|
|
73
|
-
return undefined;
|
|
74
|
-
}
|
|
75
|
-
const {
|
|
76
|
-
getEditedEntityRecord,
|
|
77
|
-
getEntityRecords,
|
|
78
|
-
getDefaultTemplateId,
|
|
79
|
-
__experimentalGetTemplateForLink
|
|
80
|
-
} = select(coreDataStore);
|
|
81
|
-
function resolveTemplateForPostTypeAndId(postTypeToResolve, postIdToResolve) {
|
|
82
|
-
// For the front page, we always use the front page template if existing.
|
|
83
|
-
if (postTypeToResolve === 'page' && homepageId === postIdToResolve) {
|
|
84
|
-
// We're still checking whether the front page template exists.
|
|
85
|
-
// Don't resolve the template yet.
|
|
86
|
-
if (frontPageTemplateId === undefined) {
|
|
87
|
-
return undefined;
|
|
88
|
-
}
|
|
89
|
-
if (!!frontPageTemplateId) {
|
|
90
|
-
return frontPageTemplateId;
|
|
91
|
-
}
|
|
92
|
-
}
|
|
93
|
-
const editedEntity = getEditedEntityRecord('postType', postTypeToResolve, postIdToResolve);
|
|
94
|
-
if (!editedEntity) {
|
|
95
|
-
return undefined;
|
|
96
|
-
}
|
|
97
|
-
// Check if the current page is the posts page.
|
|
98
|
-
if (postTypeToResolve === 'page' && postsPageId === postIdToResolve) {
|
|
99
|
-
return __experimentalGetTemplateForLink(editedEntity.link)?.id;
|
|
100
|
-
}
|
|
101
|
-
// First see if the post/page has an assigned template and fetch it.
|
|
102
|
-
const currentTemplateSlug = editedEntity.template;
|
|
103
|
-
if (currentTemplateSlug) {
|
|
104
|
-
const currentTemplate = getEntityRecords('postType', TEMPLATE_POST_TYPE, {
|
|
105
|
-
per_page: -1
|
|
106
|
-
})?.find(({
|
|
107
|
-
slug
|
|
108
|
-
}) => slug === currentTemplateSlug);
|
|
109
|
-
if (currentTemplate) {
|
|
110
|
-
return currentTemplate.id;
|
|
111
|
-
}
|
|
112
|
-
}
|
|
113
|
-
// If no template is assigned, use the default template.
|
|
114
|
-
let slugToCheck;
|
|
115
|
-
// In `draft` status we might not have a slug available, so we use the `single`
|
|
116
|
-
// post type templates slug(ex page, single-post, single-product etc..).
|
|
117
|
-
// Pages do not need the `single` prefix in the slug to be prioritized
|
|
118
|
-
// through template hierarchy.
|
|
119
|
-
if (editedEntity.slug) {
|
|
120
|
-
slugToCheck = postTypeToResolve === 'page' ? `${postTypeToResolve}-${editedEntity.slug}` : `single-${postTypeToResolve}-${editedEntity.slug}`;
|
|
121
|
-
} else {
|
|
122
|
-
slugToCheck = postTypeToResolve === 'page' ? 'page' : `single-${postTypeToResolve}`;
|
|
123
|
-
}
|
|
124
|
-
return getDefaultTemplateId({
|
|
125
|
-
slug: slugToCheck
|
|
126
|
-
});
|
|
127
|
-
}
|
|
128
|
-
if (!hasLoadedAllDependencies) {
|
|
129
|
-
return undefined;
|
|
130
|
-
}
|
|
131
|
-
|
|
132
|
-
// If we're rendering a specific page, we need to resolve its template.
|
|
133
|
-
// The site editor only supports pages for now, not other CPTs.
|
|
134
|
-
if (postType && postId && authorizedPostTypes.includes(postType)) {
|
|
135
|
-
return resolveTemplateForPostTypeAndId(postType, postId);
|
|
136
|
-
}
|
|
137
|
-
|
|
138
|
-
// If we're rendering the home page, and we have a static home page, resolve its template.
|
|
139
|
-
if (homepageId) {
|
|
140
|
-
return resolveTemplateForPostTypeAndId('page', homepageId);
|
|
141
|
-
}
|
|
142
|
-
|
|
143
|
-
// If we're not rendering a specific page, use the front page template.
|
|
144
|
-
if (url) {
|
|
145
|
-
const template = __experimentalGetTemplateForLink(url);
|
|
146
|
-
return template?.id;
|
|
147
|
-
}
|
|
148
|
-
}, [homepageId, postsPageId, hasLoadedAllDependencies, url, postId, postType, frontPageTemplateId]);
|
|
149
|
-
const context = useMemo(() => {
|
|
150
|
-
if (postTypesWithoutParentTemplate.includes(postType) && postId) {
|
|
151
|
-
return {};
|
|
152
|
-
}
|
|
153
|
-
if (postType && postId && authorizedPostTypes.includes(postType)) {
|
|
154
|
-
return {
|
|
155
|
-
postType,
|
|
156
|
-
postId
|
|
157
|
-
};
|
|
158
|
-
}
|
|
159
|
-
// TODO: for post types lists we should probably not render the front page, but maybe a placeholder
|
|
160
|
-
// with a message like "Select a page" or something similar.
|
|
161
|
-
if (homepageId) {
|
|
162
|
-
return {
|
|
163
|
-
postType: 'page',
|
|
164
|
-
postId: homepageId
|
|
165
|
-
};
|
|
166
|
-
}
|
|
167
|
-
return {};
|
|
168
|
-
}, [homepageId, postType, postId]);
|
|
169
|
-
if (postTypesWithoutParentTemplate.includes(postType) && postId) {
|
|
170
|
-
return {
|
|
171
|
-
isReady: true,
|
|
172
|
-
postType,
|
|
173
|
-
postId,
|
|
174
|
-
context
|
|
175
|
-
};
|
|
176
|
-
}
|
|
177
|
-
if (hasLoadedAllDependencies) {
|
|
178
|
-
return {
|
|
179
|
-
isReady: resolvedTemplateId !== undefined,
|
|
180
|
-
postType: TEMPLATE_POST_TYPE,
|
|
181
|
-
postId: resolvedTemplateId,
|
|
182
|
-
context
|
|
183
|
-
};
|
|
184
|
-
}
|
|
185
|
-
return {
|
|
186
|
-
isReady: false
|
|
187
|
-
};
|
|
188
|
-
}
|
|
189
|
-
export default function useInitEditedEntityFromURL() {
|
|
190
|
-
const {
|
|
191
|
-
params = {}
|
|
192
|
-
} = useLocation();
|
|
193
|
-
const {
|
|
194
|
-
postType,
|
|
195
|
-
postId,
|
|
196
|
-
context,
|
|
197
|
-
isReady
|
|
198
|
-
} = useResolveEditedEntityAndContext(params);
|
|
199
|
-
const {
|
|
200
|
-
setEditedEntity
|
|
201
|
-
} = useDispatch(editSiteStore);
|
|
202
|
-
const {
|
|
203
|
-
resetZoomLevel
|
|
204
|
-
} = unlock(useDispatch(blockEditorStore));
|
|
205
|
-
useEffect(() => {
|
|
206
|
-
if (isReady) {
|
|
207
|
-
resetZoomLevel();
|
|
208
|
-
setEditedEntity(postType, postId, context);
|
|
209
|
-
}
|
|
210
|
-
}, [isReady, postType, postId, context, setEditedEntity, resetZoomLevel]);
|
|
211
|
-
}
|
|
212
|
-
//# sourceMappingURL=use-init-edited-entity-from-url.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"names":["useEffect","useMemo","useSelect","useDispatch","store","coreDataStore","privateApis","routerPrivateApis","blockEditorStore","editSiteStore","unlock","TEMPLATE_POST_TYPE","TEMPLATE_PART_POST_TYPE","NAVIGATION_POST_TYPE","PATTERN_TYPES","useLocation","postTypesWithoutParentTemplate","user","authorizedPostTypes","useResolveEditedEntityAndContext","postId","postType","hasLoadedAllDependencies","homepageId","postsPageId","url","frontPageTemplateId","select","getEntityRecord","getEntityRecords","siteData","base","templates","per_page","_homepageId","show_on_front","includes","page_on_front","toString","_postsPageId","page_for_posts","_frontPageTemplateId","frontPageTemplate","find","t","slug","id","home","resolvedTemplateId","undefined","getEditedEntityRecord","getDefaultTemplateId","__experimentalGetTemplateForLink","resolveTemplateForPostTypeAndId","postTypeToResolve","postIdToResolve","editedEntity","link","currentTemplateSlug","template","currentTemplate","slugToCheck","context","isReady","useInitEditedEntityFromURL","params","setEditedEntity","resetZoomLevel"],"sources":["@wordpress/edit-site/src/components/sync-state-with-url/use-init-edited-entity-from-url.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { useEffect, useMemo } from '@wordpress/element';\nimport { useSelect, useDispatch } from '@wordpress/data';\nimport { store as coreDataStore } from '@wordpress/core-data';\nimport { privateApis as routerPrivateApis } from '@wordpress/router';\nimport { store as blockEditorStore } from '@wordpress/block-editor';\n\n/**\n * Internal dependencies\n */\nimport { store as editSiteStore } from '../../store';\nimport { unlock } from '../../lock-unlock';\nimport {\n\tTEMPLATE_POST_TYPE,\n\tTEMPLATE_PART_POST_TYPE,\n\tNAVIGATION_POST_TYPE,\n\tPATTERN_TYPES,\n} from '../../utils/constants';\n\nconst { useLocation } = unlock( routerPrivateApis );\n\nconst postTypesWithoutParentTemplate = [\n\tTEMPLATE_POST_TYPE,\n\tTEMPLATE_PART_POST_TYPE,\n\tNAVIGATION_POST_TYPE,\n\tPATTERN_TYPES.user,\n];\n\nconst authorizedPostTypes = [ 'page', 'post' ];\n\nfunction useResolveEditedEntityAndContext( { postId, postType } ) {\n\tconst {\n\t\thasLoadedAllDependencies,\n\t\thomepageId,\n\t\tpostsPageId,\n\t\turl,\n\t\tfrontPageTemplateId,\n\t} = useSelect( ( select ) => {\n\t\tconst { getEntityRecord, getEntityRecords } = select( coreDataStore );\n\t\tconst siteData = getEntityRecord( 'root', 'site' );\n\t\tconst base = getEntityRecord( 'root', '__unstableBase' );\n\t\tconst templates = getEntityRecords( 'postType', TEMPLATE_POST_TYPE, {\n\t\t\tper_page: -1,\n\t\t} );\n\t\tconst _homepageId =\n\t\t\tsiteData?.show_on_front === 'page' &&\n\t\t\t[ 'number', 'string' ].includes( typeof siteData.page_on_front ) &&\n\t\t\t!! +siteData.page_on_front // We also need to check if it's not zero(`0`).\n\t\t\t\t? siteData.page_on_front.toString()\n\t\t\t\t: null;\n\t\tconst _postsPageId =\n\t\t\tsiteData?.show_on_front === 'page' &&\n\t\t\t[ 'number', 'string' ].includes( typeof siteData.page_for_posts )\n\t\t\t\t? siteData.page_for_posts.toString()\n\t\t\t\t: null;\n\t\tlet _frontPageTemplateId;\n\t\tif ( templates ) {\n\t\t\tconst frontPageTemplate = templates.find(\n\t\t\t\t( t ) => t.slug === 'front-page'\n\t\t\t);\n\t\t\t_frontPageTemplateId = frontPageTemplate\n\t\t\t\t? frontPageTemplate.id\n\t\t\t\t: false;\n\t\t}\n\t\treturn {\n\t\t\thasLoadedAllDependencies: !! base && !! siteData,\n\t\t\thomepageId: _homepageId,\n\t\t\tpostsPageId: _postsPageId,\n\t\t\turl: base?.home,\n\t\t\tfrontPageTemplateId: _frontPageTemplateId,\n\t\t};\n\t}, [] );\n\n\t/**\n\t * This is a hook that recreates the logic to resolve a template for a given WordPress postID postTypeId\n\t * in order to match the frontend as closely as possible in the site editor.\n\t *\n\t * It is not possible to rely on the server logic because there maybe unsaved changes that impact the template resolution.\n\t */\n\tconst resolvedTemplateId = useSelect(\n\t\t( select ) => {\n\t\t\t// If we're rendering a post type that doesn't have a template\n\t\t\t// no need to resolve its template.\n\t\t\tif (\n\t\t\t\tpostTypesWithoutParentTemplate.includes( postType ) &&\n\t\t\t\tpostId\n\t\t\t) {\n\t\t\t\treturn undefined;\n\t\t\t}\n\n\t\t\t// Don't trigger resolution for multi-selected posts.\n\t\t\tif ( postId && postId.includes( ',' ) ) {\n\t\t\t\treturn undefined;\n\t\t\t}\n\n\t\t\tconst {\n\t\t\t\tgetEditedEntityRecord,\n\t\t\t\tgetEntityRecords,\n\t\t\t\tgetDefaultTemplateId,\n\t\t\t\t__experimentalGetTemplateForLink,\n\t\t\t} = select( coreDataStore );\n\n\t\t\tfunction resolveTemplateForPostTypeAndId(\n\t\t\t\tpostTypeToResolve,\n\t\t\t\tpostIdToResolve\n\t\t\t) {\n\t\t\t\t// For the front page, we always use the front page template if existing.\n\t\t\t\tif (\n\t\t\t\t\tpostTypeToResolve === 'page' &&\n\t\t\t\t\thomepageId === postIdToResolve\n\t\t\t\t) {\n\t\t\t\t\t// We're still checking whether the front page template exists.\n\t\t\t\t\t// Don't resolve the template yet.\n\t\t\t\t\tif ( frontPageTemplateId === undefined ) {\n\t\t\t\t\t\treturn undefined;\n\t\t\t\t\t}\n\n\t\t\t\t\tif ( !! frontPageTemplateId ) {\n\t\t\t\t\t\treturn frontPageTemplateId;\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\tconst editedEntity = getEditedEntityRecord(\n\t\t\t\t\t'postType',\n\t\t\t\t\tpostTypeToResolve,\n\t\t\t\t\tpostIdToResolve\n\t\t\t\t);\n\t\t\t\tif ( ! editedEntity ) {\n\t\t\t\t\treturn undefined;\n\t\t\t\t}\n\t\t\t\t// Check if the current page is the posts page.\n\t\t\t\tif (\n\t\t\t\t\tpostTypeToResolve === 'page' &&\n\t\t\t\t\tpostsPageId === postIdToResolve\n\t\t\t\t) {\n\t\t\t\t\treturn __experimentalGetTemplateForLink( editedEntity.link )\n\t\t\t\t\t\t?.id;\n\t\t\t\t}\n\t\t\t\t// First see if the post/page has an assigned template and fetch it.\n\t\t\t\tconst currentTemplateSlug = editedEntity.template;\n\t\t\t\tif ( currentTemplateSlug ) {\n\t\t\t\t\tconst currentTemplate = getEntityRecords(\n\t\t\t\t\t\t'postType',\n\t\t\t\t\t\tTEMPLATE_POST_TYPE,\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tper_page: -1,\n\t\t\t\t\t\t}\n\t\t\t\t\t)?.find( ( { slug } ) => slug === currentTemplateSlug );\n\t\t\t\t\tif ( currentTemplate ) {\n\t\t\t\t\t\treturn currentTemplate.id;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\t// If no template is assigned, use the default template.\n\t\t\t\tlet slugToCheck;\n\t\t\t\t// In `draft` status we might not have a slug available, so we use the `single`\n\t\t\t\t// post type templates slug(ex page, single-post, single-product etc..).\n\t\t\t\t// Pages do not need the `single` prefix in the slug to be prioritized\n\t\t\t\t// through template hierarchy.\n\t\t\t\tif ( editedEntity.slug ) {\n\t\t\t\t\tslugToCheck =\n\t\t\t\t\t\tpostTypeToResolve === 'page'\n\t\t\t\t\t\t\t? `${ postTypeToResolve }-${ editedEntity.slug }`\n\t\t\t\t\t\t\t: `single-${ postTypeToResolve }-${ editedEntity.slug }`;\n\t\t\t\t} else {\n\t\t\t\t\tslugToCheck =\n\t\t\t\t\t\tpostTypeToResolve === 'page'\n\t\t\t\t\t\t\t? 'page'\n\t\t\t\t\t\t\t: `single-${ postTypeToResolve }`;\n\t\t\t\t}\n\t\t\t\treturn getDefaultTemplateId( {\n\t\t\t\t\tslug: slugToCheck,\n\t\t\t\t} );\n\t\t\t}\n\n\t\t\tif ( ! hasLoadedAllDependencies ) {\n\t\t\t\treturn undefined;\n\t\t\t}\n\n\t\t\t// If we're rendering a specific page, we need to resolve its template.\n\t\t\t// The site editor only supports pages for now, not other CPTs.\n\t\t\tif (\n\t\t\t\tpostType &&\n\t\t\t\tpostId &&\n\t\t\t\tauthorizedPostTypes.includes( postType )\n\t\t\t) {\n\t\t\t\treturn resolveTemplateForPostTypeAndId( postType, postId );\n\t\t\t}\n\n\t\t\t// If we're rendering the home page, and we have a static home page, resolve its template.\n\t\t\tif ( homepageId ) {\n\t\t\t\treturn resolveTemplateForPostTypeAndId( 'page', homepageId );\n\t\t\t}\n\n\t\t\t// If we're not rendering a specific page, use the front page template.\n\t\t\tif ( url ) {\n\t\t\t\tconst template = __experimentalGetTemplateForLink( url );\n\t\t\t\treturn template?.id;\n\t\t\t}\n\t\t},\n\t\t[\n\t\t\thomepageId,\n\t\t\tpostsPageId,\n\t\t\thasLoadedAllDependencies,\n\t\t\turl,\n\t\t\tpostId,\n\t\t\tpostType,\n\t\t\tfrontPageTemplateId,\n\t\t]\n\t);\n\n\tconst context = useMemo( () => {\n\t\tif ( postTypesWithoutParentTemplate.includes( postType ) && postId ) {\n\t\t\treturn {};\n\t\t}\n\n\t\tif ( postType && postId && authorizedPostTypes.includes( postType ) ) {\n\t\t\treturn { postType, postId };\n\t\t}\n\t\t// TODO: for post types lists we should probably not render the front page, but maybe a placeholder\n\t\t// with a message like \"Select a page\" or something similar.\n\t\tif ( homepageId ) {\n\t\t\treturn { postType: 'page', postId: homepageId };\n\t\t}\n\n\t\treturn {};\n\t}, [ homepageId, postType, postId ] );\n\n\tif ( postTypesWithoutParentTemplate.includes( postType ) && postId ) {\n\t\treturn { isReady: true, postType, postId, context };\n\t}\n\n\tif ( hasLoadedAllDependencies ) {\n\t\treturn {\n\t\t\tisReady: resolvedTemplateId !== undefined,\n\t\t\tpostType: TEMPLATE_POST_TYPE,\n\t\t\tpostId: resolvedTemplateId,\n\t\t\tcontext,\n\t\t};\n\t}\n\n\treturn { isReady: false };\n}\n\nexport default function useInitEditedEntityFromURL() {\n\tconst { params = {} } = useLocation();\n\tconst { postType, postId, context, isReady } =\n\t\tuseResolveEditedEntityAndContext( params );\n\n\tconst { setEditedEntity } = useDispatch( editSiteStore );\n\tconst { resetZoomLevel } = unlock( useDispatch( blockEditorStore ) );\n\n\tuseEffect( () => {\n\t\tif ( isReady ) {\n\t\t\tresetZoomLevel();\n\t\t\tsetEditedEntity( postType, postId, context );\n\t\t}\n\t}, [\n\t\tisReady,\n\t\tpostType,\n\t\tpostId,\n\t\tcontext,\n\t\tsetEditedEntity,\n\t\tresetZoomLevel,\n\t] );\n}\n"],"mappings":"AAAA;AACA;AACA;AACA,SAASA,SAAS,EAAEC,OAAO,QAAQ,oBAAoB;AACvD,SAASC,SAAS,EAAEC,WAAW,QAAQ,iBAAiB;AACxD,SAASC,KAAK,IAAIC,aAAa,QAAQ,sBAAsB;AAC7D,SAASC,WAAW,IAAIC,iBAAiB,QAAQ,mBAAmB;AACpE,SAASH,KAAK,IAAII,gBAAgB,QAAQ,yBAAyB;;AAEnE;AACA;AACA;AACA,SAASJ,KAAK,IAAIK,aAAa,QAAQ,aAAa;AACpD,SAASC,MAAM,QAAQ,mBAAmB;AAC1C,SACCC,kBAAkB,EAClBC,uBAAuB,EACvBC,oBAAoB,EACpBC,aAAa,QACP,uBAAuB;AAE9B,MAAM;EAAEC;AAAY,CAAC,GAAGL,MAAM,CAAEH,iBAAkB,CAAC;AAEnD,MAAMS,8BAA8B,GAAG,CACtCL,kBAAkB,EAClBC,uBAAuB,EACvBC,oBAAoB,EACpBC,aAAa,CAACG,IAAI,CAClB;AAED,MAAMC,mBAAmB,GAAG,CAAE,MAAM,EAAE,MAAM,CAAE;AAE9C,SA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,MAAM,CAAEP,WAAW,CAAEK,gBAAiB,CAAE,CAAC;EAEpER,SAAS,CAAE,MAAM;IAChB,IAAK+D,OAAO,EAAG;MACdI,cAAc,CAAC,CAAC;MAChBD,eAAe,CAAE7C,QAAQ,EAAED,MAAM,EAAE0C,OAAQ,CAAC;IAC7C;EACD,CAAC,EAAE,CACFC,OAAO,EACP1C,QAAQ,EACRD,MAAM,EACN0C,OAAO,EACPI,eAAe,EACfC,cAAc,CACb,CAAC;AACJ","ignoreList":[]}
|
|
@@ -1,53 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* WordPress dependencies
|
|
3
|
-
*/
|
|
4
|
-
import { useSelect } from '@wordpress/data';
|
|
5
|
-
import { store as coreStore } from '@wordpress/core-data';
|
|
6
|
-
import { store as editorStore } from '@wordpress/editor';
|
|
7
|
-
import { decodeEntities } from '@wordpress/html-entities';
|
|
8
|
-
|
|
9
|
-
/**
|
|
10
|
-
* Internal dependencies
|
|
11
|
-
*/
|
|
12
|
-
import { store as editSiteStore } from '../../store';
|
|
13
|
-
export default function useEditedEntityRecord(postType, postId) {
|
|
14
|
-
const {
|
|
15
|
-
record,
|
|
16
|
-
title,
|
|
17
|
-
description,
|
|
18
|
-
isLoaded,
|
|
19
|
-
icon
|
|
20
|
-
} = useSelect(select => {
|
|
21
|
-
const {
|
|
22
|
-
getEditedPostType,
|
|
23
|
-
getEditedPostId
|
|
24
|
-
} = select(editSiteStore);
|
|
25
|
-
const {
|
|
26
|
-
getEditedEntityRecord,
|
|
27
|
-
hasFinishedResolution
|
|
28
|
-
} = select(coreStore);
|
|
29
|
-
const {
|
|
30
|
-
__experimentalGetTemplateInfo: getTemplateInfo
|
|
31
|
-
} = select(editorStore);
|
|
32
|
-
const usedPostType = postType !== null && postType !== void 0 ? postType : getEditedPostType();
|
|
33
|
-
const usedPostId = postId !== null && postId !== void 0 ? postId : getEditedPostId();
|
|
34
|
-
const _record = getEditedEntityRecord('postType', usedPostType, usedPostId);
|
|
35
|
-
const _isLoaded = usedPostId && hasFinishedResolution('getEditedEntityRecord', ['postType', usedPostType, usedPostId]);
|
|
36
|
-
const templateInfo = getTemplateInfo(_record);
|
|
37
|
-
return {
|
|
38
|
-
record: _record,
|
|
39
|
-
title: templateInfo.title,
|
|
40
|
-
description: templateInfo.description,
|
|
41
|
-
isLoaded: _isLoaded,
|
|
42
|
-
icon: templateInfo.icon
|
|
43
|
-
};
|
|
44
|
-
}, [postType, postId]);
|
|
45
|
-
return {
|
|
46
|
-
isLoaded,
|
|
47
|
-
icon,
|
|
48
|
-
record,
|
|
49
|
-
getTitle: () => title ? decodeEntities(title) : null,
|
|
50
|
-
getDescription: () => description ? decodeEntities(description) : null
|
|
51
|
-
};
|
|
52
|
-
}
|
|
53
|
-
//# sourceMappingURL=index.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"names":["useSelect","store","coreStore","editorStore","decodeEntities","editSiteStore","useEditedEntityRecord","postType","postId","record","title","description","isLoaded","icon","select","getEditedPostType","getEditedPostId","getEditedEntityRecord","hasFinishedResolution","__experimentalGetTemplateInfo","getTemplateInfo","usedPostType","usedPostId","_record","_isLoaded","templateInfo","getTitle","getDescription"],"sources":["@wordpress/edit-site/src/components/use-edited-entity-record/index.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { useSelect } from '@wordpress/data';\nimport { store as coreStore } from '@wordpress/core-data';\nimport { store as editorStore } from '@wordpress/editor';\nimport { decodeEntities } from '@wordpress/html-entities';\n\n/**\n * Internal dependencies\n */\nimport { store as editSiteStore } from '../../store';\n\nexport default function useEditedEntityRecord( postType, postId ) {\n\tconst { record, title, description, isLoaded, icon } = useSelect(\n\t\t( select ) => {\n\t\t\tconst { getEditedPostType, getEditedPostId } =\n\t\t\t\tselect( editSiteStore );\n\t\t\tconst { getEditedEntityRecord, hasFinishedResolution } =\n\t\t\t\tselect( coreStore );\n\t\t\tconst { __experimentalGetTemplateInfo: getTemplateInfo } =\n\t\t\t\tselect( editorStore );\n\t\t\tconst usedPostType = postType ?? getEditedPostType();\n\t\t\tconst usedPostId = postId ?? getEditedPostId();\n\t\t\tconst _record = getEditedEntityRecord(\n\t\t\t\t'postType',\n\t\t\t\tusedPostType,\n\t\t\t\tusedPostId\n\t\t\t);\n\t\t\tconst _isLoaded =\n\t\t\t\tusedPostId &&\n\t\t\t\thasFinishedResolution( 'getEditedEntityRecord', [\n\t\t\t\t\t'postType',\n\t\t\t\t\tusedPostType,\n\t\t\t\t\tusedPostId,\n\t\t\t\t] );\n\t\t\tconst templateInfo = getTemplateInfo( _record );\n\n\t\t\treturn {\n\t\t\t\trecord: _record,\n\t\t\t\ttitle: templateInfo.title,\n\t\t\t\tdescription: templateInfo.description,\n\t\t\t\tisLoaded: _isLoaded,\n\t\t\t\ticon: templateInfo.icon,\n\t\t\t};\n\t\t},\n\t\t[ postType, postId ]\n\t);\n\n\treturn {\n\t\tisLoaded,\n\t\ticon,\n\t\trecord,\n\t\tgetTitle: () => ( title ? decodeEntities( title ) : null ),\n\t\tgetDescription: () =>\n\t\t\tdescription ? decodeEntities( description ) : null,\n\t};\n}\n"],"mappings":"AAAA;AACA;AACA;AACA,SAASA,SAAS,QAAQ,iBAAiB;AAC3C,SAASC,KAAK,IAAIC,SAAS,QAAQ,sBAAsB;AACzD,SAASD,KAAK,IAAIE,WAAW,QAAQ,mBAAmB;AACxD,SAASC,cAAc,QAAQ,0BAA0B;;AAEzD;AACA;AACA;AACA,SAASH,KAAK,IAAII,aAAa,QAAQ,aAAa;AAEpD,eAAe,SAASC,qBAAqBA,CAAEC,QAAQ,EAAEC,MAAM,EAAG;EACjE,MAAM;IAAEC,MAAM;IAAEC,KAAK;IAAEC,WAAW;IAAEC,QAAQ;IAAEC;EAAK,CAAC,GAAGb,SAAS,CAC7Dc,MAAM,IAAM;IACb,MAAM;MAAEC,iBAAiB;MAAEC;IAAgB,CAAC,GAC3CF,MAAM,CAAET,aAAc,CAAC;IACxB,MAAM;MAAEY,qBAAqB;MAAEC;IAAsB,CAAC,GACrDJ,MAAM,CAAEZ,SAAU,CAAC;IACpB,MAAM;MAAEiB,6BAA6B,EAAEC;IAAgB,CAAC,GACvDN,MAAM,CAAEX,WAAY,CAAC;IACtB,MAAMkB,YAAY,GAAGd,QAAQ,aAARA,QAAQ,cAARA,QAAQ,GAAIQ,iBAAiB,CAAC,CAAC;IACpD,MAAMO,UAAU,GAAGd,MAAM,aAANA,MAAM,cAANA,MAAM,GAAIQ,eAAe,CAAC,CAAC;IAC9C,MAAMO,OAAO,GAAGN,qBAAqB,CACpC,UAAU,EACVI,YAAY,EACZC,UACD,CAAC;IACD,MAAME,SAAS,GACdF,UAAU,IACVJ,qBAAqB,CAAE,uBAAuB,EAAE,CAC/C,UAAU,EACVG,YAAY,EACZC,UAAU,CACT,CAAC;IACJ,MAAMG,YAAY,GAAGL,eAAe,CAAEG,OAAQ,CAAC;IAE/C,OAAO;MACNd,MAAM,EAAEc,OAAO;MACfb,KAAK,EAAEe,YAAY,CAACf,KAAK;MACzBC,WAAW,EAAEc,YAAY,CAACd,WAAW;MACrCC,QAAQ,EAAEY,SAAS;MACnBX,IAAI,EAAEY,YAAY,CAACZ;IACpB,CAAC;EACF,CAAC,EACD,CAAEN,QAAQ,EAAEC,MAAM,CACnB,CAAC;EAED,OAAO;IACNI,QAAQ;IACRC,IAAI;IACJJ,MAAM;IACNiB,QAAQ,EAAEA,CAAA,KAAQhB,KAAK,GAAGN,cAAc,CAAEM,KAAM,CAAC,GAAG,IAAM;IAC1DiB,cAAc,EAAEA,CAAA,KACfhB,WAAW,GAAGP,cAAc,CAAEO,WAAY,CAAC,GAAG;EAChD,CAAC;AACF","ignoreList":[]}
|
|
@@ -1,171 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* WordPress dependencies
|
|
3
|
-
*/
|
|
4
|
-
import { useSelect, useDispatch } from '@wordpress/data';
|
|
5
|
-
import { __, sprintf, isRTL } from '@wordpress/i18n';
|
|
6
|
-
import { trash, rotateLeft, rotateRight, layout, page } from '@wordpress/icons';
|
|
7
|
-
import { useCommandLoader } from '@wordpress/commands';
|
|
8
|
-
import { decodeEntities } from '@wordpress/html-entities';
|
|
9
|
-
import { privateApis as routerPrivateApis } from '@wordpress/router';
|
|
10
|
-
import { store as editorStore } from '@wordpress/editor';
|
|
11
|
-
|
|
12
|
-
/**
|
|
13
|
-
* Internal dependencies
|
|
14
|
-
*/
|
|
15
|
-
import { store as editSiteStore } from '../../store';
|
|
16
|
-
import useEditedEntityRecord from '../../components/use-edited-entity-record';
|
|
17
|
-
import isTemplateRemovable from '../../utils/is-template-removable';
|
|
18
|
-
import isTemplateRevertable from '../../utils/is-template-revertable';
|
|
19
|
-
import { unlock } from '../../lock-unlock';
|
|
20
|
-
import { TEMPLATE_POST_TYPE } from '../../utils/constants';
|
|
21
|
-
import { useLink } from '../../components/routes/link';
|
|
22
|
-
const {
|
|
23
|
-
useHistory,
|
|
24
|
-
useLocation
|
|
25
|
-
} = unlock(routerPrivateApis);
|
|
26
|
-
function usePageContentFocusCommands() {
|
|
27
|
-
const {
|
|
28
|
-
record: template
|
|
29
|
-
} = useEditedEntityRecord();
|
|
30
|
-
const {
|
|
31
|
-
params
|
|
32
|
-
} = useLocation();
|
|
33
|
-
const {
|
|
34
|
-
canvas = 'view'
|
|
35
|
-
} = params;
|
|
36
|
-
const {
|
|
37
|
-
isPage,
|
|
38
|
-
templateId,
|
|
39
|
-
currentPostType
|
|
40
|
-
} = useSelect(select => {
|
|
41
|
-
const {
|
|
42
|
-
isPage: _isPage
|
|
43
|
-
} = unlock(select(editSiteStore));
|
|
44
|
-
const {
|
|
45
|
-
getCurrentPostType,
|
|
46
|
-
getCurrentTemplateId
|
|
47
|
-
} = select(editorStore);
|
|
48
|
-
return {
|
|
49
|
-
isPage: _isPage(),
|
|
50
|
-
templateId: getCurrentTemplateId(),
|
|
51
|
-
currentPostType: getCurrentPostType()
|
|
52
|
-
};
|
|
53
|
-
}, []);
|
|
54
|
-
const {
|
|
55
|
-
onClick: editTemplate
|
|
56
|
-
} = useLink({
|
|
57
|
-
postType: 'wp_template',
|
|
58
|
-
postId: templateId
|
|
59
|
-
});
|
|
60
|
-
const {
|
|
61
|
-
setRenderingMode
|
|
62
|
-
} = useDispatch(editorStore);
|
|
63
|
-
if (!isPage || canvas !== 'edit') {
|
|
64
|
-
return {
|
|
65
|
-
isLoading: false,
|
|
66
|
-
commands: []
|
|
67
|
-
};
|
|
68
|
-
}
|
|
69
|
-
const commands = [];
|
|
70
|
-
if (currentPostType !== 'wp_template') {
|
|
71
|
-
commands.push({
|
|
72
|
-
name: 'core/switch-to-template-focus',
|
|
73
|
-
label: sprintf(/* translators: %s: template title */
|
|
74
|
-
__('Edit template: %s'), decodeEntities(template.title)),
|
|
75
|
-
icon: layout,
|
|
76
|
-
callback: ({
|
|
77
|
-
close
|
|
78
|
-
}) => {
|
|
79
|
-
editTemplate();
|
|
80
|
-
close();
|
|
81
|
-
}
|
|
82
|
-
});
|
|
83
|
-
} else {
|
|
84
|
-
commands.push({
|
|
85
|
-
name: 'core/switch-to-page-focus',
|
|
86
|
-
label: __('Back to page'),
|
|
87
|
-
icon: page,
|
|
88
|
-
callback: ({
|
|
89
|
-
close
|
|
90
|
-
}) => {
|
|
91
|
-
setRenderingMode('template-locked');
|
|
92
|
-
close();
|
|
93
|
-
}
|
|
94
|
-
});
|
|
95
|
-
}
|
|
96
|
-
return {
|
|
97
|
-
isLoading: false,
|
|
98
|
-
commands
|
|
99
|
-
};
|
|
100
|
-
}
|
|
101
|
-
function useManipulateDocumentCommands() {
|
|
102
|
-
const {
|
|
103
|
-
isLoaded,
|
|
104
|
-
record: template
|
|
105
|
-
} = useEditedEntityRecord();
|
|
106
|
-
const {
|
|
107
|
-
removeTemplate,
|
|
108
|
-
revertTemplate
|
|
109
|
-
} = useDispatch(editSiteStore);
|
|
110
|
-
const history = useHistory();
|
|
111
|
-
const isEditingPage = useSelect(select => select(editSiteStore).isPage() && select(editorStore).getCurrentPostType() !== 'wp_template', []);
|
|
112
|
-
if (!isLoaded) {
|
|
113
|
-
return {
|
|
114
|
-
isLoading: true,
|
|
115
|
-
commands: []
|
|
116
|
-
};
|
|
117
|
-
}
|
|
118
|
-
const commands = [];
|
|
119
|
-
if (isTemplateRevertable(template) && !isEditingPage) {
|
|
120
|
-
const label = template.type === TEMPLATE_POST_TYPE ? sprintf(/* translators: %s: template title */
|
|
121
|
-
__('Reset template: %s'), decodeEntities(template.title)) : sprintf(/* translators: %s: template part title */
|
|
122
|
-
__('Reset template part: %s'), decodeEntities(template.title));
|
|
123
|
-
commands.push({
|
|
124
|
-
name: 'core/reset-template',
|
|
125
|
-
label,
|
|
126
|
-
icon: isRTL() ? rotateRight : rotateLeft,
|
|
127
|
-
callback: ({
|
|
128
|
-
close
|
|
129
|
-
}) => {
|
|
130
|
-
revertTemplate(template);
|
|
131
|
-
close();
|
|
132
|
-
}
|
|
133
|
-
});
|
|
134
|
-
}
|
|
135
|
-
if (isTemplateRemovable(template) && !isEditingPage) {
|
|
136
|
-
const label = template.type === TEMPLATE_POST_TYPE ? sprintf(/* translators: %s: template title */
|
|
137
|
-
__('Delete template: %s'), decodeEntities(template.title)) : sprintf(/* translators: %s: template part title */
|
|
138
|
-
__('Delete template part: %s'), decodeEntities(template.title));
|
|
139
|
-
commands.push({
|
|
140
|
-
name: 'core/remove-template',
|
|
141
|
-
label,
|
|
142
|
-
icon: trash,
|
|
143
|
-
callback: ({
|
|
144
|
-
close
|
|
145
|
-
}) => {
|
|
146
|
-
removeTemplate(template);
|
|
147
|
-
// Navigate to the template list
|
|
148
|
-
history.push({
|
|
149
|
-
postType: template.type
|
|
150
|
-
});
|
|
151
|
-
close();
|
|
152
|
-
}
|
|
153
|
-
});
|
|
154
|
-
}
|
|
155
|
-
return {
|
|
156
|
-
isLoading: !isLoaded,
|
|
157
|
-
commands
|
|
158
|
-
};
|
|
159
|
-
}
|
|
160
|
-
export function useEditModeCommands() {
|
|
161
|
-
useCommandLoader({
|
|
162
|
-
name: 'core/edit-site/page-content-focus',
|
|
163
|
-
hook: usePageContentFocusCommands,
|
|
164
|
-
context: 'entity-edit'
|
|
165
|
-
});
|
|
166
|
-
useCommandLoader({
|
|
167
|
-
name: 'core/edit-site/manipulate-document',
|
|
168
|
-
hook: useManipulateDocumentCommands
|
|
169
|
-
});
|
|
170
|
-
}
|
|
171
|
-
//# sourceMappingURL=use-edit-mode-commands.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"names":["useSelect","useDispatch","__","sprintf","isRTL","trash","rotateLeft","rotateRight","layout","page","useCommandLoader","decodeEntities","privateApis","routerPrivateApis","store","editorStore","editSiteStore","useEditedEntityRecord","isTemplateRemovable","isTemplateRevertable","unlock","TEMPLATE_POST_TYPE","useLink","useHistory","useLocation","usePageContentFocusCommands","record","template","params","canvas","isPage","templateId","currentPostType","select","_isPage","getCurrentPostType","getCurrentTemplateId","onClick","editTemplate","postType","postId","setRenderingMode","isLoading","commands","push","name","label","title","icon","callback","close","useManipulateDocumentCommands","isLoaded","removeTemplate","revertTemplate","history","isEditingPage","type","useEditModeCommands","hook","context"],"sources":["@wordpress/edit-site/src/hooks/commands/use-edit-mode-commands.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { useSelect, useDispatch } from '@wordpress/data';\nimport { __, sprintf, isRTL } from '@wordpress/i18n';\nimport { trash, rotateLeft, rotateRight, layout, page } from '@wordpress/icons';\nimport { useCommandLoader } from '@wordpress/commands';\nimport { decodeEntities } from '@wordpress/html-entities';\nimport { privateApis as routerPrivateApis } from '@wordpress/router';\nimport { store as editorStore } from '@wordpress/editor';\n\n/**\n * Internal dependencies\n */\nimport { store as editSiteStore } from '../../store';\nimport useEditedEntityRecord from '../../components/use-edited-entity-record';\nimport isTemplateRemovable from '../../utils/is-template-removable';\nimport isTemplateRevertable from '../../utils/is-template-revertable';\nimport { unlock } from '../../lock-unlock';\nimport { TEMPLATE_POST_TYPE } from '../../utils/constants';\nimport { useLink } from '../../components/routes/link';\n\nconst { useHistory, useLocation } = unlock( routerPrivateApis );\n\nfunction usePageContentFocusCommands() {\n\tconst { record: template } = useEditedEntityRecord();\n\tconst { params } = useLocation();\n\tconst { canvas = 'view' } = params;\n\tconst { isPage, templateId, currentPostType } = useSelect( ( select ) => {\n\t\tconst { isPage: _isPage } = unlock( select( editSiteStore ) );\n\t\tconst { getCurrentPostType, getCurrentTemplateId } =\n\t\t\tselect( editorStore );\n\t\treturn {\n\t\t\tisPage: _isPage(),\n\t\t\ttemplateId: getCurrentTemplateId(),\n\t\t\tcurrentPostType: getCurrentPostType(),\n\t\t};\n\t}, [] );\n\n\tconst { onClick: editTemplate } = useLink( {\n\t\tpostType: 'wp_template',\n\t\tpostId: templateId,\n\t} );\n\n\tconst { setRenderingMode } = useDispatch( editorStore );\n\n\tif ( ! isPage || canvas !== 'edit' ) {\n\t\treturn { isLoading: false, commands: [] };\n\t}\n\n\tconst commands = [];\n\n\tif ( currentPostType !== 'wp_template' ) {\n\t\tcommands.push( {\n\t\t\tname: 'core/switch-to-template-focus',\n\t\t\tlabel: sprintf(\n\t\t\t\t/* translators: %s: template title */\n\t\t\t\t__( 'Edit template: %s' ),\n\t\t\t\tdecodeEntities( template.title )\n\t\t\t),\n\t\t\ticon: layout,\n\t\t\tcallback: ( { close } ) => {\n\t\t\t\teditTemplate();\n\t\t\t\tclose();\n\t\t\t},\n\t\t} );\n\t} else {\n\t\tcommands.push( {\n\t\t\tname: 'core/switch-to-page-focus',\n\t\t\tlabel: __( 'Back to page' ),\n\t\t\ticon: page,\n\t\t\tcallback: ( { close } ) => {\n\t\t\t\tsetRenderingMode( 'template-locked' );\n\t\t\t\tclose();\n\t\t\t},\n\t\t} );\n\t}\n\n\treturn { isLoading: false, commands };\n}\n\nfunction useManipulateDocumentCommands() {\n\tconst { isLoaded, record: template } = useEditedEntityRecord();\n\tconst { removeTemplate, revertTemplate } = useDispatch( editSiteStore );\n\tconst history = useHistory();\n\tconst isEditingPage = useSelect(\n\t\t( select ) =>\n\t\t\tselect( editSiteStore ).isPage() &&\n\t\t\tselect( editorStore ).getCurrentPostType() !== 'wp_template',\n\t\t[]\n\t);\n\n\tif ( ! isLoaded ) {\n\t\treturn { isLoading: true, commands: [] };\n\t}\n\n\tconst commands = [];\n\n\tif ( isTemplateRevertable( template ) && ! isEditingPage ) {\n\t\tconst label =\n\t\t\ttemplate.type === TEMPLATE_POST_TYPE\n\t\t\t\t? sprintf(\n\t\t\t\t\t\t/* translators: %s: template title */\n\t\t\t\t\t\t__( 'Reset template: %s' ),\n\t\t\t\t\t\tdecodeEntities( template.title )\n\t\t\t\t )\n\t\t\t\t: sprintf(\n\t\t\t\t\t\t/* translators: %s: template part title */\n\t\t\t\t\t\t__( 'Reset template part: %s' ),\n\t\t\t\t\t\tdecodeEntities( template.title )\n\t\t\t\t );\n\t\tcommands.push( {\n\t\t\tname: 'core/reset-template',\n\t\t\tlabel,\n\t\t\ticon: isRTL() ? rotateRight : rotateLeft,\n\t\t\tcallback: ( { close } ) => {\n\t\t\t\trevertTemplate( template );\n\t\t\t\tclose();\n\t\t\t},\n\t\t} );\n\t}\n\n\tif ( isTemplateRemovable( template ) && ! isEditingPage ) {\n\t\tconst label =\n\t\t\ttemplate.type === TEMPLATE_POST_TYPE\n\t\t\t\t? sprintf(\n\t\t\t\t\t\t/* translators: %s: template title */\n\t\t\t\t\t\t__( 'Delete template: %s' ),\n\t\t\t\t\t\tdecodeEntities( template.title )\n\t\t\t\t )\n\t\t\t\t: sprintf(\n\t\t\t\t\t\t/* translators: %s: template part title */\n\t\t\t\t\t\t__( 'Delete template part: %s' ),\n\t\t\t\t\t\tdecodeEntities( template.title )\n\t\t\t\t );\n\t\tcommands.push( {\n\t\t\tname: 'core/remove-template',\n\t\t\tlabel,\n\t\t\ticon: trash,\n\t\t\tcallback: ( { close } ) => {\n\t\t\t\tremoveTemplate( template );\n\t\t\t\t// Navigate to the template list\n\t\t\t\thistory.push( {\n\t\t\t\t\tpostType: template.type,\n\t\t\t\t} );\n\t\t\t\tclose();\n\t\t\t},\n\t\t} );\n\t}\n\n\treturn {\n\t\tisLoading: ! isLoaded,\n\t\tcommands,\n\t};\n}\n\nexport function useEditModeCommands() {\n\tuseCommandLoader( {\n\t\tname: 'core/edit-site/page-content-focus',\n\t\thook: usePageContentFocusCommands,\n\t\tcontext: 'entity-edit',\n\t} );\n\n\tuseCommandLoader( {\n\t\tname: 'core/edit-site/manipulate-document',\n\t\thook: useManipulateDocumentCommands,\n\t} );\n}\n"],"mappings":"AAAA;AACA;AACA;AACA,SAASA,SAAS,EAAEC,WAAW,QAAQ,iBAAiB;AACxD,SAASC,EAAE,EAAEC,OAAO,EAAEC,KAAK,QAAQ,iBAAiB;AACpD,SAASC,KAAK,EAAEC,UAAU,EAAEC,WAAW,EAAEC,MAAM,EAAEC,IAAI,QAAQ,kBAAkB;AAC/E,SAASC,gBAAgB,QAAQ,qBAAqB;AACtD,SAASC,cAAc,QAAQ,0BAA0B;AACzD,SAASC,WAAW,IAAIC,iBAAiB,QAAQ,mBAAmB;AACpE,SAASC,KAAK,IAAIC,WAAW,QAAQ,mBAAmB;;AAExD;AACA;AACA;AACA,SAASD,KAAK,IAAIE,aAAa,QAAQ,aAAa;AACpD,OAAOC,qBAAqB,MAAM,2CAA2C;AAC7E,OAAOC,mBAAmB,MAAM,mCAAmC;AACnE,OAAOC,oBAAoB,MAAM,oCAAoC;AACrE,SAASC,MAAM,QAAQ,mBAAmB;AAC1C,SAASC,kBAAkB,QAAQ,uBAAuB;AAC1D,SAASC,OAAO,QAAQ,8BAA8B;AAEtD,MAAM;EAAEC,UAAU;EAAEC;AAAY,CAAC,GAAGJ,MAAM,CAAEP,iBAAkB,CAAC;AAE/D,SAASY,2BAA2BA,CAAA,EAAG;EACtC,MAAM;IAAEC,MAAM,EAAEC;EAAS,CAAC,GAAGV,qBAAqB,CAAC,CAAC;EACpD,MAAM;IAAEW;EAAO,CAAC,GAAGJ,WAAW,CAAC,CAAC;EAChC,MAAM;IAA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EAEHlD,gBAAgB,CAAE;IACjBmC,IAAI,EAAE,oCAAoC;IAC1Cc,IAAI,EAAER;EACP,CAAE,CAAC;AACJ","ignoreList":[]}
|
|
@@ -1,43 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* WordPress dependencies
|
|
3
|
-
*/
|
|
4
|
-
import { useEffect, useState, flushSync } from '@wordpress/element';
|
|
5
|
-
import { createQueue } from '@wordpress/priority-queue';
|
|
6
|
-
|
|
7
|
-
const blockPreviewQueue = createQueue();
|
|
8
|
-
|
|
9
|
-
/**
|
|
10
|
-
* Renders a component at the next idle time.
|
|
11
|
-
* @param {*} props
|
|
12
|
-
*/
|
|
13
|
-
export function Async( { children, placeholder } ) {
|
|
14
|
-
const [ shouldRender, setShouldRender ] = useState( false );
|
|
15
|
-
|
|
16
|
-
// In the future, we could try to use startTransition here, but currently
|
|
17
|
-
// react will batch all transitions, which means all previews will be
|
|
18
|
-
// rendered at the same time.
|
|
19
|
-
// https://react.dev/reference/react/startTransition#caveats
|
|
20
|
-
// > If there are multiple ongoing Transitions, React currently batches them
|
|
21
|
-
// > together. This is a limitation that will likely be removed in a future
|
|
22
|
-
// > release.
|
|
23
|
-
|
|
24
|
-
useEffect( () => {
|
|
25
|
-
const context = {};
|
|
26
|
-
blockPreviewQueue.add( context, () => {
|
|
27
|
-
// Synchronously run all renders so it consumes timeRemaining.
|
|
28
|
-
// See https://github.com/WordPress/gutenberg/pull/48238
|
|
29
|
-
flushSync( () => {
|
|
30
|
-
setShouldRender( true );
|
|
31
|
-
} );
|
|
32
|
-
} );
|
|
33
|
-
return () => {
|
|
34
|
-
blockPreviewQueue.cancel( context );
|
|
35
|
-
};
|
|
36
|
-
}, [] );
|
|
37
|
-
|
|
38
|
-
if ( ! shouldRender ) {
|
|
39
|
-
return placeholder;
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
return children;
|
|
43
|
-
}
|