@wordpress/block-editor 12.20.0 → 12.21.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 +2 -0
- package/build/components/block-actions/index.js +45 -32
- package/build/components/block-actions/index.js.map +1 -1
- package/build/components/block-bindings-toolbar-indicator/index.js +25 -0
- package/build/components/block-bindings-toolbar-indicator/index.js.map +1 -0
- package/build/components/block-edit/context.js +2 -1
- package/build/components/block-edit/context.js.map +1 -1
- package/build/components/block-edit/index.js +8 -3
- package/build/components/block-edit/index.js.map +1 -1
- package/build/components/block-inspector/index.js +5 -4
- package/build/components/block-inspector/index.js.map +1 -1
- package/build/components/block-list/block-invalid-warning.native.js.map +1 -1
- package/build/components/block-list/block-list-item.native.js +1 -1
- package/build/components/block-list/block-list-item.native.js.map +1 -1
- package/build/components/block-list/block-outline.native.js +23 -7
- package/build/components/block-list/block-outline.native.js.map +1 -1
- package/build/components/block-list/block-selection-button.native.js.map +1 -1
- package/build/components/block-list/block.native.js +0 -3
- package/build/components/block-list/block.native.js.map +1 -1
- package/build/components/block-list/use-block-props/index.js +8 -1
- package/build/components/block-list/use-block-props/index.js.map +1 -1
- package/build/components/block-list/use-block-props/use-selected-block-event-handlers.js +3 -3
- package/build/components/block-list/use-block-props/use-selected-block-event-handlers.js.map +1 -1
- package/build/components/block-mover/index.native.js.map +1 -1
- package/build/components/block-popover/cover.js +68 -0
- package/build/components/block-popover/cover.js.map +1 -0
- package/build/components/block-popover/drop-zone.js +2 -3
- package/build/components/block-popover/drop-zone.js.map +1 -1
- package/build/components/block-popover/index.js +1 -19
- package/build/components/block-popover/index.js.map +1 -1
- package/build/components/block-preview/index.js +2 -1
- package/build/components/block-preview/index.js.map +1 -1
- package/build/components/block-removal-warning-modal/index.js +2 -4
- package/build/components/block-removal-warning-modal/index.js.map +1 -1
- package/build/components/block-rename/modal.js.map +1 -1
- package/build/components/block-settings-menu/block-settings-dropdown.js +12 -10
- package/build/components/block-settings-menu/block-settings-dropdown.js.map +1 -1
- package/build/components/block-switcher/block-transformations-menu.native.js.map +1 -1
- package/build/components/block-toolbar/block-toolbar-menu.native.js.map +1 -1
- package/build/components/block-toolbar/index.js +21 -10
- package/build/components/block-toolbar/index.js.map +1 -1
- package/build/components/block-toolbar/shuffle.js +89 -0
- package/build/components/block-toolbar/shuffle.js.map +1 -0
- package/build/components/block-toolbar/use-has-block-toolbar.js +43 -0
- package/build/components/block-toolbar/use-has-block-toolbar.js.map +1 -0
- package/build/components/block-tools/block-selection-button.js +5 -1
- package/build/components/block-tools/block-selection-button.js.map +1 -1
- package/build/components/block-tools/empty-block-inserter.js +2 -5
- package/build/components/block-tools/empty-block-inserter.js.map +1 -1
- package/build/components/block-tools/index.js +9 -26
- package/build/components/block-tools/index.js.map +1 -1
- package/build/components/block-tools/use-show-block-tools.js +60 -0
- package/build/components/block-tools/use-show-block-tools.js.map +1 -0
- package/build/components/caption/index.native.js.map +1 -1
- package/build/components/child-layout-control/index.js.map +1 -1
- package/build/components/color-palette/control.js.map +1 -1
- package/build/components/colors-gradients/control.js +1 -1
- package/build/components/colors-gradients/control.js.map +1 -1
- package/build/components/global-styles/border-panel.js +21 -8
- package/build/components/global-styles/border-panel.js.map +1 -1
- package/build/components/global-styles/color-panel.js +1 -1
- package/build/components/global-styles/color-panel.js.map +1 -1
- package/build/components/global-styles/image-settings-panel.js.map +1 -1
- package/build/components/global-styles/index.js +6 -0
- package/build/components/global-styles/index.js.map +1 -1
- package/build/components/global-styles/shadow-panel-components.js +80 -23
- package/build/components/global-styles/shadow-panel-components.js.map +1 -1
- package/build/components/global-styles/typography-utils.js +7 -5
- package/build/components/global-styles/typography-utils.js.map +1 -1
- package/build/components/global-styles/use-global-styles-output.js +15 -15
- package/build/components/global-styles/use-global-styles-output.js.map +1 -1
- package/build/components/global-styles/utils.js +1 -1
- package/build/components/global-styles/utils.js.map +1 -1
- package/build/components/grid-visualizer/grid-item-resizer.js +77 -0
- package/build/components/grid-visualizer/grid-item-resizer.js.map +1 -0
- package/build/components/grid-visualizer/grid-visualizer.js +81 -0
- package/build/components/grid-visualizer/grid-visualizer.js.map +1 -0
- package/build/components/grid-visualizer/index.js +20 -0
- package/build/components/grid-visualizer/index.js.map +1 -0
- package/build/components/grid-visualizer/utils.js +10 -0
- package/build/components/grid-visualizer/utils.js.map +1 -0
- package/build/components/iframe/index.js +61 -16
- package/build/components/iframe/index.js.map +1 -1
- package/build/components/index.native.js +7 -0
- package/build/components/index.native.js.map +1 -1
- package/build/components/inner-blocks/use-nested-settings-update.js +8 -2
- package/build/components/inner-blocks/use-nested-settings-update.js.map +1 -1
- package/build/components/inserter/media-tab/media-preview.js.map +1 -1
- package/build/components/inserter/menu.js +9 -3
- package/build/components/inserter/menu.js.map +1 -1
- package/build/components/inserter/menu.native.js.map +1 -1
- package/build/components/inserter/mobile-tab-navigation.js +1 -1
- package/build/components/inserter/mobile-tab-navigation.js.map +1 -1
- package/build/components/inserter/search-results.js +3 -2
- package/build/components/inserter/search-results.js.map +1 -1
- package/build/components/inserter/tabs.js +2 -1
- package/build/components/inserter/tabs.js.map +1 -1
- package/build/components/inspector-controls/block-support-tools-panel.js.map +1 -1
- package/build/components/inspector-controls-tabs/index.js +1 -1
- package/build/components/inspector-controls-tabs/index.js.map +1 -1
- package/build/components/inspector-controls-tabs/styles-tab.js +1 -1
- package/build/components/inspector-controls-tabs/styles-tab.js.map +1 -1
- package/build/components/link-control/link-preview.js +4 -1
- package/build/components/link-control/link-preview.js.map +1 -1
- package/build/components/link-control/search-input.js.map +1 -1
- package/build/components/list-view/block-select-button.js +10 -2
- package/build/components/list-view/block-select-button.js.map +1 -1
- package/build/components/list-view/branch.js.map +1 -1
- package/build/components/list-view/drop-indicator.js.map +1 -1
- package/build/components/list-view/index.js.map +1 -1
- package/build/components/list-view/use-clipboard-handler.js +2 -1
- package/build/components/list-view/use-clipboard-handler.js.map +1 -1
- package/build/components/panel-color-settings/index.js.map +1 -1
- package/build/components/provider/index.js.map +1 -1
- package/build/components/resizable-box-popover/index.js +3 -5
- package/build/components/resizable-box-popover/index.js.map +1 -1
- package/build/components/responsive-block-control/index.js +1 -1
- package/build/components/responsive-block-control/index.js.map +1 -1
- package/build/components/rich-text/index.js +46 -26
- package/build/components/rich-text/index.js.map +1 -1
- package/build/components/rich-text/use-enter.js +3 -0
- package/build/components/rich-text/use-enter.js.map +1 -1
- package/build/components/spacing-sizes-control/input-controls/spacing-input-control.js.map +1 -1
- package/build/components/url-popover/index.js +3 -3
- package/build/components/url-popover/index.js.map +1 -1
- package/build/components/writing-flow/use-clipboard-handler.js +2 -1
- package/build/components/writing-flow/use-clipboard-handler.js.map +1 -1
- package/build/components/writing-flow/utils.js +23 -6
- package/build/components/writing-flow/utils.js.map +1 -1
- package/build/hooks/background.js.map +1 -1
- package/build/hooks/block-hooks.js +34 -8
- package/build/hooks/block-hooks.js.map +1 -1
- package/build/hooks/border.js +6 -4
- package/build/hooks/border.js.map +1 -1
- package/build/hooks/dimensions.js +3 -4
- package/build/hooks/dimensions.js.map +1 -1
- package/build/hooks/font-size.js +6 -7
- package/build/hooks/font-size.js.map +1 -1
- package/build/hooks/index.js +1 -1
- package/build/hooks/index.js.map +1 -1
- package/build/hooks/layout-child.js +39 -0
- package/build/hooks/layout-child.js.map +1 -1
- package/build/hooks/layout.js +11 -4
- package/build/hooks/layout.js.map +1 -1
- package/build/hooks/line-height.js.map +1 -1
- package/build/hooks/spacing-visualizer.js +115 -0
- package/build/hooks/spacing-visualizer.js.map +1 -0
- package/build/hooks/use-bindings-attributes.js +171 -48
- package/build/hooks/use-bindings-attributes.js.map +1 -1
- package/build/hooks/use-typography-props.js +1 -2
- package/build/hooks/use-typography-props.js.map +1 -1
- package/build/layouts/grid.js +6 -2
- package/build/layouts/grid.js.map +1 -1
- package/build/private-apis.js +7 -3
- package/build/private-apis.js.map +1 -1
- package/build/store/actions.js +42 -12
- package/build/store/actions.js.map +1 -1
- package/build/store/private-actions.js +29 -55
- package/build/store/private-actions.js.map +1 -1
- package/build/store/private-selectors.js +0 -8
- package/build/store/private-selectors.js.map +1 -1
- package/build/store/reducer.js +3 -20
- package/build/store/reducer.js.map +1 -1
- package/build/store/selectors.js +27 -15
- package/build/store/selectors.js.map +1 -1
- package/build/utils/calculate-scale.js +17 -0
- package/build/utils/calculate-scale.js.map +1 -0
- package/build-module/components/block-actions/index.js +45 -32
- package/build-module/components/block-actions/index.js.map +1 -1
- package/build-module/components/block-bindings-toolbar-indicator/index.js +18 -0
- package/build-module/components/block-bindings-toolbar-indicator/index.js.map +1 -0
- package/build-module/components/block-edit/context.js +1 -0
- package/build-module/components/block-edit/context.js.map +1 -1
- package/build-module/components/block-edit/index.js +9 -4
- package/build-module/components/block-edit/index.js.map +1 -1
- package/build-module/components/block-inspector/index.js +6 -5
- package/build-module/components/block-inspector/index.js.map +1 -1
- package/build-module/components/block-list/block-invalid-warning.native.js.map +1 -1
- package/build-module/components/block-list/block-list-item.native.js +1 -1
- package/build-module/components/block-list/block-list-item.native.js.map +1 -1
- package/build-module/components/block-list/block-outline.native.js +23 -7
- package/build-module/components/block-list/block-outline.native.js.map +1 -1
- package/build-module/components/block-list/block-selection-button.native.js.map +1 -1
- package/build-module/components/block-list/block.native.js +0 -3
- package/build-module/components/block-list/block.native.js.map +1 -1
- package/build-module/components/block-list/use-block-props/index.js +9 -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-selected-block-event-handlers.js +3 -3
- package/build-module/components/block-list/use-block-props/use-selected-block-event-handlers.js.map +1 -1
- package/build-module/components/block-mover/index.native.js.map +1 -1
- package/build-module/components/block-popover/cover.js +60 -0
- package/build-module/components/block-popover/cover.js.map +1 -0
- package/build-module/components/block-popover/drop-zone.js +2 -3
- package/build-module/components/block-popover/drop-zone.js.map +1 -1
- package/build-module/components/block-popover/index.js +1 -19
- package/build-module/components/block-popover/index.js.map +1 -1
- package/build-module/components/block-preview/index.js +2 -1
- package/build-module/components/block-preview/index.js.map +1 -1
- package/build-module/components/block-removal-warning-modal/index.js +3 -5
- package/build-module/components/block-removal-warning-modal/index.js.map +1 -1
- package/build-module/components/block-rename/modal.js.map +1 -1
- package/build-module/components/block-settings-menu/block-settings-dropdown.js +12 -10
- package/build-module/components/block-settings-menu/block-settings-dropdown.js.map +1 -1
- package/build-module/components/block-switcher/block-transformations-menu.native.js.map +1 -1
- package/build-module/components/block-toolbar/block-toolbar-menu.native.js.map +1 -1
- package/build-module/components/block-toolbar/index.js +21 -11
- package/build-module/components/block-toolbar/index.js.map +1 -1
- package/build-module/components/block-toolbar/shuffle.js +82 -0
- package/build-module/components/block-toolbar/shuffle.js.map +1 -0
- package/build-module/components/block-toolbar/use-has-block-toolbar.js +36 -0
- package/build-module/components/block-toolbar/use-has-block-toolbar.js.map +1 -0
- package/build-module/components/block-tools/block-selection-button.js +5 -1
- package/build-module/components/block-tools/block-selection-button.js.map +1 -1
- package/build-module/components/block-tools/empty-block-inserter.js +2 -5
- package/build-module/components/block-tools/empty-block-inserter.js.map +1 -1
- package/build-module/components/block-tools/index.js +9 -26
- package/build-module/components/block-tools/index.js.map +1 -1
- package/build-module/components/block-tools/use-show-block-tools.js +54 -0
- package/build-module/components/block-tools/use-show-block-tools.js.map +1 -0
- package/build-module/components/caption/index.native.js.map +1 -1
- package/build-module/components/child-layout-control/index.js.map +1 -1
- package/build-module/components/color-palette/control.js.map +1 -1
- package/build-module/components/colors-gradients/control.js +1 -1
- package/build-module/components/colors-gradients/control.js.map +1 -1
- package/build-module/components/global-styles/border-panel.js +22 -10
- package/build-module/components/global-styles/border-panel.js.map +1 -1
- package/build-module/components/global-styles/color-panel.js +1 -1
- package/build-module/components/global-styles/color-panel.js.map +1 -1
- 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/shadow-panel-components.js +82 -24
- package/build-module/components/global-styles/shadow-panel-components.js.map +1 -1
- package/build-module/components/global-styles/typography-utils.js +7 -5
- package/build-module/components/global-styles/typography-utils.js.map +1 -1
- package/build-module/components/global-styles/use-global-styles-output.js +16 -16
- package/build-module/components/global-styles/use-global-styles-output.js.map +1 -1
- package/build-module/components/global-styles/utils.js +2 -2
- package/build-module/components/global-styles/utils.js.map +1 -1
- package/build-module/components/grid-visualizer/grid-item-resizer.js +69 -0
- package/build-module/components/grid-visualizer/grid-item-resizer.js.map +1 -0
- package/build-module/components/grid-visualizer/grid-visualizer.js +73 -0
- package/build-module/components/grid-visualizer/grid-visualizer.js.map +1 -0
- package/build-module/components/grid-visualizer/index.js +3 -0
- package/build-module/components/grid-visualizer/index.js.map +1 -0
- package/build-module/components/grid-visualizer/utils.js +4 -0
- package/build-module/components/grid-visualizer/utils.js.map +1 -0
- package/build-module/components/iframe/index.js +61 -16
- package/build-module/components/iframe/index.js.map +1 -1
- package/build-module/components/index.native.js +1 -1
- package/build-module/components/index.native.js.map +1 -1
- package/build-module/components/inner-blocks/use-nested-settings-update.js +8 -2
- package/build-module/components/inner-blocks/use-nested-settings-update.js.map +1 -1
- package/build-module/components/inserter/media-tab/media-preview.js.map +1 -1
- package/build-module/components/inserter/menu.js +9 -3
- package/build-module/components/inserter/menu.js.map +1 -1
- package/build-module/components/inserter/menu.native.js.map +1 -1
- package/build-module/components/inserter/mobile-tab-navigation.js +1 -1
- package/build-module/components/inserter/mobile-tab-navigation.js.map +1 -1
- package/build-module/components/inserter/search-results.js +3 -2
- package/build-module/components/inserter/search-results.js.map +1 -1
- package/build-module/components/inserter/tabs.js +2 -1
- package/build-module/components/inserter/tabs.js.map +1 -1
- package/build-module/components/inspector-controls/block-support-tools-panel.js.map +1 -1
- package/build-module/components/inspector-controls-tabs/index.js +1 -1
- package/build-module/components/inspector-controls-tabs/index.js.map +1 -1
- package/build-module/components/inspector-controls-tabs/styles-tab.js +2 -2
- package/build-module/components/inspector-controls-tabs/styles-tab.js.map +1 -1
- package/build-module/components/link-control/link-preview.js +5 -2
- package/build-module/components/link-control/link-preview.js.map +1 -1
- package/build-module/components/link-control/search-input.js.map +1 -1
- package/build-module/components/list-view/block-select-button.js +11 -3
- package/build-module/components/list-view/block-select-button.js.map +1 -1
- package/build-module/components/list-view/branch.js.map +1 -1
- package/build-module/components/list-view/drop-indicator.js.map +1 -1
- package/build-module/components/list-view/index.js.map +1 -1
- package/build-module/components/list-view/use-clipboard-handler.js +3 -2
- package/build-module/components/list-view/use-clipboard-handler.js.map +1 -1
- package/build-module/components/panel-color-settings/index.js.map +1 -1
- package/build-module/components/provider/index.js.map +1 -1
- package/build-module/components/resizable-box-popover/index.js +3 -5
- package/build-module/components/resizable-box-popover/index.js.map +1 -1
- package/build-module/components/responsive-block-control/index.js +1 -1
- package/build-module/components/responsive-block-control/index.js.map +1 -1
- package/build-module/components/rich-text/index.js +47 -28
- package/build-module/components/rich-text/index.js.map +1 -1
- package/build-module/components/rich-text/use-enter.js +3 -0
- package/build-module/components/rich-text/use-enter.js.map +1 -1
- package/build-module/components/spacing-sizes-control/input-controls/spacing-input-control.js.map +1 -1
- package/build-module/components/url-popover/index.js +3 -3
- package/build-module/components/url-popover/index.js.map +1 -1
- package/build-module/components/writing-flow/use-clipboard-handler.js +3 -2
- package/build-module/components/writing-flow/use-clipboard-handler.js.map +1 -1
- package/build-module/components/writing-flow/utils.js +22 -7
- package/build-module/components/writing-flow/utils.js.map +1 -1
- package/build-module/hooks/background.js.map +1 -1
- package/build-module/hooks/block-hooks.js +34 -8
- package/build-module/hooks/block-hooks.js.map +1 -1
- package/build-module/hooks/border.js +7 -5
- package/build-module/hooks/border.js.map +1 -1
- package/build-module/hooks/dimensions.js +1 -2
- package/build-module/hooks/dimensions.js.map +1 -1
- package/build-module/hooks/font-size.js +7 -8
- package/build-module/hooks/font-size.js.map +1 -1
- package/build-module/hooks/index.js +1 -1
- package/build-module/hooks/index.js.map +1 -1
- package/build-module/hooks/layout-child.js +39 -0
- package/build-module/hooks/layout-child.js.map +1 -1
- package/build-module/hooks/layout.js +11 -4
- package/build-module/hooks/layout.js.map +1 -1
- package/build-module/hooks/line-height.js.map +1 -1
- package/build-module/hooks/spacing-visualizer.js +106 -0
- package/build-module/hooks/spacing-visualizer.js.map +1 -0
- package/build-module/hooks/use-bindings-attributes.js +172 -49
- package/build-module/hooks/use-bindings-attributes.js.map +1 -1
- package/build-module/hooks/use-typography-props.js +2 -3
- package/build-module/hooks/use-typography-props.js.map +1 -1
- package/build-module/layouts/grid.js +6 -2
- package/build-module/layouts/grid.js.map +1 -1
- package/build-module/private-apis.js +7 -3
- package/build-module/private-apis.js.map +1 -1
- package/build-module/store/actions.js +42 -12
- package/build-module/store/actions.js.map +1 -1
- package/build-module/store/private-actions.js +29 -54
- package/build-module/store/private-actions.js.map +1 -1
- package/build-module/store/private-selectors.js +0 -6
- package/build-module/store/private-selectors.js.map +1 -1
- package/build-module/store/reducer.js +3 -20
- package/build-module/store/reducer.js.map +1 -1
- package/build-module/store/selectors.js +23 -13
- package/build-module/store/selectors.js.map +1 -1
- package/build-module/utils/calculate-scale.js +11 -0
- package/build-module/utils/calculate-scale.js.map +1 -0
- package/build-style/content-rtl.css +8 -2
- package/build-style/content.css +8 -2
- package/build-style/default-editor-styles-rtl.css +1 -0
- package/build-style/default-editor-styles.css +1 -0
- package/build-style/style-rtl.css +113 -22
- package/build-style/style.css +113 -22
- package/package.json +31 -31
- package/src/components/block-actions/index.js +57 -47
- package/src/components/block-bindings-toolbar-indicator/index.js +20 -0
- package/src/components/block-bindings-toolbar-indicator/style.scss +14 -0
- package/src/components/block-draggable/test/index.native.js +2 -2
- package/src/components/block-edit/context.js +1 -0
- package/src/components/block-edit/index.js +5 -1
- package/src/components/block-inspector/index.js +7 -5
- package/src/components/block-list/block-invalid-warning.native.js +1 -1
- package/src/components/block-list/block-list-item.native.js +1 -1
- package/src/components/block-list/block-outline.native.js +36 -21
- package/src/components/block-list/block-selection-button.native.js +1 -3
- package/src/components/block-list/block.native.js +0 -3
- package/src/components/block-list/content.scss +5 -1
- package/src/components/block-list/test/block-outline.native.js +255 -0
- package/src/components/block-list/use-block-props/index.js +12 -2
- package/src/components/block-list/use-block-props/use-selected-block-event-handlers.js +3 -7
- package/src/components/block-mover/index.native.js +1 -1
- package/src/components/block-popover/cover.js +63 -0
- package/src/components/block-popover/drop-zone.js +3 -4
- package/src/components/block-popover/index.js +1 -28
- package/src/components/block-preview/index.js +3 -1
- package/src/components/block-removal-warning-modal/index.js +5 -19
- package/src/components/block-rename/modal.js +1 -1
- package/src/components/block-settings-menu/block-settings-dropdown.js +12 -9
- package/src/components/block-switcher/block-transformations-menu.native.js +1 -1
- package/src/components/block-toolbar/block-toolbar-menu.native.js +2 -2
- package/src/components/block-toolbar/index.js +19 -15
- package/src/components/block-toolbar/shuffle.js +93 -0
- package/src/components/block-toolbar/use-has-block-toolbar.js +49 -0
- package/src/components/block-tools/block-selection-button.js +4 -0
- package/src/components/block-tools/empty-block-inserter.js +3 -6
- package/src/components/block-tools/index.js +13 -36
- package/src/components/block-tools/use-show-block-tools.js +73 -0
- package/src/components/caption/index.native.js +1 -1
- package/src/components/child-layout-control/index.js +1 -1
- package/src/components/color-palette/control.js +1 -1
- package/src/components/colors-gradients/control.js +1 -1
- package/src/components/colors-gradients/test/control.js +2 -2
- package/src/components/contrast-checker/test/index.js +10 -10
- package/src/components/default-block-appender/content.scss +5 -2
- package/src/components/global-styles/border-panel.js +35 -24
- package/src/components/global-styles/color-panel.js +1 -1
- package/src/components/global-styles/image-settings-panel.js +1 -1
- package/src/components/global-styles/index.js +5 -1
- package/src/components/global-styles/shadow-panel-components.js +92 -23
- package/src/components/global-styles/style.scss +33 -10
- package/src/components/global-styles/test/typography-utils.js +231 -81
- package/src/components/global-styles/typography-utils.js +10 -7
- package/src/components/global-styles/use-global-styles-output.js +14 -16
- package/src/components/global-styles/utils.js +2 -8
- package/src/components/grid-visualizer/grid-item-resizer.js +100 -0
- package/src/components/grid-visualizer/grid-visualizer.js +81 -0
- package/src/components/grid-visualizer/index.js +2 -0
- package/src/components/grid-visualizer/style.scss +33 -0
- package/src/components/grid-visualizer/utils.js +5 -0
- package/src/components/iframe/index.js +78 -31
- package/src/components/index.native.js +1 -0
- package/src/components/inner-blocks/use-nested-settings-update.js +12 -2
- package/src/components/inserter/media-tab/media-preview.js +1 -1
- package/src/components/inserter/menu.js +10 -4
- package/src/components/inserter/menu.native.js +3 -3
- package/src/components/inserter/mobile-tab-navigation.js +1 -1
- package/src/components/inserter/search-results.js +2 -1
- package/src/components/inserter/style.scss +10 -0
- package/src/components/inserter/tabs.js +2 -1
- package/src/components/inspector-controls/block-support-tools-panel.js +2 -2
- package/src/components/inspector-controls-tabs/index.js +1 -1
- package/src/components/inspector-controls-tabs/styles-tab.js +2 -2
- package/src/components/line-height-control/test/index.js +1 -1
- package/src/components/link-control/link-preview.js +9 -2
- package/src/components/link-control/search-input.js +1 -1
- package/src/components/link-control/style.scss +9 -0
- package/src/components/list-view/block-select-button.js +16 -2
- package/src/components/list-view/branch.js +1 -1
- package/src/components/list-view/drop-indicator.js +1 -1
- package/src/components/list-view/index.js +1 -1
- package/src/components/list-view/style.scss +8 -0
- package/src/components/list-view/use-clipboard-handler.js +3 -2
- package/src/components/panel-color-settings/index.js +1 -1
- package/src/components/panel-color-settings/test/index.js +3 -3
- package/src/components/provider/index.js +1 -4
- package/src/components/resizable-box-popover/index.js +4 -6
- package/src/components/responsive-block-control/README.md +4 -4
- package/src/components/responsive-block-control/index.js +1 -1
- package/src/components/responsive-block-control/test/index.js +5 -5
- package/src/components/rich-text/index.js +76 -53
- package/src/components/rich-text/use-enter.js +4 -0
- package/src/components/spacing-sizes-control/input-controls/spacing-input-control.js +4 -4
- package/src/components/url-popover/index.js +5 -5
- package/src/components/url-popover/style.scss +1 -0
- package/src/components/writing-flow/use-clipboard-handler.js +3 -2
- package/src/components/writing-flow/utils.js +31 -16
- package/src/hooks/background.js +1 -1
- package/src/hooks/block-hooks.js +47 -9
- package/src/hooks/block-hooks.scss +6 -0
- package/src/hooks/border.js +16 -4
- package/src/hooks/dimensions.js +1 -2
- package/src/hooks/font-size.js +7 -12
- package/src/hooks/index.js +1 -0
- package/src/hooks/layout-child.js +38 -0
- package/src/hooks/layout.js +12 -1
- package/src/hooks/line-height.js +1 -1
- package/src/hooks/spacing-visualizer.js +126 -0
- package/src/hooks/{padding.scss → spacing.scss} +1 -1
- package/src/hooks/use-bindings-attributes.js +215 -65
- package/src/hooks/use-typography-props.js +2 -8
- package/src/layouts/grid.js +8 -3
- package/src/private-apis.js +6 -2
- package/src/store/actions.js +56 -18
- package/src/store/private-actions.js +34 -79
- package/src/store/private-selectors.js +0 -8
- package/src/store/reducer.js +2 -23
- package/src/store/selectors.js +41 -46
- package/src/store/test/actions.js +0 -4
- package/src/style.scss +3 -1
- package/src/utils/calculate-scale.js +20 -0
- package/build/hooks/margin.js +0 -86
- package/build/hooks/margin.js.map +0 -1
- package/build/hooks/padding.js +0 -78
- package/build/hooks/padding.js.map +0 -1
- package/build/utils/use-can-block-toolbar-be-focused.js +0 -46
- package/build/utils/use-can-block-toolbar-be-focused.js.map +0 -1
- package/build-module/hooks/margin.js +0 -78
- package/build-module/hooks/margin.js.map +0 -1
- package/build-module/hooks/padding.js +0 -70
- package/build-module/hooks/padding.js.map +0 -1
- package/build-module/utils/use-can-block-toolbar-be-focused.js +0 -40
- package/build-module/utils/use-can-block-toolbar-be-focused.js.map +0 -1
- package/src/hooks/margin.js +0 -91
- package/src/hooks/padding.js +0 -82
- package/src/utils/use-can-block-toolbar-be-focused.js +0 -48
|
@@ -1,15 +1,16 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* WordPress dependencies
|
|
3
3
|
*/
|
|
4
|
-
import { getBlockType } from '@wordpress/blocks';
|
|
4
|
+
import { getBlockType, store as blocksStore } from '@wordpress/blocks';
|
|
5
5
|
import { createHigherOrderComponent } from '@wordpress/compose';
|
|
6
6
|
import { useSelect } from '@wordpress/data';
|
|
7
|
+
import { useLayoutEffect, useCallback, useState } from '@wordpress/element';
|
|
7
8
|
import { addFilter } from '@wordpress/hooks';
|
|
9
|
+
import { RichTextData } from '@wordpress/rich-text';
|
|
10
|
+
|
|
8
11
|
/**
|
|
9
12
|
* Internal dependencies
|
|
10
13
|
*/
|
|
11
|
-
import { store as blockEditorStore } from '../store';
|
|
12
|
-
import { useBlockEditContext } from '../components/block-edit/context';
|
|
13
14
|
import { unlock } from '../lock-unlock';
|
|
14
15
|
|
|
15
16
|
/** @typedef {import('@wordpress/compose').WPHigherOrderComponent} WPHigherOrderComponent */
|
|
@@ -22,89 +23,238 @@ import { unlock } from '../lock-unlock';
|
|
|
22
23
|
* @return {WPHigherOrderComponent} Higher-order component.
|
|
23
24
|
*/
|
|
24
25
|
|
|
25
|
-
|
|
26
|
+
const BLOCK_BINDINGS_ALLOWED_BLOCKS = {
|
|
26
27
|
'core/paragraph': [ 'content' ],
|
|
27
28
|
'core/heading': [ 'content' ],
|
|
28
29
|
'core/image': [ 'url', 'title', 'alt' ],
|
|
29
30
|
'core/button': [ 'url', 'text', 'linkTarget' ],
|
|
30
31
|
};
|
|
31
32
|
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
33
|
+
/**
|
|
34
|
+
* Based on the given block name,
|
|
35
|
+
* check if it is possible to bind the block.
|
|
36
|
+
*
|
|
37
|
+
* @param {string} blockName - The block name.
|
|
38
|
+
* @return {boolean} Whether it is possible to bind the block to sources.
|
|
39
|
+
*/
|
|
40
|
+
export function canBindBlock( blockName ) {
|
|
41
|
+
return blockName in BLOCK_BINDINGS_ALLOWED_BLOCKS;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
/**
|
|
45
|
+
* Based on the given block name and attribute name,
|
|
46
|
+
* check if it is possible to bind the block attribute.
|
|
47
|
+
*
|
|
48
|
+
* @param {string} blockName - The block name.
|
|
49
|
+
* @param {string} attributeName - The attribute name.
|
|
50
|
+
* @return {boolean} Whether it is possible to bind the block attribute.
|
|
51
|
+
*/
|
|
52
|
+
export function canBindAttribute( blockName, attributeName ) {
|
|
53
|
+
return (
|
|
54
|
+
canBindBlock( blockName ) &&
|
|
55
|
+
BLOCK_BINDINGS_ALLOWED_BLOCKS[ blockName ].includes( attributeName )
|
|
56
|
+
);
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
/**
|
|
60
|
+
* This component is responsible for detecting and
|
|
61
|
+
* propagating data changes from the source to the block.
|
|
62
|
+
*
|
|
63
|
+
* @param {Object} props - The component props.
|
|
64
|
+
* @param {string} props.attrName - The attribute name.
|
|
65
|
+
* @param {Object} props.blockProps - The block props with bound attribute.
|
|
66
|
+
* @param {Object} props.source - Source handler.
|
|
67
|
+
* @param {Object} props.args - The arguments to pass to the source.
|
|
68
|
+
* @param {Function} props.onPropValueChange - The function to call when the attribute value changes.
|
|
69
|
+
* @return {null} Data-handling component. Render nothing.
|
|
70
|
+
*/
|
|
71
|
+
const BindingConnector = ( {
|
|
72
|
+
args,
|
|
73
|
+
attrName,
|
|
74
|
+
blockProps,
|
|
75
|
+
source,
|
|
76
|
+
onPropValueChange,
|
|
77
|
+
} ) => {
|
|
78
|
+
const { placeholder, value: propValue } = source.useSource(
|
|
79
|
+
blockProps,
|
|
80
|
+
args
|
|
81
|
+
);
|
|
82
|
+
|
|
83
|
+
const { name: blockName } = blockProps;
|
|
84
|
+
const attrValue = blockProps.attributes[ attrName ];
|
|
85
|
+
|
|
86
|
+
const updateBoundAttibute = useCallback(
|
|
87
|
+
( newAttrValue, prevAttrValue ) => {
|
|
88
|
+
/*
|
|
89
|
+
* If the attribute is a RichTextData instance,
|
|
90
|
+
* (core/paragraph, core/heading, core/button, etc.)
|
|
91
|
+
* compare its HTML representation with the new value.
|
|
92
|
+
*
|
|
93
|
+
* To do: it looks like a workaround.
|
|
94
|
+
* Consider improving the attribute and metadata fields types.
|
|
95
|
+
*/
|
|
96
|
+
if ( prevAttrValue instanceof RichTextData ) {
|
|
97
|
+
// Bail early if the Rich Text value is the same.
|
|
98
|
+
if ( prevAttrValue.toHTMLString() === newAttrValue ) {
|
|
99
|
+
return;
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
/*
|
|
103
|
+
* To preserve the value type,
|
|
104
|
+
* convert the new value to a RichTextData instance.
|
|
105
|
+
*/
|
|
106
|
+
newAttrValue = RichTextData.fromHTMLString( newAttrValue );
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
if ( prevAttrValue === newAttrValue ) {
|
|
110
|
+
return;
|
|
80
111
|
}
|
|
81
112
|
|
|
82
|
-
|
|
113
|
+
onPropValueChange( { [ attrName ]: newAttrValue } );
|
|
114
|
+
},
|
|
115
|
+
[ attrName, onPropValueChange ]
|
|
116
|
+
);
|
|
117
|
+
|
|
118
|
+
useLayoutEffect( () => {
|
|
119
|
+
if ( typeof propValue !== 'undefined' ) {
|
|
120
|
+
updateBoundAttibute( propValue, attrValue );
|
|
121
|
+
} else if ( placeholder ) {
|
|
122
|
+
/*
|
|
123
|
+
* Placeholder fallback.
|
|
124
|
+
* If the attribute is `src` or `href`,
|
|
125
|
+
* a placeholder can't be used because it is not a valid url.
|
|
126
|
+
* Adding this workaround until
|
|
127
|
+
* attributes and metadata fields types are improved and include `url`.
|
|
128
|
+
*/
|
|
129
|
+
const htmlAttribute =
|
|
130
|
+
getBlockType( blockName ).attributes[ attrName ].attribute;
|
|
131
|
+
|
|
132
|
+
if ( htmlAttribute === 'src' || htmlAttribute === 'href' ) {
|
|
133
|
+
updateBoundAttibute( null );
|
|
134
|
+
return;
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
updateBoundAttibute( placeholder );
|
|
138
|
+
}
|
|
139
|
+
}, [
|
|
140
|
+
updateBoundAttibute,
|
|
141
|
+
propValue,
|
|
142
|
+
attrValue,
|
|
143
|
+
placeholder,
|
|
144
|
+
blockName,
|
|
145
|
+
attrName,
|
|
146
|
+
] );
|
|
147
|
+
|
|
148
|
+
return null;
|
|
149
|
+
};
|
|
150
|
+
|
|
151
|
+
/**
|
|
152
|
+
* BlockBindingBridge acts like a component wrapper
|
|
153
|
+
* that connects the bound attributes of a block
|
|
154
|
+
* to the source handlers.
|
|
155
|
+
* For this, it creates a BindingConnector for each bound attribute.
|
|
156
|
+
*
|
|
157
|
+
* @param {Object} props - The component props.
|
|
158
|
+
* @param {Object} props.blockProps - The BlockEdit props object.
|
|
159
|
+
* @param {Object} props.bindings - The block bindings settings.
|
|
160
|
+
* @param {Function} props.onPropValueChange - The function to call when the attribute value changes.
|
|
161
|
+
* @return {null} Data-handling component. Render nothing.
|
|
162
|
+
*/
|
|
163
|
+
function BlockBindingBridge( { blockProps, bindings, onPropValueChange } ) {
|
|
164
|
+
const blockBindingsSources = unlock(
|
|
165
|
+
useSelect( blocksStore )
|
|
166
|
+
).getAllBlockBindingsSources();
|
|
167
|
+
|
|
168
|
+
return (
|
|
169
|
+
<>
|
|
170
|
+
{ Object.entries( bindings ).map(
|
|
171
|
+
( [ attrName, boundAttribute ] ) => {
|
|
172
|
+
// Bail early if the block doesn't have a valid source handler.
|
|
173
|
+
const source =
|
|
174
|
+
blockBindingsSources[ boundAttribute.source ];
|
|
175
|
+
if ( ! source?.useSource ) {
|
|
176
|
+
return null;
|
|
177
|
+
}
|
|
178
|
+
|
|
179
|
+
return (
|
|
180
|
+
<BindingConnector
|
|
181
|
+
key={ attrName }
|
|
182
|
+
attrName={ attrName }
|
|
183
|
+
source={ source }
|
|
184
|
+
blockProps={ blockProps }
|
|
185
|
+
args={ boundAttribute.args }
|
|
186
|
+
onPropValueChange={ onPropValueChange }
|
|
187
|
+
/>
|
|
188
|
+
);
|
|
189
|
+
}
|
|
190
|
+
) }
|
|
191
|
+
</>
|
|
192
|
+
);
|
|
193
|
+
}
|
|
194
|
+
|
|
195
|
+
const withBlockBindingSupport = createHigherOrderComponent(
|
|
196
|
+
( BlockEdit ) => ( props ) => {
|
|
197
|
+
/*
|
|
198
|
+
* Collect and update the bound attributes
|
|
199
|
+
* in a separate state.
|
|
200
|
+
*/
|
|
201
|
+
const [ boundAttributes, setBoundAttributes ] = useState( {} );
|
|
202
|
+
const updateBoundAttributes = useCallback(
|
|
203
|
+
( newAttributes ) =>
|
|
204
|
+
setBoundAttributes( ( prev ) => ( {
|
|
205
|
+
...prev,
|
|
206
|
+
...newAttributes,
|
|
207
|
+
} ) ),
|
|
208
|
+
[]
|
|
209
|
+
);
|
|
210
|
+
|
|
211
|
+
/*
|
|
212
|
+
* Create binding object filtering
|
|
213
|
+
* only the attributes that can be bound.
|
|
214
|
+
*/
|
|
215
|
+
const bindings = Object.fromEntries(
|
|
216
|
+
Object.entries( props.attributes.metadata?.bindings || {} ).filter(
|
|
217
|
+
( [ attrName ] ) => canBindAttribute( props.name, attrName )
|
|
218
|
+
)
|
|
219
|
+
);
|
|
220
|
+
|
|
221
|
+
return (
|
|
222
|
+
<>
|
|
223
|
+
{ Object.keys( bindings ).length > 0 && (
|
|
224
|
+
<BlockBindingBridge
|
|
225
|
+
blockProps={ props }
|
|
226
|
+
bindings={ bindings }
|
|
227
|
+
onPropValueChange={ updateBoundAttributes }
|
|
228
|
+
/>
|
|
229
|
+
) }
|
|
230
|
+
|
|
83
231
|
<BlockEdit
|
|
84
|
-
key="edit"
|
|
85
232
|
{ ...props }
|
|
86
|
-
attributes={
|
|
233
|
+
attributes={ { ...props.attributes, ...boundAttributes } }
|
|
87
234
|
/>
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
235
|
+
</>
|
|
236
|
+
);
|
|
237
|
+
},
|
|
238
|
+
'withBlockBindingSupport'
|
|
239
|
+
);
|
|
92
240
|
|
|
93
241
|
/**
|
|
94
242
|
* Filters a registered block's settings to enhance a block's `edit` component
|
|
95
243
|
* to upgrade bound attributes.
|
|
96
244
|
*
|
|
97
|
-
* @param {WPBlockSettings} settings Registered block settings.
|
|
98
|
-
*
|
|
245
|
+
* @param {WPBlockSettings} settings - Registered block settings.
|
|
246
|
+
* @param {string} name - Block name.
|
|
99
247
|
* @return {WPBlockSettings} Filtered block settings.
|
|
100
248
|
*/
|
|
101
|
-
function shimAttributeSource( settings ) {
|
|
102
|
-
if ( ! (
|
|
249
|
+
function shimAttributeSource( settings, name ) {
|
|
250
|
+
if ( ! canBindBlock( name ) ) {
|
|
103
251
|
return settings;
|
|
104
252
|
}
|
|
105
|
-
settings.edit = createEditFunctionWithBindingsAttribute()( settings.edit );
|
|
106
253
|
|
|
107
|
-
return
|
|
254
|
+
return {
|
|
255
|
+
...settings,
|
|
256
|
+
edit: withBlockBindingSupport( settings.edit ),
|
|
257
|
+
};
|
|
108
258
|
}
|
|
109
259
|
|
|
110
260
|
addFilter(
|
|
@@ -13,10 +13,7 @@ import { privateApis as componentsPrivateApis } from '@wordpress/components';
|
|
|
13
13
|
*/
|
|
14
14
|
import { getInlineStyles } from './style';
|
|
15
15
|
import { getFontSizeClass } from '../components/font-sizes';
|
|
16
|
-
import {
|
|
17
|
-
getTypographyFontSizeValue,
|
|
18
|
-
getFluidTypographyOptionsFromSettings,
|
|
19
|
-
} from '../components/global-styles/typography-utils';
|
|
16
|
+
import { getTypographyFontSizeValue } from '../components/global-styles/typography-utils';
|
|
20
17
|
import { unlock } from '../lock-unlock';
|
|
21
18
|
|
|
22
19
|
/*
|
|
@@ -36,14 +33,11 @@ import { unlock } from '../lock-unlock';
|
|
|
36
33
|
export function getTypographyClassesAndStyles( attributes, settings ) {
|
|
37
34
|
const { kebabCase } = unlock( componentsPrivateApis );
|
|
38
35
|
let typographyStyles = attributes?.style?.typography || {};
|
|
39
|
-
const fluidTypographySettings =
|
|
40
|
-
getFluidTypographyOptionsFromSettings( settings );
|
|
41
|
-
|
|
42
36
|
typographyStyles = {
|
|
43
37
|
...typographyStyles,
|
|
44
38
|
fontSize: getTypographyFontSizeValue(
|
|
45
39
|
{ size: attributes?.style?.typography?.fontSize },
|
|
46
|
-
|
|
40
|
+
settings
|
|
47
41
|
),
|
|
48
42
|
};
|
|
49
43
|
|
package/src/layouts/grid.js
CHANGED
|
@@ -23,6 +23,7 @@ import { appendSelectors, getBlockGapCSS } from './utils';
|
|
|
23
23
|
import { getGapCSSValue } from '../hooks/gap';
|
|
24
24
|
import { shouldSkipSerialization } from '../hooks/utils';
|
|
25
25
|
import { LAYOUT_DEFINITIONS } from './definitions';
|
|
26
|
+
import { GridVisualizer } from '../components/grid-visualizer';
|
|
26
27
|
|
|
27
28
|
const RANGE_CONTROL_MAX_VALUES = {
|
|
28
29
|
px: 600,
|
|
@@ -67,6 +68,7 @@ export default {
|
|
|
67
68
|
inspectorControls: function GridLayoutInspectorControls( {
|
|
68
69
|
layout = {},
|
|
69
70
|
onChange,
|
|
71
|
+
clientId,
|
|
70
72
|
} ) {
|
|
71
73
|
return (
|
|
72
74
|
<>
|
|
@@ -85,10 +87,13 @@ export default {
|
|
|
85
87
|
onChange={ onChange }
|
|
86
88
|
/>
|
|
87
89
|
) }
|
|
90
|
+
{ window.__experimentalEnableGridInteractivity && (
|
|
91
|
+
<GridVisualizer clientId={ clientId } />
|
|
92
|
+
) }
|
|
88
93
|
</>
|
|
89
94
|
);
|
|
90
95
|
},
|
|
91
|
-
toolBarControls: function
|
|
96
|
+
toolBarControls: function GridLayoutToolbarControls() {
|
|
92
97
|
return null;
|
|
93
98
|
},
|
|
94
99
|
getLayoutStyle: function getLayoutStyle( {
|
|
@@ -305,11 +310,11 @@ function GridLayoutTypeControl( { layout, onChange } ) {
|
|
|
305
310
|
|
|
306
311
|
return (
|
|
307
312
|
<ToggleGroupControl
|
|
308
|
-
__nextHasNoMarginBottom
|
|
313
|
+
__nextHasNoMarginBottom
|
|
309
314
|
label={ __( 'Type' ) }
|
|
310
315
|
value={ isManual }
|
|
311
316
|
onChange={ onChangeType }
|
|
312
|
-
isBlock
|
|
317
|
+
isBlock
|
|
313
318
|
>
|
|
314
319
|
<ToggleGroupControlOption
|
|
315
320
|
key={ 'auto' }
|
package/src/private-apis.js
CHANGED
|
@@ -10,7 +10,7 @@ import { ComposedPrivateInserter as PrivateInserter } from './components/inserte
|
|
|
10
10
|
import { default as PrivateQuickInserter } from './components/inserter/quick-inserter';
|
|
11
11
|
import { PrivateListView } from './components/list-view';
|
|
12
12
|
import BlockInfo from './components/block-info-slot-fill';
|
|
13
|
-
import {
|
|
13
|
+
import { useShowBlockTools } from './components/block-tools/use-show-block-tools';
|
|
14
14
|
import { cleanEmptyObject, useStyleOverride } from './hooks/utils';
|
|
15
15
|
import BlockQuickNavigation from './components/block-quick-navigation';
|
|
16
16
|
import { LayoutStyle } from './components/block-list/layout';
|
|
@@ -27,6 +27,8 @@ import { ExperimentalBlockCanvas } from './components/block-canvas';
|
|
|
27
27
|
import { getDuotoneFilter } from './components/duotone/utils';
|
|
28
28
|
import { useFlashEditableBlocks } from './components/use-flash-editable-blocks';
|
|
29
29
|
import { selectBlockPatternsKey } from './store/private-keys';
|
|
30
|
+
import { requiresWrapperOnCopy } from './components/writing-flow/utils';
|
|
31
|
+
import { PrivateRichText } from './components/rich-text/';
|
|
30
32
|
|
|
31
33
|
/**
|
|
32
34
|
* Private @wordpress/block-editor APIs.
|
|
@@ -43,7 +45,7 @@ lock( privateApis, {
|
|
|
43
45
|
PrivateListView,
|
|
44
46
|
ResizableBoxPopover,
|
|
45
47
|
BlockInfo,
|
|
46
|
-
|
|
48
|
+
useShowBlockTools,
|
|
47
49
|
cleanEmptyObject,
|
|
48
50
|
useStyleOverride,
|
|
49
51
|
BlockQuickNavigation,
|
|
@@ -58,4 +60,6 @@ lock( privateApis, {
|
|
|
58
60
|
usesContextKey,
|
|
59
61
|
useFlashEditableBlocks,
|
|
60
62
|
selectBlockPatternsKey,
|
|
63
|
+
requiresWrapperOnCopy,
|
|
64
|
+
PrivateRichText,
|
|
61
65
|
} );
|
package/src/store/actions.js
CHANGED
|
@@ -924,10 +924,8 @@ export const __unstableExpandSelection =
|
|
|
924
924
|
export const mergeBlocks =
|
|
925
925
|
( firstBlockClientId, secondBlockClientId ) =>
|
|
926
926
|
( { registry, select, dispatch } ) => {
|
|
927
|
-
const
|
|
928
|
-
|
|
929
|
-
|
|
930
|
-
const [ clientIdA, clientIdB ] = blocks;
|
|
927
|
+
const clientIdA = firstBlockClientId;
|
|
928
|
+
const clientIdB = secondBlockClientId;
|
|
931
929
|
const blockA = select.getBlock( clientIdA );
|
|
932
930
|
const blockAType = getBlockType( blockA.name );
|
|
933
931
|
|
|
@@ -1539,7 +1537,7 @@ export const duplicateBlocks =
|
|
|
1539
1537
|
};
|
|
1540
1538
|
|
|
1541
1539
|
/**
|
|
1542
|
-
* Action that inserts
|
|
1540
|
+
* Action that inserts a default block before a given block.
|
|
1543
1541
|
*
|
|
1544
1542
|
* @param {string} clientId
|
|
1545
1543
|
*/
|
|
@@ -1555,16 +1553,34 @@ export const insertBeforeBlock =
|
|
|
1555
1553
|
return;
|
|
1556
1554
|
}
|
|
1557
1555
|
|
|
1558
|
-
const
|
|
1559
|
-
|
|
1560
|
-
|
|
1561
|
-
|
|
1562
|
-
|
|
1563
|
-
)
|
|
1556
|
+
const blockIndex = select.getBlockIndex( clientId );
|
|
1557
|
+
const directInsertBlock = rootClientId
|
|
1558
|
+
? select.getDirectInsertBlock( rootClientId )
|
|
1559
|
+
: null;
|
|
1560
|
+
|
|
1561
|
+
if ( ! directInsertBlock ) {
|
|
1562
|
+
return dispatch.insertDefaultBlock( {}, rootClientId, blockIndex );
|
|
1563
|
+
}
|
|
1564
|
+
|
|
1565
|
+
const copiedAttributes = {};
|
|
1566
|
+
if ( directInsertBlock.attributesToCopy ) {
|
|
1567
|
+
const attributes = select.getBlockAttributes( clientId );
|
|
1568
|
+
directInsertBlock.attributesToCopy.forEach( ( key ) => {
|
|
1569
|
+
if ( attributes[ key ] ) {
|
|
1570
|
+
copiedAttributes[ key ] = attributes[ key ];
|
|
1571
|
+
}
|
|
1572
|
+
} );
|
|
1573
|
+
}
|
|
1574
|
+
|
|
1575
|
+
const block = createBlock( directInsertBlock.name, {
|
|
1576
|
+
...directInsertBlock.attributes,
|
|
1577
|
+
...copiedAttributes,
|
|
1578
|
+
} );
|
|
1579
|
+
return dispatch.insertBlock( block, blockIndex, rootClientId );
|
|
1564
1580
|
};
|
|
1565
1581
|
|
|
1566
1582
|
/**
|
|
1567
|
-
* Action that inserts
|
|
1583
|
+
* Action that inserts a default block after a given block.
|
|
1568
1584
|
*
|
|
1569
1585
|
* @param {string} clientId
|
|
1570
1586
|
*/
|
|
@@ -1580,12 +1596,34 @@ export const insertAfterBlock =
|
|
|
1580
1596
|
return;
|
|
1581
1597
|
}
|
|
1582
1598
|
|
|
1583
|
-
const
|
|
1584
|
-
|
|
1585
|
-
|
|
1586
|
-
|
|
1587
|
-
|
|
1588
|
-
)
|
|
1599
|
+
const blockIndex = select.getBlockIndex( clientId );
|
|
1600
|
+
const directInsertBlock = rootClientId
|
|
1601
|
+
? select.getDirectInsertBlock( rootClientId )
|
|
1602
|
+
: null;
|
|
1603
|
+
|
|
1604
|
+
if ( ! directInsertBlock ) {
|
|
1605
|
+
return dispatch.insertDefaultBlock(
|
|
1606
|
+
{},
|
|
1607
|
+
rootClientId,
|
|
1608
|
+
blockIndex + 1
|
|
1609
|
+
);
|
|
1610
|
+
}
|
|
1611
|
+
|
|
1612
|
+
const copiedAttributes = {};
|
|
1613
|
+
if ( directInsertBlock.attributesToCopy ) {
|
|
1614
|
+
const attributes = select.getBlockAttributes( clientId );
|
|
1615
|
+
directInsertBlock.attributesToCopy.forEach( ( key ) => {
|
|
1616
|
+
if ( attributes[ key ] ) {
|
|
1617
|
+
copiedAttributes[ key ] = attributes[ key ];
|
|
1618
|
+
}
|
|
1619
|
+
} );
|
|
1620
|
+
}
|
|
1621
|
+
|
|
1622
|
+
const block = createBlock( directInsertBlock.name, {
|
|
1623
|
+
...directInsertBlock.attributes,
|
|
1624
|
+
...copiedAttributes,
|
|
1625
|
+
} );
|
|
1626
|
+
return dispatch.insertBlock( block, blockIndex + 1, rootClientId );
|
|
1589
1627
|
};
|
|
1590
1628
|
|
|
1591
1629
|
/**
|
|
@@ -123,61 +123,36 @@ export const privateRemoveBlocks =
|
|
|
123
123
|
//
|
|
124
124
|
// @see https://github.com/WordPress/gutenberg/pull/51145
|
|
125
125
|
const rules = ! forceRemove && select.getBlockRemovalRules();
|
|
126
|
-
if ( rules ) {
|
|
127
|
-
const blockNamesForPrompt = new Set();
|
|
128
|
-
|
|
129
|
-
// Given a list of client IDs of blocks that the user intended to
|
|
130
|
-
// remove, perform a tree search (BFS) to find all block names
|
|
131
|
-
// corresponding to "important" blocks, i.e. blocks that require a
|
|
132
|
-
// removal prompt.
|
|
133
|
-
const queue = [ ...clientIds ];
|
|
134
|
-
let messageType = 'templates';
|
|
135
|
-
while ( queue.length ) {
|
|
136
|
-
const clientId = queue.shift();
|
|
137
|
-
const blockName = select.getBlockName( clientId );
|
|
138
|
-
if ( rules[ blockName ] ) {
|
|
139
|
-
blockNamesForPrompt.add( blockName );
|
|
140
|
-
}
|
|
141
126
|
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
continue;
|
|
151
|
-
}
|
|
152
|
-
const blockAttributes =
|
|
153
|
-
select.getBlockAttributes( clientId );
|
|
154
|
-
if (
|
|
155
|
-
blockAttributes?.metadata?.bindings &&
|
|
156
|
-
JSON.stringify(
|
|
157
|
-
blockAttributes.metadata.bindings
|
|
158
|
-
).includes( 'core/pattern-overrides' )
|
|
159
|
-
) {
|
|
160
|
-
blockNamesForPrompt.add( blockName );
|
|
161
|
-
messageType = 'patternOverrides';
|
|
162
|
-
}
|
|
127
|
+
if ( rules ) {
|
|
128
|
+
function flattenBlocks( blocks ) {
|
|
129
|
+
const result = [];
|
|
130
|
+
const stack = [ ...blocks ];
|
|
131
|
+
while ( stack.length ) {
|
|
132
|
+
const { innerBlocks, ...block } = stack.shift();
|
|
133
|
+
stack.push( ...innerBlocks );
|
|
134
|
+
result.push( block );
|
|
163
135
|
}
|
|
164
|
-
|
|
165
|
-
const innerBlocks = select.getBlockOrder( clientId );
|
|
166
|
-
queue.push( ...innerBlocks );
|
|
136
|
+
return result;
|
|
167
137
|
}
|
|
168
138
|
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
139
|
+
const blockList = clientIds.map( select.getBlock );
|
|
140
|
+
const flattenedBlocks = flattenBlocks( blockList );
|
|
141
|
+
|
|
142
|
+
// Find the first message and use it.
|
|
143
|
+
let message;
|
|
144
|
+
for ( const rule of rules ) {
|
|
145
|
+
message = rule.callback( flattenedBlocks );
|
|
146
|
+
if ( message ) {
|
|
147
|
+
dispatch(
|
|
148
|
+
displayBlockRemovalPrompt(
|
|
149
|
+
clientIds,
|
|
150
|
+
selectPrevious,
|
|
151
|
+
message
|
|
152
|
+
)
|
|
153
|
+
);
|
|
154
|
+
return;
|
|
155
|
+
}
|
|
181
156
|
}
|
|
182
157
|
}
|
|
183
158
|
|
|
@@ -228,31 +203,21 @@ export const ensureDefaultBlock =
|
|
|
228
203
|
*
|
|
229
204
|
* Contrast with `setBlockRemovalRules`.
|
|
230
205
|
*
|
|
231
|
-
* @param {string|string[]} clientIds
|
|
232
|
-
* @param {boolean} selectPrevious
|
|
233
|
-
*
|
|
234
|
-
*
|
|
235
|
-
*
|
|
236
|
-
*
|
|
237
|
-
* @param {string[]} blockNamesForPrompt Names of the blocks that
|
|
238
|
-
* triggered the need for
|
|
239
|
-
* confirmation before removal.
|
|
240
|
-
* @param {string} messageType The type of message to display.
|
|
206
|
+
* @param {string|string[]} clientIds Client IDs of blocks to remove.
|
|
207
|
+
* @param {boolean} selectPrevious True if the previous block or the
|
|
208
|
+
* immediate parent (if no previous
|
|
209
|
+
* block exists) should be selected
|
|
210
|
+
* when a block is removed.
|
|
211
|
+
* @param {string} message Message to display in the prompt.
|
|
241
212
|
*
|
|
242
213
|
* @return {Object} Action object.
|
|
243
214
|
*/
|
|
244
|
-
function displayBlockRemovalPrompt(
|
|
245
|
-
clientIds,
|
|
246
|
-
selectPrevious,
|
|
247
|
-
blockNamesForPrompt,
|
|
248
|
-
messageType
|
|
249
|
-
) {
|
|
215
|
+
function displayBlockRemovalPrompt( clientIds, selectPrevious, message ) {
|
|
250
216
|
return {
|
|
251
217
|
type: 'DISPLAY_BLOCK_REMOVAL_PROMPT',
|
|
252
218
|
clientIds,
|
|
253
219
|
selectPrevious,
|
|
254
|
-
|
|
255
|
-
messageType,
|
|
220
|
+
message,
|
|
256
221
|
};
|
|
257
222
|
}
|
|
258
223
|
|
|
@@ -390,16 +355,6 @@ export function stopEditingAsBlocks( clientId ) {
|
|
|
390
355
|
};
|
|
391
356
|
}
|
|
392
357
|
|
|
393
|
-
export function registerBlockBindingsSource( source ) {
|
|
394
|
-
return {
|
|
395
|
-
type: 'REGISTER_BLOCK_BINDINGS_SOURCE',
|
|
396
|
-
sourceName: source.name,
|
|
397
|
-
sourceLabel: source.label,
|
|
398
|
-
useSource: source.useSource,
|
|
399
|
-
lockAttributesEditing: source.lockAttributesEditing,
|
|
400
|
-
};
|
|
401
|
-
}
|
|
402
|
-
|
|
403
358
|
/**
|
|
404
359
|
* Returns an action object used in signalling that the user has begun to drag.
|
|
405
360
|
*
|