@wordpress/block-editor 8.3.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 +4 -0
- package/README.md +56 -18
- 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/block-html.js +4 -1
- package/build/components/block-list/block-html.js.map +1 -1
- package/build/components/block-list/block.js +4 -1
- package/build/components/block-list/block.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 +22 -6
- 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 +32 -0
- package/build/components/block-lock/index.js.map +1 -0
- package/build/components/block-lock/menu-item.js +67 -0
- package/build/components/block-lock/menu-item.js.map +1 -0
- package/build/components/block-lock/modal.js +134 -0
- package/build/components/block-lock/modal.js.map +1 -0
- package/build/components/block-lock/toolbar.js +78 -0
- package/build/components/block-lock/toolbar.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-settings-menu/block-settings-dropdown.js +75 -10
- package/build/components/block-settings-menu/block-settings-dropdown.js.map +1 -1
- package/build/components/block-settings-menu-controls/index.js +19 -9
- package/build/components/block-settings-menu-controls/index.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 +8 -6
- 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 +24 -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/border-radius-control/index.js +0 -1
- package/build/components/border-radius-control/index.js.map +1 -1
- package/build/components/border-radius-control/utils.js +1 -1
- package/build/components/border-radius-control/utils.js.map +1 -1
- package/build/components/colors-gradients/control.js +3 -1
- package/build/components/colors-gradients/control.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/date-format-picker/index.js +132 -0
- package/build/components/date-format-picker/index.js.map +1 -0
- 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 +27 -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 +15 -6
- package/build/components/line-height-control/index.js.map +1 -1
- package/build/components/list-view/block-select-button.js +24 -23
- package/build/components/list-view/block-select-button.js.map +1 -1
- package/build/components/list-view/block.js +38 -13
- package/build/components/list-view/block.js.map +1 -1
- package/build/components/list-view/branch.js +16 -13
- package/build/components/list-view/branch.js.map +1 -1
- package/build/components/list-view/index.js +7 -1
- package/build/components/list-view/index.js.map +1 -1
- package/build/components/list-view/use-block-selection.js +9 -2
- package/build/components/list-view/use-block-selection.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 +27 -5
- package/build/components/rich-text/index.js.map +1 -1
- package/build/components/rich-text/index.native.js +13 -9
- package/build/components/rich-text/index.native.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/url-popover/image-url-input-ui.js +11 -27
- package/build/components/url-popover/image-url-input-ui.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/anchor.js +7 -6
- package/build/hooks/anchor.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 +77 -5
- 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 +82 -15
- package/build/layouts/flex.js.map +1 -1
- package/build/layouts/flow.js +22 -13
- 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 -1
- 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 +171 -21
- 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/block-html.js +5 -2
- package/build-module/components/block-list/block-html.js.map +1 -1
- package/build-module/components/block-list/block.js +5 -2
- package/build-module/components/block-list/block.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 +22 -6
- 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 +4 -0
- package/build-module/components/block-lock/index.js.map +1 -0
- package/build-module/components/block-lock/menu-item.js +53 -0
- package/build-module/components/block-lock/menu-item.js.map +1 -0
- package/build-module/components/block-lock/modal.js +119 -0
- package/build-module/components/block-lock/modal.js.map +1 -0
- package/build-module/components/block-lock/toolbar.js +63 -0
- package/build-module/components/block-lock/toolbar.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-settings-menu/block-settings-dropdown.js +75 -12
- package/build-module/components/block-settings-menu/block-settings-dropdown.js.map +1 -1
- package/build-module/components/block-settings-menu-controls/index.js +18 -9
- package/build-module/components/block-settings-menu-controls/index.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 +8 -6
- 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 +19 -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/border-radius-control/index.js +0 -1
- package/build-module/components/border-radius-control/index.js.map +1 -1
- package/build-module/components/border-radius-control/utils.js +1 -1
- package/build-module/components/border-radius-control/utils.js.map +1 -1
- package/build-module/components/colors-gradients/control.js +3 -1
- package/build-module/components/colors-gradients/control.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/date-format-picker/index.js +122 -0
- package/build-module/components/date-format-picker/index.js.map +1 -0
- 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 +3 -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 +14 -5
- package/build-module/components/line-height-control/index.js.map +1 -1
- package/build-module/components/list-view/block-select-button.js +24 -23
- package/build-module/components/list-view/block-select-button.js.map +1 -1
- package/build-module/components/list-view/block.js +36 -13
- package/build-module/components/list-view/block.js.map +1 -1
- package/build-module/components/list-view/branch.js +16 -13
- package/build-module/components/list-view/branch.js.map +1 -1
- package/build-module/components/list-view/index.js +7 -1
- package/build-module/components/list-view/index.js.map +1 -1
- package/build-module/components/list-view/use-block-selection.js +10 -3
- package/build-module/components/list-view/use-block-selection.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 +26 -5
- package/build-module/components/rich-text/index.js.map +1 -1
- package/build-module/components/rich-text/index.native.js +13 -9
- package/build-module/components/rich-text/index.native.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/url-popover/image-url-input-ui.js +12 -28
- package/build-module/components/url-popover/image-url-input-ui.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/anchor.js +7 -6
- package/build-module/hooks/anchor.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 +75 -7
- 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 +81 -16
- package/build-module/layouts/flex.js.map +1 -1
- package/build-module/layouts/flow.js +20 -13
- 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 -1
- 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 +162 -20
- 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 +214 -24
- package/build-style/style.css +214 -24
- package/build-types/utils/dom.d.ts.map +1 -1
- package/package.json +28 -27
- 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/block-html.js +8 -4
- package/src/components/block-list/block.js +5 -1
- 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 +27 -6
- 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 +3 -0
- package/src/components/block-lock/menu-item.js +59 -0
- package/src/components/block-lock/modal.js +170 -0
- package/src/components/block-lock/style.scss +70 -0
- package/src/components/block-lock/toolbar.js +68 -0
- 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 +109 -9
- package/src/components/block-settings-menu-controls/index.js +33 -12
- 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/README.md +6 -1
- package/src/components/block-title/index.js +2 -2
- package/src/components/block-title/test/index.js +43 -1
- package/src/components/block-title/use-block-display-title.js +10 -7
- 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 +24 -2
- package/src/components/block-toolbar/style.scss +10 -0
- package/src/components/block-tools/index.js +0 -19
- package/src/components/block-tools/style.scss +27 -0
- 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/border-radius-control/index.js +0 -1
- package/src/components/border-radius-control/test/utils.js +4 -0
- package/src/components/border-radius-control/utils.js +2 -1
- package/src/components/button-block-appender/style.scss +5 -1
- package/src/components/color-palette/test/__snapshots__/control.js.snap +70 -4
- package/src/components/colors-gradients/control.js +1 -1
- package/src/components/colors-gradients/style.scss +6 -0
- 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/date-format-picker/README.md +58 -0
- package/src/components/date-format-picker/index.js +161 -0
- package/src/components/date-format-picker/style.scss +31 -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 +3 -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 +11 -6
- package/src/components/link-control/README.md +1 -1
- package/src/components/list-view/block-select-button.js +21 -30
- package/src/components/list-view/block.js +55 -13
- package/src/components/list-view/branch.js +37 -15
- package/src/components/list-view/index.js +6 -0
- package/src/components/list-view/style.scss +56 -14
- package/src/components/list-view/use-block-selection.js +15 -2
- 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 +25 -2
- package/src/components/rich-text/index.native.js +24 -8
- 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/url-popover/image-url-input-ui.js +16 -29
- 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/anchor.js +8 -6
- 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 +91 -12
- package/src/hooks/layout.js +11 -1
- package/src/hooks/style.js +40 -4
- package/src/hooks/test/gap.js +66 -0
- 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 +93 -6
- package/src/layouts/flow.js +28 -12
- package/src/store/actions.js +349 -32
- package/src/store/defaults.js +7 -1
- package/src/store/reducer.js +25 -10
- package/src/store/selectors.js +207 -25
- package/src/store/test/selectors.js +305 -5
- package/src/style.scss +2 -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
|
@@ -0,0 +1,153 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* WordPress dependencies
|
|
3
|
+
*/
|
|
4
|
+
import { useSelect, useDispatch } from '@wordpress/data';
|
|
5
|
+
import { useRefEffect } from '@wordpress/compose';
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* Internal dependencies
|
|
9
|
+
*/
|
|
10
|
+
import { store as blockEditorStore } from '../../store';
|
|
11
|
+
import { getBlockClientId } from '../../utils/dom';
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* Extract the selection start node from the selection. When the anchor node is
|
|
15
|
+
* not a text node, the selection offset is the index of a child node.
|
|
16
|
+
*
|
|
17
|
+
* @param {Selection} selection The selection.
|
|
18
|
+
*
|
|
19
|
+
* @return {Element} The selection start node.
|
|
20
|
+
*/
|
|
21
|
+
function extractSelectionStartNode( selection ) {
|
|
22
|
+
const { anchorNode, anchorOffset } = selection;
|
|
23
|
+
|
|
24
|
+
if ( anchorNode.nodeType === anchorNode.TEXT_NODE ) {
|
|
25
|
+
return anchorNode;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
return anchorNode.childNodes[ anchorOffset ];
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
/**
|
|
32
|
+
* Extract the selection end node from the selection. When the focus node is not
|
|
33
|
+
* a text node, the selection offset is the index of a child node. The selection
|
|
34
|
+
* reaches up to but excluding that child node.
|
|
35
|
+
*
|
|
36
|
+
* @param {Selection} selection The selection.
|
|
37
|
+
*
|
|
38
|
+
* @return {Element} The selection start node.
|
|
39
|
+
*/
|
|
40
|
+
function extractSelectionEndNode( selection ) {
|
|
41
|
+
const { focusNode, focusOffset } = selection;
|
|
42
|
+
|
|
43
|
+
if ( focusNode.nodeType === focusNode.TEXT_NODE ) {
|
|
44
|
+
return focusNode;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
return focusNode.childNodes[ focusOffset - 1 ];
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
function findDepth( a, b ) {
|
|
51
|
+
let depth = 0;
|
|
52
|
+
|
|
53
|
+
while ( a[ depth ] === b[ depth ] ) {
|
|
54
|
+
depth++;
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
return depth;
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
/**
|
|
61
|
+
* Sets the `contenteditable` wrapper element to `value`.
|
|
62
|
+
*
|
|
63
|
+
* @param {HTMLElement} node Block element.
|
|
64
|
+
* @param {boolean} value `contentEditable` value (true or false)
|
|
65
|
+
*/
|
|
66
|
+
function setContentEditableWrapper( node, value ) {
|
|
67
|
+
node.contentEditable = value;
|
|
68
|
+
// Firefox doesn't automatically move focus.
|
|
69
|
+
if ( value ) node.focus();
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
/**
|
|
73
|
+
* Sets a multi-selection based on the native selection across blocks.
|
|
74
|
+
*/
|
|
75
|
+
export default function useSelectionObserver() {
|
|
76
|
+
const { multiSelect, selectBlock, selectionChange } = useDispatch(
|
|
77
|
+
blockEditorStore
|
|
78
|
+
);
|
|
79
|
+
const { getBlockParents } = useSelect( blockEditorStore );
|
|
80
|
+
return useRefEffect(
|
|
81
|
+
( node ) => {
|
|
82
|
+
const { ownerDocument } = node;
|
|
83
|
+
const { defaultView } = ownerDocument;
|
|
84
|
+
|
|
85
|
+
function onSelectionChange() {
|
|
86
|
+
const selection = defaultView.getSelection();
|
|
87
|
+
|
|
88
|
+
// If no selection is found, end multi selection and disable the
|
|
89
|
+
// contentEditable wrapper.
|
|
90
|
+
if ( ! selection.rangeCount || selection.isCollapsed ) {
|
|
91
|
+
setContentEditableWrapper( node, false );
|
|
92
|
+
return;
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
const clientId = getBlockClientId(
|
|
96
|
+
extractSelectionStartNode( selection )
|
|
97
|
+
);
|
|
98
|
+
const endClientId = getBlockClientId(
|
|
99
|
+
extractSelectionEndNode( selection )
|
|
100
|
+
);
|
|
101
|
+
const isSingularSelection = clientId === endClientId;
|
|
102
|
+
|
|
103
|
+
if ( isSingularSelection ) {
|
|
104
|
+
selectBlock( clientId );
|
|
105
|
+
} else {
|
|
106
|
+
const startPath = [
|
|
107
|
+
...getBlockParents( clientId ),
|
|
108
|
+
clientId,
|
|
109
|
+
];
|
|
110
|
+
const endPath = [
|
|
111
|
+
...getBlockParents( endClientId ),
|
|
112
|
+
endClientId,
|
|
113
|
+
];
|
|
114
|
+
const depth = findDepth( startPath, endPath );
|
|
115
|
+
|
|
116
|
+
multiSelect( startPath[ depth ], endPath[ depth ] );
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
function addListeners() {
|
|
121
|
+
ownerDocument.addEventListener(
|
|
122
|
+
'selectionchange',
|
|
123
|
+
onSelectionChange
|
|
124
|
+
);
|
|
125
|
+
defaultView.addEventListener( 'mouseup', onSelectionChange );
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
function removeListeners() {
|
|
129
|
+
ownerDocument.removeEventListener(
|
|
130
|
+
'selectionchange',
|
|
131
|
+
onSelectionChange
|
|
132
|
+
);
|
|
133
|
+
defaultView.removeEventListener( 'mouseup', onSelectionChange );
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
function resetListeners() {
|
|
137
|
+
removeListeners();
|
|
138
|
+
addListeners();
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
addListeners();
|
|
142
|
+
// We must allow rich text to set selection first. This ensures that
|
|
143
|
+
// our `selectionchange` listener is always reset to be called after
|
|
144
|
+
// the rich text one.
|
|
145
|
+
node.addEventListener( 'focusin', resetListeners );
|
|
146
|
+
return () => {
|
|
147
|
+
removeListeners();
|
|
148
|
+
node.removeEventListener( 'focusin', resetListeners );
|
|
149
|
+
};
|
|
150
|
+
},
|
|
151
|
+
[ multiSelect, selectBlock, selectionChange, getBlockParents ]
|
|
152
|
+
);
|
|
153
|
+
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* WordPress dependencies
|
|
3
3
|
*/
|
|
4
|
-
import { focus } from '@wordpress/dom';
|
|
4
|
+
import { focus, isFormElement } from '@wordpress/dom';
|
|
5
5
|
import { TAB, ESCAPE } from '@wordpress/keycodes';
|
|
6
6
|
import { useSelect, useDispatch } from '@wordpress/data';
|
|
7
7
|
import { useRefEffect, useMergeRefs } from '@wordpress/compose';
|
|
@@ -12,16 +12,6 @@ import { useRef } from '@wordpress/element';
|
|
|
12
12
|
*/
|
|
13
13
|
import { store as blockEditorStore } from '../../store';
|
|
14
14
|
|
|
15
|
-
function isFormElement( element ) {
|
|
16
|
-
const { tagName } = element;
|
|
17
|
-
return (
|
|
18
|
-
tagName === 'INPUT' ||
|
|
19
|
-
tagName === 'BUTTON' ||
|
|
20
|
-
tagName === 'SELECT' ||
|
|
21
|
-
tagName === 'TEXTAREA'
|
|
22
|
-
);
|
|
23
|
-
}
|
|
24
|
-
|
|
25
15
|
export default function useTabNav() {
|
|
26
16
|
const container = useRef();
|
|
27
17
|
const focusCaptureBeforeRef = useRef();
|
package/src/hooks/anchor.js
CHANGED
|
@@ -25,6 +25,13 @@ import { InspectorControls } from '../components';
|
|
|
25
25
|
*/
|
|
26
26
|
const ANCHOR_REGEX = /[\s#]/g;
|
|
27
27
|
|
|
28
|
+
const ANCHOR_SCHEMA = {
|
|
29
|
+
type: 'string',
|
|
30
|
+
source: 'attribute',
|
|
31
|
+
attribute: 'id',
|
|
32
|
+
selector: '*',
|
|
33
|
+
};
|
|
34
|
+
|
|
28
35
|
/**
|
|
29
36
|
* Filters registered block settings, extending attributes with anchor using ID
|
|
30
37
|
* of the first node.
|
|
@@ -42,12 +49,7 @@ export function addAttribute( settings ) {
|
|
|
42
49
|
// Gracefully handle if settings.attributes is undefined.
|
|
43
50
|
settings.attributes = {
|
|
44
51
|
...settings.attributes,
|
|
45
|
-
anchor:
|
|
46
|
-
type: 'string',
|
|
47
|
-
source: 'attribute',
|
|
48
|
-
attribute: 'id',
|
|
49
|
-
selector: '*',
|
|
50
|
-
},
|
|
52
|
+
anchor: ANCHOR_SCHEMA,
|
|
51
53
|
};
|
|
52
54
|
}
|
|
53
55
|
|
|
@@ -23,11 +23,11 @@ import {
|
|
|
23
23
|
} from '../components/colors';
|
|
24
24
|
import useSetting from '../components/use-setting';
|
|
25
25
|
import {
|
|
26
|
+
BORDER_SUPPORT_KEY,
|
|
26
27
|
hasBorderSupport,
|
|
27
28
|
removeBorderAttribute,
|
|
28
|
-
shouldSkipSerialization,
|
|
29
29
|
} from './border';
|
|
30
|
-
import { cleanEmptyObject } from './utils';
|
|
30
|
+
import { cleanEmptyObject, shouldSkipSerialization } from './utils';
|
|
31
31
|
|
|
32
32
|
// Defining empty array here instead of inline avoids unnecessary re-renders of
|
|
33
33
|
// color control.
|
|
@@ -200,7 +200,7 @@ function addAttributes( settings ) {
|
|
|
200
200
|
function addSaveProps( props, blockType, attributes ) {
|
|
201
201
|
if (
|
|
202
202
|
! hasBorderSupport( blockType, 'color' ) ||
|
|
203
|
-
shouldSkipSerialization( blockType )
|
|
203
|
+
shouldSkipSerialization( blockType, BORDER_SUPPORT_KEY, 'color' )
|
|
204
204
|
) {
|
|
205
205
|
return props;
|
|
206
206
|
}
|
|
@@ -231,7 +231,7 @@ function addSaveProps( props, blockType, attributes ) {
|
|
|
231
231
|
function addEditProps( settings ) {
|
|
232
232
|
if (
|
|
233
233
|
! hasBorderSupport( settings, 'color' ) ||
|
|
234
|
-
shouldSkipSerialization( settings )
|
|
234
|
+
shouldSkipSerialization( settings, BORDER_SUPPORT_KEY, 'color' )
|
|
235
235
|
) {
|
|
236
236
|
return settings;
|
|
237
237
|
}
|
|
@@ -266,7 +266,7 @@ export const withBorderColorPaletteStyles = createHigherOrderComponent(
|
|
|
266
266
|
|
|
267
267
|
if (
|
|
268
268
|
! hasBorderSupport( name, 'color' ) ||
|
|
269
|
-
shouldSkipSerialization( name )
|
|
269
|
+
shouldSkipSerialization( name, BORDER_SUPPORT_KEY, 'color' )
|
|
270
270
|
) {
|
|
271
271
|
return <BlockListBlock { ...props } />;
|
|
272
272
|
}
|
package/src/hooks/border.js
CHANGED
|
@@ -171,19 +171,6 @@ export function hasBorderSupport( blockName, feature = 'any' ) {
|
|
|
171
171
|
return !! support?.[ feature ];
|
|
172
172
|
}
|
|
173
173
|
|
|
174
|
-
/**
|
|
175
|
-
* Check whether serialization of border classes and styles should be skipped.
|
|
176
|
-
*
|
|
177
|
-
* @param {string|Object} blockType Block name or block type object.
|
|
178
|
-
*
|
|
179
|
-
* @return {boolean} Whether serialization of border properties should occur.
|
|
180
|
-
*/
|
|
181
|
-
export function shouldSkipSerialization( blockType ) {
|
|
182
|
-
const support = getBlockSupport( blockType, BORDER_SUPPORT_KEY );
|
|
183
|
-
|
|
184
|
-
return support?.__experimentalSkipSerialization;
|
|
185
|
-
}
|
|
186
|
-
|
|
187
174
|
/**
|
|
188
175
|
* Returns a new style object where the specified border attribute has been
|
|
189
176
|
* removed.
|
package/src/hooks/color.js
CHANGED
|
@@ -26,7 +26,12 @@ import {
|
|
|
26
26
|
getGradientValueBySlug,
|
|
27
27
|
getGradientSlugByValue,
|
|
28
28
|
} from '../components/gradients';
|
|
29
|
-
import {
|
|
29
|
+
import {
|
|
30
|
+
cleanEmptyObject,
|
|
31
|
+
transformStyles,
|
|
32
|
+
immutableSet,
|
|
33
|
+
shouldSkipSerialization,
|
|
34
|
+
} from './utils';
|
|
30
35
|
import ColorPanel from './color-panel';
|
|
31
36
|
import useSetting from '../components/use-setting';
|
|
32
37
|
|
|
@@ -43,12 +48,6 @@ const hasColorSupport = ( blockType ) => {
|
|
|
43
48
|
);
|
|
44
49
|
};
|
|
45
50
|
|
|
46
|
-
const shouldSkipSerialization = ( blockType ) => {
|
|
47
|
-
const colorSupport = getBlockSupport( blockType, COLOR_SUPPORT_KEY );
|
|
48
|
-
|
|
49
|
-
return colorSupport?.__experimentalSkipSerialization;
|
|
50
|
-
};
|
|
51
|
-
|
|
52
51
|
const hasLinkColorSupport = ( blockType ) => {
|
|
53
52
|
if ( Platform.OS !== 'web' ) {
|
|
54
53
|
return false;
|
|
@@ -248,7 +247,7 @@ function addAttributes( settings ) {
|
|
|
248
247
|
export function addSaveProps( props, blockType, attributes ) {
|
|
249
248
|
if (
|
|
250
249
|
! hasColorSupport( blockType ) ||
|
|
251
|
-
shouldSkipSerialization( blockType )
|
|
250
|
+
shouldSkipSerialization( blockType, COLOR_SUPPORT_KEY )
|
|
252
251
|
) {
|
|
253
252
|
return props;
|
|
254
253
|
}
|
|
@@ -258,12 +257,31 @@ export function addSaveProps( props, blockType, attributes ) {
|
|
|
258
257
|
// I'd have preferred to avoid the "style" attribute usage here
|
|
259
258
|
const { backgroundColor, textColor, gradient, style } = attributes;
|
|
260
259
|
|
|
261
|
-
const
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
260
|
+
const shouldSerialize = ( feature ) =>
|
|
261
|
+
! shouldSkipSerialization( blockType, COLOR_SUPPORT_KEY, feature );
|
|
262
|
+
|
|
263
|
+
// Primary color classes must come before the `has-text-color`,
|
|
264
|
+
// `has-background` and `has-link-color` classes to maintain backwards
|
|
265
|
+
// compatibility and avoid block invalidations.
|
|
266
|
+
const textClass = shouldSerialize( 'text' )
|
|
267
|
+
? getColorClassName( 'color', textColor )
|
|
268
|
+
: undefined;
|
|
269
|
+
|
|
270
|
+
const gradientClass = shouldSerialize( 'gradients' )
|
|
271
|
+
? __experimentalGetGradientClass( gradient )
|
|
272
|
+
: undefined;
|
|
273
|
+
|
|
274
|
+
const backgroundClass = shouldSerialize( 'background' )
|
|
275
|
+
? getColorClassName( 'background-color', backgroundColor )
|
|
276
|
+
: undefined;
|
|
277
|
+
|
|
278
|
+
const serializeHasBackground =
|
|
279
|
+
shouldSerialize( 'background' ) || shouldSerialize( 'gradients' );
|
|
280
|
+
const hasBackground =
|
|
281
|
+
backgroundColor ||
|
|
282
|
+
style?.color?.background ||
|
|
283
|
+
( hasGradient && ( gradient || style?.color?.gradient ) );
|
|
284
|
+
|
|
267
285
|
const newClassName = classnames(
|
|
268
286
|
props.className,
|
|
269
287
|
textClass,
|
|
@@ -273,12 +291,12 @@ export function addSaveProps( props, blockType, attributes ) {
|
|
|
273
291
|
[ backgroundClass ]:
|
|
274
292
|
( ! hasGradient || ! style?.color?.gradient ) &&
|
|
275
293
|
!! backgroundClass,
|
|
276
|
-
'has-text-color':
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
294
|
+
'has-text-color':
|
|
295
|
+
shouldSerialize( 'text' ) &&
|
|
296
|
+
( textColor || style?.color?.text ),
|
|
297
|
+
'has-background': serializeHasBackground && hasBackground,
|
|
298
|
+
'has-link-color':
|
|
299
|
+
shouldSerialize( 'link' ) && style?.elements?.link?.color,
|
|
282
300
|
}
|
|
283
301
|
);
|
|
284
302
|
props.className = newClassName ? newClassName : undefined;
|
|
@@ -297,7 +315,7 @@ export function addSaveProps( props, blockType, attributes ) {
|
|
|
297
315
|
export function addEditProps( settings ) {
|
|
298
316
|
if (
|
|
299
317
|
! hasColorSupport( settings ) ||
|
|
300
|
-
shouldSkipSerialization( settings )
|
|
318
|
+
shouldSkipSerialization( settings, COLOR_SUPPORT_KEY )
|
|
301
319
|
) {
|
|
302
320
|
return settings;
|
|
303
321
|
}
|
|
@@ -589,18 +607,27 @@ export const withColorPaletteStyles = createHigherOrderComponent(
|
|
|
589
607
|
],
|
|
590
608
|
[ userPalette, themePalette, defaultPalette ]
|
|
591
609
|
);
|
|
592
|
-
if (
|
|
610
|
+
if (
|
|
611
|
+
! hasColorSupport( name ) ||
|
|
612
|
+
shouldSkipSerialization( name, COLOR_SUPPORT_KEY )
|
|
613
|
+
) {
|
|
593
614
|
return <BlockListBlock { ...props } />;
|
|
594
615
|
}
|
|
595
616
|
const extraStyles = {};
|
|
596
617
|
|
|
597
|
-
if (
|
|
618
|
+
if (
|
|
619
|
+
textColor &&
|
|
620
|
+
! shouldSkipSerialization( name, COLOR_SUPPORT_KEY, 'text' )
|
|
621
|
+
) {
|
|
598
622
|
extraStyles.color = getColorObjectByAttributeValues(
|
|
599
623
|
colors,
|
|
600
624
|
textColor
|
|
601
625
|
)?.color;
|
|
602
626
|
}
|
|
603
|
-
if (
|
|
627
|
+
if (
|
|
628
|
+
backgroundColor &&
|
|
629
|
+
! shouldSkipSerialization( name, COLOR_SUPPORT_KEY, 'background' )
|
|
630
|
+
) {
|
|
604
631
|
extraStyles.backgroundColor = getColorObjectByAttributeValues(
|
|
605
632
|
colors,
|
|
606
633
|
backgroundColor
|
package/src/hooks/font-family.js
CHANGED
|
@@ -15,6 +15,8 @@ import TokenList from '@wordpress/token-list';
|
|
|
15
15
|
*/
|
|
16
16
|
import useSetting from '../components/use-setting';
|
|
17
17
|
import FontFamilyControl from '../components/font-family';
|
|
18
|
+
import { shouldSkipSerialization } from './utils';
|
|
19
|
+
import { TYPOGRAPHY_SUPPORT_KEY } from './typography';
|
|
18
20
|
|
|
19
21
|
export const FONT_FAMILY_SUPPORT_KEY = 'typography.__experimentalFontFamily';
|
|
20
22
|
|
|
@@ -56,9 +58,10 @@ function addSaveProps( props, blockType, attributes ) {
|
|
|
56
58
|
}
|
|
57
59
|
|
|
58
60
|
if (
|
|
59
|
-
|
|
61
|
+
shouldSkipSerialization(
|
|
60
62
|
blockType,
|
|
61
|
-
|
|
63
|
+
TYPOGRAPHY_SUPPORT_KEY,
|
|
64
|
+
'fontFamily'
|
|
62
65
|
)
|
|
63
66
|
) {
|
|
64
67
|
return props;
|
package/src/hooks/font-size.js
CHANGED
|
@@ -15,7 +15,12 @@ import {
|
|
|
15
15
|
getFontSizeObjectByValue,
|
|
16
16
|
FontSizePicker,
|
|
17
17
|
} from '../components/font-sizes';
|
|
18
|
-
import {
|
|
18
|
+
import { TYPOGRAPHY_SUPPORT_KEY } from './typography';
|
|
19
|
+
import {
|
|
20
|
+
cleanEmptyObject,
|
|
21
|
+
transformStyles,
|
|
22
|
+
shouldSkipSerialization,
|
|
23
|
+
} from './utils';
|
|
19
24
|
import useSetting from '../components/use-setting';
|
|
20
25
|
|
|
21
26
|
export const FONT_SIZE_SUPPORT_KEY = 'typography.fontSize';
|
|
@@ -60,10 +65,7 @@ function addSaveProps( props, blockType, attributes ) {
|
|
|
60
65
|
}
|
|
61
66
|
|
|
62
67
|
if (
|
|
63
|
-
|
|
64
|
-
blockType,
|
|
65
|
-
'typography.__experimentalSkipSerialization'
|
|
66
|
-
)
|
|
68
|
+
shouldSkipSerialization( blockType, TYPOGRAPHY_SUPPORT_KEY, 'fontSize' )
|
|
67
69
|
) {
|
|
68
70
|
return props;
|
|
69
71
|
}
|
|
@@ -223,9 +225,10 @@ const withFontSizeInlineStyles = createHigherOrderComponent(
|
|
|
223
225
|
// and does have a class to extract the font size from.
|
|
224
226
|
if (
|
|
225
227
|
! hasBlockSupport( blockName, FONT_SIZE_SUPPORT_KEY ) ||
|
|
226
|
-
|
|
228
|
+
shouldSkipSerialization(
|
|
227
229
|
blockName,
|
|
228
|
-
|
|
230
|
+
TYPOGRAPHY_SUPPORT_KEY,
|
|
231
|
+
'fontSize'
|
|
229
232
|
) ||
|
|
230
233
|
! fontSize ||
|
|
231
234
|
style?.typography?.fontSize
|
package/src/hooks/gap.js
CHANGED
|
@@ -6,6 +6,7 @@ import { Platform } from '@wordpress/element';
|
|
|
6
6
|
import { getBlockSupport } from '@wordpress/blocks';
|
|
7
7
|
import {
|
|
8
8
|
__experimentalUseCustomUnits as useCustomUnits,
|
|
9
|
+
__experimentalBoxControl as BoxControl,
|
|
9
10
|
__experimentalUnitControl as UnitControl,
|
|
10
11
|
} from '@wordpress/components';
|
|
11
12
|
|
|
@@ -14,14 +15,14 @@ import {
|
|
|
14
15
|
*/
|
|
15
16
|
import { __unstableUseBlockRef as useBlockRef } from '../components/block-list/use-block-props/use-block-refs';
|
|
16
17
|
import useSetting from '../components/use-setting';
|
|
17
|
-
import { SPACING_SUPPORT_KEY } from './dimensions';
|
|
18
|
+
import { AXIAL_SIDES, SPACING_SUPPORT_KEY, useCustomSides } from './dimensions';
|
|
18
19
|
import { cleanEmptyObject } from './utils';
|
|
19
20
|
|
|
20
21
|
/**
|
|
21
22
|
* Determines if there is gap support.
|
|
22
23
|
*
|
|
23
24
|
* @param {string|Object} blockType Block name or Block Type object.
|
|
24
|
-
* @return {boolean}
|
|
25
|
+
* @return {boolean} Whether there is support.
|
|
25
26
|
*/
|
|
26
27
|
export function hasGapSupport( blockType ) {
|
|
27
28
|
const support = getBlockSupport( blockType, SPACING_SUPPORT_KEY );
|
|
@@ -38,6 +39,47 @@ export function hasGapValue( props ) {
|
|
|
38
39
|
return props.attributes.style?.spacing?.blockGap !== undefined;
|
|
39
40
|
}
|
|
40
41
|
|
|
42
|
+
/**
|
|
43
|
+
* Returns a BoxControl object value from a given blockGap style value.
|
|
44
|
+
* The string check is for backwards compatibility before Gutenberg supported
|
|
45
|
+
* split gap values (row and column) and the value was a string n + unit.
|
|
46
|
+
*
|
|
47
|
+
* @param {string? | Object?} blockGapValue A block gap string or axial object value, e.g., '10px' or { top: '10px', left: '10px'}.
|
|
48
|
+
* @return {Object|null} A value to pass to the BoxControl component.
|
|
49
|
+
*/
|
|
50
|
+
export function getGapBoxControlValueFromStyle( blockGapValue ) {
|
|
51
|
+
if ( ! blockGapValue ) {
|
|
52
|
+
return null;
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
const isValueString = typeof blockGapValue === 'string';
|
|
56
|
+
return {
|
|
57
|
+
top: isValueString ? blockGapValue : blockGapValue?.top,
|
|
58
|
+
left: isValueString ? blockGapValue : blockGapValue?.left,
|
|
59
|
+
};
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
/**
|
|
63
|
+
* Returns a CSS value for the `gap` property from a given blockGap style.
|
|
64
|
+
*
|
|
65
|
+
* @param {string? | Object?} blockGapValue A block gap string or axial object value, e.g., '10px' or { top: '10px', left: '10px'}.
|
|
66
|
+
* @param {string?} defaultValue A default gap value.
|
|
67
|
+
* @return {string|null} The concatenated gap value (row and column).
|
|
68
|
+
*/
|
|
69
|
+
export function getGapCSSValue( blockGapValue, defaultValue = '0' ) {
|
|
70
|
+
const blockGapBoxControlValue = getGapBoxControlValueFromStyle(
|
|
71
|
+
blockGapValue
|
|
72
|
+
);
|
|
73
|
+
if ( ! blockGapBoxControlValue ) {
|
|
74
|
+
return null;
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
const row = blockGapBoxControlValue?.top || defaultValue;
|
|
78
|
+
const column = blockGapBoxControlValue?.left || defaultValue;
|
|
79
|
+
|
|
80
|
+
return row === column ? row : `${ row } ${ column }`;
|
|
81
|
+
}
|
|
82
|
+
|
|
41
83
|
/**
|
|
42
84
|
* Resets the gap block support attribute. This can be used when disabling
|
|
43
85
|
* the gap support controls for a block via a progressive discovery panel.
|
|
@@ -82,6 +124,7 @@ export function GapEdit( props ) {
|
|
|
82
124
|
const {
|
|
83
125
|
clientId,
|
|
84
126
|
attributes: { style },
|
|
127
|
+
name: blockName,
|
|
85
128
|
setAttributes,
|
|
86
129
|
} = props;
|
|
87
130
|
|
|
@@ -94,19 +137,29 @@ export function GapEdit( props ) {
|
|
|
94
137
|
'vw',
|
|
95
138
|
],
|
|
96
139
|
} );
|
|
97
|
-
|
|
140
|
+
const sides = useCustomSides( blockName, 'blockGap' );
|
|
98
141
|
const ref = useBlockRef( clientId );
|
|
99
142
|
|
|
100
143
|
if ( useIsGapDisabled( props ) ) {
|
|
101
144
|
return null;
|
|
102
145
|
}
|
|
103
146
|
|
|
147
|
+
const splitOnAxis =
|
|
148
|
+
sides && sides.some( ( side ) => AXIAL_SIDES.includes( side ) );
|
|
149
|
+
|
|
104
150
|
const onChange = ( next ) => {
|
|
151
|
+
let blockGap = next;
|
|
152
|
+
|
|
153
|
+
// If splitOnAxis activated we need to return a BoxControl object to the BoxControl component.
|
|
154
|
+
if ( !! next && splitOnAxis ) {
|
|
155
|
+
blockGap = { ...getGapBoxControlValueFromStyle( next ) };
|
|
156
|
+
}
|
|
157
|
+
|
|
105
158
|
const newStyle = {
|
|
106
159
|
...style,
|
|
107
160
|
spacing: {
|
|
108
161
|
...style?.spacing,
|
|
109
|
-
blockGap
|
|
162
|
+
blockGap,
|
|
110
163
|
},
|
|
111
164
|
};
|
|
112
165
|
|
|
@@ -128,17 +181,43 @@ export function GapEdit( props ) {
|
|
|
128
181
|
}
|
|
129
182
|
};
|
|
130
183
|
|
|
184
|
+
const gapValue = getGapBoxControlValueFromStyle( style?.spacing?.blockGap );
|
|
185
|
+
|
|
186
|
+
// The BoxControl component expects a full complement of side values.
|
|
187
|
+
// Gap row and column values translate to top/bottom and left/right respectively.
|
|
188
|
+
const boxControlGapValue = splitOnAxis
|
|
189
|
+
? {
|
|
190
|
+
...gapValue,
|
|
191
|
+
right: gapValue?.left,
|
|
192
|
+
bottom: gapValue?.top,
|
|
193
|
+
}
|
|
194
|
+
: gapValue?.top;
|
|
195
|
+
|
|
131
196
|
return Platform.select( {
|
|
132
197
|
web: (
|
|
133
198
|
<>
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
199
|
+
{ splitOnAxis ? (
|
|
200
|
+
<BoxControl
|
|
201
|
+
label={ __( 'Block spacing' ) }
|
|
202
|
+
min={ 0 }
|
|
203
|
+
onChange={ onChange }
|
|
204
|
+
units={ units }
|
|
205
|
+
sides={ sides }
|
|
206
|
+
values={ boxControlGapValue }
|
|
207
|
+
allowReset={ false }
|
|
208
|
+
splitOnAxis={ splitOnAxis }
|
|
209
|
+
/>
|
|
210
|
+
) : (
|
|
211
|
+
<UnitControl
|
|
212
|
+
label={ __( 'Block spacing' ) }
|
|
213
|
+
__unstableInputWidth="80px"
|
|
214
|
+
min={ 0 }
|
|
215
|
+
onChange={ onChange }
|
|
216
|
+
units={ units }
|
|
217
|
+
// Default to `row` for combined values.
|
|
218
|
+
value={ boxControlGapValue }
|
|
219
|
+
/>
|
|
220
|
+
) }
|
|
142
221
|
</>
|
|
143
222
|
),
|
|
144
223
|
native: null,
|
package/src/hooks/layout.js
CHANGED
|
@@ -56,6 +56,15 @@ function LayoutPanel( { setAttributes, attributes, name: blockName } ) {
|
|
|
56
56
|
return null;
|
|
57
57
|
}
|
|
58
58
|
|
|
59
|
+
// Only show the inherit toggle if it's supported,
|
|
60
|
+
// a default theme layout is set (e.g. one that provides `contentSize` and/or `wideSize` values),
|
|
61
|
+
// and that the default / flow layout type is in use, as this is the only one that supports inheritance.
|
|
62
|
+
const showInheritToggle = !! (
|
|
63
|
+
allowInheriting &&
|
|
64
|
+
!! defaultThemeLayout &&
|
|
65
|
+
( ! layout?.type || layout?.type === 'default' || layout?.inherit )
|
|
66
|
+
);
|
|
67
|
+
|
|
59
68
|
const usedLayout = layout || defaultBlockLayout || {};
|
|
60
69
|
const { inherit = false, type = 'default' } = usedLayout;
|
|
61
70
|
/**
|
|
@@ -77,7 +86,7 @@ function LayoutPanel( { setAttributes, attributes, name: blockName } ) {
|
|
|
77
86
|
<>
|
|
78
87
|
<InspectorControls>
|
|
79
88
|
<PanelBody title={ __( 'Layout' ) }>
|
|
80
|
-
{
|
|
89
|
+
{ showInheritToggle && (
|
|
81
90
|
<ToggleControl
|
|
82
91
|
label={ __( 'Inherit default layout' ) }
|
|
83
92
|
checked={ !! inherit }
|
|
@@ -213,6 +222,7 @@ export const withLayoutStyles = createHigherOrderComponent(
|
|
|
213
222
|
element &&
|
|
214
223
|
createPortal(
|
|
215
224
|
<LayoutStyle
|
|
225
|
+
blockName={ name }
|
|
216
226
|
selector={ `.wp-container-${ id }` }
|
|
217
227
|
layout={ usedLayout }
|
|
218
228
|
style={ attributes?.style }
|