@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
|
@@ -41,10 +41,10 @@ export default ( props ) => ( element ) => {
|
|
|
41
41
|
} else if ( onSplitAtEnd && start === end && end === text.length ) {
|
|
42
42
|
event.preventDefault();
|
|
43
43
|
onSplitAtEnd();
|
|
44
|
-
} else if ( onReplace && onSplit ) {
|
|
45
|
-
event.__deprecatedOnSplit = true;
|
|
46
44
|
} else if (
|
|
47
45
|
! supportsSplitting &&
|
|
46
|
+
// The deprecated onSplit is flagged on the beforeinput event.
|
|
47
|
+
! ( onReplace && onSplit ) &&
|
|
48
48
|
! disableLineBreaks &&
|
|
49
49
|
! event.defaultPrevented
|
|
50
50
|
) {
|
|
@@ -70,8 +70,22 @@ export default ( props ) => ( element ) => {
|
|
|
70
70
|
}
|
|
71
71
|
}
|
|
72
72
|
|
|
73
|
-
function
|
|
74
|
-
if ( event.
|
|
73
|
+
function onBeforeInput( event ) {
|
|
74
|
+
if ( event.inputType !== 'insertParagraph' ) {
|
|
75
|
+
return;
|
|
76
|
+
}
|
|
77
|
+
const { onReplace, onSplit } = props.current;
|
|
78
|
+
if ( onReplace && onSplit ) {
|
|
79
|
+
event.__deprecatedOnSplit = true;
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
function onDefaultBeforeInput( event ) {
|
|
84
|
+
if (
|
|
85
|
+
event.defaultPrevented ||
|
|
86
|
+
( event.inputType !== 'insertParagraph' &&
|
|
87
|
+
event.inputType !== 'insertLineBreak' )
|
|
88
|
+
) {
|
|
75
89
|
return;
|
|
76
90
|
}
|
|
77
91
|
|
|
@@ -82,12 +96,6 @@ export default ( props ) => ( element ) => {
|
|
|
82
96
|
return;
|
|
83
97
|
}
|
|
84
98
|
|
|
85
|
-
if ( event.keyCode !== ENTER ) {
|
|
86
|
-
return;
|
|
87
|
-
}
|
|
88
|
-
|
|
89
|
-
// On ENTER, we ALWAYS want to prevent the default browser behaviour
|
|
90
|
-
// at this last interception point.
|
|
91
99
|
event.preventDefault();
|
|
92
100
|
}
|
|
93
101
|
|
|
@@ -95,10 +103,10 @@ export default ( props ) => ( element ) => {
|
|
|
95
103
|
|
|
96
104
|
// Attach the listener to the window so parent elements have the chance to
|
|
97
105
|
// prevent the default behavior.
|
|
98
|
-
const
|
|
106
|
+
const unsubscribeDefaultBeforeInput = subscribeDelegatedListener(
|
|
99
107
|
defaultView,
|
|
100
|
-
'
|
|
101
|
-
|
|
108
|
+
'beforeinput',
|
|
109
|
+
onDefaultBeforeInput
|
|
102
110
|
);
|
|
103
111
|
// Capture phase so this runs before ancestor (writing flow) bubble
|
|
104
112
|
// handlers, matching the timing of the previous raw element listener.
|
|
@@ -108,8 +116,15 @@ export default ( props ) => ( element ) => {
|
|
|
108
116
|
onKeyDown,
|
|
109
117
|
true
|
|
110
118
|
);
|
|
119
|
+
const unsubscribeBeforeInput = subscribeOwnedListener(
|
|
120
|
+
element,
|
|
121
|
+
'beforeinput',
|
|
122
|
+
onBeforeInput,
|
|
123
|
+
true
|
|
124
|
+
);
|
|
111
125
|
return () => {
|
|
112
|
-
|
|
126
|
+
unsubscribeDefaultBeforeInput();
|
|
113
127
|
unsubscribeKeyDown();
|
|
128
|
+
unsubscribeBeforeInput();
|
|
114
129
|
};
|
|
115
130
|
};
|
|
@@ -6,7 +6,6 @@ import insertReplacementText from './insert-replacement-text';
|
|
|
6
6
|
import removeBrowserShortcuts from './remove-browser-shortcuts';
|
|
7
7
|
import shortcuts from './shortcuts';
|
|
8
8
|
import inputEvents from './input-events';
|
|
9
|
-
import undoAutomaticChange from './undo-automatic-change';
|
|
10
9
|
import pasteHandler from './paste-handler';
|
|
11
10
|
import _delete from './delete';
|
|
12
11
|
import enter from './enter';
|
|
@@ -19,7 +18,6 @@ const allEventListeners = [
|
|
|
19
18
|
removeBrowserShortcuts,
|
|
20
19
|
shortcuts,
|
|
21
20
|
inputEvents,
|
|
22
|
-
undoAutomaticChange,
|
|
23
21
|
pasteHandler,
|
|
24
22
|
_delete,
|
|
25
23
|
enter,
|
|
@@ -84,8 +84,13 @@ export default ( props ) => ( element ) => {
|
|
|
84
84
|
} );
|
|
85
85
|
const block = transformation.transform( content );
|
|
86
86
|
|
|
87
|
-
|
|
88
|
-
|
|
87
|
+
// Batch so the undo history records the pre-transform selection,
|
|
88
|
+
// instead of the selection change here overwriting it first.
|
|
89
|
+
registry.batch( () => {
|
|
90
|
+
selectionChange( ...findSelection( [ block ] ) );
|
|
91
|
+
onReplace( [ block ] );
|
|
92
|
+
} );
|
|
93
|
+
|
|
89
94
|
registry.dispatch( blockEditorStore ).__unstableMarkAutomaticChange();
|
|
90
95
|
|
|
91
96
|
return true;
|
|
@@ -19,18 +19,29 @@
|
|
|
19
19
|
* The tests ensure that when the SpacingSizesControl is refactored to use
|
|
20
20
|
* PresetInputControl, the existing user experience and behavior is preserved.
|
|
21
21
|
*/
|
|
22
|
+
|
|
23
|
+
import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest';
|
|
22
24
|
import { render, screen, fireEvent, waitFor } from '@testing-library/react';
|
|
23
25
|
import userEvent from '@testing-library/user-event';
|
|
24
26
|
import { useSelect } from '@wordpress/data';
|
|
25
27
|
import SpacingSizesControl from '../index';
|
|
28
|
+
import useSpacingSizes from '../hooks/use-spacing-sizes';
|
|
29
|
+
|
|
30
|
+
globalThis.wpVitest.mockMatchMedia();
|
|
31
|
+
|
|
32
|
+
globalThis.wpVitest.mockVisibleElements();
|
|
33
|
+
globalThis.wpVitest.mockScrollIntoView();
|
|
26
34
|
|
|
27
35
|
// Mock useSelect
|
|
28
|
-
|
|
36
|
+
vi.mock( import( '@wordpress/data' ), async ( importOriginal ) => ( {
|
|
37
|
+
...( await importOriginal() ),
|
|
38
|
+
useSelect: vi.fn(),
|
|
39
|
+
} ) );
|
|
29
40
|
|
|
30
41
|
// Mock useSpacingSizes hook
|
|
31
|
-
|
|
42
|
+
vi.mock( import( '../hooks/use-spacing-sizes' ), () => ( {
|
|
32
43
|
__esModule: true,
|
|
33
|
-
default:
|
|
44
|
+
default: vi.fn( () => [
|
|
34
45
|
{ name: 'None', slug: '0', size: 0 },
|
|
35
46
|
{ name: 'Small', slug: '20', size: '0.5rem' },
|
|
36
47
|
{ name: 'Medium', slug: '40', size: '1rem' },
|
|
@@ -40,8 +51,8 @@ jest.mock( '../hooks/use-spacing-sizes', () => ( {
|
|
|
40
51
|
} ) );
|
|
41
52
|
|
|
42
53
|
// Mock useSettings hook
|
|
43
|
-
|
|
44
|
-
useSettings:
|
|
54
|
+
vi.mock( import( '../../use-settings' ), () => ( {
|
|
55
|
+
useSettings: vi.fn( ( ...keys ) => {
|
|
45
56
|
const defaults = {
|
|
46
57
|
'spacing.units': [ 'px', 'em', 'rem' ],
|
|
47
58
|
'spacing.spacingSizes.custom': [],
|
|
@@ -54,7 +65,7 @@ jest.mock( '../../use-settings', () => ( {
|
|
|
54
65
|
} ) );
|
|
55
66
|
|
|
56
67
|
describe( 'SpacingSizesControl', () => {
|
|
57
|
-
const mockOnChange =
|
|
68
|
+
const mockOnChange = vi.fn();
|
|
58
69
|
const defaultProps = {
|
|
59
70
|
label: 'Padding',
|
|
60
71
|
onChange: mockOnChange,
|
|
@@ -721,15 +732,11 @@ describe( 'SpacingSizesControl', () => {
|
|
|
721
732
|
|
|
722
733
|
// Mock the large preset set
|
|
723
734
|
beforeEach( () => {
|
|
724
|
-
|
|
725
|
-
'../hooks/use-spacing-sizes'
|
|
726
|
-
).default.mockReturnValue( largeSpacingSizes );
|
|
735
|
+
useSpacingSizes.mockReturnValue( largeSpacingSizes );
|
|
727
736
|
} );
|
|
728
737
|
|
|
729
738
|
afterEach( () => {
|
|
730
|
-
|
|
731
|
-
'../hooks/use-spacing-sizes'
|
|
732
|
-
).default.mockReturnValue( [
|
|
739
|
+
useSpacingSizes.mockReturnValue( [
|
|
733
740
|
{ name: 'None', slug: '0', size: 0 },
|
|
734
741
|
{ name: 'Small', slug: '20', size: '0.5rem' },
|
|
735
742
|
{ name: 'Medium', slug: '40', size: '1rem' },
|
|
@@ -891,8 +898,8 @@ describe( 'SpacingSizesControl', () => {
|
|
|
891
898
|
} );
|
|
892
899
|
|
|
893
900
|
it( 'calls onMouseOver and onMouseOut callbacks', async () => {
|
|
894
|
-
const mockOnMouseOver =
|
|
895
|
-
const mockOnMouseOut =
|
|
901
|
+
const mockOnMouseOver = vi.fn();
|
|
902
|
+
const mockOnMouseOut = vi.fn();
|
|
896
903
|
const user = userEvent.setup();
|
|
897
904
|
|
|
898
905
|
render(
|
|
@@ -955,9 +962,7 @@ describe( 'SpacingSizesControl', () => {
|
|
|
955
962
|
{ name: 'Huge', slug: '100', size: '5rem' },
|
|
956
963
|
];
|
|
957
964
|
|
|
958
|
-
|
|
959
|
-
'../hooks/use-spacing-sizes'
|
|
960
|
-
).default.mockReturnValueOnce( customSpacingSizes );
|
|
965
|
+
useSpacingSizes.mockReturnValueOnce( customSpacingSizes );
|
|
961
966
|
|
|
962
967
|
render(
|
|
963
968
|
<SpacingSizesControl { ...defaultProps } values={ undefined } />
|
|
@@ -973,9 +978,7 @@ describe( 'SpacingSizesControl', () => {
|
|
|
973
978
|
{ name: 'Theme Large', slug: 'theme-lg', size: '2.25rem' },
|
|
974
979
|
];
|
|
975
980
|
|
|
976
|
-
|
|
977
|
-
'../hooks/use-spacing-sizes'
|
|
978
|
-
).default.mockReturnValueOnce( themeSpacingSizes );
|
|
981
|
+
useSpacingSizes.mockReturnValueOnce( themeSpacingSizes );
|
|
979
982
|
|
|
980
983
|
render(
|
|
981
984
|
<SpacingSizesControl
|
|
@@ -1,8 +1,11 @@
|
|
|
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 { useState } from '@wordpress/element';
|
|
4
5
|
import URLInputButton from '../button';
|
|
5
6
|
|
|
7
|
+
globalThis.wpVitest.mockMatchMedia();
|
|
8
|
+
|
|
6
9
|
describe( 'URLInputButton', () => {
|
|
7
10
|
it( 'should render a `Insert link` button and not be pressed when `url` is not provided', () => {
|
|
8
11
|
render( <URLInputButton /> );
|
|
@@ -67,7 +70,7 @@ describe( 'URLInputButton', () => {
|
|
|
67
70
|
|
|
68
71
|
it( 'should call `onChange` function once per each value change', async () => {
|
|
69
72
|
const user = userEvent.setup();
|
|
70
|
-
const onChangeMock =
|
|
73
|
+
const onChangeMock = vi.fn();
|
|
71
74
|
|
|
72
75
|
render( <URLInputButton onChange={ onChangeMock } /> );
|
|
73
76
|
|
|
@@ -1,4 +1,11 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest';
|
|
2
|
+
import {
|
|
3
|
+
act,
|
|
4
|
+
fireEvent,
|
|
5
|
+
render,
|
|
6
|
+
screen,
|
|
7
|
+
waitFor,
|
|
8
|
+
} from '@testing-library/react';
|
|
2
9
|
import userEvent from '@testing-library/user-event';
|
|
3
10
|
import { speak } from '@wordpress/a11y';
|
|
4
11
|
import { useState } from '@wordpress/element';
|
|
@@ -8,7 +15,10 @@ import URLInput from '../';
|
|
|
8
15
|
import { store as blockEditorStore } from '../../../store';
|
|
9
16
|
import { expectValidatedInputControlDeprecationIfCalled } from './fixtures/validated-input-control-deprecation';
|
|
10
17
|
|
|
11
|
-
|
|
18
|
+
globalThis.wpVitest.mockScrollIntoView();
|
|
19
|
+
globalThis.wpVitest.mockMatchMedia();
|
|
20
|
+
|
|
21
|
+
vi.mock( import( '@wordpress/a11y' ), () => ( { speak: vi.fn() } ) );
|
|
12
22
|
|
|
13
23
|
const SUGGESTIONS = [
|
|
14
24
|
{
|
|
@@ -37,8 +47,8 @@ const KEY_EVENTS = {
|
|
|
37
47
|
* Waits long enough for the suggestions request debounce to elapse, so that
|
|
38
48
|
* assertions about a request _not_ being made are meaningful.
|
|
39
49
|
*/
|
|
40
|
-
function flushDebounce() {
|
|
41
|
-
|
|
50
|
+
async function flushDebounce() {
|
|
51
|
+
await act( () => new Promise( ( resolve ) => setTimeout( resolve, 250 ) ) );
|
|
42
52
|
}
|
|
43
53
|
|
|
44
54
|
/**
|
|
@@ -68,16 +78,16 @@ describe( 'URLInput', () => {
|
|
|
68
78
|
let fetchLinkSuggestions;
|
|
69
79
|
|
|
70
80
|
beforeEach( () => {
|
|
71
|
-
fetchLinkSuggestions =
|
|
81
|
+
fetchLinkSuggestions = vi.fn().mockResolvedValue( SUGGESTIONS );
|
|
72
82
|
} );
|
|
73
83
|
|
|
74
84
|
afterEach( () => {
|
|
75
|
-
|
|
85
|
+
vi.clearAllMocks();
|
|
76
86
|
} );
|
|
77
87
|
|
|
78
88
|
function renderURLInput( props = {} ) {
|
|
79
89
|
const user = userEvent.setup();
|
|
80
|
-
const onChange =
|
|
90
|
+
const onChange = vi.fn();
|
|
81
91
|
|
|
82
92
|
render(
|
|
83
93
|
<ControlledURLInput
|
|
@@ -471,7 +481,7 @@ describe( 'URLInput', () => {
|
|
|
471
481
|
} );
|
|
472
482
|
|
|
473
483
|
it( 'should select and submit the active suggestion when pressing Enter', async () => {
|
|
474
|
-
const onSubmit =
|
|
484
|
+
const onSubmit = vi.fn();
|
|
475
485
|
const { input, onChange } = await renderWithSuggestions( {
|
|
476
486
|
onSubmit,
|
|
477
487
|
} );
|
|
@@ -491,7 +501,7 @@ describe( 'URLInput', () => {
|
|
|
491
501
|
} );
|
|
492
502
|
|
|
493
503
|
it( 'should submit without a suggestion when pressing Enter with no active suggestion', async () => {
|
|
494
|
-
const onSubmit =
|
|
504
|
+
const onSubmit = vi.fn();
|
|
495
505
|
const { input } = await renderWithSuggestions( { onSubmit } );
|
|
496
506
|
|
|
497
507
|
fireEvent.keyDown( input, KEY_EVENTS.enter );
|
|
@@ -500,8 +510,8 @@ describe( 'URLInput', () => {
|
|
|
500
510
|
} );
|
|
501
511
|
|
|
502
512
|
it( 'should submit without a suggestion when pressing Enter and there are no suggestions', async () => {
|
|
503
|
-
const onSubmit =
|
|
504
|
-
const onKeyDown =
|
|
513
|
+
const onSubmit = vi.fn();
|
|
514
|
+
const onKeyDown = vi.fn();
|
|
505
515
|
const { input } = renderURLInput( {
|
|
506
516
|
value: 'hello',
|
|
507
517
|
disableSuggestions: true,
|
|
@@ -587,7 +597,7 @@ describe( 'URLInput', () => {
|
|
|
587
597
|
|
|
588
598
|
describe( 'custom rendering', () => {
|
|
589
599
|
it( 'should render the control via `__experimentalRenderControl`', () => {
|
|
590
|
-
const renderControl =
|
|
600
|
+
const renderControl = vi
|
|
591
601
|
.fn()
|
|
592
602
|
.mockReturnValue( <div>Custom control</div> );
|
|
593
603
|
|
|
@@ -608,7 +618,7 @@ describe( 'URLInput', () => {
|
|
|
608
618
|
} );
|
|
609
619
|
|
|
610
620
|
it( 'should render suggestions via `__experimentalRenderSuggestions`', async () => {
|
|
611
|
-
const renderSuggestions =
|
|
621
|
+
const renderSuggestions = vi.fn( ( { suggestions } ) => (
|
|
612
622
|
<ul>
|
|
613
623
|
{ suggestions.map( ( suggestion ) => (
|
|
614
624
|
<li key={ suggestion.id }>{ suggestion.title }</li>
|
package/src/components/use-block-display-information/test/{index.jsx → index.jsdom.test.jsx}
RENAMED
|
@@ -1,14 +1,18 @@
|
|
|
1
|
+
import { beforeEach, describe, expect, it, vi } from 'vitest';
|
|
1
2
|
import { render } from '@testing-library/react';
|
|
2
3
|
import { useSelect } from '@wordpress/data';
|
|
3
4
|
import { useEffect } from '@wordpress/element';
|
|
4
5
|
import { symbol } from '@wordpress/icons';
|
|
5
6
|
import useBlockDisplayInformation from '../';
|
|
6
7
|
|
|
7
|
-
|
|
8
|
-
|
|
8
|
+
vi.mock( import( '@wordpress/data' ), async ( importOriginal ) => ( {
|
|
9
|
+
...( await importOriginal() ),
|
|
10
|
+
useSelect: vi.fn(),
|
|
11
|
+
} ) );
|
|
12
|
+
vi.mock( import( '../../../lock-unlock' ), () => ( {
|
|
9
13
|
unlock: ( value ) => ( {
|
|
10
|
-
registerPrivateActions:
|
|
11
|
-
registerPrivateSelectors:
|
|
14
|
+
registerPrivateActions: vi.fn(),
|
|
15
|
+
registerPrivateSelectors: vi.fn(),
|
|
12
16
|
...value,
|
|
13
17
|
} ),
|
|
14
18
|
} ) );
|
|
@@ -64,12 +68,12 @@ function setupUseSelect( {
|
|
|
64
68
|
|
|
65
69
|
describe( 'useBlockDisplayInformation', () => {
|
|
66
70
|
beforeEach( () => {
|
|
67
|
-
|
|
71
|
+
vi.clearAllMocks();
|
|
68
72
|
} );
|
|
69
73
|
|
|
70
74
|
it( 'displays pattern information for a pattern section that is not being edited', () => {
|
|
71
75
|
setupUseSelect();
|
|
72
|
-
const onChange =
|
|
76
|
+
const onChange = vi.fn();
|
|
73
77
|
|
|
74
78
|
render( <TestComponent onChange={ onChange } /> );
|
|
75
79
|
|
|
@@ -85,7 +89,7 @@ describe( 'useBlockDisplayInformation', () => {
|
|
|
85
89
|
|
|
86
90
|
it( 'displays block information for a pattern section that is being edited', () => {
|
|
87
91
|
setupUseSelect( { isSectionBlock: false } );
|
|
88
|
-
const onChange =
|
|
92
|
+
const onChange = vi.fn();
|
|
89
93
|
|
|
90
94
|
render( <TestComponent onChange={ onChange } /> );
|
|
91
95
|
|
|
@@ -109,7 +113,7 @@ describe( 'useBlockDisplayInformation', () => {
|
|
|
109
113
|
},
|
|
110
114
|
isSectionBlock: false,
|
|
111
115
|
} );
|
|
112
|
-
const onChange =
|
|
116
|
+
const onChange = vi.fn();
|
|
113
117
|
|
|
114
118
|
render( <TestComponent onChange={ onChange } /> );
|
|
115
119
|
|
|
@@ -127,7 +131,7 @@ describe( 'useBlockDisplayInformation', () => {
|
|
|
127
131
|
setupUseSelect( {
|
|
128
132
|
isSectionBlock: false,
|
|
129
133
|
} );
|
|
130
|
-
const onChange =
|
|
134
|
+
const onChange = vi.fn();
|
|
131
135
|
|
|
132
136
|
render( <TestComponent onChange={ onChange } /> );
|
|
133
137
|
|
|
@@ -152,7 +156,7 @@ describe( 'useBlockDisplayInformation', () => {
|
|
|
152
156
|
description: 'A template part.',
|
|
153
157
|
},
|
|
154
158
|
} );
|
|
155
|
-
const onChange =
|
|
159
|
+
const onChange = vi.fn();
|
|
156
160
|
|
|
157
161
|
render( <TestComponent onChange={ onChange } /> );
|
|
158
162
|
|
|
@@ -151,7 +151,7 @@ export function getDropTargetPosition(
|
|
|
151
151
|
rect,
|
|
152
152
|
allowedEdges
|
|
153
153
|
);
|
|
154
|
-
// If the
|
|
154
|
+
// If the point is close to a side, prioritize that side.
|
|
155
155
|
const [ sideDistance, sideEdge ] = getDistanceToNearestEdge(
|
|
156
156
|
position,
|
|
157
157
|
rect,
|
|
@@ -572,7 +572,7 @@ export default function useBlockDropZone( {
|
|
|
572
572
|
onDrop: onBlockDrop,
|
|
573
573
|
onDragOver( event ) {
|
|
574
574
|
// `currentTarget` is only available while the event is being
|
|
575
|
-
// handled, so get it now and pass it to the
|
|
575
|
+
// handled, so get it now and pass it to the throttled function.
|
|
576
576
|
// https://developer.mozilla.org/en-US/docs/Web/API/Event/currentTarget
|
|
577
577
|
throttled( event, event.currentTarget.ownerDocument );
|
|
578
578
|
},
|
|
@@ -1,15 +1,14 @@
|
|
|
1
|
+
import { describe, expect, it, vi } from 'vitest';
|
|
1
2
|
import { findTransform, pasteHandler } from '@wordpress/blocks';
|
|
2
3
|
import { parseDropEvent, onFilesDrop, onHTMLDrop, onBlockDrop } from '..';
|
|
3
4
|
|
|
4
5
|
const noop = () => {};
|
|
5
6
|
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
jest.mock( '@wordpress/blocks/src/api/raw-handling', () => ( {
|
|
12
|
-
pasteHandler: jest.fn(),
|
|
7
|
+
vi.mock( import( '@wordpress/blocks' ), async ( importOriginal ) => ( {
|
|
8
|
+
...( await importOriginal() ),
|
|
9
|
+
findTransform: vi.fn(),
|
|
10
|
+
getBlockTransforms: vi.fn(),
|
|
11
|
+
pasteHandler: vi.fn(),
|
|
13
12
|
} ) );
|
|
14
13
|
|
|
15
14
|
describe( 'parseDropEvent', () => {
|
|
@@ -92,7 +91,7 @@ describe( 'onBlockDrop', () => {
|
|
|
92
91
|
const targetBlockIndex = 0;
|
|
93
92
|
const getBlockIndex = noop;
|
|
94
93
|
const getClientIdsOfDescendants = noop;
|
|
95
|
-
const moveBlocks =
|
|
94
|
+
const moveBlocks = vi.fn();
|
|
96
95
|
|
|
97
96
|
const event = {
|
|
98
97
|
dataTransfer: {
|
|
@@ -120,9 +119,9 @@ describe( 'onBlockDrop', () => {
|
|
|
120
119
|
const targetRootClientId = '1';
|
|
121
120
|
const targetBlockIndex = 0;
|
|
122
121
|
// Target and source block index is the same.
|
|
123
|
-
const getBlockIndex =
|
|
122
|
+
const getBlockIndex = vi.fn( () => targetBlockIndex );
|
|
124
123
|
const getClientIdsOfDescendants = noop;
|
|
125
|
-
const moveBlocks =
|
|
124
|
+
const moveBlocks = vi.fn();
|
|
126
125
|
|
|
127
126
|
const event = {
|
|
128
127
|
dataTransfer: {
|
|
@@ -152,9 +151,9 @@ describe( 'onBlockDrop', () => {
|
|
|
152
151
|
it( 'does nothing if the block is dropped as a child of itself', () => {
|
|
153
152
|
const targetRootClientId = '1';
|
|
154
153
|
const targetBlockIndex = 0;
|
|
155
|
-
const getBlockIndex =
|
|
154
|
+
const getBlockIndex = vi.fn( () => 6 );
|
|
156
155
|
const getClientIdsOfDescendants = noop;
|
|
157
|
-
const moveBlocks =
|
|
156
|
+
const moveBlocks = vi.fn();
|
|
158
157
|
|
|
159
158
|
const event = {
|
|
160
159
|
dataTransfer: {
|
|
@@ -184,12 +183,10 @@ describe( 'onBlockDrop', () => {
|
|
|
184
183
|
it( 'does nothing if the block is dropped as a descendant of itself', () => {
|
|
185
184
|
const targetRootClientId = '1';
|
|
186
185
|
const targetBlockIndex = 0;
|
|
187
|
-
const getBlockIndex =
|
|
186
|
+
const getBlockIndex = vi.fn( () => 1 );
|
|
188
187
|
// Dragged block is being dropped as a descendant of itself.
|
|
189
|
-
const getClientIdsOfDescendants =
|
|
190
|
-
|
|
191
|
-
] );
|
|
192
|
-
const moveBlocks = jest.fn();
|
|
188
|
+
const getClientIdsOfDescendants = vi.fn( () => [ targetRootClientId ] );
|
|
189
|
+
const moveBlocks = vi.fn();
|
|
193
190
|
|
|
194
191
|
const event = {
|
|
195
192
|
dataTransfer: {
|
|
@@ -220,9 +217,9 @@ describe( 'onBlockDrop', () => {
|
|
|
220
217
|
const sourceRootClientId = '0';
|
|
221
218
|
const targetRootClientId = '1';
|
|
222
219
|
const targetBlockIndex = 0;
|
|
223
|
-
const getBlockIndex =
|
|
220
|
+
const getBlockIndex = vi.fn( () => 1 );
|
|
224
221
|
const getClientIdsOfDescendants = () => [];
|
|
225
|
-
const moveBlocks =
|
|
222
|
+
const moveBlocks = vi.fn();
|
|
226
223
|
|
|
227
224
|
const event = {
|
|
228
225
|
dataTransfer: {
|
|
@@ -257,10 +254,10 @@ describe( 'onBlockDrop', () => {
|
|
|
257
254
|
const sourceRootClientId = '0';
|
|
258
255
|
const targetRootClientId = sourceRootClientId;
|
|
259
256
|
const targetBlockIndex = 5;
|
|
260
|
-
const getBlockIndex =
|
|
257
|
+
const getBlockIndex = vi.fn( () => 1 );
|
|
261
258
|
// Dragged block is being dropped as a descendant of itself.
|
|
262
259
|
const getClientIdsOfDescendants = () => [];
|
|
263
|
-
const moveBlocks =
|
|
260
|
+
const moveBlocks = vi.fn();
|
|
264
261
|
|
|
265
262
|
const event = {
|
|
266
263
|
dataTransfer: {
|
|
@@ -296,11 +293,11 @@ describe( 'onBlockDrop', () => {
|
|
|
296
293
|
|
|
297
294
|
describe( 'onFilesDrop', () => {
|
|
298
295
|
it( 'does nothing if hasUploadPermissions is false', () => {
|
|
299
|
-
const updateBlockAttributes =
|
|
296
|
+
const updateBlockAttributes = vi.fn();
|
|
300
297
|
const canInsertBlockType = noop;
|
|
301
|
-
const insertOrReplaceBlocks =
|
|
298
|
+
const insertOrReplaceBlocks = vi.fn();
|
|
302
299
|
const targetRootClientId = '1';
|
|
303
|
-
const getSettings =
|
|
300
|
+
const getSettings = vi.fn( () => ( {} ) );
|
|
304
301
|
|
|
305
302
|
const onFileDropHandler = onFilesDrop(
|
|
306
303
|
targetRootClientId,
|
|
@@ -320,10 +317,10 @@ describe( 'onFilesDrop', () => {
|
|
|
320
317
|
// to have no return value.
|
|
321
318
|
findTransform.mockImplementation( noop );
|
|
322
319
|
const updateBlockAttributes = noop;
|
|
323
|
-
const insertOrReplaceBlocks =
|
|
320
|
+
const insertOrReplaceBlocks = vi.fn();
|
|
324
321
|
const canInsertBlockType = noop;
|
|
325
322
|
const targetRootClientId = '1';
|
|
326
|
-
const getSettings =
|
|
323
|
+
const getSettings = vi.fn( () => ( {
|
|
327
324
|
mediaUpload: true,
|
|
328
325
|
} ) );
|
|
329
326
|
|
|
@@ -345,13 +342,13 @@ describe( 'onFilesDrop', () => {
|
|
|
345
342
|
// of the transform isn't important just that there is a callable 'transform'
|
|
346
343
|
// function that returns a value.
|
|
347
344
|
const blocks = 'blocks';
|
|
348
|
-
const transformation = { transform:
|
|
345
|
+
const transformation = { transform: vi.fn( () => blocks ) };
|
|
349
346
|
findTransform.mockImplementation( () => transformation );
|
|
350
347
|
const updateBlockAttributes = noop;
|
|
351
348
|
const canInsertBlockType = noop;
|
|
352
|
-
const insertOrReplaceBlocks =
|
|
349
|
+
const insertOrReplaceBlocks = vi.fn();
|
|
353
350
|
const targetRootClientId = '1';
|
|
354
|
-
const getSettings =
|
|
351
|
+
const getSettings = vi.fn( () => ( {
|
|
355
352
|
mediaUpload: true,
|
|
356
353
|
} ) );
|
|
357
354
|
|
|
@@ -377,7 +374,7 @@ describe( 'onFilesDrop', () => {
|
|
|
377
374
|
describe( 'onHTMLDrop', () => {
|
|
378
375
|
it( 'does nothing if the HTML cannot be converted into blocks', () => {
|
|
379
376
|
pasteHandler.mockImplementation( () => [] );
|
|
380
|
-
const insertOrReplaceBlocks =
|
|
377
|
+
const insertOrReplaceBlocks = vi.fn();
|
|
381
378
|
|
|
382
379
|
const eventHandler = onHTMLDrop( insertOrReplaceBlocks );
|
|
383
380
|
eventHandler();
|
|
@@ -388,7 +385,7 @@ describe( 'onHTMLDrop', () => {
|
|
|
388
385
|
it( 'inserts blocks if the HTML can be converted into blocks', () => {
|
|
389
386
|
const blocks = [ 'blocks' ];
|
|
390
387
|
pasteHandler.mockImplementation( () => blocks );
|
|
391
|
-
const insertOrReplaceBlocks =
|
|
388
|
+
const insertOrReplaceBlocks = vi.fn();
|
|
392
389
|
|
|
393
390
|
const eventHandler = onHTMLDrop( insertOrReplaceBlocks );
|
|
394
391
|
eventHandler();
|
package/src/components/warning/test/__snapshots__/{index.jsx.snap → index.jsdom.test.jsx.snap}
RENAMED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
//
|
|
1
|
+
// Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html
|
|
2
2
|
|
|
3
|
-
exports[`Warning should match snapshot 1`] = `
|
|
3
|
+
exports[`Warning > should match snapshot 1`] = `
|
|
4
4
|
<div>
|
|
5
5
|
<div
|
|
6
6
|
style="display: contents; all: initial;"
|
|
@@ -7,6 +7,7 @@ import useEditableRoot from './use-editable-root';
|
|
|
7
7
|
import useHomeEnd from './use-home-end';
|
|
8
8
|
import useMultiSelection from './use-multi-selection';
|
|
9
9
|
import useTabNav from './use-tab-nav';
|
|
10
|
+
import useUndoAutomaticChange from './use-undo-automatic-change';
|
|
10
11
|
import useArrowNav from './use-arrow-nav';
|
|
11
12
|
import { usePreviewModeNav } from './use-preview-mode-nav';
|
|
12
13
|
import useSelectAll from './use-select-all';
|
|
@@ -28,6 +29,10 @@ export function useWritingFlow() {
|
|
|
28
29
|
return [
|
|
29
30
|
before,
|
|
30
31
|
useMergeRefs( [
|
|
32
|
+
// Same-node listeners run in registration order, and the undo of
|
|
33
|
+
// an automatic change must claim Escape before the tab-nav
|
|
34
|
+
// listeners step out of the canvas.
|
|
35
|
+
useUndoAutomaticChange(),
|
|
31
36
|
ref,
|
|
32
37
|
useEditableRootEventHandlers(),
|
|
33
38
|
useClipboardHandler(),
|