@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
|
@@ -1,159 +0,0 @@
|
|
|
1
|
-
import { createElement, Fragment } from "react";
|
|
2
|
-
/**
|
|
3
|
-
* WordPress dependencies
|
|
4
|
-
*/
|
|
5
|
-
import { createHigherOrderComponent, useInstanceId } from '@wordpress/compose';
|
|
6
|
-
import { addFilter } from '@wordpress/hooks';
|
|
7
|
-
import { __, sprintf } from '@wordpress/i18n';
|
|
8
|
-
import { hasBlockSupport } from '@wordpress/blocks';
|
|
9
|
-
import { MenuItem, __experimentalHStack as HStack, __experimentalVStack as VStack, Button, TextControl, Modal } from '@wordpress/components';
|
|
10
|
-
import { useState } from '@wordpress/element';
|
|
11
|
-
import { speak } from '@wordpress/a11y';
|
|
12
|
-
|
|
13
|
-
/**
|
|
14
|
-
* Internal dependencies
|
|
15
|
-
*/
|
|
16
|
-
import { BlockSettingsMenuControls, useBlockDisplayInformation, InspectorControls } from '../components';
|
|
17
|
-
const emptyString = testString => testString?.trim()?.length === 0;
|
|
18
|
-
function RenameModal({
|
|
19
|
-
blockName,
|
|
20
|
-
originalBlockName,
|
|
21
|
-
onClose,
|
|
22
|
-
onSave
|
|
23
|
-
}) {
|
|
24
|
-
const [editedBlockName, setEditedBlockName] = useState(blockName);
|
|
25
|
-
const nameHasChanged = editedBlockName !== blockName;
|
|
26
|
-
const nameIsOriginal = editedBlockName === originalBlockName;
|
|
27
|
-
const nameIsEmpty = emptyString(editedBlockName);
|
|
28
|
-
const isNameValid = nameHasChanged || nameIsOriginal;
|
|
29
|
-
const autoSelectInputText = event => event.target.select();
|
|
30
|
-
const dialogDescription = useInstanceId(RenameModal, `block-editor-rename-modal__description`);
|
|
31
|
-
const handleSubmit = () => {
|
|
32
|
-
const message = nameIsOriginal || nameIsEmpty ? sprintf( /* translators: %s: new name/label for the block */
|
|
33
|
-
__('Block name reset to: "%s".'), editedBlockName) : sprintf( /* translators: %s: new name/label for the block */
|
|
34
|
-
__('Block name changed to: "%s".'), editedBlockName);
|
|
35
|
-
|
|
36
|
-
// Must be assertive to immediately announce change.
|
|
37
|
-
speak(message, 'assertive');
|
|
38
|
-
onSave(editedBlockName);
|
|
39
|
-
|
|
40
|
-
// Immediate close avoids ability to hit save multiple times.
|
|
41
|
-
onClose();
|
|
42
|
-
};
|
|
43
|
-
return createElement(Modal, {
|
|
44
|
-
title: __('Rename'),
|
|
45
|
-
onRequestClose: onClose,
|
|
46
|
-
overlayClassName: "block-editor-block-rename-modal",
|
|
47
|
-
aria: {
|
|
48
|
-
describedby: dialogDescription
|
|
49
|
-
},
|
|
50
|
-
focusOnMount: "firstContentElement"
|
|
51
|
-
}, createElement("p", {
|
|
52
|
-
id: dialogDescription
|
|
53
|
-
}, __('Enter a custom name for this block.')), createElement("form", {
|
|
54
|
-
onSubmit: e => {
|
|
55
|
-
e.preventDefault();
|
|
56
|
-
if (!isNameValid) {
|
|
57
|
-
return;
|
|
58
|
-
}
|
|
59
|
-
handleSubmit();
|
|
60
|
-
}
|
|
61
|
-
}, createElement(VStack, {
|
|
62
|
-
spacing: "3"
|
|
63
|
-
}, createElement(TextControl, {
|
|
64
|
-
__nextHasNoMarginBottom: true,
|
|
65
|
-
__next40pxDefaultSize: true,
|
|
66
|
-
value: editedBlockName,
|
|
67
|
-
label: __('Block name'),
|
|
68
|
-
hideLabelFromVision: true,
|
|
69
|
-
placeholder: originalBlockName,
|
|
70
|
-
onChange: setEditedBlockName,
|
|
71
|
-
onFocus: autoSelectInputText
|
|
72
|
-
}), createElement(HStack, {
|
|
73
|
-
justify: "right"
|
|
74
|
-
}, createElement(Button, {
|
|
75
|
-
variant: "tertiary",
|
|
76
|
-
onClick: onClose
|
|
77
|
-
}, __('Cancel')), createElement(Button, {
|
|
78
|
-
"aria-disabled": !isNameValid,
|
|
79
|
-
variant: "primary",
|
|
80
|
-
type: "submit"
|
|
81
|
-
}, __('Save'))))));
|
|
82
|
-
}
|
|
83
|
-
function BlockRenameControl(props) {
|
|
84
|
-
const [renamingBlock, setRenamingBlock] = useState(false);
|
|
85
|
-
const {
|
|
86
|
-
clientId,
|
|
87
|
-
customName,
|
|
88
|
-
onChange
|
|
89
|
-
} = props;
|
|
90
|
-
const blockInformation = useBlockDisplayInformation(clientId);
|
|
91
|
-
return createElement(Fragment, null, createElement(InspectorControls, {
|
|
92
|
-
group: "advanced"
|
|
93
|
-
}, createElement(TextControl, {
|
|
94
|
-
__nextHasNoMarginBottom: true,
|
|
95
|
-
__next40pxDefaultSize: true,
|
|
96
|
-
label: __('Block name'),
|
|
97
|
-
value: customName || '',
|
|
98
|
-
onChange: onChange
|
|
99
|
-
})), createElement(BlockSettingsMenuControls, null, ({
|
|
100
|
-
selectedClientIds
|
|
101
|
-
}) => {
|
|
102
|
-
// Only enabled for single selections.
|
|
103
|
-
const canRename = selectedClientIds.length === 1 && clientId === selectedClientIds[0];
|
|
104
|
-
|
|
105
|
-
// This check ensures the `BlockSettingsMenuControls` fill
|
|
106
|
-
// doesn't render multiple times and also that it renders for
|
|
107
|
-
// the block from which the menu was triggered.
|
|
108
|
-
if (!canRename) {
|
|
109
|
-
return null;
|
|
110
|
-
}
|
|
111
|
-
return createElement(MenuItem, {
|
|
112
|
-
onClick: () => {
|
|
113
|
-
setRenamingBlock(true);
|
|
114
|
-
},
|
|
115
|
-
"aria-expanded": renamingBlock,
|
|
116
|
-
"aria-haspopup": "dialog"
|
|
117
|
-
}, __('Rename'));
|
|
118
|
-
}), renamingBlock && createElement(RenameModal, {
|
|
119
|
-
blockName: customName || '',
|
|
120
|
-
originalBlockName: blockInformation?.title,
|
|
121
|
-
onClose: () => setRenamingBlock(false),
|
|
122
|
-
onSave: newName => {
|
|
123
|
-
// If the new value is the block's original name (e.g. `Group`)
|
|
124
|
-
// or it is an empty string then assume the intent is to reset
|
|
125
|
-
// the value. Therefore reset the metadata.
|
|
126
|
-
if (newName === blockInformation?.title || emptyString(newName)) {
|
|
127
|
-
newName = undefined;
|
|
128
|
-
}
|
|
129
|
-
onChange(newName);
|
|
130
|
-
}
|
|
131
|
-
}));
|
|
132
|
-
}
|
|
133
|
-
export const withBlockRenameControls = createHigherOrderComponent(BlockEdit => props => {
|
|
134
|
-
const {
|
|
135
|
-
clientId,
|
|
136
|
-
name,
|
|
137
|
-
attributes,
|
|
138
|
-
setAttributes,
|
|
139
|
-
isSelected
|
|
140
|
-
} = props;
|
|
141
|
-
const supportsBlockNaming = hasBlockSupport(name, 'renaming', true);
|
|
142
|
-
return createElement(Fragment, null, isSelected && supportsBlockNaming && createElement(Fragment, null, createElement(BlockRenameControl, {
|
|
143
|
-
clientId: clientId,
|
|
144
|
-
customName: attributes?.metadata?.name,
|
|
145
|
-
onChange: newName => {
|
|
146
|
-
setAttributes({
|
|
147
|
-
metadata: {
|
|
148
|
-
...attributes?.metadata,
|
|
149
|
-
name: newName
|
|
150
|
-
}
|
|
151
|
-
});
|
|
152
|
-
}
|
|
153
|
-
})), createElement(BlockEdit, {
|
|
154
|
-
key: "edit",
|
|
155
|
-
...props
|
|
156
|
-
}));
|
|
157
|
-
}, 'withBlockRenameControls');
|
|
158
|
-
addFilter('editor.BlockEdit', 'core/block-rename-ui/with-block-rename-controls', withBlockRenameControls);
|
|
159
|
-
//# sourceMappingURL=block-rename-ui.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"names":["createHigherOrderComponent","useInstanceId","addFilter","__","sprintf","hasBlockSupport","MenuItem","__experimentalHStack","HStack","__experimentalVStack","VStack","Button","TextControl","Modal","useState","speak","BlockSettingsMenuControls","useBlockDisplayInformation","InspectorControls","emptyString","testString","trim","length","RenameModal","blockName","originalBlockName","onClose","onSave","editedBlockName","setEditedBlockName","nameHasChanged","nameIsOriginal","nameIsEmpty","isNameValid","autoSelectInputText","event","target","select","dialogDescription","handleSubmit","message","createElement","title","onRequestClose","overlayClassName","aria","describedby","focusOnMount","id","onSubmit","e","preventDefault","spacing","__nextHasNoMarginBottom","__next40pxDefaultSize","value","label","hideLabelFromVision","placeholder","onChange","onFocus","justify","variant","onClick","type","BlockRenameControl","props","renamingBlock","setRenamingBlock","clientId","customName","blockInformation","Fragment","group","selectedClientIds","canRename","newName","undefined","withBlockRenameControls","BlockEdit","name","attributes","setAttributes","isSelected","supportsBlockNaming","metadata","key"],"sources":["@wordpress/block-editor/src/hooks/block-rename-ui.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { createHigherOrderComponent, useInstanceId } from '@wordpress/compose';\nimport { addFilter } from '@wordpress/hooks';\nimport { __, sprintf } from '@wordpress/i18n';\nimport { hasBlockSupport } from '@wordpress/blocks';\nimport {\n\tMenuItem,\n\t__experimentalHStack as HStack,\n\t__experimentalVStack as VStack,\n\tButton,\n\tTextControl,\n\tModal,\n} from '@wordpress/components';\nimport { useState } from '@wordpress/element';\nimport { speak } from '@wordpress/a11y';\n\n/**\n * Internal dependencies\n */\nimport {\n\tBlockSettingsMenuControls,\n\tuseBlockDisplayInformation,\n\tInspectorControls,\n} from '../components';\n\nconst emptyString = ( testString ) => testString?.trim()?.length === 0;\n\nfunction RenameModal( { blockName, originalBlockName, onClose, onSave } ) {\n\tconst [ editedBlockName, setEditedBlockName ] = useState( blockName );\n\n\tconst nameHasChanged = editedBlockName !== blockName;\n\tconst nameIsOriginal = editedBlockName === originalBlockName;\n\tconst nameIsEmpty = emptyString( editedBlockName );\n\n\tconst isNameValid = nameHasChanged || nameIsOriginal;\n\n\tconst autoSelectInputText = ( event ) => event.target.select();\n\n\tconst dialogDescription = useInstanceId(\n\t\tRenameModal,\n\t\t`block-editor-rename-modal__description`\n\t);\n\n\tconst handleSubmit = () => {\n\t\tconst message =\n\t\t\tnameIsOriginal || nameIsEmpty\n\t\t\t\t? sprintf(\n\t\t\t\t\t\t/* translators: %s: new name/label for the block */\n\t\t\t\t\t\t__( 'Block name reset to: \"%s\".' ),\n\t\t\t\t\t\teditedBlockName\n\t\t\t\t )\n\t\t\t\t: sprintf(\n\t\t\t\t\t\t/* translators: %s: new name/label for the block */\n\t\t\t\t\t\t__( 'Block name changed to: \"%s\".' ),\n\t\t\t\t\t\teditedBlockName\n\t\t\t\t );\n\n\t\t// Must be assertive to immediately announce change.\n\t\tspeak( message, 'assertive' );\n\t\tonSave( editedBlockName );\n\n\t\t// Immediate close avoids ability to hit save multiple times.\n\t\tonClose();\n\t};\n\n\treturn (\n\t\t<Modal\n\t\t\ttitle={ __( 'Rename' ) }\n\t\t\tonRequestClose={ onClose }\n\t\t\toverlayClassName=\"block-editor-block-rename-modal\"\n\t\t\taria={ {\n\t\t\t\tdescribedby: dialogDescription,\n\t\t\t} }\n\t\t\tfocusOnMount=\"firstContentElement\"\n\t\t>\n\t\t\t<p id={ dialogDescription }>\n\t\t\t\t{ __( 'Enter a custom name for this block.' ) }\n\t\t\t</p>\n\t\t\t<form\n\t\t\t\tonSubmit={ ( e ) => {\n\t\t\t\t\te.preventDefault();\n\n\t\t\t\t\tif ( ! isNameValid ) {\n\t\t\t\t\t\treturn;\n\t\t\t\t\t}\n\n\t\t\t\t\thandleSubmit();\n\t\t\t\t} }\n\t\t\t>\n\t\t\t\t<VStack spacing=\"3\">\n\t\t\t\t\t<TextControl\n\t\t\t\t\t\t__nextHasNoMarginBottom\n\t\t\t\t\t\t__next40pxDefaultSize\n\t\t\t\t\t\tvalue={ editedBlockName }\n\t\t\t\t\t\tlabel={ __( 'Block name' ) }\n\t\t\t\t\t\thideLabelFromVision={ true }\n\t\t\t\t\t\tplaceholder={ originalBlockName }\n\t\t\t\t\t\tonChange={ setEditedBlockName }\n\t\t\t\t\t\tonFocus={ autoSelectInputText }\n\t\t\t\t\t/>\n\t\t\t\t\t<HStack justify=\"right\">\n\t\t\t\t\t\t<Button variant=\"tertiary\" onClick={ onClose }>\n\t\t\t\t\t\t\t{ __( 'Cancel' ) }\n\t\t\t\t\t\t</Button>\n\n\t\t\t\t\t\t<Button\n\t\t\t\t\t\t\taria-disabled={ ! isNameValid }\n\t\t\t\t\t\t\tvariant=\"primary\"\n\t\t\t\t\t\t\ttype=\"submit\"\n\t\t\t\t\t\t>\n\t\t\t\t\t\t\t{ __( 'Save' ) }\n\t\t\t\t\t\t</Button>\n\t\t\t\t\t</HStack>\n\t\t\t\t</VStack>\n\t\t\t</form>\n\t\t</Modal>\n\t);\n}\n\nfunction BlockRenameControl( props ) {\n\tconst [ renamingBlock, setRenamingBlock ] = useState( false );\n\n\tconst { clientId, customName, onChange } = props;\n\n\tconst blockInformation = useBlockDisplayInformation( clientId );\n\n\treturn (\n\t\t<>\n\t\t\t<InspectorControls group=\"advanced\">\n\t\t\t\t<TextControl\n\t\t\t\t\t__nextHasNoMarginBottom\n\t\t\t\t\t__next40pxDefaultSize\n\t\t\t\t\tlabel={ __( 'Block name' ) }\n\t\t\t\t\tvalue={ customName || '' }\n\t\t\t\t\tonChange={ onChange }\n\t\t\t\t/>\n\t\t\t</InspectorControls>\n\t\t\t<BlockSettingsMenuControls>\n\t\t\t\t{ ( { selectedClientIds } ) => {\n\t\t\t\t\t// Only enabled for single selections.\n\t\t\t\t\tconst canRename =\n\t\t\t\t\t\tselectedClientIds.length === 1 &&\n\t\t\t\t\t\tclientId === selectedClientIds[ 0 ];\n\n\t\t\t\t\t// This check ensures the `BlockSettingsMenuControls` fill\n\t\t\t\t\t// doesn't render multiple times and also that it renders for\n\t\t\t\t\t// the block from which the menu was triggered.\n\t\t\t\t\tif ( ! canRename ) {\n\t\t\t\t\t\treturn null;\n\t\t\t\t\t}\n\n\t\t\t\t\treturn (\n\t\t\t\t\t\t<MenuItem\n\t\t\t\t\t\t\tonClick={ () => {\n\t\t\t\t\t\t\t\tsetRenamingBlock( true );\n\t\t\t\t\t\t\t} }\n\t\t\t\t\t\t\taria-expanded={ renamingBlock }\n\t\t\t\t\t\t\taria-haspopup=\"dialog\"\n\t\t\t\t\t\t>\n\t\t\t\t\t\t\t{ __( 'Rename' ) }\n\t\t\t\t\t\t</MenuItem>\n\t\t\t\t\t);\n\t\t\t\t} }\n\t\t\t</BlockSettingsMenuControls>\n\n\t\t\t{ renamingBlock && (\n\t\t\t\t<RenameModal\n\t\t\t\t\tblockName={ customName || '' }\n\t\t\t\t\toriginalBlockName={ blockInformation?.title }\n\t\t\t\t\tonClose={ () => setRenamingBlock( false ) }\n\t\t\t\t\tonSave={ ( newName ) => {\n\t\t\t\t\t\t// If the new value is the block's original name (e.g. `Group`)\n\t\t\t\t\t\t// or it is an empty string then assume the intent is to reset\n\t\t\t\t\t\t// the value. Therefore reset the metadata.\n\t\t\t\t\t\tif (\n\t\t\t\t\t\t\tnewName === blockInformation?.title ||\n\t\t\t\t\t\t\temptyString( newName )\n\t\t\t\t\t\t) {\n\t\t\t\t\t\t\tnewName = undefined;\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\tonChange( newName );\n\t\t\t\t\t} }\n\t\t\t\t/>\n\t\t\t) }\n\t\t</>\n\t);\n}\n\nexport const withBlockRenameControls = createHigherOrderComponent(\n\t( BlockEdit ) => ( props ) => {\n\t\tconst { clientId, name, attributes, setAttributes, isSelected } = props;\n\n\t\tconst supportsBlockNaming = hasBlockSupport( name, 'renaming', true );\n\n\t\treturn (\n\t\t\t<>\n\t\t\t\t{ isSelected && supportsBlockNaming && (\n\t\t\t\t\t<>\n\t\t\t\t\t\t<BlockRenameControl\n\t\t\t\t\t\t\tclientId={ clientId }\n\t\t\t\t\t\t\tcustomName={ attributes?.metadata?.name }\n\t\t\t\t\t\t\tonChange={ ( newName ) => {\n\t\t\t\t\t\t\t\tsetAttributes( {\n\t\t\t\t\t\t\t\t\tmetadata: {\n\t\t\t\t\t\t\t\t\t\t...attributes?.metadata,\n\t\t\t\t\t\t\t\t\t\tname: newName,\n\t\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t} );\n\t\t\t\t\t\t\t} }\n\t\t\t\t\t\t/>\n\t\t\t\t\t</>\n\t\t\t\t) }\n\n\t\t\t\t<BlockEdit key=\"edit\" { ...props } />\n\t\t\t</>\n\t\t);\n\t},\n\t'withBlockRenameControls'\n);\n\naddFilter(\n\t'editor.BlockEdit',\n\t'core/block-rename-ui/with-block-rename-controls',\n\twithBlockRenameControls\n);\n"],"mappings":"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"}
|
|
@@ -1,66 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* External dependencies
|
|
3
|
-
*/
|
|
4
|
-
import classnames from 'classnames';
|
|
5
|
-
|
|
6
|
-
/**
|
|
7
|
-
* WordPress dependencies
|
|
8
|
-
*/
|
|
9
|
-
import { useSelect } from '@wordpress/data';
|
|
10
|
-
import { isReusableBlock, getBlockType } from '@wordpress/blocks';
|
|
11
|
-
|
|
12
|
-
/**
|
|
13
|
-
* Internal dependencies
|
|
14
|
-
*/
|
|
15
|
-
import { store as blockEditorStore } from '../../../store';
|
|
16
|
-
|
|
17
|
-
/**
|
|
18
|
-
* Returns the class names used for the different states of the block.
|
|
19
|
-
*
|
|
20
|
-
* @param {string} clientId The block client ID.
|
|
21
|
-
*
|
|
22
|
-
* @return {string} The class names.
|
|
23
|
-
*/
|
|
24
|
-
export function useBlockClassNames( clientId ) {
|
|
25
|
-
return useSelect(
|
|
26
|
-
( select ) => {
|
|
27
|
-
const {
|
|
28
|
-
isBlockBeingDragged,
|
|
29
|
-
isBlockHighlighted,
|
|
30
|
-
isBlockSelected,
|
|
31
|
-
isBlockMultiSelected,
|
|
32
|
-
getBlockName,
|
|
33
|
-
getSettings,
|
|
34
|
-
hasSelectedInnerBlock,
|
|
35
|
-
isTyping,
|
|
36
|
-
__unstableIsFullySelected,
|
|
37
|
-
__unstableSelectionHasUnmergeableBlock,
|
|
38
|
-
} = select( blockEditorStore );
|
|
39
|
-
const { outlineMode } = getSettings();
|
|
40
|
-
const isDragging = isBlockBeingDragged( clientId );
|
|
41
|
-
const isSelected = isBlockSelected( clientId );
|
|
42
|
-
const name = getBlockName( clientId );
|
|
43
|
-
const checkDeep = true;
|
|
44
|
-
// "ancestor" is the more appropriate label due to "deep" check.
|
|
45
|
-
const isAncestorOfSelectedBlock = hasSelectedInnerBlock(
|
|
46
|
-
clientId,
|
|
47
|
-
checkDeep
|
|
48
|
-
);
|
|
49
|
-
const isMultiSelected = isBlockMultiSelected( clientId );
|
|
50
|
-
return classnames( {
|
|
51
|
-
'is-selected': isSelected,
|
|
52
|
-
'is-highlighted': isBlockHighlighted( clientId ),
|
|
53
|
-
'is-multi-selected': isMultiSelected,
|
|
54
|
-
'is-partially-selected':
|
|
55
|
-
isMultiSelected &&
|
|
56
|
-
! __unstableIsFullySelected() &&
|
|
57
|
-
! __unstableSelectionHasUnmergeableBlock(),
|
|
58
|
-
'is-reusable': isReusableBlock( getBlockType( name ) ),
|
|
59
|
-
'is-dragging': isDragging,
|
|
60
|
-
'has-child-selected': isAncestorOfSelectedBlock,
|
|
61
|
-
'remove-outline': isSelected && outlineMode && isTyping(),
|
|
62
|
-
} );
|
|
63
|
-
},
|
|
64
|
-
[ clientId ]
|
|
65
|
-
);
|
|
66
|
-
}
|
|
@@ -1,44 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* WordPress dependencies
|
|
3
|
-
*/
|
|
4
|
-
import { useSelect } from '@wordpress/data';
|
|
5
|
-
import { getBlockType } from '@wordpress/blocks';
|
|
6
|
-
|
|
7
|
-
/**
|
|
8
|
-
* Internal dependencies
|
|
9
|
-
*/
|
|
10
|
-
import { store as blockEditorStore } from '../../../store';
|
|
11
|
-
|
|
12
|
-
/**
|
|
13
|
-
* Returns the custom class name if the block is a light block.
|
|
14
|
-
*
|
|
15
|
-
* @param {string} clientId The block client ID.
|
|
16
|
-
*
|
|
17
|
-
* @return {string} The custom class name.
|
|
18
|
-
*/
|
|
19
|
-
export function useBlockCustomClassName( clientId ) {
|
|
20
|
-
// It's good for this to be a separate selector because it will be executed
|
|
21
|
-
// on every attribute change, while the other selectors are not re-evaluated
|
|
22
|
-
// as much.
|
|
23
|
-
return useSelect(
|
|
24
|
-
( select ) => {
|
|
25
|
-
const { getBlockName, getBlockAttributes } =
|
|
26
|
-
select( blockEditorStore );
|
|
27
|
-
const attributes = getBlockAttributes( clientId );
|
|
28
|
-
|
|
29
|
-
if ( ! attributes?.className ) {
|
|
30
|
-
return;
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
const blockType = getBlockType( getBlockName( clientId ) );
|
|
34
|
-
const hasLightBlockWrapper = blockType?.apiVersion > 1;
|
|
35
|
-
|
|
36
|
-
if ( ! hasLightBlockWrapper ) {
|
|
37
|
-
return;
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
return attributes.className;
|
|
41
|
-
},
|
|
42
|
-
[ clientId ]
|
|
43
|
-
);
|
|
44
|
-
}
|
|
@@ -1,35 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* WordPress dependencies
|
|
3
|
-
*/
|
|
4
|
-
import { useSelect } from '@wordpress/data';
|
|
5
|
-
import { getBlockType, getBlockDefaultClassName } from '@wordpress/blocks';
|
|
6
|
-
|
|
7
|
-
/**
|
|
8
|
-
* Internal dependencies
|
|
9
|
-
*/
|
|
10
|
-
import { store as blockEditorStore } from '../../../store';
|
|
11
|
-
|
|
12
|
-
/**
|
|
13
|
-
* Returns the default class name if the block is a light block and it supports
|
|
14
|
-
* `className`.
|
|
15
|
-
*
|
|
16
|
-
* @param {string} clientId The block client ID.
|
|
17
|
-
*
|
|
18
|
-
* @return {string} The class name, e.g. `wp-block-paragraph`.
|
|
19
|
-
*/
|
|
20
|
-
export function useBlockDefaultClassName( clientId ) {
|
|
21
|
-
return useSelect(
|
|
22
|
-
( select ) => {
|
|
23
|
-
const name = select( blockEditorStore ).getBlockName( clientId );
|
|
24
|
-
const blockType = getBlockType( name );
|
|
25
|
-
const hasLightBlockWrapper = blockType?.apiVersion > 1;
|
|
26
|
-
|
|
27
|
-
if ( ! hasLightBlockWrapper ) {
|
|
28
|
-
return;
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
return getBlockDefaultClassName( name );
|
|
32
|
-
},
|
|
33
|
-
[ clientId ]
|
|
34
|
-
);
|
|
35
|
-
}
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
.block-editor-block-parent-selector {
|
|
2
|
-
background: $white;
|
|
3
|
-
border-radius: $radius-block-ui;
|
|
4
|
-
|
|
5
|
-
.block-editor-block-parent-selector__button {
|
|
6
|
-
width: $grid-unit-60;
|
|
7
|
-
height: $grid-unit-60;
|
|
8
|
-
border: $border-width solid $gray-900;
|
|
9
|
-
border-radius: $radius-block-ui;
|
|
10
|
-
}
|
|
11
|
-
}
|
|
@@ -1,35 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* WordPress dependencies
|
|
3
|
-
*/
|
|
4
|
-
import { useContext } from '@wordpress/element';
|
|
5
|
-
import { Disabled } from '@wordpress/components';
|
|
6
|
-
import deprecated from '@wordpress/deprecated';
|
|
7
|
-
|
|
8
|
-
/**
|
|
9
|
-
* Internal dependencies
|
|
10
|
-
*/
|
|
11
|
-
import InsertionPoint, { InsertionPointOpenRef } from './insertion-point';
|
|
12
|
-
import BlockPopover from './selected-block-tools';
|
|
13
|
-
|
|
14
|
-
export default function BlockToolsBackCompat( { children } ) {
|
|
15
|
-
const openRef = useContext( InsertionPointOpenRef );
|
|
16
|
-
const isDisabled = useContext( Disabled.Context );
|
|
17
|
-
|
|
18
|
-
// If context is set, `BlockTools` is a parent component.
|
|
19
|
-
if ( openRef || isDisabled ) {
|
|
20
|
-
return children;
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
deprecated( 'wp.components.Popover.Slot name="block-toolbar"', {
|
|
24
|
-
alternative: 'wp.blockEditor.BlockTools',
|
|
25
|
-
since: '5.8',
|
|
26
|
-
version: '6.3',
|
|
27
|
-
} );
|
|
28
|
-
|
|
29
|
-
return (
|
|
30
|
-
<InsertionPoint __unstablePopoverSlot="block-toolbar">
|
|
31
|
-
<BlockPopover __unstablePopoverSlot="block-toolbar" />
|
|
32
|
-
{ children }
|
|
33
|
-
</InsertionPoint>
|
|
34
|
-
);
|
|
35
|
-
}
|
|
@@ -1,100 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* External dependencies
|
|
3
|
-
*/
|
|
4
|
-
import classnames from 'classnames';
|
|
5
|
-
|
|
6
|
-
/**
|
|
7
|
-
* WordPress dependencies
|
|
8
|
-
*/
|
|
9
|
-
import { __ } from '@wordpress/i18n';
|
|
10
|
-
import { hasBlockSupport, store as blocksStore } from '@wordpress/blocks';
|
|
11
|
-
import { useSelect } from '@wordpress/data';
|
|
12
|
-
|
|
13
|
-
/**
|
|
14
|
-
* Internal dependencies
|
|
15
|
-
*/
|
|
16
|
-
import NavigableToolbar from '../navigable-toolbar';
|
|
17
|
-
import BlockToolbar from '../block-toolbar';
|
|
18
|
-
import { store as blockEditorStore } from '../../store';
|
|
19
|
-
import { useHasAnyBlockControls } from '../block-controls/use-has-block-controls';
|
|
20
|
-
|
|
21
|
-
export default function BlockContextualToolbar( {
|
|
22
|
-
focusOnMount,
|
|
23
|
-
isFixed,
|
|
24
|
-
...props
|
|
25
|
-
} ) {
|
|
26
|
-
const {
|
|
27
|
-
blockType,
|
|
28
|
-
blockEditingMode,
|
|
29
|
-
hasParents,
|
|
30
|
-
showParentSelector,
|
|
31
|
-
selectedBlockClientId,
|
|
32
|
-
} = useSelect( ( select ) => {
|
|
33
|
-
const {
|
|
34
|
-
getBlockName,
|
|
35
|
-
getBlockParents,
|
|
36
|
-
getSelectedBlockClientIds,
|
|
37
|
-
getBlockEditingMode,
|
|
38
|
-
} = select( blockEditorStore );
|
|
39
|
-
const { getBlockType } = select( blocksStore );
|
|
40
|
-
const selectedBlockClientIds = getSelectedBlockClientIds();
|
|
41
|
-
const _selectedBlockClientId = selectedBlockClientIds[ 0 ];
|
|
42
|
-
const parents = getBlockParents( _selectedBlockClientId );
|
|
43
|
-
const firstParentClientId = parents[ parents.length - 1 ];
|
|
44
|
-
const parentBlockName = getBlockName( firstParentClientId );
|
|
45
|
-
const parentBlockType = getBlockType( parentBlockName );
|
|
46
|
-
|
|
47
|
-
return {
|
|
48
|
-
selectedBlockClientId: _selectedBlockClientId,
|
|
49
|
-
blockType:
|
|
50
|
-
_selectedBlockClientId &&
|
|
51
|
-
getBlockType( getBlockName( _selectedBlockClientId ) ),
|
|
52
|
-
blockEditingMode: getBlockEditingMode( _selectedBlockClientId ),
|
|
53
|
-
hasParents: parents.length,
|
|
54
|
-
showParentSelector:
|
|
55
|
-
parentBlockType &&
|
|
56
|
-
getBlockEditingMode( firstParentClientId ) === 'default' &&
|
|
57
|
-
hasBlockSupport(
|
|
58
|
-
parentBlockType,
|
|
59
|
-
'__experimentalParentSelector',
|
|
60
|
-
true
|
|
61
|
-
) &&
|
|
62
|
-
selectedBlockClientIds.length <= 1 &&
|
|
63
|
-
getBlockEditingMode( _selectedBlockClientId ) === 'default',
|
|
64
|
-
};
|
|
65
|
-
}, [] );
|
|
66
|
-
|
|
67
|
-
const isToolbarEnabled =
|
|
68
|
-
blockType &&
|
|
69
|
-
hasBlockSupport( blockType, '__experimentalToolbar', true );
|
|
70
|
-
const hasAnyBlockControls = useHasAnyBlockControls();
|
|
71
|
-
if (
|
|
72
|
-
! isToolbarEnabled ||
|
|
73
|
-
( blockEditingMode !== 'default' && ! hasAnyBlockControls )
|
|
74
|
-
) {
|
|
75
|
-
return null;
|
|
76
|
-
}
|
|
77
|
-
|
|
78
|
-
// Shifts the toolbar to make room for the parent block selector.
|
|
79
|
-
const classes = classnames( 'block-editor-block-contextual-toolbar', {
|
|
80
|
-
'has-parent': hasParents && showParentSelector,
|
|
81
|
-
'is-fixed': isFixed,
|
|
82
|
-
} );
|
|
83
|
-
|
|
84
|
-
return (
|
|
85
|
-
<NavigableToolbar
|
|
86
|
-
focusOnMount={ focusOnMount }
|
|
87
|
-
focusEditorOnEscape
|
|
88
|
-
className={ classes }
|
|
89
|
-
/* translators: accessibility text for the block toolbar */
|
|
90
|
-
aria-label={ __( 'Block tools' ) }
|
|
91
|
-
variant={ isFixed ? 'unstyled' : undefined }
|
|
92
|
-
// Resets the index whenever the active block changes so
|
|
93
|
-
// this is not persisted. See https://github.com/WordPress/gutenberg/pull/25760#issuecomment-717906169
|
|
94
|
-
key={ selectedBlockClientId }
|
|
95
|
-
{ ...props }
|
|
96
|
-
>
|
|
97
|
-
<BlockToolbar hideDragHandle={ isFixed } />
|
|
98
|
-
</NavigableToolbar>
|
|
99
|
-
);
|
|
100
|
-
}
|
|
@@ -1,127 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* External dependencies
|
|
3
|
-
*/
|
|
4
|
-
import classnames from 'classnames';
|
|
5
|
-
|
|
6
|
-
/**
|
|
7
|
-
* WordPress dependencies
|
|
8
|
-
*/
|
|
9
|
-
import { useRef, useEffect } from '@wordpress/element';
|
|
10
|
-
import { useDispatch, useSelect } from '@wordpress/data';
|
|
11
|
-
import { useShortcut } from '@wordpress/keyboard-shortcuts';
|
|
12
|
-
|
|
13
|
-
/**
|
|
14
|
-
* Internal dependencies
|
|
15
|
-
*/
|
|
16
|
-
import BlockSelectionButton from './block-selection-button';
|
|
17
|
-
import BlockContextualToolbar from './block-contextual-toolbar';
|
|
18
|
-
import { store as blockEditorStore } from '../../store';
|
|
19
|
-
import BlockPopover from '../block-popover';
|
|
20
|
-
import useBlockToolbarPopoverProps from './use-block-toolbar-popover-props';
|
|
21
|
-
import useSelectedBlockToolProps from './use-selected-block-tool-props';
|
|
22
|
-
import { useShouldContextualToolbarShow } from '../../utils/use-should-contextual-toolbar-show';
|
|
23
|
-
|
|
24
|
-
export default function SelectedBlockTools( {
|
|
25
|
-
clientId,
|
|
26
|
-
showEmptyBlockSideInserter,
|
|
27
|
-
__unstableContentRef,
|
|
28
|
-
} ) {
|
|
29
|
-
const {
|
|
30
|
-
capturingClientId,
|
|
31
|
-
isInsertionPointVisible,
|
|
32
|
-
lastClientId,
|
|
33
|
-
rootClientId,
|
|
34
|
-
} = useSelectedBlockToolProps( clientId );
|
|
35
|
-
|
|
36
|
-
const { shouldShowBreadcrumb } = useSelect( ( select ) => {
|
|
37
|
-
const { hasMultiSelection, __unstableGetEditorMode } =
|
|
38
|
-
select( blockEditorStore );
|
|
39
|
-
|
|
40
|
-
const editorMode = __unstableGetEditorMode();
|
|
41
|
-
|
|
42
|
-
return {
|
|
43
|
-
shouldShowBreadcrumb:
|
|
44
|
-
! hasMultiSelection() &&
|
|
45
|
-
( editorMode === 'navigation' || editorMode === 'zoom-out' ),
|
|
46
|
-
};
|
|
47
|
-
}, [] );
|
|
48
|
-
|
|
49
|
-
const isToolbarForced = useRef( false );
|
|
50
|
-
const { shouldShowContextualToolbar, canFocusHiddenToolbar } =
|
|
51
|
-
useShouldContextualToolbarShow();
|
|
52
|
-
|
|
53
|
-
const { stopTyping } = useDispatch( blockEditorStore );
|
|
54
|
-
|
|
55
|
-
useShortcut(
|
|
56
|
-
'core/block-editor/focus-toolbar',
|
|
57
|
-
() => {
|
|
58
|
-
isToolbarForced.current = true;
|
|
59
|
-
stopTyping( true );
|
|
60
|
-
},
|
|
61
|
-
{
|
|
62
|
-
isDisabled: ! canFocusHiddenToolbar,
|
|
63
|
-
}
|
|
64
|
-
);
|
|
65
|
-
|
|
66
|
-
useEffect( () => {
|
|
67
|
-
isToolbarForced.current = false;
|
|
68
|
-
} );
|
|
69
|
-
|
|
70
|
-
// Stores the active toolbar item index so the block toolbar can return focus
|
|
71
|
-
// to it when re-mounting.
|
|
72
|
-
const initialToolbarItemIndexRef = useRef();
|
|
73
|
-
|
|
74
|
-
useEffect( () => {
|
|
75
|
-
// Resets the index whenever the active block changes so this is not
|
|
76
|
-
// persisted. See https://github.com/WordPress/gutenberg/pull/25760#issuecomment-717906169
|
|
77
|
-
initialToolbarItemIndexRef.current = undefined;
|
|
78
|
-
}, [ clientId ] );
|
|
79
|
-
|
|
80
|
-
const popoverProps = useBlockToolbarPopoverProps( {
|
|
81
|
-
contentElement: __unstableContentRef?.current,
|
|
82
|
-
clientId,
|
|
83
|
-
} );
|
|
84
|
-
|
|
85
|
-
if ( showEmptyBlockSideInserter ) {
|
|
86
|
-
return null;
|
|
87
|
-
}
|
|
88
|
-
|
|
89
|
-
if ( shouldShowBreadcrumb || shouldShowContextualToolbar ) {
|
|
90
|
-
return (
|
|
91
|
-
<BlockPopover
|
|
92
|
-
clientId={ capturingClientId || clientId }
|
|
93
|
-
bottomClientId={ lastClientId }
|
|
94
|
-
className={ classnames(
|
|
95
|
-
'block-editor-block-list__block-popover',
|
|
96
|
-
{
|
|
97
|
-
'is-insertion-point-visible': isInsertionPointVisible,
|
|
98
|
-
}
|
|
99
|
-
) }
|
|
100
|
-
resize={ false }
|
|
101
|
-
{ ...popoverProps }
|
|
102
|
-
>
|
|
103
|
-
{ shouldShowContextualToolbar && (
|
|
104
|
-
<BlockContextualToolbar
|
|
105
|
-
// If the toolbar is being shown because of being forced
|
|
106
|
-
// it should focus the toolbar right after the mount.
|
|
107
|
-
focusOnMount={ isToolbarForced.current }
|
|
108
|
-
__experimentalInitialIndex={
|
|
109
|
-
initialToolbarItemIndexRef.current
|
|
110
|
-
}
|
|
111
|
-
__experimentalOnIndexChange={ ( index ) => {
|
|
112
|
-
initialToolbarItemIndexRef.current = index;
|
|
113
|
-
} }
|
|
114
|
-
/>
|
|
115
|
-
) }
|
|
116
|
-
{ shouldShowBreadcrumb && (
|
|
117
|
-
<BlockSelectionButton
|
|
118
|
-
clientId={ clientId }
|
|
119
|
-
rootClientId={ rootClientId }
|
|
120
|
-
/>
|
|
121
|
-
) }
|
|
122
|
-
</BlockPopover>
|
|
123
|
-
);
|
|
124
|
-
}
|
|
125
|
-
|
|
126
|
-
return null;
|
|
127
|
-
}
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* WordPress dependencies
|
|
3
|
-
*/
|
|
4
|
-
import { useEffect, useState } from '@wordpress/element';
|
|
5
|
-
import { useDebounce } from '@wordpress/compose';
|
|
6
|
-
|
|
7
|
-
export default function useDebouncedInput( defaultValue = '' ) {
|
|
8
|
-
const [ input, setInput ] = useState( defaultValue );
|
|
9
|
-
const [ debouncedInput, setDebouncedState ] = useState( defaultValue );
|
|
10
|
-
|
|
11
|
-
const setDebouncedInput = useDebounce( setDebouncedState, 250 );
|
|
12
|
-
|
|
13
|
-
useEffect( () => {
|
|
14
|
-
setDebouncedInput( input );
|
|
15
|
-
}, [ input ] );
|
|
16
|
-
|
|
17
|
-
return [ input, setInput, debouncedInput ];
|
|
18
|
-
}
|