@wordpress/block-editor 12.20.0 → 12.22.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +4 -0
- package/build/components/block-actions/index.js +47 -36
- 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-heading-level-dropdown/index.js +5 -5
- package/build/components/block-heading-level-dropdown/index.js.map +1 -1
- package/build/components/block-heading-level-dropdown/index.native.js +5 -4
- package/build/components/block-heading-level-dropdown/index.native.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-crash-boundary.native.js +49 -0
- package/build/components/block-list/block-crash-boundary.native.js.map +1 -0
- package/build/components/block-list/block-crash-warning.native.js +24 -0
- package/build/components/block-list/block-crash-warning.native.js.map +1 -0
- 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 +7 -5
- 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/container.native.js +2 -1
- package/build/components/block-settings/container.native.js.map +1 -1
- package/build/components/block-settings-menu/block-settings-dropdown.js +41 -39
- package/build/components/block-settings-menu/block-settings-dropdown.js.map +1 -1
- package/build/components/block-settings-menu-controls/index.js +1 -3
- package/build/components/block-settings-menu-controls/index.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 +24 -11
- 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 +108 -11
- 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/convert-to-group-buttons/toolbar.js +11 -0
- package/build/components/convert-to-group-buttons/toolbar.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/dimensions-panel.js +8 -33
- package/build/components/global-styles/dimensions-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 +16 -16
- package/build/components/global-styles/use-global-styles-output.js.map +1 -1
- package/build/components/global-styles/utils.js +2 -4
- 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 +66 -17
- 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/block-patterns-explorer/index.js +3 -6
- package/build/components/inserter/block-patterns-explorer/index.js.map +1 -1
- package/build/components/inserter/block-patterns-explorer/pattern-list.js +3 -1
- package/build/components/inserter/block-patterns-explorer/pattern-list.js.map +1 -1
- package/build/components/inserter/media-tab/media-preview.js.map +1 -1
- package/build/components/inserter/menu.native.js.map +1 -1
- package/build/components/inserter/mobile-tab-navigation.js +2 -2
- package/build/components/inserter/mobile-tab-navigation.js.map +1 -1
- package/build/components/inspector-controls/block-support-tools-panel.js.map +1 -1
- package/build/components/inspector-controls-tabs/advanced-controls-panel.native.js +36 -0
- package/build/components/inspector-controls-tabs/advanced-controls-panel.native.js.map +1 -0
- 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 +0 -2
- package/build/components/list-view/block-select-button.js.map +1 -1
- package/build/components/list-view/block.js +4 -11
- package/build/components/list-view/block.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/list-view/utils.js +5 -3
- package/build/components/list-view/utils.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/spacing-sizes-control/sides-dropdown/index.js +1 -1
- package/build/components/spacing-sizes-control/sides-dropdown/index.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/use-moving-animation/index.js +4 -0
- package/build/components/use-moving-animation/index.js.map +1 -1
- package/build/components/warning/index.native.js +9 -4
- package/build/components/warning/index.native.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/anchor.js +7 -8
- package/build/hooks/anchor.js.map +1 -1
- package/build/hooks/background.js +39 -2
- 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 +3 -2
- package/build/hooks/index.js.map +1 -1
- package/build/hooks/layout-child.js +67 -6
- package/build/hooks/layout-child.js.map +1 -1
- package/build/hooks/layout.js +32 -14
- package/build/hooks/layout.js.map +1 -1
- package/build/hooks/line-height.js.map +1 -1
- package/build/hooks/position.js +1 -1
- package/build/hooks/position.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/private-apis.native.js +3 -1
- package/build/private-apis.native.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 +34 -46
- 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-module/components/block-actions/index.js +47 -36
- 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-heading-level-dropdown/index.js +5 -5
- package/build-module/components/block-heading-level-dropdown/index.js.map +1 -1
- package/build-module/components/block-heading-level-dropdown/index.native.js +5 -4
- package/build-module/components/block-heading-level-dropdown/index.native.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-crash-boundary.native.js +42 -0
- package/build-module/components/block-list/block-crash-boundary.native.js.map +1 -0
- package/build-module/components/block-list/block-crash-warning.native.js +15 -0
- package/build-module/components/block-list/block-crash-warning.native.js.map +1 -0
- 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 +7 -5
- 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/container.native.js +3 -2
- package/build-module/components/block-settings/container.native.js.map +1 -1
- package/build-module/components/block-settings-menu/block-settings-dropdown.js +42 -40
- package/build-module/components/block-settings-menu/block-settings-dropdown.js.map +1 -1
- package/build-module/components/block-settings-menu-controls/index.js +1 -3
- package/build-module/components/block-settings-menu-controls/index.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 +24 -12
- 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 +109 -12
- 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/convert-to-group-buttons/toolbar.js +12 -1
- package/build-module/components/convert-to-group-buttons/toolbar.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/dimensions-panel.js +9 -34
- package/build-module/components/global-styles/dimensions-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 +17 -17
- package/build-module/components/global-styles/use-global-styles-output.js.map +1 -1
- package/build-module/components/global-styles/utils.js +2 -4
- 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 +66 -17
- 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/block-patterns-explorer/index.js +3 -6
- package/build-module/components/inserter/block-patterns-explorer/index.js.map +1 -1
- package/build-module/components/inserter/block-patterns-explorer/pattern-list.js +3 -1
- package/build-module/components/inserter/block-patterns-explorer/pattern-list.js.map +1 -1
- package/build-module/components/inserter/media-tab/media-preview.js.map +1 -1
- package/build-module/components/inserter/menu.native.js.map +1 -1
- package/build-module/components/inserter/mobile-tab-navigation.js +2 -2
- package/build-module/components/inserter/mobile-tab-navigation.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/advanced-controls-panel.native.js +28 -0
- package/build-module/components/inspector-controls-tabs/advanced-controls-panel.native.js.map +1 -0
- 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 +0 -2
- package/build-module/components/list-view/block-select-button.js.map +1 -1
- package/build-module/components/list-view/block.js +6 -13
- package/build-module/components/list-view/block.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/list-view/utils.js +2 -1
- package/build-module/components/list-view/utils.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/spacing-sizes-control/sides-dropdown/index.js +1 -1
- package/build-module/components/spacing-sizes-control/sides-dropdown/index.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/use-moving-animation/index.js +4 -0
- package/build-module/components/use-moving-animation/index.js.map +1 -1
- package/build-module/components/warning/index.native.js +9 -4
- package/build-module/components/warning/index.native.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/anchor.js +8 -9
- package/build-module/hooks/anchor.js.map +1 -1
- package/build-module/hooks/background.js +38 -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 +3 -2
- package/build-module/hooks/index.js.map +1 -1
- package/build-module/hooks/layout-child.js +67 -6
- package/build-module/hooks/layout-child.js.map +1 -1
- package/build-module/hooks/layout.js +32 -14
- package/build-module/hooks/layout.js.map +1 -1
- package/build-module/hooks/line-height.js.map +1 -1
- package/build-module/hooks/position.js +1 -1
- package/build-module/hooks/position.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/private-apis.native.js +3 -1
- package/build-module/private-apis.native.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 +34 -46
- 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-style/content-rtl.css +22 -2
- package/build-style/content.css +22 -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 +106 -27
- package/build-style/style.css +106 -27
- package/package.json +31 -31
- package/src/components/block-actions/index.js +59 -55
- package/src/components/block-bindings-toolbar-indicator/index.js +20 -0
- package/src/components/block-bindings-toolbar-indicator/style.scss +16 -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-heading-level-dropdown/README.md +5 -5
- package/src/components/block-heading-level-dropdown/index.js +5 -5
- package/src/components/block-heading-level-dropdown/index.native.js +5 -4
- package/src/components/block-inspector/index.js +7 -5
- package/src/components/block-list/block-crash-boundary.native.js +43 -0
- package/src/components/block-list/block-crash-warning.native.js +19 -0
- 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 +14 -10
- package/src/components/block-list/content.scss +21 -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/container.native.js +5 -1
- package/src/components/block-settings-menu/block-settings-dropdown.js +53 -65
- package/src/components/block-settings-menu-controls/README.md +0 -9
- package/src/components/block-settings-menu-controls/index.js +1 -6
- 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 +22 -16
- package/src/components/block-toolbar/shuffle.js +93 -0
- package/src/components/block-toolbar/test/index.native.js +1 -7
- 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 +148 -36
- 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/convert-to-group-buttons/toolbar.js +13 -1
- 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/dimensions-panel.js +9 -34
- 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/test/use-global-styles-output.js +31 -0
- package/src/components/global-styles/typography-utils.js +10 -7
- package/src/components/global-styles/use-global-styles-output.js +17 -17
- package/src/components/global-styles/utils.js +2 -26
- 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 +89 -26
- package/src/components/index.native.js +1 -0
- package/src/components/inner-blocks/use-nested-settings-update.js +12 -2
- package/src/components/inserter/block-patterns-explorer/index.js +2 -9
- package/src/components/inserter/block-patterns-explorer/pattern-list.js +7 -1
- package/src/components/inserter/media-tab/media-preview.js +1 -1
- package/src/components/inserter/menu.native.js +3 -3
- package/src/components/inserter/mobile-tab-navigation.js +2 -2
- package/src/components/inserter/style.scss +10 -0
- package/src/components/inspector-controls/block-support-tools-panel.js +2 -2
- package/src/components/inspector-controls-tabs/advanced-controls-panel.native.js +31 -0
- 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 -5
- package/src/components/list-view/block-select-button.js +0 -2
- package/src/components/list-view/block.js +12 -21
- 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 +34 -16
- package/src/components/list-view/use-clipboard-handler.js +3 -2
- package/src/components/list-view/utils.js +4 -1
- 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/README.md +6 -0
- 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/spacing-sizes-control/sides-dropdown/index.js +1 -1
- package/src/components/url-popover/index.js +5 -5
- package/src/components/url-popover/style.scss +1 -0
- package/src/components/use-moving-animation/index.js +1 -0
- package/src/components/warning/index.native.js +19 -15
- package/src/components/writing-flow/use-clipboard-handler.js +3 -2
- package/src/components/writing-flow/utils.js +31 -16
- package/src/hooks/anchor.js +41 -61
- package/src/hooks/background.js +49 -4
- 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 +3 -0
- package/src/hooks/layout-child.js +82 -8
- package/src/hooks/layout.js +34 -19
- package/src/hooks/line-height.js +1 -1
- package/src/hooks/position.js +1 -1
- package/src/hooks/spacing-visualizer.js +126 -0
- package/src/hooks/{padding.scss → spacing.scss} +1 -1
- package/src/hooks/test/__snapshots__/anchor.native.js.snap +7 -0
- package/src/hooks/test/anchor.native.js +32 -0
- 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/private-apis.native.js +2 -0
- 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 +43 -64
- package/src/store/selectors.js +41 -46
- package/src/store/test/actions.js +0 -4
- package/src/style.scss +3 -1
- package/tsconfig.json +1 -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
|
@@ -0,0 +1,126 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* WordPress dependencies
|
|
3
|
+
*/
|
|
4
|
+
import {
|
|
5
|
+
useState,
|
|
6
|
+
useRef,
|
|
7
|
+
useLayoutEffect,
|
|
8
|
+
useEffect,
|
|
9
|
+
useReducer,
|
|
10
|
+
} from '@wordpress/element';
|
|
11
|
+
import isShallowEqual from '@wordpress/is-shallow-equal';
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* Internal dependencies
|
|
15
|
+
*/
|
|
16
|
+
import BlockPopoverCover from '../components/block-popover/cover';
|
|
17
|
+
import { __unstableUseBlockElement as useBlockElement } from '../components/block-list/use-block-props/use-block-refs';
|
|
18
|
+
|
|
19
|
+
function SpacingVisualizer( { clientId, value, computeStyle, forceShow } ) {
|
|
20
|
+
const blockElement = useBlockElement( clientId );
|
|
21
|
+
const [ style, updateStyle ] = useReducer( () =>
|
|
22
|
+
computeStyle( blockElement )
|
|
23
|
+
);
|
|
24
|
+
|
|
25
|
+
useLayoutEffect( () => {
|
|
26
|
+
if ( ! blockElement ) {
|
|
27
|
+
return;
|
|
28
|
+
}
|
|
29
|
+
// It's not sufficient to read the computed spacing value when value.spacing changes as
|
|
30
|
+
// useEffect may run before the browser recomputes CSS. We therefore combine
|
|
31
|
+
// useLayoutEffect and two rAF calls to ensure that we read the spacing after the current
|
|
32
|
+
// paint but before the next paint.
|
|
33
|
+
// See https://github.com/WordPress/gutenberg/pull/59227.
|
|
34
|
+
window.requestAnimationFrame( () =>
|
|
35
|
+
window.requestAnimationFrame( updateStyle )
|
|
36
|
+
);
|
|
37
|
+
}, [ blockElement, value ] );
|
|
38
|
+
|
|
39
|
+
const previousValue = useRef( value );
|
|
40
|
+
const [ isActive, setIsActive ] = useState( false );
|
|
41
|
+
|
|
42
|
+
useEffect( () => {
|
|
43
|
+
if ( isShallowEqual( value, previousValue.current ) || forceShow ) {
|
|
44
|
+
return;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
setIsActive( true );
|
|
48
|
+
previousValue.current = value;
|
|
49
|
+
|
|
50
|
+
const timeout = setTimeout( () => {
|
|
51
|
+
setIsActive( false );
|
|
52
|
+
}, 400 );
|
|
53
|
+
|
|
54
|
+
return () => {
|
|
55
|
+
setIsActive( false );
|
|
56
|
+
clearTimeout( timeout );
|
|
57
|
+
};
|
|
58
|
+
}, [ value, forceShow ] );
|
|
59
|
+
|
|
60
|
+
if ( ! isActive && ! forceShow ) {
|
|
61
|
+
return null;
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
return (
|
|
65
|
+
<BlockPopoverCover
|
|
66
|
+
clientId={ clientId }
|
|
67
|
+
__unstablePopoverSlot="block-toolbar"
|
|
68
|
+
>
|
|
69
|
+
<div className="block-editor__spacing-visualizer" style={ style } />
|
|
70
|
+
</BlockPopoverCover>
|
|
71
|
+
);
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
function getComputedCSS( element, property ) {
|
|
75
|
+
return element.ownerDocument.defaultView
|
|
76
|
+
.getComputedStyle( element )
|
|
77
|
+
.getPropertyValue( property );
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
export function MarginVisualizer( { clientId, value, forceShow } ) {
|
|
81
|
+
return (
|
|
82
|
+
<SpacingVisualizer
|
|
83
|
+
clientId={ clientId }
|
|
84
|
+
value={ value?.spacing?.margin }
|
|
85
|
+
computeStyle={ ( blockElement ) => {
|
|
86
|
+
const top = getComputedCSS( blockElement, 'margin-top' );
|
|
87
|
+
const right = getComputedCSS( blockElement, 'margin-right' );
|
|
88
|
+
const bottom = getComputedCSS( blockElement, 'margin-bottom' );
|
|
89
|
+
const left = getComputedCSS( blockElement, 'margin-left' );
|
|
90
|
+
return {
|
|
91
|
+
borderTopWidth: top,
|
|
92
|
+
borderRightWidth: right,
|
|
93
|
+
borderBottomWidth: bottom,
|
|
94
|
+
borderLeftWidth: left,
|
|
95
|
+
top: top ? `-${ top }` : 0,
|
|
96
|
+
right: right ? `-${ right }` : 0,
|
|
97
|
+
bottom: bottom ? `-${ bottom }` : 0,
|
|
98
|
+
left: left ? `-${ left }` : 0,
|
|
99
|
+
};
|
|
100
|
+
} }
|
|
101
|
+
forceShow={ forceShow }
|
|
102
|
+
/>
|
|
103
|
+
);
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
export function PaddingVisualizer( { clientId, value, forceShow } ) {
|
|
107
|
+
return (
|
|
108
|
+
<SpacingVisualizer
|
|
109
|
+
clientId={ clientId }
|
|
110
|
+
value={ value?.spacing?.padding }
|
|
111
|
+
computeStyle={ ( blockElement ) => ( {
|
|
112
|
+
borderTopWidth: getComputedCSS( blockElement, 'padding-top' ),
|
|
113
|
+
borderRightWidth: getComputedCSS(
|
|
114
|
+
blockElement,
|
|
115
|
+
'padding-right'
|
|
116
|
+
),
|
|
117
|
+
borderBottomWidth: getComputedCSS(
|
|
118
|
+
blockElement,
|
|
119
|
+
'padding-bottom'
|
|
120
|
+
),
|
|
121
|
+
borderLeftWidth: getComputedCSS( blockElement, 'padding-left' ),
|
|
122
|
+
} ) }
|
|
123
|
+
forceShow={ forceShow }
|
|
124
|
+
/>
|
|
125
|
+
);
|
|
126
|
+
}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* External dependencies
|
|
3
|
+
*/
|
|
4
|
+
import {
|
|
5
|
+
addBlock,
|
|
6
|
+
changeTextOfTextInput,
|
|
7
|
+
getEditorHtml,
|
|
8
|
+
initializeEditor,
|
|
9
|
+
openBlockSettings,
|
|
10
|
+
screen,
|
|
11
|
+
setupCoreBlocks,
|
|
12
|
+
} from 'test/helpers';
|
|
13
|
+
|
|
14
|
+
setupCoreBlocks( [ 'core/paragraph' ] );
|
|
15
|
+
|
|
16
|
+
describe( 'anchor', () => {
|
|
17
|
+
it( 'should set the ID attribute on the block', async () => {
|
|
18
|
+
// Arrange
|
|
19
|
+
await initializeEditor();
|
|
20
|
+
const block = await addBlock( screen, 'Paragraph' );
|
|
21
|
+
await openBlockSettings( screen, block );
|
|
22
|
+
|
|
23
|
+
// Act
|
|
24
|
+
await changeTextOfTextInput(
|
|
25
|
+
await screen.getByPlaceholderText( 'Add an anchor' ),
|
|
26
|
+
'my-anchor'
|
|
27
|
+
);
|
|
28
|
+
|
|
29
|
+
// Assert
|
|
30
|
+
expect( getEditorHtml() ).toMatchSnapshot();
|
|
31
|
+
} );
|
|
32
|
+
} );
|
|
@@ -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
|
} );
|
|
@@ -3,6 +3,7 @@
|
|
|
3
3
|
*/
|
|
4
4
|
import * as globalStyles from './components/global-styles';
|
|
5
5
|
import { ExperimentalBlockEditorProvider } from './components/provider';
|
|
6
|
+
import { getRichTextValues } from './components/rich-text/get-rich-text-values';
|
|
6
7
|
import { lock } from './lock-unlock';
|
|
7
8
|
|
|
8
9
|
/**
|
|
@@ -12,4 +13,5 @@ export const privateApis = {};
|
|
|
12
13
|
lock( privateApis, {
|
|
13
14
|
...globalStyles,
|
|
14
15
|
ExperimentalBlockEditorProvider,
|
|
16
|
+
getRichTextValues,
|
|
15
17
|
} );
|