@wordpress/edit-site 5.33.0 → 5.35.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 +11 -3
- package/build/components/add-new-page/index.js +3 -0
- package/build/components/add-new-page/index.js.map +1 -1
- package/build/components/add-new-pattern/index.js +8 -7
- package/build/components/add-new-pattern/index.js.map +1 -1
- package/build/components/add-new-template/add-custom-generic-template-modal-content.js +3 -0
- package/build/components/add-new-template/add-custom-generic-template-modal-content.js.map +1 -1
- package/build/components/add-new-template/add-custom-template-modal-content.js +3 -1
- package/build/components/add-new-template/add-custom-template-modal-content.js.map +1 -1
- package/build/components/add-new-template/index.js +2 -2
- package/build/components/add-new-template/index.js.map +1 -1
- package/build/components/app/index.js +4 -2
- package/build/components/app/index.js.map +1 -1
- package/build/components/block-editor/editor-canvas.js +4 -18
- package/build/components/block-editor/editor-canvas.js.map +1 -1
- package/build/components/block-editor/resize-handle.js +20 -5
- package/build/components/block-editor/resize-handle.js.map +1 -1
- package/build/components/block-editor/site-editor-canvas.js +2 -2
- package/build/components/block-editor/site-editor-canvas.js.map +1 -1
- package/build/components/create-template-part-modal/index.js +3 -0
- package/build/components/create-template-part-modal/index.js.map +1 -1
- package/build/components/dataviews-actions/index.js +46 -0
- package/build/components/dataviews-actions/index.js.map +1 -0
- package/build/components/editor/index.js +95 -16
- package/build/components/editor/index.js.map +1 -1
- package/build/components/global-styles/background-panel.js +13 -1
- package/build/components/global-styles/background-panel.js.map +1 -1
- package/build/components/global-styles/color-indicator-wrapper.js +2 -2
- package/build/components/global-styles/color-indicator-wrapper.js.map +1 -1
- package/build/components/global-styles/color-palette-panel.js +5 -2
- package/build/components/global-styles/color-palette-panel.js.map +1 -1
- package/build/components/global-styles/font-library-modal/context.js +9 -3
- package/build/components/global-styles/font-library-modal/context.js.map +1 -1
- package/build/components/global-styles/font-library-modal/font-collection.js +7 -2
- package/build/components/global-styles/font-library-modal/font-collection.js.map +1 -1
- package/build/components/global-styles/font-library-modal/installed-fonts.js +22 -20
- package/build/components/global-styles/font-library-modal/installed-fonts.js.map +1 -1
- package/build/components/global-styles/font-library-modal/utils/sort-font-faces.js +6 -2
- package/build/components/global-styles/font-library-modal/utils/sort-font-faces.js.map +1 -1
- package/build/components/global-styles/gradients-palette-panel.js +1 -2
- package/build/components/global-styles/gradients-palette-panel.js.map +1 -1
- package/build/components/global-styles/hooks.js +5 -2
- package/build/components/global-styles/hooks.js.map +1 -1
- package/build/components/global-styles/icon-with-current-color.js +2 -2
- package/build/components/global-styles/icon-with-current-color.js.map +1 -1
- package/build/components/global-styles/preset-colors.js +29 -0
- package/build/components/global-styles/preset-colors.js.map +1 -0
- package/build/components/global-styles/preview-colors.js +3 -7
- package/build/components/global-styles/preview-colors.js.map +1 -1
- package/build/components/global-styles/screen-color-palette.js +5 -5
- package/build/components/global-styles/screen-color-palette.js.map +1 -1
- package/build/components/global-styles/screen-colors.js +1 -4
- package/build/components/global-styles/screen-colors.js.map +1 -1
- package/build/components/global-styles/screen-revisions/revisions-buttons.js +2 -2
- package/build/components/global-styles/screen-revisions/revisions-buttons.js.map +1 -1
- package/build/components/global-styles/style-variations-container.js +8 -2
- package/build/components/global-styles/style-variations-container.js.map +1 -1
- package/build/components/global-styles/typography-example.js +5 -2
- package/build/components/global-styles/typography-example.js.map +1 -1
- package/build/components/global-styles/ui.js +4 -1
- package/build/components/global-styles/ui.js.map +1 -1
- package/build/components/global-styles/variations/variation.js +12 -6
- package/build/components/global-styles/variations/variation.js.map +1 -1
- package/build/components/global-styles/variations/variations-color.js +5 -5
- package/build/components/global-styles/variations/variations-color.js.map +1 -1
- package/build/components/global-styles-sidebar/default-sidebar.js.map +1 -0
- package/build/components/{sidebar-edit-mode/global-styles-sidebar.js → global-styles-sidebar/index.js} +8 -5
- package/build/components/global-styles-sidebar/index.js.map +1 -0
- package/build/components/header-edit-mode/index.js +21 -137
- package/build/components/header-edit-mode/index.js.map +1 -1
- package/build/components/header-edit-mode/more-menu/index.js +3 -97
- package/build/components/header-edit-mode/more-menu/index.js.map +1 -1
- package/build/components/keyboard-shortcuts/register.js +0 -49
- package/build/components/keyboard-shortcuts/register.js.map +1 -1
- package/build/components/layout/index.js +9 -9
- package/build/components/layout/index.js.map +1 -1
- package/build/components/layout/router.js +70 -44
- package/build/components/layout/router.js.map +1 -1
- package/build/components/page/index.js +2 -2
- package/build/components/page/index.js.map +1 -1
- package/build/components/page-pages/index.js +4 -14
- package/build/components/page-pages/index.js.map +1 -1
- package/build/components/page-patterns/dataviews-pattern-actions.js +15 -87
- package/build/components/page-patterns/dataviews-pattern-actions.js.map +1 -1
- package/build/components/page-patterns/header.js +3 -1
- package/build/components/page-patterns/header.js.map +1 -1
- package/build/components/page-patterns/index.js +28 -68
- package/build/components/page-patterns/index.js.map +1 -1
- package/build/components/page-patterns/use-patterns.js +1 -0
- package/build/components/page-patterns/use-patterns.js.map +1 -1
- package/build/components/page-templates/hooks.js.map +1 -0
- package/build/components/{page-templates-template-parts → page-templates}/index.js +73 -94
- package/build/components/page-templates/index.js.map +1 -0
- package/build/components/pagination/index.js +2 -2
- package/build/components/pagination/index.js.map +1 -1
- package/build/components/pattern-modal/duplicate.js +7 -5
- package/build/components/pattern-modal/duplicate.js.map +1 -1
- package/build/components/plugin-template-setting-panel/index.js +9 -0
- package/build/components/plugin-template-setting-panel/index.js.map +1 -1
- package/build/components/resizable-frame/index.js +20 -9
- package/build/components/resizable-frame/index.js.map +1 -1
- package/build/components/revisions/index.js +5 -2
- package/build/components/revisions/index.js.map +1 -1
- package/build/components/save-panel/index.js +4 -4
- package/build/components/save-panel/index.js.map +1 -1
- package/build/components/sidebar/index.js +61 -31
- package/build/components/sidebar/index.js.map +1 -1
- package/build/components/sidebar-button/index.js +2 -2
- package/build/components/sidebar-button/index.js.map +1 -1
- package/build/components/sidebar-dataviews/dataview-item.js +2 -2
- package/build/components/sidebar-dataviews/dataview-item.js.map +1 -1
- package/build/components/sidebar-navigation-item/index.js +5 -3
- package/build/components/sidebar-navigation-item/index.js.map +1 -1
- package/build/components/sidebar-navigation-screen/index.js +6 -32
- package/build/components/sidebar-navigation-screen/index.js.map +1 -1
- package/build/components/sidebar-navigation-screen-details-panel/sidebar-navigation-screen-details-panel-row.js +2 -2
- package/build/components/sidebar-navigation-screen-details-panel/sidebar-navigation-screen-details-panel-row.js.map +1 -1
- package/build/components/sidebar-navigation-screen-global-styles/index.js +4 -1
- package/build/components/sidebar-navigation-screen-global-styles/index.js.map +1 -1
- package/build/components/sidebar-navigation-screen-navigation-menu/index.js +10 -3
- package/build/components/sidebar-navigation-screen-navigation-menu/index.js.map +1 -1
- package/build/components/sidebar-navigation-screen-navigation-menu/more-menu.js +16 -1
- package/build/components/sidebar-navigation-screen-navigation-menu/more-menu.js.map +1 -1
- package/build/components/sidebar-navigation-screen-navigation-menu/single-navigation-menu.js +3 -0
- package/build/components/sidebar-navigation-screen-navigation-menu/single-navigation-menu.js.map +1 -1
- package/build/components/sidebar-navigation-screen-navigation-menus/index.js +16 -6
- package/build/components/sidebar-navigation-screen-navigation-menus/index.js.map +1 -1
- package/build/components/sidebar-navigation-screen-navigation-menus/leaf-more-menu.js +2 -9
- package/build/components/sidebar-navigation-screen-navigation-menus/leaf-more-menu.js.map +1 -1
- package/build/components/sidebar-navigation-screen-page/index.js +39 -8
- package/build/components/sidebar-navigation-screen-page/index.js.map +1 -1
- package/build/components/sidebar-navigation-screen-page/status-label.js +2 -2
- package/build/components/sidebar-navigation-screen-page/status-label.js.map +1 -1
- package/build/components/sidebar-navigation-screen-pattern/index.js +3 -15
- package/build/components/sidebar-navigation-screen-pattern/index.js.map +1 -1
- package/build/components/sidebar-navigation-screen-pattern/template-part-navigation-menus.js +3 -1
- package/build/components/sidebar-navigation-screen-pattern/template-part-navigation-menus.js.map +1 -1
- package/build/components/sidebar-navigation-screen-pattern/use-pattern-details.js +1 -1
- package/build/components/sidebar-navigation-screen-pattern/use-pattern-details.js.map +1 -1
- package/build/components/sidebar-navigation-screen-patterns/category-item.js +3 -2
- package/build/components/sidebar-navigation-screen-patterns/category-item.js.map +1 -1
- package/build/components/sidebar-navigation-screen-patterns/index.js +25 -29
- package/build/components/sidebar-navigation-screen-patterns/index.js.map +1 -1
- package/build/components/sidebar-navigation-screen-template/index.js +5 -2
- package/build/components/sidebar-navigation-screen-template/index.js.map +1 -1
- package/build/components/sidebar-navigation-screen-templates-browse/content.js +3 -3
- package/build/components/sidebar-navigation-screen-templates-browse/content.js.map +1 -1
- package/build/components/sidebar-navigation-screen-templates-browse/index.js +6 -33
- package/build/components/sidebar-navigation-screen-templates-browse/index.js.map +1 -1
- package/build/components/site-hub/index.js +3 -3
- package/build/components/site-hub/index.js.map +1 -1
- package/build/components/site-icon/index.js +2 -2
- package/build/components/site-icon/index.js.map +1 -1
- package/build/components/style-book/index.js +10 -7
- package/build/components/style-book/index.js.map +1 -1
- package/build/components/sync-state-with-url/use-init-edited-entity-from-url.js +0 -8
- package/build/components/sync-state-with-url/use-init-edited-entity-from-url.js.map +1 -1
- package/build/components/template-actions/index.js +1 -1
- package/build/components/template-actions/index.js.map +1 -1
- package/build/components/template-part-converter/index.js +18 -1
- package/build/components/template-part-converter/index.js.map +1 -1
- package/build/deprecated.js +55 -0
- package/build/deprecated.js.map +1 -0
- package/build/hooks/use-theme-style-variations/use-theme-style-variations-by-property.js +40 -6
- package/build/hooks/use-theme-style-variations/use-theme-style-variations-by-property.js.map +1 -1
- package/build/index.js +18 -18
- package/build/index.js.map +1 -1
- package/build/utils/constants.js +1 -2
- package/build/utils/constants.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-activate-theme.js +9 -6
- package/build/utils/use-activate-theme.js.map +1 -1
- package/build-module/components/add-new-page/index.js +3 -0
- package/build-module/components/add-new-page/index.js.map +1 -1
- package/build-module/components/add-new-pattern/index.js +8 -7
- package/build-module/components/add-new-pattern/index.js.map +1 -1
- package/build-module/components/add-new-template/add-custom-generic-template-modal-content.js +3 -0
- package/build-module/components/add-new-template/add-custom-generic-template-modal-content.js.map +1 -1
- package/build-module/components/add-new-template/add-custom-template-modal-content.js +3 -1
- package/build-module/components/add-new-template/add-custom-template-modal-content.js.map +1 -1
- package/build-module/components/add-new-template/index.js +2 -2
- package/build-module/components/add-new-template/index.js.map +1 -1
- package/build-module/components/app/index.js +4 -2
- package/build-module/components/app/index.js.map +1 -1
- package/build-module/components/block-editor/editor-canvas.js +4 -18
- package/build-module/components/block-editor/editor-canvas.js.map +1 -1
- package/build-module/components/block-editor/resize-handle.js +21 -6
- package/build-module/components/block-editor/resize-handle.js.map +1 -1
- package/build-module/components/block-editor/site-editor-canvas.js +2 -2
- package/build-module/components/block-editor/site-editor-canvas.js.map +1 -1
- package/build-module/components/create-template-part-modal/index.js +3 -0
- package/build-module/components/create-template-part-modal/index.js.map +1 -1
- package/build-module/components/dataviews-actions/index.js +38 -0
- package/build-module/components/dataviews-actions/index.js.map +1 -0
- package/build-module/components/editor/index.js +96 -17
- package/build-module/components/editor/index.js.map +1 -1
- package/build-module/components/global-styles/background-panel.js +12 -1
- package/build-module/components/global-styles/background-panel.js.map +1 -1
- package/build-module/components/global-styles/color-indicator-wrapper.js +2 -2
- package/build-module/components/global-styles/color-indicator-wrapper.js.map +1 -1
- package/build-module/components/global-styles/color-palette-panel.js +4 -2
- package/build-module/components/global-styles/color-palette-panel.js.map +1 -1
- package/build-module/components/global-styles/font-library-modal/context.js +9 -3
- 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 +7 -2
- package/build-module/components/global-styles/font-library-modal/font-collection.js.map +1 -1
- package/build-module/components/global-styles/font-library-modal/installed-fonts.js +22 -20
- package/build-module/components/global-styles/font-library-modal/installed-fonts.js.map +1 -1
- package/build-module/components/global-styles/font-library-modal/utils/sort-font-faces.js +6 -2
- package/build-module/components/global-styles/font-library-modal/utils/sort-font-faces.js.map +1 -1
- package/build-module/components/global-styles/gradients-palette-panel.js +1 -2
- package/build-module/components/global-styles/gradients-palette-panel.js.map +1 -1
- package/build-module/components/global-styles/hooks.js +4 -1
- package/build-module/components/global-styles/hooks.js.map +1 -1
- package/build-module/components/global-styles/icon-with-current-color.js +2 -2
- package/build-module/components/global-styles/icon-with-current-color.js.map +1 -1
- package/build-module/components/global-styles/preset-colors.js +22 -0
- package/build-module/components/global-styles/preset-colors.js.map +1 -0
- package/build-module/components/global-styles/preview-colors.js +3 -7
- package/build-module/components/global-styles/preview-colors.js.map +1 -1
- package/build-module/components/global-styles/screen-color-palette.js +5 -5
- package/build-module/components/global-styles/screen-color-palette.js.map +1 -1
- package/build-module/components/global-styles/screen-colors.js +1 -4
- package/build-module/components/global-styles/screen-colors.js.map +1 -1
- package/build-module/components/global-styles/screen-revisions/revisions-buttons.js +2 -2
- package/build-module/components/global-styles/screen-revisions/revisions-buttons.js.map +1 -1
- package/build-module/components/global-styles/style-variations-container.js +8 -2
- package/build-module/components/global-styles/style-variations-container.js.map +1 -1
- package/build-module/components/global-styles/typography-example.js +4 -1
- package/build-module/components/global-styles/typography-example.js.map +1 -1
- package/build-module/components/global-styles/ui.js +4 -1
- package/build-module/components/global-styles/ui.js.map +1 -1
- package/build-module/components/global-styles/variations/variation.js +11 -5
- package/build-module/components/global-styles/variations/variation.js.map +1 -1
- package/build-module/components/global-styles/variations/variations-color.js +6 -6
- package/build-module/components/global-styles/variations/variations-color.js.map +1 -1
- package/build-module/components/global-styles-sidebar/default-sidebar.js.map +1 -0
- package/build-module/components/{sidebar-edit-mode/global-styles-sidebar.js → global-styles-sidebar/index.js} +8 -5
- package/build-module/components/global-styles-sidebar/index.js.map +1 -0
- package/build-module/components/header-edit-mode/index.js +22 -138
- package/build-module/components/header-edit-mode/index.js.map +1 -1
- package/build-module/components/header-edit-mode/more-menu/index.js +5 -99
- package/build-module/components/header-edit-mode/more-menu/index.js.map +1 -1
- package/build-module/components/keyboard-shortcuts/register.js +0 -49
- package/build-module/components/keyboard-shortcuts/register.js.map +1 -1
- package/build-module/components/layout/index.js +9 -9
- package/build-module/components/layout/index.js.map +1 -1
- package/build-module/components/layout/router.js +70 -45
- package/build-module/components/layout/router.js.map +1 -1
- package/build-module/components/page/index.js +2 -2
- package/build-module/components/page/index.js.map +1 -1
- package/build-module/components/page-pages/index.js +5 -15
- package/build-module/components/page-pages/index.js.map +1 -1
- package/build-module/components/page-patterns/dataviews-pattern-actions.js +15 -87
- package/build-module/components/page-patterns/dataviews-pattern-actions.js.map +1 -1
- package/build-module/components/page-patterns/header.js +3 -1
- package/build-module/components/page-patterns/header.js.map +1 -1
- package/build-module/components/page-patterns/index.js +31 -71
- package/build-module/components/page-patterns/index.js.map +1 -1
- package/build-module/components/page-patterns/use-patterns.js +1 -0
- package/build-module/components/page-patterns/use-patterns.js.map +1 -1
- package/build-module/components/page-templates/hooks.js.map +1 -0
- package/build-module/components/{page-templates-template-parts → page-templates}/index.js +73 -94
- package/build-module/components/page-templates/index.js.map +1 -0
- package/build-module/components/pagination/index.js +2 -2
- package/build-module/components/pagination/index.js.map +1 -1
- package/build-module/components/pattern-modal/duplicate.js +7 -5
- package/build-module/components/pattern-modal/duplicate.js.map +1 -1
- package/build-module/components/plugin-template-setting-panel/index.js +8 -0
- package/build-module/components/plugin-template-setting-panel/index.js.map +1 -1
- package/build-module/components/resizable-frame/index.js +21 -10
- package/build-module/components/resizable-frame/index.js.map +1 -1
- package/build-module/components/revisions/index.js +4 -1
- package/build-module/components/revisions/index.js.map +1 -1
- package/build-module/components/save-panel/index.js +4 -4
- package/build-module/components/save-panel/index.js.map +1 -1
- package/build-module/components/sidebar/index.js +62 -32
- package/build-module/components/sidebar/index.js.map +1 -1
- package/build-module/components/sidebar-button/index.js +2 -2
- package/build-module/components/sidebar-button/index.js.map +1 -1
- package/build-module/components/sidebar-dataviews/dataview-item.js +2 -2
- package/build-module/components/sidebar-dataviews/dataview-item.js.map +1 -1
- package/build-module/components/sidebar-navigation-item/index.js +5 -3
- package/build-module/components/sidebar-navigation-item/index.js.map +1 -1
- package/build-module/components/sidebar-navigation-screen/index.js +6 -32
- package/build-module/components/sidebar-navigation-screen/index.js.map +1 -1
- package/build-module/components/sidebar-navigation-screen-details-panel/sidebar-navigation-screen-details-panel-row.js +2 -2
- package/build-module/components/sidebar-navigation-screen-details-panel/sidebar-navigation-screen-details-panel-row.js.map +1 -1
- package/build-module/components/sidebar-navigation-screen-global-styles/index.js +4 -1
- package/build-module/components/sidebar-navigation-screen-global-styles/index.js.map +1 -1
- package/build-module/components/sidebar-navigation-screen-navigation-menu/index.js +10 -3
- package/build-module/components/sidebar-navigation-screen-navigation-menu/index.js.map +1 -1
- package/build-module/components/sidebar-navigation-screen-navigation-menu/more-menu.js +16 -1
- package/build-module/components/sidebar-navigation-screen-navigation-menu/more-menu.js.map +1 -1
- package/build-module/components/sidebar-navigation-screen-navigation-menu/single-navigation-menu.js +3 -0
- package/build-module/components/sidebar-navigation-screen-navigation-menu/single-navigation-menu.js.map +1 -1
- package/build-module/components/sidebar-navigation-screen-navigation-menus/index.js +16 -6
- package/build-module/components/sidebar-navigation-screen-navigation-menus/index.js.map +1 -1
- package/build-module/components/sidebar-navigation-screen-navigation-menus/leaf-more-menu.js +2 -9
- package/build-module/components/sidebar-navigation-screen-navigation-menus/leaf-more-menu.js.map +1 -1
- package/build-module/components/sidebar-navigation-screen-page/index.js +40 -9
- package/build-module/components/sidebar-navigation-screen-page/index.js.map +1 -1
- package/build-module/components/sidebar-navigation-screen-page/status-label.js +2 -2
- package/build-module/components/sidebar-navigation-screen-page/status-label.js.map +1 -1
- package/build-module/components/sidebar-navigation-screen-pattern/index.js +3 -15
- package/build-module/components/sidebar-navigation-screen-pattern/index.js.map +1 -1
- package/build-module/components/sidebar-navigation-screen-pattern/template-part-navigation-menus.js +3 -1
- package/build-module/components/sidebar-navigation-screen-pattern/template-part-navigation-menus.js.map +1 -1
- package/build-module/components/sidebar-navigation-screen-pattern/use-pattern-details.js +1 -1
- package/build-module/components/sidebar-navigation-screen-pattern/use-pattern-details.js.map +1 -1
- package/build-module/components/sidebar-navigation-screen-patterns/category-item.js +3 -2
- package/build-module/components/sidebar-navigation-screen-patterns/category-item.js.map +1 -1
- package/build-module/components/sidebar-navigation-screen-patterns/index.js +26 -30
- package/build-module/components/sidebar-navigation-screen-patterns/index.js.map +1 -1
- package/build-module/components/sidebar-navigation-screen-template/index.js +5 -2
- package/build-module/components/sidebar-navigation-screen-template/index.js.map +1 -1
- package/build-module/components/sidebar-navigation-screen-templates-browse/content.js +3 -3
- package/build-module/components/sidebar-navigation-screen-templates-browse/content.js.map +1 -1
- package/build-module/components/sidebar-navigation-screen-templates-browse/index.js +6 -33
- package/build-module/components/sidebar-navigation-screen-templates-browse/index.js.map +1 -1
- package/build-module/components/site-hub/index.js +3 -3
- package/build-module/components/site-hub/index.js.map +1 -1
- package/build-module/components/site-icon/index.js +2 -2
- package/build-module/components/site-icon/index.js.map +1 -1
- package/build-module/components/style-book/index.js +9 -6
- package/build-module/components/style-book/index.js.map +1 -1
- package/build-module/components/sync-state-with-url/use-init-edited-entity-from-url.js +0 -8
- package/build-module/components/sync-state-with-url/use-init-edited-entity-from-url.js.map +1 -1
- package/build-module/components/template-actions/index.js +1 -1
- package/build-module/components/template-actions/index.js.map +1 -1
- package/build-module/components/template-part-converter/index.js +18 -1
- package/build-module/components/template-part-converter/index.js.map +1 -1
- package/build-module/deprecated.js +45 -0
- package/build-module/deprecated.js.map +1 -0
- package/build-module/hooks/use-theme-style-variations/use-theme-style-variations-by-property.js +38 -5
- package/build-module/hooks/use-theme-style-variations/use-theme-style-variations-by-property.js.map +1 -1
- package/build-module/index.js +2 -4
- package/build-module/index.js.map +1 -1
- package/build-module/utils/constants.js +0 -1
- package/build-module/utils/constants.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-activate-theme.js +9 -6
- package/build-module/utils/use-activate-theme.js.map +1 -1
- package/build-style/style-rtl.css +208 -484
- package/build-style/style.css +208 -484
- package/package.json +43 -45
- package/src/components/add-new-page/index.js +7 -1
- package/src/components/add-new-pattern/index.js +15 -12
- package/src/components/add-new-template/add-custom-generic-template-modal-content.js +3 -0
- package/src/components/add-new-template/add-custom-template-modal-content.js +3 -1
- package/src/components/add-new-template/index.js +2 -2
- package/src/components/app/index.js +5 -2
- package/src/components/block-editor/editor-canvas.js +6 -26
- package/src/components/block-editor/resize-handle.js +30 -11
- package/src/components/block-editor/site-editor-canvas.js +2 -2
- package/src/components/block-editor/style.scss +12 -17
- package/src/components/create-template-part-modal/index.js +3 -0
- package/src/components/dataviews-actions/index.js +38 -0
- package/src/components/editor/index.js +117 -18
- package/src/components/editor/style.scss +6 -5
- package/src/components/global-styles/background-panel.js +17 -2
- package/src/components/global-styles/color-indicator-wrapper.js +2 -2
- package/src/components/global-styles/color-palette-panel.js +3 -4
- package/src/components/global-styles/font-library-modal/context.js +9 -3
- package/src/components/global-styles/font-library-modal/font-collection.js +31 -12
- package/src/components/global-styles/font-library-modal/installed-fonts.js +82 -54
- package/src/components/global-styles/font-library-modal/style.scss +17 -0
- package/src/components/global-styles/font-library-modal/utils/sort-font-faces.js +6 -2
- package/src/components/global-styles/gradients-palette-panel.js +1 -4
- package/src/components/global-styles/hooks.js +2 -1
- package/src/components/global-styles/icon-with-current-color.js +2 -2
- package/src/components/global-styles/preset-colors.js +18 -0
- package/src/components/global-styles/preview-colors.js +4 -7
- package/src/components/global-styles/screen-color-palette.js +4 -4
- package/src/components/global-styles/screen-colors.js +0 -2
- package/src/components/global-styles/screen-revisions/revisions-buttons.js +2 -2
- package/src/components/global-styles/stories/index.story.js +2 -1
- package/src/components/global-styles/style-variations-container.js +11 -2
- package/src/components/global-styles/typography-example.js +2 -1
- package/src/components/global-styles/ui.js +5 -1
- package/src/components/global-styles/variations/style.scss +15 -31
- package/src/components/global-styles/variations/variation.js +13 -10
- package/src/components/global-styles/variations/variations-color.js +5 -8
- package/src/components/{sidebar-edit-mode/global-styles-sidebar.js → global-styles-sidebar/index.js} +7 -2
- package/src/components/{sidebar-edit-mode → global-styles-sidebar}/style.scss +0 -11
- package/src/components/header-edit-mode/index.js +25 -184
- package/src/components/header-edit-mode/more-menu/index.js +8 -145
- package/src/components/header-edit-mode/style.scss +1 -271
- package/src/components/keyboard-shortcuts/register.js +0 -58
- package/src/components/layout/index.js +14 -10
- package/src/components/layout/router.js +66 -56
- package/src/components/layout/style.scss +2 -1
- package/src/components/page/index.js +2 -2
- package/src/components/page-pages/index.js +8 -28
- package/src/components/page-patterns/dataviews-pattern-actions.js +11 -101
- package/src/components/page-patterns/header.js +3 -1
- package/src/components/page-patterns/index.js +32 -110
- package/src/components/page-patterns/style.scss +14 -1
- package/src/components/page-patterns/use-patterns.js +1 -0
- package/src/components/{page-templates-template-parts → page-templates}/index.js +33 -75
- package/src/components/{page-templates-template-parts → page-templates}/style.scss +2 -2
- package/src/components/pagination/index.js +2 -2
- package/src/components/pattern-modal/duplicate.js +4 -3
- package/src/components/plugin-template-setting-panel/index.js +8 -0
- package/src/components/resizable-frame/index.js +20 -7
- package/src/components/revisions/index.js +2 -1
- package/src/components/save-panel/index.js +4 -4
- package/src/components/sidebar/index.js +61 -37
- package/src/components/sidebar-button/index.js +2 -5
- package/src/components/sidebar-dataviews/dataview-item.js +4 -7
- package/src/components/sidebar-navigation-item/index.js +3 -3
- package/src/components/sidebar-navigation-screen/index.js +7 -31
- package/src/components/sidebar-navigation-screen/style.scss +11 -9
- package/src/components/sidebar-navigation-screen-details-panel/sidebar-navigation-screen-details-panel-row.js +2 -2
- package/src/components/sidebar-navigation-screen-global-styles/index.js +2 -1
- package/src/components/sidebar-navigation-screen-navigation-menu/index.js +6 -1
- package/src/components/sidebar-navigation-screen-navigation-menu/more-menu.js +18 -1
- package/src/components/sidebar-navigation-screen-navigation-menu/single-navigation-menu.js +3 -0
- package/src/components/sidebar-navigation-screen-navigation-menus/index.js +8 -4
- package/src/components/sidebar-navigation-screen-navigation-menus/leaf-more-menu.js +0 -10
- package/src/components/sidebar-navigation-screen-page/index.js +48 -9
- package/src/components/sidebar-navigation-screen-page/status-label.js +2 -2
- package/src/components/sidebar-navigation-screen-pattern/index.js +1 -12
- package/src/components/sidebar-navigation-screen-pattern/template-part-navigation-menus.js +3 -1
- package/src/components/sidebar-navigation-screen-pattern/use-pattern-details.js +1 -1
- package/src/components/sidebar-navigation-screen-patterns/category-item.js +2 -1
- package/src/components/sidebar-navigation-screen-patterns/index.js +20 -39
- package/src/components/sidebar-navigation-screen-template/index.js +3 -2
- package/src/components/sidebar-navigation-screen-templates-browse/content.js +3 -3
- package/src/components/sidebar-navigation-screen-templates-browse/index.js +8 -39
- package/src/components/site-hub/index.js +3 -3
- package/src/components/site-icon/index.js +2 -2
- package/src/components/style-book/index.js +7 -6
- package/src/components/sync-state-with-url/use-init-edited-entity-from-url.js +0 -4
- package/src/components/template-actions/index.js +1 -1
- package/src/components/template-part-converter/index.js +16 -3
- package/src/deprecated.js +42 -0
- package/src/hooks/use-theme-style-variations/use-theme-style-variations-by-property.js +71 -17
- package/src/index.js +2 -9
- package/src/style.scss +2 -16
- package/src/utils/constants.js +1 -1
- package/src/utils/get-is-list-page.js +1 -3
- package/src/utils/use-activate-theme.js +4 -4
- package/build/components/global-styles/global-styles-provider.js +0 -129
- package/build/components/global-styles/global-styles-provider.js.map +0 -1
- package/build/components/header-edit-mode/document-tools/index.js +0 -68
- package/build/components/header-edit-mode/document-tools/index.js.map +0 -1
- package/build/components/header-edit-mode/more-menu/copy-content-menu-item.js +0 -59
- package/build/components/header-edit-mode/more-menu/copy-content-menu-item.js.map +0 -1
- package/build/components/header-edit-mode/tools-more-menu-group/index.js +0 -23
- package/build/components/header-edit-mode/tools-more-menu-group/index.js.map +0 -1
- package/build/components/keyboard-shortcuts/edit-mode.js +0 -56
- package/build/components/keyboard-shortcuts/edit-mode.js.map +0 -1
- package/build/components/page-templates-template-parts/add-new-template-part.js +0 -65
- package/build/components/page-templates-template-parts/add-new-template-part.js.map +0 -1
- package/build/components/page-templates-template-parts/hooks.js.map +0 -1
- package/build/components/page-templates-template-parts/index.js.map +0 -1
- package/build/components/sidebar-edit-mode/default-sidebar.js.map +0 -1
- package/build/components/sidebar-edit-mode/global-styles-sidebar.js.map +0 -1
- package/build/components/sidebar-edit-mode/index.js +0 -146
- package/build/components/sidebar-edit-mode/index.js.map +0 -1
- package/build/components/sidebar-edit-mode/page-panels/index.js +0 -98
- package/build/components/sidebar-edit-mode/page-panels/index.js.map +0 -1
- package/build/components/sidebar-edit-mode/page-panels/page-content.js +0 -34
- package/build/components/sidebar-edit-mode/page-panels/page-content.js.map +0 -1
- package/build/components/sidebar-edit-mode/page-panels/page-status.js +0 -188
- package/build/components/sidebar-edit-mode/page-panels/page-status.js.map +0 -1
- package/build/components/sidebar-edit-mode/page-panels/page-summary.js +0 -39
- package/build/components/sidebar-edit-mode/page-panels/page-summary.js.map +0 -1
- package/build/components/sidebar-edit-mode/settings-header/index.js +0 -42
- package/build/components/sidebar-edit-mode/settings-header/index.js.map +0 -1
- package/build/components/sidebar-edit-mode/template-panel/hooks.js +0 -86
- package/build/components/sidebar-edit-mode/template-panel/hooks.js.map +0 -1
- package/build/components/sidebar-edit-mode/template-panel/index.js +0 -130
- package/build/components/sidebar-edit-mode/template-panel/index.js.map +0 -1
- package/build/components/start-template-options/index.js +0 -191
- package/build/components/start-template-options/index.js.map +0 -1
- package/build/utils/math.js +0 -98
- package/build/utils/math.js.map +0 -1
- package/build-module/components/global-styles/global-styles-provider.js +0 -120
- package/build-module/components/global-styles/global-styles-provider.js.map +0 -1
- package/build-module/components/header-edit-mode/document-tools/index.js +0 -61
- package/build-module/components/header-edit-mode/document-tools/index.js.map +0 -1
- package/build-module/components/header-edit-mode/more-menu/copy-content-menu-item.js +0 -52
- package/build-module/components/header-edit-mode/more-menu/copy-content-menu-item.js.map +0 -1
- package/build-module/components/header-edit-mode/tools-more-menu-group/index.js +0 -16
- package/build-module/components/header-edit-mode/tools-more-menu-group/index.js.map +0 -1
- package/build-module/components/keyboard-shortcuts/edit-mode.js +0 -49
- package/build-module/components/keyboard-shortcuts/edit-mode.js.map +0 -1
- package/build-module/components/page-templates-template-parts/add-new-template-part.js +0 -57
- package/build-module/components/page-templates-template-parts/add-new-template-part.js.map +0 -1
- package/build-module/components/page-templates-template-parts/hooks.js.map +0 -1
- package/build-module/components/page-templates-template-parts/index.js.map +0 -1
- package/build-module/components/sidebar-edit-mode/default-sidebar.js.map +0 -1
- package/build-module/components/sidebar-edit-mode/global-styles-sidebar.js.map +0 -1
- package/build-module/components/sidebar-edit-mode/index.js +0 -137
- package/build-module/components/sidebar-edit-mode/index.js.map +0 -1
- package/build-module/components/sidebar-edit-mode/page-panels/index.js +0 -90
- package/build-module/components/sidebar-edit-mode/page-panels/index.js.map +0 -1
- package/build-module/components/sidebar-edit-mode/page-panels/page-content.js +0 -27
- package/build-module/components/sidebar-edit-mode/page-panels/page-content.js.map +0 -1
- package/build-module/components/sidebar-edit-mode/page-panels/page-status.js +0 -180
- package/build-module/components/sidebar-edit-mode/page-panels/page-status.js.map +0 -1
- package/build-module/components/sidebar-edit-mode/page-panels/page-summary.js +0 -31
- package/build-module/components/sidebar-edit-mode/page-panels/page-summary.js.map +0 -1
- package/build-module/components/sidebar-edit-mode/settings-header/index.js +0 -35
- package/build-module/components/sidebar-edit-mode/settings-header/index.js.map +0 -1
- package/build-module/components/sidebar-edit-mode/template-panel/hooks.js +0 -79
- package/build-module/components/sidebar-edit-mode/template-panel/hooks.js.map +0 -1
- package/build-module/components/sidebar-edit-mode/template-panel/index.js +0 -122
- package/build-module/components/sidebar-edit-mode/template-panel/index.js.map +0 -1
- package/build-module/components/start-template-options/index.js +0 -184
- package/build-module/components/start-template-options/index.js.map +0 -1
- package/build-module/utils/math.js +0 -92
- package/build-module/utils/math.js.map +0 -1
- package/src/components/global-styles/global-styles-provider.js +0 -162
- package/src/components/header-edit-mode/document-tools/index.js +0 -68
- package/src/components/header-edit-mode/more-menu/copy-content-menu-item.js +0 -51
- package/src/components/header-edit-mode/tools-more-menu-group/index.js +0 -16
- package/src/components/keyboard-shortcuts/edit-mode.js +0 -59
- package/src/components/page-templates-template-parts/add-new-template-part.js +0 -62
- package/src/components/sidebar-edit-mode/index.js +0 -162
- package/src/components/sidebar-edit-mode/page-panels/index.js +0 -105
- package/src/components/sidebar-edit-mode/page-panels/page-content.js +0 -29
- package/src/components/sidebar-edit-mode/page-panels/page-status.js +0 -249
- package/src/components/sidebar-edit-mode/page-panels/page-summary.js +0 -49
- package/src/components/sidebar-edit-mode/page-panels/style.scss +0 -34
- package/src/components/sidebar-edit-mode/settings-header/index.js +0 -43
- package/src/components/sidebar-edit-mode/settings-header/style.scss +0 -14
- package/src/components/sidebar-edit-mode/template-panel/hooks.js +0 -114
- package/src/components/sidebar-edit-mode/template-panel/index.js +0 -144
- package/src/components/sidebar-edit-mode/template-panel/style.scss +0 -16
- package/src/components/start-template-options/index.js +0 -231
- package/src/components/start-template-options/style.scss +0 -55
- package/src/utils/math.js +0 -93
- /package/build/components/{sidebar-edit-mode → global-styles-sidebar}/default-sidebar.js +0 -0
- /package/build/components/{page-templates-template-parts → page-templates}/hooks.js +0 -0
- /package/build-module/components/{sidebar-edit-mode → global-styles-sidebar}/default-sidebar.js +0 -0
- /package/build-module/components/{page-templates-template-parts → page-templates}/hooks.js +0 -0
- /package/src/components/{sidebar-edit-mode → global-styles-sidebar}/default-sidebar.js +0 -0
- /package/src/components/{page-templates-template-parts → page-templates}/hooks.js +0 -0
|
@@ -1,184 +0,0 @@
|
|
|
1
|
-
import { createElement } from "react";
|
|
2
|
-
/**
|
|
3
|
-
* WordPress dependencies
|
|
4
|
-
*/
|
|
5
|
-
import { Modal, Flex, FlexItem, Button } from '@wordpress/components';
|
|
6
|
-
import { __ } from '@wordpress/i18n';
|
|
7
|
-
import { useState, useMemo } from '@wordpress/element';
|
|
8
|
-
import { __experimentalBlockPatternsList as BlockPatternsList } from '@wordpress/block-editor';
|
|
9
|
-
import { useSelect } from '@wordpress/data';
|
|
10
|
-
import { useAsyncList } from '@wordpress/compose';
|
|
11
|
-
import { store as preferencesStore } from '@wordpress/preferences';
|
|
12
|
-
import { parse } from '@wordpress/blocks';
|
|
13
|
-
import { store as coreStore, useEntityBlockEditor } from '@wordpress/core-data';
|
|
14
|
-
|
|
15
|
-
/**
|
|
16
|
-
* Internal dependencies
|
|
17
|
-
*/
|
|
18
|
-
import { store as editSiteStore } from '../../store';
|
|
19
|
-
import { TEMPLATE_POST_TYPE } from '../../utils/constants';
|
|
20
|
-
function useFallbackTemplateContent(slug, isCustom = false) {
|
|
21
|
-
return useSelect(select => {
|
|
22
|
-
const {
|
|
23
|
-
getEntityRecord,
|
|
24
|
-
getDefaultTemplateId
|
|
25
|
-
} = select(coreStore);
|
|
26
|
-
const templateId = getDefaultTemplateId({
|
|
27
|
-
slug,
|
|
28
|
-
is_custom: isCustom,
|
|
29
|
-
ignore_empty: true
|
|
30
|
-
});
|
|
31
|
-
return templateId ? getEntityRecord('postType', TEMPLATE_POST_TYPE, templateId)?.content?.raw : undefined;
|
|
32
|
-
}, [slug, isCustom]);
|
|
33
|
-
}
|
|
34
|
-
function useStartPatterns(fallbackContent) {
|
|
35
|
-
const {
|
|
36
|
-
slug,
|
|
37
|
-
patterns
|
|
38
|
-
} = useSelect(select => {
|
|
39
|
-
const {
|
|
40
|
-
getEditedPostType,
|
|
41
|
-
getEditedPostId
|
|
42
|
-
} = select(editSiteStore);
|
|
43
|
-
const {
|
|
44
|
-
getEntityRecord,
|
|
45
|
-
getBlockPatterns
|
|
46
|
-
} = select(coreStore);
|
|
47
|
-
const postId = getEditedPostId();
|
|
48
|
-
const postType = getEditedPostType();
|
|
49
|
-
const record = getEntityRecord('postType', postType, postId);
|
|
50
|
-
return {
|
|
51
|
-
slug: record.slug,
|
|
52
|
-
patterns: getBlockPatterns()
|
|
53
|
-
};
|
|
54
|
-
}, []);
|
|
55
|
-
const currentThemeStylesheet = useSelect(select => select(coreStore).getCurrentTheme().stylesheet);
|
|
56
|
-
|
|
57
|
-
// Duplicated from packages/block-library/src/pattern/edit.js.
|
|
58
|
-
function injectThemeAttributeInBlockTemplateContent(block) {
|
|
59
|
-
if (block.innerBlocks.find(innerBlock => innerBlock.name === 'core/template-part')) {
|
|
60
|
-
block.innerBlocks = block.innerBlocks.map(innerBlock => {
|
|
61
|
-
if (innerBlock.name === 'core/template-part' && innerBlock.attributes.theme === undefined) {
|
|
62
|
-
innerBlock.attributes.theme = currentThemeStylesheet;
|
|
63
|
-
}
|
|
64
|
-
return innerBlock;
|
|
65
|
-
});
|
|
66
|
-
}
|
|
67
|
-
if (block.name === 'core/template-part' && block.attributes.theme === undefined) {
|
|
68
|
-
block.attributes.theme = currentThemeStylesheet;
|
|
69
|
-
}
|
|
70
|
-
return block;
|
|
71
|
-
}
|
|
72
|
-
return useMemo(() => {
|
|
73
|
-
// filter patterns that are supposed to be used in the current template being edited.
|
|
74
|
-
return [{
|
|
75
|
-
name: 'fallback',
|
|
76
|
-
blocks: parse(fallbackContent),
|
|
77
|
-
title: __('Fallback content')
|
|
78
|
-
}, ...patterns.filter(pattern => {
|
|
79
|
-
return Array.isArray(pattern.templateTypes) && pattern.templateTypes.some(templateType => slug.startsWith(templateType));
|
|
80
|
-
}).map(pattern => {
|
|
81
|
-
return {
|
|
82
|
-
...pattern,
|
|
83
|
-
blocks: parse(pattern.content).map(block => injectThemeAttributeInBlockTemplateContent(block))
|
|
84
|
-
};
|
|
85
|
-
})];
|
|
86
|
-
}, [fallbackContent, slug, patterns]);
|
|
87
|
-
}
|
|
88
|
-
function PatternSelection({
|
|
89
|
-
fallbackContent,
|
|
90
|
-
onChoosePattern,
|
|
91
|
-
postType
|
|
92
|
-
}) {
|
|
93
|
-
const [,, onChange] = useEntityBlockEditor('postType', postType);
|
|
94
|
-
const blockPatterns = useStartPatterns(fallbackContent);
|
|
95
|
-
const shownBlockPatterns = useAsyncList(blockPatterns);
|
|
96
|
-
return createElement(BlockPatternsList, {
|
|
97
|
-
blockPatterns: blockPatterns,
|
|
98
|
-
shownPatterns: shownBlockPatterns,
|
|
99
|
-
onClickPattern: (pattern, blocks) => {
|
|
100
|
-
onChange(blocks, {
|
|
101
|
-
selection: undefined
|
|
102
|
-
});
|
|
103
|
-
onChoosePattern();
|
|
104
|
-
}
|
|
105
|
-
});
|
|
106
|
-
}
|
|
107
|
-
function StartModal({
|
|
108
|
-
slug,
|
|
109
|
-
isCustom,
|
|
110
|
-
onClose,
|
|
111
|
-
postType
|
|
112
|
-
}) {
|
|
113
|
-
const fallbackContent = useFallbackTemplateContent(slug, isCustom);
|
|
114
|
-
if (!fallbackContent) {
|
|
115
|
-
return null;
|
|
116
|
-
}
|
|
117
|
-
return createElement(Modal, {
|
|
118
|
-
className: "edit-site-start-template-options__modal",
|
|
119
|
-
title: __('Choose a pattern'),
|
|
120
|
-
closeLabel: __('Cancel'),
|
|
121
|
-
focusOnMount: "firstElement",
|
|
122
|
-
onRequestClose: onClose,
|
|
123
|
-
isFullScreen: true
|
|
124
|
-
}, createElement("div", {
|
|
125
|
-
className: "edit-site-start-template-options__modal-content"
|
|
126
|
-
}, createElement(PatternSelection, {
|
|
127
|
-
fallbackContent: fallbackContent,
|
|
128
|
-
slug: slug,
|
|
129
|
-
isCustom: isCustom,
|
|
130
|
-
postType: postType,
|
|
131
|
-
onChoosePattern: () => {
|
|
132
|
-
onClose();
|
|
133
|
-
}
|
|
134
|
-
})), createElement(Flex, {
|
|
135
|
-
className: "edit-site-start-template-options__modal__actions",
|
|
136
|
-
justify: "flex-end",
|
|
137
|
-
expanded: false
|
|
138
|
-
}, createElement(FlexItem, null, createElement(Button, {
|
|
139
|
-
variant: "tertiary",
|
|
140
|
-
onClick: onClose
|
|
141
|
-
}, __('Skip')))));
|
|
142
|
-
}
|
|
143
|
-
const START_TEMPLATE_MODAL_STATES = {
|
|
144
|
-
INITIAL: 'INITIAL',
|
|
145
|
-
CLOSED: 'CLOSED'
|
|
146
|
-
};
|
|
147
|
-
export default function StartTemplateOptions() {
|
|
148
|
-
const [modalState, setModalState] = useState(START_TEMPLATE_MODAL_STATES.INITIAL);
|
|
149
|
-
const {
|
|
150
|
-
shouldOpenModal,
|
|
151
|
-
slug,
|
|
152
|
-
isCustom,
|
|
153
|
-
postType
|
|
154
|
-
} = useSelect(select => {
|
|
155
|
-
const {
|
|
156
|
-
getEditedPostType,
|
|
157
|
-
getEditedPostId
|
|
158
|
-
} = select(editSiteStore);
|
|
159
|
-
const _postType = getEditedPostType();
|
|
160
|
-
const postId = getEditedPostId();
|
|
161
|
-
const {
|
|
162
|
-
getEditedEntityRecord,
|
|
163
|
-
hasEditsForEntityRecord
|
|
164
|
-
} = select(coreStore);
|
|
165
|
-
const templateRecord = getEditedEntityRecord('postType', _postType, postId);
|
|
166
|
-
const hasEdits = hasEditsForEntityRecord('postType', _postType, postId);
|
|
167
|
-
return {
|
|
168
|
-
shouldOpenModal: !hasEdits && '' === templateRecord.content && TEMPLATE_POST_TYPE === _postType && !select(preferencesStore).get('core/edit-site', 'welcomeGuide'),
|
|
169
|
-
slug: templateRecord.slug,
|
|
170
|
-
isCustom: templateRecord.is_custom,
|
|
171
|
-
postType: _postType
|
|
172
|
-
};
|
|
173
|
-
}, []);
|
|
174
|
-
if (modalState === START_TEMPLATE_MODAL_STATES.INITIAL && !shouldOpenModal || modalState === START_TEMPLATE_MODAL_STATES.CLOSED) {
|
|
175
|
-
return null;
|
|
176
|
-
}
|
|
177
|
-
return createElement(StartModal, {
|
|
178
|
-
slug: slug,
|
|
179
|
-
isCustom: isCustom,
|
|
180
|
-
postType: postType,
|
|
181
|
-
onClose: () => setModalState(START_TEMPLATE_MODAL_STATES.CLOSED)
|
|
182
|
-
});
|
|
183
|
-
}
|
|
184
|
-
//# sourceMappingURL=index.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"names":["Modal","Flex","FlexItem","Button","__","useState","useMemo","__experimentalBlockPatternsList","BlockPatternsList","useSelect","useAsyncList","store","preferencesStore","parse","coreStore","useEntityBlockEditor","editSiteStore","TEMPLATE_POST_TYPE","useFallbackTemplateContent","slug","isCustom","select","getEntityRecord","getDefaultTemplateId","templateId","is_custom","ignore_empty","content","raw","undefined","useStartPatterns","fallbackContent","patterns","getEditedPostType","getEditedPostId","getBlockPatterns","postId","postType","record","currentThemeStylesheet","getCurrentTheme","stylesheet","injectThemeAttributeInBlockTemplateContent","block","innerBlocks","find","innerBlock","name","map","attributes","theme","blocks","title","filter","pattern","Array","isArray","templateTypes","some","templateType","startsWith","PatternSelection","onChoosePattern","onChange","blockPatterns","shownBlockPatterns","createElement","shownPatterns","onClickPattern","selection","StartModal","onClose","className","closeLabel","focusOnMount","onRequestClose","isFullScreen","justify","expanded","variant","onClick","START_TEMPLATE_MODAL_STATES","INITIAL","CLOSED","StartTemplateOptions","modalState","setModalState","shouldOpenModal","_postType","getEditedEntityRecord","hasEditsForEntityRecord","templateRecord","hasEdits","get"],"sources":["@wordpress/edit-site/src/components/start-template-options/index.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { Modal, Flex, FlexItem, Button } from '@wordpress/components';\nimport { __ } from '@wordpress/i18n';\nimport { useState, useMemo } from '@wordpress/element';\nimport { __experimentalBlockPatternsList as BlockPatternsList } from '@wordpress/block-editor';\nimport { useSelect } from '@wordpress/data';\nimport { useAsyncList } from '@wordpress/compose';\nimport { store as preferencesStore } from '@wordpress/preferences';\nimport { parse } from '@wordpress/blocks';\nimport { store as coreStore, useEntityBlockEditor } from '@wordpress/core-data';\n\n/**\n * Internal dependencies\n */\nimport { store as editSiteStore } from '../../store';\nimport { TEMPLATE_POST_TYPE } from '../../utils/constants';\n\nfunction useFallbackTemplateContent( slug, isCustom = false ) {\n\treturn useSelect(\n\t\t( select ) => {\n\t\t\tconst { getEntityRecord, getDefaultTemplateId } =\n\t\t\t\tselect( coreStore );\n\t\t\tconst templateId = getDefaultTemplateId( {\n\t\t\t\tslug,\n\t\t\t\tis_custom: isCustom,\n\t\t\t\tignore_empty: true,\n\t\t\t} );\n\t\t\treturn templateId\n\t\t\t\t? getEntityRecord( 'postType', TEMPLATE_POST_TYPE, templateId )\n\t\t\t\t\t\t?.content?.raw\n\t\t\t\t: undefined;\n\t\t},\n\t\t[ slug, isCustom ]\n\t);\n}\n\nfunction useStartPatterns( fallbackContent ) {\n\tconst { slug, patterns } = useSelect( ( select ) => {\n\t\tconst { getEditedPostType, getEditedPostId } = select( editSiteStore );\n\t\tconst { getEntityRecord, getBlockPatterns } = select( coreStore );\n\t\tconst postId = getEditedPostId();\n\t\tconst postType = getEditedPostType();\n\t\tconst record = getEntityRecord( 'postType', postType, postId );\n\t\treturn {\n\t\t\tslug: record.slug,\n\t\t\tpatterns: getBlockPatterns(),\n\t\t};\n\t}, [] );\n\n\tconst currentThemeStylesheet = useSelect(\n\t\t( select ) => select( coreStore ).getCurrentTheme().stylesheet\n\t);\n\n\t// Duplicated from packages/block-library/src/pattern/edit.js.\n\tfunction injectThemeAttributeInBlockTemplateContent( block ) {\n\t\tif (\n\t\t\tblock.innerBlocks.find(\n\t\t\t\t( innerBlock ) => innerBlock.name === 'core/template-part'\n\t\t\t)\n\t\t) {\n\t\t\tblock.innerBlocks = block.innerBlocks.map( ( innerBlock ) => {\n\t\t\t\tif (\n\t\t\t\t\tinnerBlock.name === 'core/template-part' &&\n\t\t\t\t\tinnerBlock.attributes.theme === undefined\n\t\t\t\t) {\n\t\t\t\t\tinnerBlock.attributes.theme = currentThemeStylesheet;\n\t\t\t\t}\n\t\t\t\treturn innerBlock;\n\t\t\t} );\n\t\t}\n\n\t\tif (\n\t\t\tblock.name === 'core/template-part' &&\n\t\t\tblock.attributes.theme === undefined\n\t\t) {\n\t\t\tblock.attributes.theme = currentThemeStylesheet;\n\t\t}\n\t\treturn block;\n\t}\n\n\treturn useMemo( () => {\n\t\t// filter patterns that are supposed to be used in the current template being edited.\n\t\treturn [\n\t\t\t{\n\t\t\t\tname: 'fallback',\n\t\t\t\tblocks: parse( fallbackContent ),\n\t\t\t\ttitle: __( 'Fallback content' ),\n\t\t\t},\n\t\t\t...patterns\n\t\t\t\t.filter( ( pattern ) => {\n\t\t\t\t\treturn (\n\t\t\t\t\t\tArray.isArray( pattern.templateTypes ) &&\n\t\t\t\t\t\tpattern.templateTypes.some( ( templateType ) =>\n\t\t\t\t\t\t\tslug.startsWith( templateType )\n\t\t\t\t\t\t)\n\t\t\t\t\t);\n\t\t\t\t} )\n\t\t\t\t.map( ( pattern ) => {\n\t\t\t\t\treturn {\n\t\t\t\t\t\t...pattern,\n\t\t\t\t\t\tblocks: parse( pattern.content ).map( ( block ) =>\n\t\t\t\t\t\t\tinjectThemeAttributeInBlockTemplateContent( block )\n\t\t\t\t\t\t),\n\t\t\t\t\t};\n\t\t\t\t} ),\n\t\t];\n\t}, [ fallbackContent, slug, patterns ] );\n}\n\nfunction PatternSelection( { fallbackContent, onChoosePattern, postType } ) {\n\tconst [ , , onChange ] = useEntityBlockEditor( 'postType', postType );\n\tconst blockPatterns = useStartPatterns( fallbackContent );\n\tconst shownBlockPatterns = useAsyncList( blockPatterns );\n\treturn (\n\t\t<BlockPatternsList\n\t\t\tblockPatterns={ blockPatterns }\n\t\t\tshownPatterns={ shownBlockPatterns }\n\t\t\tonClickPattern={ ( pattern, blocks ) => {\n\t\t\t\tonChange( blocks, { selection: undefined } );\n\t\t\t\tonChoosePattern();\n\t\t\t} }\n\t\t/>\n\t);\n}\n\nfunction StartModal( { slug, isCustom, onClose, postType } ) {\n\tconst fallbackContent = useFallbackTemplateContent( slug, isCustom );\n\tif ( ! fallbackContent ) {\n\t\treturn null;\n\t}\n\treturn (\n\t\t<Modal\n\t\t\tclassName=\"edit-site-start-template-options__modal\"\n\t\t\ttitle={ __( 'Choose a pattern' ) }\n\t\t\tcloseLabel={ __( 'Cancel' ) }\n\t\t\tfocusOnMount=\"firstElement\"\n\t\t\tonRequestClose={ onClose }\n\t\t\tisFullScreen\n\t\t>\n\t\t\t<div className=\"edit-site-start-template-options__modal-content\">\n\t\t\t\t<PatternSelection\n\t\t\t\t\tfallbackContent={ fallbackContent }\n\t\t\t\t\tslug={ slug }\n\t\t\t\t\tisCustom={ isCustom }\n\t\t\t\t\tpostType={ postType }\n\t\t\t\t\tonChoosePattern={ () => {\n\t\t\t\t\t\tonClose();\n\t\t\t\t\t} }\n\t\t\t\t/>\n\t\t\t</div>\n\t\t\t<Flex\n\t\t\t\tclassName=\"edit-site-start-template-options__modal__actions\"\n\t\t\t\tjustify=\"flex-end\"\n\t\t\t\texpanded={ false }\n\t\t\t>\n\t\t\t\t<FlexItem>\n\t\t\t\t\t<Button variant=\"tertiary\" onClick={ onClose }>\n\t\t\t\t\t\t{ __( 'Skip' ) }\n\t\t\t\t\t</Button>\n\t\t\t\t</FlexItem>\n\t\t\t</Flex>\n\t\t</Modal>\n\t);\n}\n\nconst START_TEMPLATE_MODAL_STATES = {\n\tINITIAL: 'INITIAL',\n\tCLOSED: 'CLOSED',\n};\n\nexport default function StartTemplateOptions() {\n\tconst [ modalState, setModalState ] = useState(\n\t\tSTART_TEMPLATE_MODAL_STATES.INITIAL\n\t);\n\tconst { shouldOpenModal, slug, isCustom, postType } = useSelect(\n\t\t( select ) => {\n\t\t\tconst { getEditedPostType, getEditedPostId } =\n\t\t\t\tselect( editSiteStore );\n\t\t\tconst _postType = getEditedPostType();\n\t\t\tconst postId = getEditedPostId();\n\t\t\tconst { getEditedEntityRecord, hasEditsForEntityRecord } =\n\t\t\t\tselect( coreStore );\n\t\t\tconst templateRecord = getEditedEntityRecord(\n\t\t\t\t'postType',\n\t\t\t\t_postType,\n\t\t\t\tpostId\n\t\t\t);\n\t\t\tconst hasEdits = hasEditsForEntityRecord(\n\t\t\t\t'postType',\n\t\t\t\t_postType,\n\t\t\t\tpostId\n\t\t\t);\n\n\t\t\treturn {\n\t\t\t\tshouldOpenModal:\n\t\t\t\t\t! hasEdits &&\n\t\t\t\t\t'' === templateRecord.content &&\n\t\t\t\t\tTEMPLATE_POST_TYPE === _postType &&\n\t\t\t\t\t! select( preferencesStore ).get(\n\t\t\t\t\t\t'core/edit-site',\n\t\t\t\t\t\t'welcomeGuide'\n\t\t\t\t\t),\n\t\t\t\tslug: templateRecord.slug,\n\t\t\t\tisCustom: templateRecord.is_custom,\n\t\t\t\tpostType: _postType,\n\t\t\t};\n\t\t},\n\t\t[]\n\t);\n\n\tif (\n\t\t( modalState === START_TEMPLATE_MODAL_STATES.INITIAL &&\n\t\t\t! shouldOpenModal ) ||\n\t\tmodalState === START_TEMPLATE_MODAL_STATES.CLOSED\n\t) {\n\t\treturn null;\n\t}\n\n\treturn (\n\t\t<StartModal\n\t\t\tslug={ slug }\n\t\t\tisCustom={ isCustom }\n\t\t\tpostType={ postType }\n\t\t\tonClose={ () =>\n\t\t\t\tsetModalState( START_TEMPLATE_MODAL_STATES.CLOSED )\n\t\t\t}\n\t\t/>\n\t);\n}\n"],"mappings":"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","ignoreList":[]}
|
|
@@ -1,92 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @typedef {Object} WPPoint
|
|
3
|
-
* @property {number} x The horizontal coordinate.
|
|
4
|
-
* @property {number} y The vertical coordinate.
|
|
5
|
-
*/
|
|
6
|
-
|
|
7
|
-
/**
|
|
8
|
-
* Clamps a value to a range. Uses the CSS `clamp()` ordering for arguments.
|
|
9
|
-
*
|
|
10
|
-
* @param {number} min Minimum range.
|
|
11
|
-
* @param {number} value Value to clamp.
|
|
12
|
-
* @param {number} max Maximum range.
|
|
13
|
-
*
|
|
14
|
-
* @return {number} Clamped value.
|
|
15
|
-
*/
|
|
16
|
-
function clamp(min, value, max) {
|
|
17
|
-
return Math.max(min, Math.min(value, max));
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
/**
|
|
21
|
-
* Evaluates a linear function passing through two points at the given x value.
|
|
22
|
-
*
|
|
23
|
-
* Example:
|
|
24
|
-
* f(x)
|
|
25
|
-
* │ ╲
|
|
26
|
-
* │ * (p0)
|
|
27
|
-
* │ ╲
|
|
28
|
-
* │ ╲
|
|
29
|
-
* │ (p1) *
|
|
30
|
-
* │ ╲
|
|
31
|
-
* └──────────── x
|
|
32
|
-
*
|
|
33
|
-
* @param {WPPoint} p0 First point.
|
|
34
|
-
* @param {WPPoint} p1 Second point.
|
|
35
|
-
* @param {number} x Value to evaluate at.
|
|
36
|
-
*
|
|
37
|
-
* @return {number} Result of the two-point linear function at x.
|
|
38
|
-
*/
|
|
39
|
-
function twoPointLinearFn(p0, p1, x) {
|
|
40
|
-
return (p1.y - p0.y) / (p1.x - p0.x) * (x - p0.x) + p0.y;
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
/**
|
|
44
|
-
* Evaluates a two-point linear function at a given x value, clamped to the range of the points.
|
|
45
|
-
*
|
|
46
|
-
* Example:
|
|
47
|
-
* f(x)
|
|
48
|
-
* │ ───* (p0)
|
|
49
|
-
* │ ╲
|
|
50
|
-
* │ ╲
|
|
51
|
-
* │ (p1) *───
|
|
52
|
-
* └──────────── x
|
|
53
|
-
*
|
|
54
|
-
* @param {WPPoint} p0 First point.
|
|
55
|
-
* @param {WPPoint} p1 Second point.
|
|
56
|
-
* @param {number} x Value to evaluate at.
|
|
57
|
-
*
|
|
58
|
-
* @return {number} Result of the two-point linear function clamped to the range of the points.
|
|
59
|
-
*/
|
|
60
|
-
function clampedTwoPointLinearFn(p0, p1, x) {
|
|
61
|
-
return clamp(Math.min(p0.y, p1.y), twoPointLinearFn(p0, p1, x), Math.max(p0.y, p1.y));
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
/**
|
|
65
|
-
* Computes the iframe scale using a start and end width/scale pair and the current width.
|
|
66
|
-
*
|
|
67
|
-
* The scale is clamped outside the points and is linearly interpolated between.
|
|
68
|
-
*
|
|
69
|
-
* Example:
|
|
70
|
-
* scale
|
|
71
|
-
* │ ───* (start)
|
|
72
|
-
* │ ╲
|
|
73
|
-
* │ ╲
|
|
74
|
-
* │ (end) *───
|
|
75
|
-
* └──────────── width
|
|
76
|
-
*
|
|
77
|
-
* @param {Object} start First width and scale pair.
|
|
78
|
-
* @param {Object} end Second width and scale pair.
|
|
79
|
-
* @param {number} currentWidth Current width.
|
|
80
|
-
*
|
|
81
|
-
* @return {number} The scale of the current width between the two points.
|
|
82
|
-
*/
|
|
83
|
-
export function computeIFrameScale(start, end, currentWidth) {
|
|
84
|
-
return clampedTwoPointLinearFn({
|
|
85
|
-
x: start.width,
|
|
86
|
-
y: start.scale
|
|
87
|
-
}, {
|
|
88
|
-
x: end.width,
|
|
89
|
-
y: end.scale
|
|
90
|
-
}, currentWidth);
|
|
91
|
-
}
|
|
92
|
-
//# sourceMappingURL=math.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"names":["clamp","min","value","max","Math","twoPointLinearFn","p0","p1","x","y","clampedTwoPointLinearFn","computeIFrameScale","start","end","currentWidth","width","scale"],"sources":["@wordpress/edit-site/src/utils/math.js"],"sourcesContent":["/**\n * @typedef {Object} WPPoint\n * @property {number} x The horizontal coordinate.\n * @property {number} y The vertical coordinate.\n */\n\n/**\n * Clamps a value to a range. Uses the CSS `clamp()` ordering for arguments.\n *\n * @param {number} min Minimum range.\n * @param {number} value Value to clamp.\n * @param {number} max Maximum range.\n *\n * @return {number} Clamped value.\n */\nfunction clamp( min, value, max ) {\n\treturn Math.max( min, Math.min( value, max ) );\n}\n\n/**\n * Evaluates a linear function passing through two points at the given x value.\n *\n * Example:\n * f(x)\n * │ ╲\n * │ * (p0)\n * │ ╲\n * │ ╲\n * │ (p1) *\n * │ ╲\n * └──────────── x\n *\n * @param {WPPoint} p0 First point.\n * @param {WPPoint} p1 Second point.\n * @param {number} x Value to evaluate at.\n *\n * @return {number} Result of the two-point linear function at x.\n */\nfunction twoPointLinearFn( p0, p1, x ) {\n\treturn ( ( p1.y - p0.y ) / ( p1.x - p0.x ) ) * ( x - p0.x ) + p0.y;\n}\n\n/**\n * Evaluates a two-point linear function at a given x value, clamped to the range of the points.\n *\n * Example:\n * f(x)\n * │ ───* (p0)\n * │ ╲\n * │ ╲\n * │ (p1) *───\n * └──────────── x\n *\n * @param {WPPoint} p0 First point.\n * @param {WPPoint} p1 Second point.\n * @param {number} x Value to evaluate at.\n *\n * @return {number} Result of the two-point linear function clamped to the range of the points.\n */\nfunction clampedTwoPointLinearFn( p0, p1, x ) {\n\treturn clamp(\n\t\tMath.min( p0.y, p1.y ),\n\t\ttwoPointLinearFn( p0, p1, x ),\n\t\tMath.max( p0.y, p1.y )\n\t);\n}\n\n/**\n * Computes the iframe scale using a start and end width/scale pair and the current width.\n *\n * The scale is clamped outside the points and is linearly interpolated between.\n *\n * Example:\n * scale\n * │ ───* (start)\n * │ ╲\n * │ ╲\n * │ (end) *───\n * └──────────── width\n *\n * @param {Object} start First width and scale pair.\n * @param {Object} end Second width and scale pair.\n * @param {number} currentWidth Current width.\n *\n * @return {number} The scale of the current width between the two points.\n */\nexport function computeIFrameScale( start, end, currentWidth ) {\n\treturn clampedTwoPointLinearFn(\n\t\t{ x: start.width, y: start.scale },\n\t\t{ x: end.width, y: end.scale },\n\t\tcurrentWidth\n\t);\n}\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,SAASA,KAAKA,CAAEC,GAAG,EAAEC,KAAK,EAAEC,GAAG,EAAG;EACjC,OAAOC,IAAI,CAACD,GAAG,CAAEF,GAAG,EAAEG,IAAI,CAACH,GAAG,CAAEC,KAAK,EAAEC,GAAI,CAAE,CAAC;AAC/C;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,SAASE,gBAAgBA,CAAEC,EAAE,EAAEC,EAAE,EAAEC,CAAC,EAAG;EACtC,OAAS,CAAED,EAAE,CAACE,CAAC,GAAGH,EAAE,CAACG,CAAC,KAAOF,EAAE,CAACC,CAAC,GAAGF,EAAE,CAACE,CAAC,CAAE,IAAOA,CAAC,GAAGF,EAAE,CAACE,CAAC,CAAE,GAAGF,EAAE,CAACG,CAAC;AACnE;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,SAASC,uBAAuBA,CAAEJ,EAAE,EAAEC,EAAE,EAAEC,CAAC,EAAG;EAC7C,OAAOR,KAAK,CACXI,IAAI,CAACH,GAAG,CAAEK,EAAE,CAACG,CAAC,EAAEF,EAAE,CAACE,CAAE,CAAC,EACtBJ,gBAAgB,CAAEC,EAAE,EAAEC,EAAE,EAAEC,CAAE,CAAC,EAC7BJ,IAAI,CAACD,GAAG,CAAEG,EAAE,CAACG,CAAC,EAAEF,EAAE,CAACE,CAAE,CACtB,CAAC;AACF;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,SAASE,kBAAkBA,CAAEC,KAAK,EAAEC,GAAG,EAAEC,YAAY,EAAG;EAC9D,OAAOJ,uBAAuB,CAC7B;IAAEF,CAAC,EAAEI,KAAK,CAACG,KAAK;IAAEN,CAAC,EAAEG,KAAK,CAACI;EAAM,CAAC,EAClC;IAAER,CAAC,EAAEK,GAAG,CAACE,KAAK;IAAEN,CAAC,EAAEI,GAAG,CAACG;EAAM,CAAC,EAC9BF,YACD,CAAC;AACF","ignoreList":[]}
|
|
@@ -1,162 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* External dependencies
|
|
3
|
-
*/
|
|
4
|
-
import deepmerge from 'deepmerge';
|
|
5
|
-
import { isPlainObject } from 'is-plain-object';
|
|
6
|
-
|
|
7
|
-
/**
|
|
8
|
-
* WordPress dependencies
|
|
9
|
-
*/
|
|
10
|
-
import { useMemo, useCallback } from '@wordpress/element';
|
|
11
|
-
import { useSelect, useDispatch } from '@wordpress/data';
|
|
12
|
-
import { store as coreStore } from '@wordpress/core-data';
|
|
13
|
-
import { privateApis as blockEditorPrivateApis } from '@wordpress/block-editor';
|
|
14
|
-
|
|
15
|
-
/**
|
|
16
|
-
* Internal dependencies
|
|
17
|
-
*/
|
|
18
|
-
import { unlock } from '../../lock-unlock';
|
|
19
|
-
|
|
20
|
-
const { GlobalStylesContext, cleanEmptyObject } = unlock(
|
|
21
|
-
blockEditorPrivateApis
|
|
22
|
-
);
|
|
23
|
-
|
|
24
|
-
export function mergeBaseAndUserConfigs( base, user ) {
|
|
25
|
-
return deepmerge( base, user, {
|
|
26
|
-
// We only pass as arrays the presets,
|
|
27
|
-
// in which case we want the new array of values
|
|
28
|
-
// to override the old array (no merging).
|
|
29
|
-
isMergeableObject: isPlainObject,
|
|
30
|
-
} );
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
function useGlobalStylesUserConfig() {
|
|
34
|
-
const { globalStylesId, isReady, settings, styles } = useSelect(
|
|
35
|
-
( select ) => {
|
|
36
|
-
const { getEditedEntityRecord, hasFinishedResolution } =
|
|
37
|
-
select( coreStore );
|
|
38
|
-
const _globalStylesId =
|
|
39
|
-
select( coreStore ).__experimentalGetCurrentGlobalStylesId();
|
|
40
|
-
const record = _globalStylesId
|
|
41
|
-
? getEditedEntityRecord(
|
|
42
|
-
'root',
|
|
43
|
-
'globalStyles',
|
|
44
|
-
_globalStylesId
|
|
45
|
-
)
|
|
46
|
-
: undefined;
|
|
47
|
-
|
|
48
|
-
let hasResolved = false;
|
|
49
|
-
if (
|
|
50
|
-
hasFinishedResolution(
|
|
51
|
-
'__experimentalGetCurrentGlobalStylesId'
|
|
52
|
-
)
|
|
53
|
-
) {
|
|
54
|
-
hasResolved = _globalStylesId
|
|
55
|
-
? hasFinishedResolution( 'getEditedEntityRecord', [
|
|
56
|
-
'root',
|
|
57
|
-
'globalStyles',
|
|
58
|
-
_globalStylesId,
|
|
59
|
-
] )
|
|
60
|
-
: true;
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
return {
|
|
64
|
-
globalStylesId: _globalStylesId,
|
|
65
|
-
isReady: hasResolved,
|
|
66
|
-
settings: record?.settings,
|
|
67
|
-
styles: record?.styles,
|
|
68
|
-
};
|
|
69
|
-
},
|
|
70
|
-
[]
|
|
71
|
-
);
|
|
72
|
-
|
|
73
|
-
const { getEditedEntityRecord } = useSelect( coreStore );
|
|
74
|
-
const { editEntityRecord } = useDispatch( coreStore );
|
|
75
|
-
const config = useMemo( () => {
|
|
76
|
-
return {
|
|
77
|
-
settings: settings ?? {},
|
|
78
|
-
styles: styles ?? {},
|
|
79
|
-
};
|
|
80
|
-
}, [ settings, styles ] );
|
|
81
|
-
|
|
82
|
-
const setConfig = useCallback(
|
|
83
|
-
( callback, options = {} ) => {
|
|
84
|
-
const record = getEditedEntityRecord(
|
|
85
|
-
'root',
|
|
86
|
-
'globalStyles',
|
|
87
|
-
globalStylesId
|
|
88
|
-
);
|
|
89
|
-
const currentConfig = {
|
|
90
|
-
styles: record?.styles ?? {},
|
|
91
|
-
settings: record?.settings ?? {},
|
|
92
|
-
};
|
|
93
|
-
const updatedConfig = callback( currentConfig );
|
|
94
|
-
editEntityRecord(
|
|
95
|
-
'root',
|
|
96
|
-
'globalStyles',
|
|
97
|
-
globalStylesId,
|
|
98
|
-
{
|
|
99
|
-
styles: cleanEmptyObject( updatedConfig.styles ) || {},
|
|
100
|
-
settings: cleanEmptyObject( updatedConfig.settings ) || {},
|
|
101
|
-
},
|
|
102
|
-
options
|
|
103
|
-
);
|
|
104
|
-
},
|
|
105
|
-
[ globalStylesId ]
|
|
106
|
-
);
|
|
107
|
-
|
|
108
|
-
return [ isReady, config, setConfig ];
|
|
109
|
-
}
|
|
110
|
-
|
|
111
|
-
function useGlobalStylesBaseConfig() {
|
|
112
|
-
const baseConfig = useSelect( ( select ) => {
|
|
113
|
-
return select(
|
|
114
|
-
coreStore
|
|
115
|
-
).__experimentalGetCurrentThemeBaseGlobalStyles();
|
|
116
|
-
}, [] );
|
|
117
|
-
|
|
118
|
-
return [ !! baseConfig, baseConfig ];
|
|
119
|
-
}
|
|
120
|
-
|
|
121
|
-
function useGlobalStylesContext() {
|
|
122
|
-
const [ isUserConfigReady, userConfig, setUserConfig ] =
|
|
123
|
-
useGlobalStylesUserConfig();
|
|
124
|
-
const [ isBaseConfigReady, baseConfig ] = useGlobalStylesBaseConfig();
|
|
125
|
-
const mergedConfig = useMemo( () => {
|
|
126
|
-
if ( ! baseConfig || ! userConfig ) {
|
|
127
|
-
return {};
|
|
128
|
-
}
|
|
129
|
-
return mergeBaseAndUserConfigs( baseConfig, userConfig );
|
|
130
|
-
}, [ userConfig, baseConfig ] );
|
|
131
|
-
const context = useMemo( () => {
|
|
132
|
-
return {
|
|
133
|
-
isReady: isUserConfigReady && isBaseConfigReady,
|
|
134
|
-
user: userConfig,
|
|
135
|
-
base: baseConfig,
|
|
136
|
-
merged: mergedConfig,
|
|
137
|
-
setUserConfig,
|
|
138
|
-
};
|
|
139
|
-
}, [
|
|
140
|
-
mergedConfig,
|
|
141
|
-
userConfig,
|
|
142
|
-
baseConfig,
|
|
143
|
-
setUserConfig,
|
|
144
|
-
isUserConfigReady,
|
|
145
|
-
isBaseConfigReady,
|
|
146
|
-
] );
|
|
147
|
-
|
|
148
|
-
return context;
|
|
149
|
-
}
|
|
150
|
-
|
|
151
|
-
export function GlobalStylesProvider( { children } ) {
|
|
152
|
-
const context = useGlobalStylesContext();
|
|
153
|
-
if ( ! context.isReady ) {
|
|
154
|
-
return null;
|
|
155
|
-
}
|
|
156
|
-
|
|
157
|
-
return (
|
|
158
|
-
<GlobalStylesContext.Provider value={ context }>
|
|
159
|
-
{ children }
|
|
160
|
-
</GlobalStylesContext.Provider>
|
|
161
|
-
);
|
|
162
|
-
}
|
|
@@ -1,68 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* WordPress dependencies
|
|
3
|
-
*/
|
|
4
|
-
import { useViewportMatch } from '@wordpress/compose';
|
|
5
|
-
import { store as blockEditorStore } from '@wordpress/block-editor';
|
|
6
|
-
import { useSelect, useDispatch } from '@wordpress/data';
|
|
7
|
-
import { __ } from '@wordpress/i18n';
|
|
8
|
-
import { chevronUpDown } from '@wordpress/icons';
|
|
9
|
-
import { Button, ToolbarItem } from '@wordpress/components';
|
|
10
|
-
import {
|
|
11
|
-
store as editorStore,
|
|
12
|
-
privateApis as editorPrivateApis,
|
|
13
|
-
} from '@wordpress/editor';
|
|
14
|
-
|
|
15
|
-
/**
|
|
16
|
-
* Internal dependencies
|
|
17
|
-
*/
|
|
18
|
-
import { unlock } from '../../../lock-unlock';
|
|
19
|
-
|
|
20
|
-
const { DocumentTools: EditorDocumentTools } = unlock( editorPrivateApis );
|
|
21
|
-
|
|
22
|
-
export default function DocumentTools( {
|
|
23
|
-
blockEditorMode,
|
|
24
|
-
hasFixedToolbar,
|
|
25
|
-
isDistractionFree,
|
|
26
|
-
} ) {
|
|
27
|
-
const { isVisualMode } = useSelect( ( select ) => {
|
|
28
|
-
const { getEditorMode } = select( editorStore );
|
|
29
|
-
|
|
30
|
-
return {
|
|
31
|
-
isVisualMode: getEditorMode() === 'visual',
|
|
32
|
-
};
|
|
33
|
-
}, [] );
|
|
34
|
-
const { __unstableSetEditorMode } = useDispatch( blockEditorStore );
|
|
35
|
-
const { setDeviceType } = useDispatch( editorStore );
|
|
36
|
-
const isLargeViewport = useViewportMatch( 'medium' );
|
|
37
|
-
const isZoomedOutViewExperimentEnabled =
|
|
38
|
-
window?.__experimentalEnableZoomedOutView && isVisualMode;
|
|
39
|
-
const isZoomedOutView = blockEditorMode === 'zoom-out';
|
|
40
|
-
|
|
41
|
-
return (
|
|
42
|
-
<EditorDocumentTools
|
|
43
|
-
disableBlockTools={ ! isVisualMode }
|
|
44
|
-
listViewLabel={ __( 'List View' ) }
|
|
45
|
-
>
|
|
46
|
-
{ isZoomedOutViewExperimentEnabled &&
|
|
47
|
-
isLargeViewport &&
|
|
48
|
-
! isDistractionFree &&
|
|
49
|
-
! hasFixedToolbar && (
|
|
50
|
-
<ToolbarItem
|
|
51
|
-
as={ Button }
|
|
52
|
-
className="edit-site-header-edit-mode__zoom-out-view-toggle"
|
|
53
|
-
icon={ chevronUpDown }
|
|
54
|
-
isPressed={ isZoomedOutView }
|
|
55
|
-
/* translators: button label text should, if possible, be under 16 characters. */
|
|
56
|
-
label={ __( 'Zoom-out View' ) }
|
|
57
|
-
onClick={ () => {
|
|
58
|
-
setDeviceType( 'Desktop' );
|
|
59
|
-
__unstableSetEditorMode(
|
|
60
|
-
isZoomedOutView ? 'edit' : 'zoom-out'
|
|
61
|
-
);
|
|
62
|
-
} }
|
|
63
|
-
size="compact"
|
|
64
|
-
/>
|
|
65
|
-
) }
|
|
66
|
-
</EditorDocumentTools>
|
|
67
|
-
);
|
|
68
|
-
}
|
|
@@ -1,51 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* WordPress dependencies
|
|
3
|
-
*/
|
|
4
|
-
import { MenuItem } from '@wordpress/components';
|
|
5
|
-
import { useSelect, useDispatch } from '@wordpress/data';
|
|
6
|
-
import { __ } from '@wordpress/i18n';
|
|
7
|
-
import { useCopyToClipboard } from '@wordpress/compose';
|
|
8
|
-
import { store as noticesStore } from '@wordpress/notices';
|
|
9
|
-
import { store as coreStore } from '@wordpress/core-data';
|
|
10
|
-
import { __unstableSerializeAndClean } from '@wordpress/blocks';
|
|
11
|
-
|
|
12
|
-
/**
|
|
13
|
-
* Internal dependencies
|
|
14
|
-
*/
|
|
15
|
-
import { store as editSiteStore } from '../../../store';
|
|
16
|
-
|
|
17
|
-
export default function CopyContentMenuItem() {
|
|
18
|
-
const { createNotice } = useDispatch( noticesStore );
|
|
19
|
-
const { getEditedPostId, getEditedPostType } = useSelect( editSiteStore );
|
|
20
|
-
const { getEditedEntityRecord } = useSelect( coreStore );
|
|
21
|
-
|
|
22
|
-
function getText() {
|
|
23
|
-
const record = getEditedEntityRecord(
|
|
24
|
-
'postType',
|
|
25
|
-
getEditedPostType(),
|
|
26
|
-
getEditedPostId()
|
|
27
|
-
);
|
|
28
|
-
if ( ! record ) {
|
|
29
|
-
return '';
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
if ( typeof record.content === 'function' ) {
|
|
33
|
-
return record.content( record );
|
|
34
|
-
} else if ( record.blocks ) {
|
|
35
|
-
return __unstableSerializeAndClean( record.blocks );
|
|
36
|
-
} else if ( record.content ) {
|
|
37
|
-
return record.content;
|
|
38
|
-
}
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
function onSuccess() {
|
|
42
|
-
createNotice( 'info', __( 'All content copied.' ), {
|
|
43
|
-
isDismissible: true,
|
|
44
|
-
type: 'snackbar',
|
|
45
|
-
} );
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
const ref = useCopyToClipboard( getText, onSuccess );
|
|
49
|
-
|
|
50
|
-
return <MenuItem ref={ ref }>{ __( 'Copy all blocks' ) }</MenuItem>;
|
|
51
|
-
}
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* WordPress dependencies
|
|
3
|
-
*/
|
|
4
|
-
import { createSlotFill } from '@wordpress/components';
|
|
5
|
-
|
|
6
|
-
const { Fill: ToolsMoreMenuGroup, Slot } = createSlotFill(
|
|
7
|
-
'EditSiteToolsMoreMenuGroup'
|
|
8
|
-
);
|
|
9
|
-
|
|
10
|
-
ToolsMoreMenuGroup.Slot = ( { fillProps } ) => (
|
|
11
|
-
<Slot fillProps={ fillProps }>
|
|
12
|
-
{ ( fills ) => fills && fills.length > 0 }
|
|
13
|
-
</Slot>
|
|
14
|
-
);
|
|
15
|
-
|
|
16
|
-
export default ToolsMoreMenuGroup;
|
|
@@ -1,59 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* WordPress dependencies
|
|
3
|
-
*/
|
|
4
|
-
import { useShortcut } from '@wordpress/keyboard-shortcuts';
|
|
5
|
-
import { useDispatch, useSelect } from '@wordpress/data';
|
|
6
|
-
import { store as blockEditorStore } from '@wordpress/block-editor';
|
|
7
|
-
import { createBlock } from '@wordpress/blocks';
|
|
8
|
-
|
|
9
|
-
function KeyboardShortcutsEditMode() {
|
|
10
|
-
const { replaceBlocks } = useDispatch( blockEditorStore );
|
|
11
|
-
const { getBlockName, getSelectedBlockClientId, getBlockAttributes } =
|
|
12
|
-
useSelect( blockEditorStore );
|
|
13
|
-
|
|
14
|
-
const handleTextLevelShortcut = ( event, level ) => {
|
|
15
|
-
event.preventDefault();
|
|
16
|
-
const destinationBlockName =
|
|
17
|
-
level === 0 ? 'core/paragraph' : 'core/heading';
|
|
18
|
-
const currentClientId = getSelectedBlockClientId();
|
|
19
|
-
if ( currentClientId === null ) {
|
|
20
|
-
return;
|
|
21
|
-
}
|
|
22
|
-
const blockName = getBlockName( currentClientId );
|
|
23
|
-
if ( blockName !== 'core/paragraph' && blockName !== 'core/heading' ) {
|
|
24
|
-
return;
|
|
25
|
-
}
|
|
26
|
-
const attributes = getBlockAttributes( currentClientId );
|
|
27
|
-
const textAlign =
|
|
28
|
-
blockName === 'core/paragraph' ? 'align' : 'textAlign';
|
|
29
|
-
const destinationTextAlign =
|
|
30
|
-
destinationBlockName === 'core/paragraph' ? 'align' : 'textAlign';
|
|
31
|
-
|
|
32
|
-
replaceBlocks(
|
|
33
|
-
currentClientId,
|
|
34
|
-
createBlock( destinationBlockName, {
|
|
35
|
-
level,
|
|
36
|
-
content: attributes.content,
|
|
37
|
-
...{ [ destinationTextAlign ]: attributes[ textAlign ] },
|
|
38
|
-
} )
|
|
39
|
-
);
|
|
40
|
-
};
|
|
41
|
-
|
|
42
|
-
useShortcut( 'core/edit-site/transform-heading-to-paragraph', ( event ) =>
|
|
43
|
-
handleTextLevelShortcut( event, 0 )
|
|
44
|
-
);
|
|
45
|
-
|
|
46
|
-
[ 1, 2, 3, 4, 5, 6 ].forEach( ( level ) => {
|
|
47
|
-
//the loop is based off on a constant therefore
|
|
48
|
-
//the hook will execute the same way every time
|
|
49
|
-
//eslint-disable-next-line react-hooks/rules-of-hooks
|
|
50
|
-
useShortcut(
|
|
51
|
-
`core/edit-site/transform-paragraph-to-heading-${ level }`,
|
|
52
|
-
( event ) => handleTextLevelShortcut( event, level )
|
|
53
|
-
);
|
|
54
|
-
} );
|
|
55
|
-
|
|
56
|
-
return null;
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
export default KeyboardShortcutsEditMode;
|