@wordpress/block-editor 10.4.0 → 11.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +17 -0
- package/README.md +0 -1
- package/build/autocompleters/block.js +2 -6
- package/build/autocompleters/block.js.map +1 -1
- package/build/autocompleters/link.js +2 -0
- package/build/autocompleters/link.js.map +1 -1
- package/build/components/block-card/index.js +51 -3
- package/build/components/block-card/index.js.map +1 -1
- package/build/components/block-draggable/index.native.js +46 -39
- package/build/components/block-draggable/index.native.js.map +1 -1
- package/build/components/block-edit/edit.js +4 -3
- package/build/components/block-edit/edit.js.map +1 -1
- package/build/components/block-edit/edit.native.js +4 -7
- package/build/components/block-edit/edit.native.js.map +1 -1
- package/build/components/block-inspector/index.js +35 -33
- package/build/components/block-inspector/index.js.map +1 -1
- package/build/components/block-list/block-list-context.native.js +5 -8
- package/build/components/block-list/block-list-context.native.js.map +1 -1
- package/build/components/block-list/block.js +55 -24
- package/build/components/block-list/block.js.map +1 -1
- package/build/components/block-list/block.native.js +61 -28
- package/build/components/block-list/block.native.js.map +1 -1
- package/build/components/block-lock/menu-item.js +1 -1
- package/build/components/block-lock/menu-item.js.map +1 -1
- package/build/components/block-lock/modal.js +16 -9
- package/build/components/block-lock/modal.js.map +1 -1
- package/build/components/block-mobile-toolbar/block-actions-menu.native.js +12 -4
- package/build/components/block-mobile-toolbar/block-actions-menu.native.js.map +1 -1
- package/build/components/block-pattern-setup/index.js +3 -2
- package/build/components/block-pattern-setup/index.js.map +1 -1
- package/build/components/block-patterns-list/index.js +33 -11
- package/build/components/block-patterns-list/index.js.map +1 -1
- package/build/components/block-preview/auto.js +9 -3
- package/build/components/block-preview/auto.js.map +1 -1
- package/build/components/block-preview/index.js +5 -9
- package/build/components/block-preview/index.js.map +1 -1
- package/build/components/block-settings-menu/block-settings-dropdown.js +5 -2
- package/build/components/block-settings-menu/block-settings-dropdown.js.map +1 -1
- package/build/components/block-styles/utils.js +3 -3
- package/build/components/block-styles/utils.js.map +1 -1
- package/build/components/block-switcher/index.js +19 -4
- package/build/components/block-switcher/index.js.map +1 -1
- package/build/components/block-toolbar/index.js +5 -1
- package/build/components/block-toolbar/index.js.map +1 -1
- package/build/components/block-tools/insertion-point.js +8 -49
- package/build/components/block-tools/insertion-point.js.map +1 -1
- package/build/components/block-tools/selected-block-popover.js +27 -4
- package/build/components/block-tools/selected-block-popover.js.map +1 -1
- package/build/components/block-variation-picker/index.js +1 -2
- package/build/components/block-variation-picker/index.js.map +1 -1
- package/build/components/colors/with-colors.js +4 -3
- package/build/components/colors/with-colors.js.map +1 -1
- package/build/components/font-sizes/fluid-utils.js +24 -40
- package/build/components/font-sizes/fluid-utils.js.map +1 -1
- package/build/components/font-sizes/with-font-sizes.js +7 -5
- package/build/components/font-sizes/with-font-sizes.js.map +1 -1
- package/build/components/height-control/index.js +115 -0
- package/build/components/height-control/index.js.map +1 -0
- package/build/components/iframe/index.js +11 -8
- package/build/components/iframe/index.js.map +1 -1
- package/build/components/image-editor/use-save-image.js +2 -0
- package/build/components/image-editor/use-save-image.js.map +1 -1
- package/build/components/image-editor/zoom-dropdown.js +1 -0
- package/build/components/image-editor/zoom-dropdown.js.map +1 -1
- package/build/components/index.js +18 -0
- package/build/components/index.js.map +1 -1
- package/build/components/inner-blocks/index.js +25 -9
- package/build/components/inner-blocks/index.js.map +1 -1
- package/build/components/inner-blocks/use-inner-block-template-sync.js +25 -10
- package/build/components/inner-blocks/use-inner-block-template-sync.js.map +1 -1
- package/build/components/inserter/block-patterns-explorer/sidebar.js +1 -0
- package/build/components/inserter/block-patterns-explorer/sidebar.js.map +1 -1
- package/build/components/inserter/block-patterns-tab.js +25 -46
- package/build/components/inserter/block-patterns-tab.js.map +1 -1
- package/build/components/inserter/block-types-tab.js +3 -1
- package/build/components/inserter/block-types-tab.js.map +1 -1
- package/build/components/inserter/hooks/use-debounced-input.js +27 -0
- package/build/components/inserter/hooks/use-debounced-input.js.map +1 -0
- package/build/components/inserter/index.js +8 -3
- package/build/components/inserter/index.js.map +1 -1
- package/build/components/inserter/index.native.js +3 -4
- package/build/components/inserter/index.native.js.map +1 -1
- package/build/components/inserter/media-tab/hooks.js +103 -0
- package/build/components/inserter/media-tab/hooks.js.map +1 -0
- package/build/components/inserter/media-tab/index.js +32 -0
- package/build/components/inserter/media-tab/index.js.map +1 -0
- package/build/components/inserter/media-tab/media-list.js +100 -0
- package/build/components/inserter/media-tab/media-list.js.map +1 -0
- package/build/components/inserter/media-tab/media-panel.js +96 -0
- package/build/components/inserter/media-tab/media-panel.js.map +1 -0
- package/build/components/inserter/media-tab/media-tab.js +120 -0
- package/build/components/inserter/media-tab/media-tab.js.map +1 -0
- package/build/components/inserter/media-tab/utils.js +54 -0
- package/build/components/inserter/media-tab/utils.js.map +1 -0
- package/build/components/inserter/menu.js +35 -12
- package/build/components/inserter/menu.js.map +1 -1
- package/build/components/inserter/mobile-tab-navigation.js +70 -0
- package/build/components/inserter/mobile-tab-navigation.js.map +1 -0
- package/build/components/inserter/quick-inserter.js +1 -0
- package/build/components/inserter/quick-inserter.js.map +1 -1
- package/build/components/inserter/reusable-blocks-tab.js +4 -1
- package/build/components/inserter/reusable-blocks-tab.js.map +1 -1
- package/build/components/inserter/search-results.js +3 -1
- package/build/components/inserter/search-results.js.map +1 -1
- package/build/components/inserter/tabs.js +16 -2
- package/build/components/inserter/tabs.js.map +1 -1
- package/build/components/inserter-list-item/index.js +4 -1
- package/build/components/inserter-list-item/index.js.map +1 -1
- package/build/components/inspector-controls/groups.js +2 -0
- package/build/components/inspector-controls/groups.js.map +1 -1
- package/build/components/inspector-controls-tabs/advanced-controls-panel.js +46 -0
- package/build/components/inspector-controls-tabs/advanced-controls-panel.js.map +1 -0
- package/build/components/inspector-controls-tabs/index.js +71 -0
- package/build/components/inspector-controls-tabs/index.js.map +1 -0
- package/build/components/inspector-controls-tabs/settings-tab.js +28 -0
- package/build/components/inspector-controls-tabs/settings-tab.js.map +1 -0
- package/build/components/inspector-controls-tabs/styles-tab.js +61 -0
- package/build/components/inspector-controls-tabs/styles-tab.js.map +1 -0
- package/build/components/inspector-controls-tabs/use-inspector-controls-tabs.js +97 -0
- package/build/components/inspector-controls-tabs/use-inspector-controls-tabs.js.map +1 -0
- package/build/components/inspector-controls-tabs/use-is-list-view-tab-disabled.js +18 -0
- package/build/components/inspector-controls-tabs/use-is-list-view-tab-disabled.js.map +1 -0
- package/build/components/inspector-controls-tabs/utils.js +37 -0
- package/build/components/inspector-controls-tabs/utils.js.map +1 -0
- package/build/components/link-control/index.js +19 -34
- package/build/components/link-control/index.js.map +1 -1
- package/build/components/link-control/search-input.js +1 -2
- package/build/components/link-control/search-input.js.map +1 -1
- package/build/components/link-control/use-internal-input-value.js +26 -0
- package/build/components/link-control/use-internal-input-value.js.map +1 -0
- package/build/components/list-view/block.js +10 -5
- package/build/components/list-view/block.js.map +1 -1
- package/build/components/list-view/branch.js +22 -15
- package/build/components/list-view/branch.js.map +1 -1
- package/build/components/media-upload/index.native.js +2 -3
- package/build/components/media-upload/index.native.js.map +1 -1
- package/build/components/off-canvas-editor/appender.js +104 -0
- package/build/components/off-canvas-editor/appender.js.map +1 -0
- package/build/components/off-canvas-editor/block-contents.js +100 -0
- package/build/components/off-canvas-editor/block-contents.js.map +1 -0
- package/build/components/off-canvas-editor/block-edit-button.js +50 -0
- package/build/components/off-canvas-editor/block-edit-button.js.map +1 -0
- package/build/components/off-canvas-editor/block-select-button.js +119 -0
- package/build/components/off-canvas-editor/block-select-button.js.map +1 -0
- package/build/components/off-canvas-editor/block.js +324 -0
- package/build/components/off-canvas-editor/block.js.map +1 -0
- package/build/components/off-canvas-editor/branch.js +179 -0
- package/build/components/off-canvas-editor/branch.js.map +1 -0
- package/build/components/off-canvas-editor/context.js +19 -0
- package/build/components/off-canvas-editor/context.js.map +1 -0
- package/build/components/off-canvas-editor/drop-indicator.js +118 -0
- package/build/components/off-canvas-editor/drop-indicator.js.map +1 -0
- package/build/components/off-canvas-editor/expander.js +41 -0
- package/build/components/off-canvas-editor/expander.js.map +1 -0
- package/build/components/off-canvas-editor/index.js +213 -0
- package/build/components/off-canvas-editor/index.js.map +1 -0
- package/build/components/off-canvas-editor/leaf.js +60 -0
- package/build/components/off-canvas-editor/leaf.js.map +1 -0
- package/build/components/off-canvas-editor/link-ui.js +185 -0
- package/build/components/off-canvas-editor/link-ui.js.map +1 -0
- package/build/components/off-canvas-editor/update-attributes.js +108 -0
- package/build/components/off-canvas-editor/update-attributes.js.map +1 -0
- package/build/components/off-canvas-editor/use-block-selection.js +139 -0
- package/build/components/off-canvas-editor/use-block-selection.js.map +1 -0
- package/build/components/off-canvas-editor/use-list-view-client-ids.js +33 -0
- package/build/components/off-canvas-editor/use-list-view-client-ids.js.map +1 -0
- package/build/components/off-canvas-editor/use-list-view-drop-zone.js +235 -0
- package/build/components/off-canvas-editor/use-list-view-drop-zone.js.map +1 -0
- package/build/components/off-canvas-editor/use-list-view-expand-selected-item.js +60 -0
- package/build/components/off-canvas-editor/use-list-view-expand-selected-item.js.map +1 -0
- package/build/components/off-canvas-editor/utils.js +60 -0
- package/build/components/off-canvas-editor/utils.js.map +1 -0
- package/build/components/rich-text/format-toolbar/index.js +8 -4
- package/build/components/rich-text/format-toolbar/index.js.map +1 -1
- package/build/components/rich-text/index.js +3 -3
- package/build/components/rich-text/index.js.map +1 -1
- package/build/components/rich-text/index.native.js +0 -2
- package/build/components/rich-text/index.native.js.map +1 -1
- package/build/components/rich-text/use-insert-replacement-text.js +43 -0
- package/build/components/rich-text/use-insert-replacement-text.js.map +1 -0
- package/build/components/rich-text/use-undo-automatic-change.js +9 -1
- package/build/components/rich-text/use-undo-automatic-change.js.map +1 -1
- package/build/components/rich-text/utils.js +1 -19
- package/build/components/rich-text/utils.js.map +1 -1
- package/build/components/spacing-sizes-control/spacing-input-control.js +12 -3
- package/build/components/spacing-sizes-control/spacing-input-control.js.map +1 -1
- package/build/components/ungroup-button/index.native.js +4 -2
- package/build/components/ungroup-button/index.native.js.map +1 -1
- package/build/components/url-input/index.js +46 -43
- package/build/components/url-input/index.js.map +1 -1
- package/build/components/url-popover/index.js +31 -2
- package/build/components/url-popover/index.js.map +1 -1
- package/build/components/use-block-display-information/index.js +8 -4
- package/build/components/use-block-display-information/index.js.map +1 -1
- package/build/components/use-setting/index.js +10 -2
- package/build/components/use-setting/index.js.map +1 -1
- package/build/hooks/child-layout.js +209 -0
- package/build/hooks/child-layout.js.map +1 -0
- package/build/hooks/color-panel.js +17 -1
- package/build/hooks/color-panel.js.map +1 -1
- package/build/hooks/color.js +1 -1
- package/build/hooks/color.js.map +1 -1
- package/build/hooks/content-lock-ui.js +14 -7
- package/build/hooks/content-lock-ui.js.map +1 -1
- package/build/hooks/dimensions.js +65 -16
- package/build/hooks/dimensions.js.map +1 -1
- package/build/hooks/layout.js +59 -3
- package/build/hooks/layout.js.map +1 -1
- package/build/hooks/margin.js +4 -2
- package/build/hooks/margin.js.map +1 -1
- package/build/hooks/min-height.js +139 -0
- package/build/hooks/min-height.js.map +1 -0
- package/build/hooks/padding.js +4 -2
- package/build/hooks/padding.js.map +1 -1
- package/build/hooks/style.js +3 -2
- package/build/hooks/style.js.map +1 -1
- package/build/layouts/flex.js +22 -21
- package/build/layouts/flex.js.map +1 -1
- package/build/store/actions.js +26 -0
- package/build/store/actions.js.map +1 -1
- package/build/store/reducer.js +420 -265
- package/build/store/reducer.js.map +1 -1
- package/build/store/selectors.js +73 -49
- package/build/store/selectors.js.map +1 -1
- package/build/utils/sorting.js +63 -0
- package/build/utils/sorting.js.map +1 -0
- package/build-module/autocompleters/block.js +2 -6
- package/build-module/autocompleters/block.js.map +1 -1
- package/build-module/autocompleters/link.js +2 -0
- package/build-module/autocompleters/link.js.map +1 -1
- package/build-module/components/block-card/index.js +45 -3
- package/build-module/components/block-card/index.js.map +1 -1
- package/build-module/components/block-draggable/index.native.js +40 -31
- package/build-module/components/block-draggable/index.native.js.map +1 -1
- package/build-module/components/block-edit/edit.js +4 -2
- package/build-module/components/block-edit/edit.js.map +1 -1
- package/build-module/components/block-edit/edit.native.js +4 -6
- package/build-module/components/block-edit/edit.native.js.map +1 -1
- package/build-module/components/block-inspector/index.js +32 -30
- package/build-module/components/block-inspector/index.js.map +1 -1
- package/build-module/components/block-list/block-list-context.native.js +5 -8
- package/build-module/components/block-list/block-list-context.native.js.map +1 -1
- package/build-module/components/block-list/block.js +55 -25
- package/build-module/components/block-list/block.js.map +1 -1
- package/build-module/components/block-list/block.native.js +61 -28
- package/build-module/components/block-list/block.native.js.map +1 -1
- package/build-module/components/block-lock/menu-item.js +2 -2
- package/build-module/components/block-lock/menu-item.js.map +1 -1
- package/build-module/components/block-lock/modal.js +17 -10
- package/build-module/components/block-lock/modal.js.map +1 -1
- package/build-module/components/block-mobile-toolbar/block-actions-menu.native.js +13 -6
- package/build-module/components/block-mobile-toolbar/block-actions-menu.native.js.map +1 -1
- package/build-module/components/block-pattern-setup/index.js +3 -2
- package/build-module/components/block-pattern-setup/index.js.map +1 -1
- package/build-module/components/block-patterns-list/index.js +35 -13
- package/build-module/components/block-patterns-list/index.js.map +1 -1
- package/build-module/components/block-preview/auto.js +9 -3
- package/build-module/components/block-preview/auto.js.map +1 -1
- package/build-module/components/block-preview/index.js +5 -8
- package/build-module/components/block-preview/index.js.map +1 -1
- package/build-module/components/block-settings-menu/block-settings-dropdown.js +5 -2
- package/build-module/components/block-settings-menu/block-settings-dropdown.js.map +1 -1
- package/build-module/components/block-styles/utils.js +3 -3
- package/build-module/components/block-styles/utils.js.map +1 -1
- package/build-module/components/block-switcher/index.js +19 -4
- package/build-module/components/block-switcher/index.js.map +1 -1
- package/build-module/components/block-toolbar/index.js +6 -2
- package/build-module/components/block-toolbar/index.js.map +1 -1
- package/build-module/components/block-tools/insertion-point.js +8 -49
- package/build-module/components/block-tools/insertion-point.js.map +1 -1
- package/build-module/components/block-tools/selected-block-popover.js +27 -5
- package/build-module/components/block-tools/selected-block-popover.js.map +1 -1
- package/build-module/components/block-variation-picker/index.js +1 -2
- package/build-module/components/block-variation-picker/index.js.map +1 -1
- package/build-module/components/colors/with-colors.js +5 -4
- package/build-module/components/colors/with-colors.js.map +1 -1
- package/build-module/components/font-sizes/fluid-utils.js +24 -40
- package/build-module/components/font-sizes/fluid-utils.js.map +1 -1
- package/build-module/components/font-sizes/with-font-sizes.js +8 -6
- package/build-module/components/font-sizes/with-font-sizes.js.map +1 -1
- package/build-module/components/height-control/index.js +103 -0
- package/build-module/components/height-control/index.js.map +1 -0
- package/build-module/components/iframe/index.js +11 -8
- package/build-module/components/iframe/index.js.map +1 -1
- package/build-module/components/image-editor/use-save-image.js +2 -0
- package/build-module/components/image-editor/use-save-image.js.map +1 -1
- package/build-module/components/image-editor/zoom-dropdown.js +1 -0
- package/build-module/components/image-editor/zoom-dropdown.js.map +1 -1
- package/build-module/components/index.js +2 -0
- package/build-module/components/index.js.map +1 -1
- package/build-module/components/inner-blocks/index.js +27 -11
- package/build-module/components/inner-blocks/index.js.map +1 -1
- package/build-module/components/inner-blocks/use-inner-block-template-sync.js +23 -10
- package/build-module/components/inner-blocks/use-inner-block-template-sync.js.map +1 -1
- package/build-module/components/inserter/block-patterns-explorer/sidebar.js +1 -0
- package/build-module/components/inserter/block-patterns-explorer/sidebar.js.map +1 -1
- package/build-module/components/inserter/block-patterns-tab.js +27 -49
- package/build-module/components/inserter/block-patterns-tab.js.map +1 -1
- package/build-module/components/inserter/block-types-tab.js +3 -2
- package/build-module/components/inserter/block-types-tab.js.map +1 -1
- package/build-module/components/inserter/hooks/use-debounced-input.js +18 -0
- package/build-module/components/inserter/hooks/use-debounced-input.js.map +1 -0
- package/build-module/components/inserter/index.js +8 -3
- package/build-module/components/inserter/index.js.map +1 -1
- package/build-module/components/inserter/index.native.js +3 -5
- package/build-module/components/inserter/index.native.js.map +1 -1
- package/build-module/components/inserter/media-tab/hooks.js +89 -0
- package/build-module/components/inserter/media-tab/hooks.js.map +1 -0
- package/build-module/components/inserter/media-tab/index.js +4 -0
- package/build-module/components/inserter/media-tab/index.js.map +1 -0
- package/build-module/components/inserter/media-tab/media-list.js +86 -0
- package/build-module/components/inserter/media-tab/media-list.js.map +1 -0
- package/build-module/components/inserter/media-tab/media-panel.js +77 -0
- package/build-module/components/inserter/media-tab/media-panel.js.map +1 -0
- package/build-module/components/inserter/media-tab/media-tab.js +100 -0
- package/build-module/components/inserter/media-tab/media-tab.js.map +1 -0
- package/build-module/components/inserter/media-tab/utils.js +45 -0
- package/build-module/components/inserter/media-tab/utils.js.map +1 -0
- package/build-module/components/inserter/menu.js +33 -12
- package/build-module/components/inserter/menu.js.map +1 -1
- package/build-module/components/inserter/mobile-tab-navigation.js +61 -0
- package/build-module/components/inserter/mobile-tab-navigation.js.map +1 -0
- package/build-module/components/inserter/quick-inserter.js +1 -0
- package/build-module/components/inserter/quick-inserter.js.map +1 -1
- package/build-module/components/inserter/reusable-blocks-tab.js +3 -1
- package/build-module/components/inserter/reusable-blocks-tab.js.map +1 -1
- package/build-module/components/inserter/search-results.js +3 -2
- package/build-module/components/inserter/search-results.js.map +1 -1
- package/build-module/components/inserter/tabs.js +15 -2
- package/build-module/components/inserter/tabs.js.map +1 -1
- package/build-module/components/inserter-list-item/index.js +5 -2
- package/build-module/components/inserter-list-item/index.js.map +1 -1
- package/build-module/components/inspector-controls/groups.js +2 -0
- package/build-module/components/inspector-controls/groups.js.map +1 -1
- package/build-module/components/inspector-controls-tabs/advanced-controls-panel.js +32 -0
- package/build-module/components/inspector-controls-tabs/advanced-controls-panel.js.map +1 -0
- package/build-module/components/inspector-controls-tabs/index.js +56 -0
- package/build-module/components/inspector-controls-tabs/index.js.map +1 -0
- package/build-module/components/inspector-controls-tabs/settings-tab.js +17 -0
- package/build-module/components/inspector-controls-tabs/settings-tab.js.map +1 -0
- package/build-module/components/inspector-controls-tabs/styles-tab.js +46 -0
- package/build-module/components/inspector-controls-tabs/styles-tab.js.map +1 -0
- package/build-module/components/inspector-controls-tabs/use-inspector-controls-tabs.js +81 -0
- package/build-module/components/inspector-controls-tabs/use-inspector-controls-tabs.js.map +1 -0
- package/build-module/components/inspector-controls-tabs/use-is-list-view-tab-disabled.js +8 -0
- package/build-module/components/inspector-controls-tabs/use-is-list-view-tab-disabled.js.map +1 -0
- package/build-module/components/inspector-controls-tabs/utils.js +26 -0
- package/build-module/components/inspector-controls-tabs/utils.js.map +1 -0
- package/build-module/components/link-control/index.js +18 -34
- package/build-module/components/link-control/index.js.map +1 -1
- package/build-module/components/link-control/search-input.js +1 -2
- package/build-module/components/link-control/search-input.js.map +1 -1
- package/build-module/components/link-control/use-internal-input-value.js +18 -0
- package/build-module/components/link-control/use-internal-input-value.js.map +1 -0
- package/build-module/components/list-view/block.js +10 -5
- package/build-module/components/list-view/block.js.map +1 -1
- package/build-module/components/list-view/branch.js +21 -14
- package/build-module/components/list-view/branch.js.map +1 -1
- package/build-module/components/media-upload/index.native.js +2 -4
- package/build-module/components/media-upload/index.native.js.map +1 -1
- package/build-module/components/off-canvas-editor/appender.js +89 -0
- package/build-module/components/off-canvas-editor/appender.js.map +1 -0
- package/build-module/components/off-canvas-editor/block-contents.js +85 -0
- package/build-module/components/off-canvas-editor/block-contents.js.map +1 -0
- package/build-module/components/off-canvas-editor/block-edit-button.js +35 -0
- package/build-module/components/off-canvas-editor/block-edit-button.js.map +1 -0
- package/build-module/components/off-canvas-editor/block-select-button.js +101 -0
- package/build-module/components/off-canvas-editor/block-select-button.js.map +1 -0
- package/build-module/components/off-canvas-editor/block.js +298 -0
- package/build-module/components/off-canvas-editor/block.js.map +1 -0
- package/build-module/components/off-canvas-editor/branch.js +164 -0
- package/build-module/components/off-canvas-editor/branch.js.map +1 -0
- package/build-module/components/off-canvas-editor/context.js +7 -0
- package/build-module/components/off-canvas-editor/context.js.map +1 -0
- package/build-module/components/off-canvas-editor/drop-indicator.js +111 -0
- package/build-module/components/off-canvas-editor/drop-indicator.js.map +1 -0
- package/build-module/components/off-canvas-editor/expander.js +32 -0
- package/build-module/components/off-canvas-editor/expander.js.map +1 -0
- package/build-module/components/off-canvas-editor/index.js +189 -0
- package/build-module/components/off-canvas-editor/index.js.map +1 -0
- package/build-module/components/off-canvas-editor/leaf.js +45 -0
- package/build-module/components/off-canvas-editor/leaf.js.map +1 -0
- package/build-module/components/off-canvas-editor/link-ui.js +165 -0
- package/build-module/components/off-canvas-editor/link-ui.js.map +1 -0
- package/build-module/components/off-canvas-editor/update-attributes.js +97 -0
- package/build-module/components/off-canvas-editor/update-attributes.js.map +1 -0
- package/build-module/components/off-canvas-editor/use-block-selection.js +124 -0
- package/build-module/components/off-canvas-editor/use-block-selection.js.map +1 -0
- package/build-module/components/off-canvas-editor/use-list-view-client-ids.js +24 -0
- package/build-module/components/off-canvas-editor/use-list-view-client-ids.js.map +1 -0
- package/build-module/components/off-canvas-editor/use-list-view-drop-zone.js +220 -0
- package/build-module/components/off-canvas-editor/use-list-view-drop-zone.js.map +1 -0
- package/build-module/components/off-canvas-editor/use-list-view-expand-selected-item.js +50 -0
- package/build-module/components/off-canvas-editor/use-list-view-expand-selected-item.js.map +1 -0
- package/build-module/components/off-canvas-editor/utils.js +44 -0
- package/build-module/components/off-canvas-editor/utils.js.map +1 -0
- package/build-module/components/rich-text/format-toolbar/index.js +6 -2
- package/build-module/components/rich-text/format-toolbar/index.js.map +1 -1
- package/build-module/components/rich-text/index.js +2 -3
- package/build-module/components/rich-text/index.js.map +1 -1
- package/build-module/components/rich-text/index.native.js +0 -2
- package/build-module/components/rich-text/index.native.js.map +1 -1
- package/build-module/components/rich-text/use-insert-replacement-text.js +33 -0
- package/build-module/components/rich-text/use-insert-replacement-text.js.map +1 -0
- package/build-module/components/rich-text/use-undo-automatic-change.js +9 -1
- package/build-module/components/rich-text/use-undo-automatic-change.js.map +1 -1
- package/build-module/components/rich-text/utils.js +1 -16
- package/build-module/components/rich-text/utils.js.map +1 -1
- package/build-module/components/spacing-sizes-control/spacing-input-control.js +12 -3
- package/build-module/components/spacing-sizes-control/spacing-input-control.js.map +1 -1
- package/build-module/components/ungroup-button/index.native.js +3 -2
- package/build-module/components/ungroup-button/index.native.js.map +1 -1
- package/build-module/components/url-input/index.js +46 -43
- package/build-module/components/url-input/index.js.map +1 -1
- package/build-module/components/url-popover/index.js +30 -3
- package/build-module/components/url-popover/index.js.map +1 -1
- package/build-module/components/use-block-display-information/index.js +9 -5
- package/build-module/components/use-block-display-information/index.js.map +1 -1
- package/build-module/components/use-setting/index.js +9 -2
- package/build-module/components/use-setting/index.js.map +1 -1
- package/build-module/hooks/child-layout.js +189 -0
- package/build-module/hooks/child-layout.js.map +1 -0
- package/build-module/hooks/color-panel.js +17 -1
- package/build-module/hooks/color-panel.js.map +1 -1
- package/build-module/hooks/color.js +1 -1
- package/build-module/hooks/color.js.map +1 -1
- package/build-module/hooks/content-lock-ui.js +16 -9
- package/build-module/hooks/content-lock-ui.js.map +1 -1
- package/build-module/hooks/dimensions.js +60 -16
- package/build-module/hooks/dimensions.js.map +1 -1
- package/build-module/hooks/layout.js +57 -2
- package/build-module/hooks/layout.js.map +1 -1
- package/build-module/hooks/margin.js +4 -2
- package/build-module/hooks/margin.js.map +1 -1
- package/build-module/hooks/min-height.js +116 -0
- package/build-module/hooks/min-height.js.map +1 -0
- package/build-module/hooks/padding.js +4 -2
- package/build-module/hooks/padding.js.map +1 -1
- package/build-module/hooks/style.js +4 -3
- package/build-module/hooks/style.js.map +1 -1
- package/build-module/layouts/flex.js +23 -22
- package/build-module/layouts/flex.js.map +1 -1
- package/build-module/store/actions.js +22 -0
- package/build-module/store/actions.js.map +1 -1
- package/build-module/store/reducer.js +415 -265
- package/build-module/store/reducer.js.map +1 -1
- package/build-module/store/selectors.js +66 -48
- package/build-module/store/selectors.js.map +1 -1
- package/build-module/utils/sorting.js +56 -0
- package/build-module/utils/sorting.js.map +1 -0
- package/build-style/content-rtl.css +701 -0
- package/build-style/content.css +701 -0
- package/build-style/default-editor-styles-rtl.css +14 -0
- package/build-style/default-editor-styles.css +14 -0
- package/build-style/style-rtl.css +305 -668
- package/build-style/style.css +305 -668
- package/package.json +32 -30
- package/src/autocompleters/block.js +2 -6
- package/src/autocompleters/link.js +2 -0
- package/src/components/alignment-control/README.md +1 -1
- package/src/components/alignment-control/test/index.js +4 -1
- package/src/components/block-alignment-control/test/index.js +4 -1
- package/src/components/block-alignment-control/test/index.native.js +4 -4
- package/src/components/block-card/index.js +46 -2
- package/src/components/block-card/style.scss +4 -0
- package/src/components/block-content-overlay/{style.scss → content.scss} +7 -1
- package/src/components/block-draggable/content.scss +20 -0
- package/src/components/block-draggable/index.native.js +54 -40
- package/src/components/block-draggable/style.scss +0 -21
- package/src/components/block-draggable/test/helpers.native.js +7 -9
- package/src/components/block-draggable/test/index.native.js +35 -45
- package/src/components/block-edit/edit.js +5 -2
- package/src/components/block-edit/edit.native.js +5 -6
- package/src/components/block-inspector/index.js +96 -81
- package/src/components/block-inspector/style.scss +9 -1
- package/src/components/block-list/block-list-context.native.js +5 -8
- package/src/components/block-list/block.js +74 -23
- package/src/components/block-list/block.native.js +78 -23
- package/src/components/block-list/{style.scss → content.scss} +11 -20
- package/src/components/block-list-appender/{style.scss → content.scss} +0 -0
- package/src/components/block-lock/menu-item.js +5 -2
- package/src/components/block-lock/modal.js +19 -36
- package/src/components/block-lock/style.scss +8 -17
- package/src/components/block-mobile-toolbar/block-actions-menu.native.js +24 -6
- package/src/components/block-mover/style.scss +0 -1
- package/src/components/block-mover/test/__snapshots__/index.native.js.snap +0 -2
- package/src/components/block-pattern-setup/index.js +2 -1
- package/src/components/block-patterns-list/index.js +47 -24
- package/src/components/block-popover/style.scss +1 -1
- package/src/components/block-preview/README.md +15 -10
- package/src/components/block-preview/auto.js +7 -1
- package/src/components/block-preview/content.scss +4 -0
- package/src/components/block-preview/index.js +7 -12
- package/src/components/block-preview/style.scss +0 -7
- package/src/components/block-preview/test/index.js +18 -35
- package/src/components/block-selection-clearer/test/index.js +12 -12
- package/src/components/block-settings-menu/block-settings-dropdown.js +32 -20
- package/src/components/block-styles/utils.js +3 -3
- package/src/components/block-switcher/index.js +19 -4
- package/src/components/block-switcher/test/index.js +4 -0
- package/src/components/block-toolbar/index.js +12 -5
- package/src/components/block-toolbar/style.scss +10 -0
- package/src/components/block-tools/insertion-point.js +3 -47
- package/src/components/block-tools/selected-block-popover.js +80 -34
- package/src/components/block-tools/style.scss +27 -5
- package/src/components/block-variation-picker/index.js +1 -4
- package/src/components/block-vertical-alignment-control/test/index.js +4 -1
- package/src/components/colors/with-colors.js +13 -23
- package/src/components/default-block-appender/{style.scss → content.scss} +1 -0
- package/src/components/font-sizes/fluid-utils.js +37 -64
- package/src/components/font-sizes/test/fluid-utils.js +5 -5
- package/src/components/font-sizes/with-font-sizes.js +14 -11
- package/src/components/height-control/index.js +123 -0
- package/src/components/height-control/stories/index.js +21 -0
- package/src/components/height-control/style.scss +5 -0
- package/src/components/iframe/index.js +25 -18
- package/src/components/image-editor/use-save-image.js +2 -0
- package/src/components/image-editor/zoom-dropdown.js +1 -0
- package/src/components/index.js +2 -0
- package/src/components/inner-blocks/{style.scss → content.scss} +0 -0
- package/src/components/inner-blocks/index.js +30 -10
- package/src/components/inner-blocks/use-inner-block-template-sync.js +28 -10
- package/src/components/inserter/block-patterns-explorer/sidebar.js +1 -0
- package/src/components/inserter/block-patterns-tab.js +28 -71
- package/src/components/inserter/block-types-tab.js +3 -2
- package/src/components/inserter/hooks/use-debounced-input.js +17 -0
- package/src/components/inserter/index.js +10 -2
- package/src/components/inserter/index.native.js +1 -1
- package/src/components/inserter/media-tab/hooks.js +88 -0
- package/src/components/inserter/media-tab/index.js +3 -0
- package/src/components/inserter/media-tab/media-list.js +93 -0
- package/src/components/inserter/media-tab/media-panel.js +83 -0
- package/src/components/inserter/media-tab/media-tab.js +135 -0
- package/src/components/inserter/media-tab/utils.js +37 -0
- package/src/components/inserter/menu.js +55 -13
- package/src/components/inserter/mobile-tab-navigation.js +85 -0
- package/src/components/inserter/quick-inserter.js +1 -0
- package/src/components/inserter/reusable-blocks-tab.js +4 -2
- package/src/components/inserter/search-results.js +3 -2
- package/src/components/inserter/stories/index.js +1 -1
- package/src/components/inserter/stories/{fixtures.js → utils/fixtures.js} +0 -0
- package/src/components/inserter/style.scss +184 -18
- package/src/components/inserter/tabs.js +12 -1
- package/src/components/inserter/test/reusable-blocks-tab.js +14 -57
- package/src/components/inserter-list-item/index.js +11 -1
- package/src/components/inserter-list-item/style.scss +26 -0
- package/src/components/inspector-controls/groups.js +2 -0
- package/src/components/inspector-controls-tabs/advanced-controls-panel.js +37 -0
- package/src/components/inspector-controls-tabs/index.js +62 -0
- package/src/components/inspector-controls-tabs/settings-tab.js +18 -0
- package/src/components/inspector-controls-tabs/styles-tab.js +51 -0
- package/src/components/inspector-controls-tabs/use-inspector-controls-tabs.js +89 -0
- package/src/components/inspector-controls-tabs/use-is-list-view-tab-disabled.js +9 -0
- package/src/components/inspector-controls-tabs/utils.js +28 -0
- package/src/components/line-height-control/test/index.js +5 -5
- package/src/components/link-control/README.md +1 -1
- package/src/components/link-control/index.js +24 -39
- package/src/components/link-control/search-input.js +1 -2
- package/src/components/link-control/test/index.js +400 -582
- package/src/components/link-control/use-internal-input-value.js +22 -0
- package/src/components/list-view/block.js +7 -3
- package/src/components/list-view/branch.js +21 -14
- package/src/components/list-view/style.scss +20 -9
- package/src/components/media-placeholder/{style.scss → content.scss} +0 -0
- package/src/components/media-replace-flow/test/index.js +37 -9
- package/src/components/media-upload/test/index.native.js +2 -0
- package/src/components/off-canvas-editor/README.md +5 -0
- package/src/components/off-canvas-editor/appender.js +93 -0
- package/src/components/off-canvas-editor/block-contents.js +89 -0
- package/src/components/off-canvas-editor/block-edit-button.js +27 -0
- package/src/components/off-canvas-editor/block-select-button.js +113 -0
- package/src/components/off-canvas-editor/block.js +401 -0
- package/src/components/off-canvas-editor/branch.js +208 -0
- package/src/components/off-canvas-editor/context.js +8 -0
- package/src/components/off-canvas-editor/drop-indicator.js +126 -0
- package/src/components/off-canvas-editor/expander.js +26 -0
- package/src/components/off-canvas-editor/index.js +242 -0
- package/src/components/off-canvas-editor/leaf.js +52 -0
- package/src/components/off-canvas-editor/link-ui.js +166 -0
- package/src/components/off-canvas-editor/style.scss +26 -0
- package/src/components/off-canvas-editor/test/utils.js +50 -0
- package/src/components/off-canvas-editor/update-attributes.js +99 -0
- package/src/components/off-canvas-editor/use-block-selection.js +169 -0
- package/src/components/off-canvas-editor/use-list-view-client-ids.js +29 -0
- package/src/components/off-canvas-editor/use-list-view-drop-zone.js +260 -0
- package/src/components/off-canvas-editor/use-list-view-expand-selected-item.js +58 -0
- package/src/components/off-canvas-editor/utils.js +58 -0
- package/src/components/plain-text/{style.scss → content.scss} +0 -0
- package/src/components/recursion-provider/test/index.js +27 -29
- package/src/components/responsive-block-control/test/index.js +69 -92
- package/src/components/rich-text/content.scss +42 -0
- package/src/components/rich-text/format-toolbar/index.js +6 -4
- package/src/components/rich-text/index.js +2 -2
- package/src/components/rich-text/index.native.js +0 -2
- package/src/components/rich-text/style.scss +0 -43
- package/src/components/rich-text/use-insert-replacement-text.js +31 -0
- package/src/components/rich-text/use-undo-automatic-change.js +7 -1
- package/src/components/rich-text/utils.js +2 -21
- package/src/components/spacing-sizes-control/spacing-input-control.js +9 -0
- package/src/components/ungroup-button/index.native.js +6 -2
- package/src/components/url-input/index.js +57 -73
- package/src/components/url-popover/README.md +12 -3
- package/src/components/url-popover/index.js +33 -3
- package/src/components/url-popover/test/__snapshots__/index.js.snap +8 -6
- package/src/components/url-popover/test/index.js +21 -9
- package/src/components/use-block-display-information/index.js +14 -5
- package/src/components/use-setting/index.js +20 -2
- package/src/components/use-setting/test/index.js +99 -0
- package/src/content.scss +10 -0
- package/src/hooks/child-layout.js +190 -0
- package/src/hooks/color-panel.js +13 -1
- package/src/hooks/color.js +2 -0
- package/src/hooks/content-lock-ui.js +47 -35
- package/src/hooks/dimensions.js +119 -21
- package/src/hooks/layout.js +62 -3
- package/src/hooks/margin.js +4 -3
- package/src/hooks/min-height.js +104 -0
- package/src/hooks/padding.js +4 -3
- package/src/hooks/style.js +10 -2
- package/src/hooks/test/style.js +4 -0
- package/src/hooks/test/use-typography-props.js +1 -1
- package/src/layouts/flex.js +43 -38
- package/src/store/actions.js +22 -0
- package/src/store/reducer.js +480 -434
- package/src/store/selectors.js +70 -64
- package/src/store/test/actions.js +18 -0
- package/src/store/test/performance.js +71 -0
- package/src/store/test/reducer.js +662 -490
- package/src/store/test/selectors.js +1839 -1306
- package/src/style.scss +4 -7
- package/src/utils/sorting.js +54 -0
- package/src/utils/test/sorting.js +49 -0
- package/tsconfig.tsbuildinfo +1 -1
- package/build/components/block-preview/live.js +0 -30
- package/build/components/block-preview/live.js.map +0 -1
- package/build-module/components/block-preview/live.js +0 -20
- package/build-module/components/block-preview/live.js.map +0 -1
- package/src/components/block-preview/live.js +0 -19
|
@@ -19,6 +19,7 @@ import {
|
|
|
19
19
|
hasSameKeys,
|
|
20
20
|
isUpdatingSameBlockAttribute,
|
|
21
21
|
blocks,
|
|
22
|
+
isBlockInterfaceHidden,
|
|
22
23
|
isTyping,
|
|
23
24
|
draggedBlocks,
|
|
24
25
|
selection,
|
|
@@ -209,38 +210,48 @@ describe( 'state', () => {
|
|
|
209
210
|
} );
|
|
210
211
|
it( 'can replace a child block', () => {
|
|
211
212
|
const existingState = deepFreeze( {
|
|
212
|
-
byClientId:
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
213
|
+
byClientId: new Map(
|
|
214
|
+
Object.entries( {
|
|
215
|
+
chicken: {
|
|
216
|
+
clientId: 'chicken',
|
|
217
|
+
name: 'core/test-parent-block',
|
|
218
|
+
isValid: true,
|
|
219
|
+
},
|
|
220
|
+
'chicken-child': {
|
|
221
|
+
clientId: 'chicken-child',
|
|
222
|
+
name: 'core/test-child-block',
|
|
223
|
+
isValid: true,
|
|
224
|
+
},
|
|
225
|
+
} )
|
|
226
|
+
),
|
|
227
|
+
attributes: new Map(
|
|
228
|
+
Object.entries( {
|
|
229
|
+
chicken: {},
|
|
230
|
+
'chicken-child': {
|
|
231
|
+
attr: true,
|
|
232
|
+
},
|
|
233
|
+
} )
|
|
234
|
+
),
|
|
235
|
+
order: new Map(
|
|
236
|
+
Object.entries( {
|
|
237
|
+
'': [ 'chicken' ],
|
|
238
|
+
chicken: [ 'chicken-child' ],
|
|
239
|
+
'chicken-child': [],
|
|
240
|
+
} )
|
|
241
|
+
),
|
|
242
|
+
parents: new Map(
|
|
243
|
+
Object.entries( {
|
|
244
|
+
chicken: '',
|
|
245
|
+
'chicken-child': 'chicken',
|
|
246
|
+
} )
|
|
247
|
+
),
|
|
248
|
+
tree: new Map(
|
|
249
|
+
Object.entries( {
|
|
250
|
+
'': {},
|
|
251
|
+
chicken: {},
|
|
252
|
+
'chicken-child': {},
|
|
253
|
+
} )
|
|
254
|
+
),
|
|
244
255
|
controlledInnerBlocks: {},
|
|
245
256
|
} );
|
|
246
257
|
|
|
@@ -263,66 +274,84 @@ describe( 'state', () => {
|
|
|
263
274
|
expect( restState ).toEqual( {
|
|
264
275
|
isPersistentChange: true,
|
|
265
276
|
isIgnoredChange: false,
|
|
266
|
-
byClientId:
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
277
|
+
byClientId: new Map(
|
|
278
|
+
Object.entries( {
|
|
279
|
+
chicken: {
|
|
280
|
+
clientId: 'chicken',
|
|
281
|
+
name: 'core/test-parent-block',
|
|
282
|
+
isValid: true,
|
|
283
|
+
},
|
|
284
|
+
[ newChildBlockId ]: {
|
|
285
|
+
clientId: newChildBlockId,
|
|
286
|
+
name: 'core/test-child-block',
|
|
287
|
+
isValid: true,
|
|
288
|
+
},
|
|
289
|
+
} )
|
|
290
|
+
),
|
|
291
|
+
attributes: new Map(
|
|
292
|
+
Object.entries( {
|
|
293
|
+
chicken: {},
|
|
294
|
+
[ newChildBlockId ]: {
|
|
295
|
+
attr: false,
|
|
296
|
+
attr2: 'perfect',
|
|
297
|
+
},
|
|
298
|
+
} )
|
|
299
|
+
),
|
|
300
|
+
order: new Map(
|
|
301
|
+
Object.entries( {
|
|
302
|
+
'': [ 'chicken' ],
|
|
303
|
+
chicken: [ newChildBlockId ],
|
|
304
|
+
[ newChildBlockId ]: [],
|
|
305
|
+
} )
|
|
306
|
+
),
|
|
307
|
+
parents: new Map(
|
|
308
|
+
Object.entries( {
|
|
309
|
+
[ newChildBlockId ]: 'chicken',
|
|
310
|
+
chicken: '',
|
|
311
|
+
} )
|
|
312
|
+
),
|
|
294
313
|
controlledInnerBlocks: {},
|
|
295
314
|
} );
|
|
296
|
-
expect( state.tree.chicken ).not.toBe(
|
|
297
|
-
existingState.tree.chicken
|
|
315
|
+
expect( state.tree.get( 'chicken' ) ).not.toBe(
|
|
316
|
+
existingState.tree.get( 'chicken' )
|
|
298
317
|
);
|
|
299
318
|
} );
|
|
300
319
|
|
|
301
320
|
it( 'can insert a child block', () => {
|
|
302
321
|
const existingState = deepFreeze( {
|
|
303
|
-
byClientId:
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
322
|
+
byClientId: new Map(
|
|
323
|
+
Object.entries( {
|
|
324
|
+
chicken: {
|
|
325
|
+
clientId: 'chicken',
|
|
326
|
+
name: 'core/test-parent-block',
|
|
327
|
+
isValid: true,
|
|
328
|
+
},
|
|
329
|
+
} )
|
|
330
|
+
),
|
|
331
|
+
attributes: new Map(
|
|
332
|
+
Object.entries( {
|
|
333
|
+
chicken: {},
|
|
334
|
+
} )
|
|
335
|
+
),
|
|
336
|
+
order: new Map(
|
|
337
|
+
Object.entries( {
|
|
338
|
+
'': [ 'chicken' ],
|
|
339
|
+
chicken: [],
|
|
340
|
+
} )
|
|
341
|
+
),
|
|
342
|
+
parents: new Map(
|
|
343
|
+
Object.entries( {
|
|
344
|
+
chicken: '',
|
|
345
|
+
} )
|
|
346
|
+
),
|
|
347
|
+
tree: new Map(
|
|
348
|
+
Object.entries( {
|
|
349
|
+
'': {
|
|
350
|
+
innerBlocks: [],
|
|
351
|
+
},
|
|
352
|
+
chicken: {},
|
|
353
|
+
} )
|
|
354
|
+
),
|
|
326
355
|
controlledInnerBlocks: {},
|
|
327
356
|
} );
|
|
328
357
|
|
|
@@ -345,46 +374,54 @@ describe( 'state', () => {
|
|
|
345
374
|
expect( restState ).toEqual( {
|
|
346
375
|
isPersistentChange: true,
|
|
347
376
|
isIgnoredChange: false,
|
|
348
|
-
byClientId:
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
377
|
+
byClientId: new Map(
|
|
378
|
+
Object.entries( {
|
|
379
|
+
chicken: {
|
|
380
|
+
clientId: 'chicken',
|
|
381
|
+
name: 'core/test-parent-block',
|
|
382
|
+
isValid: true,
|
|
383
|
+
},
|
|
384
|
+
[ newChildBlockId ]: {
|
|
385
|
+
clientId: newChildBlockId,
|
|
386
|
+
name: 'core/test-child-block',
|
|
387
|
+
isValid: true,
|
|
388
|
+
},
|
|
389
|
+
} )
|
|
390
|
+
),
|
|
391
|
+
attributes: new Map(
|
|
392
|
+
Object.entries( {
|
|
393
|
+
chicken: {},
|
|
394
|
+
[ newChildBlockId ]: {
|
|
395
|
+
attr: false,
|
|
396
|
+
attr2: 'perfect',
|
|
397
|
+
},
|
|
398
|
+
} )
|
|
399
|
+
),
|
|
400
|
+
order: new Map(
|
|
401
|
+
Object.entries( {
|
|
402
|
+
'': [ 'chicken' ],
|
|
403
|
+
chicken: [ newChildBlockId ],
|
|
404
|
+
[ newChildBlockId ]: [],
|
|
405
|
+
} )
|
|
406
|
+
),
|
|
407
|
+
parents: new Map(
|
|
408
|
+
Object.entries( {
|
|
409
|
+
[ newChildBlockId ]: 'chicken',
|
|
410
|
+
chicken: '',
|
|
411
|
+
} )
|
|
412
|
+
),
|
|
376
413
|
controlledInnerBlocks: {},
|
|
377
414
|
} );
|
|
378
|
-
expect( state.tree.chicken ).not.toBe(
|
|
379
|
-
existingState.tree.chicken
|
|
415
|
+
expect( state.tree.get( 'chicken' ) ).not.toBe(
|
|
416
|
+
existingState.tree.get( 'chicken' )
|
|
380
417
|
);
|
|
381
|
-
expect( state.tree
|
|
382
|
-
state.tree.chicken
|
|
418
|
+
expect( state.tree.get( '' ).innerBlocks[ 0 ] ).toBe(
|
|
419
|
+
state.tree.get( 'chicken' )
|
|
383
420
|
);
|
|
384
|
-
expect( state.tree.chicken.innerBlocks[ 0 ] ).toBe(
|
|
385
|
-
state.tree
|
|
421
|
+
expect( state.tree.get( 'chicken' ).innerBlocks[ 0 ] ).toBe(
|
|
422
|
+
state.tree.get( newChildBlockId )
|
|
386
423
|
);
|
|
387
|
-
expect( state.tree
|
|
424
|
+
expect( state.tree.get( newChildBlockId ) ).toEqual( {
|
|
388
425
|
clientId: newChildBlockId,
|
|
389
426
|
innerBlocks: [],
|
|
390
427
|
isValid: true,
|
|
@@ -398,44 +435,52 @@ describe( 'state', () => {
|
|
|
398
435
|
|
|
399
436
|
it( 'can replace multiple child blocks', () => {
|
|
400
437
|
const existingState = deepFreeze( {
|
|
401
|
-
byClientId:
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
438
|
+
byClientId: new Map(
|
|
439
|
+
Object.entries( {
|
|
440
|
+
chicken: {
|
|
441
|
+
clientId: 'chicken',
|
|
442
|
+
name: 'core/test-parent-block',
|
|
443
|
+
isValid: true,
|
|
444
|
+
},
|
|
445
|
+
'chicken-child': {
|
|
446
|
+
clientId: 'chicken-child',
|
|
447
|
+
name: 'core/test-child-block',
|
|
448
|
+
isValid: true,
|
|
449
|
+
},
|
|
450
|
+
'chicken-child-2': {
|
|
451
|
+
clientId: 'chicken-child',
|
|
452
|
+
name: 'core/test-child-block',
|
|
453
|
+
isValid: true,
|
|
454
|
+
},
|
|
455
|
+
} )
|
|
456
|
+
),
|
|
457
|
+
attributes: new Map(
|
|
458
|
+
Object.entries( {
|
|
459
|
+
chicken: {},
|
|
460
|
+
'chicken-child': {
|
|
461
|
+
attr: true,
|
|
462
|
+
},
|
|
463
|
+
'chicken-child-2': {
|
|
464
|
+
attr2: 'ok',
|
|
465
|
+
},
|
|
466
|
+
} )
|
|
467
|
+
),
|
|
468
|
+
order: new Map(
|
|
469
|
+
Object.entries( {
|
|
470
|
+
'': [ 'chicken' ],
|
|
471
|
+
chicken: [ 'chicken-child', 'chicken-child-2' ],
|
|
472
|
+
'chicken-child': [],
|
|
473
|
+
'chicken-child-2': [],
|
|
474
|
+
} )
|
|
475
|
+
),
|
|
476
|
+
parents: new Map(
|
|
477
|
+
Object.entries( {
|
|
478
|
+
chicken: '',
|
|
479
|
+
'chicken-child': 'chicken',
|
|
480
|
+
'chicken-child-2': 'chicken',
|
|
481
|
+
} )
|
|
482
|
+
),
|
|
483
|
+
tree: new Map(),
|
|
439
484
|
controlledInnerBlocks: {},
|
|
440
485
|
} );
|
|
441
486
|
|
|
@@ -469,75 +514,83 @@ describe( 'state', () => {
|
|
|
469
514
|
expect( restState ).toEqual( {
|
|
470
515
|
isPersistentChange: true,
|
|
471
516
|
isIgnoredChange: false,
|
|
472
|
-
byClientId:
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
|
|
517
|
+
byClientId: new Map(
|
|
518
|
+
Object.entries( {
|
|
519
|
+
chicken: {
|
|
520
|
+
clientId: 'chicken',
|
|
521
|
+
name: 'core/test-parent-block',
|
|
522
|
+
isValid: true,
|
|
523
|
+
},
|
|
524
|
+
[ newChildBlockId1 ]: {
|
|
525
|
+
clientId: newChildBlockId1,
|
|
526
|
+
name: 'core/test-child-block',
|
|
527
|
+
isValid: true,
|
|
528
|
+
},
|
|
529
|
+
[ newChildBlockId2 ]: {
|
|
530
|
+
clientId: newChildBlockId2,
|
|
531
|
+
name: 'core/test-child-block',
|
|
532
|
+
isValid: true,
|
|
533
|
+
},
|
|
534
|
+
[ newChildBlockId3 ]: {
|
|
535
|
+
clientId: newChildBlockId3,
|
|
536
|
+
name: 'core/test-child-block',
|
|
537
|
+
isValid: true,
|
|
538
|
+
},
|
|
539
|
+
} )
|
|
540
|
+
),
|
|
541
|
+
attributes: new Map(
|
|
542
|
+
Object.entries( {
|
|
543
|
+
chicken: {},
|
|
544
|
+
[ newChildBlockId1 ]: {
|
|
545
|
+
attr: false,
|
|
546
|
+
attr2: 'perfect',
|
|
547
|
+
},
|
|
548
|
+
[ newChildBlockId2 ]: {
|
|
549
|
+
attr: true,
|
|
550
|
+
attr2: 'not-perfect',
|
|
551
|
+
},
|
|
552
|
+
[ newChildBlockId3 ]: {
|
|
553
|
+
attr2: 'hello',
|
|
554
|
+
},
|
|
555
|
+
} )
|
|
556
|
+
),
|
|
557
|
+
order: new Map(
|
|
558
|
+
Object.entries( {
|
|
559
|
+
'': [ 'chicken' ],
|
|
560
|
+
chicken: [
|
|
561
|
+
newChildBlockId1,
|
|
562
|
+
newChildBlockId2,
|
|
563
|
+
newChildBlockId3,
|
|
564
|
+
],
|
|
565
|
+
[ newChildBlockId1 ]: [],
|
|
566
|
+
[ newChildBlockId2 ]: [],
|
|
567
|
+
[ newChildBlockId3 ]: [],
|
|
568
|
+
} )
|
|
569
|
+
),
|
|
570
|
+
parents: new Map(
|
|
571
|
+
Object.entries( {
|
|
572
|
+
chicken: '',
|
|
573
|
+
[ newChildBlockId1 ]: 'chicken',
|
|
574
|
+
[ newChildBlockId2 ]: 'chicken',
|
|
575
|
+
[ newChildBlockId3 ]: 'chicken',
|
|
576
|
+
} )
|
|
577
|
+
),
|
|
525
578
|
controlledInnerBlocks: {},
|
|
526
579
|
} );
|
|
527
580
|
|
|
528
|
-
expect( state.tree
|
|
529
|
-
state.tree.chicken
|
|
581
|
+
expect( state.tree.get( '' ).innerBlocks[ 0 ] ).toBe(
|
|
582
|
+
state.tree.get( 'chicken' )
|
|
530
583
|
);
|
|
531
|
-
expect( state.tree.chicken.innerBlocks[ 0 ] ).toBe(
|
|
532
|
-
state.tree
|
|
584
|
+
expect( state.tree.get( 'chicken' ).innerBlocks[ 0 ] ).toBe(
|
|
585
|
+
state.tree.get( newChildBlockId1 )
|
|
533
586
|
);
|
|
534
|
-
expect( state.tree.chicken.innerBlocks[ 1 ] ).toBe(
|
|
535
|
-
state.tree
|
|
587
|
+
expect( state.tree.get( 'chicken' ).innerBlocks[ 1 ] ).toBe(
|
|
588
|
+
state.tree.get( newChildBlockId2 )
|
|
536
589
|
);
|
|
537
|
-
expect( state.tree.chicken.innerBlocks[ 2 ] ).toBe(
|
|
538
|
-
state.tree
|
|
590
|
+
expect( state.tree.get( 'chicken' ).innerBlocks[ 2 ] ).toBe(
|
|
591
|
+
state.tree.get( newChildBlockId3 )
|
|
539
592
|
);
|
|
540
|
-
expect( state.tree
|
|
593
|
+
expect( state.tree.get( newChildBlockId1 ) ).toEqual( {
|
|
541
594
|
innerBlocks: [],
|
|
542
595
|
clientId: newChildBlockId1,
|
|
543
596
|
name: 'core/test-child-block',
|
|
@@ -551,42 +604,52 @@ describe( 'state', () => {
|
|
|
551
604
|
|
|
552
605
|
it( 'can replace a child block that has other children', () => {
|
|
553
606
|
const existingState = deepFreeze( {
|
|
554
|
-
byClientId:
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
|
|
564
|
-
|
|
565
|
-
|
|
566
|
-
|
|
567
|
-
|
|
568
|
-
|
|
569
|
-
|
|
570
|
-
|
|
571
|
-
|
|
572
|
-
|
|
573
|
-
|
|
574
|
-
|
|
575
|
-
|
|
576
|
-
|
|
577
|
-
|
|
578
|
-
|
|
579
|
-
|
|
580
|
-
|
|
581
|
-
|
|
582
|
-
|
|
583
|
-
|
|
584
|
-
|
|
585
|
-
|
|
586
|
-
|
|
587
|
-
|
|
588
|
-
|
|
589
|
-
|
|
607
|
+
byClientId: new Map(
|
|
608
|
+
Object.entries( {
|
|
609
|
+
chicken: {
|
|
610
|
+
clientId: 'chicken',
|
|
611
|
+
name: 'core/test-parent-block',
|
|
612
|
+
isValid: true,
|
|
613
|
+
},
|
|
614
|
+
'chicken-child': {
|
|
615
|
+
clientId: 'chicken-child',
|
|
616
|
+
name: 'core/test-child-block',
|
|
617
|
+
isValid: true,
|
|
618
|
+
},
|
|
619
|
+
'chicken-grand-child': {
|
|
620
|
+
clientId: 'chicken-child',
|
|
621
|
+
name: 'core/test-block',
|
|
622
|
+
isValid: true,
|
|
623
|
+
},
|
|
624
|
+
} )
|
|
625
|
+
),
|
|
626
|
+
attributes: new Map(
|
|
627
|
+
Object.entries( {
|
|
628
|
+
chicken: {},
|
|
629
|
+
'chicken-child': {},
|
|
630
|
+
'chicken-grand-child': {},
|
|
631
|
+
} )
|
|
632
|
+
),
|
|
633
|
+
order: new Map(
|
|
634
|
+
Object.entries( {
|
|
635
|
+
'': [ 'chicken' ],
|
|
636
|
+
chicken: [ 'chicken-child' ],
|
|
637
|
+
'chicken-child': [ 'chicken-grand-child' ],
|
|
638
|
+
'chicken-grand-child': [],
|
|
639
|
+
} )
|
|
640
|
+
),
|
|
641
|
+
parents: new Map(
|
|
642
|
+
Object.entries( {
|
|
643
|
+
chicken: '',
|
|
644
|
+
'chicken-child': 'chicken',
|
|
645
|
+
'chicken-grand-child': 'chicken-child',
|
|
646
|
+
} )
|
|
647
|
+
),
|
|
648
|
+
tree: new Map(
|
|
649
|
+
Object.entries( {
|
|
650
|
+
chicken: {},
|
|
651
|
+
} )
|
|
652
|
+
),
|
|
590
653
|
controlledInnerBlocks: {},
|
|
591
654
|
} );
|
|
592
655
|
|
|
@@ -606,37 +669,45 @@ describe( 'state', () => {
|
|
|
606
669
|
expect( restState ).toEqual( {
|
|
607
670
|
isPersistentChange: true,
|
|
608
671
|
isIgnoredChange: false,
|
|
609
|
-
byClientId:
|
|
610
|
-
|
|
611
|
-
|
|
612
|
-
|
|
613
|
-
|
|
614
|
-
|
|
615
|
-
|
|
616
|
-
|
|
617
|
-
|
|
618
|
-
|
|
619
|
-
|
|
620
|
-
|
|
621
|
-
|
|
622
|
-
|
|
623
|
-
|
|
624
|
-
|
|
625
|
-
|
|
626
|
-
|
|
627
|
-
|
|
628
|
-
|
|
629
|
-
|
|
630
|
-
|
|
631
|
-
|
|
632
|
-
|
|
633
|
-
|
|
672
|
+
byClientId: new Map(
|
|
673
|
+
Object.entries( {
|
|
674
|
+
chicken: {
|
|
675
|
+
clientId: 'chicken',
|
|
676
|
+
name: 'core/test-parent-block',
|
|
677
|
+
isValid: true,
|
|
678
|
+
},
|
|
679
|
+
[ newChildBlockId ]: {
|
|
680
|
+
clientId: newChildBlockId,
|
|
681
|
+
name: 'core/test-block',
|
|
682
|
+
isValid: true,
|
|
683
|
+
},
|
|
684
|
+
} )
|
|
685
|
+
),
|
|
686
|
+
attributes: new Map(
|
|
687
|
+
Object.entries( {
|
|
688
|
+
chicken: {},
|
|
689
|
+
[ newChildBlockId ]: {},
|
|
690
|
+
} )
|
|
691
|
+
),
|
|
692
|
+
order: new Map(
|
|
693
|
+
Object.entries( {
|
|
694
|
+
'': [ 'chicken' ],
|
|
695
|
+
chicken: [ newChildBlockId ],
|
|
696
|
+
[ newChildBlockId ]: [],
|
|
697
|
+
} )
|
|
698
|
+
),
|
|
699
|
+
parents: new Map(
|
|
700
|
+
Object.entries( {
|
|
701
|
+
chicken: '',
|
|
702
|
+
[ newChildBlockId ]: 'chicken',
|
|
703
|
+
} )
|
|
704
|
+
),
|
|
634
705
|
controlledInnerBlocks: {},
|
|
635
706
|
} );
|
|
636
707
|
|
|
637
708
|
// The block object of the parent should be updated.
|
|
638
|
-
expect( state.tree.chicken ).not.toBe(
|
|
639
|
-
existingState.tree.chicken
|
|
709
|
+
expect( state.tree.get( 'chicken' ) ).not.toBe(
|
|
710
|
+
existingState.tree.get( 'chicken' )
|
|
640
711
|
);
|
|
641
712
|
} );
|
|
642
713
|
} );
|
|
@@ -645,13 +716,13 @@ describe( 'state', () => {
|
|
|
645
716
|
const state = blocks( undefined, {} );
|
|
646
717
|
|
|
647
718
|
expect( state ).toEqual( {
|
|
648
|
-
byClientId:
|
|
649
|
-
attributes:
|
|
650
|
-
order:
|
|
651
|
-
parents:
|
|
719
|
+
byClientId: new Map(),
|
|
720
|
+
attributes: new Map(),
|
|
721
|
+
order: new Map(),
|
|
722
|
+
parents: new Map(),
|
|
652
723
|
isPersistentChange: true,
|
|
653
724
|
isIgnoredChange: false,
|
|
654
|
-
tree:
|
|
725
|
+
tree: new Map(),
|
|
655
726
|
controlledInnerBlocks: {},
|
|
656
727
|
} );
|
|
657
728
|
} );
|
|
@@ -663,20 +734,20 @@ describe( 'state', () => {
|
|
|
663
734
|
blocks: [ { clientId: 'bananas', innerBlocks: [] } ],
|
|
664
735
|
} );
|
|
665
736
|
|
|
666
|
-
expect(
|
|
667
|
-
expect(
|
|
737
|
+
expect( state.byClientId.size ).toBe( 1 );
|
|
738
|
+
expect( state.byClientId.get( 'bananas' ).clientId ).toBe(
|
|
668
739
|
'bananas'
|
|
669
740
|
);
|
|
670
|
-
expect( state.order ).toEqual( {
|
|
741
|
+
expect( Object.fromEntries( state.order ) ).toEqual( {
|
|
671
742
|
'': [ 'bananas' ],
|
|
672
743
|
bananas: [],
|
|
673
744
|
} );
|
|
674
|
-
expect( state.tree.bananas ).toEqual( {
|
|
745
|
+
expect( state.tree.get( 'bananas' ) ).toEqual( {
|
|
675
746
|
clientId: 'bananas',
|
|
676
747
|
innerBlocks: [],
|
|
677
748
|
} );
|
|
678
|
-
expect( state.tree
|
|
679
|
-
state.tree.bananas
|
|
749
|
+
expect( state.tree.get( '' ).innerBlocks[ 0 ] ).toBe(
|
|
750
|
+
state.tree.get( 'bananas' )
|
|
680
751
|
);
|
|
681
752
|
} );
|
|
682
753
|
} );
|
|
@@ -695,8 +766,8 @@ describe( 'state', () => {
|
|
|
695
766
|
],
|
|
696
767
|
} );
|
|
697
768
|
|
|
698
|
-
expect(
|
|
699
|
-
expect( state.order ).toEqual( {
|
|
769
|
+
expect( state.byClientId.size ).toBe( 2 );
|
|
770
|
+
expect( Object.fromEntries( state.order ) ).toEqual( {
|
|
700
771
|
'': [ 'bananas' ],
|
|
701
772
|
apples: [],
|
|
702
773
|
bananas: [ 'apples' ],
|
|
@@ -726,21 +797,21 @@ describe( 'state', () => {
|
|
|
726
797
|
],
|
|
727
798
|
} );
|
|
728
799
|
|
|
729
|
-
expect(
|
|
730
|
-
expect(
|
|
731
|
-
|
|
732
|
-
);
|
|
733
|
-
expect( state.order ).toEqual( {
|
|
800
|
+
expect( state.byClientId.size ).toBe( 2 );
|
|
801
|
+
expect( state.byClientId.get( 'ribs' ).clientId ).toBe( 'ribs' );
|
|
802
|
+
expect( Object.fromEntries( state.order ) ).toEqual( {
|
|
734
803
|
'': [ 'chicken', 'ribs' ],
|
|
735
804
|
chicken: [],
|
|
736
805
|
ribs: [],
|
|
737
806
|
} );
|
|
738
807
|
|
|
739
|
-
expect( state.tree
|
|
740
|
-
state.tree.chicken
|
|
808
|
+
expect( state.tree.get( '' ).innerBlocks[ 0 ] ).toBe(
|
|
809
|
+
state.tree.get( 'chicken' )
|
|
741
810
|
);
|
|
742
|
-
expect( state.tree
|
|
743
|
-
|
|
811
|
+
expect( state.tree.get( '' ).innerBlocks[ 1 ] ).toBe(
|
|
812
|
+
state.tree.get( 'ribs' )
|
|
813
|
+
);
|
|
814
|
+
expect( state.tree.get( 'chicken' ) ).toEqual( {
|
|
744
815
|
clientId: 'chicken',
|
|
745
816
|
name: 'core/test-block',
|
|
746
817
|
attributes: {},
|
|
@@ -772,24 +843,22 @@ describe( 'state', () => {
|
|
|
772
843
|
],
|
|
773
844
|
} );
|
|
774
845
|
|
|
775
|
-
expect(
|
|
776
|
-
expect(
|
|
846
|
+
expect( state.byClientId.size ).toBe( 1 );
|
|
847
|
+
expect( state.byClientId.get( 'wings' ).name ).toBe(
|
|
777
848
|
'core/freeform'
|
|
778
849
|
);
|
|
779
|
-
expect(
|
|
780
|
-
|
|
781
|
-
);
|
|
782
|
-
expect( state.order ).toEqual( {
|
|
850
|
+
expect( state.byClientId.get( 'wings' ).clientId ).toBe( 'wings' );
|
|
851
|
+
expect( Object.fromEntries( state.order ) ).toEqual( {
|
|
783
852
|
'': [ 'wings' ],
|
|
784
853
|
wings: [],
|
|
785
854
|
} );
|
|
786
|
-
expect( state.parents ).toEqual( {
|
|
855
|
+
expect( Object.fromEntries( state.parents ) ).toEqual( {
|
|
787
856
|
wings: '',
|
|
788
857
|
} );
|
|
789
|
-
expect( state.tree
|
|
790
|
-
state.tree.wings
|
|
858
|
+
expect( state.tree.get( '' ).innerBlocks[ 0 ] ).toBe(
|
|
859
|
+
state.tree.get( 'wings' )
|
|
791
860
|
);
|
|
792
|
-
expect( state.tree.wings ).toEqual( {
|
|
861
|
+
expect( state.tree.get( 'wings' ) ).toEqual( {
|
|
793
862
|
clientId: 'wings',
|
|
794
863
|
name: 'core/freeform',
|
|
795
864
|
innerBlocks: [],
|
|
@@ -814,8 +883,8 @@ describe( 'state', () => {
|
|
|
814
883
|
blocks: [],
|
|
815
884
|
} );
|
|
816
885
|
|
|
817
|
-
expect(
|
|
818
|
-
expect( state.tree
|
|
886
|
+
expect( state.byClientId.size ).toBe( 0 );
|
|
887
|
+
expect( state.tree.get( '' ).innerBlocks ).toHaveLength( 0 );
|
|
819
888
|
} );
|
|
820
889
|
|
|
821
890
|
it( 'should replace the block and remove references to its inner blocks', () => {
|
|
@@ -849,18 +918,18 @@ describe( 'state', () => {
|
|
|
849
918
|
],
|
|
850
919
|
} );
|
|
851
920
|
|
|
852
|
-
expect(
|
|
853
|
-
expect( state.order ).toEqual( {
|
|
921
|
+
expect( state.byClientId.size ).toBe( 1 );
|
|
922
|
+
expect( Object.fromEntries( state.order ) ).toEqual( {
|
|
854
923
|
'': [ 'wings' ],
|
|
855
924
|
wings: [],
|
|
856
925
|
} );
|
|
857
|
-
expect( state.parents ).toEqual( {
|
|
926
|
+
expect( Object.fromEntries( state.parents ) ).toEqual( {
|
|
858
927
|
wings: '',
|
|
859
928
|
} );
|
|
860
|
-
expect( state.tree
|
|
861
|
-
state.tree.wings
|
|
929
|
+
expect( state.tree.get( '' ).innerBlocks[ 0 ] ).toBe(
|
|
930
|
+
state.tree.get( 'wings' )
|
|
862
931
|
);
|
|
863
|
-
expect( state.tree.wings ).toEqual( {
|
|
932
|
+
expect( state.tree.get( 'wings' ) ).toEqual( {
|
|
864
933
|
clientId: 'wings',
|
|
865
934
|
name: 'core/freeform',
|
|
866
935
|
innerBlocks: [],
|
|
@@ -884,21 +953,21 @@ describe( 'state', () => {
|
|
|
884
953
|
blocks: [ replacementBlock ],
|
|
885
954
|
} );
|
|
886
955
|
|
|
887
|
-
expect( state.order ).toEqual( {
|
|
956
|
+
expect( Object.fromEntries( state.order ) ).toEqual( {
|
|
888
957
|
'': [ wrapperBlock.clientId ],
|
|
889
958
|
[ wrapperBlock.clientId ]: [ replacementBlock.clientId ],
|
|
890
959
|
[ replacementBlock.clientId ]: [],
|
|
891
960
|
} );
|
|
892
961
|
|
|
893
|
-
expect( state.parents ).toEqual( {
|
|
962
|
+
expect( Object.fromEntries( state.parents ) ).toEqual( {
|
|
894
963
|
[ wrapperBlock.clientId ]: '',
|
|
895
964
|
[ replacementBlock.clientId ]: wrapperBlock.clientId,
|
|
896
965
|
} );
|
|
897
966
|
|
|
898
|
-
expect(
|
|
899
|
-
state.tree
|
|
900
|
-
);
|
|
901
|
-
expect( state.tree
|
|
967
|
+
expect(
|
|
968
|
+
state.tree.get( wrapperBlock.clientId ).innerBlocks[ 0 ]
|
|
969
|
+
).toBe( state.tree.get( replacementBlock.clientId ) );
|
|
970
|
+
expect( state.tree.get( replacementBlock.clientId ) ).toEqual( {
|
|
902
971
|
clientId: replacementBlock.clientId,
|
|
903
972
|
name: 'core/test-block',
|
|
904
973
|
innerBlocks: [],
|
|
@@ -931,22 +1000,22 @@ describe( 'state', () => {
|
|
|
931
1000
|
],
|
|
932
1001
|
} );
|
|
933
1002
|
|
|
934
|
-
expect(
|
|
935
|
-
expect(
|
|
1003
|
+
expect( replacedState.byClientId.size ).toBe( 1 );
|
|
1004
|
+
expect( originalState.byClientId.get( 'chicken' ).name ).toBe(
|
|
936
1005
|
'core/test-block'
|
|
937
1006
|
);
|
|
938
|
-
expect(
|
|
1007
|
+
expect( replacedState.byClientId.get( 'chicken' ).name ).toBe(
|
|
939
1008
|
'core/freeform'
|
|
940
1009
|
);
|
|
941
|
-
expect(
|
|
942
|
-
|
|
943
|
-
)
|
|
944
|
-
expect( replacedState.order ).toEqual( {
|
|
1010
|
+
expect( replacedState.byClientId.get( 'chicken' ).clientId ).toBe(
|
|
1011
|
+
'chicken'
|
|
1012
|
+
);
|
|
1013
|
+
expect( Object.fromEntries( replacedState.order ) ).toEqual( {
|
|
945
1014
|
'': [ 'chicken' ],
|
|
946
1015
|
chicken: [],
|
|
947
1016
|
} );
|
|
948
|
-
expect( originalState.tree.chicken ).not.toBe(
|
|
949
|
-
replacedState.tree.chicken
|
|
1017
|
+
expect( originalState.tree.get( 'chicken' ) ).not.toBe(
|
|
1018
|
+
replacedState.tree.get( 'chicken' )
|
|
950
1019
|
);
|
|
951
1020
|
|
|
952
1021
|
const nestedBlock = {
|
|
@@ -976,16 +1045,16 @@ describe( 'state', () => {
|
|
|
976
1045
|
blocks: [ replacementNestedBlock ],
|
|
977
1046
|
} );
|
|
978
1047
|
|
|
979
|
-
expect( replacedNestedState.order ).toEqual( {
|
|
1048
|
+
expect( Object.fromEntries( replacedNestedState.order ) ).toEqual( {
|
|
980
1049
|
'': [ wrapperBlock.clientId ],
|
|
981
1050
|
[ wrapperBlock.clientId ]: [ replacementNestedBlock.clientId ],
|
|
982
1051
|
[ replacementNestedBlock.clientId ]: [],
|
|
983
1052
|
} );
|
|
984
1053
|
|
|
985
|
-
expect( originalNestedState.byClientId.chicken.name ).toBe(
|
|
1054
|
+
expect( originalNestedState.byClientId.get( 'chicken' ).name ).toBe(
|
|
986
1055
|
'core/test-block'
|
|
987
1056
|
);
|
|
988
|
-
expect( replacedNestedState.byClientId.chicken.name ).toBe(
|
|
1057
|
+
expect( replacedNestedState.byClientId.get( 'chicken' ).name ).toBe(
|
|
989
1058
|
'core/freeform'
|
|
990
1059
|
);
|
|
991
1060
|
} );
|
|
@@ -1012,19 +1081,19 @@ describe( 'state', () => {
|
|
|
1012
1081
|
},
|
|
1013
1082
|
} );
|
|
1014
1083
|
|
|
1015
|
-
expect( state.byClientId.chicken ).toEqual( {
|
|
1084
|
+
expect( state.byClientId.get( 'chicken' ) ).toEqual( {
|
|
1016
1085
|
clientId: 'chicken',
|
|
1017
1086
|
name: 'core/test-block',
|
|
1018
1087
|
isValid: true,
|
|
1019
1088
|
} );
|
|
1020
1089
|
|
|
1021
|
-
expect( state.attributes.chicken ).toEqual( {
|
|
1090
|
+
expect( state.attributes.get( 'chicken' ) ).toEqual( {
|
|
1022
1091
|
content: 'ribs',
|
|
1023
1092
|
} );
|
|
1024
|
-
expect( state.tree
|
|
1025
|
-
state.tree.chicken
|
|
1093
|
+
expect( state.tree.get( '' ).innerBlocks[ 0 ] ).toBe(
|
|
1094
|
+
state.tree.get( 'chicken' )
|
|
1026
1095
|
);
|
|
1027
|
-
expect( state.tree.chicken ).toEqual( {
|
|
1096
|
+
expect( state.tree.get( 'chicken' ) ).toEqual( {
|
|
1028
1097
|
clientId: 'chicken',
|
|
1029
1098
|
name: 'core/test-block',
|
|
1030
1099
|
innerBlocks: [],
|
|
@@ -1057,20 +1126,20 @@ describe( 'state', () => {
|
|
|
1057
1126
|
updatedId: 3,
|
|
1058
1127
|
} );
|
|
1059
1128
|
|
|
1060
|
-
expect( state.byClientId.chicken ).toEqual( {
|
|
1129
|
+
expect( state.byClientId.get( 'chicken' ) ).toEqual( {
|
|
1061
1130
|
clientId: 'chicken',
|
|
1062
1131
|
name: 'core/block',
|
|
1063
1132
|
isValid: false,
|
|
1064
1133
|
} );
|
|
1065
1134
|
|
|
1066
|
-
expect( state.attributes.chicken ).toEqual( {
|
|
1135
|
+
expect( state.attributes.get( 'chicken' ) ).toEqual( {
|
|
1067
1136
|
ref: 3,
|
|
1068
1137
|
} );
|
|
1069
1138
|
|
|
1070
|
-
expect( state.tree
|
|
1071
|
-
state.tree.chicken
|
|
1139
|
+
expect( state.tree.get( '' ).innerBlocks[ 0 ] ).toBe(
|
|
1140
|
+
state.tree.get( 'chicken' )
|
|
1072
1141
|
);
|
|
1073
|
-
expect( state.tree.chicken ).toEqual( {
|
|
1142
|
+
expect( state.tree.get( 'chicken' ) ).toEqual( {
|
|
1074
1143
|
clientId: 'chicken',
|
|
1075
1144
|
name: 'core/block',
|
|
1076
1145
|
isValid: false,
|
|
@@ -1104,12 +1173,16 @@ describe( 'state', () => {
|
|
|
1104
1173
|
clientIds: [ 'ribs' ],
|
|
1105
1174
|
} );
|
|
1106
1175
|
|
|
1107
|
-
expect( state.order
|
|
1108
|
-
expect( state.tree
|
|
1109
|
-
|
|
1110
|
-
|
|
1176
|
+
expect( state.order.get( '' ) ).toEqual( [ 'ribs', 'chicken' ] );
|
|
1177
|
+
expect( state.tree.get( '' ).innerBlocks[ 0 ] ).toBe(
|
|
1178
|
+
state.tree.get( 'ribs' )
|
|
1179
|
+
);
|
|
1180
|
+
expect( state.tree.get( '' ).innerBlocks[ 1 ] ).toBe(
|
|
1181
|
+
state.tree.get( 'chicken' )
|
|
1182
|
+
);
|
|
1183
|
+
expect( state.tree.get( 'chicken' ) ).toBe(
|
|
1184
|
+
original.tree.get( 'chicken' )
|
|
1111
1185
|
);
|
|
1112
|
-
expect( state.tree.chicken ).toBe( original.tree.chicken );
|
|
1113
1186
|
} );
|
|
1114
1187
|
|
|
1115
1188
|
it( 'should move the nested block up', () => {
|
|
@@ -1129,7 +1202,7 @@ describe( 'state', () => {
|
|
|
1129
1202
|
rootClientId: wrapperBlock.clientId,
|
|
1130
1203
|
} );
|
|
1131
1204
|
|
|
1132
|
-
expect( state.order ).toEqual( {
|
|
1205
|
+
expect( Object.fromEntries( state.order ) ).toEqual( {
|
|
1133
1206
|
'': [ wrapperBlock.clientId ],
|
|
1134
1207
|
[ wrapperBlock.clientId ]: [
|
|
1135
1208
|
movedBlock.clientId,
|
|
@@ -1139,14 +1212,14 @@ describe( 'state', () => {
|
|
|
1139
1212
|
[ siblingBlock.clientId ]: [],
|
|
1140
1213
|
} );
|
|
1141
1214
|
|
|
1142
|
-
expect(
|
|
1143
|
-
state.tree
|
|
1144
|
-
);
|
|
1145
|
-
expect(
|
|
1146
|
-
state.tree
|
|
1147
|
-
);
|
|
1148
|
-
expect( state.tree
|
|
1149
|
-
original.tree
|
|
1215
|
+
expect(
|
|
1216
|
+
state.tree.get( wrapperBlock.clientId ).innerBlocks[ 0 ]
|
|
1217
|
+
).toBe( state.tree.get( movedBlock.clientId ) );
|
|
1218
|
+
expect(
|
|
1219
|
+
state.tree.get( wrapperBlock.clientId ).innerBlocks[ 1 ]
|
|
1220
|
+
).toBe( state.tree.get( siblingBlock.clientId ) );
|
|
1221
|
+
expect( state.tree.get( movedBlock.clientId ) ).toBe(
|
|
1222
|
+
original.tree.get( movedBlock.clientId )
|
|
1150
1223
|
);
|
|
1151
1224
|
} );
|
|
1152
1225
|
|
|
@@ -1179,7 +1252,7 @@ describe( 'state', () => {
|
|
|
1179
1252
|
clientIds: [ 'ribs', 'veggies' ],
|
|
1180
1253
|
} );
|
|
1181
1254
|
|
|
1182
|
-
expect( state.order
|
|
1255
|
+
expect( state.order.get( '' ) ).toEqual( [
|
|
1183
1256
|
'ribs',
|
|
1184
1257
|
'veggies',
|
|
1185
1258
|
'chicken',
|
|
@@ -1205,7 +1278,7 @@ describe( 'state', () => {
|
|
|
1205
1278
|
rootClientId: wrapperBlock.clientId,
|
|
1206
1279
|
} );
|
|
1207
1280
|
|
|
1208
|
-
expect( state.order ).toEqual( {
|
|
1281
|
+
expect( Object.fromEntries( state.order ) ).toEqual( {
|
|
1209
1282
|
'': [ wrapperBlock.clientId ],
|
|
1210
1283
|
[ wrapperBlock.clientId ]: [
|
|
1211
1284
|
movedBlockA.clientId,
|
|
@@ -1267,7 +1340,7 @@ describe( 'state', () => {
|
|
|
1267
1340
|
clientIds: [ 'chicken' ],
|
|
1268
1341
|
} );
|
|
1269
1342
|
|
|
1270
|
-
expect( state.order
|
|
1343
|
+
expect( state.order.get( '' ) ).toEqual( [ 'ribs', 'chicken' ] );
|
|
1271
1344
|
} );
|
|
1272
1345
|
|
|
1273
1346
|
it( 'should move the nested block down', () => {
|
|
@@ -1287,7 +1360,7 @@ describe( 'state', () => {
|
|
|
1287
1360
|
rootClientId: wrapperBlock.clientId,
|
|
1288
1361
|
} );
|
|
1289
1362
|
|
|
1290
|
-
expect( state.order ).toEqual( {
|
|
1363
|
+
expect( Object.fromEntries( state.order ) ).toEqual( {
|
|
1291
1364
|
'': [ wrapperBlock.clientId ],
|
|
1292
1365
|
[ wrapperBlock.clientId ]: [
|
|
1293
1366
|
siblingBlock.clientId,
|
|
@@ -1327,7 +1400,7 @@ describe( 'state', () => {
|
|
|
1327
1400
|
clientIds: [ 'chicken', 'ribs' ],
|
|
1328
1401
|
} );
|
|
1329
1402
|
|
|
1330
|
-
expect( state.order
|
|
1403
|
+
expect( state.order.get( '' ) ).toEqual( [
|
|
1331
1404
|
'veggies',
|
|
1332
1405
|
'chicken',
|
|
1333
1406
|
'ribs',
|
|
@@ -1353,7 +1426,7 @@ describe( 'state', () => {
|
|
|
1353
1426
|
rootClientId: wrapperBlock.clientId,
|
|
1354
1427
|
} );
|
|
1355
1428
|
|
|
1356
|
-
expect( state.order ).toEqual( {
|
|
1429
|
+
expect( Object.fromEntries( state.order ) ).toEqual( {
|
|
1357
1430
|
'': [ wrapperBlock.clientId ],
|
|
1358
1431
|
[ wrapperBlock.clientId ]: [
|
|
1359
1432
|
siblingBlock.clientId,
|
|
@@ -1415,21 +1488,23 @@ describe( 'state', () => {
|
|
|
1415
1488
|
clientIds: [ 'chicken' ],
|
|
1416
1489
|
} );
|
|
1417
1490
|
|
|
1418
|
-
expect( state.order
|
|
1419
|
-
expect( state.order ).not.toHaveProperty(
|
|
1420
|
-
|
|
1491
|
+
expect( state.order.get( '' ) ).toEqual( [ 'ribs' ] );
|
|
1492
|
+
expect( Object.fromEntries( state.order ) ).not.toHaveProperty(
|
|
1493
|
+
'chicken'
|
|
1494
|
+
);
|
|
1495
|
+
expect( Object.fromEntries( state.parents ) ).toEqual( {
|
|
1421
1496
|
ribs: '',
|
|
1422
1497
|
} );
|
|
1423
|
-
expect( state.byClientId ).toEqual( {
|
|
1498
|
+
expect( Object.fromEntries( state.byClientId ) ).toEqual( {
|
|
1424
1499
|
ribs: {
|
|
1425
1500
|
clientId: 'ribs',
|
|
1426
1501
|
name: 'core/test-block',
|
|
1427
1502
|
},
|
|
1428
1503
|
} );
|
|
1429
|
-
expect( state.attributes ).toEqual( {
|
|
1504
|
+
expect( Object.fromEntries( state.attributes ) ).toEqual( {
|
|
1430
1505
|
ribs: {},
|
|
1431
1506
|
} );
|
|
1432
|
-
expect( state.tree
|
|
1507
|
+
expect( state.tree.get( '' ).innerBlocks ).toHaveLength( 1 );
|
|
1433
1508
|
} );
|
|
1434
1509
|
|
|
1435
1510
|
it( 'should remove multiple blocks', () => {
|
|
@@ -1461,19 +1536,23 @@ describe( 'state', () => {
|
|
|
1461
1536
|
clientIds: [ 'chicken', 'veggies' ],
|
|
1462
1537
|
} );
|
|
1463
1538
|
|
|
1464
|
-
expect( state.order
|
|
1465
|
-
expect( state.order ).not.toHaveProperty(
|
|
1466
|
-
|
|
1467
|
-
|
|
1539
|
+
expect( state.order.get( '' ) ).toEqual( [ 'ribs' ] );
|
|
1540
|
+
expect( Object.fromEntries( state.order ) ).not.toHaveProperty(
|
|
1541
|
+
'chicken'
|
|
1542
|
+
);
|
|
1543
|
+
expect( Object.fromEntries( state.order ) ).not.toHaveProperty(
|
|
1544
|
+
'veggies'
|
|
1545
|
+
);
|
|
1546
|
+
expect( Object.fromEntries( state.parents ) ).toEqual( {
|
|
1468
1547
|
ribs: '',
|
|
1469
1548
|
} );
|
|
1470
|
-
expect( state.byClientId ).toEqual( {
|
|
1549
|
+
expect( Object.fromEntries( state.byClientId ) ).toEqual( {
|
|
1471
1550
|
ribs: {
|
|
1472
1551
|
clientId: 'ribs',
|
|
1473
1552
|
name: 'core/test-block',
|
|
1474
1553
|
},
|
|
1475
1554
|
} );
|
|
1476
|
-
expect( state.attributes ).toEqual( {
|
|
1555
|
+
expect( Object.fromEntries( state.attributes ) ).toEqual( {
|
|
1477
1556
|
ribs: {},
|
|
1478
1557
|
} );
|
|
1479
1558
|
} );
|
|
@@ -1495,11 +1574,11 @@ describe( 'state', () => {
|
|
|
1495
1574
|
clientIds: [ block.clientId ],
|
|
1496
1575
|
} );
|
|
1497
1576
|
|
|
1498
|
-
expect( state.byClientId ).toEqual(
|
|
1499
|
-
expect( state.order ).toEqual( {
|
|
1577
|
+
expect( state.byClientId ).toEqual( new Map() );
|
|
1578
|
+
expect( Object.fromEntries( state.order ) ).toEqual( {
|
|
1500
1579
|
'': [],
|
|
1501
1580
|
} );
|
|
1502
|
-
expect( state.parents ).toEqual( {} );
|
|
1581
|
+
expect( Object.fromEntries( state.parents ) ).toEqual( {} );
|
|
1503
1582
|
} );
|
|
1504
1583
|
|
|
1505
1584
|
it( 'should insert at the specified index', () => {
|
|
@@ -1533,8 +1612,8 @@ describe( 'state', () => {
|
|
|
1533
1612
|
],
|
|
1534
1613
|
} );
|
|
1535
1614
|
|
|
1536
|
-
expect(
|
|
1537
|
-
expect( state.order
|
|
1615
|
+
expect( state.byClientId.size ).toBe( 3 );
|
|
1616
|
+
expect( state.order.get( '' ) ).toEqual( [
|
|
1538
1617
|
'kumquat',
|
|
1539
1618
|
'persimmon',
|
|
1540
1619
|
'loquat',
|
|
@@ -1571,7 +1650,7 @@ describe( 'state', () => {
|
|
|
1571
1650
|
index: 0,
|
|
1572
1651
|
} );
|
|
1573
1652
|
|
|
1574
|
-
expect( state.order
|
|
1653
|
+
expect( state.order.get( '' ) ).toEqual( [
|
|
1575
1654
|
'ribs',
|
|
1576
1655
|
'chicken',
|
|
1577
1656
|
'veggies',
|
|
@@ -1608,7 +1687,7 @@ describe( 'state', () => {
|
|
|
1608
1687
|
index: 2,
|
|
1609
1688
|
} );
|
|
1610
1689
|
|
|
1611
|
-
expect( state.order
|
|
1690
|
+
expect( state.order.get( '' ) ).toEqual( [
|
|
1612
1691
|
'chicken',
|
|
1613
1692
|
'veggies',
|
|
1614
1693
|
'ribs',
|
|
@@ -1645,7 +1724,7 @@ describe( 'state', () => {
|
|
|
1645
1724
|
index: 1,
|
|
1646
1725
|
} );
|
|
1647
1726
|
|
|
1648
|
-
expect( state.order
|
|
1727
|
+
expect( state.order.get( '' ) ).toEqual( [
|
|
1649
1728
|
'chicken',
|
|
1650
1729
|
'ribs',
|
|
1651
1730
|
'veggies',
|
|
@@ -1682,7 +1761,7 @@ describe( 'state', () => {
|
|
|
1682
1761
|
index: 0,
|
|
1683
1762
|
} );
|
|
1684
1763
|
|
|
1685
|
-
expect( state.order
|
|
1764
|
+
expect( state.order.get( '' ) ).toEqual( [
|
|
1686
1765
|
'ribs',
|
|
1687
1766
|
'veggies',
|
|
1688
1767
|
'chicken',
|
|
@@ -1721,8 +1800,11 @@ describe( 'state', () => {
|
|
|
1721
1800
|
index: 0,
|
|
1722
1801
|
} );
|
|
1723
1802
|
|
|
1724
|
-
expect( state.order
|
|
1725
|
-
expect( state.order.chicken ).toEqual( [
|
|
1803
|
+
expect( state.order.get( '' ) ).toEqual( [ 'chicken' ] );
|
|
1804
|
+
expect( state.order.get( 'chicken' ) ).toEqual( [
|
|
1805
|
+
'ribs',
|
|
1806
|
+
'veggies',
|
|
1807
|
+
] );
|
|
1726
1808
|
} );
|
|
1727
1809
|
|
|
1728
1810
|
describe( 'blocks', () => {
|
|
@@ -1794,7 +1876,42 @@ describe( 'state', () => {
|
|
|
1794
1876
|
},
|
|
1795
1877
|
} );
|
|
1796
1878
|
|
|
1797
|
-
expect( state.attributes.kumquat.updated ).toBe(
|
|
1879
|
+
expect( state.attributes.get( 'kumquat' ).updated ).toBe(
|
|
1880
|
+
true
|
|
1881
|
+
);
|
|
1882
|
+
} );
|
|
1883
|
+
|
|
1884
|
+
it( 'should not updated equal attributes', () => {
|
|
1885
|
+
const original = deepFreeze(
|
|
1886
|
+
blocks( undefined, {
|
|
1887
|
+
type: 'RESET_BLOCKS',
|
|
1888
|
+
blocks: [
|
|
1889
|
+
{
|
|
1890
|
+
clientId: 'kumquat',
|
|
1891
|
+
attributes: {},
|
|
1892
|
+
innerBlocks: [],
|
|
1893
|
+
},
|
|
1894
|
+
],
|
|
1895
|
+
} )
|
|
1896
|
+
);
|
|
1897
|
+
const state = blocks( original, {
|
|
1898
|
+
type: 'UPDATE_BLOCK_ATTRIBUTES',
|
|
1899
|
+
clientIds: [ 'kumquat' ],
|
|
1900
|
+
attributes: {
|
|
1901
|
+
updated: true,
|
|
1902
|
+
},
|
|
1903
|
+
} );
|
|
1904
|
+
const updatedState = blocks( state, {
|
|
1905
|
+
type: 'UPDATE_BLOCK_ATTRIBUTES',
|
|
1906
|
+
clientIds: [ 'kumquat' ],
|
|
1907
|
+
attributes: {
|
|
1908
|
+
updated: true,
|
|
1909
|
+
},
|
|
1910
|
+
} );
|
|
1911
|
+
|
|
1912
|
+
expect( state.attributes.get( 'kumquat' ) ).toBe(
|
|
1913
|
+
updatedState.attributes.get( 'kumquat' )
|
|
1914
|
+
);
|
|
1798
1915
|
} );
|
|
1799
1916
|
|
|
1800
1917
|
it( 'should return with attribute block updates when attributes are unique by block', () => {
|
|
@@ -1819,7 +1936,9 @@ describe( 'state', () => {
|
|
|
1819
1936
|
uniqueByBlock: true,
|
|
1820
1937
|
} );
|
|
1821
1938
|
|
|
1822
|
-
expect( state.attributes.kumquat.updated ).toBe(
|
|
1939
|
+
expect( state.attributes.get( 'kumquat' ).updated ).toBe(
|
|
1940
|
+
true
|
|
1941
|
+
);
|
|
1823
1942
|
} );
|
|
1824
1943
|
|
|
1825
1944
|
it( 'should accumulate attribute block updates', () => {
|
|
@@ -1845,7 +1964,7 @@ describe( 'state', () => {
|
|
|
1845
1964
|
},
|
|
1846
1965
|
} );
|
|
1847
1966
|
|
|
1848
|
-
expect( state.attributes.kumquat ).toEqual( {
|
|
1967
|
+
expect( state.attributes.get( 'kumquat' ) ).toEqual( {
|
|
1849
1968
|
updated: true,
|
|
1850
1969
|
moreUpdated: true,
|
|
1851
1970
|
} );
|
|
@@ -1894,6 +2013,27 @@ describe( 'state', () => {
|
|
|
1894
2013
|
|
|
1895
2014
|
expect( state.attributes ).toBe( state.attributes );
|
|
1896
2015
|
} );
|
|
2016
|
+
|
|
2017
|
+
it( 'should handle undefined attributes', () => {
|
|
2018
|
+
const original = deepFreeze(
|
|
2019
|
+
blocks( undefined, {
|
|
2020
|
+
type: 'RESET_BLOCKS',
|
|
2021
|
+
blocks: [
|
|
2022
|
+
{
|
|
2023
|
+
clientId: 'kumquat',
|
|
2024
|
+
attributes: {},
|
|
2025
|
+
innerBlocks: [],
|
|
2026
|
+
},
|
|
2027
|
+
],
|
|
2028
|
+
} )
|
|
2029
|
+
);
|
|
2030
|
+
const state = blocks( original, {
|
|
2031
|
+
type: 'UPDATE_BLOCK_ATTRIBUTES',
|
|
2032
|
+
clientIds: [ 'kumquat' ],
|
|
2033
|
+
} );
|
|
2034
|
+
|
|
2035
|
+
expect( state.attributes.get( 'kumquat' ) ).toEqual( {} );
|
|
2036
|
+
} );
|
|
1897
2037
|
} );
|
|
1898
2038
|
|
|
1899
2039
|
describe( 'isPersistentChange', () => {
|
|
@@ -2089,105 +2229,115 @@ describe( 'state', () => {
|
|
|
2089
2229
|
expect( state.controlledInnerBlocks.chicken ).toBe( true );
|
|
2090
2230
|
// The previous content of the block should be removed
|
|
2091
2231
|
expect( state.byClientId.child ).toBeUndefined();
|
|
2092
|
-
expect( state.tree.child ).toBeUndefined();
|
|
2093
|
-
expect( state.tree.chicken.innerBlocks ).toEqual(
|
|
2232
|
+
expect( state.tree.get( 'child' ) ).toBeUndefined();
|
|
2233
|
+
expect( state.tree.get( 'chicken' ).innerBlocks ).toEqual(
|
|
2234
|
+
[]
|
|
2235
|
+
);
|
|
2094
2236
|
} );
|
|
2095
2237
|
it( 'should preserve the controlled blocks in state and re-attach them in other pieces of state(order, tree, etc..), when we replace inner blocks', () => {
|
|
2096
2238
|
const initialState = {
|
|
2097
|
-
byClientId:
|
|
2098
|
-
|
|
2099
|
-
|
|
2100
|
-
|
|
2101
|
-
|
|
2102
|
-
|
|
2103
|
-
|
|
2104
|
-
|
|
2105
|
-
|
|
2106
|
-
|
|
2107
|
-
|
|
2108
|
-
|
|
2109
|
-
|
|
2110
|
-
|
|
2111
|
-
|
|
2112
|
-
|
|
2113
|
-
|
|
2114
|
-
|
|
2115
|
-
|
|
2116
|
-
|
|
2117
|
-
|
|
2118
|
-
|
|
2119
|
-
|
|
2239
|
+
byClientId: new Map(
|
|
2240
|
+
Object.entries( {
|
|
2241
|
+
'group-id': {
|
|
2242
|
+
clientId: 'group-id',
|
|
2243
|
+
name: 'core/group',
|
|
2244
|
+
isValid: true,
|
|
2245
|
+
},
|
|
2246
|
+
'reusable-id': {
|
|
2247
|
+
clientId: 'reusable-id',
|
|
2248
|
+
name: 'core/block',
|
|
2249
|
+
isValid: true,
|
|
2250
|
+
},
|
|
2251
|
+
'paragraph-id': {
|
|
2252
|
+
clientId: 'paragraph-id',
|
|
2253
|
+
name: 'core/paragraph',
|
|
2254
|
+
isValid: true,
|
|
2255
|
+
},
|
|
2256
|
+
} )
|
|
2257
|
+
),
|
|
2258
|
+
order: new Map(
|
|
2259
|
+
Object.entries( {
|
|
2260
|
+
'': [ 'group-id' ],
|
|
2261
|
+
'group-id': [ 'reusable-id' ],
|
|
2262
|
+
'reusable-id': [ 'paragraph-id' ],
|
|
2263
|
+
'paragraph-id': [],
|
|
2264
|
+
} )
|
|
2265
|
+
),
|
|
2120
2266
|
controlledInnerBlocks: {
|
|
2121
2267
|
'reusable-id': true,
|
|
2122
2268
|
},
|
|
2123
|
-
parents:
|
|
2124
|
-
|
|
2125
|
-
|
|
2126
|
-
|
|
2127
|
-
|
|
2128
|
-
|
|
2129
|
-
|
|
2130
|
-
|
|
2131
|
-
|
|
2132
|
-
|
|
2133
|
-
|
|
2134
|
-
|
|
2135
|
-
|
|
2136
|
-
|
|
2137
|
-
|
|
2138
|
-
|
|
2139
|
-
|
|
2269
|
+
parents: new Map(
|
|
2270
|
+
Object.entries( {
|
|
2271
|
+
'group-id': '',
|
|
2272
|
+
'reusable-id': 'group-id',
|
|
2273
|
+
'paragraph-id': 'reusable-id',
|
|
2274
|
+
} )
|
|
2275
|
+
),
|
|
2276
|
+
tree: new Map(
|
|
2277
|
+
Object.entries( {
|
|
2278
|
+
'group-id': {
|
|
2279
|
+
clientId: 'group-id',
|
|
2280
|
+
name: 'core/group',
|
|
2281
|
+
isValid: true,
|
|
2282
|
+
innerBlocks: [
|
|
2283
|
+
{
|
|
2284
|
+
clientId: 'reusable-id',
|
|
2285
|
+
name: 'core/block',
|
|
2286
|
+
isValid: true,
|
|
2287
|
+
attributes: {
|
|
2288
|
+
ref: 687,
|
|
2289
|
+
},
|
|
2290
|
+
innerBlocks: [],
|
|
2140
2291
|
},
|
|
2141
|
-
|
|
2292
|
+
],
|
|
2293
|
+
},
|
|
2294
|
+
'reusable-id': {
|
|
2295
|
+
clientId: 'reusable-id',
|
|
2296
|
+
name: 'core/block',
|
|
2297
|
+
isValid: true,
|
|
2298
|
+
attributes: {
|
|
2299
|
+
ref: 687,
|
|
2142
2300
|
},
|
|
2143
|
-
|
|
2144
|
-
},
|
|
2145
|
-
'reusable-id': {
|
|
2146
|
-
clientId: 'reusable-id',
|
|
2147
|
-
name: 'core/block',
|
|
2148
|
-
isValid: true,
|
|
2149
|
-
attributes: {
|
|
2150
|
-
ref: 687,
|
|
2301
|
+
innerBlocks: [],
|
|
2151
2302
|
},
|
|
2152
|
-
|
|
2153
|
-
|
|
2154
|
-
|
|
2155
|
-
|
|
2156
|
-
|
|
2157
|
-
|
|
2158
|
-
|
|
2159
|
-
|
|
2160
|
-
|
|
2161
|
-
|
|
2162
|
-
|
|
2163
|
-
|
|
2164
|
-
|
|
2165
|
-
|
|
2166
|
-
|
|
2303
|
+
'': {
|
|
2304
|
+
innerBlocks: [
|
|
2305
|
+
{
|
|
2306
|
+
clientId: 'group-id',
|
|
2307
|
+
name: 'core/group',
|
|
2308
|
+
isValid: true,
|
|
2309
|
+
innerBlocks: [
|
|
2310
|
+
{
|
|
2311
|
+
clientId: 'reusable-id',
|
|
2312
|
+
name: 'core/block',
|
|
2313
|
+
isValid: true,
|
|
2314
|
+
attributes: {
|
|
2315
|
+
ref: 687,
|
|
2316
|
+
},
|
|
2317
|
+
innerBlocks: [],
|
|
2167
2318
|
},
|
|
2168
|
-
|
|
2169
|
-
|
|
2170
|
-
|
|
2171
|
-
|
|
2172
|
-
|
|
2173
|
-
|
|
2174
|
-
|
|
2175
|
-
|
|
2176
|
-
|
|
2177
|
-
|
|
2178
|
-
|
|
2179
|
-
|
|
2180
|
-
|
|
2181
|
-
|
|
2182
|
-
|
|
2183
|
-
|
|
2184
|
-
|
|
2185
|
-
|
|
2186
|
-
|
|
2187
|
-
|
|
2188
|
-
|
|
2189
|
-
|
|
2190
|
-
},
|
|
2319
|
+
],
|
|
2320
|
+
},
|
|
2321
|
+
],
|
|
2322
|
+
},
|
|
2323
|
+
'paragraph-id': {
|
|
2324
|
+
clientId: 'paragraph-id',
|
|
2325
|
+
name: 'core/paragraph',
|
|
2326
|
+
isValid: true,
|
|
2327
|
+
innerBlocks: [],
|
|
2328
|
+
},
|
|
2329
|
+
'controlled||reusable-id': {
|
|
2330
|
+
innerBlocks: [
|
|
2331
|
+
{
|
|
2332
|
+
clientId: 'paragraph-id',
|
|
2333
|
+
name: 'core/paragraph',
|
|
2334
|
+
isValid: true,
|
|
2335
|
+
innerBlocks: [],
|
|
2336
|
+
},
|
|
2337
|
+
],
|
|
2338
|
+
},
|
|
2339
|
+
} )
|
|
2340
|
+
),
|
|
2191
2341
|
};
|
|
2192
2342
|
// We will dispatch an action that replaces the inner
|
|
2193
2343
|
// blocks with the same inner blocks, which contain
|
|
@@ -2209,11 +2359,15 @@ describe( 'state', () => {
|
|
|
2209
2359
|
updateSelection: false,
|
|
2210
2360
|
};
|
|
2211
2361
|
const state = blocks( initialState, action );
|
|
2212
|
-
expect( state.order ).toEqual(
|
|
2213
|
-
expect.objectContaining(
|
|
2362
|
+
expect( Object.fromEntries( state.order ) ).toEqual(
|
|
2363
|
+
expect.objectContaining(
|
|
2364
|
+
Object.fromEntries( initialState.order )
|
|
2365
|
+
)
|
|
2214
2366
|
);
|
|
2215
|
-
expect( state.tree ).toEqual(
|
|
2216
|
-
expect.objectContaining(
|
|
2367
|
+
expect( Object.fromEntries( state.tree ) ).toEqual(
|
|
2368
|
+
expect.objectContaining(
|
|
2369
|
+
Object.fromEntries( initialState.tree )
|
|
2370
|
+
)
|
|
2217
2371
|
);
|
|
2218
2372
|
} );
|
|
2219
2373
|
} );
|
|
@@ -2253,6 +2407,24 @@ describe( 'state', () => {
|
|
|
2253
2407
|
} );
|
|
2254
2408
|
} );
|
|
2255
2409
|
|
|
2410
|
+
describe( 'isBlockInterfaceHidden()', () => {
|
|
2411
|
+
it( 'should set the hide block interface flag to true', () => {
|
|
2412
|
+
const state = isBlockInterfaceHidden( false, {
|
|
2413
|
+
type: 'HIDE_BLOCK_INTERFACE',
|
|
2414
|
+
} );
|
|
2415
|
+
|
|
2416
|
+
expect( state ).toBe( true );
|
|
2417
|
+
} );
|
|
2418
|
+
|
|
2419
|
+
it( 'should set the hide block interface flag to false', () => {
|
|
2420
|
+
const state = isBlockInterfaceHidden( false, {
|
|
2421
|
+
type: 'SHOW_BLOCK_INTERFACE',
|
|
2422
|
+
} );
|
|
2423
|
+
|
|
2424
|
+
expect( state ).toBe( false );
|
|
2425
|
+
} );
|
|
2426
|
+
} );
|
|
2427
|
+
|
|
2256
2428
|
describe( 'isTyping()', () => {
|
|
2257
2429
|
it( 'should set the typing flag to true', () => {
|
|
2258
2430
|
const state = isTyping( false, {
|