@wordpress/block-editor 9.3.0 → 9.6.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 +6 -0
- package/README.md +1 -8
- package/build/components/block-list/block-invalid-warning.native.js +54 -6
- package/build/components/block-list/block-invalid-warning.native.js.map +1 -1
- package/build/components/block-list/block.js +2 -2
- package/build/components/block-list/block.js.map +1 -1
- package/build/components/block-list/block.native.js +2 -1
- package/build/components/block-list/block.native.js.map +1 -1
- package/build/components/block-list/index.native.js +4 -3
- package/build/components/block-list/index.native.js.map +1 -1
- package/build/components/block-list/layout.js +20 -5
- package/build/components/block-list/layout.js.map +1 -1
- package/build/components/block-list/use-block-props/use-block-class-names.js +5 -2
- package/build/components/block-list/use-block-props/use-block-class-names.js.map +1 -1
- package/build/components/block-lock/modal.js +37 -7
- package/build/components/block-lock/modal.js.map +1 -1
- package/build/components/block-mobile-toolbar/block-actions-menu.native.js +1 -1
- package/build/components/block-mobile-toolbar/block-actions-menu.native.js.map +1 -1
- package/build/components/block-mover/mover-description.js +95 -32
- package/build/components/block-mover/mover-description.js.map +1 -1
- package/build/components/block-pattern-setup/index.js +8 -26
- package/build/components/block-pattern-setup/index.js.map +1 -1
- package/build/components/block-pattern-setup/setup-toolbar.js +3 -8
- package/build/components/block-pattern-setup/setup-toolbar.js.map +1 -1
- package/build/components/block-popover/inbetween.js +1 -1
- package/build/components/block-popover/inbetween.js.map +1 -1
- package/build/components/block-popover/index.js +1 -1
- package/build/components/block-popover/index.js.map +1 -1
- package/build/components/block-preview/auto.js +21 -5
- package/build/components/block-preview/auto.js.map +1 -1
- package/build/components/block-settings-menu/block-edit-visually-button.js +70 -0
- package/build/components/block-settings-menu/block-edit-visually-button.js.map +1 -0
- package/build/components/block-settings-menu/block-mode-toggle.js +1 -1
- package/build/components/block-settings-menu/block-mode-toggle.js.map +1 -1
- package/build/components/block-settings-menu/block-settings-dropdown.js +5 -2
- package/build/components/block-settings-menu/block-settings-dropdown.js.map +1 -1
- package/build/components/block-settings-menu/index.js +6 -2
- package/build/components/block-settings-menu/index.js.map +1 -1
- package/build/components/block-settings-menu-controls/index.js +5 -2
- package/build/components/block-settings-menu-controls/index.js.map +1 -1
- package/build/components/block-styles/preview.native.js.map +1 -1
- package/build/components/block-switcher/index.js +7 -1
- package/build/components/block-switcher/index.js.map +1 -1
- package/build/components/block-title/index.js +8 -2
- package/build/components/block-title/index.js.map +1 -1
- package/build/components/block-title/use-block-display-title.js +15 -15
- package/build/components/block-title/use-block-display-title.js.map +1 -1
- package/build/components/block-tools/block-contextual-toolbar.js +1 -1
- package/build/components/block-tools/block-contextual-toolbar.js.map +1 -1
- package/build/components/block-tools/block-selection-button.js +1 -7
- package/build/components/block-tools/block-selection-button.js.map +1 -1
- package/build/components/block-tools/index.js +4 -1
- package/build/components/block-tools/index.js.map +1 -1
- package/build/components/block-types-list/index.native.js +65 -23
- package/build/components/block-types-list/index.native.js.map +1 -1
- package/build/components/border-radius-control/index.js +2 -0
- package/build/components/border-radius-control/index.js.map +1 -1
- package/build/components/colors/with-colors.js +1 -1
- package/build/components/colors/with-colors.js.map +1 -1
- package/build/components/colors-gradients/control.js +46 -39
- package/build/components/colors-gradients/control.js.map +1 -1
- package/build/components/colors-gradients/dropdown.js +7 -3
- package/build/components/colors-gradients/dropdown.js.map +1 -1
- package/build/components/date-format-picker/index.js +1 -1
- package/build/components/date-format-picker/index.js.map +1 -1
- package/build/components/duotone/components.js +145 -0
- package/build/components/duotone/components.js.map +1 -0
- package/build/components/duotone/index.js +40 -0
- package/build/components/duotone/index.js.map +1 -0
- package/build/components/duotone/utils.js +38 -0
- package/build/components/duotone/utils.js.map +1 -0
- package/build/components/duotone-control/index.js +17 -5
- package/build/components/duotone-control/index.js.map +1 -1
- package/build/components/iframe/index.js +19 -6
- package/build/components/iframe/index.js.map +1 -1
- package/build/components/image-editor/cropper.js +4 -3
- package/build/components/image-editor/cropper.js.map +1 -1
- package/build/components/image-editor/index.js +3 -1
- package/build/components/image-editor/index.js.map +1 -1
- package/build/components/index.js +14 -0
- package/build/components/index.js.map +1 -1
- package/build/components/inserter/block-types-tab.native.js +30 -16
- package/build/components/inserter/block-types-tab.native.js.map +1 -1
- package/build/components/inserter/index.js +3 -3
- package/build/components/inserter/index.js.map +1 -1
- package/build/components/inserter/preview-panel.js +8 -8
- package/build/components/inserter/preview-panel.js.map +1 -1
- package/build/components/inserter/reusable-blocks-tab.native.js +5 -1
- package/build/components/inserter/reusable-blocks-tab.native.js.map +1 -1
- package/build/components/inserter/search-results.native.js +5 -2
- package/build/components/inserter/search-results.native.js.map +1 -1
- package/build/components/inserter/utils.native.js +21 -0
- package/build/components/inserter/utils.native.js.map +1 -1
- package/build/components/inserter-list-item/index.js +5 -1
- package/build/components/inserter-list-item/index.js.map +1 -1
- package/build/components/link-control/index.js +1 -1
- package/build/components/link-control/index.js.map +1 -1
- package/build/components/list-view/block-select-button.js +15 -7
- package/build/components/list-view/block-select-button.js.map +1 -1
- package/build/components/list-view/branch.js +1 -7
- package/build/components/list-view/branch.js.map +1 -1
- package/build/components/list-view/drop-indicator.js +1 -1
- package/build/components/list-view/drop-indicator.js.map +1 -1
- package/build/components/media-placeholder/index.js +14 -2
- package/build/components/media-placeholder/index.js.map +1 -1
- package/build/components/media-placeholder/index.native.js +4 -4
- package/build/components/media-placeholder/index.native.js.map +1 -1
- package/build/components/media-replace-flow/index.js +6 -13
- package/build/components/media-replace-flow/index.js.map +1 -1
- package/build/components/observe-typing/index.js +22 -8
- package/build/components/observe-typing/index.js.map +1 -1
- package/build/components/publish-date-time-picker/index.js +3 -0
- package/build/components/publish-date-time-picker/index.js.map +1 -1
- package/build/components/rich-text/format-toolbar-container.js +61 -12
- package/build/components/rich-text/format-toolbar-container.js.map +1 -1
- package/build/components/rich-text/index.js +2 -1
- package/build/components/rich-text/index.js.map +1 -1
- package/build/components/rich-text/use-format-types.js +36 -16
- package/build/components/rich-text/use-format-types.js.map +1 -1
- package/build/components/rich-text/use-input-rules.js +4 -13
- package/build/components/rich-text/use-input-rules.js.map +1 -1
- package/build/components/rich-text/use-paste-handler.js +20 -5
- package/build/components/rich-text/use-paste-handler.js.map +1 -1
- package/build/components/url-popover/index.js +2 -1
- package/build/components/url-popover/index.js.map +1 -1
- package/build/components/writing-flow/use-arrow-nav.js +34 -2
- package/build/components/writing-flow/use-arrow-nav.js.map +1 -1
- package/build/components/writing-flow/use-multi-selection.js +3 -47
- package/build/components/writing-flow/use-multi-selection.js.map +1 -1
- package/build/components/writing-flow/use-selection-observer.js +1 -3
- package/build/components/writing-flow/use-selection-observer.js.map +1 -1
- package/build/components/writing-flow/use-tab-nav.js +1 -1
- package/build/components/writing-flow/use-tab-nav.js.map +1 -1
- package/build/elements/index.js +11 -3
- package/build/elements/index.js.map +1 -1
- package/build/hooks/aria-label.js +71 -0
- package/build/hooks/aria-label.js.map +1 -0
- package/build/hooks/color.js +2 -4
- package/build/hooks/color.js.map +1 -1
- package/build/hooks/duotone.js +33 -160
- package/build/hooks/duotone.js.map +1 -1
- package/build/hooks/index.js +11 -7
- package/build/hooks/index.js.map +1 -1
- package/build/hooks/layout.js +59 -18
- package/build/hooks/layout.js.map +1 -1
- package/build/hooks/style.js +41 -31
- package/build/hooks/style.js.map +1 -1
- package/build/hooks/utils.js +5 -3
- package/build/hooks/utils.js.map +1 -1
- package/build/index.js +7 -7
- package/build/index.js.map +1 -1
- package/build/layouts/flex.js +42 -38
- package/build/layouts/flex.js.map +1 -1
- package/build/layouts/flow.js +35 -37
- package/build/layouts/flow.js.map +1 -1
- package/build/layouts/utils.js +35 -3
- package/build/layouts/utils.js.map +1 -1
- package/build/store/actions.js +24 -31
- package/build/store/actions.js.map +1 -1
- package/build/store/index.js +0 -4
- package/build/store/index.js.map +1 -1
- package/build/store/reducer.js +23 -12
- package/build/store/reducer.js.map +1 -1
- package/build/store/selectors.js +3 -3
- package/build/store/selectors.js.map +1 -1
- package/build/utils/selection.js +34 -0
- package/build/utils/selection.js.map +1 -0
- package/build-module/components/block-list/block-invalid-warning.native.js +50 -6
- package/build-module/components/block-list/block-invalid-warning.native.js.map +1 -1
- package/build-module/components/block-list/block.js +2 -2
- package/build-module/components/block-list/block.js.map +1 -1
- package/build-module/components/block-list/block.native.js +2 -1
- package/build-module/components/block-list/block.native.js.map +1 -1
- package/build-module/components/block-list/index.native.js +3 -1
- package/build-module/components/block-list/index.native.js.map +1 -1
- package/build-module/components/block-list/layout.js +19 -4
- package/build-module/components/block-list/layout.js.map +1 -1
- package/build-module/components/block-list/use-block-props/use-block-class-names.js +5 -2
- package/build-module/components/block-list/use-block-props/use-block-class-names.js.map +1 -1
- package/build-module/components/block-lock/modal.js +39 -8
- package/build-module/components/block-lock/modal.js.map +1 -1
- package/build-module/components/block-mobile-toolbar/block-actions-menu.native.js +2 -2
- package/build-module/components/block-mobile-toolbar/block-actions-menu.native.js.map +1 -1
- package/build-module/components/block-mover/mover-description.js +97 -33
- package/build-module/components/block-mover/mover-description.js.map +1 -1
- package/build-module/components/block-pattern-setup/index.js +9 -27
- package/build-module/components/block-pattern-setup/index.js.map +1 -1
- package/build-module/components/block-pattern-setup/setup-toolbar.js +3 -8
- package/build-module/components/block-pattern-setup/setup-toolbar.js.map +1 -1
- package/build-module/components/block-popover/inbetween.js +1 -1
- package/build-module/components/block-popover/inbetween.js.map +1 -1
- package/build-module/components/block-popover/index.js +1 -1
- package/build-module/components/block-popover/index.js.map +1 -1
- package/build-module/components/block-preview/auto.js +20 -5
- package/build-module/components/block-preview/auto.js.map +1 -1
- package/build-module/components/block-settings-menu/block-edit-visually-button.js +56 -0
- package/build-module/components/block-settings-menu/block-edit-visually-button.js.map +1 -0
- package/build-module/components/block-settings-menu/block-mode-toggle.js +1 -1
- package/build-module/components/block-settings-menu/block-mode-toggle.js.map +1 -1
- package/build-module/components/block-settings-menu/block-settings-dropdown.js +6 -5
- package/build-module/components/block-settings-menu/block-settings-dropdown.js.map +1 -1
- package/build-module/components/block-settings-menu/index.js +6 -3
- package/build-module/components/block-settings-menu/index.js.map +1 -1
- package/build-module/components/block-settings-menu-controls/index.js +7 -4
- package/build-module/components/block-settings-menu-controls/index.js.map +1 -1
- package/build-module/components/block-styles/preview.native.js.map +1 -1
- package/build-module/components/block-switcher/index.js +7 -1
- package/build-module/components/block-switcher/index.js.map +1 -1
- package/build-module/components/block-title/index.js +8 -2
- package/build-module/components/block-title/index.js.map +1 -1
- package/build-module/components/block-title/use-block-display-title.js +15 -14
- package/build-module/components/block-title/use-block-display-title.js.map +1 -1
- package/build-module/components/block-tools/block-contextual-toolbar.js +1 -1
- package/build-module/components/block-tools/block-contextual-toolbar.js.map +1 -1
- package/build-module/components/block-tools/block-selection-button.js +1 -7
- package/build-module/components/block-tools/block-selection-button.js.map +1 -1
- package/build-module/components/block-tools/index.js +4 -1
- package/build-module/components/block-tools/index.js.map +1 -1
- package/build-module/components/block-types-list/index.native.js +67 -25
- package/build-module/components/block-types-list/index.native.js.map +1 -1
- package/build-module/components/border-radius-control/index.js +2 -0
- package/build-module/components/border-radius-control/index.js.map +1 -1
- package/build-module/components/colors/with-colors.js +2 -2
- package/build-module/components/colors/with-colors.js.map +1 -1
- package/build-module/components/colors-gradients/control.js +47 -40
- package/build-module/components/colors-gradients/control.js.map +1 -1
- package/build-module/components/colors-gradients/dropdown.js +8 -4
- package/build-module/components/colors-gradients/dropdown.js.map +1 -1
- package/build-module/components/date-format-picker/index.js +1 -1
- package/build-module/components/date-format-picker/index.js.map +1 -1
- package/build-module/components/duotone/components.js +130 -0
- package/build-module/components/duotone/components.js.map +1 -0
- package/build-module/components/duotone/index.js +3 -0
- package/build-module/components/duotone/index.js.map +1 -0
- package/build-module/components/duotone/utils.js +30 -0
- package/build-module/components/duotone/utils.js.map +1 -0
- package/build-module/components/duotone-control/index.js +18 -6
- package/build-module/components/duotone-control/index.js.map +1 -1
- package/build-module/components/iframe/index.js +19 -6
- package/build-module/components/iframe/index.js.map +1 -1
- package/build-module/components/image-editor/cropper.js +4 -3
- package/build-module/components/image-editor/cropper.js.map +1 -1
- package/build-module/components/image-editor/index.js +3 -1
- package/build-module/components/image-editor/index.js.map +1 -1
- package/build-module/components/index.js +1 -0
- package/build-module/components/index.js.map +1 -1
- package/build-module/components/inserter/block-types-tab.native.js +31 -15
- package/build-module/components/inserter/block-types-tab.native.js.map +1 -1
- package/build-module/components/inserter/index.js +3 -2
- package/build-module/components/inserter/index.js.map +1 -1
- package/build-module/components/inserter/preview-panel.js +9 -9
- package/build-module/components/inserter/preview-panel.js.map +1 -1
- package/build-module/components/inserter/reusable-blocks-tab.native.js +6 -2
- package/build-module/components/inserter/reusable-blocks-tab.native.js.map +1 -1
- package/build-module/components/inserter/search-results.native.js +6 -3
- package/build-module/components/inserter/search-results.native.js.map +1 -1
- package/build-module/components/inserter/utils.native.js +19 -0
- package/build-module/components/inserter/utils.native.js.map +1 -1
- package/build-module/components/inserter-list-item/index.js +4 -1
- package/build-module/components/inserter-list-item/index.js.map +1 -1
- package/build-module/components/link-control/index.js +1 -1
- package/build-module/components/link-control/index.js.map +1 -1
- package/build-module/components/list-view/block-select-button.js +16 -8
- package/build-module/components/list-view/block-select-button.js.map +1 -1
- package/build-module/components/list-view/branch.js +1 -6
- package/build-module/components/list-view/branch.js.map +1 -1
- package/build-module/components/list-view/drop-indicator.js +1 -1
- package/build-module/components/list-view/drop-indicator.js.map +1 -1
- package/build-module/components/media-placeholder/index.js +14 -2
- package/build-module/components/media-placeholder/index.js.map +1 -1
- package/build-module/components/media-placeholder/index.native.js +5 -3
- package/build-module/components/media-placeholder/index.native.js.map +1 -1
- package/build-module/components/media-replace-flow/index.js +7 -13
- package/build-module/components/media-replace-flow/index.js.map +1 -1
- package/build-module/components/observe-typing/index.js +22 -8
- package/build-module/components/observe-typing/index.js.map +1 -1
- package/build-module/components/publish-date-time-picker/index.js +2 -0
- package/build-module/components/publish-date-time-picker/index.js.map +1 -1
- package/build-module/components/rich-text/format-toolbar-container.js +58 -12
- package/build-module/components/rich-text/format-toolbar-container.js.map +1 -1
- package/build-module/components/rich-text/index.js +2 -1
- package/build-module/components/rich-text/index.js.map +1 -1
- package/build-module/components/rich-text/use-format-types.js +37 -18
- package/build-module/components/rich-text/use-format-types.js.map +1 -1
- package/build-module/components/rich-text/use-input-rules.js +3 -11
- package/build-module/components/rich-text/use-input-rules.js.map +1 -1
- package/build-module/components/rich-text/use-paste-handler.js +20 -5
- package/build-module/components/rich-text/use-paste-handler.js.map +1 -1
- package/build-module/components/url-popover/index.js +2 -1
- package/build-module/components/url-popover/index.js.map +1 -1
- package/build-module/components/writing-flow/use-arrow-nav.js +35 -3
- package/build-module/components/writing-flow/use-arrow-nav.js.map +1 -1
- package/build-module/components/writing-flow/use-multi-selection.js +3 -45
- package/build-module/components/writing-flow/use-multi-selection.js.map +1 -1
- package/build-module/components/writing-flow/use-selection-observer.js +1 -3
- package/build-module/components/writing-flow/use-selection-observer.js.map +1 -1
- package/build-module/components/writing-flow/use-tab-nav.js +1 -1
- package/build-module/components/writing-flow/use-tab-nav.js.map +1 -1
- package/build-module/elements/index.js +7 -1
- package/build-module/elements/index.js.map +1 -1
- package/build-module/hooks/aria-label.js +59 -0
- package/build-module/hooks/aria-label.js.map +1 -0
- package/build-module/hooks/color.js +2 -3
- package/build-module/hooks/color.js.map +1 -1
- package/build-module/hooks/duotone.js +22 -140
- package/build-module/hooks/duotone.js.map +1 -1
- package/build-module/hooks/index.js +2 -1
- package/build-module/hooks/index.js.map +1 -1
- package/build-module/hooks/layout.js +60 -19
- package/build-module/hooks/layout.js.map +1 -1
- package/build-module/hooks/style.js +44 -35
- package/build-module/hooks/style.js.map +1 -1
- package/build-module/hooks/utils.js +5 -2
- package/build-module/hooks/utils.js.map +1 -1
- package/build-module/index.js +1 -1
- package/build-module/index.js.map +1 -1
- package/build-module/layouts/flex.js +43 -35
- package/build-module/layouts/flex.js.map +1 -1
- package/build-module/layouts/flow.js +35 -38
- package/build-module/layouts/flow.js.map +1 -1
- package/build-module/layouts/utils.js +33 -3
- package/build-module/layouts/utils.js.map +1 -1
- package/build-module/store/actions.js +14 -20
- package/build-module/store/actions.js.map +1 -1
- package/build-module/store/index.js +0 -4
- package/build-module/store/index.js.map +1 -1
- package/build-module/store/reducer.js +23 -11
- package/build-module/store/reducer.js.map +1 -1
- package/build-module/store/selectors.js +4 -4
- package/build-module/store/selectors.js.map +1 -1
- package/build-module/utils/selection.js +24 -0
- package/build-module/utils/selection.js.map +1 -0
- package/build-style/style-rtl.css +43 -13
- package/build-style/style.css +43 -13
- package/package.json +28 -28
- package/src/components/block-draggable/test/helpers.native.js +3 -3
- package/src/components/block-list/block-invalid-warning.native.js +42 -7
- package/src/components/block-list/block.js +2 -2
- package/src/components/block-list/block.native.js +1 -0
- package/src/components/block-list/index.native.js +1 -1
- package/src/components/block-list/layout.js +15 -3
- package/src/components/block-list/style.scss +2 -2
- package/src/components/block-list/use-block-props/use-block-class-names.js +5 -1
- package/src/components/block-lock/modal.js +47 -9
- package/src/components/block-lock/style.scss +10 -0
- package/src/components/block-mobile-toolbar/block-actions-menu.native.js +3 -3
- package/src/components/block-mover/mover-description.js +131 -48
- package/src/components/block-mover/test/mover-description.js +55 -3
- package/src/components/block-pattern-setup/index.js +5 -25
- package/src/components/block-pattern-setup/setup-toolbar.js +2 -9
- package/src/components/block-pattern-setup/style.scss +4 -2
- package/src/components/block-popover/inbetween.js +1 -1
- package/src/components/block-popover/index.js +1 -1
- package/src/components/block-preview/auto.js +17 -3
- package/src/components/block-settings-menu/block-edit-visually-button.js +52 -0
- package/src/components/block-settings-menu/block-mode-toggle.js +1 -0
- package/src/components/block-settings-menu/block-settings-dropdown.js +7 -3
- package/src/components/block-settings-menu/index.js +15 -11
- package/src/components/block-settings-menu-controls/index.js +5 -4
- package/src/components/block-styles/preview.native.js +1 -0
- package/src/components/block-switcher/index.js +7 -1
- package/src/components/block-title/index.js +3 -2
- package/src/components/block-title/use-block-display-title.js +20 -12
- package/src/components/block-tools/block-contextual-toolbar.js +3 -1
- package/src/components/block-tools/block-selection-button.js +0 -5
- package/src/components/block-tools/index.js +4 -1
- package/src/components/block-types-list/index.native.js +76 -24
- package/src/components/block-types-list/style.native.scss +18 -0
- package/src/components/border-radius-control/index.js +2 -0
- package/src/components/color-palette/test/__snapshots__/control.js.snap +0 -4
- package/src/components/colors/test/__snapshots__/with-colors.js.snap +1 -1
- package/src/components/colors/test/with-colors.js +1 -1
- package/src/components/colors/with-colors.js +2 -2
- package/src/components/colors-gradients/control.js +78 -65
- package/src/components/colors-gradients/dropdown.js +9 -2
- package/src/components/colors-gradients/style.scss +11 -8
- package/src/components/colors-gradients/test/control.js +16 -23
- package/src/components/date-format-picker/index.js +1 -0
- package/src/components/duotone/components.js +133 -0
- package/src/components/duotone/index.js +7 -0
- package/src/components/duotone/utils.js +25 -0
- package/src/components/duotone-control/index.js +12 -7
- package/src/components/duotone-control/style.scss +5 -0
- package/src/components/iframe/index.js +25 -6
- package/src/components/image-editor/cropper.js +9 -3
- package/src/components/image-editor/index.js +2 -0
- package/src/components/index.js +1 -0
- package/src/components/inserter/block-types-tab.native.js +42 -21
- package/src/components/inserter/index.js +3 -5
- package/src/components/inserter/preview-panel.js +6 -14
- package/src/components/inserter/reusable-blocks-tab.native.js +4 -2
- package/src/components/inserter/search-results.native.js +4 -2
- package/src/components/inserter/style.scss +1 -1
- package/src/components/inserter/test/block-types-tab.native.js +2 -0
- package/src/components/inserter/test/utils.native.js +37 -0
- package/src/components/inserter/utils.native.js +11 -0
- package/src/components/inserter-list-item/index.js +4 -1
- package/src/components/link-control/index.js +1 -0
- package/src/components/link-control/test/fixtures/index.js +3 -4
- package/src/components/link-control/test/index.js +64 -73
- package/src/components/list-view/block-select-button.js +29 -14
- package/src/components/list-view/branch.js +1 -6
- package/src/components/list-view/drop-indicator.js +1 -1
- package/src/components/list-view/style.scss +18 -4
- package/src/components/media-placeholder/index.js +20 -0
- package/src/components/media-placeholder/index.native.js +9 -5
- package/src/components/media-replace-flow/index.js +5 -14
- package/src/components/media-replace-flow/test/index.js +14 -4
- package/src/components/media-upload/README.md +8 -0
- package/src/components/observe-typing/index.js +17 -14
- package/src/components/publish-date-time-picker/index.js +2 -0
- package/src/components/responsive-block-control/README.md +3 -1
- package/src/components/responsive-block-control/test/index.js +1 -2
- package/src/components/rich-text/format-toolbar-container.js +63 -14
- package/src/components/rich-text/index.js +1 -0
- package/src/components/rich-text/use-format-types.js +38 -17
- package/src/components/rich-text/use-input-rules.js +6 -15
- package/src/components/rich-text/use-paste-handler.js +17 -5
- package/src/components/url-popover/index.js +1 -0
- package/src/components/url-popover/test/__snapshots__/index.js.snap +3 -0
- package/src/components/writing-flow/use-arrow-nav.js +32 -1
- package/src/components/writing-flow/use-multi-selection.js +1 -48
- package/src/components/writing-flow/use-selection-observer.js +2 -3
- package/src/components/writing-flow/use-tab-nav.js +1 -1
- package/src/elements/index.js +8 -1
- package/src/elements/test/index.js +18 -0
- package/src/hooks/aria-label.js +67 -0
- package/src/hooks/color.js +10 -3
- package/src/hooks/duotone.js +18 -139
- package/src/hooks/index.js +2 -1
- package/src/hooks/layout.js +77 -29
- package/src/hooks/style.js +46 -39
- package/src/hooks/utils.js +7 -3
- package/src/index.js +1 -1
- package/src/layouts/flex.js +49 -43
- package/src/layouts/flow.js +35 -34
- package/src/layouts/test/flex.js +21 -0
- package/src/layouts/test/flow.js +21 -0
- package/src/layouts/test/utils.js +138 -0
- package/src/layouts/utils.js +44 -3
- package/src/store/actions.js +17 -31
- package/src/store/index.js +0 -4
- package/src/store/reducer.js +24 -11
- package/src/store/selectors.js +3 -4
- package/src/store/test/reducer.js +138 -10
- package/src/store/test/selectors.js +3 -6
- package/src/utils/selection.js +26 -0
- package/src/utils/test/selection.js +39 -0
- package/tsconfig.json +2 -1
|
@@ -1,36 +1,29 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* WordPress dependencies
|
|
3
3
|
*/
|
|
4
|
-
import {
|
|
4
|
+
import { useMemo } from '@wordpress/element';
|
|
5
5
|
|
|
6
6
|
/**
|
|
7
7
|
* Internal dependencies
|
|
8
8
|
*/
|
|
9
9
|
import BlockTypesList from '../block-types-list';
|
|
10
10
|
import useClipboardBlock from './hooks/use-clipboard-block';
|
|
11
|
-
import { store as blockEditorStore } from '../../store';
|
|
12
11
|
import useBlockTypeImpressions from './hooks/use-block-type-impressions';
|
|
13
|
-
import { filterInserterItems } from './utils';
|
|
12
|
+
import { createInserterSection, filterInserterItems } from './utils';
|
|
13
|
+
import useBlockTypesState from './hooks/use-block-types-state';
|
|
14
14
|
|
|
15
|
-
|
|
16
|
-
const clipboardBlock = useClipboardBlock( rootClientId );
|
|
17
|
-
|
|
18
|
-
const { blockTypes } = useSelect(
|
|
19
|
-
( select ) => {
|
|
20
|
-
const { getInserterItems } = select( blockEditorStore );
|
|
21
|
-
const blockItems = filterInserterItems(
|
|
22
|
-
getInserterItems( rootClientId )
|
|
23
|
-
);
|
|
15
|
+
const getBlockNamespace = ( item ) => item.name.split( '/' )[ 0 ];
|
|
24
16
|
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
};
|
|
30
|
-
},
|
|
31
|
-
[ rootClientId ]
|
|
17
|
+
function BlockTypesTab( { onSelect, rootClientId, listProps } ) {
|
|
18
|
+
const [ rawBlockTypes, , collections ] = useBlockTypesState(
|
|
19
|
+
rootClientId,
|
|
20
|
+
onSelect
|
|
32
21
|
);
|
|
33
|
-
|
|
22
|
+
const clipboardBlock = useClipboardBlock( rootClientId );
|
|
23
|
+
const filteredBlockTypes = filterInserterItems( rawBlockTypes );
|
|
24
|
+
const blockTypes = clipboardBlock
|
|
25
|
+
? [ clipboardBlock, ...filteredBlockTypes ]
|
|
26
|
+
: filteredBlockTypes;
|
|
34
27
|
const { items, trackBlockTypeSelected } =
|
|
35
28
|
useBlockTypeImpressions( blockTypes );
|
|
36
29
|
|
|
@@ -39,10 +32,38 @@ function BlockTypesTab( { onSelect, rootClientId, listProps } ) {
|
|
|
39
32
|
onSelect( ...args );
|
|
40
33
|
};
|
|
41
34
|
|
|
35
|
+
const collectionSections = useMemo( () => {
|
|
36
|
+
const result = [];
|
|
37
|
+
Object.keys( collections ).forEach( ( namespace ) => {
|
|
38
|
+
const data = items.filter(
|
|
39
|
+
( item ) => getBlockNamespace( item ) === namespace
|
|
40
|
+
);
|
|
41
|
+
if ( data.length > 0 ) {
|
|
42
|
+
result.push(
|
|
43
|
+
createInserterSection( {
|
|
44
|
+
key: `collection-${ namespace }`,
|
|
45
|
+
metadata: {
|
|
46
|
+
icon: collections[ namespace ].icon,
|
|
47
|
+
title: collections[ namespace ].title,
|
|
48
|
+
},
|
|
49
|
+
items: data,
|
|
50
|
+
} )
|
|
51
|
+
);
|
|
52
|
+
}
|
|
53
|
+
} );
|
|
54
|
+
|
|
55
|
+
return result;
|
|
56
|
+
}, [ items, collections ] );
|
|
57
|
+
|
|
58
|
+
const sections = [
|
|
59
|
+
createInserterSection( { key: 'default', items } ),
|
|
60
|
+
...collectionSections,
|
|
61
|
+
];
|
|
62
|
+
|
|
42
63
|
return (
|
|
43
64
|
<BlockTypesList
|
|
44
65
|
name="Blocks"
|
|
45
|
-
|
|
66
|
+
sections={ sections }
|
|
46
67
|
onSelect={ handleSelect }
|
|
47
68
|
listProps={ listProps }
|
|
48
69
|
/>
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* External dependencies
|
|
3
3
|
*/
|
|
4
|
-
import { size } from 'lodash';
|
|
5
4
|
import classnames from 'classnames';
|
|
6
5
|
|
|
7
6
|
/**
|
|
@@ -233,10 +232,9 @@ export default compose( [
|
|
|
233
232
|
const settings = getSettings();
|
|
234
233
|
|
|
235
234
|
const hasSingleBlockType =
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
) === 0;
|
|
235
|
+
allowedBlocks?.length === 1 &&
|
|
236
|
+
getBlockVariations( allowedBlocks[ 0 ].name, 'inserter' )
|
|
237
|
+
?.length === 0;
|
|
240
238
|
|
|
241
239
|
let allowedBlockType = false;
|
|
242
240
|
if ( hasSingleBlockType ) {
|
|
@@ -5,7 +5,6 @@ import {
|
|
|
5
5
|
isReusableBlock,
|
|
6
6
|
createBlock,
|
|
7
7
|
getBlockFromExample,
|
|
8
|
-
getBlockType,
|
|
9
8
|
} from '@wordpress/blocks';
|
|
10
9
|
import { __ } from '@wordpress/i18n';
|
|
11
10
|
|
|
@@ -16,31 +15,24 @@ import BlockCard from '../block-card';
|
|
|
16
15
|
import BlockPreview from '../block-preview';
|
|
17
16
|
|
|
18
17
|
function InserterPreviewPanel( { item } ) {
|
|
19
|
-
const { name, title, icon, description, initialAttributes } = item;
|
|
20
|
-
const hoveredItemBlockType = getBlockType( name );
|
|
18
|
+
const { name, title, icon, description, initialAttributes, example } = item;
|
|
21
19
|
const isReusable = isReusableBlock( item );
|
|
22
20
|
return (
|
|
23
21
|
<div className="block-editor-inserter__preview-container">
|
|
24
22
|
<div className="block-editor-inserter__preview">
|
|
25
|
-
{ isReusable ||
|
|
23
|
+
{ isReusable || example ? (
|
|
26
24
|
<div className="block-editor-inserter__preview-content">
|
|
27
25
|
<BlockPreview
|
|
28
26
|
__experimentalPadding={ 16 }
|
|
29
|
-
viewportWidth={
|
|
30
|
-
hoveredItemBlockType.example?.viewportWidth ??
|
|
31
|
-
500
|
|
32
|
-
}
|
|
27
|
+
viewportWidth={ example?.viewportWidth ?? 500 }
|
|
33
28
|
blocks={
|
|
34
|
-
|
|
29
|
+
example
|
|
35
30
|
? getBlockFromExample( item.name, {
|
|
36
31
|
attributes: {
|
|
37
|
-
...
|
|
38
|
-
.attributes,
|
|
32
|
+
...example.attributes,
|
|
39
33
|
...initialAttributes,
|
|
40
34
|
},
|
|
41
|
-
innerBlocks:
|
|
42
|
-
hoveredItemBlockType.example
|
|
43
|
-
.innerBlocks,
|
|
35
|
+
innerBlocks: example.innerBlocks,
|
|
44
36
|
} )
|
|
45
37
|
: createBlock( name, initialAttributes )
|
|
46
38
|
}
|
|
@@ -8,7 +8,7 @@ import { useSelect } from '@wordpress/data';
|
|
|
8
8
|
*/
|
|
9
9
|
import BlockTypesList from '../block-types-list';
|
|
10
10
|
import { store as blockEditorStore } from '../../store';
|
|
11
|
-
import { filterInserterItems } from './utils';
|
|
11
|
+
import { createInserterSection, filterInserterItems } from './utils';
|
|
12
12
|
|
|
13
13
|
function ReusableBlocksTab( { onSelect, rootClientId, listProps } ) {
|
|
14
14
|
const { items } = useSelect(
|
|
@@ -23,10 +23,12 @@ function ReusableBlocksTab( { onSelect, rootClientId, listProps } ) {
|
|
|
23
23
|
[ rootClientId ]
|
|
24
24
|
);
|
|
25
25
|
|
|
26
|
+
const sections = [ createInserterSection( { key: 'reuseable', items } ) ];
|
|
27
|
+
|
|
26
28
|
return (
|
|
27
29
|
<BlockTypesList
|
|
28
30
|
name="ReusableBlocks"
|
|
29
|
-
|
|
31
|
+
sections={ sections }
|
|
30
32
|
onSelect={ onSelect }
|
|
31
33
|
listProps={ listProps }
|
|
32
34
|
/>
|
|
@@ -11,7 +11,7 @@ import BlockTypesList from '../block-types-list';
|
|
|
11
11
|
import InserterNoResults from './no-results';
|
|
12
12
|
import { store as blockEditorStore } from '../../store';
|
|
13
13
|
import useBlockTypeImpressions from './hooks/use-block-type-impressions';
|
|
14
|
-
import { filterInserterItems } from './utils';
|
|
14
|
+
import { createInserterSection, filterInserterItems } from './utils';
|
|
15
15
|
|
|
16
16
|
function InserterSearchResults( {
|
|
17
17
|
filterValue,
|
|
@@ -51,7 +51,9 @@ function InserterSearchResults( {
|
|
|
51
51
|
<BlockTypesList
|
|
52
52
|
name="Blocks"
|
|
53
53
|
initialNumToRender={ isFullScreen ? 10 : 3 }
|
|
54
|
-
{
|
|
54
|
+
sections={ [ createInserterSection( { key: 'search', items } ) ] }
|
|
55
|
+
onSelect={ handleSelect }
|
|
56
|
+
listProps={ listProps }
|
|
55
57
|
/>
|
|
56
58
|
);
|
|
57
59
|
}
|
|
@@ -18,6 +18,8 @@ jest.mock( '../hooks/use-clipboard-block' );
|
|
|
18
18
|
jest.mock( '@wordpress/data/src/components/use-select' );
|
|
19
19
|
|
|
20
20
|
const selectMock = {
|
|
21
|
+
getCategories: jest.fn().mockReturnValue( [] ),
|
|
22
|
+
getCollections: jest.fn().mockReturnValue( [] ),
|
|
21
23
|
getInserterItems: jest.fn().mockReturnValue( [] ),
|
|
22
24
|
canInsertBlockType: jest.fn(),
|
|
23
25
|
getBlockType: jest.fn(),
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Internal dependencies
|
|
3
|
+
*/
|
|
4
|
+
import { createInserterSection } from '../utils';
|
|
5
|
+
|
|
6
|
+
describe( 'createInserterSection', () => {
|
|
7
|
+
it( 'returns the expected object shape', () => {
|
|
8
|
+
const key = 'mock-1';
|
|
9
|
+
const items = [ 1, 2, 3 ];
|
|
10
|
+
const metadata = { icon: 'icon-mock', title: 'Title Mock' };
|
|
11
|
+
|
|
12
|
+
expect( createInserterSection( { key, metadata, items } ) ).toEqual(
|
|
13
|
+
expect.objectContaining( {
|
|
14
|
+
metadata,
|
|
15
|
+
data: [ { key, list: items } ],
|
|
16
|
+
} )
|
|
17
|
+
);
|
|
18
|
+
} );
|
|
19
|
+
|
|
20
|
+
it( 'return always includes metadata', () => {
|
|
21
|
+
const key = 'mock-1';
|
|
22
|
+
const items = [ 1, 2, 3 ];
|
|
23
|
+
|
|
24
|
+
expect( createInserterSection( { key, items } ) ).toEqual(
|
|
25
|
+
expect.objectContaining( {
|
|
26
|
+
metadata: {},
|
|
27
|
+
data: [ { key, list: items } ],
|
|
28
|
+
} )
|
|
29
|
+
);
|
|
30
|
+
} );
|
|
31
|
+
|
|
32
|
+
it( 'requires a unique key', () => {
|
|
33
|
+
expect( () => {
|
|
34
|
+
createInserterSection( { items: [ 1, 2, 3 ] } );
|
|
35
|
+
} ).toThrow( 'A unique key for the section must be provided.' );
|
|
36
|
+
} );
|
|
37
|
+
} );
|
|
@@ -33,3 +33,14 @@ export function filterInserterItems(
|
|
|
33
33
|
blockAllowed( block, { onlyReusable, allowReusable } )
|
|
34
34
|
);
|
|
35
35
|
}
|
|
36
|
+
|
|
37
|
+
export function createInserterSection( { key, metadata = {}, items } ) {
|
|
38
|
+
if ( ! key ) {
|
|
39
|
+
throw new Error( 'A unique key for the section must be provided.' );
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
return {
|
|
43
|
+
metadata,
|
|
44
|
+
data: [ { key, list: items } ],
|
|
45
|
+
};
|
|
46
|
+
}
|
|
@@ -11,6 +11,7 @@ import {
|
|
|
11
11
|
createBlock,
|
|
12
12
|
createBlocksFromInnerBlocksTemplate,
|
|
13
13
|
} from '@wordpress/blocks';
|
|
14
|
+
import { __experimentalTruncate as Truncate } from '@wordpress/components';
|
|
14
15
|
import { ENTER } from '@wordpress/keycodes';
|
|
15
16
|
|
|
16
17
|
/**
|
|
@@ -135,7 +136,9 @@ function InserterListItem( {
|
|
|
135
136
|
<BlockIcon icon={ item.icon } showColors />
|
|
136
137
|
</span>
|
|
137
138
|
<span className="block-editor-block-types-list__item-title">
|
|
138
|
-
{
|
|
139
|
+
<Truncate numberOfLines={ 3 }>
|
|
140
|
+
{ item.title }
|
|
141
|
+
</Truncate>
|
|
139
142
|
</span>
|
|
140
143
|
</InserterListboxItem>
|
|
141
144
|
</div>
|
|
@@ -4,7 +4,6 @@
|
|
|
4
4
|
import { render, unmountComponentAtNode } from 'react-dom';
|
|
5
5
|
import { act, Simulate } from 'react-dom/test-utils';
|
|
6
6
|
import { queryByText, queryByRole } from '@testing-library/react';
|
|
7
|
-
import { default as lodash, first, last, nth, uniqueId } from 'lodash';
|
|
8
7
|
/**
|
|
9
8
|
* WordPress dependencies
|
|
10
9
|
*/
|
|
@@ -18,13 +17,20 @@ import { useSelect } from '@wordpress/data';
|
|
|
18
17
|
* Internal dependencies
|
|
19
18
|
*/
|
|
20
19
|
import LinkControl from '../';
|
|
21
|
-
import {
|
|
20
|
+
import {
|
|
21
|
+
fauxEntitySuggestions,
|
|
22
|
+
fetchFauxEntitySuggestions,
|
|
23
|
+
uniqueId,
|
|
24
|
+
} from './fixtures';
|
|
22
25
|
|
|
23
26
|
// Mock debounce() so that it runs instantly.
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
27
|
+
jest.mock( 'lodash', () => ( {
|
|
28
|
+
...jest.requireActual( 'lodash' ),
|
|
29
|
+
debounce: ( fn ) => {
|
|
30
|
+
fn.cancel = jest.fn();
|
|
31
|
+
return fn;
|
|
32
|
+
},
|
|
33
|
+
} ) );
|
|
28
34
|
|
|
29
35
|
const mockFetchSearchSuggestions = jest.fn();
|
|
30
36
|
|
|
@@ -357,7 +363,7 @@ describe( 'Searching for a link', () => {
|
|
|
357
363
|
|
|
358
364
|
it( 'should display only search suggestions when current input value is not URL-like', async () => {
|
|
359
365
|
const searchTerm = 'Hello world';
|
|
360
|
-
const firstFauxSuggestion =
|
|
366
|
+
const firstFauxSuggestion = fauxEntitySuggestions[ 0 ];
|
|
361
367
|
|
|
362
368
|
act( () => {
|
|
363
369
|
render( <LinkControl />, container );
|
|
@@ -377,9 +383,9 @@ describe( 'Searching for a link', () => {
|
|
|
377
383
|
|
|
378
384
|
const searchResultElements = getSearchResults();
|
|
379
385
|
|
|
380
|
-
const firstSearchResultItemHTML =
|
|
381
|
-
|
|
382
|
-
|
|
386
|
+
const firstSearchResultItemHTML = searchResultElements[ 0 ].innerHTML;
|
|
387
|
+
const lastSearchResultItemHTML =
|
|
388
|
+
searchResultElements[ searchResultElements.length - 1 ].innerHTML;
|
|
383
389
|
|
|
384
390
|
expect( searchResultElements ).toHaveLength(
|
|
385
391
|
fauxEntitySuggestions.length
|
|
@@ -502,7 +508,8 @@ describe( 'Searching for a link', () => {
|
|
|
502
508
|
const searchResultElements = getSearchResults();
|
|
503
509
|
|
|
504
510
|
const lastSearchResultItemHTML =
|
|
505
|
-
|
|
511
|
+
searchResultElements[ searchResultElements.length - 1 ]
|
|
512
|
+
.innerHTML;
|
|
506
513
|
const additionalDefaultFallbackURLSuggestionLength = 1;
|
|
507
514
|
|
|
508
515
|
// We should see a search result for each of the expect search suggestions
|
|
@@ -974,11 +981,9 @@ describe( 'Creating Entities (eg: Posts, Pages)', () => {
|
|
|
974
981
|
'[role="listbox"] [role="option"]'
|
|
975
982
|
);
|
|
976
983
|
|
|
977
|
-
const createButton =
|
|
978
|
-
|
|
979
|
-
|
|
980
|
-
)
|
|
981
|
-
);
|
|
984
|
+
const createButton = Array.from( searchResultElements ).filter(
|
|
985
|
+
( result ) => result.innerHTML.includes( 'Create:' )
|
|
986
|
+
)[ 0 ];
|
|
982
987
|
|
|
983
988
|
expect( createButton ).not.toBeNull();
|
|
984
989
|
expect( createButton.innerHTML ).toEqual(
|
|
@@ -1071,11 +1076,9 @@ describe( 'Creating Entities (eg: Posts, Pages)', () => {
|
|
|
1071
1076
|
'[role="listbox"] [role="option"]'
|
|
1072
1077
|
);
|
|
1073
1078
|
|
|
1074
|
-
const createButton =
|
|
1075
|
-
|
|
1076
|
-
|
|
1077
|
-
)
|
|
1078
|
-
);
|
|
1079
|
+
const createButton = Array.from( searchResultElements ).filter(
|
|
1080
|
+
( result ) => result.innerHTML.includes( 'Create:' )
|
|
1081
|
+
)[ 0 ];
|
|
1079
1082
|
|
|
1080
1083
|
await act( async () => {
|
|
1081
1084
|
Simulate.click( createButton );
|
|
@@ -1143,11 +1146,9 @@ describe( 'Creating Entities (eg: Posts, Pages)', () => {
|
|
|
1143
1146
|
const searchResultElements = container.querySelectorAll(
|
|
1144
1147
|
'[role="listbox"] [role="option"]'
|
|
1145
1148
|
);
|
|
1146
|
-
const createButton =
|
|
1147
|
-
|
|
1148
|
-
|
|
1149
|
-
)
|
|
1150
|
-
);
|
|
1149
|
+
const createButton = Array.from( searchResultElements ).filter(
|
|
1150
|
+
( result ) => result.innerHTML.includes( 'Create:' )
|
|
1151
|
+
)[ 0 ];
|
|
1151
1152
|
|
|
1152
1153
|
// Step down into the search results, highlighting the first result item.
|
|
1153
1154
|
act( () => {
|
|
@@ -1210,11 +1211,9 @@ describe( 'Creating Entities (eg: Posts, Pages)', () => {
|
|
|
1210
1211
|
'[role="listbox"] [role="option"]'
|
|
1211
1212
|
);
|
|
1212
1213
|
|
|
1213
|
-
const createButton =
|
|
1214
|
-
|
|
1215
|
-
|
|
1216
|
-
)
|
|
1217
|
-
);
|
|
1214
|
+
const createButton = Array.from( searchResultElements ).filter(
|
|
1215
|
+
( result ) => result.innerHTML.includes( 'Custom suggestion text' )
|
|
1216
|
+
)[ 0 ];
|
|
1218
1217
|
|
|
1219
1218
|
expect( createButton ).not.toBeNull();
|
|
1220
1219
|
} );
|
|
@@ -1241,11 +1240,9 @@ describe( 'Creating Entities (eg: Posts, Pages)', () => {
|
|
|
1241
1240
|
const searchResultElements = container.querySelectorAll(
|
|
1242
1241
|
'[role="listbox"] [role="option"]'
|
|
1243
1242
|
);
|
|
1244
|
-
const createButton =
|
|
1245
|
-
|
|
1246
|
-
|
|
1247
|
-
)
|
|
1248
|
-
);
|
|
1243
|
+
const createButton = Array.from( searchResultElements ).filter(
|
|
1244
|
+
( result ) => result.innerHTML.includes( 'Create:' )
|
|
1245
|
+
)[ 0 ];
|
|
1249
1246
|
|
|
1250
1247
|
// Verify input has no value.
|
|
1251
1248
|
expect( searchInput.value ).toBe( '' );
|
|
@@ -1275,11 +1272,9 @@ describe( 'Creating Entities (eg: Posts, Pages)', () => {
|
|
|
1275
1272
|
const searchResultElements = container.querySelectorAll(
|
|
1276
1273
|
'[role="listbox"] [role="option"]'
|
|
1277
1274
|
);
|
|
1278
|
-
const createButton =
|
|
1279
|
-
|
|
1280
|
-
|
|
1281
|
-
)
|
|
1282
|
-
);
|
|
1275
|
+
const createButton = Array.from( searchResultElements ).filter(
|
|
1276
|
+
( result ) => result.innerHTML.includes( 'New page' )
|
|
1277
|
+
)[ 0 ];
|
|
1283
1278
|
|
|
1284
1279
|
// Verify input has no value.
|
|
1285
1280
|
expect( searchInput.value ).toBe( '' );
|
|
@@ -1321,11 +1316,9 @@ describe( 'Creating Entities (eg: Posts, Pages)', () => {
|
|
|
1321
1316
|
'[role="listbox"] [role="option"]'
|
|
1322
1317
|
);
|
|
1323
1318
|
|
|
1324
|
-
const createButton =
|
|
1325
|
-
|
|
1326
|
-
|
|
1327
|
-
)
|
|
1328
|
-
);
|
|
1319
|
+
const createButton = Array.from( searchResultElements ).filter(
|
|
1320
|
+
( result ) => result.innerHTML.includes( 'New page' )
|
|
1321
|
+
)[ 0 ];
|
|
1329
1322
|
|
|
1330
1323
|
expect( createButton ).toBeFalsy(); // Shouldn't exist!
|
|
1331
1324
|
}
|
|
@@ -1366,11 +1359,9 @@ describe( 'Creating Entities (eg: Posts, Pages)', () => {
|
|
|
1366
1359
|
let searchResultElements = container.querySelectorAll(
|
|
1367
1360
|
'[role="listbox"] [role="option"]'
|
|
1368
1361
|
);
|
|
1369
|
-
let createButton =
|
|
1370
|
-
|
|
1371
|
-
|
|
1372
|
-
)
|
|
1373
|
-
);
|
|
1362
|
+
let createButton = Array.from( searchResultElements ).filter(
|
|
1363
|
+
( result ) => result.innerHTML.includes( 'Create:' )
|
|
1364
|
+
)[ 0 ];
|
|
1374
1365
|
|
|
1375
1366
|
await act( async () => {
|
|
1376
1367
|
Simulate.click( createButton );
|
|
@@ -1407,18 +1398,16 @@ describe( 'Creating Entities (eg: Posts, Pages)', () => {
|
|
|
1407
1398
|
searchResultElements = container.querySelectorAll(
|
|
1408
1399
|
'[role="listbox"] [role="option"]'
|
|
1409
1400
|
);
|
|
1410
|
-
createButton =
|
|
1411
|
-
|
|
1412
|
-
|
|
1413
|
-
)
|
|
1414
|
-
);
|
|
1401
|
+
createButton = Array.from( searchResultElements ).filter(
|
|
1402
|
+
( result ) => result.innerHTML.includes( 'New page' )
|
|
1403
|
+
)[ 0 ];
|
|
1415
1404
|
} );
|
|
1416
1405
|
} );
|
|
1417
1406
|
} );
|
|
1418
1407
|
|
|
1419
1408
|
describe( 'Selecting links', () => {
|
|
1420
1409
|
it( 'should display a selected link corresponding to the provided "currentLink" prop', () => {
|
|
1421
|
-
const selectedLink =
|
|
1410
|
+
const selectedLink = fauxEntitySuggestions[ 0 ];
|
|
1422
1411
|
|
|
1423
1412
|
const LinkControlConsumer = () => {
|
|
1424
1413
|
const [ link ] = useState( selectedLink );
|
|
@@ -1447,7 +1436,7 @@ describe( 'Selecting links', () => {
|
|
|
1447
1436
|
} );
|
|
1448
1437
|
|
|
1449
1438
|
it( 'should hide "selected" link UI and display search UI prepopulated with previously selected link title when "Change" button is clicked', () => {
|
|
1450
|
-
const selectedLink =
|
|
1439
|
+
const selectedLink = fauxEntitySuggestions[ 0 ];
|
|
1451
1440
|
|
|
1452
1441
|
const LinkControlConsumer = () => {
|
|
1453
1442
|
const [ link, setLink ] = useState( selectedLink );
|
|
@@ -1484,7 +1473,7 @@ describe( 'Selecting links', () => {
|
|
|
1484
1473
|
|
|
1485
1474
|
describe( 'Selection using mouse click', () => {
|
|
1486
1475
|
it.each( [
|
|
1487
|
-
[ 'entity', 'hello world',
|
|
1476
|
+
[ 'entity', 'hello world', fauxEntitySuggestions[ 0 ] ], // Entity search.
|
|
1488
1477
|
[
|
|
1489
1478
|
'url',
|
|
1490
1479
|
'https://www.wordpress.org',
|
|
@@ -1528,7 +1517,7 @@ describe( 'Selecting links', () => {
|
|
|
1528
1517
|
|
|
1529
1518
|
const searchResultElements = getSearchResults();
|
|
1530
1519
|
|
|
1531
|
-
const firstSearchSuggestion =
|
|
1520
|
+
const firstSearchSuggestion = searchResultElements[ 0 ];
|
|
1532
1521
|
|
|
1533
1522
|
// Simulate selecting the first of the search suggestions.
|
|
1534
1523
|
act( () => {
|
|
@@ -1557,7 +1546,7 @@ describe( 'Selecting links', () => {
|
|
|
1557
1546
|
|
|
1558
1547
|
describe( 'Selection using keyboard', () => {
|
|
1559
1548
|
it.each( [
|
|
1560
|
-
[ 'entity', 'hello world',
|
|
1549
|
+
[ 'entity', 'hello world', fauxEntitySuggestions[ 0 ] ], // Entity search.
|
|
1561
1550
|
[
|
|
1562
1551
|
'url',
|
|
1563
1552
|
'https://www.wordpress.org',
|
|
@@ -1607,8 +1596,8 @@ describe( 'Selecting links', () => {
|
|
|
1607
1596
|
|
|
1608
1597
|
const searchResultElements = getSearchResults();
|
|
1609
1598
|
|
|
1610
|
-
const firstSearchSuggestion =
|
|
1611
|
-
const secondSearchSuggestion =
|
|
1599
|
+
const firstSearchSuggestion = searchResultElements[ 0 ];
|
|
1600
|
+
const secondSearchSuggestion = searchResultElements[ 1 ];
|
|
1612
1601
|
|
|
1613
1602
|
let selectedSearchResultElement = container.querySelector(
|
|
1614
1603
|
'[role="option"][aria-selected="true"]'
|
|
@@ -1711,8 +1700,8 @@ describe( 'Selecting links', () => {
|
|
|
1711
1700
|
|
|
1712
1701
|
const searchResultElements = getSearchResults();
|
|
1713
1702
|
|
|
1714
|
-
const firstSearchSuggestion =
|
|
1715
|
-
const secondSearchSuggestion =
|
|
1703
|
+
const firstSearchSuggestion = searchResultElements[ 0 ];
|
|
1704
|
+
const secondSearchSuggestion = searchResultElements[ 1 ];
|
|
1716
1705
|
|
|
1717
1706
|
let selectedSearchResultElement = container.querySelector(
|
|
1718
1707
|
'[role="option"][aria-selected="true"]'
|
|
@@ -1758,7 +1747,7 @@ describe( 'Selecting links', () => {
|
|
|
1758
1747
|
|
|
1759
1748
|
describe( 'Addition Settings UI', () => {
|
|
1760
1749
|
it( 'should display "New Tab" setting (in "off" mode) by default when a link is selected', async () => {
|
|
1761
|
-
const selectedLink =
|
|
1750
|
+
const selectedLink = fauxEntitySuggestions[ 0 ];
|
|
1762
1751
|
const expectedSettingText = 'Open in new tab';
|
|
1763
1752
|
|
|
1764
1753
|
const LinkControlConsumer = () => {
|
|
@@ -1791,7 +1780,7 @@ describe( 'Addition Settings UI', () => {
|
|
|
1791
1780
|
} );
|
|
1792
1781
|
|
|
1793
1782
|
it( 'should display a setting control with correct default state for each of the custom settings provided', async () => {
|
|
1794
|
-
const selectedLink =
|
|
1783
|
+
const selectedLink = fauxEntitySuggestions[ 0 ];
|
|
1795
1784
|
|
|
1796
1785
|
const customSettings = [
|
|
1797
1786
|
{
|
|
@@ -2266,7 +2255,7 @@ describe( 'Rich link previews', () => {
|
|
|
2266
2255
|
} );
|
|
2267
2256
|
|
|
2268
2257
|
describe( 'Controlling link title text', () => {
|
|
2269
|
-
const selectedLink =
|
|
2258
|
+
const selectedLink = fauxEntitySuggestions[ 0 ];
|
|
2270
2259
|
|
|
2271
2260
|
it( 'should not show a means to alter the link title text by default', async () => {
|
|
2272
2261
|
act( () => {
|
|
@@ -2285,7 +2274,7 @@ describe( 'Controlling link title text', () => {
|
|
|
2285
2274
|
'should not show the link title text input when the URL is `%s`',
|
|
2286
2275
|
async ( urlValue ) => {
|
|
2287
2276
|
const selectedLinkWithoutURL = {
|
|
2288
|
-
...
|
|
2277
|
+
...fauxEntitySuggestions[ 0 ],
|
|
2289
2278
|
url: urlValue,
|
|
2290
2279
|
};
|
|
2291
2280
|
|
|
@@ -2428,10 +2417,12 @@ describe( 'Controlling link title text', () => {
|
|
|
2428
2417
|
Simulate.keyDown( textInput, { keyCode: ENTER } );
|
|
2429
2418
|
} );
|
|
2430
2419
|
|
|
2431
|
-
expect( mockOnChange ).toHaveBeenCalledWith(
|
|
2432
|
-
|
|
2433
|
-
|
|
2434
|
-
|
|
2420
|
+
expect( mockOnChange ).toHaveBeenCalledWith(
|
|
2421
|
+
expect.objectContaining( {
|
|
2422
|
+
title: textValue,
|
|
2423
|
+
url: selectedLink.url,
|
|
2424
|
+
} )
|
|
2425
|
+
);
|
|
2435
2426
|
|
|
2436
2427
|
// The text input should not be showing as the form is submitted.
|
|
2437
2428
|
expect(
|