@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
|
@@ -1,16 +1,23 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* External dependencies
|
|
3
3
|
*/
|
|
4
|
-
import { castArray,
|
|
4
|
+
import { castArray, first, isArray, isBoolean, last, map, reduce, some, find, filter, mapKeys, orderBy } from 'lodash';
|
|
5
5
|
import createSelector from 'rememo';
|
|
6
6
|
/**
|
|
7
7
|
* WordPress dependencies
|
|
8
8
|
*/
|
|
9
9
|
|
|
10
|
-
import { getBlockType, getBlockTypes, getBlockVariations, hasBlockSupport, getPossibleBlockTransformations, parse } from '@wordpress/blocks';
|
|
10
|
+
import { getBlockType, getBlockTypes, getBlockVariations, hasBlockSupport, getPossibleBlockTransformations, parse, switchToBlockType } from '@wordpress/blocks';
|
|
11
11
|
import { Platform } from '@wordpress/element';
|
|
12
12
|
import { applyFilters } from '@wordpress/hooks';
|
|
13
13
|
import { symbol } from '@wordpress/icons';
|
|
14
|
+
import { __ } from '@wordpress/i18n';
|
|
15
|
+
import { create, remove, toHTMLString } from '@wordpress/rich-text';
|
|
16
|
+
/**
|
|
17
|
+
* Internal dependencies
|
|
18
|
+
*/
|
|
19
|
+
|
|
20
|
+
import { mapRichTextSettings } from './utils';
|
|
14
21
|
/**
|
|
15
22
|
* A block selection object.
|
|
16
23
|
*
|
|
@@ -182,8 +189,9 @@ export const __unstableGetClientIdsTree = createSelector(function (state) {
|
|
|
182
189
|
return map(getBlockOrder(state, rootClientId), clientId => __unstableGetClientIdWithClientIdsTree(state, clientId));
|
|
183
190
|
}, state => [state.blocks.order]);
|
|
184
191
|
/**
|
|
185
|
-
* Returns an array containing the clientIds of all descendants
|
|
186
|
-
* of the
|
|
192
|
+
* Returns an array containing the clientIds of all descendants of the blocks
|
|
193
|
+
* given. Returned ids are ordered first by the order of the ids given, then
|
|
194
|
+
* by the order that they appear in the editor.
|
|
187
195
|
*
|
|
188
196
|
* @param {Object} state Global application state.
|
|
189
197
|
* @param {Array} clientIds Array of blocks to inspect.
|
|
@@ -191,13 +199,21 @@ export const __unstableGetClientIdsTree = createSelector(function (state) {
|
|
|
191
199
|
* @return {Array} ids of descendants.
|
|
192
200
|
*/
|
|
193
201
|
|
|
194
|
-
export const getClientIdsOfDescendants = (state, clientIds) =>
|
|
195
|
-
const
|
|
196
|
-
|
|
197
|
-
|
|
202
|
+
export const getClientIdsOfDescendants = createSelector((state, clientIds) => {
|
|
203
|
+
const collectedIds = [];
|
|
204
|
+
|
|
205
|
+
for (const givenId of clientIds) {
|
|
206
|
+
for (const descendantId of getBlockOrder(state, givenId)) {
|
|
207
|
+
collectedIds.push(descendantId, ...getClientIdsOfDescendants(state, [descendantId]));
|
|
208
|
+
}
|
|
209
|
+
}
|
|
210
|
+
|
|
211
|
+
return collectedIds;
|
|
212
|
+
}, state => [state.blocks.order]);
|
|
198
213
|
/**
|
|
199
|
-
* Returns an array containing the clientIds of the top-level blocks
|
|
200
|
-
*
|
|
214
|
+
* Returns an array containing the clientIds of the top-level blocks and
|
|
215
|
+
* their descendants of any depth (for nested blocks). Ids are returned
|
|
216
|
+
* in the same order that they appear in the editor.
|
|
201
217
|
*
|
|
202
218
|
* @param {Object} state Global application state.
|
|
203
219
|
*
|
|
@@ -205,8 +221,13 @@ export const getClientIdsOfDescendants = (state, clientIds) => flatMap(clientIds
|
|
|
205
221
|
*/
|
|
206
222
|
|
|
207
223
|
export const getClientIdsWithDescendants = createSelector(state => {
|
|
208
|
-
const
|
|
209
|
-
|
|
224
|
+
const collectedIds = [];
|
|
225
|
+
|
|
226
|
+
for (const topLevelId of getBlockOrder(state)) {
|
|
227
|
+
collectedIds.push(topLevelId, ...getClientIdsOfDescendants(state, [topLevelId]));
|
|
228
|
+
}
|
|
229
|
+
|
|
230
|
+
return collectedIds;
|
|
210
231
|
}, state => [state.blocks.order]);
|
|
211
232
|
/**
|
|
212
233
|
* Returns the total number of blocks, or the total number of blocks with a specific name in a post.
|
|
@@ -825,6 +846,152 @@ export function getMultiSelectedBlocksEndClientId(state) {
|
|
|
825
846
|
|
|
826
847
|
return selectionEnd.clientId || null;
|
|
827
848
|
}
|
|
849
|
+
/**
|
|
850
|
+
* Returns true if the selection is not partial.
|
|
851
|
+
*
|
|
852
|
+
* @param {Object} state Editor state.
|
|
853
|
+
*
|
|
854
|
+
* @return {boolean} Whether the selection is mergeable.
|
|
855
|
+
*/
|
|
856
|
+
|
|
857
|
+
export function __unstableIsFullySelected(state) {
|
|
858
|
+
const selectionAnchor = getSelectionStart(state);
|
|
859
|
+
const selectionFocus = getSelectionEnd(state);
|
|
860
|
+
return !selectionAnchor.attributeKey && !selectionFocus.attributeKey && typeof selectionAnchor.offset === 'undefined' && typeof selectionFocus.offset === 'undefined';
|
|
861
|
+
}
|
|
862
|
+
/**
|
|
863
|
+
* Returns true if the selection is collapsed.
|
|
864
|
+
*
|
|
865
|
+
* @param {Object} state Editor state.
|
|
866
|
+
*
|
|
867
|
+
* @return {boolean} Whether the selection is collapsed.
|
|
868
|
+
*/
|
|
869
|
+
|
|
870
|
+
export function __unstableIsSelectionCollapsed(state) {
|
|
871
|
+
const selectionAnchor = getSelectionStart(state);
|
|
872
|
+
const selectionFocus = getSelectionEnd(state);
|
|
873
|
+
return !!selectionAnchor && !!selectionFocus && selectionAnchor.clientId === selectionFocus.clientId && selectionAnchor.attributeKey === selectionFocus.attributeKey && selectionAnchor.offset === selectionFocus.offset;
|
|
874
|
+
}
|
|
875
|
+
/**
|
|
876
|
+
* Check whether the selection is mergeable.
|
|
877
|
+
*
|
|
878
|
+
* @param {Object} state Editor state.
|
|
879
|
+
* @param {boolean} isForward Whether to merge forwards.
|
|
880
|
+
*
|
|
881
|
+
* @return {boolean} Whether the selection is mergeable.
|
|
882
|
+
*/
|
|
883
|
+
|
|
884
|
+
export function __unstableIsSelectionMergeable(state, isForward) {
|
|
885
|
+
const selectionAnchor = getSelectionStart(state);
|
|
886
|
+
const selectionFocus = getSelectionEnd(state); // It's not mergeable if the start and end are within the same block.
|
|
887
|
+
|
|
888
|
+
if (selectionAnchor.clientId === selectionFocus.clientId) return false; // It's not mergeable if there's no rich text selection.
|
|
889
|
+
|
|
890
|
+
if (!selectionAnchor.attributeKey || !selectionFocus.attributeKey || typeof selectionAnchor.offset === 'undefined' || typeof selectionFocus.offset === 'undefined') return false;
|
|
891
|
+
const anchorRootClientId = getBlockRootClientId(state, selectionAnchor.clientId);
|
|
892
|
+
const focusRootClientId = getBlockRootClientId(state, selectionFocus.clientId); // It's not mergeable if the selection doesn't start and end in the same
|
|
893
|
+
// block list. Maybe in the future it should be allowed.
|
|
894
|
+
|
|
895
|
+
if (anchorRootClientId !== focusRootClientId) {
|
|
896
|
+
return false;
|
|
897
|
+
}
|
|
898
|
+
|
|
899
|
+
const blockOrder = getBlockOrder(state, anchorRootClientId);
|
|
900
|
+
const anchorIndex = blockOrder.indexOf(selectionAnchor.clientId);
|
|
901
|
+
const focusIndex = blockOrder.indexOf(selectionFocus.clientId); // Reassign selection start and end based on order.
|
|
902
|
+
|
|
903
|
+
let selectionStart, selectionEnd;
|
|
904
|
+
|
|
905
|
+
if (anchorIndex > focusIndex) {
|
|
906
|
+
selectionStart = selectionFocus;
|
|
907
|
+
selectionEnd = selectionAnchor;
|
|
908
|
+
} else {
|
|
909
|
+
selectionStart = selectionAnchor;
|
|
910
|
+
selectionEnd = selectionFocus;
|
|
911
|
+
}
|
|
912
|
+
|
|
913
|
+
const targetBlockClientId = isForward ? selectionEnd.clientId : selectionStart.clientId;
|
|
914
|
+
const blockToMergeClientId = isForward ? selectionStart.clientId : selectionEnd.clientId;
|
|
915
|
+
const targetBlock = getBlock(state, targetBlockClientId);
|
|
916
|
+
const targetBlockType = getBlockType(targetBlock.name);
|
|
917
|
+
if (!targetBlockType.merge) return false;
|
|
918
|
+
const blockToMerge = getBlock(state, blockToMergeClientId); // It's mergeable if the blocks are of the same type.
|
|
919
|
+
|
|
920
|
+
if (blockToMerge.name === targetBlock.name) return true; // If the blocks are of a different type, try to transform the block being
|
|
921
|
+
// merged into the same type of block.
|
|
922
|
+
|
|
923
|
+
const blocksToMerge = switchToBlockType(blockToMerge, targetBlock.name);
|
|
924
|
+
return blocksToMerge && blocksToMerge.length;
|
|
925
|
+
}
|
|
926
|
+
/**
|
|
927
|
+
* Get partial selected blocks with their content updated
|
|
928
|
+
* based on the selection.
|
|
929
|
+
*
|
|
930
|
+
* @param {Object} state Editor state.
|
|
931
|
+
*
|
|
932
|
+
* @return {Object[]} Updated partial selected blocks.
|
|
933
|
+
*/
|
|
934
|
+
|
|
935
|
+
export const __unstableGetSelectedBlocksWithPartialSelection = state => {
|
|
936
|
+
const selectionAnchor = getSelectionStart(state);
|
|
937
|
+
const selectionFocus = getSelectionEnd(state);
|
|
938
|
+
|
|
939
|
+
if (selectionAnchor.clientId === selectionFocus.clientId) {
|
|
940
|
+
return EMPTY_ARRAY;
|
|
941
|
+
} // Can't split if the selection is not set.
|
|
942
|
+
|
|
943
|
+
|
|
944
|
+
if (!selectionAnchor.attributeKey || !selectionFocus.attributeKey || typeof selectionAnchor.offset === 'undefined' || typeof selectionFocus.offset === 'undefined') {
|
|
945
|
+
return EMPTY_ARRAY;
|
|
946
|
+
}
|
|
947
|
+
|
|
948
|
+
const anchorRootClientId = getBlockRootClientId(state, selectionAnchor.clientId);
|
|
949
|
+
const focusRootClientId = getBlockRootClientId(state, selectionFocus.clientId); // It's not splittable if the selection doesn't start and end in the same
|
|
950
|
+
// block list. Maybe in the future it should be allowed.
|
|
951
|
+
|
|
952
|
+
if (anchorRootClientId !== focusRootClientId) {
|
|
953
|
+
return EMPTY_ARRAY;
|
|
954
|
+
}
|
|
955
|
+
|
|
956
|
+
const blockOrder = getBlockOrder(state, anchorRootClientId);
|
|
957
|
+
const anchorIndex = blockOrder.indexOf(selectionAnchor.clientId);
|
|
958
|
+
const focusIndex = blockOrder.indexOf(selectionFocus.clientId); // Reassign selection start and end based on order.
|
|
959
|
+
|
|
960
|
+
const [selectionStart, selectionEnd] = anchorIndex > focusIndex ? [selectionFocus, selectionAnchor] : [selectionAnchor, selectionFocus];
|
|
961
|
+
const blockA = getBlock(state, selectionStart.clientId);
|
|
962
|
+
const blockAType = getBlockType(blockA.name);
|
|
963
|
+
const blockB = getBlock(state, selectionEnd.clientId);
|
|
964
|
+
const blockBType = getBlockType(blockB.name);
|
|
965
|
+
const htmlA = blockA.attributes[selectionStart.attributeKey];
|
|
966
|
+
const htmlB = blockB.attributes[selectionEnd.attributeKey];
|
|
967
|
+
const attributeDefinitionA = blockAType.attributes[selectionStart.attributeKey];
|
|
968
|
+
const attributeDefinitionB = blockBType.attributes[selectionEnd.attributeKey];
|
|
969
|
+
let valueA = create({
|
|
970
|
+
html: htmlA,
|
|
971
|
+
...mapRichTextSettings(attributeDefinitionA)
|
|
972
|
+
});
|
|
973
|
+
let valueB = create({
|
|
974
|
+
html: htmlB,
|
|
975
|
+
...mapRichTextSettings(attributeDefinitionB)
|
|
976
|
+
});
|
|
977
|
+
valueA = remove(valueA, 0, selectionStart.offset);
|
|
978
|
+
valueB = remove(valueB, selectionEnd.offset, valueB.text.length);
|
|
979
|
+
return [{ ...blockA,
|
|
980
|
+
attributes: { ...blockA.attributes,
|
|
981
|
+
[selectionStart.attributeKey]: toHTMLString({
|
|
982
|
+
value: valueA,
|
|
983
|
+
...mapRichTextSettings(attributeDefinitionA)
|
|
984
|
+
})
|
|
985
|
+
}
|
|
986
|
+
}, { ...blockB,
|
|
987
|
+
attributes: { ...blockB.attributes,
|
|
988
|
+
[selectionEnd.attributeKey]: toHTMLString({
|
|
989
|
+
value: valueB,
|
|
990
|
+
...mapRichTextSettings(attributeDefinitionB)
|
|
991
|
+
})
|
|
992
|
+
}
|
|
993
|
+
}];
|
|
994
|
+
};
|
|
828
995
|
/**
|
|
829
996
|
* Returns an array containing all block client IDs in the editor in the order
|
|
830
997
|
* they appear. Optionally accepts a root client ID of the block list for which
|
|
@@ -1217,7 +1384,15 @@ const canInsertBlockTypeUnmemoized = function (state, blockName) {
|
|
|
1217
1384
|
const blockAllowedParentBlocks = blockType.parent;
|
|
1218
1385
|
const parentName = getBlockName(state, rootClientId);
|
|
1219
1386
|
const hasBlockAllowedParent = checkAllowList(blockAllowedParentBlocks, parentName);
|
|
1220
|
-
|
|
1387
|
+
let hasBlockAllowedAncestor = true;
|
|
1388
|
+
const blockAllowedAncestorBlocks = blockType.ancestor;
|
|
1389
|
+
|
|
1390
|
+
if (blockAllowedAncestorBlocks) {
|
|
1391
|
+
const ancestors = [rootClientId, ...getBlockParents(state, rootClientId)];
|
|
1392
|
+
hasBlockAllowedAncestor = some(ancestors, ancestorClientId => checkAllowList(blockAllowedAncestorBlocks, getBlockName(state, ancestorClientId)));
|
|
1393
|
+
}
|
|
1394
|
+
|
|
1395
|
+
const canInsert = hasBlockAllowedAncestor && (hasParentAllowedBlock === null && hasBlockAllowedParent === null || hasParentAllowedBlock === true || hasBlockAllowedParent === true);
|
|
1221
1396
|
|
|
1222
1397
|
if (!canInsert) {
|
|
1223
1398
|
return canInsert;
|
|
@@ -1292,7 +1467,7 @@ export function canRemoveBlock(state, clientId) {
|
|
|
1292
1467
|
const {
|
|
1293
1468
|
lock
|
|
1294
1469
|
} = attributes;
|
|
1295
|
-
const parentIsLocked = !!getTemplateLock(state, rootClientId); // If we don't have a lock on the blockType level, we
|
|
1470
|
+
const parentIsLocked = !!getTemplateLock(state, rootClientId); // If we don't have a lock on the blockType level, we defer to the parent templateLock.
|
|
1296
1471
|
|
|
1297
1472
|
if (lock === undefined || (lock === null || lock === void 0 ? void 0 : lock.remove) === undefined) {
|
|
1298
1473
|
return !parentIsLocked;
|
|
@@ -1336,7 +1511,7 @@ export function canMoveBlock(state, clientId) {
|
|
|
1336
1511
|
const {
|
|
1337
1512
|
lock
|
|
1338
1513
|
} = attributes;
|
|
1339
|
-
const parentIsLocked = getTemplateLock(state, rootClientId) === 'all'; // If we don't have a lock on the blockType level, we
|
|
1514
|
+
const parentIsLocked = getTemplateLock(state, rootClientId) === 'all'; // If we don't have a lock on the blockType level, we defer to the parent templateLock.
|
|
1340
1515
|
|
|
1341
1516
|
if (lock === undefined || (lock === null || lock === void 0 ? void 0 : lock.move) === undefined) {
|
|
1342
1517
|
return !parentIsLocked;
|
|
@@ -1359,6 +1534,47 @@ export function canMoveBlocks(state, clientIds) {
|
|
|
1359
1534
|
let rootClientId = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : null;
|
|
1360
1535
|
return clientIds.every(clientId => canMoveBlock(state, clientId, rootClientId));
|
|
1361
1536
|
}
|
|
1537
|
+
/**
|
|
1538
|
+
* Determines if the given block is allowed to be edited.
|
|
1539
|
+
*
|
|
1540
|
+
* @param {Object} state Editor state.
|
|
1541
|
+
* @param {string} clientId The block client Id.
|
|
1542
|
+
*
|
|
1543
|
+
* @return {boolean} Whether the given block is allowed to be edited.
|
|
1544
|
+
*/
|
|
1545
|
+
|
|
1546
|
+
export function canEditBlock(state, clientId) {
|
|
1547
|
+
const attributes = getBlockAttributes(state, clientId);
|
|
1548
|
+
|
|
1549
|
+
if (attributes === null) {
|
|
1550
|
+
return true;
|
|
1551
|
+
}
|
|
1552
|
+
|
|
1553
|
+
const {
|
|
1554
|
+
lock
|
|
1555
|
+
} = attributes; // When the edit is true, we cannot edit the block.
|
|
1556
|
+
|
|
1557
|
+
return !(lock !== null && lock !== void 0 && lock.edit);
|
|
1558
|
+
}
|
|
1559
|
+
/**
|
|
1560
|
+
* Determines if the given block type can be locked/unlocked by a user.
|
|
1561
|
+
*
|
|
1562
|
+
* @param {Object} state Editor state.
|
|
1563
|
+
* @param {(string|Object)} nameOrType Block name or type object.
|
|
1564
|
+
*
|
|
1565
|
+
* @return {boolean} Whether a given block type can be locked/unlocked.
|
|
1566
|
+
*/
|
|
1567
|
+
|
|
1568
|
+
export function canLockBlockType(state, nameOrType) {
|
|
1569
|
+
var _state$settings;
|
|
1570
|
+
|
|
1571
|
+
if (!hasBlockSupport(nameOrType, 'lock', true)) {
|
|
1572
|
+
return false;
|
|
1573
|
+
} // Use block editor settings as the default value.
|
|
1574
|
+
|
|
1575
|
+
|
|
1576
|
+
return !!((_state$settings = state.settings) !== null && _state$settings !== void 0 && _state$settings.canLockBlocks);
|
|
1577
|
+
}
|
|
1362
1578
|
/**
|
|
1363
1579
|
* Returns information about how recently and frequently a block has been inserted.
|
|
1364
1580
|
*
|
|
@@ -1687,7 +1903,10 @@ export const getInserterItems = createSelector(function (state) {
|
|
|
1687
1903
|
*/
|
|
1688
1904
|
|
|
1689
1905
|
export const getBlockTransformItems = createSelector(function (state, blocks) {
|
|
1906
|
+
var _itemsByName$sourceBl;
|
|
1907
|
+
|
|
1690
1908
|
let rootClientId = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : null;
|
|
1909
|
+
const [sourceBlock] = blocks;
|
|
1691
1910
|
const buildBlockTypeTransformItem = buildBlockTypeItem(state, {
|
|
1692
1911
|
buildScope: 'transform'
|
|
1693
1912
|
});
|
|
@@ -1697,16 +1916,26 @@ export const getBlockTransformItems = createSelector(function (state, blocks) {
|
|
|
1697
1916
|
name
|
|
1698
1917
|
} = _ref5;
|
|
1699
1918
|
return name;
|
|
1700
|
-
});
|
|
1919
|
+
}); // Consider unwraping the highest priority.
|
|
1920
|
+
|
|
1921
|
+
itemsByName['*'] = {
|
|
1922
|
+
frecency: +Infinity,
|
|
1923
|
+
id: '*',
|
|
1924
|
+
isDisabled: false,
|
|
1925
|
+
name: '*',
|
|
1926
|
+
title: __('Unwrap'),
|
|
1927
|
+
icon: (_itemsByName$sourceBl = itemsByName[sourceBlock.name]) === null || _itemsByName$sourceBl === void 0 ? void 0 : _itemsByName$sourceBl.icon
|
|
1928
|
+
};
|
|
1701
1929
|
const possibleTransforms = getPossibleBlockTransformations(blocks).reduce((accumulator, block) => {
|
|
1702
|
-
if (
|
|
1930
|
+
if (block === '*') {
|
|
1931
|
+
accumulator.push(itemsByName['*']);
|
|
1932
|
+
} else if (itemsByName[block === null || block === void 0 ? void 0 : block.name]) {
|
|
1703
1933
|
accumulator.push(itemsByName[block.name]);
|
|
1704
1934
|
}
|
|
1705
1935
|
|
|
1706
1936
|
return accumulator;
|
|
1707
1937
|
}, []);
|
|
1708
|
-
|
|
1709
|
-
return possibleBlockTransformations;
|
|
1938
|
+
return orderBy(possibleTransforms, block => itemsByName[block.name].frecency, 'desc');
|
|
1710
1939
|
}, (state, rootClientId) => [state.blockListSettings[rootClientId], state.blocks.byClientId, state.preferences.insertUsage, state.settings.allowedBlockTypes, state.settings.templateLock, getBlockTypes()]);
|
|
1711
1940
|
/**
|
|
1712
1941
|
* Determines whether there are items to show in the inserter.
|
|
@@ -2076,9 +2305,9 @@ export function __experimentalGetLastBlockAttributeChanges(state) {
|
|
|
2076
2305
|
*/
|
|
2077
2306
|
|
|
2078
2307
|
function getReusableBlocks(state) {
|
|
2079
|
-
var _state$settings$__exp, _state$
|
|
2308
|
+
var _state$settings$__exp, _state$settings2;
|
|
2080
2309
|
|
|
2081
|
-
return (_state$settings$__exp = state === null || state === void 0 ? void 0 : (_state$
|
|
2310
|
+
return (_state$settings$__exp = state === null || state === void 0 ? void 0 : (_state$settings2 = state.settings) === null || _state$settings2 === void 0 ? void 0 : _state$settings2.__experimentalReusableBlocks) !== null && _state$settings$__exp !== void 0 ? _state$settings$__exp : EMPTY_ARRAY;
|
|
2082
2311
|
}
|
|
2083
2312
|
/**
|
|
2084
2313
|
* Returns whether the navigation mode is enabled.
|