@wordpress/block-editor 8.4.0 → 8.5.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +2 -0
- package/README.md +56 -19
- package/build/components/alignment-control/index.js +13 -6
- package/build/components/alignment-control/index.js.map +1 -1
- package/build/components/block-alignment-control/index.js +13 -6
- package/build/components/block-alignment-control/index.js.map +1 -1
- package/build/components/block-alignment-control/ui.js +1 -1
- package/build/components/block-alignment-control/ui.js.map +1 -1
- package/build/components/block-content-overlay/index.js +13 -4
- package/build/components/block-content-overlay/index.js.map +1 -1
- package/build/components/block-draggable/index.js +2 -3
- package/build/components/block-draggable/index.js.map +1 -1
- package/build/components/block-icon/index.js +4 -0
- package/build/components/block-icon/index.js.map +1 -1
- package/build/components/block-inspector/index.js +6 -1
- package/build/components/block-inspector/index.js.map +1 -1
- package/build/components/block-list/use-block-props/index.js +1 -6
- package/build/components/block-list/use-block-props/index.js.map +1 -1
- package/build/components/block-list/use-block-props/use-focus-first-element.js +14 -17
- package/build/components/block-list/use-block-props/use-focus-first-element.js.map +1 -1
- package/build/components/block-list/use-block-props/use-focus-handler.js +7 -1
- package/build/components/block-list/use-block-props/use-focus-handler.js.map +1 -1
- package/build/components/block-list-appender/index.js +6 -1
- package/build/components/block-list-appender/index.js.map +1 -1
- package/build/components/block-lock/index.js +8 -0
- package/build/components/block-lock/index.js.map +1 -1
- package/build/components/block-lock/menu-item.js +9 -15
- package/build/components/block-lock/menu-item.js.map +1 -1
- package/build/components/block-lock/modal.js +35 -23
- package/build/components/block-lock/modal.js.map +1 -1
- package/build/components/block-lock/toolbar.js +11 -16
- package/build/components/block-lock/toolbar.js.map +1 -1
- package/build/components/block-lock/use-block-lock.js +50 -0
- package/build/components/block-lock/use-block-lock.js.map +1 -0
- package/build/components/block-mover/index.js +4 -0
- package/build/components/block-mover/index.js.map +1 -1
- package/build/components/block-pattern-setup/index.js +37 -22
- package/build/components/block-pattern-setup/index.js.map +1 -1
- package/build/components/block-pattern-setup/setup-toolbar.js +1 -1
- package/build/components/block-pattern-setup/setup-toolbar.js.map +1 -1
- package/build/components/block-preview/auto.js +6 -3
- package/build/components/block-preview/auto.js.map +1 -1
- package/build/components/block-preview/index.js +4 -2
- package/build/components/block-preview/index.js.map +1 -1
- package/build/components/block-settings-menu/block-settings-dropdown.js +50 -5
- package/build/components/block-settings-menu/block-settings-dropdown.js.map +1 -1
- package/build/components/block-switcher/index.js +8 -3
- package/build/components/block-switcher/index.js.map +1 -1
- package/build/components/block-title/index.js +2 -2
- package/build/components/block-title/index.js.map +1 -1
- package/build/components/block-title/use-block-display-title.js +1 -1
- package/build/components/block-title/use-block-display-title.js.map +1 -1
- package/build/components/block-toolbar/block-name-context.js +17 -0
- package/build/components/block-toolbar/block-name-context.js.map +1 -0
- package/build/components/block-toolbar/block-toolbar-last-item.js +20 -0
- package/build/components/block-toolbar/block-toolbar-last-item.js.map +1 -0
- package/build/components/block-toolbar/index.js +20 -5
- package/build/components/block-toolbar/index.js.map +1 -1
- package/build/components/block-tools/index.js +0 -16
- package/build/components/block-tools/index.js.map +1 -1
- package/build/components/block-variation-transforms/index.js +92 -47
- package/build/components/block-variation-transforms/index.js.map +1 -1
- package/build/components/block-vertical-alignment-control/index.js +13 -6
- package/build/components/block-vertical-alignment-control/index.js.map +1 -1
- package/build/components/contrast-checker/index.js +4 -0
- package/build/components/contrast-checker/index.js.map +1 -1
- package/build/components/convert-to-group-buttons/index.js +8 -0
- package/build/components/convert-to-group-buttons/index.js.map +1 -1
- package/build/components/convert-to-group-buttons/toolbar.js +105 -0
- package/build/components/convert-to-group-buttons/toolbar.js.map +1 -0
- package/build/components/copy-handler/index.js +48 -9
- package/build/components/copy-handler/index.js.map +1 -1
- package/build/components/font-sizes/font-size-picker.js +4 -0
- package/build/components/font-sizes/font-size-picker.js.map +1 -1
- package/build/components/iframe/index.js +6 -9
- package/build/components/iframe/index.js.map +1 -1
- package/build/components/index.js +18 -0
- package/build/components/index.js.map +1 -1
- package/build/components/justify-content-control/index.js +13 -6
- package/build/components/justify-content-control/index.js.map +1 -1
- package/build/components/keyboard-shortcuts/index.js +1 -1
- package/build/components/keyboard-shortcuts/index.js.map +1 -1
- package/build/components/line-height-control/index.js +10 -3
- package/build/components/line-height-control/index.js.map +1 -1
- package/build/components/link-control/index.js +6 -7
- package/build/components/link-control/index.js.map +1 -1
- package/build/components/list-view/block-select-button.js +19 -6
- package/build/components/list-view/block-select-button.js.map +1 -1
- package/build/components/list-view/block.js +18 -3
- package/build/components/list-view/block.js.map +1 -1
- package/build/components/list-view/branch.js +1 -1
- package/build/components/list-view/branch.js.map +1 -1
- package/build/components/media-replace-flow/index.js +4 -0
- package/build/components/media-replace-flow/index.js.map +1 -1
- package/build/components/multi-selection-inspector/index.js +1 -1
- package/build/components/multi-selection-inspector/index.js.map +1 -1
- package/build/components/rich-text/index.js +26 -4
- package/build/components/rich-text/index.js.map +1 -1
- package/build/components/rich-text/split-value.js +12 -2
- package/build/components/rich-text/split-value.js.map +1 -1
- package/build/components/rich-text/use-firefox-compat.js +49 -0
- package/build/components/rich-text/use-firefox-compat.js.map +1 -0
- package/build/components/rich-text/use-input-rules.js +34 -2
- package/build/components/rich-text/use-input-rules.js.map +1 -1
- package/build/components/skip-to-selected-block/index.js +4 -0
- package/build/components/skip-to-selected-block/index.js.map +1 -1
- package/build/components/writing-flow/index.js +9 -1
- package/build/components/writing-flow/index.js.map +1 -1
- package/build/components/writing-flow/use-arrow-nav.js +3 -44
- package/build/components/writing-flow/use-arrow-nav.js.map +1 -1
- package/build/components/writing-flow/use-click-selection.js +68 -0
- package/build/components/writing-flow/use-click-selection.js.map +1 -0
- package/build/components/writing-flow/use-drag-selection.js +134 -0
- package/build/components/writing-flow/use-drag-selection.js.map +1 -0
- package/build/components/writing-flow/use-input.js +116 -0
- package/build/components/writing-flow/use-input.js.map +1 -0
- package/build/components/writing-flow/use-multi-selection.js +18 -38
- package/build/components/writing-flow/use-multi-selection.js.map +1 -1
- package/build/components/writing-flow/use-selection-observer.js +161 -0
- package/build/components/writing-flow/use-selection-observer.js.map +1 -0
- package/build/components/writing-flow/use-tab-nav.js +1 -8
- package/build/components/writing-flow/use-tab-nav.js.map +1 -1
- package/build/hooks/border-color.js +3 -3
- package/build/hooks/border-color.js.map +1 -1
- package/build/hooks/border.js +0 -14
- package/build/hooks/border.js.map +1 -1
- package/build/hooks/color.js +20 -17
- package/build/hooks/color.js.map +1 -1
- package/build/hooks/font-family.js +5 -1
- package/build/hooks/font-family.js.map +1 -1
- package/build/hooks/font-size.js +4 -2
- package/build/hooks/font-size.js.map +1 -1
- package/build/hooks/gap.js +23 -16
- package/build/hooks/gap.js.map +1 -1
- package/build/hooks/layout.js +7 -2
- package/build/hooks/layout.js.map +1 -1
- package/build/hooks/style.js +34 -3
- package/build/hooks/style.js.map +1 -1
- package/build/hooks/utils.js +29 -0
- package/build/hooks/utils.js.map +1 -1
- package/build/layouts/flex.js +76 -12
- package/build/layouts/flex.js.map +1 -1
- package/build/layouts/flow.js +9 -4
- package/build/layouts/flow.js.map +1 -1
- package/build/store/actions.js +290 -51
- package/build/store/actions.js.map +1 -1
- package/build/store/defaults.js +5 -2
- package/build/store/defaults.js.map +1 -1
- package/build/store/reducer.js +25 -13
- package/build/store/reducer.js.map +1 -1
- package/build/store/selectors.js +264 -21
- package/build/store/selectors.js.map +1 -1
- package/build/store/utils.js +27 -0
- package/build/store/utils.js.map +1 -0
- package/build/utils/dom.js +2 -1
- package/build/utils/dom.js.map +1 -1
- package/build-module/components/alignment-control/index.js +12 -4
- package/build-module/components/alignment-control/index.js.map +1 -1
- package/build-module/components/block-alignment-control/index.js +12 -4
- package/build-module/components/block-alignment-control/index.js.map +1 -1
- package/build-module/components/block-alignment-control/ui.js +2 -2
- package/build-module/components/block-alignment-control/ui.js.map +1 -1
- package/build-module/components/block-content-overlay/index.js +13 -4
- package/build-module/components/block-content-overlay/index.js.map +1 -1
- package/build-module/components/block-draggable/index.js +2 -3
- package/build-module/components/block-draggable/index.js.map +1 -1
- package/build-module/components/block-icon/index.js +4 -0
- package/build-module/components/block-icon/index.js.map +1 -1
- package/build-module/components/block-inspector/index.js +6 -1
- package/build-module/components/block-inspector/index.js.map +1 -1
- package/build-module/components/block-list/use-block-props/index.js +1 -4
- package/build-module/components/block-list/use-block-props/index.js.map +1 -1
- package/build-module/components/block-list/use-block-props/use-focus-first-element.js +15 -17
- package/build-module/components/block-list/use-block-props/use-focus-first-element.js.map +1 -1
- package/build-module/components/block-list/use-block-props/use-focus-handler.js +7 -1
- package/build-module/components/block-list/use-block-props/use-focus-handler.js.map +1 -1
- package/build-module/components/block-list-appender/index.js +6 -1
- package/build-module/components/block-list-appender/index.js.map +1 -1
- package/build-module/components/block-lock/index.js +1 -0
- package/build-module/components/block-lock/index.js.map +1 -1
- package/build-module/components/block-lock/menu-item.js +8 -13
- package/build-module/components/block-lock/menu-item.js.map +1 -1
- package/build-module/components/block-lock/modal.js +34 -24
- package/build-module/components/block-lock/modal.js.map +1 -1
- package/build-module/components/block-lock/toolbar.js +10 -14
- package/build-module/components/block-lock/toolbar.js.map +1 -1
- package/build-module/components/block-lock/use-block-lock.js +41 -0
- package/build-module/components/block-lock/use-block-lock.js.map +1 -0
- package/build-module/components/block-mover/index.js +4 -0
- package/build-module/components/block-mover/index.js.map +1 -1
- package/build-module/components/block-pattern-setup/index.js +39 -24
- package/build-module/components/block-pattern-setup/index.js.map +1 -1
- package/build-module/components/block-pattern-setup/setup-toolbar.js +1 -1
- package/build-module/components/block-pattern-setup/setup-toolbar.js.map +1 -1
- package/build-module/components/block-preview/auto.js +6 -3
- package/build-module/components/block-preview/auto.js.map +1 -1
- package/build-module/components/block-preview/index.js +4 -2
- package/build-module/components/block-preview/index.js.map +1 -1
- package/build-module/components/block-settings-menu/block-settings-dropdown.js +50 -7
- package/build-module/components/block-settings-menu/block-settings-dropdown.js.map +1 -1
- package/build-module/components/block-switcher/index.js +9 -4
- package/build-module/components/block-switcher/index.js.map +1 -1
- package/build-module/components/block-title/index.js +2 -2
- package/build-module/components/block-title/index.js.map +1 -1
- package/build-module/components/block-title/use-block-display-title.js +1 -1
- package/build-module/components/block-title/use-block-display-title.js.map +1 -1
- package/build-module/components/block-toolbar/block-name-context.js +9 -0
- package/build-module/components/block-toolbar/block-name-context.js.map +1 -0
- package/build-module/components/block-toolbar/block-toolbar-last-item.js +11 -0
- package/build-module/components/block-toolbar/block-toolbar-last-item.js.map +1 -0
- package/build-module/components/block-toolbar/index.js +16 -4
- package/build-module/components/block-toolbar/index.js.map +1 -1
- package/build-module/components/block-tools/index.js +0 -16
- package/build-module/components/block-tools/index.js.map +1 -1
- package/build-module/components/block-variation-transforms/index.js +95 -49
- package/build-module/components/block-variation-transforms/index.js.map +1 -1
- package/build-module/components/block-vertical-alignment-control/index.js +12 -4
- package/build-module/components/block-vertical-alignment-control/index.js.map +1 -1
- package/build-module/components/contrast-checker/index.js +4 -0
- package/build-module/components/contrast-checker/index.js.map +1 -1
- package/build-module/components/convert-to-group-buttons/index.js +2 -1
- package/build-module/components/convert-to-group-buttons/index.js.map +1 -1
- package/build-module/components/convert-to-group-buttons/toolbar.js +90 -0
- package/build-module/components/convert-to-group-buttons/toolbar.js.map +1 -0
- package/build-module/components/copy-handler/index.js +48 -9
- package/build-module/components/copy-handler/index.js.map +1 -1
- package/build-module/components/font-sizes/font-size-picker.js +4 -0
- package/build-module/components/font-sizes/font-size-picker.js.map +1 -1
- package/build-module/components/iframe/index.js +6 -9
- package/build-module/components/iframe/index.js.map +1 -1
- package/build-module/components/index.js +2 -0
- package/build-module/components/index.js.map +1 -1
- package/build-module/components/justify-content-control/index.js +12 -4
- package/build-module/components/justify-content-control/index.js.map +1 -1
- package/build-module/components/keyboard-shortcuts/index.js +1 -1
- package/build-module/components/keyboard-shortcuts/index.js.map +1 -1
- package/build-module/components/line-height-control/index.js +9 -2
- package/build-module/components/line-height-control/index.js.map +1 -1
- package/build-module/components/link-control/index.js +6 -7
- package/build-module/components/link-control/index.js.map +1 -1
- package/build-module/components/list-view/block-select-button.js +17 -6
- package/build-module/components/list-view/block-select-button.js.map +1 -1
- package/build-module/components/list-view/block.js +18 -3
- package/build-module/components/list-view/block.js.map +1 -1
- package/build-module/components/list-view/branch.js +1 -1
- package/build-module/components/list-view/branch.js.map +1 -1
- package/build-module/components/media-replace-flow/index.js +4 -0
- package/build-module/components/media-replace-flow/index.js.map +1 -1
- package/build-module/components/multi-selection-inspector/index.js +2 -2
- package/build-module/components/multi-selection-inspector/index.js.map +1 -1
- package/build-module/components/rich-text/index.js +25 -4
- package/build-module/components/rich-text/index.js.map +1 -1
- package/build-module/components/rich-text/split-value.js +12 -2
- package/build-module/components/rich-text/split-value.js.map +1 -1
- package/build-module/components/rich-text/use-firefox-compat.js +39 -0
- package/build-module/components/rich-text/use-firefox-compat.js.map +1 -0
- package/build-module/components/rich-text/use-input-rules.js +35 -4
- package/build-module/components/rich-text/use-input-rules.js.map +1 -1
- package/build-module/components/skip-to-selected-block/index.js +4 -0
- package/build-module/components/skip-to-selected-block/index.js.map +1 -1
- package/build-module/components/writing-flow/index.js +5 -1
- package/build-module/components/writing-flow/index.js.map +1 -1
- package/build-module/components/writing-flow/use-arrow-nav.js +4 -45
- package/build-module/components/writing-flow/use-arrow-nav.js.map +1 -1
- package/build-module/components/writing-flow/use-click-selection.js +57 -0
- package/build-module/components/writing-flow/use-click-selection.js.map +1 -0
- package/build-module/components/writing-flow/use-drag-selection.js +124 -0
- package/build-module/components/writing-flow/use-drag-selection.js.map +1 -0
- package/build-module/components/writing-flow/use-input.js +104 -0
- package/build-module/components/writing-flow/use-input.js.map +1 -0
- package/build-module/components/writing-flow/use-multi-selection.js +18 -37
- package/build-module/components/writing-flow/use-multi-selection.js.map +1 -1
- package/build-module/components/writing-flow/use-selection-observer.js +150 -0
- package/build-module/components/writing-flow/use-selection-observer.js.map +1 -0
- package/build-module/components/writing-flow/use-tab-nav.js +1 -9
- package/build-module/components/writing-flow/use-tab-nav.js.map +1 -1
- package/build-module/hooks/border-color.js +5 -5
- package/build-module/hooks/border-color.js.map +1 -1
- package/build-module/hooks/border.js +0 -12
- package/build-module/hooks/border.js.map +1 -1
- package/build-module/hooks/color.js +19 -18
- package/build-module/hooks/color.js.map +1 -1
- package/build-module/hooks/font-family.js +3 -1
- package/build-module/hooks/font-family.js.map +1 -1
- package/build-module/hooks/font-size.js +4 -3
- package/build-module/hooks/font-size.js.map +1 -1
- package/build-module/hooks/gap.js +22 -15
- package/build-module/hooks/gap.js.map +1 -1
- package/build-module/hooks/layout.js +7 -2
- package/build-module/hooks/layout.js.map +1 -1
- package/build-module/hooks/style.js +33 -3
- package/build-module/hooks/style.js.map +1 -1
- package/build-module/hooks/utils.js +26 -0
- package/build-module/hooks/utils.js.map +1 -1
- package/build-module/layouts/flex.js +76 -13
- package/build-module/layouts/flex.js.map +1 -1
- package/build-module/layouts/flow.js +9 -5
- package/build-module/layouts/flow.js.map +1 -1
- package/build-module/store/actions.js +277 -49
- package/build-module/store/actions.js.map +1 -1
- package/build-module/store/defaults.js +5 -2
- package/build-module/store/defaults.js.map +1 -1
- package/build-module/store/reducer.js +25 -13
- package/build-module/store/reducer.js.map +1 -1
- package/build-module/store/selectors.js +250 -21
- package/build-module/store/selectors.js.map +1 -1
- package/build-module/store/utils.js +20 -0
- package/build-module/store/utils.js.map +1 -0
- package/build-module/utils/dom.js +2 -1
- package/build-module/utils/dom.js.map +1 -1
- package/build-style/style-rtl.css +142 -101
- package/build-style/style.css +142 -101
- package/build-types/utils/dom.d.ts.map +1 -1
- package/package.json +28 -28
- package/src/components/alignment-control/index.js +9 -4
- package/src/components/block-alignment-control/index.js +9 -4
- package/src/components/block-alignment-control/ui.js +2 -2
- package/src/components/block-content-overlay/index.js +19 -2
- package/src/components/block-draggable/index.js +2 -5
- package/src/components/block-icon/index.js +3 -0
- package/src/components/block-inspector/index.js +4 -0
- package/src/components/block-list/style.scss +4 -5
- package/src/components/block-list/use-block-props/index.js +0 -5
- package/src/components/block-list/use-block-props/use-focus-first-element.js +19 -26
- package/src/components/block-list/use-block-props/use-focus-handler.js +8 -0
- package/src/components/block-list-appender/index.js +5 -0
- package/src/components/block-lock/index.js +1 -0
- package/src/components/block-lock/menu-item.js +6 -19
- package/src/components/block-lock/modal.js +52 -23
- package/src/components/block-lock/style.scss +7 -5
- package/src/components/block-lock/toolbar.js +7 -14
- package/src/components/block-lock/use-block-lock.js +45 -0
- package/src/components/block-mover/index.js +3 -0
- package/src/components/block-mover/style.scss +4 -0
- package/src/components/block-pattern-setup/index.js +84 -59
- package/src/components/block-pattern-setup/setup-toolbar.js +3 -1
- package/src/components/block-pattern-setup/style.scss +32 -26
- package/src/components/block-preview/auto.js +10 -1
- package/src/components/block-preview/index.js +2 -0
- package/src/components/block-settings-menu/block-settings-dropdown.js +62 -4
- package/src/components/block-switcher/index.js +15 -3
- package/src/components/block-switcher/style.scss +15 -4
- package/src/components/block-switcher/test/__snapshots__/index.js.snap +15 -13
- package/src/components/block-switcher/test/index.js +2 -2
- package/src/components/block-title/index.js +2 -2
- package/src/components/block-title/use-block-display-title.js +1 -1
- package/src/components/block-toolbar/block-name-context.js +8 -0
- package/src/components/block-toolbar/block-toolbar-last-item.js +12 -0
- package/src/components/block-toolbar/index.js +18 -2
- package/src/components/block-toolbar/style.scss +6 -0
- package/src/components/block-tools/index.js +0 -19
- package/src/components/block-tools/style.scss +3 -5
- package/src/components/block-variation-transforms/index.js +105 -36
- package/src/components/block-variation-transforms/style.scss +1 -1
- package/src/components/block-vertical-alignment-control/index.js +9 -4
- package/src/components/button-block-appender/style.scss +5 -1
- package/src/components/contrast-checker/index.js +3 -0
- package/src/components/convert-to-group-buttons/index.js +6 -1
- package/src/components/convert-to-group-buttons/toolbar.js +87 -0
- package/src/components/copy-handler/index.js +55 -10
- package/src/components/font-sizes/font-size-picker.js +3 -0
- package/src/components/iframe/index.js +5 -7
- package/src/components/index.js +2 -0
- package/src/components/justify-content-control/index.js +9 -4
- package/src/components/keyboard-shortcuts/index.js +1 -1
- package/src/components/line-height-control/index.js +8 -3
- package/src/components/link-control/index.js +5 -5
- package/src/components/list-view/block-select-button.js +13 -3
- package/src/components/list-view/block.js +24 -8
- package/src/components/list-view/branch.js +1 -1
- package/src/components/list-view/style.scss +56 -14
- package/src/components/media-placeholder/README.md +8 -0
- package/src/components/media-replace-flow/index.js +3 -0
- package/src/components/multi-selection-inspector/index.js +2 -2
- package/src/components/rich-text/index.js +24 -1
- package/src/components/rich-text/split-value.js +5 -1
- package/src/components/rich-text/use-firefox-compat.js +39 -0
- package/src/components/rich-text/use-input-rules.js +40 -3
- package/src/components/skip-to-selected-block/index.js +3 -0
- package/src/components/url-input/style.scss +3 -2
- package/src/components/writing-flow/index.js +8 -0
- package/src/components/writing-flow/readme.md +28 -0
- package/src/components/writing-flow/use-arrow-nav.js +4 -53
- package/src/components/writing-flow/use-click-selection.js +65 -0
- package/src/components/writing-flow/use-drag-selection.js +126 -0
- package/src/components/writing-flow/use-input.js +112 -0
- package/src/components/writing-flow/use-multi-selection.js +13 -36
- package/src/components/writing-flow/use-selection-observer.js +153 -0
- package/src/components/writing-flow/use-tab-nav.js +1 -11
- package/src/hooks/border-color.js +5 -5
- package/src/hooks/border.js +0 -13
- package/src/hooks/color.js +51 -24
- package/src/hooks/font-family.js +5 -2
- package/src/hooks/font-size.js +10 -7
- package/src/hooks/gap.js +25 -17
- package/src/hooks/layout.js +11 -1
- package/src/hooks/style.js +40 -4
- package/src/hooks/test/gap.js +25 -1
- package/src/hooks/test/style.js +94 -0
- package/src/hooks/test/utils.js +1 -1
- package/src/hooks/utils.js +26 -0
- package/src/layouts/flex.js +89 -5
- package/src/layouts/flow.js +15 -4
- package/src/store/actions.js +341 -32
- package/src/store/defaults.js +7 -2
- package/src/store/reducer.js +25 -10
- package/src/store/selectors.js +329 -26
- package/src/store/test/selectors.js +242 -5
- package/src/store/utils.js +19 -0
- package/src/utils/dom.js +2 -1
- package/tsconfig.tsbuildinfo +1 -1
- package/build/components/block-list/use-block-props/use-multi-selection.js +0 -205
- package/build/components/block-list/use-block-props/use-multi-selection.js.map +0 -1
- package/build/components/block-list/use-block-props/use-scroll-into-view.js +0 -77
- package/build/components/block-list/use-block-props/use-scroll-into-view.js.map +0 -1
- package/build-module/components/block-list/use-block-props/use-multi-selection.js +0 -192
- package/build-module/components/block-list/use-block-props/use-multi-selection.js.map +0 -1
- package/build-module/components/block-list/use-block-props/use-scroll-into-view.js +0 -63
- package/build-module/components/block-list/use-block-props/use-scroll-into-view.js.map +0 -1
- package/src/components/block-list/use-block-props/use-multi-selection.js +0 -227
- package/src/components/block-list/use-block-props/use-scroll-into-view.js +0 -73
package/src/store/reducer.js
CHANGED
|
@@ -1278,17 +1278,24 @@ function selectionHelper( state = {}, action ) {
|
|
|
1278
1278
|
export function selection( state = {}, action ) {
|
|
1279
1279
|
switch ( action.type ) {
|
|
1280
1280
|
case 'SELECTION_CHANGE':
|
|
1281
|
+
if ( action.clientId ) {
|
|
1282
|
+
return {
|
|
1283
|
+
selectionStart: {
|
|
1284
|
+
clientId: action.clientId,
|
|
1285
|
+
attributeKey: action.attributeKey,
|
|
1286
|
+
offset: action.startOffset,
|
|
1287
|
+
},
|
|
1288
|
+
selectionEnd: {
|
|
1289
|
+
clientId: action.clientId,
|
|
1290
|
+
attributeKey: action.attributeKey,
|
|
1291
|
+
offset: action.endOffset,
|
|
1292
|
+
},
|
|
1293
|
+
};
|
|
1294
|
+
}
|
|
1295
|
+
|
|
1281
1296
|
return {
|
|
1282
|
-
selectionStart:
|
|
1283
|
-
|
|
1284
|
-
attributeKey: action.attributeKey,
|
|
1285
|
-
offset: action.startOffset,
|
|
1286
|
-
},
|
|
1287
|
-
selectionEnd: {
|
|
1288
|
-
clientId: action.clientId,
|
|
1289
|
-
attributeKey: action.attributeKey,
|
|
1290
|
-
offset: action.endOffset,
|
|
1291
|
-
},
|
|
1297
|
+
selectionStart: action.start || state.selectionStart,
|
|
1298
|
+
selectionEnd: action.end || state.selectionEnd,
|
|
1292
1299
|
};
|
|
1293
1300
|
case 'RESET_SELECTION':
|
|
1294
1301
|
const { selectionStart, selectionEnd } = action;
|
|
@@ -1298,6 +1305,14 @@ export function selection( state = {}, action ) {
|
|
|
1298
1305
|
};
|
|
1299
1306
|
case 'MULTI_SELECT':
|
|
1300
1307
|
const { start, end } = action;
|
|
1308
|
+
|
|
1309
|
+
if (
|
|
1310
|
+
start === state.selectionStart?.clientId &&
|
|
1311
|
+
end === state.selectionEnd?.clientId
|
|
1312
|
+
) {
|
|
1313
|
+
return state;
|
|
1314
|
+
}
|
|
1315
|
+
|
|
1301
1316
|
return {
|
|
1302
1317
|
selectionStart: { clientId: start },
|
|
1303
1318
|
selectionEnd: { clientId: end },
|
package/src/store/selectors.js
CHANGED
|
@@ -3,7 +3,6 @@
|
|
|
3
3
|
*/
|
|
4
4
|
import {
|
|
5
5
|
castArray,
|
|
6
|
-
flatMap,
|
|
7
6
|
first,
|
|
8
7
|
isArray,
|
|
9
8
|
isBoolean,
|
|
@@ -28,10 +27,18 @@ import {
|
|
|
28
27
|
hasBlockSupport,
|
|
29
28
|
getPossibleBlockTransformations,
|
|
30
29
|
parse,
|
|
30
|
+
switchToBlockType,
|
|
31
31
|
} from '@wordpress/blocks';
|
|
32
32
|
import { Platform } from '@wordpress/element';
|
|
33
33
|
import { applyFilters } from '@wordpress/hooks';
|
|
34
34
|
import { symbol } from '@wordpress/icons';
|
|
35
|
+
import { __ } from '@wordpress/i18n';
|
|
36
|
+
import { create, remove, toHTMLString } from '@wordpress/rich-text';
|
|
37
|
+
|
|
38
|
+
/**
|
|
39
|
+
* Internal dependencies
|
|
40
|
+
*/
|
|
41
|
+
import { mapRichTextSettings } from './utils';
|
|
35
42
|
|
|
36
43
|
/**
|
|
37
44
|
* A block selection object.
|
|
@@ -215,26 +222,35 @@ export const __unstableGetClientIdsTree = createSelector(
|
|
|
215
222
|
);
|
|
216
223
|
|
|
217
224
|
/**
|
|
218
|
-
* Returns an array containing the clientIds of all descendants
|
|
219
|
-
* of the
|
|
225
|
+
* Returns an array containing the clientIds of all descendants of the blocks
|
|
226
|
+
* given. Returned ids are ordered first by the order of the ids given, then
|
|
227
|
+
* by the order that they appear in the editor.
|
|
220
228
|
*
|
|
221
229
|
* @param {Object} state Global application state.
|
|
222
230
|
* @param {Array} clientIds Array of blocks to inspect.
|
|
223
231
|
*
|
|
224
232
|
* @return {Array} ids of descendants.
|
|
225
233
|
*/
|
|
226
|
-
export const getClientIdsOfDescendants = (
|
|
227
|
-
|
|
228
|
-
const
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
+
export const getClientIdsOfDescendants = createSelector(
|
|
235
|
+
( state, clientIds ) => {
|
|
236
|
+
const collectedIds = [];
|
|
237
|
+
for ( const givenId of clientIds ) {
|
|
238
|
+
for ( const descendantId of getBlockOrder( state, givenId ) ) {
|
|
239
|
+
collectedIds.push(
|
|
240
|
+
descendantId,
|
|
241
|
+
...getClientIdsOfDescendants( state, [ descendantId ] )
|
|
242
|
+
);
|
|
243
|
+
}
|
|
244
|
+
}
|
|
245
|
+
return collectedIds;
|
|
246
|
+
},
|
|
247
|
+
( state ) => [ state.blocks.order ]
|
|
248
|
+
);
|
|
234
249
|
|
|
235
250
|
/**
|
|
236
|
-
* Returns an array containing the clientIds of the top-level blocks
|
|
237
|
-
*
|
|
251
|
+
* Returns an array containing the clientIds of the top-level blocks and
|
|
252
|
+
* their descendants of any depth (for nested blocks). Ids are returned
|
|
253
|
+
* in the same order that they appear in the editor.
|
|
238
254
|
*
|
|
239
255
|
* @param {Object} state Global application state.
|
|
240
256
|
*
|
|
@@ -242,11 +258,14 @@ export const getClientIdsOfDescendants = ( state, clientIds ) =>
|
|
|
242
258
|
*/
|
|
243
259
|
export const getClientIdsWithDescendants = createSelector(
|
|
244
260
|
( state ) => {
|
|
245
|
-
const
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
261
|
+
const collectedIds = [];
|
|
262
|
+
for ( const topLevelId of getBlockOrder( state ) ) {
|
|
263
|
+
collectedIds.push(
|
|
264
|
+
topLevelId,
|
|
265
|
+
...getClientIdsOfDescendants( state, [ topLevelId ] )
|
|
266
|
+
);
|
|
267
|
+
}
|
|
268
|
+
return collectedIds;
|
|
250
269
|
},
|
|
251
270
|
( state ) => [ state.blocks.order ]
|
|
252
271
|
);
|
|
@@ -895,6 +914,222 @@ export function getMultiSelectedBlocksEndClientId( state ) {
|
|
|
895
914
|
return selectionEnd.clientId || null;
|
|
896
915
|
}
|
|
897
916
|
|
|
917
|
+
/**
|
|
918
|
+
* Returns true if the selection is not partial.
|
|
919
|
+
*
|
|
920
|
+
* @param {Object} state Editor state.
|
|
921
|
+
*
|
|
922
|
+
* @return {boolean} Whether the selection is mergeable.
|
|
923
|
+
*/
|
|
924
|
+
export function __unstableIsFullySelected( state ) {
|
|
925
|
+
const selectionAnchor = getSelectionStart( state );
|
|
926
|
+
const selectionFocus = getSelectionEnd( state );
|
|
927
|
+
return (
|
|
928
|
+
! selectionAnchor.attributeKey &&
|
|
929
|
+
! selectionFocus.attributeKey &&
|
|
930
|
+
typeof selectionAnchor.offset === 'undefined' &&
|
|
931
|
+
typeof selectionFocus.offset === 'undefined'
|
|
932
|
+
);
|
|
933
|
+
}
|
|
934
|
+
|
|
935
|
+
/**
|
|
936
|
+
* Returns true if the selection is collapsed.
|
|
937
|
+
*
|
|
938
|
+
* @param {Object} state Editor state.
|
|
939
|
+
*
|
|
940
|
+
* @return {boolean} Whether the selection is collapsed.
|
|
941
|
+
*/
|
|
942
|
+
export function __unstableIsSelectionCollapsed( state ) {
|
|
943
|
+
const selectionAnchor = getSelectionStart( state );
|
|
944
|
+
const selectionFocus = getSelectionEnd( state );
|
|
945
|
+
return (
|
|
946
|
+
!! selectionAnchor &&
|
|
947
|
+
!! selectionFocus &&
|
|
948
|
+
selectionAnchor.clientId === selectionFocus.clientId &&
|
|
949
|
+
selectionAnchor.attributeKey === selectionFocus.attributeKey &&
|
|
950
|
+
selectionAnchor.offset === selectionFocus.offset
|
|
951
|
+
);
|
|
952
|
+
}
|
|
953
|
+
|
|
954
|
+
/**
|
|
955
|
+
* Check whether the selection is mergeable.
|
|
956
|
+
*
|
|
957
|
+
* @param {Object} state Editor state.
|
|
958
|
+
* @param {boolean} isForward Whether to merge forwards.
|
|
959
|
+
*
|
|
960
|
+
* @return {boolean} Whether the selection is mergeable.
|
|
961
|
+
*/
|
|
962
|
+
export function __unstableIsSelectionMergeable( state, isForward ) {
|
|
963
|
+
const selectionAnchor = getSelectionStart( state );
|
|
964
|
+
const selectionFocus = getSelectionEnd( state );
|
|
965
|
+
|
|
966
|
+
// It's not mergeable if the start and end are within the same block.
|
|
967
|
+
if ( selectionAnchor.clientId === selectionFocus.clientId ) return false;
|
|
968
|
+
|
|
969
|
+
// It's not mergeable if there's no rich text selection.
|
|
970
|
+
if (
|
|
971
|
+
! selectionAnchor.attributeKey ||
|
|
972
|
+
! selectionFocus.attributeKey ||
|
|
973
|
+
typeof selectionAnchor.offset === 'undefined' ||
|
|
974
|
+
typeof selectionFocus.offset === 'undefined'
|
|
975
|
+
)
|
|
976
|
+
return false;
|
|
977
|
+
|
|
978
|
+
const anchorRootClientId = getBlockRootClientId(
|
|
979
|
+
state,
|
|
980
|
+
selectionAnchor.clientId
|
|
981
|
+
);
|
|
982
|
+
const focusRootClientId = getBlockRootClientId(
|
|
983
|
+
state,
|
|
984
|
+
selectionFocus.clientId
|
|
985
|
+
);
|
|
986
|
+
|
|
987
|
+
// It's not mergeable if the selection doesn't start and end in the same
|
|
988
|
+
// block list. Maybe in the future it should be allowed.
|
|
989
|
+
if ( anchorRootClientId !== focusRootClientId ) {
|
|
990
|
+
return false;
|
|
991
|
+
}
|
|
992
|
+
|
|
993
|
+
const blockOrder = getBlockOrder( state, anchorRootClientId );
|
|
994
|
+
const anchorIndex = blockOrder.indexOf( selectionAnchor.clientId );
|
|
995
|
+
const focusIndex = blockOrder.indexOf( selectionFocus.clientId );
|
|
996
|
+
|
|
997
|
+
// Reassign selection start and end based on order.
|
|
998
|
+
let selectionStart, selectionEnd;
|
|
999
|
+
|
|
1000
|
+
if ( anchorIndex > focusIndex ) {
|
|
1001
|
+
selectionStart = selectionFocus;
|
|
1002
|
+
selectionEnd = selectionAnchor;
|
|
1003
|
+
} else {
|
|
1004
|
+
selectionStart = selectionAnchor;
|
|
1005
|
+
selectionEnd = selectionFocus;
|
|
1006
|
+
}
|
|
1007
|
+
|
|
1008
|
+
const targetBlockClientId = isForward
|
|
1009
|
+
? selectionEnd.clientId
|
|
1010
|
+
: selectionStart.clientId;
|
|
1011
|
+
const blockToMergeClientId = isForward
|
|
1012
|
+
? selectionStart.clientId
|
|
1013
|
+
: selectionEnd.clientId;
|
|
1014
|
+
|
|
1015
|
+
const targetBlock = getBlock( state, targetBlockClientId );
|
|
1016
|
+
const targetBlockType = getBlockType( targetBlock.name );
|
|
1017
|
+
|
|
1018
|
+
if ( ! targetBlockType.merge ) return false;
|
|
1019
|
+
|
|
1020
|
+
const blockToMerge = getBlock( state, blockToMergeClientId );
|
|
1021
|
+
|
|
1022
|
+
// It's mergeable if the blocks are of the same type.
|
|
1023
|
+
if ( blockToMerge.name === targetBlock.name ) return true;
|
|
1024
|
+
|
|
1025
|
+
// If the blocks are of a different type, try to transform the block being
|
|
1026
|
+
// merged into the same type of block.
|
|
1027
|
+
const blocksToMerge = switchToBlockType( blockToMerge, targetBlock.name );
|
|
1028
|
+
|
|
1029
|
+
return blocksToMerge && blocksToMerge.length;
|
|
1030
|
+
}
|
|
1031
|
+
|
|
1032
|
+
/**
|
|
1033
|
+
* Get partial selected blocks with their content updated
|
|
1034
|
+
* based on the selection.
|
|
1035
|
+
*
|
|
1036
|
+
* @param {Object} state Editor state.
|
|
1037
|
+
*
|
|
1038
|
+
* @return {Object[]} Updated partial selected blocks.
|
|
1039
|
+
*/
|
|
1040
|
+
export const __unstableGetSelectedBlocksWithPartialSelection = ( state ) => {
|
|
1041
|
+
const selectionAnchor = getSelectionStart( state );
|
|
1042
|
+
const selectionFocus = getSelectionEnd( state );
|
|
1043
|
+
|
|
1044
|
+
if ( selectionAnchor.clientId === selectionFocus.clientId ) {
|
|
1045
|
+
return EMPTY_ARRAY;
|
|
1046
|
+
}
|
|
1047
|
+
|
|
1048
|
+
// Can't split if the selection is not set.
|
|
1049
|
+
if (
|
|
1050
|
+
! selectionAnchor.attributeKey ||
|
|
1051
|
+
! selectionFocus.attributeKey ||
|
|
1052
|
+
typeof selectionAnchor.offset === 'undefined' ||
|
|
1053
|
+
typeof selectionFocus.offset === 'undefined'
|
|
1054
|
+
) {
|
|
1055
|
+
return EMPTY_ARRAY;
|
|
1056
|
+
}
|
|
1057
|
+
|
|
1058
|
+
const anchorRootClientId = getBlockRootClientId(
|
|
1059
|
+
state,
|
|
1060
|
+
selectionAnchor.clientId
|
|
1061
|
+
);
|
|
1062
|
+
const focusRootClientId = getBlockRootClientId(
|
|
1063
|
+
state,
|
|
1064
|
+
selectionFocus.clientId
|
|
1065
|
+
);
|
|
1066
|
+
|
|
1067
|
+
// It's not splittable if the selection doesn't start and end in the same
|
|
1068
|
+
// block list. Maybe in the future it should be allowed.
|
|
1069
|
+
if ( anchorRootClientId !== focusRootClientId ) {
|
|
1070
|
+
return EMPTY_ARRAY;
|
|
1071
|
+
}
|
|
1072
|
+
|
|
1073
|
+
const blockOrder = getBlockOrder( state, anchorRootClientId );
|
|
1074
|
+
const anchorIndex = blockOrder.indexOf( selectionAnchor.clientId );
|
|
1075
|
+
const focusIndex = blockOrder.indexOf( selectionFocus.clientId );
|
|
1076
|
+
|
|
1077
|
+
// Reassign selection start and end based on order.
|
|
1078
|
+
const [ selectionStart, selectionEnd ] =
|
|
1079
|
+
anchorIndex > focusIndex
|
|
1080
|
+
? [ selectionFocus, selectionAnchor ]
|
|
1081
|
+
: [ selectionAnchor, selectionFocus ];
|
|
1082
|
+
|
|
1083
|
+
const blockA = getBlock( state, selectionStart.clientId );
|
|
1084
|
+
const blockAType = getBlockType( blockA.name );
|
|
1085
|
+
|
|
1086
|
+
const blockB = getBlock( state, selectionEnd.clientId );
|
|
1087
|
+
const blockBType = getBlockType( blockB.name );
|
|
1088
|
+
|
|
1089
|
+
const htmlA = blockA.attributes[ selectionStart.attributeKey ];
|
|
1090
|
+
const htmlB = blockB.attributes[ selectionEnd.attributeKey ];
|
|
1091
|
+
|
|
1092
|
+
const attributeDefinitionA =
|
|
1093
|
+
blockAType.attributes[ selectionStart.attributeKey ];
|
|
1094
|
+
const attributeDefinitionB =
|
|
1095
|
+
blockBType.attributes[ selectionEnd.attributeKey ];
|
|
1096
|
+
|
|
1097
|
+
let valueA = create( {
|
|
1098
|
+
html: htmlA,
|
|
1099
|
+
...mapRichTextSettings( attributeDefinitionA ),
|
|
1100
|
+
} );
|
|
1101
|
+
let valueB = create( {
|
|
1102
|
+
html: htmlB,
|
|
1103
|
+
...mapRichTextSettings( attributeDefinitionB ),
|
|
1104
|
+
} );
|
|
1105
|
+
|
|
1106
|
+
valueA = remove( valueA, 0, selectionStart.offset );
|
|
1107
|
+
valueB = remove( valueB, selectionEnd.offset, valueB.text.length );
|
|
1108
|
+
|
|
1109
|
+
return [
|
|
1110
|
+
{
|
|
1111
|
+
...blockA,
|
|
1112
|
+
attributes: {
|
|
1113
|
+
...blockA.attributes,
|
|
1114
|
+
[ selectionStart.attributeKey ]: toHTMLString( {
|
|
1115
|
+
value: valueA,
|
|
1116
|
+
...mapRichTextSettings( attributeDefinitionA ),
|
|
1117
|
+
} ),
|
|
1118
|
+
},
|
|
1119
|
+
},
|
|
1120
|
+
{
|
|
1121
|
+
...blockB,
|
|
1122
|
+
attributes: {
|
|
1123
|
+
...blockB.attributes,
|
|
1124
|
+
[ selectionEnd.attributeKey ]: toHTMLString( {
|
|
1125
|
+
value: valueB,
|
|
1126
|
+
...mapRichTextSettings( attributeDefinitionB ),
|
|
1127
|
+
} ),
|
|
1128
|
+
},
|
|
1129
|
+
},
|
|
1130
|
+
];
|
|
1131
|
+
};
|
|
1132
|
+
|
|
898
1133
|
/**
|
|
899
1134
|
* Returns an array containing all block client IDs in the editor in the order
|
|
900
1135
|
* they appear. Optionally accepts a root client ID of the block list for which
|
|
@@ -1284,10 +1519,28 @@ const canInsertBlockTypeUnmemoized = (
|
|
|
1284
1519
|
parentName
|
|
1285
1520
|
);
|
|
1286
1521
|
|
|
1522
|
+
let hasBlockAllowedAncestor = true;
|
|
1523
|
+
const blockAllowedAncestorBlocks = blockType.ancestor;
|
|
1524
|
+
if ( blockAllowedAncestorBlocks ) {
|
|
1525
|
+
const ancestors = [
|
|
1526
|
+
rootClientId,
|
|
1527
|
+
...getBlockParents( state, rootClientId ),
|
|
1528
|
+
];
|
|
1529
|
+
|
|
1530
|
+
hasBlockAllowedAncestor = some( ancestors, ( ancestorClientId ) =>
|
|
1531
|
+
checkAllowList(
|
|
1532
|
+
blockAllowedAncestorBlocks,
|
|
1533
|
+
getBlockName( state, ancestorClientId )
|
|
1534
|
+
)
|
|
1535
|
+
);
|
|
1536
|
+
}
|
|
1537
|
+
|
|
1287
1538
|
const canInsert =
|
|
1288
|
-
|
|
1289
|
-
hasParentAllowedBlock ===
|
|
1290
|
-
|
|
1539
|
+
hasBlockAllowedAncestor &&
|
|
1540
|
+
( ( hasParentAllowedBlock === null &&
|
|
1541
|
+
hasBlockAllowedParent === null ) ||
|
|
1542
|
+
hasParentAllowedBlock === true ||
|
|
1543
|
+
hasBlockAllowedParent === true );
|
|
1291
1544
|
|
|
1292
1545
|
if ( ! canInsert ) {
|
|
1293
1546
|
return canInsert;
|
|
@@ -1377,7 +1630,7 @@ export function canRemoveBlock( state, clientId, rootClientId = null ) {
|
|
|
1377
1630
|
|
|
1378
1631
|
const { lock } = attributes;
|
|
1379
1632
|
const parentIsLocked = !! getTemplateLock( state, rootClientId );
|
|
1380
|
-
// If we don't have a lock on the blockType level, we
|
|
1633
|
+
// If we don't have a lock on the blockType level, we defer to the parent templateLock.
|
|
1381
1634
|
if ( lock === undefined || lock?.remove === undefined ) {
|
|
1382
1635
|
return ! parentIsLocked;
|
|
1383
1636
|
}
|
|
@@ -1418,7 +1671,7 @@ export function canMoveBlock( state, clientId, rootClientId = null ) {
|
|
|
1418
1671
|
|
|
1419
1672
|
const { lock } = attributes;
|
|
1420
1673
|
const parentIsLocked = getTemplateLock( state, rootClientId ) === 'all';
|
|
1421
|
-
// If we don't have a lock on the blockType level, we
|
|
1674
|
+
// If we don't have a lock on the blockType level, we defer to the parent templateLock.
|
|
1422
1675
|
if ( lock === undefined || lock?.move === undefined ) {
|
|
1423
1676
|
return ! parentIsLocked;
|
|
1424
1677
|
}
|
|
@@ -1442,6 +1695,43 @@ export function canMoveBlocks( state, clientIds, rootClientId = null ) {
|
|
|
1442
1695
|
);
|
|
1443
1696
|
}
|
|
1444
1697
|
|
|
1698
|
+
/**
|
|
1699
|
+
* Determines if the given block is allowed to be edited.
|
|
1700
|
+
*
|
|
1701
|
+
* @param {Object} state Editor state.
|
|
1702
|
+
* @param {string} clientId The block client Id.
|
|
1703
|
+
*
|
|
1704
|
+
* @return {boolean} Whether the given block is allowed to be edited.
|
|
1705
|
+
*/
|
|
1706
|
+
export function canEditBlock( state, clientId ) {
|
|
1707
|
+
const attributes = getBlockAttributes( state, clientId );
|
|
1708
|
+
if ( attributes === null ) {
|
|
1709
|
+
return true;
|
|
1710
|
+
}
|
|
1711
|
+
|
|
1712
|
+
const { lock } = attributes;
|
|
1713
|
+
|
|
1714
|
+
// When the edit is true, we cannot edit the block.
|
|
1715
|
+
return ! lock?.edit;
|
|
1716
|
+
}
|
|
1717
|
+
|
|
1718
|
+
/**
|
|
1719
|
+
* Determines if the given block type can be locked/unlocked by a user.
|
|
1720
|
+
*
|
|
1721
|
+
* @param {Object} state Editor state.
|
|
1722
|
+
* @param {(string|Object)} nameOrType Block name or type object.
|
|
1723
|
+
*
|
|
1724
|
+
* @return {boolean} Whether a given block type can be locked/unlocked.
|
|
1725
|
+
*/
|
|
1726
|
+
export function canLockBlockType( state, nameOrType ) {
|
|
1727
|
+
if ( ! hasBlockSupport( nameOrType, 'lock', true ) ) {
|
|
1728
|
+
return false;
|
|
1729
|
+
}
|
|
1730
|
+
|
|
1731
|
+
// Use block editor settings as the default value.
|
|
1732
|
+
return !! state.settings?.canLockBlocks;
|
|
1733
|
+
}
|
|
1734
|
+
|
|
1445
1735
|
/**
|
|
1446
1736
|
* Returns information about how recently and frequently a block has been inserted.
|
|
1447
1737
|
*
|
|
@@ -1767,6 +2057,7 @@ export const getInserterItems = createSelector(
|
|
|
1767
2057
|
*/
|
|
1768
2058
|
export const getBlockTransformItems = createSelector(
|
|
1769
2059
|
( state, blocks, rootClientId = null ) => {
|
|
2060
|
+
const [ sourceBlock ] = blocks;
|
|
1770
2061
|
const buildBlockTypeTransformItem = buildBlockTypeItem( state, {
|
|
1771
2062
|
buildScope: 'transform',
|
|
1772
2063
|
} );
|
|
@@ -1780,20 +2071,32 @@ export const getBlockTransformItems = createSelector(
|
|
|
1780
2071
|
blockTypeTransformItems,
|
|
1781
2072
|
( { name } ) => name
|
|
1782
2073
|
);
|
|
2074
|
+
|
|
2075
|
+
// Consider unwraping the highest priority.
|
|
2076
|
+
itemsByName[ '*' ] = {
|
|
2077
|
+
frecency: +Infinity,
|
|
2078
|
+
id: '*',
|
|
2079
|
+
isDisabled: false,
|
|
2080
|
+
name: '*',
|
|
2081
|
+
title: __( 'Unwrap' ),
|
|
2082
|
+
icon: itemsByName[ sourceBlock.name ]?.icon,
|
|
2083
|
+
};
|
|
2084
|
+
|
|
1783
2085
|
const possibleTransforms = getPossibleBlockTransformations(
|
|
1784
2086
|
blocks
|
|
1785
2087
|
).reduce( ( accumulator, block ) => {
|
|
1786
|
-
if (
|
|
2088
|
+
if ( block === '*' ) {
|
|
2089
|
+
accumulator.push( itemsByName[ '*' ] );
|
|
2090
|
+
} else if ( itemsByName[ block?.name ] ) {
|
|
1787
2091
|
accumulator.push( itemsByName[ block.name ] );
|
|
1788
2092
|
}
|
|
1789
2093
|
return accumulator;
|
|
1790
2094
|
}, [] );
|
|
1791
|
-
|
|
2095
|
+
return orderBy(
|
|
1792
2096
|
possibleTransforms,
|
|
1793
2097
|
( block ) => itemsByName[ block.name ].frecency,
|
|
1794
2098
|
'desc'
|
|
1795
2099
|
);
|
|
1796
|
-
return possibleBlockTransformations;
|
|
1797
2100
|
},
|
|
1798
2101
|
( state, rootClientId ) => [
|
|
1799
2102
|
state.blockListSettings[ rootClientId ],
|