@wordpress/block-editor 10.5.0 → 11.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +18 -0
- package/README.md +2 -1
- package/build/autocompleters/block.js +2 -6
- package/build/autocompleters/block.js.map +1 -1
- package/build/autocompleters/link.js +2 -0
- package/build/autocompleters/link.js.map +1 -1
- package/build/components/alignment-control/ui.js +1 -7
- package/build/components/alignment-control/ui.js.map +1 -1
- package/build/components/block-alignment-control/use-available-alignments.js +4 -3
- package/build/components/block-alignment-control/use-available-alignments.js.map +1 -1
- package/build/components/block-card/index.js +51 -3
- package/build/components/block-card/index.js.map +1 -1
- package/build/components/block-draggable/index.native.js +46 -39
- package/build/components/block-draggable/index.native.js.map +1 -1
- package/build/components/block-edit/edit.js +4 -3
- package/build/components/block-edit/edit.js.map +1 -1
- package/build/components/block-edit/edit.native.js +4 -7
- package/build/components/block-edit/edit.native.js.map +1 -1
- package/build/components/block-icon/index.js +4 -2
- package/build/components/block-icon/index.js.map +1 -1
- package/build/components/block-inspector/index.js +90 -37
- package/build/components/block-inspector/index.js.map +1 -1
- package/build/components/block-list/block-list-context.native.js +5 -8
- package/build/components/block-list/block-list-context.native.js.map +1 -1
- package/build/components/block-list/block.js +55 -24
- package/build/components/block-list/block.js.map +1 -1
- package/build/components/block-list/block.native.js +61 -28
- package/build/components/block-list/block.native.js.map +1 -1
- package/build/components/block-list-appender/index.js +46 -34
- package/build/components/block-list-appender/index.js.map +1 -1
- package/build/components/block-list-appender/index.native.js +39 -34
- package/build/components/block-list-appender/index.native.js.map +1 -1
- package/build/components/block-mobile-toolbar/block-actions-menu.native.js +30 -22
- package/build/components/block-mobile-toolbar/block-actions-menu.native.js.map +1 -1
- package/build/components/block-mobile-toolbar/index.native.js +1 -1
- package/build/components/block-mobile-toolbar/index.native.js.map +1 -1
- package/build/components/block-pattern-setup/index.js +16 -8
- package/build/components/block-pattern-setup/index.js.map +1 -1
- package/build/components/block-patterns-list/index.js +33 -11
- package/build/components/block-patterns-list/index.js.map +1 -1
- package/build/components/block-preview/auto.js +9 -3
- package/build/components/block-preview/auto.js.map +1 -1
- package/build/components/block-preview/index.js +5 -9
- package/build/components/block-preview/index.js.map +1 -1
- package/build/components/block-settings-menu/block-settings-dropdown.js +5 -2
- package/build/components/block-settings-menu/block-settings-dropdown.js.map +1 -1
- package/build/components/block-styles/index.native.js +1 -3
- package/build/components/block-styles/index.native.js.map +1 -1
- package/build/components/block-styles/utils.js +7 -10
- package/build/components/block-styles/utils.js.map +1 -1
- package/build/components/block-toolbar/index.js +5 -1
- package/build/components/block-toolbar/index.js.map +1 -1
- package/build/components/block-toolbar/index.native.js +6 -8
- package/build/components/block-toolbar/index.native.js.map +1 -1
- package/build/components/block-tools/insertion-point.js +8 -49
- package/build/components/block-tools/insertion-point.js.map +1 -1
- package/build/components/block-tools/selected-block-popover.js +1 -3
- package/build/components/block-tools/selected-block-popover.js.map +1 -1
- package/build/components/block-variation-picker/index.js +2 -3
- package/build/components/block-variation-picker/index.js.map +1 -1
- package/build/components/colors/utils.js +2 -6
- package/build/components/colors/utils.js.map +1 -1
- package/build/components/colors-gradients/control.js +0 -3
- package/build/components/colors-gradients/control.js.map +1 -1
- package/build/components/colors-gradients/dropdown.js +0 -2
- package/build/components/colors-gradients/dropdown.js.map +1 -1
- package/build/components/colors-gradients/panel-color-gradient-settings.js +2 -19
- package/build/components/colors-gradients/panel-color-gradient-settings.js.map +1 -1
- package/build/components/colors-gradients/use-multiple-origin-colors-and-gradients.js +4 -3
- package/build/components/colors-gradients/use-multiple-origin-colors-and-gradients.js.map +1 -1
- package/build/components/copy-handler/index.js +37 -9
- package/build/components/copy-handler/index.js.map +1 -1
- package/build/components/font-sizes/fluid-utils.js +5 -2
- package/build/components/font-sizes/fluid-utils.js.map +1 -1
- package/build/components/font-sizes/utils.js +10 -4
- package/build/components/font-sizes/utils.js.map +1 -1
- package/build/components/font-sizes/with-font-sizes.js +11 -6
- package/build/components/font-sizes/with-font-sizes.js.map +1 -1
- package/build/components/gradients/use-gradient.js +2 -8
- package/build/components/gradients/use-gradient.js.map +1 -1
- package/build/components/height-control/index.js +115 -0
- package/build/components/height-control/index.js.map +1 -0
- package/build/components/iframe/index.js +22 -101
- package/build/components/iframe/index.js.map +1 -1
- package/build/components/iframe/use-compatibility-styles.js +93 -0
- package/build/components/iframe/use-compatibility-styles.js.map +1 -0
- package/build/components/image-editor/use-save-image.js +2 -0
- package/build/components/image-editor/use-save-image.js.map +1 -1
- package/build/components/image-editor/zoom-dropdown.js +1 -0
- package/build/components/image-editor/zoom-dropdown.js.map +1 -1
- package/build/components/index.js +9 -0
- package/build/components/index.js.map +1 -1
- package/build/components/inner-blocks/index.js +25 -7
- package/build/components/inner-blocks/index.js.map +1 -1
- package/build/components/inner-blocks/use-inner-block-template-sync.js +25 -10
- package/build/components/inner-blocks/use-inner-block-template-sync.js.map +1 -1
- package/build/components/inserter/block-patterns-explorer/sidebar.js +1 -0
- package/build/components/inserter/block-patterns-explorer/sidebar.js.map +1 -1
- package/build/components/inserter/block-patterns-tab.js +25 -46
- package/build/components/inserter/block-patterns-tab.js.map +1 -1
- package/build/components/inserter/block-types-tab.js +3 -1
- package/build/components/inserter/block-types-tab.js.map +1 -1
- package/build/components/inserter/hooks/use-debounced-input.js +27 -0
- package/build/components/inserter/hooks/use-debounced-input.js.map +1 -0
- package/build/components/inserter/hooks/use-insertion-point.js +4 -3
- package/build/components/inserter/hooks/use-insertion-point.js.map +1 -1
- package/build/components/inserter/index.js +20 -6
- package/build/components/inserter/index.js.map +1 -1
- package/build/components/inserter/index.native.js +3 -4
- package/build/components/inserter/index.native.js.map +1 -1
- package/build/components/inserter/media-tab/hooks.js +106 -0
- package/build/components/inserter/media-tab/hooks.js.map +1 -0
- package/build/components/inserter/media-tab/index.js +32 -0
- package/build/components/inserter/media-tab/index.js.map +1 -0
- package/build/components/inserter/media-tab/media-list.js +100 -0
- package/build/components/inserter/media-tab/media-list.js.map +1 -0
- package/build/components/inserter/media-tab/media-panel.js +96 -0
- package/build/components/inserter/media-tab/media-panel.js.map +1 -0
- package/build/components/inserter/media-tab/media-tab.js +120 -0
- package/build/components/inserter/media-tab/media-tab.js.map +1 -0
- package/build/components/inserter/media-tab/utils.js +54 -0
- package/build/components/inserter/media-tab/utils.js.map +1 -0
- package/build/components/inserter/menu.js +35 -12
- package/build/components/inserter/menu.js.map +1 -1
- package/build/components/inserter/mobile-tab-navigation.js +70 -0
- package/build/components/inserter/mobile-tab-navigation.js.map +1 -0
- package/build/components/inserter/quick-inserter.js +7 -3
- package/build/components/inserter/quick-inserter.js.map +1 -1
- package/build/components/inserter/search-items.js +15 -14
- package/build/components/inserter/search-items.js.map +1 -1
- package/build/components/inserter/search-results.js +7 -3
- package/build/components/inserter/search-results.js.map +1 -1
- package/build/components/inserter/tabs.js +16 -2
- package/build/components/inserter/tabs.js.map +1 -1
- package/build/components/inserter-list-item/index.js +4 -1
- package/build/components/inserter-list-item/index.js.map +1 -1
- package/build/components/inspector-controls/groups.js +2 -0
- package/build/components/inspector-controls/groups.js.map +1 -1
- package/build/components/inspector-controls-tabs/advanced-controls-panel.js +46 -0
- package/build/components/inspector-controls-tabs/advanced-controls-panel.js.map +1 -0
- package/build/components/inspector-controls-tabs/index.js +71 -0
- package/build/components/inspector-controls-tabs/index.js.map +1 -0
- package/build/components/inspector-controls-tabs/settings-tab.js +28 -0
- package/build/components/inspector-controls-tabs/settings-tab.js.map +1 -0
- package/build/components/inspector-controls-tabs/styles-tab.js +61 -0
- package/build/components/inspector-controls-tabs/styles-tab.js.map +1 -0
- package/build/components/inspector-controls-tabs/use-inspector-controls-tabs.js +97 -0
- package/build/components/inspector-controls-tabs/use-inspector-controls-tabs.js.map +1 -0
- package/build/components/inspector-controls-tabs/use-is-list-view-tab-disabled.js +18 -0
- package/build/components/inspector-controls-tabs/use-is-list-view-tab-disabled.js.map +1 -0
- package/build/components/inspector-controls-tabs/utils.js +37 -0
- package/build/components/inspector-controls-tabs/utils.js.map +1 -0
- package/build/components/link-control/index.js +1 -0
- package/build/components/link-control/index.js.map +1 -1
- package/build/components/link-control/search-input.js +0 -1
- package/build/components/link-control/search-input.js.map +1 -1
- package/build/components/link-control/use-internal-input-value.js +3 -3
- package/build/components/link-control/use-internal-input-value.js.map +1 -1
- package/build/components/list-view/block-select-button.js +1 -1
- package/build/components/list-view/block-select-button.js.map +1 -1
- package/build/components/list-view/block.js +5 -2
- package/build/components/list-view/block.js.map +1 -1
- package/build/components/list-view/branch.js +13 -12
- package/build/components/list-view/branch.js.map +1 -1
- package/build/components/media-upload/index.native.js +2 -3
- package/build/components/media-upload/index.native.js.map +1 -1
- package/build/components/off-canvas-editor/appender.js +99 -0
- package/build/components/off-canvas-editor/appender.js.map +1 -0
- package/build/components/off-canvas-editor/block-edit-button.js +50 -0
- package/build/components/off-canvas-editor/block-edit-button.js.map +1 -0
- package/build/components/off-canvas-editor/block-select-button.js +3 -2
- package/build/components/off-canvas-editor/block-select-button.js.map +1 -1
- package/build/components/off-canvas-editor/block.js +82 -38
- package/build/components/off-canvas-editor/block.js.map +1 -1
- package/build/components/off-canvas-editor/branch.js +3 -5
- package/build/components/off-canvas-editor/branch.js.map +1 -1
- package/build/components/off-canvas-editor/index.js +24 -11
- package/build/components/off-canvas-editor/index.js.map +1 -1
- package/build/components/off-canvas-editor/leaf.js +1 -1
- package/build/components/off-canvas-editor/leaf.js.map +1 -1
- package/build/components/off-canvas-editor/link-ui.js +185 -0
- package/build/components/off-canvas-editor/link-ui.js.map +1 -0
- package/build/components/off-canvas-editor/update-attributes.js +108 -0
- package/build/components/off-canvas-editor/update-attributes.js.map +1 -0
- package/build/components/off-canvas-editor/use-inserted-block.js +58 -0
- package/build/components/off-canvas-editor/use-inserted-block.js.map +1 -0
- package/build/components/responsive-block-control/label.js.map +1 -1
- package/build/components/rich-text/format-edit.js +12 -10
- package/build/components/rich-text/format-edit.js.map +1 -1
- package/build/components/rich-text/format-toolbar/index.js +8 -4
- package/build/components/rich-text/format-toolbar/index.js.map +1 -1
- package/build/components/rich-text/index.js +3 -3
- package/build/components/rich-text/index.js.map +1 -1
- package/build/components/rich-text/index.native.js +0 -2
- package/build/components/rich-text/index.native.js.map +1 -1
- package/build/components/rich-text/use-insert-replacement-text.js +43 -0
- package/build/components/rich-text/use-insert-replacement-text.js.map +1 -0
- package/build/components/rich-text/use-paste-handler.js +21 -12
- package/build/components/rich-text/use-paste-handler.js.map +1 -1
- package/build/components/rich-text/use-undo-automatic-change.js +9 -1
- package/build/components/rich-text/use-undo-automatic-change.js.map +1 -1
- package/build/components/rich-text/utils.js +1 -19
- package/build/components/rich-text/utils.js.map +1 -1
- package/build/components/spacing-sizes-control/index.js +0 -1
- package/build/components/spacing-sizes-control/index.js.map +1 -1
- package/build/components/spacing-sizes-control/spacing-input-control.js +12 -3
- package/build/components/spacing-sizes-control/spacing-input-control.js.map +1 -1
- package/build/components/spacing-sizes-control/utils.js +1 -1
- package/build/components/spacing-sizes-control/utils.js.map +1 -1
- package/build/components/typewriter/index.js +1 -1
- package/build/components/typewriter/index.js.map +1 -1
- package/build/components/ungroup-button/index.native.js +4 -2
- package/build/components/ungroup-button/index.native.js.map +1 -1
- package/build/components/url-input/index.js +46 -43
- package/build/components/url-input/index.js.map +1 -1
- package/build/components/url-popover/image-url-input-ui.js +2 -2
- package/build/components/url-popover/image-url-input-ui.js.map +1 -1
- package/build/components/use-block-display-information/index.js +8 -4
- package/build/components/use-block-display-information/index.js.map +1 -1
- package/build/components/use-setting/index.js +9 -1
- package/build/components/use-setting/index.js.map +1 -1
- package/build/components/writing-flow/index.js +1 -1
- package/build/components/writing-flow/index.js.map +1 -1
- package/build/hooks/border.js +0 -1
- package/build/hooks/border.js.map +1 -1
- package/build/hooks/child-layout.js +209 -0
- package/build/hooks/child-layout.js.map +1 -0
- package/build/hooks/color-panel.js +0 -1
- package/build/hooks/color-panel.js.map +1 -1
- package/build/hooks/color.js +1 -2
- package/build/hooks/color.js.map +1 -1
- package/build/hooks/content-lock-ui.js +1 -1
- package/build/hooks/content-lock-ui.js.map +1 -1
- package/build/hooks/dimensions.js +25 -7
- package/build/hooks/dimensions.js.map +1 -1
- package/build/hooks/font-family.js +4 -4
- package/build/hooks/font-family.js.map +1 -1
- package/build/hooks/font-size.js +5 -3
- package/build/hooks/font-size.js.map +1 -1
- package/build/hooks/layout.js +57 -1
- package/build/hooks/layout.js.map +1 -1
- package/build/hooks/min-height.js +4 -10
- package/build/hooks/min-height.js.map +1 -1
- package/build/hooks/use-typography-props.js +11 -8
- package/build/hooks/use-typography-props.js.map +1 -1
- package/build/store/reducer.js +411 -274
- package/build/store/reducer.js.map +1 -1
- package/build/store/selectors.js +58 -48
- package/build/store/selectors.js.map +1 -1
- package/build/utils/pasting.js +6 -11
- package/build/utils/pasting.js.map +1 -1
- package/build/utils/sorting.js +63 -0
- package/build/utils/sorting.js.map +1 -0
- package/build-module/autocompleters/block.js +2 -6
- package/build-module/autocompleters/block.js.map +1 -1
- package/build-module/autocompleters/link.js +2 -0
- package/build-module/autocompleters/link.js.map +1 -1
- package/build-module/components/alignment-control/ui.js +1 -6
- package/build-module/components/alignment-control/ui.js.map +1 -1
- package/build-module/components/block-alignment-control/use-available-alignments.js +4 -3
- package/build-module/components/block-alignment-control/use-available-alignments.js.map +1 -1
- package/build-module/components/block-card/index.js +45 -3
- package/build-module/components/block-card/index.js.map +1 -1
- package/build-module/components/block-draggable/index.native.js +40 -31
- package/build-module/components/block-draggable/index.native.js.map +1 -1
- package/build-module/components/block-edit/edit.js +4 -2
- package/build-module/components/block-edit/edit.js.map +1 -1
- package/build-module/components/block-edit/edit.native.js +4 -6
- package/build-module/components/block-edit/edit.native.js.map +1 -1
- package/build-module/components/block-icon/index.js +4 -2
- package/build-module/components/block-icon/index.js.map +1 -1
- package/build-module/components/block-inspector/index.js +87 -34
- package/build-module/components/block-inspector/index.js.map +1 -1
- package/build-module/components/block-list/block-list-context.native.js +5 -8
- package/build-module/components/block-list/block-list-context.native.js.map +1 -1
- package/build-module/components/block-list/block.js +55 -25
- package/build-module/components/block-list/block.js.map +1 -1
- package/build-module/components/block-list/block.native.js +61 -28
- package/build-module/components/block-list/block.native.js.map +1 -1
- package/build-module/components/block-list-appender/index.js +46 -34
- package/build-module/components/block-list-appender/index.js.map +1 -1
- package/build-module/components/block-list-appender/index.native.js +39 -32
- package/build-module/components/block-list-appender/index.native.js.map +1 -1
- package/build-module/components/block-mobile-toolbar/block-actions-menu.native.js +31 -24
- package/build-module/components/block-mobile-toolbar/block-actions-menu.native.js.map +1 -1
- package/build-module/components/block-mobile-toolbar/index.native.js +1 -1
- package/build-module/components/block-mobile-toolbar/index.native.js.map +1 -1
- package/build-module/components/block-pattern-setup/index.js +16 -8
- package/build-module/components/block-pattern-setup/index.js.map +1 -1
- package/build-module/components/block-patterns-list/index.js +35 -13
- package/build-module/components/block-patterns-list/index.js.map +1 -1
- package/build-module/components/block-preview/auto.js +9 -3
- package/build-module/components/block-preview/auto.js.map +1 -1
- package/build-module/components/block-preview/index.js +5 -8
- package/build-module/components/block-preview/index.js.map +1 -1
- package/build-module/components/block-settings-menu/block-settings-dropdown.js +5 -2
- package/build-module/components/block-settings-menu/block-settings-dropdown.js.map +1 -1
- package/build-module/components/block-styles/index.native.js +1 -2
- package/build-module/components/block-styles/index.native.js.map +1 -1
- package/build-module/components/block-styles/utils.js +7 -9
- package/build-module/components/block-styles/utils.js.map +1 -1
- package/build-module/components/block-toolbar/index.js +6 -2
- package/build-module/components/block-toolbar/index.js.map +1 -1
- package/build-module/components/block-toolbar/index.native.js +6 -8
- package/build-module/components/block-toolbar/index.native.js.map +1 -1
- package/build-module/components/block-tools/insertion-point.js +8 -49
- package/build-module/components/block-tools/insertion-point.js.map +1 -1
- package/build-module/components/block-tools/selected-block-popover.js +1 -2
- package/build-module/components/block-tools/selected-block-popover.js.map +1 -1
- package/build-module/components/block-variation-picker/index.js +2 -3
- package/build-module/components/block-variation-picker/index.js.map +1 -1
- package/build-module/components/colors/utils.js +3 -7
- package/build-module/components/colors/utils.js.map +1 -1
- package/build-module/components/colors-gradients/control.js +0 -3
- package/build-module/components/colors-gradients/control.js.map +1 -1
- package/build-module/components/colors-gradients/dropdown.js +0 -2
- package/build-module/components/colors-gradients/dropdown.js.map +1 -1
- package/build-module/components/colors-gradients/panel-color-gradient-settings.js +4 -19
- package/build-module/components/colors-gradients/panel-color-gradient-settings.js.map +1 -1
- package/build-module/components/colors-gradients/use-multiple-origin-colors-and-gradients.js +4 -2
- package/build-module/components/colors-gradients/use-multiple-origin-colors-and-gradients.js.map +1 -1
- package/build-module/components/copy-handler/index.js +38 -10
- package/build-module/components/copy-handler/index.js.map +1 -1
- package/build-module/components/font-sizes/fluid-utils.js +5 -2
- package/build-module/components/font-sizes/fluid-utils.js.map +1 -1
- package/build-module/components/font-sizes/utils.js +11 -5
- package/build-module/components/font-sizes/utils.js.map +1 -1
- package/build-module/components/font-sizes/with-font-sizes.js +12 -7
- package/build-module/components/font-sizes/with-font-sizes.js.map +1 -1
- package/build-module/components/gradients/use-gradient.js +2 -7
- package/build-module/components/gradients/use-gradient.js.map +1 -1
- package/build-module/components/height-control/index.js +103 -0
- package/build-module/components/height-control/index.js.map +1 -0
- package/build-module/components/iframe/index.js +21 -101
- package/build-module/components/iframe/index.js.map +1 -1
- package/build-module/components/iframe/use-compatibility-styles.js +85 -0
- package/build-module/components/iframe/use-compatibility-styles.js.map +1 -0
- package/build-module/components/image-editor/use-save-image.js +2 -0
- package/build-module/components/image-editor/use-save-image.js.map +1 -1
- package/build-module/components/image-editor/zoom-dropdown.js +1 -0
- package/build-module/components/image-editor/zoom-dropdown.js.map +1 -1
- package/build-module/components/index.js +1 -0
- package/build-module/components/index.js.map +1 -1
- package/build-module/components/inner-blocks/index.js +27 -9
- package/build-module/components/inner-blocks/index.js.map +1 -1
- package/build-module/components/inner-blocks/use-inner-block-template-sync.js +23 -10
- package/build-module/components/inner-blocks/use-inner-block-template-sync.js.map +1 -1
- package/build-module/components/inserter/block-patterns-explorer/sidebar.js +1 -0
- package/build-module/components/inserter/block-patterns-explorer/sidebar.js.map +1 -1
- package/build-module/components/inserter/block-patterns-tab.js +27 -49
- package/build-module/components/inserter/block-patterns-tab.js.map +1 -1
- package/build-module/components/inserter/block-types-tab.js +3 -2
- package/build-module/components/inserter/block-types-tab.js.map +1 -1
- package/build-module/components/inserter/hooks/use-debounced-input.js +18 -0
- package/build-module/components/inserter/hooks/use-debounced-input.js.map +1 -0
- package/build-module/components/inserter/hooks/use-insertion-point.js +4 -3
- package/build-module/components/inserter/hooks/use-insertion-point.js.map +1 -1
- package/build-module/components/inserter/index.js +20 -6
- package/build-module/components/inserter/index.js.map +1 -1
- package/build-module/components/inserter/index.native.js +3 -5
- package/build-module/components/inserter/index.native.js.map +1 -1
- package/build-module/components/inserter/media-tab/hooks.js +92 -0
- package/build-module/components/inserter/media-tab/hooks.js.map +1 -0
- package/build-module/components/inserter/media-tab/index.js +4 -0
- package/build-module/components/inserter/media-tab/index.js.map +1 -0
- package/build-module/components/inserter/media-tab/media-list.js +86 -0
- package/build-module/components/inserter/media-tab/media-list.js.map +1 -0
- package/build-module/components/inserter/media-tab/media-panel.js +77 -0
- package/build-module/components/inserter/media-tab/media-panel.js.map +1 -0
- package/build-module/components/inserter/media-tab/media-tab.js +100 -0
- package/build-module/components/inserter/media-tab/media-tab.js.map +1 -0
- package/build-module/components/inserter/media-tab/utils.js +45 -0
- package/build-module/components/inserter/media-tab/utils.js.map +1 -0
- package/build-module/components/inserter/menu.js +33 -12
- package/build-module/components/inserter/menu.js.map +1 -1
- package/build-module/components/inserter/mobile-tab-navigation.js +61 -0
- package/build-module/components/inserter/mobile-tab-navigation.js.map +1 -0
- package/build-module/components/inserter/quick-inserter.js +7 -3
- package/build-module/components/inserter/quick-inserter.js.map +1 -1
- package/build-module/components/inserter/search-items.js +15 -13
- package/build-module/components/inserter/search-items.js.map +1 -1
- package/build-module/components/inserter/search-results.js +7 -4
- package/build-module/components/inserter/search-results.js.map +1 -1
- package/build-module/components/inserter/tabs.js +15 -2
- package/build-module/components/inserter/tabs.js.map +1 -1
- package/build-module/components/inserter-list-item/index.js +5 -2
- package/build-module/components/inserter-list-item/index.js.map +1 -1
- package/build-module/components/inspector-controls/groups.js +2 -0
- package/build-module/components/inspector-controls/groups.js.map +1 -1
- package/build-module/components/inspector-controls-tabs/advanced-controls-panel.js +32 -0
- package/build-module/components/inspector-controls-tabs/advanced-controls-panel.js.map +1 -0
- package/build-module/components/inspector-controls-tabs/index.js +56 -0
- package/build-module/components/inspector-controls-tabs/index.js.map +1 -0
- package/build-module/components/inspector-controls-tabs/settings-tab.js +17 -0
- package/build-module/components/inspector-controls-tabs/settings-tab.js.map +1 -0
- package/build-module/components/inspector-controls-tabs/styles-tab.js +46 -0
- package/build-module/components/inspector-controls-tabs/styles-tab.js.map +1 -0
- package/build-module/components/inspector-controls-tabs/use-inspector-controls-tabs.js +81 -0
- package/build-module/components/inspector-controls-tabs/use-inspector-controls-tabs.js.map +1 -0
- package/build-module/components/inspector-controls-tabs/use-is-list-view-tab-disabled.js +8 -0
- package/build-module/components/inspector-controls-tabs/use-is-list-view-tab-disabled.js.map +1 -0
- package/build-module/components/inspector-controls-tabs/utils.js +26 -0
- package/build-module/components/inspector-controls-tabs/utils.js.map +1 -0
- package/build-module/components/link-control/index.js +1 -0
- package/build-module/components/link-control/index.js.map +1 -1
- package/build-module/components/link-control/search-input.js +0 -1
- package/build-module/components/link-control/search-input.js.map +1 -1
- package/build-module/components/link-control/use-internal-input-value.js +3 -3
- package/build-module/components/link-control/use-internal-input-value.js.map +1 -1
- package/build-module/components/list-view/block-select-button.js +1 -1
- package/build-module/components/list-view/block-select-button.js.map +1 -1
- package/build-module/components/list-view/block.js +5 -2
- package/build-module/components/list-view/block.js.map +1 -1
- package/build-module/components/list-view/branch.js +12 -11
- package/build-module/components/list-view/branch.js.map +1 -1
- package/build-module/components/media-upload/index.native.js +2 -4
- package/build-module/components/media-upload/index.native.js.map +1 -1
- package/build-module/components/off-canvas-editor/appender.js +83 -0
- package/build-module/components/off-canvas-editor/appender.js.map +1 -0
- package/build-module/components/off-canvas-editor/block-edit-button.js +35 -0
- package/build-module/components/off-canvas-editor/block-edit-button.js.map +1 -0
- package/build-module/components/off-canvas-editor/block-select-button.js +3 -2
- package/build-module/components/off-canvas-editor/block-select-button.js.map +1 -1
- package/build-module/components/off-canvas-editor/block.js +83 -41
- package/build-module/components/off-canvas-editor/block.js.map +1 -1
- package/build-module/components/off-canvas-editor/branch.js +3 -4
- package/build-module/components/off-canvas-editor/branch.js.map +1 -1
- package/build-module/components/off-canvas-editor/index.js +24 -12
- package/build-module/components/off-canvas-editor/index.js.map +1 -1
- package/build-module/components/off-canvas-editor/leaf.js +1 -1
- package/build-module/components/off-canvas-editor/leaf.js.map +1 -1
- package/build-module/components/off-canvas-editor/link-ui.js +165 -0
- package/build-module/components/off-canvas-editor/link-ui.js.map +1 -0
- package/build-module/components/off-canvas-editor/update-attributes.js +97 -0
- package/build-module/components/off-canvas-editor/update-attributes.js.map +1 -0
- package/build-module/components/off-canvas-editor/use-inserted-block.js +47 -0
- package/build-module/components/off-canvas-editor/use-inserted-block.js.map +1 -0
- package/build-module/components/responsive-block-control/label.js +1 -2
- package/build-module/components/responsive-block-control/label.js.map +1 -1
- package/build-module/components/rich-text/format-edit.js +12 -9
- package/build-module/components/rich-text/format-edit.js.map +1 -1
- package/build-module/components/rich-text/format-toolbar/index.js +6 -2
- package/build-module/components/rich-text/format-toolbar/index.js.map +1 -1
- package/build-module/components/rich-text/index.js +2 -3
- package/build-module/components/rich-text/index.js.map +1 -1
- package/build-module/components/rich-text/index.native.js +0 -2
- package/build-module/components/rich-text/index.native.js.map +1 -1
- package/build-module/components/rich-text/use-insert-replacement-text.js +33 -0
- package/build-module/components/rich-text/use-insert-replacement-text.js.map +1 -0
- package/build-module/components/rich-text/use-paste-handler.js +22 -12
- package/build-module/components/rich-text/use-paste-handler.js.map +1 -1
- package/build-module/components/rich-text/use-undo-automatic-change.js +9 -1
- package/build-module/components/rich-text/use-undo-automatic-change.js.map +1 -1
- package/build-module/components/rich-text/utils.js +1 -16
- package/build-module/components/rich-text/utils.js.map +1 -1
- package/build-module/components/spacing-sizes-control/index.js +0 -1
- package/build-module/components/spacing-sizes-control/index.js.map +1 -1
- package/build-module/components/spacing-sizes-control/spacing-input-control.js +12 -3
- package/build-module/components/spacing-sizes-control/spacing-input-control.js.map +1 -1
- package/build-module/components/spacing-sizes-control/utils.js +1 -1
- package/build-module/components/spacing-sizes-control/utils.js.map +1 -1
- package/build-module/components/typewriter/index.js +1 -1
- package/build-module/components/typewriter/index.js.map +1 -1
- package/build-module/components/ungroup-button/index.native.js +3 -2
- package/build-module/components/ungroup-button/index.native.js.map +1 -1
- package/build-module/components/url-input/index.js +46 -43
- package/build-module/components/url-input/index.js.map +1 -1
- package/build-module/components/url-popover/image-url-input-ui.js +3 -3
- package/build-module/components/url-popover/image-url-input-ui.js.map +1 -1
- package/build-module/components/use-block-display-information/index.js +9 -5
- package/build-module/components/use-block-display-information/index.js.map +1 -1
- package/build-module/components/use-setting/index.js +8 -1
- package/build-module/components/use-setting/index.js.map +1 -1
- package/build-module/components/writing-flow/index.js +1 -1
- package/build-module/components/writing-flow/index.js.map +1 -1
- package/build-module/hooks/border.js +0 -1
- package/build-module/hooks/border.js.map +1 -1
- package/build-module/hooks/child-layout.js +189 -0
- package/build-module/hooks/child-layout.js.map +1 -0
- package/build-module/hooks/color-panel.js +0 -1
- package/build-module/hooks/color-panel.js.map +1 -1
- package/build-module/hooks/color.js +1 -2
- package/build-module/hooks/color.js.map +1 -1
- package/build-module/hooks/content-lock-ui.js +1 -1
- package/build-module/hooks/content-lock-ui.js.map +1 -1
- package/build-module/hooks/dimensions.js +25 -8
- package/build-module/hooks/dimensions.js.map +1 -1
- package/build-module/hooks/font-family.js +5 -5
- package/build-module/hooks/font-family.js.map +1 -1
- package/build-module/hooks/font-size.js +5 -3
- package/build-module/hooks/font-size.js.map +1 -1
- package/build-module/hooks/layout.js +55 -0
- package/build-module/hooks/layout.js.map +1 -1
- package/build-module/hooks/min-height.js +3 -9
- package/build-module/hooks/min-height.js.map +1 -1
- package/build-module/hooks/use-typography-props.js +11 -8
- package/build-module/hooks/use-typography-props.js.map +1 -1
- package/build-module/store/reducer.js +409 -274
- package/build-module/store/reducer.js.map +1 -1
- package/build-module/store/selectors.js +55 -48
- package/build-module/store/selectors.js.map +1 -1
- package/build-module/utils/pasting.js +6 -10
- package/build-module/utils/pasting.js.map +1 -1
- package/build-module/utils/sorting.js +56 -0
- package/build-module/utils/sorting.js.map +1 -0
- package/build-style/content-rtl.css +701 -0
- package/build-style/content.css +701 -0
- package/build-style/default-editor-styles-rtl.css +17 -3
- package/build-style/default-editor-styles.css +17 -3
- package/build-style/style-rtl.css +313 -665
- package/build-style/style.css +313 -665
- package/package.json +32 -30
- package/src/autocompleters/block.js +2 -6
- package/src/autocompleters/link.js +2 -0
- package/src/components/alignment-control/test/index.js +6 -1
- package/src/components/alignment-control/ui.js +1 -7
- package/src/components/block-alignment-control/test/index.js +6 -1
- package/src/components/block-alignment-control/use-available-alignments.js +4 -3
- package/src/components/block-card/index.js +46 -2
- package/src/components/block-card/style.scss +4 -0
- package/src/components/block-content-overlay/{style.scss → content.scss} +7 -1
- package/src/components/block-draggable/content.scss +20 -0
- package/src/components/block-draggable/index.native.js +54 -40
- package/src/components/block-draggable/style.scss +0 -21
- package/src/components/block-draggable/test/helpers.native.js +7 -9
- package/src/components/block-draggable/test/index.native.js +35 -45
- package/src/components/block-edit/edit.js +5 -2
- package/src/components/block-edit/edit.native.js +5 -6
- package/src/components/block-icon/index.js +4 -2
- package/src/components/block-icon/test/index.js +9 -5
- package/src/components/block-inspector/index.js +173 -85
- package/src/components/block-inspector/style.scss +16 -1
- package/src/components/block-list/block-list-context.native.js +5 -8
- package/src/components/block-list/block.js +74 -23
- package/src/components/block-list/block.native.js +78 -23
- package/src/components/block-list/{style.scss → content.scss} +1 -15
- package/src/components/block-list-appender/{style.scss → content.scss} +0 -0
- package/src/components/block-list-appender/index.js +65 -54
- package/src/components/block-list-appender/index.native.js +45 -34
- package/src/components/block-mobile-toolbar/block-actions-menu.native.js +42 -28
- package/src/components/block-mobile-toolbar/index.native.js +1 -1
- package/src/components/block-mobile-toolbar/test/__snapshots__/block-actions-menu.native.js.snap +125 -0
- package/src/components/block-mobile-toolbar/test/block-actions-menu.native.js +439 -0
- package/src/components/block-mover/test/__snapshots__/index.native.js.snap +42 -2
- package/src/components/block-mover/test/index.native.js +157 -1
- package/src/components/block-pattern-setup/index.js +17 -7
- package/src/components/block-pattern-setup/style.scss +29 -1
- package/src/components/block-patterns-list/index.js +47 -24
- package/src/components/block-preview/README.md +15 -10
- package/src/components/block-preview/auto.js +7 -1
- package/src/components/block-preview/content.scss +4 -0
- package/src/components/block-preview/index.js +7 -12
- package/src/components/block-preview/style.scss +0 -7
- package/src/components/block-preview/test/index.js +18 -35
- package/src/components/block-selection-clearer/test/index.js +12 -12
- package/src/components/block-settings-menu/block-settings-dropdown.js +32 -20
- package/src/components/block-styles/index.native.js +1 -2
- package/src/components/block-styles/utils.js +5 -7
- package/src/components/block-switcher/test/index.js +6 -1
- package/src/components/block-toolbar/index.js +12 -5
- package/src/components/block-toolbar/index.native.js +8 -11
- package/src/components/block-toolbar/style.scss +10 -0
- package/src/components/block-tools/insertion-point.js +3 -47
- package/src/components/block-tools/selected-block-popover.js +1 -3
- package/src/components/block-tools/style.scss +12 -5
- package/src/components/block-variation-picker/index.js +6 -5
- package/src/components/block-vertical-alignment-control/test/index.js +6 -1
- package/src/components/colors/test/with-colors.js +2 -0
- package/src/components/colors/utils.js +5 -3
- package/src/components/colors-gradients/control.js +0 -7
- package/src/components/colors-gradients/dropdown.js +0 -2
- package/src/components/colors-gradients/panel-color-gradient-settings.js +4 -22
- package/src/components/colors-gradients/use-multiple-origin-colors-and-gradients.js +4 -2
- package/src/components/copy-handler/index.js +53 -7
- package/src/components/default-block-appender/{style.scss → content.scss} +0 -0
- package/src/components/default-block-appender/test/index.js +2 -0
- package/src/components/font-sizes/fluid-utils.js +7 -1
- package/src/components/font-sizes/utils.js +5 -3
- package/src/components/font-sizes/with-font-sizes.js +4 -4
- package/src/components/gradients/use-gradient.js +2 -7
- package/src/components/height-control/index.js +123 -0
- package/src/components/height-control/stories/index.js +21 -0
- package/src/components/height-control/style.scss +5 -0
- package/src/components/iframe/index.js +33 -121
- package/src/components/iframe/use-compatibility-styles.js +95 -0
- package/src/components/image-editor/use-save-image.js +2 -0
- package/src/components/image-editor/zoom-dropdown.js +1 -0
- package/src/components/image-size-control/test/index.js +147 -79
- package/src/components/index.js +1 -0
- package/src/components/inner-blocks/{style.scss → content.scss} +0 -0
- package/src/components/inner-blocks/index.js +26 -7
- package/src/components/inner-blocks/use-inner-block-template-sync.js +28 -10
- package/src/components/inserter/block-patterns-explorer/sidebar.js +1 -0
- package/src/components/inserter/block-patterns-tab.js +28 -71
- package/src/components/inserter/block-types-tab.js +3 -2
- package/src/components/inserter/hooks/use-debounced-input.js +17 -0
- package/src/components/inserter/hooks/use-insertion-point.js +3 -2
- package/src/components/inserter/index.js +24 -3
- package/src/components/inserter/index.native.js +1 -1
- package/src/components/inserter/media-tab/hooks.js +89 -0
- package/src/components/inserter/media-tab/index.js +3 -0
- package/src/components/inserter/media-tab/media-list.js +93 -0
- package/src/components/inserter/media-tab/media-panel.js +83 -0
- package/src/components/inserter/media-tab/media-tab.js +135 -0
- package/src/components/inserter/media-tab/utils.js +37 -0
- package/src/components/inserter/menu.js +55 -13
- package/src/components/inserter/mobile-tab-navigation.js +85 -0
- package/src/components/inserter/quick-inserter.js +4 -0
- package/src/components/inserter/search-items.js +1 -2
- package/src/components/inserter/search-results.js +5 -2
- package/src/components/inserter/stories/index.js +1 -1
- package/src/components/inserter/stories/{fixtures.js → utils/fixtures.js} +0 -0
- package/src/components/inserter/style.scss +176 -11
- package/src/components/inserter/tabs.js +12 -1
- package/src/components/inserter-list-item/index.js +11 -1
- package/src/components/inserter-list-item/style.scss +26 -0
- package/src/components/inspector-controls/groups.js +2 -0
- package/src/components/inspector-controls-tabs/advanced-controls-panel.js +37 -0
- package/src/components/inspector-controls-tabs/index.js +62 -0
- package/src/components/inspector-controls-tabs/settings-tab.js +18 -0
- package/src/components/inspector-controls-tabs/styles-tab.js +51 -0
- package/src/components/inspector-controls-tabs/use-inspector-controls-tabs.js +89 -0
- package/src/components/inspector-controls-tabs/use-is-list-view-tab-disabled.js +9 -0
- package/src/components/inspector-controls-tabs/utils.js +28 -0
- package/src/components/line-height-control/test/index.js +5 -5
- package/src/components/link-control/README.md +1 -1
- package/src/components/link-control/index.js +1 -0
- package/src/components/link-control/search-input.js +0 -1
- package/src/components/link-control/test/index.js +204 -403
- package/src/components/link-control/use-internal-input-value.js +3 -3
- package/src/components/list-view/block-select-button.js +1 -1
- package/src/components/list-view/block.js +3 -0
- package/src/components/list-view/branch.js +10 -8
- package/src/components/list-view/style.scss +21 -16
- package/src/components/media-placeholder/{style.scss → content.scss} +0 -0
- package/src/components/media-replace-flow/test/index.js +39 -9
- package/src/components/media-upload/test/index.native.js +2 -0
- package/src/components/off-canvas-editor/appender.js +98 -0
- package/src/components/off-canvas-editor/block-edit-button.js +27 -0
- package/src/components/off-canvas-editor/block-select-button.js +6 -2
- package/src/components/off-canvas-editor/block.js +160 -77
- package/src/components/off-canvas-editor/branch.js +3 -5
- package/src/components/off-canvas-editor/index.js +68 -33
- package/src/components/off-canvas-editor/leaf.js +5 -1
- package/src/components/off-canvas-editor/link-ui.js +166 -0
- package/src/components/off-canvas-editor/style.scss +19 -386
- package/src/components/off-canvas-editor/test/use-inserted-block.js +108 -0
- package/src/components/off-canvas-editor/update-attributes.js +99 -0
- package/src/components/off-canvas-editor/use-inserted-block.js +47 -0
- package/src/components/plain-text/{style.scss → content.scss} +0 -0
- package/src/components/recursion-provider/test/index.js +27 -29
- package/src/components/responsive-block-control/label.js +2 -3
- package/src/components/responsive-block-control/test/index.js +4 -2
- package/src/components/rich-text/content.scss +42 -0
- package/src/components/rich-text/format-edit.js +6 -10
- package/src/components/rich-text/format-toolbar/index.js +6 -4
- package/src/components/rich-text/index.js +3 -2
- package/src/components/rich-text/index.native.js +0 -2
- package/src/components/rich-text/style.scss +0 -43
- package/src/components/rich-text/use-insert-replacement-text.js +31 -0
- package/src/components/rich-text/use-paste-handler.js +33 -14
- package/src/components/rich-text/use-undo-automatic-change.js +7 -1
- package/src/components/rich-text/utils.js +2 -21
- package/src/components/spacing-sizes-control/index.js +0 -1
- package/src/components/spacing-sizes-control/spacing-input-control.js +9 -0
- package/src/components/spacing-sizes-control/utils.js +1 -1
- package/src/components/typewriter/index.js +3 -1
- package/src/components/ungroup-button/index.native.js +6 -2
- package/src/components/url-input/index.js +57 -73
- package/src/components/url-input/test/button.js +2 -0
- package/src/components/url-popover/image-url-input-ui.js +5 -4
- package/src/components/url-popover/test/__snapshots__/index.js.snap +8 -6
- package/src/components/url-popover/test/index.js +37 -9
- package/src/components/use-block-display-information/index.js +14 -5
- package/src/components/use-setting/index.js +13 -1
- package/src/components/use-setting/test/index.js +99 -0
- package/src/components/warning/test/index.js +2 -0
- package/src/components/writing-flow/index.js +1 -1
- package/src/content.scss +10 -0
- package/src/hooks/border.js +0 -1
- package/src/hooks/child-layout.js +190 -0
- package/src/hooks/color-panel.js +0 -1
- package/src/hooks/color.js +0 -2
- package/src/hooks/content-lock-ui.js +1 -1
- package/src/hooks/dimensions.js +45 -7
- package/src/hooks/font-family.js +3 -5
- package/src/hooks/font-size.js +13 -4
- package/src/hooks/layout.js +60 -0
- package/src/hooks/min-height.js +2 -19
- package/src/hooks/test/use-typography-props.js +26 -0
- package/src/hooks/use-typography-props.js +15 -7
- package/src/store/reducer.js +471 -428
- package/src/store/selectors.js +57 -59
- package/src/store/test/performance.js +71 -0
- package/src/store/test/reducer.js +623 -491
- package/src/store/test/selectors.js +1820 -1306
- package/src/style.scss +4 -7
- package/src/utils/pasting.js +3 -9
- package/src/utils/sorting.js +54 -0
- package/src/utils/test/sorting.js +49 -0
- package/tsconfig.tsbuildinfo +1 -1
- package/build/components/block-preview/live.js +0 -30
- package/build/components/block-preview/live.js.map +0 -1
- package/build/components/colors-gradients/use-common-single-multiple-selects.js +0 -21
- package/build/components/colors-gradients/use-common-single-multiple-selects.js.map +0 -1
- package/build/components/rich-text/file-paste-handler.js +0 -21
- package/build/components/rich-text/file-paste-handler.js.map +0 -1
- package/build-module/components/block-preview/live.js +0 -20
- package/build-module/components/block-preview/live.js.map +0 -1
- package/build-module/components/colors-gradients/use-common-single-multiple-selects.js +0 -11
- package/build-module/components/colors-gradients/use-common-single-multiple-selects.js.map +0 -1
- package/build-module/components/rich-text/file-paste-handler.js +0 -13
- package/build-module/components/rich-text/file-paste-handler.js.map +0 -1
- package/src/components/block-preview/live.js +0 -19
- package/src/components/colors-gradients/use-common-single-multiple-selects.js +0 -11
- package/src/components/rich-text/file-paste-handler.js +0 -13
package/src/store/reducer.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* External dependencies
|
|
3
3
|
*/
|
|
4
|
-
import
|
|
4
|
+
import fastDeepEqual from 'fast-deep-equal/es6';
|
|
5
5
|
|
|
6
6
|
/**
|
|
7
7
|
* WordPress dependencies
|
|
@@ -28,16 +28,18 @@ const identity = ( x ) => x;
|
|
|
28
28
|
* @return {Object} Block order map object.
|
|
29
29
|
*/
|
|
30
30
|
function mapBlockOrder( blocks, rootClientId = '' ) {
|
|
31
|
-
const result =
|
|
32
|
-
|
|
31
|
+
const result = new Map();
|
|
32
|
+
const current = [];
|
|
33
|
+
result.set( rootClientId, current );
|
|
33
34
|
blocks.forEach( ( block ) => {
|
|
34
35
|
const { clientId, innerBlocks } = block;
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
36
|
+
current.push( clientId );
|
|
37
|
+
mapBlockOrder( innerBlocks, clientId ).forEach(
|
|
38
|
+
( order, subClientId ) => {
|
|
39
|
+
result.set( subClientId, order );
|
|
40
|
+
}
|
|
41
|
+
);
|
|
39
42
|
} );
|
|
40
|
-
|
|
41
43
|
return result;
|
|
42
44
|
}
|
|
43
45
|
|
|
@@ -51,15 +53,18 @@ function mapBlockOrder( blocks, rootClientId = '' ) {
|
|
|
51
53
|
* @return {Object} Block order map object.
|
|
52
54
|
*/
|
|
53
55
|
function mapBlockParents( blocks, rootClientId = '' ) {
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
)
|
|
61
|
-
|
|
62
|
-
|
|
56
|
+
const result = [];
|
|
57
|
+
const stack = [ [ rootClientId, blocks ] ];
|
|
58
|
+
while ( stack.length ) {
|
|
59
|
+
const [ parent, currentBlocks ] = stack.shift();
|
|
60
|
+
currentBlocks.forEach( ( { innerBlocks, ...block } ) => {
|
|
61
|
+
result.push( [ block.clientId, parent ] );
|
|
62
|
+
if ( innerBlocks?.length ) {
|
|
63
|
+
stack.push( [ block.clientId, innerBlocks ] );
|
|
64
|
+
}
|
|
65
|
+
} );
|
|
66
|
+
}
|
|
67
|
+
return result;
|
|
63
68
|
}
|
|
64
69
|
|
|
65
70
|
/**
|
|
@@ -70,16 +75,28 @@ function mapBlockParents( blocks, rootClientId = '' ) {
|
|
|
70
75
|
* @param {Array} blocks Blocks to flatten.
|
|
71
76
|
* @param {Function} transform Transforming function to be applied to each block.
|
|
72
77
|
*
|
|
73
|
-
* @return {
|
|
78
|
+
* @return {Array} Flattened object.
|
|
74
79
|
*/
|
|
75
80
|
function flattenBlocks( blocks, transform = identity ) {
|
|
76
|
-
const result =
|
|
81
|
+
const result = [];
|
|
77
82
|
|
|
78
83
|
const stack = [ ...blocks ];
|
|
79
84
|
while ( stack.length ) {
|
|
80
85
|
const { innerBlocks, ...block } = stack.shift();
|
|
81
86
|
stack.push( ...innerBlocks );
|
|
82
|
-
result[ block.clientId
|
|
87
|
+
result.push( [ block.clientId, transform( block ) ] );
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
return result;
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
function getFlattenedClientIds( blocks ) {
|
|
94
|
+
const result = {};
|
|
95
|
+
const stack = [ ...blocks ];
|
|
96
|
+
while ( stack.length ) {
|
|
97
|
+
const { innerBlocks, ...block } = stack.shift();
|
|
98
|
+
stack.push( ...innerBlocks );
|
|
99
|
+
result[ block.clientId ] = true;
|
|
83
100
|
}
|
|
84
101
|
|
|
85
102
|
return result;
|
|
@@ -92,10 +109,13 @@ function flattenBlocks( blocks, transform = identity ) {
|
|
|
92
109
|
*
|
|
93
110
|
* @param {Array} blocks Blocks to flatten.
|
|
94
111
|
*
|
|
95
|
-
* @return {
|
|
112
|
+
* @return {Array} Flattened block attributes object.
|
|
96
113
|
*/
|
|
97
114
|
function getFlattenedBlocksWithoutAttributes( blocks ) {
|
|
98
|
-
return flattenBlocks( blocks, ( block ) =>
|
|
115
|
+
return flattenBlocks( blocks, ( block ) => {
|
|
116
|
+
const { attributes, ...restBlock } = block;
|
|
117
|
+
return restBlock;
|
|
118
|
+
} );
|
|
99
119
|
}
|
|
100
120
|
|
|
101
121
|
/**
|
|
@@ -105,29 +125,12 @@ function getFlattenedBlocksWithoutAttributes( blocks ) {
|
|
|
105
125
|
*
|
|
106
126
|
* @param {Array} blocks Blocks to flatten.
|
|
107
127
|
*
|
|
108
|
-
* @return {
|
|
128
|
+
* @return {Array} Flattened block attributes object.
|
|
109
129
|
*/
|
|
110
130
|
function getFlattenedBlockAttributes( blocks ) {
|
|
111
131
|
return flattenBlocks( blocks, ( block ) => block.attributes );
|
|
112
132
|
}
|
|
113
133
|
|
|
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
134
|
/**
|
|
132
135
|
* Returns true if the two object arguments have the same keys, or false
|
|
133
136
|
* otherwise.
|
|
@@ -138,7 +141,7 @@ function getMutateSafeObject( original, working ) {
|
|
|
138
141
|
* @return {boolean} Whether the two objects have the same keys.
|
|
139
142
|
*/
|
|
140
143
|
export function hasSameKeys( a, b ) {
|
|
141
|
-
return
|
|
144
|
+
return fastDeepEqual( Object.keys( a ), Object.keys( b ) );
|
|
142
145
|
}
|
|
143
146
|
|
|
144
147
|
/**
|
|
@@ -156,13 +159,13 @@ export function isUpdatingSameBlockAttribute( action, lastAction ) {
|
|
|
156
159
|
action.type === 'UPDATE_BLOCK_ATTRIBUTES' &&
|
|
157
160
|
lastAction !== undefined &&
|
|
158
161
|
lastAction.type === 'UPDATE_BLOCK_ATTRIBUTES' &&
|
|
159
|
-
|
|
162
|
+
fastDeepEqual( action.clientIds, lastAction.clientIds ) &&
|
|
160
163
|
hasSameKeys( action.attributes, lastAction.attributes )
|
|
161
164
|
);
|
|
162
165
|
}
|
|
163
166
|
|
|
164
|
-
function
|
|
165
|
-
const
|
|
167
|
+
function updateBlockTreeForBlocks( state, blocks ) {
|
|
168
|
+
const treeToUpdate = state.tree;
|
|
166
169
|
const stack = [ ...blocks ];
|
|
167
170
|
const flattenedBlocks = [ ...blocks ];
|
|
168
171
|
while ( stack.length ) {
|
|
@@ -172,33 +175,34 @@ function buildBlockTree( state, blocks ) {
|
|
|
172
175
|
}
|
|
173
176
|
// Create objects before mutating them, that way it's always defined.
|
|
174
177
|
for ( const block of flattenedBlocks ) {
|
|
175
|
-
|
|
178
|
+
treeToUpdate.set( block.clientId, {} );
|
|
176
179
|
}
|
|
177
180
|
for ( const block of flattenedBlocks ) {
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
(
|
|
183
|
-
|
|
184
|
-
|
|
181
|
+
treeToUpdate.set(
|
|
182
|
+
block.clientId,
|
|
183
|
+
Object.assign( treeToUpdate.get( block.clientId ), {
|
|
184
|
+
...state.byClientId.get( block.clientId ),
|
|
185
|
+
attributes: state.attributes.get( block.clientId ),
|
|
186
|
+
innerBlocks: block.innerBlocks.map( ( subBlock ) =>
|
|
187
|
+
treeToUpdate.get( subBlock.clientId )
|
|
188
|
+
),
|
|
189
|
+
} )
|
|
190
|
+
);
|
|
185
191
|
}
|
|
186
|
-
|
|
187
|
-
return result;
|
|
188
192
|
}
|
|
189
193
|
|
|
190
194
|
function updateParentInnerBlocksInTree(
|
|
191
195
|
state,
|
|
192
|
-
tree,
|
|
193
196
|
updatedClientIds,
|
|
194
197
|
updateChildrenOfUpdatedClientIds = false
|
|
195
198
|
) {
|
|
199
|
+
const treeToUpdate = state.tree;
|
|
196
200
|
const uncontrolledParents = new Set( [] );
|
|
197
201
|
const controlledParents = new Set();
|
|
198
202
|
for ( const clientId of updatedClientIds ) {
|
|
199
203
|
let current = updateChildrenOfUpdatedClientIds
|
|
200
204
|
? clientId
|
|
201
|
-
: state.parents
|
|
205
|
+
: state.parents.get( clientId );
|
|
202
206
|
do {
|
|
203
207
|
if ( state.controlledInnerBlocks[ current ] ) {
|
|
204
208
|
// Should stop on controlled blocks.
|
|
@@ -208,7 +212,7 @@ function updateParentInnerBlocksInTree(
|
|
|
208
212
|
} else {
|
|
209
213
|
// Else continue traversing up through parents.
|
|
210
214
|
uncontrolledParents.add( current );
|
|
211
|
-
current = state.parents
|
|
215
|
+
current = state.parents.get( current );
|
|
212
216
|
}
|
|
213
217
|
} while ( current !== undefined );
|
|
214
218
|
}
|
|
@@ -216,27 +220,23 @@ function updateParentInnerBlocksInTree(
|
|
|
216
220
|
// To make sure the order of assignments doesn't matter,
|
|
217
221
|
// we first create empty objects and mutates the inner blocks later.
|
|
218
222
|
for ( const clientId of uncontrolledParents ) {
|
|
219
|
-
|
|
220
|
-
...tree[ clientId ],
|
|
221
|
-
};
|
|
223
|
+
treeToUpdate.set( clientId, { ...treeToUpdate.get( clientId ) } );
|
|
222
224
|
}
|
|
223
225
|
for ( const clientId of uncontrolledParents ) {
|
|
224
|
-
|
|
225
|
-
(
|
|
226
|
-
);
|
|
226
|
+
treeToUpdate.get( clientId ).innerBlocks = (
|
|
227
|
+
state.order.get( clientId ) || []
|
|
228
|
+
).map( ( subClientId ) => treeToUpdate.get( subClientId ) );
|
|
227
229
|
}
|
|
228
230
|
|
|
229
231
|
// Controlled parent blocks, need a dedicated key for their inner blocks
|
|
230
232
|
// to be used when doing getBlocks( controlledBlockClientId ).
|
|
231
233
|
for ( const clientId of controlledParents ) {
|
|
232
|
-
|
|
233
|
-
innerBlocks: ( state.order
|
|
234
|
-
( subClientId ) =>
|
|
234
|
+
treeToUpdate.set( 'controlled||' + clientId, {
|
|
235
|
+
innerBlocks: ( state.order.get( clientId ) || [] ).map(
|
|
236
|
+
( subClientId ) => treeToUpdate.get( subClientId )
|
|
235
237
|
),
|
|
236
|
-
};
|
|
238
|
+
} );
|
|
237
239
|
}
|
|
238
|
-
|
|
239
|
-
return tree;
|
|
240
240
|
}
|
|
241
241
|
|
|
242
242
|
/**
|
|
@@ -257,82 +257,70 @@ const withBlockTree =
|
|
|
257
257
|
return state;
|
|
258
258
|
}
|
|
259
259
|
|
|
260
|
-
newState.tree = state.tree ? state.tree :
|
|
260
|
+
newState.tree = state.tree ? state.tree : new Map();
|
|
261
261
|
switch ( action.type ) {
|
|
262
262
|
case 'RECEIVE_BLOCKS':
|
|
263
263
|
case 'INSERT_BLOCKS': {
|
|
264
|
-
|
|
265
|
-
newState.
|
|
264
|
+
newState.tree = new Map( newState.tree );
|
|
265
|
+
updateBlockTreeForBlocks( newState, action.blocks );
|
|
266
|
+
updateParentInnerBlocksInTree(
|
|
266
267
|
newState,
|
|
267
|
-
{
|
|
268
|
-
...newState.tree,
|
|
269
|
-
...subTree,
|
|
270
|
-
},
|
|
271
268
|
action.rootClientId ? [ action.rootClientId ] : [ '' ],
|
|
272
269
|
true
|
|
273
270
|
);
|
|
274
271
|
break;
|
|
275
272
|
}
|
|
276
273
|
case 'UPDATE_BLOCK':
|
|
277
|
-
newState.tree =
|
|
274
|
+
newState.tree = new Map( newState.tree );
|
|
275
|
+
newState.tree.set( action.clientId, {
|
|
276
|
+
...newState.tree.get( action.clientId ),
|
|
277
|
+
...newState.byClientId.get( action.clientId ),
|
|
278
|
+
attributes: newState.attributes.get( action.clientId ),
|
|
279
|
+
} );
|
|
280
|
+
updateParentInnerBlocksInTree(
|
|
278
281
|
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
282
|
[ action.clientId ],
|
|
288
283
|
false
|
|
289
284
|
);
|
|
290
285
|
break;
|
|
291
286
|
case 'UPDATE_BLOCK_ATTRIBUTES': {
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
{}
|
|
301
|
-
);
|
|
302
|
-
newState.tree = updateParentInnerBlocksInTree(
|
|
287
|
+
newState.tree = new Map( newState.tree );
|
|
288
|
+
action.clientIds.forEach( ( clientId ) => {
|
|
289
|
+
newState.tree.set( clientId, {
|
|
290
|
+
...newState.tree.get( clientId ),
|
|
291
|
+
attributes: newState.attributes.get( clientId ),
|
|
292
|
+
} );
|
|
293
|
+
} );
|
|
294
|
+
updateParentInnerBlocksInTree(
|
|
303
295
|
newState,
|
|
304
|
-
{
|
|
305
|
-
...newState.tree,
|
|
306
|
-
...newSubTree,
|
|
307
|
-
},
|
|
308
296
|
action.clientIds,
|
|
309
297
|
false
|
|
310
298
|
);
|
|
311
299
|
break;
|
|
312
300
|
}
|
|
313
301
|
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
|
-
)
|
|
302
|
+
const inserterClientIds = getFlattenedClientIds(
|
|
303
|
+
action.blocks
|
|
304
|
+
);
|
|
305
|
+
newState.tree = new Map( newState.tree );
|
|
306
|
+
action.replacedClientIds
|
|
307
|
+
.concat(
|
|
308
|
+
// Controlled inner blocks are only removed
|
|
309
|
+
// if the block doesn't move to another position
|
|
310
|
+
// otherwise their content will be lost.
|
|
311
|
+
action.replacedClientIds
|
|
312
|
+
.filter(
|
|
313
|
+
( clientId ) => ! inserterClientIds[ clientId ]
|
|
332
314
|
)
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
315
|
+
.map( ( clientId ) => 'controlled||' + clientId )
|
|
316
|
+
)
|
|
317
|
+
.forEach( ( key ) => {
|
|
318
|
+
newState.tree.delete( key );
|
|
319
|
+
} );
|
|
320
|
+
|
|
321
|
+
updateBlockTreeForBlocks( newState, action.blocks );
|
|
322
|
+
updateParentInnerBlocksInTree(
|
|
323
|
+
newState,
|
|
336
324
|
action.blocks.map( ( b ) => b.clientId ),
|
|
337
325
|
false
|
|
338
326
|
);
|
|
@@ -341,18 +329,19 @@ const withBlockTree =
|
|
|
341
329
|
const parentsOfRemovedBlocks = [];
|
|
342
330
|
for ( const clientId of action.clientIds ) {
|
|
343
331
|
if (
|
|
344
|
-
state.parents
|
|
345
|
-
( state.parents
|
|
346
|
-
newState.byClientId
|
|
332
|
+
state.parents.get( clientId ) !== undefined &&
|
|
333
|
+
( state.parents.get( clientId ) === '' ||
|
|
334
|
+
newState.byClientId.get(
|
|
335
|
+
state.parents.get( clientId )
|
|
336
|
+
) )
|
|
347
337
|
) {
|
|
348
338
|
parentsOfRemovedBlocks.push(
|
|
349
|
-
state.parents
|
|
339
|
+
state.parents.get( clientId )
|
|
350
340
|
);
|
|
351
341
|
}
|
|
352
342
|
}
|
|
353
|
-
|
|
343
|
+
updateParentInnerBlocksInTree(
|
|
354
344
|
newState,
|
|
355
|
-
newState.tree,
|
|
356
345
|
parentsOfRemovedBlocks,
|
|
357
346
|
true
|
|
358
347
|
);
|
|
@@ -362,25 +351,29 @@ const withBlockTree =
|
|
|
362
351
|
const parentsOfRemovedBlocks = [];
|
|
363
352
|
for ( const clientId of action.clientIds ) {
|
|
364
353
|
if (
|
|
365
|
-
state.parents
|
|
366
|
-
( state.parents
|
|
367
|
-
newState.byClientId
|
|
354
|
+
state.parents.get( clientId ) !== undefined &&
|
|
355
|
+
( state.parents.get( clientId ) === '' ||
|
|
356
|
+
newState.byClientId.get(
|
|
357
|
+
state.parents.get( clientId )
|
|
358
|
+
) )
|
|
368
359
|
) {
|
|
369
360
|
parentsOfRemovedBlocks.push(
|
|
370
|
-
state.parents
|
|
361
|
+
state.parents.get( clientId )
|
|
371
362
|
);
|
|
372
363
|
}
|
|
373
364
|
}
|
|
374
|
-
newState.tree =
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
action.removedClientIds.map(
|
|
380
|
-
( clientId ) => 'controlled||' + clientId
|
|
381
|
-
)
|
|
365
|
+
newState.tree = new Map( newState.tree );
|
|
366
|
+
action.removedClientIds
|
|
367
|
+
.concat(
|
|
368
|
+
action.removedClientIds.map(
|
|
369
|
+
( clientId ) => 'controlled||' + clientId
|
|
382
370
|
)
|
|
383
|
-
)
|
|
371
|
+
)
|
|
372
|
+
.forEach( ( key ) => {
|
|
373
|
+
newState.tree.delete( key );
|
|
374
|
+
} );
|
|
375
|
+
updateParentInnerBlocksInTree(
|
|
376
|
+
newState,
|
|
384
377
|
parentsOfRemovedBlocks,
|
|
385
378
|
true
|
|
386
379
|
);
|
|
@@ -395,9 +388,9 @@ const withBlockTree =
|
|
|
395
388
|
if ( action.toRootClientId ) {
|
|
396
389
|
updatedBlockUids.push( action.toRootClientId );
|
|
397
390
|
}
|
|
398
|
-
newState.tree =
|
|
391
|
+
newState.tree = new Map( newState.tree );
|
|
392
|
+
updateParentInnerBlocksInTree(
|
|
399
393
|
newState,
|
|
400
|
-
newState.tree,
|
|
401
394
|
updatedBlockUids,
|
|
402
395
|
true
|
|
403
396
|
);
|
|
@@ -408,39 +401,35 @@ const withBlockTree =
|
|
|
408
401
|
const updatedBlockUids = [
|
|
409
402
|
action.rootClientId ? action.rootClientId : '',
|
|
410
403
|
];
|
|
411
|
-
newState.tree =
|
|
404
|
+
newState.tree = new Map( newState.tree );
|
|
405
|
+
updateParentInnerBlocksInTree(
|
|
412
406
|
newState,
|
|
413
|
-
newState.tree,
|
|
414
407
|
updatedBlockUids,
|
|
415
408
|
true
|
|
416
409
|
);
|
|
417
410
|
break;
|
|
418
411
|
}
|
|
419
412
|
case 'SAVE_REUSABLE_BLOCK_SUCCESS': {
|
|
420
|
-
const updatedBlockUids =
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
newState.tree =
|
|
413
|
+
const updatedBlockUids = [];
|
|
414
|
+
newState.attributes.forEach( ( attributes, clientId ) => {
|
|
415
|
+
if (
|
|
416
|
+
newState.byClientId.get( clientId ).name ===
|
|
417
|
+
'core/block' &&
|
|
418
|
+
attributes.ref === action.updatedId
|
|
419
|
+
) {
|
|
420
|
+
updatedBlockUids.push( clientId );
|
|
421
|
+
}
|
|
422
|
+
} );
|
|
423
|
+
newState.tree = new Map( newState.tree );
|
|
424
|
+
updatedBlockUids.forEach( ( clientId ) => {
|
|
425
|
+
newState.tree.set( clientId, {
|
|
426
|
+
...newState.byClientId.get( clientId ),
|
|
427
|
+
attributes: newState.attributes.get( clientId ),
|
|
428
|
+
innerBlocks: newState.tree.get( clientId ).innerBlocks,
|
|
429
|
+
} );
|
|
430
|
+
} );
|
|
431
|
+
updateParentInnerBlocksInTree(
|
|
431
432
|
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
433
|
updatedBlockUids,
|
|
445
434
|
false
|
|
446
435
|
);
|
|
@@ -549,7 +538,7 @@ const withInnerBlocksRemoveCascade = ( reducer ) => ( state, action ) => {
|
|
|
549
538
|
let result = clientIds;
|
|
550
539
|
for ( let i = 0; i < result.length; i++ ) {
|
|
551
540
|
if (
|
|
552
|
-
! state.order
|
|
541
|
+
! state.order.get( result[ i ] ) ||
|
|
553
542
|
( action.keepControlledInnerBlocks &&
|
|
554
543
|
action.keepControlledInnerBlocks[ result[ i ] ] )
|
|
555
544
|
) {
|
|
@@ -560,7 +549,7 @@ const withInnerBlocksRemoveCascade = ( reducer ) => ( state, action ) => {
|
|
|
560
549
|
result = [ ...result ];
|
|
561
550
|
}
|
|
562
551
|
|
|
563
|
-
result.push( ...state.order
|
|
552
|
+
result.push( ...state.order.get( result[ i ] ) );
|
|
564
553
|
}
|
|
565
554
|
return result;
|
|
566
555
|
};
|
|
@@ -601,23 +590,22 @@ const withBlockReset = ( reducer ) => ( state, action ) => {
|
|
|
601
590
|
if ( action.type === 'RESET_BLOCKS' ) {
|
|
602
591
|
const newState = {
|
|
603
592
|
...state,
|
|
604
|
-
byClientId:
|
|
605
|
-
|
|
593
|
+
byClientId: new Map(
|
|
594
|
+
getFlattenedBlocksWithoutAttributes( action.blocks )
|
|
595
|
+
),
|
|
596
|
+
attributes: new Map( getFlattenedBlockAttributes( action.blocks ) ),
|
|
606
597
|
order: mapBlockOrder( action.blocks ),
|
|
607
|
-
parents: mapBlockParents( action.blocks ),
|
|
598
|
+
parents: new Map( mapBlockParents( action.blocks ) ),
|
|
608
599
|
controlledInnerBlocks: {},
|
|
609
600
|
};
|
|
610
601
|
|
|
611
|
-
|
|
612
|
-
newState.
|
|
613
|
-
|
|
614
|
-
|
|
615
|
-
|
|
616
|
-
|
|
617
|
-
|
|
618
|
-
),
|
|
619
|
-
},
|
|
620
|
-
};
|
|
602
|
+
newState.tree = new Map( state?.tree );
|
|
603
|
+
updateBlockTreeForBlocks( newState, action.blocks );
|
|
604
|
+
newState.tree.set( '', {
|
|
605
|
+
innerBlocks: action.blocks.map( ( subBlock ) =>
|
|
606
|
+
newState.tree.get( subBlock.clientId )
|
|
607
|
+
),
|
|
608
|
+
} );
|
|
621
609
|
|
|
622
610
|
return newState;
|
|
623
611
|
}
|
|
@@ -663,11 +651,11 @@ const withReplaceInnerBlocks = ( reducer ) => ( state, action ) => {
|
|
|
663
651
|
// marked block in the block state so that they can be reattached to the
|
|
664
652
|
// marked block when we re-insert everything a few lines below.
|
|
665
653
|
let stateAfterBlocksRemoval = state;
|
|
666
|
-
if ( state.order
|
|
654
|
+
if ( state.order.get( action.rootClientId ) ) {
|
|
667
655
|
stateAfterBlocksRemoval = reducer( stateAfterBlocksRemoval, {
|
|
668
656
|
type: 'REMOVE_BLOCKS',
|
|
669
657
|
keepControlledInnerBlocks: nestedControllers,
|
|
670
|
-
clientIds: state.order
|
|
658
|
+
clientIds: state.order.get( action.rootClientId ),
|
|
671
659
|
} );
|
|
672
660
|
}
|
|
673
661
|
let stateAfterInsert = stateAfterBlocksRemoval;
|
|
@@ -681,25 +669,20 @@ const withReplaceInnerBlocks = ( reducer ) => ( state, action ) => {
|
|
|
681
669
|
// We need to re-attach the controlled inner blocks to the blocks tree and
|
|
682
670
|
// preserve their block order. Otherwise, an inner block controller's blocks
|
|
683
671
|
// will be deleted entirely from its entity.
|
|
684
|
-
stateAfterInsert.order
|
|
685
|
-
|
|
686
|
-
|
|
687
|
-
|
|
688
|
-
|
|
689
|
-
|
|
690
|
-
|
|
691
|
-
|
|
692
|
-
|
|
693
|
-
|
|
694
|
-
|
|
695
|
-
|
|
696
|
-
|
|
697
|
-
|
|
698
|
-
result[ key ] = state.tree[ key ];
|
|
699
|
-
}
|
|
700
|
-
return result;
|
|
701
|
-
}, {} ),
|
|
702
|
-
};
|
|
672
|
+
const stateAfterInsertOrder = new Map( stateAfterInsert.order );
|
|
673
|
+
Object.keys( nestedControllers ).forEach( ( key ) => {
|
|
674
|
+
if ( state.order.get( key ) ) {
|
|
675
|
+
stateAfterInsertOrder.set( key, state.order.get( key ) );
|
|
676
|
+
}
|
|
677
|
+
} );
|
|
678
|
+
stateAfterInsert.order = stateAfterInsertOrder;
|
|
679
|
+
stateAfterInsert.tree = new Map( stateAfterInsert.tree );
|
|
680
|
+
Object.keys( nestedControllers ).forEach( ( _key ) => {
|
|
681
|
+
const key = `controlled||${ _key }`;
|
|
682
|
+
if ( state.tree.has( key ) ) {
|
|
683
|
+
stateAfterInsert.tree.set( key, state.tree.get( key ) );
|
|
684
|
+
}
|
|
685
|
+
} );
|
|
703
686
|
}
|
|
704
687
|
return stateAfterInsert;
|
|
705
688
|
};
|
|
@@ -724,21 +707,16 @@ const withSaveReusableBlock = ( reducer ) => ( state, action ) => {
|
|
|
724
707
|
}
|
|
725
708
|
|
|
726
709
|
state = { ...state };
|
|
727
|
-
|
|
728
|
-
state.attributes
|
|
729
|
-
state.
|
|
730
|
-
( attributes
|
|
731
|
-
|
|
732
|
-
|
|
733
|
-
|
|
734
|
-
|
|
735
|
-
ref: updatedId,
|
|
736
|
-
};
|
|
737
|
-
}
|
|
738
|
-
|
|
739
|
-
return attributes;
|
|
710
|
+
state.attributes = new Map( state.attributes );
|
|
711
|
+
state.attributes.forEach( ( attributes, clientId ) => {
|
|
712
|
+
const { name } = state.byClientId.get( clientId );
|
|
713
|
+
if ( name === 'core/block' && attributes.ref === id ) {
|
|
714
|
+
state.attributes.set( clientId, {
|
|
715
|
+
...attributes,
|
|
716
|
+
ref: updatedId,
|
|
717
|
+
} );
|
|
740
718
|
}
|
|
741
|
-
);
|
|
719
|
+
} );
|
|
742
720
|
}
|
|
743
721
|
|
|
744
722
|
return reducer( state, action );
|
|
@@ -784,163 +762,211 @@ export const blocks = pipe(
|
|
|
784
762
|
withIgnoredBlockChange,
|
|
785
763
|
withResetControlledBlocks
|
|
786
764
|
)( {
|
|
787
|
-
|
|
765
|
+
// The state is using a Map instead of a plain object for performance reasons.
|
|
766
|
+
// You can run the "./test/performance.js" unit test to check the impact
|
|
767
|
+
// code changes can have on this reducer.
|
|
768
|
+
byClientId( state = new Map(), action ) {
|
|
788
769
|
switch ( action.type ) {
|
|
789
770
|
case 'RECEIVE_BLOCKS':
|
|
790
|
-
case 'INSERT_BLOCKS':
|
|
791
|
-
|
|
792
|
-
|
|
793
|
-
|
|
794
|
-
|
|
795
|
-
|
|
796
|
-
|
|
771
|
+
case 'INSERT_BLOCKS': {
|
|
772
|
+
const newState = new Map( state );
|
|
773
|
+
getFlattenedBlocksWithoutAttributes( action.blocks ).forEach(
|
|
774
|
+
( [ key, value ] ) => {
|
|
775
|
+
newState.set( key, value );
|
|
776
|
+
}
|
|
777
|
+
);
|
|
778
|
+
return newState;
|
|
779
|
+
}
|
|
780
|
+
case 'UPDATE_BLOCK': {
|
|
797
781
|
// Ignore updates if block isn't known.
|
|
798
|
-
if ( ! state
|
|
782
|
+
if ( ! state.has( action.clientId ) ) {
|
|
799
783
|
return state;
|
|
800
784
|
}
|
|
801
785
|
|
|
802
786
|
// Do nothing if only attributes change.
|
|
803
|
-
const changes =
|
|
804
|
-
if (
|
|
787
|
+
const { attributes, ...changes } = action.updates;
|
|
788
|
+
if ( Object.values( changes ).length === 0 ) {
|
|
805
789
|
return state;
|
|
806
790
|
}
|
|
807
791
|
|
|
808
|
-
|
|
809
|
-
|
|
810
|
-
|
|
811
|
-
|
|
812
|
-
|
|
813
|
-
|
|
814
|
-
|
|
792
|
+
const newState = new Map( state );
|
|
793
|
+
newState.set( action.clientId, {
|
|
794
|
+
...state.get( action.clientId ),
|
|
795
|
+
...changes,
|
|
796
|
+
} );
|
|
797
|
+
return newState;
|
|
798
|
+
}
|
|
815
799
|
|
|
816
|
-
case 'REPLACE_BLOCKS_AUGMENTED_WITH_CHILDREN':
|
|
800
|
+
case 'REPLACE_BLOCKS_AUGMENTED_WITH_CHILDREN': {
|
|
817
801
|
if ( ! action.blocks ) {
|
|
818
802
|
return state;
|
|
819
803
|
}
|
|
820
804
|
|
|
821
|
-
|
|
822
|
-
|
|
823
|
-
|
|
824
|
-
};
|
|
805
|
+
const newState = new Map( state );
|
|
806
|
+
action.replacedClientIds.forEach( ( clientId ) => {
|
|
807
|
+
newState.delete( clientId );
|
|
808
|
+
} );
|
|
825
809
|
|
|
826
|
-
|
|
827
|
-
|
|
810
|
+
getFlattenedBlocksWithoutAttributes( action.blocks ).forEach(
|
|
811
|
+
( [ key, value ] ) => {
|
|
812
|
+
newState.set( key, value );
|
|
813
|
+
}
|
|
814
|
+
);
|
|
815
|
+
return newState;
|
|
816
|
+
}
|
|
817
|
+
|
|
818
|
+
case 'REMOVE_BLOCKS_AUGMENTED_WITH_CHILDREN': {
|
|
819
|
+
const newState = new Map( state );
|
|
820
|
+
action.removedClientIds.forEach( ( clientId ) => {
|
|
821
|
+
newState.delete( clientId );
|
|
822
|
+
} );
|
|
823
|
+
return newState;
|
|
824
|
+
}
|
|
828
825
|
}
|
|
829
826
|
|
|
830
827
|
return state;
|
|
831
828
|
},
|
|
832
829
|
|
|
833
|
-
|
|
830
|
+
// The state is using a Map instead of a plain object for performance reasons.
|
|
831
|
+
// You can run the "./test/performance.js" unit test to check the impact
|
|
832
|
+
// code changes can have on this reducer.
|
|
833
|
+
attributes( state = new Map(), action ) {
|
|
834
834
|
switch ( action.type ) {
|
|
835
835
|
case 'RECEIVE_BLOCKS':
|
|
836
|
-
case 'INSERT_BLOCKS':
|
|
837
|
-
|
|
838
|
-
|
|
839
|
-
|
|
840
|
-
|
|
836
|
+
case 'INSERT_BLOCKS': {
|
|
837
|
+
const newState = new Map( state );
|
|
838
|
+
getFlattenedBlockAttributes( action.blocks ).forEach(
|
|
839
|
+
( [ key, value ] ) => {
|
|
840
|
+
newState.set( key, value );
|
|
841
|
+
}
|
|
842
|
+
);
|
|
843
|
+
return newState;
|
|
844
|
+
}
|
|
841
845
|
|
|
842
|
-
case 'UPDATE_BLOCK':
|
|
846
|
+
case 'UPDATE_BLOCK': {
|
|
843
847
|
// Ignore updates if block isn't known or there are no attribute changes.
|
|
844
848
|
if (
|
|
845
|
-
! state
|
|
849
|
+
! state.get( action.clientId ) ||
|
|
846
850
|
! action.updates.attributes
|
|
847
851
|
) {
|
|
848
852
|
return state;
|
|
849
853
|
}
|
|
850
854
|
|
|
851
|
-
|
|
852
|
-
|
|
853
|
-
|
|
854
|
-
|
|
855
|
-
|
|
856
|
-
|
|
857
|
-
|
|
855
|
+
const newState = new Map( state );
|
|
856
|
+
newState.set( action.clientId, {
|
|
857
|
+
...state.get( action.clientId ),
|
|
858
|
+
...action.updates.attributes,
|
|
859
|
+
} );
|
|
860
|
+
return newState;
|
|
861
|
+
}
|
|
858
862
|
|
|
859
863
|
case 'UPDATE_BLOCK_ATTRIBUTES': {
|
|
860
864
|
// Avoid a state change if none of the block IDs are known.
|
|
861
|
-
if ( action.clientIds.every( ( id ) => ! state
|
|
865
|
+
if ( action.clientIds.every( ( id ) => ! state.get( id ) ) ) {
|
|
862
866
|
return state;
|
|
863
867
|
}
|
|
864
868
|
|
|
865
|
-
|
|
866
|
-
|
|
867
|
-
|
|
868
|
-
|
|
869
|
-
|
|
870
|
-
|
|
871
|
-
|
|
872
|
-
|
|
873
|
-
|
|
874
|
-
|
|
875
|
-
|
|
876
|
-
|
|
877
|
-
|
|
878
|
-
|
|
879
|
-
|
|
880
|
-
|
|
881
|
-
|
|
882
|
-
|
|
883
|
-
}
|
|
884
|
-
} )
|
|
885
|
-
|
|
886
|
-
|
|
887
|
-
|
|
888
|
-
|
|
889
|
-
|
|
890
|
-
|
|
891
|
-
|
|
892
|
-
) {
|
|
893
|
-
return state;
|
|
869
|
+
let hasChange = false;
|
|
870
|
+
const newState = new Map( state );
|
|
871
|
+
for ( const clientId of action.clientIds ) {
|
|
872
|
+
const updatedAttributeEntries = Object.entries(
|
|
873
|
+
action.uniqueByBlock
|
|
874
|
+
? action.attributes[ clientId ]
|
|
875
|
+
: action.attributes ?? {}
|
|
876
|
+
);
|
|
877
|
+
if ( updatedAttributeEntries.length === 0 ) {
|
|
878
|
+
continue;
|
|
879
|
+
}
|
|
880
|
+
let hasUpdatedAttributes = false;
|
|
881
|
+
const existingAttributes = state.get( clientId );
|
|
882
|
+
const newAttributes = {};
|
|
883
|
+
updatedAttributeEntries.forEach( ( [ key, value ] ) => {
|
|
884
|
+
if ( existingAttributes[ key ] !== value ) {
|
|
885
|
+
hasUpdatedAttributes = true;
|
|
886
|
+
newAttributes[ key ] = value;
|
|
887
|
+
}
|
|
888
|
+
} );
|
|
889
|
+
hasChange = hasChange || hasUpdatedAttributes;
|
|
890
|
+
if ( hasUpdatedAttributes ) {
|
|
891
|
+
newState.set( clientId, {
|
|
892
|
+
...existingAttributes,
|
|
893
|
+
...newAttributes,
|
|
894
|
+
} );
|
|
895
|
+
}
|
|
894
896
|
}
|
|
895
897
|
|
|
896
|
-
return
|
|
898
|
+
return hasChange ? newState : state;
|
|
897
899
|
}
|
|
898
900
|
|
|
899
|
-
case 'REPLACE_BLOCKS_AUGMENTED_WITH_CHILDREN':
|
|
901
|
+
case 'REPLACE_BLOCKS_AUGMENTED_WITH_CHILDREN': {
|
|
900
902
|
if ( ! action.blocks ) {
|
|
901
903
|
return state;
|
|
902
904
|
}
|
|
903
905
|
|
|
904
|
-
|
|
905
|
-
|
|
906
|
-
|
|
907
|
-
};
|
|
906
|
+
const newState = new Map( state );
|
|
907
|
+
action.replacedClientIds.forEach( ( clientId ) => {
|
|
908
|
+
newState.delete( clientId );
|
|
909
|
+
} );
|
|
910
|
+
getFlattenedBlockAttributes( action.blocks ).forEach(
|
|
911
|
+
( [ key, value ] ) => {
|
|
912
|
+
newState.set( key, value );
|
|
913
|
+
}
|
|
914
|
+
);
|
|
915
|
+
return newState;
|
|
916
|
+
}
|
|
908
917
|
|
|
909
|
-
case 'REMOVE_BLOCKS_AUGMENTED_WITH_CHILDREN':
|
|
910
|
-
|
|
918
|
+
case 'REMOVE_BLOCKS_AUGMENTED_WITH_CHILDREN': {
|
|
919
|
+
const newState = new Map( state );
|
|
920
|
+
action.removedClientIds.forEach( ( clientId ) => {
|
|
921
|
+
newState.delete( clientId );
|
|
922
|
+
} );
|
|
923
|
+
return newState;
|
|
924
|
+
}
|
|
911
925
|
}
|
|
912
926
|
|
|
913
927
|
return state;
|
|
914
928
|
},
|
|
915
929
|
|
|
916
|
-
|
|
930
|
+
// The state is using a Map instead of a plain object for performance reasons.
|
|
931
|
+
// You can run the "./test/performance.js" unit test to check the impact
|
|
932
|
+
// code changes can have on this reducer.
|
|
933
|
+
order( state = new Map(), action ) {
|
|
917
934
|
switch ( action.type ) {
|
|
918
935
|
case 'RECEIVE_BLOCKS': {
|
|
919
936
|
const blockOrder = mapBlockOrder( action.blocks );
|
|
920
|
-
|
|
921
|
-
|
|
922
|
-
|
|
923
|
-
|
|
924
|
-
|
|
937
|
+
const newState = new Map( state );
|
|
938
|
+
blockOrder.forEach( ( order, clientId ) => {
|
|
939
|
+
if ( clientId !== '' ) {
|
|
940
|
+
newState.set( clientId, order );
|
|
941
|
+
}
|
|
942
|
+
} );
|
|
943
|
+
newState.set(
|
|
944
|
+
'',
|
|
945
|
+
( state.get( '' ) ?? [] ).concat( blockOrder[ '' ] )
|
|
946
|
+
);
|
|
947
|
+
return newState;
|
|
925
948
|
}
|
|
926
949
|
case 'INSERT_BLOCKS': {
|
|
927
950
|
const { rootClientId = '' } = action;
|
|
928
|
-
const subState = state
|
|
951
|
+
const subState = state.get( rootClientId ) || [];
|
|
929
952
|
const mappedBlocks = mapBlockOrder(
|
|
930
953
|
action.blocks,
|
|
931
954
|
rootClientId
|
|
932
955
|
);
|
|
933
956
|
const { index = subState.length } = action;
|
|
934
|
-
|
|
935
|
-
|
|
936
|
-
|
|
937
|
-
|
|
938
|
-
|
|
957
|
+
const newState = new Map( state );
|
|
958
|
+
mappedBlocks.forEach( ( order, clientId ) => {
|
|
959
|
+
newState.set( clientId, order );
|
|
960
|
+
} );
|
|
961
|
+
newState.set(
|
|
962
|
+
rootClientId,
|
|
963
|
+
insertAt(
|
|
939
964
|
subState,
|
|
940
|
-
mappedBlocks
|
|
965
|
+
mappedBlocks.get( rootClientId ),
|
|
941
966
|
index
|
|
942
|
-
)
|
|
943
|
-
|
|
967
|
+
)
|
|
968
|
+
);
|
|
969
|
+
return newState;
|
|
944
970
|
}
|
|
945
971
|
|
|
946
972
|
case 'MOVE_BLOCKS_TO_POSITION': {
|
|
@@ -949,65 +975,68 @@ export const blocks = pipe(
|
|
|
949
975
|
toRootClientId = '',
|
|
950
976
|
clientIds,
|
|
951
977
|
} = action;
|
|
952
|
-
const { index = state
|
|
978
|
+
const { index = state.get( toRootClientId ).length } = action;
|
|
953
979
|
|
|
954
980
|
// Moving inside the same parent block.
|
|
955
981
|
if ( fromRootClientId === toRootClientId ) {
|
|
956
|
-
const subState = state
|
|
982
|
+
const subState = state.get( toRootClientId );
|
|
957
983
|
const fromIndex = subState.indexOf( clientIds[ 0 ] );
|
|
958
|
-
|
|
959
|
-
|
|
960
|
-
|
|
961
|
-
|
|
984
|
+
const newState = new Map( state );
|
|
985
|
+
newState.set(
|
|
986
|
+
toRootClientId,
|
|
987
|
+
moveTo(
|
|
988
|
+
state.get( toRootClientId ),
|
|
962
989
|
fromIndex,
|
|
963
990
|
index,
|
|
964
991
|
clientIds.length
|
|
965
|
-
)
|
|
966
|
-
|
|
992
|
+
)
|
|
993
|
+
);
|
|
994
|
+
return newState;
|
|
967
995
|
}
|
|
968
996
|
|
|
969
997
|
// Moving from a parent block to another.
|
|
970
|
-
|
|
971
|
-
|
|
972
|
-
|
|
973
|
-
|
|
974
|
-
|
|
975
|
-
) ?? []
|
|
976
|
-
|
|
977
|
-
|
|
978
|
-
|
|
979
|
-
|
|
980
|
-
|
|
981
|
-
|
|
998
|
+
const newState = new Map( state );
|
|
999
|
+
newState.set(
|
|
1000
|
+
fromRootClientId,
|
|
1001
|
+
state
|
|
1002
|
+
.get( fromRootClientId )
|
|
1003
|
+
?.filter( ( id ) => ! clientIds.includes( id ) ) ?? []
|
|
1004
|
+
);
|
|
1005
|
+
newState.set(
|
|
1006
|
+
toRootClientId,
|
|
1007
|
+
insertAt( state.get( toRootClientId ), clientIds, index )
|
|
1008
|
+
);
|
|
1009
|
+
return newState;
|
|
982
1010
|
}
|
|
983
1011
|
|
|
984
1012
|
case 'MOVE_BLOCKS_UP': {
|
|
985
1013
|
const { clientIds, rootClientId = '' } = action;
|
|
986
1014
|
const firstClientId = clientIds[ 0 ];
|
|
987
|
-
const subState = state
|
|
1015
|
+
const subState = state.get( rootClientId );
|
|
988
1016
|
|
|
989
1017
|
if ( ! subState.length || firstClientId === subState[ 0 ] ) {
|
|
990
1018
|
return state;
|
|
991
1019
|
}
|
|
992
1020
|
|
|
993
1021
|
const firstIndex = subState.indexOf( firstClientId );
|
|
994
|
-
|
|
995
|
-
|
|
996
|
-
|
|
997
|
-
|
|
1022
|
+
const newState = new Map( state );
|
|
1023
|
+
newState.set(
|
|
1024
|
+
rootClientId,
|
|
1025
|
+
moveTo(
|
|
998
1026
|
subState,
|
|
999
1027
|
firstIndex,
|
|
1000
1028
|
firstIndex - 1,
|
|
1001
1029
|
clientIds.length
|
|
1002
|
-
)
|
|
1003
|
-
|
|
1030
|
+
)
|
|
1031
|
+
);
|
|
1032
|
+
return newState;
|
|
1004
1033
|
}
|
|
1005
1034
|
|
|
1006
1035
|
case 'MOVE_BLOCKS_DOWN': {
|
|
1007
1036
|
const { clientIds, rootClientId = '' } = action;
|
|
1008
1037
|
const firstClientId = clientIds[ 0 ];
|
|
1009
1038
|
const lastClientId = clientIds[ clientIds.length - 1 ];
|
|
1010
|
-
const subState = state
|
|
1039
|
+
const subState = state.get( rootClientId );
|
|
1011
1040
|
|
|
1012
1041
|
if (
|
|
1013
1042
|
! subState.length ||
|
|
@@ -1017,16 +1046,17 @@ export const blocks = pipe(
|
|
|
1017
1046
|
}
|
|
1018
1047
|
|
|
1019
1048
|
const firstIndex = subState.indexOf( firstClientId );
|
|
1020
|
-
|
|
1021
|
-
|
|
1022
|
-
|
|
1023
|
-
|
|
1049
|
+
const newState = new Map( state );
|
|
1050
|
+
newState.set(
|
|
1051
|
+
rootClientId,
|
|
1052
|
+
moveTo(
|
|
1024
1053
|
subState,
|
|
1025
1054
|
firstIndex,
|
|
1026
1055
|
firstIndex + 1,
|
|
1027
1056
|
clientIds.length
|
|
1028
|
-
)
|
|
1029
|
-
|
|
1057
|
+
)
|
|
1058
|
+
);
|
|
1059
|
+
return newState;
|
|
1030
1060
|
}
|
|
1031
1061
|
|
|
1032
1062
|
case 'REPLACE_BLOCKS_AUGMENTED_WITH_CHILDREN': {
|
|
@@ -1036,55 +1066,52 @@ export const blocks = pipe(
|
|
|
1036
1066
|
}
|
|
1037
1067
|
|
|
1038
1068
|
const mappedBlocks = mapBlockOrder( action.blocks );
|
|
1069
|
+
const newState = new Map( state );
|
|
1070
|
+
action.replacedClientIds.forEach( ( clientId ) => {
|
|
1071
|
+
newState.delete( clientId );
|
|
1072
|
+
} );
|
|
1073
|
+
mappedBlocks.forEach( ( order, clientId ) => {
|
|
1074
|
+
if ( clientId !== '' ) {
|
|
1075
|
+
newState.set( clientId, order );
|
|
1076
|
+
}
|
|
1077
|
+
} );
|
|
1078
|
+
newState.forEach( ( order, clientId ) => {
|
|
1079
|
+
const newSubOrder = Object.values( order ).reduce(
|
|
1080
|
+
( result, subClientId ) => {
|
|
1081
|
+
if ( subClientId === clientIds[ 0 ] ) {
|
|
1082
|
+
return [ ...result, ...mappedBlocks.get( '' ) ];
|
|
1083
|
+
}
|
|
1039
1084
|
|
|
1040
|
-
|
|
1041
|
-
|
|
1042
|
-
|
|
1043
|
-
|
|
1044
|
-
|
|
1045
|
-
|
|
1046
|
-
|
|
1047
|
-
|
|
1048
|
-
|
|
1049
|
-
|
|
1050
|
-
|
|
1051
|
-
if ( clientId === clientIds[ 0 ] ) {
|
|
1052
|
-
return [
|
|
1053
|
-
...result,
|
|
1054
|
-
...mappedBlocks[ '' ],
|
|
1055
|
-
];
|
|
1056
|
-
}
|
|
1057
|
-
|
|
1058
|
-
if (
|
|
1059
|
-
clientIds.indexOf( clientId ) === -1
|
|
1060
|
-
) {
|
|
1061
|
-
result.push( clientId );
|
|
1062
|
-
}
|
|
1063
|
-
|
|
1064
|
-
return result;
|
|
1065
|
-
},
|
|
1066
|
-
[]
|
|
1067
|
-
)
|
|
1068
|
-
),
|
|
1069
|
-
] )( state );
|
|
1085
|
+
if ( clientIds.indexOf( subClientId ) === -1 ) {
|
|
1086
|
+
result.push( subClientId );
|
|
1087
|
+
}
|
|
1088
|
+
|
|
1089
|
+
return result;
|
|
1090
|
+
},
|
|
1091
|
+
[]
|
|
1092
|
+
);
|
|
1093
|
+
newState.set( clientId, newSubOrder );
|
|
1094
|
+
} );
|
|
1095
|
+
return newState;
|
|
1070
1096
|
}
|
|
1071
1097
|
|
|
1072
|
-
case 'REMOVE_BLOCKS_AUGMENTED_WITH_CHILDREN':
|
|
1073
|
-
|
|
1074
|
-
|
|
1075
|
-
|
|
1076
|
-
|
|
1077
|
-
|
|
1078
|
-
|
|
1079
|
-
|
|
1080
|
-
|
|
1081
|
-
(
|
|
1082
|
-
|
|
1083
|
-
|
|
1084
|
-
|
|
1085
|
-
|
|
1086
|
-
|
|
1087
|
-
|
|
1098
|
+
case 'REMOVE_BLOCKS_AUGMENTED_WITH_CHILDREN': {
|
|
1099
|
+
const newState = new Map( state );
|
|
1100
|
+
// Remove inner block ordering for removed blocks.
|
|
1101
|
+
action.removedClientIds.forEach( ( clientId ) => {
|
|
1102
|
+
newState.delete( clientId );
|
|
1103
|
+
} );
|
|
1104
|
+
newState.forEach( ( order, clientId ) => {
|
|
1105
|
+
const newSubOrder =
|
|
1106
|
+
order?.filter(
|
|
1107
|
+
( id ) => ! action.removedClientIds.includes( id )
|
|
1108
|
+
) ?? [];
|
|
1109
|
+
if ( newSubOrder.length !== order.length ) {
|
|
1110
|
+
newState.set( clientId, newSubOrder );
|
|
1111
|
+
}
|
|
1112
|
+
} );
|
|
1113
|
+
return newState;
|
|
1114
|
+
}
|
|
1088
1115
|
}
|
|
1089
1116
|
|
|
1090
1117
|
return state;
|
|
@@ -1092,44 +1119,55 @@ export const blocks = pipe(
|
|
|
1092
1119
|
|
|
1093
1120
|
// While technically redundant data as the inverse of `order`, it serves as
|
|
1094
1121
|
// an optimization for the selectors which derive the ancestry of a block.
|
|
1095
|
-
parents( state =
|
|
1122
|
+
parents( state = new Map(), action ) {
|
|
1096
1123
|
switch ( action.type ) {
|
|
1097
|
-
case 'RECEIVE_BLOCKS':
|
|
1098
|
-
|
|
1099
|
-
|
|
1100
|
-
|
|
1101
|
-
|
|
1102
|
-
|
|
1103
|
-
|
|
1104
|
-
return
|
|
1105
|
-
|
|
1106
|
-
|
|
1107
|
-
|
|
1108
|
-
|
|
1109
|
-
|
|
1110
|
-
|
|
1111
|
-
|
|
1124
|
+
case 'RECEIVE_BLOCKS': {
|
|
1125
|
+
const newState = new Map( state );
|
|
1126
|
+
mapBlockParents( action.blocks ).forEach(
|
|
1127
|
+
( [ key, value ] ) => {
|
|
1128
|
+
newState.set( key, value );
|
|
1129
|
+
}
|
|
1130
|
+
);
|
|
1131
|
+
return newState;
|
|
1132
|
+
}
|
|
1133
|
+
case 'INSERT_BLOCKS': {
|
|
1134
|
+
const newState = new Map( state );
|
|
1135
|
+
mapBlockParents(
|
|
1136
|
+
action.blocks,
|
|
1137
|
+
action.rootClientId || ''
|
|
1138
|
+
).forEach( ( [ key, value ] ) => {
|
|
1139
|
+
newState.set( key, value );
|
|
1140
|
+
} );
|
|
1141
|
+
return newState;
|
|
1142
|
+
}
|
|
1112
1143
|
case 'MOVE_BLOCKS_TO_POSITION': {
|
|
1113
|
-
|
|
1114
|
-
|
|
1115
|
-
|
|
1116
|
-
|
|
1117
|
-
|
|
1118
|
-
}, {} ),
|
|
1119
|
-
};
|
|
1144
|
+
const newState = new Map( state );
|
|
1145
|
+
action.clientIds.forEach( ( id ) => {
|
|
1146
|
+
newState.set( id, action.toRootClientId || '' );
|
|
1147
|
+
} );
|
|
1148
|
+
return newState;
|
|
1120
1149
|
}
|
|
1121
1150
|
|
|
1122
|
-
case 'REPLACE_BLOCKS_AUGMENTED_WITH_CHILDREN':
|
|
1123
|
-
|
|
1124
|
-
|
|
1125
|
-
|
|
1126
|
-
|
|
1127
|
-
|
|
1128
|
-
|
|
1129
|
-
|
|
1130
|
-
|
|
1131
|
-
|
|
1132
|
-
|
|
1151
|
+
case 'REPLACE_BLOCKS_AUGMENTED_WITH_CHILDREN': {
|
|
1152
|
+
const newState = new Map( state );
|
|
1153
|
+
action.replacedClientIds.forEach( ( clientId ) => {
|
|
1154
|
+
newState.delete( clientId );
|
|
1155
|
+
} );
|
|
1156
|
+
mapBlockParents(
|
|
1157
|
+
action.blocks,
|
|
1158
|
+
state.get( action.clientIds[ 0 ] )
|
|
1159
|
+
).forEach( ( [ key, value ] ) => {
|
|
1160
|
+
newState.set( key, value );
|
|
1161
|
+
} );
|
|
1162
|
+
return newState;
|
|
1163
|
+
}
|
|
1164
|
+
case 'REMOVE_BLOCKS_AUGMENTED_WITH_CHILDREN': {
|
|
1165
|
+
const newState = new Map( state );
|
|
1166
|
+
action.removedClientIds.forEach( ( clientId ) => {
|
|
1167
|
+
newState.delete( clientId );
|
|
1168
|
+
} );
|
|
1169
|
+
return newState;
|
|
1170
|
+
}
|
|
1133
1171
|
}
|
|
1134
1172
|
|
|
1135
1173
|
return state;
|
|
@@ -1492,7 +1530,7 @@ export function insertionPoint( state = null, action ) {
|
|
|
1492
1530
|
};
|
|
1493
1531
|
|
|
1494
1532
|
// Bail out updates if the states are the same.
|
|
1495
|
-
return
|
|
1533
|
+
return fastDeepEqual( state, nextState ) ? state : nextState;
|
|
1496
1534
|
}
|
|
1497
1535
|
|
|
1498
1536
|
case 'HIDE_INSERTION_POINT':
|
|
@@ -1605,19 +1643,24 @@ export const blockListSettings = ( state = {}, action ) => {
|
|
|
1605
1643
|
// should correct the state.
|
|
1606
1644
|
case 'REPLACE_BLOCKS':
|
|
1607
1645
|
case 'REMOVE_BLOCKS': {
|
|
1608
|
-
return
|
|
1646
|
+
return Object.fromEntries(
|
|
1647
|
+
Object.entries( state ).filter(
|
|
1648
|
+
( [ id ] ) => ! action.clientIds.includes( id )
|
|
1649
|
+
)
|
|
1650
|
+
);
|
|
1609
1651
|
}
|
|
1610
1652
|
case 'UPDATE_BLOCK_LIST_SETTINGS': {
|
|
1611
1653
|
const { clientId } = action;
|
|
1612
1654
|
if ( ! action.settings ) {
|
|
1613
1655
|
if ( state.hasOwnProperty( clientId ) ) {
|
|
1614
|
-
|
|
1656
|
+
const { [ clientId ]: removedBlock, ...restBlocks } = state;
|
|
1657
|
+
return restBlocks;
|
|
1615
1658
|
}
|
|
1616
1659
|
|
|
1617
1660
|
return state;
|
|
1618
1661
|
}
|
|
1619
1662
|
|
|
1620
|
-
if (
|
|
1663
|
+
if ( fastDeepEqual( state[ clientId ], action.settings ) ) {
|
|
1621
1664
|
return state;
|
|
1622
1665
|
}
|
|
1623
1666
|
|