@wordpress/edit-site 5.24.1 → 5.25.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/add-custom-template-modal-content.js +2 -3
- package/build/components/add-new-template/add-custom-template-modal-content.js.map +1 -1
- package/build/components/block-editor/editor-canvas.js +48 -23
- package/build/components/block-editor/editor-canvas.js.map +1 -1
- package/build/components/block-editor/site-editor-canvas.js +5 -54
- package/build/components/block-editor/site-editor-canvas.js.map +1 -1
- package/build/components/block-editor/use-site-editor-settings.js +14 -5
- package/build/components/block-editor/use-site-editor-settings.js.map +1 -1
- package/build/components/editor/index.js +6 -17
- package/build/components/editor/index.js.map +1 -1
- package/build/components/global-styles/font-library-modal/collection-font-variant.js +8 -7
- package/build/components/global-styles/font-library-modal/collection-font-variant.js.map +1 -1
- package/build/components/global-styles/font-library-modal/context.js +1 -1
- package/build/components/global-styles/font-library-modal/context.js.map +1 -1
- package/build/components/global-styles/font-library-modal/library-font-variant.js +8 -7
- package/build/components/global-styles/font-library-modal/library-font-variant.js.map +1 -1
- package/build/components/global-styles/screen-revisions/get-revision-changes.js +146 -0
- package/build/components/global-styles/screen-revisions/get-revision-changes.js.map +1 -0
- package/build/components/global-styles/screen-revisions/index.js +6 -10
- package/build/components/global-styles/screen-revisions/index.js.map +1 -1
- package/build/components/global-styles/screen-revisions/revisions-buttons.js +63 -13
- package/build/components/global-styles/screen-revisions/revisions-buttons.js.map +1 -1
- package/build/components/header-edit-mode/document-tools/index.js +17 -10
- package/build/components/header-edit-mode/document-tools/index.js.map +1 -1
- package/build/components/header-edit-mode/index.js +16 -38
- package/build/components/header-edit-mode/index.js.map +1 -1
- package/build/components/header-edit-mode/more-menu/index.js +11 -9
- package/build/components/header-edit-mode/more-menu/index.js.map +1 -1
- package/build/components/layout/index.js +9 -8
- package/build/components/layout/index.js.map +1 -1
- package/build/components/page/header.js +2 -1
- package/build/components/page/header.js.map +1 -1
- package/build/components/page-pages/index.js +31 -28
- package/build/components/page-pages/index.js.map +1 -1
- package/build/components/page-patterns/patterns-list.js +1 -2
- package/build/components/page-patterns/patterns-list.js.map +1 -1
- package/build/components/page-patterns/rename-menu-item.js +3 -0
- package/build/components/page-patterns/rename-menu-item.js.map +1 -1
- package/build/components/page-templates/dataviews-templates.js +18 -17
- package/build/components/page-templates/dataviews-templates.js.map +1 -1
- package/build/components/preferences-modal/index.js +36 -20
- package/build/components/preferences-modal/index.js.map +1 -1
- package/build/components/routes/use-title.js +3 -4
- package/build/components/routes/use-title.js.map +1 -1
- package/build/components/save-button/index.js +2 -1
- package/build/components/save-button/index.js.map +1 -1
- package/build/components/sidebar/index.js +26 -12
- package/build/components/sidebar/index.js.map +1 -1
- package/build/components/sidebar-dataviews/dataview-item.js +2 -10
- package/build/components/sidebar-dataviews/dataview-item.js.map +1 -1
- package/build/components/sidebar-dataviews/default-views.js +2 -2
- package/build/components/sidebar-dataviews/default-views.js.map +1 -1
- package/build/components/sidebar-edit-mode/page-panels/index.js +9 -3
- package/build/components/sidebar-edit-mode/page-panels/index.js.map +1 -1
- package/build/components/sidebar-edit-mode/page-panels/page-summary.js +1 -2
- package/build/components/sidebar-edit-mode/page-panels/page-summary.js.map +1 -1
- package/build/components/sidebar-navigation-screen-navigation-menu/rename-modal.js +3 -0
- package/build/components/sidebar-navigation-screen-navigation-menu/rename-modal.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-template/home-template-details.js +3 -89
- package/build/components/sidebar-navigation-screen-template/home-template-details.js.map +1 -1
- package/build/components/sidebar-navigation-screen-template/index.js +2 -1
- package/build/components/sidebar-navigation-screen-template/index.js.map +1 -1
- package/build/components/sidebar-navigation-screen-template/template-areas.js +117 -0
- package/build/components/sidebar-navigation-screen-template/template-areas.js.map +1 -0
- package/build/components/site-hub/index.js +6 -3
- package/build/components/site-hub/index.js.map +1 -1
- package/build/components/template-actions/rename-menu-item.js +3 -0
- package/build/components/template-actions/rename-menu-item.js.map +1 -1
- package/build/components/welcome-guide/styles.js +1 -1
- package/build/components/welcome-guide/styles.js.map +1 -1
- package/build/hooks/commands/use-common-commands.js +9 -1
- package/build/hooks/commands/use-common-commands.js.map +1 -1
- package/build/hooks/navigation-menu-edit.js +1 -1
- package/build/hooks/navigation-menu-edit.js.map +1 -1
- package/build/hooks/template-part-edit.js +1 -1
- package/build/hooks/template-part-edit.js.map +1 -1
- package/build/store/actions.js +15 -8
- package/build/store/actions.js.map +1 -1
- package/build/store/reducer.js +0 -18
- package/build/store/reducer.js.map +1 -1
- package/build/store/selectors.js +12 -6
- package/build/store/selectors.js.map +1 -1
- package/build/utils/constants.js +15 -1
- package/build/utils/constants.js.map +1 -1
- package/build-module/components/add-new-template/add-custom-template-modal-content.js +1 -1
- package/build-module/components/add-new-template/add-custom-template-modal-content.js.map +1 -1
- package/build-module/components/block-editor/editor-canvas.js +50 -25
- package/build-module/components/block-editor/editor-canvas.js.map +1 -1
- package/build-module/components/block-editor/site-editor-canvas.js +8 -56
- package/build-module/components/block-editor/site-editor-canvas.js.map +1 -1
- package/build-module/components/block-editor/use-site-editor-settings.js +14 -5
- package/build-module/components/block-editor/use-site-editor-settings.js.map +1 -1
- package/build-module/components/editor/index.js +9 -20
- package/build-module/components/editor/index.js.map +1 -1
- package/build-module/components/global-styles/font-library-modal/collection-font-variant.js +9 -7
- package/build-module/components/global-styles/font-library-modal/collection-font-variant.js.map +1 -1
- package/build-module/components/global-styles/font-library-modal/context.js +1 -1
- package/build-module/components/global-styles/font-library-modal/context.js.map +1 -1
- package/build-module/components/global-styles/font-library-modal/library-font-variant.js +9 -7
- package/build-module/components/global-styles/font-library-modal/library-font-variant.js.map +1 -1
- package/build-module/components/global-styles/screen-revisions/get-revision-changes.js +139 -0
- package/build-module/components/global-styles/screen-revisions/get-revision-changes.js.map +1 -0
- package/build-module/components/global-styles/screen-revisions/index.js +7 -11
- package/build-module/components/global-styles/screen-revisions/index.js.map +1 -1
- package/build-module/components/global-styles/screen-revisions/revisions-buttons.js +64 -14
- package/build-module/components/global-styles/screen-revisions/revisions-buttons.js.map +1 -1
- package/build-module/components/header-edit-mode/document-tools/index.js +17 -10
- package/build-module/components/header-edit-mode/document-tools/index.js.map +1 -1
- package/build-module/components/header-edit-mode/index.js +20 -42
- package/build-module/components/header-edit-mode/index.js.map +1 -1
- package/build-module/components/header-edit-mode/more-menu/index.js +12 -10
- package/build-module/components/header-edit-mode/more-menu/index.js.map +1 -1
- package/build-module/components/layout/index.js +9 -8
- package/build-module/components/layout/index.js.map +1 -1
- package/build-module/components/page/header.js +2 -1
- package/build-module/components/page/header.js.map +1 -1
- package/build-module/components/page-pages/index.js +31 -28
- package/build-module/components/page-pages/index.js.map +1 -1
- package/build-module/components/page-patterns/patterns-list.js +1 -2
- package/build-module/components/page-patterns/patterns-list.js.map +1 -1
- package/build-module/components/page-patterns/rename-menu-item.js +3 -0
- package/build-module/components/page-patterns/rename-menu-item.js.map +1 -1
- package/build-module/components/page-templates/dataviews-templates.js +18 -17
- package/build-module/components/page-templates/dataviews-templates.js.map +1 -1
- package/build-module/components/preferences-modal/index.js +37 -21
- package/build-module/components/preferences-modal/index.js.map +1 -1
- package/build-module/components/routes/use-title.js +3 -4
- package/build-module/components/routes/use-title.js.map +1 -1
- package/build-module/components/save-button/index.js +2 -1
- package/build-module/components/save-button/index.js.map +1 -1
- package/build-module/components/sidebar/index.js +26 -12
- package/build-module/components/sidebar/index.js.map +1 -1
- package/build-module/components/sidebar-dataviews/dataview-item.js +2 -10
- package/build-module/components/sidebar-dataviews/dataview-item.js.map +1 -1
- package/build-module/components/sidebar-dataviews/default-views.js +2 -2
- package/build-module/components/sidebar-dataviews/default-views.js.map +1 -1
- package/build-module/components/sidebar-edit-mode/page-panels/index.js +9 -3
- package/build-module/components/sidebar-edit-mode/page-panels/index.js.map +1 -1
- package/build-module/components/sidebar-edit-mode/page-panels/page-summary.js +2 -3
- package/build-module/components/sidebar-edit-mode/page-panels/page-summary.js.map +1 -1
- package/build-module/components/sidebar-navigation-screen-navigation-menu/rename-modal.js +3 -0
- package/build-module/components/sidebar-navigation-screen-navigation-menu/rename-modal.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-template/home-template-details.js +5 -90
- package/build-module/components/sidebar-navigation-screen-template/home-template-details.js.map +1 -1
- package/build-module/components/sidebar-navigation-screen-template/index.js +2 -1
- package/build-module/components/sidebar-navigation-screen-template/index.js.map +1 -1
- package/build-module/components/sidebar-navigation-screen-template/template-areas.js +109 -0
- package/build-module/components/sidebar-navigation-screen-template/template-areas.js.map +1 -0
- package/build-module/components/site-hub/index.js +6 -3
- package/build-module/components/site-hub/index.js.map +1 -1
- package/build-module/components/template-actions/rename-menu-item.js +3 -0
- package/build-module/components/template-actions/rename-menu-item.js.map +1 -1
- package/build-module/components/welcome-guide/styles.js +1 -1
- package/build-module/components/welcome-guide/styles.js.map +1 -1
- package/build-module/hooks/commands/use-common-commands.js +9 -1
- package/build-module/hooks/commands/use-common-commands.js.map +1 -1
- package/build-module/hooks/navigation-menu-edit.js +1 -1
- package/build-module/hooks/navigation-menu-edit.js.map +1 -1
- package/build-module/hooks/template-part-edit.js +1 -1
- package/build-module/hooks/template-part-edit.js.map +1 -1
- package/build-module/store/actions.js +13 -6
- package/build-module/store/actions.js.map +1 -1
- package/build-module/store/reducer.js +0 -17
- package/build-module/store/reducer.js.map +1 -1
- package/build-module/store/selectors.js +10 -3
- package/build-module/store/selectors.js.map +1 -1
- package/build-module/utils/constants.js +8 -0
- package/build-module/utils/constants.js.map +1 -1
- package/build-style/style-rtl.css +302 -354
- package/build-style/style.css +302 -354
- package/package.json +42 -42
- package/src/components/add-new-template/add-custom-template-modal-content.js +1 -1
- package/src/components/block-editor/editor-canvas.js +63 -47
- package/src/components/block-editor/site-editor-canvas.js +32 -96
- package/src/components/block-editor/style.scss +6 -12
- package/src/components/block-editor/use-site-editor-settings.js +47 -36
- package/src/components/editor/index.js +10 -16
- package/src/components/global-styles/font-library-modal/collection-font-variant.js +12 -6
- package/src/components/global-styles/font-library-modal/context.js +1 -1
- package/src/components/global-styles/font-library-modal/library-font-variant.js +12 -6
- package/src/components/global-styles/screen-revisions/get-revision-changes.js +171 -0
- package/src/components/global-styles/screen-revisions/index.js +4 -11
- package/src/components/global-styles/screen-revisions/revisions-buttons.js +86 -17
- package/src/components/global-styles/screen-revisions/style.scss +10 -2
- package/src/components/global-styles/screen-revisions/test/get-revision-changes.js +191 -0
- package/src/components/header-edit-mode/document-tools/index.js +13 -13
- package/src/components/header-edit-mode/index.js +29 -63
- package/src/components/header-edit-mode/more-menu/index.js +18 -22
- package/src/components/header-edit-mode/style.scss +58 -33
- package/src/components/layout/index.js +21 -20
- package/src/components/list/style.scss +5 -0
- package/src/components/page/header.js +2 -1
- package/src/components/page/style.scss +2 -2
- package/src/components/page-pages/index.js +59 -35
- package/src/components/page-pages/style.scss +3 -1
- package/src/components/page-patterns/patterns-list.js +5 -2
- package/src/components/page-patterns/rename-menu-item.js +7 -1
- package/src/components/page-templates/dataviews-templates.js +28 -13
- package/src/components/preferences-modal/index.js +59 -33
- package/src/components/routes/use-title.js +3 -10
- package/src/components/save-button/index.js +1 -0
- package/src/components/sidebar/index.js +41 -24
- package/src/components/sidebar/style.scss +10 -12
- package/src/components/sidebar-dataviews/dataview-item.js +3 -7
- package/src/components/sidebar-dataviews/default-views.js +2 -2
- package/src/components/sidebar-edit-mode/page-panels/index.js +39 -25
- package/src/components/sidebar-edit-mode/page-panels/page-summary.js +2 -2
- package/src/components/sidebar-edit-mode/page-panels/style.scss +1 -42
- package/src/components/sidebar-navigation-screen-navigation-menu/rename-modal.js +7 -1
- package/src/components/sidebar-navigation-screen-patterns/use-pattern-categories.js +1 -1
- package/src/components/sidebar-navigation-screen-template/home-template-details.js +1 -96
- package/src/components/sidebar-navigation-screen-template/index.js +8 -2
- package/src/components/sidebar-navigation-screen-template/template-areas.js +135 -0
- package/src/components/site-hub/index.js +4 -5
- package/src/components/template-actions/rename-menu-item.js +7 -1
- package/src/components/welcome-guide/styles.js +1 -1
- package/src/hooks/commands/use-common-commands.js +10 -5
- package/src/hooks/navigation-menu-edit.js +1 -1
- package/src/hooks/template-part-edit.js +1 -1
- package/src/store/actions.js +15 -5
- package/src/store/reducer.js +0 -18
- package/src/store/selectors.js +15 -3
- package/src/style.scss +1 -2
- package/src/utils/constants.js +8 -0
- package/build/components/dataviews/add-filter.js +0 -91
- package/build/components/dataviews/add-filter.js.map +0 -1
- package/build/components/dataviews/constants.js +0 -14
- package/build/components/dataviews/constants.js.map +0 -1
- package/build/components/dataviews/dataviews.js +0 -99
- package/build/components/dataviews/dataviews.js.map +0 -1
- package/build/components/dataviews/filter-summary.js +0 -62
- package/build/components/dataviews/filter-summary.js.map +0 -1
- package/build/components/dataviews/filters.js +0 -63
- package/build/components/dataviews/filters.js.map +0 -1
- package/build/components/dataviews/index.js +0 -21
- package/build/components/dataviews/index.js.map +0 -1
- package/build/components/dataviews/item-actions.js +0 -184
- package/build/components/dataviews/item-actions.js.map +0 -1
- package/build/components/dataviews/pagination.js +0 -123
- package/build/components/dataviews/pagination.js.map +0 -1
- package/build/components/dataviews/reset-filters.js +0 -33
- package/build/components/dataviews/reset-filters.js.map +0 -1
- package/build/components/dataviews/search.js +0 -51
- package/build/components/dataviews/search.js.map +0 -1
- package/build/components/dataviews/view-actions.js +0 -244
- package/build/components/dataviews/view-actions.js.map +0 -1
- package/build/components/dataviews/view-grid.js +0 -82
- package/build/components/dataviews/view-grid.js.map +0 -1
- package/build/components/dataviews/view-list.js +0 -399
- package/build/components/dataviews/view-list.js.map +0 -1
- package/build/components/dataviews/view-side-by-side.js +0 -20
- package/build/components/dataviews/view-side-by-side.js.map +0 -1
- package/build/components/header-edit-mode/document-actions/index.js +0 -172
- package/build/components/header-edit-mode/document-actions/index.js.map +0 -1
- package/build/components/page-content-focus-notifications/back-to-page-notification.js +0 -61
- package/build/components/page-content-focus-notifications/back-to-page-notification.js.map +0 -1
- package/build/components/page-content-focus-notifications/edit-template-notification.js +0 -102
- package/build/components/page-content-focus-notifications/edit-template-notification.js.map +0 -1
- package/build/components/page-content-focus-notifications/index.js +0 -22
- package/build/components/page-content-focus-notifications/index.js.map +0 -1
- package/build/components/sidebar-edit-mode/page-panels/edit-template.js +0 -101
- package/build/components/sidebar-edit-mode/page-panels/edit-template.js.map +0 -1
- package/build/components/sidebar-edit-mode/page-panels/hooks.js +0 -79
- package/build/components/sidebar-edit-mode/page-panels/hooks.js.map +0 -1
- package/build/components/sidebar-edit-mode/page-panels/reset-default-template.js +0 -48
- package/build/components/sidebar-edit-mode/page-panels/reset-default-template.js.map +0 -1
- package/build/components/sidebar-edit-mode/page-panels/swap-template-button.js +0 -84
- package/build/components/sidebar-edit-mode/page-panels/swap-template-button.js.map +0 -1
- package/build/utils/use-debounced-input.js +0 -22
- package/build/utils/use-debounced-input.js.map +0 -1
- package/build-module/components/dataviews/add-filter.js +0 -84
- package/build-module/components/dataviews/add-filter.js.map +0 -1
- package/build-module/components/dataviews/constants.js +0 -6
- package/build-module/components/dataviews/constants.js.map +0 -1
- package/build-module/components/dataviews/dataviews.js +0 -90
- package/build-module/components/dataviews/dataviews.js.map +0 -1
- package/build-module/components/dataviews/filter-summary.js +0 -55
- package/build-module/components/dataviews/filter-summary.js.map +0 -1
- package/build-module/components/dataviews/filters.js +0 -55
- package/build-module/components/dataviews/filters.js.map +0 -1
- package/build-module/components/dataviews/index.js +0 -2
- package/build-module/components/dataviews/index.js.map +0 -1
- package/build-module/components/dataviews/item-actions.js +0 -177
- package/build-module/components/dataviews/item-actions.js.map +0 -1
- package/build-module/components/dataviews/pagination.js +0 -115
- package/build-module/components/dataviews/pagination.js.map +0 -1
- package/build-module/components/dataviews/reset-filters.js +0 -26
- package/build-module/components/dataviews/reset-filters.js.map +0 -1
- package/build-module/components/dataviews/search.js +0 -43
- package/build-module/components/dataviews/search.js.map +0 -1
- package/build-module/components/dataviews/view-actions.js +0 -237
- package/build-module/components/dataviews/view-actions.js.map +0 -1
- package/build-module/components/dataviews/view-grid.js +0 -74
- package/build-module/components/dataviews/view-grid.js.map +0 -1
- package/build-module/components/dataviews/view-list.js +0 -390
- package/build-module/components/dataviews/view-list.js.map +0 -1
- package/build-module/components/dataviews/view-side-by-side.js +0 -12
- package/build-module/components/dataviews/view-side-by-side.js.map +0 -1
- package/build-module/components/header-edit-mode/document-actions/index.js +0 -164
- package/build-module/components/header-edit-mode/document-actions/index.js.map +0 -1
- package/build-module/components/page-content-focus-notifications/back-to-page-notification.js +0 -54
- package/build-module/components/page-content-focus-notifications/back-to-page-notification.js.map +0 -1
- package/build-module/components/page-content-focus-notifications/edit-template-notification.js +0 -96
- package/build-module/components/page-content-focus-notifications/edit-template-notification.js.map +0 -1
- package/build-module/components/page-content-focus-notifications/index.js +0 -14
- package/build-module/components/page-content-focus-notifications/index.js.map +0 -1
- package/build-module/components/sidebar-edit-mode/page-panels/edit-template.js +0 -93
- package/build-module/components/sidebar-edit-mode/page-panels/edit-template.js.map +0 -1
- package/build-module/components/sidebar-edit-mode/page-panels/hooks.js +0 -69
- package/build-module/components/sidebar-edit-mode/page-panels/hooks.js.map +0 -1
- package/build-module/components/sidebar-edit-mode/page-panels/reset-default-template.js +0 -41
- package/build-module/components/sidebar-edit-mode/page-panels/reset-default-template.js.map +0 -1
- package/build-module/components/sidebar-edit-mode/page-panels/swap-template-button.js +0 -77
- package/build-module/components/sidebar-edit-mode/page-panels/swap-template-button.js.map +0 -1
- package/build-module/utils/use-debounced-input.js +0 -15
- package/build-module/utils/use-debounced-input.js.map +0 -1
- package/src/components/dataviews/README.md +0 -191
- package/src/components/dataviews/add-filter.js +0 -108
- package/src/components/dataviews/constants.js +0 -5
- package/src/components/dataviews/dataviews.js +0 -99
- package/src/components/dataviews/filter-summary.js +0 -79
- package/src/components/dataviews/filters.js +0 -65
- package/src/components/dataviews/index.js +0 -1
- package/src/components/dataviews/item-actions.js +0 -208
- package/src/components/dataviews/pagination.js +0 -144
- package/src/components/dataviews/reset-filters.js +0 -26
- package/src/components/dataviews/search.js +0 -42
- package/src/components/dataviews/style.scss +0 -131
- package/src/components/dataviews/view-actions.js +0 -319
- package/src/components/dataviews/view-grid.js +0 -90
- package/src/components/dataviews/view-list.js +0 -512
- package/src/components/dataviews/view-side-by-side.js +0 -9
- package/src/components/header-edit-mode/document-actions/index.js +0 -204
- package/src/components/header-edit-mode/document-actions/style.scss +0 -145
- package/src/components/page-content-focus-notifications/back-to-page-notification.js +0 -58
- package/src/components/page-content-focus-notifications/edit-template-notification.js +0 -104
- package/src/components/page-content-focus-notifications/index.js +0 -14
- package/src/components/sidebar-edit-mode/page-panels/edit-template.js +0 -108
- package/src/components/sidebar-edit-mode/page-panels/hooks.js +0 -99
- package/src/components/sidebar-edit-mode/page-panels/reset-default-template.js +0 -45
- package/src/components/sidebar-edit-mode/page-panels/swap-template-button.js +0 -83
- package/src/utils/use-debounced-input.js +0 -18
package/build-module/components/page-content-focus-notifications/back-to-page-notification.js
DELETED
|
@@ -1,54 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* WordPress dependencies
|
|
3
|
-
*/
|
|
4
|
-
import { useSelect, useDispatch } from '@wordpress/data';
|
|
5
|
-
import { useEffect, useRef } from '@wordpress/element';
|
|
6
|
-
import { store as noticesStore } from '@wordpress/notices';
|
|
7
|
-
import { __ } from '@wordpress/i18n';
|
|
8
|
-
import { store as editorStore } from '@wordpress/editor';
|
|
9
|
-
|
|
10
|
-
/**
|
|
11
|
-
* Internal dependencies
|
|
12
|
-
*/
|
|
13
|
-
import { store as editSiteStore } from '../../store';
|
|
14
|
-
|
|
15
|
-
/**
|
|
16
|
-
* Component that displays a 'You are editing a template' notification when the
|
|
17
|
-
* user switches from focusing on editing page content to editing a template.
|
|
18
|
-
*/
|
|
19
|
-
export default function BackToPageNotification() {
|
|
20
|
-
useBackToPageNotification();
|
|
21
|
-
return null;
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
/**
|
|
25
|
-
* Hook that displays a 'You are editing a template' notification when the user
|
|
26
|
-
* switches from focusing on editing page content to editing a template.
|
|
27
|
-
*/
|
|
28
|
-
export function useBackToPageNotification() {
|
|
29
|
-
const renderingMode = useSelect(select => select(editorStore).getRenderingMode(), []);
|
|
30
|
-
const {
|
|
31
|
-
isPage
|
|
32
|
-
} = useSelect(editSiteStore);
|
|
33
|
-
const {
|
|
34
|
-
setRenderingMode
|
|
35
|
-
} = useDispatch(editorStore);
|
|
36
|
-
const {
|
|
37
|
-
createInfoNotice
|
|
38
|
-
} = useDispatch(noticesStore);
|
|
39
|
-
const alreadySeen = useRef(false);
|
|
40
|
-
useEffect(() => {
|
|
41
|
-
if (isPage() && !alreadySeen.current && renderingMode === 'template-only') {
|
|
42
|
-
createInfoNotice(__('You are editing a template.'), {
|
|
43
|
-
isDismissible: true,
|
|
44
|
-
type: 'snackbar',
|
|
45
|
-
actions: [{
|
|
46
|
-
label: __('Back to page'),
|
|
47
|
-
onClick: () => setRenderingMode('template-locked')
|
|
48
|
-
}]
|
|
49
|
-
});
|
|
50
|
-
alreadySeen.current = true;
|
|
51
|
-
}
|
|
52
|
-
}, [isPage, renderingMode, createInfoNotice, setRenderingMode]);
|
|
53
|
-
}
|
|
54
|
-
//# sourceMappingURL=back-to-page-notification.js.map
|
package/build-module/components/page-content-focus-notifications/back-to-page-notification.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"names":["useSelect","useDispatch","useEffect","useRef","store","noticesStore","__","editorStore","editSiteStore","BackToPageNotification","useBackToPageNotification","renderingMode","select","getRenderingMode","isPage","setRenderingMode","createInfoNotice","alreadySeen","current","isDismissible","type","actions","label","onClick"],"sources":["@wordpress/edit-site/src/components/page-content-focus-notifications/back-to-page-notification.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { useSelect, useDispatch } from '@wordpress/data';\nimport { useEffect, useRef } from '@wordpress/element';\nimport { store as noticesStore } from '@wordpress/notices';\nimport { __ } from '@wordpress/i18n';\nimport { store as editorStore } from '@wordpress/editor';\n\n/**\n * Internal dependencies\n */\nimport { store as editSiteStore } from '../../store';\n\n/**\n * Component that displays a 'You are editing a template' notification when the\n * user switches from focusing on editing page content to editing a template.\n */\nexport default function BackToPageNotification() {\n\tuseBackToPageNotification();\n\treturn null;\n}\n\n/**\n * Hook that displays a 'You are editing a template' notification when the user\n * switches from focusing on editing page content to editing a template.\n */\nexport function useBackToPageNotification() {\n\tconst renderingMode = useSelect(\n\t\t( select ) => select( editorStore ).getRenderingMode(),\n\t\t[]\n\t);\n\tconst { isPage } = useSelect( editSiteStore );\n\tconst { setRenderingMode } = useDispatch( editorStore );\n\tconst { createInfoNotice } = useDispatch( noticesStore );\n\n\tconst alreadySeen = useRef( false );\n\n\tuseEffect( () => {\n\t\tif (\n\t\t\tisPage() &&\n\t\t\t! alreadySeen.current &&\n\t\t\trenderingMode === 'template-only'\n\t\t) {\n\t\t\tcreateInfoNotice( __( 'You are editing a template.' ), {\n\t\t\t\tisDismissible: true,\n\t\t\t\ttype: 'snackbar',\n\t\t\t\tactions: [\n\t\t\t\t\t{\n\t\t\t\t\t\tlabel: __( 'Back to page' ),\n\t\t\t\t\t\tonClick: () => setRenderingMode( 'template-locked' ),\n\t\t\t\t\t},\n\t\t\t\t],\n\t\t\t} );\n\t\t\talreadySeen.current = true;\n\t\t}\n\t}, [ isPage, renderingMode, createInfoNotice, setRenderingMode ] );\n}\n"],"mappings":"AAAA;AACA;AACA;AACA,SAASA,SAAS,EAAEC,WAAW,QAAQ,iBAAiB;AACxD,SAASC,SAAS,EAAEC,MAAM,QAAQ,oBAAoB;AACtD,SAASC,KAAK,IAAIC,YAAY,QAAQ,oBAAoB;AAC1D,SAASC,EAAE,QAAQ,iBAAiB;AACpC,SAASF,KAAK,IAAIG,WAAW,QAAQ,mBAAmB;;AAExD;AACA;AACA;AACA,SAASH,KAAK,IAAII,aAAa,QAAQ,aAAa;;AAEpD;AACA;AACA;AACA;AACA,eAAe,SAASC,sBAAsBA,CAAA,EAAG;EAChDC,yBAAyB,CAAC,CAAC;EAC3B,OAAO,IAAI;AACZ;;AAEA;AACA;AACA;AACA;AACA,OAAO,SAASA,yBAAyBA,CAAA,EAAG;EAC3C,MAAMC,aAAa,GAAGX,SAAS,CAC5BY,MAAM,IAAMA,MAAM,CAAEL,WAAY,CAAC,CAACM,gBAAgB,CAAC,CAAC,EACtD,EACD,CAAC;EACD,MAAM;IAAEC;EAAO,CAAC,GAAGd,SAAS,CAAEQ,aAAc,CAAC;EAC7C,MAAM;IAAEO;EAAiB,CAAC,GAAGd,WAAW,CAAEM,WAAY,CAAC;EACvD,MAAM;IAAES;EAAiB,CAAC,GAAGf,WAAW,CAAEI,YAAa,CAAC;EAExD,MAAMY,WAAW,GAAGd,MAAM,CAAE,KAAM,CAAC;EAEnCD,SAAS,CAAE,MAAM;IAChB,IACCY,MAAM,CAAC,CAAC,IACR,CAAEG,WAAW,CAACC,OAAO,IACrBP,aAAa,KAAK,eAAe,EAChC;MACDK,gBAAgB,CAAEV,EAAE,CAAE,6BAA8B,CAAC,EAAE;QACtDa,aAAa,EAAE,IAAI;QACnBC,IAAI,EAAE,UAAU;QAChBC,OAAO,EAAE,CACR;UACCC,KAAK,EAAEhB,EAAE,CAAE,cAAe,CAAC;UAC3BiB,OAAO,EAAEA,CAAA,KAAMR,gBAAgB,CAAE,iBAAkB;QACpD,CAAC;MAEH,CAAE,CAAC;MACHE,WAAW,CAACC,OAAO,GAAG,IAAI;IAC3B;EACD,CAAC,EAAE,CAAEJ,MAAM,EAAEH,aAAa,EAAEK,gBAAgB,EAAED,gBAAgB,CAAG,CAAC;AACnE"}
|
package/build-module/components/page-content-focus-notifications/edit-template-notification.js
DELETED
|
@@ -1,96 +0,0 @@
|
|
|
1
|
-
import { createElement } from "react";
|
|
2
|
-
/**
|
|
3
|
-
* WordPress dependencies
|
|
4
|
-
*/
|
|
5
|
-
import { useSelect, useDispatch } from '@wordpress/data';
|
|
6
|
-
import { useEffect, useState, useRef } from '@wordpress/element';
|
|
7
|
-
import { store as noticesStore } from '@wordpress/notices';
|
|
8
|
-
import { __ } from '@wordpress/i18n';
|
|
9
|
-
import { __experimentalConfirmDialog as ConfirmDialog } from '@wordpress/components';
|
|
10
|
-
import { store as editorStore } from '@wordpress/editor';
|
|
11
|
-
|
|
12
|
-
/**
|
|
13
|
-
* Component that:
|
|
14
|
-
*
|
|
15
|
-
* - Displays a 'Edit your template to edit this block' notification when the
|
|
16
|
-
* user is focusing on editing page content and clicks on a disabled template
|
|
17
|
-
* block.
|
|
18
|
-
* - Displays a 'Edit your template to edit this block' dialog when the user
|
|
19
|
-
* is focusing on editing page conetnt and double clicks on a disabled
|
|
20
|
-
* template block.
|
|
21
|
-
*
|
|
22
|
-
* @param {Object} props
|
|
23
|
-
* @param {import('react').RefObject<HTMLElement>} props.contentRef Ref to the block
|
|
24
|
-
* editor iframe canvas.
|
|
25
|
-
*/
|
|
26
|
-
export default function EditTemplateNotification({
|
|
27
|
-
contentRef
|
|
28
|
-
}) {
|
|
29
|
-
const renderingMode = useSelect(select => select(editorStore).getRenderingMode(), []);
|
|
30
|
-
const {
|
|
31
|
-
getNotices
|
|
32
|
-
} = useSelect(noticesStore);
|
|
33
|
-
const {
|
|
34
|
-
createInfoNotice,
|
|
35
|
-
removeNotice
|
|
36
|
-
} = useDispatch(noticesStore);
|
|
37
|
-
const {
|
|
38
|
-
setRenderingMode
|
|
39
|
-
} = useDispatch(editorStore);
|
|
40
|
-
const [isDialogOpen, setIsDialogOpen] = useState(false);
|
|
41
|
-
const lastNoticeId = useRef(0);
|
|
42
|
-
useEffect(() => {
|
|
43
|
-
const handleClick = async event => {
|
|
44
|
-
if (renderingMode === 'template-only') {
|
|
45
|
-
return;
|
|
46
|
-
}
|
|
47
|
-
if (!event.target.classList.contains('is-root-container')) {
|
|
48
|
-
return;
|
|
49
|
-
}
|
|
50
|
-
const isNoticeAlreadyShowing = getNotices().some(notice => notice.id === lastNoticeId.current);
|
|
51
|
-
if (isNoticeAlreadyShowing) {
|
|
52
|
-
return;
|
|
53
|
-
}
|
|
54
|
-
const {
|
|
55
|
-
notice
|
|
56
|
-
} = await createInfoNotice(__('Edit your template to edit this block.'), {
|
|
57
|
-
isDismissible: true,
|
|
58
|
-
type: 'snackbar',
|
|
59
|
-
actions: [{
|
|
60
|
-
label: __('Edit template'),
|
|
61
|
-
onClick: () => setRenderingMode('template-only')
|
|
62
|
-
}]
|
|
63
|
-
});
|
|
64
|
-
lastNoticeId.current = notice.id;
|
|
65
|
-
};
|
|
66
|
-
const handleDblClick = event => {
|
|
67
|
-
if (renderingMode === 'template-only') {
|
|
68
|
-
return;
|
|
69
|
-
}
|
|
70
|
-
if (!event.target.classList.contains('is-root-container')) {
|
|
71
|
-
return;
|
|
72
|
-
}
|
|
73
|
-
if (lastNoticeId.current) {
|
|
74
|
-
removeNotice(lastNoticeId.current);
|
|
75
|
-
}
|
|
76
|
-
setIsDialogOpen(true);
|
|
77
|
-
};
|
|
78
|
-
const canvas = contentRef.current;
|
|
79
|
-
canvas?.addEventListener('click', handleClick);
|
|
80
|
-
canvas?.addEventListener('dblclick', handleDblClick);
|
|
81
|
-
return () => {
|
|
82
|
-
canvas?.removeEventListener('click', handleClick);
|
|
83
|
-
canvas?.removeEventListener('dblclick', handleDblClick);
|
|
84
|
-
};
|
|
85
|
-
}, [lastNoticeId, renderingMode, contentRef.current]);
|
|
86
|
-
return createElement(ConfirmDialog, {
|
|
87
|
-
isOpen: isDialogOpen,
|
|
88
|
-
confirmButtonText: __('Edit template'),
|
|
89
|
-
onConfirm: () => {
|
|
90
|
-
setIsDialogOpen(false);
|
|
91
|
-
setRenderingMode('template-only');
|
|
92
|
-
},
|
|
93
|
-
onCancel: () => setIsDialogOpen(false)
|
|
94
|
-
}, __('Edit your template to edit this block.'));
|
|
95
|
-
}
|
|
96
|
-
//# sourceMappingURL=edit-template-notification.js.map
|
package/build-module/components/page-content-focus-notifications/edit-template-notification.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"names":["useSelect","useDispatch","useEffect","useState","useRef","store","noticesStore","__","__experimentalConfirmDialog","ConfirmDialog","editorStore","EditTemplateNotification","contentRef","renderingMode","select","getRenderingMode","getNotices","createInfoNotice","removeNotice","setRenderingMode","isDialogOpen","setIsDialogOpen","lastNoticeId","handleClick","event","target","classList","contains","isNoticeAlreadyShowing","some","notice","id","current","isDismissible","type","actions","label","onClick","handleDblClick","canvas","addEventListener","removeEventListener","createElement","isOpen","confirmButtonText","onConfirm","onCancel"],"sources":["@wordpress/edit-site/src/components/page-content-focus-notifications/edit-template-notification.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { useSelect, useDispatch } from '@wordpress/data';\nimport { useEffect, useState, useRef } from '@wordpress/element';\nimport { store as noticesStore } from '@wordpress/notices';\nimport { __ } from '@wordpress/i18n';\nimport { __experimentalConfirmDialog as ConfirmDialog } from '@wordpress/components';\nimport { store as editorStore } from '@wordpress/editor';\n\n/**\n * Component that:\n *\n * - Displays a 'Edit your template to edit this block' notification when the\n * user is focusing on editing page content and clicks on a disabled template\n * block.\n * - Displays a 'Edit your template to edit this block' dialog when the user\n * is focusing on editing page conetnt and double clicks on a disabled\n * template block.\n *\n * @param {Object} props\n * @param {import('react').RefObject<HTMLElement>} props.contentRef Ref to the block\n * editor iframe canvas.\n */\nexport default function EditTemplateNotification( { contentRef } ) {\n\tconst renderingMode = useSelect(\n\t\t( select ) => select( editorStore ).getRenderingMode(),\n\t\t[]\n\t);\n\tconst { getNotices } = useSelect( noticesStore );\n\n\tconst { createInfoNotice, removeNotice } = useDispatch( noticesStore );\n\tconst { setRenderingMode } = useDispatch( editorStore );\n\n\tconst [ isDialogOpen, setIsDialogOpen ] = useState( false );\n\n\tconst lastNoticeId = useRef( 0 );\n\n\tuseEffect( () => {\n\t\tconst handleClick = async ( event ) => {\n\t\t\tif ( renderingMode === 'template-only' ) {\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tif ( ! event.target.classList.contains( 'is-root-container' ) ) {\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tconst isNoticeAlreadyShowing = getNotices().some(\n\t\t\t\t( notice ) => notice.id === lastNoticeId.current\n\t\t\t);\n\t\t\tif ( isNoticeAlreadyShowing ) {\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tconst { notice } = await createInfoNotice(\n\t\t\t\t__( 'Edit your template to edit this block.' ),\n\t\t\t\t{\n\t\t\t\t\tisDismissible: true,\n\t\t\t\t\ttype: 'snackbar',\n\t\t\t\t\tactions: [\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tlabel: __( 'Edit template' ),\n\t\t\t\t\t\t\tonClick: () => setRenderingMode( 'template-only' ),\n\t\t\t\t\t\t},\n\t\t\t\t\t],\n\t\t\t\t}\n\t\t\t);\n\t\t\tlastNoticeId.current = notice.id;\n\t\t};\n\n\t\tconst handleDblClick = ( event ) => {\n\t\t\tif ( renderingMode === 'template-only' ) {\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tif ( ! event.target.classList.contains( 'is-root-container' ) ) {\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tif ( lastNoticeId.current ) {\n\t\t\t\tremoveNotice( lastNoticeId.current );\n\t\t\t}\n\t\t\tsetIsDialogOpen( true );\n\t\t};\n\n\t\tconst canvas = contentRef.current;\n\t\tcanvas?.addEventListener( 'click', handleClick );\n\t\tcanvas?.addEventListener( 'dblclick', handleDblClick );\n\t\treturn () => {\n\t\t\tcanvas?.removeEventListener( 'click', handleClick );\n\t\t\tcanvas?.removeEventListener( 'dblclick', handleDblClick );\n\t\t};\n\t}, [ lastNoticeId, renderingMode, contentRef.current ] );\n\n\treturn (\n\t\t<ConfirmDialog\n\t\t\tisOpen={ isDialogOpen }\n\t\t\tconfirmButtonText={ __( 'Edit template' ) }\n\t\t\tonConfirm={ () => {\n\t\t\t\tsetIsDialogOpen( false );\n\t\t\t\tsetRenderingMode( 'template-only' );\n\t\t\t} }\n\t\t\tonCancel={ () => setIsDialogOpen( false ) }\n\t\t>\n\t\t\t{ __( 'Edit your template to edit this block.' ) }\n\t\t</ConfirmDialog>\n\t);\n}\n"],"mappings":";AAAA;AACA;AACA;AACA,SAASA,SAAS,EAAEC,WAAW,QAAQ,iBAAiB;AACxD,SAASC,SAAS,EAAEC,QAAQ,EAAEC,MAAM,QAAQ,oBAAoB;AAChE,SAASC,KAAK,IAAIC,YAAY,QAAQ,oBAAoB;AAC1D,SAASC,EAAE,QAAQ,iBAAiB;AACpC,SAASC,2BAA2B,IAAIC,aAAa,QAAQ,uBAAuB;AACpF,SAASJ,KAAK,IAAIK,WAAW,QAAQ,mBAAmB;;AAExD;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,eAAe,SAASC,wBAAwBA,CAAE;EAAEC;AAAW,CAAC,EAAG;EAClE,MAAMC,aAAa,GAAGb,SAAS,CAC5Bc,MAAM,IAAMA,MAAM,CAAEJ,WAAY,CAAC,CAACK,gBAAgB,CAAC,CAAC,EACtD,EACD,CAAC;EACD,MAAM;IAAEC;EAAW,CAAC,GAAGhB,SAAS,CAAEM,YAAa,CAAC;EAEhD,MAAM;IAAEW,gBAAgB;IAAEC;EAAa,CAAC,GAAGjB,WAAW,CAAEK,YAAa,CAAC;EACtE,MAAM;IAAEa;EAAiB,CAAC,GAAGlB,WAAW,CAAES,WAAY,CAAC;EAEvD,MAAM,CAAEU,YAAY,EAAEC,eAAe,CAAE,GAAGlB,QAAQ,CAAE,KAAM,CAAC;EAE3D,MAAMmB,YAAY,GAAGlB,MAAM,CAAE,CAAE,CAAC;EAEhCF,SAAS,CAAE,MAAM;IAChB,MAAMqB,WAAW,GAAG,MAAQC,KAAK,IA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AElB,WAAY,CAAC;MACnDgB,MAAM,EAAEE,mBAAmB,CAAE,UAAU,EAAEH,cAAe,CAAC;IAC1D,CAAC;EACF,CAAC,EAAE,CAAEhB,YAAY,EAAET,aAAa,EAAED,UAAU,CAACoB,OAAO,CAAG,CAAC;EAExD,OACCU,aAAA,CAACjC,aAAa;IACbkC,MAAM,EAAGvB,YAAc;IACvBwB,iBAAiB,EAAGrC,EAAE,CAAE,eAAgB,CAAG;IAC3CsC,SAAS,EAAGA,CAAA,KAAM;MACjBxB,eAAe,CAAE,KAAM,CAAC;MACxBF,gBAAgB,CAAE,eAAgB,CAAC;IACpC,CAAG;IACH2B,QAAQ,EAAGA,CAAA,KAAMzB,eAAe,CAAE,KAAM;EAAG,GAEzCd,EAAE,CAAE,wCAAyC,CACjC,CAAC;AAElB"}
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
import { createElement, Fragment } from "react";
|
|
2
|
-
/**
|
|
3
|
-
* Internal dependencies
|
|
4
|
-
*/
|
|
5
|
-
import EditTemplateNotification from './edit-template-notification';
|
|
6
|
-
import BackToPageNotification from './back-to-page-notification';
|
|
7
|
-
export default function PageContentFocusNotifications({
|
|
8
|
-
contentRef
|
|
9
|
-
}) {
|
|
10
|
-
return createElement(Fragment, null, createElement(EditTemplateNotification, {
|
|
11
|
-
contentRef: contentRef
|
|
12
|
-
}), createElement(BackToPageNotification, null));
|
|
13
|
-
}
|
|
14
|
-
//# sourceMappingURL=index.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"names":["EditTemplateNotification","BackToPageNotification","PageContentFocusNotifications","contentRef","createElement","Fragment"],"sources":["@wordpress/edit-site/src/components/page-content-focus-notifications/index.js"],"sourcesContent":["/**\n * Internal dependencies\n */\nimport EditTemplateNotification from './edit-template-notification';\nimport BackToPageNotification from './back-to-page-notification';\n\nexport default function PageContentFocusNotifications( { contentRef } ) {\n\treturn (\n\t\t<>\n\t\t\t<EditTemplateNotification contentRef={ contentRef } />\n\t\t\t<BackToPageNotification />\n\t\t</>\n\t);\n}\n"],"mappings":";AAAA;AACA;AACA;AACA,OAAOA,wBAAwB,MAAM,8BAA8B;AACnE,OAAOC,sBAAsB,MAAM,6BAA6B;AAEhE,eAAe,SAASC,6BAA6BA,CAAE;EAAEC;AAAW,CAAC,EAAG;EACvE,OACCC,aAAA,CAAAC,QAAA,QACCD,aAAA,CAACJ,wBAAwB;IAACG,UAAU,EAAGA;EAAY,CAAE,CAAC,EACtDC,aAAA,CAACH,sBAAsB,MAAE,CACxB,CAAC;AAEL"}
|
|
@@ -1,93 +0,0 @@
|
|
|
1
|
-
import { createElement, Fragment } from "react";
|
|
2
|
-
/**
|
|
3
|
-
* WordPress dependencies
|
|
4
|
-
*/
|
|
5
|
-
import { useSelect, useDispatch } from '@wordpress/data';
|
|
6
|
-
import { decodeEntities } from '@wordpress/html-entities';
|
|
7
|
-
import { DropdownMenu, MenuGroup, MenuItem } from '@wordpress/components';
|
|
8
|
-
import { __ } from '@wordpress/i18n';
|
|
9
|
-
import { store as coreStore } from '@wordpress/core-data';
|
|
10
|
-
import { check } from '@wordpress/icons';
|
|
11
|
-
import { privateApis as editorPrivateApis, store as editorStore } from '@wordpress/editor';
|
|
12
|
-
|
|
13
|
-
/**
|
|
14
|
-
* Internal dependencies
|
|
15
|
-
*/
|
|
16
|
-
import { store as editSiteStore } from '../../../store';
|
|
17
|
-
import SwapTemplateButton from './swap-template-button';
|
|
18
|
-
import ResetDefaultTemplate from './reset-default-template';
|
|
19
|
-
import { unlock } from '../../../lock-unlock';
|
|
20
|
-
const {
|
|
21
|
-
PostPanelRow
|
|
22
|
-
} = unlock(editorPrivateApis);
|
|
23
|
-
const POPOVER_PROPS = {
|
|
24
|
-
className: 'edit-site-page-panels-edit-template__dropdown',
|
|
25
|
-
placement: 'bottom-start'
|
|
26
|
-
};
|
|
27
|
-
export default function EditTemplate() {
|
|
28
|
-
const {
|
|
29
|
-
hasResolved,
|
|
30
|
-
template,
|
|
31
|
-
isTemplateHidden
|
|
32
|
-
} = useSelect(select => {
|
|
33
|
-
const {
|
|
34
|
-
getEditedPostContext,
|
|
35
|
-
getEditedPostType,
|
|
36
|
-
getEditedPostId
|
|
37
|
-
} = select(editSiteStore);
|
|
38
|
-
const {
|
|
39
|
-
getRenderingMode
|
|
40
|
-
} = unlock(select(editorStore));
|
|
41
|
-
const {
|
|
42
|
-
getEditedEntityRecord,
|
|
43
|
-
hasFinishedResolution
|
|
44
|
-
} = select(coreStore);
|
|
45
|
-
const _context = getEditedPostContext();
|
|
46
|
-
const _postType = getEditedPostType();
|
|
47
|
-
const queryArgs = ['postType', _postType, getEditedPostId()];
|
|
48
|
-
return {
|
|
49
|
-
context: _context,
|
|
50
|
-
hasResolved: hasFinishedResolution('getEditedEntityRecord', queryArgs),
|
|
51
|
-
template: getEditedEntityRecord(...queryArgs),
|
|
52
|
-
isTemplateHidden: getRenderingMode() === 'post-only',
|
|
53
|
-
postType: _postType
|
|
54
|
-
};
|
|
55
|
-
}, []);
|
|
56
|
-
const {
|
|
57
|
-
setRenderingMode
|
|
58
|
-
} = useDispatch(editorStore);
|
|
59
|
-
if (!hasResolved) {
|
|
60
|
-
return null;
|
|
61
|
-
}
|
|
62
|
-
return createElement(PostPanelRow, {
|
|
63
|
-
label: __('Template')
|
|
64
|
-
}, createElement(DropdownMenu, {
|
|
65
|
-
popoverProps: POPOVER_PROPS,
|
|
66
|
-
focusOnMount: true,
|
|
67
|
-
toggleProps: {
|
|
68
|
-
variant: 'tertiary',
|
|
69
|
-
className: 'edit-site-summary-field__trigger'
|
|
70
|
-
},
|
|
71
|
-
label: __('Template options'),
|
|
72
|
-
text: decodeEntities(template.title),
|
|
73
|
-
icon: null
|
|
74
|
-
}, ({
|
|
75
|
-
onClose
|
|
76
|
-
}) => createElement(Fragment, null, createElement(MenuGroup, null, createElement(MenuItem, {
|
|
77
|
-
onClick: () => {
|
|
78
|
-
setRenderingMode('template-only');
|
|
79
|
-
onClose();
|
|
80
|
-
}
|
|
81
|
-
}, __('Edit template')), createElement(SwapTemplateButton, {
|
|
82
|
-
onClick: onClose
|
|
83
|
-
})), createElement(ResetDefaultTemplate, {
|
|
84
|
-
onClick: onClose
|
|
85
|
-
}), createElement(MenuGroup, null, createElement(MenuItem, {
|
|
86
|
-
icon: !isTemplateHidden ? check : undefined,
|
|
87
|
-
isPressed: !isTemplateHidden,
|
|
88
|
-
onClick: () => {
|
|
89
|
-
setRenderingMode(isTemplateHidden ? 'template-locked' : 'post-only');
|
|
90
|
-
}
|
|
91
|
-
}, __('Template preview'))))));
|
|
92
|
-
}
|
|
93
|
-
//# sourceMappingURL=edit-template.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"names":["useSelect","useDispatch","decodeEntities","DropdownMenu","MenuGroup","MenuItem","__","store","coreStore","check","privateApis","editorPrivateApis","editorStore","editSiteStore","SwapTemplateButton","ResetDefaultTemplate","unlock","PostPanelRow","POPOVER_PROPS","className","placement","EditTemplate","hasResolved","template","isTemplateHidden","select","getEditedPostContext","getEditedPostType","getEditedPostId","getRenderingMode","getEditedEntityRecord","hasFinishedResolution","_context","_postType","queryArgs","context","postType","setRenderingMode","createElement","label","popoverProps","focusOnMount","toggleProps","variant","text","title","icon","onClose","Fragment","onClick","undefined","isPressed"],"sources":["@wordpress/edit-site/src/components/sidebar-edit-mode/page-panels/edit-template.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { useSelect, useDispatch } from '@wordpress/data';\nimport { decodeEntities } from '@wordpress/html-entities';\nimport { DropdownMenu, MenuGroup, MenuItem } from '@wordpress/components';\nimport { __ } from '@wordpress/i18n';\nimport { store as coreStore } from '@wordpress/core-data';\nimport { check } from '@wordpress/icons';\nimport {\n\tprivateApis as editorPrivateApis,\n\tstore as editorStore,\n} from '@wordpress/editor';\n\n/**\n * Internal dependencies\n */\nimport { store as editSiteStore } from '../../../store';\nimport SwapTemplateButton from './swap-template-button';\nimport ResetDefaultTemplate from './reset-default-template';\nimport { unlock } from '../../../lock-unlock';\n\nconst { PostPanelRow } = unlock( editorPrivateApis );\n\nconst POPOVER_PROPS = {\n\tclassName: 'edit-site-page-panels-edit-template__dropdown',\n\tplacement: 'bottom-start',\n};\n\nexport default function EditTemplate() {\n\tconst { hasResolved, template, isTemplateHidden } = useSelect(\n\t\t( select ) => {\n\t\t\tconst { getEditedPostContext, getEditedPostType, getEditedPostId } =\n\t\t\t\tselect( editSiteStore );\n\t\t\tconst { getRenderingMode } = unlock( select( editorStore ) );\n\t\t\tconst { getEditedEntityRecord, hasFinishedResolution } =\n\t\t\t\tselect( coreStore );\n\t\t\tconst _context = getEditedPostContext();\n\t\t\tconst _postType = getEditedPostType();\n\t\t\tconst queryArgs = [ 'postType', _postType, getEditedPostId() ];\n\t\t\treturn {\n\t\t\t\tcontext: _context,\n\t\t\t\thasResolved: hasFinishedResolution(\n\t\t\t\t\t'getEditedEntityRecord',\n\t\t\t\t\tqueryArgs\n\t\t\t\t),\n\t\t\t\ttemplate: getEditedEntityRecord( ...queryArgs ),\n\t\t\t\tisTemplateHidden: getRenderingMode() === 'post-only',\n\t\t\t\tpostType: _postType,\n\t\t\t};\n\t\t},\n\t\t[]\n\t);\n\n\tconst { setRenderingMode } = useDispatch( editorStore );\n\n\tif ( ! hasResolved ) {\n\t\treturn null;\n\t}\n\n\treturn (\n\t\t<PostPanelRow label={ __( 'Template' ) }>\n\t\t\t<DropdownMenu\n\t\t\t\tpopoverProps={ POPOVER_PROPS }\n\t\t\t\tfocusOnMount\n\t\t\t\ttoggleProps={ {\n\t\t\t\t\tvariant: 'tertiary',\n\t\t\t\t\tclassName: 'edit-site-summary-field__trigger',\n\t\t\t\t} }\n\t\t\t\tlabel={ __( 'Template options' ) }\n\t\t\t\ttext={ decodeEntities( template.title ) }\n\t\t\t\ticon={ null }\n\t\t\t>\n\t\t\t\t{ ( { onClose } ) => (\n\t\t\t\t\t<>\n\t\t\t\t\t\t<MenuGroup>\n\t\t\t\t\t\t\t<MenuItem\n\t\t\t\t\t\t\t\tonClick={ () => {\n\t\t\t\t\t\t\t\t\tsetRenderingMode( 'template-only' );\n\t\t\t\t\t\t\t\t\tonClose();\n\t\t\t\t\t\t\t\t} }\n\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t{ __( 'Edit template' ) }\n\t\t\t\t\t\t\t</MenuItem>\n\t\t\t\t\t\t\t<SwapTemplateButton onClick={ onClose } />\n\t\t\t\t\t\t</MenuGroup>\n\t\t\t\t\t\t<ResetDefaultTemplate onClick={ onClose } />\n\t\t\t\t\t\t<MenuGroup>\n\t\t\t\t\t\t\t<MenuItem\n\t\t\t\t\t\t\t\ticon={ ! isTemplateHidden ? check : undefined }\n\t\t\t\t\t\t\t\tisPressed={ ! isTemplateHidden }\n\t\t\t\t\t\t\t\tonClick={ () => {\n\t\t\t\t\t\t\t\t\tsetRenderingMode(\n\t\t\t\t\t\t\t\t\t\tisTemplateHidden\n\t\t\t\t\t\t\t\t\t\t\t? 'template-locked'\n\t\t\t\t\t\t\t\t\t\t\t: 'post-only'\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\t\t{ __( 'Template preview' ) }\n\t\t\t\t\t\t\t</MenuItem>\n\t\t\t\t\t\t</MenuGroup>\n\t\t\t\t\t</>\n\t\t\t\t) }\n\t\t\t</DropdownMenu>\n\t\t</PostPanelRow>\n\t);\n}\n"],"mappings":";AAAA;AACA;AACA;AACA,SAASA,SAAS,EAAEC,WAAW,QAAQ,iBAAiB;AACxD,SAASC,cAAc,QAAQ,0BAA0B;AACzD,SAASC,YAAY,EAAEC,SAAS,EAAEC,QAAQ,QAAQ,uBAAuB;AACzE,SAASC,EAAE,QAAQ,iBAAiB;AACpC,SAASC,KAAK,IAAIC,SAAS,QAAQ,sBAAsB;AACzD,SAASC,KAAK,QAAQ,kBAAkB;AACxC,SACCC,WAAW,IAAIC,iBAAiB,EAChCJ,KAAK,IAAIK,WAAW,QACd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
*/
|
|
4
|
-
import { useSelect } from '@wordpress/data';
|
|
5
|
-
import { useMemo } from '@wordpress/element';
|
|
6
|
-
import { store as coreStore } from '@wordpress/core-data';
|
|
7
|
-
|
|
8
|
-
/**
|
|
9
|
-
* Internal dependencies
|
|
10
|
-
*/
|
|
11
|
-
import { store as editSiteStore } from '../../../store';
|
|
12
|
-
import { TEMPLATE_POST_TYPE } from '../../../utils/constants';
|
|
13
|
-
export function useEditedPostContext() {
|
|
14
|
-
return useSelect(select => select(editSiteStore).getEditedPostContext(), []);
|
|
15
|
-
}
|
|
16
|
-
export function useAllowSwitchingTemplates() {
|
|
17
|
-
const {
|
|
18
|
-
postId
|
|
19
|
-
} = useEditedPostContext();
|
|
20
|
-
return useSelect(select => {
|
|
21
|
-
const {
|
|
22
|
-
getEntityRecord,
|
|
23
|
-
getEntityRecords
|
|
24
|
-
} = select(coreStore);
|
|
25
|
-
const siteSettings = getEntityRecord('root', 'site');
|
|
26
|
-
const templates = getEntityRecords('postType', TEMPLATE_POST_TYPE, {
|
|
27
|
-
per_page: -1
|
|
28
|
-
});
|
|
29
|
-
const isPostsPage = +postId === siteSettings?.page_for_posts;
|
|
30
|
-
// If current page is set front page or posts page, we also need
|
|
31
|
-
// to check if the current theme has a template for it. If not
|
|
32
|
-
const isFrontPage = +postId === siteSettings?.page_on_front && templates?.some(({
|
|
33
|
-
slug
|
|
34
|
-
}) => slug === 'front-page');
|
|
35
|
-
return !isPostsPage && !isFrontPage;
|
|
36
|
-
}, [postId]);
|
|
37
|
-
}
|
|
38
|
-
function useTemplates() {
|
|
39
|
-
return useSelect(select => select(coreStore).getEntityRecords('postType', TEMPLATE_POST_TYPE, {
|
|
40
|
-
per_page: -1,
|
|
41
|
-
post_type: 'page'
|
|
42
|
-
}), []);
|
|
43
|
-
}
|
|
44
|
-
export function useAvailableTemplates() {
|
|
45
|
-
const currentTemplateSlug = useCurrentTemplateSlug();
|
|
46
|
-
const allowSwitchingTemplate = useAllowSwitchingTemplates();
|
|
47
|
-
const templates = useTemplates();
|
|
48
|
-
return useMemo(() => allowSwitchingTemplate && templates?.filter(template => template.is_custom && template.slug !== currentTemplateSlug && !!template.content.raw // Skip empty templates.
|
|
49
|
-
), [templates, currentTemplateSlug, allowSwitchingTemplate]);
|
|
50
|
-
}
|
|
51
|
-
export function useCurrentTemplateSlug() {
|
|
52
|
-
const {
|
|
53
|
-
postType,
|
|
54
|
-
postId
|
|
55
|
-
} = useEditedPostContext();
|
|
56
|
-
const templates = useTemplates();
|
|
57
|
-
const entityTemplate = useSelect(select => {
|
|
58
|
-
const post = select(coreStore).getEditedEntityRecord('postType', postType, postId);
|
|
59
|
-
return post?.template;
|
|
60
|
-
}, [postType, postId]);
|
|
61
|
-
if (!entityTemplate) {
|
|
62
|
-
return;
|
|
63
|
-
}
|
|
64
|
-
// If a page has a `template` set and is not included in the list
|
|
65
|
-
// of the theme's templates, do not return it, in order to resolve
|
|
66
|
-
// to the current theme's default template.
|
|
67
|
-
return templates?.find(template => template.slug === entityTemplate)?.slug;
|
|
68
|
-
}
|
|
69
|
-
//# sourceMappingURL=hooks.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"names":["useSelect","useMemo","store","coreStore","editSiteStore","TEMPLATE_POST_TYPE","useEditedPostContext","select","getEditedPostContext","useAllowSwitchingTemplates","postId","getEntityRecord","getEntityRecords","siteSettings","templates","per_page","isPostsPage","page_for_posts","isFrontPage","page_on_front","some","slug","useTemplates","post_type","useAvailableTemplates","currentTemplateSlug","useCurrentTemplateSlug","allowSwitchingTemplate","filter","template","is_custom","content","raw","postType","entityTemplate","post","getEditedEntityRecord","find"],"sources":["@wordpress/edit-site/src/components/sidebar-edit-mode/page-panels/hooks.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { useSelect } from '@wordpress/data';\nimport { useMemo } from '@wordpress/element';\nimport { store as coreStore } from '@wordpress/core-data';\n\n/**\n * Internal dependencies\n */\nimport { store as editSiteStore } from '../../../store';\nimport { TEMPLATE_POST_TYPE } from '../../../utils/constants';\n\nexport function useEditedPostContext() {\n\treturn useSelect(\n\t\t( select ) => select( editSiteStore ).getEditedPostContext(),\n\t\t[]\n\t);\n}\n\nexport function useAllowSwitchingTemplates() {\n\tconst { postId } = useEditedPostContext();\n\treturn useSelect(\n\t\t( select ) => {\n\t\t\tconst { getEntityRecord, getEntityRecords } = select( coreStore );\n\t\t\tconst siteSettings = getEntityRecord( 'root', 'site' );\n\t\t\tconst templates = getEntityRecords(\n\t\t\t\t'postType',\n\t\t\t\tTEMPLATE_POST_TYPE,\n\t\t\t\t{ per_page: -1 }\n\t\t\t);\n\t\t\tconst isPostsPage = +postId === siteSettings?.page_for_posts;\n\t\t\t// If current page is set front page or posts page, we also need\n\t\t\t// to check if the current theme has a template for it. If not\n\t\t\tconst isFrontPage =\n\t\t\t\t+postId === siteSettings?.page_on_front &&\n\t\t\t\ttemplates?.some( ( { slug } ) => slug === 'front-page' );\n\t\t\treturn ! isPostsPage && ! isFrontPage;\n\t\t},\n\t\t[ postId ]\n\t);\n}\n\nfunction useTemplates() {\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\tpost_type: 'page',\n\t\t\t\t}\n\t\t\t),\n\t\t[]\n\t);\n}\n\nexport function useAvailableTemplates() {\n\tconst currentTemplateSlug = useCurrentTemplateSlug();\n\tconst allowSwitchingTemplate = useAllowSwitchingTemplates();\n\tconst templates = useTemplates();\n\treturn useMemo(\n\t\t() =>\n\t\t\tallowSwitchingTemplate &&\n\t\t\ttemplates?.filter(\n\t\t\t\t( template ) =>\n\t\t\t\t\ttemplate.is_custom &&\n\t\t\t\t\ttemplate.slug !== currentTemplateSlug &&\n\t\t\t\t\t!! template.content.raw // Skip empty templates.\n\t\t\t),\n\t\t[ templates, currentTemplateSlug, allowSwitchingTemplate ]\n\t);\n}\n\nexport function useCurrentTemplateSlug() {\n\tconst { postType, postId } = useEditedPostContext();\n\tconst templates = useTemplates();\n\tconst entityTemplate = useSelect(\n\t\t( select ) => {\n\t\t\tconst post = select( coreStore ).getEditedEntityRecord(\n\t\t\t\t'postType',\n\t\t\t\tpostType,\n\t\t\t\tpostId\n\t\t\t);\n\t\t\treturn post?.template;\n\t\t},\n\t\t[ postType, postId ]\n\t);\n\n\tif ( ! entityTemplate ) {\n\t\treturn;\n\t}\n\t// If a page has a `template` set and is not included in the list\n\t// of the theme's templates, do not return it, in order to resolve\n\t// to the current theme's default template.\n\treturn templates?.find( ( template ) => template.slug === entityTemplate )\n\t\t?.slug;\n}\n"],"mappings":"AAAA;AACA;AACA;AACA,SAASA,SAAS,QAAQ,iBAAiB;AAC3C,SAASC,OAAO,QAAQ,oBAAoB;AAC5C,SAASC,KAAK,IAAIC,SAAS,QAAQ,sBAAsB;;AAEzD;AACA;AACA;AACA,SAASD,KAAK,IAAIE,aAAa,QAAQ,gBAAgB;AACvD,SAASC,kBAAkB,QAAQ,0BAA0B;AAE7D,OAAO,SAASC,oBAAoBA,CAAA,EAAG;EACtC,OAAON,SAAS,CACbO,MAAM,IAAMA,MAAM,CAAEH,aAAc,CAAC,CAACI,oBAAoB,CAAC,CAAC,EAC5D,EACD,CAAC;AACF;AAEA,OAAO,SAASC,0BAA0BA,CAAA,EAAG;EAC5C,MAAM;IAAEC;EAAO,CAAC,GAAGJ,oBAAoB,CAAC,CAAC;EACzC,OAAON,SAAS,CACbO,MAAM,IAAM;IACb,MAAM;MAAEI,eAAe;MAAEC;IAAiB,CAAC,GAAGL,MAAM,CAAEJ,SAAU,CAAC;IACjE,MAAMU,YAAY,GAAGF,eAAe,CAAE,MAAM,EAAE,MAAO,CAAC;IACtD,MAAMG,SAAS,GAAGF,gBAAgB,CACjC,UAAU,EACVP,kBAAkB,EAClB;MAAEU,QAAQ,EAAE,CAAC;IAAE,CAChB,CAAC;IACD,MAAMC,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B,IAAI,GAAG5B,MAAM,CAAEJ,SAAU,CAAC,CAACiC,qBAAqB,CACrD,UAAU,EACVH,QAAQ,EACRvB,MACD,CAAC;IACD,OAAOyB,IAAI,EAAEN,QAAQ;EACtB,CAAC,EACD,CAAEI,QAAQ,EAAEvB,MAAM,CACnB,CAAC;EAED,IAAK,CAAEwB,cAAc,EAAG;IACvB;EACD;EACA;EACA;EACA;EACA,OAAOpB,SAAS,EAAEuB,IAAI,CAAIR,QAAQ,IAAMA,QAAQ,CAACR,IAAI,KAAKa,cAAe,CAAC,EACvEb,IAAI;AACR"}
|
|
@@ -1,41 +0,0 @@
|
|
|
1
|
-
import { createElement } from "react";
|
|
2
|
-
/**
|
|
3
|
-
* WordPress dependencies
|
|
4
|
-
*/
|
|
5
|
-
import { MenuGroup, MenuItem } from '@wordpress/components';
|
|
6
|
-
import { __ } from '@wordpress/i18n';
|
|
7
|
-
import { useDispatch } from '@wordpress/data';
|
|
8
|
-
import { store as coreStore } from '@wordpress/core-data';
|
|
9
|
-
|
|
10
|
-
/**
|
|
11
|
-
* Internal dependencies
|
|
12
|
-
*/
|
|
13
|
-
import { useAllowSwitchingTemplates, useCurrentTemplateSlug, useEditedPostContext } from './hooks';
|
|
14
|
-
export default function ResetDefaultTemplate({
|
|
15
|
-
onClick
|
|
16
|
-
}) {
|
|
17
|
-
const currentTemplateSlug = useCurrentTemplateSlug();
|
|
18
|
-
const allowSwitchingTemplate = useAllowSwitchingTemplates();
|
|
19
|
-
const {
|
|
20
|
-
postType,
|
|
21
|
-
postId
|
|
22
|
-
} = useEditedPostContext();
|
|
23
|
-
const {
|
|
24
|
-
editEntityRecord
|
|
25
|
-
} = useDispatch(coreStore);
|
|
26
|
-
// The default template in a post is indicated by an empty string.
|
|
27
|
-
if (!currentTemplateSlug || !allowSwitchingTemplate) {
|
|
28
|
-
return null;
|
|
29
|
-
}
|
|
30
|
-
return createElement(MenuGroup, null, createElement(MenuItem, {
|
|
31
|
-
onClick: async () => {
|
|
32
|
-
editEntityRecord('postType', postType, postId, {
|
|
33
|
-
template: ''
|
|
34
|
-
}, {
|
|
35
|
-
undoIgnore: true
|
|
36
|
-
});
|
|
37
|
-
onClick();
|
|
38
|
-
}
|
|
39
|
-
}, __('Use default template')));
|
|
40
|
-
}
|
|
41
|
-
//# sourceMappingURL=reset-default-template.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"names":["MenuGroup","MenuItem","__","useDispatch","store","coreStore","useAllowSwitchingTemplates","useCurrentTemplateSlug","useEditedPostContext","ResetDefaultTemplate","onClick","currentTemplateSlug","allowSwitchingTemplate","postType","postId","editEntityRecord","createElement","template","undoIgnore"],"sources":["@wordpress/edit-site/src/components/sidebar-edit-mode/page-panels/reset-default-template.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { MenuGroup, MenuItem } from '@wordpress/components';\nimport { __ } from '@wordpress/i18n';\nimport { useDispatch } from '@wordpress/data';\nimport { store as coreStore } from '@wordpress/core-data';\n\n/**\n * Internal dependencies\n */\nimport {\n\tuseAllowSwitchingTemplates,\n\tuseCurrentTemplateSlug,\n\tuseEditedPostContext,\n} from './hooks';\n\nexport default function ResetDefaultTemplate( { onClick } ) {\n\tconst currentTemplateSlug = useCurrentTemplateSlug();\n\tconst allowSwitchingTemplate = useAllowSwitchingTemplates();\n\tconst { postType, postId } = useEditedPostContext();\n\tconst { editEntityRecord } = useDispatch( coreStore );\n\t// The default template in a post is indicated by an empty string.\n\tif ( ! currentTemplateSlug || ! allowSwitchingTemplate ) {\n\t\treturn null;\n\t}\n\treturn (\n\t\t<MenuGroup>\n\t\t\t<MenuItem\n\t\t\t\tonClick={ async () => {\n\t\t\t\t\teditEntityRecord(\n\t\t\t\t\t\t'postType',\n\t\t\t\t\t\tpostType,\n\t\t\t\t\t\tpostId,\n\t\t\t\t\t\t{ template: '' },\n\t\t\t\t\t\t{ undoIgnore: true }\n\t\t\t\t\t);\n\t\t\t\t\tonClick();\n\t\t\t\t} }\n\t\t\t>\n\t\t\t\t{ __( 'Use default template' ) }\n\t\t\t</MenuItem>\n\t\t</MenuGroup>\n\t);\n}\n"],"mappings":";AAAA;AACA;AACA;AACA,SAASA,SAAS,EAAEC,QAAQ,QAAQ,uBAAuB;AAC3D,SAASC,EAAE,QAAQ,iBAAiB;AACpC,SAASC,WAAW,QAAQ,iBAAiB;AAC7C,SAASC,KAAK,IAAIC,SAAS,QAAQ,sBAAsB;;AAEzD;AACA;AACA;AACA,SACCC,0BAA0B,EAC1BC,sBAAsB,EACtBC,oBAAoB,QACd,SAAS;AAEhB,eAAe,SAASC,oBAAoBA,CAAE;EAAEC;AAAQ,CAAC,EAAG;EAC3D,MAAMC,mBAAmB,GAAGJ,sBAAsB,CAAC,CAAC;EACpD,MAAMK,sBAAsB,GAAGN,0BAA0B,CAAC,CAAC;EAC3D,MAAM;IAAEO,QAAQ;IAAEC;EAAO,CAAC,GAAGN,oBAAoB,CAAC,CAAC;EACnD,MAAM;IAAEO;EAAiB,CAAC,GAAGZ,WAAW,CAAEE,SAAU,CAAC;EACrD;EACA,IAAK,CAAEM,mBAAmB,IAAI,CAAEC,sBAAsB,EAAG;IACxD,OAAO,IAAI;EACZ;EACA,OACCI,aAAA,CAAChB,SAAS,QACTgB,aAAA,CAACf,QAAQ;IACRS,OAAO,EAAG,MAAAA,CAAA,KAAY;MACrBK,gBAAgB,CACf,UAAU,EACVF,QAAQ,EACRC,MAAM,EACN;QAAEG,QAAQ,EAAE;MAAG,CAAC,EAChB;QAAEC,UAAU,EAAE;MAAK,CACpB,CAAC;MACDR,OAAO,CAAC,CAAC;IACV;EAAG,GAEDR,EAAE,CAAE,sBAAuB,CACpB,CACA,CAAC;AAEd"}
|
|
@@ -1,77 +0,0 @@
|
|
|
1
|
-
import { createElement, Fragment } from "react";
|
|
2
|
-
/**
|
|
3
|
-
* WordPress dependencies
|
|
4
|
-
*/
|
|
5
|
-
import { useMemo, useState, useCallback } from '@wordpress/element';
|
|
6
|
-
import { decodeEntities } from '@wordpress/html-entities';
|
|
7
|
-
import { __experimentalBlockPatternsList as BlockPatternsList } from '@wordpress/block-editor';
|
|
8
|
-
import { MenuItem, Modal } from '@wordpress/components';
|
|
9
|
-
import { __ } from '@wordpress/i18n';
|
|
10
|
-
import { useDispatch } from '@wordpress/data';
|
|
11
|
-
import { store as coreStore } from '@wordpress/core-data';
|
|
12
|
-
import { parse } from '@wordpress/blocks';
|
|
13
|
-
import { useAsyncList } from '@wordpress/compose';
|
|
14
|
-
|
|
15
|
-
/**
|
|
16
|
-
* Internal dependencies
|
|
17
|
-
*/
|
|
18
|
-
import { useAvailableTemplates, useEditedPostContext } from './hooks';
|
|
19
|
-
export default function SwapTemplateButton({
|
|
20
|
-
onClick
|
|
21
|
-
}) {
|
|
22
|
-
const [showModal, setShowModal] = useState(false);
|
|
23
|
-
const availableTemplates = useAvailableTemplates();
|
|
24
|
-
const onClose = useCallback(() => {
|
|
25
|
-
setShowModal(false);
|
|
26
|
-
}, []);
|
|
27
|
-
const {
|
|
28
|
-
postType,
|
|
29
|
-
postId
|
|
30
|
-
} = useEditedPostContext();
|
|
31
|
-
const {
|
|
32
|
-
editEntityRecord
|
|
33
|
-
} = useDispatch(coreStore);
|
|
34
|
-
if (!availableTemplates?.length) {
|
|
35
|
-
return null;
|
|
36
|
-
}
|
|
37
|
-
const onTemplateSelect = async template => {
|
|
38
|
-
editEntityRecord('postType', postType, postId, {
|
|
39
|
-
template: template.name
|
|
40
|
-
}, {
|
|
41
|
-
undoIgnore: true
|
|
42
|
-
});
|
|
43
|
-
onClose(); // Close the template suggestions modal first.
|
|
44
|
-
onClick();
|
|
45
|
-
};
|
|
46
|
-
return createElement(Fragment, null, createElement(MenuItem, {
|
|
47
|
-
onClick: () => setShowModal(true)
|
|
48
|
-
}, __('Swap template')), showModal && createElement(Modal, {
|
|
49
|
-
title: __('Choose a template'),
|
|
50
|
-
onRequestClose: onClose,
|
|
51
|
-
overlayClassName: "edit-site-swap-template-modal",
|
|
52
|
-
isFullScreen: true
|
|
53
|
-
}, createElement("div", {
|
|
54
|
-
className: "edit-site-page-panels__swap-template__modal-content"
|
|
55
|
-
}, createElement(TemplatesList, {
|
|
56
|
-
onSelect: onTemplateSelect
|
|
57
|
-
}))));
|
|
58
|
-
}
|
|
59
|
-
function TemplatesList({
|
|
60
|
-
onSelect
|
|
61
|
-
}) {
|
|
62
|
-
const availableTemplates = useAvailableTemplates();
|
|
63
|
-
const templatesAsPatterns = useMemo(() => availableTemplates.map(template => ({
|
|
64
|
-
name: template.slug,
|
|
65
|
-
blocks: parse(template.content.raw),
|
|
66
|
-
title: decodeEntities(template.title.rendered),
|
|
67
|
-
id: template.id
|
|
68
|
-
})), [availableTemplates]);
|
|
69
|
-
const shownTemplates = useAsyncList(templatesAsPatterns);
|
|
70
|
-
return createElement(BlockPatternsList, {
|
|
71
|
-
label: __('Templates'),
|
|
72
|
-
blockPatterns: templatesAsPatterns,
|
|
73
|
-
shownPatterns: shownTemplates,
|
|
74
|
-
onClickPattern: onSelect
|
|
75
|
-
});
|
|
76
|
-
}
|
|
77
|
-
//# sourceMappingURL=swap-template-button.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"names":["useMemo","useState","useCallback","decodeEntities","__experimentalBlockPatternsList","BlockPatternsList","MenuItem","Modal","__","useDispatch","store","coreStore","parse","useAsyncList","useAvailableTemplates","useEditedPostContext","SwapTemplateButton","onClick","showModal","setShowModal","availableTemplates","onClose","postType","postId","editEntityRecord","length","onTemplateSelect","template","name","undoIgnore","createElement","Fragment","title","onRequestClose","overlayClassName","isFullScreen","className","TemplatesList","onSelect","templatesAsPatterns","map","slug","blocks","content","raw","rendered","id","shownTemplates","label","blockPatterns","shownPatterns","onClickPattern"],"sources":["@wordpress/edit-site/src/components/sidebar-edit-mode/page-panels/swap-template-button.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { useMemo, useState, useCallback } from '@wordpress/element';\nimport { decodeEntities } from '@wordpress/html-entities';\nimport { __experimentalBlockPatternsList as BlockPatternsList } from '@wordpress/block-editor';\nimport { MenuItem, Modal } from '@wordpress/components';\nimport { __ } from '@wordpress/i18n';\nimport { useDispatch } from '@wordpress/data';\nimport { store as coreStore } from '@wordpress/core-data';\nimport { parse } from '@wordpress/blocks';\nimport { useAsyncList } from '@wordpress/compose';\n\n/**\n * Internal dependencies\n */\nimport { useAvailableTemplates, useEditedPostContext } from './hooks';\n\nexport default function SwapTemplateButton( { onClick } ) {\n\tconst [ showModal, setShowModal ] = useState( false );\n\tconst availableTemplates = useAvailableTemplates();\n\tconst onClose = useCallback( () => {\n\t\tsetShowModal( false );\n\t}, [] );\n\tconst { postType, postId } = useEditedPostContext();\n\tconst { editEntityRecord } = useDispatch( coreStore );\n\tif ( ! availableTemplates?.length ) {\n\t\treturn null;\n\t}\n\tconst onTemplateSelect = async ( template ) => {\n\t\teditEntityRecord(\n\t\t\t'postType',\n\t\t\tpostType,\n\t\t\tpostId,\n\t\t\t{ template: template.name },\n\t\t\t{ undoIgnore: true }\n\t\t);\n\t\tonClose(); // Close the template suggestions modal first.\n\t\tonClick();\n\t};\n\treturn (\n\t\t<>\n\t\t\t<MenuItem onClick={ () => setShowModal( true ) }>\n\t\t\t\t{ __( 'Swap template' ) }\n\t\t\t</MenuItem>\n\t\t\t{ showModal && (\n\t\t\t\t<Modal\n\t\t\t\t\ttitle={ __( 'Choose a template' ) }\n\t\t\t\t\tonRequestClose={ onClose }\n\t\t\t\t\toverlayClassName=\"edit-site-swap-template-modal\"\n\t\t\t\t\tisFullScreen\n\t\t\t\t>\n\t\t\t\t\t<div className=\"edit-site-page-panels__swap-template__modal-content\">\n\t\t\t\t\t\t<TemplatesList onSelect={ onTemplateSelect } />\n\t\t\t\t\t</div>\n\t\t\t\t</Modal>\n\t\t\t) }\n\t\t</>\n\t);\n}\n\nfunction TemplatesList( { onSelect } ) {\n\tconst availableTemplates = useAvailableTemplates();\n\tconst templatesAsPatterns = useMemo(\n\t\t() =>\n\t\t\tavailableTemplates.map( ( template ) => ( {\n\t\t\t\tname: template.slug,\n\t\t\t\tblocks: parse( template.content.raw ),\n\t\t\t\ttitle: decodeEntities( template.title.rendered ),\n\t\t\t\tid: template.id,\n\t\t\t} ) ),\n\t\t[ availableTemplates ]\n\t);\n\tconst shownTemplates = useAsyncList( templatesAsPatterns );\n\treturn (\n\t\t<BlockPatternsList\n\t\t\tlabel={ __( 'Templates' ) }\n\t\t\tblockPatterns={ templatesAsPatterns }\n\t\t\tshownPatterns={ shownTemplates }\n\t\t\tonClickPattern={ onSelect }\n\t\t/>\n\t);\n}\n"],"mappings":";AAAA;AACA;AACA;AACA,SAASA,OAAO,EAAEC,QAAQ,EAAEC,WAAW,QAAQ,oBAAoB;AACnE,SAASC,cAAc,QAAQ,0BAA0B;AACzD,SAASC,+BAA+B,IAAIC,iBAAiB,QAAQ,yBAAyB;AAC9F,SAASC,QAAQ,EAAEC,KAAK,QAAQ,uBAAuB;AACvD,SAASC,EAAE,QAAQ,iBAAiB;AACpC,SAASC,WAAW,QAAQ,iBAAiB;AAC7C,SAASC,KAAK,IAAIC,SAAS,QAAQ,sBAAsB;AACzD,SAASC,KAAK,QAAQ,mBAAmB;AACzC,SAASC,YAAY,QAAQ,oBAAoB;;AAEjD;AACA;AACA;AACA,SAASC,qBAAqB,EAAEC,oBAAoB,QAAQ,SAAS;AAErE,eAAe,SAASC,kBAAkBA,CAAE;EAAEC;AAAQ,CAAC,EAAG;EACzD,MAAM,CAAEC,SAAS,EAAEC,YAAY,CAAE,GAAGlB,QAAQ,CAAE,KAAM,CAAC;EACrD,MAAMmB,kBAAkB,GAAGN,qBAAqB,CAAC,CAAC;EAClD,MAAMO,OAAO,GAAGnB,WAAW,CAAE,MAAM;IAClCiB,YAAY,CAAE,KAAM,CAAC;EACtB,CAAC,EAAE,EAAG,CAAC;EACP,MAAM;IAAEG,QAAQ;IAAEC;EAAO,CAAC,GAAGR,oBAAoB,CAAC,CAAC;EACnD,MAAM;IAAES;EAAiB,CAAC,G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;EACd,CAAC,CAAG,CAAC,EACN,CAAE1B,kBAAkB,CACrB,CAAC;EACD,MAAM2B,cAAc,GAAGlC,YAAY,CAAE0B,mBAAoB,CAAC;EAC1D,OACCT,aAAA,CAACzB,iBAAiB;IACjB2C,KAAK,EAAGxC,EAAE,CAAE,WAAY,CAAG;IAC3ByC,aAAa,EAAGV,mBAAqB;IACrCW,aAAa,EAAGH,cAAgB;IAChCI,cAAc,EAAGb;EAAU,CAC3B,CAAC;AAEJ"}
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* WordPress dependencies
|
|
3
|
-
*/
|
|
4
|
-
import { useEffect, useState } from '@wordpress/element';
|
|
5
|
-
import { useDebounce } from '@wordpress/compose';
|
|
6
|
-
export default function useDebouncedInput(defaultValue = '') {
|
|
7
|
-
const [input, setInput] = useState(defaultValue);
|
|
8
|
-
const [debouncedInput, setDebouncedState] = useState(defaultValue);
|
|
9
|
-
const setDebouncedInput = useDebounce(setDebouncedState, 250);
|
|
10
|
-
useEffect(() => {
|
|
11
|
-
setDebouncedInput(input);
|
|
12
|
-
}, [input]);
|
|
13
|
-
return [input, setInput, debouncedInput];
|
|
14
|
-
}
|
|
15
|
-
//# sourceMappingURL=use-debounced-input.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"names":["useEffect","useState","useDebounce","useDebouncedInput","defaultValue","input","setInput","debouncedInput","setDebouncedState","setDebouncedInput"],"sources":["@wordpress/edit-site/src/utils/use-debounced-input.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { useEffect, useState } from '@wordpress/element';\nimport { useDebounce } from '@wordpress/compose';\n\nexport default function useDebouncedInput( defaultValue = '' ) {\n\tconst [ input, setInput ] = useState( defaultValue );\n\tconst [ debouncedInput, setDebouncedState ] = useState( defaultValue );\n\n\tconst setDebouncedInput = useDebounce( setDebouncedState, 250 );\n\n\tuseEffect( () => {\n\t\tsetDebouncedInput( input );\n\t}, [ input ] );\n\n\treturn [ input, setInput, debouncedInput ];\n}\n"],"mappings":"AAAA;AACA;AACA;AACA,SAASA,SAAS,EAAEC,QAAQ,QAAQ,oBAAoB;AACxD,SAASC,WAAW,QAAQ,oBAAoB;AAEhD,eAAe,SAASC,iBAAiBA,CAAEC,YAAY,GAAG,EAAE,EAAG;EAC9D,MAAM,CAAEC,KAAK,EAAEC,QAAQ,CAAE,GAAGL,QAAQ,CAAEG,YAAa,CAAC;EACpD,MAAM,CAAEG,cAAc,EAAEC,iBAAiB,CAAE,GAAGP,QAAQ,CAAEG,YAAa,CAAC;EAEtE,MAAMK,iBAAiB,GAAGP,WAAW,CAAEM,iBAAiB,EAAE,GAAI,CAAC;EAE/DR,SAAS,CAAE,MAAM;IAChBS,iBAAiB,CAAEJ,KAAM,CAAC;EAC3B,CAAC,EAAE,CAAEA,KAAK,CAAG,CAAC;EAEd,OAAO,CAAEA,KAAK,EAAEC,QAAQ,EAAEC,cAAc,CAAE;AAC3C"}
|