@wordpress/block-editor 13.4.0 → 14.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 +13 -0
- package/README.md +20 -15
- package/build/autocompleters/block.js +1 -1
- package/build/autocompleters/block.js.map +1 -1
- package/build/components/block-breadcrumb/index.js +3 -1
- package/build/components/block-breadcrumb/index.js.map +1 -1
- package/build/components/block-draggable/index.js +2 -2
- package/build/components/block-draggable/index.js.map +1 -1
- package/build/components/block-list/use-block-props/index.js +2 -2
- package/build/components/block-list/use-block-props/index.js.map +1 -1
- package/build/components/block-list/use-block-props/use-block-refs.js +24 -32
- package/build/components/block-list/use-block-props/use-block-refs.js.map +1 -1
- package/build/components/block-list/use-in-between-inserter.js +11 -4
- package/build/components/block-list/use-in-between-inserter.js.map +1 -1
- package/build/components/block-mover/index.js +1 -2
- package/build/components/block-mover/index.js.map +1 -1
- package/build/components/block-popover/cover.js +1 -1
- package/build/components/block-popover/cover.js.map +1 -1
- package/build/components/block-popover/inbetween.js +2 -2
- package/build/components/block-popover/inbetween.js.map +1 -1
- package/build/components/block-popover/index.js +2 -2
- package/build/components/block-popover/index.js.map +1 -1
- package/build/components/block-settings-menu/block-mode-toggle.js +28 -34
- package/build/components/block-settings-menu/block-mode-toggle.js.map +1 -1
- package/build/components/block-tools/block-selection-button.js +1 -2
- package/build/components/block-tools/block-selection-button.js.map +1 -1
- package/build/components/block-tools/index.js +1 -1
- package/build/components/block-tools/index.js.map +1 -1
- package/build/components/block-tools/insertion-point.js +14 -3
- package/build/components/block-tools/insertion-point.js.map +1 -1
- package/build/components/block-tools/use-block-toolbar-popover-props.js +1 -1
- package/build/components/block-tools/use-block-toolbar-popover-props.js.map +1 -1
- package/build/components/block-tools/use-show-block-tools.js +2 -1
- package/build/components/block-tools/use-show-block-tools.js.map +1 -1
- package/build/components/block-tools/zoom-out-mode-inserters.js +22 -19
- package/build/components/block-tools/zoom-out-mode-inserters.js.map +1 -1
- package/build/components/block-tools/zoom-out-toolbar.js +0 -1
- package/build/components/block-tools/zoom-out-toolbar.js.map +1 -1
- package/build/components/border-radius-control/index.js +1 -0
- package/build/components/border-radius-control/index.js.map +1 -1
- package/build/components/child-layout-control/index.js +3 -1
- package/build/components/child-layout-control/index.js.map +1 -1
- package/build/components/convert-to-group-buttons/index.js +1 -1
- package/build/components/convert-to-group-buttons/index.js.map +1 -1
- package/build/components/date-format-picker/index.js +2 -0
- package/build/components/date-format-picker/index.js.map +1 -1
- package/build/components/dimensions-tool/scale-tool.js +1 -0
- package/build/components/dimensions-tool/scale-tool.js.map +1 -1
- package/build/components/font-appearance-control/index.js +3 -0
- package/build/components/font-appearance-control/index.js.map +1 -1
- package/build/components/font-family/index.js +15 -0
- package/build/components/font-family/index.js.map +1 -1
- package/build/components/global-styles/background-panel.js +153 -77
- package/build/components/global-styles/background-panel.js.map +1 -1
- package/build/components/global-styles/get-global-styles-changes.js +3 -1
- package/build/components/global-styles/get-global-styles-changes.js.map +1 -1
- package/build/components/global-styles/hooks.js +0 -7
- package/build/components/global-styles/hooks.js.map +1 -1
- package/build/components/global-styles/image-settings-panel.js +1 -0
- package/build/components/global-styles/image-settings-panel.js.map +1 -1
- package/build/components/global-styles/index.js +0 -6
- package/build/components/global-styles/index.js.map +1 -1
- package/build/components/global-styles/typography-panel.js +0 -1
- package/build/components/global-styles/typography-panel.js.map +1 -1
- package/build/components/global-styles/use-global-styles-output.js +59 -40
- package/build/components/global-styles/use-global-styles-output.js.map +1 -1
- package/build/components/global-styles/utils.js +80 -0
- package/build/components/global-styles/utils.js.map +1 -1
- package/build/components/grid/grid-item-movers.js +30 -26
- package/build/components/grid/grid-item-movers.js.map +1 -1
- package/build/components/grid/grid-item-resizer.js +14 -15
- package/build/components/grid/grid-item-resizer.js.map +1 -1
- package/build/components/grid/grid-visualizer.js +21 -6
- package/build/components/grid/grid-visualizer.js.map +1 -1
- package/build/components/grid/use-grid-layout-sync.js +56 -20
- package/build/components/grid/use-grid-layout-sync.js.map +1 -1
- package/build/components/height-control/index.js +1 -0
- package/build/components/height-control/index.js.map +1 -1
- package/build/components/iframe/index.js +2 -4
- package/build/components/iframe/index.js.map +1 -1
- package/build/components/image-editor/zoom-dropdown.js +11 -7
- package/build/components/image-editor/zoom-dropdown.js.map +1 -1
- package/build/components/inner-blocks/button-block-appender.js +8 -8
- package/build/components/inner-blocks/button-block-appender.js.map +1 -1
- package/build/components/inner-blocks/default-block-appender.js +7 -25
- package/build/components/inner-blocks/default-block-appender.js.map +1 -1
- package/build/components/inner-blocks/index.js +9 -11
- package/build/components/inner-blocks/index.js.map +1 -1
- package/build/components/inserter/category-tabs/index.js +29 -2
- package/build/components/inserter/category-tabs/index.js.map +1 -1
- package/build/components/inserter/library.js +4 -2
- package/build/components/inserter/library.js.map +1 -1
- package/build/components/inserter/menu.js +32 -14
- package/build/components/inserter/menu.js.map +1 -1
- package/build/components/inserter/quick-inserter.js +4 -0
- package/build/components/inserter/quick-inserter.js.map +1 -1
- package/build/components/line-height-control/index.js +3 -15
- package/build/components/line-height-control/index.js.map +1 -1
- package/build/components/link-control/search-input.js +0 -1
- package/build/components/link-control/search-input.js.map +1 -1
- package/build/components/media-placeholder/index.js +9 -4
- package/build/components/media-placeholder/index.js.map +1 -1
- package/build/components/media-replace-flow/index.js +3 -1
- package/build/components/media-replace-flow/index.js.map +1 -1
- package/build/components/media-upload/index.native.js +4 -1
- package/build/components/media-upload/index.native.js.map +1 -1
- package/build/components/multi-selection-inspector/index.js +12 -12
- package/build/components/multi-selection-inspector/index.js.map +1 -1
- package/build/components/resolution-tool/index.js +1 -0
- package/build/components/resolution-tool/index.js.map +1 -1
- package/build/components/skip-to-selected-block/index.js +4 -2
- package/build/components/skip-to-selected-block/index.js.map +1 -1
- package/build/components/spacing-sizes-control/input-controls/spacing-input-control.js +8 -8
- package/build/components/spacing-sizes-control/input-controls/spacing-input-control.js.map +1 -1
- package/build/components/text-alignment-control/index.js +13 -8
- package/build/components/text-alignment-control/index.js.map +1 -1
- package/build/components/text-decoration-control/index.js +13 -8
- package/build/components/text-decoration-control/index.js.map +1 -1
- package/build/components/text-transform-control/index.js +13 -8
- package/build/components/text-transform-control/index.js.map +1 -1
- package/build/components/url-input/button.js +0 -1
- package/build/components/url-input/button.js.map +1 -1
- package/build/components/url-input/index.js +1 -11
- package/build/components/url-input/index.js.map +1 -1
- package/build/components/url-popover/image-url-input-ui.js +2 -0
- package/build/components/url-popover/image-url-input-ui.js.map +1 -1
- package/build/components/url-popover/link-editor.js +0 -1
- package/build/components/url-popover/link-editor.js.map +1 -1
- package/build/components/use-block-drop-zone/index.js +42 -4
- package/build/components/use-block-drop-zone/index.js.map +1 -1
- package/build/components/use-on-block-drop/index.js +3 -6
- package/build/components/use-on-block-drop/index.js.map +1 -1
- package/build/components/use-resize-canvas/index.js +1 -3
- package/build/components/use-resize-canvas/index.js.map +1 -1
- package/build/components/use-settings/index.js +2 -1
- package/build/components/use-settings/index.js.map +1 -1
- package/build/components/writing-mode-control/index.js +13 -8
- package/build/components/writing-mode-control/index.js.map +1 -1
- package/build/hooks/background.js +19 -23
- package/build/hooks/background.js.map +1 -1
- package/build/hooks/block-bindings.js +209 -39
- package/build/hooks/block-bindings.js.map +1 -1
- package/build/hooks/block-hooks.js +1 -0
- package/build/hooks/block-hooks.js.map +1 -1
- package/build/hooks/block-style-variation.js +2 -2
- package/build/hooks/block-style-variation.js.map +1 -1
- package/build/hooks/contrast-checker.js +6 -6
- package/build/hooks/contrast-checker.js.map +1 -1
- package/build/hooks/duotone.js +3 -3
- package/build/hooks/duotone.js.map +1 -1
- package/build/hooks/index.js +7 -1
- package/build/hooks/index.js.map +1 -1
- package/build/hooks/line-height.js +0 -1
- package/build/hooks/line-height.js.map +1 -1
- package/build/hooks/spacing-visualizer.js +1 -1
- package/build/hooks/spacing-visualizer.js.map +1 -1
- package/build/hooks/use-bindings-attributes.js +4 -0
- package/build/hooks/use-bindings-attributes.js.map +1 -1
- package/build/hooks/use-zoom-out.js +1 -1
- package/build/hooks/use-zoom-out.js.map +1 -1
- package/build/hooks/utils.js +20 -0
- package/build/hooks/utils.js.map +1 -1
- package/build/index.js +7 -0
- package/build/index.js.map +1 -1
- package/build/layouts/constrained.js +1 -0
- package/build/layouts/constrained.js.map +1 -1
- package/build/layouts/flex.js +2 -0
- package/build/layouts/flex.js.map +1 -1
- package/build/layouts/grid.js +3 -0
- package/build/layouts/grid.js.map +1 -1
- package/build/private-apis.js +3 -2
- package/build/private-apis.js.map +1 -1
- package/build/store/actions.js +9 -1
- package/build/store/actions.js.map +1 -1
- package/build/store/private-selectors.js +30 -0
- package/build/store/private-selectors.js.map +1 -1
- package/build/store/reducer.js +10 -1
- package/build/store/reducer.js.map +1 -1
- package/build/store/selectors.js +4 -4
- package/build/store/selectors.js.map +1 -1
- package/build/utils/block-bindings.js +112 -0
- package/build/utils/block-bindings.js.map +1 -0
- package/build/utils/get-editor-region.js +1 -1
- package/build/utils/get-editor-region.js.map +1 -1
- package/build/utils/get-px-from-css-unit.js +1 -1
- package/build/utils/get-px-from-css-unit.js.map +1 -1
- package/build-module/autocompleters/block.js +1 -1
- package/build-module/autocompleters/block.js.map +1 -1
- package/build-module/components/block-breadcrumb/index.js +4 -2
- package/build-module/components/block-breadcrumb/index.js.map +1 -1
- package/build-module/components/block-draggable/index.js +3 -3
- package/build-module/components/block-draggable/index.js.map +1 -1
- package/build-module/components/block-list/use-block-props/index.js +2 -2
- package/build-module/components/block-list/use-block-props/index.js.map +1 -1
- package/build-module/components/block-list/use-block-props/use-block-refs.js +24 -34
- package/build-module/components/block-list/use-block-props/use-block-refs.js.map +1 -1
- package/build-module/components/block-list/use-in-between-inserter.js +11 -4
- package/build-module/components/block-list/use-in-between-inserter.js.map +1 -1
- package/build-module/components/block-mover/index.js +1 -2
- package/build-module/components/block-mover/index.js.map +1 -1
- package/build-module/components/block-popover/cover.js +1 -1
- package/build-module/components/block-popover/cover.js.map +1 -1
- package/build-module/components/block-popover/inbetween.js +1 -1
- package/build-module/components/block-popover/inbetween.js.map +1 -1
- package/build-module/components/block-popover/index.js +1 -1
- package/build-module/components/block-popover/index.js.map +1 -1
- package/build-module/components/block-settings-menu/block-mode-toggle.js +29 -34
- package/build-module/components/block-settings-menu/block-mode-toggle.js.map +1 -1
- package/build-module/components/block-tools/block-selection-button.js +1 -2
- package/build-module/components/block-tools/block-selection-button.js.map +1 -1
- package/build-module/components/block-tools/index.js +1 -1
- package/build-module/components/block-tools/index.js.map +1 -1
- package/build-module/components/block-tools/insertion-point.js +14 -3
- package/build-module/components/block-tools/insertion-point.js.map +1 -1
- package/build-module/components/block-tools/use-block-toolbar-popover-props.js +1 -1
- package/build-module/components/block-tools/use-block-toolbar-popover-props.js.map +1 -1
- package/build-module/components/block-tools/use-show-block-tools.js +2 -1
- package/build-module/components/block-tools/use-show-block-tools.js.map +1 -1
- package/build-module/components/block-tools/zoom-out-mode-inserters.js +23 -20
- package/build-module/components/block-tools/zoom-out-mode-inserters.js.map +1 -1
- package/build-module/components/block-tools/zoom-out-toolbar.js +0 -1
- package/build-module/components/block-tools/zoom-out-toolbar.js.map +1 -1
- package/build-module/components/border-radius-control/index.js +1 -0
- package/build-module/components/border-radius-control/index.js.map +1 -1
- package/build-module/components/child-layout-control/index.js +3 -1
- package/build-module/components/child-layout-control/index.js.map +1 -1
- package/build-module/components/convert-to-group-buttons/index.js +1 -1
- package/build-module/components/convert-to-group-buttons/index.js.map +1 -1
- package/build-module/components/date-format-picker/index.js +2 -0
- package/build-module/components/date-format-picker/index.js.map +1 -1
- package/build-module/components/dimensions-tool/scale-tool.js +1 -0
- package/build-module/components/dimensions-tool/scale-tool.js.map +1 -1
- package/build-module/components/font-appearance-control/index.js +3 -0
- package/build-module/components/font-appearance-control/index.js.map +1 -1
- package/build-module/components/font-family/index.js +14 -0
- package/build-module/components/font-family/index.js.map +1 -1
- package/build-module/components/global-styles/background-panel.js +156 -80
- package/build-module/components/global-styles/background-panel.js.map +1 -1
- package/build-module/components/global-styles/get-global-styles-changes.js +3 -1
- package/build-module/components/global-styles/get-global-styles-changes.js.map +1 -1
- package/build-module/components/global-styles/hooks.js +0 -6
- package/build-module/components/global-styles/hooks.js.map +1 -1
- package/build-module/components/global-styles/image-settings-panel.js +1 -0
- package/build-module/components/global-styles/image-settings-panel.js.map +1 -1
- package/build-module/components/global-styles/index.js +1 -1
- package/build-module/components/global-styles/index.js.map +1 -1
- package/build-module/components/global-styles/typography-panel.js +0 -1
- package/build-module/components/global-styles/typography-panel.js.map +1 -1
- package/build-module/components/global-styles/use-global-styles-output.js +61 -42
- package/build-module/components/global-styles/use-global-styles-output.js.map +1 -1
- package/build-module/components/global-styles/utils.js +77 -0
- package/build-module/components/global-styles/utils.js.map +1 -1
- package/build-module/components/grid/grid-item-movers.js +30 -26
- package/build-module/components/grid/grid-item-movers.js.map +1 -1
- package/build-module/components/grid/grid-item-resizer.js +14 -15
- package/build-module/components/grid/grid-item-resizer.js.map +1 -1
- package/build-module/components/grid/grid-visualizer.js +21 -6
- package/build-module/components/grid/grid-visualizer.js.map +1 -1
- package/build-module/components/grid/use-grid-layout-sync.js +56 -20
- package/build-module/components/grid/use-grid-layout-sync.js.map +1 -1
- package/build-module/components/height-control/index.js +1 -0
- package/build-module/components/height-control/index.js.map +1 -1
- package/build-module/components/iframe/index.js +2 -4
- package/build-module/components/iframe/index.js.map +1 -1
- package/build-module/components/image-editor/zoom-dropdown.js +12 -8
- package/build-module/components/image-editor/zoom-dropdown.js.map +1 -1
- package/build-module/components/inner-blocks/button-block-appender.js +7 -6
- package/build-module/components/inner-blocks/button-block-appender.js.map +1 -1
- package/build-module/components/inner-blocks/default-block-appender.js +6 -23
- package/build-module/components/inner-blocks/default-block-appender.js.map +1 -1
- package/build-module/components/inner-blocks/index.js +9 -11
- package/build-module/components/inner-blocks/index.js.map +1 -1
- package/build-module/components/inserter/category-tabs/index.js +30 -3
- package/build-module/components/inserter/category-tabs/index.js.map +1 -1
- package/build-module/components/inserter/library.js +4 -2
- package/build-module/components/inserter/library.js.map +1 -1
- package/build-module/components/inserter/menu.js +32 -14
- package/build-module/components/inserter/menu.js.map +1 -1
- package/build-module/components/inserter/quick-inserter.js +5 -1
- package/build-module/components/inserter/quick-inserter.js.map +1 -1
- package/build-module/components/line-height-control/index.js +3 -14
- package/build-module/components/line-height-control/index.js.map +1 -1
- package/build-module/components/link-control/search-input.js +0 -1
- package/build-module/components/link-control/search-input.js.map +1 -1
- package/build-module/components/media-placeholder/index.js +9 -4
- package/build-module/components/media-placeholder/index.js.map +1 -1
- package/build-module/components/media-replace-flow/index.js +3 -1
- package/build-module/components/media-replace-flow/index.js.map +1 -1
- package/build-module/components/media-upload/index.native.js +4 -1
- package/build-module/components/media-upload/index.native.js.map +1 -1
- package/build-module/components/multi-selection-inspector/index.js +12 -12
- package/build-module/components/multi-selection-inspector/index.js.map +1 -1
- package/build-module/components/resolution-tool/index.js +1 -0
- package/build-module/components/resolution-tool/index.js.map +1 -1
- package/build-module/components/skip-to-selected-block/index.js +5 -3
- package/build-module/components/skip-to-selected-block/index.js.map +1 -1
- package/build-module/components/spacing-sizes-control/input-controls/spacing-input-control.js +8 -8
- package/build-module/components/spacing-sizes-control/input-controls/spacing-input-control.js.map +1 -1
- package/build-module/components/text-alignment-control/index.js +13 -8
- package/build-module/components/text-alignment-control/index.js.map +1 -1
- package/build-module/components/text-decoration-control/index.js +13 -8
- package/build-module/components/text-decoration-control/index.js.map +1 -1
- package/build-module/components/text-transform-control/index.js +13 -8
- package/build-module/components/text-transform-control/index.js.map +1 -1
- package/build-module/components/url-input/button.js +0 -1
- package/build-module/components/url-input/button.js.map +1 -1
- package/build-module/components/url-input/index.js +1 -11
- package/build-module/components/url-input/index.js.map +1 -1
- package/build-module/components/url-popover/image-url-input-ui.js +2 -0
- package/build-module/components/url-popover/image-url-input-ui.js.map +1 -1
- package/build-module/components/url-popover/link-editor.js +0 -1
- package/build-module/components/url-popover/link-editor.js.map +1 -1
- package/build-module/components/use-block-drop-zone/index.js +42 -4
- package/build-module/components/use-block-drop-zone/index.js.map +1 -1
- package/build-module/components/use-on-block-drop/index.js +3 -6
- package/build-module/components/use-on-block-drop/index.js.map +1 -1
- package/build-module/components/use-resize-canvas/index.js +1 -3
- package/build-module/components/use-resize-canvas/index.js.map +1 -1
- package/build-module/components/use-settings/index.js +2 -1
- package/build-module/components/use-settings/index.js.map +1 -1
- package/build-module/components/writing-mode-control/index.js +13 -8
- package/build-module/components/writing-mode-control/index.js.map +1 -1
- package/build-module/hooks/background.js +19 -23
- package/build-module/hooks/background.js.map +1 -1
- package/build-module/hooks/block-bindings.js +214 -43
- package/build-module/hooks/block-bindings.js.map +1 -1
- package/build-module/hooks/block-hooks.js +1 -0
- package/build-module/hooks/block-hooks.js.map +1 -1
- package/build-module/hooks/block-style-variation.js +3 -3
- package/build-module/hooks/block-style-variation.js.map +1 -1
- package/build-module/hooks/contrast-checker.js +7 -7
- package/build-module/hooks/contrast-checker.js.map +1 -1
- package/build-module/hooks/duotone.js +4 -4
- package/build-module/hooks/duotone.js.map +1 -1
- package/build-module/hooks/index.js +2 -1
- package/build-module/hooks/index.js.map +1 -1
- package/build-module/hooks/line-height.js +0 -1
- package/build-module/hooks/line-height.js.map +1 -1
- package/build-module/hooks/spacing-visualizer.js +1 -1
- package/build-module/hooks/spacing-visualizer.js.map +1 -1
- package/build-module/hooks/use-bindings-attributes.js +3 -0
- package/build-module/hooks/use-bindings-attributes.js.map +1 -1
- package/build-module/hooks/use-zoom-out.js +1 -1
- package/build-module/hooks/use-zoom-out.js.map +1 -1
- package/build-module/hooks/utils.js +19 -0
- package/build-module/hooks/utils.js.map +1 -1
- package/build-module/index.js +1 -1
- package/build-module/index.js.map +1 -1
- package/build-module/layouts/constrained.js +1 -0
- package/build-module/layouts/constrained.js.map +1 -1
- package/build-module/layouts/flex.js +2 -0
- package/build-module/layouts/flex.js.map +1 -1
- package/build-module/layouts/grid.js +3 -0
- package/build-module/layouts/grid.js.map +1 -1
- package/build-module/private-apis.js +4 -3
- package/build-module/private-apis.js.map +1 -1
- package/build-module/store/actions.js +9 -1
- package/build-module/store/actions.js.map +1 -1
- package/build-module/store/private-selectors.js +27 -0
- package/build-module/store/private-selectors.js.map +1 -1
- package/build-module/store/reducer.js +9 -1
- package/build-module/store/reducer.js.map +1 -1
- package/build-module/store/selectors.js +4 -4
- package/build-module/store/selectors.js.map +1 -1
- package/build-module/utils/block-bindings.js +105 -0
- package/build-module/utils/block-bindings.js.map +1 -0
- package/build-module/utils/get-editor-region.js +1 -1
- package/build-module/utils/get-editor-region.js.map +1 -1
- package/build-module/utils/get-px-from-css-unit.js +1 -1
- package/build-module/utils/get-px-from-css-unit.js.map +1 -1
- package/build-style/content-rtl.css +12 -26
- package/build-style/content.css +12 -26
- package/build-style/default-editor-styles-rtl.css +5 -2
- package/build-style/default-editor-styles.css +5 -2
- package/build-style/style-rtl.css +123 -83
- package/build-style/style.css +123 -83
- package/package.json +32 -32
- package/src/autocompleters/block.js +2 -1
- package/src/autocompleters/style.scss +4 -0
- package/src/components/block-breadcrumb/index.js +4 -2
- package/src/components/block-canvas/style.scss +1 -0
- package/src/components/block-draggable/index.js +3 -3
- package/src/components/block-list/content.scss +5 -13
- package/src/components/block-list/use-block-props/index.js +2 -2
- package/src/components/block-list/use-block-props/use-block-refs.js +27 -43
- package/src/components/block-list/use-in-between-inserter.js +17 -5
- package/src/components/block-mover/index.js +5 -2
- package/src/components/block-popover/cover.js +1 -1
- package/src/components/block-popover/inbetween.js +1 -1
- package/src/components/block-popover/index.js +1 -1
- package/src/components/block-settings-menu/block-mode-toggle.js +28 -31
- package/src/components/block-settings-menu/test/block-mode-toggle.js +26 -23
- package/src/components/block-tools/block-selection-button.js +1 -2
- package/src/components/block-tools/index.js +5 -6
- package/src/components/block-tools/insertion-point.js +11 -0
- package/src/components/block-tools/style.scss +1 -1
- package/src/components/block-tools/use-block-toolbar-popover-props.js +1 -1
- package/src/components/block-tools/use-show-block-tools.js +4 -1
- package/src/components/block-tools/zoom-out-mode-inserters.js +21 -19
- package/src/components/block-tools/zoom-out-toolbar.js +0 -1
- package/src/components/block-variation-transforms/style.scss +1 -1
- package/src/components/border-radius-control/index.js +1 -0
- package/src/components/border-radius-control/style.scss +0 -10
- package/src/components/button-block-appender/content.scss +1 -1
- package/src/components/child-layout-control/index.js +2 -0
- package/src/components/color-palette/test/__snapshots__/control.js.snap +2 -2
- package/src/components/colors-gradients/test/control.js +3 -2
- package/src/components/convert-to-group-buttons/index.js +1 -1
- package/src/components/date-format-picker/index.js +2 -0
- package/src/components/dimensions-tool/scale-tool.js +1 -0
- package/src/components/font-appearance-control/index.js +3 -0
- package/src/components/font-family/README.md +17 -0
- package/src/components/font-family/index.js +19 -0
- package/src/components/font-family/stories/index.story.js +54 -0
- package/src/components/global-styles/background-panel.js +180 -93
- package/src/components/global-styles/get-global-styles-changes.js +4 -1
- package/src/components/global-styles/hooks.js +0 -5
- package/src/components/global-styles/image-settings-panel.js +1 -0
- package/src/components/global-styles/index.js +0 -1
- package/src/components/global-styles/style.scss +13 -12
- package/src/components/global-styles/test/use-global-styles-output.js +68 -7
- package/src/components/global-styles/test/utils.js +120 -0
- package/src/components/global-styles/typography-panel.js +0 -1
- package/src/components/global-styles/use-global-styles-output.js +71 -53
- package/src/components/global-styles/utils.js +90 -0
- package/src/components/grid/grid-item-movers.js +46 -44
- package/src/components/grid/grid-item-resizer.js +11 -17
- package/src/components/grid/grid-visualizer.js +23 -8
- package/src/components/grid/style.scss +60 -10
- package/src/components/grid/use-grid-layout-sync.js +68 -14
- package/src/components/height-control/index.js +1 -0
- package/src/components/iframe/content.scss +2 -2
- package/src/components/iframe/index.js +1 -3
- package/src/components/image-editor/zoom-dropdown.js +17 -9
- package/src/components/inner-blocks/button-block-appender.js +5 -7
- package/src/components/inner-blocks/default-block-appender.js +4 -23
- package/src/components/inner-blocks/index.js +10 -9
- package/src/components/inserter/category-tabs/index.js +35 -2
- package/src/components/inserter/library.js +2 -0
- package/src/components/inserter/menu.js +34 -29
- package/src/components/inserter/quick-inserter.js +4 -1
- package/src/components/inserter/style.scss +17 -12
- package/src/components/inserter-list-item/style.scss +1 -0
- package/src/components/inspector-controls/README.md +5 -0
- package/src/components/line-height-control/README.md +4 -5
- package/src/components/line-height-control/index.js +4 -21
- package/src/components/line-height-control/stories/index.story.js +0 -1
- package/src/components/line-height-control/test/index.js +1 -7
- package/src/components/link-control/search-input.js +0 -1
- package/src/components/link-control/style.scss +1 -1
- package/src/components/media-placeholder/index.js +12 -7
- package/src/components/media-replace-flow/README.md +7 -0
- package/src/components/media-replace-flow/index.js +3 -1
- package/src/components/media-upload/README.md +2 -0
- package/src/components/media-upload/index.native.js +2 -0
- package/src/components/multi-selection-inspector/index.js +8 -9
- package/src/components/resolution-tool/index.js +1 -0
- package/src/components/responsive-block-control/README.md +1 -0
- package/src/components/responsive-block-control/test/index.js +6 -1
- package/src/components/skip-to-selected-block/index.js +5 -3
- package/src/components/spacing-sizes-control/input-controls/spacing-input-control.js +11 -10
- package/src/components/spacing-sizes-control/style.scss +16 -16
- package/src/components/tabbed-sidebar/style.scss +1 -19
- package/src/components/text-alignment-control/index.js +20 -8
- package/src/components/text-decoration-control/index.js +20 -8
- package/src/components/text-decoration-control/stories/index.story.js +0 -4
- package/src/components/text-transform-control/index.js +20 -8
- package/src/components/text-transform-control/stories/index.story.js +0 -4
- package/src/components/url-input/README.md +0 -5
- package/src/components/url-input/button.js +0 -1
- package/src/components/url-input/index.js +1 -15
- package/src/components/url-input/style.scss +2 -2
- package/src/components/url-popover/image-url-input-ui.js +2 -0
- package/src/components/url-popover/link-editor.js +0 -1
- package/src/components/use-block-drop-zone/index.js +86 -16
- package/src/components/use-on-block-drop/index.js +1 -9
- package/src/components/use-resize-canvas/index.js +1 -3
- package/src/components/use-settings/index.js +2 -1
- package/src/components/writing-mode-control/index.js +20 -8
- package/src/hooks/background.js +21 -27
- package/src/hooks/block-bindings.js +248 -54
- package/src/hooks/block-bindings.scss +13 -2
- package/src/hooks/block-hooks.js +1 -0
- package/src/hooks/block-hooks.scss +1 -0
- package/src/hooks/block-style-variation.js +3 -3
- package/src/hooks/contrast-checker.js +7 -7
- package/src/hooks/duotone.js +4 -4
- package/src/hooks/index.js +2 -1
- package/src/hooks/line-height.js +0 -1
- package/src/hooks/spacing-visualizer.js +1 -1
- package/src/hooks/test/background.js +60 -0
- package/src/hooks/use-bindings-attributes.js +4 -0
- package/src/hooks/use-editor-wrapper-styles.native.scss +1 -0
- package/src/hooks/use-zoom-out.js +1 -1
- package/src/hooks/utils.js +14 -1
- package/src/index.js +1 -0
- package/src/layouts/constrained.js +1 -0
- package/src/layouts/flex.js +2 -0
- package/src/layouts/grid.js +3 -0
- package/src/private-apis.js +3 -2
- package/src/store/actions.js +13 -5
- package/src/store/private-selectors.js +36 -0
- package/src/store/reducer.js +7 -0
- package/src/store/selectors.js +4 -4
- package/src/store/test/private-selectors.js +89 -0
- package/src/style.scss +1 -2
- package/src/utils/block-bindings.js +98 -0
- package/src/utils/get-editor-region.js +1 -1
- package/src/utils/get-px-from-css-unit.js +1 -1
- package/src/utils/test/transform-styles.js +49 -0
- package/tsconfig.tsbuildinfo +1 -1
- package/build/components/global-styles/theme-file-uri-utils.js +0 -80
- package/build/components/global-styles/theme-file-uri-utils.js.map +0 -1
- package/build/components/inner-blocks/with-client-id.js +0 -28
- package/build/components/inner-blocks/with-client-id.js.map +0 -1
- package/build/components/inserter/block-patterns-tab/pattern-category-preview-panel.js +0 -30
- package/build/components/inserter/block-patterns-tab/pattern-category-preview-panel.js.map +0 -1
- package/build/components/segmented-text-control/index.js +0 -63
- package/build/components/segmented-text-control/index.js.map +0 -1
- package/build-module/components/global-styles/theme-file-uri-utils.js +0 -73
- package/build-module/components/global-styles/theme-file-uri-utils.js.map +0 -1
- package/build-module/components/inner-blocks/with-client-id.js +0 -21
- package/build-module/components/inner-blocks/with-client-id.js.map +0 -1
- package/build-module/components/inserter/block-patterns-tab/pattern-category-preview-panel.js +0 -23
- package/build-module/components/inserter/block-patterns-tab/pattern-category-preview-panel.js.map +0 -1
- package/build-module/components/segmented-text-control/index.js +0 -58
- package/build-module/components/segmented-text-control/index.js.map +0 -1
- package/src/components/global-styles/test/theme-file-uri-utils.js +0 -66
- package/src/components/global-styles/theme-file-uri-utils.js +0 -77
- package/src/components/inner-blocks/with-client-id.js +0 -19
- package/src/components/inserter/block-patterns-tab/pattern-category-preview-panel.js +0 -25
- package/src/components/segmented-text-control/index.js +0 -63
- package/src/components/segmented-text-control/style.scss +0 -15
|
@@ -14,7 +14,7 @@ import isShallowEqual from '@wordpress/is-shallow-equal';
|
|
|
14
14
|
* Internal dependencies
|
|
15
15
|
*/
|
|
16
16
|
import BlockPopoverCover from '../components/block-popover/cover';
|
|
17
|
-
import {
|
|
17
|
+
import { useBlockElement } from '../components/block-list/use-block-props/use-block-refs';
|
|
18
18
|
|
|
19
19
|
function SpacingVisualizer( { clientId, value, computeStyle, forceShow } ) {
|
|
20
20
|
const blockElement = useBlockElement( clientId );
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Internal dependencies
|
|
3
|
+
*/
|
|
4
|
+
import {
|
|
5
|
+
setBackgroundStyleDefaults,
|
|
6
|
+
BACKGROUND_BLOCK_DEFAULT_VALUES,
|
|
7
|
+
} from '../background';
|
|
8
|
+
|
|
9
|
+
describe( 'background', () => {
|
|
10
|
+
describe( 'setBackgroundStyleDefaults', () => {
|
|
11
|
+
const backgroundStyles = {
|
|
12
|
+
backgroundImage: { id: 123, url: 'image.png' },
|
|
13
|
+
};
|
|
14
|
+
const backgroundStylesContain = {
|
|
15
|
+
backgroundImage: { id: 123, url: 'image.png' },
|
|
16
|
+
backgroundSize: 'contain',
|
|
17
|
+
};
|
|
18
|
+
const backgroundStylesNoURL = { backgroundImage: { id: 123 } };
|
|
19
|
+
it.each( [
|
|
20
|
+
[
|
|
21
|
+
'return background size default',
|
|
22
|
+
backgroundStyles,
|
|
23
|
+
{
|
|
24
|
+
backgroundSize:
|
|
25
|
+
BACKGROUND_BLOCK_DEFAULT_VALUES.backgroundSize,
|
|
26
|
+
},
|
|
27
|
+
],
|
|
28
|
+
[ 'return early if no styles are passed', undefined, undefined ],
|
|
29
|
+
[
|
|
30
|
+
'return early if images has no id',
|
|
31
|
+
backgroundStylesNoURL,
|
|
32
|
+
undefined,
|
|
33
|
+
],
|
|
34
|
+
[
|
|
35
|
+
'return early if images has no URL',
|
|
36
|
+
backgroundStylesNoURL,
|
|
37
|
+
undefined,
|
|
38
|
+
],
|
|
39
|
+
[
|
|
40
|
+
'return background position default',
|
|
41
|
+
backgroundStylesContain,
|
|
42
|
+
{
|
|
43
|
+
backgroundPosition:
|
|
44
|
+
BACKGROUND_BLOCK_DEFAULT_VALUES.backgroundPosition,
|
|
45
|
+
},
|
|
46
|
+
],
|
|
47
|
+
[
|
|
48
|
+
'not apply background position value if one already exists in styles',
|
|
49
|
+
{
|
|
50
|
+
...backgroundStylesContain,
|
|
51
|
+
backgroundPosition: 'center',
|
|
52
|
+
},
|
|
53
|
+
undefined,
|
|
54
|
+
],
|
|
55
|
+
] )( 'should %s', ( message, styles, expected ) => {
|
|
56
|
+
const result = setBackgroundStyleDefaults( styles );
|
|
57
|
+
expect( result ).toEqual( expected );
|
|
58
|
+
} );
|
|
59
|
+
} );
|
|
60
|
+
} );
|
|
@@ -91,6 +91,10 @@ export function canBindAttribute( blockName, attributeName ) {
|
|
|
91
91
|
);
|
|
92
92
|
}
|
|
93
93
|
|
|
94
|
+
export function getBindableAttributes( blockName ) {
|
|
95
|
+
return BLOCK_BINDINGS_ALLOWED_BLOCKS[ blockName ];
|
|
96
|
+
}
|
|
97
|
+
|
|
94
98
|
export const withBlockBindingSupport = createHigherOrderComponent(
|
|
95
99
|
( BlockEdit ) => ( props ) => {
|
|
96
100
|
const registry = useRegistry();
|
|
@@ -49,5 +49,5 @@ export function useZoomOut( zoomOut = true ) {
|
|
|
49
49
|
) {
|
|
50
50
|
__unstableSetEditorMode( originalEditingMode.current );
|
|
51
51
|
}
|
|
52
|
-
}, [ __unstableSetEditorMode, zoomOut
|
|
52
|
+
}, [ __unstableGetEditorMode, __unstableSetEditorMode, zoomOut ] ); // Mode is deliberately excluded from the dependencies so that the effect does not run when mode changes.
|
|
53
53
|
}
|
package/src/hooks/utils.js
CHANGED
|
@@ -135,7 +135,20 @@ export function shouldSkipSerialization(
|
|
|
135
135
|
|
|
136
136
|
const pendingStyleOverrides = new WeakMap();
|
|
137
137
|
|
|
138
|
-
|
|
138
|
+
/**
|
|
139
|
+
* Override a block editor settings style. Leave the ID blank to create a new
|
|
140
|
+
* style.
|
|
141
|
+
*
|
|
142
|
+
* @param {Object} override Override object.
|
|
143
|
+
* @param {?string} override.id Id of the style override, leave blank to create
|
|
144
|
+
* a new style.
|
|
145
|
+
* @param {string} override.css CSS to apply.
|
|
146
|
+
*/
|
|
147
|
+
export function useStyleOverride( { id, css } ) {
|
|
148
|
+
return usePrivateStyleOverride( { id, css } );
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
export function usePrivateStyleOverride( {
|
|
139
152
|
id,
|
|
140
153
|
css,
|
|
141
154
|
assets,
|
package/src/index.js
CHANGED
package/src/layouts/flex.js
CHANGED
|
@@ -325,6 +325,7 @@ function FlexLayoutJustifyContentControl( {
|
|
|
325
325
|
|
|
326
326
|
return (
|
|
327
327
|
<ToggleGroupControl
|
|
328
|
+
__next40pxDefaultSize
|
|
328
329
|
__nextHasNoMarginBottom
|
|
329
330
|
label={ __( 'Justification' ) }
|
|
330
331
|
value={ justifyContent }
|
|
@@ -370,6 +371,7 @@ function OrientationControl( { layout, onChange } ) {
|
|
|
370
371
|
} = layout;
|
|
371
372
|
return (
|
|
372
373
|
<ToggleGroupControl
|
|
374
|
+
__next40pxDefaultSize
|
|
373
375
|
__nextHasNoMarginBottom
|
|
374
376
|
className="block-editor-hooks__flex-layout-orientation-controls"
|
|
375
377
|
label={ __( 'Orientation' ) }
|
package/src/layouts/grid.js
CHANGED
|
@@ -264,6 +264,7 @@ function GridLayoutMinimumWidthControl( { layout, onChange } ) {
|
|
|
264
264
|
</FlexItem>
|
|
265
265
|
<FlexItem isBlock>
|
|
266
266
|
<RangeControl
|
|
267
|
+
__next40pxDefaultSize
|
|
267
268
|
__nextHasNoMarginBottom
|
|
268
269
|
onChange={ handleSliderChange }
|
|
269
270
|
value={ quantity || 0 }
|
|
@@ -368,6 +369,7 @@ function GridLayoutColumnsAndRowsControl( {
|
|
|
368
369
|
/>
|
|
369
370
|
) : (
|
|
370
371
|
<RangeControl
|
|
372
|
+
__next40pxDefaultSize
|
|
371
373
|
__nextHasNoMarginBottom
|
|
372
374
|
value={ columnCount ?? 0 }
|
|
373
375
|
onChange={ ( value ) =>
|
|
@@ -449,6 +451,7 @@ function GridLayoutTypeControl( { layout, onChange } ) {
|
|
|
449
451
|
|
|
450
452
|
return (
|
|
451
453
|
<ToggleGroupControl
|
|
454
|
+
__next40pxDefaultSize
|
|
452
455
|
__nextHasNoMarginBottom
|
|
453
456
|
label={ __( 'Grid item position' ) }
|
|
454
457
|
value={ gridPlacement }
|
package/src/private-apis.js
CHANGED
|
@@ -16,7 +16,7 @@ import {
|
|
|
16
16
|
import { PrivateListView } from './components/list-view';
|
|
17
17
|
import BlockInfo from './components/block-info-slot-fill';
|
|
18
18
|
import { useHasBlockToolbar } from './components/block-toolbar/use-has-block-toolbar';
|
|
19
|
-
import { cleanEmptyObject
|
|
19
|
+
import { cleanEmptyObject } from './hooks/utils';
|
|
20
20
|
import BlockQuickNavigation from './components/block-quick-navigation';
|
|
21
21
|
import { LayoutStyle } from './components/block-list/layout';
|
|
22
22
|
import { BlockRemovalWarningModal } from './components/block-removal-warning-modal';
|
|
@@ -47,6 +47,7 @@ import { PrivatePublishDateTimePicker } from './components/publish-date-time-pic
|
|
|
47
47
|
import useSpacingSizes from './components/spacing-sizes-control/hooks/use-spacing-sizes';
|
|
48
48
|
import useBlockDisplayTitle from './components/block-title/use-block-display-title';
|
|
49
49
|
import TabbedSidebar from './components/tabbed-sidebar';
|
|
50
|
+
import { useBlockBindingsUtils } from './utils/block-bindings';
|
|
50
51
|
|
|
51
52
|
/**
|
|
52
53
|
* Private @wordpress/block-editor APIs.
|
|
@@ -68,7 +69,6 @@ lock( privateApis, {
|
|
|
68
69
|
BlockInfo,
|
|
69
70
|
useHasBlockToolbar,
|
|
70
71
|
cleanEmptyObject,
|
|
71
|
-
useStyleOverride,
|
|
72
72
|
BlockQuickNavigation,
|
|
73
73
|
LayoutStyle,
|
|
74
74
|
BlockRemovalWarningModal,
|
|
@@ -93,4 +93,5 @@ lock( privateApis, {
|
|
|
93
93
|
useBlockDisplayTitle,
|
|
94
94
|
__unstableBlockStyleVariationOverridesWithConfig,
|
|
95
95
|
setBackgroundStyleDefaults,
|
|
96
|
+
useBlockBindingsUtils,
|
|
96
97
|
} );
|
package/src/store/actions.js
CHANGED
|
@@ -1683,11 +1683,19 @@ export const __unstableSetEditorMode =
|
|
|
1683
1683
|
if ( sectionRootClientId ) {
|
|
1684
1684
|
const sectionClientIds =
|
|
1685
1685
|
select.getBlockOrder( sectionRootClientId );
|
|
1686
|
-
|
|
1687
|
-
|
|
1688
|
-
|
|
1689
|
-
|
|
1690
|
-
|
|
1686
|
+
|
|
1687
|
+
// If the selected block is a section block, use it.
|
|
1688
|
+
if ( sectionClientIds?.includes( firstSelectedClientId ) ) {
|
|
1689
|
+
sectionClientId = firstSelectedClientId;
|
|
1690
|
+
} else {
|
|
1691
|
+
// If the selected block is not a section block, find
|
|
1692
|
+
// the parent section that contains the selected block.
|
|
1693
|
+
sectionClientId = select
|
|
1694
|
+
.getBlockParents( firstSelectedClientId )
|
|
1695
|
+
.find( ( parent ) =>
|
|
1696
|
+
sectionClientIds.includes( parent )
|
|
1697
|
+
);
|
|
1698
|
+
}
|
|
1691
1699
|
} else {
|
|
1692
1700
|
sectionClientId = select.getBlockHierarchyRootClientId(
|
|
1693
1701
|
firstSelectedClientId
|
|
@@ -511,3 +511,39 @@ export function getTemporarilyEditingAsBlocks( state ) {
|
|
|
511
511
|
export function getTemporarilyEditingFocusModeToRevert( state ) {
|
|
512
512
|
return state.temporarilyEditingFocusModeRevert;
|
|
513
513
|
}
|
|
514
|
+
|
|
515
|
+
export function getInserterSearchInputRef( state ) {
|
|
516
|
+
return state.inserterSearchInputRef;
|
|
517
|
+
}
|
|
518
|
+
|
|
519
|
+
/**
|
|
520
|
+
* Returns the style attributes of multiple blocks.
|
|
521
|
+
*
|
|
522
|
+
* @param {Object} state Global application state.
|
|
523
|
+
* @param {string[]} clientIds An array of block client IDs.
|
|
524
|
+
*
|
|
525
|
+
* @return {Object} An object where keys are client IDs and values are the corresponding block styles or undefined.
|
|
526
|
+
*/
|
|
527
|
+
export const getBlockStyles = createSelector(
|
|
528
|
+
( state, clientIds ) =>
|
|
529
|
+
clientIds.reduce( ( styles, clientId ) => {
|
|
530
|
+
styles[ clientId ] = state.blocks.attributes.get( clientId )?.style;
|
|
531
|
+
return styles;
|
|
532
|
+
}, {} ),
|
|
533
|
+
( state, clientIds ) => [
|
|
534
|
+
...clientIds.map(
|
|
535
|
+
( clientId ) => state.blocks.attributes.get( clientId )?.style
|
|
536
|
+
),
|
|
537
|
+
]
|
|
538
|
+
);
|
|
539
|
+
|
|
540
|
+
/**
|
|
541
|
+
* Returns whether zoom out mode is enabled.
|
|
542
|
+
*
|
|
543
|
+
* @param {Object} state Editor state.
|
|
544
|
+
*
|
|
545
|
+
* @return {boolean} Is zoom out mode enabled.
|
|
546
|
+
*/
|
|
547
|
+
export function isZoomOutMode( state ) {
|
|
548
|
+
return state.editorMode === 'zoom-out';
|
|
549
|
+
}
|
package/src/store/reducer.js
CHANGED
|
@@ -1624,6 +1624,8 @@ export function insertionPoint( state = null, action ) {
|
|
|
1624
1624
|
}
|
|
1625
1625
|
|
|
1626
1626
|
case 'HIDE_INSERTION_POINT':
|
|
1627
|
+
case 'CLEAR_SELECTED_BLOCK':
|
|
1628
|
+
case 'SELECT_BLOCK':
|
|
1627
1629
|
return null;
|
|
1628
1630
|
}
|
|
1629
1631
|
|
|
@@ -2085,6 +2087,10 @@ export function hoveredBlockClientId( state = false, action ) {
|
|
|
2085
2087
|
return state;
|
|
2086
2088
|
}
|
|
2087
2089
|
|
|
2090
|
+
export function inserterSearchInputRef( state = { current: null } ) {
|
|
2091
|
+
return state;
|
|
2092
|
+
}
|
|
2093
|
+
|
|
2088
2094
|
const combinedReducers = combineReducers( {
|
|
2089
2095
|
blocks,
|
|
2090
2096
|
isDragging,
|
|
@@ -2118,6 +2124,7 @@ const combinedReducers = combineReducers( {
|
|
|
2118
2124
|
openedBlockSettingsMenu,
|
|
2119
2125
|
registeredInserterMediaCategories,
|
|
2120
2126
|
hoveredBlockClientId,
|
|
2127
|
+
inserterSearchInputRef,
|
|
2121
2128
|
} );
|
|
2122
2129
|
|
|
2123
2130
|
function withAutomaticChangeReset( reducer ) {
|
package/src/store/selectors.js
CHANGED
|
@@ -334,8 +334,8 @@ export const getGlobalBlockCount = createSelector(
|
|
|
334
334
|
/**
|
|
335
335
|
* Returns all blocks that match a blockName. Results include nested blocks.
|
|
336
336
|
*
|
|
337
|
-
* @param {Object}
|
|
338
|
-
* @param {
|
|
337
|
+
* @param {Object} state Global application state.
|
|
338
|
+
* @param {string[]} blockName Block name(s) for which clientIds are to be returned.
|
|
339
339
|
*
|
|
340
340
|
* @return {Array} Array of clientIds of blocks with name equal to blockName.
|
|
341
341
|
*/
|
|
@@ -362,8 +362,8 @@ export const getBlocksByName = createSelector(
|
|
|
362
362
|
*
|
|
363
363
|
* @deprecated
|
|
364
364
|
*
|
|
365
|
-
* @param {Object}
|
|
366
|
-
* @param {
|
|
365
|
+
* @param {Object} state Global application state.
|
|
366
|
+
* @param {string[]} blockName Block name(s) for which clientIds are to be returned.
|
|
367
367
|
*
|
|
368
368
|
* @return {Array} Array of clientIds of blocks with name equal to blockName.
|
|
369
369
|
*/
|
|
@@ -9,6 +9,7 @@ import {
|
|
|
9
9
|
getEnabledBlockParents,
|
|
10
10
|
getExpandedBlock,
|
|
11
11
|
isDragging,
|
|
12
|
+
getBlockStyles,
|
|
12
13
|
} from '../private-selectors';
|
|
13
14
|
import { getBlockEditingMode } from '../selectors';
|
|
14
15
|
|
|
@@ -509,4 +510,92 @@ describe( 'private selectors', () => {
|
|
|
509
510
|
);
|
|
510
511
|
} );
|
|
511
512
|
} );
|
|
513
|
+
|
|
514
|
+
describe( 'getBlockStyles', () => {
|
|
515
|
+
it( 'should return an empty object when no client IDs are provided', () => {
|
|
516
|
+
const state = {
|
|
517
|
+
blocks: {
|
|
518
|
+
attributes: new Map(),
|
|
519
|
+
},
|
|
520
|
+
};
|
|
521
|
+
const result = getBlockStyles( state, [] );
|
|
522
|
+
expect( result ).toEqual( {} );
|
|
523
|
+
} );
|
|
524
|
+
|
|
525
|
+
it( 'should return styles for a single block', () => {
|
|
526
|
+
const state = {
|
|
527
|
+
blocks: {
|
|
528
|
+
attributes: new Map( [
|
|
529
|
+
[ 'block-1', { style: { color: 'red' } } ],
|
|
530
|
+
] ),
|
|
531
|
+
},
|
|
532
|
+
};
|
|
533
|
+
const result = getBlockStyles( state, [ 'block-1' ] );
|
|
534
|
+
expect( result ).toEqual( {
|
|
535
|
+
'block-1': { color: 'red' },
|
|
536
|
+
} );
|
|
537
|
+
} );
|
|
538
|
+
|
|
539
|
+
it( 'should return styles for multiple blocks', () => {
|
|
540
|
+
const state = {
|
|
541
|
+
blocks: {
|
|
542
|
+
attributes: new Map( [
|
|
543
|
+
[ 'block-1', { style: { color: 'red' } } ],
|
|
544
|
+
[ 'block-2', { style: { fontSize: '16px' } } ],
|
|
545
|
+
[ 'block-3', { style: { margin: '10px' } } ],
|
|
546
|
+
] ),
|
|
547
|
+
},
|
|
548
|
+
};
|
|
549
|
+
const result = getBlockStyles( state, [
|
|
550
|
+
'block-1',
|
|
551
|
+
'block-2',
|
|
552
|
+
'block-3',
|
|
553
|
+
] );
|
|
554
|
+
expect( result ).toEqual( {
|
|
555
|
+
'block-1': { color: 'red' },
|
|
556
|
+
'block-2': { fontSize: '16px' },
|
|
557
|
+
'block-3': { margin: '10px' },
|
|
558
|
+
} );
|
|
559
|
+
} );
|
|
560
|
+
|
|
561
|
+
it( 'should return undefined for blocks without styles', () => {
|
|
562
|
+
const state = {
|
|
563
|
+
blocks: {
|
|
564
|
+
attributes: new Map( [
|
|
565
|
+
[ 'block-1', { style: { color: 'red' } } ],
|
|
566
|
+
[ 'block-2', {} ],
|
|
567
|
+
[ 'block-3', { style: { margin: '10px' } } ],
|
|
568
|
+
] ),
|
|
569
|
+
},
|
|
570
|
+
};
|
|
571
|
+
const result = getBlockStyles( state, [
|
|
572
|
+
'block-1',
|
|
573
|
+
'block-2',
|
|
574
|
+
'block-3',
|
|
575
|
+
] );
|
|
576
|
+
expect( result ).toEqual( {
|
|
577
|
+
'block-1': { color: 'red' },
|
|
578
|
+
'block-2': undefined,
|
|
579
|
+
'block-3': { margin: '10px' },
|
|
580
|
+
} );
|
|
581
|
+
} );
|
|
582
|
+
|
|
583
|
+
it( 'should return undefined for non-existent blocks', () => {
|
|
584
|
+
const state = {
|
|
585
|
+
blocks: {
|
|
586
|
+
attributes: new Map( [
|
|
587
|
+
[ 'block-1', { style: { color: 'red' } } ],
|
|
588
|
+
] ),
|
|
589
|
+
},
|
|
590
|
+
};
|
|
591
|
+
const result = getBlockStyles( state, [
|
|
592
|
+
'block-1',
|
|
593
|
+
'non-existent-block',
|
|
594
|
+
] );
|
|
595
|
+
expect( result ).toEqual( {
|
|
596
|
+
'block-1': { color: 'red' },
|
|
597
|
+
'non-existent-block': undefined,
|
|
598
|
+
} );
|
|
599
|
+
} );
|
|
600
|
+
} );
|
|
512
601
|
} );
|
package/src/style.scss
CHANGED
|
@@ -40,14 +40,13 @@
|
|
|
40
40
|
@import "./components/multi-selection-inspector/style.scss";
|
|
41
41
|
@import "./components/responsive-block-control/style.scss";
|
|
42
42
|
@import "./components/rich-text/style.scss";
|
|
43
|
-
@import "./components/segmented-text-control/style.scss";
|
|
44
43
|
@import "./components/skip-to-selected-block/style.scss";
|
|
45
44
|
@import "./components/tabbed-sidebar/style.scss";
|
|
46
45
|
@import "./components/tool-selector/style.scss";
|
|
47
46
|
@import "./components/url-input/style.scss";
|
|
48
47
|
@import "./components/url-popover/style.scss";
|
|
49
|
-
@import "./hooks/block-bindings.scss";
|
|
50
48
|
@import "./hooks/block-hooks.scss";
|
|
49
|
+
@import "./hooks/block-bindings.scss";
|
|
51
50
|
@import "./hooks/border.scss";
|
|
52
51
|
@import "./hooks/color.scss";
|
|
53
52
|
@import "./hooks/dimensions.scss";
|
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* WordPress dependencies
|
|
3
|
+
*/
|
|
4
|
+
import { useDispatch, useSelect } from '@wordpress/data';
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Internal dependencies
|
|
8
|
+
*/
|
|
9
|
+
import { store as blockEditorStore } from '../store';
|
|
10
|
+
import { useBlockEditContext } from '../components/block-edit';
|
|
11
|
+
|
|
12
|
+
export function useBlockBindingsUtils() {
|
|
13
|
+
const { clientId } = useBlockEditContext();
|
|
14
|
+
const { updateBlockAttributes } = useDispatch( blockEditorStore );
|
|
15
|
+
const { getBlockAttributes } = useSelect( blockEditorStore );
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* Updates the value of the bindings connected to block attributes.
|
|
19
|
+
* It removes the binding when the new value is `undefined`.
|
|
20
|
+
*
|
|
21
|
+
* @param {Object} bindings Bindings including the attributes to update and the new object.
|
|
22
|
+
* @param {string} bindings.source The source name to connect to.
|
|
23
|
+
* @param {Object} [bindings.args] Object containing the arguments needed by the source.
|
|
24
|
+
*
|
|
25
|
+
* @example
|
|
26
|
+
* ```js
|
|
27
|
+
* import { useBlockBindingsUtils } from '@wordpress/block-editor'
|
|
28
|
+
*
|
|
29
|
+
* const { updateBlockBindings } = useBlockBindingsUtils();
|
|
30
|
+
* updateBlockBindings( {
|
|
31
|
+
* url: {
|
|
32
|
+
* source: 'core/post-meta',
|
|
33
|
+
* args: {
|
|
34
|
+
* key: 'url_custom_field',
|
|
35
|
+
* },
|
|
36
|
+
* },
|
|
37
|
+
* alt: {
|
|
38
|
+
* source: 'core/post-meta',
|
|
39
|
+
* args: {
|
|
40
|
+
* key: 'text_custom_field',
|
|
41
|
+
* },
|
|
42
|
+
* }
|
|
43
|
+
* } );
|
|
44
|
+
* ```
|
|
45
|
+
*/
|
|
46
|
+
const updateBlockBindings = ( bindings ) => {
|
|
47
|
+
const { metadata } = getBlockAttributes( clientId );
|
|
48
|
+
const newBindings = { ...metadata?.bindings };
|
|
49
|
+
Object.entries( bindings ).forEach( ( [ attribute, binding ] ) => {
|
|
50
|
+
if ( ! binding && newBindings[ attribute ] ) {
|
|
51
|
+
delete newBindings[ attribute ];
|
|
52
|
+
return;
|
|
53
|
+
}
|
|
54
|
+
newBindings[ attribute ] = binding;
|
|
55
|
+
} );
|
|
56
|
+
|
|
57
|
+
const newMetadata = {
|
|
58
|
+
...metadata,
|
|
59
|
+
bindings: newBindings,
|
|
60
|
+
};
|
|
61
|
+
|
|
62
|
+
if ( Object.keys( newMetadata.bindings ).length === 0 ) {
|
|
63
|
+
delete newMetadata.bindings;
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
updateBlockAttributes( clientId, {
|
|
67
|
+
metadata:
|
|
68
|
+
Object.keys( newMetadata ).length === 0
|
|
69
|
+
? undefined
|
|
70
|
+
: newMetadata,
|
|
71
|
+
} );
|
|
72
|
+
};
|
|
73
|
+
|
|
74
|
+
/**
|
|
75
|
+
* Removes the bindings property of the `metadata` attribute.
|
|
76
|
+
*
|
|
77
|
+
* @example
|
|
78
|
+
* ```js
|
|
79
|
+
* import { useBlockBindingsUtils } from '@wordpress/block-editor'
|
|
80
|
+
*
|
|
81
|
+
* const { removeAllBlockBindings } = useBlockBindingsUtils();
|
|
82
|
+
* removeAllBlockBindings();
|
|
83
|
+
* ```
|
|
84
|
+
*/
|
|
85
|
+
const removeAllBlockBindings = () => {
|
|
86
|
+
const { metadata } = getBlockAttributes( clientId );
|
|
87
|
+
const newMetadata = { ...metadata };
|
|
88
|
+
delete newMetadata.bindings;
|
|
89
|
+
updateBlockAttributes( clientId, {
|
|
90
|
+
metadata:
|
|
91
|
+
Object.keys( newMetadata ).length === 0
|
|
92
|
+
? undefined
|
|
93
|
+
: newMetadata,
|
|
94
|
+
} );
|
|
95
|
+
};
|
|
96
|
+
|
|
97
|
+
return { updateBlockBindings, removeAllBlockBindings };
|
|
98
|
+
}
|
|
@@ -23,7 +23,7 @@ export default function getEditorRegion( editor ) {
|
|
|
23
23
|
return iframeDocument === editor.ownerDocument;
|
|
24
24
|
} ) ?? editor;
|
|
25
25
|
|
|
26
|
-
// The region is
|
|
26
|
+
// The region is provided by the editor, not the block-editor.
|
|
27
27
|
// We should send focus to the region if one is available to reuse the
|
|
28
28
|
// same interface for navigating landmarks. If no region is available,
|
|
29
29
|
// use the canvas instead.
|
|
@@ -125,6 +125,21 @@ describe( 'transformStyles', () => {
|
|
|
125
125
|
expect( output ).toMatchSnapshot();
|
|
126
126
|
} );
|
|
127
127
|
|
|
128
|
+
it( `should not try to replace 'body' in the middle of a classname`, () => {
|
|
129
|
+
const prefix = '.my-namespace';
|
|
130
|
+
const input = `.has-body-text { color: red; }`;
|
|
131
|
+
const output = transformStyles(
|
|
132
|
+
[
|
|
133
|
+
{
|
|
134
|
+
css: input,
|
|
135
|
+
},
|
|
136
|
+
],
|
|
137
|
+
prefix
|
|
138
|
+
);
|
|
139
|
+
|
|
140
|
+
expect( output ).toEqual( [ `${ prefix } ${ input }` ] );
|
|
141
|
+
} );
|
|
142
|
+
|
|
128
143
|
it( 'should ignore keyframes', () => {
|
|
129
144
|
const input = `
|
|
130
145
|
@keyframes edit-post__fade-in-animation {
|
|
@@ -210,6 +225,40 @@ describe( 'transformStyles', () => {
|
|
|
210
225
|
|
|
211
226
|
expect( output ).toMatchSnapshot();
|
|
212
227
|
} );
|
|
228
|
+
|
|
229
|
+
it( 'should not try to wrap items within `:where` selectors', () => {
|
|
230
|
+
const input = `:where(.wp-element-button:active, .wp-block-button__link:active) { color: blue; }`;
|
|
231
|
+
const prefix = '.my-namespace';
|
|
232
|
+
const expected = [ `${ prefix } ${ input }` ];
|
|
233
|
+
|
|
234
|
+
const output = transformStyles(
|
|
235
|
+
[
|
|
236
|
+
{
|
|
237
|
+
css: input,
|
|
238
|
+
},
|
|
239
|
+
],
|
|
240
|
+
prefix
|
|
241
|
+
);
|
|
242
|
+
|
|
243
|
+
expect( output ).toEqual( expected );
|
|
244
|
+
} );
|
|
245
|
+
|
|
246
|
+
it( 'should not try to prefix pseudo elements on `:where` selectors', () => {
|
|
247
|
+
const input = `:where(.wp-element-button, .wp-block-button__link)::before { color: blue; }`;
|
|
248
|
+
const prefix = '.my-namespace';
|
|
249
|
+
const expected = [ `${ prefix } ${ input }` ];
|
|
250
|
+
|
|
251
|
+
const output = transformStyles(
|
|
252
|
+
[
|
|
253
|
+
{
|
|
254
|
+
css: input,
|
|
255
|
+
},
|
|
256
|
+
],
|
|
257
|
+
prefix
|
|
258
|
+
);
|
|
259
|
+
|
|
260
|
+
expect( output ).toEqual( expected );
|
|
261
|
+
} );
|
|
213
262
|
} );
|
|
214
263
|
|
|
215
264
|
it( 'should not break with data urls', () => {
|