@wordpress/edit-site 5.2.0 → 5.3.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 +6 -0
- package/build/components/add-new-template/add-custom-generic-template-modal.js +8 -10
- package/build/components/add-new-template/add-custom-generic-template-modal.js.map +1 -1
- package/build/components/add-new-template/add-custom-template-modal.js +0 -1
- package/build/components/add-new-template/add-custom-template-modal.js.map +1 -1
- package/build/components/add-new-template/new-template-part.js +5 -29
- package/build/components/add-new-template/new-template-part.js.map +1 -1
- package/build/components/add-new-template/utils.js +1 -9
- package/build/components/add-new-template/utils.js.map +1 -1
- package/build/components/app/index.js +2 -7
- package/build/components/app/index.js.map +1 -1
- package/build/components/block-editor/index.js +13 -11
- package/build/components/block-editor/index.js.map +1 -1
- package/build/components/block-editor/inserter-media-categories.js +237 -0
- package/build/components/block-editor/inserter-media-categories.js.map +1 -0
- package/build/components/canvas-spinner/index.js +20 -0
- package/build/components/canvas-spinner/index.js.map +1 -0
- package/build/components/create-template-part-modal/index.js +4 -2
- package/build/components/create-template-part-modal/index.js.map +1 -1
- package/build/components/editor/index.js +4 -2
- package/build/components/editor/index.js.map +1 -1
- package/build/components/error-boundary/index.js +2 -12
- package/build/components/error-boundary/index.js.map +1 -1
- package/build/components/error-boundary/warning.js +5 -28
- package/build/components/error-boundary/warning.js.map +1 -1
- package/build/components/global-styles/block-preview-panel.js +2 -2
- package/build/components/global-styles/block-preview-panel.js.map +1 -1
- package/build/components/global-styles/border-panel.js +17 -9
- package/build/components/global-styles/border-panel.js.map +1 -1
- package/build/components/global-styles/color-palette-panel.js +13 -7
- package/build/components/global-styles/color-palette-panel.js.map +1 -1
- package/build/components/global-styles/context-menu.js +39 -4
- package/build/components/global-styles/context-menu.js.map +1 -1
- package/build/components/global-styles/custom-css.js +65 -14
- package/build/components/global-styles/custom-css.js.map +1 -1
- package/build/components/global-styles/dimensions-panel.js +49 -31
- package/build/components/global-styles/dimensions-panel.js.map +1 -1
- package/build/components/global-styles/global-styles-provider.js +13 -3
- package/build/components/global-styles/global-styles-provider.js.map +1 -1
- package/build/components/global-styles/gradients-palette-panel.js +17 -11
- package/build/components/global-styles/gradients-palette-panel.js.map +1 -1
- package/build/components/global-styles/hooks.js +21 -142
- package/build/components/global-styles/hooks.js.map +1 -1
- package/build/components/global-styles/index.js +0 -28
- package/build/components/global-styles/index.js.map +1 -1
- package/build/components/global-styles/palette.js +11 -4
- package/build/components/global-styles/palette.js.map +1 -1
- package/build/components/global-styles/preview.js +18 -15
- package/build/components/global-styles/preview.js.map +1 -1
- package/build/components/global-styles/screen-background-color.js +27 -13
- package/build/components/global-styles/screen-background-color.js.map +1 -1
- package/build/components/global-styles/screen-border.js +10 -4
- package/build/components/global-styles/screen-border.js.map +1 -1
- package/build/components/global-styles/screen-button-color.js +16 -9
- package/build/components/global-styles/screen-button-color.js.map +1 -1
- package/build/components/global-styles/screen-colors.js +43 -34
- package/build/components/global-styles/screen-colors.js.map +1 -1
- package/build/components/global-styles/screen-css.js +20 -8
- package/build/components/global-styles/screen-css.js.map +1 -1
- package/build/components/global-styles/screen-heading-color.js +23 -16
- package/build/components/global-styles/screen-heading-color.js.map +1 -1
- package/build/components/global-styles/screen-layout.js +3 -3
- package/build/components/global-styles/screen-layout.js.map +1 -1
- package/build/components/global-styles/screen-link-color.js +18 -11
- package/build/components/global-styles/screen-link-color.js.map +1 -1
- package/build/components/global-styles/screen-root.js +25 -9
- package/build/components/global-styles/screen-root.js.map +1 -1
- package/build/components/global-styles/screen-style-variations.js +8 -4
- package/build/components/global-styles/screen-style-variations.js.map +1 -1
- package/build/components/global-styles/screen-text-color.js +14 -7
- package/build/components/global-styles/screen-text-color.js.map +1 -1
- package/build/components/global-styles/screen-typography.js +18 -12
- package/build/components/global-styles/screen-typography.js.map +1 -1
- package/build/components/global-styles/shadow-panel.js +196 -0
- package/build/components/global-styles/shadow-panel.js.map +1 -0
- package/build/components/global-styles/typography-panel.js +43 -29
- package/build/components/global-styles/typography-panel.js.map +1 -1
- package/build/components/global-styles/typography-preview.js +19 -9
- package/build/components/global-styles/typography-preview.js.map +1 -1
- package/build/components/global-styles/ui.js +85 -34
- package/build/components/global-styles/ui.js.map +1 -1
- package/build/components/global-styles/utils.js +5 -334
- package/build/components/global-styles/utils.js.map +1 -1
- package/build/components/global-styles-renderer/index.js +7 -5
- package/build/components/global-styles-renderer/index.js.map +1 -1
- package/build/components/header-edit-mode/document-actions/index.js +2 -2
- package/build/components/header-edit-mode/document-actions/index.js.map +1 -1
- package/build/components/keyboard-shortcut-help-modal/index.js +0 -1
- package/build/components/keyboard-shortcut-help-modal/index.js.map +1 -1
- package/build/components/layout/index.js +6 -8
- package/build/components/layout/index.js.map +1 -1
- package/build/components/list/actions/rename-menu-item.js +8 -11
- package/build/components/list/actions/rename-menu-item.js.map +1 -1
- package/build/components/{sidebar-edit-mode/navigation-menu-sidebar/navigation-inspector.js → navigation-inspector/index.js} +1 -2
- package/build/components/navigation-inspector/index.js.map +1 -0
- package/build/components/{sidebar-edit-mode/navigation-menu-sidebar → navigation-inspector}/navigation-menu.js +13 -15
- package/build/components/navigation-inspector/navigation-menu.js.map +1 -0
- package/build/components/sidebar/index.js +3 -1
- package/build/components/sidebar/index.js.map +1 -1
- package/build/components/sidebar-edit-mode/global-styles-sidebar.js +3 -18
- package/build/components/sidebar-edit-mode/global-styles-sidebar.js.map +1 -1
- package/build/components/sidebar-edit-mode/index.js +1 -14
- package/build/components/sidebar-edit-mode/index.js.map +1 -1
- package/build/components/sidebar-navigation-screen/index.js +3 -2
- package/build/components/sidebar-navigation-screen/index.js.map +1 -1
- package/build/components/sidebar-navigation-screen-main/index.js +23 -1
- package/build/components/sidebar-navigation-screen-main/index.js.map +1 -1
- package/build/components/sidebar-navigation-screen-navigation-menus/index.js +35 -0
- package/build/components/sidebar-navigation-screen-navigation-menus/index.js.map +1 -0
- package/build/components/sidebar-navigation-screen-templates/index.js +3 -8
- package/build/components/sidebar-navigation-screen-templates/index.js.map +1 -1
- package/build/components/site-hub/index.js +2 -2
- package/build/components/site-hub/index.js.map +1 -1
- package/build/components/site-icon/index.js +1 -1
- package/build/components/site-icon/index.js.map +1 -1
- package/build/components/style-book/index.js +7 -4
- package/build/components/style-book/index.js.map +1 -1
- package/build/components/template-part-converter/convert-to-template-part.js +5 -9
- package/build/components/template-part-converter/convert-to-template-part.js.map +1 -1
- package/build/experiments.js +19 -0
- package/build/experiments.js.map +1 -0
- package/build/hooks/push-changes-to-global-styles/index.js +65 -6
- package/build/hooks/push-changes-to-global-styles/index.js.map +1 -1
- package/build/index.js +53 -60
- package/build/index.js.map +1 -1
- package/build/store/selectors.js +7 -27
- package/build/store/selectors.js.map +1 -1
- package/build/store/utils.js +77 -0
- package/build/store/utils.js.map +1 -0
- package/build/utils/template-part-create.js +71 -0
- package/build/utils/template-part-create.js.map +1 -0
- package/build-module/components/add-new-template/add-custom-generic-template-modal.js +9 -11
- package/build-module/components/add-new-template/add-custom-generic-template-modal.js.map +1 -1
- package/build-module/components/add-new-template/add-custom-template-modal.js +0 -1
- package/build-module/components/add-new-template/add-custom-template-modal.js.map +1 -1
- package/build-module/components/add-new-template/new-template-part.js +4 -27
- package/build-module/components/add-new-template/new-template-part.js.map +1 -1
- package/build-module/components/add-new-template/utils.js +0 -5
- package/build-module/components/add-new-template/utils.js.map +1 -1
- package/build-module/components/app/index.js +2 -7
- package/build-module/components/app/index.js.map +1 -1
- package/build-module/components/block-editor/index.js +14 -12
- package/build-module/components/block-editor/index.js.map +1 -1
- package/build-module/components/block-editor/inserter-media-categories.js +225 -0
- package/build-module/components/block-editor/inserter-media-categories.js.map +1 -0
- package/build-module/components/canvas-spinner/index.js +12 -0
- package/build-module/components/canvas-spinner/index.js.map +1 -0
- package/build-module/components/create-template-part-modal/index.js +5 -3
- package/build-module/components/create-template-part-modal/index.js.map +1 -1
- package/build-module/components/editor/index.js +3 -2
- package/build-module/components/editor/index.js.map +1 -1
- package/build-module/components/error-boundary/index.js +2 -12
- package/build-module/components/error-boundary/index.js.map +1 -1
- package/build-module/components/error-boundary/warning.js +5 -28
- package/build-module/components/error-boundary/warning.js.map +1 -1
- package/build-module/components/global-styles/block-preview-panel.js +2 -2
- package/build-module/components/global-styles/block-preview-panel.js.map +1 -1
- package/build-module/components/global-styles/border-panel.js +17 -11
- package/build-module/components/global-styles/border-panel.js.map +1 -1
- package/build-module/components/global-styles/color-palette-panel.js +11 -7
- package/build-module/components/global-styles/color-palette-panel.js.map +1 -1
- package/build-module/components/global-styles/context-menu.js +40 -8
- package/build-module/components/global-styles/context-menu.js.map +1 -1
- package/build-module/components/global-styles/custom-css.js +61 -15
- package/build-module/components/global-styles/custom-css.js.map +1 -1
- package/build-module/components/global-styles/dimensions-panel.js +49 -32
- package/build-module/components/global-styles/dimensions-panel.js.map +1 -1
- package/build-module/components/global-styles/global-styles-provider.js +7 -2
- package/build-module/components/global-styles/global-styles-provider.js.map +1 -1
- package/build-module/components/global-styles/gradients-palette-panel.js +15 -11
- package/build-module/components/global-styles/gradients-palette-panel.js.map +1 -1
- package/build-module/components/global-styles/hooks.js +23 -134
- package/build-module/components/global-styles/hooks.js.map +1 -1
- package/build-module/components/global-styles/index.js +0 -2
- package/build-module/components/global-styles/index.js.map +1 -1
- package/build-module/components/global-styles/palette.js +10 -5
- package/build-module/components/global-styles/palette.js.map +1 -1
- package/build-module/components/global-styles/preview.js +18 -14
- package/build-module/components/global-styles/preview.js.map +1 -1
- package/build-module/components/global-styles/screen-background-color.js +26 -15
- package/build-module/components/global-styles/screen-background-color.js.map +1 -1
- package/build-module/components/global-styles/screen-border.js +10 -5
- package/build-module/components/global-styles/screen-border.js.map +1 -1
- package/build-module/components/global-styles/screen-button-color.js +16 -11
- package/build-module/components/global-styles/screen-button-color.js.map +1 -1
- package/build-module/components/global-styles/screen-colors.js +43 -37
- package/build-module/components/global-styles/screen-colors.js.map +1 -1
- package/build-module/components/global-styles/screen-css.js +21 -9
- package/build-module/components/global-styles/screen-css.js.map +1 -1
- package/build-module/components/global-styles/screen-heading-color.js +23 -18
- package/build-module/components/global-styles/screen-heading-color.js.map +1 -1
- package/build-module/components/global-styles/screen-layout.js +4 -4
- package/build-module/components/global-styles/screen-layout.js.map +1 -1
- package/build-module/components/global-styles/screen-link-color.js +18 -13
- package/build-module/components/global-styles/screen-link-color.js.map +1 -1
- package/build-module/components/global-styles/screen-root.js +23 -9
- package/build-module/components/global-styles/screen-root.js.map +1 -1
- package/build-module/components/global-styles/screen-style-variations.js +5 -2
- package/build-module/components/global-styles/screen-style-variations.js.map +1 -1
- package/build-module/components/global-styles/screen-text-color.js +14 -9
- package/build-module/components/global-styles/screen-text-color.js.map +1 -1
- package/build-module/components/global-styles/screen-typography.js +16 -12
- package/build-module/components/global-styles/screen-typography.js.map +1 -1
- package/build-module/components/global-styles/shadow-panel.js +177 -0
- package/build-module/components/global-styles/shadow-panel.js.map +1 -0
- package/build-module/components/global-styles/typography-panel.js +43 -31
- package/build-module/components/global-styles/typography-panel.js.map +1 -1
- package/build-module/components/global-styles/typography-preview.js +17 -9
- package/build-module/components/global-styles/typography-preview.js.map +1 -1
- package/build-module/components/global-styles/ui.js +80 -35
- package/build-module/components/global-styles/ui.js.map +1 -1
- package/build-module/components/global-styles/utils.js +4 -319
- package/build-module/components/global-styles/utils.js.map +1 -1
- package/build-module/components/global-styles-renderer/index.js +5 -5
- package/build-module/components/global-styles-renderer/index.js.map +1 -1
- package/build-module/components/header-edit-mode/document-actions/index.js +2 -2
- package/build-module/components/header-edit-mode/document-actions/index.js.map +1 -1
- package/build-module/components/keyboard-shortcut-help-modal/index.js +0 -1
- package/build-module/components/keyboard-shortcut-help-modal/index.js.map +1 -1
- package/build-module/components/layout/index.js +6 -8
- package/build-module/components/layout/index.js.map +1 -1
- package/build-module/components/list/actions/rename-menu-item.js +9 -12
- package/build-module/components/list/actions/rename-menu-item.js.map +1 -1
- package/build-module/components/{sidebar-edit-mode/navigation-menu-sidebar/navigation-inspector.js → navigation-inspector/index.js} +1 -2
- package/build-module/components/navigation-inspector/index.js.map +1 -0
- package/build-module/components/{sidebar-edit-mode/navigation-menu-sidebar → navigation-inspector}/navigation-menu.js +13 -16
- package/build-module/components/navigation-inspector/navigation-menu.js.map +1 -0
- package/build-module/components/sidebar/index.js +2 -1
- package/build-module/components/sidebar/index.js.map +1 -1
- package/build-module/components/sidebar-edit-mode/global-styles-sidebar.js +6 -21
- package/build-module/components/sidebar-edit-mode/global-styles-sidebar.js.map +1 -1
- package/build-module/components/sidebar-edit-mode/index.js +1 -13
- package/build-module/components/sidebar-edit-mode/index.js.map +1 -1
- package/build-module/components/sidebar-navigation-screen/index.js +3 -2
- package/build-module/components/sidebar-navigation-screen/index.js.map +1 -1
- package/build-module/components/sidebar-navigation-screen-main/index.js +22 -2
- package/build-module/components/sidebar-navigation-screen-main/index.js.map +1 -1
- package/build-module/components/sidebar-navigation-screen-navigation-menus/index.js +23 -0
- package/build-module/components/sidebar-navigation-screen-navigation-menus/index.js.map +1 -0
- package/build-module/components/sidebar-navigation-screen-templates/index.js +4 -9
- package/build-module/components/sidebar-navigation-screen-templates/index.js.map +1 -1
- package/build-module/components/site-hub/index.js +2 -2
- package/build-module/components/site-hub/index.js.map +1 -1
- package/build-module/components/site-icon/index.js +1 -1
- package/build-module/components/site-icon/index.js.map +1 -1
- package/build-module/components/style-book/index.js +8 -5
- package/build-module/components/style-book/index.js.map +1 -1
- package/build-module/components/template-part-converter/convert-to-template-part.js +5 -9
- package/build-module/components/template-part-converter/convert-to-template-part.js.map +1 -1
- package/build-module/experiments.js +9 -0
- package/build-module/experiments.js.map +1 -0
- package/build-module/hooks/push-changes-to-global-styles/index.js +62 -3
- package/build-module/hooks/push-changes-to-global-styles/index.js.map +1 -1
- package/build-module/index.js +52 -60
- package/build-module/index.js.map +1 -1
- package/build-module/store/selectors.js +6 -26
- package/build-module/store/selectors.js.map +1 -1
- package/build-module/store/utils.js +66 -0
- package/build-module/store/utils.js.map +1 -0
- package/build-module/utils/template-part-create.js +53 -0
- package/build-module/utils/template-part-create.js.map +1 -0
- package/build-style/style-rtl.css +314 -216
- package/build-style/style.css +314 -216
- package/package.json +32 -30
- package/src/components/add-new-template/add-custom-generic-template-modal.js +20 -28
- package/src/components/add-new-template/add-custom-template-modal.js +0 -1
- package/src/components/add-new-template/new-template-part.js +11 -32
- package/src/components/add-new-template/style.scss +0 -4
- package/src/components/add-new-template/utils.js +0 -14
- package/src/components/app/index.js +2 -2
- package/src/components/block-editor/index.js +12 -25
- package/src/components/block-editor/inserter-media-categories.js +247 -0
- package/src/components/block-editor/style.scss +19 -7
- package/src/components/canvas-spinner/index.js +12 -0
- package/src/components/canvas-spinner/style.scss +7 -0
- package/src/components/create-template-part-modal/index.js +75 -67
- package/src/components/create-template-part-modal/style.scss +0 -10
- package/src/components/editor/index.js +4 -2
- package/src/components/error-boundary/index.js +2 -10
- package/src/components/error-boundary/warning.js +6 -35
- package/src/components/global-styles/README.md +1 -75
- package/src/components/global-styles/block-preview-panel.js +2 -2
- package/src/components/global-styles/border-panel.js +19 -17
- package/src/components/global-styles/color-palette-panel.js +10 -7
- package/src/components/global-styles/context-menu.js +114 -44
- package/src/components/global-styles/custom-css.js +76 -19
- package/src/components/global-styles/dimensions-panel.js +46 -36
- package/src/components/global-styles/global-styles-provider.js +6 -2
- package/src/components/global-styles/gradients-palette-panel.js +17 -11
- package/src/components/global-styles/hooks.js +31 -155
- package/src/components/global-styles/index.js +0 -2
- package/src/components/global-styles/palette.js +9 -5
- package/src/components/global-styles/preview.js +19 -13
- package/src/components/global-styles/screen-background-color.js +37 -21
- package/src/components/global-styles/screen-border.js +10 -5
- package/src/components/global-styles/screen-button-color.js +21 -19
- package/src/components/global-styles/screen-colors.js +48 -65
- package/src/components/global-styles/screen-css.js +30 -14
- package/src/components/global-styles/screen-heading-color.js +32 -27
- package/src/components/global-styles/screen-layout.js +4 -7
- package/src/components/global-styles/screen-link-color.js +26 -26
- package/src/components/global-styles/screen-root.js +24 -9
- package/src/components/global-styles/screen-style-variations.js +7 -2
- package/src/components/global-styles/screen-text-color.js +15 -19
- package/src/components/global-styles/screen-typography.js +27 -12
- package/src/components/global-styles/shadow-panel.js +174 -0
- package/src/components/global-styles/style.scss +85 -1
- package/src/components/global-styles/typography-panel.js +60 -48
- package/src/components/global-styles/typography-preview.js +28 -9
- package/src/components/global-styles/ui.js +78 -53
- package/src/components/global-styles/utils.js +4 -371
- package/src/components/global-styles-renderer/index.js +3 -4
- package/src/components/header-edit-mode/document-actions/index.js +1 -1
- package/src/components/keyboard-shortcut-help-modal/index.js +0 -1
- package/src/components/layout/index.js +9 -2
- package/src/components/layout/style.scss +4 -5
- package/src/components/list/actions/rename-menu-item.js +14 -23
- package/src/components/list/style.scss +0 -4
- package/src/components/{sidebar-edit-mode/navigation-menu-sidebar/navigation-inspector.js → navigation-inspector/index.js} +1 -4
- package/src/components/{sidebar-edit-mode/navigation-menu-sidebar → navigation-inspector}/navigation-menu.js +10 -12
- package/src/components/{sidebar-edit-mode/navigation-menu-sidebar → navigation-inspector}/style.scss +0 -17
- package/src/components/sidebar/index.js +2 -0
- package/src/components/sidebar-edit-mode/global-styles-sidebar.js +8 -32
- package/src/components/sidebar-edit-mode/index.js +0 -11
- package/src/components/sidebar-edit-mode/settings-header/style.scss +8 -0
- package/src/components/sidebar-navigation-item/style.scss +28 -3
- package/src/components/sidebar-navigation-screen/index.js +4 -3
- package/src/components/sidebar-navigation-screen/style.scss +2 -0
- package/src/components/sidebar-navigation-screen-main/index.js +23 -1
- package/src/components/sidebar-navigation-screen-navigation-menus/index.js +25 -0
- package/src/components/sidebar-navigation-screen-navigation-menus/style.scss +12 -0
- package/src/components/sidebar-navigation-screen-templates/index.js +12 -19
- package/src/components/site-hub/index.js +1 -1
- package/src/components/site-hub/style.scss +7 -1
- package/src/components/site-icon/index.js +1 -1
- package/src/components/site-icon/style.scss +2 -2
- package/src/components/style-book/index.js +10 -5
- package/src/components/template-part-converter/convert-to-template-part.js +12 -10
- package/src/experiments.js +10 -0
- package/src/hooks/push-changes-to-global-styles/index.js +63 -5
- package/src/index.js +51 -59
- package/src/store/selectors.js +6 -26
- package/src/store/test/utils.js +181 -0
- package/src/store/utils.js +69 -0
- package/src/style.scss +4 -2
- package/src/utils/template-part-create.js +62 -0
- package/src/utils/test/template-part-create.js +63 -0
- package/build/components/global-styles/context.js +0 -22
- package/build/components/global-styles/context.js.map +0 -1
- package/build/components/global-styles/typography-utils.js +0 -92
- package/build/components/global-styles/typography-utils.js.map +0 -1
- package/build/components/global-styles/use-global-styles-output.js +0 -943
- package/build/components/global-styles/use-global-styles-output.js.map +0 -1
- package/build/components/sidebar-edit-mode/navigation-menu-sidebar/index.js +0 -42
- package/build/components/sidebar-edit-mode/navigation-menu-sidebar/index.js.map +0 -1
- package/build/components/sidebar-edit-mode/navigation-menu-sidebar/navigation-inspector.js.map +0 -1
- package/build/components/sidebar-edit-mode/navigation-menu-sidebar/navigation-menu.js.map +0 -1
- package/build-module/components/global-styles/context.js +0 -12
- package/build-module/components/global-styles/context.js.map +0 -1
- package/build-module/components/global-styles/typography-utils.js +0 -84
- package/build-module/components/global-styles/typography-utils.js.map +0 -1
- package/build-module/components/global-styles/use-global-styles-output.js +0 -901
- package/build-module/components/global-styles/use-global-styles-output.js.map +0 -1
- package/build-module/components/sidebar-edit-mode/navigation-menu-sidebar/index.js +0 -28
- package/build-module/components/sidebar-edit-mode/navigation-menu-sidebar/index.js.map +0 -1
- package/build-module/components/sidebar-edit-mode/navigation-menu-sidebar/navigation-inspector.js.map +0 -1
- package/build-module/components/sidebar-edit-mode/navigation-menu-sidebar/navigation-menu.js.map +0 -1
- package/src/components/global-styles/context.js +0 -15
- package/src/components/global-styles/test/typography-utils.js +0 -393
- package/src/components/global-styles/test/use-global-styles-output.js +0 -814
- package/src/components/global-styles/test/utils.js +0 -206
- package/src/components/global-styles/typography-utils.js +0 -87
- package/src/components/global-styles/use-global-styles-output.js +0 -1059
- package/src/components/sidebar-edit-mode/navigation-menu-sidebar/index.js +0 -37
package/build-module/index.js
CHANGED
|
@@ -6,7 +6,8 @@ import { createElement } from "@wordpress/element";
|
|
|
6
6
|
import { store as blocksStore } from '@wordpress/blocks';
|
|
7
7
|
import { registerCoreBlocks, __experimentalRegisterExperimentalCoreBlocks } from '@wordpress/block-library';
|
|
8
8
|
import { dispatch } from '@wordpress/data';
|
|
9
|
-
import
|
|
9
|
+
import deprecated from '@wordpress/deprecated';
|
|
10
|
+
import { createRoot } from '@wordpress/element';
|
|
10
11
|
import { __experimentalFetchLinkSuggestions as fetchLinkSuggestions, __experimentalFetchUrlData as fetchUrlData } from '@wordpress/core-data';
|
|
11
12
|
import { store as editorStore } from '@wordpress/editor';
|
|
12
13
|
import { store as interfaceStore } from '@wordpress/interface';
|
|
@@ -21,15 +22,32 @@ import './hooks';
|
|
|
21
22
|
import { store as editSiteStore } from './store';
|
|
22
23
|
import App from './components/app';
|
|
23
24
|
/**
|
|
24
|
-
*
|
|
25
|
-
* an unhandled error occurs, replacing previously mounted editor element using
|
|
26
|
-
* an initial state from prior to the crash.
|
|
25
|
+
* Initializes the site editor screen.
|
|
27
26
|
*
|
|
28
|
-
* @param {
|
|
29
|
-
* @param {
|
|
27
|
+
* @param {string} id ID of the root element to render the screen in.
|
|
28
|
+
* @param {Object} settings Editor settings.
|
|
30
29
|
*/
|
|
31
30
|
|
|
32
|
-
export function
|
|
31
|
+
export function initializeEditor(id, settings) {
|
|
32
|
+
const target = document.getElementById(id);
|
|
33
|
+
const root = createRoot(target);
|
|
34
|
+
|
|
35
|
+
settings.__experimentalFetchLinkSuggestions = (search, searchOptions) => fetchLinkSuggestions(search, searchOptions, settings);
|
|
36
|
+
|
|
37
|
+
settings.__experimentalFetchRichUrlData = fetchUrlData;
|
|
38
|
+
|
|
39
|
+
dispatch(blocksStore).__experimentalReapplyBlockTypeFilters();
|
|
40
|
+
|
|
41
|
+
registerCoreBlocks();
|
|
42
|
+
registerLegacyWidgetBlock({
|
|
43
|
+
inserter: false
|
|
44
|
+
});
|
|
45
|
+
|
|
46
|
+
if (process.env.IS_GUTENBERG_PLUGIN) {
|
|
47
|
+
__experimentalRegisterExperimentalCoreBlocks({
|
|
48
|
+
enableFSEBlocks: true
|
|
49
|
+
});
|
|
50
|
+
}
|
|
33
51
|
/*
|
|
34
52
|
* Prevent adding the Clasic block in the site editor.
|
|
35
53
|
* Only add the filter when the site editor is initialized, not imported.
|
|
@@ -39,73 +57,47 @@ export function reinitializeEditor(target, settings) {
|
|
|
39
57
|
* This usage here is inspired by previous usage of the filter in the post editor:
|
|
40
58
|
* https://github.com/WordPress/gutenberg/pull/37157
|
|
41
59
|
*/
|
|
60
|
+
|
|
61
|
+
|
|
42
62
|
addFilter('blockEditor.__unstableCanInsertBlockType', 'removeClassicBlockFromInserter', (canInsert, blockType) => {
|
|
43
63
|
if (blockType.name === 'core/freeform') {
|
|
44
64
|
return false;
|
|
45
65
|
}
|
|
46
66
|
|
|
47
67
|
return canInsert;
|
|
48
|
-
}); //
|
|
49
|
-
|
|
50
|
-
unmountComponentAtNode(target);
|
|
51
|
-
const reboot = reinitializeEditor.bind(null, target, settings); // We dispatch actions and update the store synchronously before rendering
|
|
68
|
+
}); // We dispatch actions and update the store synchronously before rendering
|
|
52
69
|
// so that we won't trigger unnecessary re-renders with useEffect.
|
|
53
70
|
|
|
54
|
-
{
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
// which internally uses updateEditorSettings as well.
|
|
71
|
+
dispatch(preferencesStore).setDefaults('core/edit-site', {
|
|
72
|
+
editorMode: 'visual',
|
|
73
|
+
fixedToolbar: false,
|
|
74
|
+
focusMode: false,
|
|
75
|
+
keepCaretInsideBlock: false,
|
|
76
|
+
welcomeGuide: true,
|
|
77
|
+
welcomeGuideStyles: true,
|
|
78
|
+
showListViewByDefault: false
|
|
79
|
+
});
|
|
80
|
+
dispatch(interfaceStore).setDefaultComplementaryArea('core/edit-site', 'edit-site/template');
|
|
81
|
+
dispatch(editSiteStore).updateSettings(settings); // Keep the defaultTemplateTypes in the core/editor settings too,
|
|
82
|
+
// so that they can be selected with core/editor selectors in any editor.
|
|
83
|
+
// This is needed because edit-site doesn't initialize with EditorProvider,
|
|
84
|
+
// which internally uses updateEditorSettings as well.
|
|
69
85
|
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
} // Prevent the default browser action for files dropped outside of dropzones.
|
|
86
|
+
dispatch(editorStore).updateEditorSettings({
|
|
87
|
+
defaultTemplateTypes: settings.defaultTemplateTypes,
|
|
88
|
+
defaultTemplatePartAreas: settings.defaultTemplatePartAreas
|
|
89
|
+
}); // Prevent the default browser action for files dropped outside of dropzones.
|
|
75
90
|
|
|
76
91
|
window.addEventListener('dragover', e => e.preventDefault(), false);
|
|
77
92
|
window.addEventListener('drop', e => e.preventDefault(), false);
|
|
78
|
-
render(createElement(App,
|
|
79
|
-
|
|
80
|
-
}), target);
|
|
93
|
+
root.render(createElement(App, null));
|
|
94
|
+
return root;
|
|
81
95
|
}
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
* @param {Object} settings Editor settings.
|
|
87
|
-
*/
|
|
88
|
-
|
|
89
|
-
export function initializeEditor(id, settings) {
|
|
90
|
-
settings.__experimentalFetchLinkSuggestions = (search, searchOptions) => fetchLinkSuggestions(search, searchOptions, settings);
|
|
91
|
-
|
|
92
|
-
settings.__experimentalFetchRichUrlData = fetchUrlData;
|
|
93
|
-
const target = document.getElementById(id);
|
|
94
|
-
|
|
95
|
-
dispatch(blocksStore).__experimentalReapplyBlockTypeFilters();
|
|
96
|
-
|
|
97
|
-
registerCoreBlocks();
|
|
98
|
-
registerLegacyWidgetBlock({
|
|
99
|
-
inserter: false
|
|
96
|
+
export function reinitializeEditor() {
|
|
97
|
+
deprecated('wp.editSite.reinitializeEditor', {
|
|
98
|
+
since: '6.2',
|
|
99
|
+
version: '6.3'
|
|
100
100
|
});
|
|
101
|
-
|
|
102
|
-
if (process.env.IS_GUTENBERG_PLUGIN) {
|
|
103
|
-
__experimentalRegisterExperimentalCoreBlocks({
|
|
104
|
-
enableFSEBlocks: true
|
|
105
|
-
});
|
|
106
|
-
}
|
|
107
|
-
|
|
108
|
-
reinitializeEditor(target, settings);
|
|
109
101
|
}
|
|
110
102
|
export { default as PluginSidebar } from './components/sidebar-edit-mode/plugin-sidebar';
|
|
111
103
|
export { default as PluginSidebarMoreMenuItem } from './components/header-edit-mode/plugin-sidebar-more-menu-item';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["@wordpress/edit-site/src/index.js"],"names":["store","blocksStore","registerCoreBlocks","__experimentalRegisterExperimentalCoreBlocks","dispatch","
|
|
1
|
+
{"version":3,"sources":["@wordpress/edit-site/src/index.js"],"names":["store","blocksStore","registerCoreBlocks","__experimentalRegisterExperimentalCoreBlocks","dispatch","deprecated","createRoot","__experimentalFetchLinkSuggestions","fetchLinkSuggestions","__experimentalFetchUrlData","fetchUrlData","editorStore","interfaceStore","preferencesStore","addFilter","registerLegacyWidgetBlock","editSiteStore","App","initializeEditor","id","settings","target","document","getElementById","root","search","searchOptions","__experimentalFetchRichUrlData","__experimentalReapplyBlockTypeFilters","inserter","process","env","IS_GUTENBERG_PLUGIN","enableFSEBlocks","canInsert","blockType","name","setDefaults","editorMode","fixedToolbar","focusMode","keepCaretInsideBlock","welcomeGuide","welcomeGuideStyles","showListViewByDefault","setDefaultComplementaryArea","updateSettings","updateEditorSettings","defaultTemplateTypes","defaultTemplatePartAreas","window","addEventListener","e","preventDefault","render","reinitializeEditor","since","version","default","PluginSidebar","PluginSidebarMoreMenuItem","PluginMoreMenuItem"],"mappings":";;AAAA;AACA;AACA;AACA,SAASA,KAAK,IAAIC,WAAlB,QAAqC,mBAArC;AACA,SACCC,kBAD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AI,CAAC8B,MAAL,CAAa,cAAC,GAAD,OAAb;AAEA,SAAO9B,IAAP;AACA;AAED,OAAO,SAAS+B,kBAAT,GAA8B;AACpClD,EAAAA,UAAU,CAAE,gCAAF,EAAoC;AAC7CmD,IAAAA,KAAK,EAAE,KADsC;AAE7CC,IAAAA,OAAO,EAAE;AAFoC,GAApC,CAAV;AAIA;AAED,SAASC,OAAO,IAAIC,aAApB,QAAyC,+CAAzC;AACA,SAASD,OAAO,IAAIE,yBAApB,QAAqD,6DAArD;AACA,SAASF,OAAO,IAAIG,kBAApB,QAA8C,qDAA9C","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { store as blocksStore } from '@wordpress/blocks';\nimport {\n\tregisterCoreBlocks,\n\t__experimentalRegisterExperimentalCoreBlocks,\n} from '@wordpress/block-library';\nimport { dispatch } from '@wordpress/data';\nimport deprecated from '@wordpress/deprecated';\nimport { createRoot } from '@wordpress/element';\nimport {\n\t__experimentalFetchLinkSuggestions as fetchLinkSuggestions,\n\t__experimentalFetchUrlData as fetchUrlData,\n} from '@wordpress/core-data';\nimport { store as editorStore } from '@wordpress/editor';\nimport { store as interfaceStore } from '@wordpress/interface';\nimport { store as preferencesStore } from '@wordpress/preferences';\nimport { addFilter } from '@wordpress/hooks';\nimport { registerLegacyWidgetBlock } from '@wordpress/widgets';\n\n/**\n * Internal dependencies\n */\nimport './hooks';\nimport { store as editSiteStore } from './store';\nimport App from './components/app';\n\n/**\n * Initializes the site editor screen.\n *\n * @param {string} id ID of the root element to render the screen in.\n * @param {Object} settings Editor settings.\n */\nexport function initializeEditor( id, settings ) {\n\tconst target = document.getElementById( id );\n\tconst root = createRoot( target );\n\n\tsettings.__experimentalFetchLinkSuggestions = ( search, searchOptions ) =>\n\t\tfetchLinkSuggestions( search, searchOptions, settings );\n\tsettings.__experimentalFetchRichUrlData = fetchUrlData;\n\n\tdispatch( blocksStore ).__experimentalReapplyBlockTypeFilters();\n\tregisterCoreBlocks();\n\tregisterLegacyWidgetBlock( { inserter: false } );\n\tif ( process.env.IS_GUTENBERG_PLUGIN ) {\n\t\t__experimentalRegisterExperimentalCoreBlocks( {\n\t\t\tenableFSEBlocks: true,\n\t\t} );\n\t}\n\t/*\n\t * Prevent adding the Clasic block in the site editor.\n\t * Only add the filter when the site editor is initialized, not imported.\n\t * Also only add the filter(s) after registerCoreBlocks()\n\t * so that common filters in the block library are not overwritten.\n\t *\n\t * This usage here is inspired by previous usage of the filter in the post editor:\n\t * https://github.com/WordPress/gutenberg/pull/37157\n\t */\n\taddFilter(\n\t\t'blockEditor.__unstableCanInsertBlockType',\n\t\t'removeClassicBlockFromInserter',\n\t\t( canInsert, blockType ) => {\n\t\t\tif ( blockType.name === 'core/freeform' ) {\n\t\t\t\treturn false;\n\t\t\t}\n\t\t\treturn canInsert;\n\t\t}\n\t);\n\n\t// We dispatch actions and update the store synchronously before rendering\n\t// so that we won't trigger unnecessary re-renders with useEffect.\n\tdispatch( preferencesStore ).setDefaults( 'core/edit-site', {\n\t\teditorMode: 'visual',\n\t\tfixedToolbar: false,\n\t\tfocusMode: false,\n\t\tkeepCaretInsideBlock: false,\n\t\twelcomeGuide: true,\n\t\twelcomeGuideStyles: true,\n\t\tshowListViewByDefault: false,\n\t} );\n\n\tdispatch( interfaceStore ).setDefaultComplementaryArea(\n\t\t'core/edit-site',\n\t\t'edit-site/template'\n\t);\n\n\tdispatch( editSiteStore ).updateSettings( settings );\n\n\t// Keep the defaultTemplateTypes in the core/editor settings too,\n\t// so that they can be selected with core/editor selectors in any editor.\n\t// This is needed because edit-site doesn't initialize with EditorProvider,\n\t// which internally uses updateEditorSettings as well.\n\tdispatch( editorStore ).updateEditorSettings( {\n\t\tdefaultTemplateTypes: settings.defaultTemplateTypes,\n\t\tdefaultTemplatePartAreas: settings.defaultTemplatePartAreas,\n\t} );\n\n\t// Prevent the default browser action for files dropped outside of dropzones.\n\twindow.addEventListener( 'dragover', ( e ) => e.preventDefault(), false );\n\twindow.addEventListener( 'drop', ( e ) => e.preventDefault(), false );\n\n\troot.render( <App /> );\n\n\treturn root;\n}\n\nexport function reinitializeEditor() {\n\tdeprecated( 'wp.editSite.reinitializeEditor', {\n\t\tsince: '6.2',\n\t\tversion: '6.3',\n\t} );\n}\n\nexport { default as PluginSidebar } from './components/sidebar-edit-mode/plugin-sidebar';\nexport { default as PluginSidebarMoreMenuItem } from './components/header-edit-mode/plugin-sidebar-more-menu-item';\nexport { default as PluginMoreMenuItem } from './components/header-edit-mode/plugin-more-menu-item';\n"]}
|
|
@@ -10,9 +10,13 @@ import { store as coreDataStore } from '@wordpress/core-data';
|
|
|
10
10
|
import { createRegistrySelector } from '@wordpress/data';
|
|
11
11
|
import deprecated from '@wordpress/deprecated';
|
|
12
12
|
import { uploadMedia } from '@wordpress/media-utils';
|
|
13
|
-
import { isTemplatePart } from '@wordpress/blocks';
|
|
14
13
|
import { Platform } from '@wordpress/element';
|
|
15
14
|
import { store as preferencesStore } from '@wordpress/preferences';
|
|
15
|
+
/**
|
|
16
|
+
* Internal dependencies
|
|
17
|
+
*/
|
|
18
|
+
|
|
19
|
+
import { getFilteredTemplatePartBlocks } from './utils';
|
|
16
20
|
/**
|
|
17
21
|
* @typedef {'template'|'template_type'} TemplateType Template type.
|
|
18
22
|
*/
|
|
@@ -242,37 +246,13 @@ export function isSaveViewOpened(state) {
|
|
|
242
246
|
*/
|
|
243
247
|
|
|
244
248
|
export const getCurrentTemplateTemplateParts = createRegistrySelector(select => state => {
|
|
245
|
-
var _template$blocks;
|
|
246
|
-
|
|
247
249
|
const templateType = getEditedPostType(state);
|
|
248
250
|
const templateId = getEditedPostId(state);
|
|
249
251
|
const template = select(coreDataStore).getEditedEntityRecord('postType', templateType, templateId);
|
|
250
252
|
const templateParts = select(coreDataStore).getEntityRecords('postType', 'wp_template_part', {
|
|
251
253
|
per_page: -1
|
|
252
254
|
});
|
|
253
|
-
|
|
254
|
-
templateParts.reduce((newTemplateParts, part) => ({ ...newTemplateParts,
|
|
255
|
-
[part.id]: part
|
|
256
|
-
}), {}) : {};
|
|
257
|
-
return ((_template$blocks = template.blocks) !== null && _template$blocks !== void 0 ? _template$blocks : []).filter(block => isTemplatePart(block)).map(block => {
|
|
258
|
-
const {
|
|
259
|
-
attributes: {
|
|
260
|
-
theme,
|
|
261
|
-
slug
|
|
262
|
-
}
|
|
263
|
-
} = block;
|
|
264
|
-
const templatePartId = `${theme}//${slug}`;
|
|
265
|
-
const templatePart = templatePartsById[templatePartId];
|
|
266
|
-
return {
|
|
267
|
-
templatePart,
|
|
268
|
-
block
|
|
269
|
-
};
|
|
270
|
-
}).filter(_ref3 => {
|
|
271
|
-
let {
|
|
272
|
-
templatePart
|
|
273
|
-
} = _ref3;
|
|
274
|
-
return !!templatePart;
|
|
275
|
-
});
|
|
255
|
+
return getFilteredTemplatePartBlocks(template.blocks, templateParts);
|
|
276
256
|
});
|
|
277
257
|
/**
|
|
278
258
|
* Returns the current editing mode.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["@wordpress/edit-site/src/store/selectors.js"],"names":["createSelector","store","coreDataStore","createRegistrySelector","deprecated","uploadMedia","isTemplatePart","Platform","preferencesStore","__unstableGetPreference","select","state","name","get","isFeatureActive","featureName","since","alternative","__experimentalGetPreviewDeviceType","deviceType","getCanUserCreateMedia","canUser","getReusableBlocks","isWeb","OS","getEntityRecords","per_page","getSettings","setIsInserterOpen","settings","outlineMode","focusMode","hasFixedToolbar","keepCaretInsideBlock","showIconLabels","__experimentalSetIsInserterOpened","__experimentalReusableBlocks","__experimentalPreferPatternsOnRoot","getEditedPostType","canUserCreateMedia","mediaUpload","onError","rest","wpAllowedMimeTypes","allowedMimeTypes","message","getHomeTemplateId","version","editedPost","postType","getEditedPostId","id","getEditedPostContext","context","getPage","isInserterOpened","blockInserterPanel","__experimentalGetInsertionPoint","rootClientId","insertionIndex","filterValue","isListViewOpened","listViewPanel","isSaveViewOpened","saveViewPanel","getCurrentTemplateTemplateParts","templateType","templateId","template","getEditedEntityRecord","templateParts","templatePartsById","reduce","newTemplateParts","part","blocks","filter","block","map","attributes","theme","slug","templatePartId","templatePart","getEditorMode","__unstableGetCanvasMode","canvasMode","getCurrentTemplateNavigationPanelSubMenu","getNavigationPanelActiveMenu","isNavigationOpened"],"mappings":"AAAA;AACA;AACA;AACA,OAAOA,cAAP,MAA2B,QAA3B;AAEA;AACA;AACA;;AACA,SAASC,KAAK,IAAIC,aAAlB,QAAuC,sBAAvC;AACA,SAASC,sBAAT,QAAuC,iBAAvC;AACA,OAAOC,UAAP,MAAuB,uBAAvB;AACA,SAASC,WAAT,QAA4B,wBAA5B;AACA,SAASC,cAAT,QAA+B,mBAA/B;AACA,SAASC,QAAT,QAAyB,oBAAzB;AACA,SAASN,KAAK,IAAIO,gBAAlB,QAA0C,wBAA1C;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AACA,OAAO,MAAMC,uBAAuB,GAAGN,sBAAsB,CAC1DO,MAAF,IAAc,CAAEC,KAAF,EAASC,IAAT,KACbF,MAAM,CAAEF,gBAAF,CAAN,CAA2BK,GAA3B,CAAgC,gBAAhC,EAAkDD,IAAlD,CAF2D,CAAtD;AAKP;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AACA,OAAO,SAASE,eAAT,CAA0BH,KAA1B,EAAiCI,WAAjC,EAA+C;AACrDX,EAAAA,UAAU,CAAG,4CAAH,EAAgD;AACzDY,IAAAA,KAAK,EAAE,KADkD;AAEzDC,IAAAA,WAAW,EAAG;AAF2C,GAAhD,CAAV;AAKA,SAAO,CAAC,CAAER,uBAAuB,CAAEE,KAAF,EAASI,WAAT,CAAjC;AACA;AAED;AACA;AACA;AACA;AACA;AACA;AACA;;AACA,OAAO,SAASG,kCAAT,CAA6CP,KAA7C,EAAqD;AAC3D,SAAOA,KAAK,CAACQ,UAAb;AACA;AAED;AACA;AACA;AACA;AACA;AACA;AACA;;AACA,OAAO,MAAMC,qBAAqB,GAAGjB,sBAAsB,CACxDO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A9B;AACA;AAED;AACA;AACA;AACA;AACA;AACA;AACA;;AACA,OAAO,SAAS0E,uBAAT,CAAkC1E,KAAlC,EAA0C;AAChD,SAAOA,KAAK,CAAC2E,UAAb;AACA;AAED;AACA;AACA;;AACA,OAAO,SAASC,wCAAT,GAAoD;AAC1DnF,EAAAA,UAAU,CACT,uEADS,EAET;AACCY,IAAAA,KAAK,EAAE,KADR;AAEC+B,IAAAA,OAAO,EAAE;AAFV,GAFS,CAAV;AAOA;AAED;AACA;AACA;;AACA,OAAO,SAASyC,4BAAT,GAAwC;AAC9CpF,EAAAA,UAAU,CAAE,2DAAF,EAA+D;AACxEY,IAAAA,KAAK,EAAE,KADiE;AAExE+B,IAAAA,OAAO,EAAE;AAF+D,GAA/D,CAAV;AAIA;AAED;AACA;AACA;;AACA,OAAO,SAAS0C,kBAAT,GAA8B;AACpCrF,EAAAA,UAAU,CAAE,iDAAF,EAAqD;AAC9DY,IAAAA,KAAK,EAAE,KADuD;AAE9D+B,IAAAA,OAAO,EAAE;AAFqD,GAArD,CAAV;AAIA","sourcesContent":["/**\n * External dependencies\n */\nimport createSelector from 'rememo';\n\n/**\n * WordPress dependencies\n */\nimport { store as coreDataStore } from '@wordpress/core-data';\nimport { createRegistrySelector } from '@wordpress/data';\nimport deprecated from '@wordpress/deprecated';\nimport { uploadMedia } from '@wordpress/media-utils';\nimport { isTemplatePart } from '@wordpress/blocks';\nimport { Platform } from '@wordpress/element';\nimport { store as preferencesStore } from '@wordpress/preferences';\n\n/**\n * @typedef {'template'|'template_type'} TemplateType Template type.\n */\n\n/**\n * Helper for getting a preference from the preferences store.\n *\n * This is only present so that `getSettings` doesn't need to be made a\n * registry selector.\n *\n * It's unstable because the selector needs to be exported and so part of the\n * public API to work.\n */\nexport const __unstableGetPreference = createRegistrySelector(\n\t( select ) => ( state, name ) =>\n\t\tselect( preferencesStore ).get( 'core/edit-site', name )\n);\n\n/**\n * Returns whether the given feature is enabled or not.\n *\n * @param {Object} state Global application state.\n * @param {string} featureName Feature slug.\n *\n * @return {boolean} Is active.\n */\nexport function isFeatureActive( state, featureName ) {\n\tdeprecated( `select( 'core/interface' ).isFeatureActive`, {\n\t\tsince: '6.0',\n\t\talternative: `select( 'core/preferences' ).get`,\n\t} );\n\n\treturn !! __unstableGetPreference( state, featureName );\n}\n\n/**\n * Returns the current editing canvas device type.\n *\n * @param {Object} state Global application state.\n *\n * @return {string} Device type.\n */\nexport function __experimentalGetPreviewDeviceType( state ) {\n\treturn state.deviceType;\n}\n\n/**\n * Returns whether the current user can create media or not.\n *\n * @param {Object} state Global application state.\n *\n * @return {Object} Whether the current user can create media or not.\n */\nexport const getCanUserCreateMedia = createRegistrySelector(\n\t( select ) => () => select( coreDataStore ).canUser( 'create', 'media' )\n);\n\n/**\n * Returns any available Reusable blocks.\n *\n * @param {Object} state Global application state.\n *\n * @return {Array} The available reusable blocks.\n */\nexport const getReusableBlocks = createRegistrySelector( ( select ) => () => {\n\tconst isWeb = Platform.OS === 'web';\n\treturn isWeb\n\t\t? select( coreDataStore ).getEntityRecords( 'postType', 'wp_block', {\n\t\t\t\tper_page: -1,\n\t\t } )\n\t\t: [];\n} );\n\n/**\n * Returns the settings, taking into account active features and permissions.\n *\n * @param {Object} state Global application state.\n * @param {Function} setIsInserterOpen Setter for the open state of the global inserter.\n *\n * @return {Object} Settings.\n */\nexport const getSettings = createSelector(\n\t( state, setIsInserterOpen ) => {\n\t\tconst settings = {\n\t\t\t...state.settings,\n\t\t\toutlineMode: true,\n\t\t\tfocusMode: !! __unstableGetPreference( state, 'focusMode' ),\n\t\t\thasFixedToolbar: !! __unstableGetPreference(\n\t\t\t\tstate,\n\t\t\t\t'fixedToolbar'\n\t\t\t),\n\t\t\tkeepCaretInsideBlock: !! __unstableGetPreference(\n\t\t\t\tstate,\n\t\t\t\t'keepCaretInsideBlock'\n\t\t\t),\n\t\t\tshowIconLabels: !! __unstableGetPreference(\n\t\t\t\tstate,\n\t\t\t\t'showIconLabels'\n\t\t\t),\n\t\t\t__experimentalSetIsInserterOpened: setIsInserterOpen,\n\t\t\t__experimentalReusableBlocks: getReusableBlocks( state ),\n\t\t\t__experimentalPreferPatternsOnRoot:\n\t\t\t\t'wp_template' === getEditedPostType( state ),\n\t\t};\n\n\t\tconst canUserCreateMedia = getCanUserCreateMedia( state );\n\t\tif ( ! canUserCreateMedia ) {\n\t\t\treturn settings;\n\t\t}\n\n\t\tsettings.mediaUpload = ( { onError, ...rest } ) => {\n\t\t\tuploadMedia( {\n\t\t\t\twpAllowedMimeTypes: state.settings.allowedMimeTypes,\n\t\t\t\tonError: ( { message } ) => onError( message ),\n\t\t\t\t...rest,\n\t\t\t} );\n\t\t};\n\t\treturn settings;\n\t},\n\t( state ) => [\n\t\tgetCanUserCreateMedia( state ),\n\t\tstate.settings,\n\t\t__unstableGetPreference( state, 'focusMode' ),\n\t\t__unstableGetPreference( state, 'fixedToolbar' ),\n\t\t__unstableGetPreference( state, 'keepCaretInsideBlock' ),\n\t\t__unstableGetPreference( state, 'showIconLabels' ),\n\t\tgetReusableBlocks( state ),\n\t\tgetEditedPostType( state ),\n\t]\n);\n\n/**\n * @deprecated\n */\nexport function getHomeTemplateId() {\n\tdeprecated( \"select( 'core/edit-site' ).getHomeTemplateId\", {\n\t\tsince: '6.2',\n\t\tversion: '6.4',\n\t} );\n}\n\n/**\n * Returns the current edited post type (wp_template or wp_template_part).\n *\n * @param {Object} state Global application state.\n *\n * @return {TemplateType?} Template type.\n */\nexport function getEditedPostType( state ) {\n\treturn state.editedPost.postType;\n}\n\n/**\n * Returns the ID of the currently edited template or template part.\n *\n * @param {Object} state Global application state.\n *\n * @return {string?} Post ID.\n */\nexport function getEditedPostId( state ) {\n\treturn state.editedPost.id;\n}\n\n/**\n * Returns the edited post's context object.\n *\n * @deprecated\n * @param {Object} state Global application state.\n *\n * @return {Object} Page.\n */\nexport function getEditedPostContext( state ) {\n\treturn state.editedPost.context;\n}\n\n/**\n * Returns the current page object.\n *\n * @deprecated\n * @param {Object} state Global application state.\n *\n * @return {Object} Page.\n */\nexport function getPage( state ) {\n\treturn { context: state.editedPost.context };\n}\n\n/**\n * Returns the current opened/closed state of the inserter panel.\n *\n * @param {Object} state Global application state.\n *\n * @return {boolean} True if the inserter panel should be open; false if closed.\n */\nexport function isInserterOpened( state ) {\n\treturn !! state.blockInserterPanel;\n}\n\n/**\n * Get the insertion point for the inserter.\n *\n * @param {Object} state Global application state.\n *\n * @return {Object} The root client ID, index to insert at and starting filter value.\n */\nexport function __experimentalGetInsertionPoint( state ) {\n\tconst { rootClientId, insertionIndex, filterValue } =\n\t\tstate.blockInserterPanel;\n\treturn { rootClientId, insertionIndex, filterValue };\n}\n\n/**\n * Returns the current opened/closed state of the list view panel.\n *\n * @param {Object} state Global application state.\n *\n * @return {boolean} True if the list view panel should be open; false if closed.\n */\nexport function isListViewOpened( state ) {\n\treturn state.listViewPanel;\n}\n\n/**\n * Returns the current opened/closed state of the save panel.\n *\n * @param {Object} state Global application state.\n *\n * @return {boolean} True if the save panel should be open; false if closed.\n */\nexport function isSaveViewOpened( state ) {\n\treturn state.saveViewPanel;\n}\n\n/**\n * Returns the template parts and their blocks for the current edited template.\n *\n * @param {Object} state Global application state.\n * @return {Array} Template parts and their blocks in an array.\n */\nexport const getCurrentTemplateTemplateParts = createRegistrySelector(\n\t( select ) => ( state ) => {\n\t\tconst templateType = getEditedPostType( state );\n\t\tconst templateId = getEditedPostId( state );\n\t\tconst template = select( coreDataStore ).getEditedEntityRecord(\n\t\t\t'postType',\n\t\t\ttemplateType,\n\t\t\ttemplateId\n\t\t);\n\n\t\tconst templateParts = select( coreDataStore ).getEntityRecords(\n\t\t\t'postType',\n\t\t\t'wp_template_part',\n\t\t\t{ per_page: -1 }\n\t\t);\n\t\tconst templatePartsById = templateParts\n\t\t\t? // Key template parts by their ID.\n\t\t\t templateParts.reduce(\n\t\t\t\t\t( newTemplateParts, part ) => ( {\n\t\t\t\t\t\t...newTemplateParts,\n\t\t\t\t\t\t[ part.id ]: part,\n\t\t\t\t\t} ),\n\t\t\t\t\t{}\n\t\t\t )\n\t\t\t: {};\n\n\t\treturn ( template.blocks ?? [] )\n\t\t\t.filter( ( block ) => isTemplatePart( block ) )\n\t\t\t.map( ( block ) => {\n\t\t\t\tconst {\n\t\t\t\t\tattributes: { theme, slug },\n\t\t\t\t} = block;\n\t\t\t\tconst templatePartId = `${ theme }//${ slug }`;\n\t\t\t\tconst templatePart = templatePartsById[ templatePartId ];\n\n\t\t\t\treturn {\n\t\t\t\t\ttemplatePart,\n\t\t\t\t\tblock,\n\t\t\t\t};\n\t\t\t} )\n\t\t\t.filter( ( { templatePart } ) => !! templatePart );\n\t}\n);\n\n/**\n * Returns the current editing mode.\n *\n * @param {Object} state Global application state.\n *\n * @return {string} Editing mode.\n */\nexport function getEditorMode( state ) {\n\treturn __unstableGetPreference( state, 'editorMode' );\n}\n\n/**\n * Returns the current canvas mode.\n *\n * @param {Object} state Global application state.\n *\n * @return {string} Canvas mode.\n */\nexport function __unstableGetCanvasMode( state ) {\n\treturn state.canvasMode;\n}\n\n/**\n * @deprecated\n */\nexport function getCurrentTemplateNavigationPanelSubMenu() {\n\tdeprecated(\n\t\t\"dispatch( 'core/edit-site' ).getCurrentTemplateNavigationPanelSubMenu\",\n\t\t{\n\t\t\tsince: '6.2',\n\t\t\tversion: '6.4',\n\t\t}\n\t);\n}\n\n/**\n * @deprecated\n */\nexport function getNavigationPanelActiveMenu() {\n\tdeprecated( \"dispatch( 'core/edit-site' ).getNavigationPanelActiveMenu\", {\n\t\tsince: '6.2',\n\t\tversion: '6.4',\n\t} );\n}\n\n/**\n * @deprecated\n */\nexport function isNavigationOpened() {\n\tdeprecated( \"dispatch( 'core/edit-site' ).isNavigationOpened\", {\n\t\tsince: '6.2',\n\t\tversion: '6.4',\n\t} );\n}\n"]}
|
|
1
|
+
{"version":3,"sources":["@wordpress/edit-site/src/store/selectors.js"],"names":["createSelector","store","coreDataStore","createRegistrySelector","deprecated","uploadMedia","Platform","preferencesStore","getFilteredTemplatePartBlocks","__unstableGetPreference","select","state","name","get","isFeatureActive","featureName","since","alternative","__experimentalGetPreviewDeviceType","deviceType","getCanUserCreateMedia","canUser","getReusableBlocks","isWeb","OS","getEntityRecords","per_page","getSettings","setIsInserterOpen","settings","outlineMode","focusMode","hasFixedToolbar","keepCaretInsideBlock","showIconLabels","__experimentalSetIsInserterOpened","__experimentalReusableBlocks","__experimentalPreferPatternsOnRoot","getEditedPostType","canUserCreateMedia","mediaUpload","onError","rest","wpAllowedMimeTypes","allowedMimeTypes","message","getHomeTemplateId","version","editedPost","postType","getEditedPostId","id","getEditedPostContext","context","getPage","isInserterOpened","blockInserterPanel","__experimentalGetInsertionPoint","rootClientId","insertionIndex","filterValue","isListViewOpened","listViewPanel","isSaveViewOpened","saveViewPanel","getCurrentTemplateTemplateParts","templateType","templateId","template","getEditedEntityRecord","templateParts","blocks","getEditorMode","__unstableGetCanvasMode","canvasMode","getCurrentTemplateNavigationPanelSubMenu","getNavigationPanelActiveMenu","isNavigationOpened"],"mappings":"AAAA;AACA;AACA;AACA,OAAOA,cAAP,MAA2B,QAA3B;AAEA;AACA;AACA;;AACA,SAASC,KAAK,IAAIC,aAAlB,QAAuC,sBAAvC;AACA,SAASC,sBAAT,QAAuC,iBAAvC;AACA,OAAOC,UAAP,MAAuB,uBAAvB;AACA,SAASC,WAAT,QAA4B,wBAA5B;AACA,SAASC,QAAT,QAAyB,oBAAzB;AACA,SAASL,KAAK,IAAIM,gBAAlB,QAA0C,wBAA1C;AAEA;AACA;AACA;;AACA,SAASC,6BAAT,QAA8C,SAA9C;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AACA,OAAO,MAAMC,uBAAuB,GAAGN,sBAAsB,CAC1DO,MAAF,IAAc,CAAEC,KAAF,EAASC,IAAT,KACbF,MAAM,CAAEH,gBAAF,CAAN,CAA2BM,GAA3B,CAAgC,gBAAhC,EAAkDD,IAAlD,CAF2D,CAAtD;AAK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UAAU,CACT,uEADS,EAET;AACCY,IAAAA,KAAK,EAAE,KADR;AAEC+B,IAAAA,OAAO,EAAE;AAFV,GAFS,CAAV;AAOA;AAED;AACA;AACA;;AACA,OAAO,SAAS6B,4BAAT,GAAwC;AAC9CxE,EAAAA,UAAU,CAAE,2DAAF,EAA+D;AACxEY,IAAAA,KAAK,EAAE,KADiE;AAExE+B,IAAAA,OAAO,EAAE;AAF+D,GAA/D,CAAV;AAIA;AAED;AACA;AACA;;AACA,OAAO,SAAS8B,kBAAT,GAA8B;AACpCzE,EAAAA,UAAU,CAAE,iDAAF,EAAqD;AAC9DY,IAAAA,KAAK,EAAE,KADuD;AAE9D+B,IAAAA,OAAO,EAAE;AAFqD,GAArD,CAAV;AAIA","sourcesContent":["/**\n * External dependencies\n */\nimport createSelector from 'rememo';\n\n/**\n * WordPress dependencies\n */\nimport { store as coreDataStore } from '@wordpress/core-data';\nimport { createRegistrySelector } from '@wordpress/data';\nimport deprecated from '@wordpress/deprecated';\nimport { uploadMedia } from '@wordpress/media-utils';\nimport { Platform } from '@wordpress/element';\nimport { store as preferencesStore } from '@wordpress/preferences';\n\n/**\n * Internal dependencies\n */\nimport { getFilteredTemplatePartBlocks } from './utils';\n\n/**\n * @typedef {'template'|'template_type'} TemplateType Template type.\n */\n\n/**\n * Helper for getting a preference from the preferences store.\n *\n * This is only present so that `getSettings` doesn't need to be made a\n * registry selector.\n *\n * It's unstable because the selector needs to be exported and so part of the\n * public API to work.\n */\nexport const __unstableGetPreference = createRegistrySelector(\n\t( select ) => ( state, name ) =>\n\t\tselect( preferencesStore ).get( 'core/edit-site', name )\n);\n\n/**\n * Returns whether the given feature is enabled or not.\n *\n * @param {Object} state Global application state.\n * @param {string} featureName Feature slug.\n *\n * @return {boolean} Is active.\n */\nexport function isFeatureActive( state, featureName ) {\n\tdeprecated( `select( 'core/interface' ).isFeatureActive`, {\n\t\tsince: '6.0',\n\t\talternative: `select( 'core/preferences' ).get`,\n\t} );\n\n\treturn !! __unstableGetPreference( state, featureName );\n}\n\n/**\n * Returns the current editing canvas device type.\n *\n * @param {Object} state Global application state.\n *\n * @return {string} Device type.\n */\nexport function __experimentalGetPreviewDeviceType( state ) {\n\treturn state.deviceType;\n}\n\n/**\n * Returns whether the current user can create media or not.\n *\n * @param {Object} state Global application state.\n *\n * @return {Object} Whether the current user can create media or not.\n */\nexport const getCanUserCreateMedia = createRegistrySelector(\n\t( select ) => () => select( coreDataStore ).canUser( 'create', 'media' )\n);\n\n/**\n * Returns any available Reusable blocks.\n *\n * @param {Object} state Global application state.\n *\n * @return {Array} The available reusable blocks.\n */\nexport const getReusableBlocks = createRegistrySelector( ( select ) => () => {\n\tconst isWeb = Platform.OS === 'web';\n\treturn isWeb\n\t\t? select( coreDataStore ).getEntityRecords( 'postType', 'wp_block', {\n\t\t\t\tper_page: -1,\n\t\t } )\n\t\t: [];\n} );\n\n/**\n * Returns the settings, taking into account active features and permissions.\n *\n * @param {Object} state Global application state.\n * @param {Function} setIsInserterOpen Setter for the open state of the global inserter.\n *\n * @return {Object} Settings.\n */\nexport const getSettings = createSelector(\n\t( state, setIsInserterOpen ) => {\n\t\tconst settings = {\n\t\t\t...state.settings,\n\t\t\toutlineMode: true,\n\t\t\tfocusMode: !! __unstableGetPreference( state, 'focusMode' ),\n\t\t\thasFixedToolbar: !! __unstableGetPreference(\n\t\t\t\tstate,\n\t\t\t\t'fixedToolbar'\n\t\t\t),\n\t\t\tkeepCaretInsideBlock: !! __unstableGetPreference(\n\t\t\t\tstate,\n\t\t\t\t'keepCaretInsideBlock'\n\t\t\t),\n\t\t\tshowIconLabels: !! __unstableGetPreference(\n\t\t\t\tstate,\n\t\t\t\t'showIconLabels'\n\t\t\t),\n\t\t\t__experimentalSetIsInserterOpened: setIsInserterOpen,\n\t\t\t__experimentalReusableBlocks: getReusableBlocks( state ),\n\t\t\t__experimentalPreferPatternsOnRoot:\n\t\t\t\t'wp_template' === getEditedPostType( state ),\n\t\t};\n\n\t\tconst canUserCreateMedia = getCanUserCreateMedia( state );\n\t\tif ( ! canUserCreateMedia ) {\n\t\t\treturn settings;\n\t\t}\n\n\t\tsettings.mediaUpload = ( { onError, ...rest } ) => {\n\t\t\tuploadMedia( {\n\t\t\t\twpAllowedMimeTypes: state.settings.allowedMimeTypes,\n\t\t\t\tonError: ( { message } ) => onError( message ),\n\t\t\t\t...rest,\n\t\t\t} );\n\t\t};\n\t\treturn settings;\n\t},\n\t( state ) => [\n\t\tgetCanUserCreateMedia( state ),\n\t\tstate.settings,\n\t\t__unstableGetPreference( state, 'focusMode' ),\n\t\t__unstableGetPreference( state, 'fixedToolbar' ),\n\t\t__unstableGetPreference( state, 'keepCaretInsideBlock' ),\n\t\t__unstableGetPreference( state, 'showIconLabels' ),\n\t\tgetReusableBlocks( state ),\n\t\tgetEditedPostType( state ),\n\t]\n);\n\n/**\n * @deprecated\n */\nexport function getHomeTemplateId() {\n\tdeprecated( \"select( 'core/edit-site' ).getHomeTemplateId\", {\n\t\tsince: '6.2',\n\t\tversion: '6.4',\n\t} );\n}\n\n/**\n * Returns the current edited post type (wp_template or wp_template_part).\n *\n * @param {Object} state Global application state.\n *\n * @return {TemplateType?} Template type.\n */\nexport function getEditedPostType( state ) {\n\treturn state.editedPost.postType;\n}\n\n/**\n * Returns the ID of the currently edited template or template part.\n *\n * @param {Object} state Global application state.\n *\n * @return {string?} Post ID.\n */\nexport function getEditedPostId( state ) {\n\treturn state.editedPost.id;\n}\n\n/**\n * Returns the edited post's context object.\n *\n * @deprecated\n * @param {Object} state Global application state.\n *\n * @return {Object} Page.\n */\nexport function getEditedPostContext( state ) {\n\treturn state.editedPost.context;\n}\n\n/**\n * Returns the current page object.\n *\n * @deprecated\n * @param {Object} state Global application state.\n *\n * @return {Object} Page.\n */\nexport function getPage( state ) {\n\treturn { context: state.editedPost.context };\n}\n\n/**\n * Returns the current opened/closed state of the inserter panel.\n *\n * @param {Object} state Global application state.\n *\n * @return {boolean} True if the inserter panel should be open; false if closed.\n */\nexport function isInserterOpened( state ) {\n\treturn !! state.blockInserterPanel;\n}\n\n/**\n * Get the insertion point for the inserter.\n *\n * @param {Object} state Global application state.\n *\n * @return {Object} The root client ID, index to insert at and starting filter value.\n */\nexport function __experimentalGetInsertionPoint( state ) {\n\tconst { rootClientId, insertionIndex, filterValue } =\n\t\tstate.blockInserterPanel;\n\treturn { rootClientId, insertionIndex, filterValue };\n}\n\n/**\n * Returns the current opened/closed state of the list view panel.\n *\n * @param {Object} state Global application state.\n *\n * @return {boolean} True if the list view panel should be open; false if closed.\n */\nexport function isListViewOpened( state ) {\n\treturn state.listViewPanel;\n}\n\n/**\n * Returns the current opened/closed state of the save panel.\n *\n * @param {Object} state Global application state.\n *\n * @return {boolean} True if the save panel should be open; false if closed.\n */\nexport function isSaveViewOpened( state ) {\n\treturn state.saveViewPanel;\n}\n\n/**\n * Returns the template parts and their blocks for the current edited template.\n *\n * @param {Object} state Global application state.\n * @return {Array} Template parts and their blocks in an array.\n */\nexport const getCurrentTemplateTemplateParts = createRegistrySelector(\n\t( select ) => ( state ) => {\n\t\tconst templateType = getEditedPostType( state );\n\t\tconst templateId = getEditedPostId( state );\n\t\tconst template = select( coreDataStore ).getEditedEntityRecord(\n\t\t\t'postType',\n\t\t\ttemplateType,\n\t\t\ttemplateId\n\t\t);\n\n\t\tconst templateParts = select( coreDataStore ).getEntityRecords(\n\t\t\t'postType',\n\t\t\t'wp_template_part',\n\t\t\t{ per_page: -1 }\n\t\t);\n\n\t\treturn getFilteredTemplatePartBlocks( template.blocks, templateParts );\n\t}\n);\n\n/**\n * Returns the current editing mode.\n *\n * @param {Object} state Global application state.\n *\n * @return {string} Editing mode.\n */\nexport function getEditorMode( state ) {\n\treturn __unstableGetPreference( state, 'editorMode' );\n}\n\n/**\n * Returns the current canvas mode.\n *\n * @param {Object} state Global application state.\n *\n * @return {string} Canvas mode.\n */\nexport function __unstableGetCanvasMode( state ) {\n\treturn state.canvasMode;\n}\n\n/**\n * @deprecated\n */\nexport function getCurrentTemplateNavigationPanelSubMenu() {\n\tdeprecated(\n\t\t\"dispatch( 'core/edit-site' ).getCurrentTemplateNavigationPanelSubMenu\",\n\t\t{\n\t\t\tsince: '6.2',\n\t\t\tversion: '6.4',\n\t\t}\n\t);\n}\n\n/**\n * @deprecated\n */\nexport function getNavigationPanelActiveMenu() {\n\tdeprecated( \"dispatch( 'core/edit-site' ).getNavigationPanelActiveMenu\", {\n\t\tsince: '6.2',\n\t\tversion: '6.4',\n\t} );\n}\n\n/**\n * @deprecated\n */\nexport function isNavigationOpened() {\n\tdeprecated( \"dispatch( 'core/edit-site' ).isNavigationOpened\", {\n\t\tsince: '6.2',\n\t\tversion: '6.4',\n\t} );\n}\n"]}
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* External dependencies
|
|
3
|
+
*/
|
|
4
|
+
import memoize from 'memize';
|
|
5
|
+
/**
|
|
6
|
+
* WordPress dependencies
|
|
7
|
+
*/
|
|
8
|
+
|
|
9
|
+
import { isTemplatePart } from '@wordpress/blocks';
|
|
10
|
+
const EMPTY_ARRAY = [];
|
|
11
|
+
/**
|
|
12
|
+
* Get a flattened and filtered list of template parts and the matching block for that template part.
|
|
13
|
+
*
|
|
14
|
+
* Takes a list of blocks defined within a template, and a list of template parts, and returns a
|
|
15
|
+
* flattened list of template parts and the matching block for that template part.
|
|
16
|
+
*
|
|
17
|
+
* @param {Array} blocks Blocks to flatten.
|
|
18
|
+
* @param {?Array} templateParts Available template parts.
|
|
19
|
+
* @return {Array} An array of template parts and their blocks.
|
|
20
|
+
*/
|
|
21
|
+
|
|
22
|
+
function getFilteredTemplatePartBlocks() {
|
|
23
|
+
let blocks = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : EMPTY_ARRAY;
|
|
24
|
+
let templateParts = arguments.length > 1 ? arguments[1] : undefined;
|
|
25
|
+
const templatePartsById = templateParts ? // Key template parts by their ID.
|
|
26
|
+
templateParts.reduce((newTemplateParts, part) => ({ ...newTemplateParts,
|
|
27
|
+
[part.id]: part
|
|
28
|
+
}), {}) : {};
|
|
29
|
+
const result = []; // Iterate over all blocks, recursing into inner blocks.
|
|
30
|
+
// Output will be based on a depth-first traversal.
|
|
31
|
+
|
|
32
|
+
const stack = [...blocks];
|
|
33
|
+
|
|
34
|
+
while (stack.length) {
|
|
35
|
+
const {
|
|
36
|
+
innerBlocks,
|
|
37
|
+
...block
|
|
38
|
+
} = stack.shift(); // Place inner blocks at the beginning of the stack to preserve order.
|
|
39
|
+
|
|
40
|
+
stack.unshift(...innerBlocks);
|
|
41
|
+
|
|
42
|
+
if (isTemplatePart(block)) {
|
|
43
|
+
const {
|
|
44
|
+
attributes: {
|
|
45
|
+
theme,
|
|
46
|
+
slug
|
|
47
|
+
}
|
|
48
|
+
} = block;
|
|
49
|
+
const templatePartId = `${theme}//${slug}`;
|
|
50
|
+
const templatePart = templatePartsById[templatePartId]; // Only add to output if the found template part block is in the list of available template parts.
|
|
51
|
+
|
|
52
|
+
if (templatePart) {
|
|
53
|
+
result.push({
|
|
54
|
+
templatePart,
|
|
55
|
+
block
|
|
56
|
+
});
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
return result;
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
const memoizedGetFilteredTemplatePartBlocks = memoize(getFilteredTemplatePartBlocks);
|
|
65
|
+
export { memoizedGetFilteredTemplatePartBlocks as getFilteredTemplatePartBlocks };
|
|
66
|
+
//# sourceMappingURL=utils.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["@wordpress/edit-site/src/store/utils.js"],"names":["memoize","isTemplatePart","EMPTY_ARRAY","getFilteredTemplatePartBlocks","blocks","templateParts","templatePartsById","reduce","newTemplateParts","part","id","result","stack","length","innerBlocks","block","shift","unshift","attributes","theme","slug","templatePartId","templatePart","push","memoizedGetFilteredTemplatePartBlocks"],"mappings":"AAAA;AACA;AACA;AACA,OAAOA,OAAP,MAA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SAASqB,qCAAqC,IAAIrB,6BAAlD","sourcesContent":["/**\n * External dependencies\n */\nimport memoize from 'memize';\n\n/**\n * WordPress dependencies\n */\nimport { isTemplatePart } from '@wordpress/blocks';\n\nconst EMPTY_ARRAY = [];\n\n/**\n * Get a flattened and filtered list of template parts and the matching block for that template part.\n *\n * Takes a list of blocks defined within a template, and a list of template parts, and returns a\n * flattened list of template parts and the matching block for that template part.\n *\n * @param {Array} blocks Blocks to flatten.\n * @param {?Array} templateParts Available template parts.\n * @return {Array} An array of template parts and their blocks.\n */\nfunction getFilteredTemplatePartBlocks( blocks = EMPTY_ARRAY, templateParts ) {\n\tconst templatePartsById = templateParts\n\t\t? // Key template parts by their ID.\n\t\t templateParts.reduce(\n\t\t\t\t( newTemplateParts, part ) => ( {\n\t\t\t\t\t...newTemplateParts,\n\t\t\t\t\t[ part.id ]: part,\n\t\t\t\t} ),\n\t\t\t\t{}\n\t\t )\n\t\t: {};\n\n\tconst result = [];\n\n\t// Iterate over all blocks, recursing into inner blocks.\n\t// Output will be based on a depth-first traversal.\n\tconst stack = [ ...blocks ];\n\twhile ( stack.length ) {\n\t\tconst { innerBlocks, ...block } = stack.shift();\n\t\t// Place inner blocks at the beginning of the stack to preserve order.\n\t\tstack.unshift( ...innerBlocks );\n\n\t\tif ( isTemplatePart( block ) ) {\n\t\t\tconst {\n\t\t\t\tattributes: { theme, slug },\n\t\t\t} = block;\n\t\t\tconst templatePartId = `${ theme }//${ slug }`;\n\t\t\tconst templatePart = templatePartsById[ templatePartId ];\n\n\t\t\t// Only add to output if the found template part block is in the list of available template parts.\n\t\t\tif ( templatePart ) {\n\t\t\t\tresult.push( {\n\t\t\t\t\ttemplatePart,\n\t\t\t\t\tblock,\n\t\t\t\t} );\n\t\t\t}\n\t\t}\n\t}\n\n\treturn result;\n}\n\nconst memoizedGetFilteredTemplatePartBlocks = memoize(\n\tgetFilteredTemplatePartBlocks\n);\n\nexport { memoizedGetFilteredTemplatePartBlocks as getFilteredTemplatePartBlocks };\n"]}
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* External dependencies
|
|
3
|
+
*/
|
|
4
|
+
import { kebabCase } from 'lodash';
|
|
5
|
+
/**
|
|
6
|
+
* WordPress dependencies
|
|
7
|
+
*/
|
|
8
|
+
|
|
9
|
+
import { useSelect } from '@wordpress/data';
|
|
10
|
+
import { store as coreStore } from '@wordpress/core-data';
|
|
11
|
+
export const useExistingTemplateParts = () => {
|
|
12
|
+
return useSelect(select => select(coreStore).getEntityRecords('postType', 'wp_template_part', {
|
|
13
|
+
per_page: -1
|
|
14
|
+
}), []);
|
|
15
|
+
};
|
|
16
|
+
/**
|
|
17
|
+
* Return a unique template part title based on
|
|
18
|
+
* the given title and existing template parts.
|
|
19
|
+
*
|
|
20
|
+
* @param {string} title The original template part title.
|
|
21
|
+
* @param {Object} templateParts The array of template part entities.
|
|
22
|
+
* @return {string} A unique template part title.
|
|
23
|
+
*/
|
|
24
|
+
|
|
25
|
+
export const getUniqueTemplatePartTitle = (title, templateParts) => {
|
|
26
|
+
const lowercaseTitle = title.toLowerCase();
|
|
27
|
+
const existingTitles = templateParts.map(templatePart => templatePart.title.rendered.toLowerCase());
|
|
28
|
+
|
|
29
|
+
if (!existingTitles.includes(lowercaseTitle)) {
|
|
30
|
+
return title;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
let suffix = 2;
|
|
34
|
+
|
|
35
|
+
while (existingTitles.includes(`${lowercaseTitle} ${suffix}`)) {
|
|
36
|
+
suffix++;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
return `${title} ${suffix}`;
|
|
40
|
+
};
|
|
41
|
+
/**
|
|
42
|
+
* Get a valid slug for a template part.
|
|
43
|
+
* Currently template parts only allow latin chars.
|
|
44
|
+
* The fallback slug will receive suffix by default.
|
|
45
|
+
*
|
|
46
|
+
* @param {string} title The template part title.
|
|
47
|
+
* @return {string} A valid template part slug.
|
|
48
|
+
*/
|
|
49
|
+
|
|
50
|
+
export const getCleanTemplatePartSlug = title => {
|
|
51
|
+
return kebabCase(title).replace(/[^\w-]+/g, '') || 'wp-custom-part';
|
|
52
|
+
};
|
|
53
|
+
//# sourceMappingURL=template-part-create.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["@wordpress/edit-site/src/utils/template-part-create.js"],"names":["kebabCase","useSelect","store","coreStore","useExistingTemplateParts","select","getEntityRecords","per_page","getUniqueTemplatePartTitle","title","templateParts","lowercaseTitle","toLowerCase","existingTitles","map","templatePart","rendered","includes","suffix","getCleanTemplatePartSlug","replace"],"mappings":"AAAA;AACA;AACA;AACA,SAASA,SAAT,QAA0B,QAA1B;AAEA;AACA;AACA;;AACA,SAASC,SAAT,QAA0B,iBAA1B;AACA,SAASC,KAAK,IAAIC,SAAlB,QAAmC,sBAAnC;AAEA,OAAO,MAAMC,wBAAwB,GAAG,MAAM;AAC7C,SAAOH,SAAS,CACbI,MAAF,IACCA,MAAM,CAAEF,SAAF,CAAN,CAAoBG,gBAApB,CACC,UADD,EAEC,kBAFD,EAGC;AACCC,IAAAA,QAAQ,EAAE,CAAC;AADZ,GAHD,CAFc,EASf,EATe,CAAhB;AAWA,CAZM;AAcP;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AACA,OAAO,MAAMC,0BAA0B,GAAG,CAAEC,KAAF,EAASC,aAAT,KAA4B;AACrE,QAAMC,cAAc,GAAGF,KAAK,CAACG,WAAN,EAAvB;AACA,QAAMC,cAAc,GAAGH,aAAa,CAACI,GAAd,CAAqBC,YAAF,IACzCA,YAAY,CAACN,KAAb,CAAmBO,QAAnB,CAA4BJ,WAA5B,EADsB,CAAvB;;AAIA,MAAK,CAAEC,cAAc,CAACI,QAAf,CAAyBN,cAAzB,CAAP,EAAmD;AAClD,WAAOF,KAAP;AACA;;AAED,MAAIS,MAAM,GAAG,CAAb;;AACA,SAAQL,cAAc,CAACI,QAAf,CAA0B,GAAGN,cAAgB,IAAIO,MAAQ,EAAzD,CAAR,EAAuE;AACtEA,IAAAA,MAAM;AACN;;AAED,SAAQ,GAAGT,KAAO,IAAIS,MAAQ,EAA9B;AACA,CAhBM;AAkBP;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AACA,OAAO,MAAMC,wBAAwB,GAAKV,KAAF,IAAa;AACpD,SAAOT,SAAS,CAAES,KAAF,CAAT,CAAmBW,OAAnB,CAA4B,UAA5B,EAAwC,EAAxC,KAAgD,gBAAvD;AACA,CAFM","sourcesContent":["/**\n * External dependencies\n */\nimport { kebabCase } from 'lodash';\n\n/**\n * WordPress dependencies\n */\nimport { useSelect } from '@wordpress/data';\nimport { store as coreStore } from '@wordpress/core-data';\n\nexport const useExistingTemplateParts = () => {\n\treturn useSelect(\n\t\t( select ) =>\n\t\t\tselect( coreStore ).getEntityRecords(\n\t\t\t\t'postType',\n\t\t\t\t'wp_template_part',\n\t\t\t\t{\n\t\t\t\t\tper_page: -1,\n\t\t\t\t}\n\t\t\t),\n\t\t[]\n\t);\n};\n\n/**\n * Return a unique template part title based on\n * the given title and existing template parts.\n *\n * @param {string} title The original template part title.\n * @param {Object} templateParts The array of template part entities.\n * @return {string} A unique template part title.\n */\nexport const getUniqueTemplatePartTitle = ( title, templateParts ) => {\n\tconst lowercaseTitle = title.toLowerCase();\n\tconst existingTitles = templateParts.map( ( templatePart ) =>\n\t\ttemplatePart.title.rendered.toLowerCase()\n\t);\n\n\tif ( ! existingTitles.includes( lowercaseTitle ) ) {\n\t\treturn title;\n\t}\n\n\tlet suffix = 2;\n\twhile ( existingTitles.includes( `${ lowercaseTitle } ${ suffix }` ) ) {\n\t\tsuffix++;\n\t}\n\n\treturn `${ title } ${ suffix }`;\n};\n\n/**\n * Get a valid slug for a template part.\n * Currently template parts only allow latin chars.\n * The fallback slug will receive suffix by default.\n *\n * @param {string} title The template part title.\n * @return {string} A valid template part slug.\n */\nexport const getCleanTemplatePartSlug = ( title ) => {\n\treturn kebabCase( title ).replace( /[^\\w-]+/g, '' ) || 'wp-custom-part';\n};\n"]}
|