@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/layouts/flex.js
CHANGED
|
@@ -18,7 +18,12 @@ import { Button, ToggleControl, Flex, FlexItem } from '@wordpress/components';
|
|
|
18
18
|
import { appendSelectors } from './utils';
|
|
19
19
|
import { getGapCSSValue } from '../hooks/gap';
|
|
20
20
|
import useSetting from '../components/use-setting';
|
|
21
|
-
import {
|
|
21
|
+
import {
|
|
22
|
+
BlockControls,
|
|
23
|
+
JustifyContentControl,
|
|
24
|
+
BlockVerticalAlignmentControl,
|
|
25
|
+
} from '../components';
|
|
26
|
+
import { shouldSkipSerialization } from '../hooks/utils';
|
|
22
27
|
|
|
23
28
|
// Used with the default, horizontal flex orientation.
|
|
24
29
|
const justifyContentMap = {
|
|
@@ -35,6 +40,12 @@ const alignItemsMap = {
|
|
|
35
40
|
center: 'center',
|
|
36
41
|
};
|
|
37
42
|
|
|
43
|
+
const verticalAlignmentMap = {
|
|
44
|
+
top: 'flex-start',
|
|
45
|
+
center: 'center',
|
|
46
|
+
bottom: 'flex-end',
|
|
47
|
+
};
|
|
48
|
+
|
|
38
49
|
const flexWrapOptions = [ 'wrap', 'nowrap' ];
|
|
39
50
|
|
|
40
51
|
export default {
|
|
@@ -76,6 +87,7 @@ export default {
|
|
|
76
87
|
if ( layoutBlockSupport?.allowSwitching ) {
|
|
77
88
|
return null;
|
|
78
89
|
}
|
|
90
|
+
const { allowVerticalAlignment = true } = layoutBlockSupport;
|
|
79
91
|
return (
|
|
80
92
|
<BlockControls group="block" __experimentalShareWithChildBlocks>
|
|
81
93
|
<FlexLayoutJustifyContentControl
|
|
@@ -83,25 +95,40 @@ export default {
|
|
|
83
95
|
onChange={ onChange }
|
|
84
96
|
isToolbar
|
|
85
97
|
/>
|
|
98
|
+
{ allowVerticalAlignment &&
|
|
99
|
+
layout?.orientation !== 'vertical' && (
|
|
100
|
+
<FlexLayoutVerticalAlignmentControl
|
|
101
|
+
layout={ layout }
|
|
102
|
+
onChange={ onChange }
|
|
103
|
+
isToolbar
|
|
104
|
+
/>
|
|
105
|
+
) }
|
|
86
106
|
</BlockControls>
|
|
87
107
|
);
|
|
88
108
|
},
|
|
89
|
-
save: function FlexLayoutStyle( { selector, layout, style } ) {
|
|
109
|
+
save: function FlexLayoutStyle( { selector, layout, style, blockName } ) {
|
|
90
110
|
const { orientation = 'horizontal' } = layout;
|
|
91
111
|
const blockGapSupport = useSetting( 'spacing.blockGap' );
|
|
92
112
|
const hasBlockGapStylesSupport = blockGapSupport !== null;
|
|
113
|
+
// If a block's block.json skips serialization for spacing or spacing.blockGap,
|
|
114
|
+
// don't apply the user-defined value to the styles.
|
|
93
115
|
const blockGapValue =
|
|
94
|
-
|
|
95
|
-
|
|
116
|
+
style?.spacing?.blockGap &&
|
|
117
|
+
! shouldSkipSerialization( blockName, 'spacing', 'blockGap' )
|
|
118
|
+
? getGapCSSValue( style?.spacing?.blockGap, '0.5em' )
|
|
119
|
+
: 'var( --wp--style--block-gap, 0.5em )';
|
|
96
120
|
const justifyContent =
|
|
97
121
|
justifyContentMap[ layout.justifyContent ] ||
|
|
98
122
|
justifyContentMap.left;
|
|
99
123
|
const flexWrap = flexWrapOptions.includes( layout.flexWrap )
|
|
100
124
|
? layout.flexWrap
|
|
101
125
|
: 'wrap';
|
|
126
|
+
const verticalAlignment =
|
|
127
|
+
verticalAlignmentMap[ layout.verticalAlignment ] ||
|
|
128
|
+
verticalAlignmentMap.center;
|
|
102
129
|
const rowOrientation = `
|
|
103
130
|
flex-direction: row;
|
|
104
|
-
align-items:
|
|
131
|
+
align-items: ${ verticalAlignment };
|
|
105
132
|
justify-content: ${ justifyContent };
|
|
106
133
|
`;
|
|
107
134
|
const alignItems =
|
|
@@ -135,6 +162,63 @@ export default {
|
|
|
135
162
|
},
|
|
136
163
|
};
|
|
137
164
|
|
|
165
|
+
function FlexLayoutVerticalAlignmentControl( {
|
|
166
|
+
layout,
|
|
167
|
+
onChange,
|
|
168
|
+
isToolbar = false,
|
|
169
|
+
} ) {
|
|
170
|
+
const { verticalAlignment = verticalAlignmentMap.center } = layout;
|
|
171
|
+
|
|
172
|
+
const onVerticalAlignmentChange = ( value ) => {
|
|
173
|
+
onChange( {
|
|
174
|
+
...layout,
|
|
175
|
+
verticalAlignment: value,
|
|
176
|
+
} );
|
|
177
|
+
};
|
|
178
|
+
if ( isToolbar ) {
|
|
179
|
+
return (
|
|
180
|
+
<BlockVerticalAlignmentControl
|
|
181
|
+
onChange={ onVerticalAlignmentChange }
|
|
182
|
+
value={ verticalAlignment }
|
|
183
|
+
/>
|
|
184
|
+
);
|
|
185
|
+
}
|
|
186
|
+
|
|
187
|
+
const verticalAlignmentOptions = [
|
|
188
|
+
{
|
|
189
|
+
value: 'flex-start',
|
|
190
|
+
label: __( 'Align items top' ),
|
|
191
|
+
},
|
|
192
|
+
{
|
|
193
|
+
value: 'center',
|
|
194
|
+
label: __( 'Align items center' ),
|
|
195
|
+
},
|
|
196
|
+
{
|
|
197
|
+
value: 'flex-end',
|
|
198
|
+
label: __( 'Align items bottom' ),
|
|
199
|
+
},
|
|
200
|
+
];
|
|
201
|
+
|
|
202
|
+
return (
|
|
203
|
+
<fieldset className="block-editor-hooks__flex-layout-vertical-alignment-control">
|
|
204
|
+
<legend>{ __( 'Vertical alignment' ) }</legend>
|
|
205
|
+
<div>
|
|
206
|
+
{ verticalAlignmentOptions.map( ( value, icon, label ) => {
|
|
207
|
+
return (
|
|
208
|
+
<Button
|
|
209
|
+
key={ value }
|
|
210
|
+
label={ label }
|
|
211
|
+
icon={ icon }
|
|
212
|
+
isPressed={ verticalAlignment === value }
|
|
213
|
+
onClick={ () => onVerticalAlignmentChange( value ) }
|
|
214
|
+
/>
|
|
215
|
+
);
|
|
216
|
+
} ) }
|
|
217
|
+
</div>
|
|
218
|
+
</fieldset>
|
|
219
|
+
);
|
|
220
|
+
}
|
|
221
|
+
|
|
138
222
|
function FlexLayoutJustifyContentControl( {
|
|
139
223
|
layout,
|
|
140
224
|
onChange,
|
package/src/layouts/flow.js
CHANGED
|
@@ -14,7 +14,8 @@ import { Icon, positionCenter, stretchWide } from '@wordpress/icons';
|
|
|
14
14
|
*/
|
|
15
15
|
import useSetting from '../components/use-setting';
|
|
16
16
|
import { appendSelectors } from './utils';
|
|
17
|
-
import {
|
|
17
|
+
import { getGapBoxControlValueFromStyle } from '../hooks/gap';
|
|
18
|
+
import { shouldSkipSerialization } from '../hooks/utils';
|
|
18
19
|
|
|
19
20
|
export default {
|
|
20
21
|
name: 'default',
|
|
@@ -106,15 +107,25 @@ export default {
|
|
|
106
107
|
toolBarControls: function DefaultLayoutToolbarControls() {
|
|
107
108
|
return null;
|
|
108
109
|
},
|
|
109
|
-
save: function DefaultLayoutStyle( {
|
|
110
|
+
save: function DefaultLayoutStyle( {
|
|
111
|
+
selector,
|
|
112
|
+
layout = {},
|
|
113
|
+
style,
|
|
114
|
+
blockName,
|
|
115
|
+
} ) {
|
|
110
116
|
const { contentSize, wideSize } = layout;
|
|
111
117
|
const blockGapSupport = useSetting( 'spacing.blockGap' );
|
|
112
118
|
const hasBlockGapStylesSupport = blockGapSupport !== null;
|
|
113
|
-
const blockGapStyleValue =
|
|
119
|
+
const blockGapStyleValue = getGapBoxControlValueFromStyle(
|
|
114
120
|
style?.spacing?.blockGap
|
|
115
121
|
);
|
|
122
|
+
// If a block's block.json skips serialization for spacing or
|
|
123
|
+
// spacing.blockGap, don't apply the user-defined value to the styles.
|
|
116
124
|
const blockGapValue =
|
|
117
|
-
blockGapStyleValue?.top
|
|
125
|
+
blockGapStyleValue?.top &&
|
|
126
|
+
! shouldSkipSerialization( blockName, 'spacing', 'blockGap' )
|
|
127
|
+
? blockGapStyleValue?.top
|
|
128
|
+
: 'var( --wp--style--block-gap )';
|
|
118
129
|
|
|
119
130
|
let output =
|
|
120
131
|
!! contentSize || !! wideSize
|
package/src/store/actions.js
CHANGED
|
@@ -22,6 +22,11 @@ import { __, _n, sprintf } from '@wordpress/i18n';
|
|
|
22
22
|
import { create, insert, remove, toHTMLString } from '@wordpress/rich-text';
|
|
23
23
|
import deprecated from '@wordpress/deprecated';
|
|
24
24
|
|
|
25
|
+
/**
|
|
26
|
+
* Internal dependencies
|
|
27
|
+
*/
|
|
28
|
+
import { mapRichTextSettings } from './utils';
|
|
29
|
+
|
|
25
30
|
/**
|
|
26
31
|
* Action which will insert a default block insert action if there
|
|
27
32
|
* are no other blocks at the root of the editor. This action should be used
|
|
@@ -100,6 +105,15 @@ export const validateBlocksToTemplate = ( blocks ) => ( {
|
|
|
100
105
|
* text value. See `wp.richText.create`.
|
|
101
106
|
*/
|
|
102
107
|
|
|
108
|
+
/**
|
|
109
|
+
* A selection object.
|
|
110
|
+
*
|
|
111
|
+
* @typedef {Object} WPSelection
|
|
112
|
+
*
|
|
113
|
+
* @property {WPBlockSelection} start The selection start.
|
|
114
|
+
* @property {WPBlockSelection} end The selection end.
|
|
115
|
+
*/
|
|
116
|
+
|
|
103
117
|
/* eslint-disable jsdoc/valid-types */
|
|
104
118
|
/**
|
|
105
119
|
* Returns an action object used in signalling that selection state should be
|
|
@@ -601,7 +615,7 @@ export const insertBlocks = (
|
|
|
601
615
|
* @param {?string} rootClientId Optional root client ID of block list on
|
|
602
616
|
* which to insert.
|
|
603
617
|
* @param {?number} index Index at which block should be inserted.
|
|
604
|
-
* @param {Object} __unstableOptions
|
|
618
|
+
* @param {Object} __unstableOptions Whether or not to show an inserter button.
|
|
605
619
|
*
|
|
606
620
|
* @return {Object} Action object.
|
|
607
621
|
*/
|
|
@@ -658,6 +672,313 @@ export const synchronizeTemplate = () => ( { select, dispatch } ) => {
|
|
|
658
672
|
dispatch.resetBlocks( updatedBlockList );
|
|
659
673
|
};
|
|
660
674
|
|
|
675
|
+
/**
|
|
676
|
+
* Delete the current selection.
|
|
677
|
+
*
|
|
678
|
+
* @param {boolean} isForward
|
|
679
|
+
*/
|
|
680
|
+
export const __unstableDeleteSelection = ( isForward ) => ( {
|
|
681
|
+
registry,
|
|
682
|
+
select,
|
|
683
|
+
dispatch,
|
|
684
|
+
} ) => {
|
|
685
|
+
const selectionAnchor = select.getSelectionStart();
|
|
686
|
+
const selectionFocus = select.getSelectionEnd();
|
|
687
|
+
|
|
688
|
+
if ( selectionAnchor.clientId === selectionFocus.clientId ) return;
|
|
689
|
+
|
|
690
|
+
// It's not mergeable if there's no rich text selection.
|
|
691
|
+
if (
|
|
692
|
+
! selectionAnchor.attributeKey ||
|
|
693
|
+
! selectionFocus.attributeKey ||
|
|
694
|
+
typeof selectionAnchor.offset === 'undefined' ||
|
|
695
|
+
typeof selectionFocus.offset === 'undefined'
|
|
696
|
+
)
|
|
697
|
+
return false;
|
|
698
|
+
|
|
699
|
+
const anchorRootClientId = select.getBlockRootClientId(
|
|
700
|
+
selectionAnchor.clientId
|
|
701
|
+
);
|
|
702
|
+
const focusRootClientId = select.getBlockRootClientId(
|
|
703
|
+
selectionFocus.clientId
|
|
704
|
+
);
|
|
705
|
+
|
|
706
|
+
// It's not mergeable if the selection doesn't start and end in the same
|
|
707
|
+
// block list. Maybe in the future it should be allowed.
|
|
708
|
+
if ( anchorRootClientId !== focusRootClientId ) {
|
|
709
|
+
return;
|
|
710
|
+
}
|
|
711
|
+
|
|
712
|
+
const blockOrder = select.getBlockOrder( anchorRootClientId );
|
|
713
|
+
const anchorIndex = blockOrder.indexOf( selectionAnchor.clientId );
|
|
714
|
+
const focusIndex = blockOrder.indexOf( selectionFocus.clientId );
|
|
715
|
+
|
|
716
|
+
// Reassign selection start and end based on order.
|
|
717
|
+
let selectionStart, selectionEnd;
|
|
718
|
+
|
|
719
|
+
if ( anchorIndex > focusIndex ) {
|
|
720
|
+
selectionStart = selectionFocus;
|
|
721
|
+
selectionEnd = selectionAnchor;
|
|
722
|
+
} else {
|
|
723
|
+
selectionStart = selectionAnchor;
|
|
724
|
+
selectionEnd = selectionFocus;
|
|
725
|
+
}
|
|
726
|
+
|
|
727
|
+
const targetSelection = isForward ? selectionEnd : selectionStart;
|
|
728
|
+
const targetBlock = select.getBlock( targetSelection.clientId );
|
|
729
|
+
const targetBlockType = getBlockType( targetBlock.name );
|
|
730
|
+
|
|
731
|
+
if ( ! targetBlockType.merge ) {
|
|
732
|
+
return;
|
|
733
|
+
}
|
|
734
|
+
|
|
735
|
+
const selectionA = selectionStart;
|
|
736
|
+
const selectionB = selectionEnd;
|
|
737
|
+
|
|
738
|
+
const blockA = select.getBlock( selectionA.clientId );
|
|
739
|
+
const blockAType = getBlockType( blockA.name );
|
|
740
|
+
|
|
741
|
+
const blockB = select.getBlock( selectionB.clientId );
|
|
742
|
+
const blockBType = getBlockType( blockB.name );
|
|
743
|
+
|
|
744
|
+
const htmlA = blockA.attributes[ selectionA.attributeKey ];
|
|
745
|
+
const htmlB = blockB.attributes[ selectionB.attributeKey ];
|
|
746
|
+
|
|
747
|
+
const attributeDefinitionA =
|
|
748
|
+
blockAType.attributes[ selectionA.attributeKey ];
|
|
749
|
+
const attributeDefinitionB =
|
|
750
|
+
blockBType.attributes[ selectionB.attributeKey ];
|
|
751
|
+
|
|
752
|
+
let valueA = create( {
|
|
753
|
+
html: htmlA,
|
|
754
|
+
...mapRichTextSettings( attributeDefinitionA ),
|
|
755
|
+
} );
|
|
756
|
+
let valueB = create( {
|
|
757
|
+
html: htmlB,
|
|
758
|
+
...mapRichTextSettings( attributeDefinitionB ),
|
|
759
|
+
} );
|
|
760
|
+
|
|
761
|
+
// A robust way to retain selection position through various transforms
|
|
762
|
+
// is to insert a special character at the position and then recover it.
|
|
763
|
+
const START_OF_SELECTED_AREA = '\u0086';
|
|
764
|
+
|
|
765
|
+
valueA = remove( valueA, selectionA.offset, valueA.text.length );
|
|
766
|
+
valueB = insert( valueB, START_OF_SELECTED_AREA, 0, selectionB.offset );
|
|
767
|
+
|
|
768
|
+
// Clone the blocks so we don't manipulate the original.
|
|
769
|
+
const cloneA = cloneBlock( blockA, {
|
|
770
|
+
[ selectionA.attributeKey ]: toHTMLString( {
|
|
771
|
+
value: valueA,
|
|
772
|
+
...mapRichTextSettings( attributeDefinitionA ),
|
|
773
|
+
} ),
|
|
774
|
+
} );
|
|
775
|
+
const cloneB = cloneBlock( blockB, {
|
|
776
|
+
[ selectionB.attributeKey ]: toHTMLString( {
|
|
777
|
+
value: valueB,
|
|
778
|
+
...mapRichTextSettings( attributeDefinitionB ),
|
|
779
|
+
} ),
|
|
780
|
+
} );
|
|
781
|
+
|
|
782
|
+
const followingBlock = isForward ? cloneA : cloneB;
|
|
783
|
+
|
|
784
|
+
// We can only merge blocks with similar types
|
|
785
|
+
// thus, we transform the block to merge first
|
|
786
|
+
const blocksWithTheSameType =
|
|
787
|
+
blockA.name === blockB.name
|
|
788
|
+
? [ followingBlock ]
|
|
789
|
+
: switchToBlockType( followingBlock, targetBlockType.name );
|
|
790
|
+
|
|
791
|
+
// If the block types can not match, do nothing
|
|
792
|
+
if ( ! blocksWithTheSameType || ! blocksWithTheSameType.length ) {
|
|
793
|
+
return;
|
|
794
|
+
}
|
|
795
|
+
|
|
796
|
+
let updatedAttributes;
|
|
797
|
+
|
|
798
|
+
if ( isForward ) {
|
|
799
|
+
const blockToMerge = blocksWithTheSameType.pop();
|
|
800
|
+
updatedAttributes = targetBlockType.merge(
|
|
801
|
+
blockToMerge.attributes,
|
|
802
|
+
cloneB.attributes
|
|
803
|
+
);
|
|
804
|
+
} else {
|
|
805
|
+
const blockToMerge = blocksWithTheSameType.shift();
|
|
806
|
+
updatedAttributes = targetBlockType.merge(
|
|
807
|
+
cloneA.attributes,
|
|
808
|
+
blockToMerge.attributes
|
|
809
|
+
);
|
|
810
|
+
}
|
|
811
|
+
|
|
812
|
+
const newAttributeKey = findKey(
|
|
813
|
+
updatedAttributes,
|
|
814
|
+
( v ) =>
|
|
815
|
+
typeof v === 'string' && v.indexOf( START_OF_SELECTED_AREA ) !== -1
|
|
816
|
+
);
|
|
817
|
+
|
|
818
|
+
const convertedHtml = updatedAttributes[ newAttributeKey ];
|
|
819
|
+
const convertedValue = create( {
|
|
820
|
+
html: convertedHtml,
|
|
821
|
+
...mapRichTextSettings( targetBlockType.attributes[ newAttributeKey ] ),
|
|
822
|
+
} );
|
|
823
|
+
const newOffset = convertedValue.text.indexOf( START_OF_SELECTED_AREA );
|
|
824
|
+
const newValue = remove( convertedValue, newOffset, newOffset + 1 );
|
|
825
|
+
const newHtml = toHTMLString( {
|
|
826
|
+
value: newValue,
|
|
827
|
+
...mapRichTextSettings( targetBlockType.attributes[ newAttributeKey ] ),
|
|
828
|
+
} );
|
|
829
|
+
|
|
830
|
+
updatedAttributes[ newAttributeKey ] = newHtml;
|
|
831
|
+
|
|
832
|
+
const selectedBlockClientIds = select.getSelectedBlockClientIds();
|
|
833
|
+
const replacement = [
|
|
834
|
+
...( isForward ? blocksWithTheSameType : [] ),
|
|
835
|
+
{
|
|
836
|
+
// Preserve the original client ID.
|
|
837
|
+
...targetBlock,
|
|
838
|
+
attributes: {
|
|
839
|
+
...targetBlock.attributes,
|
|
840
|
+
...updatedAttributes,
|
|
841
|
+
},
|
|
842
|
+
},
|
|
843
|
+
...( isForward ? [] : blocksWithTheSameType ),
|
|
844
|
+
];
|
|
845
|
+
|
|
846
|
+
registry.batch( () => {
|
|
847
|
+
dispatch.selectionChange(
|
|
848
|
+
targetBlock.clientId,
|
|
849
|
+
newAttributeKey,
|
|
850
|
+
newOffset,
|
|
851
|
+
newOffset
|
|
852
|
+
);
|
|
853
|
+
|
|
854
|
+
dispatch.replaceBlocks(
|
|
855
|
+
selectedBlockClientIds,
|
|
856
|
+
replacement,
|
|
857
|
+
0, // If we don't pass the `indexToSelect` it will default to the last block.
|
|
858
|
+
select.getSelectedBlocksInitialCaretPosition()
|
|
859
|
+
);
|
|
860
|
+
} );
|
|
861
|
+
};
|
|
862
|
+
|
|
863
|
+
/**
|
|
864
|
+
* Split the current selection.
|
|
865
|
+
*/
|
|
866
|
+
export const __unstableSplitSelection = () => ( { select, dispatch } ) => {
|
|
867
|
+
const selectionAnchor = select.getSelectionStart();
|
|
868
|
+
const selectionFocus = select.getSelectionEnd();
|
|
869
|
+
|
|
870
|
+
if ( selectionAnchor.clientId === selectionFocus.clientId ) return;
|
|
871
|
+
|
|
872
|
+
// Can't split if the selection is not set.
|
|
873
|
+
if (
|
|
874
|
+
! selectionAnchor.attributeKey ||
|
|
875
|
+
! selectionFocus.attributeKey ||
|
|
876
|
+
typeof selectionAnchor.offset === 'undefined' ||
|
|
877
|
+
typeof selectionFocus.offset === 'undefined'
|
|
878
|
+
)
|
|
879
|
+
return;
|
|
880
|
+
|
|
881
|
+
const anchorRootClientId = select.getBlockRootClientId(
|
|
882
|
+
selectionAnchor.clientId
|
|
883
|
+
);
|
|
884
|
+
const focusRootClientId = select.getBlockRootClientId(
|
|
885
|
+
selectionFocus.clientId
|
|
886
|
+
);
|
|
887
|
+
|
|
888
|
+
// It's not splittable if the selection doesn't start and end in the same
|
|
889
|
+
// block list. Maybe in the future it should be allowed.
|
|
890
|
+
if ( anchorRootClientId !== focusRootClientId ) {
|
|
891
|
+
return;
|
|
892
|
+
}
|
|
893
|
+
|
|
894
|
+
const blockOrder = select.getBlockOrder( anchorRootClientId );
|
|
895
|
+
const anchorIndex = blockOrder.indexOf( selectionAnchor.clientId );
|
|
896
|
+
const focusIndex = blockOrder.indexOf( selectionFocus.clientId );
|
|
897
|
+
|
|
898
|
+
// Reassign selection start and end based on order.
|
|
899
|
+
let selectionStart, selectionEnd;
|
|
900
|
+
|
|
901
|
+
if ( anchorIndex > focusIndex ) {
|
|
902
|
+
selectionStart = selectionFocus;
|
|
903
|
+
selectionEnd = selectionAnchor;
|
|
904
|
+
} else {
|
|
905
|
+
selectionStart = selectionAnchor;
|
|
906
|
+
selectionEnd = selectionFocus;
|
|
907
|
+
}
|
|
908
|
+
|
|
909
|
+
const selectionA = selectionStart;
|
|
910
|
+
const selectionB = selectionEnd;
|
|
911
|
+
|
|
912
|
+
const blockA = select.getBlock( selectionA.clientId );
|
|
913
|
+
const blockAType = getBlockType( blockA.name );
|
|
914
|
+
|
|
915
|
+
const blockB = select.getBlock( selectionB.clientId );
|
|
916
|
+
const blockBType = getBlockType( blockB.name );
|
|
917
|
+
|
|
918
|
+
const htmlA = blockA.attributes[ selectionA.attributeKey ];
|
|
919
|
+
const htmlB = blockB.attributes[ selectionB.attributeKey ];
|
|
920
|
+
|
|
921
|
+
const attributeDefinitionA =
|
|
922
|
+
blockAType.attributes[ selectionA.attributeKey ];
|
|
923
|
+
const attributeDefinitionB =
|
|
924
|
+
blockBType.attributes[ selectionB.attributeKey ];
|
|
925
|
+
|
|
926
|
+
let valueA = create( {
|
|
927
|
+
html: htmlA,
|
|
928
|
+
...mapRichTextSettings( attributeDefinitionA ),
|
|
929
|
+
} );
|
|
930
|
+
let valueB = create( {
|
|
931
|
+
html: htmlB,
|
|
932
|
+
...mapRichTextSettings( attributeDefinitionB ),
|
|
933
|
+
} );
|
|
934
|
+
|
|
935
|
+
valueA = remove( valueA, selectionA.offset, valueA.text.length );
|
|
936
|
+
valueB = remove( valueB, 0, selectionB.offset );
|
|
937
|
+
|
|
938
|
+
dispatch.replaceBlocks(
|
|
939
|
+
select.getSelectedBlockClientIds(),
|
|
940
|
+
[
|
|
941
|
+
{
|
|
942
|
+
// Preserve the original client ID.
|
|
943
|
+
...blockA,
|
|
944
|
+
attributes: {
|
|
945
|
+
...blockA.attributes,
|
|
946
|
+
[ selectionA.attributeKey ]: toHTMLString( {
|
|
947
|
+
value: valueA,
|
|
948
|
+
...mapRichTextSettings( attributeDefinitionA ),
|
|
949
|
+
} ),
|
|
950
|
+
},
|
|
951
|
+
},
|
|
952
|
+
createBlock( getDefaultBlockName() ),
|
|
953
|
+
{
|
|
954
|
+
// Preserve the original client ID.
|
|
955
|
+
...blockB,
|
|
956
|
+
attributes: {
|
|
957
|
+
...blockB.attributes,
|
|
958
|
+
[ selectionB.attributeKey ]: toHTMLString( {
|
|
959
|
+
value: valueB,
|
|
960
|
+
...mapRichTextSettings( attributeDefinitionB ),
|
|
961
|
+
} ),
|
|
962
|
+
},
|
|
963
|
+
},
|
|
964
|
+
],
|
|
965
|
+
1, // If we don't pass the `indexToSelect` it will default to the last block.
|
|
966
|
+
select.getSelectedBlocksInitialCaretPosition()
|
|
967
|
+
);
|
|
968
|
+
};
|
|
969
|
+
|
|
970
|
+
/**
|
|
971
|
+
* Expand the selection to cover the entire blocks, removing partial selection.
|
|
972
|
+
*/
|
|
973
|
+
export const __unstableExpandSelection = () => ( { select, dispatch } ) => {
|
|
974
|
+
const selectionAnchor = select.getSelectionStart();
|
|
975
|
+
const selectionFocus = select.getSelectionEnd();
|
|
976
|
+
dispatch.selectionChange( {
|
|
977
|
+
start: { clientId: selectionAnchor.clientId },
|
|
978
|
+
end: { clientId: selectionFocus.clientId },
|
|
979
|
+
} );
|
|
980
|
+
};
|
|
981
|
+
|
|
661
982
|
/**
|
|
662
983
|
* Action that merges two blocks.
|
|
663
984
|
*
|
|
@@ -719,17 +1040,10 @@ export const mergeBlocks = ( firstBlockClientId, secondBlockClientId ) => ( {
|
|
|
719
1040
|
if ( canRestoreTextSelection ) {
|
|
720
1041
|
const selectedBlock = clientId === clientIdA ? cloneA : cloneB;
|
|
721
1042
|
const html = selectedBlock.attributes[ attributeKey ];
|
|
722
|
-
const {
|
|
723
|
-
multiline: multilineTag,
|
|
724
|
-
__unstableMultilineWrapperTags: multilineWrapperTags,
|
|
725
|
-
__unstablePreserveWhiteSpace: preserveWhiteSpace,
|
|
726
|
-
} = attributeDefinition;
|
|
727
1043
|
const value = insert(
|
|
728
1044
|
create( {
|
|
729
1045
|
html,
|
|
730
|
-
|
|
731
|
-
multilineWrapperTags,
|
|
732
|
-
preserveWhiteSpace,
|
|
1046
|
+
...mapRichTextSettings( attributeDefinition ),
|
|
733
1047
|
} ),
|
|
734
1048
|
START_OF_SELECTED_AREA,
|
|
735
1049
|
offset,
|
|
@@ -738,8 +1052,7 @@ export const mergeBlocks = ( firstBlockClientId, secondBlockClientId ) => ( {
|
|
|
738
1052
|
|
|
739
1053
|
selectedBlock.attributes[ attributeKey ] = toHTMLString( {
|
|
740
1054
|
value,
|
|
741
|
-
|
|
742
|
-
preserveWhiteSpace,
|
|
1055
|
+
...mapRichTextSettings( attributeDefinition ),
|
|
743
1056
|
} );
|
|
744
1057
|
}
|
|
745
1058
|
|
|
@@ -769,23 +1082,15 @@ export const mergeBlocks = ( firstBlockClientId, secondBlockClientId ) => ( {
|
|
|
769
1082
|
v.indexOf( START_OF_SELECTED_AREA ) !== -1
|
|
770
1083
|
);
|
|
771
1084
|
const convertedHtml = updatedAttributes[ newAttributeKey ];
|
|
772
|
-
const {
|
|
773
|
-
multiline: multilineTag,
|
|
774
|
-
__unstableMultilineWrapperTags: multilineWrapperTags,
|
|
775
|
-
__unstablePreserveWhiteSpace: preserveWhiteSpace,
|
|
776
|
-
} = blockAType.attributes[ newAttributeKey ];
|
|
777
1085
|
const convertedValue = create( {
|
|
778
1086
|
html: convertedHtml,
|
|
779
|
-
|
|
780
|
-
multilineWrapperTags,
|
|
781
|
-
preserveWhiteSpace,
|
|
1087
|
+
...mapRichTextSettings( blockAType.attributes[ newAttributeKey ] ),
|
|
782
1088
|
} );
|
|
783
1089
|
const newOffset = convertedValue.text.indexOf( START_OF_SELECTED_AREA );
|
|
784
1090
|
const newValue = remove( convertedValue, newOffset, newOffset + 1 );
|
|
785
1091
|
const newHtml = toHTMLString( {
|
|
786
1092
|
value: newValue,
|
|
787
|
-
|
|
788
|
-
preserveWhiteSpace,
|
|
1093
|
+
...mapRichTextSettings( blockAType.attributes[ newAttributeKey ] ),
|
|
789
1094
|
} );
|
|
790
1095
|
|
|
791
1096
|
updatedAttributes[ newAttributeKey ] = newHtml;
|
|
@@ -978,10 +1283,10 @@ export function exitFormattedText() {
|
|
|
978
1283
|
/**
|
|
979
1284
|
* Action that changes the position of the user caret.
|
|
980
1285
|
*
|
|
981
|
-
* @param {string} clientId The selected block client ID.
|
|
982
|
-
* @param {string}
|
|
983
|
-
* @param {number}
|
|
984
|
-
* @param {number}
|
|
1286
|
+
* @param {string|WPSelection} clientId The selected block client ID.
|
|
1287
|
+
* @param {string} attributeKey The selected block attribute key.
|
|
1288
|
+
* @param {number} startOffset The start offset.
|
|
1289
|
+
* @param {number} endOffset The end offset.
|
|
985
1290
|
*
|
|
986
1291
|
* @return {Object} Action object.
|
|
987
1292
|
*/
|
|
@@ -991,13 +1296,17 @@ export function selectionChange(
|
|
|
991
1296
|
startOffset,
|
|
992
1297
|
endOffset
|
|
993
1298
|
) {
|
|
994
|
-
|
|
995
|
-
|
|
996
|
-
|
|
997
|
-
|
|
998
|
-
|
|
999
|
-
|
|
1000
|
-
|
|
1299
|
+
if ( typeof clientId === 'string' ) {
|
|
1300
|
+
return {
|
|
1301
|
+
type: 'SELECTION_CHANGE',
|
|
1302
|
+
clientId,
|
|
1303
|
+
attributeKey,
|
|
1304
|
+
startOffset,
|
|
1305
|
+
endOffset,
|
|
1306
|
+
};
|
|
1307
|
+
}
|
|
1308
|
+
|
|
1309
|
+
return { type: 'SELECTION_CHANGE', ...clientId };
|
|
1001
1310
|
}
|
|
1002
1311
|
|
|
1003
1312
|
/**
|
package/src/store/defaults.js
CHANGED
|
@@ -23,12 +23,13 @@ export const PREFERENCES_DEFAULTS = {
|
|
|
23
23
|
* @property {boolean} keepCaretInsideBlock Whether caret should move between blocks in edit mode
|
|
24
24
|
* @property {string} bodyPlaceholder Empty post placeholder
|
|
25
25
|
* @property {string} titlePlaceholder Empty title placeholder
|
|
26
|
+
* @property {boolean} canLockBlocks Whether the user can manage Block Lock state
|
|
26
27
|
* @property {boolean} codeEditingEnabled Whether or not the user can switch to the code editor
|
|
28
|
+
* @property {boolean} generateAnchors Enable/Disable auto anchor generation for Heading blocks
|
|
27
29
|
* @property {boolean} __experimentalCanUserUseUnfilteredHTML Whether the user should be able to use unfiltered HTML or the HTML should be filtered e.g., to remove elements considered insecure like iframes.
|
|
28
30
|
* @property {boolean} __experimentalBlockDirectory Whether the user has enabled the Block Directory
|
|
29
31
|
* @property {Array} __experimentalBlockPatterns Array of objects representing the block patterns
|
|
30
32
|
* @property {Array} __experimentalBlockPatternCategories Array of objects representing the block pattern categories
|
|
31
|
-
* @property {boolean} __experimentalGenerateAnchors Enable/Disable auto anchor generation for Heading blocks
|
|
32
33
|
* @property {boolean} __unstableGalleryWithImageBlocks Whether the user has enabled the refactored gallery block which uses InnerBlocks
|
|
33
34
|
*/
|
|
34
35
|
export const SETTINGS_DEFAULTS = {
|
|
@@ -151,14 +152,18 @@ export const SETTINGS_DEFAULTS = {
|
|
|
151
152
|
// List of allowed mime types and file extensions.
|
|
152
153
|
allowedMimeTypes: null,
|
|
153
154
|
|
|
155
|
+
// Allows to disable block locking interface.
|
|
156
|
+
canLockBlocks: true,
|
|
157
|
+
|
|
154
158
|
__experimentalCanUserUseUnfilteredHTML: false,
|
|
155
159
|
__experimentalBlockDirectory: false,
|
|
156
160
|
__mobileEnablePageTemplates: false,
|
|
157
161
|
__experimentalBlockPatterns: [],
|
|
158
162
|
__experimentalBlockPatternCategories: [],
|
|
159
163
|
__experimentalSpotlightEntityBlocks: [],
|
|
160
|
-
__experimentalGenerateAnchors: false,
|
|
161
164
|
__unstableGalleryWithImageBlocks: false,
|
|
165
|
+
|
|
166
|
+
generateAnchors: false,
|
|
162
167
|
// gradients setting is not used anymore now defaults are passed from theme.json on the server and core has its own defaults.
|
|
163
168
|
// The setting is only kept for backward compatibility purposes.
|
|
164
169
|
gradients: [
|