@wordpress/edit-site 6.2.0 → 6.4.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 +4 -0
- package/build/components/add-new-pattern/index.js +8 -2
- package/build/components/add-new-pattern/index.js.map +1 -1
- package/build/components/{add-new-page → add-new-post}/index.js +21 -17
- package/build/components/add-new-post/index.js.map +1 -0
- package/build/components/add-new-template/index.js +3 -1
- package/build/components/add-new-template/index.js.map +1 -1
- package/build/components/block-editor/use-site-editor-settings.js +6 -85
- package/build/components/block-editor/use-site-editor-settings.js.map +1 -1
- package/build/components/editor/index.js +21 -3
- package/build/components/editor/index.js.map +1 -1
- package/build/components/global-styles/background-panel.js +0 -5
- package/build/components/global-styles/background-panel.js.map +1 -1
- package/build/components/global-styles/block-preview-panel.js +14 -5
- package/build/components/global-styles/block-preview-panel.js.map +1 -1
- package/build/components/global-styles/font-families.js +42 -23
- package/build/components/global-styles/font-families.js.map +1 -1
- package/build/components/global-styles/font-library-modal/font-collection.js +13 -30
- package/build/components/global-styles/font-library-modal/font-collection.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 +60 -12
- package/build/components/global-styles/font-library-modal/installed-fonts.js.map +1 -1
- package/build/components/global-styles/font-sizes/confirm-delete-font-size-dialog.js +39 -0
- package/build/components/global-styles/font-sizes/confirm-delete-font-size-dialog.js.map +1 -0
- package/build/components/global-styles/font-sizes/confirm-reset-font-sizes-dialog.js +39 -0
- package/build/components/global-styles/font-sizes/confirm-reset-font-sizes-dialog.js.map +1 -0
- package/build/components/global-styles/font-sizes/font-size-preview.js +44 -0
- package/build/components/global-styles/font-sizes/font-size-preview.js.map +1 -0
- package/build/components/global-styles/font-sizes/font-size.js +213 -0
- package/build/components/global-styles/font-sizes/font-size.js.map +1 -0
- package/build/components/global-styles/font-sizes/font-sizes-count.js +50 -0
- package/build/components/global-styles/font-sizes/font-sizes-count.js.map +1 -0
- package/build/components/global-styles/font-sizes/font-sizes.js +163 -0
- package/build/components/global-styles/font-sizes/font-sizes.js.map +1 -0
- package/build/components/global-styles/font-sizes/rename-font-size-dialog.js +67 -0
- package/build/components/global-styles/font-sizes/rename-font-size-dialog.js.map +1 -0
- package/build/components/global-styles/hooks.js +0 -40
- package/build/components/global-styles/hooks.js.map +1 -1
- package/build/components/global-styles/preview-typography.js +47 -0
- package/build/components/global-styles/preview-typography.js.map +1 -0
- package/build/components/global-styles/screen-block.js +17 -1
- package/build/components/global-styles/screen-block.js.map +1 -1
- package/build/components/global-styles/screen-layout.js +5 -1
- package/build/components/global-styles/screen-layout.js.map +1 -1
- package/build/components/global-styles/screen-revisions/revisions-buttons.js +1 -1
- package/build/components/global-styles/screen-revisions/revisions-buttons.js.map +1 -1
- package/build/components/global-styles/screen-style-variations.js +2 -2
- package/build/components/global-styles/screen-style-variations.js.map +1 -1
- package/build/components/global-styles/screen-typography.js +3 -2
- package/build/components/global-styles/screen-typography.js.map +1 -1
- package/build/components/global-styles/shadows-edit-panel.js +1 -2
- package/build/components/global-styles/shadows-edit-panel.js.map +1 -1
- package/build/components/global-styles/size-control/index.js +85 -0
- package/build/components/global-styles/size-control/index.js.map +1 -0
- package/build/components/global-styles/style-variations-container.js +8 -5
- package/build/components/global-styles/style-variations-container.js.map +1 -1
- package/build/components/global-styles/typography-elements.js +0 -2
- package/build/components/global-styles/typography-elements.js.map +1 -1
- package/build/components/global-styles/ui.js +8 -0
- package/build/components/global-styles/ui.js.map +1 -1
- package/build/components/global-styles/variations/variation.js +4 -4
- package/build/components/global-styles/variations/variation.js.map +1 -1
- package/build/components/global-styles/variations/variations-color.js +4 -3
- package/build/components/global-styles/variations/variations-color.js.map +1 -1
- package/build/components/global-styles/variations/variations-typography.js +15 -29
- package/build/components/global-styles/variations/variations-typography.js.map +1 -1
- package/build/components/global-styles-sidebar/index.js +2 -2
- package/build/components/global-styles-sidebar/index.js.map +1 -1
- package/build/components/layout/index.js +22 -8
- package/build/components/layout/index.js.map +1 -1
- package/build/components/layout/router.js +30 -43
- package/build/components/layout/router.js.map +1 -1
- package/build/components/page-patterns/header.js +1 -1
- package/build/components/page-patterns/header.js.map +1 -1
- package/build/components/page-patterns/index.js +65 -49
- package/build/components/page-patterns/index.js.map +1 -1
- package/build/components/page-patterns/search-items.js +29 -4
- package/build/components/page-patterns/search-items.js.map +1 -1
- package/build/components/page-patterns/use-patterns.js +22 -55
- package/build/components/page-patterns/use-patterns.js.map +1 -1
- package/build/components/page-templates/index.js +56 -50
- package/build/components/page-templates/index.js.map +1 -1
- package/build/components/pagination/index.js +4 -4
- package/build/components/pagination/index.js.map +1 -1
- package/build/components/post-edit/index.js +105 -0
- package/build/components/post-edit/index.js.map +1 -0
- package/build/components/post-fields/index.js +314 -0
- package/build/components/post-fields/index.js.map +1 -0
- package/build/components/post-list/index.js +281 -0
- package/build/components/post-list/index.js.map +1 -0
- package/build/components/posts-app/index.js +11 -17
- package/build/components/posts-app/index.js.map +1 -1
- package/build/components/posts-app/router.js +85 -0
- package/build/components/posts-app/router.js.map +1 -0
- package/build/components/revisions/index.js +10 -7
- package/build/components/revisions/index.js.map +1 -1
- package/build/components/save-panel/index.js +1 -1
- package/build/components/save-panel/index.js.map +1 -1
- package/build/components/sidebar-dataviews/add-new-view.js +4 -1
- package/build/components/sidebar-dataviews/add-new-view.js.map +1 -1
- package/build/components/sidebar-dataviews/custom-dataviews-list.js +6 -2
- package/build/components/sidebar-dataviews/custom-dataviews-list.js.map +1 -1
- package/build/components/sidebar-dataviews/default-views.js +119 -93
- package/build/components/sidebar-dataviews/default-views.js.map +1 -1
- package/build/components/sidebar-dataviews/index.js +44 -2
- package/build/components/sidebar-dataviews/index.js.map +1 -1
- package/build/components/sidebar-navigation-screen-global-styles/content.js +64 -0
- package/build/components/sidebar-navigation-screen-global-styles/content.js.map +1 -0
- package/build/components/sidebar-navigation-screen-global-styles/index.js +2 -47
- package/build/components/sidebar-navigation-screen-global-styles/index.js.map +1 -1
- package/build/components/sidebar-navigation-screen-navigation-menu/rename-modal.js +3 -2
- package/build/components/sidebar-navigation-screen-navigation-menu/rename-modal.js.map +1 -1
- package/build/components/sidebar-navigation-screen-patterns/use-pattern-categories.js +3 -2
- package/build/components/sidebar-navigation-screen-patterns/use-pattern-categories.js.map +1 -1
- package/build/components/site-hub/index.js +81 -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 +3 -1
- package/build/components/sync-state-with-url/use-init-edited-entity-from-url.js.map +1 -1
- package/build/hooks/push-changes-to-global-styles/index.js +2 -2
- package/build/hooks/push-changes-to-global-styles/index.js.map +1 -1
- package/build/hooks/use-theme-style-variations/use-theme-style-variations-by-property.js +65 -42
- package/build/hooks/use-theme-style-variations/use-theme-style-variations-by-property.js.map +1 -1
- package/build/index.js +10 -0
- package/build/index.js.map +1 -1
- package/build/posts.js +57 -2
- package/build/posts.js.map +1 -1
- package/build/store/private-actions.js +7 -2
- package/build/store/private-actions.js.map +1 -1
- package/build/store/selectors.js +34 -6
- package/build/store/selectors.js.map +1 -1
- package/build/utils/get-filtered-template-parts.js +64 -0
- package/build/utils/get-filtered-template-parts.js.map +1 -0
- package/build-module/components/add-new-pattern/index.js +8 -2
- package/build-module/components/add-new-pattern/index.js.map +1 -1
- package/build-module/components/{add-new-page → add-new-post}/index.js +21 -17
- package/build-module/components/add-new-post/index.js.map +1 -0
- package/build-module/components/add-new-template/index.js +3 -1
- package/build-module/components/add-new-template/index.js.map +1 -1
- package/build-module/components/block-editor/use-site-editor-settings.js +6 -85
- package/build-module/components/block-editor/use-site-editor-settings.js.map +1 -1
- package/build-module/components/editor/index.js +21 -3
- package/build-module/components/editor/index.js.map +1 -1
- package/build-module/components/global-styles/background-panel.js +0 -5
- package/build-module/components/global-styles/background-panel.js.map +1 -1
- package/build-module/components/global-styles/block-preview-panel.js +14 -5
- package/build-module/components/global-styles/block-preview-panel.js.map +1 -1
- package/build-module/components/global-styles/font-families.js +44 -25
- package/build-module/components/global-styles/font-families.js.map +1 -1
- package/build-module/components/global-styles/font-library-modal/font-collection.js +14 -31
- package/build-module/components/global-styles/font-library-modal/font-collection.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 +63 -15
- package/build-module/components/global-styles/font-library-modal/installed-fonts.js.map +1 -1
- package/build-module/components/global-styles/font-sizes/confirm-delete-font-size-dialog.js +32 -0
- package/build-module/components/global-styles/font-sizes/confirm-delete-font-size-dialog.js.map +1 -0
- package/build-module/components/global-styles/font-sizes/confirm-reset-font-sizes-dialog.js +32 -0
- package/build-module/components/global-styles/font-sizes/confirm-reset-font-sizes-dialog.js.map +1 -0
- package/build-module/components/global-styles/font-sizes/font-size-preview.js +37 -0
- package/build-module/components/global-styles/font-sizes/font-size-preview.js.map +1 -0
- package/build-module/components/global-styles/font-sizes/font-size.js +207 -0
- package/build-module/components/global-styles/font-sizes/font-size.js.map +1 -0
- package/build-module/components/global-styles/font-sizes/font-sizes-count.js +43 -0
- package/build-module/components/global-styles/font-sizes/font-sizes-count.js.map +1 -0
- package/build-module/components/global-styles/font-sizes/font-sizes.js +157 -0
- package/build-module/components/global-styles/font-sizes/font-sizes.js.map +1 -0
- package/build-module/components/global-styles/font-sizes/rename-font-size-dialog.js +61 -0
- package/build-module/components/global-styles/font-sizes/rename-font-size-dialog.js.map +1 -0
- package/build-module/components/global-styles/hooks.js +0 -38
- package/build-module/components/global-styles/hooks.js.map +1 -1
- package/build-module/components/global-styles/preview-typography.js +39 -0
- package/build-module/components/global-styles/preview-typography.js.map +1 -0
- package/build-module/components/global-styles/screen-block.js +18 -1
- package/build-module/components/global-styles/screen-block.js.map +1 -1
- package/build-module/components/global-styles/screen-layout.js +5 -1
- package/build-module/components/global-styles/screen-layout.js.map +1 -1
- package/build-module/components/global-styles/screen-revisions/revisions-buttons.js +1 -1
- package/build-module/components/global-styles/screen-revisions/revisions-buttons.js.map +1 -1
- package/build-module/components/global-styles/screen-style-variations.js +2 -2
- package/build-module/components/global-styles/screen-style-variations.js.map +1 -1
- package/build-module/components/global-styles/screen-typography.js +3 -2
- package/build-module/components/global-styles/screen-typography.js.map +1 -1
- package/build-module/components/global-styles/shadows-edit-panel.js +1 -2
- package/build-module/components/global-styles/shadows-edit-panel.js.map +1 -1
- package/build-module/components/global-styles/size-control/index.js +79 -0
- package/build-module/components/global-styles/size-control/index.js.map +1 -0
- package/build-module/components/global-styles/style-variations-container.js +9 -6
- package/build-module/components/global-styles/style-variations-container.js.map +1 -1
- package/build-module/components/global-styles/typography-elements.js +0 -2
- package/build-module/components/global-styles/typography-elements.js.map +1 -1
- package/build-module/components/global-styles/ui.js +8 -0
- package/build-module/components/global-styles/ui.js.map +1 -1
- package/build-module/components/global-styles/variations/variation.js +5 -5
- package/build-module/components/global-styles/variations/variation.js.map +1 -1
- package/build-module/components/global-styles/variations/variations-color.js +5 -4
- package/build-module/components/global-styles/variations/variations-color.js.map +1 -1
- package/build-module/components/global-styles/variations/variations-typography.js +16 -30
- package/build-module/components/global-styles/variations/variations-typography.js.map +1 -1
- package/build-module/components/global-styles-sidebar/index.js +2 -2
- package/build-module/components/global-styles-sidebar/index.js.map +1 -1
- package/build-module/components/layout/index.js +20 -8
- package/build-module/components/layout/index.js.map +1 -1
- package/build-module/components/layout/router.js +30 -43
- package/build-module/components/layout/router.js.map +1 -1
- package/build-module/components/page-patterns/header.js +1 -1
- package/build-module/components/page-patterns/header.js.map +1 -1
- package/build-module/components/page-patterns/index.js +66 -50
- package/build-module/components/page-patterns/index.js.map +1 -1
- package/build-module/components/page-patterns/search-items.js +28 -4
- package/build-module/components/page-patterns/search-items.js.map +1 -1
- package/build-module/components/page-patterns/use-patterns.js +23 -56
- package/build-module/components/page-patterns/use-patterns.js.map +1 -1
- package/build-module/components/page-templates/index.js +58 -53
- package/build-module/components/page-templates/index.js.map +1 -1
- package/build-module/components/pagination/index.js +4 -4
- package/build-module/components/pagination/index.js.map +1 -1
- package/build-module/components/post-edit/index.js +98 -0
- package/build-module/components/post-edit/index.js.map +1 -0
- package/build-module/components/post-fields/index.js +306 -0
- package/build-module/components/post-fields/index.js.map +1 -0
- package/build-module/components/post-list/index.js +275 -0
- package/build-module/components/post-list/index.js.map +1 -0
- package/build-module/components/posts-app/index.js +11 -17
- package/build-module/components/posts-app/index.js.map +1 -1
- package/build-module/components/posts-app/router.js +77 -0
- package/build-module/components/posts-app/router.js.map +1 -0
- package/build-module/components/revisions/index.js +10 -7
- package/build-module/components/revisions/index.js.map +1 -1
- package/build-module/components/save-panel/index.js +1 -1
- package/build-module/components/save-panel/index.js.map +1 -1
- package/build-module/components/sidebar-dataviews/add-new-view.js +4 -1
- package/build-module/components/sidebar-dataviews/add-new-view.js.map +1 -1
- package/build-module/components/sidebar-dataviews/custom-dataviews-list.js +6 -2
- package/build-module/components/sidebar-dataviews/custom-dataviews-list.js.map +1 -1
- package/build-module/components/sidebar-dataviews/default-views.js +117 -92
- package/build-module/components/sidebar-dataviews/default-views.js.map +1 -1
- package/build-module/components/sidebar-dataviews/index.js +47 -5
- package/build-module/components/sidebar-dataviews/index.js.map +1 -1
- package/build-module/components/sidebar-navigation-screen-global-styles/content.js +57 -0
- package/build-module/components/sidebar-navigation-screen-global-styles/content.js.map +1 -0
- package/build-module/components/sidebar-navigation-screen-global-styles/index.js +2 -47
- package/build-module/components/sidebar-navigation-screen-global-styles/index.js.map +1 -1
- package/build-module/components/sidebar-navigation-screen-navigation-menu/rename-modal.js +3 -2
- package/build-module/components/sidebar-navigation-screen-navigation-menu/rename-modal.js.map +1 -1
- package/build-module/components/sidebar-navigation-screen-patterns/use-pattern-categories.js +3 -2
- package/build-module/components/sidebar-navigation-screen-patterns/use-pattern-categories.js.map +1 -1
- package/build-module/components/site-hub/index.js +81 -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 +3 -1
- package/build-module/components/sync-state-with-url/use-init-edited-entity-from-url.js.map +1 -1
- package/build-module/hooks/push-changes-to-global-styles/index.js +2 -2
- package/build-module/hooks/push-changes-to-global-styles/index.js.map +1 -1
- package/build-module/hooks/use-theme-style-variations/use-theme-style-variations-by-property.js +61 -38
- package/build-module/hooks/use-theme-style-variations/use-theme-style-variations-by-property.js.map +1 -1
- package/build-module/index.js +11 -2
- package/build-module/index.js.map +1 -1
- package/build-module/posts.js +57 -2
- package/build-module/posts.js.map +1 -1
- package/build-module/store/private-actions.js +7 -2
- package/build-module/store/private-actions.js.map +1 -1
- package/build-module/store/selectors.js +35 -7
- package/build-module/store/selectors.js.map +1 -1
- package/build-module/utils/get-filtered-template-parts.js +57 -0
- package/build-module/utils/get-filtered-template-parts.js.map +1 -0
- package/build-style/posts-rtl.css +668 -510
- package/build-style/posts.css +668 -510
- package/build-style/style-rtl.css +772 -702
- package/build-style/style.css +772 -702
- package/package.json +41 -41
- package/src/components/add-new-pattern/index.js +8 -2
- package/src/components/{add-new-page → add-new-post}/index.js +28 -22
- package/src/components/add-new-template/index.js +4 -1
- package/src/components/add-new-template/style.scss +4 -6
- package/src/components/block-editor/use-site-editor-settings.js +10 -101
- package/src/components/editor/index.js +21 -5
- package/src/components/global-styles/background-panel.js +0 -8
- package/src/components/global-styles/block-preview-panel.js +22 -9
- package/src/components/global-styles/font-families.js +66 -31
- package/src/components/global-styles/font-library-modal/font-collection.js +17 -32
- package/src/components/global-styles/font-library-modal/index.js +4 -2
- package/src/components/global-styles/font-library-modal/installed-fonts.js +94 -13
- package/src/components/global-styles/font-library-modal/style.scss +26 -10
- package/src/components/global-styles/font-sizes/confirm-delete-font-size-dialog.js +43 -0
- package/src/components/global-styles/font-sizes/confirm-reset-font-sizes-dialog.js +37 -0
- package/src/components/global-styles/font-sizes/font-size-preview.js +43 -0
- package/src/components/global-styles/font-sizes/font-size.js +250 -0
- package/src/components/global-styles/font-sizes/font-sizes-count.js +40 -0
- package/src/components/global-styles/font-sizes/font-sizes.js +263 -0
- package/src/components/global-styles/font-sizes/rename-font-size-dialog.js +70 -0
- package/src/components/global-styles/hooks.js +0 -41
- package/src/components/global-styles/preview-typography.js +39 -0
- package/src/components/global-styles/screen-block.js +20 -0
- package/src/components/global-styles/screen-layout.js +5 -1
- package/src/components/global-styles/screen-revisions/revisions-buttons.js +1 -1
- package/src/components/global-styles/screen-style-variations.js +2 -2
- package/src/components/global-styles/screen-typography.js +3 -2
- package/src/components/global-styles/shadows-edit-panel.js +1 -2
- package/src/components/global-styles/size-control/index.js +86 -0
- package/src/components/global-styles/style-variations-container.js +14 -7
- package/src/components/global-styles/style.scss +13 -3
- package/src/components/global-styles/typography-elements.js +0 -4
- package/src/components/global-styles/ui.js +10 -0
- package/src/components/global-styles/variations/variation.js +5 -5
- package/src/components/global-styles/variations/variations-color.js +6 -4
- package/src/components/global-styles/variations/variations-typography.js +15 -33
- package/src/components/global-styles-sidebar/index.js +2 -2
- package/src/components/layout/index.js +24 -4
- package/src/components/layout/router.js +29 -37
- package/src/components/layout/style.scss +38 -8
- package/src/components/page-patterns/header.js +1 -1
- package/src/components/page-patterns/index.js +62 -64
- package/src/components/page-patterns/search-items.js +37 -3
- package/src/components/page-patterns/style.scss +1 -8
- package/src/components/page-patterns/use-patterns.js +43 -82
- package/src/components/page-templates/index.js +67 -64
- package/src/components/page-templates/style.scss +6 -9
- package/src/components/pagination/index.js +4 -4
- package/src/components/post-edit/index.js +96 -0
- package/src/components/post-edit/style.scss +9 -0
- package/src/components/post-fields/index.js +345 -0
- package/src/components/post-list/index.js +326 -0
- package/src/components/{page-pages → post-list}/style.scss +25 -8
- package/src/components/posts-app/index.js +9 -11
- package/src/components/posts-app/router.js +69 -0
- package/src/components/revisions/index.js +9 -1
- package/src/components/save-panel/index.js +1 -1
- package/src/components/sidebar/style.scss +6 -0
- package/src/components/sidebar-dataviews/add-new-view.js +2 -1
- package/src/components/sidebar-dataviews/custom-dataviews-list.js +6 -2
- package/src/components/sidebar-dataviews/default-views.js +131 -106
- package/src/components/sidebar-dataviews/index.js +39 -4
- package/src/components/sidebar-navigation-screen-global-styles/content.js +55 -0
- package/src/components/sidebar-navigation-screen-global-styles/index.js +1 -54
- package/src/components/sidebar-navigation-screen-navigation-menu/rename-modal.js +2 -1
- package/src/components/sidebar-navigation-screen-patterns/use-pattern-categories.js +10 -2
- package/src/components/site-hub/index.js +84 -1
- package/src/components/sync-state-with-url/use-init-edited-entity-from-url.js +3 -2
- package/src/hooks/push-changes-to-global-styles/index.js +2 -2
- package/src/hooks/use-theme-style-variations/test/use-theme-style-variations-by-property.js +28 -24
- package/src/hooks/use-theme-style-variations/use-theme-style-variations-by-property.js +72 -47
- package/src/index.js +14 -1
- package/src/posts.js +63 -2
- package/src/posts.scss +9 -0
- package/src/store/private-actions.js +7 -3
- package/src/store/selectors.js +53 -14
- package/src/store/test/selectors.js +1 -26
- package/src/style.scss +2 -2
- package/src/utils/get-filtered-template-parts.js +61 -0
- package/src/utils/test/get-filtered-template-parts.js +127 -0
- package/build/components/add-new-page/index.js.map +0 -1
- package/build/components/global-styles/screen-background.js +0 -36
- package/build/components/global-styles/screen-background.js.map +0 -1
- package/build/components/page-pages/index.js +0 -473
- package/build/components/page-pages/index.js.map +0 -1
- package/build/components/table/index.js +0 -35
- package/build/components/table/index.js.map +0 -1
- package/build-module/components/add-new-page/index.js.map +0 -1
- package/build-module/components/global-styles/screen-background.js +0 -30
- package/build-module/components/global-styles/screen-background.js.map +0 -1
- package/build-module/components/page-pages/index.js +0 -465
- package/build-module/components/page-pages/index.js.map +0 -1
- package/build-module/components/table/index.js +0 -30
- package/build-module/components/table/index.js.map +0 -1
- package/src/components/global-styles/screen-background.js +0 -29
- package/src/components/page-pages/index.js +0 -564
- package/src/components/table/index.js +0 -33
- package/src/components/table/style.scss +0 -38
|
@@ -5,9 +5,7 @@ import { __ } from '@wordpress/i18n';
|
|
|
5
5
|
import { edit, seen } from '@wordpress/icons';
|
|
6
6
|
import { useSelect, useDispatch } from '@wordpress/data';
|
|
7
7
|
import { store as coreStore } from '@wordpress/core-data';
|
|
8
|
-
import { __experimentalVStack as VStack } from '@wordpress/components';
|
|
9
8
|
import { useViewportMatch } from '@wordpress/compose';
|
|
10
|
-
import { BlockEditorProvider } from '@wordpress/block-editor';
|
|
11
9
|
import { useCallback } from '@wordpress/element';
|
|
12
10
|
import { store as editorStore } from '@wordpress/editor';
|
|
13
11
|
import { store as preferencesStore } from '@wordpress/preferences';
|
|
@@ -16,7 +14,6 @@ import { store as preferencesStore } from '@wordpress/preferences';
|
|
|
16
14
|
* Internal dependencies
|
|
17
15
|
*/
|
|
18
16
|
import SidebarNavigationScreen from '../sidebar-navigation-screen';
|
|
19
|
-
import StyleVariationsContainer from '../global-styles/style-variations-container';
|
|
20
17
|
import { unlock } from '../../lock-unlock';
|
|
21
18
|
import { store as editSiteStore } from '../../store';
|
|
22
19
|
import SidebarButton from '../sidebar-button';
|
|
@@ -24,14 +21,7 @@ import SidebarNavigationItem from '../sidebar-navigation-item';
|
|
|
24
21
|
import StyleBook from '../style-book';
|
|
25
22
|
import useGlobalStylesRevisions from '../global-styles/screen-revisions/use-global-styles-revisions';
|
|
26
23
|
import SidebarNavigationScreenDetailsFooter from '../sidebar-navigation-screen-details-footer';
|
|
27
|
-
import
|
|
28
|
-
import TypographyVariations from '../global-styles/variations/variations-typography';
|
|
29
|
-
import {
|
|
30
|
-
useColorVariations,
|
|
31
|
-
useTypographyVariations,
|
|
32
|
-
} from '../global-styles/hooks';
|
|
33
|
-
|
|
34
|
-
const noop = () => {};
|
|
24
|
+
import SidebarNavigationScreenGlobalStylesContent from './content';
|
|
35
25
|
|
|
36
26
|
export function SidebarNavigationItemGlobalStyles( props ) {
|
|
37
27
|
const { openGeneralSidebar } = useDispatch( editSiteStore );
|
|
@@ -66,49 +56,6 @@ export function SidebarNavigationItemGlobalStyles( props ) {
|
|
|
66
56
|
);
|
|
67
57
|
}
|
|
68
58
|
|
|
69
|
-
function SidebarNavigationScreenGlobalStylesContent() {
|
|
70
|
-
const { storedSettings } = useSelect( ( select ) => {
|
|
71
|
-
const { getSettings } = unlock( select( editSiteStore ) );
|
|
72
|
-
|
|
73
|
-
return {
|
|
74
|
-
storedSettings: getSettings(),
|
|
75
|
-
};
|
|
76
|
-
}, [] );
|
|
77
|
-
|
|
78
|
-
const colorVariations = useColorVariations();
|
|
79
|
-
const typographyVariations = useTypographyVariations();
|
|
80
|
-
const gap = 3;
|
|
81
|
-
|
|
82
|
-
// Wrap in a BlockEditorProvider to ensure that the Iframe's dependencies are
|
|
83
|
-
// loaded. This is necessary because the Iframe component waits until
|
|
84
|
-
// the block editor store's `__internalIsInitialized` is true before
|
|
85
|
-
// rendering the iframe. Without this, the iframe previews will not render
|
|
86
|
-
// in mobile viewport sizes, where the editor canvas is hidden.
|
|
87
|
-
return (
|
|
88
|
-
<BlockEditorProvider
|
|
89
|
-
settings={ storedSettings }
|
|
90
|
-
onChange={ noop }
|
|
91
|
-
onInput={ noop }
|
|
92
|
-
>
|
|
93
|
-
<VStack
|
|
94
|
-
spacing={ 10 }
|
|
95
|
-
className="edit-site-global-styles-variation-container"
|
|
96
|
-
>
|
|
97
|
-
<StyleVariationsContainer gap={ gap } />
|
|
98
|
-
{ colorVariations?.length && (
|
|
99
|
-
<ColorVariations title={ __( 'Palettes' ) } gap={ gap } />
|
|
100
|
-
) }
|
|
101
|
-
{ typographyVariations?.length && (
|
|
102
|
-
<TypographyVariations
|
|
103
|
-
title={ __( 'Typography' ) }
|
|
104
|
-
gap={ gap }
|
|
105
|
-
/>
|
|
106
|
-
) }
|
|
107
|
-
</VStack>
|
|
108
|
-
</BlockEditorProvider>
|
|
109
|
-
);
|
|
110
|
-
}
|
|
111
|
-
|
|
112
59
|
export default function SidebarNavigationScreenGlobalStyles( { backPath } ) {
|
|
113
60
|
const { revisions, isLoading: isLoadingRevisions } =
|
|
114
61
|
useGlobalStylesRevisions();
|
|
@@ -36,6 +36,7 @@ export default function RenameModal( { menuTitle, onClose, onSave } ) {
|
|
|
36
36
|
value={ editedMenuTitle }
|
|
37
37
|
placeholder={ __( 'Navigation title' ) }
|
|
38
38
|
onChange={ setEditedMenuTitle }
|
|
39
|
+
label={ __( 'Name' ) }
|
|
39
40
|
/>
|
|
40
41
|
<HStack justify="right">
|
|
41
42
|
<Button
|
|
@@ -48,7 +49,7 @@ export default function RenameModal( { menuTitle, onClose, onSave } ) {
|
|
|
48
49
|
|
|
49
50
|
<Button
|
|
50
51
|
__next40pxDefaultSize
|
|
51
|
-
|
|
52
|
+
accessibleWhenDisabled
|
|
52
53
|
disabled={ ! isEditedMenuTitleValid }
|
|
53
54
|
variant="primary"
|
|
54
55
|
type="submit"
|
|
@@ -58,13 +58,21 @@ export default function usePatternCategories() {
|
|
|
58
58
|
|
|
59
59
|
// Update the category counts to reflect user registered patterns.
|
|
60
60
|
userPatterns.forEach( ( pattern ) => {
|
|
61
|
-
pattern.
|
|
61
|
+
pattern.wp_pattern_category?.forEach( ( catId ) => {
|
|
62
|
+
const category = userPatternCategories.find(
|
|
63
|
+
( cat ) => cat.id === catId
|
|
64
|
+
)?.name;
|
|
62
65
|
if ( categoryMap[ category ] ) {
|
|
63
66
|
categoryMap[ category ].count += 1;
|
|
64
67
|
}
|
|
65
68
|
} );
|
|
66
69
|
// If the pattern has no categories, add it to uncategorized.
|
|
67
|
-
if (
|
|
70
|
+
if (
|
|
71
|
+
! pattern.wp_pattern_category?.length ||
|
|
72
|
+
! pattern.wp_pattern_category.some( ( catId ) =>
|
|
73
|
+
userPatternCategories.find( ( cat ) => cat.id === catId )
|
|
74
|
+
)
|
|
75
|
+
) {
|
|
68
76
|
categoryMap.uncategorized.count += 1;
|
|
69
77
|
}
|
|
70
78
|
} );
|
|
@@ -11,11 +11,12 @@ import { Button, __experimentalHStack as HStack } from '@wordpress/components';
|
|
|
11
11
|
import { __ } from '@wordpress/i18n';
|
|
12
12
|
import { store as coreStore } from '@wordpress/core-data';
|
|
13
13
|
import { decodeEntities } from '@wordpress/html-entities';
|
|
14
|
-
import { memo, forwardRef } from '@wordpress/element';
|
|
14
|
+
import { memo, forwardRef, useContext } from '@wordpress/element';
|
|
15
15
|
import { search } from '@wordpress/icons';
|
|
16
16
|
import { store as commandsStore } from '@wordpress/commands';
|
|
17
17
|
import { displayShortcut } from '@wordpress/keycodes';
|
|
18
18
|
import { filterURLForDisplay } from '@wordpress/url';
|
|
19
|
+
import { privateApis as routerPrivateApis } from '@wordpress/router';
|
|
19
20
|
|
|
20
21
|
/**
|
|
21
22
|
* Internal dependencies
|
|
@@ -23,6 +24,8 @@ import { filterURLForDisplay } from '@wordpress/url';
|
|
|
23
24
|
import { store as editSiteStore } from '../../store';
|
|
24
25
|
import SiteIcon from '../site-icon';
|
|
25
26
|
import { unlock } from '../../lock-unlock';
|
|
27
|
+
const { useHistory } = unlock( routerPrivateApis );
|
|
28
|
+
import { SidebarNavigationContext } from '../sidebar';
|
|
26
29
|
|
|
27
30
|
const SiteHub = memo(
|
|
28
31
|
forwardRef( ( { isTransparent }, ref ) => {
|
|
@@ -103,3 +106,83 @@ const SiteHub = memo(
|
|
|
103
106
|
);
|
|
104
107
|
|
|
105
108
|
export default SiteHub;
|
|
109
|
+
|
|
110
|
+
export const SiteHubMobile = memo(
|
|
111
|
+
forwardRef( ( { isTransparent }, ref ) => {
|
|
112
|
+
const history = useHistory();
|
|
113
|
+
const { navigate } = useContext( SidebarNavigationContext );
|
|
114
|
+
|
|
115
|
+
const { homeUrl, siteTitle } = useSelect( ( select ) => {
|
|
116
|
+
const {
|
|
117
|
+
getSite,
|
|
118
|
+
getUnstableBase, // Site index.
|
|
119
|
+
} = select( coreStore );
|
|
120
|
+
const _site = getSite();
|
|
121
|
+
return {
|
|
122
|
+
homeUrl: getUnstableBase()?.home,
|
|
123
|
+
siteTitle:
|
|
124
|
+
! _site?.title && !! _site?.url
|
|
125
|
+
? filterURLForDisplay( _site?.url )
|
|
126
|
+
: _site?.title,
|
|
127
|
+
};
|
|
128
|
+
}, [] );
|
|
129
|
+
const { open: openCommandCenter } = useDispatch( commandsStore );
|
|
130
|
+
|
|
131
|
+
return (
|
|
132
|
+
<div className="edit-site-site-hub">
|
|
133
|
+
<HStack justify="flex-start" spacing="0">
|
|
134
|
+
<div
|
|
135
|
+
className={ clsx(
|
|
136
|
+
'edit-site-site-hub__view-mode-toggle-container',
|
|
137
|
+
{
|
|
138
|
+
'has-transparent-background': isTransparent,
|
|
139
|
+
}
|
|
140
|
+
) }
|
|
141
|
+
>
|
|
142
|
+
<Button
|
|
143
|
+
ref={ ref }
|
|
144
|
+
label={ __( 'Go to Site Editor' ) }
|
|
145
|
+
className="edit-site-layout__view-mode-toggle"
|
|
146
|
+
style={ {
|
|
147
|
+
transform: 'scale(0.5)',
|
|
148
|
+
borderRadius: 4,
|
|
149
|
+
} }
|
|
150
|
+
onClick={ () => {
|
|
151
|
+
history.push( {} );
|
|
152
|
+
navigate( 'back' );
|
|
153
|
+
} }
|
|
154
|
+
>
|
|
155
|
+
<SiteIcon className="edit-site-layout__view-mode-toggle-icon" />
|
|
156
|
+
</Button>
|
|
157
|
+
</div>
|
|
158
|
+
|
|
159
|
+
<HStack>
|
|
160
|
+
<div className="edit-site-site-hub__title">
|
|
161
|
+
<Button
|
|
162
|
+
variant="link"
|
|
163
|
+
href={ homeUrl }
|
|
164
|
+
target="_blank"
|
|
165
|
+
label={ __( 'View site (opens in a new tab)' ) }
|
|
166
|
+
>
|
|
167
|
+
{ decodeEntities( siteTitle ) }
|
|
168
|
+
</Button>
|
|
169
|
+
</div>
|
|
170
|
+
<HStack
|
|
171
|
+
spacing={ 0 }
|
|
172
|
+
expanded={ false }
|
|
173
|
+
className="edit-site-site-hub__actions"
|
|
174
|
+
>
|
|
175
|
+
<Button
|
|
176
|
+
className="edit-site-site-hub_toggle-command-center"
|
|
177
|
+
icon={ search }
|
|
178
|
+
onClick={ () => openCommandCenter() }
|
|
179
|
+
label={ __( 'Open command palette' ) }
|
|
180
|
+
shortcut={ displayShortcut.primary( 'k' ) }
|
|
181
|
+
/>
|
|
182
|
+
</HStack>
|
|
183
|
+
</HStack>
|
|
184
|
+
</HStack>
|
|
185
|
+
</div>
|
|
186
|
+
);
|
|
187
|
+
} )
|
|
188
|
+
);
|
|
@@ -27,7 +27,7 @@ const postTypesWithoutParentTemplate = [
|
|
|
27
27
|
PATTERN_TYPES.user,
|
|
28
28
|
];
|
|
29
29
|
|
|
30
|
-
const authorizedPostTypes = [ 'page' ];
|
|
30
|
+
const authorizedPostTypes = [ 'page', 'post' ];
|
|
31
31
|
|
|
32
32
|
function useResolveEditedEntityAndContext( { postId, postType } ) {
|
|
33
33
|
const {
|
|
@@ -213,7 +213,8 @@ function useResolveEditedEntityAndContext( { postId, postType } ) {
|
|
|
213
213
|
if ( postType && postId && authorizedPostTypes.includes( postType ) ) {
|
|
214
214
|
return { postType, postId };
|
|
215
215
|
}
|
|
216
|
-
|
|
216
|
+
// TODO: for post types lists we should probably not render the front page, but maybe a placeholder
|
|
217
|
+
// with a message like "Select a page" or something similar.
|
|
217
218
|
if ( homepageId ) {
|
|
218
219
|
return { postType: 'page', postId: homepageId };
|
|
219
220
|
}
|
|
@@ -339,7 +339,7 @@ function PushChangesToGlobalStylesControl( {
|
|
|
339
339
|
<Button
|
|
340
340
|
__next40pxDefaultSize
|
|
341
341
|
variant="secondary"
|
|
342
|
-
|
|
342
|
+
accessibleWhenDisabled
|
|
343
343
|
disabled={ changes.length === 0 }
|
|
344
344
|
onClick={ pushChanges }
|
|
345
345
|
>
|
|
@@ -375,7 +375,7 @@ function PushChangesToGlobalStyles( props ) {
|
|
|
375
375
|
const withPushChangesToGlobalStyles = createHigherOrderComponent(
|
|
376
376
|
( BlockEdit ) => ( props ) => (
|
|
377
377
|
<>
|
|
378
|
-
<BlockEdit { ...props } />
|
|
378
|
+
<BlockEdit key="edit" { ...props } />
|
|
379
379
|
{ props.isSelected && <PushChangesToGlobalStyles { ...props } /> }
|
|
380
380
|
</>
|
|
381
381
|
)
|
|
@@ -2,11 +2,11 @@
|
|
|
2
2
|
* Internal dependencies
|
|
3
3
|
*/
|
|
4
4
|
import {
|
|
5
|
-
|
|
6
|
-
|
|
5
|
+
filterObjectByProperties,
|
|
6
|
+
removePropertiesFromObject,
|
|
7
7
|
} from '../use-theme-style-variations-by-property';
|
|
8
8
|
|
|
9
|
-
describe( '
|
|
9
|
+
describe( 'filterObjectByProperties', () => {
|
|
10
10
|
const noop = () => {};
|
|
11
11
|
test.each( [
|
|
12
12
|
{
|
|
@@ -14,21 +14,21 @@ describe( 'filterObjectByProperty', () => {
|
|
|
14
14
|
foo: 'bar',
|
|
15
15
|
array: [ 1, 3, 4 ],
|
|
16
16
|
},
|
|
17
|
-
|
|
17
|
+
properties: [ 'array' ],
|
|
18
18
|
expected: { array: [ 1, 3, 4 ] },
|
|
19
19
|
},
|
|
20
20
|
{
|
|
21
21
|
object: {
|
|
22
22
|
foo: 'bar',
|
|
23
23
|
},
|
|
24
|
-
|
|
24
|
+
properties: [ 'does-not-exist' ],
|
|
25
25
|
expected: {},
|
|
26
26
|
},
|
|
27
27
|
{
|
|
28
28
|
object: {
|
|
29
29
|
foo: 'bar',
|
|
30
30
|
},
|
|
31
|
-
|
|
31
|
+
properties: false,
|
|
32
32
|
expected: {},
|
|
33
33
|
},
|
|
34
34
|
{
|
|
@@ -39,7 +39,7 @@ describe( 'filterObjectByProperty', () => {
|
|
|
39
39
|
},
|
|
40
40
|
},
|
|
41
41
|
},
|
|
42
|
-
|
|
42
|
+
properties: [ 'null' ],
|
|
43
43
|
expected: {
|
|
44
44
|
dig: {
|
|
45
45
|
deeper: {
|
|
@@ -52,19 +52,19 @@ describe( 'filterObjectByProperty', () => {
|
|
|
52
52
|
object: {
|
|
53
53
|
function: noop,
|
|
54
54
|
},
|
|
55
|
-
|
|
55
|
+
properties: [ 'function' ],
|
|
56
56
|
expected: {
|
|
57
57
|
function: noop,
|
|
58
58
|
},
|
|
59
59
|
},
|
|
60
60
|
{
|
|
61
61
|
object: [],
|
|
62
|
-
|
|
62
|
+
properties: [ 'something' ],
|
|
63
63
|
expected: {},
|
|
64
64
|
},
|
|
65
65
|
{
|
|
66
66
|
object: {},
|
|
67
|
-
|
|
67
|
+
properties: undefined,
|
|
68
68
|
expected: {},
|
|
69
69
|
},
|
|
70
70
|
{
|
|
@@ -74,7 +74,7 @@ describe( 'filterObjectByProperty', () => {
|
|
|
74
74
|
array: [ 1, 3, 4 ],
|
|
75
75
|
},
|
|
76
76
|
},
|
|
77
|
-
|
|
77
|
+
properties: [ 'nested-object-foo' ],
|
|
78
78
|
expected: {
|
|
79
79
|
'nested-object': {
|
|
80
80
|
'nested-object-foo': 'bar',
|
|
@@ -82,15 +82,15 @@ describe( 'filterObjectByProperty', () => {
|
|
|
82
82
|
},
|
|
83
83
|
},
|
|
84
84
|
] )(
|
|
85
|
-
'should filter object by $
|
|
86
|
-
( { expected, object,
|
|
87
|
-
const result =
|
|
85
|
+
'should filter object by $properties',
|
|
86
|
+
( { expected, object, properties } ) => {
|
|
87
|
+
const result = filterObjectByProperties( object, properties );
|
|
88
88
|
expect( result ).toEqual( expected );
|
|
89
89
|
}
|
|
90
90
|
);
|
|
91
91
|
} );
|
|
92
92
|
|
|
93
|
-
describe( '
|
|
93
|
+
describe( 'removePropertiesFromObject', () => {
|
|
94
94
|
const mockBaseVariation = {
|
|
95
95
|
settings: {
|
|
96
96
|
typography: {
|
|
@@ -188,34 +188,38 @@ describe( 'removePropertyFromObject', () => {
|
|
|
188
188
|
},
|
|
189
189
|
};
|
|
190
190
|
|
|
191
|
-
it( 'should return with no
|
|
191
|
+
it( 'should return with no properties', () => {
|
|
192
192
|
const object = { test: 'me' };
|
|
193
|
-
expect(
|
|
193
|
+
expect( removePropertiesFromObject( object, undefined ) ).toEqual(
|
|
194
194
|
object
|
|
195
195
|
);
|
|
196
196
|
} );
|
|
197
197
|
|
|
198
|
-
it( 'should return with non-string
|
|
198
|
+
it( 'should return with non-string properties', () => {
|
|
199
199
|
const object = { test: 'you' };
|
|
200
|
-
expect(
|
|
200
|
+
expect( removePropertiesFromObject( object, true ) ).toEqual( object );
|
|
201
201
|
} );
|
|
202
202
|
|
|
203
203
|
it( 'should return with empty object', () => {
|
|
204
204
|
const object = {};
|
|
205
|
-
expect(
|
|
205
|
+
expect( removePropertiesFromObject( object, [ 'color' ] ) ).toEqual(
|
|
206
|
+
object
|
|
207
|
+
);
|
|
206
208
|
} );
|
|
207
209
|
|
|
208
210
|
it( 'should return with null', () => {
|
|
209
|
-
expect(
|
|
211
|
+
expect( removePropertiesFromObject( null, [ 'color' ] ) ).toEqual(
|
|
212
|
+
null
|
|
213
|
+
);
|
|
210
214
|
} );
|
|
211
215
|
|
|
212
|
-
it( 'should remove the specified
|
|
216
|
+
it( 'should remove the specified properties from the object', () => {
|
|
213
217
|
expect(
|
|
214
|
-
|
|
218
|
+
removePropertiesFromObject(
|
|
215
219
|
{
|
|
216
220
|
...mockBaseVariation,
|
|
217
221
|
},
|
|
218
|
-
'typography'
|
|
222
|
+
[ 'typography' ]
|
|
219
223
|
)
|
|
220
224
|
).toEqual( {
|
|
221
225
|
settings: {
|
|
@@ -14,18 +14,20 @@ import { __ } from '@wordpress/i18n';
|
|
|
14
14
|
import cloneDeep from '../../utils/clone-deep';
|
|
15
15
|
import { unlock } from '../../lock-unlock';
|
|
16
16
|
|
|
17
|
-
const { GlobalStylesContext } = unlock(
|
|
17
|
+
const { GlobalStylesContext, areGlobalStyleConfigsEqual } = unlock(
|
|
18
|
+
blockEditorPrivateApis
|
|
19
|
+
);
|
|
18
20
|
const { mergeBaseAndUserConfigs } = unlock( editorPrivateApis );
|
|
19
21
|
|
|
20
22
|
/**
|
|
21
|
-
* Removes all instances of
|
|
23
|
+
* Removes all instances of properties from an object.
|
|
22
24
|
*
|
|
23
|
-
* @param {Object}
|
|
24
|
-
* @param {string}
|
|
25
|
+
* @param {Object} object The object to remove the properties from.
|
|
26
|
+
* @param {string[]} properties The properties to remove.
|
|
25
27
|
* @return {Object} The modified object.
|
|
26
28
|
*/
|
|
27
|
-
export function
|
|
28
|
-
if ( !
|
|
29
|
+
export function removePropertiesFromObject( object, properties ) {
|
|
30
|
+
if ( ! properties?.length ) {
|
|
29
31
|
return object;
|
|
30
32
|
}
|
|
31
33
|
|
|
@@ -38,26 +40,42 @@ export function removePropertyFromObject( object, property ) {
|
|
|
38
40
|
}
|
|
39
41
|
|
|
40
42
|
for ( const key in object ) {
|
|
41
|
-
if ( key
|
|
43
|
+
if ( properties.includes( key ) ) {
|
|
42
44
|
delete object[ key ];
|
|
43
45
|
} else if ( typeof object[ key ] === 'object' ) {
|
|
44
|
-
|
|
46
|
+
removePropertiesFromObject( object[ key ], properties );
|
|
45
47
|
}
|
|
46
48
|
}
|
|
47
49
|
return object;
|
|
48
50
|
}
|
|
49
51
|
|
|
50
52
|
/**
|
|
51
|
-
*
|
|
53
|
+
* Checks whether a style variation is empty.
|
|
54
|
+
*
|
|
55
|
+
* @param {Object} variation A style variation object.
|
|
56
|
+
* @param {string} variation.title The title of the variation.
|
|
57
|
+
* @param {Object} variation.settings The settings of the variation.
|
|
58
|
+
* @param {Object} variation.styles The styles of the variation.
|
|
59
|
+
* @return {boolean} Whether the variation is empty.
|
|
60
|
+
*/
|
|
61
|
+
function hasThemeVariation( { title, settings, styles } ) {
|
|
62
|
+
return (
|
|
63
|
+
title === __( 'Default' ) || // Always preserve the default variation.
|
|
64
|
+
Object.keys( settings ).length > 0 ||
|
|
65
|
+
Object.keys( styles ).length > 0
|
|
66
|
+
);
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
/**
|
|
70
|
+
* Fetches the current theme style variations that contain only the specified properties
|
|
52
71
|
* and merges them with the user config.
|
|
53
72
|
*
|
|
54
|
-
* @param {
|
|
55
|
-
* @param {string} props.property The property to filter by.
|
|
73
|
+
* @param {string[]} properties The properties to filter by.
|
|
56
74
|
* @return {Object[]|*} The merged object.
|
|
57
75
|
*/
|
|
58
|
-
export function useCurrentMergeThemeStyleVariationsWithUserConfig(
|
|
59
|
-
|
|
60
|
-
|
|
76
|
+
export function useCurrentMergeThemeStyleVariationsWithUserConfig(
|
|
77
|
+
properties = []
|
|
78
|
+
) {
|
|
61
79
|
const { variationsFromTheme } = useSelect( ( select ) => {
|
|
62
80
|
const _variationsFromTheme =
|
|
63
81
|
select(
|
|
@@ -70,55 +88,67 @@ export function useCurrentMergeThemeStyleVariationsWithUserConfig( {
|
|
|
70
88
|
}, [] );
|
|
71
89
|
const { user: userVariation } = useContext( GlobalStylesContext );
|
|
72
90
|
|
|
91
|
+
const propertiesAsString = properties.toString();
|
|
92
|
+
|
|
73
93
|
return useMemo( () => {
|
|
74
94
|
const clonedUserVariation = cloneDeep( userVariation );
|
|
75
95
|
|
|
76
96
|
// Get user variation and remove the settings for the given property.
|
|
77
|
-
const
|
|
97
|
+
const userVariationWithoutProperties = removePropertiesFromObject(
|
|
78
98
|
clonedUserVariation,
|
|
79
|
-
|
|
99
|
+
properties
|
|
80
100
|
);
|
|
81
|
-
|
|
101
|
+
userVariationWithoutProperties.title = __( 'Default' );
|
|
82
102
|
|
|
83
|
-
const
|
|
103
|
+
const variationsWithPropertiesAndBase = variationsFromTheme
|
|
84
104
|
.filter( ( variation ) => {
|
|
85
|
-
return
|
|
105
|
+
return isVariationWithProperties( variation, properties );
|
|
86
106
|
} )
|
|
87
107
|
.map( ( variation ) => {
|
|
88
108
|
return mergeBaseAndUserConfigs(
|
|
89
|
-
|
|
109
|
+
userVariationWithoutProperties,
|
|
90
110
|
variation
|
|
91
111
|
);
|
|
92
112
|
} );
|
|
93
113
|
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
...
|
|
114
|
+
const variationsByProperties = [
|
|
115
|
+
userVariationWithoutProperties,
|
|
116
|
+
...variationsWithPropertiesAndBase,
|
|
97
117
|
];
|
|
98
|
-
|
|
118
|
+
|
|
119
|
+
/*
|
|
120
|
+
* Filter out variations with no settings or styles.
|
|
121
|
+
*/
|
|
122
|
+
return variationsByProperties?.length
|
|
123
|
+
? variationsByProperties.filter( hasThemeVariation )
|
|
124
|
+
: [];
|
|
125
|
+
}, [ propertiesAsString, userVariation, variationsFromTheme ] );
|
|
99
126
|
}
|
|
100
127
|
|
|
101
128
|
/**
|
|
102
|
-
* Returns a new object, with properties specified in `
|
|
129
|
+
* Returns a new object, with properties specified in `properties` array.,
|
|
103
130
|
* maintain the original object tree structure.
|
|
104
|
-
* The function is recursive, so it will perform a deep search for the given
|
|
105
|
-
* E.g., the function will return `{ a: { b: { c: { test: 1 } } } }` if the
|
|
131
|
+
* The function is recursive, so it will perform a deep search for the given properties.
|
|
132
|
+
* E.g., the function will return `{ a: { b: { c: { test: 1 } } } }` if the properties are `[ 'test' ]`.
|
|
106
133
|
*
|
|
107
|
-
* @param {Object}
|
|
108
|
-
* @param {
|
|
134
|
+
* @param {Object} object The object to filter
|
|
135
|
+
* @param {string[]} properties The properties to filter by
|
|
109
136
|
* @return {Object} The merged object.
|
|
110
137
|
*/
|
|
111
|
-
export const
|
|
112
|
-
if ( ! object ) {
|
|
138
|
+
export const filterObjectByProperties = ( object, properties ) => {
|
|
139
|
+
if ( ! object || ! properties?.length ) {
|
|
113
140
|
return {};
|
|
114
141
|
}
|
|
115
142
|
|
|
116
143
|
const newObject = {};
|
|
117
144
|
Object.keys( object ).forEach( ( key ) => {
|
|
118
|
-
if ( key
|
|
145
|
+
if ( properties.includes( key ) ) {
|
|
119
146
|
newObject[ key ] = object[ key ];
|
|
120
147
|
} else if ( typeof object[ key ] === 'object' ) {
|
|
121
|
-
const newFilter =
|
|
148
|
+
const newFilter = filterObjectByProperties(
|
|
149
|
+
object[ key ],
|
|
150
|
+
properties
|
|
151
|
+
);
|
|
122
152
|
if ( Object.keys( newFilter ).length ) {
|
|
123
153
|
newObject[ key ] = newFilter;
|
|
124
154
|
}
|
|
@@ -128,23 +158,18 @@ export const filterObjectByProperty = ( object, property ) => {
|
|
|
128
158
|
};
|
|
129
159
|
|
|
130
160
|
/**
|
|
131
|
-
* Compares a style variation to the same variation filtered by
|
|
132
|
-
* Returns true if the variation contains only the
|
|
161
|
+
* Compares a style variation to the same variation filtered by the specified properties.
|
|
162
|
+
* Returns true if the variation contains only the properties specified.
|
|
133
163
|
*
|
|
134
|
-
* @param {Object}
|
|
135
|
-
* @param {string}
|
|
136
|
-
* @return {boolean} Whether the variation contains only
|
|
164
|
+
* @param {Object} variation The variation to compare.
|
|
165
|
+
* @param {string[]} properties The properties to compare.
|
|
166
|
+
* @return {boolean} Whether the variation contains only the specified properties.
|
|
137
167
|
*/
|
|
138
|
-
export function
|
|
139
|
-
const
|
|
168
|
+
export function isVariationWithProperties( variation, properties ) {
|
|
169
|
+
const variationWithProperties = filterObjectByProperties(
|
|
140
170
|
cloneDeep( variation ),
|
|
141
|
-
|
|
171
|
+
properties
|
|
142
172
|
);
|
|
143
173
|
|
|
144
|
-
return (
|
|
145
|
-
JSON.stringify( variationWithProperty?.styles ) ===
|
|
146
|
-
JSON.stringify( variation?.styles ) &&
|
|
147
|
-
JSON.stringify( variationWithProperty?.settings ) ===
|
|
148
|
-
JSON.stringify( variation?.settings )
|
|
149
|
-
);
|
|
174
|
+
return areGlobalStyleConfigsEqual( variationWithProperties, variation );
|
|
150
175
|
}
|
package/src/index.js
CHANGED
|
@@ -10,7 +10,10 @@ import {
|
|
|
10
10
|
import { dispatch } from '@wordpress/data';
|
|
11
11
|
import deprecated from '@wordpress/deprecated';
|
|
12
12
|
import { createRoot, StrictMode } from '@wordpress/element';
|
|
13
|
-
import {
|
|
13
|
+
import {
|
|
14
|
+
store as editorStore,
|
|
15
|
+
privateApis as editorPrivateApis,
|
|
16
|
+
} from '@wordpress/editor';
|
|
14
17
|
import { store as preferencesStore } from '@wordpress/preferences';
|
|
15
18
|
import {
|
|
16
19
|
registerLegacyWidgetBlock,
|
|
@@ -22,8 +25,15 @@ import {
|
|
|
22
25
|
*/
|
|
23
26
|
import './hooks';
|
|
24
27
|
import { store as editSiteStore } from './store';
|
|
28
|
+
import { unlock } from './lock-unlock';
|
|
25
29
|
import App from './components/app';
|
|
26
30
|
|
|
31
|
+
const {
|
|
32
|
+
registerDefaultActions,
|
|
33
|
+
registerCoreBlockBindingsSources,
|
|
34
|
+
bootstrapBlockBindingsSourcesFromServer,
|
|
35
|
+
} = unlock( editorPrivateApis );
|
|
36
|
+
|
|
27
37
|
/**
|
|
28
38
|
* Initializes the site editor screen.
|
|
29
39
|
*
|
|
@@ -39,6 +49,8 @@ export function initializeEditor( id, settings ) {
|
|
|
39
49
|
( { name } ) => name !== 'core/freeform'
|
|
40
50
|
);
|
|
41
51
|
registerCoreBlocks( coreBlocks );
|
|
52
|
+
bootstrapBlockBindingsSourcesFromServer( settings?.blockBindingsSources );
|
|
53
|
+
registerCoreBlockBindingsSources();
|
|
42
54
|
dispatch( blocksStore ).setFreeformFallbackBlockName( 'core/html' );
|
|
43
55
|
registerLegacyWidgetBlock( { inserter: false } );
|
|
44
56
|
registerWidgetGroupBlock( { inserter: false } );
|
|
@@ -47,6 +59,7 @@ export function initializeEditor( id, settings ) {
|
|
|
47
59
|
enableFSEBlocks: true,
|
|
48
60
|
} );
|
|
49
61
|
}
|
|
62
|
+
registerDefaultActions();
|
|
50
63
|
|
|
51
64
|
// We dispatch actions and update the store synchronously before rendering
|
|
52
65
|
// so that we won't trigger unnecessary re-renders with useEffect.
|