@wordpress/block-editor 10.5.0 → 11.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +18 -0
- package/README.md +2 -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/alignment-control/ui.js +1 -7
- package/build/components/alignment-control/ui.js.map +1 -1
- package/build/components/block-alignment-control/use-available-alignments.js +4 -3
- package/build/components/block-alignment-control/use-available-alignments.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-icon/index.js +4 -2
- package/build/components/block-icon/index.js.map +1 -1
- package/build/components/block-inspector/index.js +90 -37
- 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-list-appender/index.js +46 -34
- package/build/components/block-list-appender/index.js.map +1 -1
- package/build/components/block-list-appender/index.native.js +39 -34
- package/build/components/block-list-appender/index.native.js.map +1 -1
- package/build/components/block-mobile-toolbar/block-actions-menu.native.js +30 -22
- package/build/components/block-mobile-toolbar/block-actions-menu.native.js.map +1 -1
- package/build/components/block-mobile-toolbar/index.native.js +1 -1
- package/build/components/block-mobile-toolbar/index.native.js.map +1 -1
- package/build/components/block-pattern-setup/index.js +16 -8
- 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/index.native.js +1 -3
- package/build/components/block-styles/index.native.js.map +1 -1
- package/build/components/block-styles/utils.js +7 -10
- package/build/components/block-styles/utils.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-toolbar/index.native.js +6 -8
- package/build/components/block-toolbar/index.native.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 +1 -3
- package/build/components/block-tools/selected-block-popover.js.map +1 -1
- package/build/components/block-variation-picker/index.js +2 -3
- package/build/components/block-variation-picker/index.js.map +1 -1
- package/build/components/colors/utils.js +2 -6
- package/build/components/colors/utils.js.map +1 -1
- package/build/components/colors-gradients/control.js +0 -3
- package/build/components/colors-gradients/control.js.map +1 -1
- package/build/components/colors-gradients/dropdown.js +0 -2
- package/build/components/colors-gradients/dropdown.js.map +1 -1
- package/build/components/colors-gradients/panel-color-gradient-settings.js +2 -19
- package/build/components/colors-gradients/panel-color-gradient-settings.js.map +1 -1
- package/build/components/colors-gradients/use-multiple-origin-colors-and-gradients.js +4 -3
- package/build/components/colors-gradients/use-multiple-origin-colors-and-gradients.js.map +1 -1
- package/build/components/copy-handler/index.js +37 -9
- package/build/components/copy-handler/index.js.map +1 -1
- package/build/components/font-sizes/fluid-utils.js +5 -2
- package/build/components/font-sizes/fluid-utils.js.map +1 -1
- package/build/components/font-sizes/utils.js +10 -4
- package/build/components/font-sizes/utils.js.map +1 -1
- package/build/components/font-sizes/with-font-sizes.js +11 -6
- package/build/components/font-sizes/with-font-sizes.js.map +1 -1
- package/build/components/gradients/use-gradient.js +2 -8
- package/build/components/gradients/use-gradient.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 +22 -101
- package/build/components/iframe/index.js.map +1 -1
- package/build/components/iframe/use-compatibility-styles.js +93 -0
- package/build/components/iframe/use-compatibility-styles.js.map +1 -0
- 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 +9 -0
- package/build/components/index.js.map +1 -1
- package/build/components/inner-blocks/index.js +25 -7
- 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/hooks/use-insertion-point.js +4 -3
- package/build/components/inserter/hooks/use-insertion-point.js.map +1 -1
- package/build/components/inserter/index.js +20 -6
- 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 +106 -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 +7 -3
- package/build/components/inserter/quick-inserter.js.map +1 -1
- package/build/components/inserter/search-items.js +15 -14
- package/build/components/inserter/search-items.js.map +1 -1
- package/build/components/inserter/search-results.js +7 -3
- 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 +1 -0
- package/build/components/link-control/index.js.map +1 -1
- package/build/components/link-control/search-input.js +0 -1
- package/build/components/link-control/search-input.js.map +1 -1
- package/build/components/link-control/use-internal-input-value.js +3 -3
- package/build/components/link-control/use-internal-input-value.js.map +1 -1
- package/build/components/list-view/block-select-button.js +1 -1
- package/build/components/list-view/block-select-button.js.map +1 -1
- package/build/components/list-view/block.js +5 -2
- package/build/components/list-view/block.js.map +1 -1
- package/build/components/list-view/branch.js +13 -12
- 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 +99 -0
- package/build/components/off-canvas-editor/appender.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 +3 -2
- package/build/components/off-canvas-editor/block-select-button.js.map +1 -1
- package/build/components/off-canvas-editor/block.js +82 -38
- package/build/components/off-canvas-editor/block.js.map +1 -1
- package/build/components/off-canvas-editor/branch.js +3 -5
- package/build/components/off-canvas-editor/branch.js.map +1 -1
- package/build/components/off-canvas-editor/index.js +24 -11
- package/build/components/off-canvas-editor/index.js.map +1 -1
- package/build/components/off-canvas-editor/leaf.js +1 -1
- package/build/components/off-canvas-editor/leaf.js.map +1 -1
- 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-inserted-block.js +58 -0
- package/build/components/off-canvas-editor/use-inserted-block.js.map +1 -0
- package/build/components/responsive-block-control/label.js.map +1 -1
- package/build/components/rich-text/format-edit.js +12 -10
- package/build/components/rich-text/format-edit.js.map +1 -1
- 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-paste-handler.js +21 -12
- package/build/components/rich-text/use-paste-handler.js.map +1 -1
- 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/index.js +0 -1
- package/build/components/spacing-sizes-control/index.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/spacing-sizes-control/utils.js +1 -1
- package/build/components/spacing-sizes-control/utils.js.map +1 -1
- package/build/components/typewriter/index.js +1 -1
- package/build/components/typewriter/index.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/image-url-input-ui.js +2 -2
- package/build/components/url-popover/image-url-input-ui.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 +9 -1
- package/build/components/use-setting/index.js.map +1 -1
- package/build/components/writing-flow/index.js +1 -1
- package/build/components/writing-flow/index.js.map +1 -1
- package/build/hooks/border.js +0 -1
- package/build/hooks/border.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 +0 -1
- package/build/hooks/color-panel.js.map +1 -1
- package/build/hooks/color.js +1 -2
- package/build/hooks/color.js.map +1 -1
- package/build/hooks/content-lock-ui.js +1 -1
- package/build/hooks/content-lock-ui.js.map +1 -1
- package/build/hooks/dimensions.js +25 -7
- package/build/hooks/dimensions.js.map +1 -1
- package/build/hooks/font-family.js +4 -4
- package/build/hooks/font-family.js.map +1 -1
- package/build/hooks/font-size.js +5 -3
- package/build/hooks/font-size.js.map +1 -1
- package/build/hooks/layout.js +57 -1
- package/build/hooks/layout.js.map +1 -1
- package/build/hooks/min-height.js +4 -10
- package/build/hooks/min-height.js.map +1 -1
- package/build/hooks/use-typography-props.js +11 -8
- package/build/hooks/use-typography-props.js.map +1 -1
- package/build/store/reducer.js +411 -274
- package/build/store/reducer.js.map +1 -1
- package/build/store/selectors.js +58 -48
- package/build/store/selectors.js.map +1 -1
- package/build/utils/pasting.js +6 -11
- package/build/utils/pasting.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/alignment-control/ui.js +1 -6
- package/build-module/components/alignment-control/ui.js.map +1 -1
- package/build-module/components/block-alignment-control/use-available-alignments.js +4 -3
- package/build-module/components/block-alignment-control/use-available-alignments.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-icon/index.js +4 -2
- package/build-module/components/block-icon/index.js.map +1 -1
- package/build-module/components/block-inspector/index.js +87 -34
- 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-list-appender/index.js +46 -34
- package/build-module/components/block-list-appender/index.js.map +1 -1
- package/build-module/components/block-list-appender/index.native.js +39 -32
- package/build-module/components/block-list-appender/index.native.js.map +1 -1
- package/build-module/components/block-mobile-toolbar/block-actions-menu.native.js +31 -24
- package/build-module/components/block-mobile-toolbar/block-actions-menu.native.js.map +1 -1
- package/build-module/components/block-mobile-toolbar/index.native.js +1 -1
- package/build-module/components/block-mobile-toolbar/index.native.js.map +1 -1
- package/build-module/components/block-pattern-setup/index.js +16 -8
- 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/index.native.js +1 -2
- package/build-module/components/block-styles/index.native.js.map +1 -1
- package/build-module/components/block-styles/utils.js +7 -9
- package/build-module/components/block-styles/utils.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-toolbar/index.native.js +6 -8
- package/build-module/components/block-toolbar/index.native.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 +1 -2
- package/build-module/components/block-tools/selected-block-popover.js.map +1 -1
- package/build-module/components/block-variation-picker/index.js +2 -3
- package/build-module/components/block-variation-picker/index.js.map +1 -1
- package/build-module/components/colors/utils.js +3 -7
- package/build-module/components/colors/utils.js.map +1 -1
- package/build-module/components/colors-gradients/control.js +0 -3
- package/build-module/components/colors-gradients/control.js.map +1 -1
- package/build-module/components/colors-gradients/dropdown.js +0 -2
- package/build-module/components/colors-gradients/dropdown.js.map +1 -1
- package/build-module/components/colors-gradients/panel-color-gradient-settings.js +4 -19
- package/build-module/components/colors-gradients/panel-color-gradient-settings.js.map +1 -1
- package/build-module/components/colors-gradients/use-multiple-origin-colors-and-gradients.js +4 -2
- package/build-module/components/colors-gradients/use-multiple-origin-colors-and-gradients.js.map +1 -1
- package/build-module/components/copy-handler/index.js +38 -10
- package/build-module/components/copy-handler/index.js.map +1 -1
- package/build-module/components/font-sizes/fluid-utils.js +5 -2
- package/build-module/components/font-sizes/fluid-utils.js.map +1 -1
- package/build-module/components/font-sizes/utils.js +11 -5
- package/build-module/components/font-sizes/utils.js.map +1 -1
- package/build-module/components/font-sizes/with-font-sizes.js +12 -7
- package/build-module/components/font-sizes/with-font-sizes.js.map +1 -1
- package/build-module/components/gradients/use-gradient.js +2 -7
- package/build-module/components/gradients/use-gradient.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 +21 -101
- package/build-module/components/iframe/index.js.map +1 -1
- package/build-module/components/iframe/use-compatibility-styles.js +85 -0
- package/build-module/components/iframe/use-compatibility-styles.js.map +1 -0
- 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 +1 -0
- package/build-module/components/index.js.map +1 -1
- package/build-module/components/inner-blocks/index.js +27 -9
- 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/hooks/use-insertion-point.js +4 -3
- package/build-module/components/inserter/hooks/use-insertion-point.js.map +1 -1
- package/build-module/components/inserter/index.js +20 -6
- 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 +92 -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 +7 -3
- package/build-module/components/inserter/quick-inserter.js.map +1 -1
- package/build-module/components/inserter/search-items.js +15 -13
- package/build-module/components/inserter/search-items.js.map +1 -1
- package/build-module/components/inserter/search-results.js +7 -4
- 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 +1 -0
- package/build-module/components/link-control/index.js.map +1 -1
- package/build-module/components/link-control/search-input.js +0 -1
- package/build-module/components/link-control/search-input.js.map +1 -1
- package/build-module/components/link-control/use-internal-input-value.js +3 -3
- package/build-module/components/link-control/use-internal-input-value.js.map +1 -1
- package/build-module/components/list-view/block-select-button.js +1 -1
- package/build-module/components/list-view/block-select-button.js.map +1 -1
- package/build-module/components/list-view/block.js +5 -2
- package/build-module/components/list-view/block.js.map +1 -1
- package/build-module/components/list-view/branch.js +12 -11
- 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 +83 -0
- package/build-module/components/off-canvas-editor/appender.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 +3 -2
- package/build-module/components/off-canvas-editor/block-select-button.js.map +1 -1
- package/build-module/components/off-canvas-editor/block.js +83 -41
- package/build-module/components/off-canvas-editor/block.js.map +1 -1
- package/build-module/components/off-canvas-editor/branch.js +3 -4
- package/build-module/components/off-canvas-editor/branch.js.map +1 -1
- package/build-module/components/off-canvas-editor/index.js +24 -12
- package/build-module/components/off-canvas-editor/index.js.map +1 -1
- package/build-module/components/off-canvas-editor/leaf.js +1 -1
- package/build-module/components/off-canvas-editor/leaf.js.map +1 -1
- 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-inserted-block.js +47 -0
- package/build-module/components/off-canvas-editor/use-inserted-block.js.map +1 -0
- package/build-module/components/responsive-block-control/label.js +1 -2
- package/build-module/components/responsive-block-control/label.js.map +1 -1
- package/build-module/components/rich-text/format-edit.js +12 -9
- package/build-module/components/rich-text/format-edit.js.map +1 -1
- 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-paste-handler.js +22 -12
- package/build-module/components/rich-text/use-paste-handler.js.map +1 -1
- 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/index.js +0 -1
- package/build-module/components/spacing-sizes-control/index.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/spacing-sizes-control/utils.js +1 -1
- package/build-module/components/spacing-sizes-control/utils.js.map +1 -1
- package/build-module/components/typewriter/index.js +1 -1
- package/build-module/components/typewriter/index.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/image-url-input-ui.js +3 -3
- package/build-module/components/url-popover/image-url-input-ui.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 +8 -1
- package/build-module/components/use-setting/index.js.map +1 -1
- package/build-module/components/writing-flow/index.js +1 -1
- package/build-module/components/writing-flow/index.js.map +1 -1
- package/build-module/hooks/border.js +0 -1
- package/build-module/hooks/border.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 +0 -1
- package/build-module/hooks/color-panel.js.map +1 -1
- package/build-module/hooks/color.js +1 -2
- package/build-module/hooks/color.js.map +1 -1
- package/build-module/hooks/content-lock-ui.js +1 -1
- package/build-module/hooks/content-lock-ui.js.map +1 -1
- package/build-module/hooks/dimensions.js +25 -8
- package/build-module/hooks/dimensions.js.map +1 -1
- package/build-module/hooks/font-family.js +5 -5
- package/build-module/hooks/font-family.js.map +1 -1
- package/build-module/hooks/font-size.js +5 -3
- package/build-module/hooks/font-size.js.map +1 -1
- package/build-module/hooks/layout.js +55 -0
- package/build-module/hooks/layout.js.map +1 -1
- package/build-module/hooks/min-height.js +3 -9
- package/build-module/hooks/min-height.js.map +1 -1
- package/build-module/hooks/use-typography-props.js +11 -8
- package/build-module/hooks/use-typography-props.js.map +1 -1
- package/build-module/store/reducer.js +409 -274
- package/build-module/store/reducer.js.map +1 -1
- package/build-module/store/selectors.js +55 -48
- package/build-module/store/selectors.js.map +1 -1
- package/build-module/utils/pasting.js +6 -10
- package/build-module/utils/pasting.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 +17 -3
- package/build-style/default-editor-styles.css +17 -3
- package/build-style/style-rtl.css +313 -665
- package/build-style/style.css +313 -665
- package/package.json +32 -30
- package/src/autocompleters/block.js +2 -6
- package/src/autocompleters/link.js +2 -0
- package/src/components/alignment-control/test/index.js +6 -1
- package/src/components/alignment-control/ui.js +1 -7
- package/src/components/block-alignment-control/test/index.js +6 -1
- package/src/components/block-alignment-control/use-available-alignments.js +4 -3
- 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-icon/index.js +4 -2
- package/src/components/block-icon/test/index.js +9 -5
- package/src/components/block-inspector/index.js +173 -85
- package/src/components/block-inspector/style.scss +16 -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} +1 -15
- package/src/components/block-list-appender/{style.scss → content.scss} +0 -0
- package/src/components/block-list-appender/index.js +65 -54
- package/src/components/block-list-appender/index.native.js +45 -34
- package/src/components/block-mobile-toolbar/block-actions-menu.native.js +42 -28
- package/src/components/block-mobile-toolbar/index.native.js +1 -1
- package/src/components/block-mobile-toolbar/test/__snapshots__/block-actions-menu.native.js.snap +125 -0
- package/src/components/block-mobile-toolbar/test/block-actions-menu.native.js +439 -0
- package/src/components/block-mover/test/__snapshots__/index.native.js.snap +42 -2
- package/src/components/block-mover/test/index.native.js +157 -1
- package/src/components/block-pattern-setup/index.js +17 -7
- package/src/components/block-pattern-setup/style.scss +29 -1
- package/src/components/block-patterns-list/index.js +47 -24
- 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/index.native.js +1 -2
- package/src/components/block-styles/utils.js +5 -7
- package/src/components/block-switcher/test/index.js +6 -1
- package/src/components/block-toolbar/index.js +12 -5
- package/src/components/block-toolbar/index.native.js +8 -11
- 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 +1 -3
- package/src/components/block-tools/style.scss +12 -5
- package/src/components/block-variation-picker/index.js +6 -5
- package/src/components/block-vertical-alignment-control/test/index.js +6 -1
- package/src/components/colors/test/with-colors.js +2 -0
- package/src/components/colors/utils.js +5 -3
- package/src/components/colors-gradients/control.js +0 -7
- package/src/components/colors-gradients/dropdown.js +0 -2
- package/src/components/colors-gradients/panel-color-gradient-settings.js +4 -22
- package/src/components/colors-gradients/use-multiple-origin-colors-and-gradients.js +4 -2
- package/src/components/copy-handler/index.js +53 -7
- package/src/components/default-block-appender/{style.scss → content.scss} +0 -0
- package/src/components/default-block-appender/test/index.js +2 -0
- package/src/components/font-sizes/fluid-utils.js +7 -1
- package/src/components/font-sizes/utils.js +5 -3
- package/src/components/font-sizes/with-font-sizes.js +4 -4
- package/src/components/gradients/use-gradient.js +2 -7
- 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 +33 -121
- package/src/components/iframe/use-compatibility-styles.js +95 -0
- package/src/components/image-editor/use-save-image.js +2 -0
- package/src/components/image-editor/zoom-dropdown.js +1 -0
- package/src/components/image-size-control/test/index.js +147 -79
- package/src/components/index.js +1 -0
- package/src/components/inner-blocks/{style.scss → content.scss} +0 -0
- package/src/components/inner-blocks/index.js +26 -7
- 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/hooks/use-insertion-point.js +3 -2
- package/src/components/inserter/index.js +24 -3
- package/src/components/inserter/index.native.js +1 -1
- package/src/components/inserter/media-tab/hooks.js +89 -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 +4 -0
- package/src/components/inserter/search-items.js +1 -2
- package/src/components/inserter/search-results.js +5 -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 +176 -11
- package/src/components/inserter/tabs.js +12 -1
- 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 +1 -0
- package/src/components/link-control/search-input.js +0 -1
- package/src/components/link-control/test/index.js +204 -403
- package/src/components/link-control/use-internal-input-value.js +3 -3
- package/src/components/list-view/block-select-button.js +1 -1
- package/src/components/list-view/block.js +3 -0
- package/src/components/list-view/branch.js +10 -8
- package/src/components/list-view/style.scss +21 -16
- package/src/components/media-placeholder/{style.scss → content.scss} +0 -0
- package/src/components/media-replace-flow/test/index.js +39 -9
- package/src/components/media-upload/test/index.native.js +2 -0
- package/src/components/off-canvas-editor/appender.js +98 -0
- package/src/components/off-canvas-editor/block-edit-button.js +27 -0
- package/src/components/off-canvas-editor/block-select-button.js +6 -2
- package/src/components/off-canvas-editor/block.js +160 -77
- package/src/components/off-canvas-editor/branch.js +3 -5
- package/src/components/off-canvas-editor/index.js +68 -33
- package/src/components/off-canvas-editor/leaf.js +5 -1
- package/src/components/off-canvas-editor/link-ui.js +166 -0
- package/src/components/off-canvas-editor/style.scss +19 -386
- package/src/components/off-canvas-editor/test/use-inserted-block.js +108 -0
- package/src/components/off-canvas-editor/update-attributes.js +99 -0
- package/src/components/off-canvas-editor/use-inserted-block.js +47 -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/label.js +2 -3
- package/src/components/responsive-block-control/test/index.js +4 -2
- package/src/components/rich-text/content.scss +42 -0
- package/src/components/rich-text/format-edit.js +6 -10
- package/src/components/rich-text/format-toolbar/index.js +6 -4
- package/src/components/rich-text/index.js +3 -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-paste-handler.js +33 -14
- 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/index.js +0 -1
- package/src/components/spacing-sizes-control/spacing-input-control.js +9 -0
- package/src/components/spacing-sizes-control/utils.js +1 -1
- package/src/components/typewriter/index.js +3 -1
- package/src/components/ungroup-button/index.native.js +6 -2
- package/src/components/url-input/index.js +57 -73
- package/src/components/url-input/test/button.js +2 -0
- package/src/components/url-popover/image-url-input-ui.js +5 -4
- package/src/components/url-popover/test/__snapshots__/index.js.snap +8 -6
- package/src/components/url-popover/test/index.js +37 -9
- package/src/components/use-block-display-information/index.js +14 -5
- package/src/components/use-setting/index.js +13 -1
- package/src/components/use-setting/test/index.js +99 -0
- package/src/components/warning/test/index.js +2 -0
- package/src/components/writing-flow/index.js +1 -1
- package/src/content.scss +10 -0
- package/src/hooks/border.js +0 -1
- package/src/hooks/child-layout.js +190 -0
- package/src/hooks/color-panel.js +0 -1
- package/src/hooks/color.js +0 -2
- package/src/hooks/content-lock-ui.js +1 -1
- package/src/hooks/dimensions.js +45 -7
- package/src/hooks/font-family.js +3 -5
- package/src/hooks/font-size.js +13 -4
- package/src/hooks/layout.js +60 -0
- package/src/hooks/min-height.js +2 -19
- package/src/hooks/test/use-typography-props.js +26 -0
- package/src/hooks/use-typography-props.js +15 -7
- package/src/store/reducer.js +471 -428
- package/src/store/selectors.js +57 -59
- package/src/store/test/performance.js +71 -0
- package/src/store/test/reducer.js +623 -491
- package/src/store/test/selectors.js +1820 -1306
- package/src/style.scss +4 -7
- package/src/utils/pasting.js +3 -9
- 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/components/colors-gradients/use-common-single-multiple-selects.js +0 -21
- package/build/components/colors-gradients/use-common-single-multiple-selects.js.map +0 -1
- package/build/components/rich-text/file-paste-handler.js +0 -21
- package/build/components/rich-text/file-paste-handler.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/build-module/components/colors-gradients/use-common-single-multiple-selects.js +0 -11
- package/build-module/components/colors-gradients/use-common-single-multiple-selects.js.map +0 -1
- package/build-module/components/rich-text/file-paste-handler.js +0 -13
- package/build-module/components/rich-text/file-paste-handler.js.map +0 -1
- package/src/components/block-preview/live.js +0 -19
- package/src/components/colors-gradients/use-common-single-multiple-selects.js +0 -11
- package/src/components/rich-text/file-paste-handler.js +0 -13
|
@@ -73,6 +73,7 @@ const {
|
|
|
73
73
|
__experimentalGetPatternTransformItems,
|
|
74
74
|
wasBlockJustInserted,
|
|
75
75
|
__experimentalGetGlobalBlocksByName,
|
|
76
|
+
getLastInsertedBlockClientId,
|
|
76
77
|
} = selectors;
|
|
77
78
|
|
|
78
79
|
describe( 'selectors', () => {
|
|
@@ -202,10 +203,10 @@ describe( 'selectors', () => {
|
|
|
202
203
|
it( 'returns null if no block by clientId', () => {
|
|
203
204
|
const state = {
|
|
204
205
|
blocks: {
|
|
205
|
-
byClientId:
|
|
206
|
+
byClientId: new Map(),
|
|
206
207
|
attributes: {},
|
|
207
|
-
order:
|
|
208
|
-
parents:
|
|
208
|
+
order: new Map(),
|
|
209
|
+
parents: new Map(),
|
|
209
210
|
},
|
|
210
211
|
};
|
|
211
212
|
|
|
@@ -220,22 +221,31 @@ describe( 'selectors', () => {
|
|
|
220
221
|
it( 'returns block name', () => {
|
|
221
222
|
const state = {
|
|
222
223
|
blocks: {
|
|
223
|
-
byClientId:
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
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
|
+
),
|
|
239
249
|
},
|
|
240
250
|
};
|
|
241
251
|
|
|
@@ -252,54 +262,68 @@ describe( 'selectors', () => {
|
|
|
252
262
|
it( 'should return the block', () => {
|
|
253
263
|
const state = {
|
|
254
264
|
blocks: {
|
|
255
|
-
byClientId:
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
}
|
|
275
|
-
|
|
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
|
+
),
|
|
276
296
|
controlledInnerBlocks: {},
|
|
277
297
|
},
|
|
278
298
|
};
|
|
279
299
|
|
|
280
|
-
expect( getBlock( state, 123 ) ).toBe(
|
|
300
|
+
expect( getBlock( state, '123' ) ).toBe(
|
|
301
|
+
state.blocks.tree.get( '123' )
|
|
302
|
+
);
|
|
281
303
|
} );
|
|
282
304
|
|
|
283
305
|
it( 'should return null if the block is not present in state', () => {
|
|
284
306
|
const state = {
|
|
285
307
|
blocks: {
|
|
286
|
-
byClientId:
|
|
287
|
-
attributes:
|
|
288
|
-
order:
|
|
289
|
-
parents:
|
|
290
|
-
tree:
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
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
|
+
),
|
|
298
322
|
controlledInnerBlocks: {},
|
|
299
323
|
},
|
|
300
324
|
};
|
|
301
325
|
|
|
302
|
-
expect( getBlock( state, 123 ) ).toBe( null );
|
|
326
|
+
expect( getBlock( state, '123' ) ).toBe( null );
|
|
303
327
|
} );
|
|
304
328
|
} );
|
|
305
329
|
|
|
@@ -307,47 +331,57 @@ describe( 'selectors', () => {
|
|
|
307
331
|
it( 'should return the ordered blocks', () => {
|
|
308
332
|
const state = {
|
|
309
333
|
blocks: {
|
|
310
|
-
byClientId:
|
|
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
|
-
|
|
344
|
-
|
|
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
|
+
),
|
|
345
379
|
controlledInnerBlocks: {},
|
|
346
380
|
},
|
|
347
381
|
};
|
|
348
382
|
|
|
349
383
|
expect( getBlocks( state ) ).toBe(
|
|
350
|
-
state.blocks.tree
|
|
384
|
+
state.blocks.tree.get( '' ).innerBlocks
|
|
351
385
|
);
|
|
352
386
|
} );
|
|
353
387
|
} );
|
|
@@ -356,30 +390,34 @@ describe( 'selectors', () => {
|
|
|
356
390
|
it( 'should return parent blocks', () => {
|
|
357
391
|
const state = {
|
|
358
392
|
blocks: {
|
|
359
|
-
parents:
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
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
|
+
),
|
|
383
421
|
cache: {
|
|
384
422
|
'client-id-01': {},
|
|
385
423
|
'client-id-02': {},
|
|
@@ -403,35 +441,39 @@ describe( 'selectors', () => {
|
|
|
403
441
|
describe( 'getBlockParentsByBlockName', () => {
|
|
404
442
|
const state = {
|
|
405
443
|
blocks: {
|
|
406
|
-
parents:
|
|
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
|
-
|
|
434
|
-
|
|
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
|
+
),
|
|
435
477
|
cache: {
|
|
436
478
|
'client-id-01': {},
|
|
437
479
|
'client-id-02': {},
|
|
@@ -487,89 +529,124 @@ describe( 'selectors', () => {
|
|
|
487
529
|
it( 'should return the ids of any descendants in sequential order, given an array of clientIds', () => {
|
|
488
530
|
const state = {
|
|
489
531
|
blocks: {
|
|
490
|
-
byClientId:
|
|
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
|
-
|
|
572
|
-
|
|
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
|
+
),
|
|
573
650
|
controlledInnerBlocks: {},
|
|
574
651
|
},
|
|
575
652
|
};
|
|
@@ -592,89 +669,124 @@ describe( 'selectors', () => {
|
|
|
592
669
|
it( 'should return the ids for top-level blocks and their descendants of any depth (for nested blocks) in sequential order.', () => {
|
|
593
670
|
const state = {
|
|
594
671
|
blocks: {
|
|
595
|
-
byClientId:
|
|
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
|
-
|
|
677
|
-
|
|
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
|
+
),
|
|
678
790
|
},
|
|
679
791
|
};
|
|
680
792
|
expect( getClientIdsWithDescendants( state ) ).toEqual( [
|
|
@@ -698,17 +810,23 @@ describe( 'selectors', () => {
|
|
|
698
810
|
it( 'should return the number of top-level blocks in the post', () => {
|
|
699
811
|
const state = {
|
|
700
812
|
blocks: {
|
|
701
|
-
byClientId:
|
|
702
|
-
|
|
703
|
-
|
|
704
|
-
|
|
705
|
-
|
|
706
|
-
|
|
707
|
-
|
|
708
|
-
|
|
709
|
-
|
|
710
|
-
|
|
711
|
-
|
|
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
|
+
),
|
|
712
830
|
},
|
|
713
831
|
};
|
|
714
832
|
|
|
@@ -718,25 +836,33 @@ describe( 'selectors', () => {
|
|
|
718
836
|
it( 'should return the number of blocks in a nested context', () => {
|
|
719
837
|
const state = {
|
|
720
838
|
blocks: {
|
|
721
|
-
byClientId:
|
|
722
|
-
|
|
723
|
-
|
|
724
|
-
|
|
725
|
-
|
|
726
|
-
|
|
727
|
-
|
|
728
|
-
|
|
729
|
-
|
|
730
|
-
|
|
731
|
-
|
|
732
|
-
|
|
733
|
-
|
|
734
|
-
|
|
735
|
-
|
|
736
|
-
|
|
737
|
-
|
|
738
|
-
|
|
739
|
-
|
|
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
|
+
),
|
|
740
866
|
},
|
|
741
867
|
};
|
|
742
868
|
|
|
@@ -790,23 +916,31 @@ describe( 'selectors', () => {
|
|
|
790
916
|
describe( 'getGlobalBlockCount', () => {
|
|
791
917
|
const state = {
|
|
792
918
|
blocks: {
|
|
793
|
-
byClientId:
|
|
794
|
-
|
|
795
|
-
|
|
796
|
-
|
|
797
|
-
|
|
798
|
-
|
|
799
|
-
|
|
800
|
-
|
|
801
|
-
|
|
802
|
-
|
|
803
|
-
|
|
804
|
-
|
|
805
|
-
|
|
806
|
-
|
|
807
|
-
|
|
808
|
-
|
|
809
|
-
|
|
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
|
+
),
|
|
810
944
|
},
|
|
811
945
|
};
|
|
812
946
|
|
|
@@ -821,10 +955,10 @@ describe( 'selectors', () => {
|
|
|
821
955
|
it( 'should return 0 if no blocks exist', () => {
|
|
822
956
|
const emptyState = {
|
|
823
957
|
blocks: {
|
|
824
|
-
byClientId:
|
|
825
|
-
attributes:
|
|
826
|
-
order:
|
|
827
|
-
parents:
|
|
958
|
+
byClientId: new Map(),
|
|
959
|
+
attributes: new Map(),
|
|
960
|
+
order: new Map(),
|
|
961
|
+
parents: new Map(),
|
|
828
962
|
},
|
|
829
963
|
};
|
|
830
964
|
expect( getGlobalBlockCount( emptyState ) ).toBe( 0 );
|
|
@@ -837,46 +971,54 @@ describe( 'selectors', () => {
|
|
|
837
971
|
describe( '__experimentalGetGlobalBlocksByName', () => {
|
|
838
972
|
const state = {
|
|
839
973
|
blocks: {
|
|
840
|
-
byClientId:
|
|
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
|
-
|
|
866
|
-
|
|
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
|
+
),
|
|
867
1009
|
},
|
|
868
1010
|
};
|
|
869
1011
|
|
|
870
1012
|
it( 'should return the clientIds of blocks of a given type', () => {
|
|
871
1013
|
expect(
|
|
872
1014
|
__experimentalGetGlobalBlocksByName( state, 'core/heading' )
|
|
873
|
-
).toStrictEqual( [ 123 ] );
|
|
1015
|
+
).toStrictEqual( [ '123' ] );
|
|
874
1016
|
} );
|
|
875
1017
|
|
|
876
1018
|
it( 'should return the clientIds of blocks of a given type even if blocks are nested', () => {
|
|
877
1019
|
expect(
|
|
878
1020
|
__experimentalGetGlobalBlocksByName( state, 'core/paragraph' )
|
|
879
|
-
).toStrictEqual( [ 456, 1415, 1213 ] );
|
|
1021
|
+
).toStrictEqual( [ '456', '1415', '1213' ] );
|
|
880
1022
|
} );
|
|
881
1023
|
|
|
882
1024
|
it( 'Should return empty array if no blocks match. The empty array should be the same reference', () => {
|
|
@@ -911,8 +1053,8 @@ describe( 'selectors', () => {
|
|
|
911
1053
|
it( 'should return null if there is multi selection', () => {
|
|
912
1054
|
const state = {
|
|
913
1055
|
selection: {
|
|
914
|
-
selectionStart: { clientId: 23 },
|
|
915
|
-
selectionEnd: { clientId: 123 },
|
|
1056
|
+
selectionStart: { clientId: '23' },
|
|
1057
|
+
selectionEnd: { clientId: '123' },
|
|
916
1058
|
},
|
|
917
1059
|
};
|
|
918
1060
|
|
|
@@ -922,19 +1064,21 @@ describe( 'selectors', () => {
|
|
|
922
1064
|
it( 'should return the selected block ClientId', () => {
|
|
923
1065
|
const state = {
|
|
924
1066
|
blocks: {
|
|
925
|
-
byClientId:
|
|
926
|
-
|
|
927
|
-
|
|
928
|
-
|
|
929
|
-
|
|
1067
|
+
byClientId: new Map(
|
|
1068
|
+
Object.entries( {
|
|
1069
|
+
23: {
|
|
1070
|
+
name: 'fake block',
|
|
1071
|
+
},
|
|
1072
|
+
} )
|
|
1073
|
+
),
|
|
930
1074
|
},
|
|
931
1075
|
selection: {
|
|
932
|
-
selectionStart: { clientId: 23 },
|
|
933
|
-
selectionEnd: { clientId: 23 },
|
|
1076
|
+
selectionStart: { clientId: '23' },
|
|
1077
|
+
selectionEnd: { clientId: '23' },
|
|
934
1078
|
},
|
|
935
1079
|
};
|
|
936
1080
|
|
|
937
|
-
expect( getSelectedBlockClientId( state ) ).toEqual( 23 );
|
|
1081
|
+
expect( getSelectedBlockClientId( state ) ).toEqual( '23' );
|
|
938
1082
|
} );
|
|
939
1083
|
} );
|
|
940
1084
|
|
|
@@ -942,31 +1086,41 @@ describe( 'selectors', () => {
|
|
|
942
1086
|
it( 'should return null if no block is selected', () => {
|
|
943
1087
|
const state = {
|
|
944
1088
|
blocks: {
|
|
945
|
-
byClientId:
|
|
946
|
-
|
|
947
|
-
|
|
948
|
-
|
|
949
|
-
|
|
950
|
-
|
|
951
|
-
|
|
952
|
-
|
|
953
|
-
|
|
954
|
-
|
|
955
|
-
|
|
956
|
-
|
|
957
|
-
|
|
958
|
-
|
|
959
|
-
|
|
960
|
-
|
|
961
|
-
|
|
962
|
-
|
|
963
|
-
|
|
964
|
-
|
|
965
|
-
|
|
966
|
-
|
|
967
|
-
|
|
968
|
-
}
|
|
969
|
-
|
|
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
|
+
),
|
|
970
1124
|
},
|
|
971
1125
|
selection: {
|
|
972
1126
|
selectionStart: {},
|
|
@@ -980,35 +1134,45 @@ describe( 'selectors', () => {
|
|
|
980
1134
|
it( 'should return null if there is multi selection', () => {
|
|
981
1135
|
const state = {
|
|
982
1136
|
blocks: {
|
|
983
|
-
byClientId:
|
|
984
|
-
|
|
985
|
-
|
|
986
|
-
|
|
987
|
-
|
|
988
|
-
|
|
989
|
-
|
|
990
|
-
|
|
991
|
-
|
|
992
|
-
|
|
993
|
-
|
|
994
|
-
|
|
995
|
-
|
|
996
|
-
|
|
997
|
-
|
|
998
|
-
|
|
999
|
-
|
|
1000
|
-
|
|
1001
|
-
|
|
1002
|
-
|
|
1003
|
-
|
|
1004
|
-
|
|
1005
|
-
|
|
1006
|
-
}
|
|
1007
|
-
|
|
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
|
+
),
|
|
1008
1172
|
},
|
|
1009
1173
|
selection: {
|
|
1010
|
-
selectionStart: { clientId: 23 },
|
|
1011
|
-
selectionEnd: { clientId: 123 },
|
|
1174
|
+
selectionStart: { clientId: '23' },
|
|
1175
|
+
selectionEnd: { clientId: '123' },
|
|
1012
1176
|
},
|
|
1013
1177
|
};
|
|
1014
1178
|
|
|
@@ -1018,41 +1182,51 @@ describe( 'selectors', () => {
|
|
|
1018
1182
|
it( 'should return the selected block', () => {
|
|
1019
1183
|
const state = {
|
|
1020
1184
|
blocks: {
|
|
1021
|
-
byClientId:
|
|
1022
|
-
|
|
1023
|
-
|
|
1024
|
-
|
|
1025
|
-
|
|
1026
|
-
|
|
1027
|
-
|
|
1028
|
-
|
|
1029
|
-
|
|
1030
|
-
|
|
1031
|
-
|
|
1032
|
-
|
|
1033
|
-
|
|
1034
|
-
|
|
1035
|
-
|
|
1036
|
-
|
|
1037
|
-
|
|
1038
|
-
|
|
1039
|
-
|
|
1040
|
-
|
|
1041
|
-
|
|
1042
|
-
|
|
1043
|
-
|
|
1044
|
-
}
|
|
1045
|
-
|
|
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
|
+
),
|
|
1046
1220
|
controlledInnerBlocks: {},
|
|
1047
1221
|
},
|
|
1048
1222
|
selection: {
|
|
1049
|
-
selectionStart: { clientId: 23 },
|
|
1050
|
-
selectionEnd: { clientId: 23 },
|
|
1223
|
+
selectionStart: { clientId: '23' },
|
|
1224
|
+
selectionEnd: { clientId: '23' },
|
|
1051
1225
|
},
|
|
1052
1226
|
};
|
|
1053
1227
|
|
|
1054
1228
|
expect( getSelectedBlock( state ) ).toEqual(
|
|
1055
|
-
getBlock( state, 23 )
|
|
1229
|
+
getBlock( state, '23' )
|
|
1056
1230
|
);
|
|
1057
1231
|
} );
|
|
1058
1232
|
} );
|
|
@@ -1061,8 +1235,8 @@ describe( 'selectors', () => {
|
|
|
1061
1235
|
it( 'should return null if the block does not exist', () => {
|
|
1062
1236
|
const state = {
|
|
1063
1237
|
blocks: {
|
|
1064
|
-
order:
|
|
1065
|
-
parents:
|
|
1238
|
+
order: new Map(),
|
|
1239
|
+
parents: new Map(),
|
|
1066
1240
|
},
|
|
1067
1241
|
};
|
|
1068
1242
|
|
|
@@ -1072,20 +1246,24 @@ describe( 'selectors', () => {
|
|
|
1072
1246
|
it( 'should return root ClientId relative the block ClientId', () => {
|
|
1073
1247
|
const state = {
|
|
1074
1248
|
blocks: {
|
|
1075
|
-
order:
|
|
1076
|
-
|
|
1077
|
-
|
|
1078
|
-
|
|
1079
|
-
|
|
1080
|
-
|
|
1081
|
-
|
|
1082
|
-
|
|
1083
|
-
|
|
1084
|
-
|
|
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
|
+
),
|
|
1085
1263
|
},
|
|
1086
1264
|
};
|
|
1087
1265
|
|
|
1088
|
-
expect( getBlockRootClientId( state, 56 ) ).toBe( 123 );
|
|
1266
|
+
expect( getBlockRootClientId( state, '56' ) ).toBe( '123' );
|
|
1089
1267
|
} );
|
|
1090
1268
|
} );
|
|
1091
1269
|
|
|
@@ -1093,8 +1271,8 @@ describe( 'selectors', () => {
|
|
|
1093
1271
|
it( 'should return the given block if the block has no parents', () => {
|
|
1094
1272
|
const state = {
|
|
1095
1273
|
blocks: {
|
|
1096
|
-
order:
|
|
1097
|
-
parents:
|
|
1274
|
+
order: new Map(),
|
|
1275
|
+
parents: new Map(),
|
|
1098
1276
|
},
|
|
1099
1277
|
};
|
|
1100
1278
|
|
|
@@ -1104,16 +1282,20 @@ describe( 'selectors', () => {
|
|
|
1104
1282
|
it( 'should return root ClientId relative the block ClientId', () => {
|
|
1105
1283
|
const state = {
|
|
1106
1284
|
blocks: {
|
|
1107
|
-
order:
|
|
1108
|
-
|
|
1109
|
-
|
|
1110
|
-
|
|
1111
|
-
|
|
1112
|
-
|
|
1113
|
-
|
|
1114
|
-
|
|
1115
|
-
|
|
1116
|
-
|
|
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
|
+
),
|
|
1117
1299
|
},
|
|
1118
1300
|
};
|
|
1119
1301
|
|
|
@@ -1123,18 +1305,22 @@ describe( 'selectors', () => {
|
|
|
1123
1305
|
it( 'should return the top level root ClientId relative the block ClientId', () => {
|
|
1124
1306
|
const state = {
|
|
1125
1307
|
blocks: {
|
|
1126
|
-
order:
|
|
1127
|
-
|
|
1128
|
-
|
|
1129
|
-
|
|
1130
|
-
|
|
1131
|
-
|
|
1132
|
-
|
|
1133
|
-
|
|
1134
|
-
|
|
1135
|
-
|
|
1136
|
-
|
|
1137
|
-
|
|
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
|
+
),
|
|
1138
1324
|
},
|
|
1139
1325
|
};
|
|
1140
1326
|
|
|
@@ -1146,13 +1332,17 @@ describe( 'selectors', () => {
|
|
|
1146
1332
|
it( 'should return empty if there is no selection', () => {
|
|
1147
1333
|
const state = {
|
|
1148
1334
|
blocks: {
|
|
1149
|
-
order:
|
|
1150
|
-
|
|
1151
|
-
|
|
1152
|
-
|
|
1153
|
-
|
|
1154
|
-
|
|
1155
|
-
|
|
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
|
+
),
|
|
1156
1346
|
},
|
|
1157
1347
|
selection: {
|
|
1158
1348
|
selectionStart: {},
|
|
@@ -1166,75 +1356,95 @@ describe( 'selectors', () => {
|
|
|
1166
1356
|
it( 'should return the selected block clientId if there is a selection', () => {
|
|
1167
1357
|
const state = {
|
|
1168
1358
|
blocks: {
|
|
1169
|
-
order:
|
|
1170
|
-
|
|
1171
|
-
|
|
1172
|
-
|
|
1173
|
-
|
|
1174
|
-
|
|
1175
|
-
|
|
1176
|
-
|
|
1177
|
-
|
|
1178
|
-
|
|
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
|
+
),
|
|
1179
1373
|
},
|
|
1180
1374
|
selection: {
|
|
1181
|
-
selectionStart: { clientId: 2 },
|
|
1182
|
-
selectionEnd: { clientId: 2 },
|
|
1375
|
+
selectionStart: { clientId: '2' },
|
|
1376
|
+
selectionEnd: { clientId: '2' },
|
|
1183
1377
|
},
|
|
1184
1378
|
};
|
|
1185
1379
|
|
|
1186
|
-
expect( getSelectedBlockClientIds( state ) ).toEqual( [ 2 ] );
|
|
1380
|
+
expect( getSelectedBlockClientIds( state ) ).toEqual( [ '2' ] );
|
|
1187
1381
|
} );
|
|
1188
1382
|
|
|
1189
1383
|
it( 'should return selected block clientIds if there is multi selection', () => {
|
|
1190
1384
|
const state = {
|
|
1191
1385
|
blocks: {
|
|
1192
|
-
order:
|
|
1193
|
-
|
|
1194
|
-
|
|
1195
|
-
|
|
1196
|
-
|
|
1197
|
-
|
|
1198
|
-
|
|
1199
|
-
|
|
1200
|
-
|
|
1201
|
-
|
|
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
|
+
),
|
|
1202
1400
|
},
|
|
1203
1401
|
selection: {
|
|
1204
|
-
selectionStart: { clientId: 2 },
|
|
1205
|
-
selectionEnd: { clientId: 4 },
|
|
1402
|
+
selectionStart: { clientId: '2' },
|
|
1403
|
+
selectionEnd: { clientId: '4' },
|
|
1206
1404
|
},
|
|
1207
1405
|
};
|
|
1208
1406
|
|
|
1209
|
-
expect( getSelectedBlockClientIds( state ) ).toEqual( [
|
|
1407
|
+
expect( getSelectedBlockClientIds( state ) ).toEqual( [
|
|
1408
|
+
'4',
|
|
1409
|
+
'3',
|
|
1410
|
+
'2',
|
|
1411
|
+
] );
|
|
1210
1412
|
} );
|
|
1211
1413
|
|
|
1212
1414
|
it( 'should return selected block clientIds if there is multi selection (nested context)', () => {
|
|
1213
1415
|
const state = {
|
|
1214
1416
|
blocks: {
|
|
1215
|
-
order:
|
|
1216
|
-
|
|
1217
|
-
|
|
1218
|
-
|
|
1219
|
-
|
|
1220
|
-
|
|
1221
|
-
|
|
1222
|
-
|
|
1223
|
-
|
|
1224
|
-
|
|
1225
|
-
|
|
1226
|
-
|
|
1227
|
-
|
|
1228
|
-
|
|
1229
|
-
|
|
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
|
+
),
|
|
1230
1436
|
},
|
|
1231
1437
|
selection: {
|
|
1232
|
-
selectionStart: { clientId: 7 },
|
|
1233
|
-
selectionEnd: { clientId: 9 },
|
|
1438
|
+
selectionStart: { clientId: '7' },
|
|
1439
|
+
selectionEnd: { clientId: '9' },
|
|
1234
1440
|
},
|
|
1235
1441
|
};
|
|
1236
1442
|
|
|
1237
|
-
expect( getSelectedBlockClientIds( state ) ).toEqual( [
|
|
1443
|
+
expect( getSelectedBlockClientIds( state ) ).toEqual( [
|
|
1444
|
+
'9',
|
|
1445
|
+
'8',
|
|
1446
|
+
'7',
|
|
1447
|
+
] );
|
|
1238
1448
|
} );
|
|
1239
1449
|
} );
|
|
1240
1450
|
|
|
@@ -1242,13 +1452,17 @@ describe( 'selectors', () => {
|
|
|
1242
1452
|
it( 'should return empty if there is no multi selection', () => {
|
|
1243
1453
|
const state = {
|
|
1244
1454
|
blocks: {
|
|
1245
|
-
order:
|
|
1246
|
-
|
|
1247
|
-
|
|
1248
|
-
|
|
1249
|
-
|
|
1250
|
-
|
|
1251
|
-
|
|
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
|
+
),
|
|
1252
1466
|
},
|
|
1253
1467
|
selection: {
|
|
1254
1468
|
selectionStart: {},
|
|
@@ -1262,55 +1476,67 @@ describe( 'selectors', () => {
|
|
|
1262
1476
|
it( 'should return selected block clientIds if there is multi selection', () => {
|
|
1263
1477
|
const state = {
|
|
1264
1478
|
blocks: {
|
|
1265
|
-
order:
|
|
1266
|
-
|
|
1267
|
-
|
|
1268
|
-
|
|
1269
|
-
|
|
1270
|
-
|
|
1271
|
-
|
|
1272
|
-
|
|
1273
|
-
|
|
1274
|
-
|
|
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
|
+
),
|
|
1275
1493
|
},
|
|
1276
1494
|
selection: {
|
|
1277
|
-
selectionStart: { clientId: 2 },
|
|
1278
|
-
selectionEnd: { clientId: 4 },
|
|
1495
|
+
selectionStart: { clientId: '2' },
|
|
1496
|
+
selectionEnd: { clientId: '4' },
|
|
1279
1497
|
},
|
|
1280
1498
|
};
|
|
1281
1499
|
|
|
1282
1500
|
expect( getMultiSelectedBlockClientIds( state ) ).toEqual( [
|
|
1283
|
-
4,
|
|
1501
|
+
'4',
|
|
1502
|
+
'3',
|
|
1503
|
+
'2',
|
|
1284
1504
|
] );
|
|
1285
1505
|
} );
|
|
1286
1506
|
|
|
1287
1507
|
it( 'should return selected block clientIds if there is multi selection (nested context)', () => {
|
|
1288
1508
|
const state = {
|
|
1289
1509
|
blocks: {
|
|
1290
|
-
order:
|
|
1291
|
-
|
|
1292
|
-
|
|
1293
|
-
|
|
1294
|
-
|
|
1295
|
-
|
|
1296
|
-
|
|
1297
|
-
|
|
1298
|
-
|
|
1299
|
-
|
|
1300
|
-
|
|
1301
|
-
|
|
1302
|
-
|
|
1303
|
-
|
|
1304
|
-
|
|
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
|
+
),
|
|
1305
1529
|
},
|
|
1306
1530
|
selection: {
|
|
1307
|
-
selectionStart: { clientId: 7 },
|
|
1308
|
-
selectionEnd: { clientId: 9 },
|
|
1531
|
+
selectionStart: { clientId: '7' },
|
|
1532
|
+
selectionEnd: { clientId: '9' },
|
|
1309
1533
|
},
|
|
1310
1534
|
};
|
|
1311
1535
|
|
|
1312
1536
|
expect( getMultiSelectedBlockClientIds( state ) ).toEqual( [
|
|
1313
|
-
9,
|
|
1537
|
+
'9',
|
|
1538
|
+
'8',
|
|
1539
|
+
'7',
|
|
1314
1540
|
] );
|
|
1315
1541
|
} );
|
|
1316
1542
|
} );
|
|
@@ -1319,10 +1545,10 @@ describe( 'selectors', () => {
|
|
|
1319
1545
|
it( 'should return the same reference on subsequent invocations of empty selection', () => {
|
|
1320
1546
|
const state = {
|
|
1321
1547
|
blocks: {
|
|
1322
|
-
byClientId:
|
|
1323
|
-
attributes:
|
|
1324
|
-
order:
|
|
1325
|
-
parents:
|
|
1548
|
+
byClientId: new Map(),
|
|
1549
|
+
attributes: new Map(),
|
|
1550
|
+
order: new Map(),
|
|
1551
|
+
parents: new Map(),
|
|
1326
1552
|
},
|
|
1327
1553
|
selection: {
|
|
1328
1554
|
selectionStart: {},
|
|
@@ -1351,12 +1577,12 @@ describe( 'selectors', () => {
|
|
|
1351
1577
|
it( 'returns multi selection start', () => {
|
|
1352
1578
|
const state = {
|
|
1353
1579
|
selection: {
|
|
1354
|
-
selectionStart: { clientId: 2 },
|
|
1355
|
-
selectionEnd: { clientId: 4 },
|
|
1580
|
+
selectionStart: { clientId: '2' },
|
|
1581
|
+
selectionEnd: { clientId: '4' },
|
|
1356
1582
|
},
|
|
1357
1583
|
};
|
|
1358
1584
|
|
|
1359
|
-
expect( getMultiSelectedBlocksStartClientId( state ) ).toBe( 2 );
|
|
1585
|
+
expect( getMultiSelectedBlocksStartClientId( state ) ).toBe( '2' );
|
|
1360
1586
|
} );
|
|
1361
1587
|
} );
|
|
1362
1588
|
|
|
@@ -1375,12 +1601,12 @@ describe( 'selectors', () => {
|
|
|
1375
1601
|
it( 'returns multi selection end', () => {
|
|
1376
1602
|
const state = {
|
|
1377
1603
|
selection: {
|
|
1378
|
-
selectionStart: { clientId: 2 },
|
|
1379
|
-
selectionEnd: { clientId: 4 },
|
|
1604
|
+
selectionStart: { clientId: '2' },
|
|
1605
|
+
selectionEnd: { clientId: '4' },
|
|
1380
1606
|
},
|
|
1381
1607
|
};
|
|
1382
1608
|
|
|
1383
|
-
expect( getMultiSelectedBlocksEndClientId( state ) ).toBe( 4 );
|
|
1609
|
+
expect( getMultiSelectedBlocksEndClientId( state ) ).toBe( '4' );
|
|
1384
1610
|
} );
|
|
1385
1611
|
} );
|
|
1386
1612
|
|
|
@@ -1388,35 +1614,43 @@ describe( 'selectors', () => {
|
|
|
1388
1614
|
it( 'should return the ordered block ClientIds of top-level blocks by default', () => {
|
|
1389
1615
|
const state = {
|
|
1390
1616
|
blocks: {
|
|
1391
|
-
order:
|
|
1392
|
-
|
|
1393
|
-
|
|
1394
|
-
|
|
1395
|
-
|
|
1396
|
-
|
|
1397
|
-
|
|
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
|
+
),
|
|
1398
1628
|
},
|
|
1399
1629
|
};
|
|
1400
1630
|
|
|
1401
|
-
expect( getBlockOrder( state ) ).toEqual( [ 123, 23 ] );
|
|
1631
|
+
expect( getBlockOrder( state ) ).toEqual( [ '123', '23' ] );
|
|
1402
1632
|
} );
|
|
1403
1633
|
|
|
1404
1634
|
it( 'should return the ordered block ClientIds at a specified rootClientId', () => {
|
|
1405
1635
|
const state = {
|
|
1406
1636
|
blocks: {
|
|
1407
|
-
order:
|
|
1408
|
-
|
|
1409
|
-
|
|
1410
|
-
|
|
1411
|
-
|
|
1412
|
-
|
|
1413
|
-
|
|
1414
|
-
|
|
1415
|
-
|
|
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
|
+
),
|
|
1416
1650
|
},
|
|
1417
1651
|
};
|
|
1418
1652
|
|
|
1419
|
-
expect( getBlockOrder( state, '123' ) ).toEqual( [ 456 ] );
|
|
1653
|
+
expect( getBlockOrder( state, '123' ) ).toEqual( [ '456' ] );
|
|
1420
1654
|
} );
|
|
1421
1655
|
} );
|
|
1422
1656
|
|
|
@@ -1424,36 +1658,44 @@ describe( 'selectors', () => {
|
|
|
1424
1658
|
it( 'should return the block order', () => {
|
|
1425
1659
|
const state = {
|
|
1426
1660
|
blocks: {
|
|
1427
|
-
order:
|
|
1428
|
-
|
|
1429
|
-
|
|
1430
|
-
|
|
1431
|
-
|
|
1432
|
-
|
|
1433
|
-
|
|
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
|
+
),
|
|
1434
1672
|
},
|
|
1435
1673
|
};
|
|
1436
1674
|
|
|
1437
|
-
expect( getBlockIndex( state, 23 ) ).toBe( 1 );
|
|
1675
|
+
expect( getBlockIndex( state, '23' ) ).toBe( 1 );
|
|
1438
1676
|
} );
|
|
1439
1677
|
|
|
1440
1678
|
it( 'should return the block order (nested context)', () => {
|
|
1441
1679
|
const state = {
|
|
1442
1680
|
blocks: {
|
|
1443
|
-
order:
|
|
1444
|
-
|
|
1445
|
-
|
|
1446
|
-
|
|
1447
|
-
|
|
1448
|
-
|
|
1449
|
-
|
|
1450
|
-
|
|
1451
|
-
|
|
1452
|
-
|
|
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
|
+
),
|
|
1453
1695
|
},
|
|
1454
1696
|
};
|
|
1455
1697
|
|
|
1456
|
-
expect( getBlockIndex( state, 56 ) ).toBe( 1 );
|
|
1698
|
+
expect( getBlockIndex( state, '56' ) ).toBe( 1 );
|
|
1457
1699
|
} );
|
|
1458
1700
|
} );
|
|
1459
1701
|
|
|
@@ -1461,73 +1703,91 @@ describe( 'selectors', () => {
|
|
|
1461
1703
|
it( 'should return the previous block', () => {
|
|
1462
1704
|
const state = {
|
|
1463
1705
|
blocks: {
|
|
1464
|
-
order:
|
|
1465
|
-
|
|
1466
|
-
|
|
1467
|
-
|
|
1468
|
-
|
|
1469
|
-
|
|
1470
|
-
|
|
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
|
+
),
|
|
1471
1717
|
},
|
|
1472
1718
|
};
|
|
1473
1719
|
|
|
1474
|
-
expect( getPreviousBlockClientId( state, 23 ) ).toEqual( 123 );
|
|
1720
|
+
expect( getPreviousBlockClientId( state, '23' ) ).toEqual( '123' );
|
|
1475
1721
|
} );
|
|
1476
1722
|
|
|
1477
1723
|
it( 'should return the previous block (nested context)', () => {
|
|
1478
1724
|
const state = {
|
|
1479
1725
|
blocks: {
|
|
1480
|
-
order:
|
|
1481
|
-
|
|
1482
|
-
|
|
1483
|
-
|
|
1484
|
-
|
|
1485
|
-
|
|
1486
|
-
|
|
1487
|
-
|
|
1488
|
-
|
|
1489
|
-
|
|
1490
|
-
|
|
1491
|
-
|
|
1492
|
-
|
|
1493
|
-
|
|
1494
|
-
|
|
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'
|
|
1495
1745
|
);
|
|
1496
1746
|
} );
|
|
1497
1747
|
|
|
1498
1748
|
it( 'should return null for the first block', () => {
|
|
1499
1749
|
const state = {
|
|
1500
1750
|
blocks: {
|
|
1501
|
-
order:
|
|
1502
|
-
|
|
1503
|
-
|
|
1504
|
-
|
|
1505
|
-
|
|
1506
|
-
|
|
1507
|
-
|
|
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
|
+
),
|
|
1508
1762
|
},
|
|
1509
1763
|
};
|
|
1510
1764
|
|
|
1511
|
-
expect( getPreviousBlockClientId( state, 123 ) ).toBeNull();
|
|
1765
|
+
expect( getPreviousBlockClientId( state, '123' ) ).toBeNull();
|
|
1512
1766
|
} );
|
|
1513
1767
|
|
|
1514
1768
|
it( 'should return null for the first block (nested context)', () => {
|
|
1515
1769
|
const state = {
|
|
1516
1770
|
blocks: {
|
|
1517
|
-
order:
|
|
1518
|
-
|
|
1519
|
-
|
|
1520
|
-
|
|
1521
|
-
|
|
1522
|
-
|
|
1523
|
-
|
|
1524
|
-
|
|
1525
|
-
|
|
1526
|
-
|
|
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
|
+
),
|
|
1527
1785
|
},
|
|
1528
1786
|
};
|
|
1529
1787
|
|
|
1530
|
-
expect(
|
|
1788
|
+
expect(
|
|
1789
|
+
getPreviousBlockClientId( state, '456', '123' )
|
|
1790
|
+
).toBeNull();
|
|
1531
1791
|
} );
|
|
1532
1792
|
} );
|
|
1533
1793
|
|
|
@@ -1535,71 +1795,89 @@ describe( 'selectors', () => {
|
|
|
1535
1795
|
it( 'should return the following block', () => {
|
|
1536
1796
|
const state = {
|
|
1537
1797
|
blocks: {
|
|
1538
|
-
order:
|
|
1539
|
-
|
|
1540
|
-
|
|
1541
|
-
|
|
1542
|
-
|
|
1543
|
-
|
|
1544
|
-
|
|
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
|
+
),
|
|
1545
1809
|
},
|
|
1546
1810
|
};
|
|
1547
1811
|
|
|
1548
|
-
expect( getNextBlockClientId( state, 123 ) ).toEqual( 23 );
|
|
1812
|
+
expect( getNextBlockClientId( state, '123' ) ).toEqual( '23' );
|
|
1549
1813
|
} );
|
|
1550
1814
|
|
|
1551
1815
|
it( 'should return the following block (nested context)', () => {
|
|
1552
1816
|
const state = {
|
|
1553
1817
|
blocks: {
|
|
1554
|
-
order:
|
|
1555
|
-
|
|
1556
|
-
|
|
1557
|
-
|
|
1558
|
-
|
|
1559
|
-
|
|
1560
|
-
|
|
1561
|
-
|
|
1562
|
-
|
|
1563
|
-
|
|
1564
|
-
|
|
1565
|
-
|
|
1566
|
-
|
|
1567
|
-
|
|
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
|
+
);
|
|
1568
1838
|
} );
|
|
1569
1839
|
|
|
1570
1840
|
it( 'should return null for the last block', () => {
|
|
1571
1841
|
const state = {
|
|
1572
|
-
blocks: {
|
|
1573
|
-
order:
|
|
1574
|
-
|
|
1575
|
-
|
|
1576
|
-
|
|
1577
|
-
|
|
1578
|
-
|
|
1579
|
-
|
|
1842
|
+
blocks: {
|
|
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
|
+
),
|
|
1580
1854
|
},
|
|
1581
1855
|
};
|
|
1582
1856
|
|
|
1583
|
-
expect( getNextBlockClientId( state, 23 ) ).toBeNull();
|
|
1857
|
+
expect( getNextBlockClientId( state, '23' ) ).toBeNull();
|
|
1584
1858
|
} );
|
|
1585
1859
|
|
|
1586
1860
|
it( 'should return null for the last block (nested context)', () => {
|
|
1587
1861
|
const state = {
|
|
1588
1862
|
blocks: {
|
|
1589
|
-
order:
|
|
1590
|
-
|
|
1591
|
-
|
|
1592
|
-
|
|
1593
|
-
|
|
1594
|
-
|
|
1595
|
-
|
|
1596
|
-
|
|
1597
|
-
|
|
1598
|
-
|
|
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
|
+
),
|
|
1599
1877
|
},
|
|
1600
1878
|
};
|
|
1601
1879
|
|
|
1602
|
-
expect( getNextBlockClientId( state, 56, '123' ) ).toBeNull();
|
|
1880
|
+
expect( getNextBlockClientId( state, '56', '123' ) ).toBeNull();
|
|
1603
1881
|
} );
|
|
1604
1882
|
} );
|
|
1605
1883
|
|
|
@@ -1607,23 +1885,23 @@ describe( 'selectors', () => {
|
|
|
1607
1885
|
it( 'should return true if the block is selected', () => {
|
|
1608
1886
|
const state = {
|
|
1609
1887
|
selection: {
|
|
1610
|
-
selectionStart: { clientId: 123 },
|
|
1611
|
-
selectionEnd: { clientId: 123 },
|
|
1888
|
+
selectionStart: { clientId: '123' },
|
|
1889
|
+
selectionEnd: { clientId: '123' },
|
|
1612
1890
|
},
|
|
1613
1891
|
};
|
|
1614
1892
|
|
|
1615
|
-
expect( isBlockSelected( state, 123 ) ).toBe( true );
|
|
1893
|
+
expect( isBlockSelected( state, '123' ) ).toBe( true );
|
|
1616
1894
|
} );
|
|
1617
1895
|
|
|
1618
1896
|
it( 'should return false if a multi-selection range exists', () => {
|
|
1619
1897
|
const state = {
|
|
1620
1898
|
selection: {
|
|
1621
|
-
selectionStart: { clientId: 123 },
|
|
1622
|
-
selectionEnd: { clientId: 124 },
|
|
1899
|
+
selectionStart: { clientId: '123' },
|
|
1900
|
+
selectionEnd: { clientId: '124' },
|
|
1623
1901
|
},
|
|
1624
1902
|
};
|
|
1625
1903
|
|
|
1626
|
-
expect( isBlockSelected( state, 123 ) ).toBe( false );
|
|
1904
|
+
expect( isBlockSelected( state, '123' ) ).toBe( false );
|
|
1627
1905
|
} );
|
|
1628
1906
|
|
|
1629
1907
|
it( 'should return false if the block is not selected', () => {
|
|
@@ -1634,7 +1912,7 @@ describe( 'selectors', () => {
|
|
|
1634
1912
|
},
|
|
1635
1913
|
};
|
|
1636
1914
|
|
|
1637
|
-
expect( isBlockSelected( state, 23 ) ).toBe( false );
|
|
1915
|
+
expect( isBlockSelected( state, '23' ) ).toBe( false );
|
|
1638
1916
|
} );
|
|
1639
1917
|
} );
|
|
1640
1918
|
|
|
@@ -1642,87 +1920,103 @@ describe( 'selectors', () => {
|
|
|
1642
1920
|
it( 'should return false if the selected block is a child of the given ClientId', () => {
|
|
1643
1921
|
const state = {
|
|
1644
1922
|
selection: {
|
|
1645
|
-
selectionStart: { clientId: 5 },
|
|
1646
|
-
selectionEnd: { clientId: 5 },
|
|
1923
|
+
selectionStart: { clientId: '5' },
|
|
1924
|
+
selectionEnd: { clientId: '5' },
|
|
1647
1925
|
},
|
|
1648
1926
|
blocks: {
|
|
1649
|
-
order:
|
|
1650
|
-
|
|
1651
|
-
|
|
1652
|
-
|
|
1653
|
-
|
|
1654
|
-
|
|
1655
|
-
|
|
1656
|
-
|
|
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
|
+
),
|
|
1657
1939
|
},
|
|
1658
1940
|
};
|
|
1659
1941
|
|
|
1660
|
-
expect( hasSelectedInnerBlock( state, 4 ) ).toBe( false );
|
|
1942
|
+
expect( hasSelectedInnerBlock( state, '4' ) ).toBe( false );
|
|
1661
1943
|
} );
|
|
1662
1944
|
|
|
1663
1945
|
it( 'should return true if the selected block is a child of the given ClientId', () => {
|
|
1664
1946
|
const state = {
|
|
1665
1947
|
selection: {
|
|
1666
|
-
selectionStart: { clientId: 3 },
|
|
1667
|
-
selectionEnd: { clientId: 3 },
|
|
1948
|
+
selectionStart: { clientId: '3' },
|
|
1949
|
+
selectionEnd: { clientId: '3' },
|
|
1668
1950
|
},
|
|
1669
1951
|
blocks: {
|
|
1670
|
-
order:
|
|
1671
|
-
|
|
1672
|
-
|
|
1673
|
-
|
|
1674
|
-
|
|
1675
|
-
|
|
1676
|
-
|
|
1677
|
-
|
|
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
|
+
),
|
|
1678
1964
|
},
|
|
1679
1965
|
};
|
|
1680
1966
|
|
|
1681
|
-
expect( hasSelectedInnerBlock( state, 4 ) ).toBe( true );
|
|
1967
|
+
expect( hasSelectedInnerBlock( state, '4' ) ).toBe( true );
|
|
1682
1968
|
} );
|
|
1683
1969
|
|
|
1684
1970
|
it( 'should return true if a multi selection exists that contains children of the block with the given ClientId', () => {
|
|
1685
1971
|
const state = {
|
|
1686
1972
|
blocks: {
|
|
1687
|
-
order:
|
|
1688
|
-
|
|
1689
|
-
|
|
1690
|
-
|
|
1691
|
-
|
|
1692
|
-
|
|
1693
|
-
|
|
1694
|
-
|
|
1695
|
-
|
|
1696
|
-
|
|
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
|
+
),
|
|
1697
1987
|
},
|
|
1698
1988
|
selection: {
|
|
1699
|
-
selectionStart: { clientId: 2 },
|
|
1700
|
-
selectionEnd: { clientId: 4 },
|
|
1989
|
+
selectionStart: { clientId: '2' },
|
|
1990
|
+
selectionEnd: { clientId: '4' },
|
|
1701
1991
|
},
|
|
1702
1992
|
};
|
|
1703
|
-
expect( hasSelectedInnerBlock( state, 6 ) ).toBe( true );
|
|
1993
|
+
expect( hasSelectedInnerBlock( state, '6' ) ).toBe( true );
|
|
1704
1994
|
} );
|
|
1705
1995
|
|
|
1706
1996
|
it( 'should return false if a multi selection exists bot does not contains children of the block with the given ClientId', () => {
|
|
1707
1997
|
const state = {
|
|
1708
1998
|
blocks: {
|
|
1709
|
-
order:
|
|
1710
|
-
|
|
1711
|
-
|
|
1712
|
-
|
|
1713
|
-
|
|
1714
|
-
|
|
1715
|
-
|
|
1716
|
-
|
|
1717
|
-
|
|
1718
|
-
|
|
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
|
+
),
|
|
1719
2013
|
},
|
|
1720
2014
|
selection: {
|
|
1721
|
-
selectionStart: { clientId: 5 },
|
|
1722
|
-
selectionEnd: { clientId: 4 },
|
|
2015
|
+
selectionStart: { clientId: '5' },
|
|
2016
|
+
selectionEnd: { clientId: '4' },
|
|
1723
2017
|
},
|
|
1724
2018
|
};
|
|
1725
|
-
expect( hasSelectedInnerBlock( state, 3 ) ).toBe( false );
|
|
2019
|
+
expect( hasSelectedInnerBlock( state, '3' ) ).toBe( false );
|
|
1726
2020
|
} );
|
|
1727
2021
|
} );
|
|
1728
2022
|
|
|
@@ -1730,70 +2024,82 @@ describe( 'selectors', () => {
|
|
|
1730
2024
|
it( 'should return true if the block is selected but not the last', () => {
|
|
1731
2025
|
const state = {
|
|
1732
2026
|
selection: {
|
|
1733
|
-
selectionStart: { clientId: 5 },
|
|
1734
|
-
selectionEnd: { clientId: 3 },
|
|
2027
|
+
selectionStart: { clientId: '5' },
|
|
2028
|
+
selectionEnd: { clientId: '3' },
|
|
1735
2029
|
},
|
|
1736
2030
|
blocks: {
|
|
1737
|
-
order:
|
|
1738
|
-
|
|
1739
|
-
|
|
1740
|
-
|
|
1741
|
-
|
|
1742
|
-
|
|
1743
|
-
|
|
1744
|
-
|
|
1745
|
-
|
|
1746
|
-
|
|
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
|
+
),
|
|
1747
2045
|
},
|
|
1748
2046
|
};
|
|
1749
2047
|
|
|
1750
|
-
expect( isBlockWithinSelection( state, 4 ) ).toBe( true );
|
|
2048
|
+
expect( isBlockWithinSelection( state, '4' ) ).toBe( true );
|
|
1751
2049
|
} );
|
|
1752
2050
|
|
|
1753
2051
|
it( 'should return false if the block is the last selected', () => {
|
|
1754
2052
|
const state = {
|
|
1755
2053
|
selection: {
|
|
1756
|
-
selectionStart: { clientId: 5 },
|
|
1757
|
-
selectionEnd: { clientId: 3 },
|
|
2054
|
+
selectionStart: { clientId: '5' },
|
|
2055
|
+
selectionEnd: { clientId: '3' },
|
|
1758
2056
|
},
|
|
1759
2057
|
blocks: {
|
|
1760
|
-
order:
|
|
1761
|
-
|
|
1762
|
-
|
|
1763
|
-
|
|
1764
|
-
|
|
1765
|
-
|
|
1766
|
-
|
|
1767
|
-
|
|
1768
|
-
|
|
1769
|
-
|
|
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
|
+
),
|
|
1770
2072
|
},
|
|
1771
2073
|
};
|
|
1772
2074
|
|
|
1773
|
-
expect( isBlockWithinSelection( state, 3 ) ).toBe( false );
|
|
2075
|
+
expect( isBlockWithinSelection( state, '3' ) ).toBe( false );
|
|
1774
2076
|
} );
|
|
1775
2077
|
|
|
1776
2078
|
it( 'should return false if the block is not selected', () => {
|
|
1777
2079
|
const state = {
|
|
1778
2080
|
selection: {
|
|
1779
|
-
selectionStart: { clientId: 5 },
|
|
1780
|
-
selectionEnd: { clientId: 3 },
|
|
2081
|
+
selectionStart: { clientId: '5' },
|
|
2082
|
+
selectionEnd: { clientId: '3' },
|
|
1781
2083
|
},
|
|
1782
2084
|
blocks: {
|
|
1783
|
-
order:
|
|
1784
|
-
|
|
1785
|
-
|
|
1786
|
-
|
|
1787
|
-
|
|
1788
|
-
|
|
1789
|
-
|
|
1790
|
-
|
|
1791
|
-
|
|
1792
|
-
|
|
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
|
+
),
|
|
1793
2099
|
},
|
|
1794
2100
|
};
|
|
1795
2101
|
|
|
1796
|
-
expect( isBlockWithinSelection( state, 2 ) ).toBe( false );
|
|
2102
|
+
expect( isBlockWithinSelection( state, '2' ) ).toBe( false );
|
|
1797
2103
|
} );
|
|
1798
2104
|
|
|
1799
2105
|
it( 'should return false if there is no selection', () => {
|
|
@@ -1803,20 +2109,24 @@ describe( 'selectors', () => {
|
|
|
1803
2109
|
selectionEnd: {},
|
|
1804
2110
|
},
|
|
1805
2111
|
blocks: {
|
|
1806
|
-
order:
|
|
1807
|
-
|
|
1808
|
-
|
|
1809
|
-
|
|
1810
|
-
|
|
1811
|
-
|
|
1812
|
-
|
|
1813
|
-
|
|
1814
|
-
|
|
1815
|
-
|
|
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
|
+
),
|
|
1816
2126
|
},
|
|
1817
2127
|
};
|
|
1818
2128
|
|
|
1819
|
-
expect( isBlockWithinSelection( state, 4 ) ).toBe( false );
|
|
2129
|
+
expect( isBlockWithinSelection( state, '4' ) ).toBe( false );
|
|
1820
2130
|
} );
|
|
1821
2131
|
} );
|
|
1822
2132
|
|
|
@@ -1866,58 +2176,66 @@ describe( 'selectors', () => {
|
|
|
1866
2176
|
describe( 'isBlockMultiSelected', () => {
|
|
1867
2177
|
const state = {
|
|
1868
2178
|
blocks: {
|
|
1869
|
-
order:
|
|
1870
|
-
|
|
1871
|
-
|
|
1872
|
-
|
|
1873
|
-
|
|
1874
|
-
|
|
1875
|
-
|
|
1876
|
-
|
|
1877
|
-
|
|
1878
|
-
|
|
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
|
+
),
|
|
1879
2193
|
},
|
|
1880
2194
|
selection: {
|
|
1881
|
-
selectionStart: { clientId: 2 },
|
|
1882
|
-
selectionEnd: { clientId: 4 },
|
|
2195
|
+
selectionStart: { clientId: '2' },
|
|
2196
|
+
selectionEnd: { clientId: '4' },
|
|
1883
2197
|
},
|
|
1884
2198
|
};
|
|
1885
2199
|
|
|
1886
2200
|
it( 'should return true if the block is multi selected', () => {
|
|
1887
|
-
expect( isBlockMultiSelected( state, 3 ) ).toBe( true );
|
|
2201
|
+
expect( isBlockMultiSelected( state, '3' ) ).toBe( true );
|
|
1888
2202
|
} );
|
|
1889
2203
|
|
|
1890
2204
|
it( 'should return false if the block is not multi selected', () => {
|
|
1891
|
-
expect( isBlockMultiSelected( state, 5 ) ).toBe( false );
|
|
2205
|
+
expect( isBlockMultiSelected( state, '5' ) ).toBe( false );
|
|
1892
2206
|
} );
|
|
1893
2207
|
} );
|
|
1894
2208
|
|
|
1895
2209
|
describe( 'isFirstMultiSelectedBlock', () => {
|
|
1896
2210
|
const state = {
|
|
1897
2211
|
blocks: {
|
|
1898
|
-
order:
|
|
1899
|
-
|
|
1900
|
-
|
|
1901
|
-
|
|
1902
|
-
|
|
1903
|
-
|
|
1904
|
-
|
|
1905
|
-
|
|
1906
|
-
|
|
1907
|
-
|
|
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
|
+
),
|
|
1908
2226
|
},
|
|
1909
2227
|
selection: {
|
|
1910
|
-
selectionStart: { clientId: 2 },
|
|
1911
|
-
selectionEnd: { clientId: 4 },
|
|
2228
|
+
selectionStart: { clientId: '2' },
|
|
2229
|
+
selectionEnd: { clientId: '4' },
|
|
1912
2230
|
},
|
|
1913
2231
|
};
|
|
1914
2232
|
|
|
1915
2233
|
it( 'should return true if the block is first in multi selection', () => {
|
|
1916
|
-
expect( isFirstMultiSelectedBlock( state, 4 ) ).toBe( true );
|
|
2234
|
+
expect( isFirstMultiSelectedBlock( state, '4' ) ).toBe( true );
|
|
1917
2235
|
} );
|
|
1918
2236
|
|
|
1919
2237
|
it( 'should return false if the block is not first in multi selection', () => {
|
|
1920
|
-
expect( isFirstMultiSelectedBlock( state, 3 ) ).toBe( false );
|
|
2238
|
+
expect( isFirstMultiSelectedBlock( state, '3' ) ).toBe( false );
|
|
1921
2239
|
} );
|
|
1922
2240
|
} );
|
|
1923
2241
|
|
|
@@ -1927,7 +2245,7 @@ describe( 'selectors', () => {
|
|
|
1927
2245
|
blocksMode: {},
|
|
1928
2246
|
};
|
|
1929
2247
|
|
|
1930
|
-
expect( getBlockMode( state, 123 ) ).toEqual( 'visual' );
|
|
2248
|
+
expect( getBlockMode( state, '123' ) ).toEqual( 'visual' );
|
|
1931
2249
|
} );
|
|
1932
2250
|
|
|
1933
2251
|
it( 'should return the block mode', () => {
|
|
@@ -1937,7 +2255,7 @@ describe( 'selectors', () => {
|
|
|
1937
2255
|
},
|
|
1938
2256
|
};
|
|
1939
2257
|
|
|
1940
|
-
expect( getBlockMode( state, 123 ) ).toEqual( 'html' );
|
|
2258
|
+
expect( getBlockMode( state, '123' ) ).toEqual( 'html' );
|
|
1941
2259
|
} );
|
|
1942
2260
|
} );
|
|
1943
2261
|
|
|
@@ -2031,10 +2349,12 @@ describe( 'selectors', () => {
|
|
|
2031
2349
|
const state = {
|
|
2032
2350
|
draggedBlocks: [ 'block-1_grandparent' ],
|
|
2033
2351
|
blocks: {
|
|
2034
|
-
parents:
|
|
2035
|
-
|
|
2036
|
-
|
|
2037
|
-
|
|
2352
|
+
parents: new Map(
|
|
2353
|
+
Object.entries( {
|
|
2354
|
+
'block-1': 'block-1_parent',
|
|
2355
|
+
'block-1_parent': 'block-1_grandparent',
|
|
2356
|
+
} )
|
|
2357
|
+
),
|
|
2038
2358
|
},
|
|
2039
2359
|
};
|
|
2040
2360
|
expect( isAncestorBeingDragged( state, 'block-1' ) ).toBe( true );
|
|
@@ -2044,10 +2364,12 @@ describe( 'selectors', () => {
|
|
|
2044
2364
|
const state = {
|
|
2045
2365
|
draggedBlocks: [ 'block-2_grandparent' ],
|
|
2046
2366
|
blocks: {
|
|
2047
|
-
parents:
|
|
2048
|
-
|
|
2049
|
-
|
|
2050
|
-
|
|
2367
|
+
parents: new Map(
|
|
2368
|
+
Object.entries( {
|
|
2369
|
+
'block-1': 'block-1_parent',
|
|
2370
|
+
'block-1_parent': 'block-1_grandparent',
|
|
2371
|
+
} )
|
|
2372
|
+
),
|
|
2051
2373
|
},
|
|
2052
2374
|
};
|
|
2053
2375
|
expect( isAncestorBeingDragged( state, 'block-1' ) ).toBe( false );
|
|
@@ -2057,10 +2379,12 @@ describe( 'selectors', () => {
|
|
|
2057
2379
|
const state = {
|
|
2058
2380
|
draggedBlocks: [],
|
|
2059
2381
|
blocks: {
|
|
2060
|
-
parents:
|
|
2061
|
-
|
|
2062
|
-
|
|
2063
|
-
|
|
2382
|
+
parents: new Map(
|
|
2383
|
+
Object.entries( {
|
|
2384
|
+
'block-1': 'block-1_parent',
|
|
2385
|
+
'block-1_parent': 'block-1_grandparent',
|
|
2386
|
+
} )
|
|
2387
|
+
),
|
|
2064
2388
|
},
|
|
2065
2389
|
};
|
|
2066
2390
|
expect( isAncestorBeingDragged( state, 'block-1' ) ).toBe( false );
|
|
@@ -2093,23 +2417,31 @@ describe( 'selectors', () => {
|
|
|
2093
2417
|
selectionEnd: { clientId: 'clientId2' },
|
|
2094
2418
|
},
|
|
2095
2419
|
blocks: {
|
|
2096
|
-
byClientId:
|
|
2097
|
-
|
|
2098
|
-
|
|
2099
|
-
|
|
2100
|
-
|
|
2101
|
-
|
|
2102
|
-
|
|
2103
|
-
|
|
2104
|
-
|
|
2105
|
-
|
|
2106
|
-
|
|
2107
|
-
|
|
2108
|
-
|
|
2109
|
-
|
|
2110
|
-
|
|
2111
|
-
|
|
2112
|
-
|
|
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
|
+
),
|
|
2113
2445
|
},
|
|
2114
2446
|
insertionPoint: {
|
|
2115
2447
|
rootClientId: undefined,
|
|
@@ -2130,19 +2462,27 @@ describe( 'selectors', () => {
|
|
|
2130
2462
|
selectionEnd: { clientId: 'clientId1' },
|
|
2131
2463
|
},
|
|
2132
2464
|
blocks: {
|
|
2133
|
-
byClientId:
|
|
2134
|
-
|
|
2135
|
-
|
|
2136
|
-
|
|
2137
|
-
|
|
2138
|
-
|
|
2139
|
-
|
|
2140
|
-
|
|
2141
|
-
|
|
2142
|
-
|
|
2143
|
-
|
|
2144
|
-
|
|
2145
|
-
|
|
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
|
+
),
|
|
2146
2486
|
},
|
|
2147
2487
|
insertionPoint: null,
|
|
2148
2488
|
};
|
|
@@ -2160,23 +2500,31 @@ describe( 'selectors', () => {
|
|
|
2160
2500
|
selectionEnd: { clientId: 'clientId2' },
|
|
2161
2501
|
},
|
|
2162
2502
|
blocks: {
|
|
2163
|
-
byClientId:
|
|
2164
|
-
|
|
2165
|
-
|
|
2166
|
-
|
|
2167
|
-
|
|
2168
|
-
|
|
2169
|
-
|
|
2170
|
-
|
|
2171
|
-
|
|
2172
|
-
|
|
2173
|
-
|
|
2174
|
-
|
|
2175
|
-
|
|
2176
|
-
|
|
2177
|
-
|
|
2178
|
-
|
|
2179
|
-
|
|
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
|
+
),
|
|
2180
2528
|
},
|
|
2181
2529
|
insertionPoint: null,
|
|
2182
2530
|
};
|
|
@@ -2194,23 +2542,31 @@ describe( 'selectors', () => {
|
|
|
2194
2542
|
selectionEnd: { clientId: 'clientId2' },
|
|
2195
2543
|
},
|
|
2196
2544
|
blocks: {
|
|
2197
|
-
byClientId:
|
|
2198
|
-
|
|
2199
|
-
|
|
2200
|
-
|
|
2201
|
-
|
|
2202
|
-
|
|
2203
|
-
|
|
2204
|
-
|
|
2205
|
-
|
|
2206
|
-
|
|
2207
|
-
|
|
2208
|
-
|
|
2209
|
-
|
|
2210
|
-
|
|
2211
|
-
|
|
2212
|
-
|
|
2213
|
-
|
|
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
|
+
),
|
|
2214
2570
|
},
|
|
2215
2571
|
insertionPoint: null,
|
|
2216
2572
|
};
|
|
@@ -2228,23 +2584,31 @@ describe( 'selectors', () => {
|
|
|
2228
2584
|
selectionEnd: {},
|
|
2229
2585
|
},
|
|
2230
2586
|
blocks: {
|
|
2231
|
-
byClientId:
|
|
2232
|
-
|
|
2233
|
-
|
|
2234
|
-
|
|
2235
|
-
|
|
2236
|
-
|
|
2237
|
-
|
|
2238
|
-
|
|
2239
|
-
|
|
2240
|
-
|
|
2241
|
-
|
|
2242
|
-
|
|
2243
|
-
|
|
2244
|
-
|
|
2245
|
-
|
|
2246
|
-
|
|
2247
|
-
|
|
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
|
+
),
|
|
2248
2612
|
},
|
|
2249
2613
|
insertionPoint: null,
|
|
2250
2614
|
};
|
|
@@ -2281,8 +2645,8 @@ describe( 'selectors', () => {
|
|
|
2281
2645
|
it( 'should deny blocks that are not registered', () => {
|
|
2282
2646
|
const state = {
|
|
2283
2647
|
blocks: {
|
|
2284
|
-
byClientId:
|
|
2285
|
-
attributes:
|
|
2648
|
+
byClientId: new Map(),
|
|
2649
|
+
attributes: new Map(),
|
|
2286
2650
|
},
|
|
2287
2651
|
blockListSettings: {},
|
|
2288
2652
|
settings: {},
|
|
@@ -2293,8 +2657,8 @@ describe( 'selectors', () => {
|
|
|
2293
2657
|
it( 'should deny blocks that are not allowed by the editor', () => {
|
|
2294
2658
|
const state = {
|
|
2295
2659
|
blocks: {
|
|
2296
|
-
byClientId:
|
|
2297
|
-
attributes:
|
|
2660
|
+
byClientId: new Map(),
|
|
2661
|
+
attributes: new Map(),
|
|
2298
2662
|
},
|
|
2299
2663
|
blockListSettings: {},
|
|
2300
2664
|
settings: {
|
|
@@ -2309,8 +2673,8 @@ describe( 'selectors', () => {
|
|
|
2309
2673
|
it( 'should allow blocks that are allowed by the editor', () => {
|
|
2310
2674
|
const state = {
|
|
2311
2675
|
blocks: {
|
|
2312
|
-
byClientId:
|
|
2313
|
-
attributes:
|
|
2676
|
+
byClientId: new Map(),
|
|
2677
|
+
attributes: new Map(),
|
|
2314
2678
|
},
|
|
2315
2679
|
blockListSettings: {},
|
|
2316
2680
|
settings: {
|
|
@@ -2325,8 +2689,8 @@ describe( 'selectors', () => {
|
|
|
2325
2689
|
it( 'should deny blocks when the editor has a template lock', () => {
|
|
2326
2690
|
const state = {
|
|
2327
2691
|
blocks: {
|
|
2328
|
-
byClientId:
|
|
2329
|
-
attributes:
|
|
2692
|
+
byClientId: new Map(),
|
|
2693
|
+
attributes: new Map(),
|
|
2330
2694
|
},
|
|
2331
2695
|
blockListSettings: {},
|
|
2332
2696
|
settings: {
|
|
@@ -2341,8 +2705,8 @@ describe( 'selectors', () => {
|
|
|
2341
2705
|
it( 'should deny blocks that restrict parent from being inserted into the root', () => {
|
|
2342
2706
|
const state = {
|
|
2343
2707
|
blocks: {
|
|
2344
|
-
byClientId:
|
|
2345
|
-
attributes:
|
|
2708
|
+
byClientId: new Map(),
|
|
2709
|
+
attributes: new Map(),
|
|
2346
2710
|
},
|
|
2347
2711
|
blockListSettings: {},
|
|
2348
2712
|
settings: {},
|
|
@@ -2355,12 +2719,16 @@ describe( 'selectors', () => {
|
|
|
2355
2719
|
it( 'should deny blocks that restrict parent from being inserted into a restricted parent', () => {
|
|
2356
2720
|
const state = {
|
|
2357
2721
|
blocks: {
|
|
2358
|
-
byClientId:
|
|
2359
|
-
|
|
2360
|
-
|
|
2361
|
-
|
|
2362
|
-
|
|
2363
|
-
|
|
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
|
+
),
|
|
2364
2732
|
},
|
|
2365
2733
|
blockListSettings: {},
|
|
2366
2734
|
settings: {},
|
|
@@ -2373,12 +2741,16 @@ describe( 'selectors', () => {
|
|
|
2373
2741
|
it( 'should allow blocks to be inserted into an allowed parent', () => {
|
|
2374
2742
|
const state = {
|
|
2375
2743
|
blocks: {
|
|
2376
|
-
byClientId:
|
|
2377
|
-
|
|
2378
|
-
|
|
2379
|
-
|
|
2380
|
-
|
|
2381
|
-
|
|
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
|
+
),
|
|
2382
2754
|
},
|
|
2383
2755
|
blockListSettings: {
|
|
2384
2756
|
block1: {},
|
|
@@ -2393,12 +2765,16 @@ describe( 'selectors', () => {
|
|
|
2393
2765
|
it( 'should deny blocks from being inserted into a block that does not allow inner blocks', () => {
|
|
2394
2766
|
const state = {
|
|
2395
2767
|
blocks: {
|
|
2396
|
-
byClientId:
|
|
2397
|
-
|
|
2398
|
-
|
|
2399
|
-
|
|
2400
|
-
|
|
2401
|
-
|
|
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
|
+
),
|
|
2402
2778
|
},
|
|
2403
2779
|
blockListSettings: {
|
|
2404
2780
|
block1: {},
|
|
@@ -2413,12 +2789,16 @@ describe( 'selectors', () => {
|
|
|
2413
2789
|
it( 'should deny restricted blocks from being inserted into a block that restricts allowedBlocks', () => {
|
|
2414
2790
|
const state = {
|
|
2415
2791
|
blocks: {
|
|
2416
|
-
byClientId:
|
|
2417
|
-
|
|
2418
|
-
|
|
2419
|
-
|
|
2420
|
-
|
|
2421
|
-
|
|
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
|
+
),
|
|
2422
2802
|
},
|
|
2423
2803
|
blockListSettings: {
|
|
2424
2804
|
block1: {
|
|
@@ -2435,12 +2815,16 @@ describe( 'selectors', () => {
|
|
|
2435
2815
|
it( 'should allow allowed blocks to be inserted into a block that restricts allowedBlocks', () => {
|
|
2436
2816
|
const state = {
|
|
2437
2817
|
blocks: {
|
|
2438
|
-
byClientId:
|
|
2439
|
-
|
|
2440
|
-
|
|
2441
|
-
|
|
2442
|
-
|
|
2443
|
-
|
|
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
|
+
),
|
|
2444
2828
|
},
|
|
2445
2829
|
blockListSettings: {
|
|
2446
2830
|
block1: {
|
|
@@ -2457,12 +2841,16 @@ describe( 'selectors', () => {
|
|
|
2457
2841
|
it( 'should prioritise parent over allowedBlocks', () => {
|
|
2458
2842
|
const state = {
|
|
2459
2843
|
blocks: {
|
|
2460
|
-
byClientId:
|
|
2461
|
-
|
|
2462
|
-
|
|
2463
|
-
|
|
2464
|
-
|
|
2465
|
-
|
|
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
|
+
),
|
|
2466
2854
|
},
|
|
2467
2855
|
blockListSettings: {
|
|
2468
2856
|
block1: {
|
|
@@ -2479,12 +2867,16 @@ describe( 'selectors', () => {
|
|
|
2479
2867
|
it( 'should deny blocks that restrict parent to core/post-content when not in editor root', () => {
|
|
2480
2868
|
const state = {
|
|
2481
2869
|
blocks: {
|
|
2482
|
-
byClientId:
|
|
2483
|
-
|
|
2484
|
-
|
|
2485
|
-
|
|
2486
|
-
|
|
2487
|
-
|
|
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
|
+
),
|
|
2488
2880
|
},
|
|
2489
2881
|
blockListSettings: {},
|
|
2490
2882
|
settings: {},
|
|
@@ -2497,8 +2889,8 @@ describe( 'selectors', () => {
|
|
|
2497
2889
|
it( 'should allow blocks that restrict parent to core/post-content when in editor root', () => {
|
|
2498
2890
|
const state = {
|
|
2499
2891
|
blocks: {
|
|
2500
|
-
byClientId:
|
|
2501
|
-
attributes:
|
|
2892
|
+
byClientId: new Map(),
|
|
2893
|
+
attributes: new Map(),
|
|
2502
2894
|
},
|
|
2503
2895
|
blockListSettings: {},
|
|
2504
2896
|
settings: {},
|
|
@@ -2511,17 +2903,23 @@ describe( 'selectors', () => {
|
|
|
2511
2903
|
it( 'should allow blocks to be inserted in a descendant of a required ancestor', () => {
|
|
2512
2904
|
const state = {
|
|
2513
2905
|
blocks: {
|
|
2514
|
-
byClientId:
|
|
2515
|
-
|
|
2516
|
-
|
|
2517
|
-
|
|
2518
|
-
|
|
2519
|
-
|
|
2520
|
-
|
|
2521
|
-
|
|
2522
|
-
|
|
2523
|
-
|
|
2524
|
-
|
|
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
|
+
),
|
|
2525
2923
|
},
|
|
2526
2924
|
blockListSettings: {
|
|
2527
2925
|
block1: {},
|
|
@@ -2541,20 +2939,26 @@ describe( 'selectors', () => {
|
|
|
2541
2939
|
it( 'should allow blocks to be inserted if both parent and ancestor restrictions are met', () => {
|
|
2542
2940
|
const state = {
|
|
2543
2941
|
blocks: {
|
|
2544
|
-
byClientId:
|
|
2545
|
-
|
|
2546
|
-
|
|
2547
|
-
|
|
2548
|
-
|
|
2549
|
-
|
|
2550
|
-
|
|
2551
|
-
|
|
2552
|
-
|
|
2553
|
-
|
|
2554
|
-
|
|
2555
|
-
|
|
2556
|
-
|
|
2557
|
-
|
|
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
|
+
),
|
|
2558
2962
|
},
|
|
2559
2963
|
blockListSettings: {
|
|
2560
2964
|
block1: {},
|
|
@@ -2575,19 +2979,25 @@ describe( 'selectors', () => {
|
|
|
2575
2979
|
it( 'should deny blocks from being inserted outside a required ancestor', () => {
|
|
2576
2980
|
const state = {
|
|
2577
2981
|
blocks: {
|
|
2578
|
-
byClientId:
|
|
2579
|
-
|
|
2580
|
-
|
|
2581
|
-
|
|
2582
|
-
|
|
2583
|
-
|
|
2584
|
-
|
|
2585
|
-
|
|
2586
|
-
|
|
2587
|
-
|
|
2588
|
-
|
|
2589
|
-
|
|
2590
|
-
|
|
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
|
+
),
|
|
2591
3001
|
},
|
|
2592
3002
|
blockListSettings: {
|
|
2593
3003
|
block1: {},
|
|
@@ -2608,19 +3018,25 @@ describe( 'selectors', () => {
|
|
|
2608
3018
|
it( 'should deny blocks from being inserted outside of a required ancestor, even if parent matches', () => {
|
|
2609
3019
|
const state = {
|
|
2610
3020
|
blocks: {
|
|
2611
|
-
byClientId:
|
|
2612
|
-
|
|
2613
|
-
|
|
2614
|
-
|
|
2615
|
-
|
|
2616
|
-
|
|
2617
|
-
|
|
2618
|
-
|
|
2619
|
-
|
|
2620
|
-
|
|
2621
|
-
|
|
2622
|
-
|
|
2623
|
-
|
|
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
|
+
),
|
|
2624
3040
|
},
|
|
2625
3041
|
blockListSettings: {
|
|
2626
3042
|
block1: {},
|
|
@@ -2641,17 +3057,23 @@ describe( 'selectors', () => {
|
|
|
2641
3057
|
it( 'should deny blocks from being inserted inside ancestor if parent restricts allowedBlocks', () => {
|
|
2642
3058
|
const state = {
|
|
2643
3059
|
blocks: {
|
|
2644
|
-
byClientId:
|
|
2645
|
-
|
|
2646
|
-
|
|
2647
|
-
|
|
2648
|
-
|
|
2649
|
-
|
|
2650
|
-
|
|
2651
|
-
|
|
2652
|
-
|
|
2653
|
-
|
|
2654
|
-
|
|
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
|
+
),
|
|
2655
3077
|
},
|
|
2656
3078
|
blockListSettings: {
|
|
2657
3079
|
block1: {},
|
|
@@ -2673,17 +3095,23 @@ describe( 'selectors', () => {
|
|
|
2673
3095
|
it( 'should deny blocks from being inserted inside ancestor if parent restriction is not met', () => {
|
|
2674
3096
|
const state = {
|
|
2675
3097
|
blocks: {
|
|
2676
|
-
byClientId:
|
|
2677
|
-
|
|
2678
|
-
|
|
2679
|
-
|
|
2680
|
-
|
|
2681
|
-
|
|
2682
|
-
|
|
2683
|
-
|
|
2684
|
-
|
|
2685
|
-
|
|
2686
|
-
|
|
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
|
+
),
|
|
2687
3115
|
},
|
|
2688
3116
|
blockListSettings: {
|
|
2689
3117
|
block1: {},
|
|
@@ -2705,16 +3133,20 @@ describe( 'selectors', () => {
|
|
|
2705
3133
|
it( 'should allow blocks', () => {
|
|
2706
3134
|
const state = {
|
|
2707
3135
|
blocks: {
|
|
2708
|
-
byClientId:
|
|
2709
|
-
|
|
2710
|
-
|
|
2711
|
-
|
|
2712
|
-
|
|
2713
|
-
|
|
2714
|
-
|
|
2715
|
-
|
|
2716
|
-
|
|
2717
|
-
|
|
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
|
+
),
|
|
2718
3150
|
},
|
|
2719
3151
|
blockListSettings: {
|
|
2720
3152
|
1: {
|
|
@@ -2732,16 +3164,20 @@ describe( 'selectors', () => {
|
|
|
2732
3164
|
it( 'should deny blocks', () => {
|
|
2733
3165
|
const state = {
|
|
2734
3166
|
blocks: {
|
|
2735
|
-
byClientId:
|
|
2736
|
-
|
|
2737
|
-
|
|
2738
|
-
|
|
2739
|
-
|
|
2740
|
-
|
|
2741
|
-
|
|
2742
|
-
|
|
2743
|
-
|
|
2744
|
-
|
|
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
|
+
),
|
|
2745
3181
|
},
|
|
2746
3182
|
blockListSettings: {
|
|
2747
3183
|
1: {
|
|
@@ -2758,15 +3194,17 @@ describe( 'selectors', () => {
|
|
|
2758
3194
|
it( 'should properly list block type and reusable block items', () => {
|
|
2759
3195
|
const state = {
|
|
2760
3196
|
blocks: {
|
|
2761
|
-
byClientId:
|
|
2762
|
-
attributes:
|
|
2763
|
-
order:
|
|
2764
|
-
parents:
|
|
2765
|
-
tree:
|
|
2766
|
-
|
|
2767
|
-
|
|
2768
|
-
|
|
2769
|
-
|
|
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
|
+
),
|
|
2770
3208
|
},
|
|
2771
3209
|
settings: {
|
|
2772
3210
|
__experimentalReusableBlocks: [
|
|
@@ -2827,35 +3265,45 @@ describe( 'selectors', () => {
|
|
|
2827
3265
|
it( 'should correctly cache the return values', () => {
|
|
2828
3266
|
const state = {
|
|
2829
3267
|
blocks: {
|
|
2830
|
-
byClientId:
|
|
2831
|
-
|
|
2832
|
-
|
|
2833
|
-
|
|
2834
|
-
|
|
2835
|
-
|
|
2836
|
-
|
|
2837
|
-
|
|
2838
|
-
|
|
2839
|
-
|
|
2840
|
-
|
|
2841
|
-
|
|
2842
|
-
|
|
2843
|
-
|
|
2844
|
-
|
|
2845
|
-
|
|
2846
|
-
|
|
2847
|
-
|
|
2848
|
-
|
|
2849
|
-
|
|
2850
|
-
|
|
2851
|
-
}
|
|
2852
|
-
|
|
2853
|
-
|
|
2854
|
-
|
|
2855
|
-
|
|
2856
|
-
|
|
2857
|
-
|
|
2858
|
-
|
|
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
|
+
),
|
|
2859
3307
|
controlledInnerBlocks: {},
|
|
2860
3308
|
},
|
|
2861
3309
|
settings: {
|
|
@@ -2934,28 +3382,36 @@ describe( 'selectors', () => {
|
|
|
2934
3382
|
it( 'should set isDisabled when a block with `multiple: false` has been used', () => {
|
|
2935
3383
|
const state = {
|
|
2936
3384
|
blocks: {
|
|
2937
|
-
byClientId:
|
|
2938
|
-
|
|
2939
|
-
|
|
2940
|
-
|
|
2941
|
-
|
|
2942
|
-
|
|
2943
|
-
|
|
2944
|
-
|
|
2945
|
-
|
|
2946
|
-
|
|
2947
|
-
|
|
2948
|
-
|
|
2949
|
-
|
|
2950
|
-
|
|
2951
|
-
|
|
2952
|
-
|
|
2953
|
-
|
|
2954
|
-
|
|
2955
|
-
|
|
2956
|
-
|
|
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
|
+
),
|
|
2957
3413
|
controlledInnerBlocks: {},
|
|
2958
|
-
parents:
|
|
3414
|
+
parents: new Map(),
|
|
2959
3415
|
},
|
|
2960
3416
|
preferences: {
|
|
2961
3417
|
insertUsage: {},
|
|
@@ -2973,10 +3429,10 @@ describe( 'selectors', () => {
|
|
|
2973
3429
|
it( 'should set a frecency', () => {
|
|
2974
3430
|
const state = {
|
|
2975
3431
|
blocks: {
|
|
2976
|
-
byClientId:
|
|
2977
|
-
attributes:
|
|
2978
|
-
order:
|
|
2979
|
-
parents:
|
|
3432
|
+
byClientId: new Map(),
|
|
3433
|
+
attributes: new Map(),
|
|
3434
|
+
order: new Map(),
|
|
3435
|
+
parents: new Map(),
|
|
2980
3436
|
cache: {},
|
|
2981
3437
|
},
|
|
2982
3438
|
preferences: {
|
|
@@ -3068,10 +3524,10 @@ describe( 'selectors', () => {
|
|
|
3068
3524
|
it( 'should properly return block type items', () => {
|
|
3069
3525
|
const state = {
|
|
3070
3526
|
blocks: {
|
|
3071
|
-
byClientId:
|
|
3072
|
-
attributes:
|
|
3073
|
-
order:
|
|
3074
|
-
parents:
|
|
3527
|
+
byClientId: new Map(),
|
|
3528
|
+
attributes: new Map(),
|
|
3529
|
+
order: new Map(),
|
|
3530
|
+
parents: new Map(),
|
|
3075
3531
|
cache: {},
|
|
3076
3532
|
},
|
|
3077
3533
|
settings: {},
|
|
@@ -3108,10 +3564,10 @@ describe( 'selectors', () => {
|
|
|
3108
3564
|
it( 'should support single block object', () => {
|
|
3109
3565
|
const state = {
|
|
3110
3566
|
blocks: {
|
|
3111
|
-
byClientId:
|
|
3112
|
-
attributes:
|
|
3113
|
-
order:
|
|
3114
|
-
parents:
|
|
3567
|
+
byClientId: new Map(),
|
|
3568
|
+
attributes: new Map(),
|
|
3569
|
+
order: new Map(),
|
|
3570
|
+
parents: new Map(),
|
|
3115
3571
|
cache: {},
|
|
3116
3572
|
},
|
|
3117
3573
|
settings: {},
|
|
@@ -3125,19 +3581,25 @@ describe( 'selectors', () => {
|
|
|
3125
3581
|
it( 'should return only eligible blocks for transformation - `allowedBlocks`', () => {
|
|
3126
3582
|
const state = {
|
|
3127
3583
|
blocks: {
|
|
3128
|
-
byClientId:
|
|
3129
|
-
|
|
3130
|
-
|
|
3131
|
-
|
|
3132
|
-
|
|
3133
|
-
|
|
3134
|
-
|
|
3135
|
-
|
|
3136
|
-
|
|
3137
|
-
|
|
3138
|
-
|
|
3139
|
-
|
|
3140
|
-
|
|
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
|
+
),
|
|
3141
3603
|
cache: {},
|
|
3142
3604
|
controlledInnerBlocks: {},
|
|
3143
3605
|
},
|
|
@@ -3160,28 +3622,36 @@ describe( 'selectors', () => {
|
|
|
3160
3622
|
it( 'should take into account the usage of blocks settings `multiple` - if multiple blocks of the same type are allowed', () => {
|
|
3161
3623
|
const state = {
|
|
3162
3624
|
blocks: {
|
|
3163
|
-
byClientId:
|
|
3164
|
-
|
|
3165
|
-
|
|
3166
|
-
|
|
3167
|
-
|
|
3168
|
-
|
|
3169
|
-
|
|
3170
|
-
|
|
3171
|
-
|
|
3172
|
-
|
|
3173
|
-
|
|
3174
|
-
|
|
3175
|
-
|
|
3176
|
-
|
|
3177
|
-
|
|
3178
|
-
|
|
3179
|
-
|
|
3180
|
-
|
|
3181
|
-
|
|
3182
|
-
|
|
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
|
+
),
|
|
3183
3653
|
controlledInnerBlocks: {},
|
|
3184
|
-
parents:
|
|
3654
|
+
parents: new Map(),
|
|
3185
3655
|
},
|
|
3186
3656
|
preferences: {
|
|
3187
3657
|
insertUsage: {},
|
|
@@ -3208,10 +3678,10 @@ describe( 'selectors', () => {
|
|
|
3208
3678
|
it( 'should set frecency', () => {
|
|
3209
3679
|
const state = {
|
|
3210
3680
|
blocks: {
|
|
3211
|
-
byClientId:
|
|
3212
|
-
attributes:
|
|
3213
|
-
order:
|
|
3214
|
-
parents:
|
|
3681
|
+
byClientId: new Map(),
|
|
3682
|
+
attributes: new Map(),
|
|
3683
|
+
order: new Map(),
|
|
3684
|
+
parents: new Map(),
|
|
3215
3685
|
cache: {},
|
|
3216
3686
|
},
|
|
3217
3687
|
preferences: {
|
|
@@ -3264,7 +3734,7 @@ describe( 'selectors', () => {
|
|
|
3264
3734
|
} );
|
|
3265
3735
|
|
|
3266
3736
|
describe( 'getTemplateLock', () => {
|
|
3267
|
-
it( 'should return the general template lock if no clientId was
|
|
3737
|
+
it( 'should return the general template lock if no clientId was specified', () => {
|
|
3268
3738
|
const state = {
|
|
3269
3739
|
settings: { templateLock: 'all' },
|
|
3270
3740
|
};
|
|
@@ -3272,7 +3742,7 @@ describe( 'selectors', () => {
|
|
|
3272
3742
|
expect( getTemplateLock( state ) ).toBe( 'all' );
|
|
3273
3743
|
} );
|
|
3274
3744
|
|
|
3275
|
-
it( 'should return
|
|
3745
|
+
it( 'should return false if the specified clientId was not found', () => {
|
|
3276
3746
|
const state = {
|
|
3277
3747
|
settings: { templateLock: 'all' },
|
|
3278
3748
|
blockListSettings: {
|
|
@@ -3282,10 +3752,10 @@ describe( 'selectors', () => {
|
|
|
3282
3752
|
},
|
|
3283
3753
|
};
|
|
3284
3754
|
|
|
3285
|
-
expect( getTemplateLock( state, 'ribs' ) ).toBe(
|
|
3755
|
+
expect( getTemplateLock( state, 'ribs' ) ).toBe( false );
|
|
3286
3756
|
} );
|
|
3287
3757
|
|
|
3288
|
-
it( 'should return
|
|
3758
|
+
it( 'should return false if template lock was not set on the specified block', () => {
|
|
3289
3759
|
const state = {
|
|
3290
3760
|
settings: { templateLock: 'all' },
|
|
3291
3761
|
blockListSettings: {
|
|
@@ -3295,7 +3765,7 @@ describe( 'selectors', () => {
|
|
|
3295
3765
|
},
|
|
3296
3766
|
};
|
|
3297
3767
|
|
|
3298
|
-
expect( getTemplateLock( state, '
|
|
3768
|
+
expect( getTemplateLock( state, 'chicken' ) ).toBe( false );
|
|
3299
3769
|
} );
|
|
3300
3770
|
|
|
3301
3771
|
it( 'should return the template lock for the specified clientId', () => {
|
|
@@ -3429,20 +3899,24 @@ describe( 'selectors', () => {
|
|
|
3429
3899
|
|
|
3430
3900
|
describe( 'getLowestCommonAncestorWithSelectedBlock', () => {
|
|
3431
3901
|
const blocks = {
|
|
3432
|
-
order:
|
|
3433
|
-
|
|
3434
|
-
|
|
3435
|
-
|
|
3436
|
-
|
|
3437
|
-
|
|
3438
|
-
|
|
3439
|
-
|
|
3440
|
-
|
|
3441
|
-
|
|
3442
|
-
|
|
3443
|
-
|
|
3444
|
-
|
|
3445
|
-
|
|
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
|
+
),
|
|
3446
3920
|
};
|
|
3447
3921
|
|
|
3448
3922
|
it( 'should not be defined if there is no block selected', () => {
|
|
@@ -3541,35 +4015,39 @@ describe( 'selectors', () => {
|
|
|
3541
4015
|
},
|
|
3542
4016
|
},
|
|
3543
4017
|
blocks: {
|
|
3544
|
-
parents:
|
|
3545
|
-
|
|
3546
|
-
|
|
3547
|
-
|
|
3548
|
-
|
|
3549
|
-
|
|
3550
|
-
|
|
3551
|
-
|
|
3552
|
-
|
|
3553
|
-
|
|
3554
|
-
|
|
3555
|
-
|
|
3556
|
-
|
|
3557
|
-
|
|
3558
|
-
|
|
3559
|
-
|
|
3560
|
-
|
|
3561
|
-
|
|
3562
|
-
|
|
3563
|
-
|
|
3564
|
-
|
|
3565
|
-
|
|
3566
|
-
|
|
3567
|
-
|
|
3568
|
-
|
|
3569
|
-
|
|
3570
|
-
|
|
3571
|
-
|
|
3572
|
-
|
|
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
|
+
),
|
|
3573
4051
|
cache: {
|
|
3574
4052
|
'client-id-01': {},
|
|
3575
4053
|
'client-id-02': {},
|
|
@@ -3577,9 +4055,11 @@ describe( 'selectors', () => {
|
|
|
3577
4055
|
'client-id-04': {},
|
|
3578
4056
|
'client-id-05': {},
|
|
3579
4057
|
},
|
|
3580
|
-
order:
|
|
3581
|
-
|
|
3582
|
-
|
|
4058
|
+
order: new Map(
|
|
4059
|
+
Object.entries( {
|
|
4060
|
+
'client-id-03': [ 'client-id-04', 'client-id-05' ],
|
|
4061
|
+
} )
|
|
4062
|
+
),
|
|
3583
4063
|
controlledInnerBlocks: {},
|
|
3584
4064
|
},
|
|
3585
4065
|
};
|
|
@@ -3611,14 +4091,18 @@ describe( 'selectors', () => {
|
|
|
3611
4091
|
describe( '__experimentalGetAllowedPatterns', () => {
|
|
3612
4092
|
const state = {
|
|
3613
4093
|
blocks: {
|
|
3614
|
-
byClientId:
|
|
3615
|
-
|
|
3616
|
-
|
|
3617
|
-
|
|
3618
|
-
|
|
3619
|
-
|
|
3620
|
-
|
|
3621
|
-
|
|
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
|
+
),
|
|
3622
4106
|
},
|
|
3623
4107
|
blockListSettings: {
|
|
3624
4108
|
block1: {
|
|
@@ -3670,7 +4154,7 @@ describe( 'selectors', () => {
|
|
|
3670
4154
|
it( 'should return empty array if only patterns hidden from UI exist', () => {
|
|
3671
4155
|
expect(
|
|
3672
4156
|
__experimentalGetAllowedPatterns( {
|
|
3673
|
-
blocks: { byClientId:
|
|
4157
|
+
blocks: { byClientId: new Map() },
|
|
3674
4158
|
blockListSettings: {},
|
|
3675
4159
|
settings: {
|
|
3676
4160
|
__experimentalBlockPatterns: [
|
|
@@ -3742,9 +4226,11 @@ describe( 'selectors', () => {
|
|
|
3742
4226
|
describe( '__experimentalGetPatternsByBlockTypes', () => {
|
|
3743
4227
|
const state = {
|
|
3744
4228
|
blocks: {
|
|
3745
|
-
byClientId:
|
|
3746
|
-
|
|
3747
|
-
|
|
4229
|
+
byClientId: new Map(
|
|
4230
|
+
Object.entries( {
|
|
4231
|
+
block1: { name: 'core/test-block-a' },
|
|
4232
|
+
} )
|
|
4233
|
+
),
|
|
3748
4234
|
},
|
|
3749
4235
|
blockListSettings: {
|
|
3750
4236
|
block1: {
|
|
@@ -3816,10 +4302,12 @@ describe( 'selectors', () => {
|
|
|
3816
4302
|
describe( '__experimentalGetPatternTransformItems', () => {
|
|
3817
4303
|
const state = {
|
|
3818
4304
|
blocks: {
|
|
3819
|
-
byClientId:
|
|
3820
|
-
|
|
3821
|
-
|
|
3822
|
-
|
|
4305
|
+
byClientId: new Map(
|
|
4306
|
+
Object.entries( {
|
|
4307
|
+
block1: { name: 'core/test-block-a' },
|
|
4308
|
+
block2: { name: 'core/test-block-b' },
|
|
4309
|
+
} )
|
|
4310
|
+
),
|
|
3823
4311
|
controlledInnerBlocks: { 'block2-clientId': true },
|
|
3824
4312
|
},
|
|
3825
4313
|
blockListSettings: {
|
|
@@ -4073,10 +4561,10 @@ describe( 'getInserterItems with core blocks prioritization', () => {
|
|
|
4073
4561
|
it( 'should prioritize core blocks by sorting them at the top of the returned list', () => {
|
|
4074
4562
|
const state = {
|
|
4075
4563
|
blocks: {
|
|
4076
|
-
byClientId:
|
|
4077
|
-
attributes:
|
|
4078
|
-
order:
|
|
4079
|
-
parents:
|
|
4564
|
+
byClientId: new Map(),
|
|
4565
|
+
attributes: new Map(),
|
|
4566
|
+
order: new Map(),
|
|
4567
|
+
parents: new Map(),
|
|
4080
4568
|
cache: {},
|
|
4081
4569
|
},
|
|
4082
4570
|
settings: {},
|
|
@@ -4104,11 +4592,13 @@ describe( '__unstableGetClientIdWithClientIdsTree', () => {
|
|
|
4104
4592
|
it( "should return a stripped down block object containing only its client ID and its inner blocks' client IDs", () => {
|
|
4105
4593
|
const state = {
|
|
4106
4594
|
blocks: {
|
|
4107
|
-
order:
|
|
4108
|
-
|
|
4109
|
-
|
|
4110
|
-
|
|
4111
|
-
|
|
4595
|
+
order: new Map(
|
|
4596
|
+
Object.entries( {
|
|
4597
|
+
'': [ 'foo' ],
|
|
4598
|
+
foo: [ 'bar', 'baz' ],
|
|
4599
|
+
bar: [ 'qux' ],
|
|
4600
|
+
} )
|
|
4601
|
+
),
|
|
4112
4602
|
},
|
|
4113
4603
|
};
|
|
4114
4604
|
|
|
@@ -4130,11 +4620,13 @@ describe( '__unstableGetClientIdsTree', () => {
|
|
|
4130
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", () => {
|
|
4131
4621
|
const state = {
|
|
4132
4622
|
blocks: {
|
|
4133
|
-
order:
|
|
4134
|
-
|
|
4135
|
-
|
|
4136
|
-
|
|
4137
|
-
|
|
4623
|
+
order: new Map(
|
|
4624
|
+
Object.entries( {
|
|
4625
|
+
'': [ 'foo' ],
|
|
4626
|
+
foo: [ 'bar', 'baz' ],
|
|
4627
|
+
bar: [ 'qux' ],
|
|
4628
|
+
} )
|
|
4629
|
+
),
|
|
4138
4630
|
},
|
|
4139
4631
|
};
|
|
4140
4632
|
|
|
@@ -4150,11 +4642,13 @@ describe( '__unstableGetClientIdsTree', () => {
|
|
|
4150
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", () => {
|
|
4151
4643
|
const state = {
|
|
4152
4644
|
blocks: {
|
|
4153
|
-
order:
|
|
4154
|
-
|
|
4155
|
-
|
|
4156
|
-
|
|
4157
|
-
|
|
4645
|
+
order: new Map(
|
|
4646
|
+
Object.entries( {
|
|
4647
|
+
'': [ 'foo' ],
|
|
4648
|
+
foo: [ 'bar', 'baz' ],
|
|
4649
|
+
bar: [ 'qux' ],
|
|
4650
|
+
} )
|
|
4651
|
+
),
|
|
4158
4652
|
},
|
|
4159
4653
|
};
|
|
4160
4654
|
|
|
@@ -4172,3 +4666,23 @@ describe( '__unstableGetClientIdsTree', () => {
|
|
|
4172
4666
|
] );
|
|
4173
4667
|
} );
|
|
4174
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
|
+
} );
|