@wordpress/block-editor 8.4.0 → 8.5.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +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-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/menu-item.js +9 -0
- package/build/components/block-lock/menu-item.js.map +1 -1
- package/build/components/block-lock/modal.js +4 -13
- package/build/components/block-lock/modal.js.map +1 -1
- package/build/components/block-lock/toolbar.js +11 -3
- package/build/components/block-lock/toolbar.js.map +1 -1
- package/build/components/block-mover/index.js +4 -0
- package/build/components/block-mover/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 +1 -1
- 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 +4 -0
- 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/list-view/block-select-button.js +25 -6
- package/build/components/list-view/block-select-button.js.map +1 -1
- package/build/components/list-view/block.js +5 -1
- 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 +297 -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 +142 -18
- package/build/store/selectors.js.map +1 -1
- 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-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/menu-item.js +9 -0
- package/build-module/components/block-lock/menu-item.js.map +1 -1
- package/build-module/components/block-lock/modal.js +5 -14
- package/build-module/components/block-lock/modal.js.map +1 -1
- package/build-module/components/block-lock/toolbar.js +11 -3
- package/build-module/components/block-lock/toolbar.js.map +1 -1
- 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-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 +2 -2
- 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 +4 -0
- 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/list-view/block-select-button.js +22 -6
- package/build-module/components/list-view/block-select-button.js.map +1 -1
- package/build-module/components/list-view/block.js +5 -1
- 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 +286 -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 +138 -19
- package/build-module/store/selectors.js.map +1 -1
- package/build-module/utils/dom.js +2 -1
- package/build-module/utils/dom.js.map +1 -1
- package/build-style/style-rtl.css +107 -74
- package/build-style/style.css +107 -74
- 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-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/menu-item.js +8 -1
- package/src/components/block-lock/modal.js +18 -13
- package/src/components/block-lock/style.scss +6 -3
- package/src/components/block-lock/toolbar.js +12 -2
- package/src/components/block-mover/index.js +3 -0
- package/src/components/block-mover/style.scss +4 -0
- package/src/components/block-settings-menu/block-settings-dropdown.js +62 -4
- package/src/components/block-switcher/index.js +2 -2
- package/src/components/block-switcher/style.scss +8 -1
- 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 +3 -0
- 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/list-view/block-select-button.js +21 -3
- package/src/components/list-view/block.js +8 -1
- 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 +349 -32
- package/src/store/defaults.js +7 -2
- package/src/store/reducer.js +25 -10
- package/src/store/selectors.js +181 -24
- package/src/store/test/selectors.js +242 -5
- 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
|
@@ -100,6 +100,15 @@ export const validateBlocksToTemplate = ( blocks ) => ( {
|
|
|
100
100
|
* text value. See `wp.richText.create`.
|
|
101
101
|
*/
|
|
102
102
|
|
|
103
|
+
/**
|
|
104
|
+
* A selection object.
|
|
105
|
+
*
|
|
106
|
+
* @typedef {Object} WPSelection
|
|
107
|
+
*
|
|
108
|
+
* @property {WPBlockSelection} start The selection start.
|
|
109
|
+
* @property {WPBlockSelection} end The selection end.
|
|
110
|
+
*/
|
|
111
|
+
|
|
103
112
|
/* eslint-disable jsdoc/valid-types */
|
|
104
113
|
/**
|
|
105
114
|
* Returns an action object used in signalling that selection state should be
|
|
@@ -601,7 +610,7 @@ export const insertBlocks = (
|
|
|
601
610
|
* @param {?string} rootClientId Optional root client ID of block list on
|
|
602
611
|
* which to insert.
|
|
603
612
|
* @param {?number} index Index at which block should be inserted.
|
|
604
|
-
* @param {Object} __unstableOptions
|
|
613
|
+
* @param {Object} __unstableOptions Whether or not to show an inserter button.
|
|
605
614
|
*
|
|
606
615
|
* @return {Object} Action object.
|
|
607
616
|
*/
|
|
@@ -658,6 +667,326 @@ export const synchronizeTemplate = () => ( { select, dispatch } ) => {
|
|
|
658
667
|
dispatch.resetBlocks( updatedBlockList );
|
|
659
668
|
};
|
|
660
669
|
|
|
670
|
+
function mapRichTextSettings( attributeDefinition ) {
|
|
671
|
+
const {
|
|
672
|
+
multiline: multilineTag,
|
|
673
|
+
__unstableMultilineWrapperTags: multilineWrapperTags,
|
|
674
|
+
__unstablePreserveWhiteSpace: preserveWhiteSpace,
|
|
675
|
+
} = attributeDefinition;
|
|
676
|
+
return {
|
|
677
|
+
multilineTag,
|
|
678
|
+
multilineWrapperTags,
|
|
679
|
+
preserveWhiteSpace,
|
|
680
|
+
};
|
|
681
|
+
}
|
|
682
|
+
|
|
683
|
+
/**
|
|
684
|
+
* Delete the current selection.
|
|
685
|
+
*
|
|
686
|
+
* @param {boolean} isForward
|
|
687
|
+
*/
|
|
688
|
+
export const __unstableDeleteSelection = ( isForward ) => ( {
|
|
689
|
+
registry,
|
|
690
|
+
select,
|
|
691
|
+
dispatch,
|
|
692
|
+
} ) => {
|
|
693
|
+
const selectionAnchor = select.getSelectionStart();
|
|
694
|
+
const selectionFocus = select.getSelectionEnd();
|
|
695
|
+
|
|
696
|
+
if ( selectionAnchor.clientId === selectionFocus.clientId ) return;
|
|
697
|
+
|
|
698
|
+
// It's not mergeable if there's no rich text selection.
|
|
699
|
+
if (
|
|
700
|
+
! selectionAnchor.attributeKey ||
|
|
701
|
+
! selectionFocus.attributeKey ||
|
|
702
|
+
typeof selectionAnchor.offset === 'undefined' ||
|
|
703
|
+
typeof selectionFocus.offset === 'undefined'
|
|
704
|
+
)
|
|
705
|
+
return false;
|
|
706
|
+
|
|
707
|
+
const anchorRootClientId = select.getBlockRootClientId(
|
|
708
|
+
selectionAnchor.clientId
|
|
709
|
+
);
|
|
710
|
+
const focusRootClientId = select.getBlockRootClientId(
|
|
711
|
+
selectionFocus.clientId
|
|
712
|
+
);
|
|
713
|
+
|
|
714
|
+
// It's not mergeable if the selection doesn't start and end in the same
|
|
715
|
+
// block list. Maybe in the future it should be allowed.
|
|
716
|
+
if ( anchorRootClientId !== focusRootClientId ) {
|
|
717
|
+
return;
|
|
718
|
+
}
|
|
719
|
+
|
|
720
|
+
const blockOrder = select.getBlockOrder( anchorRootClientId );
|
|
721
|
+
const anchorIndex = blockOrder.indexOf( selectionAnchor.clientId );
|
|
722
|
+
const focusIndex = blockOrder.indexOf( selectionFocus.clientId );
|
|
723
|
+
|
|
724
|
+
// Reassign selection start and end based on order.
|
|
725
|
+
let selectionStart, selectionEnd;
|
|
726
|
+
|
|
727
|
+
if ( anchorIndex > focusIndex ) {
|
|
728
|
+
selectionStart = selectionFocus;
|
|
729
|
+
selectionEnd = selectionAnchor;
|
|
730
|
+
} else {
|
|
731
|
+
selectionStart = selectionAnchor;
|
|
732
|
+
selectionEnd = selectionFocus;
|
|
733
|
+
}
|
|
734
|
+
|
|
735
|
+
const targetSelection = isForward ? selectionEnd : selectionStart;
|
|
736
|
+
const targetBlock = select.getBlock( targetSelection.clientId );
|
|
737
|
+
const targetBlockType = getBlockType( targetBlock.name );
|
|
738
|
+
|
|
739
|
+
if ( ! targetBlockType.merge ) {
|
|
740
|
+
return;
|
|
741
|
+
}
|
|
742
|
+
|
|
743
|
+
const selectionA = selectionStart;
|
|
744
|
+
const selectionB = selectionEnd;
|
|
745
|
+
|
|
746
|
+
const blockA = select.getBlock( selectionA.clientId );
|
|
747
|
+
const blockAType = getBlockType( blockA.name );
|
|
748
|
+
|
|
749
|
+
const blockB = select.getBlock( selectionB.clientId );
|
|
750
|
+
const blockBType = getBlockType( blockB.name );
|
|
751
|
+
|
|
752
|
+
const htmlA = blockA.attributes[ selectionA.attributeKey ];
|
|
753
|
+
const htmlB = blockB.attributes[ selectionB.attributeKey ];
|
|
754
|
+
|
|
755
|
+
const attributeDefinitionA =
|
|
756
|
+
blockAType.attributes[ selectionA.attributeKey ];
|
|
757
|
+
const attributeDefinitionB =
|
|
758
|
+
blockBType.attributes[ selectionB.attributeKey ];
|
|
759
|
+
|
|
760
|
+
let valueA = create( {
|
|
761
|
+
html: htmlA,
|
|
762
|
+
...mapRichTextSettings( attributeDefinitionA ),
|
|
763
|
+
} );
|
|
764
|
+
let valueB = create( {
|
|
765
|
+
html: htmlB,
|
|
766
|
+
...mapRichTextSettings( attributeDefinitionB ),
|
|
767
|
+
} );
|
|
768
|
+
|
|
769
|
+
// A robust way to retain selection position through various transforms
|
|
770
|
+
// is to insert a special character at the position and then recover it.
|
|
771
|
+
const START_OF_SELECTED_AREA = '\u0086';
|
|
772
|
+
|
|
773
|
+
valueA = remove( valueA, selectionA.offset, valueA.text.length );
|
|
774
|
+
valueB = insert( valueB, START_OF_SELECTED_AREA, 0, selectionB.offset );
|
|
775
|
+
|
|
776
|
+
// Clone the blocks so we don't manipulate the original.
|
|
777
|
+
const cloneA = cloneBlock( blockA, {
|
|
778
|
+
[ selectionA.attributeKey ]: toHTMLString( {
|
|
779
|
+
value: valueA,
|
|
780
|
+
...mapRichTextSettings( attributeDefinitionA ),
|
|
781
|
+
} ),
|
|
782
|
+
} );
|
|
783
|
+
const cloneB = cloneBlock( blockB, {
|
|
784
|
+
[ selectionB.attributeKey ]: toHTMLString( {
|
|
785
|
+
value: valueB,
|
|
786
|
+
...mapRichTextSettings( attributeDefinitionB ),
|
|
787
|
+
} ),
|
|
788
|
+
} );
|
|
789
|
+
|
|
790
|
+
const followingBlock = isForward ? cloneA : cloneB;
|
|
791
|
+
|
|
792
|
+
// We can only merge blocks with similar types
|
|
793
|
+
// thus, we transform the block to merge first
|
|
794
|
+
const blocksWithTheSameType =
|
|
795
|
+
blockA.name === blockB.name
|
|
796
|
+
? [ followingBlock ]
|
|
797
|
+
: switchToBlockType( followingBlock, targetBlockType.name );
|
|
798
|
+
|
|
799
|
+
// If the block types can not match, do nothing
|
|
800
|
+
if ( ! blocksWithTheSameType || ! blocksWithTheSameType.length ) {
|
|
801
|
+
return;
|
|
802
|
+
}
|
|
803
|
+
|
|
804
|
+
let updatedAttributes;
|
|
805
|
+
|
|
806
|
+
if ( isForward ) {
|
|
807
|
+
const blockToMerge = blocksWithTheSameType.pop();
|
|
808
|
+
updatedAttributes = targetBlockType.merge(
|
|
809
|
+
blockToMerge.attributes,
|
|
810
|
+
cloneB.attributes
|
|
811
|
+
);
|
|
812
|
+
} else {
|
|
813
|
+
const blockToMerge = blocksWithTheSameType.shift();
|
|
814
|
+
updatedAttributes = targetBlockType.merge(
|
|
815
|
+
cloneA.attributes,
|
|
816
|
+
blockToMerge.attributes
|
|
817
|
+
);
|
|
818
|
+
}
|
|
819
|
+
|
|
820
|
+
const newAttributeKey = findKey(
|
|
821
|
+
updatedAttributes,
|
|
822
|
+
( v ) =>
|
|
823
|
+
typeof v === 'string' && v.indexOf( START_OF_SELECTED_AREA ) !== -1
|
|
824
|
+
);
|
|
825
|
+
|
|
826
|
+
const convertedHtml = updatedAttributes[ newAttributeKey ];
|
|
827
|
+
const convertedValue = create( {
|
|
828
|
+
html: convertedHtml,
|
|
829
|
+
...mapRichTextSettings( targetBlockType.attributes[ newAttributeKey ] ),
|
|
830
|
+
} );
|
|
831
|
+
const newOffset = convertedValue.text.indexOf( START_OF_SELECTED_AREA );
|
|
832
|
+
const newValue = remove( convertedValue, newOffset, newOffset + 1 );
|
|
833
|
+
const newHtml = toHTMLString( {
|
|
834
|
+
value: newValue,
|
|
835
|
+
...mapRichTextSettings( targetBlockType.attributes[ newAttributeKey ] ),
|
|
836
|
+
} );
|
|
837
|
+
|
|
838
|
+
updatedAttributes[ newAttributeKey ] = newHtml;
|
|
839
|
+
|
|
840
|
+
const selectedBlockClientIds = select.getSelectedBlockClientIds();
|
|
841
|
+
const replacement = [
|
|
842
|
+
...( isForward ? blocksWithTheSameType : [] ),
|
|
843
|
+
{
|
|
844
|
+
// Preserve the original client ID.
|
|
845
|
+
...targetBlock,
|
|
846
|
+
attributes: {
|
|
847
|
+
...targetBlock.attributes,
|
|
848
|
+
...updatedAttributes,
|
|
849
|
+
},
|
|
850
|
+
},
|
|
851
|
+
...( isForward ? [] : blocksWithTheSameType ),
|
|
852
|
+
];
|
|
853
|
+
|
|
854
|
+
registry.batch( () => {
|
|
855
|
+
dispatch.selectionChange(
|
|
856
|
+
targetBlock.clientId,
|
|
857
|
+
newAttributeKey,
|
|
858
|
+
newOffset,
|
|
859
|
+
newOffset
|
|
860
|
+
);
|
|
861
|
+
|
|
862
|
+
dispatch.replaceBlocks(
|
|
863
|
+
selectedBlockClientIds,
|
|
864
|
+
replacement,
|
|
865
|
+
0, // If we don't pass the `indexToSelect` it will default to the last block.
|
|
866
|
+
select.getSelectedBlocksInitialCaretPosition()
|
|
867
|
+
);
|
|
868
|
+
} );
|
|
869
|
+
};
|
|
870
|
+
|
|
871
|
+
/**
|
|
872
|
+
* Split the current selection.
|
|
873
|
+
*/
|
|
874
|
+
export const __unstableSplitSelection = () => ( { select, dispatch } ) => {
|
|
875
|
+
const selectionAnchor = select.getSelectionStart();
|
|
876
|
+
const selectionFocus = select.getSelectionEnd();
|
|
877
|
+
|
|
878
|
+
if ( selectionAnchor.clientId === selectionFocus.clientId ) return;
|
|
879
|
+
|
|
880
|
+
// Can't split if the selection is not set.
|
|
881
|
+
if (
|
|
882
|
+
! selectionAnchor.attributeKey ||
|
|
883
|
+
! selectionFocus.attributeKey ||
|
|
884
|
+
typeof selectionAnchor.offset === 'undefined' ||
|
|
885
|
+
typeof selectionFocus.offset === 'undefined'
|
|
886
|
+
)
|
|
887
|
+
return;
|
|
888
|
+
|
|
889
|
+
const anchorRootClientId = select.getBlockRootClientId(
|
|
890
|
+
selectionAnchor.clientId
|
|
891
|
+
);
|
|
892
|
+
const focusRootClientId = select.getBlockRootClientId(
|
|
893
|
+
selectionFocus.clientId
|
|
894
|
+
);
|
|
895
|
+
|
|
896
|
+
// It's not splittable if the selection doesn't start and end in the same
|
|
897
|
+
// block list. Maybe in the future it should be allowed.
|
|
898
|
+
if ( anchorRootClientId !== focusRootClientId ) {
|
|
899
|
+
return;
|
|
900
|
+
}
|
|
901
|
+
|
|
902
|
+
const blockOrder = select.getBlockOrder( anchorRootClientId );
|
|
903
|
+
const anchorIndex = blockOrder.indexOf( selectionAnchor.clientId );
|
|
904
|
+
const focusIndex = blockOrder.indexOf( selectionFocus.clientId );
|
|
905
|
+
|
|
906
|
+
// Reassign selection start and end based on order.
|
|
907
|
+
let selectionStart, selectionEnd;
|
|
908
|
+
|
|
909
|
+
if ( anchorIndex > focusIndex ) {
|
|
910
|
+
selectionStart = selectionFocus;
|
|
911
|
+
selectionEnd = selectionAnchor;
|
|
912
|
+
} else {
|
|
913
|
+
selectionStart = selectionAnchor;
|
|
914
|
+
selectionEnd = selectionFocus;
|
|
915
|
+
}
|
|
916
|
+
|
|
917
|
+
const selectionA = selectionStart;
|
|
918
|
+
const selectionB = selectionEnd;
|
|
919
|
+
|
|
920
|
+
const blockA = select.getBlock( selectionA.clientId );
|
|
921
|
+
const blockAType = getBlockType( blockA.name );
|
|
922
|
+
|
|
923
|
+
const blockB = select.getBlock( selectionB.clientId );
|
|
924
|
+
const blockBType = getBlockType( blockB.name );
|
|
925
|
+
|
|
926
|
+
const htmlA = blockA.attributes[ selectionA.attributeKey ];
|
|
927
|
+
const htmlB = blockB.attributes[ selectionB.attributeKey ];
|
|
928
|
+
|
|
929
|
+
const attributeDefinitionA =
|
|
930
|
+
blockAType.attributes[ selectionA.attributeKey ];
|
|
931
|
+
const attributeDefinitionB =
|
|
932
|
+
blockBType.attributes[ selectionB.attributeKey ];
|
|
933
|
+
|
|
934
|
+
let valueA = create( {
|
|
935
|
+
html: htmlA,
|
|
936
|
+
...mapRichTextSettings( attributeDefinitionA ),
|
|
937
|
+
} );
|
|
938
|
+
let valueB = create( {
|
|
939
|
+
html: htmlB,
|
|
940
|
+
...mapRichTextSettings( attributeDefinitionB ),
|
|
941
|
+
} );
|
|
942
|
+
|
|
943
|
+
valueA = remove( valueA, selectionA.offset, valueA.text.length );
|
|
944
|
+
valueB = remove( valueB, 0, selectionB.offset );
|
|
945
|
+
|
|
946
|
+
dispatch.replaceBlocks(
|
|
947
|
+
select.getSelectedBlockClientIds(),
|
|
948
|
+
[
|
|
949
|
+
{
|
|
950
|
+
// Preserve the original client ID.
|
|
951
|
+
...blockA,
|
|
952
|
+
attributes: {
|
|
953
|
+
...blockA.attributes,
|
|
954
|
+
[ selectionA.attributeKey ]: toHTMLString( {
|
|
955
|
+
value: valueA,
|
|
956
|
+
...mapRichTextSettings( attributeDefinitionA ),
|
|
957
|
+
} ),
|
|
958
|
+
},
|
|
959
|
+
},
|
|
960
|
+
createBlock( getDefaultBlockName() ),
|
|
961
|
+
{
|
|
962
|
+
// Preserve the original client ID.
|
|
963
|
+
...blockB,
|
|
964
|
+
attributes: {
|
|
965
|
+
...blockB.attributes,
|
|
966
|
+
[ selectionB.attributeKey ]: toHTMLString( {
|
|
967
|
+
value: valueB,
|
|
968
|
+
...mapRichTextSettings( attributeDefinitionB ),
|
|
969
|
+
} ),
|
|
970
|
+
},
|
|
971
|
+
},
|
|
972
|
+
],
|
|
973
|
+
1, // If we don't pass the `indexToSelect` it will default to the last block.
|
|
974
|
+
select.getSelectedBlocksInitialCaretPosition()
|
|
975
|
+
);
|
|
976
|
+
};
|
|
977
|
+
|
|
978
|
+
/**
|
|
979
|
+
* Expand the selection to cover the entire blocks, removing partial selection.
|
|
980
|
+
*/
|
|
981
|
+
export const __unstableExpandSelection = () => ( { select, dispatch } ) => {
|
|
982
|
+
const selectionAnchor = select.getSelectionStart();
|
|
983
|
+
const selectionFocus = select.getSelectionEnd();
|
|
984
|
+
dispatch.selectionChange( {
|
|
985
|
+
start: { clientId: selectionAnchor.clientId },
|
|
986
|
+
end: { clientId: selectionFocus.clientId },
|
|
987
|
+
} );
|
|
988
|
+
};
|
|
989
|
+
|
|
661
990
|
/**
|
|
662
991
|
* Action that merges two blocks.
|
|
663
992
|
*
|
|
@@ -719,17 +1048,10 @@ export const mergeBlocks = ( firstBlockClientId, secondBlockClientId ) => ( {
|
|
|
719
1048
|
if ( canRestoreTextSelection ) {
|
|
720
1049
|
const selectedBlock = clientId === clientIdA ? cloneA : cloneB;
|
|
721
1050
|
const html = selectedBlock.attributes[ attributeKey ];
|
|
722
|
-
const {
|
|
723
|
-
multiline: multilineTag,
|
|
724
|
-
__unstableMultilineWrapperTags: multilineWrapperTags,
|
|
725
|
-
__unstablePreserveWhiteSpace: preserveWhiteSpace,
|
|
726
|
-
} = attributeDefinition;
|
|
727
1051
|
const value = insert(
|
|
728
1052
|
create( {
|
|
729
1053
|
html,
|
|
730
|
-
|
|
731
|
-
multilineWrapperTags,
|
|
732
|
-
preserveWhiteSpace,
|
|
1054
|
+
...mapRichTextSettings( attributeDefinition ),
|
|
733
1055
|
} ),
|
|
734
1056
|
START_OF_SELECTED_AREA,
|
|
735
1057
|
offset,
|
|
@@ -738,8 +1060,7 @@ export const mergeBlocks = ( firstBlockClientId, secondBlockClientId ) => ( {
|
|
|
738
1060
|
|
|
739
1061
|
selectedBlock.attributes[ attributeKey ] = toHTMLString( {
|
|
740
1062
|
value,
|
|
741
|
-
|
|
742
|
-
preserveWhiteSpace,
|
|
1063
|
+
...mapRichTextSettings( attributeDefinition ),
|
|
743
1064
|
} );
|
|
744
1065
|
}
|
|
745
1066
|
|
|
@@ -769,23 +1090,15 @@ export const mergeBlocks = ( firstBlockClientId, secondBlockClientId ) => ( {
|
|
|
769
1090
|
v.indexOf( START_OF_SELECTED_AREA ) !== -1
|
|
770
1091
|
);
|
|
771
1092
|
const convertedHtml = updatedAttributes[ newAttributeKey ];
|
|
772
|
-
const {
|
|
773
|
-
multiline: multilineTag,
|
|
774
|
-
__unstableMultilineWrapperTags: multilineWrapperTags,
|
|
775
|
-
__unstablePreserveWhiteSpace: preserveWhiteSpace,
|
|
776
|
-
} = blockAType.attributes[ newAttributeKey ];
|
|
777
1093
|
const convertedValue = create( {
|
|
778
1094
|
html: convertedHtml,
|
|
779
|
-
|
|
780
|
-
multilineWrapperTags,
|
|
781
|
-
preserveWhiteSpace,
|
|
1095
|
+
...mapRichTextSettings( blockAType.attributes[ newAttributeKey ] ),
|
|
782
1096
|
} );
|
|
783
1097
|
const newOffset = convertedValue.text.indexOf( START_OF_SELECTED_AREA );
|
|
784
1098
|
const newValue = remove( convertedValue, newOffset, newOffset + 1 );
|
|
785
1099
|
const newHtml = toHTMLString( {
|
|
786
1100
|
value: newValue,
|
|
787
|
-
|
|
788
|
-
preserveWhiteSpace,
|
|
1101
|
+
...mapRichTextSettings( blockAType.attributes[ newAttributeKey ] ),
|
|
789
1102
|
} );
|
|
790
1103
|
|
|
791
1104
|
updatedAttributes[ newAttributeKey ] = newHtml;
|
|
@@ -978,10 +1291,10 @@ export function exitFormattedText() {
|
|
|
978
1291
|
/**
|
|
979
1292
|
* Action that changes the position of the user caret.
|
|
980
1293
|
*
|
|
981
|
-
* @param {string} clientId The selected block client ID.
|
|
982
|
-
* @param {string}
|
|
983
|
-
* @param {number}
|
|
984
|
-
* @param {number}
|
|
1294
|
+
* @param {string|WPSelection} clientId The selected block client ID.
|
|
1295
|
+
* @param {string} attributeKey The selected block attribute key.
|
|
1296
|
+
* @param {number} startOffset The start offset.
|
|
1297
|
+
* @param {number} endOffset The end offset.
|
|
985
1298
|
*
|
|
986
1299
|
* @return {Object} Action object.
|
|
987
1300
|
*/
|
|
@@ -991,13 +1304,17 @@ export function selectionChange(
|
|
|
991
1304
|
startOffset,
|
|
992
1305
|
endOffset
|
|
993
1306
|
) {
|
|
994
|
-
|
|
995
|
-
|
|
996
|
-
|
|
997
|
-
|
|
998
|
-
|
|
999
|
-
|
|
1000
|
-
|
|
1307
|
+
if ( typeof clientId === 'string' ) {
|
|
1308
|
+
return {
|
|
1309
|
+
type: 'SELECTION_CHANGE',
|
|
1310
|
+
clientId,
|
|
1311
|
+
attributeKey,
|
|
1312
|
+
startOffset,
|
|
1313
|
+
endOffset,
|
|
1314
|
+
};
|
|
1315
|
+
}
|
|
1316
|
+
|
|
1317
|
+
return { type: 'SELECTION_CHANGE', ...clientId };
|
|
1001
1318
|
}
|
|
1002
1319
|
|
|
1003
1320
|
/**
|
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: [
|