@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
package/src/store/reducer.js
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* External dependencies
|
|
3
3
|
*/
|
|
4
|
-
import
|
|
4
|
+
import fastDeepEqual from 'fast-deep-equal/es6';
|
|
5
|
+
import { omit, isEmpty } from 'lodash';
|
|
5
6
|
|
|
6
7
|
/**
|
|
7
8
|
* WordPress dependencies
|
|
@@ -28,16 +29,18 @@ const identity = ( x ) => x;
|
|
|
28
29
|
* @return {Object} Block order map object.
|
|
29
30
|
*/
|
|
30
31
|
function mapBlockOrder( blocks, rootClientId = '' ) {
|
|
31
|
-
const result =
|
|
32
|
-
|
|
32
|
+
const result = new Map();
|
|
33
|
+
const current = [];
|
|
34
|
+
result.set( rootClientId, current );
|
|
33
35
|
blocks.forEach( ( block ) => {
|
|
34
36
|
const { clientId, innerBlocks } = block;
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
37
|
+
current.push( clientId );
|
|
38
|
+
mapBlockOrder( innerBlocks, clientId ).forEach(
|
|
39
|
+
( order, subClientId ) => {
|
|
40
|
+
result.set( subClientId, order );
|
|
41
|
+
}
|
|
42
|
+
);
|
|
39
43
|
} );
|
|
40
|
-
|
|
41
44
|
return result;
|
|
42
45
|
}
|
|
43
46
|
|
|
@@ -51,15 +54,18 @@ function mapBlockOrder( blocks, rootClientId = '' ) {
|
|
|
51
54
|
* @return {Object} Block order map object.
|
|
52
55
|
*/
|
|
53
56
|
function mapBlockParents( blocks, rootClientId = '' ) {
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
)
|
|
61
|
-
|
|
62
|
-
|
|
57
|
+
const result = [];
|
|
58
|
+
const stack = [ [ rootClientId, blocks ] ];
|
|
59
|
+
while ( stack.length ) {
|
|
60
|
+
const [ parent, currentBlocks ] = stack.shift();
|
|
61
|
+
currentBlocks.forEach( ( { innerBlocks, ...block } ) => {
|
|
62
|
+
result.push( [ block.clientId, parent ] );
|
|
63
|
+
if ( innerBlocks?.length ) {
|
|
64
|
+
stack.push( [ block.clientId, innerBlocks ] );
|
|
65
|
+
}
|
|
66
|
+
} );
|
|
67
|
+
}
|
|
68
|
+
return result;
|
|
63
69
|
}
|
|
64
70
|
|
|
65
71
|
/**
|
|
@@ -70,16 +76,28 @@ function mapBlockParents( blocks, rootClientId = '' ) {
|
|
|
70
76
|
* @param {Array} blocks Blocks to flatten.
|
|
71
77
|
* @param {Function} transform Transforming function to be applied to each block.
|
|
72
78
|
*
|
|
73
|
-
* @return {
|
|
79
|
+
* @return {Array} Flattened object.
|
|
74
80
|
*/
|
|
75
81
|
function flattenBlocks( blocks, transform = identity ) {
|
|
76
|
-
const result =
|
|
82
|
+
const result = [];
|
|
77
83
|
|
|
78
84
|
const stack = [ ...blocks ];
|
|
79
85
|
while ( stack.length ) {
|
|
80
86
|
const { innerBlocks, ...block } = stack.shift();
|
|
81
87
|
stack.push( ...innerBlocks );
|
|
82
|
-
result[ block.clientId
|
|
88
|
+
result.push( [ block.clientId, transform( block ) ] );
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
return result;
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
function getFlattenedClientIds( blocks ) {
|
|
95
|
+
const result = {};
|
|
96
|
+
const stack = [ ...blocks ];
|
|
97
|
+
while ( stack.length ) {
|
|
98
|
+
const { innerBlocks, ...block } = stack.shift();
|
|
99
|
+
stack.push( ...innerBlocks );
|
|
100
|
+
result[ block.clientId ] = true;
|
|
83
101
|
}
|
|
84
102
|
|
|
85
103
|
return result;
|
|
@@ -92,7 +110,7 @@ function flattenBlocks( blocks, transform = identity ) {
|
|
|
92
110
|
*
|
|
93
111
|
* @param {Array} blocks Blocks to flatten.
|
|
94
112
|
*
|
|
95
|
-
* @return {
|
|
113
|
+
* @return {Array} Flattened block attributes object.
|
|
96
114
|
*/
|
|
97
115
|
function getFlattenedBlocksWithoutAttributes( blocks ) {
|
|
98
116
|
return flattenBlocks( blocks, ( block ) => omit( block, 'attributes' ) );
|
|
@@ -105,29 +123,12 @@ function getFlattenedBlocksWithoutAttributes( blocks ) {
|
|
|
105
123
|
*
|
|
106
124
|
* @param {Array} blocks Blocks to flatten.
|
|
107
125
|
*
|
|
108
|
-
* @return {
|
|
126
|
+
* @return {Array} Flattened block attributes object.
|
|
109
127
|
*/
|
|
110
128
|
function getFlattenedBlockAttributes( blocks ) {
|
|
111
129
|
return flattenBlocks( blocks, ( block ) => block.attributes );
|
|
112
130
|
}
|
|
113
131
|
|
|
114
|
-
/**
|
|
115
|
-
* Returns an object against which it is safe to perform mutating operations,
|
|
116
|
-
* given the original object and its current working copy.
|
|
117
|
-
*
|
|
118
|
-
* @param {Object} original Original object.
|
|
119
|
-
* @param {Object} working Working object.
|
|
120
|
-
*
|
|
121
|
-
* @return {Object} Mutation-safe object.
|
|
122
|
-
*/
|
|
123
|
-
function getMutateSafeObject( original, working ) {
|
|
124
|
-
if ( original === working ) {
|
|
125
|
-
return { ...original };
|
|
126
|
-
}
|
|
127
|
-
|
|
128
|
-
return working;
|
|
129
|
-
}
|
|
130
|
-
|
|
131
132
|
/**
|
|
132
133
|
* Returns true if the two object arguments have the same keys, or false
|
|
133
134
|
* otherwise.
|
|
@@ -138,7 +139,7 @@ function getMutateSafeObject( original, working ) {
|
|
|
138
139
|
* @return {boolean} Whether the two objects have the same keys.
|
|
139
140
|
*/
|
|
140
141
|
export function hasSameKeys( a, b ) {
|
|
141
|
-
return
|
|
142
|
+
return fastDeepEqual( Object.keys( a ), Object.keys( b ) );
|
|
142
143
|
}
|
|
143
144
|
|
|
144
145
|
/**
|
|
@@ -156,13 +157,13 @@ export function isUpdatingSameBlockAttribute( action, lastAction ) {
|
|
|
156
157
|
action.type === 'UPDATE_BLOCK_ATTRIBUTES' &&
|
|
157
158
|
lastAction !== undefined &&
|
|
158
159
|
lastAction.type === 'UPDATE_BLOCK_ATTRIBUTES' &&
|
|
159
|
-
|
|
160
|
+
fastDeepEqual( action.clientIds, lastAction.clientIds ) &&
|
|
160
161
|
hasSameKeys( action.attributes, lastAction.attributes )
|
|
161
162
|
);
|
|
162
163
|
}
|
|
163
164
|
|
|
164
|
-
function
|
|
165
|
-
const
|
|
165
|
+
function updateBlockTreeForBlocks( state, blocks ) {
|
|
166
|
+
const treeToUpdate = state.tree;
|
|
166
167
|
const stack = [ ...blocks ];
|
|
167
168
|
const flattenedBlocks = [ ...blocks ];
|
|
168
169
|
while ( stack.length ) {
|
|
@@ -172,33 +173,34 @@ function buildBlockTree( state, blocks ) {
|
|
|
172
173
|
}
|
|
173
174
|
// Create objects before mutating them, that way it's always defined.
|
|
174
175
|
for ( const block of flattenedBlocks ) {
|
|
175
|
-
|
|
176
|
+
treeToUpdate.set( block.clientId, {} );
|
|
176
177
|
}
|
|
177
178
|
for ( const block of flattenedBlocks ) {
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
(
|
|
183
|
-
|
|
184
|
-
|
|
179
|
+
treeToUpdate.set(
|
|
180
|
+
block.clientId,
|
|
181
|
+
Object.assign( treeToUpdate.get( block.clientId ), {
|
|
182
|
+
...state.byClientId.get( block.clientId ),
|
|
183
|
+
attributes: state.attributes.get( block.clientId ),
|
|
184
|
+
innerBlocks: block.innerBlocks.map( ( subBlock ) =>
|
|
185
|
+
treeToUpdate.get( subBlock.clientId )
|
|
186
|
+
),
|
|
187
|
+
} )
|
|
188
|
+
);
|
|
185
189
|
}
|
|
186
|
-
|
|
187
|
-
return result;
|
|
188
190
|
}
|
|
189
191
|
|
|
190
192
|
function updateParentInnerBlocksInTree(
|
|
191
193
|
state,
|
|
192
|
-
tree,
|
|
193
194
|
updatedClientIds,
|
|
194
195
|
updateChildrenOfUpdatedClientIds = false
|
|
195
196
|
) {
|
|
197
|
+
const treeToUpdate = state.tree;
|
|
196
198
|
const uncontrolledParents = new Set( [] );
|
|
197
199
|
const controlledParents = new Set();
|
|
198
200
|
for ( const clientId of updatedClientIds ) {
|
|
199
201
|
let current = updateChildrenOfUpdatedClientIds
|
|
200
202
|
? clientId
|
|
201
|
-
: state.parents
|
|
203
|
+
: state.parents.get( clientId );
|
|
202
204
|
do {
|
|
203
205
|
if ( state.controlledInnerBlocks[ current ] ) {
|
|
204
206
|
// Should stop on controlled blocks.
|
|
@@ -208,7 +210,7 @@ function updateParentInnerBlocksInTree(
|
|
|
208
210
|
} else {
|
|
209
211
|
// Else continue traversing up through parents.
|
|
210
212
|
uncontrolledParents.add( current );
|
|
211
|
-
current = state.parents
|
|
213
|
+
current = state.parents.get( current );
|
|
212
214
|
}
|
|
213
215
|
} while ( current !== undefined );
|
|
214
216
|
}
|
|
@@ -216,27 +218,23 @@ function updateParentInnerBlocksInTree(
|
|
|
216
218
|
// To make sure the order of assignments doesn't matter,
|
|
217
219
|
// we first create empty objects and mutates the inner blocks later.
|
|
218
220
|
for ( const clientId of uncontrolledParents ) {
|
|
219
|
-
|
|
220
|
-
...tree[ clientId ],
|
|
221
|
-
};
|
|
221
|
+
treeToUpdate.set( clientId, { ...treeToUpdate.get( clientId ) } );
|
|
222
222
|
}
|
|
223
223
|
for ( const clientId of uncontrolledParents ) {
|
|
224
|
-
|
|
225
|
-
(
|
|
226
|
-
);
|
|
224
|
+
treeToUpdate.get( clientId ).innerBlocks = (
|
|
225
|
+
state.order.get( clientId ) || []
|
|
226
|
+
).map( ( subClientId ) => treeToUpdate.get( subClientId ) );
|
|
227
227
|
}
|
|
228
228
|
|
|
229
229
|
// Controlled parent blocks, need a dedicated key for their inner blocks
|
|
230
230
|
// to be used when doing getBlocks( controlledBlockClientId ).
|
|
231
231
|
for ( const clientId of controlledParents ) {
|
|
232
|
-
|
|
233
|
-
innerBlocks: ( state.order
|
|
234
|
-
( subClientId ) =>
|
|
232
|
+
treeToUpdate.set( 'controlled||' + clientId, {
|
|
233
|
+
innerBlocks: ( state.order.get( clientId ) || [] ).map(
|
|
234
|
+
( subClientId ) => treeToUpdate.get( subClientId )
|
|
235
235
|
),
|
|
236
|
-
};
|
|
236
|
+
} );
|
|
237
237
|
}
|
|
238
|
-
|
|
239
|
-
return tree;
|
|
240
238
|
}
|
|
241
239
|
|
|
242
240
|
/**
|
|
@@ -257,82 +255,70 @@ const withBlockTree =
|
|
|
257
255
|
return state;
|
|
258
256
|
}
|
|
259
257
|
|
|
260
|
-
newState.tree = state.tree ? state.tree :
|
|
258
|
+
newState.tree = state.tree ? state.tree : new Map();
|
|
261
259
|
switch ( action.type ) {
|
|
262
260
|
case 'RECEIVE_BLOCKS':
|
|
263
261
|
case 'INSERT_BLOCKS': {
|
|
264
|
-
|
|
265
|
-
newState.
|
|
262
|
+
newState.tree = new Map( newState.tree );
|
|
263
|
+
updateBlockTreeForBlocks( newState, action.blocks );
|
|
264
|
+
updateParentInnerBlocksInTree(
|
|
266
265
|
newState,
|
|
267
|
-
{
|
|
268
|
-
...newState.tree,
|
|
269
|
-
...subTree,
|
|
270
|
-
},
|
|
271
266
|
action.rootClientId ? [ action.rootClientId ] : [ '' ],
|
|
272
267
|
true
|
|
273
268
|
);
|
|
274
269
|
break;
|
|
275
270
|
}
|
|
276
271
|
case 'UPDATE_BLOCK':
|
|
277
|
-
newState.tree =
|
|
272
|
+
newState.tree = new Map( newState.tree );
|
|
273
|
+
newState.tree.set( action.clientId, {
|
|
274
|
+
...newState.tree.get( action.clientId ),
|
|
275
|
+
...newState.byClientId.get( action.clientId ),
|
|
276
|
+
attributes: newState.attributes.get( action.clientId ),
|
|
277
|
+
} );
|
|
278
|
+
updateParentInnerBlocksInTree(
|
|
278
279
|
newState,
|
|
279
|
-
{
|
|
280
|
-
...newState.tree,
|
|
281
|
-
[ action.clientId ]: {
|
|
282
|
-
...newState.tree[ action.clientId ],
|
|
283
|
-
...newState.byClientId[ action.clientId ],
|
|
284
|
-
attributes: newState.attributes[ action.clientId ],
|
|
285
|
-
},
|
|
286
|
-
},
|
|
287
280
|
[ action.clientId ],
|
|
288
281
|
false
|
|
289
282
|
);
|
|
290
283
|
break;
|
|
291
284
|
case 'UPDATE_BLOCK_ATTRIBUTES': {
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
{}
|
|
301
|
-
);
|
|
302
|
-
newState.tree = updateParentInnerBlocksInTree(
|
|
285
|
+
newState.tree = new Map( newState.tree );
|
|
286
|
+
action.clientIds.forEach( ( clientId ) => {
|
|
287
|
+
newState.tree.set( clientId, {
|
|
288
|
+
...newState.tree.get( clientId ),
|
|
289
|
+
attributes: newState.attributes.get( clientId ),
|
|
290
|
+
} );
|
|
291
|
+
} );
|
|
292
|
+
updateParentInnerBlocksInTree(
|
|
303
293
|
newState,
|
|
304
|
-
{
|
|
305
|
-
...newState.tree,
|
|
306
|
-
...newSubTree,
|
|
307
|
-
},
|
|
308
294
|
action.clientIds,
|
|
309
295
|
false
|
|
310
296
|
);
|
|
311
297
|
break;
|
|
312
298
|
}
|
|
313
299
|
case 'REPLACE_BLOCKS_AUGMENTED_WITH_CHILDREN': {
|
|
314
|
-
const
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
( clientId ) => ! subTree[ clientId ]
|
|
327
|
-
)
|
|
328
|
-
.map(
|
|
329
|
-
( clientId ) =>
|
|
330
|
-
'controlled||' + clientId
|
|
331
|
-
)
|
|
300
|
+
const inserterClientIds = getFlattenedClientIds(
|
|
301
|
+
action.blocks
|
|
302
|
+
);
|
|
303
|
+
newState.tree = new Map( newState.tree );
|
|
304
|
+
action.replacedClientIds
|
|
305
|
+
.concat(
|
|
306
|
+
// Controlled inner blocks are only removed
|
|
307
|
+
// if the block doesn't move to another position
|
|
308
|
+
// otherwise their content will be lost.
|
|
309
|
+
action.replacedClientIds
|
|
310
|
+
.filter(
|
|
311
|
+
( clientId ) => ! inserterClientIds[ clientId ]
|
|
332
312
|
)
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
313
|
+
.map( ( clientId ) => 'controlled||' + clientId )
|
|
314
|
+
)
|
|
315
|
+
.forEach( ( key ) => {
|
|
316
|
+
newState.tree.delete( key );
|
|
317
|
+
} );
|
|
318
|
+
|
|
319
|
+
updateBlockTreeForBlocks( newState, action.blocks );
|
|
320
|
+
updateParentInnerBlocksInTree(
|
|
321
|
+
newState,
|
|
336
322
|
action.blocks.map( ( b ) => b.clientId ),
|
|
337
323
|
false
|
|
338
324
|
);
|
|
@@ -341,18 +327,19 @@ const withBlockTree =
|
|
|
341
327
|
const parentsOfRemovedBlocks = [];
|
|
342
328
|
for ( const clientId of action.clientIds ) {
|
|
343
329
|
if (
|
|
344
|
-
state.parents
|
|
345
|
-
( state.parents
|
|
346
|
-
newState.byClientId
|
|
330
|
+
state.parents.get( clientId ) !== undefined &&
|
|
331
|
+
( state.parents.get( clientId ) === '' ||
|
|
332
|
+
newState.byClientId.get(
|
|
333
|
+
state.parents.get( clientId )
|
|
334
|
+
) )
|
|
347
335
|
) {
|
|
348
336
|
parentsOfRemovedBlocks.push(
|
|
349
|
-
state.parents
|
|
337
|
+
state.parents.get( clientId )
|
|
350
338
|
);
|
|
351
339
|
}
|
|
352
340
|
}
|
|
353
|
-
|
|
341
|
+
updateParentInnerBlocksInTree(
|
|
354
342
|
newState,
|
|
355
|
-
newState.tree,
|
|
356
343
|
parentsOfRemovedBlocks,
|
|
357
344
|
true
|
|
358
345
|
);
|
|
@@ -362,25 +349,29 @@ const withBlockTree =
|
|
|
362
349
|
const parentsOfRemovedBlocks = [];
|
|
363
350
|
for ( const clientId of action.clientIds ) {
|
|
364
351
|
if (
|
|
365
|
-
state.parents
|
|
366
|
-
( state.parents
|
|
367
|
-
newState.byClientId
|
|
352
|
+
state.parents.get( clientId ) !== undefined &&
|
|
353
|
+
( state.parents.get( clientId ) === '' ||
|
|
354
|
+
newState.byClientId.get(
|
|
355
|
+
state.parents.get( clientId )
|
|
356
|
+
) )
|
|
368
357
|
) {
|
|
369
358
|
parentsOfRemovedBlocks.push(
|
|
370
|
-
state.parents
|
|
359
|
+
state.parents.get( clientId )
|
|
371
360
|
);
|
|
372
361
|
}
|
|
373
362
|
}
|
|
374
|
-
newState.tree =
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
action.removedClientIds.map(
|
|
380
|
-
( clientId ) => 'controlled||' + clientId
|
|
381
|
-
)
|
|
363
|
+
newState.tree = new Map( newState.tree );
|
|
364
|
+
action.removedClientIds
|
|
365
|
+
.concat(
|
|
366
|
+
action.removedClientIds.map(
|
|
367
|
+
( clientId ) => 'controlled||' + clientId
|
|
382
368
|
)
|
|
383
|
-
)
|
|
369
|
+
)
|
|
370
|
+
.forEach( ( key ) => {
|
|
371
|
+
newState.tree.delete( key );
|
|
372
|
+
} );
|
|
373
|
+
updateParentInnerBlocksInTree(
|
|
374
|
+
newState,
|
|
384
375
|
parentsOfRemovedBlocks,
|
|
385
376
|
true
|
|
386
377
|
);
|
|
@@ -395,9 +386,9 @@ const withBlockTree =
|
|
|
395
386
|
if ( action.toRootClientId ) {
|
|
396
387
|
updatedBlockUids.push( action.toRootClientId );
|
|
397
388
|
}
|
|
398
|
-
newState.tree =
|
|
389
|
+
newState.tree = new Map( newState.tree );
|
|
390
|
+
updateParentInnerBlocksInTree(
|
|
399
391
|
newState,
|
|
400
|
-
newState.tree,
|
|
401
392
|
updatedBlockUids,
|
|
402
393
|
true
|
|
403
394
|
);
|
|
@@ -408,39 +399,35 @@ const withBlockTree =
|
|
|
408
399
|
const updatedBlockUids = [
|
|
409
400
|
action.rootClientId ? action.rootClientId : '',
|
|
410
401
|
];
|
|
411
|
-
newState.tree =
|
|
402
|
+
newState.tree = new Map( newState.tree );
|
|
403
|
+
updateParentInnerBlocksInTree(
|
|
412
404
|
newState,
|
|
413
|
-
newState.tree,
|
|
414
405
|
updatedBlockUids,
|
|
415
406
|
true
|
|
416
407
|
);
|
|
417
408
|
break;
|
|
418
409
|
}
|
|
419
410
|
case 'SAVE_REUSABLE_BLOCK_SUCCESS': {
|
|
420
|
-
const updatedBlockUids =
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
newState.tree =
|
|
411
|
+
const updatedBlockUids = [];
|
|
412
|
+
newState.attributes.forEach( ( attributes, clientId ) => {
|
|
413
|
+
if (
|
|
414
|
+
newState.byClientId.get( clientId ).name ===
|
|
415
|
+
'core/block' &&
|
|
416
|
+
attributes.ref === action.updatedId
|
|
417
|
+
) {
|
|
418
|
+
updatedBlockUids.push( clientId );
|
|
419
|
+
}
|
|
420
|
+
} );
|
|
421
|
+
newState.tree = new Map( newState.tree );
|
|
422
|
+
updatedBlockUids.forEach( ( clientId ) => {
|
|
423
|
+
newState.tree.set( clientId, {
|
|
424
|
+
...newState.byClientId.get( clientId ),
|
|
425
|
+
attributes: newState.attributes.get( clientId ),
|
|
426
|
+
innerBlocks: newState.tree.get( clientId ).innerBlocks,
|
|
427
|
+
} );
|
|
428
|
+
} );
|
|
429
|
+
updateParentInnerBlocksInTree(
|
|
431
430
|
newState,
|
|
432
|
-
{
|
|
433
|
-
...newState.tree,
|
|
434
|
-
...updatedBlockUids.reduce( ( result, clientId ) => {
|
|
435
|
-
result[ clientId ] = {
|
|
436
|
-
...newState.byClientId[ clientId ],
|
|
437
|
-
attributes: newState.attributes[ clientId ],
|
|
438
|
-
innerBlocks:
|
|
439
|
-
newState.tree[ clientId ].innerBlocks,
|
|
440
|
-
};
|
|
441
|
-
return result;
|
|
442
|
-
}, {} ),
|
|
443
|
-
},
|
|
444
431
|
updatedBlockUids,
|
|
445
432
|
false
|
|
446
433
|
);
|
|
@@ -549,7 +536,7 @@ const withInnerBlocksRemoveCascade = ( reducer ) => ( state, action ) => {
|
|
|
549
536
|
let result = clientIds;
|
|
550
537
|
for ( let i = 0; i < result.length; i++ ) {
|
|
551
538
|
if (
|
|
552
|
-
! state.order
|
|
539
|
+
! state.order.get( result[ i ] ) ||
|
|
553
540
|
( action.keepControlledInnerBlocks &&
|
|
554
541
|
action.keepControlledInnerBlocks[ result[ i ] ] )
|
|
555
542
|
) {
|
|
@@ -560,7 +547,7 @@ const withInnerBlocksRemoveCascade = ( reducer ) => ( state, action ) => {
|
|
|
560
547
|
result = [ ...result ];
|
|
561
548
|
}
|
|
562
549
|
|
|
563
|
-
result.push( ...state.order
|
|
550
|
+
result.push( ...state.order.get( result[ i ] ) );
|
|
564
551
|
}
|
|
565
552
|
return result;
|
|
566
553
|
};
|
|
@@ -601,23 +588,22 @@ const withBlockReset = ( reducer ) => ( state, action ) => {
|
|
|
601
588
|
if ( action.type === 'RESET_BLOCKS' ) {
|
|
602
589
|
const newState = {
|
|
603
590
|
...state,
|
|
604
|
-
byClientId:
|
|
605
|
-
|
|
591
|
+
byClientId: new Map(
|
|
592
|
+
getFlattenedBlocksWithoutAttributes( action.blocks )
|
|
593
|
+
),
|
|
594
|
+
attributes: new Map( getFlattenedBlockAttributes( action.blocks ) ),
|
|
606
595
|
order: mapBlockOrder( action.blocks ),
|
|
607
|
-
parents: mapBlockParents( action.blocks ),
|
|
596
|
+
parents: new Map( mapBlockParents( action.blocks ) ),
|
|
608
597
|
controlledInnerBlocks: {},
|
|
609
598
|
};
|
|
610
599
|
|
|
611
|
-
|
|
612
|
-
newState.
|
|
613
|
-
|
|
614
|
-
|
|
615
|
-
|
|
616
|
-
|
|
617
|
-
|
|
618
|
-
),
|
|
619
|
-
},
|
|
620
|
-
};
|
|
600
|
+
newState.tree = new Map( state?.tree );
|
|
601
|
+
updateBlockTreeForBlocks( newState, action.blocks );
|
|
602
|
+
newState.tree.set( '', {
|
|
603
|
+
innerBlocks: action.blocks.map( ( subBlock ) =>
|
|
604
|
+
newState.tree.get( subBlock.clientId )
|
|
605
|
+
),
|
|
606
|
+
} );
|
|
621
607
|
|
|
622
608
|
return newState;
|
|
623
609
|
}
|
|
@@ -663,11 +649,11 @@ const withReplaceInnerBlocks = ( reducer ) => ( state, action ) => {
|
|
|
663
649
|
// marked block in the block state so that they can be reattached to the
|
|
664
650
|
// marked block when we re-insert everything a few lines below.
|
|
665
651
|
let stateAfterBlocksRemoval = state;
|
|
666
|
-
if ( state.order
|
|
652
|
+
if ( state.order.get( action.rootClientId ) ) {
|
|
667
653
|
stateAfterBlocksRemoval = reducer( stateAfterBlocksRemoval, {
|
|
668
654
|
type: 'REMOVE_BLOCKS',
|
|
669
655
|
keepControlledInnerBlocks: nestedControllers,
|
|
670
|
-
clientIds: state.order
|
|
656
|
+
clientIds: state.order.get( action.rootClientId ),
|
|
671
657
|
} );
|
|
672
658
|
}
|
|
673
659
|
let stateAfterInsert = stateAfterBlocksRemoval;
|
|
@@ -681,33 +667,20 @@ const withReplaceInnerBlocks = ( reducer ) => ( state, action ) => {
|
|
|
681
667
|
// We need to re-attach the controlled inner blocks to the blocks tree and
|
|
682
668
|
// preserve their block order. Otherwise, an inner block controller's blocks
|
|
683
669
|
// will be deleted entirely from its entity.
|
|
684
|
-
stateAfterInsert.order
|
|
685
|
-
|
|
686
|
-
|
|
687
|
-
|
|
688
|
-
|
|
689
|
-
|
|
690
|
-
|
|
691
|
-
|
|
692
|
-
|
|
693
|
-
|
|
694
|
-
|
|
695
|
-
|
|
696
|
-
|
|
697
|
-
|
|
698
|
-
...stateAfterInsert.tree,
|
|
699
|
-
...reduce(
|
|
700
|
-
nestedControllers,
|
|
701
|
-
( result, value, _key ) => {
|
|
702
|
-
const key = `controlled||${ _key }`;
|
|
703
|
-
if ( state.tree[ key ] ) {
|
|
704
|
-
result[ key ] = state.tree[ key ];
|
|
705
|
-
}
|
|
706
|
-
return result;
|
|
707
|
-
},
|
|
708
|
-
{}
|
|
709
|
-
),
|
|
710
|
-
};
|
|
670
|
+
const stateAfterInsertOrder = new Map( stateAfterInsert.order );
|
|
671
|
+
Object.keys( nestedControllers ).forEach( ( key ) => {
|
|
672
|
+
if ( state.order.get( key ) ) {
|
|
673
|
+
stateAfterInsertOrder.set( key, state.order.get( key ) );
|
|
674
|
+
}
|
|
675
|
+
} );
|
|
676
|
+
stateAfterInsert.order = stateAfterInsertOrder;
|
|
677
|
+
stateAfterInsert.tree = new Map( stateAfterInsert.tree );
|
|
678
|
+
Object.keys( nestedControllers ).forEach( ( _key ) => {
|
|
679
|
+
const key = `controlled||${ _key }`;
|
|
680
|
+
if ( state.tree.has( key ) ) {
|
|
681
|
+
stateAfterInsert.tree.set( key, state.tree.get( key ) );
|
|
682
|
+
}
|
|
683
|
+
} );
|
|
711
684
|
}
|
|
712
685
|
return stateAfterInsert;
|
|
713
686
|
};
|
|
@@ -732,21 +705,16 @@ const withSaveReusableBlock = ( reducer ) => ( state, action ) => {
|
|
|
732
705
|
}
|
|
733
706
|
|
|
734
707
|
state = { ...state };
|
|
735
|
-
|
|
736
|
-
state.attributes
|
|
737
|
-
state.
|
|
738
|
-
( attributes
|
|
739
|
-
|
|
740
|
-
|
|
741
|
-
|
|
742
|
-
|
|
743
|
-
ref: updatedId,
|
|
744
|
-
};
|
|
745
|
-
}
|
|
746
|
-
|
|
747
|
-
return attributes;
|
|
708
|
+
state.attributes = new Map( state.attributes );
|
|
709
|
+
state.attributes.forEach( ( attributes, clientId ) => {
|
|
710
|
+
const { name } = state.byClientId.get( clientId );
|
|
711
|
+
if ( name === 'core/block' && attributes.ref === id ) {
|
|
712
|
+
state.attributes.set( clientId, {
|
|
713
|
+
...attributes,
|
|
714
|
+
ref: updatedId,
|
|
715
|
+
} );
|
|
748
716
|
}
|
|
749
|
-
);
|
|
717
|
+
} );
|
|
750
718
|
}
|
|
751
719
|
|
|
752
720
|
return reducer( state, action );
|
|
@@ -792,18 +760,24 @@ export const blocks = pipe(
|
|
|
792
760
|
withIgnoredBlockChange,
|
|
793
761
|
withResetControlledBlocks
|
|
794
762
|
)( {
|
|
795
|
-
|
|
763
|
+
// The state is using a Map instead of a plain object for performance reasons.
|
|
764
|
+
// You can run the "./test/performance.js" unit test to check the impact
|
|
765
|
+
// code changes can have on this reducer.
|
|
766
|
+
byClientId( state = new Map(), action ) {
|
|
796
767
|
switch ( action.type ) {
|
|
797
768
|
case 'RECEIVE_BLOCKS':
|
|
798
|
-
case 'INSERT_BLOCKS':
|
|
799
|
-
|
|
800
|
-
|
|
801
|
-
|
|
802
|
-
|
|
803
|
-
|
|
804
|
-
|
|
769
|
+
case 'INSERT_BLOCKS': {
|
|
770
|
+
const newState = new Map( state );
|
|
771
|
+
getFlattenedBlocksWithoutAttributes( action.blocks ).forEach(
|
|
772
|
+
( [ key, value ] ) => {
|
|
773
|
+
newState.set( key, value );
|
|
774
|
+
}
|
|
775
|
+
);
|
|
776
|
+
return newState;
|
|
777
|
+
}
|
|
778
|
+
case 'UPDATE_BLOCK': {
|
|
805
779
|
// Ignore updates if block isn't known.
|
|
806
|
-
if ( ! state
|
|
780
|
+
if ( ! state.has( action.clientId ) ) {
|
|
807
781
|
return state;
|
|
808
782
|
}
|
|
809
783
|
|
|
@@ -813,144 +787,184 @@ export const blocks = pipe(
|
|
|
813
787
|
return state;
|
|
814
788
|
}
|
|
815
789
|
|
|
816
|
-
|
|
817
|
-
|
|
818
|
-
|
|
819
|
-
|
|
820
|
-
|
|
821
|
-
|
|
822
|
-
|
|
790
|
+
const newState = new Map( state );
|
|
791
|
+
newState.set( action.clientId, {
|
|
792
|
+
...state.get( action.clientId ),
|
|
793
|
+
...changes,
|
|
794
|
+
} );
|
|
795
|
+
return newState;
|
|
796
|
+
}
|
|
823
797
|
|
|
824
|
-
case 'REPLACE_BLOCKS_AUGMENTED_WITH_CHILDREN':
|
|
798
|
+
case 'REPLACE_BLOCKS_AUGMENTED_WITH_CHILDREN': {
|
|
825
799
|
if ( ! action.blocks ) {
|
|
826
800
|
return state;
|
|
827
801
|
}
|
|
828
802
|
|
|
829
|
-
|
|
830
|
-
|
|
831
|
-
|
|
832
|
-
};
|
|
803
|
+
const newState = new Map( state );
|
|
804
|
+
action.replacedClientIds.forEach( ( clientId ) => {
|
|
805
|
+
newState.delete( clientId );
|
|
806
|
+
} );
|
|
833
807
|
|
|
834
|
-
|
|
835
|
-
|
|
808
|
+
getFlattenedBlocksWithoutAttributes( action.blocks ).forEach(
|
|
809
|
+
( [ key, value ] ) => {
|
|
810
|
+
newState.set( key, value );
|
|
811
|
+
}
|
|
812
|
+
);
|
|
813
|
+
return newState;
|
|
814
|
+
}
|
|
815
|
+
|
|
816
|
+
case 'REMOVE_BLOCKS_AUGMENTED_WITH_CHILDREN': {
|
|
817
|
+
const newState = new Map( state );
|
|
818
|
+
action.removedClientIds.forEach( ( clientId ) => {
|
|
819
|
+
newState.delete( clientId );
|
|
820
|
+
} );
|
|
821
|
+
return newState;
|
|
822
|
+
}
|
|
836
823
|
}
|
|
837
824
|
|
|
838
825
|
return state;
|
|
839
826
|
},
|
|
840
827
|
|
|
841
|
-
|
|
828
|
+
// The state is using a Map instead of a plain object for performance reasons.
|
|
829
|
+
// You can run the "./test/performance.js" unit test to check the impact
|
|
830
|
+
// code changes can have on this reducer.
|
|
831
|
+
attributes( state = new Map(), action ) {
|
|
842
832
|
switch ( action.type ) {
|
|
843
833
|
case 'RECEIVE_BLOCKS':
|
|
844
|
-
case 'INSERT_BLOCKS':
|
|
845
|
-
|
|
846
|
-
|
|
847
|
-
|
|
848
|
-
|
|
834
|
+
case 'INSERT_BLOCKS': {
|
|
835
|
+
const newState = new Map( state );
|
|
836
|
+
getFlattenedBlockAttributes( action.blocks ).forEach(
|
|
837
|
+
( [ key, value ] ) => {
|
|
838
|
+
newState.set( key, value );
|
|
839
|
+
}
|
|
840
|
+
);
|
|
841
|
+
return newState;
|
|
842
|
+
}
|
|
849
843
|
|
|
850
|
-
case 'UPDATE_BLOCK':
|
|
844
|
+
case 'UPDATE_BLOCK': {
|
|
851
845
|
// Ignore updates if block isn't known or there are no attribute changes.
|
|
852
846
|
if (
|
|
853
|
-
! state
|
|
847
|
+
! state.get( action.clientId ) ||
|
|
854
848
|
! action.updates.attributes
|
|
855
849
|
) {
|
|
856
850
|
return state;
|
|
857
851
|
}
|
|
858
852
|
|
|
859
|
-
|
|
860
|
-
|
|
861
|
-
|
|
862
|
-
|
|
863
|
-
|
|
864
|
-
|
|
865
|
-
|
|
853
|
+
const newState = new Map( state );
|
|
854
|
+
newState.set( action.clientId, {
|
|
855
|
+
...state.get( action.clientId ),
|
|
856
|
+
...action.updates.attributes,
|
|
857
|
+
} );
|
|
858
|
+
return newState;
|
|
859
|
+
}
|
|
866
860
|
|
|
867
861
|
case 'UPDATE_BLOCK_ATTRIBUTES': {
|
|
868
862
|
// Avoid a state change if none of the block IDs are known.
|
|
869
|
-
if ( action.clientIds.every( ( id ) => ! state
|
|
863
|
+
if ( action.clientIds.every( ( id ) => ! state.get( id ) ) ) {
|
|
870
864
|
return state;
|
|
871
865
|
}
|
|
872
866
|
|
|
873
|
-
|
|
874
|
-
|
|
875
|
-
|
|
876
|
-
|
|
877
|
-
|
|
878
|
-
|
|
879
|
-
|
|
880
|
-
|
|
881
|
-
|
|
882
|
-
|
|
883
|
-
|
|
884
|
-
|
|
885
|
-
|
|
886
|
-
|
|
887
|
-
|
|
888
|
-
|
|
889
|
-
|
|
890
|
-
|
|
891
|
-
|
|
892
|
-
|
|
893
|
-
|
|
894
|
-
|
|
895
|
-
|
|
896
|
-
|
|
897
|
-
|
|
898
|
-
|
|
899
|
-
|
|
900
|
-
( id ) => next[ id ] === state[ id ]
|
|
901
|
-
)
|
|
902
|
-
) {
|
|
903
|
-
return state;
|
|
867
|
+
let hasChange = false;
|
|
868
|
+
const newState = new Map( state );
|
|
869
|
+
for ( const clientId of action.clientIds ) {
|
|
870
|
+
const updatedAttributeEntries = Object.entries(
|
|
871
|
+
action.uniqueByBlock
|
|
872
|
+
? action.attributes[ clientId ]
|
|
873
|
+
: action.attributes ?? {}
|
|
874
|
+
);
|
|
875
|
+
if ( updatedAttributeEntries.length === 0 ) {
|
|
876
|
+
continue;
|
|
877
|
+
}
|
|
878
|
+
let hasUpdatedAttributes = false;
|
|
879
|
+
const existingAttributes = state.get( clientId );
|
|
880
|
+
const newAttributes = {};
|
|
881
|
+
updatedAttributeEntries.forEach( ( [ key, value ] ) => {
|
|
882
|
+
if ( existingAttributes[ key ] !== value ) {
|
|
883
|
+
hasUpdatedAttributes = true;
|
|
884
|
+
newAttributes[ key ] = value;
|
|
885
|
+
}
|
|
886
|
+
} );
|
|
887
|
+
hasChange = hasChange || hasUpdatedAttributes;
|
|
888
|
+
if ( hasUpdatedAttributes ) {
|
|
889
|
+
newState.set( clientId, {
|
|
890
|
+
...existingAttributes,
|
|
891
|
+
...newAttributes,
|
|
892
|
+
} );
|
|
893
|
+
}
|
|
904
894
|
}
|
|
905
895
|
|
|
906
|
-
return
|
|
896
|
+
return hasChange ? newState : state;
|
|
907
897
|
}
|
|
908
898
|
|
|
909
|
-
case 'REPLACE_BLOCKS_AUGMENTED_WITH_CHILDREN':
|
|
899
|
+
case 'REPLACE_BLOCKS_AUGMENTED_WITH_CHILDREN': {
|
|
910
900
|
if ( ! action.blocks ) {
|
|
911
901
|
return state;
|
|
912
902
|
}
|
|
913
903
|
|
|
914
|
-
|
|
915
|
-
|
|
916
|
-
|
|
917
|
-
};
|
|
904
|
+
const newState = new Map( state );
|
|
905
|
+
action.replacedClientIds.forEach( ( clientId ) => {
|
|
906
|
+
newState.delete( clientId );
|
|
907
|
+
} );
|
|
908
|
+
getFlattenedBlockAttributes( action.blocks ).forEach(
|
|
909
|
+
( [ key, value ] ) => {
|
|
910
|
+
newState.set( key, value );
|
|
911
|
+
}
|
|
912
|
+
);
|
|
913
|
+
return newState;
|
|
914
|
+
}
|
|
918
915
|
|
|
919
|
-
case 'REMOVE_BLOCKS_AUGMENTED_WITH_CHILDREN':
|
|
920
|
-
|
|
916
|
+
case 'REMOVE_BLOCKS_AUGMENTED_WITH_CHILDREN': {
|
|
917
|
+
const newState = new Map( state );
|
|
918
|
+
action.removedClientIds.forEach( ( clientId ) => {
|
|
919
|
+
newState.delete( clientId );
|
|
920
|
+
} );
|
|
921
|
+
return newState;
|
|
922
|
+
}
|
|
921
923
|
}
|
|
922
924
|
|
|
923
925
|
return state;
|
|
924
926
|
},
|
|
925
927
|
|
|
926
|
-
|
|
928
|
+
// The state is using a Map instead of a plain object for performance reasons.
|
|
929
|
+
// You can run the "./test/performance.js" unit test to check the impact
|
|
930
|
+
// code changes can have on this reducer.
|
|
931
|
+
order( state = new Map(), action ) {
|
|
927
932
|
switch ( action.type ) {
|
|
928
933
|
case 'RECEIVE_BLOCKS': {
|
|
929
934
|
const blockOrder = mapBlockOrder( action.blocks );
|
|
930
|
-
|
|
931
|
-
|
|
932
|
-
|
|
933
|
-
|
|
934
|
-
|
|
935
|
+
const newState = new Map( state );
|
|
936
|
+
blockOrder.forEach( ( order, clientId ) => {
|
|
937
|
+
if ( clientId !== '' ) {
|
|
938
|
+
newState.set( clientId, order );
|
|
939
|
+
}
|
|
940
|
+
} );
|
|
941
|
+
newState.set(
|
|
942
|
+
'',
|
|
943
|
+
( state.get( '' ) ?? [] ).concat( blockOrder[ '' ] )
|
|
944
|
+
);
|
|
945
|
+
return newState;
|
|
935
946
|
}
|
|
936
947
|
case 'INSERT_BLOCKS': {
|
|
937
948
|
const { rootClientId = '' } = action;
|
|
938
|
-
const subState = state
|
|
949
|
+
const subState = state.get( rootClientId ) || [];
|
|
939
950
|
const mappedBlocks = mapBlockOrder(
|
|
940
951
|
action.blocks,
|
|
941
952
|
rootClientId
|
|
942
953
|
);
|
|
943
954
|
const { index = subState.length } = action;
|
|
944
|
-
|
|
945
|
-
|
|
946
|
-
|
|
947
|
-
|
|
948
|
-
|
|
955
|
+
const newState = new Map( state );
|
|
956
|
+
mappedBlocks.forEach( ( order, clientId ) => {
|
|
957
|
+
newState.set( clientId, order );
|
|
958
|
+
} );
|
|
959
|
+
newState.set(
|
|
960
|
+
rootClientId,
|
|
961
|
+
insertAt(
|
|
949
962
|
subState,
|
|
950
|
-
mappedBlocks
|
|
963
|
+
mappedBlocks.get( rootClientId ),
|
|
951
964
|
index
|
|
952
|
-
)
|
|
953
|
-
|
|
965
|
+
)
|
|
966
|
+
);
|
|
967
|
+
return newState;
|
|
954
968
|
}
|
|
955
969
|
|
|
956
970
|
case 'MOVE_BLOCKS_TO_POSITION': {
|
|
@@ -959,65 +973,68 @@ export const blocks = pipe(
|
|
|
959
973
|
toRootClientId = '',
|
|
960
974
|
clientIds,
|
|
961
975
|
} = action;
|
|
962
|
-
const { index = state
|
|
976
|
+
const { index = state.get( toRootClientId ).length } = action;
|
|
963
977
|
|
|
964
978
|
// Moving inside the same parent block.
|
|
965
979
|
if ( fromRootClientId === toRootClientId ) {
|
|
966
|
-
const subState = state
|
|
980
|
+
const subState = state.get( toRootClientId );
|
|
967
981
|
const fromIndex = subState.indexOf( clientIds[ 0 ] );
|
|
968
|
-
|
|
969
|
-
|
|
970
|
-
|
|
971
|
-
|
|
982
|
+
const newState = new Map( state );
|
|
983
|
+
newState.set(
|
|
984
|
+
toRootClientId,
|
|
985
|
+
moveTo(
|
|
986
|
+
state.get( toRootClientId ),
|
|
972
987
|
fromIndex,
|
|
973
988
|
index,
|
|
974
989
|
clientIds.length
|
|
975
|
-
)
|
|
976
|
-
|
|
990
|
+
)
|
|
991
|
+
);
|
|
992
|
+
return newState;
|
|
977
993
|
}
|
|
978
994
|
|
|
979
995
|
// Moving from a parent block to another.
|
|
980
|
-
|
|
981
|
-
|
|
982
|
-
|
|
983
|
-
|
|
984
|
-
|
|
985
|
-
) ?? []
|
|
986
|
-
|
|
987
|
-
|
|
988
|
-
|
|
989
|
-
|
|
990
|
-
|
|
991
|
-
|
|
996
|
+
const newState = new Map( state );
|
|
997
|
+
newState.set(
|
|
998
|
+
fromRootClientId,
|
|
999
|
+
state
|
|
1000
|
+
.get( fromRootClientId )
|
|
1001
|
+
?.filter( ( id ) => ! clientIds.includes( id ) ) ?? []
|
|
1002
|
+
);
|
|
1003
|
+
newState.set(
|
|
1004
|
+
toRootClientId,
|
|
1005
|
+
insertAt( state.get( toRootClientId ), clientIds, index )
|
|
1006
|
+
);
|
|
1007
|
+
return newState;
|
|
992
1008
|
}
|
|
993
1009
|
|
|
994
1010
|
case 'MOVE_BLOCKS_UP': {
|
|
995
1011
|
const { clientIds, rootClientId = '' } = action;
|
|
996
1012
|
const firstClientId = clientIds[ 0 ];
|
|
997
|
-
const subState = state
|
|
1013
|
+
const subState = state.get( rootClientId );
|
|
998
1014
|
|
|
999
1015
|
if ( ! subState.length || firstClientId === subState[ 0 ] ) {
|
|
1000
1016
|
return state;
|
|
1001
1017
|
}
|
|
1002
1018
|
|
|
1003
1019
|
const firstIndex = subState.indexOf( firstClientId );
|
|
1004
|
-
|
|
1005
|
-
|
|
1006
|
-
|
|
1007
|
-
|
|
1020
|
+
const newState = new Map( state );
|
|
1021
|
+
newState.set(
|
|
1022
|
+
rootClientId,
|
|
1023
|
+
moveTo(
|
|
1008
1024
|
subState,
|
|
1009
1025
|
firstIndex,
|
|
1010
1026
|
firstIndex - 1,
|
|
1011
1027
|
clientIds.length
|
|
1012
|
-
)
|
|
1013
|
-
|
|
1028
|
+
)
|
|
1029
|
+
);
|
|
1030
|
+
return newState;
|
|
1014
1031
|
}
|
|
1015
1032
|
|
|
1016
1033
|
case 'MOVE_BLOCKS_DOWN': {
|
|
1017
1034
|
const { clientIds, rootClientId = '' } = action;
|
|
1018
1035
|
const firstClientId = clientIds[ 0 ];
|
|
1019
1036
|
const lastClientId = clientIds[ clientIds.length - 1 ];
|
|
1020
|
-
const subState = state
|
|
1037
|
+
const subState = state.get( rootClientId );
|
|
1021
1038
|
|
|
1022
1039
|
if (
|
|
1023
1040
|
! subState.length ||
|
|
@@ -1027,16 +1044,17 @@ export const blocks = pipe(
|
|
|
1027
1044
|
}
|
|
1028
1045
|
|
|
1029
1046
|
const firstIndex = subState.indexOf( firstClientId );
|
|
1030
|
-
|
|
1031
|
-
|
|
1032
|
-
|
|
1033
|
-
|
|
1047
|
+
const newState = new Map( state );
|
|
1048
|
+
newState.set(
|
|
1049
|
+
rootClientId,
|
|
1050
|
+
moveTo(
|
|
1034
1051
|
subState,
|
|
1035
1052
|
firstIndex,
|
|
1036
1053
|
firstIndex + 1,
|
|
1037
1054
|
clientIds.length
|
|
1038
|
-
)
|
|
1039
|
-
|
|
1055
|
+
)
|
|
1056
|
+
);
|
|
1057
|
+
return newState;
|
|
1040
1058
|
}
|
|
1041
1059
|
|
|
1042
1060
|
case 'REPLACE_BLOCKS_AUGMENTED_WITH_CHILDREN': {
|
|
@@ -1046,56 +1064,52 @@ export const blocks = pipe(
|
|
|
1046
1064
|
}
|
|
1047
1065
|
|
|
1048
1066
|
const mappedBlocks = mapBlockOrder( action.blocks );
|
|
1067
|
+
const newState = new Map( state );
|
|
1068
|
+
action.replacedClientIds.forEach( ( clientId ) => {
|
|
1069
|
+
newState.delete( clientId );
|
|
1070
|
+
} );
|
|
1071
|
+
mappedBlocks.forEach( ( order, clientId ) => {
|
|
1072
|
+
if ( clientId !== '' ) {
|
|
1073
|
+
newState.set( clientId, order );
|
|
1074
|
+
}
|
|
1075
|
+
} );
|
|
1076
|
+
newState.forEach( ( order, clientId ) => {
|
|
1077
|
+
const newSubOrder = Object.values( order ).reduce(
|
|
1078
|
+
( result, subClientId ) => {
|
|
1079
|
+
if ( subClientId === clientIds[ 0 ] ) {
|
|
1080
|
+
return [ ...result, ...mappedBlocks.get( '' ) ];
|
|
1081
|
+
}
|
|
1082
|
+
|
|
1083
|
+
if ( clientIds.indexOf( subClientId ) === -1 ) {
|
|
1084
|
+
result.push( subClientId );
|
|
1085
|
+
}
|
|
1049
1086
|
|
|
1050
|
-
|
|
1051
|
-
|
|
1052
|
-
|
|
1053
|
-
|
|
1054
|
-
|
|
1055
|
-
|
|
1056
|
-
|
|
1057
|
-
( nextState ) =>
|
|
1058
|
-
mapValues( nextState, ( subState ) =>
|
|
1059
|
-
reduce(
|
|
1060
|
-
subState,
|
|
1061
|
-
( result, clientId ) => {
|
|
1062
|
-
if ( clientId === clientIds[ 0 ] ) {
|
|
1063
|
-
return [
|
|
1064
|
-
...result,
|
|
1065
|
-
...mappedBlocks[ '' ],
|
|
1066
|
-
];
|
|
1067
|
-
}
|
|
1068
|
-
|
|
1069
|
-
if (
|
|
1070
|
-
clientIds.indexOf( clientId ) === -1
|
|
1071
|
-
) {
|
|
1072
|
-
result.push( clientId );
|
|
1073
|
-
}
|
|
1074
|
-
|
|
1075
|
-
return result;
|
|
1076
|
-
},
|
|
1077
|
-
[]
|
|
1078
|
-
)
|
|
1079
|
-
),
|
|
1080
|
-
] )( state );
|
|
1087
|
+
return result;
|
|
1088
|
+
},
|
|
1089
|
+
[]
|
|
1090
|
+
);
|
|
1091
|
+
newState.set( clientId, newSubOrder );
|
|
1092
|
+
} );
|
|
1093
|
+
return newState;
|
|
1081
1094
|
}
|
|
1082
1095
|
|
|
1083
|
-
case 'REMOVE_BLOCKS_AUGMENTED_WITH_CHILDREN':
|
|
1084
|
-
|
|
1085
|
-
|
|
1086
|
-
|
|
1087
|
-
|
|
1088
|
-
|
|
1089
|
-
|
|
1090
|
-
|
|
1091
|
-
|
|
1092
|
-
(
|
|
1093
|
-
|
|
1094
|
-
|
|
1095
|
-
|
|
1096
|
-
|
|
1097
|
-
|
|
1098
|
-
|
|
1096
|
+
case 'REMOVE_BLOCKS_AUGMENTED_WITH_CHILDREN': {
|
|
1097
|
+
const newState = new Map( state );
|
|
1098
|
+
// Remove inner block ordering for removed blocks.
|
|
1099
|
+
action.removedClientIds.forEach( ( clientId ) => {
|
|
1100
|
+
newState.delete( clientId );
|
|
1101
|
+
} );
|
|
1102
|
+
newState.forEach( ( order, clientId ) => {
|
|
1103
|
+
const newSubOrder =
|
|
1104
|
+
order?.filter(
|
|
1105
|
+
( id ) => ! action.removedClientIds.includes( id )
|
|
1106
|
+
) ?? [];
|
|
1107
|
+
if ( newSubOrder.length !== order.length ) {
|
|
1108
|
+
newState.set( clientId, newSubOrder );
|
|
1109
|
+
}
|
|
1110
|
+
} );
|
|
1111
|
+
return newState;
|
|
1112
|
+
}
|
|
1099
1113
|
}
|
|
1100
1114
|
|
|
1101
1115
|
return state;
|
|
@@ -1103,44 +1117,55 @@ export const blocks = pipe(
|
|
|
1103
1117
|
|
|
1104
1118
|
// While technically redundant data as the inverse of `order`, it serves as
|
|
1105
1119
|
// an optimization for the selectors which derive the ancestry of a block.
|
|
1106
|
-
parents( state =
|
|
1120
|
+
parents( state = new Map(), action ) {
|
|
1107
1121
|
switch ( action.type ) {
|
|
1108
|
-
case 'RECEIVE_BLOCKS':
|
|
1109
|
-
|
|
1110
|
-
|
|
1111
|
-
|
|
1112
|
-
|
|
1113
|
-
|
|
1114
|
-
|
|
1115
|
-
return
|
|
1116
|
-
|
|
1117
|
-
|
|
1118
|
-
|
|
1119
|
-
|
|
1120
|
-
|
|
1121
|
-
|
|
1122
|
-
|
|
1122
|
+
case 'RECEIVE_BLOCKS': {
|
|
1123
|
+
const newState = new Map( state );
|
|
1124
|
+
mapBlockParents( action.blocks ).forEach(
|
|
1125
|
+
( [ key, value ] ) => {
|
|
1126
|
+
newState.set( key, value );
|
|
1127
|
+
}
|
|
1128
|
+
);
|
|
1129
|
+
return newState;
|
|
1130
|
+
}
|
|
1131
|
+
case 'INSERT_BLOCKS': {
|
|
1132
|
+
const newState = new Map( state );
|
|
1133
|
+
mapBlockParents(
|
|
1134
|
+
action.blocks,
|
|
1135
|
+
action.rootClientId || ''
|
|
1136
|
+
).forEach( ( [ key, value ] ) => {
|
|
1137
|
+
newState.set( key, value );
|
|
1138
|
+
} );
|
|
1139
|
+
return newState;
|
|
1140
|
+
}
|
|
1123
1141
|
case 'MOVE_BLOCKS_TO_POSITION': {
|
|
1124
|
-
|
|
1125
|
-
|
|
1126
|
-
|
|
1127
|
-
|
|
1128
|
-
|
|
1129
|
-
}, {} ),
|
|
1130
|
-
};
|
|
1142
|
+
const newState = new Map( state );
|
|
1143
|
+
action.clientIds.forEach( ( id ) => {
|
|
1144
|
+
newState.set( id, action.toRootClientId || '' );
|
|
1145
|
+
} );
|
|
1146
|
+
return newState;
|
|
1131
1147
|
}
|
|
1132
1148
|
|
|
1133
|
-
case 'REPLACE_BLOCKS_AUGMENTED_WITH_CHILDREN':
|
|
1134
|
-
|
|
1135
|
-
|
|
1136
|
-
|
|
1137
|
-
|
|
1138
|
-
|
|
1139
|
-
|
|
1140
|
-
|
|
1141
|
-
|
|
1142
|
-
|
|
1143
|
-
|
|
1149
|
+
case 'REPLACE_BLOCKS_AUGMENTED_WITH_CHILDREN': {
|
|
1150
|
+
const newState = new Map( state );
|
|
1151
|
+
action.replacedClientIds.forEach( ( clientId ) => {
|
|
1152
|
+
newState.delete( clientId );
|
|
1153
|
+
} );
|
|
1154
|
+
mapBlockParents(
|
|
1155
|
+
action.blocks,
|
|
1156
|
+
state.get( action.clientIds[ 0 ] )
|
|
1157
|
+
).forEach( ( [ key, value ] ) => {
|
|
1158
|
+
newState.set( key, value );
|
|
1159
|
+
} );
|
|
1160
|
+
return newState;
|
|
1161
|
+
}
|
|
1162
|
+
case 'REMOVE_BLOCKS_AUGMENTED_WITH_CHILDREN': {
|
|
1163
|
+
const newState = new Map( state );
|
|
1164
|
+
action.removedClientIds.forEach( ( clientId ) => {
|
|
1165
|
+
newState.delete( clientId );
|
|
1166
|
+
} );
|
|
1167
|
+
return newState;
|
|
1168
|
+
}
|
|
1144
1169
|
}
|
|
1145
1170
|
|
|
1146
1171
|
return state;
|
|
@@ -1160,6 +1185,26 @@ export const blocks = pipe(
|
|
|
1160
1185
|
},
|
|
1161
1186
|
} );
|
|
1162
1187
|
|
|
1188
|
+
/**
|
|
1189
|
+
* Reducer returning visibility status of block interface.
|
|
1190
|
+
*
|
|
1191
|
+
* @param {boolean} state Current state.
|
|
1192
|
+
* @param {Object} action Dispatched action.
|
|
1193
|
+
*
|
|
1194
|
+
* @return {boolean} Updated state.
|
|
1195
|
+
*/
|
|
1196
|
+
export function isBlockInterfaceHidden( state = false, action ) {
|
|
1197
|
+
switch ( action.type ) {
|
|
1198
|
+
case 'HIDE_BLOCK_INTERFACE':
|
|
1199
|
+
return true;
|
|
1200
|
+
|
|
1201
|
+
case 'SHOW_BLOCK_INTERFACE':
|
|
1202
|
+
return false;
|
|
1203
|
+
}
|
|
1204
|
+
|
|
1205
|
+
return state;
|
|
1206
|
+
}
|
|
1207
|
+
|
|
1163
1208
|
/**
|
|
1164
1209
|
* Reducer returning typing state.
|
|
1165
1210
|
*
|
|
@@ -1483,7 +1528,7 @@ export function insertionPoint( state = null, action ) {
|
|
|
1483
1528
|
};
|
|
1484
1529
|
|
|
1485
1530
|
// Bail out updates if the states are the same.
|
|
1486
|
-
return
|
|
1531
|
+
return fastDeepEqual( state, nextState ) ? state : nextState;
|
|
1487
1532
|
}
|
|
1488
1533
|
|
|
1489
1534
|
case 'HIDE_INSERTION_POINT':
|
|
@@ -1608,7 +1653,7 @@ export const blockListSettings = ( state = {}, action ) => {
|
|
|
1608
1653
|
return state;
|
|
1609
1654
|
}
|
|
1610
1655
|
|
|
1611
|
-
if (
|
|
1656
|
+
if ( fastDeepEqual( state[ clientId ], action.settings ) ) {
|
|
1612
1657
|
return state;
|
|
1613
1658
|
}
|
|
1614
1659
|
|
|
@@ -1809,6 +1854,7 @@ export function temporarilyEditingAsBlocks( state = '', action ) {
|
|
|
1809
1854
|
export default combineReducers( {
|
|
1810
1855
|
blocks,
|
|
1811
1856
|
isTyping,
|
|
1857
|
+
isBlockInterfaceHidden,
|
|
1812
1858
|
draggedBlocks,
|
|
1813
1859
|
selection,
|
|
1814
1860
|
isMultiSelecting,
|