@wordpress/edit-site 5.23.0 → 5.24.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/actions/index.js +56 -38
- package/build/components/actions/index.js.map +1 -1
- package/build/components/block-editor/site-editor-canvas.js +7 -2
- package/build/components/block-editor/site-editor-canvas.js.map +1 -1
- package/build/components/dataviews/add-filter.js +21 -20
- package/build/components/dataviews/add-filter.js.map +1 -1
- package/build/components/dataviews/constants.js +14 -0
- package/build/components/dataviews/constants.js.map +1 -0
- package/build/components/dataviews/dataviews.js +9 -7
- package/build/components/dataviews/dataviews.js.map +1 -1
- package/build/components/dataviews/filter-summary.js +62 -0
- package/build/components/dataviews/filter-summary.js.map +1 -0
- package/build/components/dataviews/filters.js +15 -30
- package/build/components/dataviews/filters.js.map +1 -1
- package/build/components/dataviews/item-actions.js +84 -30
- package/build/components/dataviews/item-actions.js.map +1 -1
- package/build/components/dataviews/pagination.js +4 -0
- package/build/components/dataviews/pagination.js.map +1 -1
- package/build/components/dataviews/view-actions.js +24 -24
- package/build/components/dataviews/view-actions.js.map +1 -1
- package/build/components/dataviews/view-grid.js +48 -25
- package/build/components/dataviews/view-grid.js.map +1 -1
- package/build/components/dataviews/view-list.js +28 -33
- package/build/components/dataviews/view-list.js.map +1 -1
- package/build/components/editor/index.js +23 -27
- package/build/components/editor/index.js.map +1 -1
- package/build/components/global-styles/font-library-modal/utils/get-intersecting-font-faces.js +1 -1
- package/build/components/global-styles/font-library-modal/utils/get-intersecting-font-faces.js.map +1 -1
- package/build/components/global-styles/font-library-modal/utils/index.js +15 -2
- package/build/components/global-styles/font-library-modal/utils/index.js.map +1 -1
- package/build/components/global-styles/header.js +4 -2
- package/build/components/global-styles/header.js.map +1 -1
- package/build/components/global-styles/screen-block-list.js +22 -16
- package/build/components/global-styles/screen-block-list.js.map +1 -1
- package/build/components/global-styles/screen-revisions/index.js +26 -5
- package/build/components/global-styles/screen-revisions/index.js.map +1 -1
- package/build/components/global-styles/screen-revisions/revisions-buttons.js +52 -24
- package/build/components/global-styles/screen-revisions/revisions-buttons.js.map +1 -1
- package/build/components/global-styles/screen-revisions/use-global-styles-revisions.js +9 -3
- package/build/components/global-styles/screen-revisions/use-global-styles-revisions.js.map +1 -1
- package/build/components/global-styles/ui.js +28 -36
- package/build/components/global-styles/ui.js.map +1 -1
- package/build/components/header-edit-mode/document-actions/index.js +21 -16
- package/build/components/header-edit-mode/document-actions/index.js.map +1 -1
- package/build/components/header-edit-mode/index.js +2 -1
- package/build/components/header-edit-mode/index.js.map +1 -1
- package/build/components/header-edit-mode/more-menu/index.js +1 -1
- package/build/components/header-edit-mode/more-menu/index.js.map +1 -1
- package/build/components/list/added-by.js +43 -54
- package/build/components/list/added-by.js.map +1 -1
- package/build/components/{page-content-focus-manager → page-content-focus-notifications}/back-to-page-notification.js +9 -8
- package/build/components/page-content-focus-notifications/back-to-page-notification.js.map +1 -0
- package/build/components/{page-content-focus-manager → page-content-focus-notifications}/edit-template-notification.js +9 -13
- package/build/components/page-content-focus-notifications/edit-template-notification.js.map +1 -0
- package/build/components/page-content-focus-notifications/index.js +22 -0
- package/build/components/page-content-focus-notifications/index.js.map +1 -0
- package/build/components/page-pages/index.js +9 -15
- package/build/components/page-pages/index.js.map +1 -1
- package/build/components/page-patterns/use-patterns.js +1 -1
- package/build/components/page-patterns/use-patterns.js.map +1 -1
- package/build/components/page-templates/dataviews-templates.js +166 -51
- package/build/components/page-templates/dataviews-templates.js.map +1 -1
- package/build/components/preferences-modal/index.js +1 -1
- package/build/components/preferences-modal/index.js.map +1 -1
- package/build/components/save-button/index.js +9 -6
- package/build/components/save-button/index.js.map +1 -1
- package/build/components/save-hub/index.js +14 -0
- package/build/components/save-hub/index.js.map +1 -1
- package/build/components/sidebar-dataviews/custom-dataviews-list.js +3 -1
- package/build/components/sidebar-dataviews/custom-dataviews-list.js.map +1 -1
- package/build/components/sidebar-dataviews/default-views.js +7 -2
- package/build/components/sidebar-dataviews/default-views.js.map +1 -1
- package/build/components/sidebar-edit-mode/index.js +6 -5
- package/build/components/sidebar-edit-mode/index.js.map +1 -1
- package/build/components/sidebar-edit-mode/page-panels/edit-template.js +15 -26
- package/build/components/sidebar-edit-mode/page-panels/edit-template.js.map +1 -1
- package/build/components/sidebar-edit-mode/page-panels/hooks.js +22 -8
- package/build/components/sidebar-edit-mode/page-panels/hooks.js.map +1 -1
- package/build/components/sidebar-edit-mode/page-panels/page-status.js +8 -5
- package/build/components/sidebar-edit-mode/page-panels/page-status.js.map +1 -1
- package/build/components/sidebar-edit-mode/page-panels/page-summary.js +4 -8
- package/build/components/sidebar-edit-mode/page-panels/page-summary.js.map +1 -1
- package/build/components/sidebar-edit-mode/page-panels/reset-default-template.js +2 -2
- package/build/components/sidebar-edit-mode/page-panels/reset-default-template.js.map +1 -1
- package/build/components/sidebar-edit-mode/settings-header/index.js +10 -6
- package/build/components/sidebar-edit-mode/settings-header/index.js.map +1 -1
- package/build/components/sidebar-navigation-screen-page/index.js +23 -4
- package/build/components/sidebar-navigation-screen-page/index.js.map +1 -1
- package/build/components/style-book/index.js +22 -12
- package/build/components/style-book/index.js.map +1 -1
- package/build/components/sync-state-with-url/use-init-edited-entity-from-url.js +41 -9
- package/build/components/sync-state-with-url/use-init-edited-entity-from-url.js.map +1 -1
- package/build/components/welcome-guide/page.js +2 -2
- package/build/components/welcome-guide/page.js.map +1 -1
- package/build/components/welcome-guide/template.js +6 -3
- package/build/components/welcome-guide/template.js.map +1 -1
- package/build/hooks/commands/use-edit-mode-commands.js +24 -14
- package/build/hooks/commands/use-edit-mode-commands.js.map +1 -1
- package/build/store/actions.js +4 -1
- package/build/store/actions.js.map +1 -1
- package/build/store/private-actions.js +2 -27
- package/build/store/private-actions.js.map +1 -1
- package/build/store/private-selectors.js +0 -23
- package/build/store/private-selectors.js.map +1 -1
- package/build/store/reducer.js +1 -40
- package/build/store/reducer.js.map +1 -1
- package/build/store/selectors.js +8 -4
- package/build/store/selectors.js.map +1 -1
- package/build/utils/constants.js +1 -12
- package/build/utils/constants.js.map +1 -1
- package/build-module/components/actions/index.js +55 -36
- package/build-module/components/actions/index.js.map +1 -1
- package/build-module/components/block-editor/site-editor-canvas.js +7 -2
- package/build-module/components/block-editor/site-editor-canvas.js.map +1 -1
- package/build-module/components/dataviews/add-filter.js +21 -20
- package/build-module/components/dataviews/add-filter.js.map +1 -1
- package/build-module/components/dataviews/constants.js +6 -0
- package/build-module/components/dataviews/constants.js.map +1 -0
- package/build-module/components/dataviews/dataviews.js +9 -7
- package/build-module/components/dataviews/dataviews.js.map +1 -1
- package/build-module/components/dataviews/filter-summary.js +55 -0
- package/build-module/components/dataviews/filter-summary.js.map +1 -0
- package/build-module/components/dataviews/filters.js +15 -28
- package/build-module/components/dataviews/filters.js.map +1 -1
- package/build-module/components/dataviews/item-actions.js +84 -30
- package/build-module/components/dataviews/item-actions.js.map +1 -1
- package/build-module/components/dataviews/pagination.js +4 -0
- package/build-module/components/dataviews/pagination.js.map +1 -1
- package/build-module/components/dataviews/view-actions.js +24 -24
- package/build-module/components/dataviews/view-actions.js.map +1 -1
- package/build-module/components/dataviews/view-grid.js +49 -26
- package/build-module/components/dataviews/view-grid.js.map +1 -1
- package/build-module/components/dataviews/view-list.js +28 -33
- package/build-module/components/dataviews/view-list.js.map +1 -1
- package/build-module/components/editor/index.js +26 -30
- package/build-module/components/editor/index.js.map +1 -1
- package/build-module/components/global-styles/font-library-modal/utils/get-intersecting-font-faces.js +1 -1
- package/build-module/components/global-styles/font-library-modal/utils/get-intersecting-font-faces.js.map +1 -1
- package/build-module/components/global-styles/font-library-modal/utils/index.js +14 -2
- package/build-module/components/global-styles/font-library-modal/utils/index.js.map +1 -1
- package/build-module/components/global-styles/header.js +4 -2
- package/build-module/components/global-styles/header.js.map +1 -1
- package/build-module/components/global-styles/screen-block-list.js +23 -17
- package/build-module/components/global-styles/screen-block-list.js.map +1 -1
- package/build-module/components/global-styles/screen-revisions/index.js +27 -6
- package/build-module/components/global-styles/screen-revisions/index.js.map +1 -1
- package/build-module/components/global-styles/screen-revisions/revisions-buttons.js +51 -24
- package/build-module/components/global-styles/screen-revisions/revisions-buttons.js.map +1 -1
- package/build-module/components/global-styles/screen-revisions/use-global-styles-revisions.js +9 -3
- package/build-module/components/global-styles/screen-revisions/use-global-styles-revisions.js.map +1 -1
- package/build-module/components/global-styles/ui.js +28 -36
- package/build-module/components/global-styles/ui.js.map +1 -1
- package/build-module/components/header-edit-mode/document-actions/index.js +21 -16
- package/build-module/components/header-edit-mode/document-actions/index.js.map +1 -1
- package/build-module/components/header-edit-mode/index.js +2 -1
- package/build-module/components/header-edit-mode/index.js.map +1 -1
- package/build-module/components/header-edit-mode/more-menu/index.js +1 -1
- package/build-module/components/header-edit-mode/more-menu/index.js.map +1 -1
- package/build-module/components/list/added-by.js +44 -55
- package/build-module/components/list/added-by.js.map +1 -1
- package/build-module/components/{page-content-focus-manager → page-content-focus-notifications}/back-to-page-notification.js +9 -8
- package/build-module/components/page-content-focus-notifications/back-to-page-notification.js.map +1 -0
- package/build-module/components/{page-content-focus-manager → page-content-focus-notifications}/edit-template-notification.js +9 -13
- package/build-module/components/page-content-focus-notifications/edit-template-notification.js.map +1 -0
- package/build-module/components/page-content-focus-notifications/index.js +14 -0
- package/build-module/components/page-content-focus-notifications/index.js.map +1 -0
- package/build-module/components/page-pages/index.js +10 -16
- package/build-module/components/page-pages/index.js.map +1 -1
- package/build-module/components/page-patterns/use-patterns.js +1 -1
- package/build-module/components/page-patterns/use-patterns.js.map +1 -1
- package/build-module/components/page-templates/dataviews-templates.js +168 -53
- package/build-module/components/page-templates/dataviews-templates.js.map +1 -1
- package/build-module/components/preferences-modal/index.js +1 -1
- package/build-module/components/preferences-modal/index.js.map +1 -1
- package/build-module/components/save-button/index.js +11 -8
- package/build-module/components/save-button/index.js.map +1 -1
- package/build-module/components/save-hub/index.js +14 -0
- package/build-module/components/save-hub/index.js.map +1 -1
- package/build-module/components/sidebar-dataviews/custom-dataviews-list.js +3 -1
- package/build-module/components/sidebar-dataviews/custom-dataviews-list.js.map +1 -1
- package/build-module/components/sidebar-dataviews/default-views.js +7 -2
- package/build-module/components/sidebar-dataviews/default-views.js.map +1 -1
- package/build-module/components/sidebar-edit-mode/index.js +6 -5
- package/build-module/components/sidebar-edit-mode/index.js.map +1 -1
- package/build-module/components/sidebar-edit-mode/page-panels/edit-template.js +16 -27
- package/build-module/components/sidebar-edit-mode/page-panels/edit-template.js.map +1 -1
- package/build-module/components/sidebar-edit-mode/page-panels/hooks.js +21 -7
- package/build-module/components/sidebar-edit-mode/page-panels/hooks.js.map +1 -1
- package/build-module/components/sidebar-edit-mode/page-panels/page-status.js +9 -6
- package/build-module/components/sidebar-edit-mode/page-panels/page-status.js.map +1 -1
- package/build-module/components/sidebar-edit-mode/page-panels/page-summary.js +5 -9
- package/build-module/components/sidebar-edit-mode/page-panels/page-summary.js.map +1 -1
- package/build-module/components/sidebar-edit-mode/page-panels/reset-default-template.js +3 -3
- package/build-module/components/sidebar-edit-mode/page-panels/reset-default-template.js.map +1 -1
- package/build-module/components/sidebar-edit-mode/settings-header/index.js +10 -6
- package/build-module/components/sidebar-edit-mode/settings-header/index.js.map +1 -1
- package/build-module/components/sidebar-navigation-screen-page/index.js +23 -4
- package/build-module/components/sidebar-navigation-screen-page/index.js.map +1 -1
- package/build-module/components/style-book/index.js +22 -12
- package/build-module/components/style-book/index.js.map +1 -1
- package/build-module/components/sync-state-with-url/use-init-edited-entity-from-url.js +41 -9
- package/build-module/components/sync-state-with-url/use-init-edited-entity-from-url.js.map +1 -1
- package/build-module/components/welcome-guide/page.js +2 -2
- package/build-module/components/welcome-guide/page.js.map +1 -1
- package/build-module/components/welcome-guide/template.js +6 -3
- package/build-module/components/welcome-guide/template.js.map +1 -1
- package/build-module/hooks/commands/use-edit-mode-commands.js +24 -14
- package/build-module/hooks/commands/use-edit-mode-commands.js.map +1 -1
- package/build-module/store/actions.js +4 -1
- package/build-module/store/actions.js.map +1 -1
- package/build-module/store/private-actions.js +1 -25
- package/build-module/store/private-actions.js.map +1 -1
- package/build-module/store/private-selectors.js +0 -22
- package/build-module/store/private-selectors.js.map +1 -1
- package/build-module/store/reducer.js +1 -38
- package/build-module/store/reducer.js.map +1 -1
- package/build-module/store/selectors.js +8 -4
- package/build-module/store/selectors.js.map +1 -1
- package/build-module/utils/constants.js +0 -10
- package/build-module/utils/constants.js.map +1 -1
- package/build-style/style-rtl.css +152 -62
- package/build-style/style.css +152 -62
- package/package.json +41 -41
- package/src/components/actions/index.js +76 -48
- package/src/components/block-editor/site-editor-canvas.js +8 -2
- package/src/components/dataviews/README.md +14 -11
- package/src/components/dataviews/add-filter.js +21 -24
- package/src/components/dataviews/constants.js +5 -0
- package/src/components/dataviews/dataviews.js +10 -10
- package/src/components/dataviews/filter-summary.js +79 -0
- package/src/components/dataviews/filters.js +18 -35
- package/src/components/dataviews/item-actions.js +106 -42
- package/src/components/dataviews/pagination.js +4 -0
- package/src/components/dataviews/style.scss +84 -8
- package/src/components/dataviews/view-actions.js +39 -41
- package/src/components/dataviews/view-grid.js +63 -38
- package/src/components/dataviews/view-list.js +50 -57
- package/src/components/editor/index.js +18 -34
- package/src/components/global-styles/font-library-modal/utils/get-intersecting-font-faces.js +1 -1
- package/src/components/global-styles/font-library-modal/utils/index.js +20 -9
- package/src/components/global-styles/font-library-modal/utils/test/getIntersectingFontFaces.spec.js +46 -15
- package/src/components/global-styles/font-library-modal/utils/test/wpKebabCase.spec.js +28 -0
- package/src/components/global-styles/header.js +2 -1
- package/src/components/global-styles/screen-block-list.js +37 -26
- package/src/components/global-styles/screen-revisions/index.js +39 -10
- package/src/components/global-styles/screen-revisions/revisions-buttons.js +65 -45
- package/src/components/global-styles/screen-revisions/style.scss +52 -28
- package/src/components/global-styles/screen-revisions/use-global-styles-revisions.js +15 -6
- package/src/components/global-styles/style.scss +0 -11
- package/src/components/global-styles/ui.js +59 -74
- package/src/components/header-edit-mode/document-actions/index.js +20 -18
- package/src/components/header-edit-mode/index.js +1 -0
- package/src/components/header-edit-mode/more-menu/index.js +1 -1
- package/src/components/list/added-by.js +23 -63
- package/src/components/list/style.scss +11 -13
- package/src/components/{page-content-focus-manager → page-content-focus-notifications}/back-to-page-notification.js +12 -13
- package/src/components/{page-content-focus-manager → page-content-focus-notifications}/edit-template-notification.js +9 -13
- package/src/components/page-content-focus-notifications/index.js +14 -0
- package/src/components/page-pages/index.js +15 -20
- package/src/components/page-patterns/use-patterns.js +1 -1
- package/src/components/page-templates/dataviews-templates.js +169 -48
- package/src/components/page-templates/style.scss +13 -0
- package/src/components/preferences-modal/index.js +1 -1
- package/src/components/save-button/index.js +37 -24
- package/src/components/save-hub/index.js +15 -0
- package/src/components/save-hub/style.scss +7 -0
- package/src/components/sidebar-dataviews/custom-dataviews-list.js +2 -0
- package/src/components/sidebar-dataviews/default-views.js +7 -2
- package/src/components/sidebar-dataviews/style.scss +7 -0
- package/src/components/sidebar-edit-mode/index.js +13 -9
- package/src/components/sidebar-edit-mode/page-panels/edit-template.js +33 -52
- package/src/components/sidebar-edit-mode/page-panels/hooks.js +20 -9
- package/src/components/sidebar-edit-mode/page-panels/page-status.js +6 -6
- package/src/components/sidebar-edit-mode/page-panels/page-summary.js +8 -9
- package/src/components/sidebar-edit-mode/page-panels/reset-default-template.js +3 -3
- package/src/components/sidebar-edit-mode/page-panels/style.scss +9 -19
- package/src/components/sidebar-edit-mode/settings-header/index.js +8 -9
- package/src/components/sidebar-navigation-screen/style.scss +1 -0
- package/src/components/sidebar-navigation-screen-page/index.js +24 -3
- package/src/components/sidebar-navigation-screen-template/style.scss +6 -1
- package/src/components/style-book/index.js +48 -35
- package/src/components/sync-state-with-url/use-init-edited-entity-from-url.js +69 -17
- package/src/components/welcome-guide/page.js +2 -2
- package/src/components/welcome-guide/template.js +4 -2
- package/src/hooks/commands/use-edit-mode-commands.js +22 -16
- package/src/store/actions.js +5 -1
- package/src/store/private-actions.js +1 -24
- package/src/store/private-selectors.js +0 -22
- package/src/store/reducer.js +0 -39
- package/src/store/selectors.js +12 -4
- package/src/store/test/actions.js +3 -32
- package/src/store/test/reducer.js +0 -62
- package/src/store/test/selectors.js +0 -35
- package/src/style.scss +1 -0
- package/src/utils/constants.js +0 -10
- package/build/components/dataviews/in-filter.js +0 -51
- package/build/components/dataviews/in-filter.js.map +0 -1
- package/build/components/page-content-focus-manager/back-to-page-notification.js.map +0 -1
- package/build/components/page-content-focus-manager/disable-non-page-content-blocks.js +0 -63
- package/build/components/page-content-focus-manager/disable-non-page-content-blocks.js.map +0 -1
- package/build/components/page-content-focus-manager/edit-template-notification.js.map +0 -1
- package/build/components/page-content-focus-manager/index.js +0 -61
- package/build/components/page-content-focus-manager/index.js.map +0 -1
- package/build/components/sidebar-edit-mode/page-panels/publish-date.js +0 -87
- package/build/components/sidebar-edit-mode/page-panels/publish-date.js.map +0 -1
- package/build-module/components/dataviews/in-filter.js +0 -42
- package/build-module/components/dataviews/in-filter.js.map +0 -1
- package/build-module/components/page-content-focus-manager/back-to-page-notification.js.map +0 -1
- package/build-module/components/page-content-focus-manager/disable-non-page-content-blocks.js +0 -56
- package/build-module/components/page-content-focus-manager/disable-non-page-content-blocks.js.map +0 -1
- package/build-module/components/page-content-focus-manager/edit-template-notification.js.map +0 -1
- package/build-module/components/page-content-focus-manager/index.js +0 -52
- package/build-module/components/page-content-focus-manager/index.js.map +0 -1
- package/build-module/components/sidebar-edit-mode/page-panels/publish-date.js +0 -80
- package/build-module/components/sidebar-edit-mode/page-panels/publish-date.js.map +0 -1
- package/src/components/dataviews/in-filter.js +0 -63
- package/src/components/page-content-focus-manager/disable-non-page-content-blocks.js +0 -57
- package/src/components/page-content-focus-manager/index.js +0 -51
- package/src/components/sidebar-edit-mode/page-panels/publish-date.js +0 -94
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_coreData","require","_data","_deprecated","_interopRequireDefault","_element","_preferences","_blockEditor","_utils","_constants","isFeatureActive","createRegistrySelector","select","_","featureName","deprecated","since","alternative","preferencesStore","get","exports","__experimentalGetPreviewDeviceType","state","deviceType","getCanUserCreateMedia","coreDataStore","canUser","getReusableBlocks","version","isWeb","Platform","OS","getEntityRecords","per_page","getSettings","settings","getHomeTemplateId","getEditedPostType","editedPost","postType","getEditedPostId","id","getEditedPostContext","context","getPage","isInserterOpened","blockInserterPanel","__experimentalGetInsertionPoint","rootClientId","insertionIndex","filterValue","hasPageContentFocus","postContentClientId","blockEditorStore","__experimentalGetGlobalBlocksByName","undefined","isListViewOpened","listViewPanel","isSaveViewOpened","saveViewPanel","getCurrentTemplateTemplateParts","templateParts","TEMPLATE_PART_POST_TYPE","clientIds","blocks","getBlocksByClientId","getFilteredTemplatePartBlocks","getEditorMode","getCurrentTemplateNavigationPanelSubMenu","getNavigationPanelActiveMenu","isNavigationOpened","isPage","postId"],"sources":["@wordpress/edit-site/src/store/selectors.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { store as coreDataStore } from '@wordpress/core-data';\nimport { createRegistrySelector } from '@wordpress/data';\nimport deprecated from '@wordpress/deprecated';\nimport { Platform } from '@wordpress/element';\nimport { store as preferencesStore } from '@wordpress/preferences';\nimport { store as blockEditorStore } from '@wordpress/block-editor';\n\n/**\n * Internal dependencies\n */\nimport { getFilteredTemplatePartBlocks } from './utils';\nimport { TEMPLATE_PART_POST_TYPE } from '../utils/constants';\n/**\n * @typedef {'template'|'template_type'} TemplateType Template type.\n */\n\n/**\n * Returns whether the given feature is enabled or not.\n *\n * @deprecated\n * @param {Object} state Global application state.\n * @param {string} featureName Feature slug.\n *\n * @return {boolean} Is active.\n */\nexport const isFeatureActive = createRegistrySelector(\n\t( select ) => ( _, featureName ) => {\n\t\tdeprecated( `select( 'core/edit-site' ).isFeatureActive`, {\n\t\t\tsince: '6.0',\n\t\t\talternative: `select( 'core/preferences' ).get`,\n\t\t} );\n\n\t\treturn !! select( preferencesStore ).get(\n\t\t\t'core/edit-site',\n\t\t\tfeatureName\n\t\t);\n\t}\n);\n\n/**\n * Returns the current editing canvas device type.\n *\n * @param {Object} state Global application state.\n *\n * @return {string} Device type.\n */\nexport function __experimentalGetPreviewDeviceType( state ) {\n\treturn state.deviceType;\n}\n\n/**\n * Returns whether the current user can create media or not.\n *\n * @param {Object} state Global application state.\n *\n * @return {Object} Whether the current user can create media or not.\n */\nexport const getCanUserCreateMedia = createRegistrySelector(\n\t( select ) => () => select( coreDataStore ).canUser( 'create', 'media' )\n);\n\n/**\n * Returns any available Reusable blocks.\n *\n * @param {Object} state Global application state.\n *\n * @return {Array} The available reusable blocks.\n */\nexport const getReusableBlocks = createRegistrySelector( ( select ) => () => {\n\tdeprecated(\n\t\t\"select( 'core/core' ).getEntityRecords( 'postType', 'wp_block' )\",\n\t\t{\n\t\t\tsince: '6.5',\n\t\t\tversion: '6.8',\n\t\t}\n\t);\n\tconst isWeb = Platform.OS === 'web';\n\treturn isWeb\n\t\t? select( coreDataStore ).getEntityRecords( 'postType', 'wp_block', {\n\t\t\t\tper_page: -1,\n\t\t } )\n\t\t: [];\n} );\n\n/**\n * Returns the site editor settings.\n *\n * @param {Object} state Global application state.\n *\n * @return {Object} Settings.\n */\nexport function getSettings( state ) {\n\t// It is important that we don't inject anything into these settings locally.\n\t// The reason for this is that we have an effect in place that calls setSettings based on the previous value of getSettings.\n\t// If we add computed settings here, we'll be adding these computed settings to the state which is very unexpected.\n\treturn state.settings;\n}\n\n/**\n * @deprecated\n */\nexport function getHomeTemplateId() {\n\tdeprecated( \"select( 'core/edit-site' ).getHomeTemplateId\", {\n\t\tsince: '6.2',\n\t\tversion: '6.4',\n\t} );\n}\n\n/**\n * Returns the current edited post type (wp_template or wp_template_part).\n *\n * @param {Object} state Global application state.\n *\n * @return {TemplateType?} Template type.\n */\nexport function getEditedPostType( state ) {\n\treturn state.editedPost.postType;\n}\n\n/**\n * Returns the ID of the currently edited template or template part.\n *\n * @param {Object} state Global application state.\n *\n * @return {string?} Post ID.\n */\nexport function getEditedPostId( state ) {\n\treturn state.editedPost.id;\n}\n\n/**\n * Returns the edited post's context object.\n *\n * @deprecated\n * @param {Object} state Global application state.\n *\n * @return {Object} Page.\n */\nexport function getEditedPostContext( state ) {\n\treturn state.editedPost.context;\n}\n\n/**\n * Returns the current page object.\n *\n * @deprecated\n * @param {Object} state Global application state.\n *\n * @return {Object} Page.\n */\nexport function getPage( state ) {\n\treturn { context: state.editedPost.context };\n}\n\n/**\n * Returns the current opened/closed state of the inserter panel.\n *\n * @param {Object} state Global application state.\n *\n * @return {boolean} True if the inserter panel should be open; false if closed.\n */\nexport function isInserterOpened( state ) {\n\treturn !! state.blockInserterPanel;\n}\n\n/**\n * Get the insertion point for the inserter.\n *\n * @param {Object} state Global application state.\n *\n * @return {Object} The root client ID, index to insert at and starting filter value.\n */\nexport const __experimentalGetInsertionPoint = createRegistrySelector(\n\t( select ) => ( state ) => {\n\t\tif ( typeof state.blockInserterPanel === 'object' ) {\n\t\t\tconst { rootClientId, insertionIndex, filterValue } =\n\t\t\t\tstate.blockInserterPanel;\n\t\t\treturn { rootClientId, insertionIndex, filterValue };\n\t\t}\n\n\t\tif ( hasPageContentFocus( state ) ) {\n\t\t\tconst [ postContentClientId ] =\n\t\t\t\tselect( blockEditorStore ).__experimentalGetGlobalBlocksByName(\n\t\t\t\t\t'core/post-content'\n\t\t\t\t);\n\t\t\tif ( postContentClientId ) {\n\t\t\t\treturn {\n\t\t\t\t\trootClientId: postContentClientId,\n\t\t\t\t\tinsertionIndex: undefined,\n\t\t\t\t\tfilterValue: undefined,\n\t\t\t\t};\n\t\t\t}\n\t\t}\n\n\t\treturn {\n\t\t\trootClientId: undefined,\n\t\t\tinsertionIndex: undefined,\n\t\t\tfilterValue: undefined,\n\t\t};\n\t}\n);\n\n/**\n * Returns the current opened/closed state of the list view panel.\n *\n * @param {Object} state Global application state.\n *\n * @return {boolean} True if the list view panel should be open; false if closed.\n */\nexport function isListViewOpened( state ) {\n\treturn state.listViewPanel;\n}\n\n/**\n * Returns the current opened/closed state of the save panel.\n *\n * @param {Object} state Global application state.\n *\n * @return {boolean} True if the save panel should be open; false if closed.\n */\nexport function isSaveViewOpened( state ) {\n\treturn state.saveViewPanel;\n}\n\n/**\n * Returns the template parts and their blocks for the current edited template.\n *\n * @param {Object} state Global application state.\n * @return {Array} Template parts and their blocks in an array.\n */\nexport const getCurrentTemplateTemplateParts = createRegistrySelector(\n\t( select ) => () => {\n\t\tconst templateParts = select( coreDataStore ).getEntityRecords(\n\t\t\t'postType',\n\t\t\tTEMPLATE_PART_POST_TYPE,\n\t\t\t{ per_page: -1 }\n\t\t);\n\n\t\tconst clientIds =\n\t\t\tselect( blockEditorStore ).__experimentalGetGlobalBlocksByName(\n\t\t\t\t'core/template-part'\n\t\t\t);\n\t\tconst blocks =\n\t\t\tselect( blockEditorStore ).getBlocksByClientId( clientIds );\n\n\t\treturn getFilteredTemplatePartBlocks( blocks, templateParts );\n\t}\n);\n\n/**\n * Returns the current editing mode.\n *\n * @param {Object} state Global application state.\n *\n * @return {string} Editing mode.\n */\nexport const getEditorMode = createRegistrySelector( ( select ) => () => {\n\treturn select( preferencesStore ).get( 'core/edit-site', 'editorMode' );\n} );\n\n/**\n * @deprecated\n */\nexport function getCurrentTemplateNavigationPanelSubMenu() {\n\tdeprecated(\n\t\t\"dispatch( 'core/edit-site' ).getCurrentTemplateNavigationPanelSubMenu\",\n\t\t{\n\t\t\tsince: '6.2',\n\t\t\tversion: '6.4',\n\t\t}\n\t);\n}\n\n/**\n * @deprecated\n */\nexport function getNavigationPanelActiveMenu() {\n\tdeprecated( \"dispatch( 'core/edit-site' ).getNavigationPanelActiveMenu\", {\n\t\tsince: '6.2',\n\t\tversion: '6.4',\n\t} );\n}\n\n/**\n * @deprecated\n */\nexport function isNavigationOpened() {\n\tdeprecated( \"dispatch( 'core/edit-site' ).isNavigationOpened\", {\n\t\tsince: '6.2',\n\t\tversion: '6.4',\n\t} );\n}\n\n/**\n * Whether or not the editor has a page loaded into it.\n *\n * @see setPage\n *\n * @param {Object} state Global application state.\n *\n * @return {boolean} Whether or not the editor has a page loaded into it.\n */\nexport function isPage( state ) {\n\treturn !! state.editedPost.context?.postId;\n}\n\n/**\n * Whether or not the editor allows only page content to be edited.\n *\n * @param {Object} state Global application state.\n *\n * @return {boolean} Whether or not focus is on editing page content.\n */\nexport function hasPageContentFocus( state ) {\n\treturn isPage( state ) ? state.hasPageContentFocus : false;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;AAGA,IAAAA,SAAA,GAAAC,OAAA;AACA,IAAAC,KAAA,GAAAD,OAAA;AACA,IAAAE,WAAA,GAAAC,sBAAA,CAAAH,OAAA;AACA,IAAAI,QAAA,GAAAJ,OAAA;AACA,IAAAK,YAAA,GAAAL,OAAA;AACA,IAAAM,YAAA,GAAAN,OAAA;AAKA,IAAAO,MAAA,GAAAP,OAAA;AACA,IAAAQ,UAAA,GAAAR,OAAA;AAdA;AACA;AACA;;AAQA;AACA;AACA;;AAGA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,MAAMS,eAAe,GAAG,IAAAC,4BAAsB,EAClDC,MAAM,IAAM,CAAEC,CAAC,EAAEC,WAAW,KAAM;EACnC,IAAAC,mBAAU,EAAG,4CAA2C,EAAE;IACzDC,KAAK,EAAE,KAAK;IACZC,WAAW,EAAG;EACf,CAAE,CAAC;EAEH,OAAO,CAAC,CAAEL,MAAM,CAAEM,kBAAiB,CAAC,CAACC,GAAG,CACvC,gBAAgB,EAChBL,WACD,CAAC;AACF,CACD,CAAC;;AAED;AACA;AACA;AACA;AACA;AACA;AACA;AANAM,OAAA,CAAAV,eAAA,GAAAA,eAAA;AAOO,SAASW,kCAAkCA,CAAEC,KAAK,EAAG;EAC3D,OAAOA,KAAK,CAACC,UAAU;AACxB;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,MAAMC,qBAAqB,GAAG,IAAAb,4BAAsB,EACxDC,MAAM,IAAM,MAAMA,MAAM,CAA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AAG;EACpC,IAAAvD,mBAAU,EAAE,iDAAiD,EAAE;IAC9DC,KAAK,EAAE,KAAK;IACZY,OAAO,EAAE;EACV,CAAE,CAAC;AACJ;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,SAAS2C,MAAMA,CAAEjD,KAAK,EAAG;EAC/B,OAAO,CAAC,CAAEA,KAAK,CAACgB,UAAU,CAACK,OAAO,EAAE6B,MAAM;AAC3C;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,SAASrB,mBAAmBA,CAAE7B,KAAK,EAAG;EAC5C,OAAOiD,MAAM,CAAEjD,KAAM,CAAC,GAAGA,KAAK,CAAC6B,mBAAmB,GAAG,KAAK;AAC3D"}
|
|
1
|
+
{"version":3,"names":["_coreData","require","_data","_deprecated","_interopRequireDefault","_element","_preferences","_blockEditor","_editor","_utils","_constants","isFeatureActive","createRegistrySelector","select","_","featureName","deprecated","since","alternative","preferencesStore","get","exports","__experimentalGetPreviewDeviceType","state","deviceType","getCanUserCreateMedia","coreDataStore","canUser","getReusableBlocks","version","isWeb","Platform","OS","getEntityRecords","per_page","getSettings","settings","getHomeTemplateId","getEditedPostType","editedPost","postType","getEditedPostId","id","getEditedPostContext","context","getPage","isInserterOpened","blockInserterPanel","__experimentalGetInsertionPoint","rootClientId","insertionIndex","filterValue","isPage","editorStore","getRenderingMode","postContentClientId","blockEditorStore","__experimentalGetGlobalBlocksByName","undefined","isListViewOpened","listViewPanel","isSaveViewOpened","saveViewPanel","getCurrentTemplateTemplateParts","templateParts","TEMPLATE_PART_POST_TYPE","clientIds","blocks","getBlocksByClientId","getFilteredTemplatePartBlocks","getEditorMode","getCurrentTemplateNavigationPanelSubMenu","getNavigationPanelActiveMenu","isNavigationOpened","postId","hasPageContentFocus"],"sources":["@wordpress/edit-site/src/store/selectors.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { store as coreDataStore } from '@wordpress/core-data';\nimport { createRegistrySelector } from '@wordpress/data';\nimport deprecated from '@wordpress/deprecated';\nimport { Platform } from '@wordpress/element';\nimport { store as preferencesStore } from '@wordpress/preferences';\nimport { store as blockEditorStore } from '@wordpress/block-editor';\nimport { store as editorStore } from '@wordpress/editor';\n\n/**\n * Internal dependencies\n */\nimport { getFilteredTemplatePartBlocks } from './utils';\nimport { TEMPLATE_PART_POST_TYPE } from '../utils/constants';\n/**\n * @typedef {'template'|'template_type'} TemplateType Template type.\n */\n\n/**\n * Returns whether the given feature is enabled or not.\n *\n * @deprecated\n * @param {Object} state Global application state.\n * @param {string} featureName Feature slug.\n *\n * @return {boolean} Is active.\n */\nexport const isFeatureActive = createRegistrySelector(\n\t( select ) => ( _, featureName ) => {\n\t\tdeprecated( `select( 'core/edit-site' ).isFeatureActive`, {\n\t\t\tsince: '6.0',\n\t\t\talternative: `select( 'core/preferences' ).get`,\n\t\t} );\n\n\t\treturn !! select( preferencesStore ).get(\n\t\t\t'core/edit-site',\n\t\t\tfeatureName\n\t\t);\n\t}\n);\n\n/**\n * Returns the current editing canvas device type.\n *\n * @param {Object} state Global application state.\n *\n * @return {string} Device type.\n */\nexport function __experimentalGetPreviewDeviceType( state ) {\n\treturn state.deviceType;\n}\n\n/**\n * Returns whether the current user can create media or not.\n *\n * @param {Object} state Global application state.\n *\n * @return {Object} Whether the current user can create media or not.\n */\nexport const getCanUserCreateMedia = createRegistrySelector(\n\t( select ) => () => select( coreDataStore ).canUser( 'create', 'media' )\n);\n\n/**\n * Returns any available Reusable blocks.\n *\n * @param {Object} state Global application state.\n *\n * @return {Array} The available reusable blocks.\n */\nexport const getReusableBlocks = createRegistrySelector( ( select ) => () => {\n\tdeprecated(\n\t\t\"select( 'core/core' ).getEntityRecords( 'postType', 'wp_block' )\",\n\t\t{\n\t\t\tsince: '6.5',\n\t\t\tversion: '6.8',\n\t\t}\n\t);\n\tconst isWeb = Platform.OS === 'web';\n\treturn isWeb\n\t\t? select( coreDataStore ).getEntityRecords( 'postType', 'wp_block', {\n\t\t\t\tper_page: -1,\n\t\t } )\n\t\t: [];\n} );\n\n/**\n * Returns the site editor settings.\n *\n * @param {Object} state Global application state.\n *\n * @return {Object} Settings.\n */\nexport function getSettings( state ) {\n\t// It is important that we don't inject anything into these settings locally.\n\t// The reason for this is that we have an effect in place that calls setSettings based on the previous value of getSettings.\n\t// If we add computed settings here, we'll be adding these computed settings to the state which is very unexpected.\n\treturn state.settings;\n}\n\n/**\n * @deprecated\n */\nexport function getHomeTemplateId() {\n\tdeprecated( \"select( 'core/edit-site' ).getHomeTemplateId\", {\n\t\tsince: '6.2',\n\t\tversion: '6.4',\n\t} );\n}\n\n/**\n * Returns the current edited post type (wp_template or wp_template_part).\n *\n * @param {Object} state Global application state.\n *\n * @return {TemplateType?} Template type.\n */\nexport function getEditedPostType( state ) {\n\treturn state.editedPost.postType;\n}\n\n/**\n * Returns the ID of the currently edited template or template part.\n *\n * @param {Object} state Global application state.\n *\n * @return {string?} Post ID.\n */\nexport function getEditedPostId( state ) {\n\treturn state.editedPost.id;\n}\n\n/**\n * Returns the edited post's context object.\n *\n * @deprecated\n * @param {Object} state Global application state.\n *\n * @return {Object} Page.\n */\nexport function getEditedPostContext( state ) {\n\treturn state.editedPost.context;\n}\n\n/**\n * Returns the current page object.\n *\n * @deprecated\n * @param {Object} state Global application state.\n *\n * @return {Object} Page.\n */\nexport function getPage( state ) {\n\treturn { context: state.editedPost.context };\n}\n\n/**\n * Returns the current opened/closed state of the inserter panel.\n *\n * @param {Object} state Global application state.\n *\n * @return {boolean} True if the inserter panel should be open; false if closed.\n */\nexport function isInserterOpened( state ) {\n\treturn !! state.blockInserterPanel;\n}\n\n/**\n * Get the insertion point for the inserter.\n *\n * @param {Object} state Global application state.\n *\n * @return {Object} The root client ID, index to insert at and starting filter value.\n */\nexport const __experimentalGetInsertionPoint = createRegistrySelector(\n\t( select ) => ( state ) => {\n\t\tif ( typeof state.blockInserterPanel === 'object' ) {\n\t\t\tconst { rootClientId, insertionIndex, filterValue } =\n\t\t\t\tstate.blockInserterPanel;\n\t\t\treturn { rootClientId, insertionIndex, filterValue };\n\t\t}\n\n\t\tif (\n\t\t\tisPage( state ) &&\n\t\t\tselect( editorStore ).getRenderingMode() !== 'template-only'\n\t\t) {\n\t\t\tconst [ postContentClientId ] =\n\t\t\t\tselect( blockEditorStore ).__experimentalGetGlobalBlocksByName(\n\t\t\t\t\t'core/post-content'\n\t\t\t\t);\n\t\t\tif ( postContentClientId ) {\n\t\t\t\treturn {\n\t\t\t\t\trootClientId: postContentClientId,\n\t\t\t\t\tinsertionIndex: undefined,\n\t\t\t\t\tfilterValue: undefined,\n\t\t\t\t};\n\t\t\t}\n\t\t}\n\n\t\treturn {\n\t\t\trootClientId: undefined,\n\t\t\tinsertionIndex: undefined,\n\t\t\tfilterValue: undefined,\n\t\t};\n\t}\n);\n\n/**\n * Returns the current opened/closed state of the list view panel.\n *\n * @param {Object} state Global application state.\n *\n * @return {boolean} True if the list view panel should be open; false if closed.\n */\nexport function isListViewOpened( state ) {\n\treturn state.listViewPanel;\n}\n\n/**\n * Returns the current opened/closed state of the save panel.\n *\n * @param {Object} state Global application state.\n *\n * @return {boolean} True if the save panel should be open; false if closed.\n */\nexport function isSaveViewOpened( state ) {\n\treturn state.saveViewPanel;\n}\n\n/**\n * Returns the template parts and their blocks for the current edited template.\n *\n * @param {Object} state Global application state.\n * @return {Array} Template parts and their blocks in an array.\n */\nexport const getCurrentTemplateTemplateParts = createRegistrySelector(\n\t( select ) => () => {\n\t\tconst templateParts = select( coreDataStore ).getEntityRecords(\n\t\t\t'postType',\n\t\t\tTEMPLATE_PART_POST_TYPE,\n\t\t\t{ per_page: -1 }\n\t\t);\n\n\t\tconst clientIds =\n\t\t\tselect( blockEditorStore ).__experimentalGetGlobalBlocksByName(\n\t\t\t\t'core/template-part'\n\t\t\t);\n\t\tconst blocks =\n\t\t\tselect( blockEditorStore ).getBlocksByClientId( clientIds );\n\n\t\treturn getFilteredTemplatePartBlocks( blocks, templateParts );\n\t}\n);\n\n/**\n * Returns the current editing mode.\n *\n * @param {Object} state Global application state.\n *\n * @return {string} Editing mode.\n */\nexport const getEditorMode = createRegistrySelector( ( select ) => () => {\n\treturn select( preferencesStore ).get( 'core/edit-site', 'editorMode' );\n} );\n\n/**\n * @deprecated\n */\nexport function getCurrentTemplateNavigationPanelSubMenu() {\n\tdeprecated(\n\t\t\"dispatch( 'core/edit-site' ).getCurrentTemplateNavigationPanelSubMenu\",\n\t\t{\n\t\t\tsince: '6.2',\n\t\t\tversion: '6.4',\n\t\t}\n\t);\n}\n\n/**\n * @deprecated\n */\nexport function getNavigationPanelActiveMenu() {\n\tdeprecated( \"dispatch( 'core/edit-site' ).getNavigationPanelActiveMenu\", {\n\t\tsince: '6.2',\n\t\tversion: '6.4',\n\t} );\n}\n\n/**\n * @deprecated\n */\nexport function isNavigationOpened() {\n\tdeprecated( \"dispatch( 'core/edit-site' ).isNavigationOpened\", {\n\t\tsince: '6.2',\n\t\tversion: '6.4',\n\t} );\n}\n\n/**\n * Whether or not the editor has a page loaded into it.\n *\n * @see setPage\n *\n * @param {Object} state Global application state.\n *\n * @return {boolean} Whether or not the editor has a page loaded into it.\n */\nexport function isPage( state ) {\n\treturn !! state.editedPost.context?.postId;\n}\n\n/**\n * Whether or not the editor allows only page content to be edited.\n *\n * @deprecated\n *\n * @return {boolean} Whether or not focus is on editing page content.\n */\nexport function hasPageContentFocus() {\n\tdeprecated( `select( 'core/edit-site' ).hasPageContentFocus`, {\n\t\tsince: '6.5',\n\t} );\n\n\treturn false;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;AAGA,IAAAA,SAAA,GAAAC,OAAA;AACA,IAAAC,KAAA,GAAAD,OAAA;AACA,IAAAE,WAAA,GAAAC,sBAAA,CAAAH,OAAA;AACA,IAAAI,QAAA,GAAAJ,OAAA;AACA,IAAAK,YAAA,GAAAL,OAAA;AACA,IAAAM,YAAA,GAAAN,OAAA;AACA,IAAAO,OAAA,GAAAP,OAAA;AAKA,IAAAQ,MA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"}
|
package/build/utils/constants.js
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
exports.TEMPLATE_POST_TYPE = exports.TEMPLATE_PART_POST_TYPE = exports.TEMPLATE_PART_AREA_DEFAULT_CATEGORY = exports.TEMPLATE_ORIGINS = exports.POST_TYPE_LABELS = exports.PATTERN_USER_CATEGORY = exports.PATTERN_TYPES = exports.PATTERN_SYNC_TYPES = exports.PATTERN_DEFAULT_CATEGORY = exports.
|
|
6
|
+
exports.TEMPLATE_POST_TYPE = exports.TEMPLATE_PART_POST_TYPE = exports.TEMPLATE_PART_AREA_DEFAULT_CATEGORY = exports.TEMPLATE_ORIGINS = exports.POST_TYPE_LABELS = exports.PATTERN_USER_CATEGORY = exports.PATTERN_TYPES = exports.PATTERN_SYNC_TYPES = exports.PATTERN_DEFAULT_CATEGORY = exports.NAVIGATION_POST_TYPE = exports.FOCUSABLE_ENTITIES = exports.EXCLUDED_PATTERN_SOURCES = void 0;
|
|
7
7
|
var _i18n = require("@wordpress/i18n");
|
|
8
8
|
var _patterns = require("@wordpress/patterns");
|
|
9
9
|
var _lockUnlock = require("../lock-unlock");
|
|
@@ -49,18 +49,7 @@ exports.PATTERN_USER_CATEGORY = PATTERN_USER_CATEGORY;
|
|
|
49
49
|
exports.PATTERN_DEFAULT_CATEGORY = PATTERN_DEFAULT_CATEGORY;
|
|
50
50
|
exports.PATTERN_TYPES = PATTERN_TYPES;
|
|
51
51
|
const FOCUSABLE_ENTITIES = [TEMPLATE_PART_POST_TYPE, NAVIGATION_POST_TYPE, PATTERN_TYPES.user];
|
|
52
|
-
|
|
53
|
-
/**
|
|
54
|
-
* Block types that are considered to be page content. These are the only blocks
|
|
55
|
-
* editable when hasPageContentFocus() is true.
|
|
56
|
-
*/
|
|
57
52
|
exports.FOCUSABLE_ENTITIES = FOCUSABLE_ENTITIES;
|
|
58
|
-
const PAGE_CONTENT_BLOCK_TYPES = {
|
|
59
|
-
'core/post-title': true,
|
|
60
|
-
'core/post-featured-image': true,
|
|
61
|
-
'core/post-content': true
|
|
62
|
-
};
|
|
63
|
-
exports.PAGE_CONTENT_BLOCK_TYPES = PAGE_CONTENT_BLOCK_TYPES;
|
|
64
53
|
const POST_TYPE_LABELS = {
|
|
65
54
|
[TEMPLATE_POST_TYPE]: (0, _i18n.__)('Template'),
|
|
66
55
|
[TEMPLATE_PART_POST_TYPE]: (0, _i18n.__)('Template part'),
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_i18n","require","_patterns","_lockUnlock","NAVIGATION_POST_TYPE","exports","TEMPLATE_POST_TYPE","TEMPLATE_PART_POST_TYPE","TEMPLATE_ORIGINS","custom","theme","plugin","TEMPLATE_PART_AREA_DEFAULT_CATEGORY","PATTERN_TYPES","PATTERN_DEFAULT_CATEGORY","PATTERN_USER_CATEGORY","EXCLUDED_PATTERN_SOURCES","PATTERN_SYNC_TYPES","unlock","patternPrivateApis","FOCUSABLE_ENTITIES","user","
|
|
1
|
+
{"version":3,"names":["_i18n","require","_patterns","_lockUnlock","NAVIGATION_POST_TYPE","exports","TEMPLATE_POST_TYPE","TEMPLATE_PART_POST_TYPE","TEMPLATE_ORIGINS","custom","theme","plugin","TEMPLATE_PART_AREA_DEFAULT_CATEGORY","PATTERN_TYPES","PATTERN_DEFAULT_CATEGORY","PATTERN_USER_CATEGORY","EXCLUDED_PATTERN_SOURCES","PATTERN_SYNC_TYPES","unlock","patternPrivateApis","FOCUSABLE_ENTITIES","user","POST_TYPE_LABELS","__"],"sources":["@wordpress/edit-site/src/utils/constants.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { __ } from '@wordpress/i18n';\nimport { privateApis as patternPrivateApis } from '@wordpress/patterns';\n\n/**\n * Internal dependencies\n */\nimport { unlock } from '../lock-unlock';\n\n// Navigation\nexport const NAVIGATION_POST_TYPE = 'wp_navigation';\n\n// Templates.\nexport const TEMPLATE_POST_TYPE = 'wp_template';\nexport const TEMPLATE_PART_POST_TYPE = 'wp_template_part';\nexport const TEMPLATE_ORIGINS = {\n\tcustom: 'custom',\n\ttheme: 'theme',\n\tplugin: 'plugin',\n};\nexport const TEMPLATE_PART_AREA_DEFAULT_CATEGORY = 'uncategorized';\n\n// Patterns.\nexport const {\n\tPATTERN_TYPES,\n\tPATTERN_DEFAULT_CATEGORY,\n\tPATTERN_USER_CATEGORY,\n\tEXCLUDED_PATTERN_SOURCES,\n\tPATTERN_SYNC_TYPES,\n} = unlock( patternPrivateApis );\n\n// Entities that are editable in focus mode.\nexport const FOCUSABLE_ENTITIES = [\n\tTEMPLATE_PART_POST_TYPE,\n\tNAVIGATION_POST_TYPE,\n\tPATTERN_TYPES.user,\n];\n\nexport const POST_TYPE_LABELS = {\n\t[ TEMPLATE_POST_TYPE ]: __( 'Template' ),\n\t[ TEMPLATE_PART_POST_TYPE ]: __( 'Template part' ),\n\t[ PATTERN_TYPES.user ]: __( 'Pattern' ),\n\t[ NAVIGATION_POST_TYPE ]: __( 'Navigation' ),\n};\n"],"mappings":";;;;;;AAGA,IAAAA,KAAA,GAAAC,OAAA;AACA,IAAAC,SAAA,GAAAD,OAAA;AAKA,IAAAE,WAAA,GAAAF,OAAA;AATA;AACA;AACA;;AAIA;AACA;AACA;;AAGA;AACO,MAAMG,oBAAoB,GAAG,eAAe;;AAEnD;AAAAC,OAAA,CAAAD,oBAAA,GAAAA,oBAAA;AACO,MAAME,kBAAkB,GAAG,aAAa;AAACD,OAAA,CAAAC,kBAAA,GAAAA,kBAAA;AACzC,MAAMC,uBAAuB,GAAG,kBAAkB;AAACF,OAAA,CAAAE,uBAAA,GAAAA,uBAAA;AACnD,MAAMC,gBAAgB,GAAG;EAC/BC,MAAM,EAAE,QAAQ;EAChBC,KAAK,EAAE,OAAO;EACdC,MAAM,EAAE;AACT,CAAC;AAACN,OAAA,CAAAG,gBAAA,GAAAA,gBAAA;AACK,MAAMI,mCAAmC,GAAG,eAAe;;AAElE;AAAAP,OAAA,CAAAO,mCAAA,GAAAA,mCAAA;AACO,MAAM;EACZC,aAAa;EACbC,wBAAwB;EACxBC,qBAAqB;EACrBC,wBAAwB;EACxBC;AACD,CAAC,GAAG,IAAAC,kBAAM,EAAEC,qBAAmB,CAAC;;AAEhC;AAAAd,OAAA,CAAAY,kBAAA,GAAAA,kBAAA;AAAAZ,OAAA,CAAAW,wBAAA,GAAAA,wBAAA;AAAAX,OAAA,CAAAU,qBAAA,GAAAA,qBAAA;AAAAV,OAAA,CAAAS,wBAAA,GAAAA,wBAAA;AAAAT,OAAA,CAAAQ,aAAA,GAAAA,aAAA;AACO,MAAMO,kBAAkB,GAAG,CACjCb,uBAAuB,EACvBH,oBAAoB,EACpBS,aAAa,CAACQ,IAAI,CAClB;AAAChB,OAAA,CAAAe,kBAAA,GAAAA,kBAAA;AAEK,MAAME,gBAAgB,GAAG;EAC/B,CAAEhB,kBAAkB,GAAI,IAAAiB,QAAE,EAAE,UAAW,CAAC;EACxC,CAAEhB,uBAAuB,GAAI,IAAAgB,QAAE,EAAE,eAAgB,CAAC;EAClD,CAAEV,aAAa,CAACQ,IAAI,GAAI,IAAAE,QAAE,EAAE,SAAU,CAAC;EACvC,CAAEnB,oBAAoB,GAAI,IAAAmB,QAAE,EAAE,YAAa;AAC5C,CAAC;AAAClB,OAAA,CAAAiB,gBAAA,GAAAA,gBAAA"}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { createElement } from "react";
|
|
1
2
|
/**
|
|
2
3
|
* WordPress dependencies
|
|
3
4
|
*/
|
|
@@ -10,6 +11,8 @@ import { __, sprintf } from '@wordpress/i18n';
|
|
|
10
11
|
import { store as noticesStore } from '@wordpress/notices';
|
|
11
12
|
import { useMemo } from '@wordpress/element';
|
|
12
13
|
import { privateApis as routerPrivateApis } from '@wordpress/router';
|
|
14
|
+
import { Button, __experimentalText as Text, __experimentalHStack as HStack, __experimentalVStack as VStack } from '@wordpress/components';
|
|
15
|
+
|
|
13
16
|
/**
|
|
14
17
|
* Internal dependencies
|
|
15
18
|
*/
|
|
@@ -17,43 +20,59 @@ import { unlock } from '../../lock-unlock';
|
|
|
17
20
|
const {
|
|
18
21
|
useHistory
|
|
19
22
|
} = unlock(routerPrivateApis);
|
|
20
|
-
export
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
23
|
+
export const trashPostAction = {
|
|
24
|
+
id: 'move-to-trash',
|
|
25
|
+
label: __('Move to Trash'),
|
|
26
|
+
isPrimary: true,
|
|
27
|
+
icon: trash,
|
|
28
|
+
isEligible({
|
|
29
|
+
status
|
|
30
|
+
}) {
|
|
31
|
+
return status !== 'trash';
|
|
32
|
+
},
|
|
33
|
+
hideModalHeader: true,
|
|
34
|
+
RenderModal: ({
|
|
35
|
+
item: post,
|
|
36
|
+
closeModal
|
|
37
|
+
}) => {
|
|
38
|
+
const {
|
|
39
|
+
createSuccessNotice,
|
|
40
|
+
createErrorNotice
|
|
41
|
+
} = useDispatch(noticesStore);
|
|
42
|
+
const {
|
|
43
|
+
deleteEntityRecord
|
|
44
|
+
} = useDispatch(coreStore);
|
|
45
|
+
return createElement(VStack, {
|
|
46
|
+
spacing: "5"
|
|
47
|
+
}, createElement(Text, null, sprintf(
|
|
48
|
+
// translators: %s: The page's title.
|
|
49
|
+
__('Are you sure you want to delete "%s"?'), decodeEntities(post.title.rendered))), createElement(HStack, {
|
|
50
|
+
justify: "right"
|
|
51
|
+
}, createElement(Button, {
|
|
52
|
+
variant: "tertiary",
|
|
53
|
+
onClick: closeModal
|
|
54
|
+
}, __('Cancel')), createElement(Button, {
|
|
55
|
+
variant: "primary",
|
|
56
|
+
onClick: async () => {
|
|
57
|
+
try {
|
|
58
|
+
await deleteEntityRecord('postType', post.type, post.id, {}, {
|
|
59
|
+
throwOnError: true
|
|
60
|
+
});
|
|
61
|
+
createSuccessNotice(sprintf( /* translators: The page's title. */
|
|
62
|
+
__('"%s" moved to the Trash.'), decodeEntities(post.title.rendered)), {
|
|
63
|
+
type: 'snackbar',
|
|
64
|
+
id: 'edit-site-page-trashed'
|
|
65
|
+
});
|
|
66
|
+
} catch (error) {
|
|
67
|
+
const errorMessage = error.message && error.code !== 'unknown_error' ? error.message : __('An error occurred while moving the page to the trash.');
|
|
68
|
+
createErrorNotice(errorMessage, {
|
|
69
|
+
type: 'snackbar'
|
|
70
|
+
});
|
|
71
|
+
}
|
|
53
72
|
}
|
|
54
|
-
}
|
|
55
|
-
}
|
|
56
|
-
}
|
|
73
|
+
}, __('Delete'))));
|
|
74
|
+
}
|
|
75
|
+
};
|
|
57
76
|
export function usePermanentlyDeletePostAction() {
|
|
58
77
|
const {
|
|
59
78
|
createSuccessNotice,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["external","trash","backup","addQueryArgs","useDispatch","decodeEntities","store","coreStore","__","sprintf","noticesStore","useMemo","privateApis","routerPrivateApis","unlock","useHistory","useTrashPostAction","createSuccessNotice","createErrorNotice","deleteEntityRecord","id","label","isPrimary","icon","isEligible","status","callback","post","type","throwOnError","title","rendered","error","errorMessage","message","code","usePermanentlyDeletePostAction","force","useRestorePostAction","editEntityRecord","saveEditedEntityRecord","viewPostAction","document","location","href","link","useEditPostAction","history","push","postId","postType","canvas","postRevisionsAction","_post$_links$predeces","_post$_links$version","lastRevisionId","_links","revisionsCount","count","revision"],"sources":["@wordpress/edit-site/src/components/actions/index.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { external, trash, backup } from '@wordpress/icons';\nimport { addQueryArgs } from '@wordpress/url';\nimport { useDispatch } from '@wordpress/data';\nimport { decodeEntities } from '@wordpress/html-entities';\nimport { store as coreStore } from '@wordpress/core-data';\nimport { __, sprintf } from '@wordpress/i18n';\nimport { store as noticesStore } from '@wordpress/notices';\nimport { useMemo } from '@wordpress/element';\nimport { privateApis as routerPrivateApis } from '@wordpress/router';\n/**\n * Internal dependencies\n */\nimport { unlock } from '../../lock-unlock';\n\nconst { useHistory } = unlock( routerPrivateApis );\n\nexport function useTrashPostAction() {\n\tconst { createSuccessNotice, createErrorNotice } =\n\t\tuseDispatch( noticesStore );\n\tconst { deleteEntityRecord } = useDispatch( coreStore );\n\n\treturn useMemo(\n\t\t() => ( {\n\t\t\tid: 'move-to-trash',\n\t\t\tlabel: __( 'Move to Trash' ),\n\t\t\tisPrimary: true,\n\t\t\ticon: trash,\n\t\t\tisEligible( { status } ) {\n\t\t\t\treturn status !== 'trash';\n\t\t\t},\n\t\t\tasync callback( post ) {\n\t\t\t\ttry {\n\t\t\t\t\tawait deleteEntityRecord(\n\t\t\t\t\t\t'postType',\n\t\t\t\t\t\tpost.type,\n\t\t\t\t\t\tpost.id,\n\t\t\t\t\t\t{},\n\t\t\t\t\t\t{ throwOnError: true }\n\t\t\t\t\t);\n\t\t\t\t\tcreateSuccessNotice(\n\t\t\t\t\t\tsprintf(\n\t\t\t\t\t\t\t/* translators: The page's title. */\n\t\t\t\t\t\t\t__( '\"%s\" moved to the Trash.' ),\n\t\t\t\t\t\t\tdecodeEntities( post.title.rendered )\n\t\t\t\t\t\t),\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\ttype: 'snackbar',\n\t\t\t\t\t\t\tid: 'edit-site-page-trashed',\n\t\t\t\t\t\t}\n\t\t\t\t\t);\n\t\t\t\t} catch ( error ) {\n\t\t\t\t\tconst errorMessage =\n\t\t\t\t\t\terror.message && error.code !== 'unknown_error'\n\t\t\t\t\t\t\t? error.message\n\t\t\t\t\t\t\t: __(\n\t\t\t\t\t\t\t\t\t'An error occurred while moving the page to the trash.'\n\t\t\t\t\t\t\t );\n\n\t\t\t\t\tcreateErrorNotice( errorMessage, { type: 'snackbar' } );\n\t\t\t\t}\n\t\t\t},\n\t\t} ),\n\t\t[ createSuccessNotice, createErrorNotice, deleteEntityRecord ]\n\t);\n}\n\nexport function usePermanentlyDeletePostAction() {\n\tconst { createSuccessNotice, createErrorNotice } =\n\t\tuseDispatch( noticesStore );\n\tconst { deleteEntityRecord } = useDispatch( coreStore );\n\n\treturn useMemo(\n\t\t() => ( {\n\t\t\tid: 'permanently-delete',\n\t\t\tlabel: __( 'Permanently delete' ),\n\t\t\tisPrimary: true,\n\t\t\ticon: trash,\n\t\t\tisEligible( { status } ) {\n\t\t\t\treturn status === 'trash';\n\t\t\t},\n\t\t\tasync callback( post ) {\n\t\t\t\ttry {\n\t\t\t\t\tawait deleteEntityRecord(\n\t\t\t\t\t\t'postType',\n\t\t\t\t\t\tpost.type,\n\t\t\t\t\t\tpost.id,\n\t\t\t\t\t\t{ force: true },\n\t\t\t\t\t\t{ throwOnError: true }\n\t\t\t\t\t);\n\t\t\t\t\tcreateSuccessNotice(\n\t\t\t\t\t\tsprintf(\n\t\t\t\t\t\t\t/* translators: The posts's title. */\n\t\t\t\t\t\t\t__( '\"%s\" permanently deleted.' ),\n\t\t\t\t\t\t\tdecodeEntities( post.title.rendered )\n\t\t\t\t\t\t),\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\ttype: 'snackbar',\n\t\t\t\t\t\t\tid: 'edit-site-post-permanently-deleted',\n\t\t\t\t\t\t}\n\t\t\t\t\t);\n\t\t\t\t} catch ( error ) {\n\t\t\t\t\tconst errorMessage =\n\t\t\t\t\t\terror.message && error.code !== 'unknown_error'\n\t\t\t\t\t\t\t? error.message\n\t\t\t\t\t\t\t: __(\n\t\t\t\t\t\t\t\t\t'An error occurred while permanently deleting the post.'\n\t\t\t\t\t\t\t );\n\n\t\t\t\t\tcreateErrorNotice( errorMessage, { type: 'snackbar' } );\n\t\t\t\t}\n\t\t\t},\n\t\t} ),\n\t\t[ createSuccessNotice, createErrorNotice, deleteEntityRecord ]\n\t);\n}\n\nexport function useRestorePostAction() {\n\tconst { createSuccessNotice, createErrorNotice } =\n\t\tuseDispatch( noticesStore );\n\tconst { editEntityRecord, saveEditedEntityRecord } =\n\t\tuseDispatch( coreStore );\n\n\treturn useMemo(\n\t\t() => ( {\n\t\t\tid: 'restore',\n\t\t\tlabel: __( 'Restore' ),\n\t\t\tisPrimary: true,\n\t\t\ticon: backup,\n\t\t\tisEligible( { status } ) {\n\t\t\t\treturn status === 'trash';\n\t\t\t},\n\t\t\tasync callback( post ) {\n\t\t\t\tawait editEntityRecord( 'postType', post.type, post.id, {\n\t\t\t\t\tstatus: 'draft',\n\t\t\t\t} );\n\t\t\t\ttry {\n\t\t\t\t\tawait saveEditedEntityRecord(\n\t\t\t\t\t\t'postType',\n\t\t\t\t\t\tpost.type,\n\t\t\t\t\t\tpost.id,\n\t\t\t\t\t\t{ throwOnError: true }\n\t\t\t\t\t);\n\t\t\t\t\tcreateSuccessNotice(\n\t\t\t\t\t\tsprintf(\n\t\t\t\t\t\t\t/* translators: The posts's title. */\n\t\t\t\t\t\t\t__( '\"%s\" has been restored.' ),\n\t\t\t\t\t\t\tdecodeEntities( post.title.rendered )\n\t\t\t\t\t\t),\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\ttype: 'snackbar',\n\t\t\t\t\t\t\tid: 'edit-site-post-restored',\n\t\t\t\t\t\t}\n\t\t\t\t\t);\n\t\t\t\t} catch ( error ) {\n\t\t\t\t\tconst errorMessage =\n\t\t\t\t\t\terror.message && error.code !== 'unknown_error'\n\t\t\t\t\t\t\t? error.message\n\t\t\t\t\t\t\t: __(\n\t\t\t\t\t\t\t\t\t'An error occurred while restoring the post.'\n\t\t\t\t\t\t\t );\n\n\t\t\t\t\tcreateErrorNotice( errorMessage, { type: 'snackbar' } );\n\t\t\t\t}\n\t\t\t},\n\t\t} ),\n\t\t[\n\t\t\tcreateSuccessNotice,\n\t\t\tcreateErrorNotice,\n\t\t\teditEntityRecord,\n\t\t\tsaveEditedEntityRecord,\n\t\t]\n\t);\n}\n\nexport const viewPostAction = {\n\tid: 'view-post',\n\tlabel: __( 'View' ),\n\tisPrimary: true,\n\ticon: external,\n\tisEligible( post ) {\n\t\treturn post.status !== 'trash';\n\t},\n\tcallback( post ) {\n\t\tdocument.location.href = post.link;\n\t},\n};\n\nexport function useEditPostAction() {\n\tconst history = useHistory();\n\treturn useMemo(\n\t\t() => ( {\n\t\t\tid: 'edit-post',\n\t\t\tlabel: __( 'Edit' ),\n\t\t\tisEligible( { status } ) {\n\t\t\t\treturn status !== 'trash';\n\t\t\t},\n\t\t\tcallback( post ) {\n\t\t\t\thistory.push( {\n\t\t\t\t\tpostId: post.id,\n\t\t\t\t\tpostType: post.type,\n\t\t\t\t\tcanvas: 'edit',\n\t\t\t\t} );\n\t\t\t},\n\t\t} ),\n\t\t[ history ]\n\t);\n}\nexport const postRevisionsAction = {\n\tid: 'view-post-revisions',\n\tlabel: __( 'View revisions' ),\n\tisPrimary: false,\n\tisEligible: ( post ) => {\n\t\tif ( post.status === 'trash' ) {\n\t\t\treturn false;\n\t\t}\n\t\tconst lastRevisionId =\n\t\t\tpost?._links?.[ 'predecessor-version' ]?.[ 0 ]?.id ?? null;\n\t\tconst revisionsCount =\n\t\t\tpost?._links?.[ 'version-history' ]?.[ 0 ]?.count ?? 0;\n\t\treturn lastRevisionId && revisionsCount > 1;\n\t},\n\tcallback( post ) {\n\t\tconst href = addQueryArgs( 'revision.php', {\n\t\t\trevision: post?._links?.[ 'predecessor-version' ]?.[ 0 ]?.id,\n\t\t} );\n\t\tdocument.location.href = href;\n\t},\n};\n"],"mappings":"AAAA;AACA;AACA;AACA,SAASA,QAAQ,EAAEC,KAAK,EAAEC,MAAM,QAAQ,kBAAkB;AAC1D,SAASC,YAAY,QAA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O,CACV,CAAC;AACF;AACA,OAAO,MAAMK,mBAAmB,GAAG;EAClChC,EAAE,EAAE,qBAAqB;EACzBC,KAAK,EAAEb,EAAE,CAAE,gBAAiB,CAAC;EAC7Bc,SAAS,EAAE,KAAK;EAChBE,UAAU,EAAIG,IAAI,IAAM;IAAA,IAAA0B,qBAAA,EAAAC,oBAAA;IACvB,IAAK3B,IAAI,CAACF,MAAM,KAAK,OAAO,EAAG;MAC9B,OAAO,KAAK;IACb;IACA,MAAM8B,cAAc,IAAAF,qBAAA,GACnB1B,IAAI,EAAE6B,MAAM,GAAI,qBAAqB,CAAE,GAAI,CAAC,CAAE,EAAEpC,EAAE,cAAAiC,qBAAA,cAAAA,qBAAA,GAAI,IAAI;IAC3D,MAAMI,cAAc,IAAAH,oBAAA,GACnB3B,IAAI,EAAE6B,MAAM,GAAI,iBAAiB,CAAE,GAAI,CAAC,CAAE,EAAEE,KAAK,cAAAJ,oBAAA,cAAAA,oBAAA,GAAI,CAAC;IACvD,OAAOC,cAAc,IAAIE,cAAc,GAAG,CAAC;EAC5C,CAAC;EACD/B,QAAQA,CAAEC,IAAI,EAAG;IAChB,MAAMiB,IAAI,GAAGzC,YAAY,CAAE,cAAc,EAAE;MAC1CwD,QAAQ,EAAEhC,IAAI,EAAE6B,MAAM,GAAI,qBAAqB,CAAE,GAAI,CAAC,CAAE,EAAEpC;IAC3D,CAAE,CAAC;IACHsB,QAAQ,CAACC,QAAQ,CAACC,IAAI,GAAGA,IAAI;EAC9B;AACD,CAAC"}
|
|
1
|
+
{"version":3,"names":["external","trash","backup","addQueryArgs","useDispatch","decodeEntities","store","coreStore","__","sprintf","noticesStore","useMemo","privateApis","routerPrivateApis","Button","__experimentalText","Text","__experimentalHStack","HStack","__experimentalVStack","VStack","unlock","useHistory","trashPostAction","id","label","isPrimary","icon","isEligible","status","hideModalHeader","RenderModal","item","post","closeModal","createSuccessNotice","createErrorNotice","deleteEntityRecord","createElement","spacing","title","rendered","justify","variant","onClick","type","throwOnError","error","errorMessage","message","code","usePermanentlyDeletePostAction","callback","force","useRestorePostAction","editEntityRecord","saveEditedEntityRecord","viewPostAction","document","location","href","link","useEditPostAction","history","push","postId","postType","canvas","postRevisionsAction","_post$_links$predeces","_post$_links$version","lastRevisionId","_links","revisionsCount","count","revision"],"sources":["@wordpress/edit-site/src/components/actions/index.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { external, trash, backup } from '@wordpress/icons';\nimport { addQueryArgs } from '@wordpress/url';\nimport { useDispatch } from '@wordpress/data';\nimport { decodeEntities } from '@wordpress/html-entities';\nimport { store as coreStore } from '@wordpress/core-data';\nimport { __, sprintf } from '@wordpress/i18n';\nimport { store as noticesStore } from '@wordpress/notices';\nimport { useMemo } from '@wordpress/element';\nimport { privateApis as routerPrivateApis } from '@wordpress/router';\nimport {\n\tButton,\n\t__experimentalText as Text,\n\t__experimentalHStack as HStack,\n\t__experimentalVStack as VStack,\n} from '@wordpress/components';\n\n/**\n * Internal dependencies\n */\nimport { unlock } from '../../lock-unlock';\n\nconst { useHistory } = unlock( routerPrivateApis );\n\nexport const trashPostAction = {\n\tid: 'move-to-trash',\n\tlabel: __( 'Move to Trash' ),\n\tisPrimary: true,\n\ticon: trash,\n\tisEligible( { status } ) {\n\t\treturn status !== 'trash';\n\t},\n\thideModalHeader: true,\n\tRenderModal: ( { item: post, closeModal } ) => {\n\t\tconst { createSuccessNotice, createErrorNotice } =\n\t\t\tuseDispatch( noticesStore );\n\t\tconst { deleteEntityRecord } = useDispatch( coreStore );\n\t\treturn (\n\t\t\t<VStack spacing=\"5\">\n\t\t\t\t<Text>\n\t\t\t\t\t{ sprintf(\n\t\t\t\t\t\t// translators: %s: The page's title.\n\t\t\t\t\t\t__( 'Are you sure you want to delete \"%s\"?' ),\n\t\t\t\t\t\tdecodeEntities( post.title.rendered )\n\t\t\t\t\t) }\n\t\t\t\t</Text>\n\t\t\t\t<HStack justify=\"right\">\n\t\t\t\t\t<Button variant=\"tertiary\" onClick={ closeModal }>\n\t\t\t\t\t\t{ __( 'Cancel' ) }\n\t\t\t\t\t</Button>\n\t\t\t\t\t<Button\n\t\t\t\t\t\tvariant=\"primary\"\n\t\t\t\t\t\tonClick={ async () => {\n\t\t\t\t\t\t\ttry {\n\t\t\t\t\t\t\t\tawait deleteEntityRecord(\n\t\t\t\t\t\t\t\t\t'postType',\n\t\t\t\t\t\t\t\t\tpost.type,\n\t\t\t\t\t\t\t\t\tpost.id,\n\t\t\t\t\t\t\t\t\t{},\n\t\t\t\t\t\t\t\t\t{ throwOnError: true }\n\t\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\t\tcreateSuccessNotice(\n\t\t\t\t\t\t\t\t\tsprintf(\n\t\t\t\t\t\t\t\t\t\t/* translators: The page's title. */\n\t\t\t\t\t\t\t\t\t\t__( '\"%s\" moved to the Trash.' ),\n\t\t\t\t\t\t\t\t\t\tdecodeEntities( post.title.rendered )\n\t\t\t\t\t\t\t\t\t),\n\t\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\t\ttype: 'snackbar',\n\t\t\t\t\t\t\t\t\t\tid: 'edit-site-page-trashed',\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} catch ( error ) {\n\t\t\t\t\t\t\t\tconst errorMessage =\n\t\t\t\t\t\t\t\t\terror.message &&\n\t\t\t\t\t\t\t\t\terror.code !== 'unknown_error'\n\t\t\t\t\t\t\t\t\t\t? error.message\n\t\t\t\t\t\t\t\t\t\t: __(\n\t\t\t\t\t\t\t\t\t\t\t\t'An error occurred while moving the page to the trash.'\n\t\t\t\t\t\t\t\t\t\t );\n\n\t\t\t\t\t\t\t\tcreateErrorNotice( errorMessage, {\n\t\t\t\t\t\t\t\t\ttype: 'snackbar',\n\t\t\t\t\t\t\t\t} );\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t} }\n\t\t\t\t\t>\n\t\t\t\t\t\t{ __( 'Delete' ) }\n\t\t\t\t\t</Button>\n\t\t\t\t</HStack>\n\t\t\t</VStack>\n\t\t);\n\t},\n};\n\nexport function usePermanentlyDeletePostAction() {\n\tconst { createSuccessNotice, createErrorNotice } =\n\t\tuseDispatch( noticesStore );\n\tconst { deleteEntityRecord } = useDispatch( coreStore );\n\n\treturn useMemo(\n\t\t() => ( {\n\t\t\tid: 'permanently-delete',\n\t\t\tlabel: __( 'Permanently delete' ),\n\t\t\tisPrimary: true,\n\t\t\ticon: trash,\n\t\t\tisEligible( { status } ) {\n\t\t\t\treturn status === 'trash';\n\t\t\t},\n\t\t\tasync callback( post ) {\n\t\t\t\ttry {\n\t\t\t\t\tawait deleteEntityRecord(\n\t\t\t\t\t\t'postType',\n\t\t\t\t\t\tpost.type,\n\t\t\t\t\t\tpost.id,\n\t\t\t\t\t\t{ force: true },\n\t\t\t\t\t\t{ throwOnError: true }\n\t\t\t\t\t);\n\t\t\t\t\tcreateSuccessNotice(\n\t\t\t\t\t\tsprintf(\n\t\t\t\t\t\t\t/* translators: The posts's title. */\n\t\t\t\t\t\t\t__( '\"%s\" permanently deleted.' ),\n\t\t\t\t\t\t\tdecodeEntities( post.title.rendered )\n\t\t\t\t\t\t),\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\ttype: 'snackbar',\n\t\t\t\t\t\t\tid: 'edit-site-post-permanently-deleted',\n\t\t\t\t\t\t}\n\t\t\t\t\t);\n\t\t\t\t} catch ( error ) {\n\t\t\t\t\tconst errorMessage =\n\t\t\t\t\t\terror.message && error.code !== 'unknown_error'\n\t\t\t\t\t\t\t? error.message\n\t\t\t\t\t\t\t: __(\n\t\t\t\t\t\t\t\t\t'An error occurred while permanently deleting the post.'\n\t\t\t\t\t\t\t );\n\n\t\t\t\t\tcreateErrorNotice( errorMessage, { type: 'snackbar' } );\n\t\t\t\t}\n\t\t\t},\n\t\t} ),\n\t\t[ createSuccessNotice, createErrorNotice, deleteEntityRecord ]\n\t);\n}\n\nexport function useRestorePostAction() {\n\tconst { createSuccessNotice, createErrorNotice } =\n\t\tuseDispatch( noticesStore );\n\tconst { editEntityRecord, saveEditedEntityRecord } =\n\t\tuseDispatch( coreStore );\n\n\treturn useMemo(\n\t\t() => ( {\n\t\t\tid: 'restore',\n\t\t\tlabel: __( 'Restore' ),\n\t\t\tisPrimary: true,\n\t\t\ticon: backup,\n\t\t\tisEligible( { status } ) {\n\t\t\t\treturn status === 'trash';\n\t\t\t},\n\t\t\tasync callback( post ) {\n\t\t\t\tawait editEntityRecord( 'postType', post.type, post.id, {\n\t\t\t\t\tstatus: 'draft',\n\t\t\t\t} );\n\t\t\t\ttry {\n\t\t\t\t\tawait saveEditedEntityRecord(\n\t\t\t\t\t\t'postType',\n\t\t\t\t\t\tpost.type,\n\t\t\t\t\t\tpost.id,\n\t\t\t\t\t\t{ throwOnError: true }\n\t\t\t\t\t);\n\t\t\t\t\tcreateSuccessNotice(\n\t\t\t\t\t\tsprintf(\n\t\t\t\t\t\t\t/* translators: The posts's title. */\n\t\t\t\t\t\t\t__( '\"%s\" has been restored.' ),\n\t\t\t\t\t\t\tdecodeEntities( post.title.rendered )\n\t\t\t\t\t\t),\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\ttype: 'snackbar',\n\t\t\t\t\t\t\tid: 'edit-site-post-restored',\n\t\t\t\t\t\t}\n\t\t\t\t\t);\n\t\t\t\t} catch ( error ) {\n\t\t\t\t\tconst errorMessage =\n\t\t\t\t\t\terror.message && error.code !== 'unknown_error'\n\t\t\t\t\t\t\t? error.message\n\t\t\t\t\t\t\t: __(\n\t\t\t\t\t\t\t\t\t'An error occurred while restoring the post.'\n\t\t\t\t\t\t\t );\n\n\t\t\t\t\tcreateErrorNotice( errorMessage, { type: 'snackbar' } );\n\t\t\t\t}\n\t\t\t},\n\t\t} ),\n\t\t[\n\t\t\tcreateSuccessNotice,\n\t\t\tcreateErrorNotice,\n\t\t\teditEntityRecord,\n\t\t\tsaveEditedEntityRecord,\n\t\t]\n\t);\n}\n\nexport const viewPostAction = {\n\tid: 'view-post',\n\tlabel: __( 'View' ),\n\tisPrimary: true,\n\ticon: external,\n\tisEligible( post ) {\n\t\treturn post.status !== 'trash';\n\t},\n\tcallback( post ) {\n\t\tdocument.location.href = post.link;\n\t},\n};\n\nexport function useEditPostAction() {\n\tconst history = useHistory();\n\treturn useMemo(\n\t\t() => ( {\n\t\t\tid: 'edit-post',\n\t\t\tlabel: __( 'Edit' ),\n\t\t\tisEligible( { status } ) {\n\t\t\t\treturn status !== 'trash';\n\t\t\t},\n\t\t\tcallback( post ) {\n\t\t\t\thistory.push( {\n\t\t\t\t\tpostId: post.id,\n\t\t\t\t\tpostType: post.type,\n\t\t\t\t\tcanvas: 'edit',\n\t\t\t\t} );\n\t\t\t},\n\t\t} ),\n\t\t[ history ]\n\t);\n}\nexport const postRevisionsAction = {\n\tid: 'view-post-revisions',\n\tlabel: __( 'View revisions' ),\n\tisPrimary: false,\n\tisEligible: ( post ) => {\n\t\tif ( post.status === 'trash' ) {\n\t\t\treturn false;\n\t\t}\n\t\tconst lastRevisionId =\n\t\t\tpost?._links?.[ 'predecessor-version' ]?.[ 0 ]?.id ?? null;\n\t\tconst revisionsCount =\n\t\t\tpost?._links?.[ 'version-history' ]?.[ 0 ]?.count ?? 0;\n\t\treturn lastRevisionId && revisionsCount > 1;\n\t},\n\tcallback( post ) {\n\t\tconst href = addQueryArgs( 'revision.php', {\n\t\t\trevision: post?._links?.[ 'predecessor-version' ]?.[ 0 ]?.id,\n\t\t} );\n\t\tdocument.location.href = href;\n\t},\n};\n"],"mappings":";AAAA;AACA;AACA;AACA,SAASA,QAAQ,EAAEC,KAAK,EAAEC,MAAM,QAAQ,kBAAkB;AAC1D,SAASC,YAAY,QAAQ,gBAAgB;AAC7C,SAASC,WAAW,QAAQ,iBAAiB;AAC7C,SAASC,cAAc,QAAQ,0BAA0B;AACzD,SAASC,KAAK,IAAIC,SAAS,QAAQ,sBAAsB;AACzD,SAASC,EAAE,EAAEC,OAAO,QAAQ,iBAAiB;AAC7C,SAASH,K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,QAAQ,EAAE1C,IAAI,EAAEuC,MAAM,GAAI,qBAAqB,CAAE,GAAI,CAAC,CAAE,EAAEhD;IAC3D,CAAE,CAAC;IACHkC,QAAQ,CAACC,QAAQ,CAACC,IAAI,GAAGA,IAAI;EAC9B;AACD,CAAC"}
|
|
@@ -21,7 +21,7 @@ import useSiteEditorSettings from './use-site-editor-settings';
|
|
|
21
21
|
import { store as editSiteStore } from '../../store';
|
|
22
22
|
import { FOCUSABLE_ENTITIES, NAVIGATION_POST_TYPE } from '../../utils/constants';
|
|
23
23
|
import { unlock } from '../../lock-unlock';
|
|
24
|
-
import
|
|
24
|
+
import PageContentFocusNotifications from '../page-content-focus-notifications';
|
|
25
25
|
const LAYOUT = {
|
|
26
26
|
type: 'default',
|
|
27
27
|
// At the root level of the site editor, no alignments should be allowed.
|
|
@@ -98,9 +98,14 @@ export default function SiteEditorCanvas() {
|
|
|
98
98
|
className: classnames('edit-site-block-editor__block-list wp-site-blocks', {
|
|
99
99
|
'is-navigation-block': isTemplateTypeNavigation
|
|
100
100
|
}),
|
|
101
|
+
dropZoneElement:
|
|
102
|
+
// Pass in the html element of the iframe to ensure that
|
|
103
|
+
// the drop zone extends to the very edges of the iframe,
|
|
104
|
+
// even if the template is shorter than the viewport.
|
|
105
|
+
contentRef.current?.parentNode,
|
|
101
106
|
layout: LAYOUT,
|
|
102
107
|
renderAppender: showBlockAppender
|
|
103
|
-
}))))), createElement(
|
|
108
|
+
}))))), createElement(PageContentFocusNotifications, {
|
|
104
109
|
contentRef: contentRef
|
|
105
110
|
}));
|
|
106
111
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["classnames","useSelect","useDispatch","useRef","BlockList","BlockTools","store","blockEditorStore","useViewportMatch","useResizeObserver","BackButton","ResizableEditor","EditorCanvas","EditorCanvasContainer","useSiteEditorSettings","editSiteStore","FOCUSABLE_ENTITIES","NAVIGATION_POST_TYPE","unlock","
|
|
1
|
+
{"version":3,"names":["classnames","useSelect","useDispatch","useRef","BlockList","BlockTools","store","blockEditorStore","useViewportMatch","useResizeObserver","BackButton","ResizableEditor","EditorCanvas","EditorCanvasContainer","useSiteEditorSettings","editSiteStore","FOCUSABLE_ENTITIES","NAVIGATION_POST_TYPE","unlock","PageContentFocusNotifications","LAYOUT","type","alignments","SiteEditorCanvas","clearSelectedBlock","templateType","isFocusMode","isViewMode","select","getEditedPostType","getCanvasMode","_templateType","includes","resizeObserver","sizes","settings","hasBlocks","getBlockCount","blocks","isMobileViewport","enableResizing","contentRef","isTemplateTypeNavigation","isNavigationFocusMode","showBlockAppender","undefined","forceFullHeight","createElement","Fragment","Slot","editorCanvasView","className","__unstableContentRef","onClick","event","target","currentTarget","height","dropZoneElement","current","parentNode","layout","renderAppender"],"sources":["@wordpress/edit-site/src/components/block-editor/site-editor-canvas.js"],"sourcesContent":["/**\n * External dependencies\n */\nimport classnames from 'classnames';\n/**\n * WordPress dependencies\n */\nimport { useSelect, useDispatch } from '@wordpress/data';\nimport { useRef } from '@wordpress/element';\nimport {\n\tBlockList,\n\tBlockTools,\n\tstore as blockEditorStore,\n} from '@wordpress/block-editor';\nimport { useViewportMatch, useResizeObserver } from '@wordpress/compose';\n/**\n * Internal dependencies\n */\nimport BackButton from './back-button';\nimport ResizableEditor from './resizable-editor';\nimport EditorCanvas from './editor-canvas';\nimport EditorCanvasContainer from '../editor-canvas-container';\nimport useSiteEditorSettings from './use-site-editor-settings';\nimport { store as editSiteStore } from '../../store';\nimport {\n\tFOCUSABLE_ENTITIES,\n\tNAVIGATION_POST_TYPE,\n} from '../../utils/constants';\nimport { unlock } from '../../lock-unlock';\nimport PageContentFocusNotifications from '../page-content-focus-notifications';\n\nconst LAYOUT = {\n\ttype: 'default',\n\t// At the root level of the site editor, no alignments should be allowed.\n\talignments: [],\n};\n\nexport default function SiteEditorCanvas() {\n\tconst { clearSelectedBlock } = useDispatch( blockEditorStore );\n\n\tconst { templateType, isFocusMode, isViewMode } = useSelect( ( select ) => {\n\t\tconst { getEditedPostType, getCanvasMode } = unlock(\n\t\t\tselect( editSiteStore )\n\t\t);\n\n\t\tconst _templateType = getEditedPostType();\n\n\t\treturn {\n\t\t\ttemplateType: _templateType,\n\t\t\tisFocusMode: FOCUSABLE_ENTITIES.includes( _templateType ),\n\t\t\tisViewMode: getCanvasMode() === 'view',\n\t\t};\n\t}, [] );\n\n\tconst [ resizeObserver, sizes ] = useResizeObserver();\n\n\tconst settings = useSiteEditorSettings();\n\n\tconst { hasBlocks } = useSelect( ( select ) => {\n\t\tconst { getBlockCount } = select( blockEditorStore );\n\n\t\tconst blocks = getBlockCount();\n\n\t\treturn {\n\t\t\thasBlocks: !! blocks,\n\t\t};\n\t}, [] );\n\n\tconst isMobileViewport = useViewportMatch( 'small', '<' );\n\tconst enableResizing =\n\t\tisFocusMode &&\n\t\t! isViewMode &&\n\t\t// Disable resizing in mobile viewport.\n\t\t! isMobileViewport;\n\n\tconst contentRef = useRef();\n\tconst isTemplateTypeNavigation = templateType === NAVIGATION_POST_TYPE;\n\n\tconst isNavigationFocusMode = isTemplateTypeNavigation && isFocusMode;\n\n\t// Hide the appender when:\n\t// - In navigation focus mode (should only allow the root Nav block).\n\t// - In view mode (i.e. not editing).\n\tconst showBlockAppender =\n\t\t( isNavigationFocusMode && hasBlocks ) || isViewMode\n\t\t\t? false\n\t\t\t: undefined;\n\n\tconst forceFullHeight = isNavigationFocusMode;\n\n\treturn (\n\t\t<>\n\t\t\t<EditorCanvasContainer.Slot>\n\t\t\t\t{ ( [ editorCanvasView ] ) =>\n\t\t\t\t\teditorCanvasView ? (\n\t\t\t\t\t\t<div className=\"edit-site-visual-editor is-focus-mode\">\n\t\t\t\t\t\t\t{ editorCanvasView }\n\t\t\t\t\t\t</div>\n\t\t\t\t\t) : (\n\t\t\t\t\t\t<BlockTools\n\t\t\t\t\t\t\tclassName={ classnames( 'edit-site-visual-editor', {\n\t\t\t\t\t\t\t\t'is-focus-mode':\n\t\t\t\t\t\t\t\t\tisFocusMode || !! editorCanvasView,\n\t\t\t\t\t\t\t\t'is-view-mode': isViewMode,\n\t\t\t\t\t\t\t} ) }\n\t\t\t\t\t\t\t__unstableContentRef={ contentRef }\n\t\t\t\t\t\t\tonClick={ ( event ) => {\n\t\t\t\t\t\t\t\t// Clear selected block when clicking on the gray background.\n\t\t\t\t\t\t\t\tif ( event.target === event.currentTarget ) {\n\t\t\t\t\t\t\t\t\tclearSelectedBlock();\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t} }\n\t\t\t\t\t\t>\n\t\t\t\t\t\t\t<BackButton />\n\t\t\t\t\t\t\t<ResizableEditor\n\t\t\t\t\t\t\t\tenableResizing={ enableResizing }\n\t\t\t\t\t\t\t\theight={\n\t\t\t\t\t\t\t\t\tsizes.height && ! forceFullHeight\n\t\t\t\t\t\t\t\t\t\t? sizes.height\n\t\t\t\t\t\t\t\t\t\t: '100%'\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<EditorCanvas\n\t\t\t\t\t\t\t\t\tenableResizing={ enableResizing }\n\t\t\t\t\t\t\t\t\tsettings={ settings }\n\t\t\t\t\t\t\t\t\tcontentRef={ contentRef }\n\t\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t\t{ resizeObserver }\n\t\t\t\t\t\t\t\t\t<BlockList\n\t\t\t\t\t\t\t\t\t\tclassName={ classnames(\n\t\t\t\t\t\t\t\t\t\t\t'edit-site-block-editor__block-list wp-site-blocks',\n\t\t\t\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\t\t\t\t'is-navigation-block':\n\t\t\t\t\t\t\t\t\t\t\t\t\tisTemplateTypeNavigation,\n\t\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\t\t\t\tdropZoneElement={\n\t\t\t\t\t\t\t\t\t\t\t// Pass in the html element of the iframe to ensure that\n\t\t\t\t\t\t\t\t\t\t\t// the drop zone extends to the very edges of the iframe,\n\t\t\t\t\t\t\t\t\t\t\t// even if the template is shorter than the viewport.\n\t\t\t\t\t\t\t\t\t\t\tcontentRef.current?.parentNode\n\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t\tlayout={ LAYOUT }\n\t\t\t\t\t\t\t\t\t\trenderAppender={ showBlockAppender }\n\t\t\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t\t</EditorCanvas>\n\t\t\t\t\t\t\t</ResizableEditor>\n\t\t\t\t\t\t</BlockTools>\n\t\t\t\t\t)\n\t\t\t\t}\n\t\t\t</EditorCanvasContainer.Slot>\n\t\t\t<PageContentFocusNotifications contentRef={ contentRef } />\n\t\t</>\n\t);\n}\n"],"mappings":";AAAA;AACA;AACA;AACA,OAAOA,UAAU,MAAM,YAAY;AACnC;AACA;AACA;AACA,SAASC,SAAS,EAAEC,WAAW,QAAQ,iBAAiB;AACxD,SAASC,MAAM,QAAQ,oBAAoB;AAC3C,SACCC,SAAS,EACTC,UAAU,EACVC,KAAK,IAAIC,gBAAgB,QACnB,yBAAyB;AAChC,SAASC,gBAAgB,EAAEC,iBAAiB,QAAQ,oBAAoB;AACxE;AACA;AACA;AACA,OAAOC,UAAU,MAAM,eAAe;AACtC,OAAOC,eAAe,MAAM,oBAAoB;AAChD,OAAOC,YAAY,MAAM,iBAAiB;AAC1C,OAAOC,qBAAqB,MAAM,4BAA4B;AAC9D,OAAOC,qBAAqB,MAAM,4BAA4B;AAC9D,SAASR,KAAK,IAAIS,aAAa,QAAQ,aAAa;AACpD,SACCC,kBAAkB,EAClBC,oBAAoB,QACd,uBAAuB;AAC9B,SAASC,MAAM,QAAQ,mBAAmB;AAC1C,OAAOC,6BAA6B,MAAM,qCAAqC;AAE/E,MAAMC,MAAM,GAAG;EACdC,IAAI,EAAE,SAAS;EACf;EACAC,UAAU,EAAE;AACb,CAAC;AAED,eAAe,SAASC,gBAAgBA,CAAA,EAAG;EAC1C,MAAM;IAAEC;EAAmB,CAAC,GAA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AAE,CACzD,CAAC;AAEL"}
|
|
@@ -10,14 +10,13 @@ import { __ } from '@wordpress/i18n';
|
|
|
10
10
|
* Internal dependencies
|
|
11
11
|
*/
|
|
12
12
|
import { unlock } from '../../lock-unlock';
|
|
13
|
-
import { OPERATOR_IN } from './
|
|
13
|
+
import { ENUMERATION_TYPE, OPERATOR_IN } from './constants';
|
|
14
14
|
const {
|
|
15
|
-
DropdownMenuV2,
|
|
16
|
-
DropdownSubMenuV2,
|
|
17
|
-
DropdownSubMenuTriggerV2,
|
|
18
|
-
DropdownMenuItemV2
|
|
15
|
+
DropdownMenuV2: DropdownMenu,
|
|
16
|
+
DropdownSubMenuV2: DropdownSubMenu,
|
|
17
|
+
DropdownSubMenuTriggerV2: DropdownSubMenuTrigger,
|
|
18
|
+
DropdownMenuItemV2: DropdownMenuItem
|
|
19
19
|
} = unlock(componentsPrivateApis);
|
|
20
|
-
const VALID_OPERATORS = [OPERATOR_IN];
|
|
21
20
|
export default function AddFilter({
|
|
22
21
|
fields,
|
|
23
22
|
view,
|
|
@@ -25,45 +24,47 @@ export default function AddFilter({
|
|
|
25
24
|
}) {
|
|
26
25
|
const filters = [];
|
|
27
26
|
fields.forEach(field => {
|
|
28
|
-
if (!field.
|
|
27
|
+
if (!field.type) {
|
|
29
28
|
return;
|
|
30
29
|
}
|
|
31
|
-
field.
|
|
32
|
-
|
|
30
|
+
switch (field.type) {
|
|
31
|
+
case ENUMERATION_TYPE:
|
|
33
32
|
filters.push({
|
|
34
33
|
field: field.id,
|
|
35
34
|
name: field.header,
|
|
36
|
-
operator: filter,
|
|
37
35
|
elements: field.elements || [],
|
|
38
|
-
isVisible: view.filters.some(f => f.field === field.id && f.operator ===
|
|
36
|
+
isVisible: view.filters.some(f => f.field === field.id && f.operator === OPERATOR_IN)
|
|
39
37
|
});
|
|
40
|
-
|
|
41
|
-
});
|
|
38
|
+
}
|
|
42
39
|
});
|
|
43
40
|
if (filters.length === 0) {
|
|
44
41
|
return null;
|
|
45
42
|
}
|
|
46
|
-
return createElement(
|
|
43
|
+
return createElement(DropdownMenu, {
|
|
47
44
|
label: __('Add filter'),
|
|
48
45
|
trigger: createElement(Button, {
|
|
49
46
|
disabled: filters.length === view.filters?.length,
|
|
50
47
|
__experimentalIsFocusable: true,
|
|
51
|
-
icon: plus,
|
|
52
48
|
variant: "tertiary",
|
|
53
49
|
size: "compact"
|
|
54
|
-
},
|
|
50
|
+
}, createElement(Icon, {
|
|
51
|
+
icon: plus,
|
|
52
|
+
style: {
|
|
53
|
+
flexShrink: 0
|
|
54
|
+
}
|
|
55
|
+
}), __('Add filter'))
|
|
55
56
|
}, filters.map(filter => {
|
|
56
57
|
if (filter.isVisible) {
|
|
57
58
|
return null;
|
|
58
59
|
}
|
|
59
|
-
return createElement(
|
|
60
|
+
return createElement(DropdownSubMenu, {
|
|
60
61
|
key: filter.field,
|
|
61
|
-
trigger: createElement(
|
|
62
|
+
trigger: createElement(DropdownSubMenuTrigger, {
|
|
62
63
|
suffix: createElement(Icon, {
|
|
63
64
|
icon: chevronRightSmall
|
|
64
65
|
})
|
|
65
66
|
}, filter.name)
|
|
66
|
-
}, filter.elements.map(element => createElement(
|
|
67
|
+
}, filter.elements.map(element => createElement(DropdownMenuItem, {
|
|
67
68
|
key: element.value,
|
|
68
69
|
onSelect: () => {
|
|
69
70
|
onChangeView(currentView => ({
|
|
@@ -71,7 +72,7 @@ export default function AddFilter({
|
|
|
71
72
|
page: 1,
|
|
72
73
|
filters: [...currentView.filters, {
|
|
73
74
|
field: filter.field,
|
|
74
|
-
operator:
|
|
75
|
+
operator: OPERATOR_IN,
|
|
75
76
|
value: element.value
|
|
76
77
|
}]
|
|
77
78
|
}));
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["privateApis","componentsPrivateApis","Button","Icon","chevronRightSmall","plus","__","unlock","OPERATOR_IN","DropdownMenuV2","DropdownSubMenuV2","DropdownSubMenuTriggerV2","DropdownMenuItemV2","
|
|
1
|
+
{"version":3,"names":["privateApis","componentsPrivateApis","Button","Icon","chevronRightSmall","plus","__","unlock","ENUMERATION_TYPE","OPERATOR_IN","DropdownMenuV2","DropdownMenu","DropdownSubMenuV2","DropdownSubMenu","DropdownSubMenuTriggerV2","DropdownSubMenuTrigger","DropdownMenuItemV2","DropdownMenuItem","AddFilter","fields","view","onChangeView","filters","forEach","field","type","push","id","name","header","elements","isVisible","some","f","operator","length","createElement","label","trigger","disabled","__experimentalIsFocusable","variant","size","icon","style","flexShrink","map","filter","key","suffix","element","value","onSelect","currentView","page","role"],"sources":["@wordpress/edit-site/src/components/dataviews/add-filter.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport {\n\tprivateApis as componentsPrivateApis,\n\tButton,\n\tIcon,\n} from '@wordpress/components';\nimport { chevronRightSmall, plus } from '@wordpress/icons';\nimport { __ } from '@wordpress/i18n';\n\n/**\n * Internal dependencies\n */\nimport { unlock } from '../../lock-unlock';\nimport { ENUMERATION_TYPE, OPERATOR_IN } from './constants';\n\nconst {\n\tDropdownMenuV2: DropdownMenu,\n\tDropdownSubMenuV2: DropdownSubMenu,\n\tDropdownSubMenuTriggerV2: DropdownSubMenuTrigger,\n\tDropdownMenuItemV2: DropdownMenuItem,\n} = unlock( componentsPrivateApis );\n\nexport default function AddFilter( { fields, view, onChangeView } ) {\n\tconst filters = [];\n\tfields.forEach( ( field ) => {\n\t\tif ( ! field.type ) {\n\t\t\treturn;\n\t\t}\n\n\t\tswitch ( field.type ) {\n\t\t\tcase ENUMERATION_TYPE:\n\t\t\t\tfilters.push( {\n\t\t\t\t\tfield: field.id,\n\t\t\t\t\tname: field.header,\n\t\t\t\t\telements: field.elements || [],\n\t\t\t\t\tisVisible: view.filters.some(\n\t\t\t\t\t\t( f ) =>\n\t\t\t\t\t\t\tf.field === field.id && f.operator === OPERATOR_IN\n\t\t\t\t\t),\n\t\t\t\t} );\n\t\t}\n\t} );\n\n\tif ( filters.length === 0 ) {\n\t\treturn null;\n\t}\n\n\treturn (\n\t\t<DropdownMenu\n\t\t\tlabel={ __( 'Add filter' ) }\n\t\t\ttrigger={\n\t\t\t\t<Button\n\t\t\t\t\tdisabled={ filters.length === view.filters?.length }\n\t\t\t\t\t__experimentalIsFocusable\n\t\t\t\t\tvariant=\"tertiary\"\n\t\t\t\t\tsize=\"compact\"\n\t\t\t\t>\n\t\t\t\t\t<Icon icon={ plus } style={ { flexShrink: 0 } } />\n\t\t\t\t\t{ __( 'Add filter' ) }\n\t\t\t\t</Button>\n\t\t\t}\n\t\t>\n\t\t\t{ filters.map( ( filter ) => {\n\t\t\t\tif ( filter.isVisible ) {\n\t\t\t\t\treturn null;\n\t\t\t\t}\n\n\t\t\t\treturn (\n\t\t\t\t\t<DropdownSubMenu\n\t\t\t\t\t\tkey={ filter.field }\n\t\t\t\t\t\ttrigger={\n\t\t\t\t\t\t\t<DropdownSubMenuTrigger\n\t\t\t\t\t\t\t\tsuffix={ <Icon icon={ chevronRightSmall } /> }\n\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t{ filter.name }\n\t\t\t\t\t\t\t</DropdownSubMenuTrigger>\n\t\t\t\t\t\t}\n\t\t\t\t\t>\n\t\t\t\t\t\t{ filter.elements.map( ( element ) => (\n\t\t\t\t\t\t\t<DropdownMenuItem\n\t\t\t\t\t\t\t\tkey={ element.value }\n\t\t\t\t\t\t\t\tonSelect={ () => {\n\t\t\t\t\t\t\t\t\tonChangeView( ( currentView ) => ( {\n\t\t\t\t\t\t\t\t\t\t...currentView,\n\t\t\t\t\t\t\t\t\t\tpage: 1,\n\t\t\t\t\t\t\t\t\t\tfilters: [\n\t\t\t\t\t\t\t\t\t\t\t...currentView.filters,\n\t\t\t\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\t\t\t\tfield: filter.field,\n\t\t\t\t\t\t\t\t\t\t\t\toperator: OPERATOR_IN,\n\t\t\t\t\t\t\t\t\t\t\t\tvalue: element.value,\n\t\t\t\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t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,WAAW,CAAC/B,OAAO,EACtB;YACCE,KAAK,EAAEuB,MAAM,CAACvB,KAAK;YACnBU,QAAQ,EAAEzB,WAAW;YACrB0C,KAAK,EAAED,OAAO,CAACC;UAChB,CAAC;QAEH,CAAC,CAAG,CAAC;MACN,CAAG;MACHI,IAAI,EAAC;IAAkB,GAErBL,OAAO,CAACb,KACO,CACjB,CACc,CAAC;EAEpB,CAAE,CACW,CAAC;AAEjB"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["ENUMERATION_TYPE","OPERATOR_IN"],"sources":["@wordpress/edit-site/src/components/dataviews/constants.js"],"sourcesContent":["// Field types.\nexport const ENUMERATION_TYPE = 'enumeration';\n\n// Filter operators.\nexport const OPERATOR_IN = 'in';\n"],"mappings":"AAAA;AACA,OAAO,MAAMA,gBAAgB,GAAG,aAAa;;AAE7C;AACA,OAAO,MAAMC,WAAW,GAAG,IAAI"}
|
|
@@ -37,6 +37,7 @@ export default function DataViews({
|
|
|
37
37
|
searchLabel = undefined,
|
|
38
38
|
actions,
|
|
39
39
|
data,
|
|
40
|
+
getItemId,
|
|
40
41
|
isLoading = false,
|
|
41
42
|
paginationInfo,
|
|
42
43
|
supportedLayouts
|
|
@@ -53,8 +54,11 @@ export default function DataViews({
|
|
|
53
54
|
}, createElement(VStack, {
|
|
54
55
|
spacing: 4,
|
|
55
56
|
justify: "flex-start"
|
|
56
|
-
}, createElement(HStack,
|
|
57
|
-
|
|
57
|
+
}, createElement(HStack, {
|
|
58
|
+
alignment: "flex-start"
|
|
59
|
+
}, createElement(HStack, {
|
|
60
|
+
justify: "start",
|
|
61
|
+
wrap: true
|
|
58
62
|
}, search && createElement(Search, {
|
|
59
63
|
label: searchLabel,
|
|
60
64
|
view: view,
|
|
@@ -63,21 +67,19 @@ export default function DataViews({
|
|
|
63
67
|
fields: fields,
|
|
64
68
|
view: view,
|
|
65
69
|
onChangeView: onChangeView
|
|
66
|
-
})), createElement(
|
|
67
|
-
justify: "end",
|
|
68
|
-
expanded: false
|
|
69
|
-
}, createElement(ViewActions, {
|
|
70
|
+
})), createElement(ViewActions, {
|
|
70
71
|
fields: fields,
|
|
71
72
|
view: view,
|
|
72
73
|
onChangeView: onChangeView,
|
|
73
74
|
supportedLayouts: supportedLayouts
|
|
74
|
-
}))
|
|
75
|
+
})), createElement(ViewComponent, {
|
|
75
76
|
fields: _fields,
|
|
76
77
|
view: view,
|
|
77
78
|
onChangeView: onChangeView,
|
|
78
79
|
paginationInfo: paginationInfo,
|
|
79
80
|
actions: actions,
|
|
80
81
|
data: data,
|
|
82
|
+
getItemId: getItemId,
|
|
81
83
|
isLoading: isLoading
|
|
82
84
|
}), createElement(Pagination, {
|
|
83
85
|
view: view,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["__experimentalVStack","VStack","__experimentalHStack","HStack","useMemo","ViewList","Pagination","ViewActions","Filters","Search","ViewGrid","ViewSideBySide","viewTypeSupportsMap","list","grid","preview","viewTypeMap","DataViews","view","onChangeView","fields","search","searchLabel","undefined","actions","data","isLoading","paginationInfo","supportedLayouts","ViewComponent","type","_fields","map","field","render","getValue","createElement","className","spacing","justify","
|
|
1
|
+
{"version":3,"names":["__experimentalVStack","VStack","__experimentalHStack","HStack","useMemo","ViewList","Pagination","ViewActions","Filters","Search","ViewGrid","ViewSideBySide","viewTypeSupportsMap","list","grid","preview","viewTypeMap","DataViews","view","onChangeView","fields","search","searchLabel","undefined","actions","data","getItemId","isLoading","paginationInfo","supportedLayouts","ViewComponent","type","_fields","map","field","render","getValue","createElement","className","spacing","justify","alignment","wrap","label"],"sources":["@wordpress/edit-site/src/components/dataviews/dataviews.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport {\n\t__experimentalVStack as VStack,\n\t__experimentalHStack as HStack,\n} from '@wordpress/components';\nimport { useMemo } from '@wordpress/element';\n\n/**\n * Internal dependencies\n */\nimport ViewList from './view-list';\nimport Pagination from './pagination';\nimport ViewActions from './view-actions';\nimport Filters from './filters';\nimport Search from './search';\nimport { ViewGrid } from './view-grid';\nimport { ViewSideBySide } from './view-side-by-side';\n\n// To do: convert to view type registry.\nexport const viewTypeSupportsMap = {\n\tlist: {},\n\tgrid: {},\n\t'side-by-side': {\n\t\tpreview: true,\n\t},\n};\n\nconst viewTypeMap = {\n\tlist: ViewList,\n\tgrid: ViewGrid,\n\t'side-by-side': ViewSideBySide,\n};\n\nexport default function DataViews( {\n\tview,\n\tonChangeView,\n\tfields,\n\tsearch = true,\n\tsearchLabel = undefined,\n\tactions,\n\tdata,\n\tgetItemId,\n\tisLoading = false,\n\tpaginationInfo,\n\tsupportedLayouts,\n} ) {\n\tconst ViewComponent = viewTypeMap[ view.type ];\n\tconst _fields = useMemo( () => {\n\t\treturn fields.map( ( field ) => ( {\n\t\t\t...field,\n\t\t\trender: field.render || field.getValue,\n\t\t} ) );\n\t}, [ fields ] );\n\treturn (\n\t\t<div className=\"dataviews-wrapper\">\n\t\t\t<VStack spacing={ 4 } justify=\"flex-start\">\n\t\t\t\t<HStack alignment=\"flex-start\">\n\t\t\t\t\t<HStack justify=\"start\" wrap>\n\t\t\t\t\t\t{ search && (\n\t\t\t\t\t\t\t<Search\n\t\t\t\t\t\t\t\tlabel={ searchLabel }\n\t\t\t\t\t\t\t\tview={ view }\n\t\t\t\t\t\t\t\tonChangeView={ onChangeView }\n\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t) }\n\t\t\t\t\t\t<Filters\n\t\t\t\t\t\t\tfields={ fields }\n\t\t\t\t\t\t\tview={ view }\n\t\t\t\t\t\t\tonChangeView={ onChangeView }\n\t\t\t\t\t\t/>\n\t\t\t\t\t</HStack>\n\t\t\t\t\t<ViewActions\n\t\t\t\t\t\tfields={ fields }\n\t\t\t\t\t\tview={ view }\n\t\t\t\t\t\tonChangeView={ onChangeView }\n\t\t\t\t\t\tsupportedLayouts={ supportedLayouts }\n\t\t\t\t\t/>\n\t\t\t\t</HStack>\n\t\t\t\t<ViewComponent\n\t\t\t\t\tfields={ _fields }\n\t\t\t\t\tview={ view }\n\t\t\t\t\tonChangeView={ onChangeView }\n\t\t\t\t\tpaginationInfo={ paginationInfo }\n\t\t\t\t\tactions={ actions }\n\t\t\t\t\tdata={ data }\n\t\t\t\t\tgetItemId={ getItemId }\n\t\t\t\t\tisLoading={ isLoading }\n\t\t\t\t/>\n\t\t\t\t<Pagination\n\t\t\t\t\tview={ view }\n\t\t\t\t\tonChangeView={ onChangeView }\n\t\t\t\t\tpaginationInfo={ paginationInfo }\n\t\t\t\t/>\n\t\t\t</VStack>\n\t\t</div>\n\t);\n}\n"],"mappings":";AAAA;AACA;AACA;AACA,SACCA,oBAAoB,IAAIC,MAAM,EAC9BC,oBAAoB,IAAIC,MAAM,QACxB,uBAAuB;AAC9B,SAASC,OAAO,QAAQ,oBAAoB;;AAE5C;AACA;AACA;AACA,OAAOC,QAAQ,MAAM,aAAa;AAClC,OAAOC,UAAU,MAAM,cAAc;AACrC,OAAOC,WAAW,MAAM,gBAAgB;AACxC,OAAOC,OAAO,MAAM,WAAW;AAC/B,OAAOC,MAAM,MAAM,UAAU;AAC7B,SAASC,QAAQ,QAAQ,aAAa;AACtC,SAASC,cAAc,QAAQ,qBAAqB;;AAEpD;AACA,OAAO,MAAMC,mBAAmB,GAAG;EAClCC,IAAI,EAAE,CAAC,CAAC;EACRC,IAAI,EAAE,CAAC,CAAC;EACR,cAAc,EAAE;IACfC,OAAO,EAAE;EACV;AACD,CAAC;AAED,MAAMC,WAAW,GAAG;EACnBH,IAAI,EAAER,QAAQ;EACdS,IAAI,EAAEJ,QAAQ;EACd,cAAc,EAAEC;AACjB,CAAC;AAED,eAAe,SAASM,SAASA,CAAE;EAClCC,IAAI;EACJC,YAAY;EACZC,MAAM;EACNC,MAAM,GAAG,IAAI;EACbC,WAAW,GAAGC,SAAS;EACvBC,OAAO;EACPC,IAAI;EACJC,SAAS;EACTC,SAAS,GAAG,KAAK;EACjBC,cAAc;EACdC;AACD,CAAC,EAAG;EACH,MA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