@wordpress/block-editor 8.4.0 → 8.5.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +2 -0
- package/README.md +56 -19
- package/build/components/alignment-control/index.js +13 -6
- package/build/components/alignment-control/index.js.map +1 -1
- package/build/components/block-alignment-control/index.js +13 -6
- package/build/components/block-alignment-control/index.js.map +1 -1
- package/build/components/block-alignment-control/ui.js +1 -1
- package/build/components/block-alignment-control/ui.js.map +1 -1
- package/build/components/block-content-overlay/index.js +13 -4
- package/build/components/block-content-overlay/index.js.map +1 -1
- package/build/components/block-draggable/index.js +2 -3
- package/build/components/block-draggable/index.js.map +1 -1
- package/build/components/block-icon/index.js +4 -0
- package/build/components/block-icon/index.js.map +1 -1
- package/build/components/block-inspector/index.js +6 -1
- package/build/components/block-inspector/index.js.map +1 -1
- package/build/components/block-list/use-block-props/index.js +1 -6
- package/build/components/block-list/use-block-props/index.js.map +1 -1
- package/build/components/block-list/use-block-props/use-focus-first-element.js +14 -17
- package/build/components/block-list/use-block-props/use-focus-first-element.js.map +1 -1
- package/build/components/block-list/use-block-props/use-focus-handler.js +7 -1
- package/build/components/block-list/use-block-props/use-focus-handler.js.map +1 -1
- package/build/components/block-list-appender/index.js +6 -1
- package/build/components/block-list-appender/index.js.map +1 -1
- package/build/components/block-lock/index.js +8 -0
- package/build/components/block-lock/index.js.map +1 -1
- package/build/components/block-lock/menu-item.js +9 -15
- package/build/components/block-lock/menu-item.js.map +1 -1
- package/build/components/block-lock/modal.js +35 -23
- package/build/components/block-lock/modal.js.map +1 -1
- package/build/components/block-lock/toolbar.js +11 -16
- package/build/components/block-lock/toolbar.js.map +1 -1
- package/build/components/block-lock/use-block-lock.js +50 -0
- package/build/components/block-lock/use-block-lock.js.map +1 -0
- package/build/components/block-mover/index.js +4 -0
- package/build/components/block-mover/index.js.map +1 -1
- package/build/components/block-pattern-setup/index.js +37 -22
- package/build/components/block-pattern-setup/index.js.map +1 -1
- package/build/components/block-pattern-setup/setup-toolbar.js +1 -1
- package/build/components/block-pattern-setup/setup-toolbar.js.map +1 -1
- package/build/components/block-preview/auto.js +6 -3
- package/build/components/block-preview/auto.js.map +1 -1
- package/build/components/block-preview/index.js +4 -2
- package/build/components/block-preview/index.js.map +1 -1
- package/build/components/block-settings-menu/block-settings-dropdown.js +50 -5
- package/build/components/block-settings-menu/block-settings-dropdown.js.map +1 -1
- package/build/components/block-switcher/index.js +8 -3
- package/build/components/block-switcher/index.js.map +1 -1
- package/build/components/block-title/index.js +2 -2
- package/build/components/block-title/index.js.map +1 -1
- package/build/components/block-title/use-block-display-title.js +1 -1
- package/build/components/block-title/use-block-display-title.js.map +1 -1
- package/build/components/block-toolbar/block-name-context.js +17 -0
- package/build/components/block-toolbar/block-name-context.js.map +1 -0
- package/build/components/block-toolbar/block-toolbar-last-item.js +20 -0
- package/build/components/block-toolbar/block-toolbar-last-item.js.map +1 -0
- package/build/components/block-toolbar/index.js +20 -5
- package/build/components/block-toolbar/index.js.map +1 -1
- package/build/components/block-tools/index.js +0 -16
- package/build/components/block-tools/index.js.map +1 -1
- package/build/components/block-variation-transforms/index.js +92 -47
- package/build/components/block-variation-transforms/index.js.map +1 -1
- package/build/components/block-vertical-alignment-control/index.js +13 -6
- package/build/components/block-vertical-alignment-control/index.js.map +1 -1
- package/build/components/contrast-checker/index.js +4 -0
- package/build/components/contrast-checker/index.js.map +1 -1
- package/build/components/convert-to-group-buttons/index.js +8 -0
- package/build/components/convert-to-group-buttons/index.js.map +1 -1
- package/build/components/convert-to-group-buttons/toolbar.js +105 -0
- package/build/components/convert-to-group-buttons/toolbar.js.map +1 -0
- package/build/components/copy-handler/index.js +48 -9
- package/build/components/copy-handler/index.js.map +1 -1
- package/build/components/font-sizes/font-size-picker.js +4 -0
- package/build/components/font-sizes/font-size-picker.js.map +1 -1
- package/build/components/iframe/index.js +6 -9
- package/build/components/iframe/index.js.map +1 -1
- package/build/components/index.js +18 -0
- package/build/components/index.js.map +1 -1
- package/build/components/justify-content-control/index.js +13 -6
- package/build/components/justify-content-control/index.js.map +1 -1
- package/build/components/keyboard-shortcuts/index.js +1 -1
- package/build/components/keyboard-shortcuts/index.js.map +1 -1
- package/build/components/line-height-control/index.js +10 -3
- package/build/components/line-height-control/index.js.map +1 -1
- package/build/components/link-control/index.js +6 -7
- package/build/components/link-control/index.js.map +1 -1
- package/build/components/list-view/block-select-button.js +19 -6
- package/build/components/list-view/block-select-button.js.map +1 -1
- package/build/components/list-view/block.js +18 -3
- package/build/components/list-view/block.js.map +1 -1
- package/build/components/list-view/branch.js +1 -1
- package/build/components/list-view/branch.js.map +1 -1
- package/build/components/media-replace-flow/index.js +4 -0
- package/build/components/media-replace-flow/index.js.map +1 -1
- package/build/components/multi-selection-inspector/index.js +1 -1
- package/build/components/multi-selection-inspector/index.js.map +1 -1
- package/build/components/rich-text/index.js +26 -4
- package/build/components/rich-text/index.js.map +1 -1
- package/build/components/rich-text/split-value.js +12 -2
- package/build/components/rich-text/split-value.js.map +1 -1
- package/build/components/rich-text/use-firefox-compat.js +49 -0
- package/build/components/rich-text/use-firefox-compat.js.map +1 -0
- package/build/components/rich-text/use-input-rules.js +34 -2
- package/build/components/rich-text/use-input-rules.js.map +1 -1
- package/build/components/skip-to-selected-block/index.js +4 -0
- package/build/components/skip-to-selected-block/index.js.map +1 -1
- package/build/components/writing-flow/index.js +9 -1
- package/build/components/writing-flow/index.js.map +1 -1
- package/build/components/writing-flow/use-arrow-nav.js +3 -44
- package/build/components/writing-flow/use-arrow-nav.js.map +1 -1
- package/build/components/writing-flow/use-click-selection.js +68 -0
- package/build/components/writing-flow/use-click-selection.js.map +1 -0
- package/build/components/writing-flow/use-drag-selection.js +134 -0
- package/build/components/writing-flow/use-drag-selection.js.map +1 -0
- package/build/components/writing-flow/use-input.js +116 -0
- package/build/components/writing-flow/use-input.js.map +1 -0
- package/build/components/writing-flow/use-multi-selection.js +18 -38
- package/build/components/writing-flow/use-multi-selection.js.map +1 -1
- package/build/components/writing-flow/use-selection-observer.js +161 -0
- package/build/components/writing-flow/use-selection-observer.js.map +1 -0
- package/build/components/writing-flow/use-tab-nav.js +1 -8
- package/build/components/writing-flow/use-tab-nav.js.map +1 -1
- package/build/hooks/border-color.js +3 -3
- package/build/hooks/border-color.js.map +1 -1
- package/build/hooks/border.js +0 -14
- package/build/hooks/border.js.map +1 -1
- package/build/hooks/color.js +20 -17
- package/build/hooks/color.js.map +1 -1
- package/build/hooks/font-family.js +5 -1
- package/build/hooks/font-family.js.map +1 -1
- package/build/hooks/font-size.js +4 -2
- package/build/hooks/font-size.js.map +1 -1
- package/build/hooks/gap.js +23 -16
- package/build/hooks/gap.js.map +1 -1
- package/build/hooks/layout.js +7 -2
- package/build/hooks/layout.js.map +1 -1
- package/build/hooks/style.js +34 -3
- package/build/hooks/style.js.map +1 -1
- package/build/hooks/utils.js +29 -0
- package/build/hooks/utils.js.map +1 -1
- package/build/layouts/flex.js +76 -12
- package/build/layouts/flex.js.map +1 -1
- package/build/layouts/flow.js +9 -4
- package/build/layouts/flow.js.map +1 -1
- package/build/store/actions.js +290 -51
- package/build/store/actions.js.map +1 -1
- package/build/store/defaults.js +5 -2
- package/build/store/defaults.js.map +1 -1
- package/build/store/reducer.js +25 -13
- package/build/store/reducer.js.map +1 -1
- package/build/store/selectors.js +264 -21
- package/build/store/selectors.js.map +1 -1
- package/build/store/utils.js +27 -0
- package/build/store/utils.js.map +1 -0
- package/build/utils/dom.js +2 -1
- package/build/utils/dom.js.map +1 -1
- package/build-module/components/alignment-control/index.js +12 -4
- package/build-module/components/alignment-control/index.js.map +1 -1
- package/build-module/components/block-alignment-control/index.js +12 -4
- package/build-module/components/block-alignment-control/index.js.map +1 -1
- package/build-module/components/block-alignment-control/ui.js +2 -2
- package/build-module/components/block-alignment-control/ui.js.map +1 -1
- package/build-module/components/block-content-overlay/index.js +13 -4
- package/build-module/components/block-content-overlay/index.js.map +1 -1
- package/build-module/components/block-draggable/index.js +2 -3
- package/build-module/components/block-draggable/index.js.map +1 -1
- package/build-module/components/block-icon/index.js +4 -0
- package/build-module/components/block-icon/index.js.map +1 -1
- package/build-module/components/block-inspector/index.js +6 -1
- package/build-module/components/block-inspector/index.js.map +1 -1
- package/build-module/components/block-list/use-block-props/index.js +1 -4
- package/build-module/components/block-list/use-block-props/index.js.map +1 -1
- package/build-module/components/block-list/use-block-props/use-focus-first-element.js +15 -17
- package/build-module/components/block-list/use-block-props/use-focus-first-element.js.map +1 -1
- package/build-module/components/block-list/use-block-props/use-focus-handler.js +7 -1
- package/build-module/components/block-list/use-block-props/use-focus-handler.js.map +1 -1
- package/build-module/components/block-list-appender/index.js +6 -1
- package/build-module/components/block-list-appender/index.js.map +1 -1
- package/build-module/components/block-lock/index.js +1 -0
- package/build-module/components/block-lock/index.js.map +1 -1
- package/build-module/components/block-lock/menu-item.js +8 -13
- package/build-module/components/block-lock/menu-item.js.map +1 -1
- package/build-module/components/block-lock/modal.js +34 -24
- package/build-module/components/block-lock/modal.js.map +1 -1
- package/build-module/components/block-lock/toolbar.js +10 -14
- package/build-module/components/block-lock/toolbar.js.map +1 -1
- package/build-module/components/block-lock/use-block-lock.js +41 -0
- package/build-module/components/block-lock/use-block-lock.js.map +1 -0
- package/build-module/components/block-mover/index.js +4 -0
- package/build-module/components/block-mover/index.js.map +1 -1
- package/build-module/components/block-pattern-setup/index.js +39 -24
- package/build-module/components/block-pattern-setup/index.js.map +1 -1
- package/build-module/components/block-pattern-setup/setup-toolbar.js +1 -1
- package/build-module/components/block-pattern-setup/setup-toolbar.js.map +1 -1
- package/build-module/components/block-preview/auto.js +6 -3
- package/build-module/components/block-preview/auto.js.map +1 -1
- package/build-module/components/block-preview/index.js +4 -2
- package/build-module/components/block-preview/index.js.map +1 -1
- package/build-module/components/block-settings-menu/block-settings-dropdown.js +50 -7
- package/build-module/components/block-settings-menu/block-settings-dropdown.js.map +1 -1
- package/build-module/components/block-switcher/index.js +9 -4
- package/build-module/components/block-switcher/index.js.map +1 -1
- package/build-module/components/block-title/index.js +2 -2
- package/build-module/components/block-title/index.js.map +1 -1
- package/build-module/components/block-title/use-block-display-title.js +1 -1
- package/build-module/components/block-title/use-block-display-title.js.map +1 -1
- package/build-module/components/block-toolbar/block-name-context.js +9 -0
- package/build-module/components/block-toolbar/block-name-context.js.map +1 -0
- package/build-module/components/block-toolbar/block-toolbar-last-item.js +11 -0
- package/build-module/components/block-toolbar/block-toolbar-last-item.js.map +1 -0
- package/build-module/components/block-toolbar/index.js +16 -4
- package/build-module/components/block-toolbar/index.js.map +1 -1
- package/build-module/components/block-tools/index.js +0 -16
- package/build-module/components/block-tools/index.js.map +1 -1
- package/build-module/components/block-variation-transforms/index.js +95 -49
- package/build-module/components/block-variation-transforms/index.js.map +1 -1
- package/build-module/components/block-vertical-alignment-control/index.js +12 -4
- package/build-module/components/block-vertical-alignment-control/index.js.map +1 -1
- package/build-module/components/contrast-checker/index.js +4 -0
- package/build-module/components/contrast-checker/index.js.map +1 -1
- package/build-module/components/convert-to-group-buttons/index.js +2 -1
- package/build-module/components/convert-to-group-buttons/index.js.map +1 -1
- package/build-module/components/convert-to-group-buttons/toolbar.js +90 -0
- package/build-module/components/convert-to-group-buttons/toolbar.js.map +1 -0
- package/build-module/components/copy-handler/index.js +48 -9
- package/build-module/components/copy-handler/index.js.map +1 -1
- package/build-module/components/font-sizes/font-size-picker.js +4 -0
- package/build-module/components/font-sizes/font-size-picker.js.map +1 -1
- package/build-module/components/iframe/index.js +6 -9
- package/build-module/components/iframe/index.js.map +1 -1
- package/build-module/components/index.js +2 -0
- package/build-module/components/index.js.map +1 -1
- package/build-module/components/justify-content-control/index.js +12 -4
- package/build-module/components/justify-content-control/index.js.map +1 -1
- package/build-module/components/keyboard-shortcuts/index.js +1 -1
- package/build-module/components/keyboard-shortcuts/index.js.map +1 -1
- package/build-module/components/line-height-control/index.js +9 -2
- package/build-module/components/line-height-control/index.js.map +1 -1
- package/build-module/components/link-control/index.js +6 -7
- package/build-module/components/link-control/index.js.map +1 -1
- package/build-module/components/list-view/block-select-button.js +17 -6
- package/build-module/components/list-view/block-select-button.js.map +1 -1
- package/build-module/components/list-view/block.js +18 -3
- package/build-module/components/list-view/block.js.map +1 -1
- package/build-module/components/list-view/branch.js +1 -1
- package/build-module/components/list-view/branch.js.map +1 -1
- package/build-module/components/media-replace-flow/index.js +4 -0
- package/build-module/components/media-replace-flow/index.js.map +1 -1
- package/build-module/components/multi-selection-inspector/index.js +2 -2
- package/build-module/components/multi-selection-inspector/index.js.map +1 -1
- package/build-module/components/rich-text/index.js +25 -4
- package/build-module/components/rich-text/index.js.map +1 -1
- package/build-module/components/rich-text/split-value.js +12 -2
- package/build-module/components/rich-text/split-value.js.map +1 -1
- package/build-module/components/rich-text/use-firefox-compat.js +39 -0
- package/build-module/components/rich-text/use-firefox-compat.js.map +1 -0
- package/build-module/components/rich-text/use-input-rules.js +35 -4
- package/build-module/components/rich-text/use-input-rules.js.map +1 -1
- package/build-module/components/skip-to-selected-block/index.js +4 -0
- package/build-module/components/skip-to-selected-block/index.js.map +1 -1
- package/build-module/components/writing-flow/index.js +5 -1
- package/build-module/components/writing-flow/index.js.map +1 -1
- package/build-module/components/writing-flow/use-arrow-nav.js +4 -45
- package/build-module/components/writing-flow/use-arrow-nav.js.map +1 -1
- package/build-module/components/writing-flow/use-click-selection.js +57 -0
- package/build-module/components/writing-flow/use-click-selection.js.map +1 -0
- package/build-module/components/writing-flow/use-drag-selection.js +124 -0
- package/build-module/components/writing-flow/use-drag-selection.js.map +1 -0
- package/build-module/components/writing-flow/use-input.js +104 -0
- package/build-module/components/writing-flow/use-input.js.map +1 -0
- package/build-module/components/writing-flow/use-multi-selection.js +18 -37
- package/build-module/components/writing-flow/use-multi-selection.js.map +1 -1
- package/build-module/components/writing-flow/use-selection-observer.js +150 -0
- package/build-module/components/writing-flow/use-selection-observer.js.map +1 -0
- package/build-module/components/writing-flow/use-tab-nav.js +1 -9
- package/build-module/components/writing-flow/use-tab-nav.js.map +1 -1
- package/build-module/hooks/border-color.js +5 -5
- package/build-module/hooks/border-color.js.map +1 -1
- package/build-module/hooks/border.js +0 -12
- package/build-module/hooks/border.js.map +1 -1
- package/build-module/hooks/color.js +19 -18
- package/build-module/hooks/color.js.map +1 -1
- package/build-module/hooks/font-family.js +3 -1
- package/build-module/hooks/font-family.js.map +1 -1
- package/build-module/hooks/font-size.js +4 -3
- package/build-module/hooks/font-size.js.map +1 -1
- package/build-module/hooks/gap.js +22 -15
- package/build-module/hooks/gap.js.map +1 -1
- package/build-module/hooks/layout.js +7 -2
- package/build-module/hooks/layout.js.map +1 -1
- package/build-module/hooks/style.js +33 -3
- package/build-module/hooks/style.js.map +1 -1
- package/build-module/hooks/utils.js +26 -0
- package/build-module/hooks/utils.js.map +1 -1
- package/build-module/layouts/flex.js +76 -13
- package/build-module/layouts/flex.js.map +1 -1
- package/build-module/layouts/flow.js +9 -5
- package/build-module/layouts/flow.js.map +1 -1
- package/build-module/store/actions.js +277 -49
- package/build-module/store/actions.js.map +1 -1
- package/build-module/store/defaults.js +5 -2
- package/build-module/store/defaults.js.map +1 -1
- package/build-module/store/reducer.js +25 -13
- package/build-module/store/reducer.js.map +1 -1
- package/build-module/store/selectors.js +250 -21
- package/build-module/store/selectors.js.map +1 -1
- package/build-module/store/utils.js +20 -0
- package/build-module/store/utils.js.map +1 -0
- package/build-module/utils/dom.js +2 -1
- package/build-module/utils/dom.js.map +1 -1
- package/build-style/style-rtl.css +142 -101
- package/build-style/style.css +142 -101
- package/build-types/utils/dom.d.ts.map +1 -1
- package/package.json +28 -28
- package/src/components/alignment-control/index.js +9 -4
- package/src/components/block-alignment-control/index.js +9 -4
- package/src/components/block-alignment-control/ui.js +2 -2
- package/src/components/block-content-overlay/index.js +19 -2
- package/src/components/block-draggable/index.js +2 -5
- package/src/components/block-icon/index.js +3 -0
- package/src/components/block-inspector/index.js +4 -0
- package/src/components/block-list/style.scss +4 -5
- package/src/components/block-list/use-block-props/index.js +0 -5
- package/src/components/block-list/use-block-props/use-focus-first-element.js +19 -26
- package/src/components/block-list/use-block-props/use-focus-handler.js +8 -0
- package/src/components/block-list-appender/index.js +5 -0
- package/src/components/block-lock/index.js +1 -0
- package/src/components/block-lock/menu-item.js +6 -19
- package/src/components/block-lock/modal.js +52 -23
- package/src/components/block-lock/style.scss +7 -5
- package/src/components/block-lock/toolbar.js +7 -14
- package/src/components/block-lock/use-block-lock.js +45 -0
- package/src/components/block-mover/index.js +3 -0
- package/src/components/block-mover/style.scss +4 -0
- package/src/components/block-pattern-setup/index.js +84 -59
- package/src/components/block-pattern-setup/setup-toolbar.js +3 -1
- package/src/components/block-pattern-setup/style.scss +32 -26
- package/src/components/block-preview/auto.js +10 -1
- package/src/components/block-preview/index.js +2 -0
- package/src/components/block-settings-menu/block-settings-dropdown.js +62 -4
- package/src/components/block-switcher/index.js +15 -3
- package/src/components/block-switcher/style.scss +15 -4
- package/src/components/block-switcher/test/__snapshots__/index.js.snap +15 -13
- package/src/components/block-switcher/test/index.js +2 -2
- package/src/components/block-title/index.js +2 -2
- package/src/components/block-title/use-block-display-title.js +1 -1
- package/src/components/block-toolbar/block-name-context.js +8 -0
- package/src/components/block-toolbar/block-toolbar-last-item.js +12 -0
- package/src/components/block-toolbar/index.js +18 -2
- package/src/components/block-toolbar/style.scss +6 -0
- package/src/components/block-tools/index.js +0 -19
- package/src/components/block-tools/style.scss +3 -5
- package/src/components/block-variation-transforms/index.js +105 -36
- package/src/components/block-variation-transforms/style.scss +1 -1
- package/src/components/block-vertical-alignment-control/index.js +9 -4
- package/src/components/button-block-appender/style.scss +5 -1
- package/src/components/contrast-checker/index.js +3 -0
- package/src/components/convert-to-group-buttons/index.js +6 -1
- package/src/components/convert-to-group-buttons/toolbar.js +87 -0
- package/src/components/copy-handler/index.js +55 -10
- package/src/components/font-sizes/font-size-picker.js +3 -0
- package/src/components/iframe/index.js +5 -7
- package/src/components/index.js +2 -0
- package/src/components/justify-content-control/index.js +9 -4
- package/src/components/keyboard-shortcuts/index.js +1 -1
- package/src/components/line-height-control/index.js +8 -3
- package/src/components/link-control/index.js +5 -5
- package/src/components/list-view/block-select-button.js +13 -3
- package/src/components/list-view/block.js +24 -8
- package/src/components/list-view/branch.js +1 -1
- package/src/components/list-view/style.scss +56 -14
- package/src/components/media-placeholder/README.md +8 -0
- package/src/components/media-replace-flow/index.js +3 -0
- package/src/components/multi-selection-inspector/index.js +2 -2
- package/src/components/rich-text/index.js +24 -1
- package/src/components/rich-text/split-value.js +5 -1
- package/src/components/rich-text/use-firefox-compat.js +39 -0
- package/src/components/rich-text/use-input-rules.js +40 -3
- package/src/components/skip-to-selected-block/index.js +3 -0
- package/src/components/url-input/style.scss +3 -2
- package/src/components/writing-flow/index.js +8 -0
- package/src/components/writing-flow/readme.md +28 -0
- package/src/components/writing-flow/use-arrow-nav.js +4 -53
- package/src/components/writing-flow/use-click-selection.js +65 -0
- package/src/components/writing-flow/use-drag-selection.js +126 -0
- package/src/components/writing-flow/use-input.js +112 -0
- package/src/components/writing-flow/use-multi-selection.js +13 -36
- package/src/components/writing-flow/use-selection-observer.js +153 -0
- package/src/components/writing-flow/use-tab-nav.js +1 -11
- package/src/hooks/border-color.js +5 -5
- package/src/hooks/border.js +0 -13
- package/src/hooks/color.js +51 -24
- package/src/hooks/font-family.js +5 -2
- package/src/hooks/font-size.js +10 -7
- package/src/hooks/gap.js +25 -17
- package/src/hooks/layout.js +11 -1
- package/src/hooks/style.js +40 -4
- package/src/hooks/test/gap.js +25 -1
- package/src/hooks/test/style.js +94 -0
- package/src/hooks/test/utils.js +1 -1
- package/src/hooks/utils.js +26 -0
- package/src/layouts/flex.js +89 -5
- package/src/layouts/flow.js +15 -4
- package/src/store/actions.js +341 -32
- package/src/store/defaults.js +7 -2
- package/src/store/reducer.js +25 -10
- package/src/store/selectors.js +329 -26
- package/src/store/test/selectors.js +242 -5
- package/src/store/utils.js +19 -0
- package/src/utils/dom.js +2 -1
- package/tsconfig.tsbuildinfo +1 -1
- package/build/components/block-list/use-block-props/use-multi-selection.js +0 -205
- package/build/components/block-list/use-block-props/use-multi-selection.js.map +0 -1
- package/build/components/block-list/use-block-props/use-scroll-into-view.js +0 -77
- package/build/components/block-list/use-block-props/use-scroll-into-view.js.map +0 -1
- package/build-module/components/block-list/use-block-props/use-multi-selection.js +0 -192
- package/build-module/components/block-list/use-block-props/use-multi-selection.js.map +0 -1
- package/build-module/components/block-list/use-block-props/use-scroll-into-view.js +0 -63
- package/build-module/components/block-list/use-block-props/use-scroll-into-view.js.map +0 -1
- package/src/components/block-list/use-block-props/use-multi-selection.js +0 -227
- package/src/components/block-list/use-block-props/use-scroll-into-view.js +0 -73
|
@@ -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
|
@@ -40,34 +40,36 @@ export function hasGapValue( props ) {
|
|
|
40
40
|
}
|
|
41
41
|
|
|
42
42
|
/**
|
|
43
|
-
* Returns a BoxControl object value from a given blockGap style.
|
|
43
|
+
* Returns a BoxControl object value from a given blockGap style value.
|
|
44
44
|
* The string check is for backwards compatibility before Gutenberg supported
|
|
45
45
|
* split gap values (row and column) and the value was a string n + unit.
|
|
46
46
|
*
|
|
47
|
-
* @param {string? | Object?}
|
|
48
|
-
* @return {Object
|
|
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
49
|
*/
|
|
50
|
-
export function
|
|
51
|
-
if ( !
|
|
52
|
-
return
|
|
50
|
+
export function getGapBoxControlValueFromStyle( blockGapValue ) {
|
|
51
|
+
if ( ! blockGapValue ) {
|
|
52
|
+
return null;
|
|
53
53
|
}
|
|
54
54
|
|
|
55
|
-
const isValueString = typeof
|
|
55
|
+
const isValueString = typeof blockGapValue === 'string';
|
|
56
56
|
return {
|
|
57
|
-
top: isValueString ?
|
|
58
|
-
left: isValueString ?
|
|
57
|
+
top: isValueString ? blockGapValue : blockGapValue?.top,
|
|
58
|
+
left: isValueString ? blockGapValue : blockGapValue?.left,
|
|
59
59
|
};
|
|
60
60
|
}
|
|
61
61
|
|
|
62
62
|
/**
|
|
63
63
|
* Returns a CSS value for the `gap` property from a given blockGap style.
|
|
64
64
|
*
|
|
65
|
-
* @param {string? | Object?} blockGapValue A
|
|
65
|
+
* @param {string? | Object?} blockGapValue A block gap string or axial object value, e.g., '10px' or { top: '10px', left: '10px'}.
|
|
66
66
|
* @param {string?} defaultValue A default gap value.
|
|
67
67
|
* @return {string|null} The concatenated gap value (row and column).
|
|
68
68
|
*/
|
|
69
69
|
export function getGapCSSValue( blockGapValue, defaultValue = '0' ) {
|
|
70
|
-
const blockGapBoxControlValue =
|
|
70
|
+
const blockGapBoxControlValue = getGapBoxControlValueFromStyle(
|
|
71
|
+
blockGapValue
|
|
72
|
+
);
|
|
71
73
|
if ( ! blockGapBoxControlValue ) {
|
|
72
74
|
return null;
|
|
73
75
|
}
|
|
@@ -142,14 +144,22 @@ export function GapEdit( props ) {
|
|
|
142
144
|
return null;
|
|
143
145
|
}
|
|
144
146
|
|
|
147
|
+
const splitOnAxis =
|
|
148
|
+
sides && sides.some( ( side ) => AXIAL_SIDES.includes( side ) );
|
|
149
|
+
|
|
145
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
|
+
|
|
146
158
|
const newStyle = {
|
|
147
159
|
...style,
|
|
148
160
|
spacing: {
|
|
149
161
|
...style?.spacing,
|
|
150
|
-
blockGap
|
|
151
|
-
...getGapValueFromStyle( next ),
|
|
152
|
-
},
|
|
162
|
+
blockGap,
|
|
153
163
|
},
|
|
154
164
|
};
|
|
155
165
|
|
|
@@ -171,9 +181,7 @@ export function GapEdit( props ) {
|
|
|
171
181
|
}
|
|
172
182
|
};
|
|
173
183
|
|
|
174
|
-
const
|
|
175
|
-
sides && sides.some( ( side ) => AXIAL_SIDES.includes( side ) );
|
|
176
|
-
const gapValue = getGapValueFromStyle( style?.spacing?.blockGap );
|
|
184
|
+
const gapValue = getGapBoxControlValueFromStyle( style?.spacing?.blockGap );
|
|
177
185
|
|
|
178
186
|
// The BoxControl component expects a full complement of side values.
|
|
179
187
|
// Gap row and column values translate to top/bottom and left/right respectively.
|
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 }
|
package/src/hooks/style.js
CHANGED
|
@@ -42,6 +42,7 @@ import {
|
|
|
42
42
|
} from './typography';
|
|
43
43
|
import { SPACING_SUPPORT_KEY, DimensionsPanel } from './dimensions';
|
|
44
44
|
import useDisplayBlockControls from '../components/use-display-block-controls';
|
|
45
|
+
import { shouldSkipSerialization } from './utils';
|
|
45
46
|
|
|
46
47
|
const styleSupportKeys = [
|
|
47
48
|
...TYPOGRAPHY_SUPPORT_KEYS,
|
|
@@ -200,6 +201,19 @@ const skipSerializationPathsSave = {
|
|
|
200
201
|
[ `${ SPACING_SUPPORT_KEY }` ]: [ 'spacing.blockGap' ],
|
|
201
202
|
};
|
|
202
203
|
|
|
204
|
+
/**
|
|
205
|
+
* A dictionary used to normalize feature names between support flags, style
|
|
206
|
+
* object properties and __experimentSkipSerialization configuration arrays.
|
|
207
|
+
*
|
|
208
|
+
* This allows not having to provide a migration for a support flag and possible
|
|
209
|
+
* backwards compatibility bridges, while still achieving consistency between
|
|
210
|
+
* the support flag and the skip serialization array.
|
|
211
|
+
*
|
|
212
|
+
* @constant
|
|
213
|
+
* @type {Record<string, string>}
|
|
214
|
+
*/
|
|
215
|
+
const renamedFeatures = { gradients: 'gradient' };
|
|
216
|
+
|
|
203
217
|
/**
|
|
204
218
|
* Override props assigned to save component to inject the CSS variables definition.
|
|
205
219
|
*
|
|
@@ -223,9 +237,18 @@ export function addSaveProps(
|
|
|
223
237
|
let { style } = attributes;
|
|
224
238
|
|
|
225
239
|
forEach( skipPaths, ( path, indicator ) => {
|
|
226
|
-
|
|
240
|
+
const skipSerialization = getBlockSupport( blockType, indicator );
|
|
241
|
+
|
|
242
|
+
if ( skipSerialization === true ) {
|
|
227
243
|
style = omit( style, path );
|
|
228
244
|
}
|
|
245
|
+
|
|
246
|
+
if ( Array.isArray( skipSerialization ) ) {
|
|
247
|
+
skipSerialization.forEach( ( featureName ) => {
|
|
248
|
+
const feature = renamedFeatures[ featureName ] || featureName;
|
|
249
|
+
style = omit( style, [ [ ...path, feature ] ] );
|
|
250
|
+
} );
|
|
251
|
+
}
|
|
229
252
|
} );
|
|
230
253
|
|
|
231
254
|
props.style = {
|
|
@@ -304,14 +327,27 @@ export const withBlockControls = createHigherOrderComponent(
|
|
|
304
327
|
*/
|
|
305
328
|
const withElementsStyles = createHigherOrderComponent(
|
|
306
329
|
( BlockListBlock ) => ( props ) => {
|
|
307
|
-
const elements = props.attributes.style?.elements;
|
|
308
|
-
|
|
309
330
|
const blockElementsContainerIdentifier = `wp-elements-${ useInstanceId(
|
|
310
331
|
BlockListBlock
|
|
311
332
|
) }`;
|
|
333
|
+
|
|
334
|
+
const skipLinkColorSerialization = shouldSkipSerialization(
|
|
335
|
+
props.name,
|
|
336
|
+
COLOR_SUPPORT_KEY,
|
|
337
|
+
'link'
|
|
338
|
+
);
|
|
339
|
+
|
|
340
|
+
// The Elements API only supports link colors for now,
|
|
341
|
+
// hence the specific omission of `link` in the elements styles.
|
|
342
|
+
// This might need to be refactored or removed if the Elements API
|
|
343
|
+
// changes or `link` supports styles beyond `color`.
|
|
344
|
+
const elements = skipLinkColorSerialization
|
|
345
|
+
? omit( props.attributes.style?.elements, [ 'link' ] )
|
|
346
|
+
: props.attributes.style?.elements;
|
|
347
|
+
|
|
312
348
|
const styles = compileElementsStyles(
|
|
313
349
|
blockElementsContainerIdentifier,
|
|
314
|
-
|
|
350
|
+
elements
|
|
315
351
|
);
|
|
316
352
|
const element = useContext( BlockList.__unstableElementContext );
|
|
317
353
|
|
package/src/hooks/test/gap.js
CHANGED
|
@@ -1,9 +1,33 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Internal dependencies
|
|
3
3
|
*/
|
|
4
|
-
import { getGapCSSValue } from '../gap';
|
|
4
|
+
import { getGapCSSValue, getGapBoxControlValueFromStyle } from '../gap';
|
|
5
5
|
|
|
6
6
|
describe( 'gap', () => {
|
|
7
|
+
describe( 'getGapBoxControlValueFromStyle()', () => {
|
|
8
|
+
it( 'should return `null` if argument is falsey', () => {
|
|
9
|
+
expect( getGapBoxControlValueFromStyle( undefined ) ).toBeNull();
|
|
10
|
+
expect( getGapBoxControlValueFromStyle( '' ) ).toBeNull();
|
|
11
|
+
} );
|
|
12
|
+
it( 'should return box control value from string', () => {
|
|
13
|
+
const expectedValue = {
|
|
14
|
+
top: '88rem',
|
|
15
|
+
left: '88rem',
|
|
16
|
+
};
|
|
17
|
+
expect( getGapBoxControlValueFromStyle( '88rem' ) ).toEqual(
|
|
18
|
+
expectedValue
|
|
19
|
+
);
|
|
20
|
+
} );
|
|
21
|
+
it( 'should return box control value from object', () => {
|
|
22
|
+
const blockGapValue = {
|
|
23
|
+
top: '222em',
|
|
24
|
+
left: '22px',
|
|
25
|
+
};
|
|
26
|
+
expect( getGapBoxControlValueFromStyle( blockGapValue ) ).toEqual( {
|
|
27
|
+
...blockGapValue,
|
|
28
|
+
} );
|
|
29
|
+
} );
|
|
30
|
+
} );
|
|
7
31
|
describe( 'getGapCSSValue()', () => {
|
|
8
32
|
it( 'should return `null` if argument is falsey', () => {
|
|
9
33
|
expect( getGapCSSValue( undefined ) ).toBeNull();
|
package/src/hooks/test/style.js
CHANGED
|
@@ -1,3 +1,8 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* WordPress dependencies
|
|
3
|
+
*/
|
|
4
|
+
import { applyFilters } from '@wordpress/hooks';
|
|
5
|
+
|
|
1
6
|
/**
|
|
2
7
|
* Internal dependencies
|
|
3
8
|
*/
|
|
@@ -108,3 +113,92 @@ describe( 'getInlineStyles', () => {
|
|
|
108
113
|
} );
|
|
109
114
|
} );
|
|
110
115
|
} );
|
|
116
|
+
|
|
117
|
+
describe( 'addSaveProps', () => {
|
|
118
|
+
const addSaveProps = applyFilters.bind(
|
|
119
|
+
null,
|
|
120
|
+
'blocks.getSaveContent.extraProps'
|
|
121
|
+
);
|
|
122
|
+
|
|
123
|
+
const blockSettings = {
|
|
124
|
+
save: () => <div className="default" />,
|
|
125
|
+
category: 'text',
|
|
126
|
+
title: 'block title',
|
|
127
|
+
supports: {
|
|
128
|
+
spacing: { padding: true },
|
|
129
|
+
color: { gradients: true, text: true },
|
|
130
|
+
typography: {
|
|
131
|
+
fontSize: true,
|
|
132
|
+
__experimentalTextTransform: true,
|
|
133
|
+
__experimentalTextDecoration: true,
|
|
134
|
+
},
|
|
135
|
+
},
|
|
136
|
+
};
|
|
137
|
+
|
|
138
|
+
const applySkipSerialization = ( features ) => {
|
|
139
|
+
const updatedSettings = { ...blockSettings };
|
|
140
|
+
Object.keys( features ).forEach( ( key ) => {
|
|
141
|
+
updatedSettings.supports[ key ].__experimentalSkipSerialization =
|
|
142
|
+
features[ key ];
|
|
143
|
+
} );
|
|
144
|
+
return updatedSettings;
|
|
145
|
+
};
|
|
146
|
+
|
|
147
|
+
const attributes = {
|
|
148
|
+
style: {
|
|
149
|
+
color: {
|
|
150
|
+
text: '#d92828',
|
|
151
|
+
gradient:
|
|
152
|
+
'linear-gradient(135deg,rgb(6,147,227) 0%,rgb(223,13,13) 46%,rgb(155,81,224) 100%)',
|
|
153
|
+
},
|
|
154
|
+
spacing: { padding: '10px' },
|
|
155
|
+
typography: {
|
|
156
|
+
fontSize: '1rem',
|
|
157
|
+
textDecoration: 'underline',
|
|
158
|
+
textTransform: 'uppercase',
|
|
159
|
+
},
|
|
160
|
+
},
|
|
161
|
+
};
|
|
162
|
+
|
|
163
|
+
it( 'should serialize all styles by default', () => {
|
|
164
|
+
const extraProps = addSaveProps( {}, blockSettings, attributes );
|
|
165
|
+
|
|
166
|
+
expect( extraProps.style ).toEqual( {
|
|
167
|
+
background:
|
|
168
|
+
'linear-gradient(135deg,rgb(6,147,227) 0%,rgb(223,13,13) 46%,rgb(155,81,224) 100%)',
|
|
169
|
+
color: '#d92828',
|
|
170
|
+
padding: '10px',
|
|
171
|
+
fontSize: '1rem',
|
|
172
|
+
textDecoration: 'underline',
|
|
173
|
+
textTransform: 'uppercase',
|
|
174
|
+
} );
|
|
175
|
+
} );
|
|
176
|
+
|
|
177
|
+
it( 'should skip serialization of entire feature set if flag is true', () => {
|
|
178
|
+
const settings = applySkipSerialization( {
|
|
179
|
+
typography: true,
|
|
180
|
+
} );
|
|
181
|
+
const extraProps = addSaveProps( {}, settings, attributes );
|
|
182
|
+
|
|
183
|
+
expect( extraProps.style ).toEqual( {
|
|
184
|
+
background:
|
|
185
|
+
'linear-gradient(135deg,rgb(6,147,227) 0%,rgb(223,13,13) 46%,rgb(155,81,224) 100%)',
|
|
186
|
+
color: '#d92828',
|
|
187
|
+
padding: '10px',
|
|
188
|
+
} );
|
|
189
|
+
} );
|
|
190
|
+
|
|
191
|
+
it( 'should skip serialization of individual features if flag is an array', () => {
|
|
192
|
+
const settings = applySkipSerialization( {
|
|
193
|
+
color: [ 'gradient' ],
|
|
194
|
+
typography: [ 'textDecoration', 'textTransform' ],
|
|
195
|
+
} );
|
|
196
|
+
const extraProps = addSaveProps( {}, settings, attributes );
|
|
197
|
+
|
|
198
|
+
expect( extraProps.style ).toEqual( {
|
|
199
|
+
color: '#d92828',
|
|
200
|
+
padding: '10px',
|
|
201
|
+
fontSize: '1rem',
|
|
202
|
+
} );
|
|
203
|
+
} );
|
|
204
|
+
} );
|
package/src/hooks/test/utils.js
CHANGED
|
@@ -97,7 +97,7 @@ describe( 'anchor', () => {
|
|
|
97
97
|
expect( extraProps.id ).toBe( 'foo' );
|
|
98
98
|
} );
|
|
99
99
|
|
|
100
|
-
it( 'should remove an anchor attribute ID when
|
|
100
|
+
it( 'should remove an anchor attribute ID when field is cleared', () => {
|
|
101
101
|
const attributes = { anchor: '' };
|
|
102
102
|
const extraProps = getSaveContentExtraProps(
|
|
103
103
|
{},
|
package/src/hooks/utils.js
CHANGED
|
@@ -14,6 +14,11 @@ import {
|
|
|
14
14
|
every,
|
|
15
15
|
} from 'lodash';
|
|
16
16
|
|
|
17
|
+
/**
|
|
18
|
+
* WordPress dependencies
|
|
19
|
+
*/
|
|
20
|
+
import { getBlockSupport } from '@wordpress/blocks';
|
|
21
|
+
|
|
17
22
|
/**
|
|
18
23
|
* Removed falsy values from nested object.
|
|
19
24
|
*
|
|
@@ -87,3 +92,24 @@ export function transformStyles(
|
|
|
87
92
|
} );
|
|
88
93
|
return returnBlock;
|
|
89
94
|
}
|
|
95
|
+
|
|
96
|
+
/**
|
|
97
|
+
* Check whether serialization of specific block support feature or set should
|
|
98
|
+
* be skipped.
|
|
99
|
+
*
|
|
100
|
+
* @param {string|Object} blockType Block name or block type object.
|
|
101
|
+
* @param {string} featureSet Name of block support feature set.
|
|
102
|
+
* @param {string} feature Name of the individual feature to check.
|
|
103
|
+
*
|
|
104
|
+
* @return {boolean} Whether serialization should occur.
|
|
105
|
+
*/
|
|
106
|
+
export function shouldSkipSerialization( blockType, featureSet, feature ) {
|
|
107
|
+
const support = getBlockSupport( blockType, featureSet );
|
|
108
|
+
const skipSerialization = support?.__experimentalSkipSerialization;
|
|
109
|
+
|
|
110
|
+
if ( Array.isArray( skipSerialization ) ) {
|
|
111
|
+
return skipSerialization.includes( feature );
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
return skipSerialization;
|
|
115
|
+
}
|