@wordpress/block-editor 15.23.0 → 16.0.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 +33 -0
- package/build/autocompleters/block.cjs +10 -2
- package/build/autocompleters/block.cjs.map +2 -2
- package/build/components/background-image-control/index.cjs +0 -2
- package/build/components/background-image-control/index.cjs.map +2 -2
- package/build/components/block-canvas/index.cjs +6 -1
- package/build/components/block-canvas/index.cjs.map +2 -2
- package/build/components/block-controls/groups.cjs +3 -1
- package/build/components/block-controls/groups.cjs.map +2 -2
- package/build/components/block-edit/edit.cjs +10 -18
- package/build/components/block-edit/edit.cjs.map +2 -2
- package/build/components/block-inspector/edit-contents.cjs +3 -0
- package/build/components/block-inspector/edit-contents.cjs.map +3 -3
- package/build/components/block-inspector/index.cjs +2 -3
- package/build/components/block-inspector/index.cjs.map +2 -2
- package/build/components/block-list/block-invalid-warning.cjs +8 -19
- package/build/components/block-list/block-invalid-warning.cjs.map +2 -2
- package/build/components/block-list/block.cjs +9 -3
- package/build/components/block-list/block.cjs.map +3 -3
- package/build/components/block-list/index.cjs +1 -3
- package/build/components/block-list/index.cjs.map +2 -2
- package/build/components/block-list/use-block-props/index.cjs +3 -1
- package/build/components/block-list/use-block-props/index.cjs.map +2 -2
- package/build/components/block-list/use-block-props/use-focus-first-element.cjs +9 -4
- package/build/components/block-list/use-block-props/use-focus-first-element.cjs.map +2 -2
- package/build/components/block-list/use-block-props/use-focus-handler.cjs +12 -4
- package/build/components/block-list/use-block-props/use-focus-handler.cjs.map +2 -2
- package/build/components/block-styles/use-styles-for-block.cjs +2 -1
- package/build/components/block-styles/use-styles-for-block.cjs.map +2 -2
- package/build/components/block-title/use-block-display-title.cjs +7 -2
- package/build/components/block-title/use-block-display-title.cjs.map +2 -2
- package/build/components/block-toolbar/block-toolbar-icon.cjs +10 -14
- package/build/components/block-toolbar/block-toolbar-icon.cjs.map +2 -2
- package/build/components/block-toolbar/index.cjs +43 -24
- package/build/components/block-toolbar/index.cjs.map +2 -2
- package/build/components/block-tools/index.cjs +7 -2
- package/build/components/block-tools/index.cjs.map +2 -2
- package/build/components/block-variation-transforms/index.cjs +0 -1
- package/build/components/block-variation-transforms/index.cjs.map +2 -2
- package/build/components/block-visibility/modal.cjs +20 -6
- package/build/components/block-visibility/modal.cjs.map +2 -2
- package/build/components/block-visibility/use-block-visibility.cjs +16 -6
- package/build/components/block-visibility/use-block-visibility.cjs.map +3 -3
- package/build/components/block-visibility/utils.cjs +15 -2
- package/build/components/block-visibility/utils.cjs.map +3 -3
- package/build/components/block-visibility/viewport-menu-item.cjs +7 -1
- package/build/components/block-visibility/viewport-menu-item.cjs.map +2 -2
- package/build/components/block-visibility/viewport-toolbar.cjs +5 -0
- package/build/components/block-visibility/viewport-toolbar.cjs.map +2 -2
- package/build/components/block-visibility/viewport-visibility-info.cjs +5 -1
- package/build/components/block-visibility/viewport-visibility-info.cjs.map +2 -2
- package/build/components/child-layout-control/index.cjs +0 -6
- package/build/components/child-layout-control/index.cjs.map +2 -2
- package/build/components/colors-gradients/control.cjs +5 -5
- package/build/components/colors-gradients/control.cjs.map +2 -2
- package/build/components/date-format-picker/index.cjs +0 -1
- package/build/components/date-format-picker/index.cjs.map +2 -2
- package/build/components/dimensions-tool/aspect-ratio-tool.cjs +1 -2
- package/build/components/dimensions-tool/aspect-ratio-tool.cjs.map +2 -2
- package/build/components/dimensions-tool/scale-tool.cjs +0 -1
- package/build/components/dimensions-tool/scale-tool.cjs.map +2 -2
- package/build/components/dimensions-tool/width-height-tool.cjs +2 -4
- package/build/components/dimensions-tool/width-height-tool.cjs.map +2 -2
- package/build/components/font-appearance-control/index.cjs +6 -25
- package/build/components/font-appearance-control/index.cjs.map +3 -3
- package/build/components/font-family/index.cjs +6 -15
- package/build/components/font-family/index.cjs.map +3 -3
- package/build/components/font-sizes/font-size-picker.cjs +1 -2
- package/build/components/font-sizes/font-size-picker.cjs.map +2 -2
- package/build/components/global-styles/border-panel.cjs +0 -1
- package/build/components/global-styles/border-panel.cjs.map +2 -2
- package/build/components/global-styles/dimensions-panel.cjs +0 -3
- package/build/components/global-styles/dimensions-panel.cjs.map +2 -2
- package/build/components/global-styles/state-control-badges.cjs +39 -3
- package/build/components/global-styles/state-control-badges.cjs.map +2 -2
- package/build/components/global-styles/typography-panel.cjs +4 -11
- package/build/components/global-styles/typography-panel.cjs.map +2 -2
- package/build/components/height-control/index.cjs +0 -2
- package/build/components/height-control/index.cjs.map +2 -2
- package/build/components/html-element-control/index.cjs +0 -1
- package/build/components/html-element-control/index.cjs.map +2 -2
- package/build/components/image-editor/index.cjs +5 -0
- package/build/components/image-editor/index.cjs.map +3 -3
- package/build/components/image-editor/zoom-dropdown.cjs +0 -1
- package/build/components/image-editor/zoom-dropdown.cjs.map +2 -2
- package/build/components/image-size-control/index.cjs +3 -7
- package/build/components/image-size-control/index.cjs.map +2 -2
- package/build/components/inner-content/index.cjs +107 -0
- package/build/components/inner-content/index.cjs.map +7 -0
- package/build/components/inserter/hooks/use-block-types-state.cjs +10 -2
- package/build/components/inserter/hooks/use-block-types-state.cjs.map +2 -2
- package/build/components/inserter/media-tab/hooks.cjs +67 -12
- package/build/components/inserter/media-tab/hooks.cjs.map +2 -2
- package/build/components/inserter/media-tab/media-list.cjs +3 -1
- package/build/components/inserter/media-tab/media-list.cjs.map +2 -2
- package/build/components/inserter/media-tab/media-panel.cjs +287 -28
- package/build/components/inserter/media-tab/media-panel.cjs.map +3 -3
- package/build/components/inserter/media-tab/media-preview.cjs +32 -17
- package/build/components/inserter/media-tab/media-preview.cjs.map +2 -2
- package/build/components/inserter/media-tab/media-tab.cjs +26 -6
- package/build/components/inserter/media-tab/media-tab.cjs.map +2 -2
- package/build/components/inserter/mobile-tab-navigation.cjs +6 -1
- package/build/components/inserter/mobile-tab-navigation.cjs.map +2 -2
- package/build/components/inserter/no-results.cjs +2 -2
- package/build/components/inserter/no-results.cjs.map +2 -2
- package/build/components/inserter/preview-panel.cjs +2 -1
- package/build/components/inserter/preview-panel.cjs.map +2 -2
- package/build/components/inserter-list-item/index.cjs +8 -2
- package/build/components/inserter-list-item/index.cjs.map +2 -2
- package/build/components/keyboard-shortcuts/index.cjs +19 -11
- package/build/components/keyboard-shortcuts/index.cjs.map +2 -2
- package/build/components/letter-spacing-control/index.cjs +0 -24
- package/build/components/letter-spacing-control/index.cjs.map +3 -3
- package/build/components/line-height-control/index.cjs +6 -22
- package/build/components/line-height-control/index.cjs.map +3 -3
- package/build/components/list-view/block-select-button.cjs +90 -84
- package/build/components/list-view/block-select-button.cjs.map +2 -2
- package/build/components/list-view/block.cjs +61 -21
- package/build/components/list-view/block.cjs.map +2 -2
- package/build/components/list-view/expander.cjs +1 -1
- package/build/components/list-view/expander.cjs.map +2 -2
- package/build/components/list-view/use-list-view-client-ids.cjs +2 -2
- package/build/components/list-view/use-list-view-client-ids.cjs.map +2 -2
- package/build/components/media-placeholder/index.cjs +0 -1
- package/build/components/media-placeholder/index.cjs.map +2 -2
- package/build/components/observe-typing/index.cjs +4 -3
- package/build/components/observe-typing/index.cjs.map +2 -2
- package/build/components/preset-input-control/custom-value-controls.cjs +1 -3
- package/build/components/preset-input-control/custom-value-controls.cjs.map +2 -2
- package/build/components/preset-input-control/index.cjs +1 -3
- package/build/components/preset-input-control/index.cjs.map +2 -2
- package/build/components/resolution-tool/index.cjs +1 -2
- package/build/components/resolution-tool/index.cjs.map +2 -2
- package/build/components/rich-text/event-listeners/before-input-rules.cjs +3 -4
- package/build/components/rich-text/event-listeners/before-input-rules.cjs.map +3 -3
- package/build/components/rich-text/event-listeners/delete.cjs +2 -3
- package/build/components/rich-text/event-listeners/delete.cjs.map +3 -3
- package/build/components/rich-text/event-listeners/enter.cjs +3 -2
- package/build/components/rich-text/event-listeners/enter.cjs.map +3 -3
- package/build/components/rich-text/event-listeners/input-events.cjs +3 -3
- package/build/components/rich-text/event-listeners/input-events.cjs.map +3 -3
- package/build/components/rich-text/event-listeners/input-rules.cjs +3 -4
- package/build/components/rich-text/event-listeners/input-rules.cjs.map +3 -3
- package/build/components/rich-text/event-listeners/insert-replacement-text.cjs +3 -3
- package/build/components/rich-text/event-listeners/insert-replacement-text.cjs.map +3 -3
- package/build/components/rich-text/event-listeners/paste-handler.cjs +2 -1
- package/build/components/rich-text/event-listeners/paste-handler.cjs.map +3 -3
- package/build/components/rich-text/event-listeners/remove-browser-shortcuts.cjs +3 -3
- package/build/components/rich-text/event-listeners/remove-browser-shortcuts.cjs.map +3 -3
- package/build/components/rich-text/event-listeners/shortcuts.cjs +3 -3
- package/build/components/rich-text/event-listeners/shortcuts.cjs.map +3 -3
- package/build/components/rich-text/event-listeners/undo-automatic-change.cjs +3 -3
- package/build/components/rich-text/event-listeners/undo-automatic-change.cjs.map +3 -3
- package/build/components/rich-text/index.cjs +66 -17
- package/build/components/rich-text/index.cjs.map +2 -2
- package/build/components/text-alignment-control/index.cjs +0 -1
- package/build/components/text-alignment-control/index.cjs.map +2 -2
- package/build/components/text-decoration-control/index.cjs +0 -1
- package/build/components/text-decoration-control/index.cjs.map +2 -2
- package/build/components/text-indent-control/index.cjs +0 -8
- package/build/components/text-indent-control/index.cjs.map +2 -2
- package/build/components/text-transform-control/index.cjs +0 -1
- package/build/components/text-transform-control/index.cjs.map +2 -2
- package/build/components/typewriter/index.cjs +129 -136
- package/build/components/typewriter/index.cjs.map +3 -3
- package/build/components/use-block-commands/index.cjs +21 -17
- package/build/components/use-block-commands/index.cjs.map +2 -2
- package/build/components/use-block-display-information/index.cjs +10 -8
- package/build/components/use-block-display-information/index.cjs.map +2 -2
- package/build/components/use-on-block-drop/index.cjs +3 -7
- package/build/components/use-on-block-drop/index.cjs.map +2 -2
- package/build/components/writing-flow/index.cjs +12 -1
- package/build/components/writing-flow/index.cjs.map +3 -3
- package/build/components/writing-flow/use-arrow-nav.cjs +18 -5
- package/build/components/writing-flow/use-arrow-nav.cjs.map +2 -2
- package/build/components/writing-flow/use-click-selection.cjs +2 -2
- package/build/components/writing-flow/use-click-selection.cjs.map +2 -2
- package/build/components/writing-flow/use-clipboard-handler.cjs +4 -1
- package/build/components/writing-flow/use-clipboard-handler.cjs.map +2 -2
- package/build/components/writing-flow/use-drag-selection.cjs +3 -8
- package/build/components/writing-flow/use-drag-selection.cjs.map +2 -2
- package/build/components/writing-flow/use-editable-root.cjs +112 -0
- package/build/components/writing-flow/use-editable-root.cjs.map +7 -0
- package/build/components/writing-flow/use-home-end.cjs +64 -0
- package/build/components/writing-flow/use-home-end.cjs.map +7 -0
- package/build/components/writing-flow/use-input.cjs +15 -5
- package/build/components/writing-flow/use-input.cjs.map +2 -2
- package/build/components/writing-flow/use-multi-selection.cjs +2 -2
- package/build/components/writing-flow/use-multi-selection.cjs.map +2 -2
- package/build/components/writing-flow/use-select-all.cjs +14 -2
- package/build/components/writing-flow/use-select-all.cjs.map +2 -2
- package/build/components/writing-flow/use-selection-observer.cjs +126 -20
- package/build/components/writing-flow/use-selection-observer.cjs.map +3 -3
- package/build/components/writing-flow/utils.cjs +39 -2
- package/build/components/writing-flow/utils.cjs.map +2 -2
- package/build/components/writing-mode-control/index.cjs +0 -1
- package/build/components/writing-mode-control/index.cjs.map +2 -2
- package/build/hooks/background.cjs +3 -2
- package/build/hooks/background.cjs.map +2 -2
- package/build/hooks/block-fields/rich-text/index.cjs +2 -3
- package/build/hooks/block-fields/rich-text/index.cjs.map +3 -3
- package/build/hooks/elements.cjs +1 -1
- package/build/hooks/elements.cjs.map +2 -2
- package/build/hooks/font-size.cjs +1 -2
- package/build/hooks/font-size.cjs.map +2 -2
- package/build/hooks/grid-visualizer.cjs +5 -3
- package/build/hooks/grid-visualizer.cjs.map +2 -2
- package/build/hooks/layout-child.cjs +22 -12
- package/build/hooks/layout-child.cjs.map +3 -3
- package/build/hooks/layout.cjs +33 -16
- package/build/hooks/layout.cjs.map +3 -3
- package/build/hooks/position.cjs +36 -16
- package/build/hooks/position.cjs.map +2 -2
- package/build/hooks/states.cjs +29 -12
- package/build/hooks/states.cjs.map +3 -3
- package/build/hooks/style.cjs +31 -9
- package/build/hooks/style.cjs.map +3 -3
- package/build/hooks/text-align.cjs +36 -6
- package/build/hooks/text-align.cjs.map +3 -3
- package/build/hooks/typography.cjs +1 -1
- package/build/hooks/typography.cjs.map +2 -2
- package/build/layouts/constrained.cjs +35 -27
- package/build/layouts/constrained.cjs.map +2 -2
- package/build/layouts/flex.cjs +27 -22
- package/build/layouts/flex.cjs.map +2 -2
- package/build/layouts/grid.cjs +51 -11
- package/build/layouts/grid.cjs.map +2 -2
- package/build/private-apis.cjs +4 -1
- package/build/private-apis.cjs.map +3 -3
- package/build/store/actions.cjs +2 -2
- package/build/store/actions.cjs.map +2 -2
- package/build/store/private-keys.cjs +3 -0
- package/build/store/private-keys.cjs.map +2 -2
- package/build/store/private-selectors.cjs +85 -6
- package/build/store/private-selectors.cjs.map +3 -3
- package/build/store/selectors.cjs +13 -0
- package/build/store/selectors.cjs.map +2 -2
- package/build/utils/block-bindings.cjs +29 -0
- package/build/utils/block-bindings.cjs.map +2 -2
- package/build/utils/dom.cjs +14 -0
- package/build/utils/dom.cjs.map +2 -2
- package/build-module/autocompleters/block.mjs +10 -2
- package/build-module/autocompleters/block.mjs.map +2 -2
- package/build-module/components/background-image-control/index.mjs +0 -2
- package/build-module/components/background-image-control/index.mjs.map +2 -2
- package/build-module/components/block-canvas/index.mjs +7 -2
- package/build-module/components/block-canvas/index.mjs.map +2 -2
- package/build-module/components/block-controls/groups.mjs +3 -1
- package/build-module/components/block-controls/groups.mjs.map +2 -2
- package/build-module/components/block-edit/edit.mjs +11 -18
- package/build-module/components/block-edit/edit.mjs.map +2 -2
- package/build-module/components/block-inspector/edit-contents.mjs +4 -1
- package/build-module/components/block-inspector/edit-contents.mjs.map +2 -2
- package/build-module/components/block-inspector/index.mjs +2 -3
- package/build-module/components/block-inspector/index.mjs.map +2 -2
- package/build-module/components/block-list/block-invalid-warning.mjs +8 -19
- package/build-module/components/block-list/block-invalid-warning.mjs.map +2 -2
- package/build-module/components/block-list/block.mjs +9 -3
- package/build-module/components/block-list/block.mjs.map +3 -3
- package/build-module/components/block-list/index.mjs +1 -3
- package/build-module/components/block-list/index.mjs.map +2 -2
- package/build-module/components/block-list/use-block-props/index.mjs +3 -1
- package/build-module/components/block-list/use-block-props/index.mjs.map +2 -2
- package/build-module/components/block-list/use-block-props/use-focus-first-element.mjs +9 -4
- package/build-module/components/block-list/use-block-props/use-focus-first-element.mjs.map +2 -2
- package/build-module/components/block-list/use-block-props/use-focus-handler.mjs +12 -4
- package/build-module/components/block-list/use-block-props/use-focus-handler.mjs.map +2 -2
- package/build-module/components/block-styles/use-styles-for-block.mjs +2 -1
- package/build-module/components/block-styles/use-styles-for-block.mjs.map +2 -2
- package/build-module/components/block-title/use-block-display-title.mjs +7 -2
- package/build-module/components/block-title/use-block-display-title.mjs.map +2 -2
- package/build-module/components/block-toolbar/block-toolbar-icon.mjs +10 -14
- package/build-module/components/block-toolbar/block-toolbar-icon.mjs.map +2 -2
- package/build-module/components/block-toolbar/index.mjs +43 -24
- package/build-module/components/block-toolbar/index.mjs.map +2 -2
- package/build-module/components/block-tools/index.mjs +7 -2
- package/build-module/components/block-tools/index.mjs.map +2 -2
- package/build-module/components/block-variation-transforms/index.mjs +0 -1
- package/build-module/components/block-variation-transforms/index.mjs.map +2 -2
- package/build-module/components/block-visibility/modal.mjs +22 -10
- package/build-module/components/block-visibility/modal.mjs.map +2 -2
- package/build-module/components/block-visibility/use-block-visibility.mjs +17 -7
- package/build-module/components/block-visibility/use-block-visibility.mjs.map +2 -2
- package/build-module/components/block-visibility/utils.mjs +18 -3
- package/build-module/components/block-visibility/utils.mjs.map +2 -2
- package/build-module/components/block-visibility/viewport-menu-item.mjs +7 -1
- package/build-module/components/block-visibility/viewport-menu-item.mjs.map +2 -2
- package/build-module/components/block-visibility/viewport-toolbar.mjs +5 -0
- package/build-module/components/block-visibility/viewport-toolbar.mjs.map +2 -2
- package/build-module/components/block-visibility/viewport-visibility-info.mjs +5 -1
- package/build-module/components/block-visibility/viewport-visibility-info.mjs.map +2 -2
- package/build-module/components/child-layout-control/index.mjs +0 -6
- package/build-module/components/child-layout-control/index.mjs.map +2 -2
- package/build-module/components/colors-gradients/control.mjs +5 -5
- package/build-module/components/colors-gradients/control.mjs.map +2 -2
- package/build-module/components/date-format-picker/index.mjs +0 -1
- package/build-module/components/date-format-picker/index.mjs.map +2 -2
- package/build-module/components/dimensions-tool/aspect-ratio-tool.mjs +1 -2
- package/build-module/components/dimensions-tool/aspect-ratio-tool.mjs.map +2 -2
- package/build-module/components/dimensions-tool/scale-tool.mjs +0 -1
- package/build-module/components/dimensions-tool/scale-tool.mjs.map +2 -2
- package/build-module/components/dimensions-tool/width-height-tool.mjs +2 -4
- package/build-module/components/dimensions-tool/width-height-tool.mjs.map +2 -2
- package/build-module/components/font-appearance-control/index.mjs +6 -15
- package/build-module/components/font-appearance-control/index.mjs.map +2 -2
- package/build-module/components/font-family/index.mjs +6 -15
- package/build-module/components/font-family/index.mjs.map +2 -2
- package/build-module/components/font-sizes/font-size-picker.mjs +1 -2
- package/build-module/components/font-sizes/font-size-picker.mjs.map +2 -2
- package/build-module/components/global-styles/border-panel.mjs +0 -1
- package/build-module/components/global-styles/border-panel.mjs.map +2 -2
- package/build-module/components/global-styles/dimensions-panel.mjs +0 -3
- package/build-module/components/global-styles/dimensions-panel.mjs.map +2 -2
- package/build-module/components/global-styles/state-control-badges.mjs +41 -5
- package/build-module/components/global-styles/state-control-badges.mjs.map +2 -2
- package/build-module/components/global-styles/typography-panel.mjs +4 -11
- package/build-module/components/global-styles/typography-panel.mjs.map +2 -2
- package/build-module/components/height-control/index.mjs +0 -2
- package/build-module/components/height-control/index.mjs.map +2 -2
- package/build-module/components/html-element-control/index.mjs +0 -1
- package/build-module/components/html-element-control/index.mjs.map +2 -2
- package/build-module/components/image-editor/index.mjs +5 -0
- package/build-module/components/image-editor/index.mjs.map +2 -2
- package/build-module/components/image-editor/zoom-dropdown.mjs +0 -1
- package/build-module/components/image-editor/zoom-dropdown.mjs.map +2 -2
- package/build-module/components/image-size-control/index.mjs +3 -7
- package/build-module/components/image-size-control/index.mjs.map +2 -2
- package/build-module/components/inner-content/index.mjs +82 -0
- package/build-module/components/inner-content/index.mjs.map +7 -0
- package/build-module/components/inserter/hooks/use-block-types-state.mjs +10 -2
- package/build-module/components/inserter/hooks/use-block-types-state.mjs.map +2 -2
- package/build-module/components/inserter/media-tab/hooks.mjs +66 -12
- package/build-module/components/inserter/media-tab/hooks.mjs.map +2 -2
- package/build-module/components/inserter/media-tab/media-list.mjs +3 -1
- package/build-module/components/inserter/media-tab/media-list.mjs.map +2 -2
- package/build-module/components/inserter/media-tab/media-panel.mjs +297 -32
- package/build-module/components/inserter/media-tab/media-panel.mjs.map +2 -2
- package/build-module/components/inserter/media-tab/media-preview.mjs +33 -18
- package/build-module/components/inserter/media-tab/media-preview.mjs.map +2 -2
- package/build-module/components/inserter/media-tab/media-tab.mjs +27 -7
- package/build-module/components/inserter/media-tab/media-tab.mjs.map +2 -2
- package/build-module/components/inserter/mobile-tab-navigation.mjs +6 -1
- package/build-module/components/inserter/mobile-tab-navigation.mjs.map +2 -2
- package/build-module/components/inserter/no-results.mjs +2 -2
- package/build-module/components/inserter/no-results.mjs.map +2 -2
- package/build-module/components/inserter/preview-panel.mjs +2 -1
- package/build-module/components/inserter/preview-panel.mjs.map +2 -2
- package/build-module/components/inserter-list-item/index.mjs +8 -2
- package/build-module/components/inserter-list-item/index.mjs.map +2 -2
- package/build-module/components/keyboard-shortcuts/index.mjs +19 -11
- package/build-module/components/keyboard-shortcuts/index.mjs.map +2 -2
- package/build-module/components/letter-spacing-control/index.mjs +0 -14
- package/build-module/components/letter-spacing-control/index.mjs.map +2 -2
- package/build-module/components/line-height-control/index.mjs +6 -12
- package/build-module/components/line-height-control/index.mjs.map +2 -2
- package/build-module/components/list-view/block-select-button.mjs +90 -84
- package/build-module/components/list-view/block-select-button.mjs.map +2 -2
- package/build-module/components/list-view/block.mjs +61 -21
- package/build-module/components/list-view/block.mjs.map +2 -2
- package/build-module/components/list-view/expander.mjs +1 -1
- package/build-module/components/list-view/expander.mjs.map +2 -2
- package/build-module/components/list-view/use-list-view-client-ids.mjs +2 -2
- package/build-module/components/list-view/use-list-view-client-ids.mjs.map +2 -2
- package/build-module/components/media-placeholder/index.mjs +0 -1
- package/build-module/components/media-placeholder/index.mjs.map +2 -2
- package/build-module/components/observe-typing/index.mjs +4 -3
- package/build-module/components/observe-typing/index.mjs.map +2 -2
- package/build-module/components/preset-input-control/custom-value-controls.mjs +1 -3
- package/build-module/components/preset-input-control/custom-value-controls.mjs.map +2 -2
- package/build-module/components/preset-input-control/index.mjs +1 -3
- package/build-module/components/preset-input-control/index.mjs.map +2 -2
- package/build-module/components/resolution-tool/index.mjs +1 -2
- package/build-module/components/resolution-tool/index.mjs.map +2 -2
- package/build-module/components/rich-text/event-listeners/before-input-rules.mjs +8 -5
- package/build-module/components/rich-text/event-listeners/before-input-rules.mjs.map +2 -2
- package/build-module/components/rich-text/event-listeners/delete.mjs +7 -4
- package/build-module/components/rich-text/event-listeners/delete.mjs.map +2 -2
- package/build-module/components/rich-text/event-listeners/enter.mjs +8 -3
- package/build-module/components/rich-text/event-listeners/enter.mjs.map +2 -2
- package/build-module/components/rich-text/event-listeners/input-events.mjs +3 -3
- package/build-module/components/rich-text/event-listeners/input-events.mjs.map +2 -2
- package/build-module/components/rich-text/event-listeners/input-rules.mjs +8 -5
- package/build-module/components/rich-text/event-listeners/input-rules.mjs.map +2 -2
- package/build-module/components/rich-text/event-listeners/insert-replacement-text.mjs +3 -3
- package/build-module/components/rich-text/event-listeners/insert-replacement-text.mjs.map +2 -2
- package/build-module/components/rich-text/event-listeners/paste-handler.mjs +8 -2
- package/build-module/components/rich-text/event-listeners/paste-handler.mjs.map +2 -2
- package/build-module/components/rich-text/event-listeners/remove-browser-shortcuts.mjs +3 -3
- package/build-module/components/rich-text/event-listeners/remove-browser-shortcuts.mjs.map +2 -2
- package/build-module/components/rich-text/event-listeners/shortcuts.mjs +3 -3
- package/build-module/components/rich-text/event-listeners/shortcuts.mjs.map +2 -2
- package/build-module/components/rich-text/event-listeners/undo-automatic-change.mjs +3 -3
- package/build-module/components/rich-text/event-listeners/undo-automatic-change.mjs.map +2 -2
- package/build-module/components/rich-text/index.mjs +64 -13
- package/build-module/components/rich-text/index.mjs.map +2 -2
- package/build-module/components/text-alignment-control/index.mjs +0 -1
- package/build-module/components/text-alignment-control/index.mjs.map +2 -2
- package/build-module/components/text-decoration-control/index.mjs +0 -1
- package/build-module/components/text-decoration-control/index.mjs.map +2 -2
- package/build-module/components/text-indent-control/index.mjs +0 -8
- package/build-module/components/text-indent-control/index.mjs.map +2 -2
- package/build-module/components/text-transform-control/index.mjs +0 -1
- package/build-module/components/text-transform-control/index.mjs.map +2 -2
- package/build-module/components/typewriter/index.mjs +129 -136
- package/build-module/components/typewriter/index.mjs.map +2 -2
- package/build-module/components/use-block-commands/index.mjs +21 -17
- package/build-module/components/use-block-commands/index.mjs.map +2 -2
- package/build-module/components/use-block-display-information/index.mjs +10 -8
- package/build-module/components/use-block-display-information/index.mjs.map +2 -2
- package/build-module/components/use-on-block-drop/index.mjs +4 -7
- package/build-module/components/use-on-block-drop/index.mjs.map +2 -2
- package/build-module/components/writing-flow/index.mjs +12 -1
- package/build-module/components/writing-flow/index.mjs.map +2 -2
- package/build-module/components/writing-flow/use-arrow-nav.mjs +19 -6
- package/build-module/components/writing-flow/use-arrow-nav.mjs.map +2 -2
- package/build-module/components/writing-flow/use-click-selection.mjs +2 -2
- package/build-module/components/writing-flow/use-click-selection.mjs.map +2 -2
- package/build-module/components/writing-flow/use-clipboard-handler.mjs +5 -2
- package/build-module/components/writing-flow/use-clipboard-handler.mjs.map +2 -2
- package/build-module/components/writing-flow/use-drag-selection.mjs +1 -6
- package/build-module/components/writing-flow/use-drag-selection.mjs.map +2 -2
- package/build-module/components/writing-flow/use-editable-root.mjs +86 -0
- package/build-module/components/writing-flow/use-editable-root.mjs.map +7 -0
- package/build-module/components/writing-flow/use-home-end.mjs +43 -0
- package/build-module/components/writing-flow/use-home-end.mjs.map +7 -0
- package/build-module/components/writing-flow/use-input.mjs +15 -5
- package/build-module/components/writing-flow/use-input.mjs.map +2 -2
- package/build-module/components/writing-flow/use-multi-selection.mjs +2 -2
- package/build-module/components/writing-flow/use-multi-selection.mjs.map +2 -2
- package/build-module/components/writing-flow/use-select-all.mjs +19 -3
- package/build-module/components/writing-flow/use-select-all.mjs.map +2 -2
- package/build-module/components/writing-flow/use-selection-observer.mjs +128 -19
- package/build-module/components/writing-flow/use-selection-observer.mjs.map +2 -2
- package/build-module/components/writing-flow/utils.mjs +35 -1
- package/build-module/components/writing-flow/utils.mjs.map +2 -2
- package/build-module/components/writing-mode-control/index.mjs +0 -1
- package/build-module/components/writing-mode-control/index.mjs.map +2 -2
- package/build-module/hooks/background.mjs +3 -2
- package/build-module/hooks/background.mjs.map +2 -2
- package/build-module/hooks/block-fields/rich-text/index.mjs +2 -6
- package/build-module/hooks/block-fields/rich-text/index.mjs.map +2 -2
- package/build-module/hooks/elements.mjs +1 -1
- package/build-module/hooks/elements.mjs.map +2 -2
- package/build-module/hooks/font-size.mjs +1 -2
- package/build-module/hooks/font-size.mjs.map +2 -2
- package/build-module/hooks/grid-visualizer.mjs +5 -3
- package/build-module/hooks/grid-visualizer.mjs.map +2 -2
- package/build-module/hooks/layout-child.mjs +22 -12
- package/build-module/hooks/layout-child.mjs.map +2 -2
- package/build-module/hooks/layout.mjs +32 -16
- package/build-module/hooks/layout.mjs.map +2 -2
- package/build-module/hooks/position.mjs +38 -18
- package/build-module/hooks/position.mjs.map +2 -2
- package/build-module/hooks/states.mjs +29 -12
- package/build-module/hooks/states.mjs.map +2 -2
- package/build-module/hooks/style.mjs +40 -11
- package/build-module/hooks/style.mjs.map +2 -2
- package/build-module/hooks/text-align.mjs +39 -10
- package/build-module/hooks/text-align.mjs.map +2 -2
- package/build-module/hooks/typography.mjs +1 -1
- package/build-module/hooks/typography.mjs.map +2 -2
- package/build-module/layouts/constrained.mjs +35 -27
- package/build-module/layouts/constrained.mjs.map +2 -2
- package/build-module/layouts/flex.mjs +27 -22
- package/build-module/layouts/flex.mjs.map +2 -2
- package/build-module/layouts/grid.mjs +52 -11
- package/build-module/layouts/grid.mjs.map +2 -2
- package/build-module/private-apis.mjs +5 -1
- package/build-module/private-apis.mjs.map +2 -2
- package/build-module/store/actions.mjs +3 -3
- package/build-module/store/actions.mjs.map +2 -2
- package/build-module/store/private-keys.mjs +2 -0
- package/build-module/store/private-keys.mjs.map +2 -2
- package/build-module/store/private-selectors.mjs +84 -6
- package/build-module/store/private-selectors.mjs.map +2 -2
- package/build-module/store/selectors.mjs +13 -0
- package/build-module/store/selectors.mjs.map +2 -2
- package/build-module/utils/block-bindings.mjs +28 -0
- package/build-module/utils/block-bindings.mjs.map +2 -2
- package/build-module/utils/dom.mjs +13 -0
- package/build-module/utils/dom.mjs.map +2 -2
- package/build-style/content-rtl.css +15 -14
- package/build-style/content.css +15 -14
- package/build-style/default-editor-styles-rtl.css +1 -1
- package/build-style/default-editor-styles.css +1 -1
- package/build-style/style-rtl.css +144 -47
- package/build-style/style.css +144 -47
- package/build-types/components/block-context/index.d.ts +7 -0
- package/build-types/components/block-context/index.d.ts.map +1 -1
- package/build-types/utils/block-bindings.d.ts +19 -0
- package/build-types/utils/block-bindings.d.ts.map +1 -1
- package/build-types/utils/dom.d.ts +11 -0
- package/build-types/utils/dom.d.ts.map +1 -1
- package/build-types/utils/get-px-from-css-unit.d.ts +2 -2
- package/build-types/utils/get-px-from-css-unit.d.ts.map +1 -1
- package/build-types/utils/pasting.d.ts +1 -1
- package/build-types/utils/pasting.d.ts.map +1 -1
- package/package.json +46 -44
- package/src/autocompleters/block.js +10 -3
- package/src/autocompleters/test/block.js +53 -0
- package/src/components/background-image-control/index.js +0 -2
- package/src/components/block-canvas/index.js +9 -2
- package/src/components/block-card/style.scss +1 -1
- package/src/components/block-controls/groups.js +2 -0
- package/src/components/block-edit/edit.js +13 -31
- package/src/components/block-inspector/edit-contents.js +5 -1
- package/src/components/block-inspector/index.js +3 -2
- package/src/components/block-list/block-invalid-warning.js +8 -19
- package/src/components/block-list/block.js +6 -0
- package/src/components/block-list/index.js +0 -2
- package/src/components/block-list/use-block-props/index.js +2 -0
- package/src/components/block-list/use-block-props/use-focus-first-element.js +23 -4
- package/src/components/block-list/use-block-props/use-focus-handler.js +34 -9
- package/src/components/block-lock/style.scss +1 -1
- package/src/components/block-manager/style.scss +1 -1
- package/src/components/block-navigation/style.scss +1 -1
- package/src/components/block-patterns-list/stories/index.story.jsx +1 -1
- package/src/components/block-quick-navigation/style.scss +1 -3
- package/src/components/block-styles/style.scss +2 -2
- package/src/components/block-styles/use-styles-for-block.js +1 -0
- package/src/components/block-title/use-block-display-title.js +7 -2
- package/src/components/block-toolbar/block-toolbar-icon.js +11 -16
- package/src/components/block-toolbar/index.js +41 -18
- package/src/components/block-toolbar/test/block-toolbar-icon.js +32 -9
- package/src/components/block-tools/index.js +7 -0
- package/src/components/block-types-list/style.scss +0 -1
- package/src/components/block-variation-transforms/index.js +0 -1
- package/src/components/block-visibility/modal.js +24 -10
- package/src/components/block-visibility/style.scss +1 -1
- package/src/components/block-visibility/test/use-block-visibility.js +128 -35
- package/src/components/block-visibility/test/utils.js +11 -0
- package/src/components/block-visibility/use-block-visibility.js +33 -11
- package/src/components/block-visibility/utils.js +31 -6
- package/src/components/block-visibility/viewport-menu-item.js +10 -1
- package/src/components/block-visibility/viewport-toolbar.js +6 -0
- package/src/components/block-visibility/viewport-visibility-info.js +5 -1
- package/src/components/button-block-appender/content.scss +1 -7
- package/src/components/child-layout-control/index.js +0 -6
- package/src/components/color-palette/test/__snapshots__/control.js.snap +13 -108
- package/src/components/colors-gradients/control.js +4 -4
- package/src/components/colors-gradients/style.scss +2 -2
- package/src/components/date-format-picker/index.js +0 -1
- package/src/components/dimensions-tool/aspect-ratio-tool.js +0 -1
- package/src/components/dimensions-tool/scale-tool.js +0 -1
- package/src/components/dimensions-tool/width-height-tool.js +0 -2
- package/src/components/font-appearance-control/index.js +6 -19
- package/src/components/font-family/README.md +0 -9
- package/src/components/font-family/index.js +6 -19
- package/src/components/font-family/stories/index.story.jsx +1 -2
- package/src/components/font-sizes/font-size-picker.js +0 -1
- package/src/components/global-styles/border-panel.js +0 -1
- package/src/components/global-styles/dimensions-panel.js +0 -3
- package/src/components/global-styles/state-control-badges.js +45 -6
- package/src/components/global-styles/style.scss +5 -0
- package/src/components/global-styles/test/state-control-badges.js +65 -0
- package/src/components/global-styles/typography-panel.js +0 -7
- package/src/components/height-control/index.js +0 -2
- package/src/components/html-element-control/index.js +0 -1
- package/src/components/iframe/content.scss +3 -3
- package/src/components/image-editor/index.js +22 -0
- package/src/components/image-editor/zoom-dropdown.js +0 -1
- package/src/components/image-size-control/index.js +0 -4
- package/src/components/inner-content/index.js +119 -0
- package/src/components/inner-content/test/index.js +81 -0
- package/src/components/inserter/hooks/use-block-types-state.js +10 -2
- package/src/components/inserter/media-tab/hooks.js +114 -16
- package/src/components/inserter/media-tab/media-list.js +2 -0
- package/src/components/inserter/media-tab/media-panel.js +354 -19
- package/src/components/inserter/media-tab/media-preview.js +34 -17
- package/src/components/inserter/media-tab/media-tab.js +20 -2
- package/src/components/inserter/media-tab/test/hooks.js +267 -0
- package/src/components/inserter/media-tab/test/media-panel.js +127 -0
- package/src/components/inserter/mobile-tab-navigation.js +6 -1
- package/src/components/inserter/no-results.js +2 -2
- package/src/components/inserter/preview-panel.js +1 -0
- package/src/components/inserter/style.scss +115 -3
- package/src/components/inserter-list-item/index.js +8 -2
- package/src/components/inserter-list-item/style.scss +0 -15
- package/src/components/keyboard-shortcuts/index.js +28 -11
- package/src/components/letter-spacing-control/README.md +0 -8
- package/src/components/letter-spacing-control/index.js +5 -23
- package/src/components/letter-spacing-control/stories/index.story.jsx +0 -12
- package/src/components/line-height-control/README.md +0 -8
- package/src/components/line-height-control/index.js +6 -16
- package/src/components/line-height-control/stories/index.story.jsx +0 -1
- package/src/components/line-height-control/test/index.js +1 -7
- package/src/components/link-control/style.scss +2 -2
- package/src/components/link-control/test/index.js +6 -6
- package/src/components/link-picker/style.scss +1 -2
- package/src/components/link-picker/test/index.js +3 -1
- package/src/components/list-view/block-select-button.js +5 -1
- package/src/components/list-view/block.js +69 -23
- package/src/components/list-view/expander.js +5 -1
- package/src/components/list-view/style.scss +23 -5
- package/src/components/list-view/use-list-view-client-ids.js +2 -2
- package/src/components/media-placeholder/index.js +0 -1
- package/src/components/multi-selection-inspector/style.scss +1 -1
- package/src/components/observe-typing/index.js +9 -4
- package/src/components/preset-input-control/custom-value-controls.js +0 -2
- package/src/components/preset-input-control/index.js +0 -2
- package/src/components/resolution-tool/index.js +0 -1
- package/src/components/responsive-block-control/style.scss +1 -1
- package/src/components/responsive-block-control/test/index.js +1 -5
- package/src/components/rich-text/event-listeners/before-input-rules.js +8 -5
- package/src/components/rich-text/event-listeners/delete.js +7 -4
- package/src/components/rich-text/event-listeners/enter.js +10 -4
- package/src/components/rich-text/event-listeners/input-events.js +4 -3
- package/src/components/rich-text/event-listeners/input-rules.js +8 -5
- package/src/components/rich-text/event-listeners/insert-replacement-text.js +4 -3
- package/src/components/rich-text/event-listeners/paste-handler.js +15 -3
- package/src/components/rich-text/event-listeners/remove-browser-shortcuts.js +4 -3
- package/src/components/rich-text/event-listeners/shortcuts.js +4 -3
- package/src/components/rich-text/event-listeners/undo-automatic-change.js +4 -3
- package/src/components/rich-text/index.js +94 -25
- package/src/components/skip-to-selected-block/style.scss +1 -1
- package/src/components/text-alignment-control/index.js +0 -1
- package/src/components/text-decoration-control/index.js +0 -1
- package/src/components/text-indent-control/index.js +7 -16
- package/src/components/text-transform-control/index.js +0 -1
- package/src/components/typewriter/index.js +228 -224
- package/src/components/use-block-commands/index.js +27 -17
- package/src/components/use-block-display-information/index.js +9 -13
- package/src/components/use-block-display-information/test/index.js +47 -9
- package/src/components/use-on-block-drop/index.js +4 -7
- package/src/components/writing-flow/index.js +15 -1
- package/src/components/writing-flow/use-arrow-nav.js +39 -12
- package/src/components/writing-flow/use-click-selection.js +2 -3
- package/src/components/writing-flow/use-clipboard-handler.js +5 -2
- package/src/components/writing-flow/use-drag-selection.js +1 -14
- package/src/components/writing-flow/use-editable-root.js +182 -0
- package/src/components/writing-flow/use-home-end.js +63 -0
- package/src/components/writing-flow/use-input.js +25 -8
- package/src/components/writing-flow/use-multi-selection.js +2 -3
- package/src/components/writing-flow/use-select-all.js +33 -3
- package/src/components/writing-flow/use-selection-observer.js +197 -38
- package/src/components/writing-flow/utils.js +83 -0
- package/src/components/writing-mode-control/index.js +0 -1
- package/src/hooks/background.js +7 -9
- package/src/hooks/block-fields/link/styles.scss +1 -6
- package/src/hooks/block-fields/media/styles.scss +1 -6
- package/src/hooks/block-fields/rich-text/index.js +6 -9
- package/src/hooks/block-hooks.scss +15 -0
- package/src/hooks/elements.js +0 -1
- package/src/hooks/font-size.js +0 -1
- package/src/hooks/grid-visualizer.js +40 -36
- package/src/hooks/layout-child.js +19 -9
- package/src/hooks/layout.js +53 -35
- package/src/hooks/position.js +44 -23
- package/src/hooks/states.js +36 -13
- package/src/hooks/style.js +67 -17
- package/src/hooks/test/cross-origin-isolation.js +0 -4
- package/src/hooks/test/layout.js +75 -1
- package/src/hooks/test/style.js +29 -0
- package/src/hooks/test/text-align.js +34 -1
- package/src/hooks/text-align.js +41 -10
- package/src/hooks/typography.js +0 -1
- package/src/layouts/constrained.js +56 -29
- package/src/layouts/flex.js +5 -4
- package/src/layouts/grid.js +59 -9
- package/src/layouts/test/constrained.js +91 -0
- package/src/layouts/test/grid.js +71 -0
- package/src/private-apis.js +4 -0
- package/src/store/actions.js +43 -14
- package/src/store/private-keys.js +1 -0
- package/src/store/private-selectors.js +166 -9
- package/src/store/selectors.js +41 -0
- package/src/store/test/actions.js +1 -1
- package/src/store/test/private-selectors.js +533 -0
- package/src/store/test/reducer.js +11 -11
- package/src/store/test/selectors.js +133 -0
- package/src/style.scss +1 -0
- package/src/utils/block-bindings.ts +50 -0
- package/src/utils/dom.ts +33 -0
- package/src/utils/test/block-bindings.js +181 -0
- package/build/components/rich-text/input-event.cjs +0 -50
- package/build/components/rich-text/input-event.cjs.map +0 -7
- package/build/components/rich-text/shortcut.cjs +0 -51
- package/build/components/rich-text/shortcut.cjs.map +0 -7
- package/build-module/components/rich-text/input-event.mjs +0 -25
- package/build-module/components/rich-text/input-event.mjs.map +0 -7
- package/build-module/components/rich-text/shortcut.mjs +0 -26
- package/build-module/components/rich-text/shortcut.mjs.map +0 -7
- package/src/components/rich-text/input-event.js +0 -31
- package/src/components/rich-text/shortcut.js +0 -32
|
@@ -26,158 +26,151 @@ __export(typewriter_exports, {
|
|
|
26
26
|
module.exports = __toCommonJS(typewriter_exports);
|
|
27
27
|
var import_compose = require("@wordpress/compose");
|
|
28
28
|
var import_dom = require("@wordpress/dom");
|
|
29
|
-
var import_data = require("@wordpress/data");
|
|
30
29
|
var import_keycodes = require("@wordpress/keycodes");
|
|
31
|
-
var import_store = require("../../store/index.cjs");
|
|
32
30
|
var import_jsx_runtime = require("react/jsx-runtime");
|
|
33
31
|
var isIE = window.navigator.userAgent.indexOf("Trident") !== -1;
|
|
34
32
|
var arrowKeyCodes = /* @__PURE__ */ new Set([import_keycodes.UP, import_keycodes.DOWN, import_keycodes.LEFT, import_keycodes.RIGHT]);
|
|
35
33
|
var initialTriggerPercentage = 0.75;
|
|
36
34
|
function useTypewriter() {
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
35
|
+
return (0, import_compose.useRefEffect)((node) => {
|
|
36
|
+
const { ownerDocument } = node;
|
|
37
|
+
const { defaultView } = ownerDocument;
|
|
38
|
+
let scrollResizeRafId;
|
|
39
|
+
let onKeyDownRafId;
|
|
40
|
+
let caretRect;
|
|
41
|
+
function onScrollResize() {
|
|
42
|
+
if (scrollResizeRafId) {
|
|
44
43
|
return;
|
|
45
44
|
}
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
}
|
|
55
|
-
scrollResizeRafId = defaultView.requestAnimationFrame(() => {
|
|
56
|
-
computeCaretRectangle();
|
|
57
|
-
scrollResizeRafId = null;
|
|
58
|
-
});
|
|
45
|
+
scrollResizeRafId = defaultView.requestAnimationFrame(() => {
|
|
46
|
+
computeCaretRectangle();
|
|
47
|
+
scrollResizeRafId = null;
|
|
48
|
+
});
|
|
49
|
+
}
|
|
50
|
+
function onKeyDown(event) {
|
|
51
|
+
if (onKeyDownRafId) {
|
|
52
|
+
defaultView.cancelAnimationFrame(onKeyDownRafId);
|
|
59
53
|
}
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
54
|
+
onKeyDownRafId = defaultView.requestAnimationFrame(() => {
|
|
55
|
+
maintainCaretPosition(event);
|
|
56
|
+
onKeyDownRafId = null;
|
|
57
|
+
});
|
|
58
|
+
}
|
|
59
|
+
function maintainCaretPosition({ keyCode }) {
|
|
60
|
+
if (!isSelectionEligibleForScroll()) {
|
|
61
|
+
return;
|
|
68
62
|
}
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
}
|
|
73
|
-
const currentCaretRect = (0, import_dom.computeCaretRect)(defaultView);
|
|
74
|
-
if (!currentCaretRect) {
|
|
75
|
-
return;
|
|
76
|
-
}
|
|
77
|
-
if (!caretRect) {
|
|
78
|
-
caretRect = currentCaretRect;
|
|
79
|
-
return;
|
|
80
|
-
}
|
|
81
|
-
if (arrowKeyCodes.has(keyCode)) {
|
|
82
|
-
caretRect = currentCaretRect;
|
|
83
|
-
return;
|
|
84
|
-
}
|
|
85
|
-
const diff = currentCaretRect.top - caretRect.top;
|
|
86
|
-
if (diff === 0) {
|
|
87
|
-
return;
|
|
88
|
-
}
|
|
89
|
-
const scrollContainer = (0, import_dom.getScrollContainer)(node);
|
|
90
|
-
if (!scrollContainer) {
|
|
91
|
-
return;
|
|
92
|
-
}
|
|
93
|
-
const windowScroll = scrollContainer === ownerDocument.body || scrollContainer === ownerDocument.documentElement;
|
|
94
|
-
const scrollY = windowScroll ? defaultView.scrollY : scrollContainer.scrollTop;
|
|
95
|
-
const scrollContainerY = windowScroll ? 0 : scrollContainer.getBoundingClientRect().top;
|
|
96
|
-
const relativeScrollPosition = windowScroll ? caretRect.top / defaultView.innerHeight : (caretRect.top - scrollContainerY) / (defaultView.innerHeight - scrollContainerY);
|
|
97
|
-
if (scrollY === 0 && relativeScrollPosition < initialTriggerPercentage && isLastEditableNode()) {
|
|
98
|
-
caretRect = currentCaretRect;
|
|
99
|
-
return;
|
|
100
|
-
}
|
|
101
|
-
const scrollContainerHeight = windowScroll ? defaultView.innerHeight : scrollContainer.clientHeight;
|
|
102
|
-
if (
|
|
103
|
-
// The caret is under the lower fold.
|
|
104
|
-
caretRect.top + caretRect.height > scrollContainerY + scrollContainerHeight || // The caret is above the upper fold.
|
|
105
|
-
caretRect.top < scrollContainerY
|
|
106
|
-
) {
|
|
107
|
-
caretRect = currentCaretRect;
|
|
108
|
-
return;
|
|
109
|
-
}
|
|
110
|
-
if (windowScroll) {
|
|
111
|
-
defaultView.scrollBy(0, diff);
|
|
112
|
-
} else {
|
|
113
|
-
scrollContainer.scrollTop += diff;
|
|
114
|
-
}
|
|
63
|
+
const currentCaretRect = (0, import_dom.computeCaretRect)(defaultView);
|
|
64
|
+
if (!currentCaretRect) {
|
|
65
|
+
return;
|
|
115
66
|
}
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
computeCaretRectOnSelectionChange
|
|
120
|
-
);
|
|
67
|
+
if (!caretRect) {
|
|
68
|
+
caretRect = currentCaretRect;
|
|
69
|
+
return;
|
|
121
70
|
}
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
71
|
+
if (arrowKeyCodes.has(keyCode)) {
|
|
72
|
+
caretRect = currentCaretRect;
|
|
73
|
+
return;
|
|
74
|
+
}
|
|
75
|
+
const diff = currentCaretRect.top - caretRect.top;
|
|
76
|
+
if (diff === 0) {
|
|
77
|
+
return;
|
|
128
78
|
}
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
}
|
|
79
|
+
const scrollContainer = (0, import_dom.getScrollContainer)(node);
|
|
80
|
+
if (!scrollContainer) {
|
|
81
|
+
return;
|
|
133
82
|
}
|
|
134
|
-
|
|
135
|
-
|
|
83
|
+
const windowScroll = scrollContainer === ownerDocument.body || scrollContainer === ownerDocument.documentElement;
|
|
84
|
+
const scrollY = windowScroll ? defaultView.scrollY : scrollContainer.scrollTop;
|
|
85
|
+
const scrollContainerY = windowScroll ? 0 : scrollContainer.getBoundingClientRect().top;
|
|
86
|
+
const relativeScrollPosition = windowScroll ? caretRect.top / defaultView.innerHeight : (caretRect.top - scrollContainerY) / (defaultView.innerHeight - scrollContainerY);
|
|
87
|
+
if (scrollY === 0 && relativeScrollPosition < initialTriggerPercentage && isLastEditableNode()) {
|
|
88
|
+
caretRect = currentCaretRect;
|
|
89
|
+
return;
|
|
136
90
|
}
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
91
|
+
const scrollContainerHeight = windowScroll ? defaultView.innerHeight : scrollContainer.clientHeight;
|
|
92
|
+
if (
|
|
93
|
+
// The caret is under the lower fold.
|
|
94
|
+
caretRect.top + caretRect.height > scrollContainerY + scrollContainerHeight || // The caret is above the upper fold.
|
|
95
|
+
caretRect.top < scrollContainerY
|
|
96
|
+
) {
|
|
97
|
+
caretRect = currentCaretRect;
|
|
98
|
+
return;
|
|
143
99
|
}
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
100
|
+
if (windowScroll) {
|
|
101
|
+
defaultView.scrollBy(0, diff);
|
|
102
|
+
} else {
|
|
103
|
+
scrollContainer.scrollTop += diff;
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
function addSelectionChangeListener() {
|
|
107
|
+
ownerDocument.addEventListener(
|
|
108
|
+
"selectionchange",
|
|
109
|
+
computeCaretRectOnSelectionChange
|
|
110
|
+
);
|
|
111
|
+
}
|
|
112
|
+
function computeCaretRectOnSelectionChange() {
|
|
113
|
+
ownerDocument.removeEventListener(
|
|
114
|
+
"selectionchange",
|
|
115
|
+
computeCaretRectOnSelectionChange
|
|
116
|
+
);
|
|
117
|
+
computeCaretRectangle();
|
|
118
|
+
}
|
|
119
|
+
function computeCaretRectangle() {
|
|
120
|
+
if (isSelectionEligibleForScroll()) {
|
|
121
|
+
caretRect = (0, import_dom.computeCaretRect)(defaultView);
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
function getActiveEditableElement() {
|
|
125
|
+
const { activeElement } = ownerDocument;
|
|
126
|
+
if (!activeElement) {
|
|
127
|
+
return null;
|
|
128
|
+
}
|
|
129
|
+
if (!activeElement.isContentEditable || !activeElement.contains(node)) {
|
|
130
|
+
return activeElement;
|
|
131
|
+
}
|
|
132
|
+
const { anchorNode } = defaultView.getSelection();
|
|
133
|
+
if (!anchorNode) {
|
|
134
|
+
return null;
|
|
135
|
+
}
|
|
136
|
+
const element = anchorNode.nodeType === anchorNode.ELEMENT_NODE ? anchorNode : anchorNode.parentElement;
|
|
137
|
+
return element?.closest('[contenteditable="true"]') ?? null;
|
|
138
|
+
}
|
|
139
|
+
function isSelectionEligibleForScroll() {
|
|
140
|
+
const activeEditableElement = getActiveEditableElement();
|
|
141
|
+
return !!activeEditableElement && node.contains(activeEditableElement) && activeEditableElement.isContentEditable;
|
|
142
|
+
}
|
|
143
|
+
function isLastEditableNode() {
|
|
144
|
+
const editableNodes = node.querySelectorAll(
|
|
145
|
+
'[contenteditable="true"]'
|
|
146
|
+
);
|
|
147
|
+
const lastEditableNode = editableNodes[editableNodes.length - 1];
|
|
148
|
+
return lastEditableNode === getActiveEditableElement();
|
|
149
|
+
}
|
|
150
|
+
defaultView.addEventListener("scroll", onScrollResize, true);
|
|
151
|
+
defaultView.addEventListener("resize", onScrollResize, true);
|
|
152
|
+
node.addEventListener("keydown", onKeyDown);
|
|
153
|
+
node.addEventListener("keyup", maintainCaretPosition);
|
|
154
|
+
node.addEventListener("mousedown", addSelectionChangeListener);
|
|
155
|
+
node.addEventListener("touchstart", addSelectionChangeListener);
|
|
156
|
+
return () => {
|
|
157
|
+
defaultView.removeEventListener("scroll", onScrollResize, true);
|
|
158
|
+
defaultView.removeEventListener("resize", onScrollResize, true);
|
|
159
|
+
node.removeEventListener("keydown", onKeyDown);
|
|
160
|
+
node.removeEventListener("keyup", maintainCaretPosition);
|
|
161
|
+
node.removeEventListener("mousedown", addSelectionChangeListener);
|
|
162
|
+
node.removeEventListener(
|
|
163
|
+
"touchstart",
|
|
164
|
+
addSelectionChangeListener
|
|
165
|
+
);
|
|
166
|
+
ownerDocument.removeEventListener(
|
|
167
|
+
"selectionchange",
|
|
168
|
+
computeCaretRectOnSelectionChange
|
|
169
|
+
);
|
|
170
|
+
defaultView.cancelAnimationFrame(scrollResizeRafId);
|
|
171
|
+
defaultView.cancelAnimationFrame(onKeyDownRafId);
|
|
172
|
+
};
|
|
173
|
+
}, []);
|
|
181
174
|
}
|
|
182
175
|
function Typewriter({ children }) {
|
|
183
176
|
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { ref: useTypewriter(), className: "block-editor__typewriter", children });
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../src/components/typewriter/index.js"],
|
|
4
|
-
"sourcesContent": ["/**\n * WordPress dependencies\n */\nimport { useRefEffect } from '@wordpress/compose';\nimport { computeCaretRect, getScrollContainer } from '@wordpress/dom';\nimport {
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAGA,qBAA6B;AAC7B,iBAAqD;AACrD,
|
|
6
|
-
"names": [
|
|
4
|
+
"sourcesContent": ["/**\n * WordPress dependencies\n */\nimport { useRefEffect } from '@wordpress/compose';\nimport { computeCaretRect, getScrollContainer } from '@wordpress/dom';\nimport { UP, DOWN, LEFT, RIGHT } from '@wordpress/keycodes';\n\nconst isIE = window.navigator.userAgent.indexOf( 'Trident' ) !== -1;\nconst arrowKeyCodes = new Set( [ UP, DOWN, LEFT, RIGHT ] );\nconst initialTriggerPercentage = 0.75;\n\nexport function useTypewriter() {\n\treturn useRefEffect( ( node ) => {\n\t\tconst { ownerDocument } = node;\n\t\tconst { defaultView } = ownerDocument;\n\n\t\tlet scrollResizeRafId;\n\t\tlet onKeyDownRafId;\n\n\t\tlet caretRect;\n\n\t\tfunction onScrollResize() {\n\t\t\tif ( scrollResizeRafId ) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tscrollResizeRafId = defaultView.requestAnimationFrame( () => {\n\t\t\t\tcomputeCaretRectangle();\n\t\t\t\tscrollResizeRafId = null;\n\t\t\t} );\n\t\t}\n\n\t\tfunction onKeyDown( event ) {\n\t\t\t// Ensure the any remaining request is cancelled.\n\t\t\tif ( onKeyDownRafId ) {\n\t\t\t\tdefaultView.cancelAnimationFrame( onKeyDownRafId );\n\t\t\t}\n\n\t\t\t// Use an animation frame for a smooth result.\n\t\t\tonKeyDownRafId = defaultView.requestAnimationFrame( () => {\n\t\t\t\tmaintainCaretPosition( event );\n\t\t\t\tonKeyDownRafId = null;\n\t\t\t} );\n\t\t}\n\n\t\t/**\n\t\t * Maintains the scroll position after a selection change caused by a\n\t\t * keyboard event.\n\t\t *\n\t\t * @param {KeyboardEvent} event Keyboard event.\n\t\t */\n\t\tfunction maintainCaretPosition( { keyCode } ) {\n\t\t\tif ( ! isSelectionEligibleForScroll() ) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tconst currentCaretRect = computeCaretRect( defaultView );\n\n\t\t\tif ( ! currentCaretRect ) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\t// If for some reason there is no position set to be scrolled to, let\n\t\t\t// this be the position to be scrolled to in the future.\n\t\t\tif ( ! caretRect ) {\n\t\t\t\tcaretRect = currentCaretRect;\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\t// Even though enabling the typewriter effect for arrow keys results in\n\t\t\t// a pleasant experience, it may not be the case for everyone, so, for\n\t\t\t// now, let's disable it.\n\t\t\tif ( arrowKeyCodes.has( keyCode ) ) {\n\t\t\t\t// Reset the caret position to maintain.\n\t\t\t\tcaretRect = currentCaretRect;\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tconst diff = currentCaretRect.top - caretRect.top;\n\n\t\t\tif ( diff === 0 ) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tconst scrollContainer = getScrollContainer( node );\n\n\t\t\t// The page must be scrollable.\n\t\t\tif ( ! scrollContainer ) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tconst windowScroll =\n\t\t\t\tscrollContainer === ownerDocument.body ||\n\t\t\t\tscrollContainer === ownerDocument.documentElement;\n\t\t\tconst scrollY = windowScroll\n\t\t\t\t? defaultView.scrollY\n\t\t\t\t: scrollContainer.scrollTop;\n\t\t\tconst scrollContainerY = windowScroll\n\t\t\t\t? 0\n\t\t\t\t: scrollContainer.getBoundingClientRect().top;\n\t\t\tconst relativeScrollPosition = windowScroll\n\t\t\t\t? caretRect.top / defaultView.innerHeight\n\t\t\t\t: ( caretRect.top - scrollContainerY ) /\n\t\t\t\t ( defaultView.innerHeight - scrollContainerY );\n\n\t\t\t// If the scroll position is at the start, the active editable element\n\t\t\t// is the last one, and the caret is positioned within the initial\n\t\t\t// trigger percentage of the page, do not scroll the page.\n\t\t\t// The typewriter effect should not kick in until an empty page has been\n\t\t\t// filled with the initial trigger percentage or the user scrolls\n\t\t\t// intentionally down.\n\t\t\tif (\n\t\t\t\tscrollY === 0 &&\n\t\t\t\trelativeScrollPosition < initialTriggerPercentage &&\n\t\t\t\tisLastEditableNode()\n\t\t\t) {\n\t\t\t\t// Reset the caret position to maintain.\n\t\t\t\tcaretRect = currentCaretRect;\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tconst scrollContainerHeight = windowScroll\n\t\t\t\t? defaultView.innerHeight\n\t\t\t\t: scrollContainer.clientHeight;\n\n\t\t\t// Abort if the target scroll position would scroll the caret out of\n\t\t\t// view.\n\t\t\tif (\n\t\t\t\t// The caret is under the lower fold.\n\t\t\t\tcaretRect.top + caretRect.height >\n\t\t\t\t\tscrollContainerY + scrollContainerHeight ||\n\t\t\t\t// The caret is above the upper fold.\n\t\t\t\tcaretRect.top < scrollContainerY\n\t\t\t) {\n\t\t\t\t// Reset the caret position to maintain.\n\t\t\t\tcaretRect = currentCaretRect;\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tif ( windowScroll ) {\n\t\t\t\tdefaultView.scrollBy( 0, diff );\n\t\t\t} else {\n\t\t\t\tscrollContainer.scrollTop += diff;\n\t\t\t}\n\t\t}\n\n\t\t/**\n\t\t * Adds a `selectionchange` listener to reset the scroll position to be\n\t\t * maintained.\n\t\t */\n\t\tfunction addSelectionChangeListener() {\n\t\t\townerDocument.addEventListener(\n\t\t\t\t'selectionchange',\n\t\t\t\tcomputeCaretRectOnSelectionChange\n\t\t\t);\n\t\t}\n\n\t\t/**\n\t\t * Resets the scroll position to be maintained during a `selectionchange`\n\t\t * event. Also removes the listener, so it acts as a one-time listener.\n\t\t */\n\t\tfunction computeCaretRectOnSelectionChange() {\n\t\t\townerDocument.removeEventListener(\n\t\t\t\t'selectionchange',\n\t\t\t\tcomputeCaretRectOnSelectionChange\n\t\t\t);\n\t\t\tcomputeCaretRectangle();\n\t\t}\n\n\t\t/**\n\t\t * Resets the scroll position to be maintained.\n\t\t */\n\t\tfunction computeCaretRectangle() {\n\t\t\tif ( isSelectionEligibleForScroll() ) {\n\t\t\t\tcaretRect = computeCaretRect( defaultView );\n\t\t\t}\n\t\t}\n\n\t\t/**\n\t\t * Returns the editable element owning the selection: the active\n\t\t * element, or, when a focused editing host contains the node\n\t\t * (a selected block supports `editableRoot`), the editable\n\t\t * element containing the selection.\n\t\t */\n\t\tfunction getActiveEditableElement() {\n\t\t\tconst { activeElement } = ownerDocument;\n\n\t\t\tif ( ! activeElement ) {\n\t\t\t\treturn null;\n\t\t\t}\n\n\t\t\tif (\n\t\t\t\t! activeElement.isContentEditable ||\n\t\t\t\t! activeElement.contains( node )\n\t\t\t) {\n\t\t\t\treturn activeElement;\n\t\t\t}\n\n\t\t\tconst { anchorNode } = defaultView.getSelection();\n\n\t\t\tif ( ! anchorNode ) {\n\t\t\t\treturn null;\n\t\t\t}\n\n\t\t\tconst element =\n\t\t\t\tanchorNode.nodeType === anchorNode.ELEMENT_NODE\n\t\t\t\t\t? anchorNode\n\t\t\t\t\t: anchorNode.parentElement;\n\t\t\treturn element?.closest( '[contenteditable=\"true\"]' ) ?? null;\n\t\t}\n\n\t\t/**\n\t\t * Checks if the current situation is eligible for scroll:\n\t\t * - The component must contain the selection.\n\t\t * - The active element must be contenteditable.\n\t\t */\n\t\tfunction isSelectionEligibleForScroll() {\n\t\t\tconst activeEditableElement = getActiveEditableElement();\n\t\t\treturn (\n\t\t\t\t!! activeEditableElement &&\n\t\t\t\tnode.contains( activeEditableElement ) &&\n\t\t\t\tactiveEditableElement.isContentEditable\n\t\t\t);\n\t\t}\n\n\t\tfunction isLastEditableNode() {\n\t\t\tconst editableNodes = node.querySelectorAll(\n\t\t\t\t'[contenteditable=\"true\"]'\n\t\t\t);\n\t\t\tconst lastEditableNode = editableNodes[ editableNodes.length - 1 ];\n\t\t\treturn lastEditableNode === getActiveEditableElement();\n\t\t}\n\n\t\t// When the user scrolls or resizes, the scroll position should be\n\t\t// reset.\n\t\tdefaultView.addEventListener( 'scroll', onScrollResize, true );\n\t\tdefaultView.addEventListener( 'resize', onScrollResize, true );\n\n\t\tnode.addEventListener( 'keydown', onKeyDown );\n\t\tnode.addEventListener( 'keyup', maintainCaretPosition );\n\t\tnode.addEventListener( 'mousedown', addSelectionChangeListener );\n\t\tnode.addEventListener( 'touchstart', addSelectionChangeListener );\n\n\t\treturn () => {\n\t\t\tdefaultView.removeEventListener( 'scroll', onScrollResize, true );\n\t\t\tdefaultView.removeEventListener( 'resize', onScrollResize, true );\n\n\t\t\tnode.removeEventListener( 'keydown', onKeyDown );\n\t\t\tnode.removeEventListener( 'keyup', maintainCaretPosition );\n\t\t\tnode.removeEventListener( 'mousedown', addSelectionChangeListener );\n\t\t\tnode.removeEventListener(\n\t\t\t\t'touchstart',\n\t\t\t\taddSelectionChangeListener\n\t\t\t);\n\n\t\t\townerDocument.removeEventListener(\n\t\t\t\t'selectionchange',\n\t\t\t\tcomputeCaretRectOnSelectionChange\n\t\t\t);\n\n\t\t\tdefaultView.cancelAnimationFrame( scrollResizeRafId );\n\t\t\tdefaultView.cancelAnimationFrame( onKeyDownRafId );\n\t\t};\n\t}, [] );\n}\n\nfunction Typewriter( { children } ) {\n\treturn (\n\t\t<div ref={ useTypewriter() } className=\"block-editor__typewriter\">\n\t\t\t{ children }\n\t\t</div>\n\t);\n}\n\n/**\n * The exported component. The implementation of Typewriter faced technical\n * challenges in Internet Explorer, and is simply skipped, rendering the given\n * props children instead.\n *\n * @type {Component}\n */\nconst TypewriterOrIEBypass = isIE ? ( props ) => props.children : Typewriter;\n\n/**\n * Ensures that the text selection keeps the same vertical distance from the\n * viewport during keyboard events within this component. The vertical distance\n * can vary. It is the last clicked or scrolled to position.\n */\nexport default TypewriterOrIEBypass;\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAGA,qBAA6B;AAC7B,iBAAqD;AACrD,sBAAsC;AAuQpC;AArQF,IAAM,OAAO,OAAO,UAAU,UAAU,QAAS,SAAU,MAAM;AACjE,IAAM,gBAAgB,oBAAI,IAAK,CAAE,oBAAI,sBAAM,sBAAM,qBAAM,CAAE;AACzD,IAAM,2BAA2B;AAE1B,SAAS,gBAAgB;AAC/B,aAAO,6BAAc,CAAE,SAAU;AAChC,UAAM,EAAE,cAAc,IAAI;AAC1B,UAAM,EAAE,YAAY,IAAI;AAExB,QAAI;AACJ,QAAI;AAEJ,QAAI;AAEJ,aAAS,iBAAiB;AACzB,UAAK,mBAAoB;AACxB;AAAA,MACD;AAEA,0BAAoB,YAAY,sBAAuB,MAAM;AAC5D,8BAAsB;AACtB,4BAAoB;AAAA,MACrB,CAAE;AAAA,IACH;AAEA,aAAS,UAAW,OAAQ;AAE3B,UAAK,gBAAiB;AACrB,oBAAY,qBAAsB,cAAe;AAAA,MAClD;AAGA,uBAAiB,YAAY,sBAAuB,MAAM;AACzD,8BAAuB,KAAM;AAC7B,yBAAiB;AAAA,MAClB,CAAE;AAAA,IACH;AAQA,aAAS,sBAAuB,EAAE,QAAQ,GAAI;AAC7C,UAAK,CAAE,6BAA6B,GAAI;AACvC;AAAA,MACD;AAEA,YAAM,uBAAmB,6BAAkB,WAAY;AAEvD,UAAK,CAAE,kBAAmB;AACzB;AAAA,MACD;AAIA,UAAK,CAAE,WAAY;AAClB,oBAAY;AACZ;AAAA,MACD;AAKA,UAAK,cAAc,IAAK,OAAQ,GAAI;AAEnC,oB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CAAE,UAAW,MAAM,WAAW;AAOlE,IAAO,qBAAQ;",
|
|
6
|
+
"names": []
|
|
7
7
|
}
|
|
@@ -115,22 +115,26 @@ var getTransformCommands = () => function useTransformCommands() {
|
|
|
115
115
|
return { isLoading: false, commands };
|
|
116
116
|
};
|
|
117
117
|
var getQuickActionsCommands = () => function useQuickActionsCommands() {
|
|
118
|
-
const {
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
118
|
+
const {
|
|
119
|
+
clientIds,
|
|
120
|
+
isUngroupable,
|
|
121
|
+
isGroupable,
|
|
122
|
+
blockVisibilitySetting
|
|
123
|
+
} = (0, import_data.useSelect)((select) => {
|
|
124
|
+
const {
|
|
125
|
+
getSelectedBlockClientIds,
|
|
126
|
+
getSettings,
|
|
127
|
+
isUngroupable: _isUngroupable,
|
|
128
|
+
isGroupable: _isGroupable
|
|
129
|
+
} = select(import_store.store);
|
|
130
|
+
const selectedBlockClientIds = getSelectedBlockClientIds();
|
|
131
|
+
return {
|
|
132
|
+
clientIds: selectedBlockClientIds,
|
|
133
|
+
isUngroupable: _isUngroupable(),
|
|
134
|
+
isGroupable: _isGroupable(),
|
|
135
|
+
blockVisibilitySetting: getSettings().__experimentalFeatures?.blockVisibility?.allowEditing
|
|
136
|
+
};
|
|
137
|
+
}, []);
|
|
134
138
|
const {
|
|
135
139
|
canInsertBlockType,
|
|
136
140
|
getBlockRootClientId,
|
|
@@ -244,7 +248,7 @@ var getQuickActionsCommands = () => function useQuickActionsCommands() {
|
|
|
244
248
|
const allBlocksDefaultMode = clientIds.every(
|
|
245
249
|
(id) => getBlockEditingMode(id) === "default"
|
|
246
250
|
);
|
|
247
|
-
if (supportsVisibility && allBlocksDefaultMode) {
|
|
251
|
+
if (supportsVisibility && allBlocksDefaultMode && blockVisibilitySetting !== false) {
|
|
248
252
|
const hasHiddenBlock = clientIds.some(
|
|
249
253
|
(id) => isBlockHiddenAnywhere(id)
|
|
250
254
|
);
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../src/components/use-block-commands/index.js"],
|
|
4
|
-
"sourcesContent": ["/**\n * WordPress dependencies\n */\nimport { __, sprintf } from '@wordpress/i18n';\nimport {\n\thasBlockSupport,\n\tstore as blocksStore,\n\tswitchToBlockType,\n\tisTemplatePart,\n} from '@wordpress/blocks';\nimport { useSelect, useDispatch } from '@wordpress/data';\nimport { useCommandLoader } from '@wordpress/commands';\nimport {\n\tcopy,\n\ttrash as remove,\n\tplus as add,\n\tgroup,\n\tungroup,\n\tseen,\n\tunseen,\n\tblockDefault as blockDefaultIcon,\n} from '@wordpress/icons';\n\n/**\n * Internal dependencies\n */\nimport { store as blockEditorStore } from '../../store';\nimport { unlock } from '../../lock-unlock';\n\nconst getTransformCommands = () =>\n\tfunction useTransformCommands() {\n\t\tconst { replaceBlocks, multiSelect } = useDispatch( blockEditorStore );\n\t\tconst {\n\t\t\tblocks,\n\t\t\tclientIds,\n\t\t\tcanRemove,\n\t\t\tpossibleBlockTransformations,\n\t\t\tinvalidSelection,\n\t\t} = useSelect( ( select ) => {\n\t\t\tconst {\n\t\t\t\tgetBlockRootClientId,\n\t\t\t\tgetBlockTransformItems,\n\t\t\t\tgetSelectedBlockClientIds,\n\t\t\t\tgetBlocksByClientId,\n\t\t\t\tcanRemoveBlocks,\n\t\t\t} = select( blockEditorStore );\n\n\t\t\tconst selectedBlockClientIds = getSelectedBlockClientIds();\n\t\t\tconst selectedBlocks = getBlocksByClientId(\n\t\t\t\tselectedBlockClientIds\n\t\t\t);\n\n\t\t\t// selectedBlocks can have `null`s when something tries to call `selectBlock` with an inexistent clientId.\n\t\t\t// These nulls will cause fatal errors down the line.\n\t\t\t// In order to prevent discrepancies between selectedBlockClientIds and selectedBlocks, we effectively treat the entire selection as invalid.\n\t\t\t// @see https://github.com/WordPress/gutenberg/pull/59410#issuecomment-2006304536\n\t\t\tif ( selectedBlocks.filter( ( block ) => ! block ).length > 0 ) {\n\t\t\t\treturn {\n\t\t\t\t\tinvalidSelection: true,\n\t\t\t\t};\n\t\t\t}\n\n\t\t\tconst rootClientId = getBlockRootClientId(\n\t\t\t\tselectedBlockClientIds[ 0 ]\n\t\t\t);\n\t\t\treturn {\n\t\t\t\tblocks: selectedBlocks,\n\t\t\t\tclientIds: selectedBlockClientIds,\n\t\t\t\tpossibleBlockTransformations: getBlockTransformItems(\n\t\t\t\t\tselectedBlocks,\n\t\t\t\t\trootClientId\n\t\t\t\t),\n\t\t\t\tcanRemove: canRemoveBlocks( selectedBlockClientIds ),\n\t\t\t\tinvalidSelection: false,\n\t\t\t};\n\t\t}, [] );\n\n\t\tif ( invalidSelection ) {\n\t\t\treturn {\n\t\t\t\tisLoading: false,\n\t\t\t\tcommands: [],\n\t\t\t};\n\t\t}\n\t\tconst isTemplate = blocks.length === 1 && isTemplatePart( blocks[ 0 ] );\n\n\t\tfunction selectForMultipleBlocks( insertedBlocks ) {\n\t\t\tif ( insertedBlocks.length > 1 ) {\n\t\t\t\tmultiSelect(\n\t\t\t\t\tinsertedBlocks[ 0 ].clientId,\n\t\t\t\t\tinsertedBlocks[ insertedBlocks.length - 1 ].clientId\n\t\t\t\t);\n\t\t\t}\n\t\t}\n\n\t\t// Simple block transformation based on the `Block Transforms` API.\n\t\tfunction onBlockTransform( name, variationName ) {\n\t\t\tconst newBlocks = switchToBlockType( blocks, name, variationName );\n\t\t\treplaceBlocks( clientIds, newBlocks );\n\t\t\tselectForMultipleBlocks( newBlocks );\n\t\t}\n\n\t\t/**\n\t\t * The `isTemplate` check is a stopgap solution here.\n\t\t * Ideally, the Transforms API should handle this\n\t\t * by allowing to exclude blocks from wildcard transformations.\n\t\t */\n\t\tconst hasPossibleBlockTransformations =\n\t\t\t!! possibleBlockTransformations.length && canRemove && ! isTemplate;\n\n\t\tif (\n\t\t\t! clientIds ||\n\t\t\tclientIds.length < 1 ||\n\t\t\t! hasPossibleBlockTransformations\n\t\t) {\n\t\t\treturn { isLoading: false, commands: [] };\n\t\t}\n\n\t\tconst commands = possibleBlockTransformations.map(\n\t\t\t( transformation ) => {\n\t\t\t\tconst { id, name, title, icon, variationName } = transformation;\n\t\t\t\t/*\n\t\t\t\t * Command menu uses Icon from @wordpress/icons, which expects a ReactElement\n\t\t\t\t * (cloneElement). Normalize to blockDefaultIcon to avoid crash. See #55668 / PR #55676.\n\t\t\t\t */\n\t\t\t\tconst blockIcon =\n\t\t\t\t\t! icon?.src || icon?.src === 'block-default'\n\t\t\t\t\t\t? {\n\t\t\t\t\t\t\t\tsrc: blockDefaultIcon,\n\t\t\t\t\t\t }\n\t\t\t\t\t\t: icon;\n\n\t\t\t\treturn {\n\t\t\t\t\tname:\n\t\t\t\t\t\t'core/block-editor/transform-to-' +\n\t\t\t\t\t\t( id || name ).replace( /\\//g, '-' ),\n\t\t\t\t\t/* translators: %s: Block or block variation name. */\n\t\t\t\t\tlabel: sprintf( __( 'Transform to %s' ), title ),\n\t\t\t\t\ticon: blockIcon?.src,\n\t\t\t\t\tcategory: 'command',\n\t\t\t\t\tcallback: ( { close } ) => {\n\t\t\t\t\t\tonBlockTransform( name, variationName );\n\t\t\t\t\t\tclose();\n\t\t\t\t\t},\n\t\t\t\t};\n\t\t\t}\n\t\t);\n\n\t\treturn { isLoading: false, commands };\n\t};\n\nconst getQuickActionsCommands = () =>\n\tfunction useQuickActionsCommands() {\n\t\tconst { clientIds, isUngroupable, isGroupable } = useSelect(\n\t\t\t( select ) => {\n\t\t\t\tconst {\n\t\t\t\t\tgetSelectedBlockClientIds,\n\t\t\t\t\tisUngroupable: _isUngroupable,\n\t\t\t\t\tisGroupable: _isGroupable,\n\t\t\t\t} = select( blockEditorStore );\n\t\t\t\tconst selectedBlockClientIds = getSelectedBlockClientIds();\n\n\t\t\t\treturn {\n\t\t\t\t\tclientIds: selectedBlockClientIds,\n\t\t\t\t\tisUngroupable: _isUngroupable(),\n\t\t\t\t\tisGroupable: _isGroupable(),\n\t\t\t\t};\n\t\t\t},\n\t\t\t[]\n\t\t);\n\t\tconst {\n\t\t\tcanInsertBlockType,\n\t\t\tgetBlockRootClientId,\n\t\t\tgetBlocksByClientId,\n\t\t\tcanRemoveBlocks,\n\t\t\tisBlockHiddenAnywhere,\n\t\t} = unlock( useSelect( blockEditorStore ) );\n\t\tconst { getBlockEditingMode } = useSelect( blockEditorStore );\n\t\tconst { getDefaultBlockName, getGroupingBlockName } =\n\t\t\tuseSelect( blocksStore );\n\n\t\tconst blocks = getBlocksByClientId( clientIds );\n\n\t\tconst blockEditorDispatch = useDispatch( blockEditorStore );\n\t\tconst {\n\t\t\tremoveBlocks,\n\t\t\treplaceBlocks,\n\t\t\tduplicateBlocks,\n\t\t\tinsertAfterBlock,\n\t\t\tinsertBeforeBlock,\n\t\t} = blockEditorDispatch;\n\n\t\tconst onGroup = () => {\n\t\t\tif ( ! blocks.length ) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tconst groupingBlockName = getGroupingBlockName();\n\n\t\t\t// Activate the `transform` on `core/group` which does the conversion.\n\t\t\tconst newBlocks = switchToBlockType( blocks, groupingBlockName );\n\n\t\t\tif ( ! newBlocks ) {\n\t\t\t\treturn;\n\t\t\t}\n\t\t\treplaceBlocks( clientIds, newBlocks );\n\t\t};\n\t\tconst onUngroup = () => {\n\t\t\tif ( ! blocks.length ) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tconst innerBlocks = blocks[ 0 ].innerBlocks;\n\n\t\t\tif ( ! innerBlocks.length ) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\treplaceBlocks( clientIds, innerBlocks );\n\t\t};\n\n\t\tif ( ! clientIds || clientIds.length < 1 ) {\n\t\t\treturn { isLoading: false, commands: [] };\n\t\t}\n\n\t\tconst { showViewportModal } = unlock( blockEditorDispatch );\n\t\tconst rootClientId = getBlockRootClientId( clientIds[ 0 ] );\n\t\tconst canInsertDefaultBlock = canInsertBlockType(\n\t\t\tgetDefaultBlockName(),\n\t\t\trootClientId\n\t\t);\n\t\tconst canDuplicate = blocks.every( ( block ) => {\n\t\t\treturn (\n\t\t\t\t!! block &&\n\t\t\t\thasBlockSupport( block.name, 'multiple', true ) &&\n\t\t\t\tcanInsertBlockType( block.name, rootClientId )\n\t\t\t);\n\t\t} );\n\t\tconst canRemove = canRemoveBlocks( clientIds );\n\n\t\tconst commands = [];\n\n\t\tif ( canDuplicate ) {\n\t\t\tcommands.push( {\n\t\t\t\tname: 'duplicate',\n\t\t\t\tlabel: __( 'Duplicate' ),\n\t\t\t\tcallback: () => duplicateBlocks( clientIds, true ),\n\t\t\t\ticon: copy,\n\t\t\t} );\n\t\t}\n\n\t\tif ( canInsertDefaultBlock ) {\n\t\t\tcommands.push(\n\t\t\t\t{\n\t\t\t\t\tname: 'add-before',\n\t\t\t\t\tlabel: __( 'Add before' ),\n\t\t\t\t\tcallback: () => {\n\t\t\t\t\t\tconst clientId = Array.isArray( clientIds )\n\t\t\t\t\t\t\t? clientIds[ 0 ]\n\t\t\t\t\t\t\t: clientId;\n\t\t\t\t\t\tinsertBeforeBlock( clientId );\n\t\t\t\t\t},\n\t\t\t\t\ticon: add,\n\t\t\t\t},\n\t\t\t\t{\n\t\t\t\t\tname: 'add-after',\n\t\t\t\t\tlabel: __( 'Add after' ),\n\t\t\t\t\tcallback: () => {\n\t\t\t\t\t\tconst clientId = Array.isArray( clientIds )\n\t\t\t\t\t\t\t? clientIds[ clientIds.length - 1 ]\n\t\t\t\t\t\t\t: clientId;\n\t\t\t\t\t\tinsertAfterBlock( clientId );\n\t\t\t\t\t},\n\t\t\t\t\ticon: add,\n\t\t\t\t}\n\t\t\t);\n\t\t}\n\n\t\tif ( isGroupable ) {\n\t\t\tcommands.push( {\n\t\t\t\tname: 'Group',\n\t\t\t\tlabel: __( 'Group' ),\n\t\t\t\tcallback: onGroup,\n\t\t\t\ticon: group,\n\t\t\t} );\n\t\t}\n\n\t\tif ( isUngroupable ) {\n\t\t\tcommands.push( {\n\t\t\t\tname: 'ungroup',\n\t\t\t\tlabel: __( 'Ungroup' ),\n\t\t\t\tcallback: onUngroup,\n\t\t\t\ticon: ungroup,\n\t\t\t} );\n\t\t}\n\n\t\tif ( canRemove ) {\n\t\t\tcommands.push( {\n\t\t\t\tname: 'remove',\n\t\t\t\tlabel: __( 'Delete' ),\n\t\t\t\tcallback: () => removeBlocks( clientIds, true ),\n\t\t\t\ticon: remove,\n\t\t\t} );\n\t\t}\n\n\t\tconst supportsVisibility = blocks.every(\n\t\t\t( block ) =>\n\t\t\t\t!! block && hasBlockSupport( block.name, 'visibility', true )\n\t\t);\n\t\tconst allBlocksDefaultMode = clientIds.every(\n\t\t\t( id ) => getBlockEditingMode( id ) === 'default'\n\t\t);\n\n\t\tif ( supportsVisibility && allBlocksDefaultMode ) {\n\t\t\tconst hasHiddenBlock = clientIds.some( ( id ) =>\n\t\t\t\tisBlockHiddenAnywhere( id )\n\t\t\t);\n\t\t\tcommands.push( {\n\t\t\t\tname: 'toggle-visibility',\n\t\t\t\tlabel: hasHiddenBlock ? __( 'Show' ) : __( 'Hide' ),\n\t\t\t\tcallback: () => showViewportModal( clientIds ),\n\t\t\t\ticon: hasHiddenBlock ? seen : unseen,\n\t\t\t} );\n\t\t}\n\n\t\treturn {\n\t\t\tisLoading: false,\n\t\t\tcommands: commands.map( ( command ) => ( {\n\t\t\t\t...command,\n\t\t\t\tname: 'core/block-editor/action-' + command.name,\n\t\t\t\tcategory: 'command',\n\t\t\t\tcallback: ( { close } ) => {\n\t\t\t\t\tcommand.callback();\n\t\t\t\t\tclose();\n\t\t\t\t},\n\t\t\t} ) ),\n\t\t};\n\t};\n\nexport const useBlockCommands = () => {\n\tuseCommandLoader( {\n\t\tname: 'core/block-editor/blockTransforms',\n\t\thook: getTransformCommands(),\n\t} );\n\tuseCommandLoader( {\n\t\tname: 'core/block-editor/blockQuickActions',\n\t\thook: getQuickActionsCommands(),\n\t\tcontext: 'block-selection-edit',\n\t} );\n};\n"],
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAGA,kBAA4B;AAC5B,oBAKO;AACP,kBAAuC;AACvC,sBAAiC;AACjC,mBASO;AAKP,mBAA0C;AAC1C,yBAAuB;AAEvB,IAAM,uBAAuB,MAC5B,SAAS,uBAAuB;AAC/B,QAAM,EAAE,eAAe,YAAY,QAAI,yBAAa,aAAAA,KAAiB;AACrE,QAAM;AAAA,IACL;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,EACD,QAAI,uBAAW,CAAE,WAAY;AAC5B,UAAM;AAAA,MACL;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,IACD,IAAI,OAAQ,aAAAA,KAAiB;AAE7B,UAAM,yBAAyB,0BAA0B;AACzD,UAAM,iBAAiB;AAAA,MACtB;AAAA,IACD;AAMA,QAAK,eAAe,OAAQ,CAAE,UAAW,CAAE,KAAM,EAAE,SAAS,GAAI;AAC/D,aAAO;AAAA,QACN,kBAAkB;AAAA,MACnB;AAAA,IACD;AAEA,UAAM,eAAe;AAAA,MACpB,uBAAwB,CAAE;AAAA,IAC3B;AACA,WAAO;AAAA,MACN,QAAQ;AAAA,MACR,WAAW;AAAA,MACX,8BAA8B;AAAA,QAC7B;AAAA,QACA;AAAA,MACD;AAAA,MACA,WAAW,gBAAiB,sBAAuB;AAAA,MACnD,kBAAkB;AAAA,IACnB;AAAA,EACD,GAAG,CAAC,CAAE;AAEN,MAAK,kBAAmB;AACvB,WAAO;AAAA,MACN,WAAW;AAAA,MACX,UAAU,CAAC;AAAA,IACZ;AAAA,EACD;AACA,QAAM,aAAa,OAAO,WAAW,SAAK,8BAAgB,OAAQ,CAAE,CAAE;AAEtE,WAAS,wBAAyB,gBAAiB;AAClD,QAAK,eAAe,SAAS,GAAI;AAChC;AAAA,QACC,eAAgB,CAAE,EAAE;AAAA,QACpB,eAAgB,eAAe,SAAS,CAAE,EAAE;AAAA,MAC7C;AAAA,IACD;AAAA,EACD;AAGA,WAAS,iBAAkB,MAAM,eAAgB;AAChD,UAAM,gBAAY,iCAAmB,QAAQ,MAAM,aAAc;AACjE,kBAAe,WAAW,SAAU;AACpC,4BAAyB,SAAU;AAAA,EACpC;AAOA,QAAM,kCACL,CAAC,CAAE,6BAA6B,UAAU,aAAa,CAAE;AAE1D,MACC,CAAE,aACF,UAAU,SAAS,KACnB,CAAE,iCACD;AACD,WAAO,EAAE,WAAW,OAAO,UAAU,CAAC,EAAE;AAAA,EACzC;AAEA,QAAM,WAAW,6BAA6B;AAAA,IAC7C,CAAE,mBAAoB;AACrB,YAAM,EAAE,IAAI,MAAM,OAAO,MAAM,cAAc,IAAI;AAKjD,YAAM,YACL,CAAE,MAAM,OAAO,MAAM,QAAQ,kBAC1B;AAAA,QACA,KAAK,aAAAC;AAAA,MACL,IACA;AAEJ,aAAO;AAAA,QACN,MACC,qCACE,MAAM,MAAO,QAAS,OAAO,GAAI;AAAA;AAAA,QAEpC,WAAO,yBAAS,gBAAI,iBAAkB,GAAG,KAAM;AAAA,QAC/C,MAAM,WAAW;AAAA,QACjB,UAAU;AAAA,QACV,UAAU,CAAE,EAAE,MAAM,MAAO;AAC1B,2BAAkB,MAAM,aAAc;AACtC,gBAAM;AAAA,QACP;AAAA,MACD;AAAA,IACD;AAAA,EACD;AAEA,SAAO,EAAE,WAAW,OAAO,SAAS;AACrC;AAED,IAAM,0BAA0B,MAC/B,SAAS,0BAA0B;AAClC,QAAM,
|
|
4
|
+
"sourcesContent": ["/**\n * WordPress dependencies\n */\nimport { __, sprintf } from '@wordpress/i18n';\nimport {\n\thasBlockSupport,\n\tstore as blocksStore,\n\tswitchToBlockType,\n\tisTemplatePart,\n} from '@wordpress/blocks';\nimport { useSelect, useDispatch } from '@wordpress/data';\nimport { useCommandLoader } from '@wordpress/commands';\nimport {\n\tcopy,\n\ttrash as remove,\n\tplus as add,\n\tgroup,\n\tungroup,\n\tseen,\n\tunseen,\n\tblockDefault as blockDefaultIcon,\n} from '@wordpress/icons';\n\n/**\n * Internal dependencies\n */\nimport { store as blockEditorStore } from '../../store';\nimport { unlock } from '../../lock-unlock';\n\nconst getTransformCommands = () =>\n\tfunction useTransformCommands() {\n\t\tconst { replaceBlocks, multiSelect } = useDispatch( blockEditorStore );\n\t\tconst {\n\t\t\tblocks,\n\t\t\tclientIds,\n\t\t\tcanRemove,\n\t\t\tpossibleBlockTransformations,\n\t\t\tinvalidSelection,\n\t\t} = useSelect( ( select ) => {\n\t\t\tconst {\n\t\t\t\tgetBlockRootClientId,\n\t\t\t\tgetBlockTransformItems,\n\t\t\t\tgetSelectedBlockClientIds,\n\t\t\t\tgetBlocksByClientId,\n\t\t\t\tcanRemoveBlocks,\n\t\t\t} = select( blockEditorStore );\n\n\t\t\tconst selectedBlockClientIds = getSelectedBlockClientIds();\n\t\t\tconst selectedBlocks = getBlocksByClientId(\n\t\t\t\tselectedBlockClientIds\n\t\t\t);\n\n\t\t\t// selectedBlocks can have `null`s when something tries to call `selectBlock` with an inexistent clientId.\n\t\t\t// These nulls will cause fatal errors down the line.\n\t\t\t// In order to prevent discrepancies between selectedBlockClientIds and selectedBlocks, we effectively treat the entire selection as invalid.\n\t\t\t// @see https://github.com/WordPress/gutenberg/pull/59410#issuecomment-2006304536\n\t\t\tif ( selectedBlocks.filter( ( block ) => ! block ).length > 0 ) {\n\t\t\t\treturn {\n\t\t\t\t\tinvalidSelection: true,\n\t\t\t\t};\n\t\t\t}\n\n\t\t\tconst rootClientId = getBlockRootClientId(\n\t\t\t\tselectedBlockClientIds[ 0 ]\n\t\t\t);\n\t\t\treturn {\n\t\t\t\tblocks: selectedBlocks,\n\t\t\t\tclientIds: selectedBlockClientIds,\n\t\t\t\tpossibleBlockTransformations: getBlockTransformItems(\n\t\t\t\t\tselectedBlocks,\n\t\t\t\t\trootClientId\n\t\t\t\t),\n\t\t\t\tcanRemove: canRemoveBlocks( selectedBlockClientIds ),\n\t\t\t\tinvalidSelection: false,\n\t\t\t};\n\t\t}, [] );\n\n\t\tif ( invalidSelection ) {\n\t\t\treturn {\n\t\t\t\tisLoading: false,\n\t\t\t\tcommands: [],\n\t\t\t};\n\t\t}\n\t\tconst isTemplate = blocks.length === 1 && isTemplatePart( blocks[ 0 ] );\n\n\t\tfunction selectForMultipleBlocks( insertedBlocks ) {\n\t\t\tif ( insertedBlocks.length > 1 ) {\n\t\t\t\tmultiSelect(\n\t\t\t\t\tinsertedBlocks[ 0 ].clientId,\n\t\t\t\t\tinsertedBlocks[ insertedBlocks.length - 1 ].clientId\n\t\t\t\t);\n\t\t\t}\n\t\t}\n\n\t\t// Simple block transformation based on the `Block Transforms` API.\n\t\tfunction onBlockTransform( name, variationName ) {\n\t\t\tconst newBlocks = switchToBlockType( blocks, name, variationName );\n\t\t\treplaceBlocks( clientIds, newBlocks );\n\t\t\tselectForMultipleBlocks( newBlocks );\n\t\t}\n\n\t\t/**\n\t\t * The `isTemplate` check is a stopgap solution here.\n\t\t * Ideally, the Transforms API should handle this\n\t\t * by allowing to exclude blocks from wildcard transformations.\n\t\t */\n\t\tconst hasPossibleBlockTransformations =\n\t\t\t!! possibleBlockTransformations.length && canRemove && ! isTemplate;\n\n\t\tif (\n\t\t\t! clientIds ||\n\t\t\tclientIds.length < 1 ||\n\t\t\t! hasPossibleBlockTransformations\n\t\t) {\n\t\t\treturn { isLoading: false, commands: [] };\n\t\t}\n\n\t\tconst commands = possibleBlockTransformations.map(\n\t\t\t( transformation ) => {\n\t\t\t\tconst { id, name, title, icon, variationName } = transformation;\n\t\t\t\t/*\n\t\t\t\t * Command menu uses Icon from @wordpress/icons, which expects a ReactElement\n\t\t\t\t * (cloneElement). Normalize to blockDefaultIcon to avoid crash. See #55668 / PR #55676.\n\t\t\t\t */\n\t\t\t\tconst blockIcon =\n\t\t\t\t\t! icon?.src || icon?.src === 'block-default'\n\t\t\t\t\t\t? {\n\t\t\t\t\t\t\t\tsrc: blockDefaultIcon,\n\t\t\t\t\t\t }\n\t\t\t\t\t\t: icon;\n\n\t\t\t\treturn {\n\t\t\t\t\tname:\n\t\t\t\t\t\t'core/block-editor/transform-to-' +\n\t\t\t\t\t\t( id || name ).replace( /\\//g, '-' ),\n\t\t\t\t\t/* translators: %s: Block or block variation name. */\n\t\t\t\t\tlabel: sprintf( __( 'Transform to %s' ), title ),\n\t\t\t\t\ticon: blockIcon?.src,\n\t\t\t\t\tcategory: 'command',\n\t\t\t\t\tcallback: ( { close } ) => {\n\t\t\t\t\t\tonBlockTransform( name, variationName );\n\t\t\t\t\t\tclose();\n\t\t\t\t\t},\n\t\t\t\t};\n\t\t\t}\n\t\t);\n\n\t\treturn { isLoading: false, commands };\n\t};\n\nconst getQuickActionsCommands = () =>\n\tfunction useQuickActionsCommands() {\n\t\tconst {\n\t\t\tclientIds,\n\t\t\tisUngroupable,\n\t\t\tisGroupable,\n\t\t\tblockVisibilitySetting,\n\t\t} = useSelect( ( select ) => {\n\t\t\tconst {\n\t\t\t\tgetSelectedBlockClientIds,\n\t\t\t\tgetSettings,\n\t\t\t\tisUngroupable: _isUngroupable,\n\t\t\t\tisGroupable: _isGroupable,\n\t\t\t} = select( blockEditorStore );\n\t\t\tconst selectedBlockClientIds = getSelectedBlockClientIds();\n\n\t\t\treturn {\n\t\t\t\tclientIds: selectedBlockClientIds,\n\t\t\t\tisUngroupable: _isUngroupable(),\n\t\t\t\tisGroupable: _isGroupable(),\n\t\t\t\tblockVisibilitySetting:\n\t\t\t\t\tgetSettings().__experimentalFeatures?.blockVisibility\n\t\t\t\t\t\t?.allowEditing,\n\t\t\t};\n\t\t}, [] );\n\t\tconst {\n\t\t\tcanInsertBlockType,\n\t\t\tgetBlockRootClientId,\n\t\t\tgetBlocksByClientId,\n\t\t\tcanRemoveBlocks,\n\t\t\tisBlockHiddenAnywhere,\n\t\t} = unlock( useSelect( blockEditorStore ) );\n\t\tconst { getBlockEditingMode } = useSelect( blockEditorStore );\n\t\tconst { getDefaultBlockName, getGroupingBlockName } =\n\t\t\tuseSelect( blocksStore );\n\n\t\tconst blocks = getBlocksByClientId( clientIds );\n\n\t\tconst blockEditorDispatch = useDispatch( blockEditorStore );\n\t\tconst {\n\t\t\tremoveBlocks,\n\t\t\treplaceBlocks,\n\t\t\tduplicateBlocks,\n\t\t\tinsertAfterBlock,\n\t\t\tinsertBeforeBlock,\n\t\t} = blockEditorDispatch;\n\n\t\tconst onGroup = () => {\n\t\t\tif ( ! blocks.length ) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tconst groupingBlockName = getGroupingBlockName();\n\n\t\t\t// Activate the `transform` on `core/group` which does the conversion.\n\t\t\tconst newBlocks = switchToBlockType( blocks, groupingBlockName );\n\n\t\t\tif ( ! newBlocks ) {\n\t\t\t\treturn;\n\t\t\t}\n\t\t\treplaceBlocks( clientIds, newBlocks );\n\t\t};\n\t\tconst onUngroup = () => {\n\t\t\tif ( ! blocks.length ) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tconst innerBlocks = blocks[ 0 ].innerBlocks;\n\n\t\t\tif ( ! innerBlocks.length ) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\treplaceBlocks( clientIds, innerBlocks );\n\t\t};\n\n\t\tif ( ! clientIds || clientIds.length < 1 ) {\n\t\t\treturn { isLoading: false, commands: [] };\n\t\t}\n\n\t\tconst { showViewportModal } = unlock( blockEditorDispatch );\n\t\tconst rootClientId = getBlockRootClientId( clientIds[ 0 ] );\n\t\tconst canInsertDefaultBlock = canInsertBlockType(\n\t\t\tgetDefaultBlockName(),\n\t\t\trootClientId\n\t\t);\n\t\tconst canDuplicate = blocks.every( ( block ) => {\n\t\t\treturn (\n\t\t\t\t!! block &&\n\t\t\t\thasBlockSupport( block.name, 'multiple', true ) &&\n\t\t\t\tcanInsertBlockType( block.name, rootClientId )\n\t\t\t);\n\t\t} );\n\t\tconst canRemove = canRemoveBlocks( clientIds );\n\n\t\tconst commands = [];\n\n\t\tif ( canDuplicate ) {\n\t\t\tcommands.push( {\n\t\t\t\tname: 'duplicate',\n\t\t\t\tlabel: __( 'Duplicate' ),\n\t\t\t\tcallback: () => duplicateBlocks( clientIds, true ),\n\t\t\t\ticon: copy,\n\t\t\t} );\n\t\t}\n\n\t\tif ( canInsertDefaultBlock ) {\n\t\t\tcommands.push(\n\t\t\t\t{\n\t\t\t\t\tname: 'add-before',\n\t\t\t\t\tlabel: __( 'Add before' ),\n\t\t\t\t\tcallback: () => {\n\t\t\t\t\t\tconst clientId = Array.isArray( clientIds )\n\t\t\t\t\t\t\t? clientIds[ 0 ]\n\t\t\t\t\t\t\t: clientId;\n\t\t\t\t\t\tinsertBeforeBlock( clientId );\n\t\t\t\t\t},\n\t\t\t\t\ticon: add,\n\t\t\t\t},\n\t\t\t\t{\n\t\t\t\t\tname: 'add-after',\n\t\t\t\t\tlabel: __( 'Add after' ),\n\t\t\t\t\tcallback: () => {\n\t\t\t\t\t\tconst clientId = Array.isArray( clientIds )\n\t\t\t\t\t\t\t? clientIds[ clientIds.length - 1 ]\n\t\t\t\t\t\t\t: clientId;\n\t\t\t\t\t\tinsertAfterBlock( clientId );\n\t\t\t\t\t},\n\t\t\t\t\ticon: add,\n\t\t\t\t}\n\t\t\t);\n\t\t}\n\n\t\tif ( isGroupable ) {\n\t\t\tcommands.push( {\n\t\t\t\tname: 'Group',\n\t\t\t\tlabel: __( 'Group' ),\n\t\t\t\tcallback: onGroup,\n\t\t\t\ticon: group,\n\t\t\t} );\n\t\t}\n\n\t\tif ( isUngroupable ) {\n\t\t\tcommands.push( {\n\t\t\t\tname: 'ungroup',\n\t\t\t\tlabel: __( 'Ungroup' ),\n\t\t\t\tcallback: onUngroup,\n\t\t\t\ticon: ungroup,\n\t\t\t} );\n\t\t}\n\n\t\tif ( canRemove ) {\n\t\t\tcommands.push( {\n\t\t\t\tname: 'remove',\n\t\t\t\tlabel: __( 'Delete' ),\n\t\t\t\tcallback: () => removeBlocks( clientIds, true ),\n\t\t\t\ticon: remove,\n\t\t\t} );\n\t\t}\n\n\t\tconst supportsVisibility = blocks.every(\n\t\t\t( block ) =>\n\t\t\t\t!! block && hasBlockSupport( block.name, 'visibility', true )\n\t\t);\n\t\tconst allBlocksDefaultMode = clientIds.every(\n\t\t\t( id ) => getBlockEditingMode( id ) === 'default'\n\t\t);\n\n\t\tif (\n\t\t\tsupportsVisibility &&\n\t\t\tallBlocksDefaultMode &&\n\t\t\tblockVisibilitySetting !== false\n\t\t) {\n\t\t\tconst hasHiddenBlock = clientIds.some( ( id ) =>\n\t\t\t\tisBlockHiddenAnywhere( id )\n\t\t\t);\n\t\t\tcommands.push( {\n\t\t\t\tname: 'toggle-visibility',\n\t\t\t\tlabel: hasHiddenBlock ? __( 'Show' ) : __( 'Hide' ),\n\t\t\t\tcallback: () => showViewportModal( clientIds ),\n\t\t\t\ticon: hasHiddenBlock ? seen : unseen,\n\t\t\t} );\n\t\t}\n\n\t\treturn {\n\t\t\tisLoading: false,\n\t\t\tcommands: commands.map( ( command ) => ( {\n\t\t\t\t...command,\n\t\t\t\tname: 'core/block-editor/action-' + command.name,\n\t\t\t\tcategory: 'command',\n\t\t\t\tcallback: ( { close } ) => {\n\t\t\t\t\tcommand.callback();\n\t\t\t\t\tclose();\n\t\t\t\t},\n\t\t\t} ) ),\n\t\t};\n\t};\n\nexport const useBlockCommands = () => {\n\tuseCommandLoader( {\n\t\tname: 'core/block-editor/blockTransforms',\n\t\thook: getTransformCommands(),\n\t} );\n\tuseCommandLoader( {\n\t\tname: 'core/block-editor/blockQuickActions',\n\t\thook: getQuickActionsCommands(),\n\t\tcontext: 'block-selection-edit',\n\t} );\n};\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAGA,kBAA4B;AAC5B,oBAKO;AACP,kBAAuC;AACvC,sBAAiC;AACj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AAK;AAAA,EAC9D;AACA,QAAM,uBAAuB,UAAU;AAAA,IACtC,CAAE,OAAQ,oBAAqB,EAAG,MAAM;AAAA,EACzC;AAEA,MACC,sBACA,wBACA,2BAA2B,OAC1B;AACD,UAAM,iBAAiB,UAAU;AAAA,MAAM,CAAE,OACxC,sBAAuB,EAAG;AAAA,IAC3B;AACA,aAAS,KAAM;AAAA,MACd,MAAM;AAAA,MACN,OAAO,qBAAiB,gBAAI,MAAO,QAAI,gBAAI,MAAO;AAAA,MAClD,UAAU,MAAM,kBAAmB,SAAU;AAAA,MAC7C,MAAM,iBAAiB,oBAAO;AAAA,IAC/B,CAAE;AAAA,EACH;AAEA,SAAO;AAAA,IACN,WAAW;AAAA,IACX,UAAU,SAAS,IAAK,CAAE,aAAe;AAAA,MACxC,GAAG;AAAA,MACH,MAAM,8BAA8B,QAAQ;AAAA,MAC5C,UAAU;AAAA,MACV,UAAU,CAAE,EAAE,MAAM,MAAO;AAC1B,gBAAQ,SAAS;AACjB,cAAM;AAAA,MACP;AAAA,IACD,EAAI;AAAA,EACL;AACD;AAEM,IAAM,mBAAmB,MAAM;AACrC,wCAAkB;AAAA,IACjB,MAAM;AAAA,IACN,MAAM,qBAAqB;AAAA,EAC5B,CAAE;AACF,wCAAkB;AAAA,IACjB,MAAM;AAAA,IACN,MAAM,wBAAwB;AAAA,IAC9B,SAAS;AAAA,EACV,CAAE;AACH;",
|
|
6
6
|
"names": ["blockEditorStore", "blockDefaultIcon", "blocksStore", "add", "remove"]
|
|
7
7
|
}
|
|
@@ -29,7 +29,6 @@ var import_i18n = require("@wordpress/i18n");
|
|
|
29
29
|
var import_icons = require("@wordpress/icons");
|
|
30
30
|
var import_store = require("../../store/index.cjs");
|
|
31
31
|
var import_lock_unlock = require("../../lock-unlock.cjs");
|
|
32
|
-
var import_private_keys = require("../../store/private-keys.cjs");
|
|
33
32
|
function getPositionTypeLabel(attributes) {
|
|
34
33
|
const positionType = attributes?.style?.position?.type;
|
|
35
34
|
if (positionType === "sticky") {
|
|
@@ -50,8 +49,8 @@ function useBlockDisplayInformation(clientId) {
|
|
|
50
49
|
const {
|
|
51
50
|
getBlockName,
|
|
52
51
|
getBlockAttributes,
|
|
53
|
-
|
|
54
|
-
|
|
52
|
+
getBlock,
|
|
53
|
+
__experimentalGetParsedPattern
|
|
55
54
|
} = blockEditorSelect;
|
|
56
55
|
const { getBlockType, getActiveBlockVariation } = select(import_blocks.store);
|
|
57
56
|
const blockName = getBlockName(clientId);
|
|
@@ -60,11 +59,9 @@ function useBlockDisplayInformation(clientId) {
|
|
|
60
59
|
return null;
|
|
61
60
|
}
|
|
62
61
|
const attributes = getBlockAttributes(clientId);
|
|
63
|
-
const {
|
|
64
|
-
const isIsolatedEditor = !!getSettings()?.[import_private_keys.isIsolatedEditorKey];
|
|
62
|
+
const { isSectionBlock } = (0, import_lock_unlock.unlock)(blockEditorSelect);
|
|
65
63
|
const patternName = attributes?.metadata?.patternName;
|
|
66
|
-
|
|
67
|
-
if (patternName && !isEditedContentOnlySection && !isIsolatedEditor) {
|
|
64
|
+
if (patternName && isSectionBlock(clientId)) {
|
|
68
65
|
const pattern = __experimentalGetParsedPattern(patternName);
|
|
69
66
|
const positionLabel2 = getPositionTypeLabel(attributes);
|
|
70
67
|
return {
|
|
@@ -78,7 +75,12 @@ function useBlockDisplayInformation(clientId) {
|
|
|
78
75
|
name: pattern?.title || attributes?.metadata?.name
|
|
79
76
|
};
|
|
80
77
|
}
|
|
81
|
-
const match = getActiveBlockVariation(
|
|
78
|
+
const match = getActiveBlockVariation(
|
|
79
|
+
blockName,
|
|
80
|
+
attributes,
|
|
81
|
+
void 0,
|
|
82
|
+
getBlock?.(clientId)?.innerContent
|
|
83
|
+
);
|
|
82
84
|
const isSynced = (0, import_blocks.isReusableBlock)(blockType) || (0, import_blocks.isTemplatePart)(blockType);
|
|
83
85
|
const syncedTitle = isSynced ? (0, import_blocks.__experimentalGetBlockLabel)(blockType, attributes) : void 0;
|
|
84
86
|
const title = syncedTitle || blockType.title;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../src/components/use-block-display-information/index.js"],
|
|
4
|
-
"sourcesContent": ["/**\n * WordPress dependencies\n */\nimport { useSelect } from '@wordpress/data';\nimport {\n\tstore as blocksStore,\n\tisReusableBlock,\n\tisTemplatePart,\n\t__experimentalGetBlockLabel as getBlockLabel,\n} from '@wordpress/blocks';\nimport { __ } from '@wordpress/i18n';\nimport { symbol } from '@wordpress/icons';\n\n/**\n * Internal dependencies\n */\nimport { store as blockEditorStore } from '../../store';\nimport { unlock } from '../../lock-unlock';\
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAGA,kBAA0B;AAC1B,oBAKO;AACP,kBAAmB;AACnB,mBAAuB;AAKvB,mBAA0C;AAC1C,yBAAuB;
|
|
4
|
+
"sourcesContent": ["/**\n * WordPress dependencies\n */\nimport { useSelect } from '@wordpress/data';\nimport {\n\tstore as blocksStore,\n\tisReusableBlock,\n\tisTemplatePart,\n\t__experimentalGetBlockLabel as getBlockLabel,\n} from '@wordpress/blocks';\nimport { __ } from '@wordpress/i18n';\nimport { symbol } from '@wordpress/icons';\n\n/**\n * Internal dependencies\n */\nimport { store as blockEditorStore } from '../../store';\nimport { unlock } from '../../lock-unlock';\n\n/** @typedef {import('@wordpress/blocks').WPIcon} WPIcon */\n\n/**\n * Contains basic block's information for display reasons.\n *\n * @typedef {Object} WPBlockDisplayInformation\n *\n * @property {boolean} isSynced True if is a reusable block or template part\n * @property {string} title Human-readable block type label.\n * @property {WPIcon} icon Block type icon.\n * @property {string} description A detailed block type description.\n * @property {string} anchor HTML anchor.\n * @property {name} name A custom, human readable name for the block.\n */\n\n/**\n * Get the display label for a block's position type.\n *\n * @param {Object} attributes Block attributes.\n * @return {string} The position type label.\n */\nfunction getPositionTypeLabel( attributes ) {\n\tconst positionType = attributes?.style?.position?.type;\n\n\tif ( positionType === 'sticky' ) {\n\t\treturn __( 'Sticky' );\n\t}\n\n\tif ( positionType === 'fixed' ) {\n\t\treturn __( 'Fixed' );\n\t}\n\n\treturn null;\n}\n\n/**\n * Hook used to try to find a matching block variation and return\n * the appropriate information for display reasons. In order to\n * to try to find a match we need to things:\n * 1. Block's client id to extract it's current attributes.\n * 2. A block variation should have set `isActive` prop to a proper function.\n *\n * If for any reason a block variation match cannot be found,\n * the returned information come from the Block Type.\n * If no blockType is found with the provided clientId, returns null.\n *\n * @param {string} clientId Block's client id.\n * @return {?WPBlockDisplayInformation} Block's display information, or `null` when the block or its type not found.\n */\n\nexport default function useBlockDisplayInformation( clientId ) {\n\treturn useSelect(\n\t\t( select ) => {\n\t\t\tif ( ! clientId ) {\n\t\t\t\treturn null;\n\t\t\t}\n\t\t\tconst blockEditorSelect = select( blockEditorStore );\n\t\t\tconst {\n\t\t\t\tgetBlockName,\n\t\t\t\tgetBlockAttributes,\n\t\t\t\tgetBlock,\n\t\t\t\t__experimentalGetParsedPattern,\n\t\t\t} = blockEditorSelect;\n\t\t\tconst { getBlockType, getActiveBlockVariation } =\n\t\t\t\tselect( blocksStore );\n\t\t\tconst blockName = getBlockName( clientId );\n\t\t\tconst blockType = getBlockType( blockName );\n\t\t\tif ( ! blockType ) {\n\t\t\t\treturn null;\n\t\t\t}\n\t\t\tconst attributes = getBlockAttributes( clientId );\n\t\t\tconst { isSectionBlock } = unlock( blockEditorSelect );\n\n\t\t\t// Check if this block is a pattern\n\t\t\tconst patternName = attributes?.metadata?.patternName;\n\n\t\t\tif ( patternName && isSectionBlock( clientId ) ) {\n\t\t\t\tconst pattern = __experimentalGetParsedPattern( patternName );\n\t\t\t\tconst positionLabel = getPositionTypeLabel( attributes );\n\t\t\t\treturn {\n\t\t\t\t\tisSynced: false,\n\t\t\t\t\ttitle: __( 'Pattern' ),\n\t\t\t\t\ticon: symbol,\n\t\t\t\t\tdescription:\n\t\t\t\t\t\tpattern?.description || __( 'A block pattern.' ),\n\t\t\t\t\tanchor: attributes?.anchor,\n\t\t\t\t\tpositionLabel,\n\t\t\t\t\tpositionType: attributes?.style?.position?.type,\n\t\t\t\t\tname: pattern?.title || attributes?.metadata?.name,\n\t\t\t\t};\n\t\t\t}\n\n\t\t\tconst match = getActiveBlockVariation(\n\t\t\t\tblockName,\n\t\t\t\tattributes,\n\t\t\t\tundefined,\n\t\t\t\tgetBlock?.( clientId )?.innerContent\n\t\t\t);\n\t\t\tconst isSynced =\n\t\t\t\tisReusableBlock( blockType ) || isTemplatePart( blockType );\n\t\t\tconst syncedTitle = isSynced\n\t\t\t\t? getBlockLabel( blockType, attributes )\n\t\t\t\t: undefined;\n\t\t\tconst title = syncedTitle || blockType.title;\n\t\t\tconst positionLabel = getPositionTypeLabel( attributes );\n\t\t\tconst blockTypeInfo = {\n\t\t\t\tisSynced,\n\t\t\t\ttitle,\n\t\t\t\ticon: blockType.icon,\n\t\t\t\tdescription: blockType.description,\n\t\t\t\tanchor: attributes?.anchor,\n\t\t\t\tpositionLabel,\n\t\t\t\tpositionType: attributes?.style?.position?.type,\n\t\t\t\tname: attributes?.metadata?.name,\n\t\t\t};\n\t\t\tif ( ! match ) {\n\t\t\t\treturn blockTypeInfo;\n\t\t\t}\n\n\t\t\treturn {\n\t\t\t\tisSynced,\n\t\t\t\ttitle: match.title || blockType.title,\n\t\t\t\ticon: match.icon || blockType.icon,\n\t\t\t\tdescription: match.description || blockType.description,\n\t\t\t\tanchor: attributes?.anchor,\n\t\t\t\tpositionLabel,\n\t\t\t\tpositionType: attributes?.style?.position?.type,\n\t\t\t\tname: attributes?.metadata?.name,\n\t\t\t};\n\t\t},\n\t\t[ clientId ]\n\t);\n}\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAGA,kBAA0B;AAC1B,oBAKO;AACP,kBAAmB;AACnB,mBAAuB;AAKvB,mBAA0C;AAC1C,yBAAuB;AAuBvB,S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AAM,cAAc,eACjB,cAAAC,6BAAe,WAAW,UAAW,IACrC;AACH,YAAM,QAAQ,eAAe,UAAU;AACvC,YAAM,gBAAgB,qBAAsB,UAAW;AACvD,YAAM,gBAAgB;AAAA,QACrB;AAAA,QACA;AAAA,QACA,MAAM,UAAU;AAAA,QAChB,aAAa,UAAU;AAAA,QACvB,QAAQ,YAAY;AAAA,QACpB;AAAA,QACA,cAAc,YAAY,OAAO,UAAU;AAAA,QAC3C,MAAM,YAAY,UAAU;AAAA,MAC7B;AACA,UAAK,CAAE,OAAQ;AACd,eAAO;AAAA,MACR;AAEA,aAAO;AAAA,QACN;AAAA,QACA,OAAO,MAAM,SAAS,UAAU;AAAA,QAChC,MAAM,MAAM,QAAQ,UAAU;AAAA,QAC9B,aAAa,MAAM,eAAe,UAAU;AAAA,QAC5C,QAAQ,YAAY;AAAA,QACpB;AAAA,QACA,cAAc,YAAY,OAAO,UAAU;AAAA,QAC3C,MAAM,YAAY,UAAU;AAAA,MAC7B;AAAA,IACD;AAAA,IACA,CAAE,QAAS;AAAA,EACZ;AACD;",
|
|
6
6
|
"names": ["blockEditorStore", "blocksStore", "positionLabel", "getBlockLabel"]
|
|
7
7
|
}
|
|
@@ -160,13 +160,9 @@ function useOnBlockDrop(targetRootClientId, targetBlockIndex, options = {}) {
|
|
|
160
160
|
} else {
|
|
161
161
|
blocks.unshift(targetBlock);
|
|
162
162
|
}
|
|
163
|
-
const groupInnerBlocks = blocks.map(
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
block.attributes,
|
|
167
|
-
block.innerBlocks
|
|
168
|
-
);
|
|
169
|
-
});
|
|
163
|
+
const groupInnerBlocks = blocks.map(
|
|
164
|
+
(block) => (0, import_blocks.cloneSanitizedBlock)(block)
|
|
165
|
+
);
|
|
170
166
|
const areAllImages = blocks.every((block) => {
|
|
171
167
|
return block.name === "core/image";
|
|
172
168
|
});
|