@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
|
@@ -0,0 +1,138 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Internal dependencies
|
|
3
|
+
*/
|
|
4
|
+
import { appendSelectors, getBlockGapCSS } from '../utils';
|
|
5
|
+
|
|
6
|
+
const layoutDefinitions = {
|
|
7
|
+
default: {
|
|
8
|
+
spacingStyles: [
|
|
9
|
+
{
|
|
10
|
+
selector: ' > *',
|
|
11
|
+
rules: {
|
|
12
|
+
'margin-block-start': '0',
|
|
13
|
+
'margin-block-end': '0',
|
|
14
|
+
},
|
|
15
|
+
},
|
|
16
|
+
{
|
|
17
|
+
selector: ' > * + *',
|
|
18
|
+
rules: {
|
|
19
|
+
'margin-block-start': null,
|
|
20
|
+
'margin-block-end': '0',
|
|
21
|
+
},
|
|
22
|
+
},
|
|
23
|
+
],
|
|
24
|
+
},
|
|
25
|
+
flex: {
|
|
26
|
+
spacingStyles: [
|
|
27
|
+
{
|
|
28
|
+
selector: '',
|
|
29
|
+
rules: {
|
|
30
|
+
gap: null,
|
|
31
|
+
},
|
|
32
|
+
},
|
|
33
|
+
],
|
|
34
|
+
},
|
|
35
|
+
};
|
|
36
|
+
|
|
37
|
+
describe( 'getBlockGapCSS', () => {
|
|
38
|
+
it( 'should output default blockGap rules', () => {
|
|
39
|
+
const expected =
|
|
40
|
+
'.editor-styles-wrapper .my-container > * { margin-block-start: 0; margin-block-end: 0; }.editor-styles-wrapper .my-container > * + * { margin-block-start: 3em; margin-block-end: 0; }';
|
|
41
|
+
|
|
42
|
+
const result = getBlockGapCSS(
|
|
43
|
+
'.my-container',
|
|
44
|
+
layoutDefinitions,
|
|
45
|
+
'default',
|
|
46
|
+
'3em'
|
|
47
|
+
);
|
|
48
|
+
|
|
49
|
+
expect( result ).toBe( expected );
|
|
50
|
+
} );
|
|
51
|
+
|
|
52
|
+
it( 'should output flex blockGap rules', () => {
|
|
53
|
+
const expected = '.editor-styles-wrapper .my-container { gap: 3em; }';
|
|
54
|
+
|
|
55
|
+
const result = getBlockGapCSS(
|
|
56
|
+
'.my-container',
|
|
57
|
+
layoutDefinitions,
|
|
58
|
+
'flex',
|
|
59
|
+
'3em'
|
|
60
|
+
);
|
|
61
|
+
|
|
62
|
+
expect( result ).toBe( expected );
|
|
63
|
+
} );
|
|
64
|
+
|
|
65
|
+
it( 'should return an empty string if layout type cannot be found', () => {
|
|
66
|
+
const expected = '';
|
|
67
|
+
|
|
68
|
+
const result = getBlockGapCSS(
|
|
69
|
+
'.my-container',
|
|
70
|
+
layoutDefinitions,
|
|
71
|
+
'aTypeThatDoesNotExist',
|
|
72
|
+
'3em'
|
|
73
|
+
);
|
|
74
|
+
|
|
75
|
+
expect( result ).toBe( expected );
|
|
76
|
+
} );
|
|
77
|
+
|
|
78
|
+
it( 'should return an empty string if layout definitions cannot be found', () => {
|
|
79
|
+
const expected = '';
|
|
80
|
+
|
|
81
|
+
const result = getBlockGapCSS(
|
|
82
|
+
'.my-container',
|
|
83
|
+
undefined,
|
|
84
|
+
'flex',
|
|
85
|
+
'3em'
|
|
86
|
+
);
|
|
87
|
+
|
|
88
|
+
expect( result ).toBe( expected );
|
|
89
|
+
} );
|
|
90
|
+
|
|
91
|
+
it( 'should return an empty string if blockGap is empty', () => {
|
|
92
|
+
const expected = '';
|
|
93
|
+
|
|
94
|
+
const result = getBlockGapCSS(
|
|
95
|
+
'.my-container',
|
|
96
|
+
layoutDefinitions,
|
|
97
|
+
'flex',
|
|
98
|
+
null
|
|
99
|
+
);
|
|
100
|
+
|
|
101
|
+
expect( result ).toBe( expected );
|
|
102
|
+
} );
|
|
103
|
+
|
|
104
|
+
it( 'should treat a blockGap string containing 0 as a valid value', () => {
|
|
105
|
+
const expected = '.editor-styles-wrapper .my-container { gap: 0; }';
|
|
106
|
+
|
|
107
|
+
const result = getBlockGapCSS(
|
|
108
|
+
'.my-container',
|
|
109
|
+
layoutDefinitions,
|
|
110
|
+
'flex',
|
|
111
|
+
'0'
|
|
112
|
+
);
|
|
113
|
+
|
|
114
|
+
expect( result ).toBe( expected );
|
|
115
|
+
} );
|
|
116
|
+
} );
|
|
117
|
+
|
|
118
|
+
describe( 'appendSelectors', () => {
|
|
119
|
+
it( 'should append a subselector without an appended selector', () => {
|
|
120
|
+
expect( appendSelectors( '.original-selector' ) ).toBe(
|
|
121
|
+
'.editor-styles-wrapper .original-selector'
|
|
122
|
+
);
|
|
123
|
+
} );
|
|
124
|
+
|
|
125
|
+
it( 'should append a subselector to a single selector', () => {
|
|
126
|
+
expect( appendSelectors( '.original-selector', '.appended' ) ).toBe(
|
|
127
|
+
'.editor-styles-wrapper .original-selector .appended'
|
|
128
|
+
);
|
|
129
|
+
} );
|
|
130
|
+
|
|
131
|
+
it( 'should append a subselector to multiple selectors', () => {
|
|
132
|
+
expect(
|
|
133
|
+
appendSelectors( '.first-selector,.second-selector', '.appended' )
|
|
134
|
+
).toBe(
|
|
135
|
+
'.editor-styles-wrapper .first-selector .appended,.editor-styles-wrapper .second-selector .appended'
|
|
136
|
+
);
|
|
137
|
+
} );
|
|
138
|
+
} );
|
package/src/layouts/utils.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Utility to generate the proper CSS selector for layout styles.
|
|
3
3
|
*
|
|
4
|
-
* @param {string
|
|
5
|
-
* @param {
|
|
4
|
+
* @param {string} selectors CSS selector, also supports multiple comma-separated selectors.
|
|
5
|
+
* @param {string} append The string to append.
|
|
6
6
|
*
|
|
7
7
|
* @return {string} - CSS selector.
|
|
8
8
|
*/
|
|
@@ -17,7 +17,48 @@ export function appendSelectors( selectors, append = '' ) {
|
|
|
17
17
|
.split( ',' )
|
|
18
18
|
.map(
|
|
19
19
|
( subselector ) =>
|
|
20
|
-
`.editor-styles-wrapper ${ subselector }
|
|
20
|
+
`.editor-styles-wrapper ${ subselector }${
|
|
21
|
+
append ? ` ${ append }` : ''
|
|
22
|
+
}`
|
|
21
23
|
)
|
|
22
24
|
.join( ',' );
|
|
23
25
|
}
|
|
26
|
+
|
|
27
|
+
/**
|
|
28
|
+
* Get generated blockGap CSS rules based on layout definitions provided in theme.json
|
|
29
|
+
* Falsy values in the layout definition's spacingStyles rules will be swapped out
|
|
30
|
+
* with the provided `blockGapValue`.
|
|
31
|
+
*
|
|
32
|
+
* @param {string} selector The CSS selector to target for the generated rules.
|
|
33
|
+
* @param {Object} layoutDefinitions Layout definitions object from theme.json.
|
|
34
|
+
* @param {string} layoutType The layout type (e.g. `default` or `flex`).
|
|
35
|
+
* @param {string} blockGapValue The current blockGap value to be applied.
|
|
36
|
+
* @return {string} The generated CSS rules.
|
|
37
|
+
*/
|
|
38
|
+
export function getBlockGapCSS(
|
|
39
|
+
selector,
|
|
40
|
+
layoutDefinitions,
|
|
41
|
+
layoutType,
|
|
42
|
+
blockGapValue
|
|
43
|
+
) {
|
|
44
|
+
let output = '';
|
|
45
|
+
if (
|
|
46
|
+
layoutDefinitions?.[ layoutType ]?.spacingStyles?.length &&
|
|
47
|
+
blockGapValue
|
|
48
|
+
) {
|
|
49
|
+
layoutDefinitions[ layoutType ].spacingStyles.forEach( ( gapStyle ) => {
|
|
50
|
+
output += `${ appendSelectors(
|
|
51
|
+
selector,
|
|
52
|
+
gapStyle.selector.trim()
|
|
53
|
+
) } { `;
|
|
54
|
+
output += Object.entries( gapStyle.rules )
|
|
55
|
+
.map(
|
|
56
|
+
( [ cssProperty, value ] ) =>
|
|
57
|
+
`${ cssProperty }: ${ value ? value : blockGapValue }`
|
|
58
|
+
)
|
|
59
|
+
.join( '; ' );
|
|
60
|
+
output += '; }';
|
|
61
|
+
} );
|
|
62
|
+
}
|
|
63
|
+
return output;
|
|
64
|
+
}
|
package/src/store/actions.js
CHANGED
|
@@ -1,8 +1,3 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* External dependencies
|
|
3
|
-
*/
|
|
4
|
-
import { castArray, findKey, first, isObject, last, some } from 'lodash';
|
|
5
|
-
|
|
6
1
|
/**
|
|
7
2
|
* WordPress dependencies
|
|
8
3
|
*/
|
|
@@ -26,6 +21,13 @@ import deprecated from '@wordpress/deprecated';
|
|
|
26
21
|
* Internal dependencies
|
|
27
22
|
*/
|
|
28
23
|
import { mapRichTextSettings } from './utils';
|
|
24
|
+
import {
|
|
25
|
+
retrieveSelectedAttribute,
|
|
26
|
+
START_OF_SELECTED_AREA,
|
|
27
|
+
} from '../utils/selection';
|
|
28
|
+
|
|
29
|
+
const castArray = ( maybeArray ) =>
|
|
30
|
+
Array.isArray( maybeArray ) ? maybeArray : [ maybeArray ];
|
|
29
31
|
|
|
30
32
|
/**
|
|
31
33
|
* Action which will insert a default block insert action if there
|
|
@@ -392,7 +394,7 @@ export const replaceBlocks =
|
|
|
392
394
|
castArray( blocks ),
|
|
393
395
|
select.getSettings()
|
|
394
396
|
);
|
|
395
|
-
const rootClientId = select.getBlockRootClientId(
|
|
397
|
+
const rootClientId = select.getBlockRootClientId( clientIds[ 0 ] );
|
|
396
398
|
// Replace is valid if the new blocks can be inserted in the root block.
|
|
397
399
|
for ( let index = 0; index < blocks.length; index++ ) {
|
|
398
400
|
const block = blocks[ index ];
|
|
@@ -579,7 +581,7 @@ export const insertBlocks =
|
|
|
579
581
|
) =>
|
|
580
582
|
( { select, dispatch } ) => {
|
|
581
583
|
/* eslint-enable jsdoc/valid-types */
|
|
582
|
-
if (
|
|
584
|
+
if ( initialPosition !== null && typeof initialPosition === 'object' ) {
|
|
583
585
|
meta = initialPosition;
|
|
584
586
|
initialPosition = 0;
|
|
585
587
|
deprecated(
|
|
@@ -771,10 +773,6 @@ export const __unstableDeleteSelection =
|
|
|
771
773
|
...mapRichTextSettings( attributeDefinitionB ),
|
|
772
774
|
} );
|
|
773
775
|
|
|
774
|
-
// A robust way to retain selection position through various transforms
|
|
775
|
-
// is to insert a special character at the position and then recover it.
|
|
776
|
-
const START_OF_SELECTED_AREA = '\u0086';
|
|
777
|
-
|
|
778
776
|
valueA = remove( valueA, selectionA.offset, valueA.text.length );
|
|
779
777
|
valueB = insert( valueB, START_OF_SELECTED_AREA, 0, selectionB.offset );
|
|
780
778
|
|
|
@@ -822,12 +820,7 @@ export const __unstableDeleteSelection =
|
|
|
822
820
|
);
|
|
823
821
|
}
|
|
824
822
|
|
|
825
|
-
const newAttributeKey =
|
|
826
|
-
updatedAttributes,
|
|
827
|
-
( v ) =>
|
|
828
|
-
typeof v === 'string' &&
|
|
829
|
-
v.indexOf( START_OF_SELECTED_AREA ) !== -1
|
|
830
|
-
);
|
|
823
|
+
const newAttributeKey = retrieveSelectedAttribute( updatedAttributes );
|
|
831
824
|
|
|
832
825
|
const convertedHtml = updatedAttributes[ newAttributeKey ];
|
|
833
826
|
const convertedValue = create( {
|
|
@@ -1052,10 +1045,6 @@ export const mergeBlocks =
|
|
|
1052
1045
|
}
|
|
1053
1046
|
}
|
|
1054
1047
|
|
|
1055
|
-
// A robust way to retain selection position through various transforms
|
|
1056
|
-
// is to insert a special character at the position and then recover it.
|
|
1057
|
-
const START_OF_SELECTED_AREA = '\u0086';
|
|
1058
|
-
|
|
1059
1048
|
// Clone the blocks so we don't insert the character in a "live" block.
|
|
1060
1049
|
const cloneA = cloneBlock( blockA );
|
|
1061
1050
|
const cloneB = cloneBlock( blockB );
|
|
@@ -1098,12 +1087,8 @@ export const mergeBlocks =
|
|
|
1098
1087
|
);
|
|
1099
1088
|
|
|
1100
1089
|
if ( canRestoreTextSelection ) {
|
|
1101
|
-
const newAttributeKey =
|
|
1102
|
-
updatedAttributes
|
|
1103
|
-
( v ) =>
|
|
1104
|
-
typeof v === 'string' &&
|
|
1105
|
-
v.indexOf( START_OF_SELECTED_AREA ) !== -1
|
|
1106
|
-
);
|
|
1090
|
+
const newAttributeKey =
|
|
1091
|
+
retrieveSelectedAttribute( updatedAttributes );
|
|
1107
1092
|
const convertedHtml = updatedAttributes[ newAttributeKey ];
|
|
1108
1093
|
const convertedValue = create( {
|
|
1109
1094
|
html: convertedHtml,
|
|
@@ -1517,7 +1502,7 @@ export const duplicateBlocks =
|
|
|
1517
1502
|
|
|
1518
1503
|
// Return early if blocks don't exist.
|
|
1519
1504
|
const blocks = select.getBlocksByClientId( clientIds );
|
|
1520
|
-
if ( some(
|
|
1505
|
+
if ( blocks.some( ( block ) => ! block ) ) {
|
|
1521
1506
|
return;
|
|
1522
1507
|
}
|
|
1523
1508
|
|
|
@@ -1533,8 +1518,9 @@ export const duplicateBlocks =
|
|
|
1533
1518
|
}
|
|
1534
1519
|
|
|
1535
1520
|
const rootClientId = select.getBlockRootClientId( clientIds[ 0 ] );
|
|
1521
|
+
const clientIdsArray = castArray( clientIds );
|
|
1536
1522
|
const lastSelectedIndex = select.getBlockIndex(
|
|
1537
|
-
|
|
1523
|
+
clientIdsArray[ clientIdsArray.length - 1 ]
|
|
1538
1524
|
);
|
|
1539
1525
|
const clonedBlocks = blocks.map( ( block ) =>
|
|
1540
1526
|
__experimentalCloneSanitizedBlock( block )
|
|
@@ -1547,8 +1533,8 @@ export const duplicateBlocks =
|
|
|
1547
1533
|
);
|
|
1548
1534
|
if ( clonedBlocks.length > 1 && updateSelection ) {
|
|
1549
1535
|
dispatch.multiSelect(
|
|
1550
|
-
|
|
1551
|
-
|
|
1536
|
+
clonedBlocks[ 0 ].clientId,
|
|
1537
|
+
clonedBlocks[ clonedBlocks.length - 1 ].clientId
|
|
1552
1538
|
);
|
|
1553
1539
|
}
|
|
1554
1540
|
return clonedBlocks.map( ( block ) => block.clientId );
|
package/src/store/index.js
CHANGED
|
@@ -15,8 +15,6 @@ import { STORE_NAME } from './constants';
|
|
|
15
15
|
* Block editor data store configuration.
|
|
16
16
|
*
|
|
17
17
|
* @see https://github.com/WordPress/gutenberg/blob/HEAD/packages/data/README.md#registerStore
|
|
18
|
-
*
|
|
19
|
-
* @type {Object}
|
|
20
18
|
*/
|
|
21
19
|
export const storeConfig = {
|
|
22
20
|
reducer,
|
|
@@ -28,8 +26,6 @@ export const storeConfig = {
|
|
|
28
26
|
* Store definition for the block editor namespace.
|
|
29
27
|
*
|
|
30
28
|
* @see https://github.com/WordPress/gutenberg/blob/HEAD/packages/data/README.md#createReduxStore
|
|
31
|
-
*
|
|
32
|
-
* @type {Object}
|
|
33
29
|
*/
|
|
34
30
|
export const store = createReduxStore( STORE_NAME, {
|
|
35
31
|
...storeConfig,
|
package/src/store/reducer.js
CHANGED
|
@@ -9,10 +9,8 @@ import {
|
|
|
9
9
|
omit,
|
|
10
10
|
without,
|
|
11
11
|
mapValues,
|
|
12
|
-
keys,
|
|
13
12
|
isEqual,
|
|
14
13
|
isEmpty,
|
|
15
|
-
identity,
|
|
16
14
|
omitBy,
|
|
17
15
|
} from 'lodash';
|
|
18
16
|
|
|
@@ -27,6 +25,8 @@ import { store as blocksStore } from '@wordpress/blocks';
|
|
|
27
25
|
import { PREFERENCES_DEFAULTS, SETTINGS_DEFAULTS } from './defaults';
|
|
28
26
|
import { insertAt, moveTo } from './array';
|
|
29
27
|
|
|
28
|
+
const identity = ( x ) => x;
|
|
29
|
+
|
|
30
30
|
/**
|
|
31
31
|
* Given an array of blocks, returns an object where each key is a nesting
|
|
32
32
|
* context, the value of which is an array of block client IDs existing within
|
|
@@ -148,7 +148,7 @@ function getMutateSafeObject( original, working ) {
|
|
|
148
148
|
* @return {boolean} Whether the two objects have the same keys.
|
|
149
149
|
*/
|
|
150
150
|
export function hasSameKeys( a, b ) {
|
|
151
|
-
return isEqual( keys( a ), keys( b ) );
|
|
151
|
+
return isEqual( Object.keys( a ), Object.keys( b ) );
|
|
152
152
|
}
|
|
153
153
|
|
|
154
154
|
/**
|
|
@@ -399,13 +399,12 @@ const withBlockTree =
|
|
|
399
399
|
const updatedBlockUids = [];
|
|
400
400
|
if ( action.fromRootClientId ) {
|
|
401
401
|
updatedBlockUids.push( action.fromRootClientId );
|
|
402
|
+
} else {
|
|
403
|
+
updatedBlockUids.push( '' );
|
|
402
404
|
}
|
|
403
405
|
if ( action.toRootClientId ) {
|
|
404
406
|
updatedBlockUids.push( action.toRootClientId );
|
|
405
407
|
}
|
|
406
|
-
if ( ! action.fromRootClientId || ! action.fromRootClientId ) {
|
|
407
|
-
updatedBlockUids.push( '' );
|
|
408
|
-
}
|
|
409
408
|
newState.tree = updateParentInnerBlocksInTree(
|
|
410
409
|
newState,
|
|
411
410
|
newState.tree,
|
|
@@ -428,7 +427,7 @@ const withBlockTree =
|
|
|
428
427
|
break;
|
|
429
428
|
}
|
|
430
429
|
case 'SAVE_REUSABLE_BLOCK_SUCCESS': {
|
|
431
|
-
const updatedBlockUids = keys(
|
|
430
|
+
const updatedBlockUids = Object.keys(
|
|
432
431
|
omitBy( newState.attributes, ( attributes, clientId ) => {
|
|
433
432
|
return (
|
|
434
433
|
newState.byClientId[ clientId ].name !==
|
|
@@ -690,9 +689,9 @@ const withReplaceInnerBlocks = ( reducer ) => ( state, action ) => {
|
|
|
690
689
|
index: 0,
|
|
691
690
|
} );
|
|
692
691
|
|
|
693
|
-
// We need to re-attach the
|
|
694
|
-
// Otherwise, an inner block controller's blocks
|
|
695
|
-
// from its entity
|
|
692
|
+
// We need to re-attach the controlled inner blocks to the blocks tree and
|
|
693
|
+
// preserve their block order. Otherwise, an inner block controller's blocks
|
|
694
|
+
// will be deleted entirely from its entity.
|
|
696
695
|
stateAfterInsert.order = {
|
|
697
696
|
...stateAfterInsert.order,
|
|
698
697
|
...reduce(
|
|
@@ -706,6 +705,20 @@ const withReplaceInnerBlocks = ( reducer ) => ( state, action ) => {
|
|
|
706
705
|
{}
|
|
707
706
|
),
|
|
708
707
|
};
|
|
708
|
+
stateAfterInsert.tree = {
|
|
709
|
+
...stateAfterInsert.tree,
|
|
710
|
+
...reduce(
|
|
711
|
+
nestedControllers,
|
|
712
|
+
( result, value, _key ) => {
|
|
713
|
+
const key = `controlled||${ _key }`;
|
|
714
|
+
if ( state.tree[ key ] ) {
|
|
715
|
+
result[ key ] = state.tree[ key ];
|
|
716
|
+
}
|
|
717
|
+
return result;
|
|
718
|
+
},
|
|
719
|
+
{}
|
|
720
|
+
),
|
|
721
|
+
};
|
|
709
722
|
}
|
|
710
723
|
return stateAfterInsert;
|
|
711
724
|
};
|
|
@@ -1678,7 +1691,7 @@ export function lastBlockAttributesChange( state, action ) {
|
|
|
1678
1691
|
/**
|
|
1679
1692
|
* Reducer returning automatic change state.
|
|
1680
1693
|
*
|
|
1681
|
-
* @param {
|
|
1694
|
+
* @param {?string} state Current state.
|
|
1682
1695
|
* @param {Object} action Dispatched action.
|
|
1683
1696
|
*
|
|
1684
1697
|
* @return {string} Updated state.
|
package/src/store/selectors.js
CHANGED
|
@@ -4,7 +4,6 @@
|
|
|
4
4
|
import {
|
|
5
5
|
castArray,
|
|
6
6
|
first,
|
|
7
|
-
isBoolean,
|
|
8
7
|
last,
|
|
9
8
|
map,
|
|
10
9
|
reduce,
|
|
@@ -1382,7 +1381,7 @@ export function getBlockInsertionPoint( state ) {
|
|
|
1382
1381
|
|
|
1383
1382
|
if ( clientId ) {
|
|
1384
1383
|
rootClientId = getBlockRootClientId( state, clientId ) || undefined;
|
|
1385
|
-
index = getBlockIndex( state, selectionEnd.clientId
|
|
1384
|
+
index = getBlockIndex( state, selectionEnd.clientId ) + 1;
|
|
1386
1385
|
} else {
|
|
1387
1386
|
index = getBlockOrder( state ).length;
|
|
1388
1387
|
}
|
|
@@ -1445,7 +1444,7 @@ export function getTemplateLock( state, rootClientId ) {
|
|
|
1445
1444
|
}
|
|
1446
1445
|
|
|
1447
1446
|
const checkAllowList = ( list, item, defaultResult = null ) => {
|
|
1448
|
-
if (
|
|
1447
|
+
if ( typeof list === 'boolean' ) {
|
|
1449
1448
|
return list;
|
|
1450
1449
|
}
|
|
1451
1450
|
if ( Array.isArray( list ) ) {
|
|
@@ -2218,7 +2217,7 @@ export const __experimentalGetDirectInsertBlock = createSelector(
|
|
|
2218
2217
|
);
|
|
2219
2218
|
|
|
2220
2219
|
const checkAllowListRecursive = ( blocks, allowedBlockTypes ) => {
|
|
2221
|
-
if (
|
|
2220
|
+
if ( typeof allowedBlockTypes === 'boolean' ) {
|
|
2222
2221
|
return allowedBlockTypes;
|
|
2223
2222
|
}
|
|
2224
2223
|
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* External dependencies
|
|
3
3
|
*/
|
|
4
|
-
import {
|
|
4
|
+
import { omit } from 'lodash';
|
|
5
5
|
import deepFreeze from 'deep-freeze';
|
|
6
6
|
|
|
7
7
|
/**
|
|
@@ -666,7 +666,7 @@ describe( 'state', () => {
|
|
|
666
666
|
} );
|
|
667
667
|
|
|
668
668
|
expect( Object.keys( state.byClientId ) ).toHaveLength( 1 );
|
|
669
|
-
expect( values( state.byClientId )[ 0 ].clientId ).toBe(
|
|
669
|
+
expect( Object.values( state.byClientId )[ 0 ].clientId ).toBe(
|
|
670
670
|
'bananas'
|
|
671
671
|
);
|
|
672
672
|
expect( state.order ).toEqual( {
|
|
@@ -729,7 +729,9 @@ describe( 'state', () => {
|
|
|
729
729
|
} );
|
|
730
730
|
|
|
731
731
|
expect( Object.keys( state.byClientId ) ).toHaveLength( 2 );
|
|
732
|
-
expect( values( state.byClientId )[ 1 ].clientId ).toBe(
|
|
732
|
+
expect( Object.values( state.byClientId )[ 1 ].clientId ).toBe(
|
|
733
|
+
'ribs'
|
|
734
|
+
);
|
|
733
735
|
expect( state.order ).toEqual( {
|
|
734
736
|
'': [ 'chicken', 'ribs' ],
|
|
735
737
|
chicken: [],
|
|
@@ -773,10 +775,12 @@ describe( 'state', () => {
|
|
|
773
775
|
} );
|
|
774
776
|
|
|
775
777
|
expect( Object.keys( state.byClientId ) ).toHaveLength( 1 );
|
|
776
|
-
expect( values( state.byClientId )[ 0 ].name ).toBe(
|
|
778
|
+
expect( Object.values( state.byClientId )[ 0 ].name ).toBe(
|
|
777
779
|
'core/freeform'
|
|
778
780
|
);
|
|
779
|
-
expect( values( state.byClientId )[ 0 ].clientId ).toBe(
|
|
781
|
+
expect( Object.values( state.byClientId )[ 0 ].clientId ).toBe(
|
|
782
|
+
'wings'
|
|
783
|
+
);
|
|
780
784
|
expect( state.order ).toEqual( {
|
|
781
785
|
'': [ 'wings' ],
|
|
782
786
|
wings: [],
|
|
@@ -930,15 +934,15 @@ describe( 'state', () => {
|
|
|
930
934
|
} );
|
|
931
935
|
|
|
932
936
|
expect( Object.keys( replacedState.byClientId ) ).toHaveLength( 1 );
|
|
933
|
-
expect( values( originalState.byClientId )[ 0 ].name ).toBe(
|
|
937
|
+
expect( Object.values( originalState.byClientId )[ 0 ].name ).toBe(
|
|
934
938
|
'core/test-block'
|
|
935
939
|
);
|
|
936
|
-
expect( values( replacedState.byClientId )[ 0 ].name ).toBe(
|
|
940
|
+
expect( Object.values( replacedState.byClientId )[ 0 ].name ).toBe(
|
|
937
941
|
'core/freeform'
|
|
938
942
|
);
|
|
939
|
-
expect(
|
|
940
|
-
|
|
941
|
-
);
|
|
943
|
+
expect(
|
|
944
|
+
Object.values( replacedState.byClientId )[ 0 ].clientId
|
|
945
|
+
).toBe( 'chicken' );
|
|
942
946
|
expect( replacedState.order ).toEqual( {
|
|
943
947
|
'': [ 'chicken' ],
|
|
944
948
|
chicken: [],
|
|
@@ -2090,6 +2094,130 @@ describe( 'state', () => {
|
|
|
2090
2094
|
expect( state.tree.child ).toBeUndefined();
|
|
2091
2095
|
expect( state.tree.chicken.innerBlocks ).toEqual( [] );
|
|
2092
2096
|
} );
|
|
2097
|
+
it( 'should preserve the controlled blocks in state and re-attach them in other pieces of state(order, tree, etc..), when we replace inner blocks', () => {
|
|
2098
|
+
const initialState = {
|
|
2099
|
+
byClientId: {
|
|
2100
|
+
'group-id': {
|
|
2101
|
+
clientId: 'group-id',
|
|
2102
|
+
name: 'core/group',
|
|
2103
|
+
isValid: true,
|
|
2104
|
+
},
|
|
2105
|
+
'reusable-id': {
|
|
2106
|
+
clientId: 'reusable-id',
|
|
2107
|
+
name: 'core/block',
|
|
2108
|
+
isValid: true,
|
|
2109
|
+
},
|
|
2110
|
+
'paragraph-id': {
|
|
2111
|
+
clientId: 'paragraph-id',
|
|
2112
|
+
name: 'core/paragraph',
|
|
2113
|
+
isValid: true,
|
|
2114
|
+
},
|
|
2115
|
+
},
|
|
2116
|
+
order: {
|
|
2117
|
+
'': [ 'group-id' ],
|
|
2118
|
+
'group-id': [ 'reusable-id' ],
|
|
2119
|
+
'reusable-id': [ 'paragraph-id' ],
|
|
2120
|
+
'paragraph-id': [],
|
|
2121
|
+
},
|
|
2122
|
+
controlledInnerBlocks: {
|
|
2123
|
+
'reusable-id': true,
|
|
2124
|
+
},
|
|
2125
|
+
parents: {
|
|
2126
|
+
'group-id': '',
|
|
2127
|
+
'reusable-id': 'group-id',
|
|
2128
|
+
'paragraph-id': 'reusable-id',
|
|
2129
|
+
},
|
|
2130
|
+
tree: {
|
|
2131
|
+
'group-id': {
|
|
2132
|
+
clientId: 'group-id',
|
|
2133
|
+
name: 'core/group',
|
|
2134
|
+
isValid: true,
|
|
2135
|
+
innerBlocks: [
|
|
2136
|
+
{
|
|
2137
|
+
clientId: 'reusable-id',
|
|
2138
|
+
name: 'core/block',
|
|
2139
|
+
isValid: true,
|
|
2140
|
+
attributes: {
|
|
2141
|
+
ref: 687,
|
|
2142
|
+
},
|
|
2143
|
+
innerBlocks: [],
|
|
2144
|
+
},
|
|
2145
|
+
],
|
|
2146
|
+
},
|
|
2147
|
+
'reusable-id': {
|
|
2148
|
+
clientId: 'reusable-id',
|
|
2149
|
+
name: 'core/block',
|
|
2150
|
+
isValid: true,
|
|
2151
|
+
attributes: {
|
|
2152
|
+
ref: 687,
|
|
2153
|
+
},
|
|
2154
|
+
innerBlocks: [],
|
|
2155
|
+
},
|
|
2156
|
+
'': {
|
|
2157
|
+
innerBlocks: [
|
|
2158
|
+
{
|
|
2159
|
+
clientId: 'group-id',
|
|
2160
|
+
name: 'core/group',
|
|
2161
|
+
isValid: true,
|
|
2162
|
+
innerBlocks: [
|
|
2163
|
+
{
|
|
2164
|
+
clientId: 'reusable-id',
|
|
2165
|
+
name: 'core/block',
|
|
2166
|
+
isValid: true,
|
|
2167
|
+
attributes: {
|
|
2168
|
+
ref: 687,
|
|
2169
|
+
},
|
|
2170
|
+
innerBlocks: [],
|
|
2171
|
+
},
|
|
2172
|
+
],
|
|
2173
|
+
},
|
|
2174
|
+
],
|
|
2175
|
+
},
|
|
2176
|
+
'paragraph-id': {
|
|
2177
|
+
clientId: 'paragraph-id',
|
|
2178
|
+
name: 'core/paragraph',
|
|
2179
|
+
isValid: true,
|
|
2180
|
+
innerBlocks: [],
|
|
2181
|
+
},
|
|
2182
|
+
'controlled||reusable-id': {
|
|
2183
|
+
innerBlocks: [
|
|
2184
|
+
{
|
|
2185
|
+
clientId: 'paragraph-id',
|
|
2186
|
+
name: 'core/paragraph',
|
|
2187
|
+
isValid: true,
|
|
2188
|
+
innerBlocks: [],
|
|
2189
|
+
},
|
|
2190
|
+
],
|
|
2191
|
+
},
|
|
2192
|
+
},
|
|
2193
|
+
};
|
|
2194
|
+
// We will dispatch an action that replaces the inner
|
|
2195
|
+
// blocks with the same inner blocks, which contain
|
|
2196
|
+
// a controlled block (`reusable-id`).
|
|
2197
|
+
const action = {
|
|
2198
|
+
type: 'REPLACE_INNER_BLOCKS',
|
|
2199
|
+
rootClientId: 'group-id',
|
|
2200
|
+
blocks: [
|
|
2201
|
+
{
|
|
2202
|
+
clientId: 'reusable-id',
|
|
2203
|
+
name: 'core/block',
|
|
2204
|
+
isValid: true,
|
|
2205
|
+
attributes: {
|
|
2206
|
+
ref: 687,
|
|
2207
|
+
},
|
|
2208
|
+
innerBlocks: [],
|
|
2209
|
+
},
|
|
2210
|
+
],
|
|
2211
|
+
updateSelection: false,
|
|
2212
|
+
};
|
|
2213
|
+
const state = blocks( initialState, action );
|
|
2214
|
+
expect( state.order ).toEqual(
|
|
2215
|
+
expect.objectContaining( initialState.order )
|
|
2216
|
+
);
|
|
2217
|
+
expect( state.tree ).toEqual(
|
|
2218
|
+
expect.objectContaining( initialState.tree )
|
|
2219
|
+
);
|
|
2220
|
+
} );
|
|
2093
2221
|
} );
|
|
2094
2222
|
} );
|
|
2095
2223
|
} );
|
|
@@ -1,8 +1,3 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* External dependencies
|
|
3
|
-
*/
|
|
4
|
-
import { filter } from 'lodash';
|
|
5
|
-
|
|
6
1
|
/**
|
|
7
2
|
* WordPress dependencies
|
|
8
3
|
*/
|
|
@@ -83,7 +78,9 @@ describe( 'selectors', () => {
|
|
|
83
78
|
let cachedSelectors;
|
|
84
79
|
|
|
85
80
|
beforeAll( () => {
|
|
86
|
-
cachedSelectors =
|
|
81
|
+
cachedSelectors = Object.entries( selectors )
|
|
82
|
+
.filter( ( [ , selector ] ) => selector.clear )
|
|
83
|
+
.map( ( [ , selector ] ) => selector );
|
|
87
84
|
} );
|
|
88
85
|
|
|
89
86
|
beforeEach( () => {
|