@wordpress/block-editor 12.5.0 → 12.7.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +4 -0
- package/README.md +2 -6
- package/build/autocompleters/block.js +6 -2
- package/build/autocompleters/block.js.map +1 -1
- package/build/components/block-draggable/index.js +6 -3
- package/build/components/block-draggable/index.js.map +1 -1
- package/build/components/block-draggable/index.native.js +2 -2
- package/build/components/block-draggable/index.native.js.map +1 -1
- package/build/components/block-edit/edit.js +25 -13
- package/build/components/block-edit/edit.js.map +1 -1
- package/build/components/block-editing-mode/index.js +1 -1
- package/build/components/block-editing-mode/index.js.map +1 -1
- package/build/components/block-list/block-outline.native.js +14 -18
- package/build/components/block-list/block-outline.native.js.map +1 -1
- package/build/components/block-list/block.js +4 -2
- package/build/components/block-list/block.js.map +1 -1
- package/build/components/block-list/block.native.js +21 -42
- package/build/components/block-list/block.native.js.map +1 -1
- package/build/components/block-list/index.js +2 -4
- package/build/components/block-list/index.js.map +1 -1
- package/build/components/block-mover/index.native.js +1 -1
- package/build/components/block-mover/index.native.js.map +1 -1
- package/build/components/block-parent-selector/index.js +6 -21
- package/build/components/block-parent-selector/index.js.map +1 -1
- package/build/components/block-preview/auto.js +6 -1
- package/build/components/block-preview/auto.js.map +1 -1
- package/build/components/block-removal-warning-modal/index.js +1 -4
- package/build/components/block-removal-warning-modal/index.js.map +1 -1
- package/build/components/block-settings/button.native.js +2 -2
- package/build/components/block-settings/button.native.js.map +1 -1
- package/build/components/block-settings-menu/block-settings-dropdown.js +3 -17
- package/build/components/block-settings-menu/block-settings-dropdown.js.map +1 -1
- package/build/components/{block-mobile-toolbar/block-actions-menu.native.js → block-toolbar/block-toolbar-menu.native.js} +7 -5
- package/build/components/block-toolbar/block-toolbar-menu.native.js.map +1 -0
- package/build/components/block-toolbar/index.js +4 -33
- package/build/components/block-toolbar/index.js.map +1 -1
- package/build/components/block-toolbar/index.native.js +62 -3
- package/build/components/block-toolbar/index.native.js.map +1 -1
- package/build/components/block-toolbar/utils.js +56 -51
- package/build/components/block-toolbar/utils.js.map +1 -1
- package/build/components/block-tools/block-contextual-toolbar.js +4 -2
- package/build/components/block-tools/block-contextual-toolbar.js.map +1 -1
- package/build/components/block-variation-picker/index.native.js +10 -20
- package/build/components/block-variation-picker/index.native.js.map +1 -1
- package/build/components/colors-gradients/control.js +4 -2
- package/build/components/colors-gradients/control.js.map +1 -1
- package/build/components/editor-styles/index.js +2 -2
- package/build/components/editor-styles/index.js.map +1 -1
- package/build/components/font-sizes/fluid-utils.js +11 -11
- package/build/components/font-sizes/fluid-utils.js.map +1 -1
- package/build/components/global-styles/behaviors-panel.js +66 -0
- package/build/components/global-styles/behaviors-panel.js.map +1 -0
- package/build/components/global-styles/color-panel.js +21 -15
- package/build/components/global-styles/color-panel.js.map +1 -1
- package/build/components/global-styles/dimensions-panel.js +13 -2
- package/build/components/global-styles/dimensions-panel.js.map +1 -1
- package/build/components/global-styles/get-block-css-selector.js +4 -8
- package/build/components/global-styles/get-block-css-selector.js.map +1 -1
- package/build/components/global-styles/hooks.js +131 -27
- package/build/components/global-styles/hooks.js.map +1 -1
- package/build/components/global-styles/index.js +20 -0
- package/build/components/global-styles/index.js.map +1 -1
- package/build/components/global-styles/typography-panel.js +18 -3
- package/build/components/global-styles/typography-panel.js.map +1 -1
- package/build/components/global-styles/typography-utils.js +4 -4
- package/build/components/global-styles/typography-utils.js.map +1 -1
- package/build/components/global-styles/use-global-styles-output.js +12 -18
- package/build/components/global-styles/use-global-styles-output.js.map +1 -1
- package/build/components/global-styles/utils.js +7 -7
- package/build/components/global-styles/utils.js.map +1 -1
- package/build/components/iframe/index.js +36 -48
- package/build/components/iframe/index.js.map +1 -1
- package/build/components/iframe/use-compatibility-styles.js +5 -0
- package/build/components/iframe/use-compatibility-styles.js.map +1 -1
- package/build/components/index.js +1 -10
- package/build/components/index.js.map +1 -1
- package/build/components/inner-blocks/index.js +3 -1
- package/build/components/inner-blocks/index.js.map +1 -1
- package/build/components/inner-blocks/index.native.js +3 -1
- package/build/components/inner-blocks/index.native.js.map +1 -1
- package/build/components/inner-blocks/use-nested-settings-update.js +33 -7
- package/build/components/inner-blocks/use-nested-settings-update.js.map +1 -1
- package/build/components/inserter/hooks/use-block-types-state.js +6 -2
- package/build/components/inserter/hooks/use-block-types-state.js.map +1 -1
- package/build/components/inserter/hooks/use-debounced-input.js +5 -7
- package/build/components/inserter/hooks/use-debounced-input.js.map +1 -1
- package/build/components/inserter/hooks/use-patterns-state.js +3 -2
- package/build/components/inserter/hooks/use-patterns-state.js.map +1 -1
- package/build/components/inserter/index.js +2 -4
- package/build/components/inserter/index.js.map +1 -1
- package/build/components/inserter/index.native.js +21 -32
- package/build/components/inserter/index.native.js.map +1 -1
- package/build/components/inserter/reusable-block-rename-hint.js +23 -3
- package/build/components/inserter/reusable-block-rename-hint.js.map +1 -1
- package/build/components/inserter/reusable-blocks-tab.js +3 -2
- package/build/components/inserter/reusable-blocks-tab.js.map +1 -1
- package/build/components/inserter-list-item/index.js +1 -1
- package/build/components/inserter-list-item/index.js.map +1 -1
- package/build/components/link-control/index.js +51 -7
- package/build/components/link-control/index.js.map +1 -1
- package/build/components/link-control/link-preview.js +3 -3
- package/build/components/link-control/link-preview.js.map +1 -1
- package/build/components/link-control/search-item.js +1 -1
- package/build/components/link-control/search-item.js.map +1 -1
- package/build/components/list-view/use-list-view-client-ids.js +2 -2
- package/build/components/list-view/use-list-view-client-ids.js.map +1 -1
- package/build/components/list-view/use-list-view-drop-zone.js +6 -1
- package/build/components/list-view/use-list-view-drop-zone.js.map +1 -1
- package/build/components/media-placeholder/index.native.js +65 -31
- package/build/components/media-placeholder/index.native.js.map +1 -1
- package/build/components/media-replace-flow/index.native.js +15 -3
- package/build/components/media-replace-flow/index.native.js.map +1 -1
- package/build/components/preview-options/index.js +2 -2
- package/build/components/preview-options/index.js.map +1 -1
- package/build/components/rich-text/content.js +0 -36
- package/build/components/rich-text/content.js.map +1 -1
- package/build/components/rich-text/format-edit.js +57 -28
- package/build/components/rich-text/format-edit.js.map +1 -1
- package/build/components/rich-text/get-rich-text-values.js +111 -0
- package/build/components/rich-text/get-rich-text-values.js.map +1 -0
- package/build/components/spacing-sizes-control/hooks/use-spacing-sizes.js +1 -1
- package/build/components/spacing-sizes-control/hooks/use-spacing-sizes.js.map +1 -1
- package/build/components/spacing-sizes-control/input-controls/axial.js +6 -2
- package/build/components/spacing-sizes-control/input-controls/axial.js.map +1 -1
- package/build/components/spacing-sizes-control/input-controls/separated.js +5 -1
- package/build/components/spacing-sizes-control/input-controls/separated.js.map +1 -1
- package/build/components/spacing-sizes-control/input-controls/single.js +5 -1
- package/build/components/spacing-sizes-control/input-controls/single.js.map +1 -1
- package/build/components/spacing-sizes-control/utils.js +2 -2
- package/build/components/spacing-sizes-control/utils.js.map +1 -1
- package/build/components/use-block-display-information/index.js +7 -3
- package/build/components/use-block-display-information/index.js.map +1 -1
- package/build/components/use-block-drop-zone/index.native.js +49 -8
- package/build/components/use-block-drop-zone/index.native.js.map +1 -1
- package/build/components/use-setting/index.js +5 -9
- package/build/components/use-setting/index.js.map +1 -1
- package/build/hooks/behaviors.js +5 -12
- package/build/hooks/behaviors.js.map +1 -1
- package/build/hooks/border.js +2 -1
- package/build/hooks/border.js.map +1 -1
- package/build/hooks/margin.js +1 -1
- package/build/hooks/margin.js.map +1 -1
- package/build/hooks/padding.js +1 -1
- package/build/hooks/padding.js.map +1 -1
- package/build/hooks/style.js +11 -2
- package/build/hooks/style.js.map +1 -1
- package/build/hooks/utils.js +1 -7
- package/build/hooks/utils.js.map +1 -1
- package/build/private-apis.js +10 -3
- package/build/private-apis.js.map +1 -1
- package/build/store/actions.js +3 -4
- package/build/store/actions.js.map +1 -1
- package/build/store/private-selectors.js +5 -6
- package/build/store/private-selectors.js.map +1 -1
- package/build/store/reducer.js +0 -1
- package/build/store/reducer.js.map +1 -1
- package/build/store/selectors.js +23 -79
- package/build/store/selectors.js.map +1 -1
- package/build/utils/object.js +38 -2
- package/build/utils/object.js.map +1 -1
- package/build-module/autocompleters/block.js +7 -3
- package/build-module/autocompleters/block.js.map +1 -1
- package/build-module/components/block-draggable/index.js +6 -3
- package/build-module/components/block-draggable/index.js.map +1 -1
- package/build-module/components/block-draggable/index.native.js +2 -2
- package/build-module/components/block-draggable/index.native.js.map +1 -1
- package/build-module/components/block-edit/edit.js +27 -10
- package/build-module/components/block-edit/edit.js.map +1 -1
- package/build-module/components/block-editing-mode/index.js +1 -1
- package/build-module/components/block-editing-mode/index.js.map +1 -1
- package/build-module/components/block-list/block-outline.native.js +14 -18
- package/build-module/components/block-list/block-outline.native.js.map +1 -1
- package/build-module/components/block-list/block.js +4 -2
- package/build-module/components/block-list/block.js.map +1 -1
- package/build-module/components/block-list/block.native.js +24 -43
- package/build-module/components/block-list/block.native.js.map +1 -1
- package/build-module/components/block-list/index.js +2 -3
- package/build-module/components/block-list/index.js.map +1 -1
- package/build-module/components/block-mover/index.native.js +3 -3
- package/build-module/components/block-mover/index.native.js.map +1 -1
- package/build-module/components/block-parent-selector/index.js +7 -22
- package/build-module/components/block-parent-selector/index.js.map +1 -1
- package/build-module/components/block-preview/auto.js +6 -1
- package/build-module/components/block-preview/auto.js.map +1 -1
- package/build-module/components/block-removal-warning-modal/index.js +1 -4
- package/build-module/components/block-removal-warning-modal/index.js.map +1 -1
- package/build-module/components/block-settings/button.native.js +3 -3
- package/build-module/components/block-settings/button.native.js.map +1 -1
- package/build-module/components/block-settings-menu/block-settings-dropdown.js +4 -18
- package/build-module/components/block-settings-menu/block-settings-dropdown.js.map +1 -1
- package/build-module/components/{block-mobile-toolbar/block-actions-menu.native.js → block-toolbar/block-toolbar-menu.native.js} +9 -7
- package/build-module/components/block-toolbar/block-toolbar-menu.native.js.map +1 -0
- package/build-module/components/block-toolbar/index.js +6 -35
- package/build-module/components/block-toolbar/index.js.map +1 -1
- package/build-module/components/block-toolbar/index.native.js +60 -4
- package/build-module/components/block-toolbar/index.native.js.map +1 -1
- package/build-module/components/block-toolbar/utils.js +54 -49
- package/build-module/components/block-toolbar/utils.js.map +1 -1
- package/build-module/components/block-tools/block-contextual-toolbar.js +4 -2
- package/build-module/components/block-tools/block-contextual-toolbar.js.map +1 -1
- package/build-module/components/block-variation-picker/index.native.js +13 -23
- package/build-module/components/block-variation-picker/index.native.js.map +1 -1
- package/build-module/components/colors-gradients/control.js +3 -2
- package/build-module/components/colors-gradients/control.js.map +1 -1
- package/build-module/components/editor-styles/index.js +2 -2
- package/build-module/components/editor-styles/index.js.map +1 -1
- package/build-module/components/font-sizes/fluid-utils.js +11 -11
- package/build-module/components/font-sizes/fluid-utils.js.map +1 -1
- package/build-module/components/global-styles/behaviors-panel.js +57 -0
- package/build-module/components/global-styles/behaviors-panel.js.map +1 -0
- package/build-module/components/global-styles/color-panel.js +21 -15
- package/build-module/components/global-styles/color-panel.js.map +1 -1
- package/build-module/components/global-styles/dimensions-panel.js +13 -2
- package/build-module/components/global-styles/dimensions-panel.js.map +1 -1
- package/build-module/components/global-styles/get-block-css-selector.js +4 -8
- package/build-module/components/global-styles/get-block-css-selector.js.map +1 -1
- package/build-module/components/global-styles/hooks.js +127 -27
- package/build-module/components/global-styles/hooks.js.map +1 -1
- package/build-module/components/global-styles/index.js +2 -1
- package/build-module/components/global-styles/index.js.map +1 -1
- package/build-module/components/global-styles/typography-panel.js +18 -3
- package/build-module/components/global-styles/typography-panel.js.map +1 -1
- package/build-module/components/global-styles/typography-utils.js +4 -4
- package/build-module/components/global-styles/typography-utils.js.map +1 -1
- package/build-module/components/global-styles/use-global-styles-output.js +13 -18
- package/build-module/components/global-styles/use-global-styles-output.js.map +1 -1
- package/build-module/components/global-styles/utils.js +6 -6
- package/build-module/components/global-styles/utils.js.map +1 -1
- package/build-module/components/iframe/index.js +37 -49
- package/build-module/components/iframe/index.js.map +1 -1
- package/build-module/components/iframe/use-compatibility-styles.js +5 -0
- package/build-module/components/iframe/use-compatibility-styles.js.map +1 -1
- package/build-module/components/index.js +0 -5
- package/build-module/components/index.js.map +1 -1
- package/build-module/components/inner-blocks/index.js +3 -1
- package/build-module/components/inner-blocks/index.js.map +1 -1
- package/build-module/components/inner-blocks/index.native.js +3 -1
- package/build-module/components/inner-blocks/index.native.js.map +1 -1
- package/build-module/components/inner-blocks/use-nested-settings-update.js +30 -7
- package/build-module/components/inner-blocks/use-nested-settings-update.js.map +1 -1
- package/build-module/components/inserter/hooks/use-block-types-state.js +7 -3
- package/build-module/components/inserter/hooks/use-block-types-state.js.map +1 -1
- package/build-module/components/inserter/hooks/use-debounced-input.js +5 -7
- package/build-module/components/inserter/hooks/use-debounced-input.js.map +1 -1
- package/build-module/components/inserter/hooks/use-patterns-state.js +3 -2
- package/build-module/components/inserter/hooks/use-patterns-state.js.map +1 -1
- package/build-module/components/inserter/index.js +2 -4
- package/build-module/components/inserter/index.js.map +1 -1
- package/build-module/components/inserter/index.native.js +22 -33
- package/build-module/components/inserter/index.native.js.map +1 -1
- package/build-module/components/inserter/reusable-block-rename-hint.js +22 -3
- package/build-module/components/inserter/reusable-block-rename-hint.js.map +1 -1
- package/build-module/components/inserter/reusable-blocks-tab.js +3 -2
- package/build-module/components/inserter/reusable-blocks-tab.js.map +1 -1
- package/build-module/components/inserter-list-item/index.js +1 -1
- package/build-module/components/inserter-list-item/index.js.map +1 -1
- package/build-module/components/link-control/index.js +49 -7
- package/build-module/components/link-control/index.js.map +1 -1
- package/build-module/components/link-control/link-preview.js +3 -3
- package/build-module/components/link-control/link-preview.js.map +1 -1
- package/build-module/components/link-control/search-item.js +1 -1
- package/build-module/components/link-control/search-item.js.map +1 -1
- package/build-module/components/list-view/use-list-view-client-ids.js +2 -2
- package/build-module/components/list-view/use-list-view-client-ids.js.map +1 -1
- package/build-module/components/list-view/use-list-view-drop-zone.js +6 -1
- package/build-module/components/list-view/use-list-view-drop-zone.js.map +1 -1
- package/build-module/components/media-placeholder/index.native.js +66 -33
- package/build-module/components/media-placeholder/index.native.js.map +1 -1
- package/build-module/components/media-replace-flow/index.native.js +15 -3
- package/build-module/components/media-replace-flow/index.native.js.map +1 -1
- package/build-module/components/preview-options/index.js +2 -2
- package/build-module/components/preview-options/index.js.map +1 -1
- package/build-module/components/rich-text/content.js +1 -36
- package/build-module/components/rich-text/content.js.map +1 -1
- package/build-module/components/rich-text/format-edit.js +51 -26
- package/build-module/components/rich-text/format-edit.js.map +1 -1
- package/build-module/components/rich-text/get-rich-text-values.js +100 -0
- package/build-module/components/rich-text/get-rich-text-values.js.map +1 -0
- package/build-module/components/spacing-sizes-control/hooks/use-spacing-sizes.js +1 -1
- package/build-module/components/spacing-sizes-control/hooks/use-spacing-sizes.js.map +1 -1
- package/build-module/components/spacing-sizes-control/input-controls/axial.js +7 -3
- package/build-module/components/spacing-sizes-control/input-controls/axial.js.map +1 -1
- package/build-module/components/spacing-sizes-control/input-controls/separated.js +6 -2
- package/build-module/components/spacing-sizes-control/input-controls/separated.js.map +1 -1
- package/build-module/components/spacing-sizes-control/input-controls/single.js +6 -2
- package/build-module/components/spacing-sizes-control/input-controls/single.js.map +1 -1
- package/build-module/components/spacing-sizes-control/utils.js +2 -2
- package/build-module/components/spacing-sizes-control/utils.js.map +1 -1
- package/build-module/components/use-block-display-information/index.js +7 -3
- package/build-module/components/use-block-display-information/index.js.map +1 -1
- package/build-module/components/use-block-drop-zone/index.native.js +50 -8
- package/build-module/components/use-block-drop-zone/index.native.js.map +1 -1
- package/build-module/components/use-setting/index.js +5 -9
- package/build-module/components/use-setting/index.js.map +1 -1
- package/build-module/hooks/behaviors.js +5 -12
- package/build-module/hooks/behaviors.js.map +1 -1
- package/build-module/hooks/border.js +2 -1
- package/build-module/hooks/border.js.map +1 -1
- package/build-module/hooks/margin.js +1 -1
- package/build-module/hooks/margin.js.map +1 -1
- package/build-module/hooks/padding.js +1 -1
- package/build-module/hooks/padding.js.map +1 -1
- package/build-module/hooks/style.js +11 -2
- package/build-module/hooks/style.js.map +1 -1
- package/build-module/hooks/utils.js +2 -7
- package/build-module/hooks/utils.js.map +1 -1
- package/build-module/private-apis.js +7 -2
- package/build-module/private-apis.js.map +1 -1
- package/build-module/store/actions.js +4 -5
- package/build-module/store/actions.js.map +1 -1
- package/build-module/store/private-selectors.js +3 -3
- package/build-module/store/private-selectors.js.map +1 -1
- package/build-module/store/reducer.js +0 -1
- package/build-module/store/reducer.js.map +1 -1
- package/build-module/store/selectors.js +20 -75
- package/build-module/store/selectors.js.map +1 -1
- package/build-module/utils/object.js +34 -2
- package/build-module/utils/object.js.map +1 -1
- package/build-style/content-rtl.css +2 -1
- package/build-style/content.css +2 -1
- package/build-style/style-rtl.css +25 -6
- package/build-style/style.css +25 -6
- package/package.json +32 -32
- package/src/autocompleters/block.js +21 -6
- package/src/components/block-controls/README.md +89 -0
- package/src/components/block-draggable/index.js +13 -4
- package/src/components/block-draggable/index.native.js +7 -3
- package/src/components/block-draggable/test/index.native.js +2 -57
- package/src/components/block-edit/edit.js +26 -9
- package/src/components/block-edit/test/edit.js +1 -1
- package/src/components/block-editing-mode/index.js +1 -1
- package/src/components/block-list/block-outline.native.js +26 -25
- package/src/components/block-list/block.js +6 -1
- package/src/components/block-list/block.native.js +24 -38
- package/src/components/block-list/block.native.scss +18 -40
- package/src/components/block-list/index.js +3 -6
- package/src/components/block-list/style.native.scss +3 -3
- package/src/components/block-list/test/block-invalid-warning.native.js +8 -1
- package/src/components/block-mover/index.native.js +3 -3
- package/src/components/block-mover/test/__snapshots__/index.native.js.snap +40 -6
- package/src/components/block-parent-selector/index.js +30 -42
- package/src/components/block-preview/auto.js +8 -1
- package/src/components/block-preview/style.scss +2 -1
- package/src/components/block-removal-warning-modal/index.js +0 -3
- package/src/components/block-settings/button.native.js +12 -6
- package/src/components/block-settings-menu/block-settings-dropdown.js +4 -13
- package/src/components/{block-mobile-toolbar/block-actions-menu.native.js → block-toolbar/block-toolbar-menu.native.js} +15 -10
- package/src/components/block-toolbar/index.js +36 -64
- package/src/components/block-toolbar/index.native.js +86 -6
- package/src/components/{block-mobile-toolbar/test/block-actions-menu.native.js → block-toolbar/test/block-toolbar-menu.native.js} +20 -54
- package/src/components/block-toolbar/test/index.native.js +42 -0
- package/src/components/block-toolbar/utils.js +57 -45
- package/src/components/block-tools/block-contextual-toolbar.js +43 -35
- package/src/components/block-tools/style.scss +17 -5
- package/src/components/block-variation-picker/index.native.js +52 -72
- package/src/components/button-block-appender/styles.native.scss +2 -2
- package/src/components/caption/README.md +49 -0
- package/src/components/color-palette/test/__snapshots__/control.js.snap +1 -1
- package/src/components/colors-gradients/control.js +3 -2
- package/src/components/editor-styles/index.js +2 -2
- package/src/components/font-sizes/fluid-utils.js +17 -17
- package/src/components/font-sizes/test/fluid-utils.js +6 -6
- package/src/components/global-styles/behaviors-panel.js +71 -0
- package/src/components/global-styles/color-panel.js +23 -16
- package/src/components/global-styles/dimensions-panel.js +8 -2
- package/src/components/global-styles/get-block-css-selector.js +5 -9
- package/src/components/global-styles/hooks.js +134 -31
- package/src/components/global-styles/index.js +3 -0
- package/src/components/global-styles/test/typography-utils.js +6 -6
- package/src/components/global-styles/typography-panel.js +17 -5
- package/src/components/global-styles/typography-utils.js +4 -4
- package/src/components/global-styles/use-global-styles-output.js +36 -18
- package/src/components/global-styles/utils.js +17 -7
- package/src/components/iframe/index.js +30 -56
- package/src/components/iframe/use-compatibility-styles.js +5 -0
- package/src/components/index.js +0 -5
- package/src/components/inner-blocks/README.md +10 -0
- package/src/components/inner-blocks/index.js +4 -0
- package/src/components/inner-blocks/index.native.js +4 -0
- package/src/components/inner-blocks/use-nested-settings-update.js +32 -5
- package/src/components/inserter/hooks/use-block-types-state.js +15 -6
- package/src/components/inserter/hooks/use-debounced-input.js +8 -7
- package/src/components/inserter/hooks/use-patterns-state.js +2 -1
- package/src/components/inserter/index.js +2 -3
- package/src/components/inserter/index.native.js +17 -36
- package/src/components/inserter/reusable-block-rename-hint.js +18 -1
- package/src/components/inserter/reusable-blocks-tab.js +4 -1
- package/src/components/inserter/style.native.scss +10 -15
- package/src/components/inserter-list-item/index.js +3 -1
- package/src/components/link-control/README.md +12 -3
- package/src/components/link-control/index.js +47 -7
- package/src/components/link-control/link-preview.js +6 -4
- package/src/components/link-control/search-item.js +1 -1
- package/src/components/link-control/style.scss +11 -3
- package/src/components/link-control/test/index.js +28 -1
- package/src/components/list-view/use-list-view-client-ids.js +2 -2
- package/src/components/list-view/use-list-view-drop-zone.js +5 -1
- package/src/components/media-placeholder/index.native.js +108 -59
- package/src/components/media-placeholder/styles.native.scss +59 -24
- package/src/components/media-replace-flow/index.native.js +12 -3
- package/src/components/media-upload/test/index.native.js +1 -0
- package/src/components/preview-options/README.md +18 -17
- package/src/components/preview-options/index.js +2 -2
- package/src/components/rich-text/content.js +1 -46
- package/src/components/rich-text/format-edit.js +62 -38
- package/src/components/rich-text/get-rich-text-values.js +99 -0
- package/src/components/spacing-sizes-control/hooks/use-spacing-sizes.js +1 -1
- package/src/components/spacing-sizes-control/input-controls/axial.js +17 -2
- package/src/components/spacing-sizes-control/input-controls/separated.js +17 -2
- package/src/components/spacing-sizes-control/input-controls/single.js +12 -2
- package/src/components/spacing-sizes-control/test/utils.js +9 -1
- package/src/components/spacing-sizes-control/utils.js +2 -2
- package/src/components/text-transform-control/README.md +44 -0
- package/src/components/use-block-display-information/index.js +12 -5
- package/src/components/use-block-drop-zone/index.native.js +65 -28
- package/src/components/use-setting/index.js +8 -8
- package/src/hooks/behaviors.js +10 -16
- package/src/hooks/border.js +2 -1
- package/src/hooks/margin.js +4 -1
- package/src/hooks/padding.js +4 -1
- package/src/hooks/style.js +7 -3
- package/src/hooks/utils.js +5 -7
- package/src/private-apis.js +9 -1
- package/src/store/actions.js +23 -30
- package/src/store/private-selectors.js +3 -6
- package/src/store/reducer.js +0 -1
- package/src/store/selectors.js +36 -85
- package/src/store/test/actions.js +3 -0
- package/src/store/test/private-selectors.js +5 -5
- package/src/store/test/reducer.js +14 -7
- package/src/store/test/selectors.js +8 -7
- package/src/utils/object.js +32 -2
- package/src/utils/test/object.js +36 -0
- package/build/components/block-mobile-toolbar/block-actions-menu.native.js.map +0 -1
- package/build/components/block-mobile-toolbar/index.native.js +0 -135
- package/build/components/block-mobile-toolbar/index.native.js.map +0 -1
- package/build-module/components/block-mobile-toolbar/block-actions-menu.native.js.map +0 -1
- package/build-module/components/block-mobile-toolbar/index.native.js +0 -116
- package/build-module/components/block-mobile-toolbar/index.native.js.map +0 -1
- package/src/components/block-mobile-toolbar/index.native.js +0 -127
- package/src/components/block-mobile-toolbar/style.native.scss +0 -16
- /package/src/components/{block-mobile-toolbar/test/__snapshots__/block-actions-menu.native.js.snap → block-toolbar/test/__snapshots__/block-toolbar-menu.native.js.snap} +0 -0
|
@@ -2,27 +2,28 @@
|
|
|
2
2
|
* External dependencies
|
|
3
3
|
*/
|
|
4
4
|
import fastDeepEqual from 'fast-deep-equal/es6';
|
|
5
|
-
import { get, set } from 'lodash';
|
|
6
5
|
|
|
7
6
|
/**
|
|
8
7
|
* WordPress dependencies
|
|
9
8
|
*/
|
|
10
9
|
import { useContext, useCallback, useMemo } from '@wordpress/element';
|
|
11
10
|
import { useSelect } from '@wordpress/data';
|
|
12
|
-
import { store as blocksStore } from '@wordpress/blocks';
|
|
11
|
+
import { store as blocksStore, hasBlockSupport } from '@wordpress/blocks';
|
|
13
12
|
import { _x } from '@wordpress/i18n';
|
|
14
13
|
|
|
15
14
|
/**
|
|
16
15
|
* Internal dependencies
|
|
17
16
|
*/
|
|
18
17
|
import { getValueFromVariable, getPresetVariableFromValue } from './utils';
|
|
18
|
+
import { getValueFromObjectPath, setImmutably } from '../../utils/object';
|
|
19
19
|
import { GlobalStylesContext } from './context';
|
|
20
20
|
import { unlock } from '../../lock-unlock';
|
|
21
21
|
|
|
22
|
-
const EMPTY_CONFIG = { settings: {}, styles: {} };
|
|
22
|
+
const EMPTY_CONFIG = { settings: {}, styles: {}, behaviors: {} };
|
|
23
23
|
|
|
24
24
|
const VALID_SETTINGS = [
|
|
25
25
|
'appearanceTools',
|
|
26
|
+
'behaviors',
|
|
26
27
|
'useRootPaddingAwareAlignments',
|
|
27
28
|
'border.color',
|
|
28
29
|
'border.radius',
|
|
@@ -88,7 +89,6 @@ export const useGlobalStylesReset = () => {
|
|
|
88
89
|
|
|
89
90
|
export function useGlobalSetting( propertyPath, blockName, source = 'all' ) {
|
|
90
91
|
const { setUserConfig, ...configs } = useContext( GlobalStylesContext );
|
|
91
|
-
|
|
92
92
|
const appendedBlockPath = blockName ? '.blocks.' + blockName : '';
|
|
93
93
|
const appendedPropertyPath = propertyPath ? '.' + propertyPath : '';
|
|
94
94
|
const contextualPath = `settings${ appendedBlockPath }${ appendedPropertyPath }`;
|
|
@@ -103,20 +103,21 @@ export function useGlobalSetting( propertyPath, blockName, source = 'all' ) {
|
|
|
103
103
|
|
|
104
104
|
if ( propertyPath ) {
|
|
105
105
|
return (
|
|
106
|
-
|
|
107
|
-
|
|
106
|
+
getValueFromObjectPath( configToUse, contextualPath ) ??
|
|
107
|
+
getValueFromObjectPath( configToUse, globalPath )
|
|
108
108
|
);
|
|
109
109
|
}
|
|
110
110
|
|
|
111
|
-
|
|
111
|
+
let result = {};
|
|
112
112
|
VALID_SETTINGS.forEach( ( setting ) => {
|
|
113
113
|
const value =
|
|
114
|
-
|
|
114
|
+
getValueFromObjectPath(
|
|
115
115
|
configToUse,
|
|
116
116
|
`settings${ appendedBlockPath }.${ setting }`
|
|
117
|
-
) ??
|
|
117
|
+
) ??
|
|
118
|
+
getValueFromObjectPath( configToUse, `settings.${ setting }` );
|
|
118
119
|
if ( value ) {
|
|
119
|
-
|
|
120
|
+
result = setImmutably( result, setting.split( '.' ), value );
|
|
120
121
|
}
|
|
121
122
|
} );
|
|
122
123
|
return result;
|
|
@@ -130,15 +131,10 @@ export function useGlobalSetting( propertyPath, blockName, source = 'all' ) {
|
|
|
130
131
|
] );
|
|
131
132
|
|
|
132
133
|
const setSetting = ( newValue ) => {
|
|
133
|
-
setUserConfig( ( currentConfig ) =>
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
set( newUserConfig, contextualPath, newValue );
|
|
137
|
-
|
|
138
|
-
return newUserConfig;
|
|
139
|
-
} );
|
|
134
|
+
setUserConfig( ( currentConfig ) =>
|
|
135
|
+
setImmutably( currentConfig, contextualPath.split( '.' ), newValue )
|
|
136
|
+
);
|
|
140
137
|
};
|
|
141
|
-
|
|
142
138
|
return [ settingValue, setSetting ];
|
|
143
139
|
}
|
|
144
140
|
|
|
@@ -160,12 +156,10 @@ export function useGlobalStyle(
|
|
|
160
156
|
: `styles.blocks.${ blockName }${ appendedPath }`;
|
|
161
157
|
|
|
162
158
|
const setStyle = ( newValue ) => {
|
|
163
|
-
setUserConfig( ( currentConfig ) =>
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
newUserConfig,
|
|
168
|
-
finalPath,
|
|
159
|
+
setUserConfig( ( currentConfig ) =>
|
|
160
|
+
setImmutably(
|
|
161
|
+
currentConfig,
|
|
162
|
+
finalPath.split( '.' ),
|
|
169
163
|
shouldDecodeEncode
|
|
170
164
|
? getPresetVariableFromValue(
|
|
171
165
|
mergedConfig.settings,
|
|
@@ -174,27 +168,26 @@ export function useGlobalStyle(
|
|
|
174
168
|
newValue
|
|
175
169
|
)
|
|
176
170
|
: newValue
|
|
177
|
-
)
|
|
178
|
-
|
|
179
|
-
} );
|
|
171
|
+
)
|
|
172
|
+
);
|
|
180
173
|
};
|
|
181
174
|
|
|
182
175
|
let rawResult, result;
|
|
183
176
|
switch ( source ) {
|
|
184
177
|
case 'all':
|
|
185
|
-
rawResult =
|
|
178
|
+
rawResult = getValueFromObjectPath( mergedConfig, finalPath );
|
|
186
179
|
result = shouldDecodeEncode
|
|
187
180
|
? getValueFromVariable( mergedConfig, blockName, rawResult )
|
|
188
181
|
: rawResult;
|
|
189
182
|
break;
|
|
190
183
|
case 'user':
|
|
191
|
-
rawResult =
|
|
184
|
+
rawResult = getValueFromObjectPath( userConfig, finalPath );
|
|
192
185
|
result = shouldDecodeEncode
|
|
193
186
|
? getValueFromVariable( mergedConfig, blockName, rawResult )
|
|
194
187
|
: rawResult;
|
|
195
188
|
break;
|
|
196
189
|
case 'base':
|
|
197
|
-
rawResult =
|
|
190
|
+
rawResult = getValueFromObjectPath( baseConfig, finalPath );
|
|
198
191
|
result = shouldDecodeEncode
|
|
199
192
|
? getValueFromVariable( baseConfig, blockName, rawResult )
|
|
200
193
|
: rawResult;
|
|
@@ -333,7 +326,8 @@ export function useSettingsForBlockElement(
|
|
|
333
326
|
const sides = Array.isArray( supports?.spacing?.[ key ] )
|
|
334
327
|
? supports?.spacing?.[ key ]
|
|
335
328
|
: supports?.spacing?.[ key ]?.sides;
|
|
336
|
-
if
|
|
329
|
+
// Check if spacing type is supported before adding sides.
|
|
330
|
+
if ( sides?.length && updatedSettings.spacing?.[ key ] ) {
|
|
337
331
|
updatedSettings.spacing = {
|
|
338
332
|
...updatedSettings.spacing,
|
|
339
333
|
[ key ]: {
|
|
@@ -467,3 +461,112 @@ export function useGradientsPerOrigin( settings ) {
|
|
|
467
461
|
shouldDisplayDefaultGradients,
|
|
468
462
|
] );
|
|
469
463
|
}
|
|
464
|
+
|
|
465
|
+
export function __experimentalUseGlobalBehaviors( blockName, source = 'all' ) {
|
|
466
|
+
const {
|
|
467
|
+
merged: mergedConfig,
|
|
468
|
+
base: baseConfig,
|
|
469
|
+
user: userConfig,
|
|
470
|
+
setUserConfig,
|
|
471
|
+
} = useContext( GlobalStylesContext );
|
|
472
|
+
const finalPath = ! blockName
|
|
473
|
+
? `behaviors`
|
|
474
|
+
: `behaviors.blocks.${ blockName }`;
|
|
475
|
+
|
|
476
|
+
let rawResult, result;
|
|
477
|
+
switch ( source ) {
|
|
478
|
+
case 'all':
|
|
479
|
+
rawResult = getValueFromObjectPath( mergedConfig, finalPath );
|
|
480
|
+
result = getValueFromVariable( mergedConfig, blockName, rawResult );
|
|
481
|
+
break;
|
|
482
|
+
case 'user':
|
|
483
|
+
rawResult = getValueFromObjectPath( userConfig, finalPath );
|
|
484
|
+
result = getValueFromVariable( mergedConfig, blockName, rawResult );
|
|
485
|
+
break;
|
|
486
|
+
case 'base':
|
|
487
|
+
rawResult = getValueFromObjectPath( baseConfig, finalPath );
|
|
488
|
+
result = getValueFromVariable( baseConfig, blockName, rawResult );
|
|
489
|
+
break;
|
|
490
|
+
default:
|
|
491
|
+
throw 'Unsupported source';
|
|
492
|
+
}
|
|
493
|
+
|
|
494
|
+
const animation = result?.lightbox?.animation || 'zoom';
|
|
495
|
+
|
|
496
|
+
const setBehavior = ( newValue ) => {
|
|
497
|
+
let newBehavior;
|
|
498
|
+
// The user saves with Apply Globally option.
|
|
499
|
+
if ( typeof newValue === 'object' ) {
|
|
500
|
+
newBehavior = newValue;
|
|
501
|
+
} else {
|
|
502
|
+
switch ( newValue ) {
|
|
503
|
+
case 'lightbox':
|
|
504
|
+
newBehavior = {
|
|
505
|
+
lightbox: {
|
|
506
|
+
enabled: true,
|
|
507
|
+
animation,
|
|
508
|
+
},
|
|
509
|
+
};
|
|
510
|
+
break;
|
|
511
|
+
case 'fade':
|
|
512
|
+
newBehavior = {
|
|
513
|
+
lightbox: {
|
|
514
|
+
enabled: true,
|
|
515
|
+
animation: 'fade',
|
|
516
|
+
},
|
|
517
|
+
};
|
|
518
|
+
break;
|
|
519
|
+
case 'zoom':
|
|
520
|
+
newBehavior = {
|
|
521
|
+
lightbox: {
|
|
522
|
+
enabled: true,
|
|
523
|
+
animation: 'zoom',
|
|
524
|
+
},
|
|
525
|
+
};
|
|
526
|
+
break;
|
|
527
|
+
case '':
|
|
528
|
+
newBehavior = {
|
|
529
|
+
lightbox: {
|
|
530
|
+
enabled: false,
|
|
531
|
+
animation,
|
|
532
|
+
},
|
|
533
|
+
};
|
|
534
|
+
break;
|
|
535
|
+
default:
|
|
536
|
+
break;
|
|
537
|
+
}
|
|
538
|
+
}
|
|
539
|
+
setUserConfig( ( currentConfig ) =>
|
|
540
|
+
setImmutably( currentConfig, finalPath.split( '.' ), newBehavior )
|
|
541
|
+
);
|
|
542
|
+
};
|
|
543
|
+
let behavior = '';
|
|
544
|
+
if ( result === undefined ) behavior = 'default';
|
|
545
|
+
if ( result?.lightbox.enabled ) behavior = 'lightbox';
|
|
546
|
+
|
|
547
|
+
return { behavior, inheritedBehaviors: result, setBehavior };
|
|
548
|
+
}
|
|
549
|
+
|
|
550
|
+
export function __experimentalUseHasBehaviorsPanel(
|
|
551
|
+
settings,
|
|
552
|
+
name,
|
|
553
|
+
{ blockSupportOnly = false } = {}
|
|
554
|
+
) {
|
|
555
|
+
if ( ! settings?.behaviors ) {
|
|
556
|
+
return false;
|
|
557
|
+
}
|
|
558
|
+
|
|
559
|
+
// If every behavior is disabled on block supports, do not show the behaviors inspector control.
|
|
560
|
+
const hasSomeBlockSupport = Object.keys( settings?.behaviors ).some(
|
|
561
|
+
( key ) => hasBlockSupport( name, `behaviors.${ key }` )
|
|
562
|
+
);
|
|
563
|
+
|
|
564
|
+
if ( blockSupportOnly ) {
|
|
565
|
+
return hasSomeBlockSupport;
|
|
566
|
+
}
|
|
567
|
+
|
|
568
|
+
// If every behavior is disabled, do not show the behaviors inspector control.
|
|
569
|
+
return Object.values( settings?.behaviors ).some(
|
|
570
|
+
( value ) => value === true && hasSomeBlockSupport
|
|
571
|
+
);
|
|
572
|
+
}
|
|
@@ -1,4 +1,6 @@
|
|
|
1
1
|
export {
|
|
2
|
+
__experimentalUseGlobalBehaviors,
|
|
3
|
+
__experimentalUseHasBehaviorsPanel,
|
|
2
4
|
useGlobalStylesReset,
|
|
3
5
|
useGlobalSetting,
|
|
4
6
|
useGlobalStyle,
|
|
@@ -23,5 +25,6 @@ export { default as BorderPanel, useHasBorderPanel } from './border-panel';
|
|
|
23
25
|
export { default as ColorPanel, useHasColorPanel } from './color-panel';
|
|
24
26
|
export { default as EffectsPanel, useHasEffectsPanel } from './effects-panel';
|
|
25
27
|
export { default as FiltersPanel, useHasFiltersPanel } from './filters-panel';
|
|
28
|
+
export { default as __experimentalBehaviorsPanel } from './behaviors-panel';
|
|
26
29
|
export { default as AdvancedPanel } from './advanced-panel';
|
|
27
30
|
export { areGlobalStyleConfigsEqual } from './utils';
|
|
@@ -192,7 +192,7 @@ describe( 'typography utils', () => {
|
|
|
192
192
|
|
|
193
193
|
{
|
|
194
194
|
message:
|
|
195
|
-
'should apply
|
|
195
|
+
'should apply maxViewportWidth as maximum viewport width',
|
|
196
196
|
preset: {
|
|
197
197
|
size: '80px',
|
|
198
198
|
fluid: {
|
|
@@ -202,7 +202,7 @@ describe( 'typography utils', () => {
|
|
|
202
202
|
},
|
|
203
203
|
typographySettings: {
|
|
204
204
|
fluid: {
|
|
205
|
-
|
|
205
|
+
maxViewportWidth: '1100px',
|
|
206
206
|
},
|
|
207
207
|
},
|
|
208
208
|
expected:
|
|
@@ -548,18 +548,18 @@ describe( 'typography utils', () => {
|
|
|
548
548
|
layout: { wideSize: '1000rem' },
|
|
549
549
|
},
|
|
550
550
|
expected: {
|
|
551
|
-
fluid: {
|
|
551
|
+
fluid: { maxViewportWidth: '1000rem', minFontSize: '16px' },
|
|
552
552
|
},
|
|
553
553
|
},
|
|
554
554
|
|
|
555
555
|
{
|
|
556
556
|
message:
|
|
557
|
-
'should prioritize fluid `
|
|
557
|
+
'should prioritize fluid `maxViewportWidth` over `layout.wideSize`',
|
|
558
558
|
settings: {
|
|
559
|
-
typography: { fluid: {
|
|
559
|
+
typography: { fluid: { maxViewportWidth: '10px' } },
|
|
560
560
|
layout: { wideSize: '1000rem' },
|
|
561
561
|
},
|
|
562
|
-
expected: { fluid: {
|
|
562
|
+
expected: { fluid: { maxViewportWidth: '10px' } },
|
|
563
563
|
},
|
|
564
564
|
].forEach( ( { message, settings, expected } ) => {
|
|
565
565
|
it( `${ message }`, () => {
|
|
@@ -114,6 +114,21 @@ function useHasTextColumnsControl( settings ) {
|
|
|
114
114
|
return settings?.typography?.textColumns;
|
|
115
115
|
}
|
|
116
116
|
|
|
117
|
+
function getUniqueFontSizesBySlug( settings ) {
|
|
118
|
+
const fontSizesPerOrigin = settings?.typography?.fontSizes ?? {};
|
|
119
|
+
const fontSizes = []
|
|
120
|
+
.concat( fontSizesPerOrigin?.custom ?? [] )
|
|
121
|
+
.concat( fontSizesPerOrigin?.theme ?? [] )
|
|
122
|
+
.concat( fontSizesPerOrigin.default ?? [] );
|
|
123
|
+
|
|
124
|
+
return fontSizes.reduce( ( acc, currentSize ) => {
|
|
125
|
+
if ( ! acc.some( ( { slug } ) => slug === currentSize.slug ) ) {
|
|
126
|
+
acc.push( currentSize );
|
|
127
|
+
}
|
|
128
|
+
return acc;
|
|
129
|
+
}, [] );
|
|
130
|
+
}
|
|
131
|
+
|
|
117
132
|
function TypographyToolsPanel( {
|
|
118
133
|
resetAllFilter,
|
|
119
134
|
onChange,
|
|
@@ -189,11 +204,8 @@ export default function TypographyPanel( {
|
|
|
189
204
|
// Font Size
|
|
190
205
|
const hasFontSizeEnabled = useHasFontSizeControl( settings );
|
|
191
206
|
const disableCustomFontSizes = ! settings?.typography?.customFontSize;
|
|
192
|
-
const
|
|
193
|
-
|
|
194
|
-
.concat( fontSizesPerOrigin?.custom ?? [] )
|
|
195
|
-
.concat( fontSizesPerOrigin?.theme ?? [] )
|
|
196
|
-
.concat( fontSizesPerOrigin.default ?? [] );
|
|
207
|
+
const fontSizes = getUniqueFontSizesBySlug( settings );
|
|
208
|
+
|
|
197
209
|
const fontSize = decodeValue( inheritedValue?.typography?.fontSize );
|
|
198
210
|
const setFontSize = ( newValue, metadata ) => {
|
|
199
211
|
const actualValue = !! metadata?.slug
|
|
@@ -25,8 +25,8 @@ import { getComputedFluidTypographyValue } from '../font-sizes/fluid-utils';
|
|
|
25
25
|
|
|
26
26
|
/**
|
|
27
27
|
* @typedef {Object} TypographySettings
|
|
28
|
-
* @property {?string}
|
|
29
|
-
* @property {?string}
|
|
28
|
+
* @property {?string} minViewportWidth Minimum viewport size from which type will have fluidity. Optional if size is specified.
|
|
29
|
+
* @property {?string} maxViewportWidth Maximum size up to which type will have fluidity. Optional if size is specified.
|
|
30
30
|
* @property {?number} scaleFactor A scale factor to determine how fast a font scales within boundaries. Optional.
|
|
31
31
|
* @property {?number} minFontSizeFactor How much to scale defaultFontSize by to derive minimumFontSize. Optional.
|
|
32
32
|
* @property {?string} minFontSize The smallest a calculated font size may be. Optional.
|
|
@@ -67,7 +67,7 @@ export function getTypographyFontSizeValue( preset, typographyOptions ) {
|
|
|
67
67
|
maximumFontSize: preset?.fluid?.max,
|
|
68
68
|
fontSize: defaultSize,
|
|
69
69
|
minimumFontSizeLimit: fluidTypographySettings?.minFontSize,
|
|
70
|
-
|
|
70
|
+
maximumViewportWidth: fluidTypographySettings?.maxViewportWidth,
|
|
71
71
|
} );
|
|
72
72
|
|
|
73
73
|
if ( !! fluidFontSizeValue ) {
|
|
@@ -102,7 +102,7 @@ export function getFluidTypographyOptionsFromSettings( settings ) {
|
|
|
102
102
|
layoutSettings?.wideSize
|
|
103
103
|
? {
|
|
104
104
|
fluid: {
|
|
105
|
-
|
|
105
|
+
maxViewportWidth: layoutSettings.wideSize,
|
|
106
106
|
...typographySettings.fluid,
|
|
107
107
|
},
|
|
108
108
|
}
|
|
@@ -1,8 +1,3 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* External dependencies
|
|
3
|
-
*/
|
|
4
|
-
import { get, set } from 'lodash';
|
|
5
|
-
|
|
6
1
|
/**
|
|
7
2
|
* WordPress dependencies
|
|
8
3
|
*/
|
|
@@ -32,7 +27,11 @@ import { PresetDuotoneFilter } from '../duotone/components';
|
|
|
32
27
|
import { getGapCSSValue } from '../../hooks/gap';
|
|
33
28
|
import { store as blockEditorStore } from '../../store';
|
|
34
29
|
import { LAYOUT_DEFINITIONS } from '../../layouts/definitions';
|
|
35
|
-
import {
|
|
30
|
+
import {
|
|
31
|
+
getValueFromObjectPath,
|
|
32
|
+
kebabCase,
|
|
33
|
+
setImmutably,
|
|
34
|
+
} from '../../utils/object';
|
|
36
35
|
|
|
37
36
|
// List of block support features that can have their related styles
|
|
38
37
|
// generated under their own feature level selector rather than the block's.
|
|
@@ -69,7 +68,11 @@ function compileStyleValue( uncompiledValue ) {
|
|
|
69
68
|
function getPresetsDeclarations( blockPresets = {}, mergedSettings ) {
|
|
70
69
|
return PRESET_METADATA.reduce(
|
|
71
70
|
( declarations, { path, valueKey, valueFunc, cssVarInfix } ) => {
|
|
72
|
-
const presetByOrigin =
|
|
71
|
+
const presetByOrigin = getValueFromObjectPath(
|
|
72
|
+
blockPresets,
|
|
73
|
+
path,
|
|
74
|
+
[]
|
|
75
|
+
);
|
|
73
76
|
[ 'default', 'theme', 'custom' ].forEach( ( origin ) => {
|
|
74
77
|
if ( presetByOrigin[ origin ] ) {
|
|
75
78
|
presetByOrigin[ origin ].forEach( ( value ) => {
|
|
@@ -113,7 +116,11 @@ function getPresetsClasses( blockSelector = '*', blockPresets = {} ) {
|
|
|
113
116
|
return declarations;
|
|
114
117
|
}
|
|
115
118
|
|
|
116
|
-
const presetByOrigin =
|
|
119
|
+
const presetByOrigin = getValueFromObjectPath(
|
|
120
|
+
blockPresets,
|
|
121
|
+
path,
|
|
122
|
+
[]
|
|
123
|
+
);
|
|
117
124
|
[ 'default', 'theme', 'custom' ].forEach( ( origin ) => {
|
|
118
125
|
if ( presetByOrigin[ origin ] ) {
|
|
119
126
|
presetByOrigin[ origin ].forEach( ( { slug } ) => {
|
|
@@ -147,7 +154,11 @@ function getPresetsSvgFilters( blockPresets = {} ) {
|
|
|
147
154
|
// Duotone are the only type of filters for now.
|
|
148
155
|
( metadata ) => metadata.path.at( -1 ) === 'duotone'
|
|
149
156
|
).flatMap( ( metadata ) => {
|
|
150
|
-
const presetByOrigin =
|
|
157
|
+
const presetByOrigin = getValueFromObjectPath(
|
|
158
|
+
blockPresets,
|
|
159
|
+
metadata.path,
|
|
160
|
+
{}
|
|
161
|
+
);
|
|
151
162
|
return [ 'default', 'theme' ]
|
|
152
163
|
.filter( ( origin ) => presetByOrigin[ origin ] )
|
|
153
164
|
.flatMap( ( origin ) =>
|
|
@@ -319,7 +330,10 @@ export function getStylesDeclarations(
|
|
|
319
330
|
return declarations;
|
|
320
331
|
}
|
|
321
332
|
|
|
322
|
-
const styleValue =
|
|
333
|
+
const styleValue = getValueFromObjectPath(
|
|
334
|
+
blockStyles,
|
|
335
|
+
pathToValue
|
|
336
|
+
);
|
|
323
337
|
|
|
324
338
|
// Root-level padding styles don't currently support strings with CSS shorthand values.
|
|
325
339
|
// This may change: https://github.com/WordPress/gutenberg/issues/40132.
|
|
@@ -334,7 +348,9 @@ export function getStylesDeclarations(
|
|
|
334
348
|
Object.entries( properties ).forEach( ( entry ) => {
|
|
335
349
|
const [ name, prop ] = entry;
|
|
336
350
|
|
|
337
|
-
if (
|
|
351
|
+
if (
|
|
352
|
+
! getValueFromObjectPath( styleValue, [ prop ], false )
|
|
353
|
+
) {
|
|
338
354
|
// Do not create a declaration
|
|
339
355
|
// for sub-properties that don't have any value.
|
|
340
356
|
return;
|
|
@@ -345,17 +361,19 @@ export function getStylesDeclarations(
|
|
|
345
361
|
: kebabCase( name );
|
|
346
362
|
declarations.push(
|
|
347
363
|
`${ cssProperty }: ${ compileStyleValue(
|
|
348
|
-
|
|
364
|
+
getValueFromObjectPath( styleValue, [ prop ] )
|
|
349
365
|
) }`
|
|
350
366
|
);
|
|
351
367
|
} );
|
|
352
|
-
} else if (
|
|
368
|
+
} else if (
|
|
369
|
+
getValueFromObjectPath( blockStyles, pathToValue, false )
|
|
370
|
+
) {
|
|
353
371
|
const cssProperty = key.startsWith( '--' )
|
|
354
372
|
? key
|
|
355
373
|
: kebabCase( key );
|
|
356
374
|
declarations.push(
|
|
357
375
|
`${ cssProperty }: ${ compileStyleValue(
|
|
358
|
-
|
|
376
|
+
getValueFromObjectPath( blockStyles, pathToValue )
|
|
359
377
|
) }`
|
|
360
378
|
);
|
|
361
379
|
}
|
|
@@ -384,7 +402,7 @@ export function getStylesDeclarations(
|
|
|
384
402
|
let ruleValue = rule.value;
|
|
385
403
|
if ( typeof ruleValue !== 'string' && ruleValue?.ref ) {
|
|
386
404
|
const refPath = ruleValue.ref.split( '.' );
|
|
387
|
-
ruleValue =
|
|
405
|
+
ruleValue = getValueFromObjectPath( tree, refPath );
|
|
388
406
|
// Presence of another ref indicates a reference to another dynamic value.
|
|
389
407
|
// Pointing to another dynamic value is not supported.
|
|
390
408
|
if ( ! ruleValue || ruleValue?.ref ) {
|
|
@@ -678,11 +696,11 @@ export const getNodesWithSettings = ( tree, blockSelectors ) => {
|
|
|
678
696
|
}
|
|
679
697
|
|
|
680
698
|
const pickPresets = ( treeToPickFrom ) => {
|
|
681
|
-
|
|
699
|
+
let presets = {};
|
|
682
700
|
PRESET_METADATA.forEach( ( { path } ) => {
|
|
683
|
-
const value =
|
|
701
|
+
const value = getValueFromObjectPath( treeToPickFrom, path, false );
|
|
684
702
|
if ( value !== false ) {
|
|
685
|
-
|
|
703
|
+
presets = setImmutably( presets, path, value );
|
|
686
704
|
}
|
|
687
705
|
} );
|
|
688
706
|
return presets;
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* External dependencies
|
|
3
3
|
*/
|
|
4
|
-
import { get } from 'lodash';
|
|
5
4
|
import fastDeepEqual from 'fast-deep-equal/es6';
|
|
6
5
|
|
|
7
6
|
/**
|
|
@@ -11,6 +10,7 @@ import {
|
|
|
11
10
|
getTypographyFontSizeValue,
|
|
12
11
|
getFluidTypographyOptionsFromSettings,
|
|
13
12
|
} from './typography-utils';
|
|
13
|
+
import { getValueFromObjectPath } from '../../utils/object';
|
|
14
14
|
|
|
15
15
|
/* Supporting data. */
|
|
16
16
|
export const ROOT_BLOCK_NAME = 'root';
|
|
@@ -168,8 +168,12 @@ function findInPresetsBy(
|
|
|
168
168
|
) {
|
|
169
169
|
// Block presets take priority above root level presets.
|
|
170
170
|
const orderedPresetsByOrigin = [
|
|
171
|
-
|
|
172
|
-
|
|
171
|
+
getValueFromObjectPath( features, [
|
|
172
|
+
'blocks',
|
|
173
|
+
blockName,
|
|
174
|
+
...presetPath,
|
|
175
|
+
] ),
|
|
176
|
+
getValueFromObjectPath( features, presetPath ),
|
|
173
177
|
];
|
|
174
178
|
|
|
175
179
|
for ( const presetByOrigin of orderedPresetsByOrigin ) {
|
|
@@ -282,8 +286,13 @@ function getValueFromPresetVariable(
|
|
|
282
286
|
|
|
283
287
|
function getValueFromCustomVariable( features, blockName, variable, path ) {
|
|
284
288
|
const result =
|
|
285
|
-
|
|
286
|
-
|
|
289
|
+
getValueFromObjectPath( features.settings, [
|
|
290
|
+
'blocks',
|
|
291
|
+
blockName,
|
|
292
|
+
'custom',
|
|
293
|
+
...path,
|
|
294
|
+
] ) ??
|
|
295
|
+
getValueFromObjectPath( features.settings, [ 'custom', ...path ] );
|
|
287
296
|
if ( ! result ) {
|
|
288
297
|
return variable;
|
|
289
298
|
}
|
|
@@ -303,7 +312,7 @@ export function getValueFromVariable( features, blockName, variable ) {
|
|
|
303
312
|
if ( ! variable || typeof variable !== 'string' ) {
|
|
304
313
|
if ( variable?.ref && typeof variable?.ref === 'string' ) {
|
|
305
314
|
const refPath = variable.ref.split( '.' );
|
|
306
|
-
variable =
|
|
315
|
+
variable = getValueFromObjectPath( features, refPath );
|
|
307
316
|
// Presence of another ref indicates a reference to another dynamic value.
|
|
308
317
|
// Pointing to another dynamic value is not supported.
|
|
309
318
|
if ( ! variable || !! variable?.ref ) {
|
|
@@ -406,6 +415,7 @@ export function areGlobalStyleConfigsEqual( original, variation ) {
|
|
|
406
415
|
}
|
|
407
416
|
return (
|
|
408
417
|
fastDeepEqual( original?.styles, variation?.styles ) &&
|
|
409
|
-
fastDeepEqual( original?.settings, variation?.settings )
|
|
418
|
+
fastDeepEqual( original?.settings, variation?.settings ) &&
|
|
419
|
+
fastDeepEqual( original?.behaviors, variation?.behaviors )
|
|
410
420
|
);
|
|
411
421
|
}
|