@wordpress/edit-site 5.26.0 → 5.27.1
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 +139 -36
- package/build/components/actions/index.js.map +1 -1
- package/build/components/editor-canvas-container/index.js +1 -1
- package/build/components/editor-canvas-container/index.js.map +1 -1
- package/build/components/global-styles/font-families.js +3 -2
- package/build/components/global-styles/font-families.js.map +1 -1
- package/build/components/global-styles/font-family-item.js +3 -4
- package/build/components/global-styles/font-family-item.js.map +1 -1
- package/build/components/global-styles/font-library-modal/context.js +80 -41
- package/build/components/global-styles/font-library-modal/context.js.map +1 -1
- package/build/components/global-styles/font-library-modal/font-collection.js +49 -22
- package/build/components/global-styles/font-library-modal/font-collection.js.map +1 -1
- package/build/components/global-styles/font-library-modal/fonts-grid.js +4 -1
- package/build/components/global-styles/font-library-modal/fonts-grid.js.map +1 -1
- package/build/components/global-styles/font-library-modal/index.js +4 -4
- package/build/components/global-styles/font-library-modal/index.js.map +1 -1
- package/build/components/global-styles/font-library-modal/installed-fonts.js +16 -8
- package/build/components/global-styles/font-library-modal/installed-fonts.js.map +1 -1
- package/build/components/global-styles/font-library-modal/library-font-card.js +1 -1
- package/build/components/global-styles/font-library-modal/library-font-card.js.map +1 -1
- package/build/components/global-styles/font-library-modal/library-font-variant.js +2 -2
- package/build/components/global-styles/font-library-modal/library-font-variant.js.map +1 -1
- package/build/components/global-styles/font-library-modal/local-fonts.js +13 -4
- package/build/components/global-styles/font-library-modal/local-fonts.js.map +1 -1
- package/build/components/global-styles/font-library-modal/resolvers.js +49 -20
- package/build/components/global-styles/font-library-modal/resolvers.js.map +1 -1
- package/build/components/global-styles/font-library-modal/tab-panel-layout.js +6 -2
- package/build/components/global-styles/font-library-modal/tab-panel-layout.js.map +1 -1
- package/build/components/global-styles/font-library-modal/utils/filter-fonts.js +17 -2
- package/build/components/global-styles/font-library-modal/utils/filter-fonts.js.map +1 -1
- package/build/components/global-styles/font-library-modal/utils/index.js +103 -17
- package/build/components/global-styles/font-library-modal/utils/index.js.map +1 -1
- package/build/components/global-styles/font-library-modal/utils/preview-styles.js +4 -3
- package/build/components/global-styles/font-library-modal/utils/preview-styles.js.map +1 -1
- package/build/components/global-styles/screen-block.js +10 -0
- package/build/components/global-styles/screen-block.js.map +1 -1
- package/build/components/global-styles/screen-typography.js +4 -1
- package/build/components/global-styles/screen-typography.js.map +1 -1
- package/build/components/layout/hooks.js +6 -5
- package/build/components/layout/hooks.js.map +1 -1
- package/build/components/layout/index.js +19 -28
- package/build/components/layout/index.js.map +1 -1
- package/build/components/layout/router.js +135 -0
- package/build/components/layout/router.js.map +1 -0
- package/build/components/page-pages/index.js +92 -69
- package/build/components/page-pages/index.js.map +1 -1
- package/build/components/page-patterns/dataviews-pattern-actions.js +11 -6
- package/build/components/page-patterns/dataviews-pattern-actions.js.map +1 -1
- package/build/components/page-patterns/index.js +295 -15
- package/build/components/page-patterns/index.js.map +1 -1
- package/build/components/{page-templates/template-actions.js → page-templates-template-parts/actions.js} +51 -23
- package/build/components/page-templates-template-parts/actions.js.map +1 -0
- package/build/components/page-templates-template-parts/add-new-template-part.js.map +1 -0
- package/build/components/page-templates-template-parts/index.js +395 -0
- package/build/components/page-templates-template-parts/index.js.map +1 -0
- package/build/components/preferences-modal/index.js +9 -134
- package/build/components/preferences-modal/index.js.map +1 -1
- package/build/components/revisions/index.js +1 -1
- package/build/components/revisions/index.js.map +1 -1
- package/build/components/save-button/index.js +4 -2
- package/build/components/save-button/index.js.map +1 -1
- package/build/components/save-panel/index.js +6 -5
- package/build/components/save-panel/index.js.map +1 -1
- package/build/components/sidebar/index.js +3 -1
- package/build/components/sidebar/index.js.map +1 -1
- package/build/components/sidebar-dataviews/dataview-item.js +3 -1
- package/build/components/sidebar-dataviews/dataview-item.js.map +1 -1
- package/build/components/sidebar-dataviews/default-views.js +4 -2
- package/build/components/sidebar-dataviews/default-views.js.map +1 -1
- package/build/components/sidebar-dataviews/index.js +2 -2
- package/build/components/sidebar-dataviews/index.js.map +1 -1
- package/build/components/sidebar-navigation-screen/index.js +8 -7
- package/build/components/sidebar-navigation-screen/index.js.map +1 -1
- package/build/components/sidebar-navigation-screen-pages/index.js +2 -10
- package/build/components/sidebar-navigation-screen-pages/index.js.map +1 -1
- package/build/components/sidebar-navigation-screen-pages-dataviews/index.js +26 -3
- package/build/components/sidebar-navigation-screen-pages-dataviews/index.js.map +1 -1
- package/build/components/sidebar-navigation-screen-templates/index.js +63 -8
- package/build/components/sidebar-navigation-screen-templates/index.js.map +1 -1
- package/build/components/sidebar-navigation-screen-templates-browse/content.js +76 -0
- package/build/components/sidebar-navigation-screen-templates-browse/content.js.map +1 -0
- package/build/components/sidebar-navigation-screen-templates-browse/index.js +9 -2
- package/build/components/sidebar-navigation-screen-templates-browse/index.js.map +1 -1
- package/build/components/site-hub/index.js +3 -1
- package/build/components/site-hub/index.js.map +1 -1
- package/build/components/sync-state-with-url/use-init-edited-entity-from-url.js +47 -12
- package/build/components/sync-state-with-url/use-init-edited-entity-from-url.js.map +1 -1
- package/build/components/sync-state-with-url/use-sync-path-with-url.js +25 -2
- package/build/components/sync-state-with-url/use-sync-path-with-url.js.map +1 -1
- package/build/hooks/commands/use-edit-mode-commands.js +33 -5
- package/build/hooks/commands/use-edit-mode-commands.js.map +1 -1
- package/build/hooks/push-changes-to-global-styles/index.js +13 -6
- package/build/hooks/push-changes-to-global-styles/index.js.map +1 -1
- package/build/hooks/template-part-edit.js +7 -6
- package/build/hooks/template-part-edit.js.map +1 -1
- package/build/index.js +1 -1
- package/build/index.js.map +1 -1
- package/build/store/actions.js +11 -29
- package/build/store/actions.js.map +1 -1
- package/build/store/private-actions.js +85 -1
- package/build/store/private-actions.js.map +1 -1
- package/build/store/selectors.js +2 -2
- package/build/store/selectors.js.map +1 -1
- package/build/utils/get-is-list-page.js +1 -1
- package/build/utils/get-is-list-page.js.map +1 -1
- package/build/utils/use-actual-current-theme.js +32 -0
- package/build/utils/use-actual-current-theme.js.map +1 -0
- package/build-module/components/actions/index.js +139 -36
- package/build-module/components/actions/index.js.map +1 -1
- package/build-module/components/editor-canvas-container/index.js +1 -1
- package/build-module/components/editor-canvas-container/index.js.map +1 -1
- package/build-module/components/global-styles/font-families.js +3 -2
- package/build-module/components/global-styles/font-families.js.map +1 -1
- package/build-module/components/global-styles/font-family-item.js +4 -5
- package/build-module/components/global-styles/font-family-item.js.map +1 -1
- package/build-module/components/global-styles/font-library-modal/context.js +82 -42
- package/build-module/components/global-styles/font-library-modal/context.js.map +1 -1
- package/build-module/components/global-styles/font-library-modal/font-collection.js +49 -22
- package/build-module/components/global-styles/font-library-modal/font-collection.js.map +1 -1
- package/build-module/components/global-styles/font-library-modal/fonts-grid.js +4 -1
- package/build-module/components/global-styles/font-library-modal/fonts-grid.js.map +1 -1
- package/build-module/components/global-styles/font-library-modal/index.js +4 -4
- package/build-module/components/global-styles/font-library-modal/index.js.map +1 -1
- package/build-module/components/global-styles/font-library-modal/installed-fonts.js +16 -8
- package/build-module/components/global-styles/font-library-modal/installed-fonts.js.map +1 -1
- package/build-module/components/global-styles/font-library-modal/library-font-card.js +1 -1
- package/build-module/components/global-styles/font-library-modal/library-font-card.js.map +1 -1
- package/build-module/components/global-styles/font-library-modal/library-font-variant.js +2 -2
- package/build-module/components/global-styles/font-library-modal/library-font-variant.js.map +1 -1
- package/build-module/components/global-styles/font-library-modal/local-fonts.js +13 -4
- package/build-module/components/global-styles/font-library-modal/local-fonts.js.map +1 -1
- package/build-module/components/global-styles/font-library-modal/resolvers.js +45 -18
- package/build-module/components/global-styles/font-library-modal/resolvers.js.map +1 -1
- package/build-module/components/global-styles/font-library-modal/tab-panel-layout.js +6 -2
- package/build-module/components/global-styles/font-library-modal/tab-panel-layout.js.map +1 -1
- package/build-module/components/global-styles/font-library-modal/utils/filter-fonts.js +17 -2
- package/build-module/components/global-styles/font-library-modal/utils/filter-fonts.js.map +1 -1
- package/build-module/components/global-styles/font-library-modal/utils/index.js +99 -16
- package/build-module/components/global-styles/font-library-modal/utils/index.js.map +1 -1
- package/build-module/components/global-styles/font-library-modal/utils/preview-styles.js +4 -3
- package/build-module/components/global-styles/font-library-modal/utils/preview-styles.js.map +1 -1
- package/build-module/components/global-styles/screen-block.js +10 -0
- package/build-module/components/global-styles/screen-block.js.map +1 -1
- package/build-module/components/global-styles/screen-typography.js +4 -1
- package/build-module/components/global-styles/screen-typography.js.map +1 -1
- package/build-module/components/layout/hooks.js +6 -5
- package/build-module/components/layout/hooks.js.map +1 -1
- package/build-module/components/layout/index.js +19 -28
- package/build-module/components/layout/index.js.map +1 -1
- package/build-module/components/layout/router.js +127 -0
- package/build-module/components/layout/router.js.map +1 -0
- package/build-module/components/page-pages/index.js +91 -70
- package/build-module/components/page-pages/index.js.map +1 -1
- package/build-module/components/page-patterns/dataviews-pattern-actions.js +11 -6
- package/build-module/components/page-patterns/dataviews-pattern-actions.js.map +1 -1
- package/build-module/components/page-patterns/index.js +296 -16
- package/build-module/components/page-patterns/index.js.map +1 -1
- package/build-module/components/{page-templates/template-actions.js → page-templates-template-parts/actions.js} +52 -24
- package/build-module/components/page-templates-template-parts/actions.js.map +1 -0
- package/build-module/components/page-templates-template-parts/add-new-template-part.js.map +1 -0
- package/build-module/components/page-templates-template-parts/index.js +385 -0
- package/build-module/components/page-templates-template-parts/index.js.map +1 -0
- package/build-module/components/preferences-modal/index.js +12 -136
- package/build-module/components/preferences-modal/index.js.map +1 -1
- package/build-module/components/revisions/index.js +1 -1
- package/build-module/components/revisions/index.js.map +1 -1
- package/build-module/components/save-button/index.js +4 -2
- package/build-module/components/save-button/index.js.map +1 -1
- package/build-module/components/save-panel/index.js +7 -6
- package/build-module/components/save-panel/index.js.map +1 -1
- package/build-module/components/sidebar/index.js +3 -1
- package/build-module/components/sidebar/index.js.map +1 -1
- package/build-module/components/sidebar-dataviews/dataview-item.js +3 -1
- package/build-module/components/sidebar-dataviews/dataview-item.js.map +1 -1
- package/build-module/components/sidebar-dataviews/default-views.js +4 -2
- package/build-module/components/sidebar-dataviews/default-views.js.map +1 -1
- package/build-module/components/sidebar-dataviews/index.js +2 -2
- package/build-module/components/sidebar-dataviews/index.js.map +1 -1
- package/build-module/components/sidebar-navigation-screen/index.js +8 -7
- package/build-module/components/sidebar-navigation-screen/index.js.map +1 -1
- package/build-module/components/sidebar-navigation-screen-pages/index.js +2 -10
- package/build-module/components/sidebar-navigation-screen-pages/index.js.map +1 -1
- package/build-module/components/sidebar-navigation-screen-pages-dataviews/index.js +27 -4
- package/build-module/components/sidebar-navigation-screen-pages-dataviews/index.js.map +1 -1
- package/build-module/components/sidebar-navigation-screen-templates/index.js +64 -9
- package/build-module/components/sidebar-navigation-screen-templates/index.js.map +1 -1
- package/build-module/components/sidebar-navigation-screen-templates-browse/content.js +68 -0
- package/build-module/components/sidebar-navigation-screen-templates-browse/content.js.map +1 -0
- package/build-module/components/sidebar-navigation-screen-templates-browse/index.js +9 -2
- package/build-module/components/sidebar-navigation-screen-templates-browse/index.js.map +1 -1
- package/build-module/components/site-hub/index.js +3 -1
- package/build-module/components/site-hub/index.js.map +1 -1
- package/build-module/components/sync-state-with-url/use-init-edited-entity-from-url.js +47 -11
- package/build-module/components/sync-state-with-url/use-init-edited-entity-from-url.js.map +1 -1
- package/build-module/components/sync-state-with-url/use-sync-path-with-url.js +25 -2
- package/build-module/components/sync-state-with-url/use-sync-path-with-url.js.map +1 -1
- package/build-module/hooks/commands/use-edit-mode-commands.js +33 -5
- package/build-module/hooks/commands/use-edit-mode-commands.js.map +1 -1
- package/build-module/hooks/push-changes-to-global-styles/index.js +13 -6
- package/build-module/hooks/push-changes-to-global-styles/index.js.map +1 -1
- package/build-module/hooks/template-part-edit.js +7 -6
- package/build-module/hooks/template-part-edit.js.map +1 -1
- package/build-module/index.js +1 -1
- package/build-module/index.js.map +1 -1
- package/build-module/store/actions.js +13 -30
- package/build-module/store/actions.js.map +1 -1
- package/build-module/store/private-actions.js +83 -0
- package/build-module/store/private-actions.js.map +1 -1
- package/build-module/store/selectors.js +2 -2
- package/build-module/store/selectors.js.map +1 -1
- package/build-module/utils/get-is-list-page.js +1 -1
- package/build-module/utils/get-is-list-page.js.map +1 -1
- package/build-module/utils/use-actual-current-theme.js +24 -0
- package/build-module/utils/use-actual-current-theme.js.map +1 -0
- package/build-style/style-rtl.css +316 -215
- package/build-style/style.css +316 -215
- package/package.json +42 -42
- package/src/components/actions/index.js +236 -84
- package/src/components/editor-canvas-container/index.js +1 -1
- package/src/components/global-styles/font-families.js +14 -8
- package/src/components/global-styles/font-family-item.js +7 -4
- package/src/components/global-styles/font-library-modal/context.js +156 -50
- package/src/components/global-styles/font-library-modal/font-collection.js +56 -21
- package/src/components/global-styles/font-library-modal/fonts-grid.js +6 -2
- package/src/components/global-styles/font-library-modal/index.js +4 -4
- package/src/components/global-styles/font-library-modal/installed-fonts.js +18 -8
- package/src/components/global-styles/font-library-modal/library-font-card.js +2 -1
- package/src/components/global-styles/font-library-modal/library-font-variant.js +10 -9
- package/src/components/global-styles/font-library-modal/local-fonts.js +14 -4
- package/src/components/global-styles/font-library-modal/resolvers.js +50 -17
- package/src/components/global-styles/font-library-modal/style.scss +23 -35
- package/src/components/global-styles/font-library-modal/tab-panel-layout.js +30 -26
- package/src/components/global-styles/font-library-modal/utils/filter-fonts.js +19 -2
- package/src/components/global-styles/font-library-modal/utils/index.js +136 -29
- package/src/components/global-styles/font-library-modal/utils/preview-styles.js +7 -3
- package/src/components/global-styles/font-library-modal/utils/test/filter-fonts.spec.js +40 -10
- package/src/components/global-styles/font-library-modal/utils/test/preview-styles.spec.js +5 -5
- package/src/components/global-styles/screen-block.js +10 -0
- package/src/components/global-styles/screen-typography.js +9 -3
- package/src/components/global-styles/style.scss +4 -0
- package/src/components/header-edit-mode/style.scss +15 -5
- package/src/components/layout/hooks.js +6 -5
- package/src/components/layout/index.js +80 -96
- package/src/components/layout/router.js +121 -0
- package/src/components/layout/style.scss +13 -16
- package/src/components/page/style.scss +1 -8
- package/src/components/page-pages/index.js +142 -148
- package/src/components/page-pages/style.scss +41 -2
- package/src/components/page-patterns/dataviews-pattern-actions.js +11 -6
- package/src/components/page-patterns/index.js +392 -14
- package/src/components/page-patterns/style.scss +36 -2
- package/src/components/{page-templates/template-actions.js → page-templates-template-parts/actions.js} +90 -37
- package/src/components/{page-templates → page-templates-template-parts}/index.js +198 -169
- package/src/components/page-templates-template-parts/style.scss +44 -0
- package/src/components/preferences-modal/index.js +8 -211
- package/src/components/revisions/index.js +1 -1
- package/src/components/save-button/index.js +7 -4
- package/src/components/save-panel/index.js +13 -12
- package/src/components/sidebar/index.js +4 -5
- package/src/components/sidebar-dataviews/dataview-item.js +2 -1
- package/src/components/sidebar-dataviews/default-views.js +4 -2
- package/src/components/sidebar-dataviews/index.js +8 -6
- package/src/components/sidebar-navigation-item/style.scss +1 -1
- package/src/components/sidebar-navigation-screen/index.js +19 -10
- package/src/components/sidebar-navigation-screen-pages/index.js +2 -10
- package/src/components/sidebar-navigation-screen-pages-dataviews/index.js +32 -6
- package/src/components/sidebar-navigation-screen-templates/index.js +85 -28
- package/src/components/sidebar-navigation-screen-templates/style.scss +9 -0
- package/src/components/sidebar-navigation-screen-templates-browse/content.js +73 -0
- package/src/components/sidebar-navigation-screen-templates-browse/index.js +10 -1
- package/src/components/site-hub/index.js +4 -1
- package/src/components/site-hub/style.scss +1 -12
- package/src/components/site-icon/style.scss +1 -1
- package/src/components/sync-state-with-url/use-init-edited-entity-from-url.js +40 -10
- package/src/components/sync-state-with-url/use-sync-path-with-url.js +32 -0
- package/src/hooks/commands/use-edit-mode-commands.js +50 -3
- package/src/hooks/push-changes-to-global-styles/index.js +29 -23
- package/src/hooks/template-part-edit.js +12 -12
- package/src/index.js +1 -1
- package/src/store/actions.js +17 -51
- package/src/store/private-actions.js +133 -0
- package/src/store/selectors.js +2 -4
- package/src/style.scss +2 -1
- package/src/utils/get-is-list-page.js +3 -2
- package/src/utils/use-actual-current-theme.js +27 -0
- package/build/components/global-styles/font-library-modal/utils/get-intersecting-font-faces.js +0 -58
- package/build/components/global-styles/font-library-modal/utils/get-intersecting-font-faces.js.map +0 -1
- package/build/components/global-styles/font-library-modal/utils/get-notice-from-response.js +0 -71
- package/build/components/global-styles/font-library-modal/utils/get-notice-from-response.js.map +0 -1
- package/build/components/page-main/index.js +0 -44
- package/build/components/page-main/index.js.map +0 -1
- package/build/components/page-patterns/dataviews-patterns.js +0 -307
- package/build/components/page-patterns/dataviews-patterns.js.map +0 -1
- package/build/components/page-template-parts/add-new-template-part.js.map +0 -1
- package/build/components/page-template-parts/index.js +0 -81
- package/build/components/page-template-parts/index.js.map +0 -1
- package/build/components/page-templates/index.js +0 -352
- package/build/components/page-templates/index.js.map +0 -1
- package/build/components/page-templates/template-actions.js.map +0 -1
- package/build/components/post-preview/index.js +0 -29
- package/build/components/post-preview/index.js.map +0 -1
- package/build/components/preferences-modal/enable-feature.js +0 -36
- package/build/components/preferences-modal/enable-feature.js.map +0 -1
- package/build/components/preferences-modal/enable-panel-option.js +0 -33
- package/build/components/preferences-modal/enable-panel-option.js.map +0 -1
- package/build-module/components/global-styles/font-library-modal/utils/get-intersecting-font-faces.js +0 -52
- package/build-module/components/global-styles/font-library-modal/utils/get-intersecting-font-faces.js.map +0 -1
- package/build-module/components/global-styles/font-library-modal/utils/get-notice-from-response.js +0 -63
- package/build-module/components/global-styles/font-library-modal/utils/get-notice-from-response.js.map +0 -1
- package/build-module/components/page-main/index.js +0 -36
- package/build-module/components/page-main/index.js.map +0 -1
- package/build-module/components/page-patterns/dataviews-patterns.js +0 -299
- package/build-module/components/page-patterns/dataviews-patterns.js.map +0 -1
- package/build-module/components/page-template-parts/add-new-template-part.js.map +0 -1
- package/build-module/components/page-template-parts/index.js +0 -73
- package/build-module/components/page-template-parts/index.js.map +0 -1
- package/build-module/components/page-templates/index.js +0 -344
- package/build-module/components/page-templates/index.js.map +0 -1
- package/build-module/components/page-templates/template-actions.js.map +0 -1
- package/build-module/components/post-preview/index.js +0 -21
- package/build-module/components/post-preview/index.js.map +0 -1
- package/build-module/components/preferences-modal/enable-feature.js +0 -29
- package/build-module/components/preferences-modal/enable-feature.js.map +0 -1
- package/build-module/components/preferences-modal/enable-panel-option.js +0 -26
- package/build-module/components/preferences-modal/enable-panel-option.js.map +0 -1
- package/src/components/global-styles/font-library-modal/utils/get-intersecting-font-faces.js +0 -58
- package/src/components/global-styles/font-library-modal/utils/get-notice-from-response.js +0 -62
- package/src/components/global-styles/font-library-modal/utils/test/getIntersectingFontFaces.spec.js +0 -271
- package/src/components/global-styles/font-library-modal/utils/test/makeFormDataFromFontFamily.spec.js +0 -58
- package/src/components/page-main/index.js +0 -38
- package/src/components/page-patterns/dataviews-patterns.js +0 -380
- package/src/components/page-template-parts/index.js +0 -99
- package/src/components/page-templates/style.scss +0 -13
- package/src/components/post-preview/index.js +0 -16
- package/src/components/preferences-modal/enable-feature.js +0 -31
- package/src/components/preferences-modal/enable-panel-option.js +0 -23
- /package/build/components/{page-template-parts → page-templates-template-parts}/add-new-template-part.js +0 -0
- /package/build-module/components/{page-template-parts → page-templates-template-parts}/add-new-template-part.js +0 -0
- /package/src/components/{page-template-parts → page-templates-template-parts}/add-new-template-part.js +0 -0
|
@@ -1,344 +0,0 @@
|
|
|
1
|
-
import { createElement, Fragment } from "react";
|
|
2
|
-
/**
|
|
3
|
-
* External dependencies
|
|
4
|
-
*/
|
|
5
|
-
import removeAccents from 'remove-accents';
|
|
6
|
-
|
|
7
|
-
/**
|
|
8
|
-
* WordPress dependencies
|
|
9
|
-
*/
|
|
10
|
-
import { Icon, __experimentalView as View, __experimentalText as Text, __experimentalHStack as HStack, __experimentalVStack as VStack, VisuallyHidden } from '@wordpress/components';
|
|
11
|
-
import { __ } from '@wordpress/i18n';
|
|
12
|
-
import { useState, useMemo, useCallback } from '@wordpress/element';
|
|
13
|
-
import { useEntityRecords } from '@wordpress/core-data';
|
|
14
|
-
import { decodeEntities } from '@wordpress/html-entities';
|
|
15
|
-
import { ENTER, SPACE } from '@wordpress/keycodes';
|
|
16
|
-
import { parse } from '@wordpress/blocks';
|
|
17
|
-
import { BlockPreview, privateApis as blockEditorPrivateApis } from '@wordpress/block-editor';
|
|
18
|
-
import { DataViews, sortByTextFields, getPaginationResults } from '@wordpress/dataviews';
|
|
19
|
-
import { privateApis as routerPrivateApis } from '@wordpress/router';
|
|
20
|
-
|
|
21
|
-
/**
|
|
22
|
-
* Internal dependencies
|
|
23
|
-
*/
|
|
24
|
-
import Page from '../page';
|
|
25
|
-
import Link from '../routes/link';
|
|
26
|
-
import AddNewTemplate from '../add-new-template';
|
|
27
|
-
import { useAddedBy, AvatarImage } from '../list/added-by';
|
|
28
|
-
import { TEMPLATE_POST_TYPE, ENUMERATION_TYPE, OPERATOR_IN, OPERATOR_NOT_IN, LAYOUT_GRID, LAYOUT_TABLE, LAYOUT_LIST } from '../../utils/constants';
|
|
29
|
-
import { useResetTemplateAction, deleteTemplateAction, renameTemplateAction } from './template-actions';
|
|
30
|
-
import { postRevisionsAction } from '../actions';
|
|
31
|
-
import usePatternSettings from '../page-patterns/use-pattern-settings';
|
|
32
|
-
import { unlock } from '../../lock-unlock';
|
|
33
|
-
import PostPreview from '../post-preview';
|
|
34
|
-
const {
|
|
35
|
-
ExperimentalBlockEditorProvider,
|
|
36
|
-
useGlobalStyle
|
|
37
|
-
} = unlock(blockEditorPrivateApis);
|
|
38
|
-
const {
|
|
39
|
-
useHistory
|
|
40
|
-
} = unlock(routerPrivateApis);
|
|
41
|
-
const EMPTY_ARRAY = [];
|
|
42
|
-
const defaultConfigPerViewType = {
|
|
43
|
-
[LAYOUT_TABLE]: {},
|
|
44
|
-
[LAYOUT_GRID]: {
|
|
45
|
-
mediaField: 'preview',
|
|
46
|
-
primaryField: 'title'
|
|
47
|
-
},
|
|
48
|
-
[LAYOUT_LIST]: {
|
|
49
|
-
primaryField: 'title',
|
|
50
|
-
mediaField: 'preview'
|
|
51
|
-
}
|
|
52
|
-
};
|
|
53
|
-
const DEFAULT_VIEW = {
|
|
54
|
-
type: LAYOUT_TABLE,
|
|
55
|
-
search: '',
|
|
56
|
-
page: 1,
|
|
57
|
-
perPage: 20,
|
|
58
|
-
// All fields are visible by default, so it's
|
|
59
|
-
// better to keep track of the hidden ones.
|
|
60
|
-
hiddenFields: ['preview'],
|
|
61
|
-
layout: {},
|
|
62
|
-
filters: []
|
|
63
|
-
};
|
|
64
|
-
function normalizeSearchInput(input = '') {
|
|
65
|
-
return removeAccents(input.trim().toLowerCase());
|
|
66
|
-
}
|
|
67
|
-
function TemplateTitle({
|
|
68
|
-
item,
|
|
69
|
-
viewType
|
|
70
|
-
}) {
|
|
71
|
-
if (viewType === LAYOUT_LIST) {
|
|
72
|
-
return createElement(Fragment, null, decodeEntities(item.title?.rendered) || __('(no title)'));
|
|
73
|
-
}
|
|
74
|
-
return createElement(VStack, {
|
|
75
|
-
spacing: 1
|
|
76
|
-
}, createElement(View, {
|
|
77
|
-
as: "span",
|
|
78
|
-
className: "dataviews-view-grid__title-field"
|
|
79
|
-
}, createElement(Link, {
|
|
80
|
-
params: {
|
|
81
|
-
postId: item.id,
|
|
82
|
-
postType: item.type,
|
|
83
|
-
canvas: 'edit'
|
|
84
|
-
}
|
|
85
|
-
}, decodeEntities(item.title?.rendered) || __('(no title)'))));
|
|
86
|
-
}
|
|
87
|
-
function AuthorField({
|
|
88
|
-
item,
|
|
89
|
-
viewType
|
|
90
|
-
}) {
|
|
91
|
-
const {
|
|
92
|
-
text,
|
|
93
|
-
icon,
|
|
94
|
-
imageUrl
|
|
95
|
-
} = useAddedBy(item.type, item.id);
|
|
96
|
-
const withIcon = viewType !== LAYOUT_LIST;
|
|
97
|
-
return createElement(HStack, {
|
|
98
|
-
alignment: "left",
|
|
99
|
-
spacing: 1
|
|
100
|
-
}, withIcon && imageUrl && createElement(AvatarImage, {
|
|
101
|
-
imageUrl: imageUrl
|
|
102
|
-
}), withIcon && !imageUrl && createElement("div", {
|
|
103
|
-
className: "edit-site-list-added-by__icon"
|
|
104
|
-
}, createElement(Icon, {
|
|
105
|
-
icon: icon
|
|
106
|
-
})), createElement("span", null, text));
|
|
107
|
-
}
|
|
108
|
-
function TemplatePreview({
|
|
109
|
-
content,
|
|
110
|
-
viewType
|
|
111
|
-
}) {
|
|
112
|
-
const settings = usePatternSettings();
|
|
113
|
-
const [backgroundColor = 'white'] = useGlobalStyle('color.background');
|
|
114
|
-
const blocks = useMemo(() => {
|
|
115
|
-
return parse(content);
|
|
116
|
-
}, [content]);
|
|
117
|
-
if (!blocks?.length) {
|
|
118
|
-
return null;
|
|
119
|
-
}
|
|
120
|
-
// Wrap everything in a block editor provider to ensure 'styles' that are needed
|
|
121
|
-
// for the previews are synced between the site editor store and the block editor store.
|
|
122
|
-
// Additionally we need to have the `__experimentalBlockPatterns` setting in order to
|
|
123
|
-
// render patterns inside the previews.
|
|
124
|
-
// TODO: Same approach is used in the patterns list and it becomes obvious that some of
|
|
125
|
-
// the block editor settings are needed in context where we don't have the block editor.
|
|
126
|
-
// Explore how we can solve this in a better way.
|
|
127
|
-
return createElement(ExperimentalBlockEditorProvider, {
|
|
128
|
-
settings: settings
|
|
129
|
-
}, createElement("div", {
|
|
130
|
-
className: `page-templates-preview-field is-viewtype-${viewType}`,
|
|
131
|
-
style: {
|
|
132
|
-
backgroundColor
|
|
133
|
-
}
|
|
134
|
-
}, createElement(BlockPreview, {
|
|
135
|
-
blocks: blocks
|
|
136
|
-
})));
|
|
137
|
-
}
|
|
138
|
-
export default function DataviewsTemplates() {
|
|
139
|
-
const [templateId, setTemplateId] = useState(null);
|
|
140
|
-
const [view, setView] = useState(DEFAULT_VIEW);
|
|
141
|
-
const {
|
|
142
|
-
records: allTemplates,
|
|
143
|
-
isResolving: isLoadingData
|
|
144
|
-
} = useEntityRecords('postType', TEMPLATE_POST_TYPE, {
|
|
145
|
-
per_page: -1
|
|
146
|
-
});
|
|
147
|
-
const history = useHistory();
|
|
148
|
-
const onSelectionChange = useCallback(items => setTemplateId(items?.length === 1 ? items[0].id : null), [setTemplateId]);
|
|
149
|
-
const authors = useMemo(() => {
|
|
150
|
-
if (!allTemplates) {
|
|
151
|
-
return EMPTY_ARRAY;
|
|
152
|
-
}
|
|
153
|
-
const authorsSet = new Set();
|
|
154
|
-
allTemplates.forEach(template => {
|
|
155
|
-
authorsSet.add(template.author_text);
|
|
156
|
-
});
|
|
157
|
-
return Array.from(authorsSet).map(author => ({
|
|
158
|
-
value: author,
|
|
159
|
-
label: author
|
|
160
|
-
}));
|
|
161
|
-
}, [allTemplates]);
|
|
162
|
-
const fields = useMemo(() => [{
|
|
163
|
-
header: __('Preview'),
|
|
164
|
-
id: 'preview',
|
|
165
|
-
render: ({
|
|
166
|
-
item
|
|
167
|
-
}) => {
|
|
168
|
-
return createElement(TemplatePreview, {
|
|
169
|
-
content: item.content.raw,
|
|
170
|
-
viewType: view.type
|
|
171
|
-
});
|
|
172
|
-
},
|
|
173
|
-
minWidth: 120,
|
|
174
|
-
maxWidth: 120,
|
|
175
|
-
enableSorting: false
|
|
176
|
-
}, {
|
|
177
|
-
header: __('Template'),
|
|
178
|
-
id: 'title',
|
|
179
|
-
getValue: ({
|
|
180
|
-
item
|
|
181
|
-
}) => item.title?.rendered,
|
|
182
|
-
render: ({
|
|
183
|
-
item
|
|
184
|
-
}) => createElement(TemplateTitle, {
|
|
185
|
-
item: item,
|
|
186
|
-
viewType: view.type
|
|
187
|
-
}),
|
|
188
|
-
maxWidth: 400,
|
|
189
|
-
enableHiding: false
|
|
190
|
-
}, {
|
|
191
|
-
header: __('Description'),
|
|
192
|
-
id: 'description',
|
|
193
|
-
getValue: ({
|
|
194
|
-
item
|
|
195
|
-
}) => item.description,
|
|
196
|
-
render: ({
|
|
197
|
-
item
|
|
198
|
-
}) => {
|
|
199
|
-
return item.description ? decodeEntities(item.description) : createElement(Fragment, null, createElement(Text, {
|
|
200
|
-
variant: "muted",
|
|
201
|
-
"aria-hidden": "true"
|
|
202
|
-
}, "\u2014"), createElement(VisuallyHidden, null, __('No description.')));
|
|
203
|
-
},
|
|
204
|
-
maxWidth: 200,
|
|
205
|
-
enableSorting: false
|
|
206
|
-
}, {
|
|
207
|
-
header: __('Author'),
|
|
208
|
-
id: 'author',
|
|
209
|
-
getValue: ({
|
|
210
|
-
item
|
|
211
|
-
}) => item.author_text,
|
|
212
|
-
render: ({
|
|
213
|
-
item
|
|
214
|
-
}) => {
|
|
215
|
-
return createElement(AuthorField, {
|
|
216
|
-
viewType: view.type,
|
|
217
|
-
item: item
|
|
218
|
-
});
|
|
219
|
-
},
|
|
220
|
-
enableHiding: false,
|
|
221
|
-
type: ENUMERATION_TYPE,
|
|
222
|
-
elements: authors
|
|
223
|
-
}], [authors, view.type]);
|
|
224
|
-
const {
|
|
225
|
-
data,
|
|
226
|
-
paginationInfo
|
|
227
|
-
} = useMemo(() => {
|
|
228
|
-
if (!allTemplates) {
|
|
229
|
-
return {
|
|
230
|
-
data: EMPTY_ARRAY,
|
|
231
|
-
paginationInfo: {
|
|
232
|
-
totalItems: 0,
|
|
233
|
-
totalPages: 0
|
|
234
|
-
}
|
|
235
|
-
};
|
|
236
|
-
}
|
|
237
|
-
let filteredTemplates = [...allTemplates];
|
|
238
|
-
// Handle global search.
|
|
239
|
-
if (view.search) {
|
|
240
|
-
const normalizedSearch = normalizeSearchInput(view.search);
|
|
241
|
-
filteredTemplates = filteredTemplates.filter(item => {
|
|
242
|
-
const title = item.title?.rendered || item.slug;
|
|
243
|
-
return normalizeSearchInput(title).includes(normalizedSearch) || normalizeSearchInput(item.description).includes(normalizedSearch);
|
|
244
|
-
});
|
|
245
|
-
}
|
|
246
|
-
|
|
247
|
-
// Handle filters.
|
|
248
|
-
if (view.filters.length > 0) {
|
|
249
|
-
view.filters.forEach(filter => {
|
|
250
|
-
if (filter.field === 'author' && filter.operator === OPERATOR_IN && !!filter.value) {
|
|
251
|
-
filteredTemplates = filteredTemplates.filter(item => {
|
|
252
|
-
return item.author_text === filter.value;
|
|
253
|
-
});
|
|
254
|
-
} else if (filter.field === 'author' && filter.operator === OPERATOR_NOT_IN && !!filter.value) {
|
|
255
|
-
filteredTemplates = filteredTemplates.filter(item => {
|
|
256
|
-
return item.author_text !== filter.value;
|
|
257
|
-
});
|
|
258
|
-
}
|
|
259
|
-
});
|
|
260
|
-
}
|
|
261
|
-
|
|
262
|
-
// Handle sorting.
|
|
263
|
-
if (view.sort) {
|
|
264
|
-
filteredTemplates = sortByTextFields({
|
|
265
|
-
data: filteredTemplates,
|
|
266
|
-
view,
|
|
267
|
-
fields,
|
|
268
|
-
textFields: ['title']
|
|
269
|
-
});
|
|
270
|
-
}
|
|
271
|
-
// Handle pagination.
|
|
272
|
-
return getPaginationResults({
|
|
273
|
-
data: filteredTemplates,
|
|
274
|
-
view
|
|
275
|
-
});
|
|
276
|
-
}, [allTemplates, view, fields]);
|
|
277
|
-
const resetTemplateAction = useResetTemplateAction();
|
|
278
|
-
const actions = useMemo(() => [resetTemplateAction, deleteTemplateAction, renameTemplateAction, postRevisionsAction], [resetTemplateAction]);
|
|
279
|
-
const onChangeView = useCallback(newView => {
|
|
280
|
-
if (newView.type !== view.type) {
|
|
281
|
-
newView = {
|
|
282
|
-
...newView,
|
|
283
|
-
layout: {
|
|
284
|
-
...defaultConfigPerViewType[newView.type]
|
|
285
|
-
}
|
|
286
|
-
};
|
|
287
|
-
}
|
|
288
|
-
setView(newView);
|
|
289
|
-
}, [view.type, setView]);
|
|
290
|
-
return createElement(Fragment, null, createElement(Page, {
|
|
291
|
-
className: view.type === LAYOUT_LIST ? 'edit-site-template-pages-list-view' : null,
|
|
292
|
-
title: __('Templates'),
|
|
293
|
-
actions: createElement(AddNewTemplate, {
|
|
294
|
-
templateType: TEMPLATE_POST_TYPE,
|
|
295
|
-
showIcon: false,
|
|
296
|
-
toggleProps: {
|
|
297
|
-
variant: 'primary'
|
|
298
|
-
}
|
|
299
|
-
})
|
|
300
|
-
}, createElement(DataViews, {
|
|
301
|
-
paginationInfo: paginationInfo,
|
|
302
|
-
fields: fields,
|
|
303
|
-
actions: actions,
|
|
304
|
-
data: data,
|
|
305
|
-
isLoading: isLoadingData,
|
|
306
|
-
view: view,
|
|
307
|
-
onChangeView: onChangeView,
|
|
308
|
-
onSelectionChange: onSelectionChange,
|
|
309
|
-
deferredRendering: !view.hiddenFields?.includes('preview')
|
|
310
|
-
})), view.type === LAYOUT_LIST && createElement(Page, null, createElement("div", {
|
|
311
|
-
className: "edit-site-template-pages-preview",
|
|
312
|
-
tabIndex: 0,
|
|
313
|
-
role: "button",
|
|
314
|
-
onKeyDown: event => {
|
|
315
|
-
const {
|
|
316
|
-
keyCode
|
|
317
|
-
} = event;
|
|
318
|
-
if (keyCode === ENTER || keyCode === SPACE) {
|
|
319
|
-
history.push({
|
|
320
|
-
postId: templateId,
|
|
321
|
-
postType: TEMPLATE_POST_TYPE,
|
|
322
|
-
canvas: 'edit'
|
|
323
|
-
});
|
|
324
|
-
}
|
|
325
|
-
},
|
|
326
|
-
onClick: () => history.push({
|
|
327
|
-
postId: templateId,
|
|
328
|
-
postType: TEMPLATE_POST_TYPE,
|
|
329
|
-
canvas: 'edit'
|
|
330
|
-
})
|
|
331
|
-
}, templateId !== null ? createElement(PostPreview, {
|
|
332
|
-
postId: templateId,
|
|
333
|
-
postType: TEMPLATE_POST_TYPE
|
|
334
|
-
}) : createElement("div", {
|
|
335
|
-
style: {
|
|
336
|
-
display: 'flex',
|
|
337
|
-
flexDirection: 'column',
|
|
338
|
-
justifyContent: 'center',
|
|
339
|
-
textAlign: 'center',
|
|
340
|
-
height: '100%'
|
|
341
|
-
}
|
|
342
|
-
}, createElement("p", null, __('Select a template to preview'))))));
|
|
343
|
-
}
|
|
344
|
-
//# sourceMappingURL=index.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"names":["removeAccents","Icon","__experimentalView","View","__experimentalText","Text","__experimentalHStack","HStack","__experimentalVStack","VStack","VisuallyHidden","__","useState","useMemo","useCallback","useEntityRecords","decodeEntities","ENTER","SPACE","parse","BlockPreview","privateApis","blockEditorPrivateApis","DataViews","sortByTextFields","getPaginationResults","routerPrivateApis","Page","Link","AddNewTemplate","useAddedBy","AvatarImage","TEMPLATE_POST_TYPE","ENUMERATION_TYPE","OPERATOR_IN","OPERATOR_NOT_IN","LAYOUT_GRID","LAYOUT_TABLE","LAYOUT_LIST","useResetTemplateAction","deleteTemplateAction","renameTemplateAction","postRevisionsAction","usePatternSettings","unlock","PostPreview","ExperimentalBlockEditorProvider","useGlobalStyle","useHistory","EMPTY_ARRAY","defaultConfigPerViewType","mediaField","primaryField","DEFAULT_VIEW","type","search","page","perPage","hiddenFields","layout","filters","normalizeSearchInput","input","trim","toLowerCase","TemplateTitle","item","viewType","createElement","Fragment","title","rendered","spacing","as","className","params","postId","id","postType","canvas","AuthorField","text","icon","imageUrl","withIcon","alignment","TemplatePreview","content","settings","backgroundColor","blocks","length","style","DataviewsTemplates","templateId","setTemplateId","view","setView","records","allTemplates","isResolving","isLoadingData","per_page","history","onSelectionChange","items","authors","authorsSet","Set","forEach","template","add","author_text","Array","from","map","author","value","label","fields","header","render","raw","minWidth","maxWidth","enableSorting","getValue","enableHiding","description","variant","elements","data","paginationInfo","totalItems","totalPages","filteredTemplates","normalizedSearch","filter","slug","includes","field","operator","sort","textFields","resetTemplateAction","actions","onChangeView","newView","templateType","showIcon","toggleProps","isLoading","deferredRendering","tabIndex","role","onKeyDown","event","keyCode","push","onClick","display","flexDirection","justifyContent","textAlign","height"],"sources":["@wordpress/edit-site/src/components/page-templates/index.js"],"sourcesContent":["/**\n * External dependencies\n */\nimport removeAccents from 'remove-accents';\n\n/**\n * WordPress dependencies\n */\nimport {\n\tIcon,\n\t__experimentalView as View,\n\t__experimentalText as Text,\n\t__experimentalHStack as HStack,\n\t__experimentalVStack as VStack,\n\tVisuallyHidden,\n} from '@wordpress/components';\nimport { __ } from '@wordpress/i18n';\nimport { useState, useMemo, useCallback } from '@wordpress/element';\nimport { useEntityRecords } from '@wordpress/core-data';\nimport { decodeEntities } from '@wordpress/html-entities';\nimport { ENTER, SPACE } from '@wordpress/keycodes';\nimport { parse } from '@wordpress/blocks';\nimport {\n\tBlockPreview,\n\tprivateApis as blockEditorPrivateApis,\n} from '@wordpress/block-editor';\nimport {\n\tDataViews,\n\tsortByTextFields,\n\tgetPaginationResults,\n} from '@wordpress/dataviews';\nimport { privateApis as routerPrivateApis } from '@wordpress/router';\n\n/**\n * Internal dependencies\n */\nimport Page from '../page';\nimport Link from '../routes/link';\nimport AddNewTemplate from '../add-new-template';\nimport { useAddedBy, AvatarImage } from '../list/added-by';\nimport {\n\tTEMPLATE_POST_TYPE,\n\tENUMERATION_TYPE,\n\tOPERATOR_IN,\n\tOPERATOR_NOT_IN,\n\tLAYOUT_GRID,\n\tLAYOUT_TABLE,\n\tLAYOUT_LIST,\n} from '../../utils/constants';\nimport {\n\tuseResetTemplateAction,\n\tdeleteTemplateAction,\n\trenameTemplateAction,\n} from './template-actions';\nimport { postRevisionsAction } from '../actions';\nimport usePatternSettings from '../page-patterns/use-pattern-settings';\nimport { unlock } from '../../lock-unlock';\nimport PostPreview from '../post-preview';\n\nconst { ExperimentalBlockEditorProvider, useGlobalStyle } = unlock(\n\tblockEditorPrivateApis\n);\nconst { useHistory } = unlock( routerPrivateApis );\n\nconst EMPTY_ARRAY = [];\n\nconst defaultConfigPerViewType = {\n\t[ LAYOUT_TABLE ]: {},\n\t[ LAYOUT_GRID ]: {\n\t\tmediaField: 'preview',\n\t\tprimaryField: 'title',\n\t},\n\t[ LAYOUT_LIST ]: {\n\t\tprimaryField: 'title',\n\t\tmediaField: 'preview',\n\t},\n};\n\nconst DEFAULT_VIEW = {\n\ttype: LAYOUT_TABLE,\n\tsearch: '',\n\tpage: 1,\n\tperPage: 20,\n\t// All fields are visible by default, so it's\n\t// better to keep track of the hidden ones.\n\thiddenFields: [ 'preview' ],\n\tlayout: {},\n\tfilters: [],\n};\n\nfunction normalizeSearchInput( input = '' ) {\n\treturn removeAccents( input.trim().toLowerCase() );\n}\n\nfunction TemplateTitle( { item, viewType } ) {\n\tif ( viewType === LAYOUT_LIST ) {\n\t\treturn (\n\t\t\t<>\n\t\t\t\t{ decodeEntities( item.title?.rendered ) || __( '(no title)' ) }\n\t\t\t</>\n\t\t);\n\t}\n\n\treturn (\n\t\t<VStack spacing={ 1 }>\n\t\t\t<View as=\"span\" className=\"dataviews-view-grid__title-field\">\n\t\t\t\t<Link\n\t\t\t\t\tparams={ {\n\t\t\t\t\t\tpostId: item.id,\n\t\t\t\t\t\tpostType: item.type,\n\t\t\t\t\t\tcanvas: 'edit',\n\t\t\t\t\t} }\n\t\t\t\t>\n\t\t\t\t\t{ decodeEntities( item.title?.rendered ) ||\n\t\t\t\t\t\t__( '(no title)' ) }\n\t\t\t\t</Link>\n\t\t\t</View>\n\t\t</VStack>\n\t);\n}\n\nfunction AuthorField( { item, viewType } ) {\n\tconst { text, icon, imageUrl } = useAddedBy( item.type, item.id );\n\tconst withIcon = viewType !== LAYOUT_LIST;\n\n\treturn (\n\t\t<HStack alignment=\"left\" spacing={ 1 }>\n\t\t\t{ withIcon && imageUrl && <AvatarImage imageUrl={ imageUrl } /> }\n\t\t\t{ withIcon && ! imageUrl && (\n\t\t\t\t<div className=\"edit-site-list-added-by__icon\">\n\t\t\t\t\t<Icon icon={ icon } />\n\t\t\t\t</div>\n\t\t\t) }\n\t\t\t<span>{ text }</span>\n\t\t</HStack>\n\t);\n}\n\nfunction TemplatePreview( { content, viewType } ) {\n\tconst settings = usePatternSettings();\n\tconst [ backgroundColor = 'white' ] = useGlobalStyle( 'color.background' );\n\tconst blocks = useMemo( () => {\n\t\treturn parse( content );\n\t}, [ content ] );\n\tif ( ! blocks?.length ) {\n\t\treturn null;\n\t}\n\t// Wrap everything in a block editor provider to ensure 'styles' that are needed\n\t// for the previews are synced between the site editor store and the block editor store.\n\t// Additionally we need to have the `__experimentalBlockPatterns` setting in order to\n\t// render patterns inside the previews.\n\t// TODO: Same approach is used in the patterns list and it becomes obvious that some of\n\t// the block editor settings are needed in context where we don't have the block editor.\n\t// Explore how we can solve this in a better way.\n\treturn (\n\t\t<ExperimentalBlockEditorProvider settings={ settings }>\n\t\t\t<div\n\t\t\t\tclassName={ `page-templates-preview-field is-viewtype-${ viewType }` }\n\t\t\t\tstyle={ { backgroundColor } }\n\t\t\t>\n\t\t\t\t<BlockPreview blocks={ blocks } />\n\t\t\t</div>\n\t\t</ExperimentalBlockEditorProvider>\n\t);\n}\n\nexport default function DataviewsTemplates() {\n\tconst [ templateId, setTemplateId ] = useState( null );\n\tconst [ view, setView ] = useState( DEFAULT_VIEW );\n\tconst { records: allTemplates, isResolving: isLoadingData } =\n\t\tuseEntityRecords( 'postType', TEMPLATE_POST_TYPE, {\n\t\t\tper_page: -1,\n\t\t} );\n\tconst history = useHistory();\n\n\tconst onSelectionChange = useCallback(\n\t\t( items ) =>\n\t\t\tsetTemplateId( items?.length === 1 ? items[ 0 ].id : null ),\n\t\t[ setTemplateId ]\n\t);\n\n\tconst authors = useMemo( () => {\n\t\tif ( ! allTemplates ) {\n\t\t\treturn EMPTY_ARRAY;\n\t\t}\n\t\tconst authorsSet = new Set();\n\t\tallTemplates.forEach( ( template ) => {\n\t\t\tauthorsSet.add( template.author_text );\n\t\t} );\n\t\treturn Array.from( authorsSet ).map( ( author ) => ( {\n\t\t\tvalue: author,\n\t\t\tlabel: author,\n\t\t} ) );\n\t}, [ allTemplates ] );\n\n\tconst fields = useMemo(\n\t\t() => [\n\t\t\t{\n\t\t\t\theader: __( 'Preview' ),\n\t\t\t\tid: 'preview',\n\t\t\t\trender: ( { item } ) => {\n\t\t\t\t\treturn (\n\t\t\t\t\t\t<TemplatePreview\n\t\t\t\t\t\t\tcontent={ item.content.raw }\n\t\t\t\t\t\t\tviewType={ view.type }\n\t\t\t\t\t\t/>\n\t\t\t\t\t);\n\t\t\t\t},\n\t\t\t\tminWidth: 120,\n\t\t\t\tmaxWidth: 120,\n\t\t\t\tenableSorting: false,\n\t\t\t},\n\t\t\t{\n\t\t\t\theader: __( 'Template' ),\n\t\t\t\tid: 'title',\n\t\t\t\tgetValue: ( { item } ) => item.title?.rendered,\n\t\t\t\trender: ( { item } ) => (\n\t\t\t\t\t<TemplateTitle item={ item } viewType={ view.type } />\n\t\t\t\t),\n\t\t\t\tmaxWidth: 400,\n\t\t\t\tenableHiding: false,\n\t\t\t},\n\t\t\t{\n\t\t\t\theader: __( 'Description' ),\n\t\t\t\tid: 'description',\n\t\t\t\tgetValue: ( { item } ) => item.description,\n\t\t\t\trender: ( { item } ) => {\n\t\t\t\t\treturn item.description ? (\n\t\t\t\t\t\tdecodeEntities( item.description )\n\t\t\t\t\t) : (\n\t\t\t\t\t\t<>\n\t\t\t\t\t\t\t<Text variant=\"muted\" aria-hidden=\"true\">\n\t\t\t\t\t\t\t\t—\n\t\t\t\t\t\t\t</Text>\n\t\t\t\t\t\t\t<VisuallyHidden>\n\t\t\t\t\t\t\t\t{ __( 'No description.' ) }\n\t\t\t\t\t\t\t</VisuallyHidden>\n\t\t\t\t\t\t</>\n\t\t\t\t\t);\n\t\t\t\t},\n\t\t\t\tmaxWidth: 200,\n\t\t\t\tenableSorting: false,\n\t\t\t},\n\t\t\t{\n\t\t\t\theader: __( 'Author' ),\n\t\t\t\tid: 'author',\n\t\t\t\tgetValue: ( { item } ) => item.author_text,\n\t\t\t\trender: ( { item } ) => {\n\t\t\t\t\treturn <AuthorField viewType={ view.type } item={ item } />;\n\t\t\t\t},\n\t\t\t\tenableHiding: false,\n\t\t\t\ttype: ENUMERATION_TYPE,\n\t\t\t\telements: authors,\n\t\t\t},\n\t\t],\n\t\t[ authors, view.type ]\n\t);\n\n\tconst { data, paginationInfo } = useMemo( () => {\n\t\tif ( ! allTemplates ) {\n\t\t\treturn {\n\t\t\t\tdata: EMPTY_ARRAY,\n\t\t\t\tpaginationInfo: { totalItems: 0, totalPages: 0 },\n\t\t\t};\n\t\t}\n\t\tlet filteredTemplates = [ ...allTemplates ];\n\t\t// Handle global search.\n\t\tif ( view.search ) {\n\t\t\tconst normalizedSearch = normalizeSearchInput( view.search );\n\t\t\tfilteredTemplates = filteredTemplates.filter( ( item ) => {\n\t\t\t\tconst title = item.title?.rendered || item.slug;\n\t\t\t\treturn (\n\t\t\t\t\tnormalizeSearchInput( title ).includes(\n\t\t\t\t\t\tnormalizedSearch\n\t\t\t\t\t) ||\n\t\t\t\t\tnormalizeSearchInput( item.description ).includes(\n\t\t\t\t\t\tnormalizedSearch\n\t\t\t\t\t)\n\t\t\t\t);\n\t\t\t} );\n\t\t}\n\n\t\t// Handle filters.\n\t\tif ( view.filters.length > 0 ) {\n\t\t\tview.filters.forEach( ( filter ) => {\n\t\t\t\tif (\n\t\t\t\t\tfilter.field === 'author' &&\n\t\t\t\t\tfilter.operator === OPERATOR_IN &&\n\t\t\t\t\t!! filter.value\n\t\t\t\t) {\n\t\t\t\t\tfilteredTemplates = filteredTemplates.filter( ( item ) => {\n\t\t\t\t\t\treturn item.author_text === filter.value;\n\t\t\t\t\t} );\n\t\t\t\t} else if (\n\t\t\t\t\tfilter.field === 'author' &&\n\t\t\t\t\tfilter.operator === OPERATOR_NOT_IN &&\n\t\t\t\t\t!! filter.value\n\t\t\t\t) {\n\t\t\t\t\tfilteredTemplates = filteredTemplates.filter( ( item ) => {\n\t\t\t\t\t\treturn item.author_text !== filter.value;\n\t\t\t\t\t} );\n\t\t\t\t}\n\t\t\t} );\n\t\t}\n\n\t\t// Handle sorting.\n\t\tif ( view.sort ) {\n\t\t\tfilteredTemplates = sortByTextFields( {\n\t\t\t\tdata: filteredTemplates,\n\t\t\t\tview,\n\t\t\t\tfields,\n\t\t\t\ttextFields: [ 'title' ],\n\t\t\t} );\n\t\t}\n\t\t// Handle pagination.\n\t\treturn getPaginationResults( {\n\t\t\tdata: filteredTemplates,\n\t\t\tview,\n\t\t} );\n\t}, [ allTemplates, view, fields ] );\n\n\tconst resetTemplateAction = useResetTemplateAction();\n\tconst actions = useMemo(\n\t\t() => [\n\t\t\tresetTemplateAction,\n\t\t\tdeleteTemplateAction,\n\t\t\trenameTemplateAction,\n\t\t\tpostRevisionsAction,\n\t\t],\n\t\t[ resetTemplateAction ]\n\t);\n\n\tconst onChangeView = useCallback(\n\t\t( newView ) => {\n\t\t\tif ( newView.type !== view.type ) {\n\t\t\t\tnewView = {\n\t\t\t\t\t...newView,\n\t\t\t\t\tlayout: {\n\t\t\t\t\t\t...defaultConfigPerViewType[ newView.type ],\n\t\t\t\t\t},\n\t\t\t\t};\n\t\t\t}\n\n\t\t\tsetView( newView );\n\t\t},\n\t\t[ view.type, setView ]\n\t);\n\n\treturn (\n\t\t<>\n\t\t\t<Page\n\t\t\t\tclassName={\n\t\t\t\t\tview.type === LAYOUT_LIST\n\t\t\t\t\t\t? 'edit-site-template-pages-list-view'\n\t\t\t\t\t\t: null\n\t\t\t\t}\n\t\t\t\ttitle={ __( 'Templates' ) }\n\t\t\t\tactions={\n\t\t\t\t\t<AddNewTemplate\n\t\t\t\t\t\ttemplateType={ TEMPLATE_POST_TYPE }\n\t\t\t\t\t\tshowIcon={ false }\n\t\t\t\t\t\ttoggleProps={ { variant: 'primary' } }\n\t\t\t\t\t/>\n\t\t\t\t}\n\t\t\t>\n\t\t\t\t<DataViews\n\t\t\t\t\tpaginationInfo={ paginationInfo }\n\t\t\t\t\tfields={ fields }\n\t\t\t\t\tactions={ actions }\n\t\t\t\t\tdata={ data }\n\t\t\t\t\tisLoading={ isLoadingData }\n\t\t\t\t\tview={ view }\n\t\t\t\t\tonChangeView={ onChangeView }\n\t\t\t\t\tonSelectionChange={ onSelectionChange }\n\t\t\t\t\tdeferredRendering={\n\t\t\t\t\t\t! view.hiddenFields?.includes( 'preview' )\n\t\t\t\t\t}\n\t\t\t\t/>\n\t\t\t</Page>\n\t\t\t{ view.type === LAYOUT_LIST && (\n\t\t\t\t<Page>\n\t\t\t\t\t<div\n\t\t\t\t\t\tclassName=\"edit-site-template-pages-preview\"\n\t\t\t\t\t\ttabIndex={ 0 }\n\t\t\t\t\t\trole=\"button\"\n\t\t\t\t\t\tonKeyDown={ ( event ) => {\n\t\t\t\t\t\t\tconst { keyCode } = event;\n\t\t\t\t\t\t\tif ( keyCode === ENTER || keyCode === SPACE ) {\n\t\t\t\t\t\t\t\thistory.push( {\n\t\t\t\t\t\t\t\t\tpostId: templateId,\n\t\t\t\t\t\t\t\t\tpostType: TEMPLATE_POST_TYPE,\n\t\t\t\t\t\t\t\t\tcanvas: 'edit',\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\tonClick={ () =>\n\t\t\t\t\t\t\thistory.push( {\n\t\t\t\t\t\t\t\tpostId: templateId,\n\t\t\t\t\t\t\t\tpostType: TEMPLATE_POST_TYPE,\n\t\t\t\t\t\t\t\tcanvas: 'edit',\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{ templateId !== null ? (\n\t\t\t\t\t\t\t<PostPreview\n\t\t\t\t\t\t\t\tpostId={ templateId }\n\t\t\t\t\t\t\t\tpostType={ TEMPLATE_POST_TYPE }\n\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t) : (\n\t\t\t\t\t\t\t<div\n\t\t\t\t\t\t\t\tstyle={ {\n\t\t\t\t\t\t\t\t\tdisplay: 'flex',\n\t\t\t\t\t\t\t\t\tflexDirection: 'column',\n\t\t\t\t\t\t\t\t\tjustifyContent: 'center',\n\t\t\t\t\t\t\t\t\ttextAlign: 'center',\n\t\t\t\t\t\t\t\t\theight: '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<p>{ __( 'Select a template to preview' ) }</p>\n\t\t\t\t\t\t\t</div>\n\t\t\t\t\t\t) }\n\t\t\t\t\t</div>\n\t\t\t\t</Page>\n\t\t\t) }\n\t\t</>\n\t);\n}\n"],"mappings":";AAAA;AACA;AACA;AACA,OAAOA,aAAa,MAAM,gBAAgB;;AAE1C;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ACJyC,aAAA;IACCM,SAAS,EAAC,kCAAkC;IAC5C+E,QAAQ,EAAG,CAAG;IACdC,IAAI,EAAC,QAAQ;IACbC,SAAS,EAAKC,KAAK,IAAM;MACxB,MAAM;QAAEC;MAAQ,CAAC,GAAGD,KAAK;MACzB,IAAKC,OAAO,KAAK5I,KAAK,IAAI4I,OAAO,KAAK3I,KAAK,EAAG;QAC7CqF,OAAO,CAACuD,IAAI,CAAE;UACblF,MAAM,EAAEkB,UAAU;UAClBhB,QAAQ,EAAE9C,kBAAkB;UAC5B+C,MAAM,EAAE;QACT,CAAE,CAAC;MACJ;IACD,CAAG;IACHgF,OAAO,EAAGA,CAAA,KACTxD,OAAO,CAACuD,IAAI,CAAE;MACblF,MAAM,EAAEkB,UAAU;MAClBhB,QAAQ,EAAE9C,kBAAkB;MAC5B+C,MAAM,EAAE;IACT,CAAE;EACF,GAECe,UAAU,KAAK,IAAI,GACpB1B,aAAA,CAACvB,WAAW;IACX+B,MAAM,EAAGkB,UAAY;IACrBhB,QAAQ,EAAG9C;EAAoB,CAC/B,CAAC,GAEFoC,aAAA;IACCwB,KAAK,EAAG;MACPoE,OAAO,EAAE,MAAM;MACfC,aAAa,EAAE,QAAQ;MACvBC,cAAc,EAAE,QAAQ;MACxBC,SAAS,EAAE,QAAQ;MACnBC,MAAM,EAAE;IACT;EAAG,GAEHhG,aAAA,YAAKzD,EAAE,CAAE,8BAA+B,CAAM,CAC1C,CAEF,CACA,CAEN,CAAC;AAEL"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"names":["backup","trash","__","sprintf","useDispatch","useMemo","useState","store","coreStore","noticesStore","decodeEntities","Button","TextControl","__experimentalText","Text","__experimentalHStack","HStack","__experimentalVStack","VStack","editSiteStore","isTemplateRevertable","isTemplateRemovable","TEMPLATE_POST_TYPE","useResetTemplateAction","revertTemplate","saveEditedEntityRecord","createSuccessNotice","createErrorNotice","id","label","isPrimary","icon","isEligible","callback","template","allowUndo","type","title","rendered","error","fallbackErrorMessage","errorMessage","message","code","deleteTemplateAction","hideModalHeader","RenderModal","item","closeModal","removeTemplate","createElement","spacing","justify","variant","onClick","renameTemplateAction","is_custom","editedTitle","setEditedTitle","editEntityRecord","__experimentalSaveSpecifiedEntityEdits","saveSpecifiedEntityEdits","onTemplateRename","event","preventDefault","throwOnError","onSubmit","__nextHasNoMarginBottom","value","onChange","required"],"sources":["@wordpress/edit-site/src/components/page-templates/template-actions.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { backup, trash } from '@wordpress/icons';\nimport { __, sprintf } from '@wordpress/i18n';\nimport { useDispatch } from '@wordpress/data';\nimport { useMemo, useState } from '@wordpress/element';\nimport { store as coreStore } from '@wordpress/core-data';\nimport { store as noticesStore } from '@wordpress/notices';\nimport { decodeEntities } from '@wordpress/html-entities';\nimport {\n\tButton,\n\tTextControl,\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 { store as editSiteStore } from '../../store';\nimport isTemplateRevertable from '../../utils/is-template-revertable';\nimport isTemplateRemovable from '../../utils/is-template-removable';\nimport { TEMPLATE_POST_TYPE } from '../../utils/constants';\n\nexport function useResetTemplateAction() {\n\tconst { revertTemplate } = useDispatch( editSiteStore );\n\tconst { saveEditedEntityRecord } = useDispatch( coreStore );\n\tconst { createSuccessNotice, createErrorNotice } =\n\t\tuseDispatch( noticesStore );\n\treturn useMemo(\n\t\t() => ( {\n\t\t\tid: 'reset-template',\n\t\t\tlabel: __( 'Reset template' ),\n\t\t\tisPrimary: true,\n\t\t\ticon: backup,\n\t\t\tisEligible: isTemplateRevertable,\n\t\t\tasync callback( template ) {\n\t\t\t\ttry {\n\t\t\t\t\tawait revertTemplate( template, { allowUndo: false } );\n\t\t\t\t\tawait saveEditedEntityRecord(\n\t\t\t\t\t\t'postType',\n\t\t\t\t\t\ttemplate.type,\n\t\t\t\t\t\ttemplate.id\n\t\t\t\t\t);\n\n\t\t\t\t\tcreateSuccessNotice(\n\t\t\t\t\t\tsprintf(\n\t\t\t\t\t\t\t/* translators: The template/part's name. */\n\t\t\t\t\t\t\t__( '\"%s\" reverted.' ),\n\t\t\t\t\t\t\tdecodeEntities( template.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-template-reverted',\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 fallbackErrorMessage =\n\t\t\t\t\t\ttemplate.type === TEMPLATE_POST_TYPE\n\t\t\t\t\t\t\t? __(\n\t\t\t\t\t\t\t\t\t'An error occurred while reverting the template.'\n\t\t\t\t\t\t\t )\n\t\t\t\t\t\t\t: __(\n\t\t\t\t\t\t\t\t\t'An error occurred while reverting the template part.'\n\t\t\t\t\t\t\t );\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: fallbackErrorMessage;\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\tcreateErrorNotice,\n\t\t\tcreateSuccessNotice,\n\t\t\trevertTemplate,\n\t\t\tsaveEditedEntityRecord,\n\t\t]\n\t);\n}\n\nexport const deleteTemplateAction = {\n\tid: 'delete-template',\n\tlabel: __( 'Delete template' ),\n\tisPrimary: true,\n\ticon: trash,\n\tisEligible: isTemplateRemovable,\n\thideModalHeader: true,\n\tRenderModal: ( { item: template, closeModal } ) => {\n\t\tconst { removeTemplate } = useDispatch( editSiteStore );\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 template or template part's title.\n\t\t\t\t\t\t__( 'Are you sure you want to delete \"%s\"?' ),\n\t\t\t\t\t\tdecodeEntities( template.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={ () =>\n\t\t\t\t\t\t\tremoveTemplate( template, {\n\t\t\t\t\t\t\t\tallowUndo: false,\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 const renameTemplateAction = {\n\tid: 'rename-template',\n\tlabel: __( 'Rename' ),\n\tisEligible: ( template ) =>\n\t\tisTemplateRemovable( template ) && template.is_custom,\n\tRenderModal: ( { item: template, closeModal } ) => {\n\t\tconst title = decodeEntities( template.title.rendered );\n\t\tconst [ editedTitle, setEditedTitle ] = useState( title );\n\t\tconst {\n\t\t\teditEntityRecord,\n\t\t\t__experimentalSaveSpecifiedEntityEdits: saveSpecifiedEntityEdits,\n\t\t} = useDispatch( coreStore );\n\t\tconst { createSuccessNotice, createErrorNotice } =\n\t\t\tuseDispatch( noticesStore );\n\t\tasync function onTemplateRename( event ) {\n\t\t\tevent.preventDefault();\n\t\t\ttry {\n\t\t\t\tawait editEntityRecord(\n\t\t\t\t\t'postType',\n\t\t\t\t\ttemplate.type,\n\t\t\t\t\ttemplate.id,\n\t\t\t\t\t{\n\t\t\t\t\t\ttitle: editedTitle,\n\t\t\t\t\t}\n\t\t\t\t);\n\t\t\t\t// Update state before saving rerenders the list.\n\t\t\t\tsetEditedTitle( '' );\n\t\t\t\tcloseModal();\n\t\t\t\t// Persist edited entity.\n\t\t\t\tawait saveSpecifiedEntityEdits(\n\t\t\t\t\t'postType',\n\t\t\t\t\ttemplate.type,\n\t\t\t\t\ttemplate.id,\n\t\t\t\t\t[ 'title' ], // Only save title to avoid persisting other edits.\n\t\t\t\t\t{\n\t\t\t\t\t\tthrowOnError: true,\n\t\t\t\t\t}\n\t\t\t\t);\n\t\t\t\t// TODO: this action will be reused in template parts list, so\n\t\t\t\t// let's keep this for a bit, even it's always a `template` now.\n\t\t\t\tcreateSuccessNotice(\n\t\t\t\t\ttemplate.type === TEMPLATE_POST_TYPE\n\t\t\t\t\t\t? __( 'Template renamed.' )\n\t\t\t\t\t\t: __( 'Template part renamed.' ),\n\t\t\t\t\t{\n\t\t\t\t\t\ttype: 'snackbar',\n\t\t\t\t\t}\n\t\t\t\t);\n\t\t\t} catch ( error ) {\n\t\t\t\tconst fallbackErrorMessage =\n\t\t\t\t\ttemplate.type === TEMPLATE_POST_TYPE\n\t\t\t\t\t\t? __( 'An error occurred while renaming the template.' )\n\t\t\t\t\t\t: __(\n\t\t\t\t\t\t\t\t'An error occurred while renaming the template part.'\n\t\t\t\t\t\t );\n\t\t\t\tconst errorMessage =\n\t\t\t\t\terror.message && error.code !== 'unknown_error'\n\t\t\t\t\t\t? error.message\n\t\t\t\t\t\t: fallbackErrorMessage;\n\n\t\t\t\tcreateErrorNotice( errorMessage, { type: 'snackbar' } );\n\t\t\t}\n\t\t}\n\t\treturn (\n\t\t\t<form onSubmit={ onTemplateRename }>\n\t\t\t\t<VStack spacing=\"5\">\n\t\t\t\t\t<TextControl\n\t\t\t\t\t\t__nextHasNoMarginBottom\n\t\t\t\t\t\tlabel={ __( 'Name' ) }\n\t\t\t\t\t\tvalue={ editedTitle }\n\t\t\t\t\t\tonChange={ setEditedTitle }\n\t\t\t\t\t\trequired\n\t\t\t\t\t/>\n\t\t\t\t\t<HStack justify=\"right\">\n\t\t\t\t\t\t<Button variant=\"tertiary\" onClick={ closeModal }>\n\t\t\t\t\t\t\t{ __( 'Cancel' ) }\n\t\t\t\t\t\t</Button>\n\t\t\t\t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C3BY,QAAQ;IAAA,CACR,CAAC,EACFpB,aAAA,CAAClC,MAAM;MAACoC,OAAO,EAAC;IAAO,GACtBF,aAAA,CAACvC,MAAM;MAAC0C,OAAO,EAAC,UAAU;MAACC,OAAO,EAAGN;IAAY,GAC9C9C,EAAE,CAAE,QAAS,CACR,CAAC,EACTgD,aAAA,CAACvC,MAAM;MAAC0C,OAAO,EAAC,SAAS;MAACjB,IAAI,EAAC;IAAQ,GACpClC,EAAE,CAAE,MAAO,CACN,CACD,CACD,CACH,CAAC;EAET;AACD,CAAC"}
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
import { createElement } from "react";
|
|
2
|
-
/**
|
|
3
|
-
* Internal dependencies
|
|
4
|
-
*/
|
|
5
|
-
import Editor from '../editor';
|
|
6
|
-
import { useInitEditedEntity } from '../sync-state-with-url/use-init-edited-entity-from-url';
|
|
7
|
-
import { useIsSiteEditorLoading } from '../layout/hooks';
|
|
8
|
-
export default function PostPreview({
|
|
9
|
-
postType,
|
|
10
|
-
postId
|
|
11
|
-
}) {
|
|
12
|
-
useInitEditedEntity({
|
|
13
|
-
postId,
|
|
14
|
-
postType
|
|
15
|
-
});
|
|
16
|
-
const isEditorLoading = useIsSiteEditorLoading();
|
|
17
|
-
return createElement(Editor, {
|
|
18
|
-
isLoading: isEditorLoading
|
|
19
|
-
});
|
|
20
|
-
}
|
|
21
|
-
//# sourceMappingURL=index.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"names":["Editor","useInitEditedEntity","useIsSiteEditorLoading","PostPreview","postType","postId","isEditorLoading","createElement","isLoading"],"sources":["@wordpress/edit-site/src/components/post-preview/index.js"],"sourcesContent":["/**\n * Internal dependencies\n */\nimport Editor from '../editor';\nimport { useInitEditedEntity } from '../sync-state-with-url/use-init-edited-entity-from-url';\nimport { useIsSiteEditorLoading } from '../layout/hooks';\n\nexport default function PostPreview( { postType, postId } ) {\n\tuseInitEditedEntity( {\n\t\tpostId,\n\t\tpostType,\n\t} );\n\tconst isEditorLoading = useIsSiteEditorLoading();\n\n\treturn <Editor isLoading={ isEditorLoading } />;\n}\n"],"mappings":";AAAA;AACA;AACA;AACA,OAAOA,MAAM,MAAM,WAAW;AAC9B,SAASC,mBAAmB,QAAQ,wDAAwD;AAC5F,SAASC,sBAAsB,QAAQ,iBAAiB;AAExD,eAAe,SAASC,WAAWA,CAAE;EAAEC,QAAQ;EAAEC;AAAO,CAAC,EAAG;EAC3DJ,mBAAmB,CAAE;IACpBI,MAAM;IACND;EACD,CAAE,CAAC;EACH,MAAME,eAAe,GAAGJ,sBAAsB,CAAC,CAAC;EAEhD,OAAOK,aAAA,CAACP,MAAM;IAACQ,SAAS,EAAGF;EAAiB,CAAE,CAAC;AAChD"}
|
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
import { createElement } from "react";
|
|
2
|
-
/**
|
|
3
|
-
* WordPress dependencies
|
|
4
|
-
*/
|
|
5
|
-
import { useSelect, useDispatch } from '@wordpress/data';
|
|
6
|
-
import { ___unstablePreferencesModalBaseOption as BaseOption } from '@wordpress/interface';
|
|
7
|
-
import { store as preferencesStore } from '@wordpress/preferences';
|
|
8
|
-
export default function EnableFeature(props) {
|
|
9
|
-
const {
|
|
10
|
-
scope = 'core/edit-site',
|
|
11
|
-
featureName,
|
|
12
|
-
onToggle = () => {},
|
|
13
|
-
...remainingProps
|
|
14
|
-
} = props;
|
|
15
|
-
const isChecked = useSelect(select => !!select(preferencesStore).get(scope, featureName), [scope, featureName]);
|
|
16
|
-
const {
|
|
17
|
-
toggle
|
|
18
|
-
} = useDispatch(preferencesStore);
|
|
19
|
-
const onChange = () => {
|
|
20
|
-
onToggle();
|
|
21
|
-
toggle(scope, featureName);
|
|
22
|
-
};
|
|
23
|
-
return createElement(BaseOption, {
|
|
24
|
-
onChange: onChange,
|
|
25
|
-
isChecked: isChecked,
|
|
26
|
-
...remainingProps
|
|
27
|
-
});
|
|
28
|
-
}
|
|
29
|
-
//# sourceMappingURL=enable-feature.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"names":["useSelect","useDispatch","___unstablePreferencesModalBaseOption","BaseOption","store","preferencesStore","EnableFeature","props","scope","featureName","onToggle","remainingProps","isChecked","select","get","toggle","onChange","createElement"],"sources":["@wordpress/edit-site/src/components/preferences-modal/enable-feature.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { useSelect, useDispatch } from '@wordpress/data';\nimport { ___unstablePreferencesModalBaseOption as BaseOption } from '@wordpress/interface';\nimport { store as preferencesStore } from '@wordpress/preferences';\n\nexport default function EnableFeature( props ) {\n\tconst {\n\t\tscope = 'core/edit-site',\n\t\tfeatureName,\n\t\tonToggle = () => {},\n\t\t...remainingProps\n\t} = props;\n\tconst isChecked = useSelect(\n\t\t( select ) => !! select( preferencesStore ).get( scope, featureName ),\n\t\t[ scope, featureName ]\n\t);\n\tconst { toggle } = useDispatch( preferencesStore );\n\tconst onChange = () => {\n\t\tonToggle();\n\t\ttoggle( scope, featureName );\n\t};\n\treturn (\n\t\t<BaseOption\n\t\t\tonChange={ onChange }\n\t\t\tisChecked={ isChecked }\n\t\t\t{ ...remainingProps }\n\t\t/>\n\t);\n}\n"],"mappings":";AAAA;AACA;AACA;AACA,SAASA,SAAS,EAAEC,WAAW,QAAQ,iBAAiB;AACxD,SAASC,qCAAqC,IAAIC,UAAU,QAAQ,sBAAsB;AAC1F,SAASC,KAAK,IAAIC,gBAAgB,QAAQ,wBAAwB;AAElE,eAAe,SAASC,aAAaA,CAAEC,KAAK,EAAG;EAC9C,MAAM;IACLC,KAAK,GAAG,gBAAgB;IACxBC,WAAW;IACXC,QAAQ,GAAGA,CAAA,KAAM,CAAC,CAAC;IACnB,GAAGC;EACJ,CAAC,GAAGJ,KAAK;EACT,MAAMK,SAAS,GAAGZ,SAAS,CACxBa,MAAM,IAAM,CAAC,CAAEA,MAAM,CAAER,gBAAiB,CAAC,CAACS,GAAG,CAAEN,KAAK,EAAEC,WAAY,CAAC,EACrE,CAAED,KAAK,EAAEC,WAAW,CACrB,CAAC;EACD,MAAM;IAAEM;EAAO,CAAC,GAAGd,WAAW,CAAEI,gBAAiB,CAAC;EAClD,MAAMW,QAAQ,GAAGA,CAAA,KAAM;IACtBN,QAAQ,CAAC,CAAC;IACVK,MAAM,CAAEP,KAAK,EAAEC,WAAY,CAAC;EAC7B,CAAC;EACD,OACCQ,aAAA,CAACd,UAAU;IACVa,QAAQ,EAAGA,QAAU;IACrBJ,SAAS,EAAGA,SAAW;IAAA,GAClBD;EAAc,CACnB,CAAC;AAEJ"}
|
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* WordPress dependencies
|
|
3
|
-
*/
|
|
4
|
-
import { compose, ifCondition } from '@wordpress/compose';
|
|
5
|
-
import { withSelect, withDispatch } from '@wordpress/data';
|
|
6
|
-
import { ___unstablePreferencesModalBaseOption as BaseOption } from '@wordpress/interface';
|
|
7
|
-
import { store as editorStore } from '@wordpress/editor';
|
|
8
|
-
export default compose(withSelect((select, {
|
|
9
|
-
panelName
|
|
10
|
-
}) => {
|
|
11
|
-
const {
|
|
12
|
-
isEditorPanelEnabled,
|
|
13
|
-
isEditorPanelRemoved
|
|
14
|
-
} = select(editorStore);
|
|
15
|
-
return {
|
|
16
|
-
isRemoved: isEditorPanelRemoved(panelName),
|
|
17
|
-
isChecked: isEditorPanelEnabled(panelName)
|
|
18
|
-
};
|
|
19
|
-
}), ifCondition(({
|
|
20
|
-
isRemoved
|
|
21
|
-
}) => !isRemoved), withDispatch((dispatch, {
|
|
22
|
-
panelName
|
|
23
|
-
}) => ({
|
|
24
|
-
onChange: () => dispatch(editorStore).toggleEditorPanelEnabled(panelName)
|
|
25
|
-
})))(BaseOption);
|
|
26
|
-
//# sourceMappingURL=enable-panel-option.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"names":["compose","ifCondition","withSelect","withDispatch","___unstablePreferencesModalBaseOption","BaseOption","store","editorStore","select","panelName","isEditorPanelEnabled","isEditorPanelRemoved","isRemoved","isChecked","dispatch","onChange","toggleEditorPanelEnabled"],"sources":["@wordpress/edit-site/src/components/preferences-modal/enable-panel-option.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { compose, ifCondition } from '@wordpress/compose';\nimport { withSelect, withDispatch } from '@wordpress/data';\nimport { ___unstablePreferencesModalBaseOption as BaseOption } from '@wordpress/interface';\nimport { store as editorStore } from '@wordpress/editor';\n\nexport default compose(\n\twithSelect( ( select, { panelName } ) => {\n\t\tconst { isEditorPanelEnabled, isEditorPanelRemoved } =\n\t\t\tselect( editorStore );\n\t\treturn {\n\t\t\tisRemoved: isEditorPanelRemoved( panelName ),\n\t\t\tisChecked: isEditorPanelEnabled( panelName ),\n\t\t};\n\t} ),\n\tifCondition( ( { isRemoved } ) => ! isRemoved ),\n\twithDispatch( ( dispatch, { panelName } ) => ( {\n\t\tonChange: () =>\n\t\t\tdispatch( editorStore ).toggleEditorPanelEnabled( panelName ),\n\t} ) )\n)( BaseOption );\n"],"mappings":"AAAA;AACA;AACA;AACA,SAASA,OAAO,EAAEC,WAAW,QAAQ,oBAAoB;AACzD,SAASC,UAAU,EAAEC,YAAY,QAAQ,iBAAiB;AAC1D,SAASC,qCAAqC,IAAIC,UAAU,QAAQ,sBAAsB;AAC1F,SAASC,KAAK,IAAIC,WAAW,QAAQ,mBAAmB;AAExD,eAAeP,OAAO,CACrBE,UAAU,CAAE,CAAEM,MAAM,EAAE;EAAEC;AAAU,CAAC,KAAM;EACxC,MAAM;IAAEC,oBAAoB;IAAEC;EAAqB,CAAC,GACnDH,MAAM,CAAED,WAAY,CAAC;EACtB,OAAO;IACNK,SAAS,EAAED,oBAAoB,CAAEF,SAAU,CAAC;IAC5CI,SAAS,EAAEH,oBAAoB,CAAED,SAAU;EAC5C,CAAC;AACF,CAAE,CAAC,EACHR,WAAW,CAAE,CAAE;EAAEW;AAAU,CAAC,KAAM,CAAEA,SAAU,CAAC,EAC/CT,YAAY,CAAE,CAAEW,QAAQ,EAAE;EAAEL;AAAU,CAAC,MAAQ;EAC9CM,QAAQ,EAAEA,CAAA,KACTD,QAAQ,CAAEP,WAAY,CAAC,CAACS,wBAAwB,CAAEP,SAAU;AAC9D,CAAC,CAAG,CACL,CAAC,CAAEJ,UAAW,CAAC"}
|
package/src/components/global-styles/font-library-modal/utils/get-intersecting-font-faces.js
DELETED
|
@@ -1,58 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Retrieves intersecting font faces between two sets of fonts.
|
|
3
|
-
*
|
|
4
|
-
* For each font in the `incoming` list, the function checks for a corresponding match
|
|
5
|
-
* in the `existing` list based on the `slug` property. If a match is found and both
|
|
6
|
-
* have `fontFace` properties, it further narrows down to matching font faces based on
|
|
7
|
-
* the `fontWeight` and `fontStyle`. The result includes the properties of the matched
|
|
8
|
-
* existing font but only with intersecting font faces.
|
|
9
|
-
*
|
|
10
|
-
* @param {Array.<{ slug: string, fontFace?: Array.<{ fontWeight: string, fontStyle: string }> }>} incoming - The list of fonts to compare.
|
|
11
|
-
* @param {Array.<{ slug: string, fontFace?: Array.<{ fontWeight: string, fontStyle: string }> }>} existing - The reference list of fonts.
|
|
12
|
-
*
|
|
13
|
-
* @return {Array.<{ slug: string, fontFace?: Array.<{ fontWeight: string, fontStyle: string }> }>} An array of fonts from the `existing` list with intersecting font faces.
|
|
14
|
-
*
|
|
15
|
-
* @example
|
|
16
|
-
* const incomingFonts = [
|
|
17
|
-
* { slug: 'arial', fontFace: [{ fontWeight: '400', fontStyle: 'normal' }] },
|
|
18
|
-
* { slug: 'times-new', fontFace: [{ fontWeight: '700', fontStyle: 'italic' }] }
|
|
19
|
-
* ];
|
|
20
|
-
*
|
|
21
|
-
* const existingFonts = [
|
|
22
|
-
* { slug: 'arial', fontFace: [{ fontWeight: '400', fontStyle: 'normal' }, { fontWeight: '700', fontStyle: 'italic' }] },
|
|
23
|
-
* { slug: 'helvetica', fontFace: [{ fontWeight: '400', fontStyle: 'normal' }] }
|
|
24
|
-
* ];
|
|
25
|
-
*
|
|
26
|
-
* getIntersectingFontFaces(incomingFonts, existingFonts);
|
|
27
|
-
* // Returns:
|
|
28
|
-
* // [{ slug: 'arial', fontFace: [{ fontWeight: '400', fontStyle: 'normal' }] }]
|
|
29
|
-
*/
|
|
30
|
-
export default function getIntersectingFontFaces( incoming, existing ) {
|
|
31
|
-
const matches = [];
|
|
32
|
-
|
|
33
|
-
for ( const incomingFont of incoming ) {
|
|
34
|
-
const existingFont = existing.find(
|
|
35
|
-
( f ) => f.slug === incomingFont.slug
|
|
36
|
-
);
|
|
37
|
-
|
|
38
|
-
if ( existingFont ) {
|
|
39
|
-
if ( incomingFont?.fontFace ) {
|
|
40
|
-
const matchingFaces = incomingFont.fontFace.filter(
|
|
41
|
-
( face ) => {
|
|
42
|
-
return ( existingFont?.fontFace || [] ).find( ( f ) => {
|
|
43
|
-
return (
|
|
44
|
-
f.fontWeight === face.fontWeight &&
|
|
45
|
-
f.fontStyle === face.fontStyle
|
|
46
|
-
);
|
|
47
|
-
} );
|
|
48
|
-
}
|
|
49
|
-
);
|
|
50
|
-
matches.push( { ...incomingFont, fontFace: matchingFaces } );
|
|
51
|
-
} else {
|
|
52
|
-
matches.push( incomingFont );
|
|
53
|
-
}
|
|
54
|
-
}
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
return matches;
|
|
58
|
-
}
|
|
@@ -1,62 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* WordPress dependencies
|
|
3
|
-
*/
|
|
4
|
-
import { __ } from '@wordpress/i18n';
|
|
5
|
-
|
|
6
|
-
export function getNoticeFromInstallResponse( response ) {
|
|
7
|
-
const { errors = [], successes = [] } = response;
|
|
8
|
-
// Everything failed.
|
|
9
|
-
if ( errors.length && ! successes.length ) {
|
|
10
|
-
return {
|
|
11
|
-
type: 'error',
|
|
12
|
-
message: __( 'Error installing the fonts.' ),
|
|
13
|
-
};
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
// Eveerything succeeded.
|
|
17
|
-
if ( ! errors.length && successes.length ) {
|
|
18
|
-
return {
|
|
19
|
-
type: 'success',
|
|
20
|
-
message: __( 'Fonts were installed successfully.' ),
|
|
21
|
-
};
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
// Some succeeded, some failed.
|
|
25
|
-
if ( errors.length && successes.length ) {
|
|
26
|
-
return {
|
|
27
|
-
type: 'warning',
|
|
28
|
-
message: __(
|
|
29
|
-
'Some fonts were installed successfully and some failed.'
|
|
30
|
-
),
|
|
31
|
-
};
|
|
32
|
-
}
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
export function getNoticeFromUninstallResponse( response ) {
|
|
36
|
-
const { errors = [], successes = [] } = response;
|
|
37
|
-
// Everything failed.
|
|
38
|
-
if ( errors.length && ! successes.length ) {
|
|
39
|
-
return {
|
|
40
|
-
type: 'error',
|
|
41
|
-
message: __( 'Error uninstalling the fonts.' ),
|
|
42
|
-
};
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
// Everything succeeded.
|
|
46
|
-
if ( ! errors.length && successes.length ) {
|
|
47
|
-
return {
|
|
48
|
-
type: 'success',
|
|
49
|
-
message: __( 'Fonts were uninstalled successfully.' ),
|
|
50
|
-
};
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
// Some succeeded, some failed.
|
|
54
|
-
if ( errors.length && successes.length ) {
|
|
55
|
-
return {
|
|
56
|
-
type: 'warning',
|
|
57
|
-
message: __(
|
|
58
|
-
'Some fonts were uninstalled successfully and some failed.'
|
|
59
|
-
),
|
|
60
|
-
};
|
|
61
|
-
}
|
|
62
|
-
}
|