@wordpress/block-editor 16.0.0 → 16.1.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 +18 -0
- package/README.md +8 -0
- package/build/components/alignment-control/ui.cjs +2 -4
- package/build/components/alignment-control/ui.cjs.map +2 -2
- package/build/components/background-image-control/index.cjs +40 -10
- package/build/components/background-image-control/index.cjs.map +2 -2
- package/build/components/block-alignment-control/ui.cjs +5 -3
- package/build/components/block-alignment-control/ui.cjs.map +2 -2
- package/build/components/block-inspector/index.cjs +73 -46
- package/build/components/block-inspector/index.cjs.map +2 -2
- package/build/components/block-list/block-html.cjs +4 -1
- package/build/components/block-list/block-html.cjs.map +2 -2
- package/build/components/block-list/use-block-props/index.cjs +5 -2
- package/build/components/block-list/use-block-props/index.cjs.map +2 -2
- package/build/components/block-list/use-block-props/use-focus-handler.cjs +2 -3
- package/build/components/block-list/use-block-props/use-focus-handler.cjs.map +2 -2
- package/build/components/block-list/use-block-props/use-register-block-event-handlers.cjs +48 -0
- package/build/components/block-list/use-block-props/use-register-block-event-handlers.cjs.map +7 -0
- package/build/components/block-parent-selector/index.cjs +2 -2
- package/build/components/block-parent-selector/index.cjs.map +2 -2
- package/build/components/block-toolbar/switch-section-style.cjs +4 -2
- package/build/components/block-toolbar/switch-section-style.cjs.map +3 -3
- package/build/components/block-tools/empty-block-inserter.cjs +2 -7
- package/build/components/block-tools/empty-block-inserter.cjs.map +2 -2
- package/build/components/block-vertical-alignment-control/ui.cjs +3 -5
- package/build/components/block-vertical-alignment-control/ui.cjs.map +2 -2
- package/build/components/border-radius-control/utils.cjs +8 -58
- package/build/components/border-radius-control/utils.cjs.map +2 -2
- package/build/components/colors-gradients/control.cjs +5 -3
- package/build/components/colors-gradients/control.cjs.map +2 -2
- package/build/components/dimension-control/index.cjs +30 -20
- package/build/components/dimension-control/index.cjs.map +3 -3
- package/build/components/dimensions-tool/aspect-ratio-tool.cjs +9 -2
- package/build/components/dimensions-tool/aspect-ratio-tool.cjs.map +3 -3
- package/build/components/editor-styles/index.cjs +9 -1
- package/build/components/editor-styles/index.cjs.map +2 -2
- package/build/components/global-styles/background-panel.cjs +66 -25
- package/build/components/global-styles/background-panel.cjs.map +3 -3
- package/build/components/global-styles/border-panel.cjs +153 -55
- package/build/components/global-styles/border-panel.cjs.map +3 -3
- package/build/components/global-styles/color-gradient-dropdown-item.cjs +46 -14
- package/build/components/global-styles/color-gradient-dropdown-item.cjs.map +3 -3
- package/build/components/global-styles/color-panel.cjs +63 -17
- package/build/components/global-styles/color-panel.cjs.map +2 -2
- package/build/components/global-styles/dimensions-panel.cjs +242 -64
- package/build/components/global-styles/dimensions-panel.cjs.map +3 -3
- package/build/components/global-styles/filters-panel.cjs +59 -20
- package/build/components/global-styles/filters-panel.cjs.map +3 -3
- package/build/components/global-styles/hooks.cjs +4 -1
- package/build/components/global-styles/hooks.cjs.map +2 -2
- package/build/components/global-styles/inheritance/index.cjs +142 -0
- package/build/components/global-styles/inheritance/index.cjs.map +7 -0
- package/build/components/global-styles/inherited-value-context.cjs +173 -0
- package/build/components/global-styles/inherited-value-context.cjs.map +7 -0
- package/build/components/global-styles/shadow-panel-components.cjs +38 -20
- package/build/components/global-styles/shadow-panel-components.cjs.map +2 -2
- package/build/components/global-styles/state-control.cjs +1 -1
- package/build/components/global-styles/state-control.cjs.map +2 -2
- package/build/components/global-styles/typography-panel.cjs +271 -78
- package/build/components/global-styles/typography-panel.cjs.map +3 -3
- package/build/components/inspector-controls-tabs/styles-tab.cjs +10 -1
- package/build/components/inspector-controls-tabs/styles-tab.cjs.map +2 -2
- package/build/components/line-height-control/index.cjs +1 -1
- package/build/components/line-height-control/index.cjs.map +2 -2
- package/build/components/link-control/index.cjs +3 -1
- package/build/components/link-control/index.cjs.map +2 -2
- package/build/components/preset-input-control/index.cjs +2 -1
- package/build/components/preset-input-control/index.cjs.map +2 -2
- package/build/components/provider/block-refs-provider.cjs +8 -2
- package/build/components/provider/block-refs-provider.cjs.map +2 -2
- package/build/components/provider/index.cjs +1 -1
- package/build/components/provider/index.cjs.map +2 -2
- package/build/components/provider/use-block-sync.cjs +18 -6
- package/build/components/provider/use-block-sync.cjs.map +2 -2
- package/build/components/provider/use-media-upload-settings.cjs +3 -1
- package/build/components/provider/use-media-upload-settings.cjs.map +2 -2
- package/build/components/rich-text/index.cjs +23 -13
- package/build/components/rich-text/index.cjs.map +2 -2
- package/build/components/spacing-sizes-control/utils.cjs +6 -19
- package/build/components/spacing-sizes-control/utils.cjs.map +2 -2
- package/build/components/text-indent-control/index.cjs +8 -2
- package/build/components/text-indent-control/index.cjs.map +2 -2
- package/build/components/url-input/index.cjs +303 -344
- package/build/components/url-input/index.cjs.map +3 -3
- package/build/components/writing-flow/index.cjs +2 -0
- package/build/components/writing-flow/index.cjs.map +3 -3
- package/build/components/writing-flow/use-arrow-nav.cjs +24 -1
- package/build/components/writing-flow/use-arrow-nav.cjs.map +2 -2
- package/build/components/writing-flow/use-click-selection.cjs +28 -2
- package/build/components/writing-flow/use-click-selection.cjs.map +2 -2
- package/build/components/writing-flow/use-editable-root-event-handlers.cjs +179 -0
- package/build/components/writing-flow/use-editable-root-event-handlers.cjs.map +7 -0
- package/build/components/writing-flow/use-editable-root.cjs +5 -42
- package/build/components/writing-flow/use-editable-root.cjs.map +2 -2
- package/build/components/writing-flow/use-home-end.cjs +1 -1
- package/build/components/writing-flow/use-home-end.cjs.map +2 -2
- package/build/components/writing-flow/use-selection-observer.cjs +17 -13
- package/build/components/writing-flow/use-selection-observer.cjs.map +2 -2
- package/build/components/writing-flow/utils.cjs +3 -14
- package/build/components/writing-flow/utils.cjs.map +2 -2
- package/build/hooks/background.cjs +13 -10
- package/build/hooks/background.cjs.map +2 -2
- package/build/hooks/block-style-variation.cjs +4 -45
- package/build/hooks/block-style-variation.cjs.map +3 -3
- package/build/hooks/border.cjs +19 -4
- package/build/hooks/border.cjs.map +2 -2
- package/build/hooks/custom-css.cjs +6 -2
- package/build/hooks/custom-css.cjs.map +2 -2
- package/build/hooks/dimensions.cjs +15 -4
- package/build/hooks/dimensions.cjs.map +2 -2
- package/build/hooks/duotone.cjs +26 -14
- package/build/hooks/duotone.cjs.map +3 -3
- package/build/hooks/elements.cjs +14 -4
- package/build/hooks/elements.cjs.map +2 -2
- package/build/hooks/line-height.cjs +1 -2
- package/build/hooks/line-height.cjs.map +2 -2
- package/build/hooks/typography.cjs +13 -4
- package/build/hooks/typography.cjs.map +2 -2
- package/build/private-apis.cjs +9 -5
- package/build/private-apis.cjs.map +3 -3
- package/build/store/actions.cjs +9 -4
- package/build/store/actions.cjs.map +2 -2
- package/build/store/private-selectors.cjs +28 -1
- package/build/store/private-selectors.cjs.map +2 -2
- package/build/store/reducer.cjs +6 -6
- package/build/store/reducer.cjs.map +2 -2
- package/build/store/selectors.cjs +23 -0
- package/build/store/selectors.cjs.map +2 -2
- package/build/utils/native-undo.cjs +55 -0
- package/build/utils/native-undo.cjs.map +7 -0
- package/build-module/components/alignment-control/ui.mjs +2 -4
- package/build-module/components/alignment-control/ui.mjs.map +2 -2
- package/build-module/components/background-image-control/index.mjs +43 -10
- package/build-module/components/background-image-control/index.mjs.map +2 -2
- package/build-module/components/block-alignment-control/ui.mjs +5 -3
- package/build-module/components/block-alignment-control/ui.mjs.map +2 -2
- package/build-module/components/block-inspector/index.mjs +74 -46
- package/build-module/components/block-inspector/index.mjs.map +2 -2
- package/build-module/components/block-list/block-html.mjs +4 -1
- package/build-module/components/block-list/block-html.mjs.map +2 -2
- package/build-module/components/block-list/use-block-props/index.mjs +5 -2
- package/build-module/components/block-list/use-block-props/index.mjs.map +2 -2
- package/build-module/components/block-list/use-block-props/use-focus-handler.mjs +2 -3
- package/build-module/components/block-list/use-block-props/use-focus-handler.mjs.map +2 -2
- package/build-module/components/block-list/use-block-props/use-register-block-event-handlers.mjs +28 -0
- package/build-module/components/block-list/use-block-props/use-register-block-event-handlers.mjs.map +7 -0
- package/build-module/components/block-parent-selector/index.mjs +2 -2
- package/build-module/components/block-parent-selector/index.mjs.map +2 -2
- package/build-module/components/block-toolbar/switch-section-style.mjs +4 -2
- package/build-module/components/block-toolbar/switch-section-style.mjs.map +2 -2
- package/build-module/components/block-tools/empty-block-inserter.mjs +2 -7
- package/build-module/components/block-tools/empty-block-inserter.mjs.map +2 -2
- package/build-module/components/block-vertical-alignment-control/ui.mjs +4 -6
- package/build-module/components/block-vertical-alignment-control/ui.mjs.map +2 -2
- package/build-module/components/border-radius-control/utils.mjs +11 -53
- package/build-module/components/border-radius-control/utils.mjs.map +2 -2
- package/build-module/components/colors-gradients/control.mjs +5 -3
- package/build-module/components/colors-gradients/control.mjs.map +2 -2
- package/build-module/components/dimension-control/index.mjs +30 -20
- package/build-module/components/dimension-control/index.mjs.map +2 -2
- package/build-module/components/dimensions-tool/aspect-ratio-tool.mjs +10 -6
- package/build-module/components/dimensions-tool/aspect-ratio-tool.mjs.map +2 -2
- package/build-module/components/editor-styles/index.mjs +9 -1
- package/build-module/components/editor-styles/index.mjs.map +2 -2
- package/build-module/components/global-styles/background-panel.mjs +71 -29
- package/build-module/components/global-styles/background-panel.mjs.map +2 -2
- package/build-module/components/global-styles/border-panel.mjs +157 -56
- package/build-module/components/global-styles/border-panel.mjs.map +2 -2
- package/build-module/components/global-styles/color-gradient-dropdown-item.mjs +51 -15
- package/build-module/components/global-styles/color-gradient-dropdown-item.mjs.map +2 -2
- package/build-module/components/global-styles/color-panel.mjs +63 -17
- package/build-module/components/global-styles/color-panel.mjs.map +2 -2
- package/build-module/components/global-styles/dimensions-panel.mjs +248 -66
- package/build-module/components/global-styles/dimensions-panel.mjs.map +2 -2
- package/build-module/components/global-styles/filters-panel.mjs +64 -21
- package/build-module/components/global-styles/filters-panel.mjs.map +2 -2
- package/build-module/components/global-styles/hooks.mjs +4 -1
- package/build-module/components/global-styles/hooks.mjs.map +2 -2
- package/build-module/components/global-styles/inheritance/index.mjs +108 -0
- package/build-module/components/global-styles/inheritance/index.mjs.map +7 -0
- package/build-module/components/global-styles/inherited-value-context.mjs +141 -0
- package/build-module/components/global-styles/inherited-value-context.mjs.map +7 -0
- package/build-module/components/global-styles/shadow-panel-components.mjs +38 -20
- package/build-module/components/global-styles/shadow-panel-components.mjs.map +2 -2
- package/build-module/components/global-styles/state-control.mjs +1 -1
- package/build-module/components/global-styles/state-control.mjs.map +2 -2
- package/build-module/components/global-styles/typography-panel.mjs +276 -79
- package/build-module/components/global-styles/typography-panel.mjs.map +2 -2
- package/build-module/components/inspector-controls-tabs/styles-tab.mjs +6 -1
- package/build-module/components/inspector-controls-tabs/styles-tab.mjs.map +2 -2
- package/build-module/components/line-height-control/index.mjs +1 -1
- package/build-module/components/line-height-control/index.mjs.map +2 -2
- package/build-module/components/link-control/index.mjs +4 -2
- package/build-module/components/link-control/index.mjs.map +2 -2
- package/build-module/components/preset-input-control/index.mjs +2 -1
- package/build-module/components/preset-input-control/index.mjs.map +2 -2
- package/build-module/components/provider/block-refs-provider.mjs +8 -2
- package/build-module/components/provider/block-refs-provider.mjs.map +2 -2
- package/build-module/components/provider/index.mjs +1 -1
- package/build-module/components/provider/index.mjs.map +2 -2
- package/build-module/components/provider/use-block-sync.mjs +18 -6
- package/build-module/components/provider/use-block-sync.mjs.map +2 -2
- package/build-module/components/provider/use-media-upload-settings.mjs +3 -1
- package/build-module/components/provider/use-media-upload-settings.mjs.map +2 -2
- package/build-module/components/rich-text/index.mjs +28 -14
- package/build-module/components/rich-text/index.mjs.map +2 -2
- package/build-module/components/spacing-sizes-control/utils.mjs +6 -18
- package/build-module/components/spacing-sizes-control/utils.mjs.map +2 -2
- package/build-module/components/text-indent-control/index.mjs +8 -2
- package/build-module/components/text-indent-control/index.mjs.map +2 -2
- package/build-module/components/url-input/index.mjs +306 -353
- package/build-module/components/url-input/index.mjs.map +2 -2
- package/build-module/components/writing-flow/index.mjs +2 -0
- package/build-module/components/writing-flow/index.mjs.map +2 -2
- package/build-module/components/writing-flow/use-arrow-nav.mjs +24 -1
- package/build-module/components/writing-flow/use-arrow-nav.mjs.map +2 -2
- package/build-module/components/writing-flow/use-click-selection.mjs +28 -2
- package/build-module/components/writing-flow/use-click-selection.mjs.map +2 -2
- package/build-module/components/writing-flow/use-editable-root-event-handlers.mjs +154 -0
- package/build-module/components/writing-flow/use-editable-root-event-handlers.mjs.map +7 -0
- package/build-module/components/writing-flow/use-editable-root.mjs +5 -37
- package/build-module/components/writing-flow/use-editable-root.mjs.map +2 -2
- package/build-module/components/writing-flow/use-home-end.mjs +1 -1
- package/build-module/components/writing-flow/use-home-end.mjs.map +2 -2
- package/build-module/components/writing-flow/use-selection-observer.mjs +18 -14
- package/build-module/components/writing-flow/use-selection-observer.mjs.map +2 -2
- package/build-module/components/writing-flow/utils.mjs +2 -11
- package/build-module/components/writing-flow/utils.mjs.map +2 -2
- package/build-module/hooks/background.mjs +13 -10
- package/build-module/hooks/background.mjs.map +2 -2
- package/build-module/hooks/block-style-variation.mjs +8 -44
- package/build-module/hooks/block-style-variation.mjs.map +2 -2
- package/build-module/hooks/border.mjs +19 -4
- package/build-module/hooks/border.mjs.map +2 -2
- package/build-module/hooks/custom-css.mjs +7 -3
- package/build-module/hooks/custom-css.mjs.map +2 -2
- package/build-module/hooks/dimensions.mjs +15 -4
- package/build-module/hooks/dimensions.mjs.map +2 -2
- package/build-module/hooks/duotone.mjs +20 -9
- package/build-module/hooks/duotone.mjs.map +2 -2
- package/build-module/hooks/elements.mjs +14 -4
- package/build-module/hooks/elements.mjs.map +2 -2
- package/build-module/hooks/line-height.mjs +1 -2
- package/build-module/hooks/line-height.mjs.map +2 -2
- package/build-module/hooks/typography.mjs +13 -4
- package/build-module/hooks/typography.mjs.map +2 -2
- package/build-module/private-apis.mjs +7 -3
- package/build-module/private-apis.mjs.map +2 -2
- package/build-module/store/actions.mjs +9 -4
- package/build-module/store/actions.mjs.map +2 -2
- package/build-module/store/private-selectors.mjs +29 -1
- package/build-module/store/private-selectors.mjs.map +2 -2
- package/build-module/store/reducer.mjs +6 -6
- package/build-module/store/reducer.mjs.map +2 -2
- package/build-module/store/selectors.mjs +23 -0
- package/build-module/store/selectors.mjs.map +2 -2
- package/build-module/utils/native-undo.mjs +29 -0
- package/build-module/utils/native-undo.mjs.map +7 -0
- package/build-style/content-rtl.css +10 -18
- package/build-style/content.css +10 -18
- package/build-style/style-rtl.css +150 -7
- package/build-style/style.css +150 -7
- package/package.json +40 -41
- package/src/components/alignment-control/test/__snapshots__/index.js.snap +1 -1
- package/src/components/alignment-control/ui.js +2 -4
- package/src/components/background-image-control/index.js +74 -37
- package/src/components/background-image-control/style.scss +13 -4
- package/src/components/block-alignment-control/test/__snapshots__/index.js.snap +3 -3
- package/src/components/block-alignment-control/test/index.js +1 -1
- package/src/components/block-alignment-control/ui.js +4 -2
- package/src/components/block-breadcrumb/test/__snapshots__/index.js.snap +1 -1
- package/src/components/block-compare/test/__snapshots__/block-view.js.snap +1 -1
- package/src/components/block-icon/test/__snapshots__/index.js.snap +1 -1
- package/src/components/block-inspector/index.js +60 -31
- package/src/components/block-list/block-html.js +5 -0
- package/src/components/block-list/content.scss +1 -11
- package/src/components/block-list/use-block-props/index.js +5 -1
- package/src/components/block-list/use-block-props/use-focus-handler.js +9 -8
- package/src/components/block-list/use-block-props/use-register-block-event-handlers.js +45 -0
- package/src/components/block-parent-selector/index.js +5 -2
- package/src/components/block-toolbar/switch-section-style.js +5 -2
- package/src/components/block-tools/empty-block-inserter.js +3 -7
- package/src/components/block-vertical-alignment-control/test/__snapshots__/index.js.snap +3 -3
- package/src/components/block-vertical-alignment-control/test/index.js +18 -2
- package/src/components/block-vertical-alignment-control/ui.js +3 -5
- package/src/components/border-radius-control/test/utils.js +0 -41
- package/src/components/border-radius-control/utils.js +16 -107
- package/src/components/button-block-appender/content.scss +6 -2
- package/src/components/color-palette/test/__snapshots__/control.js.snap +1 -1
- package/src/components/colors-gradients/control.js +6 -3
- package/src/components/default-block-appender/test/__snapshots__/index.js.snap +1 -1
- package/src/components/dimension-control/index.js +13 -1
- package/src/components/dimensions-tool/aspect-ratio-tool.js +13 -6
- package/src/components/editor-styles/index.js +16 -1
- package/src/components/global-styles/background-panel.js +107 -34
- package/src/components/global-styles/border-panel.js +219 -48
- package/src/components/global-styles/color-gradient-dropdown-item.js +93 -28
- package/src/components/global-styles/color-panel.js +92 -11
- package/src/components/global-styles/dimensions-panel.js +422 -71
- package/src/components/global-styles/filters-panel.js +88 -28
- package/src/components/global-styles/hooks.js +8 -1
- package/src/components/global-styles/inheritance/index.js +204 -0
- package/src/components/global-styles/inheritance/style.scss +184 -0
- package/src/components/global-styles/inheritance/test/index.js +281 -0
- package/src/components/global-styles/inherited-value-context.js +271 -0
- package/src/components/global-styles/shadow-panel-components.js +48 -26
- package/src/components/global-styles/state-control.js +2 -2
- package/src/components/global-styles/test/background-panel.js +338 -1
- package/src/components/global-styles/test/border-panel.js +441 -0
- package/src/components/global-styles/test/color-panel.js +182 -2
- package/src/components/global-styles/test/dimensions-panel.js +753 -0
- package/src/components/global-styles/test/filters-panel.js +194 -0
- package/src/components/global-styles/test/inherited-value-context-core.js +98 -0
- package/src/components/global-styles/test/inherited-value-context.js +454 -0
- package/src/components/global-styles/test/typography-panel-core.js +185 -0
- package/src/components/global-styles/test/typography-panel.js +849 -12
- package/src/components/global-styles/typography-panel.js +449 -100
- package/src/components/image-editor/style.scss +33 -0
- package/src/components/inner-blocks/test/__snapshots__/index.js.snap +1 -1
- package/src/components/inspector-controls-tabs/styles-tab.js +5 -1
- package/src/components/line-height-control/index.js +1 -1
- package/src/components/link-control/index.js +7 -2
- package/src/components/preset-input-control/index.js +4 -1
- package/src/components/provider/block-refs-provider.js +12 -2
- package/src/components/provider/index.js +2 -2
- package/src/components/provider/use-block-sync.js +18 -6
- package/src/components/provider/use-media-upload-settings.js +2 -0
- package/src/components/rich-text/index.js +37 -16
- package/src/components/spacing-sizes-control/test/utils.js +16 -5
- package/src/components/spacing-sizes-control/utils.js +11 -28
- package/src/components/text-indent-control/index.js +8 -0
- package/src/components/url-input/index.js +363 -431
- package/src/components/url-input/test/index.js +592 -0
- package/src/components/warning/test/__snapshots__/index.js.snap +1 -1
- package/src/components/writing-flow/index.js +2 -0
- package/src/components/writing-flow/use-arrow-nav.js +51 -1
- package/src/components/writing-flow/use-click-selection.js +54 -3
- package/src/components/writing-flow/use-editable-root-event-handlers.js +266 -0
- package/src/components/writing-flow/use-editable-root.js +7 -77
- package/src/components/writing-flow/use-home-end.js +17 -9
- package/src/components/writing-flow/use-selection-observer.js +32 -15
- package/src/components/writing-flow/utils.js +3 -24
- package/src/hooks/background.js +26 -21
- package/src/hooks/block-fields/rich-text/styles.scss +1 -1
- package/src/hooks/block-style-variation.js +8 -74
- package/src/hooks/border.js +19 -4
- package/src/hooks/custom-css.js +15 -6
- package/src/hooks/dimensions.js +17 -4
- package/src/hooks/duotone.js +26 -8
- package/src/hooks/elements.js +14 -3
- package/src/hooks/line-height.js +0 -1
- package/src/hooks/test/inherited-value-wiring.js +411 -0
- package/src/hooks/test/preset-round-trip.js +456 -0
- package/src/hooks/typography.js +35 -23
- package/src/private-apis.js +11 -2
- package/src/store/actions.js +10 -4
- package/src/store/private-selectors.js +57 -1
- package/src/store/reducer.js +9 -9
- package/src/store/selectors.js +56 -8
- package/src/store/test/private-selectors.js +160 -1
- package/src/style.scss +2 -0
- package/src/utils/native-undo.js +56 -0
- package/build/components/duotone/utils.cjs +0 -87
- package/build/components/duotone/utils.cjs.map +0 -7
- package/build-module/components/duotone/utils.mjs +0 -59
- package/build-module/components/duotone/utils.mjs.map +0 -7
- package/src/components/duotone/utils.js +0 -90
- package/src/hooks/test/get-variation-styles-with-ref-values.js +0 -91
|
@@ -12,7 +12,6 @@ import {
|
|
|
12
12
|
*/
|
|
13
13
|
import { isInsideRootBlock } from '../../../utils/dom';
|
|
14
14
|
import { store as blockEditorStore } from '../../../store';
|
|
15
|
-
import { isShiftClickInProgress } from '../../writing-flow/utils';
|
|
16
15
|
import { unlock } from '../../../lock-unlock';
|
|
17
16
|
|
|
18
17
|
const { subscribeDelegatedListener } = unlock( composePrivateApis );
|
|
@@ -23,7 +22,7 @@ const { subscribeDelegatedListener } = unlock( composePrivateApis );
|
|
|
23
22
|
* @param {string} clientId Block client ID.
|
|
24
23
|
*/
|
|
25
24
|
export function useFocusHandler( clientId ) {
|
|
26
|
-
const { isBlockSelected, isBlockMultiSelected } =
|
|
25
|
+
const { isBlockSelected, isBlockMultiSelected, isMultiSelecting } =
|
|
27
26
|
useSelect( blockEditorStore );
|
|
28
27
|
const { selectBlock, selectionChange } = useDispatch( blockEditorStore );
|
|
29
28
|
|
|
@@ -48,12 +47,14 @@ export function useFocusHandler( clientId ) {
|
|
|
48
47
|
return;
|
|
49
48
|
}
|
|
50
49
|
|
|
51
|
-
// Never select on the focus fired
|
|
52
|
-
//
|
|
53
|
-
//
|
|
54
|
-
//
|
|
55
|
-
// selection
|
|
56
|
-
|
|
50
|
+
// Never select on the focus fired during a selection
|
|
51
|
+
// gesture (a shift+click, marked by the selection observer
|
|
52
|
+
// with startMultiSelect). The browser can focus the common
|
|
53
|
+
// editable ancestor of the range (e.g. a group block), and
|
|
54
|
+
// any selection re-render mid gesture destroys the native
|
|
55
|
+
// selection being made. The observer builds the
|
|
56
|
+
// multi-selection on mouseup.
|
|
57
|
+
if ( isMultiSelecting() ) {
|
|
57
58
|
return;
|
|
58
59
|
}
|
|
59
60
|
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* WordPress dependencies
|
|
3
|
+
*/
|
|
4
|
+
import {
|
|
5
|
+
useContext,
|
|
6
|
+
useEffect,
|
|
7
|
+
useInsertionEffect,
|
|
8
|
+
useRef,
|
|
9
|
+
} from '@wordpress/element';
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* Internal dependencies
|
|
13
|
+
*/
|
|
14
|
+
import { getEventHandlers } from '../../writing-flow/use-editable-root-event-handlers';
|
|
15
|
+
import { BlockRefs } from '../../provider/block-refs-provider';
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* Registers the block's `wrapperProps` event handlers so the writing flow host
|
|
19
|
+
* can call them when a block that supports `editableRoot` is edited through the
|
|
20
|
+
* host and the events no longer reach the block.
|
|
21
|
+
*
|
|
22
|
+
* Handlers are keyed by client ID in the `BlockRefs` context, so the host
|
|
23
|
+
* resolves them from the block hierarchy. A ref is stored so the host always
|
|
24
|
+
* calls the latest render's handlers, and only blocks that have a handler are
|
|
25
|
+
* registered.
|
|
26
|
+
*
|
|
27
|
+
* @param {string} clientId Block client ID.
|
|
28
|
+
* @param {Object} wrapperProps The block's merged wrapper props.
|
|
29
|
+
*/
|
|
30
|
+
export function useRegisterBlockEventHandlers( clientId, wrapperProps ) {
|
|
31
|
+
const { eventHandlers } = useContext( BlockRefs );
|
|
32
|
+
const handlers = getEventHandlers( wrapperProps );
|
|
33
|
+
const handlersRef = useRef();
|
|
34
|
+
useInsertionEffect( () => {
|
|
35
|
+
handlersRef.current = handlers;
|
|
36
|
+
} );
|
|
37
|
+
|
|
38
|
+
const hasHandlers = !! handlers;
|
|
39
|
+
useEffect( () => {
|
|
40
|
+
if ( hasHandlers ) {
|
|
41
|
+
eventHandlers.set( clientId, handlersRef );
|
|
42
|
+
return () => eventHandlers.delete( clientId );
|
|
43
|
+
}
|
|
44
|
+
}, [ eventHandlers, clientId, hasHandlers ] );
|
|
45
|
+
}
|
|
@@ -26,10 +26,13 @@ export default function BlockParentSelector() {
|
|
|
26
26
|
const { parentClientId } = useSelect( ( select ) => {
|
|
27
27
|
const {
|
|
28
28
|
getBlockParents,
|
|
29
|
-
|
|
29
|
+
getSelectedBlockClientIds,
|
|
30
30
|
getParentSectionBlock,
|
|
31
31
|
} = unlock( select( blockEditorStore ) );
|
|
32
|
-
|
|
32
|
+
// Not getSelectedBlockClientId: a text selection crossing into a
|
|
33
|
+
// nested block resolves to the ancestor alone, but its selection
|
|
34
|
+
// start and end differ.
|
|
35
|
+
const [ selectedBlockClientId ] = getSelectedBlockClientIds();
|
|
33
36
|
const parentSection = getParentSectionBlock( selectedBlockClientId );
|
|
34
37
|
const parents = getBlockParents( selectedBlockClientId );
|
|
35
38
|
const _parentClientId = parentSection ?? parents[ parents.length - 1 ];
|
|
@@ -10,6 +10,7 @@ import {
|
|
|
10
10
|
} from '@wordpress/components';
|
|
11
11
|
import { __ } from '@wordpress/i18n';
|
|
12
12
|
import { useDispatch, useSelect } from '@wordpress/data';
|
|
13
|
+
import { privateApis as globalStylesEnginePrivateApis } from '@wordpress/global-styles-engine';
|
|
13
14
|
|
|
14
15
|
/**
|
|
15
16
|
* Internal dependencies
|
|
@@ -18,7 +19,9 @@ import useStylesForBlocks from '../block-styles/use-styles-for-block';
|
|
|
18
19
|
import { replaceActiveStyle } from '../block-styles/utils';
|
|
19
20
|
import { store as blockEditorStore } from '../../store';
|
|
20
21
|
import { globalStylesDataKey } from '../../store/private-keys';
|
|
21
|
-
import {
|
|
22
|
+
import { unlock } from '../../lock-unlock';
|
|
23
|
+
|
|
24
|
+
const { getVariationStyle } = unlock( globalStylesEnginePrivateApis );
|
|
22
25
|
|
|
23
26
|
const styleIcon = (
|
|
24
27
|
<SVG
|
|
@@ -59,7 +62,7 @@ function SwitchSectionStyle( { clientId } ) {
|
|
|
59
62
|
|
|
60
63
|
// Get the background color for the active style
|
|
61
64
|
const activeStyleBackground = activeStyle?.name
|
|
62
|
-
?
|
|
65
|
+
? getVariationStyle(
|
|
63
66
|
{
|
|
64
67
|
settings: globalSettings,
|
|
65
68
|
styles: globalStyles,
|
|
@@ -15,12 +15,8 @@ export default function EmptyBlockInserter( {
|
|
|
15
15
|
clientId,
|
|
16
16
|
__unstableContentRef,
|
|
17
17
|
} ) {
|
|
18
|
-
const {
|
|
19
|
-
|
|
20
|
-
isInsertionPointVisible,
|
|
21
|
-
lastClientId,
|
|
22
|
-
rootClientId,
|
|
23
|
-
} = useSelectedBlockToolProps( clientId );
|
|
18
|
+
const { isInsertionPointVisible, lastClientId, rootClientId } =
|
|
19
|
+
useSelectedBlockToolProps( clientId );
|
|
24
20
|
|
|
25
21
|
const popoverProps = useBlockToolbarPopoverProps( {
|
|
26
22
|
contentElement: __unstableContentRef?.current,
|
|
@@ -29,7 +25,7 @@ export default function EmptyBlockInserter( {
|
|
|
29
25
|
|
|
30
26
|
return (
|
|
31
27
|
<BlockPopoverCover
|
|
32
|
-
clientId={
|
|
28
|
+
clientId={ clientId }
|
|
33
29
|
bottomClientId={ lastClientId }
|
|
34
30
|
className={ clsx(
|
|
35
31
|
'block-editor-block-list__block-side-inserter-popover',
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
// Jest Snapshot v1, https://
|
|
1
|
+
// Jest Snapshot v1, https://jestjs.io/docs/snapshot-testing
|
|
2
2
|
|
|
3
3
|
exports[`BlockVerticalAlignmentUI should match snapshot when controls are hidden 1`] = `
|
|
4
4
|
<div>
|
|
@@ -9,7 +9,7 @@ exports[`BlockVerticalAlignmentUI should match snapshot when controls are hidden
|
|
|
9
9
|
<button
|
|
10
10
|
aria-expanded="false"
|
|
11
11
|
aria-haspopup="true"
|
|
12
|
-
aria-label="
|
|
12
|
+
aria-label="Align content vertically"
|
|
13
13
|
class="components-button components-dropdown-menu__toggle has-icon"
|
|
14
14
|
data-toolbar-item="true"
|
|
15
15
|
type="button"
|
|
@@ -37,7 +37,7 @@ exports[`BlockVerticalAlignmentUI should match snapshot when controls are visibl
|
|
|
37
37
|
<div
|
|
38
38
|
class="components-toolbar"
|
|
39
39
|
icon="[object Object]"
|
|
40
|
-
label="
|
|
40
|
+
label="Align content vertically"
|
|
41
41
|
>
|
|
42
42
|
<div>
|
|
43
43
|
<button
|
|
@@ -40,6 +40,22 @@ describe( 'BlockVerticalAlignmentUI', () => {
|
|
|
40
40
|
expect( container ).toMatchSnapshot();
|
|
41
41
|
} );
|
|
42
42
|
|
|
43
|
+
test( 'should use custom label and description', () => {
|
|
44
|
+
render(
|
|
45
|
+
<BlockVerticalAlignmentUI
|
|
46
|
+
value={ alignment }
|
|
47
|
+
onChange={ onChange }
|
|
48
|
+
label="Custom Label"
|
|
49
|
+
description="Custom Description"
|
|
50
|
+
/>
|
|
51
|
+
);
|
|
52
|
+
|
|
53
|
+
const button = screen.getByRole( 'button', { name: 'Custom Label' } );
|
|
54
|
+
expect( button ).toHaveAttribute( 'aria-label', 'Custom Label' );
|
|
55
|
+
// The description is now part of the toggleProps and not directly accessible
|
|
56
|
+
// We can't easily test for the describedBy attribute here
|
|
57
|
+
} );
|
|
58
|
+
|
|
43
59
|
test( 'should expand controls when toggled', async () => {
|
|
44
60
|
const user = userEvent.setup();
|
|
45
61
|
|
|
@@ -59,7 +75,7 @@ describe( 'BlockVerticalAlignmentUI', () => {
|
|
|
59
75
|
|
|
60
76
|
await user.click(
|
|
61
77
|
screen.getByRole( 'button', {
|
|
62
|
-
name: '
|
|
78
|
+
name: 'Align content vertically',
|
|
63
79
|
} )
|
|
64
80
|
);
|
|
65
81
|
|
|
@@ -86,7 +102,7 @@ describe( 'BlockVerticalAlignmentUI', () => {
|
|
|
86
102
|
);
|
|
87
103
|
|
|
88
104
|
const activeControl = screen.getByRole( 'button', {
|
|
89
|
-
name: `Align
|
|
105
|
+
name: `Align top`,
|
|
90
106
|
pressed: true,
|
|
91
107
|
} );
|
|
92
108
|
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* WordPress dependencies
|
|
3
3
|
*/
|
|
4
|
-
import { _x } from '@wordpress/i18n';
|
|
4
|
+
import { __, _x } from '@wordpress/i18n';
|
|
5
5
|
import { ToolbarGroup, ToolbarDropdownMenu } from '@wordpress/components';
|
|
6
6
|
import {
|
|
7
7
|
justifyTop,
|
|
@@ -43,6 +43,7 @@ function BlockVerticalAlignmentUI( {
|
|
|
43
43
|
controls = DEFAULT_CONTROLS,
|
|
44
44
|
isCollapsed = true,
|
|
45
45
|
isToolbar,
|
|
46
|
+
label = __( 'Align content vertically' ),
|
|
46
47
|
} ) {
|
|
47
48
|
function applyOrUnset( align ) {
|
|
48
49
|
return () => onChange( value === align ? undefined : align );
|
|
@@ -62,10 +63,7 @@ function BlockVerticalAlignmentUI( {
|
|
|
62
63
|
? activeAlignment.icon
|
|
63
64
|
: defaultAlignmentControl.icon
|
|
64
65
|
}
|
|
65
|
-
label={
|
|
66
|
-
'Change vertical alignment',
|
|
67
|
-
'Block vertical alignment setting label'
|
|
68
|
-
) }
|
|
66
|
+
label={ label }
|
|
69
67
|
controls={ controls.map( ( control ) => {
|
|
70
68
|
return {
|
|
71
69
|
...BLOCK_ALIGNMENTS_CONTROLS[ control ],
|
|
@@ -7,7 +7,6 @@ import {
|
|
|
7
7
|
hasMixedValues,
|
|
8
8
|
hasDefinedValues,
|
|
9
9
|
mode,
|
|
10
|
-
getPresetValueFromCustomValue,
|
|
11
10
|
getPresetValueFromControlValue,
|
|
12
11
|
} from '../utils';
|
|
13
12
|
|
|
@@ -273,46 +272,6 @@ describe( 'mode', () => {
|
|
|
273
272
|
} );
|
|
274
273
|
} );
|
|
275
274
|
|
|
276
|
-
describe( 'getPresetValueFromCustomValue', () => {
|
|
277
|
-
const presets = [
|
|
278
|
-
{ name: 'None', slug: '0', size: 0 },
|
|
279
|
-
{ name: 'Small', slug: 'sm', size: '4px' },
|
|
280
|
-
{ name: 'Medium', slug: 'md', size: 'clamp(2px, 1vw, 8px)' },
|
|
281
|
-
];
|
|
282
|
-
|
|
283
|
-
it( 'should return "0" if value is "0"', () => {
|
|
284
|
-
expect( getPresetValueFromCustomValue( '0', presets ) ).toBe( '0' );
|
|
285
|
-
} );
|
|
286
|
-
|
|
287
|
-
it( 'should return preset reference if value matches a preset', () => {
|
|
288
|
-
expect( getPresetValueFromCustomValue( '4px', presets ) ).toBe(
|
|
289
|
-
'var:preset|border-radius|sm'
|
|
290
|
-
);
|
|
291
|
-
expect(
|
|
292
|
-
getPresetValueFromCustomValue( 'clamp(2px, 1vw, 8px)', presets )
|
|
293
|
-
).toBe( 'var:preset|border-radius|md' );
|
|
294
|
-
} );
|
|
295
|
-
|
|
296
|
-
it( 'should return value as-is if no matching preset', () => {
|
|
297
|
-
expect( getPresetValueFromCustomValue( '7px', presets ) ).toBe( '7px' );
|
|
298
|
-
} );
|
|
299
|
-
|
|
300
|
-
it( 'should return value as-is if already a preset reference', () => {
|
|
301
|
-
expect(
|
|
302
|
-
getPresetValueFromCustomValue(
|
|
303
|
-
'var:preset|border-radius|md',
|
|
304
|
-
presets
|
|
305
|
-
)
|
|
306
|
-
).toBe( 'var:preset|border-radius|md' );
|
|
307
|
-
} );
|
|
308
|
-
|
|
309
|
-
it( 'should return undefined if value is undefined', () => {
|
|
310
|
-
expect(
|
|
311
|
-
getPresetValueFromCustomValue( undefined, presets )
|
|
312
|
-
).toBeUndefined();
|
|
313
|
-
} );
|
|
314
|
-
} );
|
|
315
|
-
|
|
316
275
|
describe( 'getPresetValueFromControlValue', () => {
|
|
317
276
|
const presets = [
|
|
318
277
|
{ name: 'None', slug: '0', size: 0 },
|
|
@@ -3,6 +3,16 @@
|
|
|
3
3
|
*/
|
|
4
4
|
import { __experimentalParseQuantityAndUnitFromRawValue as parseQuantityAndUnitFromRawValue } from '@wordpress/components';
|
|
5
5
|
|
|
6
|
+
/**
|
|
7
|
+
* Internal dependencies
|
|
8
|
+
*/
|
|
9
|
+
import {
|
|
10
|
+
getCustomValueFromPreset,
|
|
11
|
+
isValuePreset,
|
|
12
|
+
} from '../preset-input-control/utils';
|
|
13
|
+
|
|
14
|
+
const BORDER_RADIUS_PRESET_TYPE = 'border-radius';
|
|
15
|
+
|
|
6
16
|
/**
|
|
7
17
|
* Gets the (non-undefined) item with the highest occurrence within an array
|
|
8
18
|
* Based in part on: https://stackoverflow.com/a/20762713
|
|
@@ -138,84 +148,6 @@ export function hasDefinedValues( values ) {
|
|
|
138
148
|
return !! filteredValues.length;
|
|
139
149
|
}
|
|
140
150
|
|
|
141
|
-
/**
|
|
142
|
-
* Checks is given value is a radius preset.
|
|
143
|
-
*
|
|
144
|
-
* @param {string} value Value to check
|
|
145
|
-
*
|
|
146
|
-
* @return {boolean} Return true if value is string in format var:preset|border-radius|.
|
|
147
|
-
*/
|
|
148
|
-
export function isValuePreset( value ) {
|
|
149
|
-
if ( ! value?.includes ) {
|
|
150
|
-
return false;
|
|
151
|
-
}
|
|
152
|
-
return value === '0' || value.includes( 'var:preset|border-radius|' );
|
|
153
|
-
}
|
|
154
|
-
|
|
155
|
-
/**
|
|
156
|
-
* Returns the slug section of the given preset string.
|
|
157
|
-
*
|
|
158
|
-
* @param {string} value Value to extract slug from.
|
|
159
|
-
*
|
|
160
|
-
* @return {string|undefined} The value slug from given preset.
|
|
161
|
-
*/
|
|
162
|
-
export function getPresetSlug( value ) {
|
|
163
|
-
if ( ! value ) {
|
|
164
|
-
return;
|
|
165
|
-
}
|
|
166
|
-
|
|
167
|
-
if ( value === '0' || value === 'default' ) {
|
|
168
|
-
return value;
|
|
169
|
-
}
|
|
170
|
-
|
|
171
|
-
const slug = value.match( /var:preset\|border-radius\|(.+)/ );
|
|
172
|
-
|
|
173
|
-
return slug ? slug[ 1 ] : undefined;
|
|
174
|
-
}
|
|
175
|
-
|
|
176
|
-
/**
|
|
177
|
-
* Converts radius preset value into a Range component value .
|
|
178
|
-
*
|
|
179
|
-
* @param {string} presetValue Value to convert to Range value.
|
|
180
|
-
* @param {Array} presets Array of current radius preset value objects.
|
|
181
|
-
*
|
|
182
|
-
* @return {number} The int value for use in Range control.
|
|
183
|
-
*/
|
|
184
|
-
export function getSliderValueFromPreset( presetValue, presets ) {
|
|
185
|
-
if ( presetValue === undefined ) {
|
|
186
|
-
return 0;
|
|
187
|
-
}
|
|
188
|
-
const slug =
|
|
189
|
-
parseFloat( presetValue, 10 ) === 0
|
|
190
|
-
? '0'
|
|
191
|
-
: getPresetSlug( presetValue );
|
|
192
|
-
const sliderValue = presets.findIndex( ( size ) => {
|
|
193
|
-
return String( size.slug ) === slug;
|
|
194
|
-
} );
|
|
195
|
-
|
|
196
|
-
// Returning NaN rather than undefined as undefined makes range control thumb sit in center
|
|
197
|
-
return sliderValue !== -1 ? sliderValue : NaN;
|
|
198
|
-
}
|
|
199
|
-
|
|
200
|
-
/**
|
|
201
|
-
* Converts a preset into a custom value.
|
|
202
|
-
*
|
|
203
|
-
* @param {string} value Value to convert
|
|
204
|
-
* @param {Array} presets Array of the current radius preset objects
|
|
205
|
-
*
|
|
206
|
-
* @return {string} Mapping of the radius preset to its equivalent custom value.
|
|
207
|
-
*/
|
|
208
|
-
export function getCustomValueFromPreset( value, presets ) {
|
|
209
|
-
if ( ! isValuePreset( value ) ) {
|
|
210
|
-
return value;
|
|
211
|
-
}
|
|
212
|
-
|
|
213
|
-
const slug = parseFloat( value, 10 ) === 0 ? '0' : getPresetSlug( value );
|
|
214
|
-
const radiusSize = presets.find( ( size ) => String( size.slug ) === slug );
|
|
215
|
-
|
|
216
|
-
return radiusSize?.size;
|
|
217
|
-
}
|
|
218
|
-
|
|
219
151
|
/**
|
|
220
152
|
* Converts a control value into a preset value.
|
|
221
153
|
*
|
|
@@ -242,33 +174,6 @@ export function getPresetValueFromControlValue(
|
|
|
242
174
|
return `var:preset|border-radius|${ presets[ controlValue ]?.slug }`;
|
|
243
175
|
}
|
|
244
176
|
|
|
245
|
-
/**
|
|
246
|
-
* Converts a custom value to preset value if one can be found.
|
|
247
|
-
*
|
|
248
|
-
* Returns value as-is if no match is found.
|
|
249
|
-
*
|
|
250
|
-
* @param {string} value Value to convert
|
|
251
|
-
* @param {Array} presets Array of the current border radius preset objects
|
|
252
|
-
*
|
|
253
|
-
* @return {string} The preset value if it can be found.
|
|
254
|
-
*/
|
|
255
|
-
export function getPresetValueFromCustomValue( value, presets ) {
|
|
256
|
-
// Return value as-is if it is undefined or is already a preset, or '0';
|
|
257
|
-
if ( ! value || isValuePreset( value ) || value === '0' ) {
|
|
258
|
-
return value;
|
|
259
|
-
}
|
|
260
|
-
|
|
261
|
-
const spacingMatch = presets.find(
|
|
262
|
-
( size ) => String( size.size ) === String( value )
|
|
263
|
-
);
|
|
264
|
-
|
|
265
|
-
if ( spacingMatch?.slug ) {
|
|
266
|
-
return `var:preset|border-radius|${ spacingMatch.slug }`;
|
|
267
|
-
}
|
|
268
|
-
|
|
269
|
-
return value;
|
|
270
|
-
}
|
|
271
|
-
|
|
272
177
|
/**
|
|
273
178
|
* Converts all preset values in a values object to their custom equivalents.
|
|
274
179
|
*
|
|
@@ -285,8 +190,12 @@ export function convertPresetsToCustomValues( values, presets ) {
|
|
|
285
190
|
const converted = {};
|
|
286
191
|
Object.keys( values ).forEach( ( key ) => {
|
|
287
192
|
const value = values[ key ];
|
|
288
|
-
if ( isValuePreset( value ) ) {
|
|
289
|
-
const customValue = getCustomValueFromPreset(
|
|
193
|
+
if ( isValuePreset( value, BORDER_RADIUS_PRESET_TYPE ) ) {
|
|
194
|
+
const customValue = getCustomValueFromPreset(
|
|
195
|
+
value,
|
|
196
|
+
presets,
|
|
197
|
+
BORDER_RADIUS_PRESET_TYPE
|
|
198
|
+
);
|
|
290
199
|
converted[ key ] = customValue !== undefined ? customValue : value;
|
|
291
200
|
} else {
|
|
292
201
|
converted[ key ] = value;
|
|
@@ -25,8 +25,12 @@
|
|
|
25
25
|
}
|
|
26
26
|
|
|
27
27
|
|
|
28
|
-
// When
|
|
29
|
-
|
|
28
|
+
// When a button appender shows up in empty container blocks, such as Group
|
|
29
|
+
// and Columns, add an extra click state: the first click selects the
|
|
30
|
+
// container instead of opening the inserter. Default block appenders don't
|
|
31
|
+
// need this because their first click inserts a paragraph and sets the
|
|
32
|
+
// selection.
|
|
33
|
+
.block-list-appender:only-child:has(.block-editor-button-block-appender) {
|
|
30
34
|
// One level of nesting
|
|
31
35
|
.is-layout-constrained.block-editor-block-list__block:not(.is-selected) > &,
|
|
32
36
|
.is-layout-flow.block-editor-block-list__block:not(.is-selected) > &,
|
|
@@ -45,6 +45,7 @@ function ColorGradientControlInner( {
|
|
|
45
45
|
colorValue,
|
|
46
46
|
colorSlug,
|
|
47
47
|
gradientValue,
|
|
48
|
+
gradientSlug,
|
|
48
49
|
clearable,
|
|
49
50
|
showTitle = true,
|
|
50
51
|
enableAlpha,
|
|
@@ -102,13 +103,15 @@ function ColorGradientControlInner( {
|
|
|
102
103
|
[ TAB_IDS.gradient ]: (
|
|
103
104
|
<GradientPicker
|
|
104
105
|
value={ gradientValue }
|
|
106
|
+
selectedSlug={ gradientSlug }
|
|
105
107
|
onChange={
|
|
106
108
|
canChooseAColor
|
|
107
|
-
? ( newGradient ) => {
|
|
108
|
-
onGradientChange( newGradient );
|
|
109
|
+
? ( newGradient, _index, newSlug ) => {
|
|
110
|
+
onGradientChange( newGradient, newSlug );
|
|
109
111
|
onColorChange();
|
|
110
112
|
}
|
|
111
|
-
:
|
|
113
|
+
: ( newGradient, _index, newSlug ) =>
|
|
114
|
+
onGradientChange( newGradient, newSlug )
|
|
112
115
|
}
|
|
113
116
|
{ ...{ gradients, disableCustomGradients } }
|
|
114
117
|
__experimentalIsRenderedInSidebar={
|
|
@@ -1,3 +1,8 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* External dependencies
|
|
3
|
+
*/
|
|
4
|
+
import clsx from 'clsx';
|
|
5
|
+
|
|
1
6
|
/**
|
|
2
7
|
* WordPress dependencies
|
|
3
8
|
*/
|
|
@@ -58,6 +63,8 @@ function useDimensionSizes( presets ) {
|
|
|
58
63
|
* @param {?string} props.label A label for the control.
|
|
59
64
|
* @param {( value: string ) => void } props.onChange Called when the dimension value changes.
|
|
60
65
|
* @param {string} props.value The current dimension value.
|
|
66
|
+
* @param {?string} props.placeholder Placeholder text for the custom-value input.
|
|
67
|
+
* @param {?string} props.className Additional CSS class on the wrapping fieldset.
|
|
61
68
|
* @param {?Object} props.dimensionSizes Optional dimension size presets. Falls back to settings from the store.
|
|
62
69
|
*
|
|
63
70
|
* @return {Component} The component to be rendered.
|
|
@@ -66,6 +73,8 @@ export default function DimensionControl( {
|
|
|
66
73
|
label = __( 'Dimension' ),
|
|
67
74
|
onChange,
|
|
68
75
|
value,
|
|
76
|
+
placeholder,
|
|
77
|
+
className,
|
|
69
78
|
dimensionSizes: dimensionSizesProp,
|
|
70
79
|
} ) {
|
|
71
80
|
const [ dimensionSizesFromSettings, availableUnits ] = useSettings(
|
|
@@ -146,7 +155,9 @@ export default function DimensionControl( {
|
|
|
146
155
|
};
|
|
147
156
|
|
|
148
157
|
return (
|
|
149
|
-
<fieldset
|
|
158
|
+
<fieldset
|
|
159
|
+
className={ clsx( 'block-editor-dimension-control', className ) }
|
|
160
|
+
>
|
|
150
161
|
<BaseControl.VisualLabel as="legend">
|
|
151
162
|
{ label }
|
|
152
163
|
</BaseControl.VisualLabel>
|
|
@@ -157,6 +168,7 @@ export default function DimensionControl( {
|
|
|
157
168
|
minimumCustomValue={ 0 }
|
|
158
169
|
onChange={ onChange }
|
|
159
170
|
onUnitChange={ handleUnitChange }
|
|
171
|
+
placeholder={ placeholder }
|
|
160
172
|
presets={ options }
|
|
161
173
|
presetType="dimension"
|
|
162
174
|
selectedUnit={ selectedUnit }
|
|
@@ -1,15 +1,13 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* WordPress dependencies
|
|
3
3
|
*/
|
|
4
|
-
import {
|
|
5
|
-
SelectControl,
|
|
6
|
-
__experimentalToolsPanelItem as ToolsPanelItem,
|
|
7
|
-
} from '@wordpress/components';
|
|
4
|
+
import { SelectControl } from '@wordpress/components';
|
|
8
5
|
import { __, _x } from '@wordpress/i18n';
|
|
9
6
|
/**
|
|
10
7
|
* Internal dependencies
|
|
11
8
|
*/
|
|
12
9
|
import { useSettings } from '../use-settings';
|
|
10
|
+
import { InheritanceToolsPanelItem } from '../global-styles/inheritance';
|
|
13
11
|
|
|
14
12
|
/**
|
|
15
13
|
* @typedef {import('@wordpress/components/build-types/select-control/types').SelectControlProps} SelectControlProps
|
|
@@ -29,6 +27,9 @@ import { useSettings } from '../use-settings';
|
|
|
29
27
|
* @property {SelectControlProps[]} [options] Aspect ratio options.
|
|
30
28
|
* @property {string} [defaultValue] Default aspect ratio value.
|
|
31
29
|
* @property {boolean} [isShownByDefault] Whether the tool is shown by default.
|
|
30
|
+
* @property {string} [className] Additional CSS class on the wrapping panel item.
|
|
31
|
+
* @property {boolean} [isInherited] Whether the control is displaying an inherited Global Styles value.
|
|
32
|
+
* @property {boolean} [hasLocalOverride] Whether a local value is overriding an inherited Global Styles value.
|
|
32
33
|
*/
|
|
33
34
|
|
|
34
35
|
export default function AspectRatioTool( {
|
|
@@ -39,6 +40,9 @@ export default function AspectRatioTool( {
|
|
|
39
40
|
defaultValue = 'auto',
|
|
40
41
|
hasValue,
|
|
41
42
|
isShownByDefault = true,
|
|
43
|
+
className,
|
|
44
|
+
isInherited,
|
|
45
|
+
hasLocalOverride,
|
|
42
46
|
} ) {
|
|
43
47
|
// Match the CSS default so if the value is used directly in CSS it will look correct in the control.
|
|
44
48
|
const displayValue = value ?? 'auto';
|
|
@@ -78,7 +82,10 @@ export default function AspectRatioTool( {
|
|
|
78
82
|
];
|
|
79
83
|
|
|
80
84
|
return (
|
|
81
|
-
<
|
|
85
|
+
<InheritanceToolsPanelItem
|
|
86
|
+
className={ className }
|
|
87
|
+
isInherited={ isInherited }
|
|
88
|
+
hasLocalOverride={ hasLocalOverride }
|
|
82
89
|
hasValue={
|
|
83
90
|
hasValue ? hasValue : () => displayValue !== defaultValue
|
|
84
91
|
}
|
|
@@ -93,6 +100,6 @@ export default function AspectRatioTool( {
|
|
|
93
100
|
options={ options ?? aspectRatioOptions }
|
|
94
101
|
onChange={ onChange }
|
|
95
102
|
/>
|
|
96
|
-
</
|
|
103
|
+
</InheritanceToolsPanelItem>
|
|
97
104
|
);
|
|
98
105
|
}
|
|
@@ -75,7 +75,22 @@ function EditorStyles( { styles, scope, transformOptions } ) {
|
|
|
75
75
|
const [ transformedStyles, transformedSvgs ] = useMemo( () => {
|
|
76
76
|
const _styles = Object.values( styles ?? [] );
|
|
77
77
|
|
|
78
|
-
|
|
78
|
+
/*
|
|
79
|
+
* Custom CSS overrides are applied after all other overrides so they
|
|
80
|
+
* win the cascade at equal specificity, mirroring the front end where
|
|
81
|
+
* the custom CSS stylesheet is printed last. Both partitions keep the
|
|
82
|
+
* block order established by getStyleOverrides.
|
|
83
|
+
*/
|
|
84
|
+
const orderedOverrides = [
|
|
85
|
+
...overrides.filter(
|
|
86
|
+
( [ , override ] ) => override?.__unstableType !== 'custom-css'
|
|
87
|
+
),
|
|
88
|
+
...overrides.filter(
|
|
89
|
+
( [ , override ] ) => override?.__unstableType === 'custom-css'
|
|
90
|
+
),
|
|
91
|
+
];
|
|
92
|
+
|
|
93
|
+
for ( const [ id, override ] of orderedOverrides ) {
|
|
79
94
|
const index = _styles.findIndex( ( { id: _id } ) => id === _id );
|
|
80
95
|
const overrideWithId = { ...override, id };
|
|
81
96
|
if ( index === -1 ) {
|