@wordpress/block-editor 10.4.0 → 11.0.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 +17 -0
- package/README.md +0 -1
- package/build/autocompleters/block.js +2 -6
- package/build/autocompleters/block.js.map +1 -1
- package/build/autocompleters/link.js +2 -0
- package/build/autocompleters/link.js.map +1 -1
- package/build/components/block-card/index.js +51 -3
- package/build/components/block-card/index.js.map +1 -1
- package/build/components/block-draggable/index.native.js +46 -39
- package/build/components/block-draggable/index.native.js.map +1 -1
- package/build/components/block-edit/edit.js +4 -3
- package/build/components/block-edit/edit.js.map +1 -1
- package/build/components/block-edit/edit.native.js +4 -7
- package/build/components/block-edit/edit.native.js.map +1 -1
- package/build/components/block-inspector/index.js +35 -33
- package/build/components/block-inspector/index.js.map +1 -1
- package/build/components/block-list/block-list-context.native.js +5 -8
- package/build/components/block-list/block-list-context.native.js.map +1 -1
- package/build/components/block-list/block.js +55 -24
- package/build/components/block-list/block.js.map +1 -1
- package/build/components/block-list/block.native.js +61 -28
- package/build/components/block-list/block.native.js.map +1 -1
- package/build/components/block-lock/menu-item.js +1 -1
- package/build/components/block-lock/menu-item.js.map +1 -1
- package/build/components/block-lock/modal.js +16 -9
- package/build/components/block-lock/modal.js.map +1 -1
- package/build/components/block-mobile-toolbar/block-actions-menu.native.js +12 -4
- package/build/components/block-mobile-toolbar/block-actions-menu.native.js.map +1 -1
- package/build/components/block-pattern-setup/index.js +3 -2
- package/build/components/block-pattern-setup/index.js.map +1 -1
- package/build/components/block-patterns-list/index.js +33 -11
- package/build/components/block-patterns-list/index.js.map +1 -1
- package/build/components/block-preview/auto.js +9 -3
- package/build/components/block-preview/auto.js.map +1 -1
- package/build/components/block-preview/index.js +5 -9
- package/build/components/block-preview/index.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-styles/utils.js +3 -3
- package/build/components/block-styles/utils.js.map +1 -1
- package/build/components/block-switcher/index.js +19 -4
- package/build/components/block-switcher/index.js.map +1 -1
- package/build/components/block-toolbar/index.js +5 -1
- package/build/components/block-toolbar/index.js.map +1 -1
- package/build/components/block-tools/insertion-point.js +8 -49
- package/build/components/block-tools/insertion-point.js.map +1 -1
- package/build/components/block-tools/selected-block-popover.js +27 -4
- package/build/components/block-tools/selected-block-popover.js.map +1 -1
- package/build/components/block-variation-picker/index.js +1 -2
- package/build/components/block-variation-picker/index.js.map +1 -1
- package/build/components/colors/with-colors.js +4 -3
- package/build/components/colors/with-colors.js.map +1 -1
- package/build/components/font-sizes/fluid-utils.js +24 -40
- package/build/components/font-sizes/fluid-utils.js.map +1 -1
- package/build/components/font-sizes/with-font-sizes.js +7 -5
- package/build/components/font-sizes/with-font-sizes.js.map +1 -1
- package/build/components/height-control/index.js +115 -0
- package/build/components/height-control/index.js.map +1 -0
- package/build/components/iframe/index.js +11 -8
- package/build/components/iframe/index.js.map +1 -1
- package/build/components/image-editor/use-save-image.js +2 -0
- package/build/components/image-editor/use-save-image.js.map +1 -1
- package/build/components/image-editor/zoom-dropdown.js +1 -0
- package/build/components/image-editor/zoom-dropdown.js.map +1 -1
- package/build/components/index.js +18 -0
- package/build/components/index.js.map +1 -1
- package/build/components/inner-blocks/index.js +25 -9
- package/build/components/inner-blocks/index.js.map +1 -1
- package/build/components/inner-blocks/use-inner-block-template-sync.js +25 -10
- package/build/components/inner-blocks/use-inner-block-template-sync.js.map +1 -1
- package/build/components/inserter/block-patterns-explorer/sidebar.js +1 -0
- package/build/components/inserter/block-patterns-explorer/sidebar.js.map +1 -1
- package/build/components/inserter/block-patterns-tab.js +25 -46
- package/build/components/inserter/block-patterns-tab.js.map +1 -1
- package/build/components/inserter/block-types-tab.js +3 -1
- package/build/components/inserter/block-types-tab.js.map +1 -1
- package/build/components/inserter/hooks/use-debounced-input.js +27 -0
- package/build/components/inserter/hooks/use-debounced-input.js.map +1 -0
- package/build/components/inserter/index.js +8 -3
- package/build/components/inserter/index.js.map +1 -1
- package/build/components/inserter/index.native.js +3 -4
- package/build/components/inserter/index.native.js.map +1 -1
- package/build/components/inserter/media-tab/hooks.js +103 -0
- package/build/components/inserter/media-tab/hooks.js.map +1 -0
- package/build/components/inserter/media-tab/index.js +32 -0
- package/build/components/inserter/media-tab/index.js.map +1 -0
- package/build/components/inserter/media-tab/media-list.js +100 -0
- package/build/components/inserter/media-tab/media-list.js.map +1 -0
- package/build/components/inserter/media-tab/media-panel.js +96 -0
- package/build/components/inserter/media-tab/media-panel.js.map +1 -0
- package/build/components/inserter/media-tab/media-tab.js +120 -0
- package/build/components/inserter/media-tab/media-tab.js.map +1 -0
- package/build/components/inserter/media-tab/utils.js +54 -0
- package/build/components/inserter/media-tab/utils.js.map +1 -0
- package/build/components/inserter/menu.js +35 -12
- package/build/components/inserter/menu.js.map +1 -1
- package/build/components/inserter/mobile-tab-navigation.js +70 -0
- package/build/components/inserter/mobile-tab-navigation.js.map +1 -0
- package/build/components/inserter/quick-inserter.js +1 -0
- package/build/components/inserter/quick-inserter.js.map +1 -1
- package/build/components/inserter/reusable-blocks-tab.js +4 -1
- package/build/components/inserter/reusable-blocks-tab.js.map +1 -1
- package/build/components/inserter/search-results.js +3 -1
- package/build/components/inserter/search-results.js.map +1 -1
- package/build/components/inserter/tabs.js +16 -2
- package/build/components/inserter/tabs.js.map +1 -1
- package/build/components/inserter-list-item/index.js +4 -1
- package/build/components/inserter-list-item/index.js.map +1 -1
- package/build/components/inspector-controls/groups.js +2 -0
- package/build/components/inspector-controls/groups.js.map +1 -1
- package/build/components/inspector-controls-tabs/advanced-controls-panel.js +46 -0
- package/build/components/inspector-controls-tabs/advanced-controls-panel.js.map +1 -0
- package/build/components/inspector-controls-tabs/index.js +71 -0
- package/build/components/inspector-controls-tabs/index.js.map +1 -0
- package/build/components/inspector-controls-tabs/settings-tab.js +28 -0
- package/build/components/inspector-controls-tabs/settings-tab.js.map +1 -0
- package/build/components/inspector-controls-tabs/styles-tab.js +61 -0
- package/build/components/inspector-controls-tabs/styles-tab.js.map +1 -0
- package/build/components/inspector-controls-tabs/use-inspector-controls-tabs.js +97 -0
- package/build/components/inspector-controls-tabs/use-inspector-controls-tabs.js.map +1 -0
- package/build/components/inspector-controls-tabs/use-is-list-view-tab-disabled.js +18 -0
- package/build/components/inspector-controls-tabs/use-is-list-view-tab-disabled.js.map +1 -0
- package/build/components/inspector-controls-tabs/utils.js +37 -0
- package/build/components/inspector-controls-tabs/utils.js.map +1 -0
- package/build/components/link-control/index.js +19 -34
- package/build/components/link-control/index.js.map +1 -1
- package/build/components/link-control/search-input.js +1 -2
- package/build/components/link-control/search-input.js.map +1 -1
- package/build/components/link-control/use-internal-input-value.js +26 -0
- package/build/components/link-control/use-internal-input-value.js.map +1 -0
- package/build/components/list-view/block.js +10 -5
- package/build/components/list-view/block.js.map +1 -1
- package/build/components/list-view/branch.js +22 -15
- package/build/components/list-view/branch.js.map +1 -1
- package/build/components/media-upload/index.native.js +2 -3
- package/build/components/media-upload/index.native.js.map +1 -1
- package/build/components/off-canvas-editor/appender.js +104 -0
- package/build/components/off-canvas-editor/appender.js.map +1 -0
- package/build/components/off-canvas-editor/block-contents.js +100 -0
- package/build/components/off-canvas-editor/block-contents.js.map +1 -0
- package/build/components/off-canvas-editor/block-edit-button.js +50 -0
- package/build/components/off-canvas-editor/block-edit-button.js.map +1 -0
- package/build/components/off-canvas-editor/block-select-button.js +119 -0
- package/build/components/off-canvas-editor/block-select-button.js.map +1 -0
- package/build/components/off-canvas-editor/block.js +324 -0
- package/build/components/off-canvas-editor/block.js.map +1 -0
- package/build/components/off-canvas-editor/branch.js +179 -0
- package/build/components/off-canvas-editor/branch.js.map +1 -0
- package/build/components/off-canvas-editor/context.js +19 -0
- package/build/components/off-canvas-editor/context.js.map +1 -0
- package/build/components/off-canvas-editor/drop-indicator.js +118 -0
- package/build/components/off-canvas-editor/drop-indicator.js.map +1 -0
- package/build/components/off-canvas-editor/expander.js +41 -0
- package/build/components/off-canvas-editor/expander.js.map +1 -0
- package/build/components/off-canvas-editor/index.js +213 -0
- package/build/components/off-canvas-editor/index.js.map +1 -0
- package/build/components/off-canvas-editor/leaf.js +60 -0
- package/build/components/off-canvas-editor/leaf.js.map +1 -0
- package/build/components/off-canvas-editor/link-ui.js +185 -0
- package/build/components/off-canvas-editor/link-ui.js.map +1 -0
- package/build/components/off-canvas-editor/update-attributes.js +108 -0
- package/build/components/off-canvas-editor/update-attributes.js.map +1 -0
- package/build/components/off-canvas-editor/use-block-selection.js +139 -0
- package/build/components/off-canvas-editor/use-block-selection.js.map +1 -0
- package/build/components/off-canvas-editor/use-list-view-client-ids.js +33 -0
- package/build/components/off-canvas-editor/use-list-view-client-ids.js.map +1 -0
- package/build/components/off-canvas-editor/use-list-view-drop-zone.js +235 -0
- package/build/components/off-canvas-editor/use-list-view-drop-zone.js.map +1 -0
- package/build/components/off-canvas-editor/use-list-view-expand-selected-item.js +60 -0
- package/build/components/off-canvas-editor/use-list-view-expand-selected-item.js.map +1 -0
- package/build/components/off-canvas-editor/utils.js +60 -0
- package/build/components/off-canvas-editor/utils.js.map +1 -0
- package/build/components/rich-text/format-toolbar/index.js +8 -4
- package/build/components/rich-text/format-toolbar/index.js.map +1 -1
- package/build/components/rich-text/index.js +3 -3
- package/build/components/rich-text/index.js.map +1 -1
- package/build/components/rich-text/index.native.js +0 -2
- package/build/components/rich-text/index.native.js.map +1 -1
- package/build/components/rich-text/use-insert-replacement-text.js +43 -0
- package/build/components/rich-text/use-insert-replacement-text.js.map +1 -0
- package/build/components/rich-text/use-undo-automatic-change.js +9 -1
- package/build/components/rich-text/use-undo-automatic-change.js.map +1 -1
- package/build/components/rich-text/utils.js +1 -19
- package/build/components/rich-text/utils.js.map +1 -1
- package/build/components/spacing-sizes-control/spacing-input-control.js +12 -3
- package/build/components/spacing-sizes-control/spacing-input-control.js.map +1 -1
- package/build/components/ungroup-button/index.native.js +4 -2
- package/build/components/ungroup-button/index.native.js.map +1 -1
- package/build/components/url-input/index.js +46 -43
- package/build/components/url-input/index.js.map +1 -1
- package/build/components/url-popover/index.js +31 -2
- package/build/components/url-popover/index.js.map +1 -1
- package/build/components/use-block-display-information/index.js +8 -4
- package/build/components/use-block-display-information/index.js.map +1 -1
- package/build/components/use-setting/index.js +10 -2
- package/build/components/use-setting/index.js.map +1 -1
- package/build/hooks/child-layout.js +209 -0
- package/build/hooks/child-layout.js.map +1 -0
- package/build/hooks/color-panel.js +17 -1
- package/build/hooks/color-panel.js.map +1 -1
- package/build/hooks/color.js +1 -1
- package/build/hooks/color.js.map +1 -1
- package/build/hooks/content-lock-ui.js +14 -7
- package/build/hooks/content-lock-ui.js.map +1 -1
- package/build/hooks/dimensions.js +65 -16
- package/build/hooks/dimensions.js.map +1 -1
- package/build/hooks/layout.js +59 -3
- package/build/hooks/layout.js.map +1 -1
- package/build/hooks/margin.js +4 -2
- package/build/hooks/margin.js.map +1 -1
- package/build/hooks/min-height.js +139 -0
- package/build/hooks/min-height.js.map +1 -0
- package/build/hooks/padding.js +4 -2
- package/build/hooks/padding.js.map +1 -1
- package/build/hooks/style.js +3 -2
- package/build/hooks/style.js.map +1 -1
- package/build/layouts/flex.js +22 -21
- package/build/layouts/flex.js.map +1 -1
- package/build/store/actions.js +26 -0
- package/build/store/actions.js.map +1 -1
- package/build/store/reducer.js +420 -265
- package/build/store/reducer.js.map +1 -1
- package/build/store/selectors.js +73 -49
- package/build/store/selectors.js.map +1 -1
- package/build/utils/sorting.js +63 -0
- package/build/utils/sorting.js.map +1 -0
- package/build-module/autocompleters/block.js +2 -6
- package/build-module/autocompleters/block.js.map +1 -1
- package/build-module/autocompleters/link.js +2 -0
- package/build-module/autocompleters/link.js.map +1 -1
- package/build-module/components/block-card/index.js +45 -3
- package/build-module/components/block-card/index.js.map +1 -1
- package/build-module/components/block-draggable/index.native.js +40 -31
- package/build-module/components/block-draggable/index.native.js.map +1 -1
- package/build-module/components/block-edit/edit.js +4 -2
- package/build-module/components/block-edit/edit.js.map +1 -1
- package/build-module/components/block-edit/edit.native.js +4 -6
- package/build-module/components/block-edit/edit.native.js.map +1 -1
- package/build-module/components/block-inspector/index.js +32 -30
- package/build-module/components/block-inspector/index.js.map +1 -1
- package/build-module/components/block-list/block-list-context.native.js +5 -8
- package/build-module/components/block-list/block-list-context.native.js.map +1 -1
- package/build-module/components/block-list/block.js +55 -25
- package/build-module/components/block-list/block.js.map +1 -1
- package/build-module/components/block-list/block.native.js +61 -28
- package/build-module/components/block-list/block.native.js.map +1 -1
- package/build-module/components/block-lock/menu-item.js +2 -2
- package/build-module/components/block-lock/menu-item.js.map +1 -1
- package/build-module/components/block-lock/modal.js +17 -10
- package/build-module/components/block-lock/modal.js.map +1 -1
- package/build-module/components/block-mobile-toolbar/block-actions-menu.native.js +13 -6
- package/build-module/components/block-mobile-toolbar/block-actions-menu.native.js.map +1 -1
- package/build-module/components/block-pattern-setup/index.js +3 -2
- package/build-module/components/block-pattern-setup/index.js.map +1 -1
- package/build-module/components/block-patterns-list/index.js +35 -13
- package/build-module/components/block-patterns-list/index.js.map +1 -1
- package/build-module/components/block-preview/auto.js +9 -3
- package/build-module/components/block-preview/auto.js.map +1 -1
- package/build-module/components/block-preview/index.js +5 -8
- package/build-module/components/block-preview/index.js.map +1 -1
- package/build-module/components/block-settings-menu/block-settings-dropdown.js +5 -2
- package/build-module/components/block-settings-menu/block-settings-dropdown.js.map +1 -1
- package/build-module/components/block-styles/utils.js +3 -3
- package/build-module/components/block-styles/utils.js.map +1 -1
- package/build-module/components/block-switcher/index.js +19 -4
- package/build-module/components/block-switcher/index.js.map +1 -1
- package/build-module/components/block-toolbar/index.js +6 -2
- package/build-module/components/block-toolbar/index.js.map +1 -1
- package/build-module/components/block-tools/insertion-point.js +8 -49
- package/build-module/components/block-tools/insertion-point.js.map +1 -1
- package/build-module/components/block-tools/selected-block-popover.js +27 -5
- package/build-module/components/block-tools/selected-block-popover.js.map +1 -1
- package/build-module/components/block-variation-picker/index.js +1 -2
- package/build-module/components/block-variation-picker/index.js.map +1 -1
- package/build-module/components/colors/with-colors.js +5 -4
- package/build-module/components/colors/with-colors.js.map +1 -1
- package/build-module/components/font-sizes/fluid-utils.js +24 -40
- package/build-module/components/font-sizes/fluid-utils.js.map +1 -1
- package/build-module/components/font-sizes/with-font-sizes.js +8 -6
- package/build-module/components/font-sizes/with-font-sizes.js.map +1 -1
- package/build-module/components/height-control/index.js +103 -0
- package/build-module/components/height-control/index.js.map +1 -0
- package/build-module/components/iframe/index.js +11 -8
- package/build-module/components/iframe/index.js.map +1 -1
- package/build-module/components/image-editor/use-save-image.js +2 -0
- package/build-module/components/image-editor/use-save-image.js.map +1 -1
- package/build-module/components/image-editor/zoom-dropdown.js +1 -0
- package/build-module/components/image-editor/zoom-dropdown.js.map +1 -1
- package/build-module/components/index.js +2 -0
- package/build-module/components/index.js.map +1 -1
- package/build-module/components/inner-blocks/index.js +27 -11
- package/build-module/components/inner-blocks/index.js.map +1 -1
- package/build-module/components/inner-blocks/use-inner-block-template-sync.js +23 -10
- package/build-module/components/inner-blocks/use-inner-block-template-sync.js.map +1 -1
- package/build-module/components/inserter/block-patterns-explorer/sidebar.js +1 -0
- package/build-module/components/inserter/block-patterns-explorer/sidebar.js.map +1 -1
- package/build-module/components/inserter/block-patterns-tab.js +27 -49
- package/build-module/components/inserter/block-patterns-tab.js.map +1 -1
- package/build-module/components/inserter/block-types-tab.js +3 -2
- package/build-module/components/inserter/block-types-tab.js.map +1 -1
- package/build-module/components/inserter/hooks/use-debounced-input.js +18 -0
- package/build-module/components/inserter/hooks/use-debounced-input.js.map +1 -0
- package/build-module/components/inserter/index.js +8 -3
- package/build-module/components/inserter/index.js.map +1 -1
- package/build-module/components/inserter/index.native.js +3 -5
- package/build-module/components/inserter/index.native.js.map +1 -1
- package/build-module/components/inserter/media-tab/hooks.js +89 -0
- package/build-module/components/inserter/media-tab/hooks.js.map +1 -0
- package/build-module/components/inserter/media-tab/index.js +4 -0
- package/build-module/components/inserter/media-tab/index.js.map +1 -0
- package/build-module/components/inserter/media-tab/media-list.js +86 -0
- package/build-module/components/inserter/media-tab/media-list.js.map +1 -0
- package/build-module/components/inserter/media-tab/media-panel.js +77 -0
- package/build-module/components/inserter/media-tab/media-panel.js.map +1 -0
- package/build-module/components/inserter/media-tab/media-tab.js +100 -0
- package/build-module/components/inserter/media-tab/media-tab.js.map +1 -0
- package/build-module/components/inserter/media-tab/utils.js +45 -0
- package/build-module/components/inserter/media-tab/utils.js.map +1 -0
- package/build-module/components/inserter/menu.js +33 -12
- package/build-module/components/inserter/menu.js.map +1 -1
- package/build-module/components/inserter/mobile-tab-navigation.js +61 -0
- package/build-module/components/inserter/mobile-tab-navigation.js.map +1 -0
- package/build-module/components/inserter/quick-inserter.js +1 -0
- package/build-module/components/inserter/quick-inserter.js.map +1 -1
- package/build-module/components/inserter/reusable-blocks-tab.js +3 -1
- package/build-module/components/inserter/reusable-blocks-tab.js.map +1 -1
- package/build-module/components/inserter/search-results.js +3 -2
- package/build-module/components/inserter/search-results.js.map +1 -1
- package/build-module/components/inserter/tabs.js +15 -2
- package/build-module/components/inserter/tabs.js.map +1 -1
- package/build-module/components/inserter-list-item/index.js +5 -2
- package/build-module/components/inserter-list-item/index.js.map +1 -1
- package/build-module/components/inspector-controls/groups.js +2 -0
- package/build-module/components/inspector-controls/groups.js.map +1 -1
- package/build-module/components/inspector-controls-tabs/advanced-controls-panel.js +32 -0
- package/build-module/components/inspector-controls-tabs/advanced-controls-panel.js.map +1 -0
- package/build-module/components/inspector-controls-tabs/index.js +56 -0
- package/build-module/components/inspector-controls-tabs/index.js.map +1 -0
- package/build-module/components/inspector-controls-tabs/settings-tab.js +17 -0
- package/build-module/components/inspector-controls-tabs/settings-tab.js.map +1 -0
- package/build-module/components/inspector-controls-tabs/styles-tab.js +46 -0
- package/build-module/components/inspector-controls-tabs/styles-tab.js.map +1 -0
- package/build-module/components/inspector-controls-tabs/use-inspector-controls-tabs.js +81 -0
- package/build-module/components/inspector-controls-tabs/use-inspector-controls-tabs.js.map +1 -0
- package/build-module/components/inspector-controls-tabs/use-is-list-view-tab-disabled.js +8 -0
- package/build-module/components/inspector-controls-tabs/use-is-list-view-tab-disabled.js.map +1 -0
- package/build-module/components/inspector-controls-tabs/utils.js +26 -0
- package/build-module/components/inspector-controls-tabs/utils.js.map +1 -0
- package/build-module/components/link-control/index.js +18 -34
- package/build-module/components/link-control/index.js.map +1 -1
- package/build-module/components/link-control/search-input.js +1 -2
- package/build-module/components/link-control/search-input.js.map +1 -1
- package/build-module/components/link-control/use-internal-input-value.js +18 -0
- package/build-module/components/link-control/use-internal-input-value.js.map +1 -0
- package/build-module/components/list-view/block.js +10 -5
- package/build-module/components/list-view/block.js.map +1 -1
- package/build-module/components/list-view/branch.js +21 -14
- package/build-module/components/list-view/branch.js.map +1 -1
- package/build-module/components/media-upload/index.native.js +2 -4
- package/build-module/components/media-upload/index.native.js.map +1 -1
- package/build-module/components/off-canvas-editor/appender.js +89 -0
- package/build-module/components/off-canvas-editor/appender.js.map +1 -0
- package/build-module/components/off-canvas-editor/block-contents.js +85 -0
- package/build-module/components/off-canvas-editor/block-contents.js.map +1 -0
- package/build-module/components/off-canvas-editor/block-edit-button.js +35 -0
- package/build-module/components/off-canvas-editor/block-edit-button.js.map +1 -0
- package/build-module/components/off-canvas-editor/block-select-button.js +101 -0
- package/build-module/components/off-canvas-editor/block-select-button.js.map +1 -0
- package/build-module/components/off-canvas-editor/block.js +298 -0
- package/build-module/components/off-canvas-editor/block.js.map +1 -0
- package/build-module/components/off-canvas-editor/branch.js +164 -0
- package/build-module/components/off-canvas-editor/branch.js.map +1 -0
- package/build-module/components/off-canvas-editor/context.js +7 -0
- package/build-module/components/off-canvas-editor/context.js.map +1 -0
- package/build-module/components/off-canvas-editor/drop-indicator.js +111 -0
- package/build-module/components/off-canvas-editor/drop-indicator.js.map +1 -0
- package/build-module/components/off-canvas-editor/expander.js +32 -0
- package/build-module/components/off-canvas-editor/expander.js.map +1 -0
- package/build-module/components/off-canvas-editor/index.js +189 -0
- package/build-module/components/off-canvas-editor/index.js.map +1 -0
- package/build-module/components/off-canvas-editor/leaf.js +45 -0
- package/build-module/components/off-canvas-editor/leaf.js.map +1 -0
- package/build-module/components/off-canvas-editor/link-ui.js +165 -0
- package/build-module/components/off-canvas-editor/link-ui.js.map +1 -0
- package/build-module/components/off-canvas-editor/update-attributes.js +97 -0
- package/build-module/components/off-canvas-editor/update-attributes.js.map +1 -0
- package/build-module/components/off-canvas-editor/use-block-selection.js +124 -0
- package/build-module/components/off-canvas-editor/use-block-selection.js.map +1 -0
- package/build-module/components/off-canvas-editor/use-list-view-client-ids.js +24 -0
- package/build-module/components/off-canvas-editor/use-list-view-client-ids.js.map +1 -0
- package/build-module/components/off-canvas-editor/use-list-view-drop-zone.js +220 -0
- package/build-module/components/off-canvas-editor/use-list-view-drop-zone.js.map +1 -0
- package/build-module/components/off-canvas-editor/use-list-view-expand-selected-item.js +50 -0
- package/build-module/components/off-canvas-editor/use-list-view-expand-selected-item.js.map +1 -0
- package/build-module/components/off-canvas-editor/utils.js +44 -0
- package/build-module/components/off-canvas-editor/utils.js.map +1 -0
- package/build-module/components/rich-text/format-toolbar/index.js +6 -2
- package/build-module/components/rich-text/format-toolbar/index.js.map +1 -1
- package/build-module/components/rich-text/index.js +2 -3
- package/build-module/components/rich-text/index.js.map +1 -1
- package/build-module/components/rich-text/index.native.js +0 -2
- package/build-module/components/rich-text/index.native.js.map +1 -1
- package/build-module/components/rich-text/use-insert-replacement-text.js +33 -0
- package/build-module/components/rich-text/use-insert-replacement-text.js.map +1 -0
- package/build-module/components/rich-text/use-undo-automatic-change.js +9 -1
- package/build-module/components/rich-text/use-undo-automatic-change.js.map +1 -1
- package/build-module/components/rich-text/utils.js +1 -16
- package/build-module/components/rich-text/utils.js.map +1 -1
- package/build-module/components/spacing-sizes-control/spacing-input-control.js +12 -3
- package/build-module/components/spacing-sizes-control/spacing-input-control.js.map +1 -1
- package/build-module/components/ungroup-button/index.native.js +3 -2
- package/build-module/components/ungroup-button/index.native.js.map +1 -1
- package/build-module/components/url-input/index.js +46 -43
- package/build-module/components/url-input/index.js.map +1 -1
- package/build-module/components/url-popover/index.js +30 -3
- package/build-module/components/url-popover/index.js.map +1 -1
- package/build-module/components/use-block-display-information/index.js +9 -5
- package/build-module/components/use-block-display-information/index.js.map +1 -1
- package/build-module/components/use-setting/index.js +9 -2
- package/build-module/components/use-setting/index.js.map +1 -1
- package/build-module/hooks/child-layout.js +189 -0
- package/build-module/hooks/child-layout.js.map +1 -0
- package/build-module/hooks/color-panel.js +17 -1
- package/build-module/hooks/color-panel.js.map +1 -1
- package/build-module/hooks/color.js +1 -1
- package/build-module/hooks/color.js.map +1 -1
- package/build-module/hooks/content-lock-ui.js +16 -9
- package/build-module/hooks/content-lock-ui.js.map +1 -1
- package/build-module/hooks/dimensions.js +60 -16
- package/build-module/hooks/dimensions.js.map +1 -1
- package/build-module/hooks/layout.js +57 -2
- package/build-module/hooks/layout.js.map +1 -1
- package/build-module/hooks/margin.js +4 -2
- package/build-module/hooks/margin.js.map +1 -1
- package/build-module/hooks/min-height.js +116 -0
- package/build-module/hooks/min-height.js.map +1 -0
- package/build-module/hooks/padding.js +4 -2
- package/build-module/hooks/padding.js.map +1 -1
- package/build-module/hooks/style.js +4 -3
- package/build-module/hooks/style.js.map +1 -1
- package/build-module/layouts/flex.js +23 -22
- package/build-module/layouts/flex.js.map +1 -1
- package/build-module/store/actions.js +22 -0
- package/build-module/store/actions.js.map +1 -1
- package/build-module/store/reducer.js +415 -265
- package/build-module/store/reducer.js.map +1 -1
- package/build-module/store/selectors.js +66 -48
- package/build-module/store/selectors.js.map +1 -1
- package/build-module/utils/sorting.js +56 -0
- package/build-module/utils/sorting.js.map +1 -0
- package/build-style/content-rtl.css +701 -0
- package/build-style/content.css +701 -0
- package/build-style/default-editor-styles-rtl.css +14 -0
- package/build-style/default-editor-styles.css +14 -0
- package/build-style/style-rtl.css +305 -668
- package/build-style/style.css +305 -668
- package/package.json +32 -30
- package/src/autocompleters/block.js +2 -6
- package/src/autocompleters/link.js +2 -0
- package/src/components/alignment-control/README.md +1 -1
- package/src/components/alignment-control/test/index.js +4 -1
- package/src/components/block-alignment-control/test/index.js +4 -1
- package/src/components/block-alignment-control/test/index.native.js +4 -4
- package/src/components/block-card/index.js +46 -2
- package/src/components/block-card/style.scss +4 -0
- package/src/components/block-content-overlay/{style.scss → content.scss} +7 -1
- package/src/components/block-draggable/content.scss +20 -0
- package/src/components/block-draggable/index.native.js +54 -40
- package/src/components/block-draggable/style.scss +0 -21
- package/src/components/block-draggable/test/helpers.native.js +7 -9
- package/src/components/block-draggable/test/index.native.js +35 -45
- package/src/components/block-edit/edit.js +5 -2
- package/src/components/block-edit/edit.native.js +5 -6
- package/src/components/block-inspector/index.js +96 -81
- package/src/components/block-inspector/style.scss +9 -1
- package/src/components/block-list/block-list-context.native.js +5 -8
- package/src/components/block-list/block.js +74 -23
- package/src/components/block-list/block.native.js +78 -23
- package/src/components/block-list/{style.scss → content.scss} +11 -20
- package/src/components/block-list-appender/{style.scss → content.scss} +0 -0
- package/src/components/block-lock/menu-item.js +5 -2
- package/src/components/block-lock/modal.js +19 -36
- package/src/components/block-lock/style.scss +8 -17
- package/src/components/block-mobile-toolbar/block-actions-menu.native.js +24 -6
- package/src/components/block-mover/style.scss +0 -1
- package/src/components/block-mover/test/__snapshots__/index.native.js.snap +0 -2
- package/src/components/block-pattern-setup/index.js +2 -1
- package/src/components/block-patterns-list/index.js +47 -24
- package/src/components/block-popover/style.scss +1 -1
- package/src/components/block-preview/README.md +15 -10
- package/src/components/block-preview/auto.js +7 -1
- package/src/components/block-preview/content.scss +4 -0
- package/src/components/block-preview/index.js +7 -12
- package/src/components/block-preview/style.scss +0 -7
- package/src/components/block-preview/test/index.js +18 -35
- package/src/components/block-selection-clearer/test/index.js +12 -12
- package/src/components/block-settings-menu/block-settings-dropdown.js +32 -20
- package/src/components/block-styles/utils.js +3 -3
- package/src/components/block-switcher/index.js +19 -4
- package/src/components/block-switcher/test/index.js +4 -0
- package/src/components/block-toolbar/index.js +12 -5
- package/src/components/block-toolbar/style.scss +10 -0
- package/src/components/block-tools/insertion-point.js +3 -47
- package/src/components/block-tools/selected-block-popover.js +80 -34
- package/src/components/block-tools/style.scss +27 -5
- package/src/components/block-variation-picker/index.js +1 -4
- package/src/components/block-vertical-alignment-control/test/index.js +4 -1
- package/src/components/colors/with-colors.js +13 -23
- package/src/components/default-block-appender/{style.scss → content.scss} +1 -0
- package/src/components/font-sizes/fluid-utils.js +37 -64
- package/src/components/font-sizes/test/fluid-utils.js +5 -5
- package/src/components/font-sizes/with-font-sizes.js +14 -11
- package/src/components/height-control/index.js +123 -0
- package/src/components/height-control/stories/index.js +21 -0
- package/src/components/height-control/style.scss +5 -0
- package/src/components/iframe/index.js +25 -18
- package/src/components/image-editor/use-save-image.js +2 -0
- package/src/components/image-editor/zoom-dropdown.js +1 -0
- package/src/components/index.js +2 -0
- package/src/components/inner-blocks/{style.scss → content.scss} +0 -0
- package/src/components/inner-blocks/index.js +30 -10
- package/src/components/inner-blocks/use-inner-block-template-sync.js +28 -10
- package/src/components/inserter/block-patterns-explorer/sidebar.js +1 -0
- package/src/components/inserter/block-patterns-tab.js +28 -71
- package/src/components/inserter/block-types-tab.js +3 -2
- package/src/components/inserter/hooks/use-debounced-input.js +17 -0
- package/src/components/inserter/index.js +10 -2
- package/src/components/inserter/index.native.js +1 -1
- package/src/components/inserter/media-tab/hooks.js +88 -0
- package/src/components/inserter/media-tab/index.js +3 -0
- package/src/components/inserter/media-tab/media-list.js +93 -0
- package/src/components/inserter/media-tab/media-panel.js +83 -0
- package/src/components/inserter/media-tab/media-tab.js +135 -0
- package/src/components/inserter/media-tab/utils.js +37 -0
- package/src/components/inserter/menu.js +55 -13
- package/src/components/inserter/mobile-tab-navigation.js +85 -0
- package/src/components/inserter/quick-inserter.js +1 -0
- package/src/components/inserter/reusable-blocks-tab.js +4 -2
- package/src/components/inserter/search-results.js +3 -2
- package/src/components/inserter/stories/index.js +1 -1
- package/src/components/inserter/stories/{fixtures.js → utils/fixtures.js} +0 -0
- package/src/components/inserter/style.scss +184 -18
- package/src/components/inserter/tabs.js +12 -1
- package/src/components/inserter/test/reusable-blocks-tab.js +14 -57
- package/src/components/inserter-list-item/index.js +11 -1
- package/src/components/inserter-list-item/style.scss +26 -0
- package/src/components/inspector-controls/groups.js +2 -0
- package/src/components/inspector-controls-tabs/advanced-controls-panel.js +37 -0
- package/src/components/inspector-controls-tabs/index.js +62 -0
- package/src/components/inspector-controls-tabs/settings-tab.js +18 -0
- package/src/components/inspector-controls-tabs/styles-tab.js +51 -0
- package/src/components/inspector-controls-tabs/use-inspector-controls-tabs.js +89 -0
- package/src/components/inspector-controls-tabs/use-is-list-view-tab-disabled.js +9 -0
- package/src/components/inspector-controls-tabs/utils.js +28 -0
- package/src/components/line-height-control/test/index.js +5 -5
- package/src/components/link-control/README.md +1 -1
- package/src/components/link-control/index.js +24 -39
- package/src/components/link-control/search-input.js +1 -2
- package/src/components/link-control/test/index.js +400 -582
- package/src/components/link-control/use-internal-input-value.js +22 -0
- package/src/components/list-view/block.js +7 -3
- package/src/components/list-view/branch.js +21 -14
- package/src/components/list-view/style.scss +20 -9
- package/src/components/media-placeholder/{style.scss → content.scss} +0 -0
- package/src/components/media-replace-flow/test/index.js +37 -9
- package/src/components/media-upload/test/index.native.js +2 -0
- package/src/components/off-canvas-editor/README.md +5 -0
- package/src/components/off-canvas-editor/appender.js +93 -0
- package/src/components/off-canvas-editor/block-contents.js +89 -0
- package/src/components/off-canvas-editor/block-edit-button.js +27 -0
- package/src/components/off-canvas-editor/block-select-button.js +113 -0
- package/src/components/off-canvas-editor/block.js +401 -0
- package/src/components/off-canvas-editor/branch.js +208 -0
- package/src/components/off-canvas-editor/context.js +8 -0
- package/src/components/off-canvas-editor/drop-indicator.js +126 -0
- package/src/components/off-canvas-editor/expander.js +26 -0
- package/src/components/off-canvas-editor/index.js +242 -0
- package/src/components/off-canvas-editor/leaf.js +52 -0
- package/src/components/off-canvas-editor/link-ui.js +166 -0
- package/src/components/off-canvas-editor/style.scss +26 -0
- package/src/components/off-canvas-editor/test/utils.js +50 -0
- package/src/components/off-canvas-editor/update-attributes.js +99 -0
- package/src/components/off-canvas-editor/use-block-selection.js +169 -0
- package/src/components/off-canvas-editor/use-list-view-client-ids.js +29 -0
- package/src/components/off-canvas-editor/use-list-view-drop-zone.js +260 -0
- package/src/components/off-canvas-editor/use-list-view-expand-selected-item.js +58 -0
- package/src/components/off-canvas-editor/utils.js +58 -0
- package/src/components/plain-text/{style.scss → content.scss} +0 -0
- package/src/components/recursion-provider/test/index.js +27 -29
- package/src/components/responsive-block-control/test/index.js +69 -92
- package/src/components/rich-text/content.scss +42 -0
- package/src/components/rich-text/format-toolbar/index.js +6 -4
- package/src/components/rich-text/index.js +2 -2
- package/src/components/rich-text/index.native.js +0 -2
- package/src/components/rich-text/style.scss +0 -43
- package/src/components/rich-text/use-insert-replacement-text.js +31 -0
- package/src/components/rich-text/use-undo-automatic-change.js +7 -1
- package/src/components/rich-text/utils.js +2 -21
- package/src/components/spacing-sizes-control/spacing-input-control.js +9 -0
- package/src/components/ungroup-button/index.native.js +6 -2
- package/src/components/url-input/index.js +57 -73
- package/src/components/url-popover/README.md +12 -3
- package/src/components/url-popover/index.js +33 -3
- package/src/components/url-popover/test/__snapshots__/index.js.snap +8 -6
- package/src/components/url-popover/test/index.js +21 -9
- package/src/components/use-block-display-information/index.js +14 -5
- package/src/components/use-setting/index.js +20 -2
- package/src/components/use-setting/test/index.js +99 -0
- package/src/content.scss +10 -0
- package/src/hooks/child-layout.js +190 -0
- package/src/hooks/color-panel.js +13 -1
- package/src/hooks/color.js +2 -0
- package/src/hooks/content-lock-ui.js +47 -35
- package/src/hooks/dimensions.js +119 -21
- package/src/hooks/layout.js +62 -3
- package/src/hooks/margin.js +4 -3
- package/src/hooks/min-height.js +104 -0
- package/src/hooks/padding.js +4 -3
- package/src/hooks/style.js +10 -2
- package/src/hooks/test/style.js +4 -0
- package/src/hooks/test/use-typography-props.js +1 -1
- package/src/layouts/flex.js +43 -38
- package/src/store/actions.js +22 -0
- package/src/store/reducer.js +480 -434
- package/src/store/selectors.js +70 -64
- package/src/store/test/actions.js +18 -0
- package/src/store/test/performance.js +71 -0
- package/src/store/test/reducer.js +662 -490
- package/src/store/test/selectors.js +1839 -1306
- package/src/style.scss +4 -7
- package/src/utils/sorting.js +54 -0
- package/src/utils/test/sorting.js +49 -0
- package/tsconfig.tsbuildinfo +1 -1
- package/build/components/block-preview/live.js +0 -30
- package/build/components/block-preview/live.js.map +0 -1
- package/build-module/components/block-preview/live.js +0 -20
- package/build-module/components/block-preview/live.js.map +0 -1
- package/src/components/block-preview/live.js +0 -19
|
@@ -44,6 +44,7 @@ const {
|
|
|
44
44
|
isBlockMultiSelected,
|
|
45
45
|
isFirstMultiSelectedBlock,
|
|
46
46
|
getBlockMode,
|
|
47
|
+
__experimentalIsBlockInterfaceHidden: isBlockInterfaceHidden,
|
|
47
48
|
isTyping,
|
|
48
49
|
isDraggingBlocks,
|
|
49
50
|
getDraggedBlockClientIds,
|
|
@@ -72,6 +73,7 @@ const {
|
|
|
72
73
|
__experimentalGetPatternTransformItems,
|
|
73
74
|
wasBlockJustInserted,
|
|
74
75
|
__experimentalGetGlobalBlocksByName,
|
|
76
|
+
getLastInsertedBlockClientId,
|
|
75
77
|
} = selectors;
|
|
76
78
|
|
|
77
79
|
describe( 'selectors', () => {
|
|
@@ -201,10 +203,10 @@ describe( 'selectors', () => {
|
|
|
201
203
|
it( 'returns null if no block by clientId', () => {
|
|
202
204
|
const state = {
|
|
203
205
|
blocks: {
|
|
204
|
-
byClientId:
|
|
206
|
+
byClientId: new Map(),
|
|
205
207
|
attributes: {},
|
|
206
|
-
order:
|
|
207
|
-
parents:
|
|
208
|
+
order: new Map(),
|
|
209
|
+
parents: new Map(),
|
|
208
210
|
},
|
|
209
211
|
};
|
|
210
212
|
|
|
@@ -219,22 +221,31 @@ describe( 'selectors', () => {
|
|
|
219
221
|
it( 'returns block name', () => {
|
|
220
222
|
const state = {
|
|
221
223
|
blocks: {
|
|
222
|
-
byClientId:
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
224
|
+
byClientId: new Map(
|
|
225
|
+
Object.entries( {
|
|
226
|
+
'afd1cb17-2c08-4e7a-91be-007ba7ddc3a1': {
|
|
227
|
+
clientId:
|
|
228
|
+
'afd1cb17-2c08-4e7a-91be-007ba7ddc3a1',
|
|
229
|
+
name: 'core/paragraph',
|
|
230
|
+
},
|
|
231
|
+
} )
|
|
232
|
+
),
|
|
233
|
+
attributes: new Map(
|
|
234
|
+
Object.entries( {
|
|
235
|
+
'afd1cb17-2c08-4e7a-91be-007ba7ddc3a1': {},
|
|
236
|
+
} )
|
|
237
|
+
),
|
|
238
|
+
order: new Map(
|
|
239
|
+
Object.entries( {
|
|
240
|
+
'': [ 'afd1cb17-2c08-4e7a-91be-007ba7ddc3a1' ],
|
|
241
|
+
'afd1cb17-2c08-4e7a-91be-007ba7ddc3a1': [],
|
|
242
|
+
} )
|
|
243
|
+
),
|
|
244
|
+
parents: new Map(
|
|
245
|
+
Object.entries( {
|
|
246
|
+
'afd1cb17-2c08-4e7a-91be-007ba7ddc3a1': '',
|
|
247
|
+
} )
|
|
248
|
+
),
|
|
238
249
|
},
|
|
239
250
|
};
|
|
240
251
|
|
|
@@ -251,54 +262,68 @@ describe( 'selectors', () => {
|
|
|
251
262
|
it( 'should return the block', () => {
|
|
252
263
|
const state = {
|
|
253
264
|
blocks: {
|
|
254
|
-
byClientId:
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
}
|
|
274
|
-
|
|
265
|
+
byClientId: new Map(
|
|
266
|
+
Object.entries( {
|
|
267
|
+
123: { clientId: '123', name: 'core/paragraph' },
|
|
268
|
+
} )
|
|
269
|
+
),
|
|
270
|
+
attributes: new Map(
|
|
271
|
+
Object.entries( {
|
|
272
|
+
123: {},
|
|
273
|
+
} )
|
|
274
|
+
),
|
|
275
|
+
order: new Map(
|
|
276
|
+
Object.entries( {
|
|
277
|
+
'': [ '123' ],
|
|
278
|
+
123: [],
|
|
279
|
+
} )
|
|
280
|
+
),
|
|
281
|
+
parents: new Map(
|
|
282
|
+
Object.entries( {
|
|
283
|
+
123: '',
|
|
284
|
+
} )
|
|
285
|
+
),
|
|
286
|
+
tree: new Map(
|
|
287
|
+
Object.entries( {
|
|
288
|
+
123: {
|
|
289
|
+
clientId: '123',
|
|
290
|
+
name: 'core/paragraph',
|
|
291
|
+
attributes: {},
|
|
292
|
+
innerBlocks: [],
|
|
293
|
+
},
|
|
294
|
+
} )
|
|
295
|
+
),
|
|
275
296
|
controlledInnerBlocks: {},
|
|
276
297
|
},
|
|
277
298
|
};
|
|
278
299
|
|
|
279
|
-
expect( getBlock( state, 123 ) ).toBe(
|
|
300
|
+
expect( getBlock( state, '123' ) ).toBe(
|
|
301
|
+
state.blocks.tree.get( '123' )
|
|
302
|
+
);
|
|
280
303
|
} );
|
|
281
304
|
|
|
282
305
|
it( 'should return null if the block is not present in state', () => {
|
|
283
306
|
const state = {
|
|
284
307
|
blocks: {
|
|
285
|
-
byClientId:
|
|
286
|
-
attributes:
|
|
287
|
-
order:
|
|
288
|
-
parents:
|
|
289
|
-
tree:
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
308
|
+
byClientId: new Map(),
|
|
309
|
+
attributes: new Map(),
|
|
310
|
+
order: new Map(),
|
|
311
|
+
parents: new Map(),
|
|
312
|
+
tree: new Map(
|
|
313
|
+
Object.entries( {
|
|
314
|
+
123: {
|
|
315
|
+
clientId: '123',
|
|
316
|
+
name: 'core/paragraph',
|
|
317
|
+
attributes: {},
|
|
318
|
+
innerBlocks: [],
|
|
319
|
+
},
|
|
320
|
+
} )
|
|
321
|
+
),
|
|
297
322
|
controlledInnerBlocks: {},
|
|
298
323
|
},
|
|
299
324
|
};
|
|
300
325
|
|
|
301
|
-
expect( getBlock( state, 123 ) ).toBe( null );
|
|
326
|
+
expect( getBlock( state, '123' ) ).toBe( null );
|
|
302
327
|
} );
|
|
303
328
|
} );
|
|
304
329
|
|
|
@@ -306,47 +331,57 @@ describe( 'selectors', () => {
|
|
|
306
331
|
it( 'should return the ordered blocks', () => {
|
|
307
332
|
const state = {
|
|
308
333
|
blocks: {
|
|
309
|
-
byClientId:
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
334
|
+
byClientId: new Map(
|
|
335
|
+
Object.entries( {
|
|
336
|
+
23: { clientId: '23', name: 'core/heading' },
|
|
337
|
+
123: { clientId: '123', name: 'core/paragraph' },
|
|
338
|
+
} )
|
|
339
|
+
),
|
|
340
|
+
attributes: new Map(
|
|
341
|
+
Object.entries( {
|
|
342
|
+
23: {},
|
|
343
|
+
123: {},
|
|
344
|
+
} )
|
|
345
|
+
),
|
|
346
|
+
order: new Map(
|
|
347
|
+
Object.entries( {
|
|
348
|
+
'': [ '123', '23' ],
|
|
349
|
+
} )
|
|
350
|
+
),
|
|
351
|
+
parents: new Map(
|
|
352
|
+
Object.entries( {
|
|
353
|
+
123: '',
|
|
354
|
+
23: '',
|
|
355
|
+
} )
|
|
356
|
+
),
|
|
357
|
+
tree: new Map(
|
|
358
|
+
Object.entries( {
|
|
359
|
+
'': {
|
|
360
|
+
innerBlocks: [
|
|
361
|
+
{
|
|
362
|
+
clientId: '123',
|
|
363
|
+
name: 'core/paragraph',
|
|
364
|
+
attributes: {},
|
|
365
|
+
innerBlocks: [],
|
|
366
|
+
},
|
|
367
|
+
{
|
|
368
|
+
clientId: '23',
|
|
369
|
+
name: 'core/heading',
|
|
370
|
+
attributes: {},
|
|
371
|
+
innerBlocks: [],
|
|
372
|
+
},
|
|
373
|
+
],
|
|
374
|
+
},
|
|
375
|
+
123: {},
|
|
376
|
+
23: {},
|
|
377
|
+
} )
|
|
378
|
+
),
|
|
344
379
|
controlledInnerBlocks: {},
|
|
345
380
|
},
|
|
346
381
|
};
|
|
347
382
|
|
|
348
383
|
expect( getBlocks( state ) ).toBe(
|
|
349
|
-
state.blocks.tree
|
|
384
|
+
state.blocks.tree.get( '' ).innerBlocks
|
|
350
385
|
);
|
|
351
386
|
} );
|
|
352
387
|
} );
|
|
@@ -355,30 +390,34 @@ describe( 'selectors', () => {
|
|
|
355
390
|
it( 'should return parent blocks', () => {
|
|
356
391
|
const state = {
|
|
357
392
|
blocks: {
|
|
358
|
-
parents:
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
393
|
+
parents: new Map(
|
|
394
|
+
Object.entries( {
|
|
395
|
+
'client-id-01': '',
|
|
396
|
+
'client-id-02': 'client-id-01',
|
|
397
|
+
'client-id-03': 'client-id-02',
|
|
398
|
+
'client-id-04': 'client-id-03',
|
|
399
|
+
} )
|
|
400
|
+
),
|
|
401
|
+
byClientId: new Map(
|
|
402
|
+
Object.entries( {
|
|
403
|
+
'client-id-01': {
|
|
404
|
+
clientId: 'client-id-01',
|
|
405
|
+
name: 'core/columns',
|
|
406
|
+
},
|
|
407
|
+
'client-id-02': {
|
|
408
|
+
clientId: 'client-id-02',
|
|
409
|
+
name: 'core/navigation',
|
|
410
|
+
},
|
|
411
|
+
'client-id-03': {
|
|
412
|
+
clientId: 'client-id-03',
|
|
413
|
+
name: 'core/navigation-link',
|
|
414
|
+
},
|
|
415
|
+
'client-id-04': {
|
|
416
|
+
clientId: 'client-id-04',
|
|
417
|
+
name: 'core/paragraph',
|
|
418
|
+
},
|
|
419
|
+
} )
|
|
420
|
+
),
|
|
382
421
|
cache: {
|
|
383
422
|
'client-id-01': {},
|
|
384
423
|
'client-id-02': {},
|
|
@@ -402,35 +441,39 @@ describe( 'selectors', () => {
|
|
|
402
441
|
describe( 'getBlockParentsByBlockName', () => {
|
|
403
442
|
const state = {
|
|
404
443
|
blocks: {
|
|
405
|
-
parents:
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
444
|
+
parents: new Map(
|
|
445
|
+
Object.entries( {
|
|
446
|
+
'client-id-01': '',
|
|
447
|
+
'client-id-02': 'client-id-01',
|
|
448
|
+
'client-id-03': 'client-id-02',
|
|
449
|
+
'client-id-04': 'client-id-03',
|
|
450
|
+
'client-id-05': 'client-id-04',
|
|
451
|
+
} )
|
|
452
|
+
),
|
|
453
|
+
byClientId: new Map(
|
|
454
|
+
Object.entries( {
|
|
455
|
+
'client-id-01': {
|
|
456
|
+
clientId: 'client-id-01',
|
|
457
|
+
name: 'core/navigation',
|
|
458
|
+
},
|
|
459
|
+
'client-id-02': {
|
|
460
|
+
clientId: 'client-id-02',
|
|
461
|
+
name: 'core/columns',
|
|
462
|
+
},
|
|
463
|
+
'client-id-03': {
|
|
464
|
+
clientId: 'client-id-03',
|
|
465
|
+
name: 'core/navigation',
|
|
466
|
+
},
|
|
467
|
+
'client-id-04': {
|
|
468
|
+
clientId: 'client-id-04',
|
|
469
|
+
name: 'core/navigation-link',
|
|
470
|
+
},
|
|
471
|
+
'client-id-05': {
|
|
472
|
+
clientId: 'client-id-05',
|
|
473
|
+
name: 'core/navigation-link',
|
|
474
|
+
},
|
|
475
|
+
} )
|
|
476
|
+
),
|
|
434
477
|
cache: {
|
|
435
478
|
'client-id-01': {},
|
|
436
479
|
'client-id-02': {},
|
|
@@ -486,89 +529,124 @@ describe( 'selectors', () => {
|
|
|
486
529
|
it( 'should return the ids of any descendants in sequential order, given an array of clientIds', () => {
|
|
487
530
|
const state = {
|
|
488
531
|
blocks: {
|
|
489
|
-
byClientId:
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
|
|
564
|
-
|
|
565
|
-
|
|
566
|
-
|
|
567
|
-
|
|
568
|
-
|
|
569
|
-
|
|
570
|
-
|
|
571
|
-
|
|
532
|
+
byClientId: new Map(
|
|
533
|
+
Object.entries( {
|
|
534
|
+
'uuid-2': {
|
|
535
|
+
clientId: 'uuid-2',
|
|
536
|
+
name: 'core/image',
|
|
537
|
+
},
|
|
538
|
+
'uuid-4': {
|
|
539
|
+
clientId: 'uuid-4',
|
|
540
|
+
name: 'core/paragraph',
|
|
541
|
+
},
|
|
542
|
+
'uuid-6': {
|
|
543
|
+
clientId: 'uuid-6',
|
|
544
|
+
name: 'core/paragraph',
|
|
545
|
+
},
|
|
546
|
+
'uuid-8': {
|
|
547
|
+
clientId: 'uuid-8',
|
|
548
|
+
name: 'core/block',
|
|
549
|
+
},
|
|
550
|
+
'uuid-10': {
|
|
551
|
+
clientId: 'uuid-10',
|
|
552
|
+
name: 'core/columns',
|
|
553
|
+
},
|
|
554
|
+
'uuid-12': {
|
|
555
|
+
clientId: 'uuid-12',
|
|
556
|
+
name: 'core/column',
|
|
557
|
+
},
|
|
558
|
+
'uuid-14': {
|
|
559
|
+
clientId: 'uuid-14',
|
|
560
|
+
name: 'core/column',
|
|
561
|
+
},
|
|
562
|
+
'uuid-16': {
|
|
563
|
+
clientId: 'uuid-16',
|
|
564
|
+
name: 'core/quote',
|
|
565
|
+
},
|
|
566
|
+
'uuid-18': {
|
|
567
|
+
clientId: 'uuid-18',
|
|
568
|
+
name: 'core/block',
|
|
569
|
+
},
|
|
570
|
+
'uuid-20': {
|
|
571
|
+
clientId: 'uuid-20',
|
|
572
|
+
name: 'core/gallery',
|
|
573
|
+
},
|
|
574
|
+
'uuid-22': {
|
|
575
|
+
clientId: 'uuid-22',
|
|
576
|
+
name: 'core/block',
|
|
577
|
+
},
|
|
578
|
+
'uuid-24': {
|
|
579
|
+
clientId: 'uuid-24',
|
|
580
|
+
name: 'core/columns',
|
|
581
|
+
},
|
|
582
|
+
'uuid-26': {
|
|
583
|
+
clientId: 'uuid-26',
|
|
584
|
+
name: 'core/column',
|
|
585
|
+
},
|
|
586
|
+
'uuid-28': {
|
|
587
|
+
clientId: 'uuid-28',
|
|
588
|
+
name: 'core/column',
|
|
589
|
+
},
|
|
590
|
+
'uuid-30': {
|
|
591
|
+
clientId: 'uuid-30',
|
|
592
|
+
name: 'core/paragraph',
|
|
593
|
+
},
|
|
594
|
+
} )
|
|
595
|
+
),
|
|
596
|
+
attributes: new Map(
|
|
597
|
+
Object.entries( {
|
|
598
|
+
'uuid-2': {},
|
|
599
|
+
'uuid-4': {},
|
|
600
|
+
'uuid-6': {},
|
|
601
|
+
'uuid-8': {},
|
|
602
|
+
'uuid-10': {},
|
|
603
|
+
'uuid-12': {},
|
|
604
|
+
'uuid-14': {},
|
|
605
|
+
'uuid-16': {},
|
|
606
|
+
'uuid-18': {},
|
|
607
|
+
'uuid-20': {},
|
|
608
|
+
'uuid-22': {},
|
|
609
|
+
'uuid-24': {},
|
|
610
|
+
'uuid-26': {},
|
|
611
|
+
'uuid-28': {},
|
|
612
|
+
'uuid-30': {},
|
|
613
|
+
} )
|
|
614
|
+
),
|
|
615
|
+
order: new Map(
|
|
616
|
+
Object.entries( {
|
|
617
|
+
'': [ 'uuid-6', 'uuid-8', 'uuid-10', 'uuid-22' ],
|
|
618
|
+
'uuid-2': [],
|
|
619
|
+
'uuid-4': [],
|
|
620
|
+
'uuid-6': [],
|
|
621
|
+
'uuid-8': [],
|
|
622
|
+
'uuid-10': [ 'uuid-12', 'uuid-14' ],
|
|
623
|
+
'uuid-12': [ 'uuid-16' ],
|
|
624
|
+
'uuid-14': [ 'uuid-18' ],
|
|
625
|
+
'uuid-16': [],
|
|
626
|
+
'uuid-18': [ 'uuid-24' ],
|
|
627
|
+
'uuid-20': [],
|
|
628
|
+
'uuid-22': [],
|
|
629
|
+
'uuid-24': [ 'uuid-26', 'uuid-28' ],
|
|
630
|
+
'uuid-26': [],
|
|
631
|
+
'uuid-28': [ 'uuid-30' ],
|
|
632
|
+
} )
|
|
633
|
+
),
|
|
634
|
+
parents: new Map(
|
|
635
|
+
Object.entries( {
|
|
636
|
+
'uuid-6': '',
|
|
637
|
+
'uuid-8': '',
|
|
638
|
+
'uuid-10': '',
|
|
639
|
+
'uuid-22': '',
|
|
640
|
+
'uuid-12': 'uuid-10',
|
|
641
|
+
'uuid-14': 'uuid-10',
|
|
642
|
+
'uuid-16': 'uuid-12',
|
|
643
|
+
'uuid-18': 'uuid-14',
|
|
644
|
+
'uuid-24': 'uuid-18',
|
|
645
|
+
'uuid-26': 'uuid-24',
|
|
646
|
+
'uuid-28': 'uuid-24',
|
|
647
|
+
'uuid-30': 'uuid-28',
|
|
648
|
+
} )
|
|
649
|
+
),
|
|
572
650
|
controlledInnerBlocks: {},
|
|
573
651
|
},
|
|
574
652
|
};
|
|
@@ -591,89 +669,124 @@ describe( 'selectors', () => {
|
|
|
591
669
|
it( 'should return the ids for top-level blocks and their descendants of any depth (for nested blocks) in sequential order.', () => {
|
|
592
670
|
const state = {
|
|
593
671
|
blocks: {
|
|
594
|
-
byClientId:
|
|
595
|
-
|
|
596
|
-
|
|
597
|
-
|
|
598
|
-
|
|
599
|
-
|
|
600
|
-
|
|
601
|
-
|
|
602
|
-
|
|
603
|
-
|
|
604
|
-
|
|
605
|
-
|
|
606
|
-
|
|
607
|
-
|
|
608
|
-
|
|
609
|
-
|
|
610
|
-
|
|
611
|
-
|
|
612
|
-
|
|
613
|
-
|
|
614
|
-
|
|
615
|
-
|
|
616
|
-
|
|
617
|
-
|
|
618
|
-
|
|
619
|
-
|
|
620
|
-
|
|
621
|
-
|
|
622
|
-
|
|
623
|
-
|
|
624
|
-
|
|
625
|
-
|
|
626
|
-
|
|
627
|
-
|
|
628
|
-
|
|
629
|
-
|
|
630
|
-
|
|
631
|
-
|
|
632
|
-
|
|
633
|
-
|
|
634
|
-
|
|
635
|
-
|
|
636
|
-
|
|
637
|
-
|
|
638
|
-
|
|
639
|
-
|
|
640
|
-
|
|
641
|
-
|
|
642
|
-
|
|
643
|
-
|
|
644
|
-
|
|
645
|
-
|
|
646
|
-
|
|
647
|
-
|
|
648
|
-
|
|
649
|
-
|
|
650
|
-
|
|
651
|
-
|
|
652
|
-
|
|
653
|
-
|
|
654
|
-
|
|
655
|
-
|
|
656
|
-
|
|
657
|
-
|
|
658
|
-
|
|
659
|
-
|
|
660
|
-
|
|
661
|
-
|
|
662
|
-
|
|
663
|
-
|
|
664
|
-
|
|
665
|
-
|
|
666
|
-
|
|
667
|
-
|
|
668
|
-
|
|
669
|
-
|
|
670
|
-
|
|
671
|
-
|
|
672
|
-
|
|
673
|
-
|
|
674
|
-
|
|
675
|
-
|
|
676
|
-
|
|
672
|
+
byClientId: new Map(
|
|
673
|
+
Object.entries( {
|
|
674
|
+
'uuid-2': {
|
|
675
|
+
clientId: 'uuid-2',
|
|
676
|
+
name: 'core/image',
|
|
677
|
+
},
|
|
678
|
+
'uuid-4': {
|
|
679
|
+
clientId: 'uuid-4',
|
|
680
|
+
name: 'core/paragraph',
|
|
681
|
+
},
|
|
682
|
+
'uuid-6': {
|
|
683
|
+
clientId: 'uuid-6',
|
|
684
|
+
name: 'core/paragraph',
|
|
685
|
+
},
|
|
686
|
+
'uuid-8': {
|
|
687
|
+
clientId: 'uuid-8',
|
|
688
|
+
name: 'core/block',
|
|
689
|
+
},
|
|
690
|
+
'uuid-10': {
|
|
691
|
+
clientId: 'uuid-10',
|
|
692
|
+
name: 'core/columns',
|
|
693
|
+
},
|
|
694
|
+
'uuid-12': {
|
|
695
|
+
clientId: 'uuid-12',
|
|
696
|
+
name: 'core/column',
|
|
697
|
+
},
|
|
698
|
+
'uuid-14': {
|
|
699
|
+
clientId: 'uuid-14',
|
|
700
|
+
name: 'core/column',
|
|
701
|
+
},
|
|
702
|
+
'uuid-16': {
|
|
703
|
+
clientId: 'uuid-16',
|
|
704
|
+
name: 'core/quote',
|
|
705
|
+
},
|
|
706
|
+
'uuid-18': {
|
|
707
|
+
clientId: 'uuid-18',
|
|
708
|
+
name: 'core/block',
|
|
709
|
+
},
|
|
710
|
+
'uuid-20': {
|
|
711
|
+
clientId: 'uuid-20',
|
|
712
|
+
name: 'core/gallery',
|
|
713
|
+
},
|
|
714
|
+
'uuid-22': {
|
|
715
|
+
clientId: 'uuid-22',
|
|
716
|
+
name: 'core/block',
|
|
717
|
+
},
|
|
718
|
+
'uuid-24': {
|
|
719
|
+
clientId: 'uuid-24',
|
|
720
|
+
name: 'core/columns',
|
|
721
|
+
},
|
|
722
|
+
'uuid-26': {
|
|
723
|
+
clientId: 'uuid-26',
|
|
724
|
+
name: 'core/column',
|
|
725
|
+
},
|
|
726
|
+
'uuid-28': {
|
|
727
|
+
clientId: 'uuid-28',
|
|
728
|
+
name: 'core/column',
|
|
729
|
+
},
|
|
730
|
+
'uuid-30': {
|
|
731
|
+
clientId: 'uuid-30',
|
|
732
|
+
name: 'core/paragraph',
|
|
733
|
+
},
|
|
734
|
+
} )
|
|
735
|
+
),
|
|
736
|
+
attributes: new Map(
|
|
737
|
+
Object.entries( {
|
|
738
|
+
'uuid-2': {},
|
|
739
|
+
'uuid-4': {},
|
|
740
|
+
'uuid-6': {},
|
|
741
|
+
'uuid-8': {},
|
|
742
|
+
'uuid-10': {},
|
|
743
|
+
'uuid-12': {},
|
|
744
|
+
'uuid-14': {},
|
|
745
|
+
'uuid-16': {},
|
|
746
|
+
'uuid-18': {},
|
|
747
|
+
'uuid-20': {},
|
|
748
|
+
'uuid-22': {},
|
|
749
|
+
'uuid-24': {},
|
|
750
|
+
'uuid-26': {},
|
|
751
|
+
'uuid-28': {},
|
|
752
|
+
'uuid-30': {},
|
|
753
|
+
} )
|
|
754
|
+
),
|
|
755
|
+
order: new Map(
|
|
756
|
+
Object.entries( {
|
|
757
|
+
'': [ 'uuid-6', 'uuid-8', 'uuid-10', 'uuid-22' ],
|
|
758
|
+
'uuid-2': [],
|
|
759
|
+
'uuid-4': [],
|
|
760
|
+
'uuid-6': [],
|
|
761
|
+
'uuid-8': [],
|
|
762
|
+
'uuid-10': [ 'uuid-12', 'uuid-14' ],
|
|
763
|
+
'uuid-12': [ 'uuid-16' ],
|
|
764
|
+
'uuid-14': [ 'uuid-18' ],
|
|
765
|
+
'uuid-16': [],
|
|
766
|
+
'uuid-18': [ 'uuid-24' ],
|
|
767
|
+
'uuid-20': [],
|
|
768
|
+
'uuid-22': [],
|
|
769
|
+
'uuid-24': [ 'uuid-26', 'uuid-28' ],
|
|
770
|
+
'uuid-26': [],
|
|
771
|
+
'uuid-28': [ 'uuid-30' ],
|
|
772
|
+
} )
|
|
773
|
+
),
|
|
774
|
+
parents: new Map(
|
|
775
|
+
Object.entries( {
|
|
776
|
+
'uuid-6': '',
|
|
777
|
+
'uuid-8': '',
|
|
778
|
+
'uuid-10': '',
|
|
779
|
+
'uuid-22': '',
|
|
780
|
+
'uuid-12': 'uuid-10',
|
|
781
|
+
'uuid-14': 'uuid-10',
|
|
782
|
+
'uuid-16': 'uuid-12',
|
|
783
|
+
'uuid-18': 'uuid-14',
|
|
784
|
+
'uuid-24': 'uuid-18',
|
|
785
|
+
'uuid-26': 'uuid-24',
|
|
786
|
+
'uuid-28': 'uuid-24',
|
|
787
|
+
'uuid-30': 'uuid-28',
|
|
788
|
+
} )
|
|
789
|
+
),
|
|
677
790
|
},
|
|
678
791
|
};
|
|
679
792
|
expect( getClientIdsWithDescendants( state ) ).toEqual( [
|
|
@@ -697,17 +810,23 @@ describe( 'selectors', () => {
|
|
|
697
810
|
it( 'should return the number of top-level blocks in the post', () => {
|
|
698
811
|
const state = {
|
|
699
812
|
blocks: {
|
|
700
|
-
byClientId:
|
|
701
|
-
|
|
702
|
-
|
|
703
|
-
|
|
704
|
-
|
|
705
|
-
|
|
706
|
-
|
|
707
|
-
|
|
708
|
-
|
|
709
|
-
|
|
710
|
-
|
|
813
|
+
byClientId: new Map(
|
|
814
|
+
Object.entries( {
|
|
815
|
+
23: { clientId: '23', name: 'core/heading' },
|
|
816
|
+
123: { clientId: '123', name: 'core/paragraph' },
|
|
817
|
+
} )
|
|
818
|
+
),
|
|
819
|
+
attributes: new Map(
|
|
820
|
+
Object.entries( {
|
|
821
|
+
23: {},
|
|
822
|
+
123: {},
|
|
823
|
+
} )
|
|
824
|
+
),
|
|
825
|
+
order: new Map(
|
|
826
|
+
Object.entries( {
|
|
827
|
+
'': [ '123', '23' ],
|
|
828
|
+
} )
|
|
829
|
+
),
|
|
711
830
|
},
|
|
712
831
|
};
|
|
713
832
|
|
|
@@ -717,25 +836,33 @@ describe( 'selectors', () => {
|
|
|
717
836
|
it( 'should return the number of blocks in a nested context', () => {
|
|
718
837
|
const state = {
|
|
719
838
|
blocks: {
|
|
720
|
-
byClientId:
|
|
721
|
-
|
|
722
|
-
|
|
723
|
-
|
|
724
|
-
|
|
725
|
-
|
|
726
|
-
|
|
727
|
-
|
|
728
|
-
|
|
729
|
-
|
|
730
|
-
|
|
731
|
-
|
|
732
|
-
|
|
733
|
-
|
|
734
|
-
|
|
735
|
-
|
|
736
|
-
|
|
737
|
-
|
|
738
|
-
|
|
839
|
+
byClientId: new Map(
|
|
840
|
+
Object.entries( {
|
|
841
|
+
123: { clientId: '123', name: 'core/columns' },
|
|
842
|
+
456: { clientId: '456', name: 'core/paragraph' },
|
|
843
|
+
789: { clientId: '789', name: 'core/paragraph' },
|
|
844
|
+
} )
|
|
845
|
+
),
|
|
846
|
+
attributes: new Map(
|
|
847
|
+
Object.entries( {
|
|
848
|
+
123: {},
|
|
849
|
+
456: {},
|
|
850
|
+
789: {},
|
|
851
|
+
} )
|
|
852
|
+
),
|
|
853
|
+
order: new Map(
|
|
854
|
+
Object.entries( {
|
|
855
|
+
'': [ '123' ],
|
|
856
|
+
123: [ '456', '789' ],
|
|
857
|
+
} )
|
|
858
|
+
),
|
|
859
|
+
parents: new Map(
|
|
860
|
+
Object.entries( {
|
|
861
|
+
123: '',
|
|
862
|
+
456: '123',
|
|
863
|
+
789: '123',
|
|
864
|
+
} )
|
|
865
|
+
),
|
|
739
866
|
},
|
|
740
867
|
};
|
|
741
868
|
|
|
@@ -789,23 +916,31 @@ describe( 'selectors', () => {
|
|
|
789
916
|
describe( 'getGlobalBlockCount', () => {
|
|
790
917
|
const state = {
|
|
791
918
|
blocks: {
|
|
792
|
-
byClientId:
|
|
793
|
-
|
|
794
|
-
|
|
795
|
-
|
|
796
|
-
|
|
797
|
-
|
|
798
|
-
|
|
799
|
-
|
|
800
|
-
|
|
801
|
-
|
|
802
|
-
|
|
803
|
-
|
|
804
|
-
|
|
805
|
-
|
|
806
|
-
|
|
807
|
-
|
|
808
|
-
|
|
919
|
+
byClientId: new Map(
|
|
920
|
+
Object.entries( {
|
|
921
|
+
123: { clientId: '123', name: 'core/heading' },
|
|
922
|
+
456: { clientId: '456', name: 'core/paragraph' },
|
|
923
|
+
789: { clientId: '789', name: 'core/paragraph' },
|
|
924
|
+
} )
|
|
925
|
+
),
|
|
926
|
+
attributes: new Map(
|
|
927
|
+
Object.entries( {
|
|
928
|
+
123: {},
|
|
929
|
+
456: {},
|
|
930
|
+
789: {},
|
|
931
|
+
} )
|
|
932
|
+
),
|
|
933
|
+
order: new Map(
|
|
934
|
+
Object.entries( {
|
|
935
|
+
'': [ '123', '456' ],
|
|
936
|
+
} )
|
|
937
|
+
),
|
|
938
|
+
parents: new Map(
|
|
939
|
+
Object.entries( {
|
|
940
|
+
123: '',
|
|
941
|
+
456: '',
|
|
942
|
+
} )
|
|
943
|
+
),
|
|
809
944
|
},
|
|
810
945
|
};
|
|
811
946
|
|
|
@@ -820,10 +955,10 @@ describe( 'selectors', () => {
|
|
|
820
955
|
it( 'should return 0 if no blocks exist', () => {
|
|
821
956
|
const emptyState = {
|
|
822
957
|
blocks: {
|
|
823
|
-
byClientId:
|
|
824
|
-
attributes:
|
|
825
|
-
order:
|
|
826
|
-
parents:
|
|
958
|
+
byClientId: new Map(),
|
|
959
|
+
attributes: new Map(),
|
|
960
|
+
order: new Map(),
|
|
961
|
+
parents: new Map(),
|
|
827
962
|
},
|
|
828
963
|
};
|
|
829
964
|
expect( getGlobalBlockCount( emptyState ) ).toBe( 0 );
|
|
@@ -836,46 +971,54 @@ describe( 'selectors', () => {
|
|
|
836
971
|
describe( '__experimentalGetGlobalBlocksByName', () => {
|
|
837
972
|
const state = {
|
|
838
973
|
blocks: {
|
|
839
|
-
byClientId:
|
|
840
|
-
|
|
841
|
-
|
|
842
|
-
|
|
843
|
-
|
|
844
|
-
|
|
845
|
-
|
|
846
|
-
|
|
847
|
-
|
|
848
|
-
|
|
849
|
-
|
|
850
|
-
|
|
851
|
-
|
|
852
|
-
|
|
853
|
-
|
|
854
|
-
|
|
855
|
-
|
|
856
|
-
|
|
857
|
-
|
|
858
|
-
|
|
859
|
-
|
|
860
|
-
|
|
861
|
-
|
|
862
|
-
|
|
863
|
-
|
|
864
|
-
|
|
865
|
-
|
|
974
|
+
byClientId: new Map(
|
|
975
|
+
Object.entries( {
|
|
976
|
+
123: { clientId: '123', name: 'core/heading' },
|
|
977
|
+
456: { clientId: '456', name: 'core/paragraph' },
|
|
978
|
+
789: { clientId: '789', name: 'core/paragraph' },
|
|
979
|
+
1011: { clientId: '1011', name: 'core/group' },
|
|
980
|
+
1213: { clientId: '1213', name: 'core/paragraph' },
|
|
981
|
+
1415: { clientId: '1213', name: 'core/paragraph' },
|
|
982
|
+
} )
|
|
983
|
+
),
|
|
984
|
+
attributes: new Map(
|
|
985
|
+
Object.entries( {
|
|
986
|
+
123: {},
|
|
987
|
+
456: {},
|
|
988
|
+
789: {},
|
|
989
|
+
1011: {},
|
|
990
|
+
1213: {},
|
|
991
|
+
1415: {},
|
|
992
|
+
} )
|
|
993
|
+
),
|
|
994
|
+
order: new Map(
|
|
995
|
+
Object.entries( {
|
|
996
|
+
'': [ '123', '456', '1011' ],
|
|
997
|
+
1011: [ '1415', '1213' ],
|
|
998
|
+
} )
|
|
999
|
+
),
|
|
1000
|
+
parents: new Map(
|
|
1001
|
+
Object.entries( {
|
|
1002
|
+
123: '',
|
|
1003
|
+
456: '',
|
|
1004
|
+
1011: '',
|
|
1005
|
+
1213: '1011',
|
|
1006
|
+
1415: '1011',
|
|
1007
|
+
} )
|
|
1008
|
+
),
|
|
866
1009
|
},
|
|
867
1010
|
};
|
|
868
1011
|
|
|
869
1012
|
it( 'should return the clientIds of blocks of a given type', () => {
|
|
870
1013
|
expect(
|
|
871
1014
|
__experimentalGetGlobalBlocksByName( state, 'core/heading' )
|
|
872
|
-
).toStrictEqual( [ 123 ] );
|
|
1015
|
+
).toStrictEqual( [ '123' ] );
|
|
873
1016
|
} );
|
|
874
1017
|
|
|
875
1018
|
it( 'should return the clientIds of blocks of a given type even if blocks are nested', () => {
|
|
876
1019
|
expect(
|
|
877
1020
|
__experimentalGetGlobalBlocksByName( state, 'core/paragraph' )
|
|
878
|
-
).toStrictEqual( [ 456, 1415, 1213 ] );
|
|
1021
|
+
).toStrictEqual( [ '456', '1415', '1213' ] );
|
|
879
1022
|
} );
|
|
880
1023
|
|
|
881
1024
|
it( 'Should return empty array if no blocks match. The empty array should be the same reference', () => {
|
|
@@ -910,8 +1053,8 @@ describe( 'selectors', () => {
|
|
|
910
1053
|
it( 'should return null if there is multi selection', () => {
|
|
911
1054
|
const state = {
|
|
912
1055
|
selection: {
|
|
913
|
-
selectionStart: { clientId: 23 },
|
|
914
|
-
selectionEnd: { clientId: 123 },
|
|
1056
|
+
selectionStart: { clientId: '23' },
|
|
1057
|
+
selectionEnd: { clientId: '123' },
|
|
915
1058
|
},
|
|
916
1059
|
};
|
|
917
1060
|
|
|
@@ -921,19 +1064,21 @@ describe( 'selectors', () => {
|
|
|
921
1064
|
it( 'should return the selected block ClientId', () => {
|
|
922
1065
|
const state = {
|
|
923
1066
|
blocks: {
|
|
924
|
-
byClientId:
|
|
925
|
-
|
|
926
|
-
|
|
927
|
-
|
|
928
|
-
|
|
1067
|
+
byClientId: new Map(
|
|
1068
|
+
Object.entries( {
|
|
1069
|
+
23: {
|
|
1070
|
+
name: 'fake block',
|
|
1071
|
+
},
|
|
1072
|
+
} )
|
|
1073
|
+
),
|
|
929
1074
|
},
|
|
930
1075
|
selection: {
|
|
931
|
-
selectionStart: { clientId: 23 },
|
|
932
|
-
selectionEnd: { clientId: 23 },
|
|
1076
|
+
selectionStart: { clientId: '23' },
|
|
1077
|
+
selectionEnd: { clientId: '23' },
|
|
933
1078
|
},
|
|
934
1079
|
};
|
|
935
1080
|
|
|
936
|
-
expect( getSelectedBlockClientId( state ) ).toEqual( 23 );
|
|
1081
|
+
expect( getSelectedBlockClientId( state ) ).toEqual( '23' );
|
|
937
1082
|
} );
|
|
938
1083
|
} );
|
|
939
1084
|
|
|
@@ -941,31 +1086,41 @@ describe( 'selectors', () => {
|
|
|
941
1086
|
it( 'should return null if no block is selected', () => {
|
|
942
1087
|
const state = {
|
|
943
1088
|
blocks: {
|
|
944
|
-
byClientId:
|
|
945
|
-
|
|
946
|
-
|
|
947
|
-
|
|
948
|
-
|
|
949
|
-
|
|
950
|
-
|
|
951
|
-
|
|
952
|
-
|
|
953
|
-
|
|
954
|
-
|
|
955
|
-
|
|
956
|
-
|
|
957
|
-
|
|
958
|
-
|
|
959
|
-
|
|
960
|
-
|
|
961
|
-
|
|
962
|
-
|
|
963
|
-
|
|
964
|
-
|
|
965
|
-
|
|
966
|
-
|
|
967
|
-
}
|
|
968
|
-
|
|
1089
|
+
byClientId: new Map(
|
|
1090
|
+
Object.entries( {
|
|
1091
|
+
23: { clientId: '23', name: 'core/heading' },
|
|
1092
|
+
123: { clientId: '123', name: 'core/paragraph' },
|
|
1093
|
+
} )
|
|
1094
|
+
),
|
|
1095
|
+
attributes: new Map(
|
|
1096
|
+
Object.entries( {
|
|
1097
|
+
23: {},
|
|
1098
|
+
123: {},
|
|
1099
|
+
} )
|
|
1100
|
+
),
|
|
1101
|
+
order: new Map(
|
|
1102
|
+
Object.entries( {
|
|
1103
|
+
'': [ '23', '123' ],
|
|
1104
|
+
23: [],
|
|
1105
|
+
123: [],
|
|
1106
|
+
} )
|
|
1107
|
+
),
|
|
1108
|
+
parents: new Map(
|
|
1109
|
+
Object.entries( {
|
|
1110
|
+
23: '',
|
|
1111
|
+
123: '',
|
|
1112
|
+
} )
|
|
1113
|
+
),
|
|
1114
|
+
tree: new Map(
|
|
1115
|
+
Object.entries( {
|
|
1116
|
+
23: {
|
|
1117
|
+
clientId: '23',
|
|
1118
|
+
name: 'core/heading',
|
|
1119
|
+
attributes: {},
|
|
1120
|
+
innerBlocks: [],
|
|
1121
|
+
},
|
|
1122
|
+
} )
|
|
1123
|
+
),
|
|
969
1124
|
},
|
|
970
1125
|
selection: {
|
|
971
1126
|
selectionStart: {},
|
|
@@ -979,35 +1134,45 @@ describe( 'selectors', () => {
|
|
|
979
1134
|
it( 'should return null if there is multi selection', () => {
|
|
980
1135
|
const state = {
|
|
981
1136
|
blocks: {
|
|
982
|
-
byClientId:
|
|
983
|
-
|
|
984
|
-
|
|
985
|
-
|
|
986
|
-
|
|
987
|
-
|
|
988
|
-
|
|
989
|
-
|
|
990
|
-
|
|
991
|
-
|
|
992
|
-
|
|
993
|
-
|
|
994
|
-
|
|
995
|
-
|
|
996
|
-
|
|
997
|
-
|
|
998
|
-
|
|
999
|
-
|
|
1000
|
-
|
|
1001
|
-
|
|
1002
|
-
|
|
1003
|
-
|
|
1004
|
-
|
|
1005
|
-
}
|
|
1006
|
-
|
|
1137
|
+
byClientId: new Map(
|
|
1138
|
+
Object.entries( {
|
|
1139
|
+
23: { clientId: '23', name: 'core/heading' },
|
|
1140
|
+
123: { clientId: '123', name: 'core/paragraph' },
|
|
1141
|
+
} )
|
|
1142
|
+
),
|
|
1143
|
+
attributes: new Map(
|
|
1144
|
+
Object.entries( {
|
|
1145
|
+
23: {},
|
|
1146
|
+
123: {},
|
|
1147
|
+
} )
|
|
1148
|
+
),
|
|
1149
|
+
order: new Map(
|
|
1150
|
+
Object.entries( {
|
|
1151
|
+
'': [ '23', '123' ],
|
|
1152
|
+
23: [],
|
|
1153
|
+
123: [],
|
|
1154
|
+
} )
|
|
1155
|
+
),
|
|
1156
|
+
parents: new Map(
|
|
1157
|
+
Object.entries( {
|
|
1158
|
+
123: '',
|
|
1159
|
+
23: '',
|
|
1160
|
+
} )
|
|
1161
|
+
),
|
|
1162
|
+
tree: new Map(
|
|
1163
|
+
Object.entries( {
|
|
1164
|
+
23: {
|
|
1165
|
+
clientId: '23',
|
|
1166
|
+
name: 'core/heading',
|
|
1167
|
+
attributes: {},
|
|
1168
|
+
innerBlocks: [],
|
|
1169
|
+
},
|
|
1170
|
+
} )
|
|
1171
|
+
),
|
|
1007
1172
|
},
|
|
1008
1173
|
selection: {
|
|
1009
|
-
selectionStart: { clientId: 23 },
|
|
1010
|
-
selectionEnd: { clientId: 123 },
|
|
1174
|
+
selectionStart: { clientId: '23' },
|
|
1175
|
+
selectionEnd: { clientId: '123' },
|
|
1011
1176
|
},
|
|
1012
1177
|
};
|
|
1013
1178
|
|
|
@@ -1017,41 +1182,51 @@ describe( 'selectors', () => {
|
|
|
1017
1182
|
it( 'should return the selected block', () => {
|
|
1018
1183
|
const state = {
|
|
1019
1184
|
blocks: {
|
|
1020
|
-
byClientId:
|
|
1021
|
-
|
|
1022
|
-
|
|
1023
|
-
|
|
1024
|
-
|
|
1025
|
-
|
|
1026
|
-
|
|
1027
|
-
|
|
1028
|
-
|
|
1029
|
-
|
|
1030
|
-
|
|
1031
|
-
|
|
1032
|
-
|
|
1033
|
-
|
|
1034
|
-
|
|
1035
|
-
|
|
1036
|
-
|
|
1037
|
-
|
|
1038
|
-
|
|
1039
|
-
|
|
1040
|
-
|
|
1041
|
-
|
|
1042
|
-
|
|
1043
|
-
}
|
|
1044
|
-
|
|
1185
|
+
byClientId: new Map(
|
|
1186
|
+
Object.entries( {
|
|
1187
|
+
23: { clientId: '23', name: 'core/heading' },
|
|
1188
|
+
123: { clientId: '123', name: 'core/paragraph' },
|
|
1189
|
+
} )
|
|
1190
|
+
),
|
|
1191
|
+
attributes: new Map(
|
|
1192
|
+
Object.entries( {
|
|
1193
|
+
23: {},
|
|
1194
|
+
123: {},
|
|
1195
|
+
} )
|
|
1196
|
+
),
|
|
1197
|
+
order: new Map(
|
|
1198
|
+
Object.entries( {
|
|
1199
|
+
'': [ '23', '123' ],
|
|
1200
|
+
23: [],
|
|
1201
|
+
123: [],
|
|
1202
|
+
} )
|
|
1203
|
+
),
|
|
1204
|
+
parents: new Map(
|
|
1205
|
+
Object.entries( {
|
|
1206
|
+
123: '',
|
|
1207
|
+
23: '',
|
|
1208
|
+
} )
|
|
1209
|
+
),
|
|
1210
|
+
tree: new Map(
|
|
1211
|
+
Object.entries( {
|
|
1212
|
+
23: {
|
|
1213
|
+
clientId: '23',
|
|
1214
|
+
name: 'core/heading',
|
|
1215
|
+
attributes: {},
|
|
1216
|
+
innerBlocks: [],
|
|
1217
|
+
},
|
|
1218
|
+
} )
|
|
1219
|
+
),
|
|
1045
1220
|
controlledInnerBlocks: {},
|
|
1046
1221
|
},
|
|
1047
1222
|
selection: {
|
|
1048
|
-
selectionStart: { clientId: 23 },
|
|
1049
|
-
selectionEnd: { clientId: 23 },
|
|
1223
|
+
selectionStart: { clientId: '23' },
|
|
1224
|
+
selectionEnd: { clientId: '23' },
|
|
1050
1225
|
},
|
|
1051
1226
|
};
|
|
1052
1227
|
|
|
1053
1228
|
expect( getSelectedBlock( state ) ).toEqual(
|
|
1054
|
-
getBlock( state, 23 )
|
|
1229
|
+
getBlock( state, '23' )
|
|
1055
1230
|
);
|
|
1056
1231
|
} );
|
|
1057
1232
|
} );
|
|
@@ -1060,8 +1235,8 @@ describe( 'selectors', () => {
|
|
|
1060
1235
|
it( 'should return null if the block does not exist', () => {
|
|
1061
1236
|
const state = {
|
|
1062
1237
|
blocks: {
|
|
1063
|
-
order:
|
|
1064
|
-
parents:
|
|
1238
|
+
order: new Map(),
|
|
1239
|
+
parents: new Map(),
|
|
1065
1240
|
},
|
|
1066
1241
|
};
|
|
1067
1242
|
|
|
@@ -1071,20 +1246,24 @@ describe( 'selectors', () => {
|
|
|
1071
1246
|
it( 'should return root ClientId relative the block ClientId', () => {
|
|
1072
1247
|
const state = {
|
|
1073
1248
|
blocks: {
|
|
1074
|
-
order:
|
|
1075
|
-
|
|
1076
|
-
|
|
1077
|
-
|
|
1078
|
-
|
|
1079
|
-
|
|
1080
|
-
|
|
1081
|
-
|
|
1082
|
-
|
|
1083
|
-
|
|
1249
|
+
order: new Map(
|
|
1250
|
+
Object.entries( {
|
|
1251
|
+
'': [ '123', '23' ],
|
|
1252
|
+
123: [ '456', '56' ],
|
|
1253
|
+
} )
|
|
1254
|
+
),
|
|
1255
|
+
parents: new Map(
|
|
1256
|
+
Object.entries( {
|
|
1257
|
+
123: '',
|
|
1258
|
+
23: '',
|
|
1259
|
+
456: '123',
|
|
1260
|
+
56: '123',
|
|
1261
|
+
} )
|
|
1262
|
+
),
|
|
1084
1263
|
},
|
|
1085
1264
|
};
|
|
1086
1265
|
|
|
1087
|
-
expect( getBlockRootClientId( state, 56 ) ).toBe( 123 );
|
|
1266
|
+
expect( getBlockRootClientId( state, '56' ) ).toBe( '123' );
|
|
1088
1267
|
} );
|
|
1089
1268
|
} );
|
|
1090
1269
|
|
|
@@ -1092,8 +1271,8 @@ describe( 'selectors', () => {
|
|
|
1092
1271
|
it( 'should return the given block if the block has no parents', () => {
|
|
1093
1272
|
const state = {
|
|
1094
1273
|
blocks: {
|
|
1095
|
-
order:
|
|
1096
|
-
parents:
|
|
1274
|
+
order: new Map(),
|
|
1275
|
+
parents: new Map(),
|
|
1097
1276
|
},
|
|
1098
1277
|
};
|
|
1099
1278
|
|
|
@@ -1103,16 +1282,20 @@ describe( 'selectors', () => {
|
|
|
1103
1282
|
it( 'should return root ClientId relative the block ClientId', () => {
|
|
1104
1283
|
const state = {
|
|
1105
1284
|
blocks: {
|
|
1106
|
-
order:
|
|
1107
|
-
|
|
1108
|
-
|
|
1109
|
-
|
|
1110
|
-
|
|
1111
|
-
|
|
1112
|
-
|
|
1113
|
-
|
|
1114
|
-
|
|
1115
|
-
|
|
1285
|
+
order: new Map(
|
|
1286
|
+
Object.entries( {
|
|
1287
|
+
'': [ 'a', 'b' ],
|
|
1288
|
+
a: [ 'c', 'd' ],
|
|
1289
|
+
} )
|
|
1290
|
+
),
|
|
1291
|
+
parents: new Map(
|
|
1292
|
+
Object.entries( {
|
|
1293
|
+
a: '',
|
|
1294
|
+
b: '',
|
|
1295
|
+
c: 'a',
|
|
1296
|
+
d: 'a',
|
|
1297
|
+
} )
|
|
1298
|
+
),
|
|
1116
1299
|
},
|
|
1117
1300
|
};
|
|
1118
1301
|
|
|
@@ -1122,18 +1305,22 @@ describe( 'selectors', () => {
|
|
|
1122
1305
|
it( 'should return the top level root ClientId relative the block ClientId', () => {
|
|
1123
1306
|
const state = {
|
|
1124
1307
|
blocks: {
|
|
1125
|
-
order:
|
|
1126
|
-
|
|
1127
|
-
|
|
1128
|
-
|
|
1129
|
-
|
|
1130
|
-
|
|
1131
|
-
|
|
1132
|
-
|
|
1133
|
-
|
|
1134
|
-
|
|
1135
|
-
|
|
1136
|
-
|
|
1308
|
+
order: new Map(
|
|
1309
|
+
Object.entries( {
|
|
1310
|
+
'': [ 'a', 'b' ],
|
|
1311
|
+
a: [ 'c', 'd' ],
|
|
1312
|
+
d: [ 'e' ],
|
|
1313
|
+
} )
|
|
1314
|
+
),
|
|
1315
|
+
parents: new Map(
|
|
1316
|
+
Object.entries( {
|
|
1317
|
+
a: '',
|
|
1318
|
+
b: '',
|
|
1319
|
+
c: 'a',
|
|
1320
|
+
d: 'a',
|
|
1321
|
+
e: 'd',
|
|
1322
|
+
} )
|
|
1323
|
+
),
|
|
1137
1324
|
},
|
|
1138
1325
|
};
|
|
1139
1326
|
|
|
@@ -1145,13 +1332,17 @@ describe( 'selectors', () => {
|
|
|
1145
1332
|
it( 'should return empty if there is no selection', () => {
|
|
1146
1333
|
const state = {
|
|
1147
1334
|
blocks: {
|
|
1148
|
-
order:
|
|
1149
|
-
|
|
1150
|
-
|
|
1151
|
-
|
|
1152
|
-
|
|
1153
|
-
|
|
1154
|
-
|
|
1335
|
+
order: new Map(
|
|
1336
|
+
Object.entries( {
|
|
1337
|
+
'': [ '123', '23' ],
|
|
1338
|
+
} )
|
|
1339
|
+
),
|
|
1340
|
+
parents: new Map(
|
|
1341
|
+
Object.entries( {
|
|
1342
|
+
123: '',
|
|
1343
|
+
23: '',
|
|
1344
|
+
} )
|
|
1345
|
+
),
|
|
1155
1346
|
},
|
|
1156
1347
|
selection: {
|
|
1157
1348
|
selectionStart: {},
|
|
@@ -1165,75 +1356,95 @@ describe( 'selectors', () => {
|
|
|
1165
1356
|
it( 'should return the selected block clientId if there is a selection', () => {
|
|
1166
1357
|
const state = {
|
|
1167
1358
|
blocks: {
|
|
1168
|
-
order:
|
|
1169
|
-
|
|
1170
|
-
|
|
1171
|
-
|
|
1172
|
-
|
|
1173
|
-
|
|
1174
|
-
|
|
1175
|
-
|
|
1176
|
-
|
|
1177
|
-
|
|
1359
|
+
order: new Map(
|
|
1360
|
+
Object.entries( {
|
|
1361
|
+
'': [ '5', '4', '3', '2', '1' ],
|
|
1362
|
+
} )
|
|
1363
|
+
),
|
|
1364
|
+
parents: new Map(
|
|
1365
|
+
Object.entries( {
|
|
1366
|
+
1: '',
|
|
1367
|
+
2: '',
|
|
1368
|
+
3: '',
|
|
1369
|
+
4: '',
|
|
1370
|
+
5: '',
|
|
1371
|
+
} )
|
|
1372
|
+
),
|
|
1178
1373
|
},
|
|
1179
1374
|
selection: {
|
|
1180
|
-
selectionStart: { clientId: 2 },
|
|
1181
|
-
selectionEnd: { clientId: 2 },
|
|
1375
|
+
selectionStart: { clientId: '2' },
|
|
1376
|
+
selectionEnd: { clientId: '2' },
|
|
1182
1377
|
},
|
|
1183
1378
|
};
|
|
1184
1379
|
|
|
1185
|
-
expect( getSelectedBlockClientIds( state ) ).toEqual( [ 2 ] );
|
|
1380
|
+
expect( getSelectedBlockClientIds( state ) ).toEqual( [ '2' ] );
|
|
1186
1381
|
} );
|
|
1187
1382
|
|
|
1188
1383
|
it( 'should return selected block clientIds if there is multi selection', () => {
|
|
1189
1384
|
const state = {
|
|
1190
1385
|
blocks: {
|
|
1191
|
-
order:
|
|
1192
|
-
|
|
1193
|
-
|
|
1194
|
-
|
|
1195
|
-
|
|
1196
|
-
|
|
1197
|
-
|
|
1198
|
-
|
|
1199
|
-
|
|
1200
|
-
|
|
1386
|
+
order: new Map(
|
|
1387
|
+
Object.entries( {
|
|
1388
|
+
'': [ '5', '4', '3', '2', '1' ],
|
|
1389
|
+
} )
|
|
1390
|
+
),
|
|
1391
|
+
parents: new Map(
|
|
1392
|
+
Object.entries( {
|
|
1393
|
+
1: '',
|
|
1394
|
+
2: '',
|
|
1395
|
+
3: '',
|
|
1396
|
+
4: '',
|
|
1397
|
+
5: '',
|
|
1398
|
+
} )
|
|
1399
|
+
),
|
|
1201
1400
|
},
|
|
1202
1401
|
selection: {
|
|
1203
|
-
selectionStart: { clientId: 2 },
|
|
1204
|
-
selectionEnd: { clientId: 4 },
|
|
1402
|
+
selectionStart: { clientId: '2' },
|
|
1403
|
+
selectionEnd: { clientId: '4' },
|
|
1205
1404
|
},
|
|
1206
1405
|
};
|
|
1207
1406
|
|
|
1208
|
-
expect( getSelectedBlockClientIds( state ) ).toEqual( [
|
|
1407
|
+
expect( getSelectedBlockClientIds( state ) ).toEqual( [
|
|
1408
|
+
'4',
|
|
1409
|
+
'3',
|
|
1410
|
+
'2',
|
|
1411
|
+
] );
|
|
1209
1412
|
} );
|
|
1210
1413
|
|
|
1211
1414
|
it( 'should return selected block clientIds if there is multi selection (nested context)', () => {
|
|
1212
1415
|
const state = {
|
|
1213
1416
|
blocks: {
|
|
1214
|
-
order:
|
|
1215
|
-
|
|
1216
|
-
|
|
1217
|
-
|
|
1218
|
-
|
|
1219
|
-
|
|
1220
|
-
|
|
1221
|
-
|
|
1222
|
-
|
|
1223
|
-
|
|
1224
|
-
|
|
1225
|
-
|
|
1226
|
-
|
|
1227
|
-
|
|
1228
|
-
|
|
1417
|
+
order: new Map(
|
|
1418
|
+
Object.entries( {
|
|
1419
|
+
'': [ '5', '4', '3', '2', '1' ],
|
|
1420
|
+
4: [ '9', '8', '7', '6' ],
|
|
1421
|
+
} )
|
|
1422
|
+
),
|
|
1423
|
+
parents: new Map(
|
|
1424
|
+
Object.entries( {
|
|
1425
|
+
1: '',
|
|
1426
|
+
2: '',
|
|
1427
|
+
3: '',
|
|
1428
|
+
4: '',
|
|
1429
|
+
5: '',
|
|
1430
|
+
6: '4',
|
|
1431
|
+
7: '4',
|
|
1432
|
+
8: '4',
|
|
1433
|
+
9: '4',
|
|
1434
|
+
} )
|
|
1435
|
+
),
|
|
1229
1436
|
},
|
|
1230
1437
|
selection: {
|
|
1231
|
-
selectionStart: { clientId: 7 },
|
|
1232
|
-
selectionEnd: { clientId: 9 },
|
|
1438
|
+
selectionStart: { clientId: '7' },
|
|
1439
|
+
selectionEnd: { clientId: '9' },
|
|
1233
1440
|
},
|
|
1234
1441
|
};
|
|
1235
1442
|
|
|
1236
|
-
expect( getSelectedBlockClientIds( state ) ).toEqual( [
|
|
1443
|
+
expect( getSelectedBlockClientIds( state ) ).toEqual( [
|
|
1444
|
+
'9',
|
|
1445
|
+
'8',
|
|
1446
|
+
'7',
|
|
1447
|
+
] );
|
|
1237
1448
|
} );
|
|
1238
1449
|
} );
|
|
1239
1450
|
|
|
@@ -1241,13 +1452,17 @@ describe( 'selectors', () => {
|
|
|
1241
1452
|
it( 'should return empty if there is no multi selection', () => {
|
|
1242
1453
|
const state = {
|
|
1243
1454
|
blocks: {
|
|
1244
|
-
order:
|
|
1245
|
-
|
|
1246
|
-
|
|
1247
|
-
|
|
1248
|
-
|
|
1249
|
-
|
|
1250
|
-
|
|
1455
|
+
order: new Map(
|
|
1456
|
+
Object.entries( {
|
|
1457
|
+
'': [ '123', '23' ],
|
|
1458
|
+
} )
|
|
1459
|
+
),
|
|
1460
|
+
parents: new Map(
|
|
1461
|
+
Object.entries( {
|
|
1462
|
+
23: '',
|
|
1463
|
+
123: '',
|
|
1464
|
+
} )
|
|
1465
|
+
),
|
|
1251
1466
|
},
|
|
1252
1467
|
selection: {
|
|
1253
1468
|
selectionStart: {},
|
|
@@ -1261,55 +1476,67 @@ describe( 'selectors', () => {
|
|
|
1261
1476
|
it( 'should return selected block clientIds if there is multi selection', () => {
|
|
1262
1477
|
const state = {
|
|
1263
1478
|
blocks: {
|
|
1264
|
-
order:
|
|
1265
|
-
|
|
1266
|
-
|
|
1267
|
-
|
|
1268
|
-
|
|
1269
|
-
|
|
1270
|
-
|
|
1271
|
-
|
|
1272
|
-
|
|
1273
|
-
|
|
1479
|
+
order: new Map(
|
|
1480
|
+
Object.entries( {
|
|
1481
|
+
'': [ '5', '4', '3', '2', '1' ],
|
|
1482
|
+
} )
|
|
1483
|
+
),
|
|
1484
|
+
parents: new Map(
|
|
1485
|
+
Object.entries( {
|
|
1486
|
+
1: '',
|
|
1487
|
+
2: '',
|
|
1488
|
+
3: '',
|
|
1489
|
+
4: '',
|
|
1490
|
+
5: '',
|
|
1491
|
+
} )
|
|
1492
|
+
),
|
|
1274
1493
|
},
|
|
1275
1494
|
selection: {
|
|
1276
|
-
selectionStart: { clientId: 2 },
|
|
1277
|
-
selectionEnd: { clientId: 4 },
|
|
1495
|
+
selectionStart: { clientId: '2' },
|
|
1496
|
+
selectionEnd: { clientId: '4' },
|
|
1278
1497
|
},
|
|
1279
1498
|
};
|
|
1280
1499
|
|
|
1281
1500
|
expect( getMultiSelectedBlockClientIds( state ) ).toEqual( [
|
|
1282
|
-
4,
|
|
1501
|
+
'4',
|
|
1502
|
+
'3',
|
|
1503
|
+
'2',
|
|
1283
1504
|
] );
|
|
1284
1505
|
} );
|
|
1285
1506
|
|
|
1286
1507
|
it( 'should return selected block clientIds if there is multi selection (nested context)', () => {
|
|
1287
1508
|
const state = {
|
|
1288
1509
|
blocks: {
|
|
1289
|
-
order:
|
|
1290
|
-
|
|
1291
|
-
|
|
1292
|
-
|
|
1293
|
-
|
|
1294
|
-
|
|
1295
|
-
|
|
1296
|
-
|
|
1297
|
-
|
|
1298
|
-
|
|
1299
|
-
|
|
1300
|
-
|
|
1301
|
-
|
|
1302
|
-
|
|
1303
|
-
|
|
1510
|
+
order: new Map(
|
|
1511
|
+
Object.entries( {
|
|
1512
|
+
'': [ '5', '4', '3', '2', '1' ],
|
|
1513
|
+
4: [ '9', '8', '7', '6' ],
|
|
1514
|
+
} )
|
|
1515
|
+
),
|
|
1516
|
+
parents: new Map(
|
|
1517
|
+
Object.entries( {
|
|
1518
|
+
1: '',
|
|
1519
|
+
2: '',
|
|
1520
|
+
3: '',
|
|
1521
|
+
4: '',
|
|
1522
|
+
5: '',
|
|
1523
|
+
6: '4',
|
|
1524
|
+
7: '4',
|
|
1525
|
+
8: '4',
|
|
1526
|
+
9: '4',
|
|
1527
|
+
} )
|
|
1528
|
+
),
|
|
1304
1529
|
},
|
|
1305
1530
|
selection: {
|
|
1306
|
-
selectionStart: { clientId: 7 },
|
|
1307
|
-
selectionEnd: { clientId: 9 },
|
|
1531
|
+
selectionStart: { clientId: '7' },
|
|
1532
|
+
selectionEnd: { clientId: '9' },
|
|
1308
1533
|
},
|
|
1309
1534
|
};
|
|
1310
1535
|
|
|
1311
1536
|
expect( getMultiSelectedBlockClientIds( state ) ).toEqual( [
|
|
1312
|
-
9,
|
|
1537
|
+
'9',
|
|
1538
|
+
'8',
|
|
1539
|
+
'7',
|
|
1313
1540
|
] );
|
|
1314
1541
|
} );
|
|
1315
1542
|
} );
|
|
@@ -1318,10 +1545,10 @@ describe( 'selectors', () => {
|
|
|
1318
1545
|
it( 'should return the same reference on subsequent invocations of empty selection', () => {
|
|
1319
1546
|
const state = {
|
|
1320
1547
|
blocks: {
|
|
1321
|
-
byClientId:
|
|
1322
|
-
attributes:
|
|
1323
|
-
order:
|
|
1324
|
-
parents:
|
|
1548
|
+
byClientId: new Map(),
|
|
1549
|
+
attributes: new Map(),
|
|
1550
|
+
order: new Map(),
|
|
1551
|
+
parents: new Map(),
|
|
1325
1552
|
},
|
|
1326
1553
|
selection: {
|
|
1327
1554
|
selectionStart: {},
|
|
@@ -1350,12 +1577,12 @@ describe( 'selectors', () => {
|
|
|
1350
1577
|
it( 'returns multi selection start', () => {
|
|
1351
1578
|
const state = {
|
|
1352
1579
|
selection: {
|
|
1353
|
-
selectionStart: { clientId: 2 },
|
|
1354
|
-
selectionEnd: { clientId: 4 },
|
|
1580
|
+
selectionStart: { clientId: '2' },
|
|
1581
|
+
selectionEnd: { clientId: '4' },
|
|
1355
1582
|
},
|
|
1356
1583
|
};
|
|
1357
1584
|
|
|
1358
|
-
expect( getMultiSelectedBlocksStartClientId( state ) ).toBe( 2 );
|
|
1585
|
+
expect( getMultiSelectedBlocksStartClientId( state ) ).toBe( '2' );
|
|
1359
1586
|
} );
|
|
1360
1587
|
} );
|
|
1361
1588
|
|
|
@@ -1374,12 +1601,12 @@ describe( 'selectors', () => {
|
|
|
1374
1601
|
it( 'returns multi selection end', () => {
|
|
1375
1602
|
const state = {
|
|
1376
1603
|
selection: {
|
|
1377
|
-
selectionStart: { clientId: 2 },
|
|
1378
|
-
selectionEnd: { clientId: 4 },
|
|
1604
|
+
selectionStart: { clientId: '2' },
|
|
1605
|
+
selectionEnd: { clientId: '4' },
|
|
1379
1606
|
},
|
|
1380
1607
|
};
|
|
1381
1608
|
|
|
1382
|
-
expect( getMultiSelectedBlocksEndClientId( state ) ).toBe( 4 );
|
|
1609
|
+
expect( getMultiSelectedBlocksEndClientId( state ) ).toBe( '4' );
|
|
1383
1610
|
} );
|
|
1384
1611
|
} );
|
|
1385
1612
|
|
|
@@ -1387,35 +1614,43 @@ describe( 'selectors', () => {
|
|
|
1387
1614
|
it( 'should return the ordered block ClientIds of top-level blocks by default', () => {
|
|
1388
1615
|
const state = {
|
|
1389
1616
|
blocks: {
|
|
1390
|
-
order:
|
|
1391
|
-
|
|
1392
|
-
|
|
1393
|
-
|
|
1394
|
-
|
|
1395
|
-
|
|
1396
|
-
|
|
1617
|
+
order: new Map(
|
|
1618
|
+
Object.entries( {
|
|
1619
|
+
'': [ '123', '23' ],
|
|
1620
|
+
} )
|
|
1621
|
+
),
|
|
1622
|
+
parents: new Map(
|
|
1623
|
+
Object.entries( {
|
|
1624
|
+
23: '',
|
|
1625
|
+
123: '',
|
|
1626
|
+
} )
|
|
1627
|
+
),
|
|
1397
1628
|
},
|
|
1398
1629
|
};
|
|
1399
1630
|
|
|
1400
|
-
expect( getBlockOrder( state ) ).toEqual( [ 123, 23 ] );
|
|
1631
|
+
expect( getBlockOrder( state ) ).toEqual( [ '123', '23' ] );
|
|
1401
1632
|
} );
|
|
1402
1633
|
|
|
1403
1634
|
it( 'should return the ordered block ClientIds at a specified rootClientId', () => {
|
|
1404
1635
|
const state = {
|
|
1405
1636
|
blocks: {
|
|
1406
|
-
order:
|
|
1407
|
-
|
|
1408
|
-
|
|
1409
|
-
|
|
1410
|
-
|
|
1411
|
-
|
|
1412
|
-
|
|
1413
|
-
|
|
1414
|
-
|
|
1637
|
+
order: new Map(
|
|
1638
|
+
Object.entries( {
|
|
1639
|
+
'': [ '123', '23' ],
|
|
1640
|
+
123: [ '456' ],
|
|
1641
|
+
} )
|
|
1642
|
+
),
|
|
1643
|
+
parents: new Map(
|
|
1644
|
+
Object.entries( {
|
|
1645
|
+
23: '',
|
|
1646
|
+
123: '',
|
|
1647
|
+
456: '123',
|
|
1648
|
+
} )
|
|
1649
|
+
),
|
|
1415
1650
|
},
|
|
1416
1651
|
};
|
|
1417
1652
|
|
|
1418
|
-
expect( getBlockOrder( state, '123' ) ).toEqual( [ 456 ] );
|
|
1653
|
+
expect( getBlockOrder( state, '123' ) ).toEqual( [ '456' ] );
|
|
1419
1654
|
} );
|
|
1420
1655
|
} );
|
|
1421
1656
|
|
|
@@ -1423,36 +1658,44 @@ describe( 'selectors', () => {
|
|
|
1423
1658
|
it( 'should return the block order', () => {
|
|
1424
1659
|
const state = {
|
|
1425
1660
|
blocks: {
|
|
1426
|
-
order:
|
|
1427
|
-
|
|
1428
|
-
|
|
1429
|
-
|
|
1430
|
-
|
|
1431
|
-
|
|
1432
|
-
|
|
1661
|
+
order: new Map(
|
|
1662
|
+
Object.entries( {
|
|
1663
|
+
'': [ '123', '23' ],
|
|
1664
|
+
} )
|
|
1665
|
+
),
|
|
1666
|
+
parents: new Map(
|
|
1667
|
+
Object.entries( {
|
|
1668
|
+
23: '',
|
|
1669
|
+
123: '',
|
|
1670
|
+
} )
|
|
1671
|
+
),
|
|
1433
1672
|
},
|
|
1434
1673
|
};
|
|
1435
1674
|
|
|
1436
|
-
expect( getBlockIndex( state, 23 ) ).toBe( 1 );
|
|
1675
|
+
expect( getBlockIndex( state, '23' ) ).toBe( 1 );
|
|
1437
1676
|
} );
|
|
1438
1677
|
|
|
1439
1678
|
it( 'should return the block order (nested context)', () => {
|
|
1440
1679
|
const state = {
|
|
1441
1680
|
blocks: {
|
|
1442
|
-
order:
|
|
1443
|
-
|
|
1444
|
-
|
|
1445
|
-
|
|
1446
|
-
|
|
1447
|
-
|
|
1448
|
-
|
|
1449
|
-
|
|
1450
|
-
|
|
1451
|
-
|
|
1681
|
+
order: new Map(
|
|
1682
|
+
Object.entries( {
|
|
1683
|
+
'': [ '123', '23' ],
|
|
1684
|
+
123: [ '456', '56' ],
|
|
1685
|
+
} )
|
|
1686
|
+
),
|
|
1687
|
+
parents: new Map(
|
|
1688
|
+
Object.entries( {
|
|
1689
|
+
23: '',
|
|
1690
|
+
123: '',
|
|
1691
|
+
56: '123',
|
|
1692
|
+
456: '123',
|
|
1693
|
+
} )
|
|
1694
|
+
),
|
|
1452
1695
|
},
|
|
1453
1696
|
};
|
|
1454
1697
|
|
|
1455
|
-
expect( getBlockIndex( state, 56 ) ).toBe( 1 );
|
|
1698
|
+
expect( getBlockIndex( state, '56' ) ).toBe( 1 );
|
|
1456
1699
|
} );
|
|
1457
1700
|
} );
|
|
1458
1701
|
|
|
@@ -1460,73 +1703,91 @@ describe( 'selectors', () => {
|
|
|
1460
1703
|
it( 'should return the previous block', () => {
|
|
1461
1704
|
const state = {
|
|
1462
1705
|
blocks: {
|
|
1463
|
-
order:
|
|
1464
|
-
|
|
1465
|
-
|
|
1466
|
-
|
|
1467
|
-
|
|
1468
|
-
|
|
1469
|
-
|
|
1706
|
+
order: new Map(
|
|
1707
|
+
Object.entries( {
|
|
1708
|
+
'': [ '123', '23' ],
|
|
1709
|
+
} )
|
|
1710
|
+
),
|
|
1711
|
+
parents: new Map(
|
|
1712
|
+
Object.entries( {
|
|
1713
|
+
23: '',
|
|
1714
|
+
123: '',
|
|
1715
|
+
} )
|
|
1716
|
+
),
|
|
1470
1717
|
},
|
|
1471
1718
|
};
|
|
1472
1719
|
|
|
1473
|
-
expect( getPreviousBlockClientId( state, 23 ) ).toEqual( 123 );
|
|
1720
|
+
expect( getPreviousBlockClientId( state, '23' ) ).toEqual( '123' );
|
|
1474
1721
|
} );
|
|
1475
1722
|
|
|
1476
1723
|
it( 'should return the previous block (nested context)', () => {
|
|
1477
1724
|
const state = {
|
|
1478
1725
|
blocks: {
|
|
1479
|
-
order:
|
|
1480
|
-
|
|
1481
|
-
|
|
1482
|
-
|
|
1483
|
-
|
|
1484
|
-
|
|
1485
|
-
|
|
1486
|
-
|
|
1487
|
-
|
|
1488
|
-
|
|
1489
|
-
|
|
1490
|
-
|
|
1491
|
-
|
|
1492
|
-
|
|
1493
|
-
|
|
1726
|
+
order: new Map(
|
|
1727
|
+
Object.entries( {
|
|
1728
|
+
'': [ '123', '23' ],
|
|
1729
|
+
123: [ '456', '56' ],
|
|
1730
|
+
} )
|
|
1731
|
+
),
|
|
1732
|
+
parents: new Map(
|
|
1733
|
+
Object.entries( {
|
|
1734
|
+
23: '',
|
|
1735
|
+
123: '',
|
|
1736
|
+
456: '123',
|
|
1737
|
+
56: '123',
|
|
1738
|
+
} )
|
|
1739
|
+
),
|
|
1740
|
+
},
|
|
1741
|
+
};
|
|
1742
|
+
|
|
1743
|
+
expect( getPreviousBlockClientId( state, '56', '123' ) ).toEqual(
|
|
1744
|
+
'456'
|
|
1494
1745
|
);
|
|
1495
1746
|
} );
|
|
1496
1747
|
|
|
1497
1748
|
it( 'should return null for the first block', () => {
|
|
1498
1749
|
const state = {
|
|
1499
1750
|
blocks: {
|
|
1500
|
-
order:
|
|
1501
|
-
|
|
1502
|
-
|
|
1503
|
-
|
|
1504
|
-
|
|
1505
|
-
|
|
1506
|
-
|
|
1751
|
+
order: new Map(
|
|
1752
|
+
Object.entries( {
|
|
1753
|
+
'': [ '123', '23' ],
|
|
1754
|
+
} )
|
|
1755
|
+
),
|
|
1756
|
+
parents: new Map(
|
|
1757
|
+
Object.entries( {
|
|
1758
|
+
23: '',
|
|
1759
|
+
123: '',
|
|
1760
|
+
} )
|
|
1761
|
+
),
|
|
1507
1762
|
},
|
|
1508
1763
|
};
|
|
1509
1764
|
|
|
1510
|
-
expect( getPreviousBlockClientId( state, 123 ) ).toBeNull();
|
|
1765
|
+
expect( getPreviousBlockClientId( state, '123' ) ).toBeNull();
|
|
1511
1766
|
} );
|
|
1512
1767
|
|
|
1513
1768
|
it( 'should return null for the first block (nested context)', () => {
|
|
1514
1769
|
const state = {
|
|
1515
1770
|
blocks: {
|
|
1516
|
-
order:
|
|
1517
|
-
|
|
1518
|
-
|
|
1519
|
-
|
|
1520
|
-
|
|
1521
|
-
|
|
1522
|
-
|
|
1523
|
-
|
|
1524
|
-
|
|
1525
|
-
|
|
1771
|
+
order: new Map(
|
|
1772
|
+
Object.entries( {
|
|
1773
|
+
'': [ '123', '23' ],
|
|
1774
|
+
123: [ '456', '56' ],
|
|
1775
|
+
} )
|
|
1776
|
+
),
|
|
1777
|
+
parents: new Map(
|
|
1778
|
+
Object.entries( {
|
|
1779
|
+
23: '',
|
|
1780
|
+
123: '',
|
|
1781
|
+
456: '123',
|
|
1782
|
+
56: '123',
|
|
1783
|
+
} )
|
|
1784
|
+
),
|
|
1526
1785
|
},
|
|
1527
1786
|
};
|
|
1528
1787
|
|
|
1529
|
-
expect(
|
|
1788
|
+
expect(
|
|
1789
|
+
getPreviousBlockClientId( state, '456', '123' )
|
|
1790
|
+
).toBeNull();
|
|
1530
1791
|
} );
|
|
1531
1792
|
} );
|
|
1532
1793
|
|
|
@@ -1534,71 +1795,89 @@ describe( 'selectors', () => {
|
|
|
1534
1795
|
it( 'should return the following block', () => {
|
|
1535
1796
|
const state = {
|
|
1536
1797
|
blocks: {
|
|
1537
|
-
order:
|
|
1538
|
-
|
|
1539
|
-
|
|
1540
|
-
|
|
1541
|
-
|
|
1542
|
-
|
|
1543
|
-
|
|
1798
|
+
order: new Map(
|
|
1799
|
+
Object.entries( {
|
|
1800
|
+
'': [ '123', '23' ],
|
|
1801
|
+
} )
|
|
1802
|
+
),
|
|
1803
|
+
parents: new Map(
|
|
1804
|
+
Object.entries( {
|
|
1805
|
+
23: '',
|
|
1806
|
+
123: '',
|
|
1807
|
+
} )
|
|
1808
|
+
),
|
|
1544
1809
|
},
|
|
1545
1810
|
};
|
|
1546
1811
|
|
|
1547
|
-
expect( getNextBlockClientId( state, 123 ) ).toEqual( 23 );
|
|
1812
|
+
expect( getNextBlockClientId( state, '123' ) ).toEqual( '23' );
|
|
1548
1813
|
} );
|
|
1549
1814
|
|
|
1550
1815
|
it( 'should return the following block (nested context)', () => {
|
|
1551
1816
|
const state = {
|
|
1552
1817
|
blocks: {
|
|
1553
|
-
order:
|
|
1554
|
-
|
|
1555
|
-
|
|
1556
|
-
|
|
1557
|
-
|
|
1558
|
-
|
|
1559
|
-
|
|
1560
|
-
|
|
1561
|
-
|
|
1562
|
-
|
|
1563
|
-
|
|
1564
|
-
|
|
1565
|
-
|
|
1566
|
-
|
|
1818
|
+
order: new Map(
|
|
1819
|
+
Object.entries( {
|
|
1820
|
+
'': [ '123', '23' ],
|
|
1821
|
+
123: [ '456', '56' ],
|
|
1822
|
+
} )
|
|
1823
|
+
),
|
|
1824
|
+
parents: new Map(
|
|
1825
|
+
Object.entries( {
|
|
1826
|
+
23: '',
|
|
1827
|
+
123: '',
|
|
1828
|
+
456: '123',
|
|
1829
|
+
56: '123',
|
|
1830
|
+
} )
|
|
1831
|
+
),
|
|
1832
|
+
},
|
|
1833
|
+
};
|
|
1834
|
+
|
|
1835
|
+
expect( getNextBlockClientId( state, '456', '123' ) ).toEqual(
|
|
1836
|
+
'56'
|
|
1837
|
+
);
|
|
1567
1838
|
} );
|
|
1568
1839
|
|
|
1569
1840
|
it( 'should return null for the last block', () => {
|
|
1570
1841
|
const state = {
|
|
1571
1842
|
blocks: {
|
|
1572
|
-
order:
|
|
1573
|
-
|
|
1574
|
-
|
|
1575
|
-
|
|
1576
|
-
|
|
1577
|
-
|
|
1578
|
-
|
|
1843
|
+
order: new Map(
|
|
1844
|
+
Object.entries( {
|
|
1845
|
+
'': [ '123', '23' ],
|
|
1846
|
+
} )
|
|
1847
|
+
),
|
|
1848
|
+
parents: new Map(
|
|
1849
|
+
Object.entries( {
|
|
1850
|
+
23: '',
|
|
1851
|
+
123: '',
|
|
1852
|
+
} )
|
|
1853
|
+
),
|
|
1579
1854
|
},
|
|
1580
1855
|
};
|
|
1581
1856
|
|
|
1582
|
-
expect( getNextBlockClientId( state, 23 ) ).toBeNull();
|
|
1857
|
+
expect( getNextBlockClientId( state, '23' ) ).toBeNull();
|
|
1583
1858
|
} );
|
|
1584
1859
|
|
|
1585
1860
|
it( 'should return null for the last block (nested context)', () => {
|
|
1586
1861
|
const state = {
|
|
1587
1862
|
blocks: {
|
|
1588
|
-
order:
|
|
1589
|
-
|
|
1590
|
-
|
|
1591
|
-
|
|
1592
|
-
|
|
1593
|
-
|
|
1594
|
-
|
|
1595
|
-
|
|
1596
|
-
|
|
1597
|
-
|
|
1863
|
+
order: new Map(
|
|
1864
|
+
Object.entries( {
|
|
1865
|
+
'': [ '123', '23' ],
|
|
1866
|
+
123: [ '456', '56' ],
|
|
1867
|
+
} )
|
|
1868
|
+
),
|
|
1869
|
+
parents: new Map(
|
|
1870
|
+
Object.entries( {
|
|
1871
|
+
23: '',
|
|
1872
|
+
123: '',
|
|
1873
|
+
456: '123',
|
|
1874
|
+
56: '123',
|
|
1875
|
+
} )
|
|
1876
|
+
),
|
|
1598
1877
|
},
|
|
1599
1878
|
};
|
|
1600
1879
|
|
|
1601
|
-
expect( getNextBlockClientId( state, 56, '123' ) ).toBeNull();
|
|
1880
|
+
expect( getNextBlockClientId( state, '56', '123' ) ).toBeNull();
|
|
1602
1881
|
} );
|
|
1603
1882
|
} );
|
|
1604
1883
|
|
|
@@ -1606,23 +1885,23 @@ describe( 'selectors', () => {
|
|
|
1606
1885
|
it( 'should return true if the block is selected', () => {
|
|
1607
1886
|
const state = {
|
|
1608
1887
|
selection: {
|
|
1609
|
-
selectionStart: { clientId: 123 },
|
|
1610
|
-
selectionEnd: { clientId: 123 },
|
|
1888
|
+
selectionStart: { clientId: '123' },
|
|
1889
|
+
selectionEnd: { clientId: '123' },
|
|
1611
1890
|
},
|
|
1612
1891
|
};
|
|
1613
1892
|
|
|
1614
|
-
expect( isBlockSelected( state, 123 ) ).toBe( true );
|
|
1893
|
+
expect( isBlockSelected( state, '123' ) ).toBe( true );
|
|
1615
1894
|
} );
|
|
1616
1895
|
|
|
1617
1896
|
it( 'should return false if a multi-selection range exists', () => {
|
|
1618
1897
|
const state = {
|
|
1619
1898
|
selection: {
|
|
1620
|
-
selectionStart: { clientId: 123 },
|
|
1621
|
-
selectionEnd: { clientId: 124 },
|
|
1899
|
+
selectionStart: { clientId: '123' },
|
|
1900
|
+
selectionEnd: { clientId: '124' },
|
|
1622
1901
|
},
|
|
1623
1902
|
};
|
|
1624
1903
|
|
|
1625
|
-
expect( isBlockSelected( state, 123 ) ).toBe( false );
|
|
1904
|
+
expect( isBlockSelected( state, '123' ) ).toBe( false );
|
|
1626
1905
|
} );
|
|
1627
1906
|
|
|
1628
1907
|
it( 'should return false if the block is not selected', () => {
|
|
@@ -1633,7 +1912,7 @@ describe( 'selectors', () => {
|
|
|
1633
1912
|
},
|
|
1634
1913
|
};
|
|
1635
1914
|
|
|
1636
|
-
expect( isBlockSelected( state, 23 ) ).toBe( false );
|
|
1915
|
+
expect( isBlockSelected( state, '23' ) ).toBe( false );
|
|
1637
1916
|
} );
|
|
1638
1917
|
} );
|
|
1639
1918
|
|
|
@@ -1641,87 +1920,103 @@ describe( 'selectors', () => {
|
|
|
1641
1920
|
it( 'should return false if the selected block is a child of the given ClientId', () => {
|
|
1642
1921
|
const state = {
|
|
1643
1922
|
selection: {
|
|
1644
|
-
selectionStart: { clientId: 5 },
|
|
1645
|
-
selectionEnd: { clientId: 5 },
|
|
1923
|
+
selectionStart: { clientId: '5' },
|
|
1924
|
+
selectionEnd: { clientId: '5' },
|
|
1646
1925
|
},
|
|
1647
1926
|
blocks: {
|
|
1648
|
-
order:
|
|
1649
|
-
|
|
1650
|
-
|
|
1651
|
-
|
|
1652
|
-
|
|
1653
|
-
|
|
1654
|
-
|
|
1655
|
-
|
|
1927
|
+
order: new Map(
|
|
1928
|
+
Object.entries( {
|
|
1929
|
+
4: [ '3', '2', '1' ],
|
|
1930
|
+
} )
|
|
1931
|
+
),
|
|
1932
|
+
parents: new Map(
|
|
1933
|
+
Object.entries( {
|
|
1934
|
+
1: '4',
|
|
1935
|
+
2: '4',
|
|
1936
|
+
3: '4',
|
|
1937
|
+
} )
|
|
1938
|
+
),
|
|
1656
1939
|
},
|
|
1657
1940
|
};
|
|
1658
1941
|
|
|
1659
|
-
expect( hasSelectedInnerBlock( state, 4 ) ).toBe( false );
|
|
1942
|
+
expect( hasSelectedInnerBlock( state, '4' ) ).toBe( false );
|
|
1660
1943
|
} );
|
|
1661
1944
|
|
|
1662
1945
|
it( 'should return true if the selected block is a child of the given ClientId', () => {
|
|
1663
1946
|
const state = {
|
|
1664
1947
|
selection: {
|
|
1665
|
-
selectionStart: { clientId: 3 },
|
|
1666
|
-
selectionEnd: { clientId: 3 },
|
|
1948
|
+
selectionStart: { clientId: '3' },
|
|
1949
|
+
selectionEnd: { clientId: '3' },
|
|
1667
1950
|
},
|
|
1668
1951
|
blocks: {
|
|
1669
|
-
order:
|
|
1670
|
-
|
|
1671
|
-
|
|
1672
|
-
|
|
1673
|
-
|
|
1674
|
-
|
|
1675
|
-
|
|
1676
|
-
|
|
1952
|
+
order: new Map(
|
|
1953
|
+
Object.entries( {
|
|
1954
|
+
4: [ '3', '2', '1' ],
|
|
1955
|
+
} )
|
|
1956
|
+
),
|
|
1957
|
+
parents: new Map(
|
|
1958
|
+
Object.entries( {
|
|
1959
|
+
1: '4',
|
|
1960
|
+
2: '4',
|
|
1961
|
+
3: '4',
|
|
1962
|
+
} )
|
|
1963
|
+
),
|
|
1677
1964
|
},
|
|
1678
1965
|
};
|
|
1679
1966
|
|
|
1680
|
-
expect( hasSelectedInnerBlock( state, 4 ) ).toBe( true );
|
|
1967
|
+
expect( hasSelectedInnerBlock( state, '4' ) ).toBe( true );
|
|
1681
1968
|
} );
|
|
1682
1969
|
|
|
1683
1970
|
it( 'should return true if a multi selection exists that contains children of the block with the given ClientId', () => {
|
|
1684
1971
|
const state = {
|
|
1685
1972
|
blocks: {
|
|
1686
|
-
order:
|
|
1687
|
-
|
|
1688
|
-
|
|
1689
|
-
|
|
1690
|
-
|
|
1691
|
-
|
|
1692
|
-
|
|
1693
|
-
|
|
1694
|
-
|
|
1695
|
-
|
|
1973
|
+
order: new Map(
|
|
1974
|
+
Object.entries( {
|
|
1975
|
+
6: [ '5', '4', '3', '2', '1' ],
|
|
1976
|
+
} )
|
|
1977
|
+
),
|
|
1978
|
+
parents: new Map(
|
|
1979
|
+
Object.entries( {
|
|
1980
|
+
1: '6',
|
|
1981
|
+
2: '6',
|
|
1982
|
+
3: '6',
|
|
1983
|
+
4: '6',
|
|
1984
|
+
5: '6',
|
|
1985
|
+
} )
|
|
1986
|
+
),
|
|
1696
1987
|
},
|
|
1697
1988
|
selection: {
|
|
1698
|
-
selectionStart: { clientId: 2 },
|
|
1699
|
-
selectionEnd: { clientId: 4 },
|
|
1989
|
+
selectionStart: { clientId: '2' },
|
|
1990
|
+
selectionEnd: { clientId: '4' },
|
|
1700
1991
|
},
|
|
1701
1992
|
};
|
|
1702
|
-
expect( hasSelectedInnerBlock( state, 6 ) ).toBe( true );
|
|
1993
|
+
expect( hasSelectedInnerBlock( state, '6' ) ).toBe( true );
|
|
1703
1994
|
} );
|
|
1704
1995
|
|
|
1705
1996
|
it( 'should return false if a multi selection exists bot does not contains children of the block with the given ClientId', () => {
|
|
1706
1997
|
const state = {
|
|
1707
|
-
blocks: {
|
|
1708
|
-
order:
|
|
1709
|
-
|
|
1710
|
-
|
|
1711
|
-
|
|
1712
|
-
|
|
1713
|
-
|
|
1714
|
-
|
|
1715
|
-
|
|
1716
|
-
|
|
1717
|
-
|
|
1998
|
+
blocks: {
|
|
1999
|
+
order: new Map(
|
|
2000
|
+
Object.entries( {
|
|
2001
|
+
3: [ '2', '1' ],
|
|
2002
|
+
6: [ '5', '4' ],
|
|
2003
|
+
} )
|
|
2004
|
+
),
|
|
2005
|
+
parents: new Map(
|
|
2006
|
+
Object.entries( {
|
|
2007
|
+
1: '3',
|
|
2008
|
+
2: '3',
|
|
2009
|
+
4: '6',
|
|
2010
|
+
5: '6',
|
|
2011
|
+
} )
|
|
2012
|
+
),
|
|
1718
2013
|
},
|
|
1719
2014
|
selection: {
|
|
1720
|
-
selectionStart: { clientId: 5 },
|
|
1721
|
-
selectionEnd: { clientId: 4 },
|
|
2015
|
+
selectionStart: { clientId: '5' },
|
|
2016
|
+
selectionEnd: { clientId: '4' },
|
|
1722
2017
|
},
|
|
1723
2018
|
};
|
|
1724
|
-
expect( hasSelectedInnerBlock( state, 3 ) ).toBe( false );
|
|
2019
|
+
expect( hasSelectedInnerBlock( state, '3' ) ).toBe( false );
|
|
1725
2020
|
} );
|
|
1726
2021
|
} );
|
|
1727
2022
|
|
|
@@ -1729,70 +2024,82 @@ describe( 'selectors', () => {
|
|
|
1729
2024
|
it( 'should return true if the block is selected but not the last', () => {
|
|
1730
2025
|
const state = {
|
|
1731
2026
|
selection: {
|
|
1732
|
-
selectionStart: { clientId: 5 },
|
|
1733
|
-
selectionEnd: { clientId: 3 },
|
|
2027
|
+
selectionStart: { clientId: '5' },
|
|
2028
|
+
selectionEnd: { clientId: '3' },
|
|
1734
2029
|
},
|
|
1735
2030
|
blocks: {
|
|
1736
|
-
order:
|
|
1737
|
-
|
|
1738
|
-
|
|
1739
|
-
|
|
1740
|
-
|
|
1741
|
-
|
|
1742
|
-
|
|
1743
|
-
|
|
1744
|
-
|
|
1745
|
-
|
|
2031
|
+
order: new Map(
|
|
2032
|
+
Object.entries( {
|
|
2033
|
+
'': [ '5', '4', '3', '2', '1' ],
|
|
2034
|
+
} )
|
|
2035
|
+
),
|
|
2036
|
+
parents: new Map(
|
|
2037
|
+
Object.entries( {
|
|
2038
|
+
1: '',
|
|
2039
|
+
2: '',
|
|
2040
|
+
3: '',
|
|
2041
|
+
4: '',
|
|
2042
|
+
5: '',
|
|
2043
|
+
} )
|
|
2044
|
+
),
|
|
1746
2045
|
},
|
|
1747
2046
|
};
|
|
1748
2047
|
|
|
1749
|
-
expect( isBlockWithinSelection( state, 4 ) ).toBe( true );
|
|
2048
|
+
expect( isBlockWithinSelection( state, '4' ) ).toBe( true );
|
|
1750
2049
|
} );
|
|
1751
2050
|
|
|
1752
2051
|
it( 'should return false if the block is the last selected', () => {
|
|
1753
2052
|
const state = {
|
|
1754
2053
|
selection: {
|
|
1755
|
-
selectionStart: { clientId: 5 },
|
|
1756
|
-
selectionEnd: { clientId: 3 },
|
|
2054
|
+
selectionStart: { clientId: '5' },
|
|
2055
|
+
selectionEnd: { clientId: '3' },
|
|
1757
2056
|
},
|
|
1758
2057
|
blocks: {
|
|
1759
|
-
order:
|
|
1760
|
-
|
|
1761
|
-
|
|
1762
|
-
|
|
1763
|
-
|
|
1764
|
-
|
|
1765
|
-
|
|
1766
|
-
|
|
1767
|
-
|
|
1768
|
-
|
|
2058
|
+
order: new Map(
|
|
2059
|
+
Object.entries( {
|
|
2060
|
+
'': [ '5', '4', '3', '2', '1' ],
|
|
2061
|
+
} )
|
|
2062
|
+
),
|
|
2063
|
+
parents: new Map(
|
|
2064
|
+
Object.entries( {
|
|
2065
|
+
1: '',
|
|
2066
|
+
2: '',
|
|
2067
|
+
3: '',
|
|
2068
|
+
4: '',
|
|
2069
|
+
5: '',
|
|
2070
|
+
} )
|
|
2071
|
+
),
|
|
1769
2072
|
},
|
|
1770
2073
|
};
|
|
1771
2074
|
|
|
1772
|
-
expect( isBlockWithinSelection( state, 3 ) ).toBe( false );
|
|
2075
|
+
expect( isBlockWithinSelection( state, '3' ) ).toBe( false );
|
|
1773
2076
|
} );
|
|
1774
2077
|
|
|
1775
2078
|
it( 'should return false if the block is not selected', () => {
|
|
1776
2079
|
const state = {
|
|
1777
2080
|
selection: {
|
|
1778
|
-
selectionStart: { clientId: 5 },
|
|
1779
|
-
selectionEnd: { clientId: 3 },
|
|
2081
|
+
selectionStart: { clientId: '5' },
|
|
2082
|
+
selectionEnd: { clientId: '3' },
|
|
1780
2083
|
},
|
|
1781
2084
|
blocks: {
|
|
1782
|
-
order:
|
|
1783
|
-
|
|
1784
|
-
|
|
1785
|
-
|
|
1786
|
-
|
|
1787
|
-
|
|
1788
|
-
|
|
1789
|
-
|
|
1790
|
-
|
|
1791
|
-
|
|
2085
|
+
order: new Map(
|
|
2086
|
+
Object.entries( {
|
|
2087
|
+
'': [ '5', '4', '3', '2', '1' ],
|
|
2088
|
+
} )
|
|
2089
|
+
),
|
|
2090
|
+
parents: new Map(
|
|
2091
|
+
Object.entries( {
|
|
2092
|
+
1: '',
|
|
2093
|
+
2: '',
|
|
2094
|
+
3: '',
|
|
2095
|
+
4: '',
|
|
2096
|
+
5: '',
|
|
2097
|
+
} )
|
|
2098
|
+
),
|
|
1792
2099
|
},
|
|
1793
2100
|
};
|
|
1794
2101
|
|
|
1795
|
-
expect( isBlockWithinSelection( state, 2 ) ).toBe( false );
|
|
2102
|
+
expect( isBlockWithinSelection( state, '2' ) ).toBe( false );
|
|
1796
2103
|
} );
|
|
1797
2104
|
|
|
1798
2105
|
it( 'should return false if there is no selection', () => {
|
|
@@ -1802,20 +2109,24 @@ describe( 'selectors', () => {
|
|
|
1802
2109
|
selectionEnd: {},
|
|
1803
2110
|
},
|
|
1804
2111
|
blocks: {
|
|
1805
|
-
order:
|
|
1806
|
-
|
|
1807
|
-
|
|
1808
|
-
|
|
1809
|
-
|
|
1810
|
-
|
|
1811
|
-
|
|
1812
|
-
|
|
1813
|
-
|
|
1814
|
-
|
|
2112
|
+
order: new Map(
|
|
2113
|
+
Object.entries( {
|
|
2114
|
+
'': [ '5', '4', '3', '2', '1' ],
|
|
2115
|
+
} )
|
|
2116
|
+
),
|
|
2117
|
+
parents: new Map(
|
|
2118
|
+
Object.entries( {
|
|
2119
|
+
1: '',
|
|
2120
|
+
2: '',
|
|
2121
|
+
3: '',
|
|
2122
|
+
4: '',
|
|
2123
|
+
5: '',
|
|
2124
|
+
} )
|
|
2125
|
+
),
|
|
1815
2126
|
},
|
|
1816
2127
|
};
|
|
1817
2128
|
|
|
1818
|
-
expect( isBlockWithinSelection( state, 4 ) ).toBe( false );
|
|
2129
|
+
expect( isBlockWithinSelection( state, '4' ) ).toBe( false );
|
|
1819
2130
|
} );
|
|
1820
2131
|
} );
|
|
1821
2132
|
|
|
@@ -1865,58 +2176,66 @@ describe( 'selectors', () => {
|
|
|
1865
2176
|
describe( 'isBlockMultiSelected', () => {
|
|
1866
2177
|
const state = {
|
|
1867
2178
|
blocks: {
|
|
1868
|
-
order:
|
|
1869
|
-
|
|
1870
|
-
|
|
1871
|
-
|
|
1872
|
-
|
|
1873
|
-
|
|
1874
|
-
|
|
1875
|
-
|
|
1876
|
-
|
|
1877
|
-
|
|
2179
|
+
order: new Map(
|
|
2180
|
+
Object.entries( {
|
|
2181
|
+
'': [ '5', '4', '3', '2', '1' ],
|
|
2182
|
+
} )
|
|
2183
|
+
),
|
|
2184
|
+
parents: new Map(
|
|
2185
|
+
Object.entries( {
|
|
2186
|
+
1: '',
|
|
2187
|
+
2: '',
|
|
2188
|
+
3: '',
|
|
2189
|
+
4: '',
|
|
2190
|
+
5: '',
|
|
2191
|
+
} )
|
|
2192
|
+
),
|
|
1878
2193
|
},
|
|
1879
2194
|
selection: {
|
|
1880
|
-
selectionStart: { clientId: 2 },
|
|
1881
|
-
selectionEnd: { clientId: 4 },
|
|
2195
|
+
selectionStart: { clientId: '2' },
|
|
2196
|
+
selectionEnd: { clientId: '4' },
|
|
1882
2197
|
},
|
|
1883
2198
|
};
|
|
1884
2199
|
|
|
1885
2200
|
it( 'should return true if the block is multi selected', () => {
|
|
1886
|
-
expect( isBlockMultiSelected( state, 3 ) ).toBe( true );
|
|
2201
|
+
expect( isBlockMultiSelected( state, '3' ) ).toBe( true );
|
|
1887
2202
|
} );
|
|
1888
2203
|
|
|
1889
2204
|
it( 'should return false if the block is not multi selected', () => {
|
|
1890
|
-
expect( isBlockMultiSelected( state, 5 ) ).toBe( false );
|
|
2205
|
+
expect( isBlockMultiSelected( state, '5' ) ).toBe( false );
|
|
1891
2206
|
} );
|
|
1892
2207
|
} );
|
|
1893
2208
|
|
|
1894
2209
|
describe( 'isFirstMultiSelectedBlock', () => {
|
|
1895
2210
|
const state = {
|
|
1896
2211
|
blocks: {
|
|
1897
|
-
order:
|
|
1898
|
-
|
|
1899
|
-
|
|
1900
|
-
|
|
1901
|
-
|
|
1902
|
-
|
|
1903
|
-
|
|
1904
|
-
|
|
1905
|
-
|
|
1906
|
-
|
|
2212
|
+
order: new Map(
|
|
2213
|
+
Object.entries( {
|
|
2214
|
+
'': [ '5', '4', '3', '2', '1' ],
|
|
2215
|
+
} )
|
|
2216
|
+
),
|
|
2217
|
+
parents: new Map(
|
|
2218
|
+
Object.entries( {
|
|
2219
|
+
1: '',
|
|
2220
|
+
2: '',
|
|
2221
|
+
3: '',
|
|
2222
|
+
4: '',
|
|
2223
|
+
5: '',
|
|
2224
|
+
} )
|
|
2225
|
+
),
|
|
1907
2226
|
},
|
|
1908
2227
|
selection: {
|
|
1909
|
-
selectionStart: { clientId: 2 },
|
|
1910
|
-
selectionEnd: { clientId: 4 },
|
|
2228
|
+
selectionStart: { clientId: '2' },
|
|
2229
|
+
selectionEnd: { clientId: '4' },
|
|
1911
2230
|
},
|
|
1912
2231
|
};
|
|
1913
2232
|
|
|
1914
2233
|
it( 'should return true if the block is first in multi selection', () => {
|
|
1915
|
-
expect( isFirstMultiSelectedBlock( state, 4 ) ).toBe( true );
|
|
2234
|
+
expect( isFirstMultiSelectedBlock( state, '4' ) ).toBe( true );
|
|
1916
2235
|
} );
|
|
1917
2236
|
|
|
1918
2237
|
it( 'should return false if the block is not first in multi selection', () => {
|
|
1919
|
-
expect( isFirstMultiSelectedBlock( state, 3 ) ).toBe( false );
|
|
2238
|
+
expect( isFirstMultiSelectedBlock( state, '3' ) ).toBe( false );
|
|
1920
2239
|
} );
|
|
1921
2240
|
} );
|
|
1922
2241
|
|
|
@@ -1926,7 +2245,7 @@ describe( 'selectors', () => {
|
|
|
1926
2245
|
blocksMode: {},
|
|
1927
2246
|
};
|
|
1928
2247
|
|
|
1929
|
-
expect( getBlockMode( state, 123 ) ).toEqual( 'visual' );
|
|
2248
|
+
expect( getBlockMode( state, '123' ) ).toEqual( 'visual' );
|
|
1930
2249
|
} );
|
|
1931
2250
|
|
|
1932
2251
|
it( 'should return the block mode', () => {
|
|
@@ -1936,7 +2255,25 @@ describe( 'selectors', () => {
|
|
|
1936
2255
|
},
|
|
1937
2256
|
};
|
|
1938
2257
|
|
|
1939
|
-
expect( getBlockMode( state, 123 ) ).toEqual( 'html' );
|
|
2258
|
+
expect( getBlockMode( state, '123' ) ).toEqual( 'html' );
|
|
2259
|
+
} );
|
|
2260
|
+
} );
|
|
2261
|
+
|
|
2262
|
+
describe( 'isBlockInterfaceHidden', () => {
|
|
2263
|
+
it( 'should return the true if toggled true in state', () => {
|
|
2264
|
+
const state = {
|
|
2265
|
+
isBlockInterfaceHidden: true,
|
|
2266
|
+
};
|
|
2267
|
+
|
|
2268
|
+
expect( isBlockInterfaceHidden( state ) ).toBe( true );
|
|
2269
|
+
} );
|
|
2270
|
+
|
|
2271
|
+
it( 'should return false if toggled false in state', () => {
|
|
2272
|
+
const state = {
|
|
2273
|
+
isBlockInterfaceHidden: false,
|
|
2274
|
+
};
|
|
2275
|
+
|
|
2276
|
+
expect( isBlockInterfaceHidden( state ) ).toBe( false );
|
|
1940
2277
|
} );
|
|
1941
2278
|
} );
|
|
1942
2279
|
|
|
@@ -2012,10 +2349,12 @@ describe( 'selectors', () => {
|
|
|
2012
2349
|
const state = {
|
|
2013
2350
|
draggedBlocks: [ 'block-1_grandparent' ],
|
|
2014
2351
|
blocks: {
|
|
2015
|
-
parents:
|
|
2016
|
-
|
|
2017
|
-
|
|
2018
|
-
|
|
2352
|
+
parents: new Map(
|
|
2353
|
+
Object.entries( {
|
|
2354
|
+
'block-1': 'block-1_parent',
|
|
2355
|
+
'block-1_parent': 'block-1_grandparent',
|
|
2356
|
+
} )
|
|
2357
|
+
),
|
|
2019
2358
|
},
|
|
2020
2359
|
};
|
|
2021
2360
|
expect( isAncestorBeingDragged( state, 'block-1' ) ).toBe( true );
|
|
@@ -2025,10 +2364,12 @@ describe( 'selectors', () => {
|
|
|
2025
2364
|
const state = {
|
|
2026
2365
|
draggedBlocks: [ 'block-2_grandparent' ],
|
|
2027
2366
|
blocks: {
|
|
2028
|
-
parents:
|
|
2029
|
-
|
|
2030
|
-
|
|
2031
|
-
|
|
2367
|
+
parents: new Map(
|
|
2368
|
+
Object.entries( {
|
|
2369
|
+
'block-1': 'block-1_parent',
|
|
2370
|
+
'block-1_parent': 'block-1_grandparent',
|
|
2371
|
+
} )
|
|
2372
|
+
),
|
|
2032
2373
|
},
|
|
2033
2374
|
};
|
|
2034
2375
|
expect( isAncestorBeingDragged( state, 'block-1' ) ).toBe( false );
|
|
@@ -2038,10 +2379,12 @@ describe( 'selectors', () => {
|
|
|
2038
2379
|
const state = {
|
|
2039
2380
|
draggedBlocks: [],
|
|
2040
2381
|
blocks: {
|
|
2041
|
-
parents:
|
|
2042
|
-
|
|
2043
|
-
|
|
2044
|
-
|
|
2382
|
+
parents: new Map(
|
|
2383
|
+
Object.entries( {
|
|
2384
|
+
'block-1': 'block-1_parent',
|
|
2385
|
+
'block-1_parent': 'block-1_grandparent',
|
|
2386
|
+
} )
|
|
2387
|
+
),
|
|
2045
2388
|
},
|
|
2046
2389
|
};
|
|
2047
2390
|
expect( isAncestorBeingDragged( state, 'block-1' ) ).toBe( false );
|
|
@@ -2074,23 +2417,31 @@ describe( 'selectors', () => {
|
|
|
2074
2417
|
selectionEnd: { clientId: 'clientId2' },
|
|
2075
2418
|
},
|
|
2076
2419
|
blocks: {
|
|
2077
|
-
byClientId:
|
|
2078
|
-
|
|
2079
|
-
|
|
2080
|
-
|
|
2081
|
-
|
|
2082
|
-
|
|
2083
|
-
|
|
2084
|
-
|
|
2085
|
-
|
|
2086
|
-
|
|
2087
|
-
|
|
2088
|
-
|
|
2089
|
-
|
|
2090
|
-
|
|
2091
|
-
|
|
2092
|
-
|
|
2093
|
-
|
|
2420
|
+
byClientId: new Map(
|
|
2421
|
+
Object.entries( {
|
|
2422
|
+
clientId1: { clientId: 'clientId1' },
|
|
2423
|
+
clientId2: { clientId: 'clientId2' },
|
|
2424
|
+
} )
|
|
2425
|
+
),
|
|
2426
|
+
attributes: new Map(
|
|
2427
|
+
Object.entries( {
|
|
2428
|
+
clientId1: {},
|
|
2429
|
+
clientId2: {},
|
|
2430
|
+
} )
|
|
2431
|
+
),
|
|
2432
|
+
order: new Map(
|
|
2433
|
+
Object.entries( {
|
|
2434
|
+
'': [ 'clientId1' ],
|
|
2435
|
+
clientId1: [ 'clientId2' ],
|
|
2436
|
+
clientId2: [],
|
|
2437
|
+
} )
|
|
2438
|
+
),
|
|
2439
|
+
parents: new Map(
|
|
2440
|
+
Object.entries( {
|
|
2441
|
+
clientId1: '',
|
|
2442
|
+
clientId2: 'clientId1',
|
|
2443
|
+
} )
|
|
2444
|
+
),
|
|
2094
2445
|
},
|
|
2095
2446
|
insertionPoint: {
|
|
2096
2447
|
rootClientId: undefined,
|
|
@@ -2111,19 +2462,27 @@ describe( 'selectors', () => {
|
|
|
2111
2462
|
selectionEnd: { clientId: 'clientId1' },
|
|
2112
2463
|
},
|
|
2113
2464
|
blocks: {
|
|
2114
|
-
byClientId:
|
|
2115
|
-
|
|
2116
|
-
|
|
2117
|
-
|
|
2118
|
-
|
|
2119
|
-
|
|
2120
|
-
|
|
2121
|
-
|
|
2122
|
-
|
|
2123
|
-
|
|
2124
|
-
|
|
2125
|
-
|
|
2126
|
-
|
|
2465
|
+
byClientId: new Map(
|
|
2466
|
+
Object.entries( {
|
|
2467
|
+
clientId1: { clientId: 'clientId1' },
|
|
2468
|
+
} )
|
|
2469
|
+
),
|
|
2470
|
+
attributes: new Map(
|
|
2471
|
+
Object.entries( {
|
|
2472
|
+
clientId1: {},
|
|
2473
|
+
} )
|
|
2474
|
+
),
|
|
2475
|
+
order: new Map(
|
|
2476
|
+
Object.entries( {
|
|
2477
|
+
'': [ 'clientId1' ],
|
|
2478
|
+
clientId1: [],
|
|
2479
|
+
} )
|
|
2480
|
+
),
|
|
2481
|
+
parents: new Map(
|
|
2482
|
+
Object.entries( {
|
|
2483
|
+
clientId1: '',
|
|
2484
|
+
} )
|
|
2485
|
+
),
|
|
2127
2486
|
},
|
|
2128
2487
|
insertionPoint: null,
|
|
2129
2488
|
};
|
|
@@ -2141,23 +2500,31 @@ describe( 'selectors', () => {
|
|
|
2141
2500
|
selectionEnd: { clientId: 'clientId2' },
|
|
2142
2501
|
},
|
|
2143
2502
|
blocks: {
|
|
2144
|
-
byClientId:
|
|
2145
|
-
|
|
2146
|
-
|
|
2147
|
-
|
|
2148
|
-
|
|
2149
|
-
|
|
2150
|
-
|
|
2151
|
-
|
|
2152
|
-
|
|
2153
|
-
|
|
2154
|
-
|
|
2155
|
-
|
|
2156
|
-
|
|
2157
|
-
|
|
2158
|
-
|
|
2159
|
-
|
|
2160
|
-
|
|
2503
|
+
byClientId: new Map(
|
|
2504
|
+
Object.entries( {
|
|
2505
|
+
clientId1: { clientId: 'clientId1' },
|
|
2506
|
+
clientId2: { clientId: 'clientId2' },
|
|
2507
|
+
} )
|
|
2508
|
+
),
|
|
2509
|
+
attributes: new Map(
|
|
2510
|
+
Object.entries( {
|
|
2511
|
+
clientId1: {},
|
|
2512
|
+
clientId2: {},
|
|
2513
|
+
} )
|
|
2514
|
+
),
|
|
2515
|
+
order: new Map(
|
|
2516
|
+
Object.entries( {
|
|
2517
|
+
'': [ 'clientId1' ],
|
|
2518
|
+
clientId1: [ 'clientId2' ],
|
|
2519
|
+
clientId2: [],
|
|
2520
|
+
} )
|
|
2521
|
+
),
|
|
2522
|
+
parents: new Map(
|
|
2523
|
+
Object.entries( {
|
|
2524
|
+
clientId1: '',
|
|
2525
|
+
clientId2: 'clientId1',
|
|
2526
|
+
} )
|
|
2527
|
+
),
|
|
2161
2528
|
},
|
|
2162
2529
|
insertionPoint: null,
|
|
2163
2530
|
};
|
|
@@ -2175,23 +2542,31 @@ describe( 'selectors', () => {
|
|
|
2175
2542
|
selectionEnd: { clientId: 'clientId2' },
|
|
2176
2543
|
},
|
|
2177
2544
|
blocks: {
|
|
2178
|
-
byClientId:
|
|
2179
|
-
|
|
2180
|
-
|
|
2181
|
-
|
|
2182
|
-
|
|
2183
|
-
|
|
2184
|
-
|
|
2185
|
-
|
|
2186
|
-
|
|
2187
|
-
|
|
2188
|
-
|
|
2189
|
-
|
|
2190
|
-
|
|
2191
|
-
|
|
2192
|
-
|
|
2193
|
-
|
|
2194
|
-
|
|
2545
|
+
byClientId: new Map(
|
|
2546
|
+
Object.entries( {
|
|
2547
|
+
clientId1: { clientId: 'clientId1' },
|
|
2548
|
+
clientId2: { clientId: 'clientId2' },
|
|
2549
|
+
} )
|
|
2550
|
+
),
|
|
2551
|
+
attributes: new Map(
|
|
2552
|
+
Object.entries( {
|
|
2553
|
+
clientId1: {},
|
|
2554
|
+
clientId2: {},
|
|
2555
|
+
} )
|
|
2556
|
+
),
|
|
2557
|
+
order: new Map(
|
|
2558
|
+
Object.entries( {
|
|
2559
|
+
'': [ 'clientId1', 'clientId2' ],
|
|
2560
|
+
clientId1: [],
|
|
2561
|
+
clientId2: [],
|
|
2562
|
+
} )
|
|
2563
|
+
),
|
|
2564
|
+
parents: new Map(
|
|
2565
|
+
Object.entries( {
|
|
2566
|
+
clientId1: '',
|
|
2567
|
+
clientId2: '',
|
|
2568
|
+
} )
|
|
2569
|
+
),
|
|
2195
2570
|
},
|
|
2196
2571
|
insertionPoint: null,
|
|
2197
2572
|
};
|
|
@@ -2209,23 +2584,31 @@ describe( 'selectors', () => {
|
|
|
2209
2584
|
selectionEnd: {},
|
|
2210
2585
|
},
|
|
2211
2586
|
blocks: {
|
|
2212
|
-
byClientId:
|
|
2213
|
-
|
|
2214
|
-
|
|
2215
|
-
|
|
2216
|
-
|
|
2217
|
-
|
|
2218
|
-
|
|
2219
|
-
|
|
2220
|
-
|
|
2221
|
-
|
|
2222
|
-
|
|
2223
|
-
|
|
2224
|
-
|
|
2225
|
-
|
|
2226
|
-
|
|
2227
|
-
|
|
2228
|
-
|
|
2587
|
+
byClientId: new Map(
|
|
2588
|
+
Object.entries( {
|
|
2589
|
+
clientId1: { clientId: 'clientId1' },
|
|
2590
|
+
clientId2: { clientId: 'clientId2' },
|
|
2591
|
+
} )
|
|
2592
|
+
),
|
|
2593
|
+
attributes: new Map(
|
|
2594
|
+
Object.entries( {
|
|
2595
|
+
clientId1: {},
|
|
2596
|
+
clientId2: {},
|
|
2597
|
+
} )
|
|
2598
|
+
),
|
|
2599
|
+
order: new Map(
|
|
2600
|
+
Object.entries( {
|
|
2601
|
+
'': [ 'clientId1', 'clientId2' ],
|
|
2602
|
+
clientId1: [],
|
|
2603
|
+
clientId2: [],
|
|
2604
|
+
} )
|
|
2605
|
+
),
|
|
2606
|
+
parents: new Map(
|
|
2607
|
+
Object.entries( {
|
|
2608
|
+
clientId1: '',
|
|
2609
|
+
clientId2: '',
|
|
2610
|
+
} )
|
|
2611
|
+
),
|
|
2229
2612
|
},
|
|
2230
2613
|
insertionPoint: null,
|
|
2231
2614
|
};
|
|
@@ -2262,8 +2645,8 @@ describe( 'selectors', () => {
|
|
|
2262
2645
|
it( 'should deny blocks that are not registered', () => {
|
|
2263
2646
|
const state = {
|
|
2264
2647
|
blocks: {
|
|
2265
|
-
byClientId:
|
|
2266
|
-
attributes:
|
|
2648
|
+
byClientId: new Map(),
|
|
2649
|
+
attributes: new Map(),
|
|
2267
2650
|
},
|
|
2268
2651
|
blockListSettings: {},
|
|
2269
2652
|
settings: {},
|
|
@@ -2274,8 +2657,8 @@ describe( 'selectors', () => {
|
|
|
2274
2657
|
it( 'should deny blocks that are not allowed by the editor', () => {
|
|
2275
2658
|
const state = {
|
|
2276
2659
|
blocks: {
|
|
2277
|
-
byClientId:
|
|
2278
|
-
attributes:
|
|
2660
|
+
byClientId: new Map(),
|
|
2661
|
+
attributes: new Map(),
|
|
2279
2662
|
},
|
|
2280
2663
|
blockListSettings: {},
|
|
2281
2664
|
settings: {
|
|
@@ -2290,8 +2673,8 @@ describe( 'selectors', () => {
|
|
|
2290
2673
|
it( 'should allow blocks that are allowed by the editor', () => {
|
|
2291
2674
|
const state = {
|
|
2292
2675
|
blocks: {
|
|
2293
|
-
byClientId:
|
|
2294
|
-
attributes:
|
|
2676
|
+
byClientId: new Map(),
|
|
2677
|
+
attributes: new Map(),
|
|
2295
2678
|
},
|
|
2296
2679
|
blockListSettings: {},
|
|
2297
2680
|
settings: {
|
|
@@ -2306,8 +2689,8 @@ describe( 'selectors', () => {
|
|
|
2306
2689
|
it( 'should deny blocks when the editor has a template lock', () => {
|
|
2307
2690
|
const state = {
|
|
2308
2691
|
blocks: {
|
|
2309
|
-
byClientId:
|
|
2310
|
-
attributes:
|
|
2692
|
+
byClientId: new Map(),
|
|
2693
|
+
attributes: new Map(),
|
|
2311
2694
|
},
|
|
2312
2695
|
blockListSettings: {},
|
|
2313
2696
|
settings: {
|
|
@@ -2322,8 +2705,8 @@ describe( 'selectors', () => {
|
|
|
2322
2705
|
it( 'should deny blocks that restrict parent from being inserted into the root', () => {
|
|
2323
2706
|
const state = {
|
|
2324
2707
|
blocks: {
|
|
2325
|
-
byClientId:
|
|
2326
|
-
attributes:
|
|
2708
|
+
byClientId: new Map(),
|
|
2709
|
+
attributes: new Map(),
|
|
2327
2710
|
},
|
|
2328
2711
|
blockListSettings: {},
|
|
2329
2712
|
settings: {},
|
|
@@ -2336,12 +2719,16 @@ describe( 'selectors', () => {
|
|
|
2336
2719
|
it( 'should deny blocks that restrict parent from being inserted into a restricted parent', () => {
|
|
2337
2720
|
const state = {
|
|
2338
2721
|
blocks: {
|
|
2339
|
-
byClientId:
|
|
2340
|
-
|
|
2341
|
-
|
|
2342
|
-
|
|
2343
|
-
|
|
2344
|
-
|
|
2722
|
+
byClientId: new Map(
|
|
2723
|
+
Object.entries( {
|
|
2724
|
+
block1: { name: 'core/test-block-a' },
|
|
2725
|
+
} )
|
|
2726
|
+
),
|
|
2727
|
+
attributes: new Map(
|
|
2728
|
+
Object.entries( {
|
|
2729
|
+
block1: {},
|
|
2730
|
+
} )
|
|
2731
|
+
),
|
|
2345
2732
|
},
|
|
2346
2733
|
blockListSettings: {},
|
|
2347
2734
|
settings: {},
|
|
@@ -2354,12 +2741,16 @@ describe( 'selectors', () => {
|
|
|
2354
2741
|
it( 'should allow blocks to be inserted into an allowed parent', () => {
|
|
2355
2742
|
const state = {
|
|
2356
2743
|
blocks: {
|
|
2357
|
-
byClientId:
|
|
2358
|
-
|
|
2359
|
-
|
|
2360
|
-
|
|
2361
|
-
|
|
2362
|
-
|
|
2744
|
+
byClientId: new Map(
|
|
2745
|
+
Object.entries( {
|
|
2746
|
+
block1: { name: 'core/test-block-b' },
|
|
2747
|
+
} )
|
|
2748
|
+
),
|
|
2749
|
+
attributes: new Map(
|
|
2750
|
+
Object.entries( {
|
|
2751
|
+
block1: {},
|
|
2752
|
+
} )
|
|
2753
|
+
),
|
|
2363
2754
|
},
|
|
2364
2755
|
blockListSettings: {
|
|
2365
2756
|
block1: {},
|
|
@@ -2374,12 +2765,16 @@ describe( 'selectors', () => {
|
|
|
2374
2765
|
it( 'should deny blocks from being inserted into a block that does not allow inner blocks', () => {
|
|
2375
2766
|
const state = {
|
|
2376
2767
|
blocks: {
|
|
2377
|
-
byClientId:
|
|
2378
|
-
|
|
2379
|
-
|
|
2380
|
-
|
|
2381
|
-
|
|
2382
|
-
|
|
2768
|
+
byClientId: new Map(
|
|
2769
|
+
Object.entries( {
|
|
2770
|
+
block1: { name: 'core/test-block-b' },
|
|
2771
|
+
} )
|
|
2772
|
+
),
|
|
2773
|
+
attributes: new Map(
|
|
2774
|
+
Object.entries( {
|
|
2775
|
+
block1: {},
|
|
2776
|
+
} )
|
|
2777
|
+
),
|
|
2383
2778
|
},
|
|
2384
2779
|
blockListSettings: {
|
|
2385
2780
|
block1: {},
|
|
@@ -2394,12 +2789,16 @@ describe( 'selectors', () => {
|
|
|
2394
2789
|
it( 'should deny restricted blocks from being inserted into a block that restricts allowedBlocks', () => {
|
|
2395
2790
|
const state = {
|
|
2396
2791
|
blocks: {
|
|
2397
|
-
byClientId:
|
|
2398
|
-
|
|
2399
|
-
|
|
2400
|
-
|
|
2401
|
-
|
|
2402
|
-
|
|
2792
|
+
byClientId: new Map(
|
|
2793
|
+
Object.entries( {
|
|
2794
|
+
block1: { name: 'core/test-block-a' },
|
|
2795
|
+
} )
|
|
2796
|
+
),
|
|
2797
|
+
attributes: new Map(
|
|
2798
|
+
Object.entries( {
|
|
2799
|
+
block1: {},
|
|
2800
|
+
} )
|
|
2801
|
+
),
|
|
2403
2802
|
},
|
|
2404
2803
|
blockListSettings: {
|
|
2405
2804
|
block1: {
|
|
@@ -2416,12 +2815,16 @@ describe( 'selectors', () => {
|
|
|
2416
2815
|
it( 'should allow allowed blocks to be inserted into a block that restricts allowedBlocks', () => {
|
|
2417
2816
|
const state = {
|
|
2418
2817
|
blocks: {
|
|
2419
|
-
byClientId:
|
|
2420
|
-
|
|
2421
|
-
|
|
2422
|
-
|
|
2423
|
-
|
|
2424
|
-
|
|
2818
|
+
byClientId: new Map(
|
|
2819
|
+
Object.entries( {
|
|
2820
|
+
block1: { name: 'core/test-block-a' },
|
|
2821
|
+
} )
|
|
2822
|
+
),
|
|
2823
|
+
attributes: new Map(
|
|
2824
|
+
Object.entries( {
|
|
2825
|
+
block1: {},
|
|
2826
|
+
} )
|
|
2827
|
+
),
|
|
2425
2828
|
},
|
|
2426
2829
|
blockListSettings: {
|
|
2427
2830
|
block1: {
|
|
@@ -2438,12 +2841,16 @@ describe( 'selectors', () => {
|
|
|
2438
2841
|
it( 'should prioritise parent over allowedBlocks', () => {
|
|
2439
2842
|
const state = {
|
|
2440
2843
|
blocks: {
|
|
2441
|
-
byClientId:
|
|
2442
|
-
|
|
2443
|
-
|
|
2444
|
-
|
|
2445
|
-
|
|
2446
|
-
|
|
2844
|
+
byClientId: new Map(
|
|
2845
|
+
Object.entries( {
|
|
2846
|
+
block1: { name: 'core/test-block-b' },
|
|
2847
|
+
} )
|
|
2848
|
+
),
|
|
2849
|
+
attributes: new Map(
|
|
2850
|
+
Object.entries( {
|
|
2851
|
+
block1: {},
|
|
2852
|
+
} )
|
|
2853
|
+
),
|
|
2447
2854
|
},
|
|
2448
2855
|
blockListSettings: {
|
|
2449
2856
|
block1: {
|
|
@@ -2460,12 +2867,16 @@ describe( 'selectors', () => {
|
|
|
2460
2867
|
it( 'should deny blocks that restrict parent to core/post-content when not in editor root', () => {
|
|
2461
2868
|
const state = {
|
|
2462
2869
|
blocks: {
|
|
2463
|
-
byClientId:
|
|
2464
|
-
|
|
2465
|
-
|
|
2466
|
-
|
|
2467
|
-
|
|
2468
|
-
|
|
2870
|
+
byClientId: new Map(
|
|
2871
|
+
Object.entries( {
|
|
2872
|
+
block1: { name: 'core/test-block-c' },
|
|
2873
|
+
} )
|
|
2874
|
+
),
|
|
2875
|
+
attributes: new Map(
|
|
2876
|
+
Object.entries( {
|
|
2877
|
+
block1: {},
|
|
2878
|
+
} )
|
|
2879
|
+
),
|
|
2469
2880
|
},
|
|
2470
2881
|
blockListSettings: {},
|
|
2471
2882
|
settings: {},
|
|
@@ -2478,8 +2889,8 @@ describe( 'selectors', () => {
|
|
|
2478
2889
|
it( 'should allow blocks that restrict parent to core/post-content when in editor root', () => {
|
|
2479
2890
|
const state = {
|
|
2480
2891
|
blocks: {
|
|
2481
|
-
byClientId:
|
|
2482
|
-
attributes:
|
|
2892
|
+
byClientId: new Map(),
|
|
2893
|
+
attributes: new Map(),
|
|
2483
2894
|
},
|
|
2484
2895
|
blockListSettings: {},
|
|
2485
2896
|
settings: {},
|
|
@@ -2492,17 +2903,23 @@ describe( 'selectors', () => {
|
|
|
2492
2903
|
it( 'should allow blocks to be inserted in a descendant of a required ancestor', () => {
|
|
2493
2904
|
const state = {
|
|
2494
2905
|
blocks: {
|
|
2495
|
-
byClientId:
|
|
2496
|
-
|
|
2497
|
-
|
|
2498
|
-
|
|
2499
|
-
|
|
2500
|
-
|
|
2501
|
-
|
|
2502
|
-
|
|
2503
|
-
|
|
2504
|
-
|
|
2505
|
-
|
|
2906
|
+
byClientId: new Map(
|
|
2907
|
+
Object.entries( {
|
|
2908
|
+
block1: { name: 'core/test-block-ancestor' },
|
|
2909
|
+
block2: { name: 'core/block' },
|
|
2910
|
+
} )
|
|
2911
|
+
),
|
|
2912
|
+
attributes: new Map(
|
|
2913
|
+
Object.entries( {
|
|
2914
|
+
block1: {},
|
|
2915
|
+
block2: {},
|
|
2916
|
+
} )
|
|
2917
|
+
),
|
|
2918
|
+
parents: new Map(
|
|
2919
|
+
Object.entries( {
|
|
2920
|
+
block2: 'block1',
|
|
2921
|
+
} )
|
|
2922
|
+
),
|
|
2506
2923
|
},
|
|
2507
2924
|
blockListSettings: {
|
|
2508
2925
|
block1: {},
|
|
@@ -2522,20 +2939,26 @@ describe( 'selectors', () => {
|
|
|
2522
2939
|
it( 'should allow blocks to be inserted if both parent and ancestor restrictions are met', () => {
|
|
2523
2940
|
const state = {
|
|
2524
2941
|
blocks: {
|
|
2525
|
-
byClientId:
|
|
2526
|
-
|
|
2527
|
-
|
|
2528
|
-
|
|
2529
|
-
|
|
2530
|
-
|
|
2531
|
-
|
|
2532
|
-
|
|
2533
|
-
|
|
2534
|
-
|
|
2535
|
-
|
|
2536
|
-
|
|
2537
|
-
|
|
2538
|
-
|
|
2942
|
+
byClientId: new Map(
|
|
2943
|
+
Object.entries( {
|
|
2944
|
+
block1: { name: 'core/test-block-ancestor' },
|
|
2945
|
+
block2: { name: 'core/block' },
|
|
2946
|
+
block3: { name: 'core/test-block-parent' },
|
|
2947
|
+
} )
|
|
2948
|
+
),
|
|
2949
|
+
attributes: new Map(
|
|
2950
|
+
Object.entries( {
|
|
2951
|
+
block1: {},
|
|
2952
|
+
block2: {},
|
|
2953
|
+
block3: {},
|
|
2954
|
+
} )
|
|
2955
|
+
),
|
|
2956
|
+
parents: new Map(
|
|
2957
|
+
Object.entries( {
|
|
2958
|
+
block2: 'block1',
|
|
2959
|
+
block3: 'block2',
|
|
2960
|
+
} )
|
|
2961
|
+
),
|
|
2539
2962
|
},
|
|
2540
2963
|
blockListSettings: {
|
|
2541
2964
|
block1: {},
|
|
@@ -2556,19 +2979,25 @@ describe( 'selectors', () => {
|
|
|
2556
2979
|
it( 'should deny blocks from being inserted outside a required ancestor', () => {
|
|
2557
2980
|
const state = {
|
|
2558
2981
|
blocks: {
|
|
2559
|
-
byClientId:
|
|
2560
|
-
|
|
2561
|
-
|
|
2562
|
-
|
|
2563
|
-
|
|
2564
|
-
|
|
2565
|
-
|
|
2566
|
-
|
|
2567
|
-
|
|
2568
|
-
|
|
2569
|
-
|
|
2570
|
-
|
|
2571
|
-
|
|
2982
|
+
byClientId: new Map(
|
|
2983
|
+
Object.entries( {
|
|
2984
|
+
block1: { name: 'core/test-block-ancestor' },
|
|
2985
|
+
block2: { name: 'core/block' },
|
|
2986
|
+
block3: { name: 'core/block' },
|
|
2987
|
+
} )
|
|
2988
|
+
),
|
|
2989
|
+
attributes: new Map(
|
|
2990
|
+
Object.entries( {
|
|
2991
|
+
block1: {},
|
|
2992
|
+
block2: {},
|
|
2993
|
+
block3: {},
|
|
2994
|
+
} )
|
|
2995
|
+
),
|
|
2996
|
+
parents: new Map(
|
|
2997
|
+
Object.entries( {
|
|
2998
|
+
block3: 'block2',
|
|
2999
|
+
} )
|
|
3000
|
+
),
|
|
2572
3001
|
},
|
|
2573
3002
|
blockListSettings: {
|
|
2574
3003
|
block1: {},
|
|
@@ -2589,19 +3018,25 @@ describe( 'selectors', () => {
|
|
|
2589
3018
|
it( 'should deny blocks from being inserted outside of a required ancestor, even if parent matches', () => {
|
|
2590
3019
|
const state = {
|
|
2591
3020
|
blocks: {
|
|
2592
|
-
byClientId:
|
|
2593
|
-
|
|
2594
|
-
|
|
2595
|
-
|
|
2596
|
-
|
|
2597
|
-
|
|
2598
|
-
|
|
2599
|
-
|
|
2600
|
-
|
|
2601
|
-
|
|
2602
|
-
|
|
2603
|
-
|
|
2604
|
-
|
|
3021
|
+
byClientId: new Map(
|
|
3022
|
+
Object.entries( {
|
|
3023
|
+
block1: { name: 'core/test-block-ancestor' },
|
|
3024
|
+
block2: { name: 'core/block' },
|
|
3025
|
+
block3: { name: 'core/test-block-parent' },
|
|
3026
|
+
} )
|
|
3027
|
+
),
|
|
3028
|
+
attributes: new Map(
|
|
3029
|
+
Object.entries( {
|
|
3030
|
+
block1: {},
|
|
3031
|
+
block2: {},
|
|
3032
|
+
block3: {},
|
|
3033
|
+
} )
|
|
3034
|
+
),
|
|
3035
|
+
parents: new Map(
|
|
3036
|
+
Object.entries( {
|
|
3037
|
+
block3: 'block2',
|
|
3038
|
+
} )
|
|
3039
|
+
),
|
|
2605
3040
|
},
|
|
2606
3041
|
blockListSettings: {
|
|
2607
3042
|
block1: {},
|
|
@@ -2622,17 +3057,23 @@ describe( 'selectors', () => {
|
|
|
2622
3057
|
it( 'should deny blocks from being inserted inside ancestor if parent restricts allowedBlocks', () => {
|
|
2623
3058
|
const state = {
|
|
2624
3059
|
blocks: {
|
|
2625
|
-
byClientId:
|
|
2626
|
-
|
|
2627
|
-
|
|
2628
|
-
|
|
2629
|
-
|
|
2630
|
-
|
|
2631
|
-
|
|
2632
|
-
|
|
2633
|
-
|
|
2634
|
-
|
|
2635
|
-
|
|
3060
|
+
byClientId: new Map(
|
|
3061
|
+
Object.entries( {
|
|
3062
|
+
block1: { name: 'core/test-block-ancestor' },
|
|
3063
|
+
block2: { name: 'core/block' },
|
|
3064
|
+
} )
|
|
3065
|
+
),
|
|
3066
|
+
attributes: new Map(
|
|
3067
|
+
Object.entries( {
|
|
3068
|
+
block1: {},
|
|
3069
|
+
block2: {},
|
|
3070
|
+
} )
|
|
3071
|
+
),
|
|
3072
|
+
parents: new Map(
|
|
3073
|
+
Object.entries( {
|
|
3074
|
+
block2: 'block1',
|
|
3075
|
+
} )
|
|
3076
|
+
),
|
|
2636
3077
|
},
|
|
2637
3078
|
blockListSettings: {
|
|
2638
3079
|
block1: {},
|
|
@@ -2654,17 +3095,23 @@ describe( 'selectors', () => {
|
|
|
2654
3095
|
it( 'should deny blocks from being inserted inside ancestor if parent restriction is not met', () => {
|
|
2655
3096
|
const state = {
|
|
2656
3097
|
blocks: {
|
|
2657
|
-
byClientId:
|
|
2658
|
-
|
|
2659
|
-
|
|
2660
|
-
|
|
2661
|
-
|
|
2662
|
-
|
|
2663
|
-
|
|
2664
|
-
|
|
2665
|
-
|
|
2666
|
-
|
|
2667
|
-
|
|
3098
|
+
byClientId: new Map(
|
|
3099
|
+
Object.entries( {
|
|
3100
|
+
block1: { name: 'core/test-block-ancestor' },
|
|
3101
|
+
block2: { name: 'core/block' },
|
|
3102
|
+
} )
|
|
3103
|
+
),
|
|
3104
|
+
attributes: new Map(
|
|
3105
|
+
Object.entries( {
|
|
3106
|
+
block1: {},
|
|
3107
|
+
block2: {},
|
|
3108
|
+
} )
|
|
3109
|
+
),
|
|
3110
|
+
parents: new Map(
|
|
3111
|
+
Object.entries( {
|
|
3112
|
+
block2: 'block1',
|
|
3113
|
+
} )
|
|
3114
|
+
),
|
|
2668
3115
|
},
|
|
2669
3116
|
blockListSettings: {
|
|
2670
3117
|
block1: {},
|
|
@@ -2686,16 +3133,20 @@ describe( 'selectors', () => {
|
|
|
2686
3133
|
it( 'should allow blocks', () => {
|
|
2687
3134
|
const state = {
|
|
2688
3135
|
blocks: {
|
|
2689
|
-
byClientId:
|
|
2690
|
-
|
|
2691
|
-
|
|
2692
|
-
|
|
2693
|
-
|
|
2694
|
-
|
|
2695
|
-
|
|
2696
|
-
|
|
2697
|
-
|
|
2698
|
-
|
|
3136
|
+
byClientId: new Map(
|
|
3137
|
+
Object.entries( {
|
|
3138
|
+
1: { name: 'core/test-block-a' },
|
|
3139
|
+
2: { name: 'core/test-block-b' },
|
|
3140
|
+
3: { name: 'core/test-block-c' },
|
|
3141
|
+
} )
|
|
3142
|
+
),
|
|
3143
|
+
attributes: new Map(
|
|
3144
|
+
Object.entries( {
|
|
3145
|
+
1: {},
|
|
3146
|
+
2: {},
|
|
3147
|
+
3: {},
|
|
3148
|
+
} )
|
|
3149
|
+
),
|
|
2699
3150
|
},
|
|
2700
3151
|
blockListSettings: {
|
|
2701
3152
|
1: {
|
|
@@ -2713,16 +3164,20 @@ describe( 'selectors', () => {
|
|
|
2713
3164
|
it( 'should deny blocks', () => {
|
|
2714
3165
|
const state = {
|
|
2715
3166
|
blocks: {
|
|
2716
|
-
byClientId:
|
|
2717
|
-
|
|
2718
|
-
|
|
2719
|
-
|
|
2720
|
-
|
|
2721
|
-
|
|
2722
|
-
|
|
2723
|
-
|
|
2724
|
-
|
|
2725
|
-
|
|
3167
|
+
byClientId: new Map(
|
|
3168
|
+
Object.entries( {
|
|
3169
|
+
1: { name: 'core/test-block-a' },
|
|
3170
|
+
2: { name: 'core/test-block-b' },
|
|
3171
|
+
3: { name: 'core/test-block-c' },
|
|
3172
|
+
} )
|
|
3173
|
+
),
|
|
3174
|
+
attributes: new Map(
|
|
3175
|
+
Object.entries( {
|
|
3176
|
+
1: {},
|
|
3177
|
+
2: {},
|
|
3178
|
+
3: {},
|
|
3179
|
+
} )
|
|
3180
|
+
),
|
|
2726
3181
|
},
|
|
2727
3182
|
blockListSettings: {
|
|
2728
3183
|
1: {
|
|
@@ -2739,15 +3194,17 @@ describe( 'selectors', () => {
|
|
|
2739
3194
|
it( 'should properly list block type and reusable block items', () => {
|
|
2740
3195
|
const state = {
|
|
2741
3196
|
blocks: {
|
|
2742
|
-
byClientId:
|
|
2743
|
-
attributes:
|
|
2744
|
-
order:
|
|
2745
|
-
parents:
|
|
2746
|
-
tree:
|
|
2747
|
-
|
|
2748
|
-
|
|
2749
|
-
|
|
2750
|
-
|
|
3197
|
+
byClientId: new Map(),
|
|
3198
|
+
attributes: new Map(),
|
|
3199
|
+
order: new Map(),
|
|
3200
|
+
parents: new Map(),
|
|
3201
|
+
tree: new Map(
|
|
3202
|
+
Object.entries( {
|
|
3203
|
+
'': {
|
|
3204
|
+
innerBlocks: [],
|
|
3205
|
+
},
|
|
3206
|
+
} )
|
|
3207
|
+
),
|
|
2751
3208
|
},
|
|
2752
3209
|
settings: {
|
|
2753
3210
|
__experimentalReusableBlocks: [
|
|
@@ -2808,35 +3265,45 @@ describe( 'selectors', () => {
|
|
|
2808
3265
|
it( 'should correctly cache the return values', () => {
|
|
2809
3266
|
const state = {
|
|
2810
3267
|
blocks: {
|
|
2811
|
-
byClientId:
|
|
2812
|
-
|
|
2813
|
-
|
|
2814
|
-
|
|
2815
|
-
|
|
2816
|
-
|
|
2817
|
-
|
|
2818
|
-
|
|
2819
|
-
|
|
2820
|
-
|
|
2821
|
-
|
|
2822
|
-
|
|
2823
|
-
|
|
2824
|
-
|
|
2825
|
-
|
|
2826
|
-
|
|
2827
|
-
|
|
2828
|
-
|
|
2829
|
-
|
|
2830
|
-
|
|
2831
|
-
|
|
2832
|
-
}
|
|
2833
|
-
|
|
2834
|
-
|
|
2835
|
-
|
|
2836
|
-
|
|
2837
|
-
|
|
2838
|
-
|
|
2839
|
-
|
|
3268
|
+
byClientId: new Map(
|
|
3269
|
+
Object.entries( {
|
|
3270
|
+
block3: { name: 'core/test-block-a' },
|
|
3271
|
+
block4: { name: 'core/test-block-a' },
|
|
3272
|
+
} )
|
|
3273
|
+
),
|
|
3274
|
+
attributes: new Map(
|
|
3275
|
+
Object.entries( {
|
|
3276
|
+
block3: {},
|
|
3277
|
+
block4: {},
|
|
3278
|
+
} )
|
|
3279
|
+
),
|
|
3280
|
+
order: new Map(
|
|
3281
|
+
Object.entries( {
|
|
3282
|
+
'': [ 'block3', 'block4' ],
|
|
3283
|
+
} )
|
|
3284
|
+
),
|
|
3285
|
+
parents: new Map(
|
|
3286
|
+
Object.entries( {
|
|
3287
|
+
block3: '',
|
|
3288
|
+
block4: '',
|
|
3289
|
+
} )
|
|
3290
|
+
),
|
|
3291
|
+
tree: new Map(
|
|
3292
|
+
Object.entries( {
|
|
3293
|
+
block3: {
|
|
3294
|
+
clientId: 'block3',
|
|
3295
|
+
name: 'core/test-block-a',
|
|
3296
|
+
attributes: {},
|
|
3297
|
+
innerBlocks: [],
|
|
3298
|
+
},
|
|
3299
|
+
block4: {
|
|
3300
|
+
clientId: 'block4',
|
|
3301
|
+
name: 'core/test-block-a',
|
|
3302
|
+
attributes: {},
|
|
3303
|
+
innerBlocks: [],
|
|
3304
|
+
},
|
|
3305
|
+
} )
|
|
3306
|
+
),
|
|
2840
3307
|
controlledInnerBlocks: {},
|
|
2841
3308
|
},
|
|
2842
3309
|
settings: {
|
|
@@ -2915,28 +3382,36 @@ describe( 'selectors', () => {
|
|
|
2915
3382
|
it( 'should set isDisabled when a block with `multiple: false` has been used', () => {
|
|
2916
3383
|
const state = {
|
|
2917
3384
|
blocks: {
|
|
2918
|
-
byClientId:
|
|
2919
|
-
|
|
2920
|
-
|
|
2921
|
-
|
|
2922
|
-
|
|
2923
|
-
|
|
2924
|
-
|
|
2925
|
-
|
|
2926
|
-
|
|
2927
|
-
|
|
2928
|
-
|
|
2929
|
-
|
|
2930
|
-
|
|
2931
|
-
|
|
2932
|
-
|
|
2933
|
-
|
|
2934
|
-
|
|
2935
|
-
|
|
2936
|
-
|
|
2937
|
-
|
|
3385
|
+
byClientId: new Map(
|
|
3386
|
+
Object.entries( {
|
|
3387
|
+
block1: {
|
|
3388
|
+
clientId: 'block1',
|
|
3389
|
+
name: 'core/test-block-b',
|
|
3390
|
+
},
|
|
3391
|
+
} )
|
|
3392
|
+
),
|
|
3393
|
+
attributes: new Map(
|
|
3394
|
+
Object.entries( {
|
|
3395
|
+
block1: { attribute: {} },
|
|
3396
|
+
} )
|
|
3397
|
+
),
|
|
3398
|
+
order: new Map(
|
|
3399
|
+
Object.entries( {
|
|
3400
|
+
'': [ 'block1' ],
|
|
3401
|
+
} )
|
|
3402
|
+
),
|
|
3403
|
+
tree: new Map(
|
|
3404
|
+
Object.entries( {
|
|
3405
|
+
block1: {
|
|
3406
|
+
clientId: 'block1',
|
|
3407
|
+
name: 'core/test-block-b',
|
|
3408
|
+
attributes: {},
|
|
3409
|
+
innerBlocks: [],
|
|
3410
|
+
},
|
|
3411
|
+
} )
|
|
3412
|
+
),
|
|
2938
3413
|
controlledInnerBlocks: {},
|
|
2939
|
-
parents:
|
|
3414
|
+
parents: new Map(),
|
|
2940
3415
|
},
|
|
2941
3416
|
preferences: {
|
|
2942
3417
|
insertUsage: {},
|
|
@@ -2954,10 +3429,10 @@ describe( 'selectors', () => {
|
|
|
2954
3429
|
it( 'should set a frecency', () => {
|
|
2955
3430
|
const state = {
|
|
2956
3431
|
blocks: {
|
|
2957
|
-
byClientId:
|
|
2958
|
-
attributes:
|
|
2959
|
-
order:
|
|
2960
|
-
parents:
|
|
3432
|
+
byClientId: new Map(),
|
|
3433
|
+
attributes: new Map(),
|
|
3434
|
+
order: new Map(),
|
|
3435
|
+
parents: new Map(),
|
|
2961
3436
|
cache: {},
|
|
2962
3437
|
},
|
|
2963
3438
|
preferences: {
|
|
@@ -3049,10 +3524,10 @@ describe( 'selectors', () => {
|
|
|
3049
3524
|
it( 'should properly return block type items', () => {
|
|
3050
3525
|
const state = {
|
|
3051
3526
|
blocks: {
|
|
3052
|
-
byClientId:
|
|
3053
|
-
attributes:
|
|
3054
|
-
order:
|
|
3055
|
-
parents:
|
|
3527
|
+
byClientId: new Map(),
|
|
3528
|
+
attributes: new Map(),
|
|
3529
|
+
order: new Map(),
|
|
3530
|
+
parents: new Map(),
|
|
3056
3531
|
cache: {},
|
|
3057
3532
|
},
|
|
3058
3533
|
settings: {},
|
|
@@ -3089,10 +3564,10 @@ describe( 'selectors', () => {
|
|
|
3089
3564
|
it( 'should support single block object', () => {
|
|
3090
3565
|
const state = {
|
|
3091
3566
|
blocks: {
|
|
3092
|
-
byClientId:
|
|
3093
|
-
attributes:
|
|
3094
|
-
order:
|
|
3095
|
-
parents:
|
|
3567
|
+
byClientId: new Map(),
|
|
3568
|
+
attributes: new Map(),
|
|
3569
|
+
order: new Map(),
|
|
3570
|
+
parents: new Map(),
|
|
3096
3571
|
cache: {},
|
|
3097
3572
|
},
|
|
3098
3573
|
settings: {},
|
|
@@ -3106,19 +3581,25 @@ describe( 'selectors', () => {
|
|
|
3106
3581
|
it( 'should return only eligible blocks for transformation - `allowedBlocks`', () => {
|
|
3107
3582
|
const state = {
|
|
3108
3583
|
blocks: {
|
|
3109
|
-
byClientId:
|
|
3110
|
-
|
|
3111
|
-
|
|
3112
|
-
|
|
3113
|
-
|
|
3114
|
-
|
|
3115
|
-
|
|
3116
|
-
|
|
3117
|
-
|
|
3118
|
-
|
|
3119
|
-
|
|
3120
|
-
|
|
3121
|
-
|
|
3584
|
+
byClientId: new Map(
|
|
3585
|
+
Object.entries( {
|
|
3586
|
+
block1: { name: 'core/with-tranforms-b' },
|
|
3587
|
+
block2: { name: 'core/with-tranforms-a' },
|
|
3588
|
+
} )
|
|
3589
|
+
),
|
|
3590
|
+
attributes: new Map(
|
|
3591
|
+
Object.entries( {
|
|
3592
|
+
block1: {},
|
|
3593
|
+
block2: {},
|
|
3594
|
+
} )
|
|
3595
|
+
),
|
|
3596
|
+
order: new Map(),
|
|
3597
|
+
parents: new Map(
|
|
3598
|
+
Object.entries( {
|
|
3599
|
+
block1: '',
|
|
3600
|
+
block2: 'block1',
|
|
3601
|
+
} )
|
|
3602
|
+
),
|
|
3122
3603
|
cache: {},
|
|
3123
3604
|
controlledInnerBlocks: {},
|
|
3124
3605
|
},
|
|
@@ -3141,28 +3622,36 @@ describe( 'selectors', () => {
|
|
|
3141
3622
|
it( 'should take into account the usage of blocks settings `multiple` - if multiple blocks of the same type are allowed', () => {
|
|
3142
3623
|
const state = {
|
|
3143
3624
|
blocks: {
|
|
3144
|
-
byClientId:
|
|
3145
|
-
|
|
3146
|
-
|
|
3147
|
-
|
|
3148
|
-
|
|
3149
|
-
|
|
3150
|
-
|
|
3151
|
-
|
|
3152
|
-
|
|
3153
|
-
|
|
3154
|
-
|
|
3155
|
-
|
|
3156
|
-
|
|
3157
|
-
|
|
3158
|
-
|
|
3159
|
-
|
|
3160
|
-
|
|
3161
|
-
|
|
3162
|
-
|
|
3163
|
-
|
|
3625
|
+
byClientId: new Map(
|
|
3626
|
+
Object.entries( {
|
|
3627
|
+
block1: {
|
|
3628
|
+
clientId: 'block1',
|
|
3629
|
+
name: 'core/with-tranforms-c',
|
|
3630
|
+
},
|
|
3631
|
+
} )
|
|
3632
|
+
),
|
|
3633
|
+
attributes: new Map(
|
|
3634
|
+
Object.entries( {
|
|
3635
|
+
block1: { attribute: {} },
|
|
3636
|
+
} )
|
|
3637
|
+
),
|
|
3638
|
+
order: new Map(
|
|
3639
|
+
Object.entries( {
|
|
3640
|
+
'': [ 'block1' ],
|
|
3641
|
+
} )
|
|
3642
|
+
),
|
|
3643
|
+
tree: new Map(
|
|
3644
|
+
Object.entries( {
|
|
3645
|
+
block1: {
|
|
3646
|
+
clientId: 'block1',
|
|
3647
|
+
name: 'core/with-tranforms-c',
|
|
3648
|
+
attributes: {},
|
|
3649
|
+
innerBlocks: [],
|
|
3650
|
+
},
|
|
3651
|
+
} )
|
|
3652
|
+
),
|
|
3164
3653
|
controlledInnerBlocks: {},
|
|
3165
|
-
parents:
|
|
3654
|
+
parents: new Map(),
|
|
3166
3655
|
},
|
|
3167
3656
|
preferences: {
|
|
3168
3657
|
insertUsage: {},
|
|
@@ -3189,10 +3678,10 @@ describe( 'selectors', () => {
|
|
|
3189
3678
|
it( 'should set frecency', () => {
|
|
3190
3679
|
const state = {
|
|
3191
3680
|
blocks: {
|
|
3192
|
-
byClientId:
|
|
3193
|
-
attributes:
|
|
3194
|
-
order:
|
|
3195
|
-
parents:
|
|
3681
|
+
byClientId: new Map(),
|
|
3682
|
+
attributes: new Map(),
|
|
3683
|
+
order: new Map(),
|
|
3684
|
+
parents: new Map(),
|
|
3196
3685
|
cache: {},
|
|
3197
3686
|
},
|
|
3198
3687
|
preferences: {
|
|
@@ -3245,7 +3734,7 @@ describe( 'selectors', () => {
|
|
|
3245
3734
|
} );
|
|
3246
3735
|
|
|
3247
3736
|
describe( 'getTemplateLock', () => {
|
|
3248
|
-
it( 'should return the general template lock if no clientId was
|
|
3737
|
+
it( 'should return the general template lock if no clientId was specified', () => {
|
|
3249
3738
|
const state = {
|
|
3250
3739
|
settings: { templateLock: 'all' },
|
|
3251
3740
|
};
|
|
@@ -3253,7 +3742,7 @@ describe( 'selectors', () => {
|
|
|
3253
3742
|
expect( getTemplateLock( state ) ).toBe( 'all' );
|
|
3254
3743
|
} );
|
|
3255
3744
|
|
|
3256
|
-
it( 'should return
|
|
3745
|
+
it( 'should return false if the specified clientId was not found', () => {
|
|
3257
3746
|
const state = {
|
|
3258
3747
|
settings: { templateLock: 'all' },
|
|
3259
3748
|
blockListSettings: {
|
|
@@ -3263,10 +3752,10 @@ describe( 'selectors', () => {
|
|
|
3263
3752
|
},
|
|
3264
3753
|
};
|
|
3265
3754
|
|
|
3266
|
-
expect( getTemplateLock( state, 'ribs' ) ).toBe(
|
|
3755
|
+
expect( getTemplateLock( state, 'ribs' ) ).toBe( false );
|
|
3267
3756
|
} );
|
|
3268
3757
|
|
|
3269
|
-
it( 'should return
|
|
3758
|
+
it( 'should return false if template lock was not set on the specified block', () => {
|
|
3270
3759
|
const state = {
|
|
3271
3760
|
settings: { templateLock: 'all' },
|
|
3272
3761
|
blockListSettings: {
|
|
@@ -3276,7 +3765,7 @@ describe( 'selectors', () => {
|
|
|
3276
3765
|
},
|
|
3277
3766
|
};
|
|
3278
3767
|
|
|
3279
|
-
expect( getTemplateLock( state, '
|
|
3768
|
+
expect( getTemplateLock( state, 'chicken' ) ).toBe( false );
|
|
3280
3769
|
} );
|
|
3281
3770
|
|
|
3282
3771
|
it( 'should return the template lock for the specified clientId', () => {
|
|
@@ -3410,20 +3899,24 @@ describe( 'selectors', () => {
|
|
|
3410
3899
|
|
|
3411
3900
|
describe( 'getLowestCommonAncestorWithSelectedBlock', () => {
|
|
3412
3901
|
const blocks = {
|
|
3413
|
-
order:
|
|
3414
|
-
|
|
3415
|
-
|
|
3416
|
-
|
|
3417
|
-
|
|
3418
|
-
|
|
3419
|
-
|
|
3420
|
-
|
|
3421
|
-
|
|
3422
|
-
|
|
3423
|
-
|
|
3424
|
-
|
|
3425
|
-
|
|
3426
|
-
|
|
3902
|
+
order: new Map(
|
|
3903
|
+
Object.entries( {
|
|
3904
|
+
'': [ 'a', 'b' ],
|
|
3905
|
+
a: [ 'c', 'd' ],
|
|
3906
|
+
d: [ 'e' ],
|
|
3907
|
+
b: [ 'f' ],
|
|
3908
|
+
} )
|
|
3909
|
+
),
|
|
3910
|
+
parents: new Map(
|
|
3911
|
+
Object.entries( {
|
|
3912
|
+
a: '',
|
|
3913
|
+
b: '',
|
|
3914
|
+
c: 'a',
|
|
3915
|
+
d: 'a',
|
|
3916
|
+
e: 'd',
|
|
3917
|
+
f: 'b',
|
|
3918
|
+
} )
|
|
3919
|
+
),
|
|
3427
3920
|
};
|
|
3428
3921
|
|
|
3429
3922
|
it( 'should not be defined if there is no block selected', () => {
|
|
@@ -3522,35 +4015,39 @@ describe( 'selectors', () => {
|
|
|
3522
4015
|
},
|
|
3523
4016
|
},
|
|
3524
4017
|
blocks: {
|
|
3525
|
-
parents:
|
|
3526
|
-
|
|
3527
|
-
|
|
3528
|
-
|
|
3529
|
-
|
|
3530
|
-
|
|
3531
|
-
|
|
3532
|
-
|
|
3533
|
-
|
|
3534
|
-
|
|
3535
|
-
|
|
3536
|
-
|
|
3537
|
-
|
|
3538
|
-
|
|
3539
|
-
|
|
3540
|
-
|
|
3541
|
-
|
|
3542
|
-
|
|
3543
|
-
|
|
3544
|
-
|
|
3545
|
-
|
|
3546
|
-
|
|
3547
|
-
|
|
3548
|
-
|
|
3549
|
-
|
|
3550
|
-
|
|
3551
|
-
|
|
3552
|
-
|
|
3553
|
-
|
|
4018
|
+
parents: new Map(
|
|
4019
|
+
Object.entries( {
|
|
4020
|
+
'client-id-01': '',
|
|
4021
|
+
'client-id-02': 'client-id-01',
|
|
4022
|
+
'client-id-03': 'client-id-02',
|
|
4023
|
+
'client-id-04': 'client-id-03',
|
|
4024
|
+
'client-id-05': 'client-id-03',
|
|
4025
|
+
} )
|
|
4026
|
+
),
|
|
4027
|
+
byClientId: new Map(
|
|
4028
|
+
Object.entries( {
|
|
4029
|
+
'client-id-01': {
|
|
4030
|
+
clientId: 'client-id-01',
|
|
4031
|
+
name: 'core/columns',
|
|
4032
|
+
},
|
|
4033
|
+
'client-id-02': {
|
|
4034
|
+
clientId: 'client-id-02',
|
|
4035
|
+
name: 'core/navigation',
|
|
4036
|
+
},
|
|
4037
|
+
'client-id-03': {
|
|
4038
|
+
clientId: 'client-id-03',
|
|
4039
|
+
name: 'core/navigation-link',
|
|
4040
|
+
},
|
|
4041
|
+
'client-id-04': {
|
|
4042
|
+
clientId: 'client-id-04',
|
|
4043
|
+
name: 'core/navigation-link',
|
|
4044
|
+
},
|
|
4045
|
+
'client-id-05': {
|
|
4046
|
+
clientId: 'client-id-05',
|
|
4047
|
+
name: 'core/navigation-link',
|
|
4048
|
+
},
|
|
4049
|
+
} )
|
|
4050
|
+
),
|
|
3554
4051
|
cache: {
|
|
3555
4052
|
'client-id-01': {},
|
|
3556
4053
|
'client-id-02': {},
|
|
@@ -3558,9 +4055,11 @@ describe( 'selectors', () => {
|
|
|
3558
4055
|
'client-id-04': {},
|
|
3559
4056
|
'client-id-05': {},
|
|
3560
4057
|
},
|
|
3561
|
-
order:
|
|
3562
|
-
|
|
3563
|
-
|
|
4058
|
+
order: new Map(
|
|
4059
|
+
Object.entries( {
|
|
4060
|
+
'client-id-03': [ 'client-id-04', 'client-id-05' ],
|
|
4061
|
+
} )
|
|
4062
|
+
),
|
|
3564
4063
|
controlledInnerBlocks: {},
|
|
3565
4064
|
},
|
|
3566
4065
|
};
|
|
@@ -3592,14 +4091,18 @@ describe( 'selectors', () => {
|
|
|
3592
4091
|
describe( '__experimentalGetAllowedPatterns', () => {
|
|
3593
4092
|
const state = {
|
|
3594
4093
|
blocks: {
|
|
3595
|
-
byClientId:
|
|
3596
|
-
|
|
3597
|
-
|
|
3598
|
-
|
|
3599
|
-
|
|
3600
|
-
|
|
3601
|
-
|
|
3602
|
-
|
|
4094
|
+
byClientId: new Map(
|
|
4095
|
+
Object.entries( {
|
|
4096
|
+
block1: { name: 'core/test-block-a' },
|
|
4097
|
+
block2: { name: 'core/test-block-b' },
|
|
4098
|
+
} )
|
|
4099
|
+
),
|
|
4100
|
+
attributes: new Map(
|
|
4101
|
+
Object.entries( {
|
|
4102
|
+
block1: {},
|
|
4103
|
+
block2: {},
|
|
4104
|
+
} )
|
|
4105
|
+
),
|
|
3603
4106
|
},
|
|
3604
4107
|
blockListSettings: {
|
|
3605
4108
|
block1: {
|
|
@@ -3651,7 +4154,7 @@ describe( 'selectors', () => {
|
|
|
3651
4154
|
it( 'should return empty array if only patterns hidden from UI exist', () => {
|
|
3652
4155
|
expect(
|
|
3653
4156
|
__experimentalGetAllowedPatterns( {
|
|
3654
|
-
blocks: { byClientId:
|
|
4157
|
+
blocks: { byClientId: new Map() },
|
|
3655
4158
|
blockListSettings: {},
|
|
3656
4159
|
settings: {
|
|
3657
4160
|
__experimentalBlockPatterns: [
|
|
@@ -3723,9 +4226,11 @@ describe( 'selectors', () => {
|
|
|
3723
4226
|
describe( '__experimentalGetPatternsByBlockTypes', () => {
|
|
3724
4227
|
const state = {
|
|
3725
4228
|
blocks: {
|
|
3726
|
-
byClientId:
|
|
3727
|
-
|
|
3728
|
-
|
|
4229
|
+
byClientId: new Map(
|
|
4230
|
+
Object.entries( {
|
|
4231
|
+
block1: { name: 'core/test-block-a' },
|
|
4232
|
+
} )
|
|
4233
|
+
),
|
|
3729
4234
|
},
|
|
3730
4235
|
blockListSettings: {
|
|
3731
4236
|
block1: {
|
|
@@ -3797,10 +4302,12 @@ describe( 'selectors', () => {
|
|
|
3797
4302
|
describe( '__experimentalGetPatternTransformItems', () => {
|
|
3798
4303
|
const state = {
|
|
3799
4304
|
blocks: {
|
|
3800
|
-
byClientId:
|
|
3801
|
-
|
|
3802
|
-
|
|
3803
|
-
|
|
4305
|
+
byClientId: new Map(
|
|
4306
|
+
Object.entries( {
|
|
4307
|
+
block1: { name: 'core/test-block-a' },
|
|
4308
|
+
block2: { name: 'core/test-block-b' },
|
|
4309
|
+
} )
|
|
4310
|
+
),
|
|
3804
4311
|
controlledInnerBlocks: { 'block2-clientId': true },
|
|
3805
4312
|
},
|
|
3806
4313
|
blockListSettings: {
|
|
@@ -4054,10 +4561,10 @@ describe( 'getInserterItems with core blocks prioritization', () => {
|
|
|
4054
4561
|
it( 'should prioritize core blocks by sorting them at the top of the returned list', () => {
|
|
4055
4562
|
const state = {
|
|
4056
4563
|
blocks: {
|
|
4057
|
-
byClientId:
|
|
4058
|
-
attributes:
|
|
4059
|
-
order:
|
|
4060
|
-
parents:
|
|
4564
|
+
byClientId: new Map(),
|
|
4565
|
+
attributes: new Map(),
|
|
4566
|
+
order: new Map(),
|
|
4567
|
+
parents: new Map(),
|
|
4061
4568
|
cache: {},
|
|
4062
4569
|
},
|
|
4063
4570
|
settings: {},
|
|
@@ -4085,11 +4592,13 @@ describe( '__unstableGetClientIdWithClientIdsTree', () => {
|
|
|
4085
4592
|
it( "should return a stripped down block object containing only its client ID and its inner blocks' client IDs", () => {
|
|
4086
4593
|
const state = {
|
|
4087
4594
|
blocks: {
|
|
4088
|
-
order:
|
|
4089
|
-
|
|
4090
|
-
|
|
4091
|
-
|
|
4092
|
-
|
|
4595
|
+
order: new Map(
|
|
4596
|
+
Object.entries( {
|
|
4597
|
+
'': [ 'foo' ],
|
|
4598
|
+
foo: [ 'bar', 'baz' ],
|
|
4599
|
+
bar: [ 'qux' ],
|
|
4600
|
+
} )
|
|
4601
|
+
),
|
|
4093
4602
|
},
|
|
4094
4603
|
};
|
|
4095
4604
|
|
|
@@ -4111,11 +4620,13 @@ describe( '__unstableGetClientIdsTree', () => {
|
|
|
4111
4620
|
it( "should return the full content tree starting from the given root, consisting of stripped down block object containing only its client ID and its inner blocks' client IDs", () => {
|
|
4112
4621
|
const state = {
|
|
4113
4622
|
blocks: {
|
|
4114
|
-
order:
|
|
4115
|
-
|
|
4116
|
-
|
|
4117
|
-
|
|
4118
|
-
|
|
4623
|
+
order: new Map(
|
|
4624
|
+
Object.entries( {
|
|
4625
|
+
'': [ 'foo' ],
|
|
4626
|
+
foo: [ 'bar', 'baz' ],
|
|
4627
|
+
bar: [ 'qux' ],
|
|
4628
|
+
} )
|
|
4629
|
+
),
|
|
4119
4630
|
},
|
|
4120
4631
|
};
|
|
4121
4632
|
|
|
@@ -4131,11 +4642,13 @@ describe( '__unstableGetClientIdsTree', () => {
|
|
|
4131
4642
|
it( "should return the full content tree starting from the root, consisting of stripped down block object containing only its client ID and its inner blocks' client IDs", () => {
|
|
4132
4643
|
const state = {
|
|
4133
4644
|
blocks: {
|
|
4134
|
-
order:
|
|
4135
|
-
|
|
4136
|
-
|
|
4137
|
-
|
|
4138
|
-
|
|
4645
|
+
order: new Map(
|
|
4646
|
+
Object.entries( {
|
|
4647
|
+
'': [ 'foo' ],
|
|
4648
|
+
foo: [ 'bar', 'baz' ],
|
|
4649
|
+
bar: [ 'qux' ],
|
|
4650
|
+
} )
|
|
4651
|
+
),
|
|
4139
4652
|
},
|
|
4140
4653
|
};
|
|
4141
4654
|
|
|
@@ -4153,3 +4666,23 @@ describe( '__unstableGetClientIdsTree', () => {
|
|
|
4153
4666
|
] );
|
|
4154
4667
|
} );
|
|
4155
4668
|
} );
|
|
4669
|
+
|
|
4670
|
+
describe( 'getLastInsertedBlockClientId', () => {
|
|
4671
|
+
it( 'should return undefined if no blocks have been inserted', () => {
|
|
4672
|
+
const state = {
|
|
4673
|
+
lastBlockInserted: {},
|
|
4674
|
+
};
|
|
4675
|
+
|
|
4676
|
+
expect( getLastInsertedBlockClientId( state ) ).toEqual( undefined );
|
|
4677
|
+
} );
|
|
4678
|
+
|
|
4679
|
+
it( 'should return clientId if blocks have been inserted', () => {
|
|
4680
|
+
const state = {
|
|
4681
|
+
lastBlockInserted: {
|
|
4682
|
+
clientId: '123456',
|
|
4683
|
+
},
|
|
4684
|
+
};
|
|
4685
|
+
|
|
4686
|
+
expect( getLastInsertedBlockClientId( state ) ).toEqual( '123456' );
|
|
4687
|
+
} );
|
|
4688
|
+
} );
|