@wordpress/block-editor 12.14.0 → 12.16.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +4 -0
- package/README.md +10 -5
- package/build/components/block-canvas/index.js +22 -6
- package/build/components/block-canvas/index.js.map +1 -1
- package/build/components/block-card/index.js +1 -1
- package/build/components/block-card/index.js.map +1 -1
- package/build/components/block-controls/hook.js +3 -23
- package/build/components/block-controls/hook.js.map +1 -1
- package/build/components/block-edit/context.js +5 -1
- package/build/components/block-edit/context.js.map +1 -1
- package/build/components/block-edit/index.js +18 -9
- package/build/components/block-edit/index.js.map +1 -1
- package/build/components/block-info-slot-fill/index.js +3 -4
- package/build/components/block-info-slot-fill/index.js.map +1 -1
- package/build/components/block-list/block.js +28 -9
- package/build/components/block-list/block.js.map +1 -1
- package/build/components/block-list/block.native.js +16 -5
- package/build/components/block-list/block.native.js.map +1 -1
- package/build/components/block-list/use-block-props/index.js +61 -18
- package/build/components/block-list/use-block-props/index.js.map +1 -1
- package/build/components/block-list/use-block-props/use-focus-first-element.js +4 -29
- package/build/components/block-list/use-block-props/use-focus-first-element.js.map +1 -1
- package/build/components/block-list/use-block-props/use-is-hovered.js +4 -14
- package/build/components/block-list/use-block-props/use-is-hovered.js.map +1 -1
- package/build/components/block-list/use-block-props/use-selected-block-event-handlers.js +4 -2
- package/build/components/block-list/use-block-props/use-selected-block-event-handlers.js.map +1 -1
- package/build/components/block-parent-selector/index.js +1 -1
- package/build/components/block-parent-selector/index.js.map +1 -1
- package/build/components/block-pattern-setup/index.js +25 -16
- package/build/components/block-pattern-setup/index.js.map +1 -1
- package/build/components/block-pattern-setup/setup-toolbar.js +4 -2
- package/build/components/block-pattern-setup/setup-toolbar.js.map +1 -1
- package/build/components/block-patterns-list/index.js +37 -20
- package/build/components/block-patterns-list/index.js.map +1 -1
- package/build/components/block-removal-warning-modal/index.js +2 -9
- package/build/components/block-removal-warning-modal/index.js.map +1 -1
- package/build/components/block-rename/index.js +28 -0
- package/build/components/block-rename/index.js.map +1 -0
- package/build/components/block-rename/is-empty-string.js +10 -0
- package/build/components/block-rename/is-empty-string.js.map +1 -0
- package/build/components/block-rename/modal.js +90 -0
- package/build/components/block-rename/modal.js.map +1 -0
- package/build/components/block-rename/rename-control.js +74 -0
- package/build/components/block-rename/rename-control.js.map +1 -0
- package/build/components/block-rename/use-block-rename.js +17 -0
- package/build/components/block-rename/use-block-rename.js.map +1 -0
- package/build/components/block-settings/container.native.js +6 -4
- package/build/components/block-settings/container.native.js.map +1 -1
- package/build/components/block-settings-menu/block-settings-dropdown.js +33 -20
- package/build/components/block-settings-menu/block-settings-dropdown.js.map +1 -1
- package/build/components/block-settings-menu-controls/index.js +7 -0
- package/build/components/block-settings-menu-controls/index.js.map +1 -1
- package/build/components/block-styles/index.js +1 -1
- package/build/components/block-styles/index.js.map +1 -1
- package/build/components/block-styles/index.native.js +3 -2
- package/build/components/block-styles/index.native.js.map +1 -1
- package/build/components/block-toolbar/block-toolbar-menu.native.js +1 -1
- package/build/components/block-toolbar/block-toolbar-menu.native.js.map +1 -1
- package/build/components/block-toolbar/index.js +89 -27
- package/build/components/block-toolbar/index.js.map +1 -1
- package/build/components/block-tools/block-toolbar-breadcrumb.js +49 -0
- package/build/components/block-tools/block-toolbar-breadcrumb.js.map +1 -0
- package/build/components/block-tools/block-toolbar-popover.js +86 -0
- package/build/components/block-tools/block-toolbar-popover.js.map +1 -0
- package/build/components/block-tools/index.js +27 -24
- package/build/components/block-tools/index.js.map +1 -1
- package/build/components/block-types-list/index.js +6 -2
- package/build/components/block-types-list/index.js.map +1 -1
- package/build/components/block-types-list/index.native.js +4 -3
- package/build/components/block-types-list/index.native.js.map +1 -1
- package/build/components/block-variation-picker/index.native.js +2 -1
- package/build/components/block-variation-picker/index.native.js.map +1 -1
- package/build/components/colors-gradients/control.js +28 -17
- package/build/components/colors-gradients/control.js.map +1 -1
- package/build/components/date-format-picker/index.js +8 -1
- package/build/components/date-format-picker/index.js.map +1 -1
- package/build/components/duotone-control/index.js +1 -4
- package/build/components/duotone-control/index.js.map +1 -1
- package/build/components/global-styles/advanced-panel.js +1 -1
- package/build/components/global-styles/advanced-panel.js.map +1 -1
- package/build/components/global-styles/color-panel.js +22 -20
- package/build/components/global-styles/color-panel.js.map +1 -1
- package/build/components/global-styles/filters-panel.js +9 -3
- package/build/components/global-styles/filters-panel.js.map +1 -1
- package/build/components/global-styles/typography-panel.js +20 -31
- package/build/components/global-styles/typography-panel.js.map +1 -1
- package/build/components/image-link-destinations/index.native.js +118 -0
- package/build/components/image-link-destinations/index.native.js.map +1 -0
- package/build/components/image-size-control/index.js +0 -5
- package/build/components/image-size-control/index.js.map +1 -1
- package/build/components/index.native.js +8 -0
- package/build/components/index.native.js.map +1 -1
- package/build/components/inner-blocks/index.js +3 -1
- package/build/components/inner-blocks/index.js.map +1 -1
- package/build/components/inner-blocks/warning-max-depth-exceeded.native.js +29 -31
- package/build/components/inner-blocks/warning-max-depth-exceeded.native.js.map +1 -1
- package/build/components/inserter/block-patterns-explorer/pattern-list.js +1 -1
- package/build/components/inserter/block-patterns-explorer/pattern-list.js.map +1 -1
- package/build/components/inserter/block-patterns-tab/pattern-category-previews.js +1 -1
- package/build/components/inserter/block-patterns-tab/pattern-category-previews.js.map +1 -1
- package/build/components/inserter/block-patterns-tab/use-pattern-categories.js +1 -1
- package/build/components/inserter/block-patterns-tab/use-pattern-categories.js.map +1 -1
- package/build/components/inserter/block-patterns-tab/utils.js +3 -4
- package/build/components/inserter/block-patterns-tab/utils.js.map +1 -1
- package/build/components/inserter/hooks/use-patterns-state.js +2 -1
- package/build/components/inserter/hooks/use-patterns-state.js.map +1 -1
- package/build/components/inserter/media-tab/media-panel.js +2 -2
- package/build/components/inserter/media-tab/media-panel.js.map +1 -1
- package/build/components/inserter/menu.js +14 -7
- package/build/components/inserter/menu.js.map +1 -1
- package/build/components/inserter/preview-panel.js +2 -2
- package/build/components/inserter/preview-panel.js.map +1 -1
- package/build/components/inserter-button/index.native.js +98 -0
- package/build/components/inserter-button/index.native.js.map +1 -0
- package/build/components/inserter-button/sparkles.js +23 -0
- package/build/components/inserter-button/sparkles.js.map +1 -0
- package/build/components/inserter-draggable-blocks/index.js +8 -4
- package/build/components/inserter-draggable-blocks/index.js.map +1 -1
- package/build/components/inserter-listbox/index.js +11 -6
- package/build/components/inserter-listbox/index.js.map +1 -1
- package/build/components/inserter-listbox/item.js +24 -23
- package/build/components/inserter-listbox/item.js.map +1 -1
- package/build/components/inserter-listbox/row.js +5 -5
- package/build/components/inserter-listbox/row.js.map +1 -1
- package/build/components/inspector-controls/fill.js +3 -3
- package/build/components/inspector-controls/fill.js.map +1 -1
- package/build/components/inspector-controls/fill.native.js +3 -3
- package/build/components/inspector-controls/fill.native.js.map +1 -1
- package/build/components/list-view/use-list-view-expand-selected-item.js +2 -3
- package/build/components/list-view/use-list-view-expand-selected-item.js.map +1 -1
- package/build/components/navigable-toolbar/index.js +2 -2
- package/build/components/navigable-toolbar/index.js.map +1 -1
- package/build/components/preview-options/index.js +6 -60
- package/build/components/preview-options/index.js.map +1 -1
- package/build/components/rich-text/content.js +26 -23
- package/build/components/rich-text/content.js.map +1 -1
- package/build/components/rich-text/get-rich-text-values.js +2 -1
- package/build/components/rich-text/get-rich-text-values.js.map +1 -1
- package/build/components/rich-text/index.js +2 -30
- package/build/components/rich-text/index.js.map +1 -1
- package/build/components/rich-text/index.native.js +10 -17
- package/build/components/rich-text/index.native.js.map +1 -1
- package/build/components/rich-text/native/get-format-colors.native.js +22 -24
- package/build/components/rich-text/native/get-format-colors.native.js.map +1 -1
- package/build/components/rich-text/native/index.native.js +41 -37
- package/build/components/rich-text/native/index.native.js.map +1 -1
- package/build/components/rich-text/use-input-rules.js +35 -2
- package/build/components/rich-text/use-input-rules.js.map +1 -1
- package/build/components/rich-text/with-deprecations.js +50 -0
- package/build/components/rich-text/with-deprecations.js.map +1 -0
- package/build/components/spacing-sizes-control/input-controls/spacing-input-control.js +1 -1
- package/build/components/spacing-sizes-control/input-controls/spacing-input-control.js.map +1 -1
- package/build/components/use-block-drop-zone/index.js +74 -9
- package/build/components/use-block-drop-zone/index.js.map +1 -1
- package/build/components/use-moving-animation/index.js +2 -1
- package/build/components/use-moving-animation/index.js.map +1 -1
- package/build/components/use-on-block-drop/index.js +1 -1
- package/build/components/use-on-block-drop/index.js.map +1 -1
- package/build/components/use-resize-canvas/index.js +4 -1
- package/build/components/use-resize-canvas/index.js.map +1 -1
- package/build/components/use-settings/index.js +16 -2
- package/build/components/use-settings/index.js.map +1 -1
- package/build/hooks/align.js +20 -68
- package/build/hooks/align.js.map +1 -1
- package/build/hooks/align.native.js +11 -1
- package/build/hooks/align.native.js.map +1 -1
- package/build/hooks/anchor.js +13 -29
- package/build/hooks/anchor.js.map +1 -1
- package/build/hooks/background.js +28 -31
- package/build/hooks/background.js.map +1 -1
- package/build/hooks/block-hooks.js +24 -32
- package/build/hooks/block-hooks.js.map +1 -1
- package/build/hooks/block-renaming.js +38 -0
- package/build/hooks/block-renaming.js.map +1 -1
- package/build/hooks/border.js +58 -80
- package/build/hooks/border.js.map +1 -1
- package/build/hooks/color.js +76 -89
- package/build/hooks/color.js.map +1 -1
- package/build/hooks/content-lock-ui.js +29 -29
- package/build/hooks/content-lock-ui.js.map +1 -1
- package/build/hooks/custom-class-name.js +12 -29
- package/build/hooks/custom-class-name.js.map +1 -1
- package/build/hooks/custom-fields.js +64 -73
- package/build/hooks/custom-fields.js.map +1 -1
- package/build/hooks/dimensions.js +21 -17
- package/build/hooks/dimensions.js.map +1 -1
- package/build/hooks/duotone.js +31 -61
- package/build/hooks/duotone.js.map +1 -1
- package/build/hooks/font-family.js +16 -25
- package/build/hooks/font-family.js.map +1 -1
- package/build/hooks/font-size.js +51 -119
- package/build/hooks/font-size.js.map +1 -1
- package/build/hooks/index.js +25 -15
- package/build/hooks/index.js.map +1 -1
- package/build/hooks/index.native.js +10 -3
- package/build/hooks/index.native.js.map +1 -1
- package/build/hooks/layout-child.js +68 -0
- package/build/hooks/layout-child.js.map +1 -0
- package/build/hooks/layout.js +29 -108
- package/build/hooks/layout.js.map +1 -1
- package/build/hooks/padding.js +2 -2
- package/build/hooks/padding.js.map +1 -1
- package/build/hooks/position.js +40 -62
- package/build/hooks/position.js.map +1 -1
- package/build/hooks/style.js +51 -88
- package/build/hooks/style.js.map +1 -1
- package/build/hooks/typography.js +34 -14
- package/build/hooks/typography.js.map +1 -1
- package/build/hooks/utils.js +154 -7
- package/build/hooks/utils.js.map +1 -1
- package/build/layouts/constrained.js +4 -3
- package/build/layouts/constrained.js.map +1 -1
- package/build/private-apis.js +0 -2
- package/build/private-apis.js.map +1 -1
- package/build/store/private-actions.js +8 -0
- package/build/store/private-actions.js.map +1 -1
- package/build/store/private-selectors.js +34 -0
- package/build/store/private-selectors.js.map +1 -1
- package/build/store/reducer.js +8 -0
- package/build/store/reducer.js.map +1 -1
- package/build/store/selectors.js +10 -58
- package/build/store/selectors.js.map +1 -1
- package/build/store/utils.js +66 -0
- package/build/store/utils.js.map +1 -0
- package/build/utils/object.js +21 -61
- package/build/utils/object.js.map +1 -1
- package/build/utils/selection.js +9 -1
- package/build/utils/selection.js.map +1 -1
- package/build/utils/transform-styles/index.js +26 -6
- package/build/utils/transform-styles/index.js.map +1 -1
- package/build-module/components/block-canvas/index.js +23 -7
- package/build-module/components/block-canvas/index.js.map +1 -1
- package/build-module/components/block-card/index.js +1 -1
- package/build-module/components/block-card/index.js.map +1 -1
- package/build-module/components/block-controls/hook.js +4 -24
- package/build-module/components/block-controls/hook.js.map +1 -1
- package/build-module/components/block-edit/context.js +2 -0
- package/build-module/components/block-edit/context.js.map +1 -1
- package/build-module/components/block-edit/index.js +19 -10
- package/build-module/components/block-edit/index.js.map +1 -1
- package/build-module/components/block-info-slot-fill/index.js +3 -3
- package/build-module/components/block-info-slot-fill/index.js.map +1 -1
- package/build-module/components/block-list/block.js +29 -10
- package/build-module/components/block-list/block.js.map +1 -1
- package/build-module/components/block-list/block.native.js +16 -5
- package/build-module/components/block-list/block.native.js.map +1 -1
- package/build-module/components/block-list/use-block-props/index.js +62 -19
- package/build-module/components/block-list/use-block-props/index.js.map +1 -1
- package/build-module/components/block-list/use-block-props/use-focus-first-element.js +4 -29
- package/build-module/components/block-list/use-block-props/use-focus-first-element.js.map +1 -1
- package/build-module/components/block-list/use-block-props/use-is-hovered.js +4 -14
- package/build-module/components/block-list/use-block-props/use-is-hovered.js.map +1 -1
- package/build-module/components/block-list/use-block-props/use-selected-block-event-handlers.js +4 -2
- package/build-module/components/block-list/use-block-props/use-selected-block-event-handlers.js.map +1 -1
- package/build-module/components/block-parent-selector/index.js +1 -1
- package/build-module/components/block-parent-selector/index.js.map +1 -1
- package/build-module/components/block-pattern-setup/index.js +24 -15
- package/build-module/components/block-pattern-setup/index.js.map +1 -1
- package/build-module/components/block-pattern-setup/setup-toolbar.js +4 -2
- package/build-module/components/block-pattern-setup/setup-toolbar.js.map +1 -1
- package/build-module/components/block-patterns-list/index.js +37 -20
- package/build-module/components/block-patterns-list/index.js.map +1 -1
- package/build-module/components/block-removal-warning-modal/index.js +3 -10
- package/build-module/components/block-removal-warning-modal/index.js.map +1 -1
- package/build-module/components/block-rename/index.js +4 -0
- package/build-module/components/block-rename/index.js.map +1 -0
- package/build-module/components/block-rename/is-empty-string.js +4 -0
- package/build-module/components/block-rename/is-empty-string.js.map +1 -0
- package/build-module/components/block-rename/modal.js +82 -0
- package/build-module/components/block-rename/modal.js.map +1 -0
- package/build-module/components/block-rename/rename-control.js +66 -0
- package/build-module/components/block-rename/rename-control.js.map +1 -0
- package/build-module/components/block-rename/use-block-rename.js +10 -0
- package/build-module/components/block-rename/use-block-rename.js.map +1 -0
- package/build-module/components/block-settings/container.native.js +4 -2
- package/build-module/components/block-settings/container.native.js.map +1 -1
- package/build-module/components/block-settings-menu/block-settings-dropdown.js +34 -21
- package/build-module/components/block-settings-menu/block-settings-dropdown.js.map +1 -1
- package/build-module/components/block-settings-menu-controls/index.js +7 -0
- package/build-module/components/block-settings-menu-controls/index.js.map +1 -1
- package/build-module/components/block-styles/index.js +1 -1
- package/build-module/components/block-styles/index.js.map +1 -1
- package/build-module/components/block-styles/index.native.js +3 -2
- package/build-module/components/block-styles/index.native.js.map +1 -1
- package/build-module/components/block-toolbar/block-toolbar-menu.native.js +1 -1
- package/build-module/components/block-toolbar/block-toolbar-menu.native.js.map +1 -1
- package/build-module/components/block-toolbar/index.js +88 -25
- package/build-module/components/block-toolbar/index.js.map +1 -1
- package/build-module/components/block-tools/block-toolbar-breadcrumb.js +41 -0
- package/build-module/components/block-tools/block-toolbar-breadcrumb.js.map +1 -0
- package/build-module/components/block-tools/block-toolbar-popover.js +76 -0
- package/build-module/components/block-tools/block-toolbar-popover.js.map +1 -0
- package/build-module/components/block-tools/index.js +27 -24
- package/build-module/components/block-tools/index.js.map +1 -1
- package/build-module/components/block-types-list/index.js +6 -2
- package/build-module/components/block-types-list/index.js.map +1 -1
- package/build-module/components/block-types-list/index.native.js +2 -1
- package/build-module/components/block-types-list/index.native.js.map +1 -1
- package/build-module/components/block-variation-picker/index.native.js +2 -1
- package/build-module/components/block-variation-picker/index.native.js.map +1 -1
- package/build-module/components/colors-gradients/control.js +29 -18
- package/build-module/components/colors-gradients/control.js.map +1 -1
- package/build-module/components/date-format-picker/index.js +8 -1
- package/build-module/components/date-format-picker/index.js.map +1 -1
- package/build-module/components/duotone-control/index.js +1 -4
- package/build-module/components/duotone-control/index.js.map +1 -1
- package/build-module/components/global-styles/advanced-panel.js +1 -1
- package/build-module/components/global-styles/advanced-panel.js.map +1 -1
- package/build-module/components/global-styles/color-panel.js +23 -21
- package/build-module/components/global-styles/color-panel.js.map +1 -1
- package/build-module/components/global-styles/filters-panel.js +10 -4
- package/build-module/components/global-styles/filters-panel.js.map +1 -1
- package/build-module/components/global-styles/typography-panel.js +20 -31
- package/build-module/components/global-styles/typography-panel.js.map +1 -1
- package/build-module/components/image-link-destinations/index.native.js +109 -0
- package/build-module/components/image-link-destinations/index.native.js.map +1 -0
- package/build-module/components/image-size-control/index.js +0 -5
- package/build-module/components/image-size-control/index.js.map +1 -1
- package/build-module/components/index.native.js +1 -0
- package/build-module/components/index.native.js.map +1 -1
- package/build-module/components/inner-blocks/index.js +3 -1
- package/build-module/components/inner-blocks/index.js.map +1 -1
- package/build-module/components/inner-blocks/warning-max-depth-exceeded.native.js +30 -32
- package/build-module/components/inner-blocks/warning-max-depth-exceeded.native.js.map +1 -1
- package/build-module/components/inserter/block-patterns-explorer/pattern-list.js +2 -2
- package/build-module/components/inserter/block-patterns-explorer/pattern-list.js.map +1 -1
- package/build-module/components/inserter/block-patterns-tab/pattern-category-previews.js +4 -4
- package/build-module/components/inserter/block-patterns-tab/pattern-category-previews.js.map +1 -1
- package/build-module/components/inserter/block-patterns-tab/use-pattern-categories.js +2 -2
- package/build-module/components/inserter/block-patterns-tab/use-pattern-categories.js.map +1 -1
- package/build-module/components/inserter/block-patterns-tab/utils.js +3 -4
- package/build-module/components/inserter/block-patterns-tab/utils.js.map +1 -1
- package/build-module/components/inserter/hooks/use-patterns-state.js +2 -1
- package/build-module/components/inserter/hooks/use-patterns-state.js.map +1 -1
- package/build-module/components/inserter/media-tab/media-panel.js +1 -1
- package/build-module/components/inserter/media-tab/media-panel.js.map +1 -1
- package/build-module/components/inserter/menu.js +14 -7
- package/build-module/components/inserter/menu.js.map +1 -1
- package/build-module/components/inserter/preview-panel.js +2 -2
- package/build-module/components/inserter/preview-panel.js.map +1 -1
- package/build-module/components/inserter-button/index.native.js +89 -0
- package/build-module/components/inserter-button/index.native.js.map +1 -0
- package/build-module/components/inserter-button/sparkles.js +15 -0
- package/build-module/components/inserter-button/sparkles.js.map +1 -0
- package/build-module/components/inserter-draggable-blocks/index.js +9 -5
- package/build-module/components/inserter-draggable-blocks/index.js.map +1 -1
- package/build-module/components/inserter-listbox/index.js +13 -8
- package/build-module/components/inserter-listbox/index.js.map +1 -1
- package/build-module/components/inserter-listbox/item.js +25 -23
- package/build-module/components/inserter-listbox/item.js.map +1 -1
- package/build-module/components/inserter-listbox/row.js +6 -5
- package/build-module/components/inserter-listbox/row.js.map +1 -1
- package/build-module/components/inspector-controls/fill.js +3 -3
- package/build-module/components/inspector-controls/fill.js.map +1 -1
- package/build-module/components/inspector-controls/fill.native.js +3 -3
- package/build-module/components/inspector-controls/fill.native.js.map +1 -1
- package/build-module/components/list-view/use-list-view-expand-selected-item.js +2 -3
- package/build-module/components/list-view/use-list-view-expand-selected-item.js.map +1 -1
- package/build-module/components/navigable-toolbar/index.js +2 -2
- package/build-module/components/navigable-toolbar/index.js.map +1 -1
- package/build-module/components/preview-options/index.js +6 -60
- package/build-module/components/preview-options/index.js.map +1 -1
- package/build-module/components/rich-text/content.js +25 -21
- package/build-module/components/rich-text/content.js.map +1 -1
- package/build-module/components/rich-text/get-rich-text-values.js +2 -1
- package/build-module/components/rich-text/get-rich-text-values.js.map +1 -1
- package/build-module/components/rich-text/index.js +4 -32
- package/build-module/components/rich-text/index.js.map +1 -1
- package/build-module/components/rich-text/index.native.js +11 -19
- package/build-module/components/rich-text/index.native.js.map +1 -1
- package/build-module/components/rich-text/native/get-format-colors.native.js +22 -24
- package/build-module/components/rich-text/native/get-format-colors.native.js.map +1 -1
- package/build-module/components/rich-text/native/index.native.js +41 -37
- package/build-module/components/rich-text/native/index.native.js.map +1 -1
- package/build-module/components/rich-text/use-input-rules.js +36 -3
- package/build-module/components/rich-text/use-input-rules.js.map +1 -1
- package/build-module/components/rich-text/with-deprecations.js +42 -0
- package/build-module/components/rich-text/with-deprecations.js.map +1 -0
- package/build-module/components/spacing-sizes-control/input-controls/spacing-input-control.js +1 -1
- package/build-module/components/spacing-sizes-control/input-controls/spacing-input-control.js.map +1 -1
- package/build-module/components/use-block-drop-zone/index.js +73 -9
- package/build-module/components/use-block-drop-zone/index.js.map +1 -1
- package/build-module/components/use-moving-animation/index.js +2 -1
- package/build-module/components/use-moving-animation/index.js.map +1 -1
- package/build-module/components/use-on-block-drop/index.js +1 -1
- package/build-module/components/use-on-block-drop/index.js.map +1 -1
- package/build-module/components/use-resize-canvas/index.js +4 -1
- package/build-module/components/use-resize-canvas/index.js.map +1 -1
- package/build-module/components/use-settings/index.js +15 -3
- package/build-module/components/use-settings/index.js.map +1 -1
- package/build-module/hooks/align.js +19 -66
- package/build-module/hooks/align.js.map +1 -1
- package/build-module/hooks/align.native.js +1 -0
- package/build-module/hooks/align.native.js.map +1 -1
- package/build-module/hooks/anchor.js +11 -26
- package/build-module/hooks/anchor.js.map +1 -1
- package/build-module/hooks/background.js +26 -28
- package/build-module/hooks/background.js.map +1 -1
- package/build-module/hooks/block-hooks.js +22 -30
- package/build-module/hooks/block-hooks.js.map +1 -1
- package/build-module/hooks/block-renaming.js +36 -0
- package/build-module/hooks/block-renaming.js.map +1 -1
- package/build-module/hooks/border.js +57 -78
- package/build-module/hooks/border.js.map +1 -1
- package/build-module/hooks/color.js +74 -86
- package/build-module/hooks/color.js.map +1 -1
- package/build-module/hooks/content-lock-ui.js +27 -27
- package/build-module/hooks/content-lock-ui.js.map +1 -1
- package/build-module/hooks/custom-class-name.js +11 -27
- package/build-module/hooks/custom-class-name.js.map +1 -1
- package/build-module/hooks/custom-fields.js +60 -74
- package/build-module/hooks/custom-fields.js.map +1 -1
- package/build-module/hooks/dimensions.js +21 -16
- package/build-module/hooks/dimensions.js.map +1 -1
- package/build-module/hooks/duotone.js +30 -61
- package/build-module/hooks/duotone.js.map +1 -1
- package/build-module/hooks/font-family.js +14 -23
- package/build-module/hooks/font-family.js.map +1 -1
- package/build-module/hooks/font-size.js +49 -119
- package/build-module/hooks/font-size.js.map +1 -1
- package/build-module/hooks/index.js +18 -15
- package/build-module/hooks/index.js.map +1 -1
- package/build-module/hooks/index.native.js +5 -3
- package/build-module/hooks/index.native.js.map +1 -1
- package/build-module/hooks/layout-child.js +60 -0
- package/build-module/hooks/layout-child.js.map +1 -0
- package/build-module/hooks/layout.js +26 -105
- package/build-module/hooks/layout.js.map +1 -1
- package/build-module/hooks/padding.js +2 -2
- package/build-module/hooks/padding.js.map +1 -1
- package/build-module/hooks/position.js +38 -59
- package/build-module/hooks/position.js.map +1 -1
- package/build-module/hooks/style.js +51 -84
- package/build-module/hooks/style.js.map +1 -1
- package/build-module/hooks/typography.js +33 -12
- package/build-module/hooks/typography.js.map +1 -1
- package/build-module/hooks/utils.js +149 -6
- package/build-module/hooks/utils.js.map +1 -1
- package/build-module/layouts/constrained.js +4 -3
- package/build-module/layouts/constrained.js.map +1 -1
- package/build-module/private-apis.js +0 -2
- package/build-module/private-apis.js.map +1 -1
- package/build-module/store/private-actions.js +7 -0
- package/build-module/store/private-actions.js.map +1 -1
- package/build-module/store/private-selectors.js +33 -1
- package/build-module/store/private-selectors.js.map +1 -1
- package/build-module/store/reducer.js +8 -0
- package/build-module/store/reducer.js.map +1 -1
- package/build-module/store/selectors.js +3 -51
- package/build-module/store/selectors.js.map +1 -1
- package/build-module/store/utils.js +56 -0
- package/build-module/store/utils.js.map +1 -0
- package/build-module/utils/object.js +21 -60
- package/build-module/utils/object.js.map +1 -1
- package/build-module/utils/selection.js +9 -1
- package/build-module/utils/selection.js.map +1 -1
- package/build-module/utils/transform-styles/index.js +24 -7
- package/build-module/utils/transform-styles/index.js.map +1 -1
- package/build-style/content-rtl.css +6 -6
- package/build-style/content.css +6 -6
- package/build-style/style-rtl.css +123 -298
- package/build-style/style.css +123 -298
- package/package.json +31 -31
- package/src/components/block-canvas/index.js +31 -17
- package/src/components/block-caption/README.md +2 -2
- package/src/components/block-card/index.js +5 -3
- package/src/components/block-card/style.scss +7 -3
- package/src/components/block-controls/hook.js +8 -30
- package/src/components/block-controls/test/index.js +3 -3
- package/src/components/block-edit/context.js +3 -0
- package/src/components/block-edit/index.js +36 -10
- package/src/components/block-info-slot-fill/index.js +6 -3
- package/src/components/block-inspector/style.scss +0 -4
- package/src/components/block-list/block.js +39 -5
- package/src/components/block-list/block.native.js +20 -4
- package/src/components/block-list/use-block-props/index.js +74 -21
- package/src/components/block-list/use-block-props/use-focus-first-element.js +1 -34
- package/src/components/block-list/use-block-props/use-is-hovered.js +2 -13
- package/src/components/block-list/use-block-props/use-selected-block-event-handlers.js +1 -5
- package/src/components/block-parent-selector/index.js +1 -1
- package/src/components/block-pattern-setup/index.js +38 -22
- package/src/components/block-pattern-setup/setup-toolbar.js +2 -0
- package/src/components/block-pattern-setup/style.scss +4 -1
- package/src/components/block-patterns-list/README.md +4 -4
- package/src/components/block-patterns-list/index.js +61 -35
- package/src/components/block-patterns-list/style.scss +7 -0
- package/src/components/block-removal-warning-modal/index.js +7 -14
- package/src/components/block-rename/index.js +3 -0
- package/src/components/block-rename/is-empty-string.js +3 -0
- package/src/components/block-rename/modal.js +121 -0
- package/src/components/block-rename/rename-control.js +80 -0
- package/src/components/block-rename/use-block-rename.js +10 -0
- package/src/components/block-settings/container.native.js +3 -5
- package/src/components/block-settings-menu/block-settings-dropdown.js +38 -34
- package/src/components/block-settings-menu-controls/index.js +9 -0
- package/src/components/block-styles/index.js +1 -1
- package/src/components/block-styles/index.native.js +4 -2
- package/src/components/block-styles/style.scss +0 -11
- package/src/components/block-switcher/test/__snapshots__/index.js.snap +3 -1
- package/src/components/block-toolbar/block-toolbar-menu.native.js +1 -4
- package/src/components/block-toolbar/index.js +180 -95
- package/src/components/block-toolbar/style.scss +50 -66
- package/src/components/block-tools/block-toolbar-breadcrumb.js +46 -0
- package/src/components/block-tools/block-toolbar-popover.js +90 -0
- package/src/components/block-tools/index.js +42 -29
- package/src/components/block-tools/style.scss +60 -172
- package/src/components/block-types-list/index.js +5 -4
- package/src/components/block-types-list/index.native.js +2 -1
- package/src/components/block-variation-picker/index.native.js +1 -1
- package/src/components/button-block-appender/content.scss +2 -2
- package/src/components/colors-gradients/control.js +49 -30
- package/src/components/colors-gradients/style.scss +0 -7
- package/src/components/date-format-picker/index.js +7 -0
- package/src/components/duotone-control/index.js +2 -5
- package/src/components/duotone-control/style.scss +1 -6
- package/src/components/editable-text/README.md +0 -36
- package/src/components/global-styles/advanced-panel.js +1 -1
- package/src/components/global-styles/color-panel.js +34 -25
- package/src/components/global-styles/filters-panel.js +8 -4
- package/src/components/global-styles/typography-panel.js +23 -43
- package/src/components/image-link-destinations/index.native.js +152 -0
- package/src/components/image-link-destinations/style.native.scss +16 -0
- package/src/components/image-size-control/index.js +0 -6
- package/src/components/index.native.js +1 -0
- package/src/components/inner-blocks/README.md +13 -2
- package/src/components/inner-blocks/index.js +6 -2
- package/src/components/inner-blocks/warning-max-depth-exceeded.native.js +57 -33
- package/src/components/inserter/block-patterns-explorer/pattern-list.js +5 -1
- package/src/components/inserter/block-patterns-tab/pattern-category-previews.js +7 -3
- package/src/components/inserter/block-patterns-tab/use-pattern-categories.js +6 -1
- package/src/components/inserter/block-patterns-tab/utils.js +6 -4
- package/src/components/inserter/hooks/use-patterns-state.js +3 -1
- package/src/components/inserter/media-tab/media-panel.js +1 -1
- package/src/components/inserter/menu.js +16 -8
- package/src/components/inserter/preview-panel.js +2 -2
- package/src/components/inserter/style.scss +15 -17
- package/src/components/inserter-button/README.md +62 -0
- package/src/components/inserter-button/index.native.js +116 -0
- package/src/components/inserter-button/sparkles.js +15 -0
- package/src/components/inserter-button/style.native.scss +72 -0
- package/src/components/inserter-draggable-blocks/index.js +18 -5
- package/src/components/inserter-listbox/index.js +11 -7
- package/src/components/inserter-listbox/item.js +11 -12
- package/src/components/inserter-listbox/row.js +6 -12
- package/src/components/inspector-controls/fill.js +6 -3
- package/src/components/inspector-controls/fill.native.js +6 -3
- package/src/components/link-control/style.scss +1 -1
- package/src/components/link-control/test/index.js +1 -1
- package/src/components/list-view/use-list-view-expand-selected-item.js +7 -8
- package/src/components/navigable-toolbar/README.md +2 -0
- package/src/components/navigable-toolbar/index.js +2 -2
- package/src/components/plain-text/README.md +0 -28
- package/src/components/preview-options/index.js +6 -84
- package/src/components/rich-text/README.md +0 -58
- package/src/components/rich-text/content.js +27 -20
- package/src/components/rich-text/get-rich-text-values.js +6 -1
- package/src/components/rich-text/index.js +5 -46
- package/src/components/rich-text/index.native.js +9 -26
- package/src/components/rich-text/native/get-format-colors.native.js +33 -40
- package/src/components/rich-text/native/index.native.js +52 -50
- package/src/components/rich-text/use-input-rules.js +36 -3
- package/src/components/rich-text/with-deprecations.js +51 -0
- package/src/components/spacing-sizes-control/input-controls/spacing-input-control.js +1 -1
- package/src/components/url-input/README.md +1 -74
- package/src/components/use-block-drop-zone/index.js +118 -15
- package/src/components/use-moving-animation/index.js +1 -1
- package/src/components/use-on-block-drop/index.js +2 -1
- package/src/components/use-resize-canvas/README.md +3 -3
- package/src/components/use-resize-canvas/index.js +4 -1
- package/src/components/use-settings/index.js +17 -3
- package/src/components/use-settings/test/index.js +1 -1
- package/src/hooks/align.js +15 -76
- package/src/hooks/align.native.js +1 -0
- package/src/hooks/anchor.js +13 -33
- package/src/hooks/background.js +28 -23
- package/src/hooks/block-hooks.js +22 -51
- package/src/hooks/block-renaming.js +33 -0
- package/src/hooks/border.js +67 -118
- package/src/hooks/color.js +100 -132
- package/src/hooks/content-lock-ui.js +110 -122
- package/src/hooks/custom-class-name.js +8 -40
- package/src/hooks/custom-fields.js +70 -94
- package/src/hooks/dimensions.js +20 -16
- package/src/hooks/duotone.js +70 -127
- package/src/hooks/font-family.js +10 -29
- package/src/hooks/font-size.js +66 -162
- package/src/hooks/index.js +42 -15
- package/src/hooks/index.native.js +6 -3
- package/src/hooks/layout-child.js +53 -0
- package/src/hooks/layout.js +25 -110
- package/src/hooks/padding.js +2 -2
- package/src/hooks/position.js +50 -90
- package/src/hooks/style.js +117 -187
- package/src/hooks/test/__snapshots__/align.native.js.snap +5 -5
- package/src/hooks/test/align.js +1 -178
- package/src/hooks/typography.js +20 -16
- package/src/hooks/utils.js +187 -6
- package/src/layouts/constrained.js +57 -50
- package/src/private-apis.js +0 -2
- package/src/store/private-actions.js +8 -0
- package/src/store/private-selectors.js +45 -0
- package/src/store/reducer.js +8 -0
- package/src/store/selectors.js +5 -67
- package/src/store/utils.js +74 -0
- package/src/style.scss +1 -3
- package/src/utils/object.js +18 -69
- package/src/utils/selection.js +9 -2
- package/src/utils/test/transform-styles.js +49 -0
- package/src/utils/transform-styles/index.js +39 -13
- package/build/components/block-list/use-block-props/use-block-class-names.js +0 -67
- package/build/components/block-list/use-block-props/use-block-class-names.js.map +0 -1
- package/build/components/block-list/use-block-props/use-block-custom-class-name.js +0 -46
- package/build/components/block-list/use-block-props/use-block-custom-class-name.js.map +0 -1
- package/build/components/block-list/use-block-props/use-block-default-class-name.js +0 -37
- package/build/components/block-list/use-block-props/use-block-default-class-name.js.map +0 -1
- package/build/components/block-tools/back-compat.js +0 -45
- package/build/components/block-tools/back-compat.js.map +0 -1
- package/build/components/block-tools/block-contextual-toolbar.js +0 -91
- package/build/components/block-tools/block-contextual-toolbar.js.map +0 -1
- package/build/components/block-tools/selected-block-tools.js +0 -113
- package/build/components/block-tools/selected-block-tools.js.map +0 -1
- package/build/components/inserter/hooks/use-debounced-input.js +0 -22
- package/build/components/inserter/hooks/use-debounced-input.js.map +0 -1
- package/build/components/use-display-block-controls/index.js +0 -39
- package/build/components/use-display-block-controls/index.js.map +0 -1
- package/build/components/use-display-block-controls/index.native.js +0 -39
- package/build/components/use-display-block-controls/index.native.js.map +0 -1
- package/build/hooks/block-rename-ui.js +0 -167
- package/build/hooks/block-rename-ui.js.map +0 -1
- package/build-module/components/block-list/use-block-props/use-block-class-names.js +0 -60
- package/build-module/components/block-list/use-block-props/use-block-class-names.js.map +0 -1
- package/build-module/components/block-list/use-block-props/use-block-custom-class-name.js +0 -40
- package/build-module/components/block-list/use-block-props/use-block-custom-class-name.js.map +0 -1
- package/build-module/components/block-list/use-block-props/use-block-default-class-name.js +0 -31
- package/build-module/components/block-list/use-block-props/use-block-default-class-name.js.map +0 -1
- package/build-module/components/block-tools/back-compat.js +0 -35
- package/build-module/components/block-tools/back-compat.js.map +0 -1
- package/build-module/components/block-tools/block-contextual-toolbar.js +0 -83
- package/build-module/components/block-tools/block-contextual-toolbar.js.map +0 -1
- package/build-module/components/block-tools/selected-block-tools.js +0 -105
- package/build-module/components/block-tools/selected-block-tools.js.map +0 -1
- package/build-module/components/inserter/hooks/use-debounced-input.js +0 -15
- package/build-module/components/inserter/hooks/use-debounced-input.js.map +0 -1
- package/build-module/components/use-display-block-controls/index.js +0 -32
- package/build-module/components/use-display-block-controls/index.js.map +0 -1
- package/build-module/components/use-display-block-controls/index.native.js +0 -32
- package/build-module/components/use-display-block-controls/index.native.js.map +0 -1
- package/build-module/hooks/block-rename-ui.js +0 -159
- package/build-module/hooks/block-rename-ui.js.map +0 -1
- package/src/components/block-list/use-block-props/use-block-class-names.js +0 -66
- package/src/components/block-list/use-block-props/use-block-custom-class-name.js +0 -44
- package/src/components/block-list/use-block-props/use-block-default-class-name.js +0 -35
- package/src/components/block-parent-selector/style.scss +0 -11
- package/src/components/block-tools/back-compat.js +0 -35
- package/src/components/block-tools/block-contextual-toolbar.js +0 -100
- package/src/components/block-tools/selected-block-tools.js +0 -127
- package/src/components/inserter/hooks/use-debounced-input.js +0 -18
- package/src/components/preview-options/README.md +0 -94
- package/src/components/preview-options/style.scss +0 -64
- package/src/components/use-display-block-controls/index.js +0 -36
- package/src/components/use-display-block-controls/index.native.js +0 -37
- package/src/hooks/block-rename-ui.js +0 -228
- package/src/hooks/test/color.js +0 -112
- /package/src/{hooks/block-rename-ui.scss → components/block-rename/style.scss} +0 -0
package/src/hooks/background.js
CHANGED
|
@@ -24,6 +24,7 @@ import { Platform, useCallback, useRef } from '@wordpress/element';
|
|
|
24
24
|
import { __, sprintf } from '@wordpress/i18n';
|
|
25
25
|
import { store as noticesStore } from '@wordpress/notices';
|
|
26
26
|
import { getFilename } from '@wordpress/url';
|
|
27
|
+
import { pure } from '@wordpress/compose';
|
|
27
28
|
|
|
28
29
|
/**
|
|
29
30
|
* Internal dependencies
|
|
@@ -41,13 +42,13 @@ export const IMAGE_BACKGROUND_TYPE = 'image';
|
|
|
41
42
|
* Checks if there is a current value in the background image block support
|
|
42
43
|
* attributes.
|
|
43
44
|
*
|
|
44
|
-
* @param {Object}
|
|
45
|
+
* @param {Object} style Style attribute.
|
|
45
46
|
* @return {boolean} Whether or not the block has a background image value set.
|
|
46
47
|
*/
|
|
47
|
-
export function hasBackgroundImageValue(
|
|
48
|
+
export function hasBackgroundImageValue( style ) {
|
|
48
49
|
const hasValue =
|
|
49
|
-
!!
|
|
50
|
-
!!
|
|
50
|
+
!! style?.background?.backgroundImage?.id ||
|
|
51
|
+
!! style?.background?.backgroundImage?.url;
|
|
51
52
|
|
|
52
53
|
return hasValue;
|
|
53
54
|
}
|
|
@@ -82,13 +83,10 @@ export function hasBackgroundSupport( blockName, feature = 'any' ) {
|
|
|
82
83
|
* Resets the background image block support attributes. This can be used when disabling
|
|
83
84
|
* the background image controls for a block via a `ToolsPanel`.
|
|
84
85
|
*
|
|
85
|
-
* @param {Object}
|
|
86
|
-
* @param {
|
|
87
|
-
* @param {Object} props.setAttributes Function to set block's attributes.
|
|
86
|
+
* @param {Object} style Style attribute.
|
|
87
|
+
* @param {Function} setAttributes Function to set block's attributes.
|
|
88
88
|
*/
|
|
89
|
-
export function resetBackgroundImage(
|
|
90
|
-
const { style = {} } = attributes;
|
|
91
|
-
|
|
89
|
+
export function resetBackgroundImage( style = {}, setAttributes ) {
|
|
92
90
|
setAttributes( {
|
|
93
91
|
style: cleanEmptyObject( {
|
|
94
92
|
...style,
|
|
@@ -145,11 +143,13 @@ function InspectorImagePreview( { label, filename, url: imgUrl } ) {
|
|
|
145
143
|
);
|
|
146
144
|
}
|
|
147
145
|
|
|
148
|
-
function BackgroundImagePanelItem(
|
|
149
|
-
const
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
146
|
+
function BackgroundImagePanelItem( { clientId, setAttributes } ) {
|
|
147
|
+
const style = useSelect(
|
|
148
|
+
( select ) =>
|
|
149
|
+
select( blockEditorStore ).getBlockAttributes( clientId )?.style,
|
|
150
|
+
[ clientId ]
|
|
151
|
+
);
|
|
152
|
+
const { id, title, url } = style?.background?.backgroundImage || {};
|
|
153
153
|
|
|
154
154
|
const replaceContainerRef = useRef();
|
|
155
155
|
|
|
@@ -167,9 +167,9 @@ function BackgroundImagePanelItem( props ) {
|
|
|
167
167
|
const onSelectMedia = ( media ) => {
|
|
168
168
|
if ( ! media || ! media.url ) {
|
|
169
169
|
const newStyle = {
|
|
170
|
-
...
|
|
170
|
+
...style,
|
|
171
171
|
background: {
|
|
172
|
-
...
|
|
172
|
+
...style?.background,
|
|
173
173
|
backgroundImage: undefined,
|
|
174
174
|
},
|
|
175
175
|
};
|
|
@@ -201,9 +201,9 @@ function BackgroundImagePanelItem( props ) {
|
|
|
201
201
|
}
|
|
202
202
|
|
|
203
203
|
const newStyle = {
|
|
204
|
-
...
|
|
204
|
+
...style,
|
|
205
205
|
background: {
|
|
206
|
-
...
|
|
206
|
+
...style?.background,
|
|
207
207
|
backgroundImage: {
|
|
208
208
|
url: media.url,
|
|
209
209
|
id: media.id,
|
|
@@ -244,14 +244,14 @@ function BackgroundImagePanelItem( props ) {
|
|
|
244
244
|
};
|
|
245
245
|
}, [] );
|
|
246
246
|
|
|
247
|
-
const hasValue = hasBackgroundImageValue(
|
|
247
|
+
const hasValue = hasBackgroundImageValue( style );
|
|
248
248
|
|
|
249
249
|
return (
|
|
250
250
|
<ToolsPanelItem
|
|
251
251
|
className="single-column"
|
|
252
252
|
hasValue={ () => hasValue }
|
|
253
253
|
label={ __( 'Background image' ) }
|
|
254
|
-
onDeselect={ () => resetBackgroundImage(
|
|
254
|
+
onDeselect={ () => resetBackgroundImage( style, setAttributes ) }
|
|
255
255
|
isShownByDefault={ true }
|
|
256
256
|
resetAllFilter={ resetAllFilter }
|
|
257
257
|
panelId={ clientId }
|
|
@@ -286,7 +286,7 @@ function BackgroundImagePanelItem( props ) {
|
|
|
286
286
|
// closed and focus is redirected to the dropdown toggle button.
|
|
287
287
|
toggleButton?.focus();
|
|
288
288
|
toggleButton?.click();
|
|
289
|
-
resetBackgroundImage(
|
|
289
|
+
resetBackgroundImage( style, setAttributes );
|
|
290
290
|
} }
|
|
291
291
|
>
|
|
292
292
|
{ __( 'Reset ' ) }
|
|
@@ -302,7 +302,7 @@ function BackgroundImagePanelItem( props ) {
|
|
|
302
302
|
);
|
|
303
303
|
}
|
|
304
304
|
|
|
305
|
-
|
|
305
|
+
function BackgroundImagePanelPure( props ) {
|
|
306
306
|
const [ backgroundImage ] = useSettings( 'background.backgroundImage' );
|
|
307
307
|
if (
|
|
308
308
|
! backgroundImage ||
|
|
@@ -317,3 +317,8 @@ export function BackgroundImagePanel( props ) {
|
|
|
317
317
|
</InspectorControls>
|
|
318
318
|
);
|
|
319
319
|
}
|
|
320
|
+
|
|
321
|
+
// We don't want block controls to re-render when typing inside a block. `pure`
|
|
322
|
+
// will prevent re-renders unless props change, so only pass the needed props
|
|
323
|
+
// and not the whole attributes object.
|
|
324
|
+
export const BackgroundImagePanel = pure( BackgroundImagePanelPure );
|
package/src/hooks/block-hooks.js
CHANGED
|
@@ -2,14 +2,12 @@
|
|
|
2
2
|
* WordPress dependencies
|
|
3
3
|
*/
|
|
4
4
|
import { __ } from '@wordpress/i18n';
|
|
5
|
-
import { addFilter } from '@wordpress/hooks';
|
|
6
5
|
import { Fragment, useMemo } from '@wordpress/element';
|
|
7
6
|
import {
|
|
8
7
|
__experimentalHStack as HStack,
|
|
9
8
|
PanelBody,
|
|
10
9
|
ToggleControl,
|
|
11
10
|
} from '@wordpress/components';
|
|
12
|
-
import { createHigherOrderComponent } from '@wordpress/compose';
|
|
13
11
|
import { createBlock, store as blocksStore } from '@wordpress/blocks';
|
|
14
12
|
import { useDispatch, useSelect } from '@wordpress/data';
|
|
15
13
|
|
|
@@ -21,7 +19,7 @@ import { store as blockEditorStore } from '../store';
|
|
|
21
19
|
|
|
22
20
|
const EMPTY_OBJECT = {};
|
|
23
21
|
|
|
24
|
-
function
|
|
22
|
+
function BlockHooksControlPure( { name, clientId } ) {
|
|
25
23
|
const blockTypes = useSelect(
|
|
26
24
|
( select ) => select( blocksStore ).getBlockTypes(),
|
|
27
25
|
[]
|
|
@@ -30,10 +28,9 @@ function BlockHooksControl( props ) {
|
|
|
30
28
|
const hookedBlocksForCurrentBlock = useMemo(
|
|
31
29
|
() =>
|
|
32
30
|
blockTypes?.filter(
|
|
33
|
-
( { blockHooks } ) =>
|
|
34
|
-
blockHooks && props.blockName in blockHooks
|
|
31
|
+
( { blockHooks } ) => blockHooks && name in blockHooks
|
|
35
32
|
),
|
|
36
|
-
[ blockTypes,
|
|
33
|
+
[ blockTypes, name ]
|
|
37
34
|
);
|
|
38
35
|
|
|
39
36
|
const { blockIndex, rootClientId, innerBlocksLength } = useSelect(
|
|
@@ -42,13 +39,12 @@ function BlockHooksControl( props ) {
|
|
|
42
39
|
select( blockEditorStore );
|
|
43
40
|
|
|
44
41
|
return {
|
|
45
|
-
blockIndex: getBlockIndex(
|
|
46
|
-
innerBlocksLength: getBlock(
|
|
47
|
-
|
|
48
|
-
rootClientId: getBlockRootClientId( props.clientId ),
|
|
42
|
+
blockIndex: getBlockIndex( clientId ),
|
|
43
|
+
innerBlocksLength: getBlock( clientId )?.innerBlocks?.length,
|
|
44
|
+
rootClientId: getBlockRootClientId( clientId ),
|
|
49
45
|
};
|
|
50
46
|
},
|
|
51
|
-
[
|
|
47
|
+
[ clientId ]
|
|
52
48
|
);
|
|
53
49
|
|
|
54
50
|
const hookedBlockClientIds = useSelect(
|
|
@@ -65,8 +61,7 @@ function BlockHooksControl( props ) {
|
|
|
65
61
|
return clientIds;
|
|
66
62
|
}
|
|
67
63
|
|
|
68
|
-
const relativePosition =
|
|
69
|
-
block?.blockHooks?.[ props.blockName ];
|
|
64
|
+
const relativePosition = block?.blockHooks?.[ name ];
|
|
70
65
|
let candidates;
|
|
71
66
|
|
|
72
67
|
switch ( relativePosition ) {
|
|
@@ -83,12 +78,12 @@ function BlockHooksControl( props ) {
|
|
|
83
78
|
// Any of the current block's child blocks (with the right block type) qualifies
|
|
84
79
|
// as a hooked first or last child block, as the block might've been automatically
|
|
85
80
|
// inserted and then moved around a bit by the user.
|
|
86
|
-
candidates = getBlock(
|
|
81
|
+
candidates = getBlock( clientId ).innerBlocks;
|
|
87
82
|
break;
|
|
88
83
|
}
|
|
89
84
|
|
|
90
85
|
const hookedBlock = candidates?.find(
|
|
91
|
-
(
|
|
86
|
+
( candidate ) => name === candidate.name
|
|
92
87
|
);
|
|
93
88
|
|
|
94
89
|
// If the block exists in the designated location, we consider it hooked
|
|
@@ -118,12 +113,7 @@ function BlockHooksControl( props ) {
|
|
|
118
113
|
|
|
119
114
|
return EMPTY_OBJECT;
|
|
120
115
|
},
|
|
121
|
-
[
|
|
122
|
-
hookedBlocksForCurrentBlock,
|
|
123
|
-
props.blockName,
|
|
124
|
-
props.clientId,
|
|
125
|
-
rootClientId,
|
|
126
|
-
]
|
|
116
|
+
[ hookedBlocksForCurrentBlock, name, clientId, rootClientId ]
|
|
127
117
|
);
|
|
128
118
|
|
|
129
119
|
const { insertBlock, removeBlock } = useDispatch( blockEditorStore );
|
|
@@ -169,7 +159,7 @@ function BlockHooksControl( props ) {
|
|
|
169
159
|
block,
|
|
170
160
|
// TODO: It'd be great if insertBlock() would accept negative indices for insertion.
|
|
171
161
|
relativePosition === 'first_child' ? 0 : innerBlocksLength,
|
|
172
|
-
|
|
162
|
+
clientId, // Insert as a child of the current block.
|
|
173
163
|
false
|
|
174
164
|
);
|
|
175
165
|
break;
|
|
@@ -207,9 +197,7 @@ function BlockHooksControl( props ) {
|
|
|
207
197
|
if ( ! checked ) {
|
|
208
198
|
// Create and insert block.
|
|
209
199
|
const relativePosition =
|
|
210
|
-
block.blockHooks[
|
|
211
|
-
props.blockName
|
|
212
|
-
];
|
|
200
|
+
block.blockHooks[ name ];
|
|
213
201
|
insertBlockIntoDesignatedLocation(
|
|
214
202
|
createBlock( block.name ),
|
|
215
203
|
relativePosition
|
|
@@ -218,11 +206,12 @@ function BlockHooksControl( props ) {
|
|
|
218
206
|
}
|
|
219
207
|
|
|
220
208
|
// Remove block.
|
|
221
|
-
|
|
209
|
+
removeBlock(
|
|
222
210
|
hookedBlockClientIds[
|
|
223
211
|
block.name
|
|
224
|
-
]
|
|
225
|
-
|
|
212
|
+
],
|
|
213
|
+
false
|
|
214
|
+
);
|
|
226
215
|
} }
|
|
227
216
|
/>
|
|
228
217
|
);
|
|
@@ -235,27 +224,9 @@ function BlockHooksControl( props ) {
|
|
|
235
224
|
);
|
|
236
225
|
}
|
|
237
226
|
|
|
238
|
-
export
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
<>
|
|
243
|
-
<BlockEdit key="edit" { ...props } />
|
|
244
|
-
{ props.isSelected && (
|
|
245
|
-
<BlockHooksControl
|
|
246
|
-
blockName={ props.name }
|
|
247
|
-
clientId={ props.clientId }
|
|
248
|
-
/>
|
|
249
|
-
) }
|
|
250
|
-
</>
|
|
251
|
-
);
|
|
252
|
-
};
|
|
227
|
+
export default {
|
|
228
|
+
edit: BlockHooksControlPure,
|
|
229
|
+
hasSupport() {
|
|
230
|
+
return true;
|
|
253
231
|
},
|
|
254
|
-
|
|
255
|
-
);
|
|
256
|
-
|
|
257
|
-
addFilter(
|
|
258
|
-
'editor.BlockEdit',
|
|
259
|
-
'core/editor/block-hooks/with-inspector-controls',
|
|
260
|
-
withBlockHooksControls
|
|
261
|
-
);
|
|
232
|
+
};
|
|
@@ -3,6 +3,13 @@
|
|
|
3
3
|
*/
|
|
4
4
|
import { addFilter } from '@wordpress/hooks';
|
|
5
5
|
import { hasBlockSupport } from '@wordpress/blocks';
|
|
6
|
+
import { __ } from '@wordpress/i18n';
|
|
7
|
+
import { TextControl } from '@wordpress/components';
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* Internal dependencies
|
|
11
|
+
*/
|
|
12
|
+
import { InspectorControls } from '../components';
|
|
6
13
|
|
|
7
14
|
/**
|
|
8
15
|
* Filters registered block settings, adding an `__experimentalLabel` callback if one does not already exist.
|
|
@@ -38,6 +45,32 @@ export function addLabelCallback( settings ) {
|
|
|
38
45
|
return settings;
|
|
39
46
|
}
|
|
40
47
|
|
|
48
|
+
function BlockRenameControlPure( { metadata, setAttributes } ) {
|
|
49
|
+
return (
|
|
50
|
+
<InspectorControls group="advanced">
|
|
51
|
+
<TextControl
|
|
52
|
+
__nextHasNoMarginBottom
|
|
53
|
+
__next40pxDefaultSize
|
|
54
|
+
label={ __( 'Block name' ) }
|
|
55
|
+
value={ metadata?.name || '' }
|
|
56
|
+
onChange={ ( newName ) => {
|
|
57
|
+
setAttributes( {
|
|
58
|
+
metadata: { ...metadata, name: newName },
|
|
59
|
+
} );
|
|
60
|
+
} }
|
|
61
|
+
/>
|
|
62
|
+
</InspectorControls>
|
|
63
|
+
);
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
export default {
|
|
67
|
+
edit: BlockRenameControlPure,
|
|
68
|
+
attributeKeys: [ 'metadata' ],
|
|
69
|
+
hasSupport( name ) {
|
|
70
|
+
return hasBlockSupport( name, 'renaming', true );
|
|
71
|
+
},
|
|
72
|
+
};
|
|
73
|
+
|
|
41
74
|
addFilter(
|
|
42
75
|
'blocks.registerBlockType',
|
|
43
76
|
'core/metadata/addLabelCallback',
|
package/src/hooks/border.js
CHANGED
|
@@ -8,9 +8,10 @@ import classnames from 'classnames';
|
|
|
8
8
|
*/
|
|
9
9
|
import { getBlockSupport } from '@wordpress/blocks';
|
|
10
10
|
import { __experimentalHasSplitBorders as hasSplitBorders } from '@wordpress/components';
|
|
11
|
-
import {
|
|
11
|
+
import { pure } from '@wordpress/compose';
|
|
12
12
|
import { Platform, useCallback, useMemo } from '@wordpress/element';
|
|
13
13
|
import { addFilter } from '@wordpress/hooks';
|
|
14
|
+
import { useSelect } from '@wordpress/data';
|
|
14
15
|
|
|
15
16
|
/**
|
|
16
17
|
* Internal dependencies
|
|
@@ -18,15 +19,12 @@ import { addFilter } from '@wordpress/hooks';
|
|
|
18
19
|
import { getColorClassName } from '../components/colors';
|
|
19
20
|
import InspectorControls from '../components/inspector-controls';
|
|
20
21
|
import useMultipleOriginColorsAndGradients from '../components/colors-gradients/use-multiple-origin-colors-and-gradients';
|
|
21
|
-
import {
|
|
22
|
-
cleanEmptyObject,
|
|
23
|
-
shouldSkipSerialization,
|
|
24
|
-
useBlockSettings,
|
|
25
|
-
} from './utils';
|
|
22
|
+
import { cleanEmptyObject, shouldSkipSerialization } from './utils';
|
|
26
23
|
import {
|
|
27
24
|
useHasBorderPanel,
|
|
28
25
|
BorderPanel as StylesBorderPanel,
|
|
29
26
|
} from '../components/global-styles';
|
|
27
|
+
import { store as blockEditorStore } from '../store';
|
|
30
28
|
|
|
31
29
|
export const BORDER_SUPPORT_KEY = '__experimentalBorder';
|
|
32
30
|
|
|
@@ -135,16 +133,17 @@ function BordersInspectorControl( { children, resetAllFilter } ) {
|
|
|
135
133
|
);
|
|
136
134
|
}
|
|
137
135
|
|
|
138
|
-
|
|
139
|
-
const { clientId, name, attributes, setAttributes } = props;
|
|
140
|
-
const settings = useBlockSettings( name );
|
|
136
|
+
function BorderPanelPure( { clientId, name, setAttributes, settings } ) {
|
|
141
137
|
const isEnabled = useHasBorderPanel( settings );
|
|
138
|
+
function selector( select ) {
|
|
139
|
+
const { style, borderColor } =
|
|
140
|
+
select( blockEditorStore ).getBlockAttributes( clientId ) || {};
|
|
141
|
+
return { style, borderColor };
|
|
142
|
+
}
|
|
143
|
+
const { style, borderColor } = useSelect( selector, [ clientId ] );
|
|
142
144
|
const value = useMemo( () => {
|
|
143
|
-
return attributesToStyle( {
|
|
144
|
-
|
|
145
|
-
borderColor: attributes.borderColor,
|
|
146
|
-
} );
|
|
147
|
-
}, [ attributes.style, attributes.borderColor ] );
|
|
145
|
+
return attributesToStyle( { style, borderColor } );
|
|
146
|
+
}, [ style, borderColor ] );
|
|
148
147
|
|
|
149
148
|
const onChange = ( newStyle ) => {
|
|
150
149
|
setAttributes( styleToAttributes( newStyle ) );
|
|
@@ -154,7 +153,7 @@ export function BorderPanel( props ) {
|
|
|
154
153
|
return null;
|
|
155
154
|
}
|
|
156
155
|
|
|
157
|
-
const defaultControls = getBlockSupport(
|
|
156
|
+
const defaultControls = getBlockSupport( name, [
|
|
158
157
|
BORDER_SUPPORT_KEY,
|
|
159
158
|
'__experimentalDefaultControls',
|
|
160
159
|
] );
|
|
@@ -171,6 +170,11 @@ export function BorderPanel( props ) {
|
|
|
171
170
|
);
|
|
172
171
|
}
|
|
173
172
|
|
|
173
|
+
// We don't want block controls to re-render when typing inside a block. `pure`
|
|
174
|
+
// will prevent re-renders unless props change, so only pass the needed props
|
|
175
|
+
// and not the whole attributes object.
|
|
176
|
+
export const BorderPanel = pure( BorderPanelPure );
|
|
177
|
+
|
|
174
178
|
/**
|
|
175
179
|
* Determine whether there is block support for border properties.
|
|
176
180
|
*
|
|
@@ -254,16 +258,16 @@ function addAttributes( settings ) {
|
|
|
254
258
|
/**
|
|
255
259
|
* Override props assigned to save component to inject border color.
|
|
256
260
|
*
|
|
257
|
-
* @param {Object}
|
|
258
|
-
* @param {Object}
|
|
259
|
-
* @param {Object}
|
|
261
|
+
* @param {Object} props Additional props applied to save element.
|
|
262
|
+
* @param {Object|string} blockNameOrType Block type definition.
|
|
263
|
+
* @param {Object} attributes Block's attributes.
|
|
260
264
|
*
|
|
261
265
|
* @return {Object} Filtered props to apply to save element.
|
|
262
266
|
*/
|
|
263
|
-
function addSaveProps( props,
|
|
267
|
+
function addSaveProps( props, blockNameOrType, attributes ) {
|
|
264
268
|
if (
|
|
265
|
-
! hasBorderSupport(
|
|
266
|
-
shouldSkipSerialization(
|
|
269
|
+
! hasBorderSupport( blockNameOrType, 'color' ) ||
|
|
270
|
+
shouldSkipSerialization( blockNameOrType, BORDER_SUPPORT_KEY, 'color' )
|
|
267
271
|
) {
|
|
268
272
|
return props;
|
|
269
273
|
}
|
|
@@ -296,102 +300,59 @@ export function getBorderClasses( attributes ) {
|
|
|
296
300
|
} );
|
|
297
301
|
}
|
|
298
302
|
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
*
|
|
303
|
-
* @param {Object} settings Original block settings.
|
|
304
|
-
*
|
|
305
|
-
* @return {Object} Filtered block settings.
|
|
306
|
-
*/
|
|
307
|
-
function addEditProps( settings ) {
|
|
303
|
+
function useBlockProps( { name, borderColor, style } ) {
|
|
304
|
+
const { colors } = useMultipleOriginColorsAndGradients();
|
|
305
|
+
|
|
308
306
|
if (
|
|
309
|
-
! hasBorderSupport(
|
|
310
|
-
shouldSkipSerialization(
|
|
307
|
+
! hasBorderSupport( name, 'color' ) ||
|
|
308
|
+
shouldSkipSerialization( name, BORDER_SUPPORT_KEY, 'color' )
|
|
311
309
|
) {
|
|
312
|
-
return
|
|
310
|
+
return {};
|
|
313
311
|
}
|
|
314
312
|
|
|
315
|
-
const
|
|
316
|
-
|
|
317
|
-
|
|
313
|
+
const { color: borderColorValue } = getMultiOriginColor( {
|
|
314
|
+
colors,
|
|
315
|
+
namedColor: borderColor,
|
|
316
|
+
} );
|
|
317
|
+
const { color: borderTopColor } = getMultiOriginColor( {
|
|
318
|
+
colors,
|
|
319
|
+
namedColor: getColorSlugFromVariable( style?.border?.top?.color ),
|
|
320
|
+
} );
|
|
321
|
+
const { color: borderRightColor } = getMultiOriginColor( {
|
|
322
|
+
colors,
|
|
323
|
+
namedColor: getColorSlugFromVariable( style?.border?.right?.color ),
|
|
324
|
+
} );
|
|
318
325
|
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
326
|
+
const { color: borderBottomColor } = getMultiOriginColor( {
|
|
327
|
+
colors,
|
|
328
|
+
namedColor: getColorSlugFromVariable( style?.border?.bottom?.color ),
|
|
329
|
+
} );
|
|
330
|
+
const { color: borderLeftColor } = getMultiOriginColor( {
|
|
331
|
+
colors,
|
|
332
|
+
namedColor: getColorSlugFromVariable( style?.border?.left?.color ),
|
|
333
|
+
} );
|
|
322
334
|
|
|
323
|
-
|
|
335
|
+
const extraStyles = {
|
|
336
|
+
borderTopColor: borderTopColor || borderColorValue,
|
|
337
|
+
borderRightColor: borderRightColor || borderColorValue,
|
|
338
|
+
borderBottomColor: borderBottomColor || borderColorValue,
|
|
339
|
+
borderLeftColor: borderLeftColor || borderColorValue,
|
|
324
340
|
};
|
|
325
341
|
|
|
326
|
-
return
|
|
342
|
+
return addSaveProps(
|
|
343
|
+
{ style: cleanEmptyObject( extraStyles ) || {} },
|
|
344
|
+
name,
|
|
345
|
+
{ borderColor, style }
|
|
346
|
+
);
|
|
327
347
|
}
|
|
328
348
|
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
*
|
|
335
|
-
* @return {Function} Wrapped component.
|
|
336
|
-
*/
|
|
337
|
-
export const withBorderColorPaletteStyles = createHigherOrderComponent(
|
|
338
|
-
( BlockListBlock ) => ( props ) => {
|
|
339
|
-
const { name, attributes } = props;
|
|
340
|
-
const { borderColor, style } = attributes;
|
|
341
|
-
const { colors } = useMultipleOriginColorsAndGradients();
|
|
342
|
-
|
|
343
|
-
if (
|
|
344
|
-
! hasBorderSupport( name, 'color' ) ||
|
|
345
|
-
shouldSkipSerialization( name, BORDER_SUPPORT_KEY, 'color' )
|
|
346
|
-
) {
|
|
347
|
-
return <BlockListBlock { ...props } />;
|
|
348
|
-
}
|
|
349
|
-
|
|
350
|
-
const { color: borderColorValue } = getMultiOriginColor( {
|
|
351
|
-
colors,
|
|
352
|
-
namedColor: borderColor,
|
|
353
|
-
} );
|
|
354
|
-
const { color: borderTopColor } = getMultiOriginColor( {
|
|
355
|
-
colors,
|
|
356
|
-
namedColor: getColorSlugFromVariable( style?.border?.top?.color ),
|
|
357
|
-
} );
|
|
358
|
-
const { color: borderRightColor } = getMultiOriginColor( {
|
|
359
|
-
colors,
|
|
360
|
-
namedColor: getColorSlugFromVariable( style?.border?.right?.color ),
|
|
361
|
-
} );
|
|
362
|
-
|
|
363
|
-
const { color: borderBottomColor } = getMultiOriginColor( {
|
|
364
|
-
colors,
|
|
365
|
-
namedColor: getColorSlugFromVariable(
|
|
366
|
-
style?.border?.bottom?.color
|
|
367
|
-
),
|
|
368
|
-
} );
|
|
369
|
-
const { color: borderLeftColor } = getMultiOriginColor( {
|
|
370
|
-
colors,
|
|
371
|
-
namedColor: getColorSlugFromVariable( style?.border?.left?.color ),
|
|
372
|
-
} );
|
|
373
|
-
|
|
374
|
-
const extraStyles = {
|
|
375
|
-
borderTopColor: borderTopColor || borderColorValue,
|
|
376
|
-
borderRightColor: borderRightColor || borderColorValue,
|
|
377
|
-
borderBottomColor: borderBottomColor || borderColorValue,
|
|
378
|
-
borderLeftColor: borderLeftColor || borderColorValue,
|
|
379
|
-
};
|
|
380
|
-
const cleanedExtraStyles = cleanEmptyObject( extraStyles ) || {};
|
|
381
|
-
|
|
382
|
-
let wrapperProps = props.wrapperProps;
|
|
383
|
-
wrapperProps = {
|
|
384
|
-
...props.wrapperProps,
|
|
385
|
-
style: {
|
|
386
|
-
...props.wrapperProps?.style,
|
|
387
|
-
...cleanedExtraStyles,
|
|
388
|
-
},
|
|
389
|
-
};
|
|
390
|
-
|
|
391
|
-
return <BlockListBlock { ...props } wrapperProps={ wrapperProps } />;
|
|
349
|
+
export default {
|
|
350
|
+
useBlockProps,
|
|
351
|
+
attributeKeys: [ 'borderColor', 'style' ],
|
|
352
|
+
hasSupport( name ) {
|
|
353
|
+
return hasBorderSupport( name, 'color' );
|
|
392
354
|
},
|
|
393
|
-
|
|
394
|
-
);
|
|
355
|
+
};
|
|
395
356
|
|
|
396
357
|
addFilter(
|
|
397
358
|
'blocks.registerBlockType',
|
|
@@ -404,15 +365,3 @@ addFilter(
|
|
|
404
365
|
'core/border/addSaveProps',
|
|
405
366
|
addSaveProps
|
|
406
367
|
);
|
|
407
|
-
|
|
408
|
-
addFilter(
|
|
409
|
-
'blocks.registerBlockType',
|
|
410
|
-
'core/border/addEditProps',
|
|
411
|
-
addEditProps
|
|
412
|
-
);
|
|
413
|
-
|
|
414
|
-
addFilter(
|
|
415
|
-
'editor.BlockListBlock',
|
|
416
|
-
'core/border/with-border-color-palette-styles',
|
|
417
|
-
withBorderColorPaletteStyles
|
|
418
|
-
);
|