@wordpress/block-editor 17.0.2-next.v.202608281122.0 → 17.1.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 +29 -1
- package/build/components/background-image-control/index.cjs +18 -1
- package/build/components/background-image-control/index.cjs.map +2 -2
- package/build/components/block-allowed-blocks/modal.cjs +2 -1
- package/build/components/block-allowed-blocks/modal.cjs.map +3 -3
- package/build/components/block-edit/edit.cjs.map +1 -1
- package/build/components/block-inspector/index.cjs +3 -12
- package/build/components/block-inspector/index.cjs.map +2 -2
- package/build/components/block-list/use-block-props/use-is-hovered.cjs +17 -4
- package/build/components/block-list/use-block-props/use-is-hovered.cjs.map +2 -2
- package/build/components/block-preview/index.cjs +1 -2
- package/build/components/block-preview/index.cjs.map +2 -2
- package/build/components/block-switcher/index.cjs +2 -1
- package/build/components/block-switcher/index.cjs.map +3 -3
- package/build/components/block-toolbar/pattern-overrides-dropdown.cjs +2 -1
- package/build/components/block-toolbar/pattern-overrides-dropdown.cjs.map +3 -3
- package/build/components/global-styles/border-panel.cjs +19 -42
- package/build/components/global-styles/border-panel.cjs.map +2 -2
- package/build/components/global-styles/image-settings-panel.cjs.map +1 -1
- package/build/components/iframe/index.cjs.map +1 -1
- package/build/components/inserter/hooks/use-patterns-paging.cjs.map +1 -1
- package/build/components/inserter-draggable-blocks/index.cjs.map +1 -1
- package/build/components/inspector-controls-tabs/content-tab.cjs +2 -3
- package/build/components/inspector-controls-tabs/content-tab.cjs.map +2 -2
- package/build/components/inspector-controls-tabs/styles-tab.cjs +1 -3
- package/build/components/inspector-controls-tabs/styles-tab.cjs.map +2 -2
- package/build/components/inspector-controls-tabs/use-inspector-controls-tabs.cjs +1 -2
- package/build/components/inspector-controls-tabs/use-inspector-controls-tabs.cjs.map +2 -2
- package/build/components/inspector-popover-header/index.cjs +5 -4
- package/build/components/inspector-popover-header/index.cjs.map +3 -3
- package/build/components/link-control/index.cjs.map +2 -2
- package/build/components/link-control/search-input.cjs.map +1 -1
- package/build/components/list-view/block-select-button.cjs +9 -1
- package/build/components/list-view/block-select-button.cjs.map +2 -2
- package/build/components/list-view/block.cjs +2 -1
- package/build/components/list-view/block.cjs.map +2 -2
- package/build/components/list-view/use-list-view-drop-zone.cjs.map +1 -1
- package/build/components/media-replace-flow/index.cjs +4 -1
- package/build/components/media-replace-flow/index.cjs.map +2 -2
- package/build/components/navigable-toolbar/index.cjs +3 -0
- package/build/components/navigable-toolbar/index.cjs.map +2 -2
- package/build/components/rich-text/event-listeners/enter.cjs +23 -11
- package/build/components/rich-text/event-listeners/enter.cjs.map +2 -2
- package/build/components/rich-text/event-listeners/index.cjs +0 -2
- package/build/components/rich-text/event-listeners/index.cjs.map +3 -3
- package/build/components/rich-text/event-listeners/input-rules.cjs +4 -2
- package/build/components/rich-text/event-listeners/input-rules.cjs.map +2 -2
- package/build/components/use-block-drop-zone/index.cjs.map +1 -1
- package/build/components/writing-flow/index.cjs +5 -0
- package/build/components/writing-flow/index.cjs.map +3 -3
- package/build/components/writing-flow/use-arrow-nav.cjs.map +1 -1
- package/build/components/writing-flow/use-input.cjs +12 -2
- package/build/components/writing-flow/use-input.cjs.map +2 -2
- package/build/components/writing-flow/use-tab-nav.cjs +84 -41
- package/build/components/writing-flow/use-tab-nav.cjs.map +3 -3
- package/build/components/{rich-text/event-listeners/undo-automatic-change.cjs → writing-flow/use-undo-automatic-change.cjs} +18 -15
- package/build/components/writing-flow/use-undo-automatic-change.cjs.map +7 -0
- package/build/hooks/border.cjs +2 -46
- package/build/hooks/border.cjs.map +2 -2
- package/build/hooks/generate-fields-from-attributes.cjs.map +1 -1
- package/build/hooks/index.cjs +0 -2
- package/build/hooks/index.cjs.map +3 -3
- package/build/hooks/style.cjs +2 -2
- package/build/hooks/style.cjs.map +2 -2
- package/build/layouts/flex.cjs +3 -0
- package/build/layouts/flex.cjs.map +2 -2
- package/build/store/actions.cjs +12 -9
- package/build/store/actions.cjs.map +3 -3
- package/build-module/components/background-image-control/index.mjs +18 -1
- package/build-module/components/background-image-control/index.mjs.map +2 -2
- package/build-module/components/block-allowed-blocks/modal.mjs +2 -2
- package/build-module/components/block-allowed-blocks/modal.mjs.map +2 -2
- package/build-module/components/block-edit/edit.mjs.map +1 -1
- package/build-module/components/block-inspector/index.mjs +3 -12
- package/build-module/components/block-inspector/index.mjs.map +2 -2
- package/build-module/components/block-list/use-block-props/use-is-hovered.mjs +17 -4
- package/build-module/components/block-list/use-block-props/use-is-hovered.mjs.map +2 -2
- package/build-module/components/block-preview/index.mjs +1 -2
- package/build-module/components/block-preview/index.mjs.map +2 -2
- package/build-module/components/block-switcher/index.mjs +2 -2
- package/build-module/components/block-switcher/index.mjs.map +2 -2
- package/build-module/components/block-toolbar/pattern-overrides-dropdown.mjs +3 -6
- package/build-module/components/block-toolbar/pattern-overrides-dropdown.mjs.map +2 -2
- package/build-module/components/global-styles/border-panel.mjs +19 -42
- package/build-module/components/global-styles/border-panel.mjs.map +2 -2
- package/build-module/components/global-styles/image-settings-panel.mjs.map +1 -1
- package/build-module/components/iframe/index.mjs.map +1 -1
- package/build-module/components/inserter/hooks/use-patterns-paging.mjs.map +1 -1
- package/build-module/components/inserter-draggable-blocks/index.mjs.map +1 -1
- package/build-module/components/inspector-controls-tabs/content-tab.mjs +3 -4
- package/build-module/components/inspector-controls-tabs/content-tab.mjs.map +2 -2
- package/build-module/components/inspector-controls-tabs/styles-tab.mjs +1 -3
- package/build-module/components/inspector-controls-tabs/styles-tab.mjs.map +2 -2
- package/build-module/components/inspector-controls-tabs/use-inspector-controls-tabs.mjs +1 -2
- package/build-module/components/inspector-controls-tabs/use-inspector-controls-tabs.mjs.map +2 -2
- package/build-module/components/inspector-popover-header/index.mjs +6 -7
- package/build-module/components/inspector-popover-header/index.mjs.map +2 -2
- package/build-module/components/link-control/index.mjs.map +2 -2
- package/build-module/components/link-control/search-input.mjs.map +1 -1
- package/build-module/components/list-view/block-select-button.mjs +9 -1
- package/build-module/components/list-view/block-select-button.mjs.map +2 -2
- package/build-module/components/list-view/block.mjs +2 -1
- package/build-module/components/list-view/block.mjs.map +2 -2
- package/build-module/components/list-view/use-list-view-drop-zone.mjs.map +1 -1
- package/build-module/components/media-replace-flow/index.mjs +4 -1
- package/build-module/components/media-replace-flow/index.mjs.map +2 -2
- package/build-module/components/navigable-toolbar/index.mjs +3 -0
- package/build-module/components/navigable-toolbar/index.mjs.map +2 -2
- package/build-module/components/rich-text/event-listeners/enter.mjs +23 -11
- package/build-module/components/rich-text/event-listeners/enter.mjs.map +2 -2
- package/build-module/components/rich-text/event-listeners/index.mjs +0 -2
- package/build-module/components/rich-text/event-listeners/index.mjs.map +2 -2
- package/build-module/components/rich-text/event-listeners/input-rules.mjs +4 -2
- package/build-module/components/rich-text/event-listeners/input-rules.mjs.map +2 -2
- package/build-module/components/use-block-drop-zone/index.mjs.map +1 -1
- package/build-module/components/writing-flow/index.mjs +5 -0
- package/build-module/components/writing-flow/index.mjs.map +2 -2
- package/build-module/components/writing-flow/use-arrow-nav.mjs.map +1 -1
- package/build-module/components/writing-flow/use-input.mjs +12 -2
- package/build-module/components/writing-flow/use-input.mjs.map +2 -2
- package/build-module/components/writing-flow/use-tab-nav.mjs +86 -43
- package/build-module/components/writing-flow/use-tab-nav.mjs.map +3 -3
- package/build-module/components/writing-flow/use-undo-automatic-change.mjs +36 -0
- package/build-module/components/writing-flow/use-undo-automatic-change.mjs.map +7 -0
- package/build-module/hooks/border.mjs +1 -45
- package/build-module/hooks/border.mjs.map +2 -2
- package/build-module/hooks/generate-fields-from-attributes.mjs.map +1 -1
- package/build-module/hooks/index.mjs +0 -2
- package/build-module/hooks/index.mjs.map +2 -2
- package/build-module/hooks/style.mjs +3 -2
- package/build-module/hooks/style.mjs.map +2 -2
- package/build-module/layouts/flex.mjs +3 -0
- package/build-module/layouts/flex.mjs.map +2 -2
- package/build-module/store/actions.mjs +12 -9
- package/build-module/store/actions.mjs.map +2 -2
- package/build-style/content-rtl.css +9 -20
- package/build-style/content.css +9 -20
- package/build-style/style-rtl.css +100 -221
- package/build-style/style.css +100 -221
- package/package.json +42 -41
- package/src/autocompleters/test/block.js +1 -0
- package/src/components/alignment-control/test/__snapshots__/{index.jsx.snap → index.jsdom.test.jsx.snap} +34 -16
- package/src/components/alignment-control/test/{index.jsx → index.jsdom.test.jsx} +2 -1
- package/src/components/background-image-control/index.jsx +32 -1
- package/src/components/background-image-control/style.scss +5 -3
- package/src/components/background-image-control/test/{index.js → index.jsdom.test.js} +1 -0
- package/src/components/block-alignment-control/test/__snapshots__/{index.jsx.snap → index.jsdom.test.jsx.snap} +68 -13
- package/src/components/block-alignment-control/test/{index.jsx → index.jsdom.test.jsx} +2 -1
- package/src/components/block-allowed-blocks/modal.jsx +3 -3
- package/src/components/block-bindings/test/{use-block-bindings-utils.js → use-block-bindings-utils.jsdom.test.js} +2 -1
- package/src/components/block-breadcrumb/test/__snapshots__/{index.jsx.snap → index.jsdom.test.jsx.snap} +2 -2
- package/src/components/block-breadcrumb/test/{index.jsx → index.jsdom.test.jsx} +1 -0
- package/src/components/block-compare/test/__snapshots__/{block-view.jsx.snap → block-view.jsdom.test.jsx.snap} +2 -2
- package/src/components/block-compare/test/{block-view.jsx → block-view.jsdom.test.jsx} +1 -0
- package/src/components/block-controls/test/{index.jsx → index.jsdom.test.jsx} +1 -0
- package/src/components/block-edit/edit.jsx +1 -1
- package/src/components/block-edit/test/{edit.jsx → edit.jsdom.test.jsx} +1 -0
- package/src/components/block-icon/content.scss +0 -6
- package/src/components/block-icon/style.scss +0 -6
- package/src/components/block-icon/test/__snapshots__/{index.jsx.snap → index.jsdom.test.jsx.snap} +6 -2
- package/src/components/block-inspector/index.jsx +3 -11
- package/src/components/block-list/content.scss +4 -1
- package/src/components/block-list/use-block-props/use-is-hovered.js +24 -5
- package/src/components/block-manager/style.scss +2 -0
- package/src/components/block-mover/test/mover-description.js +1 -0
- package/src/components/block-preview/index.jsx +1 -2
- package/src/components/block-preview/test/{index.jsx → index.jsdom.test.jsx} +10 -6
- package/src/components/block-selection-clearer/test/{index.jsx → index.jsdom.test.jsx} +24 -19
- package/src/components/block-settings-menu/test/{block-mode-toggle.jsx → block-mode-toggle.jsdom.test.jsx} +5 -1
- package/src/components/block-styles/test/utils.js +1 -0
- package/src/components/block-switcher/index.jsx +3 -3
- package/src/components/block-switcher/test/{index.jsx → index.jsdom.test.jsx} +8 -4
- package/src/components/block-switcher/test/use-transformed.patterns.js +1 -0
- package/src/components/block-switcher/test/utils.js +1 -0
- package/src/components/block-title/test/{index.jsx → index.jsdom.test.jsx} +7 -3
- package/src/components/block-toolbar/pattern-overrides-dropdown.jsx +3 -6
- package/src/components/block-toolbar/style.scss +1 -1
- package/src/components/block-toolbar/test/{block-toolbar-icon.jsx → block-toolbar-icon.jsdom.test.jsx} +25 -21
- package/src/components/block-variation-picker/content.scss +5 -3
- package/src/components/block-vertical-alignment-control/test/__snapshots__/{index.jsx.snap → index.jsdom.test.jsx.snap} +55 -11
- package/src/components/block-vertical-alignment-control/test/{index.jsx → index.jsdom.test.jsx} +2 -1
- package/src/components/block-visibility/test/{use-block-visibility.js → use-block-visibility.jsdom.test.js} +6 -5
- package/src/components/block-visibility/test/utils.js +2 -1
- package/src/components/border-radius-control/test/{index.jsx → index.jsdom.test.jsx} +8 -1
- package/src/components/border-radius-control/test/utils.js +1 -0
- package/src/components/button-block-appender/content.scss +1 -1
- package/src/components/child-layout-control/test/{index.jsx → index.jsdom.test.jsx} +18 -15
- package/src/components/color-palette/test/{control.jsx → control.jsdom.test.jsx} +15 -4
- package/src/components/colors/test/utils.js +1 -0
- package/src/components/colors/test/{with-colors.jsx → with-colors.jsdom.test.jsx} +4 -3
- package/src/components/colors-gradients/test/{control.jsx → control.jsdom.test.jsx} +8 -3
- package/src/components/contrast-checker/test/{index.jsx → index.jsdom.test.jsx} +2 -1
- package/src/components/default-block-appender/test/__snapshots__/{index.jsx.snap → index.jsdom.test.jsx.snap} +4 -4
- package/src/components/default-block-appender/test/{index.jsx → index.jsdom.test.jsx} +8 -7
- package/src/components/dimensions-tool/test/{index.jsx → index.jsdom.test.jsx} +27 -22
- package/src/components/dimensions-tool/test/utils.js +1 -0
- package/src/components/duotone-control/test/{index.jsx → index.jsdom.test.jsx} +6 -3
- package/src/components/font-sizes/test/fluid-utils.js +1 -0
- package/src/components/font-sizes/test/utils.js +1 -0
- package/src/components/global-styles/border-panel.jsx +17 -40
- package/src/components/global-styles/image-settings-panel.jsx +1 -1
- package/src/components/global-styles/inheritance/test/{index.jsx → index.jsdom.test.jsx} +5 -2
- package/src/components/global-styles/test/{background-panel.jsx → background-panel.jsdom.test.jsx} +10 -5
- package/src/components/global-styles/test/{border-panel.jsx → border-panel.jsdom.test.jsx} +113 -13
- package/src/components/global-styles/test/{color-panel.jsx → color-panel.jsdom.test.jsx} +5 -0
- package/src/components/global-styles/test/{dimensions-panel.jsx → dimensions-panel.jsdom.test.jsx} +14 -14
- package/src/components/global-styles/test/{filters-panel.jsx → filters-panel.jsdom.test.jsx} +7 -4
- package/src/components/global-styles/test/{inherited-value-context-core.js → inherited-value-context-core.jsdom.test.js} +10 -9
- package/src/components/global-styles/test/{inherited-value-context.jsx → inherited-value-context.jsdom.test.jsx} +18 -17
- package/src/components/global-styles/test/{state-control-badges.jsx → state-control-badges.jsdom.test.jsx} +3 -2
- package/src/components/global-styles/test/{typography-panel-core.jsx → typography-panel-core.jsdom.test.jsx} +5 -2
- package/src/components/global-styles/test/{typography-panel.jsx → typography-panel.jsdom.test.jsx} +17 -12
- package/src/components/global-styles/test/typography-utils.js +1 -0
- package/src/components/global-styles/test/utils.js +1 -0
- package/src/components/grid/style.scss +0 -10
- package/src/components/iframe/index.jsx +3 -3
- package/src/components/image-editor/test/index.js +1 -0
- package/src/components/image-size-control/test/{index.jsx → index.jsdom.test.jsx} +8 -3
- package/src/components/inner-blocks/test/__snapshots__/index.jsdom.test.jsx.snap +15 -0
- package/src/components/inner-blocks/test/{index.jsx → index.jsdom.test.jsx} +2 -0
- package/src/components/inner-content/test/{index.jsx → index.jsdom.test.jsx} +1 -0
- package/src/components/inserter/hooks/use-patterns-paging.js +1 -1
- package/src/components/inserter/media-tab/test/{hooks.js → hooks.jsdom.test.js} +12 -11
- package/src/components/inserter/media-tab/test/{media-panel.jsx → media-panel.jsdom.test.jsx} +15 -12
- package/src/components/inserter/style.scss +2 -2
- package/src/components/inserter/test/get-appender-label.js +12 -11
- package/src/components/inserter/test/search-items.js +1 -0
- package/src/components/inserter-draggable-blocks/index.jsx +1 -1
- package/src/components/inserter-list-item/style.scss +1 -0
- package/src/components/inspector-controls-tabs/content-tab.jsx +7 -14
- package/src/components/inspector-controls-tabs/styles-tab.jsx +1 -4
- package/src/components/inspector-controls-tabs/use-inspector-controls-tabs.js +1 -8
- package/src/components/inspector-popover-header/index.jsx +6 -7
- package/src/components/line-height-control/test/{index.jsx → index.jsdom.test.jsx} +3 -0
- package/src/components/link-control/index.jsx +3 -0
- package/src/components/link-control/search-input.jsx +1 -1
- package/src/components/link-control/style.scss +1 -1
- package/src/components/link-control/test/{index.jsx → index.jsdom.test.jsx} +52 -42
- package/src/components/link-control/test/is-url-like.js +1 -0
- package/src/components/link-control/test/{url-normalization.test.jsx → url-normalization.jsdom.test.jsx} +21 -20
- package/src/components/link-picker/test/{index.jsx → index.jsdom.test.jsx} +31 -30
- package/src/components/list-view/block-select-button.jsx +6 -1
- package/src/components/list-view/block.jsx +6 -4
- package/src/components/list-view/style.scss +55 -35
- package/src/components/list-view/test/use-list-view-drop-zone.js +1 -0
- package/src/components/list-view/test/utils.js +1 -0
- package/src/components/list-view/use-list-view-drop-zone.js +1 -1
- package/src/components/media-placeholder/test/get-computed-accept-attribute.js +1 -0
- package/src/components/media-placeholder/test/{index.jsx → index.jsdom.test.jsx} +8 -2
- package/src/components/media-replace-flow/index.jsx +6 -1
- package/src/components/media-replace-flow/test/{index.jsx → index.jsdom.test.jsx} +3 -0
- package/src/components/navigable-toolbar/index.jsx +4 -0
- package/src/components/navigable-toolbar/test/index.browser.test.js +50 -0
- package/src/components/panel-color-settings/test/{index.jsx → index.jsdom.test.jsx} +3 -0
- package/src/components/preset-input-control/test/{index.jsx → index.jsdom.test.jsx} +8 -2
- package/src/components/preset-input-control/test/utils.js +1 -0
- package/src/components/provider/test/{experimental-provider.jsx → experimental-provider.jsdom.test.jsx} +3 -2
- package/src/components/provider/test/{use-block-sync.jsx → use-block-sync.jsdom.test.jsx} +45 -44
- package/src/components/recursion-provider/test/{index.jsx → index.jsdom.test.jsx} +1 -0
- package/src/components/responsive-block-control/style.scss +1 -0
- package/src/components/responsive-block-control/test/{index.jsx → index.jsdom.test.jsx} +6 -3
- package/src/components/rich-text/event-listeners/enter.js +29 -14
- package/src/components/rich-text/event-listeners/index.js +0 -2
- package/src/components/rich-text/event-listeners/input-rules.js +7 -2
- package/src/components/spacing-sizes-control/test/{index.jsx → index.jsdom.test.jsx} +23 -20
- package/src/components/spacing-sizes-control/test/utils.js +1 -0
- package/src/components/url-input/test/{button.jsx → button.jsdom.test.jsx} +4 -1
- package/src/components/url-input/test/fixtures/validated-input-control-deprecation.js +2 -0
- package/src/components/url-input/test/{index.jsx → index.jsdom.test.jsx} +23 -13
- package/src/components/use-block-display-information/test/{index.jsx → index.jsdom.test.jsx} +14 -10
- package/src/components/use-block-drop-zone/index.js +2 -2
- package/src/components/use-block-drop-zone/test/index.js +1 -0
- package/src/components/use-on-block-drop/test/index.js +28 -31
- package/src/components/warning/test/__snapshots__/{index.jsx.snap → index.jsdom.test.jsx.snap} +2 -2
- package/src/components/warning/test/{index.jsx → index.jsdom.test.jsx} +1 -0
- package/src/components/writing-flow/index.jsx +5 -0
- package/src/components/writing-flow/style.scss +48 -0
- package/src/components/writing-flow/test/{index.js → index.jsdom.test.js} +1 -0
- package/src/components/writing-flow/use-arrow-nav.js +2 -2
- package/src/components/writing-flow/use-input.js +29 -2
- package/src/components/writing-flow/use-tab-nav.jsx +155 -70
- package/src/components/writing-flow/use-undo-automatic-change.js +40 -0
- package/src/elements/test/{index.js → index.jsdom.test.js} +1 -0
- package/src/hooks/border.jsx +0 -53
- package/src/hooks/generate-fields-from-attributes.js +1 -1
- package/src/hooks/index.js +0 -2
- package/src/hooks/style.jsx +3 -2
- package/src/hooks/test/{align.jsx → align.jsdom.test.jsx} +1 -0
- package/src/hooks/test/allowed-blocks.js +1 -0
- package/src/hooks/test/{anchor.js → anchor.jsdom.test.js} +1 -0
- package/src/hooks/test/{auto-inspector-controls.js → auto-inspector-controls.jsdom.test.js} +1 -0
- package/src/hooks/test/{background.jsx → background.jsdom.test.jsx} +5 -2
- package/src/hooks/test/{block-style-state.js → block-style-state.jsdom.test.js} +4 -3
- package/src/hooks/test/{cross-origin-isolation.js → cross-origin-isolation.jsdom.test.js} +18 -25
- package/src/hooks/test/{custom-class-name.jsx → custom-class-name.jsdom.test.jsx} +1 -0
- package/src/hooks/test/{dimensions.js → dimensions.jsdom.test.js} +1 -0
- package/src/hooks/test/{duotone.js → duotone.jsdom.test.js} +1 -0
- package/src/hooks/test/{font-size.js → font-size.jsdom.test.js} +1 -0
- package/src/hooks/test/gap.js +1 -0
- package/src/hooks/test/generate-fields-from-attributes.js +1 -0
- package/src/hooks/test/generated-class-name.js +1 -0
- package/src/hooks/test/{inherited-value-wiring.jsx → inherited-value-wiring.jsdom.test.jsx} +49 -51
- package/src/hooks/test/{layout-child.js → layout-child.jsdom.test.js} +1 -0
- package/src/hooks/test/{layout.js → layout.jsdom.test.js} +1 -0
- package/src/hooks/test/metadata.js +1 -0
- package/src/hooks/test/preset-round-trip.js +2 -0
- package/src/hooks/test/settings.jsx +1 -0
- package/src/hooks/test/state-utils.js +1 -0
- package/src/hooks/test/{style.jsx → style.jsdom.test.jsx} +1 -0
- package/src/hooks/test/{text-align.jsx → text-align.jsdom.test.jsx} +1 -0
- package/src/hooks/test/{use-typography-props.js → use-typography-props.jsdom.test.js} +1 -0
- package/src/hooks/test/{utils.js → utils.jsdom.test.js} +1 -0
- package/src/layouts/flex.jsx +7 -0
- package/src/layouts/test/{constrained.jsx → constrained.jsdom.test.jsx} +6 -3
- package/src/layouts/test/{flex.jsx → flex.jsdom.test.jsx} +52 -2
- package/src/layouts/test/{flow.js → flow.jsdom.test.js} +1 -0
- package/src/layouts/test/{grid.jsx → grid.jsdom.test.jsx} +5 -2
- package/src/layouts/test/utils.js +1 -0
- package/src/store/actions.js +14 -12
- package/src/store/test/{actions.js → actions.jsdom.test.js} +50 -49
- package/src/store/test/array.js +1 -0
- package/src/store/test/get-block-settings.js +1 -0
- package/src/store/test/performance.js +2 -1
- package/src/store/test/private-actions.js +1 -0
- package/src/store/test/private-selectors.js +13 -3
- package/src/store/test/reducer.js +37 -8
- package/src/store/test/{registry-selectors.js → registry-selectors.jsdom.test.js} +9 -0
- package/src/store/test/{selectors.jsx → selectors.jsdom.test.jsx} +13 -3
- package/src/style.scss +1 -1
- package/src/utils/test/block-bindings.js +1 -0
- package/src/utils/test/color-values.js +1 -0
- package/src/utils/test/{dom.jsx → dom.jsdom.test.jsx} +38 -43
- package/src/utils/test/format-font-style.js +1 -0
- package/src/utils/test/format-font-weight.js +1 -0
- package/src/utils/test/get-font-styles-and-weights.js +1 -0
- package/src/utils/test/math.js +1 -0
- package/src/utils/test/object.js +1 -0
- package/src/utils/test/pasting.js +1 -0
- package/src/utils/test/selection.js +1 -0
- package/src/utils/test/sorting.js +1 -0
- package/src/utils/test/transform-styles.js +2 -1
- package/build/components/rich-text/event-listeners/undo-automatic-change.cjs.map +0 -7
- package/build/hooks/block-fields/fields-dropdown-menu.cjs +0 -67
- package/build/hooks/block-fields/fields-dropdown-menu.cjs.map +0 -7
- package/build/hooks/block-fields/index.cjs +0 -238
- package/build/hooks/block-fields/index.cjs.map +0 -7
- package/build/hooks/block-fields/link/index.cjs +0 -174
- package/build/hooks/block-fields/link/index.cjs.map +0 -7
- package/build/hooks/block-fields/media/index.cjs +0 -262
- package/build/hooks/block-fields/media/index.cjs.map +0 -7
- package/build/hooks/block-fields/rich-text/index.cjs +0 -146
- package/build/hooks/block-fields/rich-text/index.cjs.map +0 -7
- package/build/hooks/block-fields/use-inspector-popover-placement.cjs +0 -41
- package/build/hooks/block-fields/use-inspector-popover-placement.cjs.map +0 -7
- package/build-module/components/rich-text/event-listeners/undo-automatic-change.mjs +0 -33
- package/build-module/components/rich-text/event-listeners/undo-automatic-change.mjs.map +0 -7
- package/build-module/hooks/block-fields/fields-dropdown-menu.mjs +0 -46
- package/build-module/hooks/block-fields/fields-dropdown-menu.mjs.map +0 -7
- package/build-module/hooks/block-fields/index.mjs +0 -210
- package/build-module/hooks/block-fields/index.mjs.map +0 -7
- package/build-module/hooks/block-fields/link/index.mjs +0 -141
- package/build-module/hooks/block-fields/link/index.mjs.map +0 -7
- package/build-module/hooks/block-fields/media/index.mjs +0 -241
- package/build-module/hooks/block-fields/media/index.mjs.map +0 -7
- package/build-module/hooks/block-fields/rich-text/index.mjs +0 -115
- package/build-module/hooks/block-fields/rich-text/index.mjs.map +0 -7
- package/build-module/hooks/block-fields/use-inspector-popover-placement.mjs +0 -16
- package/build-module/hooks/block-fields/use-inspector-popover-placement.mjs.map +0 -7
- package/src/components/color-palette/test/__snapshots__/control.jsx.snap +0 -143
- package/src/components/inner-blocks/test/__snapshots__/index.jsx.snap +0 -15
- package/src/components/rich-text/event-listeners/undo-automatic-change.js +0 -39
- package/src/hooks/block-fields/fields-dropdown-menu.jsx +0 -47
- package/src/hooks/block-fields/index.jsx +0 -302
- package/src/hooks/block-fields/link/index.jsx +0 -155
- package/src/hooks/block-fields/link/styles.scss +0 -18
- package/src/hooks/block-fields/media/index.jsx +0 -269
- package/src/hooks/block-fields/media/styles.scss +0 -77
- package/src/hooks/block-fields/rich-text/index.jsx +0 -123
- package/src/hooks/block-fields/rich-text/styles.scss +0 -24
- package/src/hooks/block-fields/styles.scss +0 -33
- package/src/hooks/block-fields/use-inspector-popover-placement.js +0 -16
- /package/src/components/block-icon/test/{index.jsx → index.jsdom.test.jsx} +0 -0
|
@@ -431,11 +431,12 @@ function ListViewBlock( {
|
|
|
431
431
|
const selectEditorBlock = useCallback(
|
|
432
432
|
( event ) => {
|
|
433
433
|
// For keyboard activation (Enter/Space on a link), transfer focus
|
|
434
|
-
// to the canvas
|
|
435
|
-
// For mouse clicks, keep focus in the list view so that
|
|
436
|
-
// keyboard operations (arrow navigation, copy/paste)
|
|
434
|
+
// to the canvas at the default initial position (start of the first
|
|
435
|
+
// field). For mouse clicks, keep focus in the list view so that
|
|
436
|
+
// subsequent keyboard operations (arrow navigation, copy/paste)
|
|
437
|
+
// still work.
|
|
437
438
|
const isKeyboardActivation = event?.detail === 0;
|
|
438
|
-
selectBlock( event, clientId, isKeyboardActivation ?
|
|
439
|
+
selectBlock( event, clientId, isKeyboardActivation ? 0 : null );
|
|
439
440
|
event.preventDefault();
|
|
440
441
|
},
|
|
441
442
|
[ clientId, selectBlock ]
|
|
@@ -655,6 +656,7 @@ function ListViewBlock( {
|
|
|
655
656
|
tabIndex={ getListViewBlockTabIndex( tabIndex ) }
|
|
656
657
|
onFocus={ onFocus }
|
|
657
658
|
isExpanded={ canEditBlock ? isExpanded : undefined }
|
|
659
|
+
isSelected={ isSelected }
|
|
658
660
|
selectedClientIds={ selectedClientIds }
|
|
659
661
|
ariaDescribedBy={ descriptionId }
|
|
660
662
|
visibilityLabel={ blockVisibilityDescription }
|
|
@@ -31,6 +31,14 @@
|
|
|
31
31
|
// when rows later receive the is-displacement-up or is-displacement-down class.
|
|
32
32
|
transform: translateY(0);
|
|
33
33
|
|
|
34
|
+
// The transform above makes each row its own stacking context, so the focus
|
|
35
|
+
// ring cannot escape it. Lift the focused row above the siblings that would
|
|
36
|
+
// otherwise paint over it.
|
|
37
|
+
&:focus-within,
|
|
38
|
+
&.is-nesting {
|
|
39
|
+
z-index: 1;
|
|
40
|
+
}
|
|
41
|
+
|
|
34
42
|
&.is-draggable,
|
|
35
43
|
&.is-draggable .block-editor-list-view-block-contents {
|
|
36
44
|
cursor: grab;
|
|
@@ -49,11 +57,6 @@
|
|
|
49
57
|
|
|
50
58
|
svg {
|
|
51
59
|
fill: currentColor;
|
|
52
|
-
// Optimize for high contrast modes.
|
|
53
|
-
// See also https://blogs.windows.com/msedgedev/2020/09/17/styling-for-windows-high-contrast-with-new-standards-for-forced-colors/.
|
|
54
|
-
@media (forced-colors: active) {
|
|
55
|
-
fill: CanvasText;
|
|
56
|
-
}
|
|
57
60
|
}
|
|
58
61
|
}
|
|
59
62
|
|
|
@@ -81,33 +84,54 @@
|
|
|
81
84
|
.block-editor-block-icon {
|
|
82
85
|
color: var(--wp-block-synced-color);
|
|
83
86
|
}
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
87
|
+
}
|
|
88
|
+
&.is-synced .block-editor-list-view-block-contents:focus::after {
|
|
89
|
+
--focus-color: var(--wp-block-synced-color);
|
|
90
|
+
}
|
|
91
|
+
&.is-synced:not(.is-selected) .block-editor-list-view-block__menu:focus {
|
|
92
|
+
--focus-color: var(--wp-block-synced-color);
|
|
93
|
+
@include outset-ring__focus();
|
|
88
94
|
}
|
|
89
95
|
&.is-selected .block-editor-list-view-block-contents,
|
|
90
96
|
&.is-selected .components-button.has-icon {
|
|
91
97
|
color: $white;
|
|
92
98
|
}
|
|
93
|
-
&.is-selected .block-editor-list-view-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
0 0 0 var(--wp-admin-border-width-focus)
|
|
98
|
-
var(--wpds-color-stroke-focus);
|
|
99
|
-
}
|
|
99
|
+
&.is-selected .block-editor-list-view-block__menu:focus {
|
|
100
|
+
--focus-color: var(--wpds-color-foreground-interactive-brand-strong);
|
|
101
|
+
@include outset-ring__focus();
|
|
102
|
+
outline-offset: calc(-1 * var(--wpds-border-width-focus));
|
|
100
103
|
}
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
104
|
+
@media (forced-colors: active) {
|
|
105
|
+
&.is-selected td,
|
|
106
|
+
&.is-selected.is-synced td {
|
|
107
|
+
background: SelectedItem;
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
&.is-selected .block-editor-list-view-block-contents,
|
|
111
|
+
&.is-selected .components-button.has-icon {
|
|
112
|
+
color: SelectedItemText;
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
&.is-selected svg,
|
|
116
|
+
&.is-selected .block-editor-block-icon.has-colors svg {
|
|
117
|
+
fill: SelectedItemText;
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
// Prevent backplate with same color as text in dark mode.
|
|
121
|
+
// Opt-out scoped to only the row title.
|
|
122
|
+
&.is-selected .block-editor-list-view-block-select-button__title {
|
|
123
|
+
forced-color-adjust: none;
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
// The row-wide ring sits outside the selected background.
|
|
127
|
+
&.is-selected .block-editor-list-view-block-contents:focus::after {
|
|
128
|
+
--focus-color: CanvasText;
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
// The menu ring is inset over the selected background.
|
|
132
|
+
&.is-selected .block-editor-list-view-block__menu:focus {
|
|
133
|
+
--focus-color: SelectedItemText;
|
|
107
134
|
}
|
|
108
|
-
}
|
|
109
|
-
&.is-selected .block-editor-list-view-block__menu:focus {
|
|
110
|
-
box-shadow: inset 0 0 0 var(--wp-admin-border-width-focus) $white;
|
|
111
135
|
}
|
|
112
136
|
|
|
113
137
|
// Border radius for corners of the selected item.
|
|
@@ -261,18 +285,21 @@
|
|
|
261
285
|
&.is-nesting .block-editor-list-view-block-contents,
|
|
262
286
|
.block-editor-list-view-block-contents:focus {
|
|
263
287
|
box-shadow: none;
|
|
288
|
+
outline: none;
|
|
264
289
|
|
|
265
290
|
&::after {
|
|
266
291
|
content: "";
|
|
267
292
|
position: absolute;
|
|
268
293
|
top: 0;
|
|
269
|
-
right: -(24px +
|
|
294
|
+
right: -(24px + 4px); // Icon size + padding.
|
|
270
295
|
bottom: 0;
|
|
271
296
|
left: 0;
|
|
272
297
|
border-radius: inherit;
|
|
298
|
+
@include outset-ring__focus();
|
|
299
|
+
outline-offset: 1px;
|
|
273
300
|
box-shadow:
|
|
274
|
-
|
|
275
|
-
var(--wpds-color-
|
|
301
|
+
0 0 0 calc(var(--wpds-border-width-focus) + 2px)
|
|
302
|
+
var(--wpds-color-background-surface-neutral-strong);
|
|
276
303
|
z-index: 2;
|
|
277
304
|
pointer-events: none;
|
|
278
305
|
}
|
|
@@ -283,13 +310,6 @@
|
|
|
283
310
|
right: 0;
|
|
284
311
|
}
|
|
285
312
|
|
|
286
|
-
&.is-nesting .block-editor-list-view__menu {
|
|
287
|
-
box-shadow:
|
|
288
|
-
inset 0 0 0 var(--wp-admin-border-width-focus)
|
|
289
|
-
var(--wpds-color-stroke-focus);
|
|
290
|
-
z-index: 1;
|
|
291
|
-
}
|
|
292
|
-
|
|
293
313
|
&.is-visible .block-editor-list-view-block-contents {
|
|
294
314
|
opacity: 1;
|
|
295
315
|
@include animation__fade-in;
|
|
@@ -557,7 +557,7 @@ export default function useListViewDropZone( {
|
|
|
557
557
|
},
|
|
558
558
|
onDragOver( event ) {
|
|
559
559
|
// `currentTarget` is only available while the event is being
|
|
560
|
-
// handled, so get it now and pass it to the
|
|
560
|
+
// handled, so get it now and pass it to the throttled function.
|
|
561
561
|
// https://developer.mozilla.org/en-US/docs/Web/API/Event/currentTarget
|
|
562
562
|
throttled( event, event.currentTarget );
|
|
563
563
|
},
|
|
@@ -1,8 +1,14 @@
|
|
|
1
|
+
import { describe, expect, it, vi } from 'vitest';
|
|
1
2
|
import { render } from '@testing-library/react';
|
|
2
3
|
import { MediaPlaceholder } from '../';
|
|
3
4
|
|
|
4
|
-
|
|
5
|
-
|
|
5
|
+
vi.mock( import( '../../media-upload/check' ), () => ( {
|
|
6
|
+
default: () => null,
|
|
7
|
+
} ) );
|
|
8
|
+
vi.mock( import( '@wordpress/data' ), async ( importOriginal ) => ( {
|
|
9
|
+
...( await importOriginal() ),
|
|
10
|
+
useSelect: () => ( {} ),
|
|
11
|
+
} ) );
|
|
6
12
|
|
|
7
13
|
describe( 'MediaPlaceholder', () => {
|
|
8
14
|
it( 'renders successfully when allowedTypes property is not specified', () => {
|
|
@@ -96,13 +96,18 @@ const MediaReplaceFlow = ( {
|
|
|
96
96
|
};
|
|
97
97
|
|
|
98
98
|
const selectMedia = ( media, closeMenu ) => {
|
|
99
|
+
const hasMedia = !! ( mediaURL || mediaId || mediaIds?.length );
|
|
99
100
|
if ( useFeaturedImage && onToggleFeaturedImage ) {
|
|
100
101
|
onToggleFeaturedImage();
|
|
101
102
|
}
|
|
102
103
|
closeMenu();
|
|
103
104
|
// Calling `onSelect` after the state update since it might unmount the component.
|
|
104
105
|
onSelect( media );
|
|
105
|
-
speak(
|
|
106
|
+
speak(
|
|
107
|
+
hasMedia
|
|
108
|
+
? __( 'The media file has been replaced' )
|
|
109
|
+
: __( 'The media file has been added' )
|
|
110
|
+
);
|
|
106
111
|
removeNotice( errorNoticeID );
|
|
107
112
|
};
|
|
108
113
|
|
|
@@ -1,9 +1,12 @@
|
|
|
1
|
+
import { describe, expect, it } from 'vitest';
|
|
1
2
|
import { render, screen, waitFor } from '@testing-library/react';
|
|
2
3
|
import userEvent from '@testing-library/user-event';
|
|
3
4
|
import { useState } from '@wordpress/element';
|
|
4
5
|
import { SlotFillProvider } from '@wordpress/components';
|
|
5
6
|
import MediaReplaceFlow from '../';
|
|
6
7
|
|
|
8
|
+
globalThis.wpVitest.mockMatchMedia();
|
|
9
|
+
|
|
7
10
|
const noop = () => {};
|
|
8
11
|
|
|
9
12
|
function TestWrapper() {
|
|
@@ -69,6 +69,10 @@ function useIsAccessibleToolbar( toolbarRef ) {
|
|
|
69
69
|
|
|
70
70
|
const determineIsAccessibleToolbar = useCallback( () => {
|
|
71
71
|
const tabbables = focus.tabbable.find( toolbarRef.current );
|
|
72
|
+
// A hidden toolbar has no tabbables, so keep its current classification.
|
|
73
|
+
if ( tabbables.length === 0 ) {
|
|
74
|
+
return;
|
|
75
|
+
}
|
|
72
76
|
const onlyToolbarItem = hasOnlyToolbarItem( tabbables );
|
|
73
77
|
if ( ! onlyToolbarItem ) {
|
|
74
78
|
deprecated( 'Using custom components as toolbar controls', {
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import { afterEach, describe, expect, it } from 'vitest';
|
|
2
|
+
import { act, cleanup, render, screen, waitFor } from '@testing-library/react';
|
|
3
|
+
import { createElement } from '@wordpress/element';
|
|
4
|
+
import NavigableToolbar from '..';
|
|
5
|
+
|
|
6
|
+
function createToolbar( { hidden = false, extraChildren = 0 } = {} ) {
|
|
7
|
+
return createElement(
|
|
8
|
+
'div',
|
|
9
|
+
hidden ? { style: { visibility: 'hidden' } } : null,
|
|
10
|
+
createElement(
|
|
11
|
+
NavigableToolbar,
|
|
12
|
+
{ 'aria-label': 'Block tools' },
|
|
13
|
+
createElement( 'button', null, 'Custom control' ),
|
|
14
|
+
...Array.from( { length: extraChildren }, ( _, index ) =>
|
|
15
|
+
createElement( 'span', { key: index } )
|
|
16
|
+
)
|
|
17
|
+
)
|
|
18
|
+
);
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
describe( 'NavigableToolbar', () => {
|
|
22
|
+
afterEach( cleanup );
|
|
23
|
+
|
|
24
|
+
it( 'does not reclassify a visibility-hidden toolbar when its subtree changes', async () => {
|
|
25
|
+
const { rerender } = render( createToolbar() );
|
|
26
|
+
const initialToolbar = screen.getByRole( 'toolbar' );
|
|
27
|
+
|
|
28
|
+
rerender( createToolbar( { extraChildren: 1 } ) );
|
|
29
|
+
|
|
30
|
+
await waitFor( () => {
|
|
31
|
+
expect( screen.getByRole( 'toolbar' ) ).not.toBe( initialToolbar );
|
|
32
|
+
} );
|
|
33
|
+
expect( console ).toHaveWarned();
|
|
34
|
+
const toolbar = screen.getByRole( 'toolbar' );
|
|
35
|
+
|
|
36
|
+
rerender( createToolbar( { hidden: true, extraChildren: 2 } ) );
|
|
37
|
+
|
|
38
|
+
await act(
|
|
39
|
+
() =>
|
|
40
|
+
new Promise( ( resolve ) =>
|
|
41
|
+
window.requestAnimationFrame( () =>
|
|
42
|
+
window.requestAnimationFrame( resolve )
|
|
43
|
+
)
|
|
44
|
+
)
|
|
45
|
+
);
|
|
46
|
+
expect( screen.getByRole( 'toolbar', { hidden: true } ) ).toBe(
|
|
47
|
+
toolbar
|
|
48
|
+
);
|
|
49
|
+
} );
|
|
50
|
+
} );
|
|
@@ -1,9 +1,15 @@
|
|
|
1
|
+
import { beforeEach, describe, expect, it, vi } from 'vitest';
|
|
1
2
|
import { render, screen, fireEvent, waitFor } from '@testing-library/react';
|
|
2
3
|
import userEvent from '@testing-library/user-event';
|
|
3
4
|
import PresetInputControl from '../index';
|
|
4
5
|
|
|
6
|
+
globalThis.wpVitest.mockMatchMedia();
|
|
7
|
+
|
|
8
|
+
globalThis.wpVitest.mockVisibleElements();
|
|
9
|
+
globalThis.wpVitest.mockScrollIntoView();
|
|
10
|
+
|
|
5
11
|
describe( 'PresetInputControl', () => {
|
|
6
|
-
const mockOnChange =
|
|
12
|
+
const mockOnChange = vi.fn();
|
|
7
13
|
|
|
8
14
|
const defaultProps = {
|
|
9
15
|
ariaLabel: 'Spacing control',
|
|
@@ -19,7 +25,7 @@ describe( 'PresetInputControl', () => {
|
|
|
19
25
|
];
|
|
20
26
|
|
|
21
27
|
beforeEach( () => {
|
|
22
|
-
|
|
28
|
+
vi.clearAllMocks();
|
|
23
29
|
} );
|
|
24
30
|
|
|
25
31
|
it( 'renders preset selection controls', () => {
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { beforeEach, describe, expect, it, vi } from 'vitest';
|
|
1
2
|
import { render } from '@testing-library/react';
|
|
2
3
|
import { useRegistry, useSelect } from '@wordpress/data';
|
|
3
4
|
import { BlockEditorProvider, ExperimentalBlockEditorProvider } from '../';
|
|
@@ -63,9 +64,9 @@ describe( 'BlockEditorProvider', () => {
|
|
|
63
64
|
expect( settings ).toHaveProperty( 'stableSetting' );
|
|
64
65
|
} );
|
|
65
66
|
it( 'preserves deprecated getters incoming from the settings reducer', async () => {
|
|
66
|
-
const consoleWarn =
|
|
67
|
+
const consoleWarn = vi
|
|
67
68
|
.spyOn( global.console, 'warn' )
|
|
68
|
-
.mockImplementation();
|
|
69
|
+
.mockImplementation( () => {} );
|
|
69
70
|
|
|
70
71
|
const { container } = render(
|
|
71
72
|
<BlockEditorProvider
|
|
@@ -1,16 +1,17 @@
|
|
|
1
1
|
import { registerBlockType } from '@wordpress/blocks';
|
|
2
|
+
import { afterEach, beforeAll, describe, expect, it, vi } from 'vitest';
|
|
2
3
|
import { render } from '@testing-library/react';
|
|
3
4
|
import useBlockSync from '../use-block-sync';
|
|
4
5
|
import withRegistryProvider from '../with-registry-provider';
|
|
5
6
|
import * as blockEditorActions from '../../../store/actions';
|
|
6
7
|
import { store as blockEditorStore } from '../../../store';
|
|
7
|
-
|
|
8
|
-
const actions =
|
|
8
|
+
vi.mock( import( '../../../store/actions' ), async ( importOriginal ) => {
|
|
9
|
+
const actions = await importOriginal();
|
|
9
10
|
return {
|
|
10
11
|
...actions,
|
|
11
|
-
resetBlocks:
|
|
12
|
-
replaceInnerBlocks:
|
|
13
|
-
setHasControlledInnerBlocks:
|
|
12
|
+
resetBlocks: vi.fn( actions.resetBlocks ),
|
|
13
|
+
replaceInnerBlocks: vi.fn( actions.replaceInnerBlocks ),
|
|
14
|
+
setHasControlledInnerBlocks: vi.fn(
|
|
14
15
|
actions.setHasControlledInnerBlocks
|
|
15
16
|
),
|
|
16
17
|
};
|
|
@@ -36,18 +37,18 @@ describe( 'useBlockSync hook', () => {
|
|
|
36
37
|
} );
|
|
37
38
|
|
|
38
39
|
afterEach( () => {
|
|
39
|
-
|
|
40
|
+
vi.clearAllMocks();
|
|
40
41
|
} );
|
|
41
42
|
|
|
42
43
|
it( 'resets the block-editor blocks when the controlled value changes', async () => {
|
|
43
44
|
const fakeBlocks = [];
|
|
44
|
-
const resetBlocks =
|
|
45
|
-
const replaceInnerBlocks =
|
|
45
|
+
const resetBlocks = vi.spyOn( blockEditorActions, 'resetBlocks' );
|
|
46
|
+
const replaceInnerBlocks = vi.spyOn(
|
|
46
47
|
blockEditorActions,
|
|
47
48
|
'replaceInnerBlocks'
|
|
48
49
|
);
|
|
49
|
-
const onChange =
|
|
50
|
-
const onInput =
|
|
50
|
+
const onChange = vi.fn();
|
|
51
|
+
const onInput = vi.fn();
|
|
51
52
|
|
|
52
53
|
const { rerender, unmount } = render(
|
|
53
54
|
<TestWrapper
|
|
@@ -93,13 +94,13 @@ describe( 'useBlockSync hook', () => {
|
|
|
93
94
|
|
|
94
95
|
it( 'replaces the inner blocks of a block when the controlled value changes if a clientId is passed', async () => {
|
|
95
96
|
const fakeBlocks = [];
|
|
96
|
-
const replaceInnerBlocks =
|
|
97
|
+
const replaceInnerBlocks = vi.spyOn(
|
|
97
98
|
blockEditorActions,
|
|
98
99
|
'replaceInnerBlocks'
|
|
99
100
|
);
|
|
100
|
-
const resetBlocks =
|
|
101
|
-
const onChange =
|
|
102
|
-
const onInput =
|
|
101
|
+
const resetBlocks = vi.spyOn( blockEditorActions, 'resetBlocks' );
|
|
102
|
+
const onChange = vi.fn();
|
|
103
|
+
const onInput = vi.fn();
|
|
103
104
|
|
|
104
105
|
const { rerender, unmount } = render(
|
|
105
106
|
<TestWrapper
|
|
@@ -155,12 +156,12 @@ describe( 'useBlockSync hook', () => {
|
|
|
155
156
|
} );
|
|
156
157
|
|
|
157
158
|
it( 'does not add the controlled blocks to the block-editor store if the store already contains them', async () => {
|
|
158
|
-
const replaceInnerBlocks =
|
|
159
|
+
const replaceInnerBlocks = vi.spyOn(
|
|
159
160
|
blockEditorActions,
|
|
160
161
|
'replaceInnerBlocks'
|
|
161
162
|
);
|
|
162
|
-
const onChange =
|
|
163
|
-
const onInput =
|
|
163
|
+
const onChange = vi.fn();
|
|
164
|
+
const onInput = vi.fn();
|
|
164
165
|
|
|
165
166
|
const value1 = [
|
|
166
167
|
{
|
|
@@ -213,7 +214,7 @@ describe( 'useBlockSync hook', () => {
|
|
|
213
214
|
} );
|
|
214
215
|
|
|
215
216
|
it( 'sets a block as an inner block controller if a clientId is provided', async () => {
|
|
216
|
-
const setAsController =
|
|
217
|
+
const setAsController = vi.spyOn(
|
|
217
218
|
blockEditorActions,
|
|
218
219
|
'setHasControlledInnerBlocks'
|
|
219
220
|
);
|
|
@@ -222,16 +223,16 @@ describe( 'useBlockSync hook', () => {
|
|
|
222
223
|
<TestWrapper
|
|
223
224
|
clientId="test"
|
|
224
225
|
value={ [] }
|
|
225
|
-
onChange={
|
|
226
|
-
onInput={
|
|
226
|
+
onChange={ vi.fn() }
|
|
227
|
+
onInput={ vi.fn() }
|
|
227
228
|
/>
|
|
228
229
|
);
|
|
229
230
|
expect( setAsController ).toHaveBeenCalledWith( 'test', true );
|
|
230
231
|
} );
|
|
231
232
|
|
|
232
233
|
it( 'calls onInput when a non-persistent block change occurs', async () => {
|
|
233
|
-
const onChange =
|
|
234
|
-
const onInput =
|
|
234
|
+
const onChange = vi.fn();
|
|
235
|
+
const onInput = vi.fn();
|
|
235
236
|
const value1 = [
|
|
236
237
|
{ clientId: 'a', innerBlocks: [], attributes: { foo: 1 } },
|
|
237
238
|
];
|
|
@@ -266,8 +267,8 @@ describe( 'useBlockSync hook', () => {
|
|
|
266
267
|
} );
|
|
267
268
|
|
|
268
269
|
it( 'passes undoIgnore when a non-persistent block change ignores history', async () => {
|
|
269
|
-
const onChange =
|
|
270
|
-
const onInput =
|
|
270
|
+
const onChange = vi.fn();
|
|
271
|
+
const onInput = vi.fn();
|
|
271
272
|
const value1 = [
|
|
272
273
|
{ clientId: 'a', innerBlocks: [], attributes: { foo: 1 } },
|
|
273
274
|
];
|
|
@@ -306,8 +307,8 @@ describe( 'useBlockSync hook', () => {
|
|
|
306
307
|
} );
|
|
307
308
|
|
|
308
309
|
it( 'calls onChange if a persistent change occurs', async () => {
|
|
309
|
-
const onChange =
|
|
310
|
-
const onInput =
|
|
310
|
+
const onChange = vi.fn();
|
|
311
|
+
const onInput = vi.fn();
|
|
311
312
|
|
|
312
313
|
const value1 = [
|
|
313
314
|
{ clientId: 'a', innerBlocks: [], attributes: { foo: 1 } },
|
|
@@ -340,13 +341,13 @@ describe( 'useBlockSync hook', () => {
|
|
|
340
341
|
} );
|
|
341
342
|
|
|
342
343
|
it( 'avoids updating the parent if there is a pending incoming change', async () => {
|
|
343
|
-
const replaceInnerBlocks =
|
|
344
|
+
const replaceInnerBlocks = vi.spyOn(
|
|
344
345
|
blockEditorActions,
|
|
345
346
|
'replaceInnerBlocks'
|
|
346
347
|
);
|
|
347
348
|
|
|
348
|
-
const onChange =
|
|
349
|
-
const onInput =
|
|
349
|
+
const onChange = vi.fn();
|
|
350
|
+
const onInput = vi.fn();
|
|
350
351
|
|
|
351
352
|
const value1 = [
|
|
352
353
|
{
|
|
@@ -385,13 +386,13 @@ describe( 'useBlockSync hook', () => {
|
|
|
385
386
|
} );
|
|
386
387
|
|
|
387
388
|
it( 'avoids updating the block-editor store if there is a pending outgoint change', async () => {
|
|
388
|
-
const replaceInnerBlocks =
|
|
389
|
+
const replaceInnerBlocks = vi.spyOn(
|
|
389
390
|
blockEditorActions,
|
|
390
391
|
'replaceInnerBlocks'
|
|
391
392
|
);
|
|
392
393
|
|
|
393
|
-
const onChange =
|
|
394
|
-
const onInput =
|
|
394
|
+
const onChange = vi.fn();
|
|
395
|
+
const onInput = vi.fn();
|
|
395
396
|
|
|
396
397
|
const value1 = [
|
|
397
398
|
{
|
|
@@ -441,8 +442,8 @@ describe( 'useBlockSync hook', () => {
|
|
|
441
442
|
const fakeBlocks = [
|
|
442
443
|
{ clientId: 'a', innerBlocks: [], attributes: { foo: 1 } },
|
|
443
444
|
];
|
|
444
|
-
const onChange1 =
|
|
445
|
-
const onInput =
|
|
445
|
+
const onChange1 = vi.fn();
|
|
446
|
+
const onInput = vi.fn();
|
|
446
447
|
|
|
447
448
|
let registry;
|
|
448
449
|
const setRegistry = ( reg ) => {
|
|
@@ -478,7 +479,7 @@ describe( 'useBlockSync hook', () => {
|
|
|
478
479
|
|
|
479
480
|
// Reset it so that we can test that it was not called after this point.
|
|
480
481
|
onChange1.mockReset();
|
|
481
|
-
const onChange2 =
|
|
482
|
+
const onChange2 = vi.fn();
|
|
482
483
|
|
|
483
484
|
// Update the component to point at a "different entity" (e.g. different
|
|
484
485
|
// blocks and onChange handler.)
|
|
@@ -510,8 +511,8 @@ describe( 'useBlockSync hook', () => {
|
|
|
510
511
|
const fakeBlocks = [
|
|
511
512
|
{ clientId: 'a', innerBlocks: [], attributes: { foo: 1 } },
|
|
512
513
|
];
|
|
513
|
-
const onChange1 =
|
|
514
|
-
const onInput =
|
|
514
|
+
const onChange1 = vi.fn();
|
|
515
|
+
const onInput = vi.fn();
|
|
515
516
|
|
|
516
517
|
let registry;
|
|
517
518
|
const setRegistry = ( reg ) => {
|
|
@@ -531,7 +532,7 @@ describe( 'useBlockSync hook', () => {
|
|
|
531
532
|
{ clientId: 'b', innerBlocks: [], attributes: { foo: 1 } },
|
|
532
533
|
];
|
|
533
534
|
|
|
534
|
-
const onChange2 =
|
|
535
|
+
const onChange2 = vi.fn();
|
|
535
536
|
|
|
536
537
|
// Update the component to point at a "different entity" (e.g. different
|
|
537
538
|
// blocks and onChange handler.)
|
|
@@ -562,9 +563,9 @@ describe( 'useBlockSync hook', () => {
|
|
|
562
563
|
it( 'preserves external client IDs in onChange callback for inner block controllers', async () => {
|
|
563
564
|
const originalClientId = 'original-external-id';
|
|
564
565
|
const innerBlockClientId = 'inner-external-id';
|
|
565
|
-
const onChange =
|
|
566
|
-
const onInput =
|
|
567
|
-
const replaceInnerBlocks =
|
|
566
|
+
const onChange = vi.fn();
|
|
567
|
+
const onInput = vi.fn();
|
|
568
|
+
const replaceInnerBlocks = vi.spyOn(
|
|
568
569
|
blockEditorActions,
|
|
569
570
|
'replaceInnerBlocks'
|
|
570
571
|
);
|
|
@@ -630,7 +631,7 @@ describe( 'useBlockSync hook', () => {
|
|
|
630
631
|
|
|
631
632
|
it( 'clones blocks with new internal IDs for inner block controllers', async () => {
|
|
632
633
|
const originalClientId = 'original-external-id';
|
|
633
|
-
const replaceInnerBlocks =
|
|
634
|
+
const replaceInnerBlocks = vi.spyOn(
|
|
634
635
|
blockEditorActions,
|
|
635
636
|
'replaceInnerBlocks'
|
|
636
637
|
);
|
|
@@ -649,8 +650,8 @@ describe( 'useBlockSync hook', () => {
|
|
|
649
650
|
<TestWrapper
|
|
650
651
|
clientId="test-controller"
|
|
651
652
|
value={ controlledBlocks }
|
|
652
|
-
onChange={
|
|
653
|
-
onInput={
|
|
653
|
+
onChange={ vi.fn() }
|
|
654
|
+
onInput={ vi.fn() }
|
|
654
655
|
/>
|
|
655
656
|
);
|
|
656
657
|
|
|
@@ -1,9 +1,12 @@
|
|
|
1
|
+
import { describe, expect, it, vi } from 'vitest';
|
|
1
2
|
import { render, screen } from '@testing-library/react';
|
|
2
3
|
import userEvent from '@testing-library/user-event';
|
|
3
4
|
import { Fragment, useState } from '@wordpress/element';
|
|
4
5
|
import { SelectControl } from '@wordpress/components';
|
|
5
6
|
import ResponsiveBlockControl from '../index';
|
|
6
7
|
|
|
8
|
+
globalThis.wpVitest.mockMatchMedia();
|
|
9
|
+
|
|
7
10
|
const inputId = 'input-12345678';
|
|
8
11
|
|
|
9
12
|
const sizeOptions = [
|
|
@@ -198,7 +201,7 @@ describe( 'Default and Responsive modes', () => {
|
|
|
198
201
|
},
|
|
199
202
|
];
|
|
200
203
|
|
|
201
|
-
const mockRenderDefaultControl =
|
|
204
|
+
const mockRenderDefaultControl = vi.fn(
|
|
202
205
|
renderTestDefaultControlComponent
|
|
203
206
|
);
|
|
204
207
|
|
|
@@ -285,9 +288,9 @@ describe( 'Default and Responsive modes', () => {
|
|
|
285
288
|
} );
|
|
286
289
|
|
|
287
290
|
it( 'should render custom responsive controls when renderResponsiveControls prop is provided and in responsive mode', () => {
|
|
288
|
-
const spyRenderDefaultControl =
|
|
291
|
+
const spyRenderDefaultControl = vi.fn();
|
|
289
292
|
|
|
290
|
-
const mockRenderResponsiveControls =
|
|
293
|
+
const mockRenderResponsiveControls = vi.fn( ( viewports ) => {
|
|
291
294
|
return viewports.map( ( { id, label } ) => {
|
|
292
295
|
return (
|
|
293
296
|
<Fragment key={ `${ inputId }-${ id }` }>
|