@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
|
@@ -4,38 +4,63 @@ import { createElement } from "@wordpress/element";
|
|
|
4
4
|
* WordPress dependencies
|
|
5
5
|
*/
|
|
6
6
|
import { getActiveFormat, getActiveObject } from '@wordpress/rich-text';
|
|
7
|
-
|
|
8
|
-
|
|
7
|
+
import { useContext, useMemo } from '@wordpress/element';
|
|
8
|
+
/**
|
|
9
|
+
* Internal dependencies
|
|
10
|
+
*/
|
|
11
|
+
|
|
12
|
+
import BlockContext from '../block-context';
|
|
13
|
+
const DEFAULT_BLOCK_CONTEXT = {};
|
|
14
|
+
export const usesContextKey = Symbol('usesContext');
|
|
15
|
+
|
|
16
|
+
function Edit({
|
|
9
17
|
onChange,
|
|
10
18
|
onFocus,
|
|
11
19
|
value,
|
|
12
|
-
forwardedRef
|
|
20
|
+
forwardedRef,
|
|
21
|
+
settings
|
|
13
22
|
}) {
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
23
|
+
const {
|
|
24
|
+
name,
|
|
25
|
+
edit: EditFunction,
|
|
26
|
+
[usesContextKey]: usesContext
|
|
27
|
+
} = settings;
|
|
28
|
+
const blockContext = useContext(BlockContext); // Assign context values using the block type's declared context needs.
|
|
19
29
|
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
30
|
+
const context = useMemo(() => {
|
|
31
|
+
return usesContext ? Object.fromEntries(Object.entries(blockContext).filter(([key]) => usesContext.includes(key))) : DEFAULT_BLOCK_CONTEXT;
|
|
32
|
+
}, [usesContext, blockContext]);
|
|
23
33
|
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
34
|
+
if (!EditFunction) {
|
|
35
|
+
return null;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
const activeFormat = getActiveFormat(value, name);
|
|
39
|
+
const isActive = activeFormat !== undefined;
|
|
40
|
+
const activeObject = getActiveObject(value);
|
|
41
|
+
const isObjectActive = activeObject !== undefined && activeObject.type === name;
|
|
42
|
+
return createElement(EditFunction, {
|
|
43
|
+
key: name,
|
|
44
|
+
isActive: isActive,
|
|
45
|
+
activeAttributes: isActive ? activeFormat.attributes || {} : {},
|
|
46
|
+
isObjectActive: isObjectActive,
|
|
47
|
+
activeObjectAttributes: isObjectActive ? activeObject.attributes || {} : {},
|
|
48
|
+
value: value,
|
|
49
|
+
onChange: onChange,
|
|
50
|
+
onFocus: onFocus,
|
|
51
|
+
contentRef: forwardedRef,
|
|
52
|
+
context: context
|
|
39
53
|
});
|
|
40
54
|
}
|
|
55
|
+
|
|
56
|
+
export default function FormatEdit({
|
|
57
|
+
formatTypes,
|
|
58
|
+
...props
|
|
59
|
+
}) {
|
|
60
|
+
return formatTypes.map(settings => createElement(Edit, {
|
|
61
|
+
settings: settings,
|
|
62
|
+
...props,
|
|
63
|
+
key: settings.name
|
|
64
|
+
}));
|
|
65
|
+
}
|
|
41
66
|
//# sourceMappingURL=format-edit.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["@wordpress/block-editor/src/components/rich-text/format-edit.js"],"names":["getActiveFormat","getActiveObject","
|
|
1
|
+
{"version":3,"sources":["@wordpress/block-editor/src/components/rich-text/format-edit.js"],"names":["getActiveFormat","getActiveObject","useContext","useMemo","BlockContext","DEFAULT_BLOCK_CONTEXT","usesContextKey","Symbol","Edit","onChange","onFocus","value","forwardedRef","settings","name","edit","EditFunction","usesContext","blockContext","context","Object","fromEntries","entries","filter","key","includes","activeFormat","isActive","undefined","activeObject","isObjectActive","type","attributes","FormatEdit","formatTypes","props","map"],"mappings":";;AAAA;AACA;AACA;AACA,SAASA,eAAT,EAA0BC,eAA1B,QAAiD,sBAAjD;AACA,SAASC,UAAT,EAAqBC,OAArB,QAAoC,oBAApC;AAEA;AACA;AACA;;AACA,OAAOC,YAAP,MAAyB,kBAAzB;AAEA,MAAMC,qBAAqB,GAAG,EAA9B;AAEA,OAAO,MAAMC,cAAc,GAAGC,MAAM,CAAE,aAAF,CAA7B;;AAEP,SAASC,IAAT,CAAe;AAAEC,EAAAA,QAAF;AAAYC,EAAAA,OAAZ;AAAqBC,EAAAA,KAArB;AAA4BC,EAAAA,YAA5B;AAA0CC,EAAAA;AAA1C,CAAf,EAAsE;AACrE,QAAM;AACLC,IAAAA,IADK;AAELC,IAAAA,IAAI,EAAEC,YAFD;AAGL,KAAEV,cAAF,GAAoBW;AAHf,MAIFJ,QAJJ;AAMA,QAAMK,YAAY,GAAGhB,UAAU,CAAEE,YAAF,CAA/B,CAPqE,CASrE;;AACA,QAAMe,OAAO,GAAGhB,OAAO,CAAE,MAAM;AAC9B,WAAOc,WAAW,GACfG,MAAM,CAACC,WAAP,CACAD,MAAM,CAACE,OAAP,CAAgBJ,YAAhB,EAA+BK,MAA/B,CAAuC,CAAE,CAAEC,GAAF,CAAF,KACtCP,WAAW,CAACQ,QAAZ,CAAsBD,GAAtB,CADD,CADA,CADe,GAMfnB,qBANH;AAOA,GARsB,EAQpB,CAAEY,WAAF,EAAeC,YAAf,CARoB,CAAvB;;AAUA,MAAK,CAAEF,YAAP,EAAsB;AACrB,WAAO,IAAP;AACA;;AAED,QAAMU,YAAY,GAAG1B,eAAe,CAAEW,KAAF,EAASG,IAAT,CAApC;AACA,QAAMa,QAAQ,GAAGD,YAAY,KAAKE,SAAlC;AACA,QAAMC,YAAY,GAAG5B,eAAe,CAAEU,KAAF,CAApC;AACA,QAAMmB,cAAc,GACnBD,YAAY,KAAKD,SAAjB,IAA8BC,YAAY,CAACE,IAAb,KAAsBjB,IADrD;AAGA,SACC,cAAC,YAAD;AACC,IAAA,GAAG,EAAGA,IADP;AAEC,IAAA,QAAQ,EAAGa,QAFZ;AAGC,IAAA,gBAAgB,EAAGA,QAAQ,GAAGD,YAAY,CAACM,UAAb,IAA2B,EAA9B,GAAmC,EAH/D;AAIC,IAAA,cAAc,EAAGF,cAJlB;AAKC,IAAA,sBAAsB,EACrBA,cAAc,GAAGD,YAAY,CAACG,UAAb,IAA2B,EAA9B,GAAmC,EANnD;AAQC,IAAA,KAAK,EAAGrB,KART;AASC,IAAA,QAAQ,EAAGF,QATZ;AAUC,IAAA,OAAO,EAAGC,OAVX;AAWC,IAAA,UAAU,EAAGE,YAXd;AAYC,IAAA,OAAO,EAAGO;AAZX,IADD;AAgBA;;AAED,eAAe,SAASc,UAAT,CAAqB;AAAEC,EAAAA,WAAF;AAAe,KAAGC;AAAlB,CAArB,EAAiD;AAC/D,SAAOD,WAAW,CAACE,GAAZ,CAAmBvB,QAAF,IACvB,cAAC,IAAD;AAAM,IAAA,QAAQ,EAAGA,QAAjB;AAAA,OAAiCsB,KAAjC;AAAyC,IAAA,GAAG,EAAGtB,QAAQ,CAACC;AAAxD,IADM,CAAP;AAGA","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { getActiveFormat, getActiveObject } from '@wordpress/rich-text';\nimport { useContext, useMemo } from '@wordpress/element';\n\n/**\n * Internal dependencies\n */\nimport BlockContext from '../block-context';\n\nconst DEFAULT_BLOCK_CONTEXT = {};\n\nexport const usesContextKey = Symbol( 'usesContext' );\n\nfunction Edit( { onChange, onFocus, value, forwardedRef, settings } ) {\n\tconst {\n\t\tname,\n\t\tedit: EditFunction,\n\t\t[ usesContextKey ]: usesContext,\n\t} = settings;\n\n\tconst blockContext = useContext( BlockContext );\n\n\t// Assign context values using the block type's declared context needs.\n\tconst context = useMemo( () => {\n\t\treturn usesContext\n\t\t\t? Object.fromEntries(\n\t\t\t\t\tObject.entries( blockContext ).filter( ( [ key ] ) =>\n\t\t\t\t\t\tusesContext.includes( key )\n\t\t\t\t\t)\n\t\t\t )\n\t\t\t: DEFAULT_BLOCK_CONTEXT;\n\t}, [ usesContext, blockContext ] );\n\n\tif ( ! EditFunction ) {\n\t\treturn null;\n\t}\n\n\tconst activeFormat = getActiveFormat( value, name );\n\tconst isActive = activeFormat !== undefined;\n\tconst activeObject = getActiveObject( value );\n\tconst isObjectActive =\n\t\tactiveObject !== undefined && activeObject.type === name;\n\n\treturn (\n\t\t<EditFunction\n\t\t\tkey={ name }\n\t\t\tisActive={ isActive }\n\t\t\tactiveAttributes={ isActive ? activeFormat.attributes || {} : {} }\n\t\t\tisObjectActive={ isObjectActive }\n\t\t\tactiveObjectAttributes={\n\t\t\t\tisObjectActive ? activeObject.attributes || {} : {}\n\t\t\t}\n\t\t\tvalue={ value }\n\t\t\tonChange={ onChange }\n\t\t\tonFocus={ onFocus }\n\t\t\tcontentRef={ forwardedRef }\n\t\t\tcontext={ context }\n\t\t/>\n\t);\n}\n\nexport default function FormatEdit( { formatTypes, ...props } ) {\n\treturn formatTypes.map( ( settings ) => (\n\t\t<Edit settings={ settings } { ...props } key={ settings.name } />\n\t) );\n}\n"]}
|
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
import { createElement } from "@wordpress/element";
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* WordPress dependencies
|
|
5
|
+
*/
|
|
6
|
+
import { RawHTML, StrictMode, Fragment } from '@wordpress/element';
|
|
7
|
+
import { getSaveElement, __unstableGetBlockProps as getBlockProps } from '@wordpress/blocks';
|
|
8
|
+
/**
|
|
9
|
+
* Internal dependencies
|
|
10
|
+
*/
|
|
11
|
+
|
|
12
|
+
import InnerBlocks from '../inner-blocks';
|
|
13
|
+
import { Content } from './content';
|
|
14
|
+
/*
|
|
15
|
+
* This function is similar to `@wordpress/element`'s `renderToString` function,
|
|
16
|
+
* except that it does not render the elements to a string, but instead collects
|
|
17
|
+
* the values of all rich text `Content` elements.
|
|
18
|
+
*/
|
|
19
|
+
|
|
20
|
+
function addValuesForElement(element, values, innerBlocks) {
|
|
21
|
+
if (null === element || undefined === element || false === element) {
|
|
22
|
+
return;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
if (Array.isArray(element)) {
|
|
26
|
+
return addValuesForElements(element, values, innerBlocks);
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
switch (typeof element) {
|
|
30
|
+
case 'string':
|
|
31
|
+
case 'number':
|
|
32
|
+
return;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
const {
|
|
36
|
+
type,
|
|
37
|
+
props
|
|
38
|
+
} = element;
|
|
39
|
+
|
|
40
|
+
switch (type) {
|
|
41
|
+
case StrictMode:
|
|
42
|
+
case Fragment:
|
|
43
|
+
return addValuesForElements(props.children, values, innerBlocks);
|
|
44
|
+
|
|
45
|
+
case RawHTML:
|
|
46
|
+
return;
|
|
47
|
+
|
|
48
|
+
case InnerBlocks.Content:
|
|
49
|
+
return addValuesForBlocks(values, innerBlocks);
|
|
50
|
+
|
|
51
|
+
case Content:
|
|
52
|
+
values.push(props.value);
|
|
53
|
+
return;
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
switch (typeof type) {
|
|
57
|
+
case 'string':
|
|
58
|
+
if (typeof props.children !== 'undefined') {
|
|
59
|
+
return addValuesForElements(props.children, values, innerBlocks);
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
return;
|
|
63
|
+
|
|
64
|
+
case 'function':
|
|
65
|
+
const el = type.prototype && typeof type.prototype.render === 'function' ? new type(props).render() : type(props);
|
|
66
|
+
return addValuesForElement(el, values, innerBlocks);
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
function addValuesForElements(children, ...args) {
|
|
71
|
+
children = Array.isArray(children) ? children : [children];
|
|
72
|
+
|
|
73
|
+
for (let i = 0; i < children.length; i++) {
|
|
74
|
+
addValuesForElement(children[i], ...args);
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
function addValuesForBlocks(values, blocks) {
|
|
79
|
+
for (let i = 0; i < blocks.length; i++) {
|
|
80
|
+
const {
|
|
81
|
+
name,
|
|
82
|
+
attributes,
|
|
83
|
+
innerBlocks
|
|
84
|
+
} = blocks[i];
|
|
85
|
+
const saveElement = getSaveElement(name, attributes, // Instead of letting save elements use `useInnerBlocksProps.save`,
|
|
86
|
+
// force them to use InnerBlocks.Content instead so we can intercept
|
|
87
|
+
// a single component.
|
|
88
|
+
createElement(InnerBlocks.Content, null));
|
|
89
|
+
addValuesForElement(saveElement, values, innerBlocks);
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
export function getRichTextValues(blocks = []) {
|
|
94
|
+
getBlockProps.skipFilters = true;
|
|
95
|
+
const values = [];
|
|
96
|
+
addValuesForBlocks(values, blocks);
|
|
97
|
+
getBlockProps.skipFilters = false;
|
|
98
|
+
return values;
|
|
99
|
+
}
|
|
100
|
+
//# sourceMappingURL=get-rich-text-values.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["@wordpress/block-editor/src/components/rich-text/get-rich-text-values.js"],"names":["RawHTML","StrictMode","Fragment","getSaveElement","__unstableGetBlockProps","getBlockProps","InnerBlocks","Content","addValuesForElement","element","values","innerBlocks","undefined","Array","isArray","addValuesForElements","type","props","children","addValuesForBlocks","push","value","el","prototype","render","args","i","length","blocks","name","attributes","saveElement","getRichTextValues","skipFilters"],"mappings":";;AAAA;AACA;AACA;AACA,SAASA,OAAT,EAAkBC,UAAlB,EAA8BC,QAA9B,QAA8C,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AAkB,CAAET,MAAF,EAAUkB,MAAV,CAAlB;AACAvB,EAAAA,aAAa,CAAC4B,WAAd,GAA4B,KAA5B;AACA,SAAOvB,MAAP;AACA","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { RawHTML, StrictMode, Fragment } from '@wordpress/element';\nimport {\n\tgetSaveElement,\n\t__unstableGetBlockProps as getBlockProps,\n} from '@wordpress/blocks';\n\n/**\n * Internal dependencies\n */\nimport InnerBlocks from '../inner-blocks';\nimport { Content } from './content';\n\n/*\n * This function is similar to `@wordpress/element`'s `renderToString` function,\n * except that it does not render the elements to a string, but instead collects\n * the values of all rich text `Content` elements.\n */\nfunction addValuesForElement( element, values, innerBlocks ) {\n\tif ( null === element || undefined === element || false === element ) {\n\t\treturn;\n\t}\n\n\tif ( Array.isArray( element ) ) {\n\t\treturn addValuesForElements( element, values, innerBlocks );\n\t}\n\n\tswitch ( typeof element ) {\n\t\tcase 'string':\n\t\tcase 'number':\n\t\t\treturn;\n\t}\n\n\tconst { type, props } = element;\n\n\tswitch ( type ) {\n\t\tcase StrictMode:\n\t\tcase Fragment:\n\t\t\treturn addValuesForElements( props.children, values, innerBlocks );\n\t\tcase RawHTML:\n\t\t\treturn;\n\t\tcase InnerBlocks.Content:\n\t\t\treturn addValuesForBlocks( values, innerBlocks );\n\t\tcase Content:\n\t\t\tvalues.push( props.value );\n\t\t\treturn;\n\t}\n\n\tswitch ( typeof type ) {\n\t\tcase 'string':\n\t\t\tif ( typeof props.children !== 'undefined' ) {\n\t\t\t\treturn addValuesForElements(\n\t\t\t\t\tprops.children,\n\t\t\t\t\tvalues,\n\t\t\t\t\tinnerBlocks\n\t\t\t\t);\n\t\t\t}\n\t\t\treturn;\n\t\tcase 'function':\n\t\t\tconst el =\n\t\t\t\ttype.prototype && typeof type.prototype.render === 'function'\n\t\t\t\t\t? new type( props ).render()\n\t\t\t\t\t: type( props );\n\t\t\treturn addValuesForElement( el, values, innerBlocks );\n\t}\n}\n\nfunction addValuesForElements( children, ...args ) {\n\tchildren = Array.isArray( children ) ? children : [ children ];\n\n\tfor ( let i = 0; i < children.length; i++ ) {\n\t\taddValuesForElement( children[ i ], ...args );\n\t}\n}\n\nfunction addValuesForBlocks( values, blocks ) {\n\tfor ( let i = 0; i < blocks.length; i++ ) {\n\t\tconst { name, attributes, innerBlocks } = blocks[ i ];\n\t\tconst saveElement = getSaveElement(\n\t\t\tname,\n\t\t\tattributes,\n\t\t\t// Instead of letting save elements use `useInnerBlocksProps.save`,\n\t\t\t// force them to use InnerBlocks.Content instead so we can intercept\n\t\t\t// a single component.\n\t\t\t<InnerBlocks.Content />\n\t\t);\n\t\taddValuesForElement( saveElement, values, innerBlocks );\n\t}\n}\n\nexport function getRichTextValues( blocks = [] ) {\n\tgetBlockProps.skipFilters = true;\n\tconst values = [];\n\taddValuesForBlocks( values, blocks );\n\tgetBlockProps.skipFilters = false;\n\treturn values;\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["@wordpress/block-editor/src/components/spacing-sizes-control/hooks/use-spacing-sizes.js"],"names":["__","useSetting","useSpacingSizes","spacingSizes","name","slug","
|
|
1
|
+
{"version":3,"sources":["@wordpress/block-editor/src/components/spacing-sizes-control/hooks/use-spacing-sizes.js"],"names":["__","useSetting","useSpacingSizes","spacingSizes","name","slug","size","length","unshift","undefined"],"mappings":"AAAA;AACA;AACA;AACA,SAASA,EAAT,QAAmB,iBAAnB;AAEA;AACA;AACA;;AACA,OAAOC,UAAP,MAAuB,mBAAvB;AAEA,eAAe,SAASC,eAAT,GAA2B;AACzC,QAAMC,YAAY,GAAG,CACpB;AAAEC,IAAAA,IAAI,EAAE,CAAR;AAAWC,IAAAA,IAAI,EAAE,GAAjB;AAAsBC,IAAAA,IAAI,EAAE;AAA5B,GADoB,EAEpB,IAAKL,UAAU,CAAE,sBAAF,CAAV,IAAwC,EAA7C,CAFoB,CAArB;;AAKA,MAAKE,YAAY,CAACI,MAAb,GAAsB,CAA3B,EAA+B;AAC9BJ,IAAAA,YAAY,CAACK,OAAb,CAAsB;AACrBJ,MAAAA,IAAI,EAAEJ,EAAE,CAAE,SAAF,CADa;AAErBK,MAAAA,IAAI,EAAE,SAFe;AAGrBC,MAAAA,IAAI,EAAEG;AAHe,KAAtB;AAKA;;AAED,SAAON,YAAP;AACA","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { __ } from '@wordpress/i18n';\n\n/**\n * Internal dependencies\n */\nimport useSetting from '../../use-setting';\n\nexport default function useSpacingSizes() {\n\tconst spacingSizes = [\n\t\t{ name: 0, slug: '0', size: 0 },\n\t\t...( useSetting( 'spacing.spacingSizes' ) || [] ),\n\t];\n\n\tif ( spacingSizes.length > 8 ) {\n\t\tspacingSizes.unshift( {\n\t\t\tname: __( 'Default' ),\n\t\t\tslug: 'default',\n\t\t\tsize: undefined,\n\t\t} );\n\t}\n\n\treturn spacingSizes;\n}\n"]}
|
|
@@ -4,7 +4,7 @@ import { createElement, Fragment } from "@wordpress/element";
|
|
|
4
4
|
* Internal dependencies
|
|
5
5
|
*/
|
|
6
6
|
import SpacingInputControl from './spacing-input-control';
|
|
7
|
-
import { LABELS, ICONS, hasAxisSupport } from '../utils';
|
|
7
|
+
import { LABELS, ICONS, getPresetValueFromCustomValue, hasAxisSupport } from '../utils';
|
|
8
8
|
const groupedSides = ['vertical', 'horizontal'];
|
|
9
9
|
export default function AxialInputControls({
|
|
10
10
|
minimumCustomValue,
|
|
@@ -19,9 +19,13 @@ export default function AxialInputControls({
|
|
|
19
19
|
const createHandleOnChange = side => next => {
|
|
20
20
|
if (!onChange) {
|
|
21
21
|
return;
|
|
22
|
-
}
|
|
22
|
+
} // Encode the existing value into the preset value if the passed in value matches the value of one of the spacingSizes.
|
|
23
|
+
|
|
23
24
|
|
|
24
|
-
const nextValues = { ...values
|
|
25
|
+
const nextValues = { ...Object.keys(values).reduce((acc, key) => {
|
|
26
|
+
acc[key] = getPresetValueFromCustomValue(values[key], spacingSizes);
|
|
27
|
+
return acc;
|
|
28
|
+
}, {})
|
|
25
29
|
};
|
|
26
30
|
|
|
27
31
|
if (side === 'vertical') {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["@wordpress/block-editor/src/components/spacing-sizes-control/input-controls/axial.js"],"names":["SpacingInputControl","LABELS","ICONS","hasAxisSupport","groupedSides","AxialInputControls","minimumCustomValue","onChange","onMouseOut","onMouseOver","sides","spacingSizes","type","values","createHandleOnChange","side","next","nextValues","top","bottom","left","right","filteredSides","length","filter","map","axisValue"],"mappings":";;AAAA;AACA;AACA;AACA,OAAOA,mBAAP,MAAgC,yBAAhC;AACA,
|
|
1
|
+
{"version":3,"sources":["@wordpress/block-editor/src/components/spacing-sizes-control/input-controls/axial.js"],"names":["SpacingInputControl","LABELS","ICONS","getPresetValueFromCustomValue","hasAxisSupport","groupedSides","AxialInputControls","minimumCustomValue","onChange","onMouseOut","onMouseOver","sides","spacingSizes","type","values","createHandleOnChange","side","next","nextValues","Object","keys","reduce","acc","key","top","bottom","left","right","filteredSides","length","filter","map","axisValue"],"mappings":";;AAAA;AACA;AACA;AACA,OAAOA,mBAAP,MAAgC,yBAAhC;AACA,SACCC,MADD,EAECC,KAFD,EAGCC,6BAHD,EAICC,cAJD,QAKO,UALP;AAOA,MAAMC,YAAY,GAAG,CAAE,UAAF,EAAc,YAAd,CAArB;AAEA,eAAe,SAASC,kBAAT,CAA6B;AAC3CC,EAAAA,kBAD2C;AAE3CC,EAAAA,QAF2C;AAG3CC,EAAAA,UAH2C;AAI3CC,EAAAA,WAJ2C;AAK3CC,EAAAA,KAL2C;AAM3CC,EAAAA,YAN2C;AAO3CC,EAAAA,IAP2C;AAQ3CC,EAAAA;AAR2C,CAA7B,EASX;AACH,QAAMC,oBAAoB,GAAKC,IAAF,IAAcC,IAAF,IAAY;AACpD,QAAK,CAAET,QAAP,EAAkB;AACjB;AACA,KAHmD,CAKpD;;;AACA,UAAMU,UAAU,GAAG,EAClB,GAAGC,MAAM,CAACC,IAAP,CAA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EAAGM,IARR;AASC,MAAA,YAAY,EAAGJ,YAThB;AAUC,MAAA,IAAI,EAAGC,IAVR;AAWC,MAAA,KAAK,EAAGmB,SAXT;AAYC,MAAA,cAAc,EAAG;AAZlB,MADD;AAgBA,GAnBC,CADH,CADD;AAwBA","sourcesContent":["/**\n * Internal dependencies\n */\nimport SpacingInputControl from './spacing-input-control';\nimport {\n\tLABELS,\n\tICONS,\n\tgetPresetValueFromCustomValue,\n\thasAxisSupport,\n} from '../utils';\n\nconst groupedSides = [ 'vertical', 'horizontal' ];\n\nexport default function AxialInputControls( {\n\tminimumCustomValue,\n\tonChange,\n\tonMouseOut,\n\tonMouseOver,\n\tsides,\n\tspacingSizes,\n\ttype,\n\tvalues,\n} ) {\n\tconst createHandleOnChange = ( side ) => ( next ) => {\n\t\tif ( ! onChange ) {\n\t\t\treturn;\n\t\t}\n\n\t\t// Encode the existing value into the preset value if the passed in value matches the value of one of the spacingSizes.\n\t\tconst nextValues = {\n\t\t\t...Object.keys( values ).reduce( ( acc, key ) => {\n\t\t\t\tacc[ key ] = getPresetValueFromCustomValue(\n\t\t\t\t\tvalues[ key ],\n\t\t\t\t\tspacingSizes\n\t\t\t\t);\n\t\t\t\treturn acc;\n\t\t\t}, {} ),\n\t\t};\n\n\t\tif ( side === 'vertical' ) {\n\t\t\tnextValues.top = next;\n\t\t\tnextValues.bottom = next;\n\t\t}\n\n\t\tif ( side === 'horizontal' ) {\n\t\t\tnextValues.left = next;\n\t\t\tnextValues.right = next;\n\t\t}\n\n\t\tonChange( nextValues );\n\t};\n\n\t// Filter sides if custom configuration provided, maintaining default order.\n\tconst filteredSides = sides?.length\n\t\t? groupedSides.filter( ( side ) => hasAxisSupport( sides, side ) )\n\t\t: groupedSides;\n\n\treturn (\n\t\t<>\n\t\t\t{ filteredSides.map( ( side ) => {\n\t\t\t\tconst axisValue =\n\t\t\t\t\tside === 'vertical' ? values.top : values.left;\n\t\t\t\treturn (\n\t\t\t\t\t<SpacingInputControl\n\t\t\t\t\t\tkey={ `spacing-sizes-control-${ side }` }\n\t\t\t\t\t\ticon={ ICONS[ side ] }\n\t\t\t\t\t\tlabel={ LABELS[ side ] }\n\t\t\t\t\t\tminimumCustomValue={ minimumCustomValue }\n\t\t\t\t\t\tonChange={ createHandleOnChange( side ) }\n\t\t\t\t\t\tonMouseOut={ onMouseOut }\n\t\t\t\t\t\tonMouseOver={ onMouseOver }\n\t\t\t\t\t\tside={ side }\n\t\t\t\t\t\tspacingSizes={ spacingSizes }\n\t\t\t\t\t\ttype={ type }\n\t\t\t\t\t\tvalue={ axisValue }\n\t\t\t\t\t\twithInputField={ false }\n\t\t\t\t\t/>\n\t\t\t\t);\n\t\t\t} ) }\n\t\t</>\n\t);\n}\n"]}
|
|
@@ -4,7 +4,7 @@ import { createElement, Fragment } from "@wordpress/element";
|
|
|
4
4
|
* Internal dependencies
|
|
5
5
|
*/
|
|
6
6
|
import SpacingInputControl from './spacing-input-control';
|
|
7
|
-
import { ALL_SIDES, LABELS, ICONS } from '../utils';
|
|
7
|
+
import { ALL_SIDES, LABELS, ICONS, getPresetValueFromCustomValue } from '../utils';
|
|
8
8
|
export default function SeparatedInputControls({
|
|
9
9
|
minimumCustomValue,
|
|
10
10
|
onChange,
|
|
@@ -19,7 +19,11 @@ export default function SeparatedInputControls({
|
|
|
19
19
|
const filteredSides = sides?.length ? ALL_SIDES.filter(side => sides.includes(side)) : ALL_SIDES;
|
|
20
20
|
|
|
21
21
|
const createHandleOnChange = side => next => {
|
|
22
|
-
|
|
22
|
+
// Encode the existing value into the preset value if the passed in value matches the value of one of the spacingSizes.
|
|
23
|
+
const nextValues = { ...Object.keys(values).reduce((acc, key) => {
|
|
24
|
+
acc[key] = getPresetValueFromCustomValue(values[key], spacingSizes);
|
|
25
|
+
return acc;
|
|
26
|
+
}, {})
|
|
23
27
|
};
|
|
24
28
|
nextValues[side] = next;
|
|
25
29
|
onChange(nextValues);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["@wordpress/block-editor/src/components/spacing-sizes-control/input-controls/separated.js"],"names":["SpacingInputControl","ALL_SIDES","LABELS","ICONS","SeparatedInputControls","minimumCustomValue","onChange","onMouseOut","onMouseOver","sides","spacingSizes","type","values","filteredSides","length","filter","side","includes","createHandleOnChange","next","nextValues","map"],"mappings":";;AAAA;AACA;AACA;AACA,OAAOA,mBAAP,MAAgC,yBAAhC;AACA,
|
|
1
|
+
{"version":3,"sources":["@wordpress/block-editor/src/components/spacing-sizes-control/input-controls/separated.js"],"names":["SpacingInputControl","ALL_SIDES","LABELS","ICONS","getPresetValueFromCustomValue","SeparatedInputControls","minimumCustomValue","onChange","onMouseOut","onMouseOver","sides","spacingSizes","type","values","filteredSides","length","filter","side","includes","createHandleOnChange","next","nextValues","Object","keys","reduce","acc","key","map"],"mappings":";;AAAA;AACA;AACA;AACA,OAAOA,mBAAP,MAAgC,yBAAhC;AACA,SACCC,SADD,EAECC,MAFD,EAGCC,KAHD,EAICC,6BAJD,QAKO,UALP;AAOA,eAAe,SAASC,sBAAT,CAAiC;AAC/CC,EAAAA,kBAD+C;AAE/CC,EAAAA,QAF+C;AAG/CC,EAAAA,UAH+C;AAI/CC,EAAAA,WAJ+C;AAK/CC,EAAAA,KAL+C;AAM/CC,EAAAA,YAN+C;AAO/CC,EAAAA,IAP+C;AAQ/CC,EAAAA;AAR+C,CAAjC,EASX;AACH;AACA,QAAMC,aAAa,GAAGJ,KAAK,EAAEK,MAAP,GACnBd,SAAS,CAACe,MAAV,CAAoBC,IAAF,IAAYP,KAAK,CAACQ,QAAN,CAAgBD,IAAhB,CAA9B,CADmB,GAEnBhB,SAFH;;AAIA,QAAMkB,oBAAoB,GAAKF,IAAF,IAAcG,IAAF,IAAY;AACpD;AACA,UAAMC,UAAU,GAAG,EAClB,GAAGC,MAAM,CAACC,IAAP,CAAaV,MAAb,EAAsBW,MAAtB,CAA8B,CAAEC,GAAF,EAAOC,GAAP,KAAgB;AAChDD,QAAAA,GAAG,CAAEC,GAAF,CAAH,GAAatB,6BAA6B,CACzCS,MAAM,CAAEa,GAAF,CADmC,EAEzCf,YAFyC,CAA1C;AAIA,eAAOc,GAAP;AACA,OANE,EAMA,EANA;AADe,KAAnB;AAUAJ,IAAAA,UAAU,CAAEJ,IAAF,CAAV,GAAqBG,IAArB;AAEAb,IAAAA,QAAQ,CAAEc,UAAF,CAAR;AACA,GAfD;;AAiBA,SACC,8BACGP,aAAa,CAACa,GAAd,CAAqBV,IAAF,IAAY;AAChC,WACC,cAAC,mBAAD;AACC,MAAA,GAAG,EAAI,yBAAyBA,IAAM,EADvC;AAEC,MAAA,IAAI,EAAGd,KAAK,CAAEc,IAAF,CAFb;AAGC,MAAA,KAAK,EAAGf,MAAM,CAAEe,IAAF,CAHf;AAIC,MAAA,kBAAkB,EAAGX,kBAJtB;AAKC,MAAA,QAAQ,EAAGa,oBAAoB,CAAEF,IAAF,CALhC;AAMC,MAAA,UAAU,EAAGT,UANd;AAOC,MAAA,WAAW,EAAGC,WAPf;AAQC,MAAA,IAAI,EAAGQ,IARR;AASC,MAAA,YAAY,EAAGN,YAThB;AAUC,MAAA,IAAI,EAAGC,IAVR;AAWC,MAAA,KAAK,EAAGC,MAAM,CAAEI,IAAF,CAXf;AAYC,MAAA,cAAc,EAAG;AAZlB,MADD;AAgBA,GAjBC,CADH,CADD;AAsBA","sourcesContent":["/**\n * Internal dependencies\n */\nimport SpacingInputControl from './spacing-input-control';\nimport {\n\tALL_SIDES,\n\tLABELS,\n\tICONS,\n\tgetPresetValueFromCustomValue,\n} from '../utils';\n\nexport default function SeparatedInputControls( {\n\tminimumCustomValue,\n\tonChange,\n\tonMouseOut,\n\tonMouseOver,\n\tsides,\n\tspacingSizes,\n\ttype,\n\tvalues,\n} ) {\n\t// Filter sides if custom configuration provided, maintaining default order.\n\tconst filteredSides = sides?.length\n\t\t? ALL_SIDES.filter( ( side ) => sides.includes( side ) )\n\t\t: ALL_SIDES;\n\n\tconst createHandleOnChange = ( side ) => ( next ) => {\n\t\t// Encode the existing value into the preset value if the passed in value matches the value of one of the spacingSizes.\n\t\tconst nextValues = {\n\t\t\t...Object.keys( values ).reduce( ( acc, key ) => {\n\t\t\t\tacc[ key ] = getPresetValueFromCustomValue(\n\t\t\t\t\tvalues[ key ],\n\t\t\t\t\tspacingSizes\n\t\t\t\t);\n\t\t\t\treturn acc;\n\t\t\t}, {} ),\n\t\t};\n\n\t\tnextValues[ side ] = next;\n\n\t\tonChange( nextValues );\n\t};\n\n\treturn (\n\t\t<>\n\t\t\t{ filteredSides.map( ( side ) => {\n\t\t\t\treturn (\n\t\t\t\t\t<SpacingInputControl\n\t\t\t\t\t\tkey={ `spacing-sizes-control-${ side }` }\n\t\t\t\t\t\ticon={ ICONS[ side ] }\n\t\t\t\t\t\tlabel={ LABELS[ side ] }\n\t\t\t\t\t\tminimumCustomValue={ minimumCustomValue }\n\t\t\t\t\t\tonChange={ createHandleOnChange( side ) }\n\t\t\t\t\t\tonMouseOut={ onMouseOut }\n\t\t\t\t\t\tonMouseOver={ onMouseOver }\n\t\t\t\t\t\tside={ side }\n\t\t\t\t\t\tspacingSizes={ spacingSizes }\n\t\t\t\t\t\ttype={ type }\n\t\t\t\t\t\tvalue={ values[ side ] }\n\t\t\t\t\t\twithInputField={ false }\n\t\t\t\t\t/>\n\t\t\t\t);\n\t\t\t} ) }\n\t\t</>\n\t);\n}\n"]}
|
|
@@ -4,7 +4,7 @@ import { createElement } from "@wordpress/element";
|
|
|
4
4
|
* Internal dependencies
|
|
5
5
|
*/
|
|
6
6
|
import SpacingInputControl from './spacing-input-control';
|
|
7
|
-
import { LABELS } from '../utils';
|
|
7
|
+
import { LABELS, getPresetValueFromCustomValue } from '../utils';
|
|
8
8
|
export default function SingleInputControl({
|
|
9
9
|
minimumCustomValue,
|
|
10
10
|
onChange,
|
|
@@ -17,7 +17,11 @@ export default function SingleInputControl({
|
|
|
17
17
|
values
|
|
18
18
|
}) {
|
|
19
19
|
const createHandleOnChange = currentSide => next => {
|
|
20
|
-
|
|
20
|
+
// Encode the existing value into the preset value if the passed in value matches the value of one of the spacingSizes.
|
|
21
|
+
const nextValues = { ...Object.keys(values).reduce((acc, key) => {
|
|
22
|
+
acc[key] = getPresetValueFromCustomValue(values[key], spacingSizes);
|
|
23
|
+
return acc;
|
|
24
|
+
}, {})
|
|
21
25
|
};
|
|
22
26
|
nextValues[currentSide] = next;
|
|
23
27
|
onChange(nextValues);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["@wordpress/block-editor/src/components/spacing-sizes-control/input-controls/single.js"],"names":["SpacingInputControl","LABELS","SingleInputControl","minimumCustomValue","onChange","onMouseOut","onMouseOver","showSideInLabel","side","spacingSizes","type","values","createHandleOnChange","currentSide","next","nextValues"],"mappings":";;AAAA;AACA;AACA;AACA,OAAOA,mBAAP,MAAgC,yBAAhC;AACA,SAASC,MAAT,
|
|
1
|
+
{"version":3,"sources":["@wordpress/block-editor/src/components/spacing-sizes-control/input-controls/single.js"],"names":["SpacingInputControl","LABELS","getPresetValueFromCustomValue","SingleInputControl","minimumCustomValue","onChange","onMouseOut","onMouseOver","showSideInLabel","side","spacingSizes","type","values","createHandleOnChange","currentSide","next","nextValues","Object","keys","reduce","acc","key"],"mappings":";;AAAA;AACA;AACA;AACA,OAAOA,mBAAP,MAAgC,yBAAhC;AACA,SAASC,MAAT,EAAiBC,6BAAjB,QAAsD,UAAtD;AAEA,eAAe,SAASC,kBAAT,CAA6B;AAC3CC,EAAAA,kBAD2C;AAE3CC,EAAAA,QAF2C;AAG3CC,EAAAA,UAH2C;AAI3CC,EAAAA,WAJ2C;AAK3CC,EAAAA,eAL2C;AAM3CC,EAAAA,IAN2C;AAO3CC,EAAAA,YAP2C;AAQ3CC,EAAAA,IAR2C;AAS3CC,EAAAA;AAT2C,CAA7B,EAUX;AACH,QAAMC,oBAAoB,GAAKC,WAAF,IAAqBC,IAAF,IAAY;AAC3D;AACA,UAAMC,UAAU,GAAG,EAClB,GAAGC,MAAM,CAACC,IAAP,CAAaN,MAAb,EAAsBO,MAAtB,CAA8B,CAAEC,GAAF,EAAOC,GAAP,KAAgB;AAChDD,QAAAA,GAAG,CAAEC,GAAF,CAAH,GAAanB,6BAA6B,CACzCU,MAAM,CAAES,GAAF,CADmC,EAEzCX,YAFyC,CAA1C;AAIA,eAAOU,GAAP;AACA,OANE,EAMA,EANA;AADe,KAAnB;AAUAJ,IAAAA,UAAU,CAAEF,WAAF,CAAV,GAA4BC,IAA5B;AAEAV,IAAAA,QAAQ,CAAEW,UAAF,CAAR;AACA,GAfD;;AAiBA,SACC,cAAC,mBAAD;AACC,IAAA,KAAK,EAAGf,MAAM,CAAEQ,IAAF,CADf;AAEC,IAAA,kBAAkB,EAAGL,kBAFtB;AAGC,IAAA,QAAQ,EAAGS,oBAAoB,CAAEJ,IAAF,CAHhC;AAIC,IAAA,UAAU,EAAGH,UAJd;AAKC,IAAA,WAAW,EAAGC,WALf;AAMC,IAAA,eAAe,EAAGC,eANnB;AAOC,IAAA,IAAI,EAAGC,IAPR;AAQC,IAAA,YAAY,EAAGC,YARhB;AASC,IAAA,IAAI,EAAGC,IATR;AAUC,IAAA,KAAK,EAAGC,MAAM,CAAEH,IAAF,CAVf;AAWC,IAAA,cAAc,EAAG;AAXlB,IADD;AAeA","sourcesContent":["/**\n * Internal dependencies\n */\nimport SpacingInputControl from './spacing-input-control';\nimport { LABELS, getPresetValueFromCustomValue } from '../utils';\n\nexport default function SingleInputControl( {\n\tminimumCustomValue,\n\tonChange,\n\tonMouseOut,\n\tonMouseOver,\n\tshowSideInLabel,\n\tside,\n\tspacingSizes,\n\ttype,\n\tvalues,\n} ) {\n\tconst createHandleOnChange = ( currentSide ) => ( next ) => {\n\t\t// Encode the existing value into the preset value if the passed in value matches the value of one of the spacingSizes.\n\t\tconst nextValues = {\n\t\t\t...Object.keys( values ).reduce( ( acc, key ) => {\n\t\t\t\tacc[ key ] = getPresetValueFromCustomValue(\n\t\t\t\t\tvalues[ key ],\n\t\t\t\t\tspacingSizes\n\t\t\t\t);\n\t\t\t\treturn acc;\n\t\t\t}, {} ),\n\t\t};\n\n\t\tnextValues[ currentSide ] = next;\n\n\t\tonChange( nextValues );\n\t};\n\n\treturn (\n\t\t<SpacingInputControl\n\t\t\tlabel={ LABELS[ side ] }\n\t\t\tminimumCustomValue={ minimumCustomValue }\n\t\t\tonChange={ createHandleOnChange( side ) }\n\t\t\tonMouseOut={ onMouseOut }\n\t\t\tonMouseOver={ onMouseOver }\n\t\t\tshowSideInLabel={ showSideInLabel }\n\t\t\tside={ side }\n\t\t\tspacingSizes={ spacingSizes }\n\t\t\ttype={ type }\n\t\t\tvalue={ values[ side ] }\n\t\t\twithInputField={ false }\n\t\t/>\n\t);\n}\n"]}
|
|
@@ -85,8 +85,8 @@ export function getCustomValueFromPreset(value, spacingSizes) {
|
|
|
85
85
|
*/
|
|
86
86
|
|
|
87
87
|
export function getPresetValueFromCustomValue(value, spacingSizes) {
|
|
88
|
-
// Return value as-is if it is already a preset;
|
|
89
|
-
if (isValueSpacingPreset(value)) {
|
|
88
|
+
// Return value as-is if it is undefined or is already a preset, or '0';
|
|
89
|
+
if (!value || isValueSpacingPreset(value) || value === '0') {
|
|
90
90
|
return value;
|
|
91
91
|
}
|
|
92
92
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["@wordpress/block-editor/src/components/spacing-sizes-control/utils.js"],"names":["__","sidesAll","sidesAxial","sidesBottom","sidesHorizontal","sidesLeft","sidesRight","sidesTop","sidesVertical","ALL_SIDES","DEFAULT_VALUES","top","undefined","right","bottom","left","ICONS","custom","axial","horizontal","vertical","LABELS","default","mixed","VIEWS","isValueSpacingPreset","value","includes","getCustomValueFromPreset","spacingSizes","slug","getSpacingPresetSlug","spacingSize","find","size","String","getPresetValueFromCustomValue","spacingMatch","getSpacingPresetCssVar","match","getSliderValueFromPreset","presetValue","parseFloat","sliderValue","findIndex","NaN","mode","arr","sort","a","b","filter","v","length","pop","getAllRawValue","values","Object","isValuesMixed","sides","Set","isValuesDefined","hasAxisSupport","axis","hasHorizontalSupport","hasVerticalSupport","getSupportedMenuItems","menuItems","label","icon","numberOfIndividualSides","forEach","side","hasBalancedSidesSupport","counts","getInitialView","sideValues","Boolean","hasMatchingAxialValues","hasNoValuesAndBalancedSides","entries","some","key"],"mappings":"AAAA;AACA;AACA;AACA,SAASA,EAAT,QAAmB,iBAAnB;AACA,SACCC,QADD,EAECC,UAFD,EAGCC,WAHD,EAICC,eAJD,EAKCC,SALD,EAMCC,UAND,EAOCC,QAPD,EAQCC,aARD,QASO,kBATP;AAWA,OAAO,MAAMC,SAAS,GAAG,CAAE,KAAF,EAAS,OAAT,EAAkB,QAAlB,EAA4B,MAA5B,CAAlB;AAEP,OAAO,MAAMC,cAAc,GAAG;AAC7BC,EAAAA,GAAG,EAAEC,SADwB;AAE7BC,EAAAA,KAAK,EAAED,SAFsB;AAG7BE,EAAAA,MAAM,EAAEF,SAHqB;AAI7BG,EAAAA,IAAI,EAAEH;AAJuB,CAAvB;AAOP,OAAO,MAAMI,KAAK,GAAG;AACpBC,EAAAA,MAAM,EAAEhB,QADY;AAEpBiB,EAAAA,KAAK,EAAEhB,UAFa;AAGpBiB,EAAAA,UAAU,EAAEf,eAHQ;AAIpBgB,EAAAA,QAAQ,EAAEZ,aAJU;AAKpBG,EAAAA,GAAG,EAAEJ,QALe;AAMpBM,EAAAA,KAAK,EAAEP,UANa;AAOpBQ,EAAAA,MAAM,EAAEX,WAPY;AAQpBY,EAAAA,IAAI,EAAEV;AARc,CAAd;AAWP,OAAO,MAAMgB,MAAM,GAAG;AACrBC,EAAAA,OAAO,EAAEtB,EAAE,CAAE,iBAAF,CADU;AAErBW,EAAAA,GAAG,EAAEX,EAAE,CAAE,KAAF,CAFc;AAGrBc,EAAAA,MAAM,EAAEd,EAAE,CAAE,QAAF,CAHW;AAIrBe,EAAAA,IAAI,EAAEf,EAAE,CAAE,MAAF,CAJa;AAKrBa,EAAAA,KAAK,EAAEb,EAAE,C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AF,CAD/C;;AAGA,MACCG,cAAc,CAAEH,KAAF,CAAd,KACEmB,sBAAsB,IAAIC,2BAD5B,CADD,EAGE;AACD,WAAOvD,KAAK,CAACN,KAAb;AACA,GAlBmD,CAoBpD;AACA;;;AACA,MAAK0D,UAAU,CAACvB,MAAX,KAAsB,CAA3B,EAA+B;AAC9B,QAAImB,IAAJ;AAEAf,IAAAA,MAAM,CAACuB,OAAP,CAAgBxB,MAAhB,EAAyByB,IAAzB,CAA+B,CAAE,CAAEC,GAAF,EAAOxD,KAAP,CAAF,KAAsB;AACpD8C,MAAAA,IAAI,GAAGU,GAAP;AACA,aAAOxD,KAAK,KAAKd,SAAjB;AACA,KAHD;AAKA,WAAO4D,IAAP;AACA,GA/BmD,CAiCpD;;;AACA,MAAKb,KAAK,EAAEN,MAAP,KAAkB,CAAlB,IAAuB,CAAEuB,UAAU,CAACvB,MAAzC,EAAkD;AACjD,WAAOM,KAAK,CAAE,CAAF,CAAZ;AACA,GApCmD,CAsCpD;;;AACA,SAAOnC,KAAK,CAACP,MAAb;AACA","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { __ } from '@wordpress/i18n';\nimport {\n\tsidesAll,\n\tsidesAxial,\n\tsidesBottom,\n\tsidesHorizontal,\n\tsidesLeft,\n\tsidesRight,\n\tsidesTop,\n\tsidesVertical,\n} from '@wordpress/icons';\n\nexport const ALL_SIDES = [ 'top', 'right', 'bottom', 'left' ];\n\nexport const DEFAULT_VALUES = {\n\ttop: undefined,\n\tright: undefined,\n\tbottom: undefined,\n\tleft: undefined,\n};\n\nexport const ICONS = {\n\tcustom: sidesAll,\n\taxial: sidesAxial,\n\thorizontal: sidesHorizontal,\n\tvertical: sidesVertical,\n\ttop: sidesTop,\n\tright: sidesRight,\n\tbottom: sidesBottom,\n\tleft: sidesLeft,\n};\n\nexport const LABELS = {\n\tdefault: __( 'Spacing control' ),\n\ttop: __( 'Top' ),\n\tbottom: __( 'Bottom' ),\n\tleft: __( 'Left' ),\n\tright: __( 'Right' ),\n\tmixed: __( 'Mixed' ),\n\tvertical: __( 'Vertical' ),\n\thorizontal: __( 'Horizontal' ),\n\taxial: __( 'Horizontal & vertical' ),\n\tcustom: __( 'Custom' ),\n};\n\nexport const VIEWS = {\n\taxial: 'axial',\n\ttop: 'top',\n\tright: 'right',\n\tbottom: 'bottom',\n\tleft: 'left',\n\tcustom: 'custom',\n};\n\n/**\n * Checks is given value is a spacing preset.\n *\n * @param {string} value Value to check\n *\n * @return {boolean} Return true if value is string in format var:preset|spacing|.\n */\nexport function isValueSpacingPreset( value ) {\n\tif ( ! value?.includes ) {\n\t\treturn false;\n\t}\n\treturn value === '0' || value.includes( 'var:preset|spacing|' );\n}\n\n/**\n * Converts a spacing preset into a custom value.\n *\n * @param {string} value Value to convert\n * @param {Array} spacingSizes Array of the current spacing preset objects\n *\n * @return {string} Mapping of the spacing preset to its equivalent custom value.\n */\nexport function getCustomValueFromPreset( value, spacingSizes ) {\n\tif ( ! isValueSpacingPreset( value ) ) {\n\t\treturn value;\n\t}\n\n\tconst slug = getSpacingPresetSlug( value );\n\tconst spacingSize = spacingSizes.find(\n\t\t( size ) => String( size.slug ) === slug\n\t);\n\n\treturn spacingSize?.size;\n}\n\n/**\n * Converts a custom value to preset value if one can be found.\n *\n * Returns value as-is if no match is found.\n *\n * @param {string} value Value to convert\n * @param {Array} spacingSizes Array of the current spacing preset objects\n *\n * @return {string} The preset value if it can be found.\n */\nexport function getPresetValueFromCustomValue( value, spacingSizes ) {\n\t// Return value as-is if it is already a preset;\n\tif ( isValueSpacingPreset( value ) ) {\n\t\treturn value;\n\t}\n\n\tconst spacingMatch = spacingSizes.find(\n\t\t( size ) => String( size.size ) === String( value )\n\t);\n\n\tif ( spacingMatch?.slug ) {\n\t\treturn `var:preset|spacing|${ spacingMatch.slug }`;\n\t}\n\n\treturn value;\n}\n\n/**\n * Converts a spacing preset into a custom value.\n *\n * @param {string} value Value to convert.\n *\n * @return {string | undefined} CSS var string for given spacing preset value.\n */\nexport function getSpacingPresetCssVar( value ) {\n\tif ( ! value ) {\n\t\treturn;\n\t}\n\n\tconst slug = value.match( /var:preset\\|spacing\\|(.+)/ );\n\n\tif ( ! slug ) {\n\t\treturn value;\n\t}\n\n\treturn `var(--wp--preset--spacing--${ slug[ 1 ] })`;\n}\n\n/**\n * Returns the slug section of the given spacing preset string.\n *\n * @param {string} value Value to extract slug from.\n *\n * @return {string|undefined} The int value of the slug from given spacing preset.\n */\nexport function getSpacingPresetSlug( value ) {\n\tif ( ! value ) {\n\t\treturn;\n\t}\n\n\tif ( value === '0' || value === 'default' ) {\n\t\treturn value;\n\t}\n\n\tconst slug = value.match( /var:preset\\|spacing\\|(.+)/ );\n\n\treturn slug ? slug[ 1 ] : undefined;\n}\n\n/**\n * Converts spacing preset value into a Range component value .\n *\n * @param {string} presetValue Value to convert to Range value.\n * @param {Array} spacingSizes Array of current spacing preset value objects.\n *\n * @return {number} The int value for use in Range control.\n */\nexport function getSliderValueFromPreset( presetValue, spacingSizes ) {\n\tif ( presetValue === undefined ) {\n\t\treturn 0;\n\t}\n\tconst slug =\n\t\tparseFloat( presetValue, 10 ) === 0\n\t\t\t? '0'\n\t\t\t: getSpacingPresetSlug( presetValue );\n\tconst sliderValue = spacingSizes.findIndex( ( spacingSize ) => {\n\t\treturn String( spacingSize.slug ) === slug;\n\t} );\n\n\t// Returning NaN rather than undefined as undefined makes range control thumb sit in center\n\treturn sliderValue !== -1 ? sliderValue : NaN;\n}\n\n/**\n * Gets an items with the most occurrence within an array\n * https://stackoverflow.com/a/20762713\n *\n * @param {Array<any>} arr Array of items to check.\n * @return {any} The item with the most occurrences.\n */\nfunction mode( arr ) {\n\treturn arr\n\t\t.sort(\n\t\t\t( a, b ) =>\n\t\t\t\tarr.filter( ( v ) => v === a ).length -\n\t\t\t\tarr.filter( ( v ) => v === b ).length\n\t\t)\n\t\t.pop();\n}\n\n/**\n * Gets the 'all' input value from values data.\n *\n * @param {Object} values Box spacing values\n *\n * @return {string} The most common value from all sides of box.\n */\nexport function getAllRawValue( values = {} ) {\n\treturn mode( Object.values( values ) );\n}\n\n/**\n * Checks to determine if values are mixed.\n *\n * @param {Object} values Box values.\n * @param {Array} sides Sides that values relate to.\n *\n * @return {boolean} Whether values are mixed.\n */\nexport function isValuesMixed( values = {}, sides = ALL_SIDES ) {\n\treturn (\n\t\t( Object.values( values ).length >= 1 &&\n\t\t\tObject.values( values ).length < sides.length ) ||\n\t\tnew Set( Object.values( values ) ).size > 1\n\t);\n}\n\n/**\n * Checks to determine if values are defined.\n *\n * @param {Object} values Box values.\n *\n * @return {boolean} Whether values are defined.\n */\nexport function isValuesDefined( values ) {\n\tif ( values === undefined || values === null ) {\n\t\treturn false;\n\t}\n\treturn Object.values( values ).filter( ( value ) => !! value ).length > 0;\n}\n\n/**\n * Determines whether a particular axis has support. If no axis is\n * specified, this function checks if either axis is supported.\n *\n * @param {Array} sides Supported sides.\n * @param {string} axis Which axis to check.\n *\n * @return {boolean} Whether there is support for the specified axis or both axes.\n */\nexport function hasAxisSupport( sides, axis ) {\n\tif ( ! sides || ! sides.length ) {\n\t\treturn false;\n\t}\n\n\tconst hasHorizontalSupport =\n\t\tsides.includes( 'horizontal' ) ||\n\t\t( sides.includes( 'left' ) && sides.includes( 'right' ) );\n\n\tconst hasVerticalSupport =\n\t\tsides.includes( 'vertical' ) ||\n\t\t( sides.includes( 'top' ) && sides.includes( 'bottom' ) );\n\n\tif ( axis === 'horizontal' ) {\n\t\treturn hasHorizontalSupport;\n\t}\n\n\tif ( axis === 'vertical' ) {\n\t\treturn hasVerticalSupport;\n\t}\n\n\treturn hasHorizontalSupport || hasVerticalSupport;\n}\n\n/**\n * Determines which menu options should be included in the SidePicker.\n *\n * @param {Array} sides Supported sides.\n *\n * @return {Object} Menu options with each option containing label & icon.\n */\nexport function getSupportedMenuItems( sides ) {\n\tif ( ! sides || ! sides.length ) {\n\t\treturn {};\n\t}\n\n\tconst menuItems = {};\n\n\t// Determine the primary \"side\" menu options.\n\tconst hasHorizontalSupport = hasAxisSupport( sides, 'horizontal' );\n\tconst hasVerticalSupport = hasAxisSupport( sides, 'vertical' );\n\n\tif ( hasHorizontalSupport && hasVerticalSupport ) {\n\t\tmenuItems.axial = { label: LABELS.axial, icon: ICONS.axial };\n\t} else if ( hasHorizontalSupport ) {\n\t\tmenuItems.axial = { label: LABELS.horizontal, icon: ICONS.horizontal };\n\t} else if ( hasVerticalSupport ) {\n\t\tmenuItems.axial = { label: LABELS.vertical, icon: ICONS.vertical };\n\t}\n\n\t// Track whether we have any individual sides so we can omit the custom\n\t// option if required.\n\tlet numberOfIndividualSides = 0;\n\n\tALL_SIDES.forEach( ( side ) => {\n\t\tif ( sides.includes( side ) ) {\n\t\t\tnumberOfIndividualSides += 1;\n\t\t\tmenuItems[ side ] = {\n\t\t\t\tlabel: LABELS[ side ],\n\t\t\t\ticon: ICONS[ side ],\n\t\t\t};\n\t\t}\n\t} );\n\n\t// Add custom item if there are enough sides to warrant a separated view.\n\tif ( numberOfIndividualSides > 1 ) {\n\t\tmenuItems.custom = { label: LABELS.custom, icon: ICONS.custom };\n\t}\n\n\treturn menuItems;\n}\n\n/**\n * Checks if the supported sides are balanced for each axis.\n * - Horizontal - both left and right sides are supported.\n * - Vertical - both top and bottom are supported.\n *\n * @param {Array} sides The supported sides which may be axes as well.\n *\n * @return {boolean} Whether or not the supported sides are balanced.\n */\nexport function hasBalancedSidesSupport( sides = [] ) {\n\tconst counts = { top: 0, right: 0, bottom: 0, left: 0 };\n\tsides.forEach( ( side ) => ( counts[ side ] += 1 ) );\n\n\treturn (\n\t\t( counts.top + counts.bottom ) % 2 === 0 &&\n\t\t( counts.left + counts.right ) % 2 === 0\n\t);\n}\n\n/**\n * Determines which view the SpacingSizesControl should default to on its\n * first render; Axial, Custom, or Single side.\n *\n * @param {Object} values Current side values.\n * @param {Array} sides Supported sides.\n *\n * @return {string} View to display.\n */\nexport function getInitialView( values = {}, sides ) {\n\tconst { top, right, bottom, left } = values;\n\tconst sideValues = [ top, right, bottom, left ].filter( Boolean );\n\n\t// Axial ( Horizontal & vertical ).\n\t// - Has axial side support\n\t// - Has axial side values which match\n\t// - Has no values and the supported sides are balanced\n\tconst hasMatchingAxialValues =\n\t\ttop === bottom && left === right && ( !! top || !! left );\n\tconst hasNoValuesAndBalancedSides =\n\t\t! sideValues.length && hasBalancedSidesSupport( sides );\n\n\tif (\n\t\thasAxisSupport( sides ) &&\n\t\t( hasMatchingAxialValues || hasNoValuesAndBalancedSides )\n\t) {\n\t\treturn VIEWS.axial;\n\t}\n\n\t// Single side.\n\t// - Ensure the side returned is the first side that has a value.\n\tif ( sideValues.length === 1 ) {\n\t\tlet side;\n\n\t\tObject.entries( values ).some( ( [ key, value ] ) => {\n\t\t\tside = key;\n\t\t\treturn value !== undefined;\n\t\t} );\n\n\t\treturn side;\n\t}\n\n\t// Only single side supported and no value defined.\n\tif ( sides?.length === 1 && ! sideValues.length ) {\n\t\treturn sides[ 0 ];\n\t}\n\n\t// Default to the Custom (separated sides) view.\n\treturn VIEWS.custom;\n}\n"]}
|
|
1
|
+
{"version":3,"sources":["@wordpress/block-editor/src/components/spacing-sizes-control/utils.js"],"names":["__","sidesAll","sidesAxial","sidesBottom","sidesHorizontal","sidesLeft","sidesRight","sidesTop","sidesVertical","ALL_SIDES","DEFAULT_VALUES","top","undefined","right","bottom","left","ICONS","custom","axial","horizontal","vertical","LABELS","default","mixed","VIEWS","isValueSpacingPreset","value","includes","getCustomValueFromPreset","spacingSizes","slug","getSpacingPresetSlug","spacingSize","find","size","String","getPresetValueFromCustomValue","spacingMatch","getSpacingPresetCssVar","match","getSliderValueFromPreset","presetValue","parseFloat","sliderValue","findIndex","NaN","mode","arr","sort","a","b","filter","v","length","pop","getAllRawValue","values","Object","isValuesMixed","sides","Set","isValuesDefined","hasAxisSupport","axis","hasHorizontalSupport","hasVerticalSupport","getSupportedMenuItems","menuItems","label","icon","numberOfIndividualSides","forEach","side","hasBalancedSidesSupport","counts","getInitialView","sideValues","Bo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AAOvD,KAAK,CAACN,KAAb;AACA,GAlBmD,CAoBpD;AACA;;;AACA,MAAK0D,UAAU,CAACvB,MAAX,KAAsB,CAA3B,EAA+B;AAC9B,QAAImB,IAAJ;AAEAf,IAAAA,MAAM,CAACuB,OAAP,CAAgBxB,MAAhB,EAAyByB,IAAzB,CAA+B,CAAE,CAAEC,GAAF,EAAOxD,KAAP,CAAF,KAAsB;AACpD8C,MAAAA,IAAI,GAAGU,GAAP;AACA,aAAOxD,KAAK,KAAKd,SAAjB;AACA,KAHD;AAKA,WAAO4D,IAAP;AACA,GA/BmD,CAiCpD;;;AACA,MAAKb,KAAK,EAAEN,MAAP,KAAkB,CAAlB,IAAuB,CAAEuB,UAAU,CAACvB,MAAzC,EAAkD;AACjD,WAAOM,KAAK,CAAE,CAAF,CAAZ;AACA,GApCmD,CAsCpD;;;AACA,SAAOnC,KAAK,CAACP,MAAb;AACA","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { __ } from '@wordpress/i18n';\nimport {\n\tsidesAll,\n\tsidesAxial,\n\tsidesBottom,\n\tsidesHorizontal,\n\tsidesLeft,\n\tsidesRight,\n\tsidesTop,\n\tsidesVertical,\n} from '@wordpress/icons';\n\nexport const ALL_SIDES = [ 'top', 'right', 'bottom', 'left' ];\n\nexport const DEFAULT_VALUES = {\n\ttop: undefined,\n\tright: undefined,\n\tbottom: undefined,\n\tleft: undefined,\n};\n\nexport const ICONS = {\n\tcustom: sidesAll,\n\taxial: sidesAxial,\n\thorizontal: sidesHorizontal,\n\tvertical: sidesVertical,\n\ttop: sidesTop,\n\tright: sidesRight,\n\tbottom: sidesBottom,\n\tleft: sidesLeft,\n};\n\nexport const LABELS = {\n\tdefault: __( 'Spacing control' ),\n\ttop: __( 'Top' ),\n\tbottom: __( 'Bottom' ),\n\tleft: __( 'Left' ),\n\tright: __( 'Right' ),\n\tmixed: __( 'Mixed' ),\n\tvertical: __( 'Vertical' ),\n\thorizontal: __( 'Horizontal' ),\n\taxial: __( 'Horizontal & vertical' ),\n\tcustom: __( 'Custom' ),\n};\n\nexport const VIEWS = {\n\taxial: 'axial',\n\ttop: 'top',\n\tright: 'right',\n\tbottom: 'bottom',\n\tleft: 'left',\n\tcustom: 'custom',\n};\n\n/**\n * Checks is given value is a spacing preset.\n *\n * @param {string} value Value to check\n *\n * @return {boolean} Return true if value is string in format var:preset|spacing|.\n */\nexport function isValueSpacingPreset( value ) {\n\tif ( ! value?.includes ) {\n\t\treturn false;\n\t}\n\treturn value === '0' || value.includes( 'var:preset|spacing|' );\n}\n\n/**\n * Converts a spacing preset into a custom value.\n *\n * @param {string} value Value to convert\n * @param {Array} spacingSizes Array of the current spacing preset objects\n *\n * @return {string} Mapping of the spacing preset to its equivalent custom value.\n */\nexport function getCustomValueFromPreset( value, spacingSizes ) {\n\tif ( ! isValueSpacingPreset( value ) ) {\n\t\treturn value;\n\t}\n\n\tconst slug = getSpacingPresetSlug( value );\n\tconst spacingSize = spacingSizes.find(\n\t\t( size ) => String( size.slug ) === slug\n\t);\n\n\treturn spacingSize?.size;\n}\n\n/**\n * Converts a custom value to preset value if one can be found.\n *\n * Returns value as-is if no match is found.\n *\n * @param {string} value Value to convert\n * @param {Array} spacingSizes Array of the current spacing preset objects\n *\n * @return {string} The preset value if it can be found.\n */\nexport function getPresetValueFromCustomValue( value, spacingSizes ) {\n\t// Return value as-is if it is undefined or is already a preset, or '0';\n\tif ( ! value || isValueSpacingPreset( value ) || value === '0' ) {\n\t\treturn value;\n\t}\n\n\tconst spacingMatch = spacingSizes.find(\n\t\t( size ) => String( size.size ) === String( value )\n\t);\n\n\tif ( spacingMatch?.slug ) {\n\t\treturn `var:preset|spacing|${ spacingMatch.slug }`;\n\t}\n\n\treturn value;\n}\n\n/**\n * Converts a spacing preset into a custom value.\n *\n * @param {string} value Value to convert.\n *\n * @return {string | undefined} CSS var string for given spacing preset value.\n */\nexport function getSpacingPresetCssVar( value ) {\n\tif ( ! value ) {\n\t\treturn;\n\t}\n\n\tconst slug = value.match( /var:preset\\|spacing\\|(.+)/ );\n\n\tif ( ! slug ) {\n\t\treturn value;\n\t}\n\n\treturn `var(--wp--preset--spacing--${ slug[ 1 ] })`;\n}\n\n/**\n * Returns the slug section of the given spacing preset string.\n *\n * @param {string} value Value to extract slug from.\n *\n * @return {string|undefined} The int value of the slug from given spacing preset.\n */\nexport function getSpacingPresetSlug( value ) {\n\tif ( ! value ) {\n\t\treturn;\n\t}\n\n\tif ( value === '0' || value === 'default' ) {\n\t\treturn value;\n\t}\n\n\tconst slug = value.match( /var:preset\\|spacing\\|(.+)/ );\n\n\treturn slug ? slug[ 1 ] : undefined;\n}\n\n/**\n * Converts spacing preset value into a Range component value .\n *\n * @param {string} presetValue Value to convert to Range value.\n * @param {Array} spacingSizes Array of current spacing preset value objects.\n *\n * @return {number} The int value for use in Range control.\n */\nexport function getSliderValueFromPreset( presetValue, spacingSizes ) {\n\tif ( presetValue === undefined ) {\n\t\treturn 0;\n\t}\n\tconst slug =\n\t\tparseFloat( presetValue, 10 ) === 0\n\t\t\t? '0'\n\t\t\t: getSpacingPresetSlug( presetValue );\n\tconst sliderValue = spacingSizes.findIndex( ( spacingSize ) => {\n\t\treturn String( spacingSize.slug ) === slug;\n\t} );\n\n\t// Returning NaN rather than undefined as undefined makes range control thumb sit in center\n\treturn sliderValue !== -1 ? sliderValue : NaN;\n}\n\n/**\n * Gets an items with the most occurrence within an array\n * https://stackoverflow.com/a/20762713\n *\n * @param {Array<any>} arr Array of items to check.\n * @return {any} The item with the most occurrences.\n */\nfunction mode( arr ) {\n\treturn arr\n\t\t.sort(\n\t\t\t( a, b ) =>\n\t\t\t\tarr.filter( ( v ) => v === a ).length -\n\t\t\t\tarr.filter( ( v ) => v === b ).length\n\t\t)\n\t\t.pop();\n}\n\n/**\n * Gets the 'all' input value from values data.\n *\n * @param {Object} values Box spacing values\n *\n * @return {string} The most common value from all sides of box.\n */\nexport function getAllRawValue( values = {} ) {\n\treturn mode( Object.values( values ) );\n}\n\n/**\n * Checks to determine if values are mixed.\n *\n * @param {Object} values Box values.\n * @param {Array} sides Sides that values relate to.\n *\n * @return {boolean} Whether values are mixed.\n */\nexport function isValuesMixed( values = {}, sides = ALL_SIDES ) {\n\treturn (\n\t\t( Object.values( values ).length >= 1 &&\n\t\t\tObject.values( values ).length < sides.length ) ||\n\t\tnew Set( Object.values( values ) ).size > 1\n\t);\n}\n\n/**\n * Checks to determine if values are defined.\n *\n * @param {Object} values Box values.\n *\n * @return {boolean} Whether values are defined.\n */\nexport function isValuesDefined( values ) {\n\tif ( values === undefined || values === null ) {\n\t\treturn false;\n\t}\n\treturn Object.values( values ).filter( ( value ) => !! value ).length > 0;\n}\n\n/**\n * Determines whether a particular axis has support. If no axis is\n * specified, this function checks if either axis is supported.\n *\n * @param {Array} sides Supported sides.\n * @param {string} axis Which axis to check.\n *\n * @return {boolean} Whether there is support for the specified axis or both axes.\n */\nexport function hasAxisSupport( sides, axis ) {\n\tif ( ! sides || ! sides.length ) {\n\t\treturn false;\n\t}\n\n\tconst hasHorizontalSupport =\n\t\tsides.includes( 'horizontal' ) ||\n\t\t( sides.includes( 'left' ) && sides.includes( 'right' ) );\n\n\tconst hasVerticalSupport =\n\t\tsides.includes( 'vertical' ) ||\n\t\t( sides.includes( 'top' ) && sides.includes( 'bottom' ) );\n\n\tif ( axis === 'horizontal' ) {\n\t\treturn hasHorizontalSupport;\n\t}\n\n\tif ( axis === 'vertical' ) {\n\t\treturn hasVerticalSupport;\n\t}\n\n\treturn hasHorizontalSupport || hasVerticalSupport;\n}\n\n/**\n * Determines which menu options should be included in the SidePicker.\n *\n * @param {Array} sides Supported sides.\n *\n * @return {Object} Menu options with each option containing label & icon.\n */\nexport function getSupportedMenuItems( sides ) {\n\tif ( ! sides || ! sides.length ) {\n\t\treturn {};\n\t}\n\n\tconst menuItems = {};\n\n\t// Determine the primary \"side\" menu options.\n\tconst hasHorizontalSupport = hasAxisSupport( sides, 'horizontal' );\n\tconst hasVerticalSupport = hasAxisSupport( sides, 'vertical' );\n\n\tif ( hasHorizontalSupport && hasVerticalSupport ) {\n\t\tmenuItems.axial = { label: LABELS.axial, icon: ICONS.axial };\n\t} else if ( hasHorizontalSupport ) {\n\t\tmenuItems.axial = { label: LABELS.horizontal, icon: ICONS.horizontal };\n\t} else if ( hasVerticalSupport ) {\n\t\tmenuItems.axial = { label: LABELS.vertical, icon: ICONS.vertical };\n\t}\n\n\t// Track whether we have any individual sides so we can omit the custom\n\t// option if required.\n\tlet numberOfIndividualSides = 0;\n\n\tALL_SIDES.forEach( ( side ) => {\n\t\tif ( sides.includes( side ) ) {\n\t\t\tnumberOfIndividualSides += 1;\n\t\t\tmenuItems[ side ] = {\n\t\t\t\tlabel: LABELS[ side ],\n\t\t\t\ticon: ICONS[ side ],\n\t\t\t};\n\t\t}\n\t} );\n\n\t// Add custom item if there are enough sides to warrant a separated view.\n\tif ( numberOfIndividualSides > 1 ) {\n\t\tmenuItems.custom = { label: LABELS.custom, icon: ICONS.custom };\n\t}\n\n\treturn menuItems;\n}\n\n/**\n * Checks if the supported sides are balanced for each axis.\n * - Horizontal - both left and right sides are supported.\n * - Vertical - both top and bottom are supported.\n *\n * @param {Array} sides The supported sides which may be axes as well.\n *\n * @return {boolean} Whether or not the supported sides are balanced.\n */\nexport function hasBalancedSidesSupport( sides = [] ) {\n\tconst counts = { top: 0, right: 0, bottom: 0, left: 0 };\n\tsides.forEach( ( side ) => ( counts[ side ] += 1 ) );\n\n\treturn (\n\t\t( counts.top + counts.bottom ) % 2 === 0 &&\n\t\t( counts.left + counts.right ) % 2 === 0\n\t);\n}\n\n/**\n * Determines which view the SpacingSizesControl should default to on its\n * first render; Axial, Custom, or Single side.\n *\n * @param {Object} values Current side values.\n * @param {Array} sides Supported sides.\n *\n * @return {string} View to display.\n */\nexport function getInitialView( values = {}, sides ) {\n\tconst { top, right, bottom, left } = values;\n\tconst sideValues = [ top, right, bottom, left ].filter( Boolean );\n\n\t// Axial ( Horizontal & vertical ).\n\t// - Has axial side support\n\t// - Has axial side values which match\n\t// - Has no values and the supported sides are balanced\n\tconst hasMatchingAxialValues =\n\t\ttop === bottom && left === right && ( !! top || !! left );\n\tconst hasNoValuesAndBalancedSides =\n\t\t! sideValues.length && hasBalancedSidesSupport( sides );\n\n\tif (\n\t\thasAxisSupport( sides ) &&\n\t\t( hasMatchingAxialValues || hasNoValuesAndBalancedSides )\n\t) {\n\t\treturn VIEWS.axial;\n\t}\n\n\t// Single side.\n\t// - Ensure the side returned is the first side that has a value.\n\tif ( sideValues.length === 1 ) {\n\t\tlet side;\n\n\t\tObject.entries( values ).some( ( [ key, value ] ) => {\n\t\t\tside = key;\n\t\t\treturn value !== undefined;\n\t\t} );\n\n\t\treturn side;\n\t}\n\n\t// Only single side supported and no value defined.\n\tif ( sides?.length === 1 && ! sideValues.length ) {\n\t\treturn sides[ 0 ];\n\t}\n\n\t// Default to the Custom (separated sides) view.\n\treturn VIEWS.custom;\n}\n"]}
|
|
@@ -64,7 +64,8 @@ export default function useBlockDisplayInformation(clientId) {
|
|
|
64
64
|
if (!clientId) return null;
|
|
65
65
|
const {
|
|
66
66
|
getBlockName,
|
|
67
|
-
getBlockAttributes
|
|
67
|
+
getBlockAttributes,
|
|
68
|
+
__experimentalGetReusableBlockTitle
|
|
68
69
|
} = select(blockEditorStore);
|
|
69
70
|
const {
|
|
70
71
|
getBlockType,
|
|
@@ -75,11 +76,14 @@ export default function useBlockDisplayInformation(clientId) {
|
|
|
75
76
|
if (!blockType) return null;
|
|
76
77
|
const attributes = getBlockAttributes(clientId);
|
|
77
78
|
const match = getActiveBlockVariation(blockName, attributes);
|
|
78
|
-
const
|
|
79
|
+
const isReusable = isReusableBlock(blockType);
|
|
80
|
+
const resusableTitle = isReusable ? __experimentalGetReusableBlockTitle(attributes.ref) : undefined;
|
|
81
|
+
const title = resusableTitle || blockType.title;
|
|
82
|
+
const isSynced = isReusable || isTemplatePart(blockType);
|
|
79
83
|
const positionLabel = getPositionTypeLabel(attributes);
|
|
80
84
|
const blockTypeInfo = {
|
|
81
85
|
isSynced,
|
|
82
|
-
title
|
|
86
|
+
title,
|
|
83
87
|
icon: blockType.icon,
|
|
84
88
|
description: blockType.description,
|
|
85
89
|
anchor: attributes?.anchor,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["@wordpress/block-editor/src/components/use-block-display-information/index.js"],"names":["useSelect","store","blocksStore","isReusableBlock","isTemplatePart","__","blockEditorStore","getPositionTypeLabel","attributes","positionType","style","position","type","useBlockDisplayInformation","clientId","select","getBlockName","getBlockAttributes","getBlockType","getActiveBlockVariation","blockName","blockType","match","
|
|
1
|
+
{"version":3,"sources":["@wordpress/block-editor/src/components/use-block-display-information/index.js"],"names":["useSelect","store","blocksStore","isReusableBlock","isTemplatePart","__","blockEditorStore","getPositionTypeLabel","attributes","positionType","style","position","type","useBlockDisplayInformation","clientId","select","getBlockName","getBlockAttributes","__experimentalGetReusableBlockTitle","getBlockType","getActiveBlockVariation","blockName","blockType","match","isReusable","resusableTitle","ref","undefined","title","isSynced","positionLabel","blockTypeInfo","icon","description","anchor"],"mappings":"AAAA;AACA;AACA;AACA,SAASA,SAAT,QAA0B,iBAA1B;AACA,SACCC,KAAK,IAAIC,WADV,EAECC,eAFD,EAGCC,cAHD,QAIO,mBAJP;AAKA,SAASC,EAAT,QAAmB,iBAAnB;AAEA;AACA;AACA;;AACA,SAASJ,KAAK,IAAIK,gBAAlB,QAA0C,aAA1C;AAEA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;;AACA,SAASC,oBAAT,CAA+BC,UAA/B,EAA4C;AAC3C,QAAMC,YAAY,GAAGD,UAAU,EAAEE,KAAZ,EAAmBC,QAAnB,EAA6BC,IAAlD;;AAEA,MAAKH,YAAY,KAAK,QAAtB,EAAiC;AAChC,WAAOJ,EAAE,CAAE,QAAF,CAAT;AACA;;AAED,MAAKI,YAAY,KAAK,OAAtB,EAAgC;AAC/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AM,EAAE1B,UAAU,EAAE0B,MALC;AAMrBJ,MAAAA,aANqB;AAOrBrB,MAAAA,YAAY,EAAED,UAAU,EAAEE,KAAZ,EAAmBC,QAAnB,EAA6BC;AAPtB,KAAtB;AASA,QAAK,CAAEW,KAAP,EAAe,OAAOQ,aAAP;AAEf,WAAO;AACNF,MAAAA,QADM;AAEND,MAAAA,KAAK,EAAEL,KAAK,CAACK,KAAN,IAAeN,SAAS,CAACM,KAF1B;AAGNI,MAAAA,IAAI,EAAET,KAAK,CAACS,IAAN,IAAcV,SAAS,CAACU,IAHxB;AAINC,MAAAA,WAAW,EAAEV,KAAK,CAACU,WAAN,IAAqBX,SAAS,CAACW,WAJtC;AAKNC,MAAAA,MAAM,EAAE1B,UAAU,EAAE0B,MALd;AAMNJ,MAAAA,aANM;AAONrB,MAAAA,YAAY,EAAED,UAAU,EAAEE,KAAZ,EAAmBC,QAAnB,EAA6BC;AAPrC,KAAP;AASA,GA1Cc,EA2Cf,CAAEE,QAAF,CA3Ce,CAAhB;AA6CA","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { useSelect } from '@wordpress/data';\nimport {\n\tstore as blocksStore,\n\tisReusableBlock,\n\tisTemplatePart,\n} from '@wordpress/blocks';\nimport { __ } from '@wordpress/i18n';\n\n/**\n * Internal dependencies\n */\nimport { store as blockEditorStore } from '../../store';\n\n/** @typedef {import('@wordpress/blocks').WPIcon} WPIcon */\n\n/**\n * Contains basic block's information for display reasons.\n *\n * @typedef {Object} WPBlockDisplayInformation\n *\n * @property {boolean} isSynced True if is a reusable block or template part\n * @property {string} title Human-readable block type label.\n * @property {WPIcon} icon Block type icon.\n * @property {string} description A detailed block type description.\n * @property {string} anchor HTML anchor.\n */\n\n/**\n * Get the display label for a block's position type.\n *\n * @param {Object} attributes Block attributes.\n * @return {string} The position type label.\n */\nfunction getPositionTypeLabel( attributes ) {\n\tconst positionType = attributes?.style?.position?.type;\n\n\tif ( positionType === 'sticky' ) {\n\t\treturn __( 'Sticky' );\n\t}\n\n\tif ( positionType === 'fixed' ) {\n\t\treturn __( 'Fixed' );\n\t}\n\n\treturn null;\n}\n\n/**\n * Hook used to try to find a matching block variation and return\n * the appropriate information for display reasons. In order to\n * to try to find a match we need to things:\n * 1. Block's client id to extract it's current attributes.\n * 2. A block variation should have set `isActive` prop to a proper function.\n *\n * If for any reason a block variation match cannot be found,\n * the returned information come from the Block Type.\n * If no blockType is found with the provided clientId, returns null.\n *\n * @param {string} clientId Block's client id.\n * @return {?WPBlockDisplayInformation} Block's display information, or `null` when the block or its type not found.\n */\n\nexport default function useBlockDisplayInformation( clientId ) {\n\treturn useSelect(\n\t\t( select ) => {\n\t\t\tif ( ! clientId ) return null;\n\t\t\tconst {\n\t\t\t\tgetBlockName,\n\t\t\t\tgetBlockAttributes,\n\t\t\t\t__experimentalGetReusableBlockTitle,\n\t\t\t} = select( blockEditorStore );\n\t\t\tconst { getBlockType, getActiveBlockVariation } =\n\t\t\t\tselect( blocksStore );\n\t\t\tconst blockName = getBlockName( clientId );\n\t\t\tconst blockType = getBlockType( blockName );\n\t\t\tif ( ! blockType ) return null;\n\t\t\tconst attributes = getBlockAttributes( clientId );\n\t\t\tconst match = getActiveBlockVariation( blockName, attributes );\n\t\t\tconst isReusable = isReusableBlock( blockType );\n\t\t\tconst resusableTitle = isReusable\n\t\t\t\t? __experimentalGetReusableBlockTitle( attributes.ref )\n\t\t\t\t: undefined;\n\t\t\tconst title = resusableTitle || blockType.title;\n\t\t\tconst isSynced = isReusable || isTemplatePart( blockType );\n\t\t\tconst positionLabel = getPositionTypeLabel( attributes );\n\t\t\tconst blockTypeInfo = {\n\t\t\t\tisSynced,\n\t\t\t\ttitle,\n\t\t\t\ticon: blockType.icon,\n\t\t\t\tdescription: blockType.description,\n\t\t\t\tanchor: attributes?.anchor,\n\t\t\t\tpositionLabel,\n\t\t\t\tpositionType: attributes?.style?.position?.type,\n\t\t\t};\n\t\t\tif ( ! match ) return blockTypeInfo;\n\n\t\t\treturn {\n\t\t\t\tisSynced,\n\t\t\t\ttitle: match.title || blockType.title,\n\t\t\t\ticon: match.icon || blockType.icon,\n\t\t\t\tdescription: match.description || blockType.description,\n\t\t\t\tanchor: attributes?.anchor,\n\t\t\t\tpositionLabel,\n\t\t\t\tpositionType: attributes?.style?.position?.type,\n\t\t\t};\n\t\t},\n\t\t[ clientId ]\n\t);\n}\n"]}
|