@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
|
@@ -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
|
* WordPress dependencies
|
|
7
7
|
*/
|
|
@@ -31,16 +31,18 @@ const identity = x => x;
|
|
|
31
31
|
|
|
32
32
|
function mapBlockOrder(blocks) {
|
|
33
33
|
let rootClientId = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : '';
|
|
34
|
-
const result =
|
|
35
|
-
|
|
36
|
-
|
|
34
|
+
const result = new Map();
|
|
35
|
+
const current = [];
|
|
36
|
+
result.set(rootClientId, current);
|
|
37
37
|
blocks.forEach(block => {
|
|
38
38
|
const {
|
|
39
39
|
clientId,
|
|
40
40
|
innerBlocks
|
|
41
41
|
} = block;
|
|
42
|
-
|
|
43
|
-
|
|
42
|
+
current.push(clientId);
|
|
43
|
+
mapBlockOrder(innerBlocks, clientId).forEach((order, subClientId) => {
|
|
44
|
+
result.set(subClientId, order);
|
|
45
|
+
});
|
|
44
46
|
});
|
|
45
47
|
return result;
|
|
46
48
|
}
|
|
@@ -57,9 +59,25 @@ function mapBlockOrder(blocks) {
|
|
|
57
59
|
|
|
58
60
|
function mapBlockParents(blocks) {
|
|
59
61
|
let rootClientId = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : '';
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
62
|
+
const result = [];
|
|
63
|
+
const stack = [[rootClientId, blocks]];
|
|
64
|
+
|
|
65
|
+
while (stack.length) {
|
|
66
|
+
const [parent, currentBlocks] = stack.shift();
|
|
67
|
+
currentBlocks.forEach(_ref => {
|
|
68
|
+
let {
|
|
69
|
+
innerBlocks,
|
|
70
|
+
...block
|
|
71
|
+
} = _ref;
|
|
72
|
+
result.push([block.clientId, parent]);
|
|
73
|
+
|
|
74
|
+
if (innerBlocks !== null && innerBlocks !== void 0 && innerBlocks.length) {
|
|
75
|
+
stack.push([block.clientId, innerBlocks]);
|
|
76
|
+
}
|
|
77
|
+
});
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
return result;
|
|
63
81
|
}
|
|
64
82
|
/**
|
|
65
83
|
* Helper method to iterate through all blocks, recursing into inner blocks,
|
|
@@ -69,12 +87,28 @@ function mapBlockParents(blocks) {
|
|
|
69
87
|
* @param {Array} blocks Blocks to flatten.
|
|
70
88
|
* @param {Function} transform Transforming function to be applied to each block.
|
|
71
89
|
*
|
|
72
|
-
* @return {
|
|
90
|
+
* @return {Array} Flattened object.
|
|
73
91
|
*/
|
|
74
92
|
|
|
75
93
|
|
|
76
94
|
function flattenBlocks(blocks) {
|
|
77
95
|
let transform = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : identity;
|
|
96
|
+
const result = [];
|
|
97
|
+
const stack = [...blocks];
|
|
98
|
+
|
|
99
|
+
while (stack.length) {
|
|
100
|
+
const {
|
|
101
|
+
innerBlocks,
|
|
102
|
+
...block
|
|
103
|
+
} = stack.shift();
|
|
104
|
+
stack.push(...innerBlocks);
|
|
105
|
+
result.push([block.clientId, transform(block)]);
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
return result;
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
function getFlattenedClientIds(blocks) {
|
|
78
112
|
const result = {};
|
|
79
113
|
const stack = [...blocks];
|
|
80
114
|
|
|
@@ -84,7 +118,7 @@ function flattenBlocks(blocks) {
|
|
|
84
118
|
...block
|
|
85
119
|
} = stack.shift();
|
|
86
120
|
stack.push(...innerBlocks);
|
|
87
|
-
result[block.clientId] =
|
|
121
|
+
result[block.clientId] = true;
|
|
88
122
|
}
|
|
89
123
|
|
|
90
124
|
return result;
|
|
@@ -96,12 +130,18 @@ function flattenBlocks(blocks) {
|
|
|
96
130
|
*
|
|
97
131
|
* @param {Array} blocks Blocks to flatten.
|
|
98
132
|
*
|
|
99
|
-
* @return {
|
|
133
|
+
* @return {Array} Flattened block attributes object.
|
|
100
134
|
*/
|
|
101
135
|
|
|
102
136
|
|
|
103
137
|
function getFlattenedBlocksWithoutAttributes(blocks) {
|
|
104
|
-
return flattenBlocks(blocks, block =>
|
|
138
|
+
return flattenBlocks(blocks, block => {
|
|
139
|
+
const {
|
|
140
|
+
attributes,
|
|
141
|
+
...restBlock
|
|
142
|
+
} = block;
|
|
143
|
+
return restBlock;
|
|
144
|
+
});
|
|
105
145
|
}
|
|
106
146
|
/**
|
|
107
147
|
* Given an array of blocks, returns an object containing all block attributes,
|
|
@@ -110,32 +150,13 @@ function getFlattenedBlocksWithoutAttributes(blocks) {
|
|
|
110
150
|
*
|
|
111
151
|
* @param {Array} blocks Blocks to flatten.
|
|
112
152
|
*
|
|
113
|
-
* @return {
|
|
153
|
+
* @return {Array} Flattened block attributes object.
|
|
114
154
|
*/
|
|
115
155
|
|
|
116
156
|
|
|
117
157
|
function getFlattenedBlockAttributes(blocks) {
|
|
118
158
|
return flattenBlocks(blocks, block => block.attributes);
|
|
119
159
|
}
|
|
120
|
-
/**
|
|
121
|
-
* Returns an object against which it is safe to perform mutating operations,
|
|
122
|
-
* given the original object and its current working copy.
|
|
123
|
-
*
|
|
124
|
-
* @param {Object} original Original object.
|
|
125
|
-
* @param {Object} working Working object.
|
|
126
|
-
*
|
|
127
|
-
* @return {Object} Mutation-safe object.
|
|
128
|
-
*/
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
function getMutateSafeObject(original, working) {
|
|
132
|
-
if (original === working) {
|
|
133
|
-
return { ...original
|
|
134
|
-
};
|
|
135
|
-
}
|
|
136
|
-
|
|
137
|
-
return working;
|
|
138
|
-
}
|
|
139
160
|
/**
|
|
140
161
|
* Returns true if the two object arguments have the same keys, or false
|
|
141
162
|
* otherwise.
|
|
@@ -148,7 +169,7 @@ function getMutateSafeObject(original, working) {
|
|
|
148
169
|
|
|
149
170
|
|
|
150
171
|
export function hasSameKeys(a, b) {
|
|
151
|
-
return
|
|
172
|
+
return fastDeepEqual(Object.keys(a), Object.keys(b));
|
|
152
173
|
}
|
|
153
174
|
/**
|
|
154
175
|
* Returns true if, given the currently dispatching action and the previously
|
|
@@ -162,11 +183,11 @@ export function hasSameKeys(a, b) {
|
|
|
162
183
|
*/
|
|
163
184
|
|
|
164
185
|
export function isUpdatingSameBlockAttribute(action, lastAction) {
|
|
165
|
-
return action.type === 'UPDATE_BLOCK_ATTRIBUTES' && lastAction !== undefined && lastAction.type === 'UPDATE_BLOCK_ATTRIBUTES' &&
|
|
186
|
+
return action.type === 'UPDATE_BLOCK_ATTRIBUTES' && lastAction !== undefined && lastAction.type === 'UPDATE_BLOCK_ATTRIBUTES' && fastDeepEqual(action.clientIds, lastAction.clientIds) && hasSameKeys(action.attributes, lastAction.attributes);
|
|
166
187
|
}
|
|
167
188
|
|
|
168
|
-
function
|
|
169
|
-
const
|
|
189
|
+
function updateBlockTreeForBlocks(state, blocks) {
|
|
190
|
+
const treeToUpdate = state.tree;
|
|
170
191
|
const stack = [...blocks];
|
|
171
192
|
const flattenedBlocks = [...blocks];
|
|
172
193
|
|
|
@@ -178,26 +199,25 @@ function buildBlockTree(state, blocks) {
|
|
|
178
199
|
|
|
179
200
|
|
|
180
201
|
for (const block of flattenedBlocks) {
|
|
181
|
-
|
|
202
|
+
treeToUpdate.set(block.clientId, {});
|
|
182
203
|
}
|
|
183
204
|
|
|
184
205
|
for (const block of flattenedBlocks) {
|
|
185
|
-
|
|
186
|
-
attributes: state.attributes
|
|
187
|
-
innerBlocks: block.innerBlocks.map(subBlock =>
|
|
188
|
-
});
|
|
206
|
+
treeToUpdate.set(block.clientId, Object.assign(treeToUpdate.get(block.clientId), { ...state.byClientId.get(block.clientId),
|
|
207
|
+
attributes: state.attributes.get(block.clientId),
|
|
208
|
+
innerBlocks: block.innerBlocks.map(subBlock => treeToUpdate.get(subBlock.clientId))
|
|
209
|
+
}));
|
|
189
210
|
}
|
|
190
|
-
|
|
191
|
-
return result;
|
|
192
211
|
}
|
|
193
212
|
|
|
194
|
-
function updateParentInnerBlocksInTree(state,
|
|
195
|
-
let updateChildrenOfUpdatedClientIds = arguments.length >
|
|
213
|
+
function updateParentInnerBlocksInTree(state, updatedClientIds) {
|
|
214
|
+
let updateChildrenOfUpdatedClientIds = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
|
|
215
|
+
const treeToUpdate = state.tree;
|
|
196
216
|
const uncontrolledParents = new Set([]);
|
|
197
217
|
const controlledParents = new Set();
|
|
198
218
|
|
|
199
219
|
for (const clientId of updatedClientIds) {
|
|
200
|
-
let current = updateChildrenOfUpdatedClientIds ? clientId : state.parents
|
|
220
|
+
let current = updateChildrenOfUpdatedClientIds ? clientId : state.parents.get(clientId);
|
|
201
221
|
|
|
202
222
|
do {
|
|
203
223
|
if (state.controlledInnerBlocks[current]) {
|
|
@@ -208,7 +228,7 @@ function updateParentInnerBlocksInTree(state, tree, updatedClientIds) {
|
|
|
208
228
|
} else {
|
|
209
229
|
// Else continue traversing up through parents.
|
|
210
230
|
uncontrolledParents.add(current);
|
|
211
|
-
current = state.parents
|
|
231
|
+
current = state.parents.get(current);
|
|
212
232
|
}
|
|
213
233
|
} while (current !== undefined);
|
|
214
234
|
} // To make sure the order of assignments doesn't matter,
|
|
@@ -216,23 +236,21 @@ function updateParentInnerBlocksInTree(state, tree, updatedClientIds) {
|
|
|
216
236
|
|
|
217
237
|
|
|
218
238
|
for (const clientId of uncontrolledParents) {
|
|
219
|
-
|
|
220
|
-
};
|
|
239
|
+
treeToUpdate.set(clientId, { ...treeToUpdate.get(clientId)
|
|
240
|
+
});
|
|
221
241
|
}
|
|
222
242
|
|
|
223
243
|
for (const clientId of uncontrolledParents) {
|
|
224
|
-
|
|
244
|
+
treeToUpdate.get(clientId).innerBlocks = (state.order.get(clientId) || []).map(subClientId => treeToUpdate.get(subClientId));
|
|
225
245
|
} // Controlled parent blocks, need a dedicated key for their inner blocks
|
|
226
246
|
// to be used when doing getBlocks( controlledBlockClientId ).
|
|
227
247
|
|
|
228
248
|
|
|
229
249
|
for (const clientId of controlledParents) {
|
|
230
|
-
|
|
231
|
-
innerBlocks: (state.order
|
|
232
|
-
};
|
|
250
|
+
treeToUpdate.set('controlled||' + clientId, {
|
|
251
|
+
innerBlocks: (state.order.get(clientId) || []).map(subClientId => treeToUpdate.get(subClientId))
|
|
252
|
+
});
|
|
233
253
|
}
|
|
234
|
-
|
|
235
|
-
return tree;
|
|
236
254
|
}
|
|
237
255
|
/**
|
|
238
256
|
* Higher-order reducer intended to compute full block objects key for each block in the post.
|
|
@@ -254,61 +272,61 @@ const withBlockTree = reducer => function () {
|
|
|
254
272
|
return state;
|
|
255
273
|
}
|
|
256
274
|
|
|
257
|
-
newState.tree = state.tree ? state.tree :
|
|
275
|
+
newState.tree = state.tree ? state.tree : new Map();
|
|
258
276
|
|
|
259
277
|
switch (action.type) {
|
|
260
278
|
case 'RECEIVE_BLOCKS':
|
|
261
279
|
case 'INSERT_BLOCKS':
|
|
262
280
|
{
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
}, action.rootClientId ? [action.rootClientId] : [''], true);
|
|
281
|
+
newState.tree = new Map(newState.tree);
|
|
282
|
+
updateBlockTreeForBlocks(newState, action.blocks);
|
|
283
|
+
updateParentInnerBlocksInTree(newState, action.rootClientId ? [action.rootClientId] : [''], true);
|
|
267
284
|
break;
|
|
268
285
|
}
|
|
269
286
|
|
|
270
287
|
case 'UPDATE_BLOCK':
|
|
271
|
-
newState.tree =
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
288
|
+
newState.tree = new Map(newState.tree);
|
|
289
|
+
newState.tree.set(action.clientId, { ...newState.tree.get(action.clientId),
|
|
290
|
+
...newState.byClientId.get(action.clientId),
|
|
291
|
+
attributes: newState.attributes.get(action.clientId)
|
|
292
|
+
});
|
|
293
|
+
updateParentInnerBlocksInTree(newState, [action.clientId], false);
|
|
277
294
|
break;
|
|
278
295
|
|
|
279
296
|
case 'UPDATE_BLOCK_ATTRIBUTES':
|
|
280
297
|
{
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
}
|
|
287
|
-
|
|
288
|
-
...newSubTree
|
|
289
|
-
}, action.clientIds, false);
|
|
298
|
+
newState.tree = new Map(newState.tree);
|
|
299
|
+
action.clientIds.forEach(clientId => {
|
|
300
|
+
newState.tree.set(clientId, { ...newState.tree.get(clientId),
|
|
301
|
+
attributes: newState.attributes.get(clientId)
|
|
302
|
+
});
|
|
303
|
+
});
|
|
304
|
+
updateParentInnerBlocksInTree(newState, action.clientIds, false);
|
|
290
305
|
break;
|
|
291
306
|
}
|
|
292
307
|
|
|
293
308
|
case 'REPLACE_BLOCKS_AUGMENTED_WITH_CHILDREN':
|
|
294
309
|
{
|
|
295
|
-
const
|
|
296
|
-
newState.tree =
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
310
|
+
const inserterClientIds = getFlattenedClientIds(action.blocks);
|
|
311
|
+
newState.tree = new Map(newState.tree);
|
|
312
|
+
action.replacedClientIds.concat( // Controlled inner blocks are only removed
|
|
313
|
+
// if the block doesn't move to another position
|
|
314
|
+
// otherwise their content will be lost.
|
|
315
|
+
action.replacedClientIds.filter(clientId => !inserterClientIds[clientId]).map(clientId => 'controlled||' + clientId)).forEach(key => {
|
|
316
|
+
newState.tree.delete(key);
|
|
317
|
+
});
|
|
318
|
+
updateBlockTreeForBlocks(newState, action.blocks);
|
|
319
|
+
updateParentInnerBlocksInTree(newState, action.blocks.map(b => b.clientId), false); // If there are no replaced blocks, it means we're removing blocks so we need to update their parent.
|
|
302
320
|
|
|
303
321
|
const parentsOfRemovedBlocks = [];
|
|
304
322
|
|
|
305
323
|
for (const clientId of action.clientIds) {
|
|
306
|
-
if (state.parents
|
|
307
|
-
parentsOfRemovedBlocks.push(state.parents
|
|
324
|
+
if (state.parents.get(clientId) !== undefined && (state.parents.get(clientId) === '' || newState.byClientId.get(state.parents.get(clientId)))) {
|
|
325
|
+
parentsOfRemovedBlocks.push(state.parents.get(clientId));
|
|
308
326
|
}
|
|
309
327
|
}
|
|
310
328
|
|
|
311
|
-
|
|
329
|
+
updateParentInnerBlocksInTree(newState, parentsOfRemovedBlocks, true);
|
|
312
330
|
break;
|
|
313
331
|
}
|
|
314
332
|
|
|
@@ -316,12 +334,16 @@ const withBlockTree = reducer => function () {
|
|
|
316
334
|
const parentsOfRemovedBlocks = [];
|
|
317
335
|
|
|
318
336
|
for (const clientId of action.clientIds) {
|
|
319
|
-
if (state.parents
|
|
320
|
-
parentsOfRemovedBlocks.push(state.parents
|
|
337
|
+
if (state.parents.get(clientId) !== undefined && (state.parents.get(clientId) === '' || newState.byClientId.get(state.parents.get(clientId)))) {
|
|
338
|
+
parentsOfRemovedBlocks.push(state.parents.get(clientId));
|
|
321
339
|
}
|
|
322
340
|
}
|
|
323
341
|
|
|
324
|
-
newState.tree =
|
|
342
|
+
newState.tree = new Map(newState.tree);
|
|
343
|
+
action.removedClientIds.concat(action.removedClientIds.map(clientId => 'controlled||' + clientId)).forEach(key => {
|
|
344
|
+
newState.tree.delete(key);
|
|
345
|
+
});
|
|
346
|
+
updateParentInnerBlocksInTree(newState, parentsOfRemovedBlocks, true);
|
|
325
347
|
break;
|
|
326
348
|
|
|
327
349
|
case 'MOVE_BLOCKS_TO_POSITION':
|
|
@@ -338,7 +360,8 @@ const withBlockTree = reducer => function () {
|
|
|
338
360
|
updatedBlockUids.push(action.toRootClientId);
|
|
339
361
|
}
|
|
340
362
|
|
|
341
|
-
newState.tree =
|
|
363
|
+
newState.tree = new Map(newState.tree);
|
|
364
|
+
updateParentInnerBlocksInTree(newState, updatedBlockUids, true);
|
|
342
365
|
break;
|
|
343
366
|
}
|
|
344
367
|
|
|
@@ -346,28 +369,27 @@ const withBlockTree = reducer => function () {
|
|
|
346
369
|
case 'MOVE_BLOCKS_DOWN':
|
|
347
370
|
{
|
|
348
371
|
const updatedBlockUids = [action.rootClientId ? action.rootClientId : ''];
|
|
349
|
-
newState.tree =
|
|
372
|
+
newState.tree = new Map(newState.tree);
|
|
373
|
+
updateParentInnerBlocksInTree(newState, updatedBlockUids, true);
|
|
350
374
|
break;
|
|
351
375
|
}
|
|
352
376
|
|
|
353
377
|
case 'SAVE_REUSABLE_BLOCK_SUCCESS':
|
|
354
378
|
{
|
|
355
|
-
const updatedBlockUids =
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
379
|
+
const updatedBlockUids = [];
|
|
380
|
+
newState.attributes.forEach((attributes, clientId) => {
|
|
381
|
+
if (newState.byClientId.get(clientId).name === 'core/block' && attributes.ref === action.updatedId) {
|
|
382
|
+
updatedBlockUids.push(clientId);
|
|
383
|
+
}
|
|
384
|
+
});
|
|
385
|
+
newState.tree = new Map(newState.tree);
|
|
386
|
+
updatedBlockUids.forEach(clientId => {
|
|
387
|
+
newState.tree.set(clientId, { ...newState.byClientId.get(clientId),
|
|
388
|
+
attributes: newState.attributes.get(clientId),
|
|
389
|
+
innerBlocks: newState.tree.get(clientId).innerBlocks
|
|
390
|
+
});
|
|
361
391
|
});
|
|
362
|
-
|
|
363
|
-
...updatedBlockUids.reduce((result, clientId) => {
|
|
364
|
-
result[clientId] = { ...newState.byClientId[clientId],
|
|
365
|
-
attributes: newState.attributes[clientId],
|
|
366
|
-
innerBlocks: newState.tree[clientId].innerBlocks
|
|
367
|
-
};
|
|
368
|
-
return result;
|
|
369
|
-
}, {})
|
|
370
|
-
}, updatedBlockUids, false);
|
|
392
|
+
updateParentInnerBlocksInTree(newState, updatedBlockUids, false);
|
|
371
393
|
}
|
|
372
394
|
}
|
|
373
395
|
|
|
@@ -464,7 +486,7 @@ const withInnerBlocksRemoveCascade = reducer => (state, action) => {
|
|
|
464
486
|
let result = clientIds;
|
|
465
487
|
|
|
466
488
|
for (let i = 0; i < result.length; i++) {
|
|
467
|
-
if (!state.order
|
|
489
|
+
if (!state.order.get(result[i]) || action.keepControlledInnerBlocks && action.keepControlledInnerBlocks[result[i]]) {
|
|
468
490
|
continue;
|
|
469
491
|
}
|
|
470
492
|
|
|
@@ -472,7 +494,7 @@ const withInnerBlocksRemoveCascade = reducer => (state, action) => {
|
|
|
472
494
|
result = [...result];
|
|
473
495
|
}
|
|
474
496
|
|
|
475
|
-
result.push(...state.order
|
|
497
|
+
result.push(...state.order.get(result[i]));
|
|
476
498
|
}
|
|
477
499
|
|
|
478
500
|
return result;
|
|
@@ -513,19 +535,17 @@ const withInnerBlocksRemoveCascade = reducer => (state, action) => {
|
|
|
513
535
|
const withBlockReset = reducer => (state, action) => {
|
|
514
536
|
if (action.type === 'RESET_BLOCKS') {
|
|
515
537
|
const newState = { ...state,
|
|
516
|
-
byClientId: getFlattenedBlocksWithoutAttributes(action.blocks),
|
|
517
|
-
attributes: getFlattenedBlockAttributes(action.blocks),
|
|
538
|
+
byClientId: new Map(getFlattenedBlocksWithoutAttributes(action.blocks)),
|
|
539
|
+
attributes: new Map(getFlattenedBlockAttributes(action.blocks)),
|
|
518
540
|
order: mapBlockOrder(action.blocks),
|
|
519
|
-
parents: mapBlockParents(action.blocks),
|
|
541
|
+
parents: new Map(mapBlockParents(action.blocks)),
|
|
520
542
|
controlledInnerBlocks: {}
|
|
521
543
|
};
|
|
522
|
-
|
|
523
|
-
newState.
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
}
|
|
528
|
-
};
|
|
544
|
+
newState.tree = new Map(state === null || state === void 0 ? void 0 : state.tree);
|
|
545
|
+
updateBlockTreeForBlocks(newState, action.blocks);
|
|
546
|
+
newState.tree.set('', {
|
|
547
|
+
innerBlocks: action.blocks.map(subBlock => newState.tree.get(subBlock.clientId))
|
|
548
|
+
});
|
|
529
549
|
return newState;
|
|
530
550
|
}
|
|
531
551
|
|
|
@@ -578,11 +598,11 @@ const withReplaceInnerBlocks = reducer => (state, action) => {
|
|
|
578
598
|
|
|
579
599
|
let stateAfterBlocksRemoval = state;
|
|
580
600
|
|
|
581
|
-
if (state.order
|
|
601
|
+
if (state.order.get(action.rootClientId)) {
|
|
582
602
|
stateAfterBlocksRemoval = reducer(stateAfterBlocksRemoval, {
|
|
583
603
|
type: 'REMOVE_BLOCKS',
|
|
584
604
|
keepControlledInnerBlocks: nestedControllers,
|
|
585
|
-
clientIds: state.order
|
|
605
|
+
clientIds: state.order.get(action.rootClientId)
|
|
586
606
|
});
|
|
587
607
|
}
|
|
588
608
|
|
|
@@ -596,26 +616,21 @@ const withReplaceInnerBlocks = reducer => (state, action) => {
|
|
|
596
616
|
// preserve their block order. Otherwise, an inner block controller's blocks
|
|
597
617
|
// will be deleted entirely from its entity.
|
|
598
618
|
|
|
599
|
-
|
|
600
|
-
|
|
601
|
-
|
|
602
|
-
|
|
603
|
-
|
|
604
|
-
|
|
605
|
-
|
|
606
|
-
|
|
607
|
-
|
|
608
|
-
|
|
609
|
-
...Object.keys(nestedControllers).reduce((result, _key) => {
|
|
610
|
-
const key = `controlled||${_key}`;
|
|
611
|
-
|
|
612
|
-
if (state.tree[key]) {
|
|
613
|
-
result[key] = state.tree[key];
|
|
614
|
-
}
|
|
619
|
+
const stateAfterInsertOrder = new Map(stateAfterInsert.order);
|
|
620
|
+
Object.keys(nestedControllers).forEach(key => {
|
|
621
|
+
if (state.order.get(key)) {
|
|
622
|
+
stateAfterInsertOrder.set(key, state.order.get(key));
|
|
623
|
+
}
|
|
624
|
+
});
|
|
625
|
+
stateAfterInsert.order = stateAfterInsertOrder;
|
|
626
|
+
stateAfterInsert.tree = new Map(stateAfterInsert.tree);
|
|
627
|
+
Object.keys(nestedControllers).forEach(_key => {
|
|
628
|
+
const key = `controlled||${_key}`;
|
|
615
629
|
|
|
616
|
-
|
|
617
|
-
|
|
618
|
-
|
|
630
|
+
if (state.tree.has(key)) {
|
|
631
|
+
stateAfterInsert.tree.set(key, state.tree.get(key));
|
|
632
|
+
}
|
|
633
|
+
});
|
|
619
634
|
}
|
|
620
635
|
|
|
621
636
|
return stateAfterInsert;
|
|
@@ -645,18 +660,17 @@ const withSaveReusableBlock = reducer => (state, action) => {
|
|
|
645
660
|
|
|
646
661
|
state = { ...state
|
|
647
662
|
};
|
|
648
|
-
state.attributes =
|
|
663
|
+
state.attributes = new Map(state.attributes);
|
|
664
|
+
state.attributes.forEach((attributes, clientId) => {
|
|
649
665
|
const {
|
|
650
666
|
name
|
|
651
|
-
} = state.byClientId
|
|
667
|
+
} = state.byClientId.get(clientId);
|
|
652
668
|
|
|
653
669
|
if (name === 'core/block' && attributes.ref === id) {
|
|
654
|
-
|
|
670
|
+
state.attributes.set(clientId, { ...attributes,
|
|
655
671
|
ref: updatedId
|
|
656
|
-
};
|
|
672
|
+
});
|
|
657
673
|
}
|
|
658
|
-
|
|
659
|
-
return attributes;
|
|
660
674
|
});
|
|
661
675
|
}
|
|
662
676
|
|
|
@@ -699,137 +713,205 @@ export const blocks = pipe(combineReducers, withSaveReusableBlock, // Needs to b
|
|
|
699
713
|
withBlockTree, // Needs to be before withInnerBlocksRemoveCascade.
|
|
700
714
|
withInnerBlocksRemoveCascade, withReplaceInnerBlocks, // Needs to be after withInnerBlocksRemoveCascade.
|
|
701
715
|
withBlockReset, withPersistentBlockChange, withIgnoredBlockChange, withResetControlledBlocks)({
|
|
716
|
+
// The state is using a Map instead of a plain object for performance reasons.
|
|
717
|
+
// You can run the "./test/performance.js" unit test to check the impact
|
|
718
|
+
// code changes can have on this reducer.
|
|
702
719
|
byClientId() {
|
|
703
|
-
let state = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] :
|
|
720
|
+
let state = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : new Map();
|
|
704
721
|
let action = arguments.length > 1 ? arguments[1] : undefined;
|
|
705
722
|
|
|
706
723
|
switch (action.type) {
|
|
707
724
|
case 'RECEIVE_BLOCKS':
|
|
708
725
|
case 'INSERT_BLOCKS':
|
|
709
|
-
|
|
710
|
-
|
|
711
|
-
|
|
726
|
+
{
|
|
727
|
+
const newState = new Map(state);
|
|
728
|
+
getFlattenedBlocksWithoutAttributes(action.blocks).forEach(_ref2 => {
|
|
729
|
+
let [key, value] = _ref2;
|
|
730
|
+
newState.set(key, value);
|
|
731
|
+
});
|
|
732
|
+
return newState;
|
|
733
|
+
}
|
|
712
734
|
|
|
713
735
|
case 'UPDATE_BLOCK':
|
|
714
|
-
|
|
715
|
-
|
|
716
|
-
|
|
717
|
-
|
|
736
|
+
{
|
|
737
|
+
// Ignore updates if block isn't known.
|
|
738
|
+
if (!state.has(action.clientId)) {
|
|
739
|
+
return state;
|
|
740
|
+
} // Do nothing if only attributes change.
|
|
718
741
|
|
|
719
742
|
|
|
720
|
-
|
|
743
|
+
const {
|
|
744
|
+
attributes,
|
|
745
|
+
...changes
|
|
746
|
+
} = action.updates;
|
|
721
747
|
|
|
722
|
-
|
|
723
|
-
|
|
724
|
-
|
|
748
|
+
if (Object.values(changes).length === 0) {
|
|
749
|
+
return state;
|
|
750
|
+
}
|
|
725
751
|
|
|
726
|
-
|
|
727
|
-
|
|
752
|
+
const newState = new Map(state);
|
|
753
|
+
newState.set(action.clientId, { ...state.get(action.clientId),
|
|
728
754
|
...changes
|
|
729
|
-
}
|
|
730
|
-
|
|
755
|
+
});
|
|
756
|
+
return newState;
|
|
757
|
+
}
|
|
731
758
|
|
|
732
759
|
case 'REPLACE_BLOCKS_AUGMENTED_WITH_CHILDREN':
|
|
733
|
-
|
|
734
|
-
|
|
735
|
-
|
|
760
|
+
{
|
|
761
|
+
if (!action.blocks) {
|
|
762
|
+
return state;
|
|
763
|
+
}
|
|
736
764
|
|
|
737
|
-
|
|
738
|
-
|
|
739
|
-
|
|
765
|
+
const newState = new Map(state);
|
|
766
|
+
action.replacedClientIds.forEach(clientId => {
|
|
767
|
+
newState.delete(clientId);
|
|
768
|
+
});
|
|
769
|
+
getFlattenedBlocksWithoutAttributes(action.blocks).forEach(_ref3 => {
|
|
770
|
+
let [key, value] = _ref3;
|
|
771
|
+
newState.set(key, value);
|
|
772
|
+
});
|
|
773
|
+
return newState;
|
|
774
|
+
}
|
|
740
775
|
|
|
741
776
|
case 'REMOVE_BLOCKS_AUGMENTED_WITH_CHILDREN':
|
|
742
|
-
|
|
777
|
+
{
|
|
778
|
+
const newState = new Map(state);
|
|
779
|
+
action.removedClientIds.forEach(clientId => {
|
|
780
|
+
newState.delete(clientId);
|
|
781
|
+
});
|
|
782
|
+
return newState;
|
|
783
|
+
}
|
|
743
784
|
}
|
|
744
785
|
|
|
745
786
|
return state;
|
|
746
787
|
},
|
|
747
788
|
|
|
789
|
+
// The state is using a Map instead of a plain object for performance reasons.
|
|
790
|
+
// You can run the "./test/performance.js" unit test to check the impact
|
|
791
|
+
// code changes can have on this reducer.
|
|
748
792
|
attributes() {
|
|
749
|
-
let state = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] :
|
|
793
|
+
let state = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : new Map();
|
|
750
794
|
let action = arguments.length > 1 ? arguments[1] : undefined;
|
|
751
795
|
|
|
752
796
|
switch (action.type) {
|
|
753
797
|
case 'RECEIVE_BLOCKS':
|
|
754
798
|
case 'INSERT_BLOCKS':
|
|
755
|
-
|
|
756
|
-
|
|
757
|
-
|
|
799
|
+
{
|
|
800
|
+
const newState = new Map(state);
|
|
801
|
+
getFlattenedBlockAttributes(action.blocks).forEach(_ref4 => {
|
|
802
|
+
let [key, value] = _ref4;
|
|
803
|
+
newState.set(key, value);
|
|
804
|
+
});
|
|
805
|
+
return newState;
|
|
806
|
+
}
|
|
758
807
|
|
|
759
808
|
case 'UPDATE_BLOCK':
|
|
760
|
-
|
|
761
|
-
|
|
762
|
-
|
|
763
|
-
|
|
809
|
+
{
|
|
810
|
+
// Ignore updates if block isn't known or there are no attribute changes.
|
|
811
|
+
if (!state.get(action.clientId) || !action.updates.attributes) {
|
|
812
|
+
return state;
|
|
813
|
+
}
|
|
764
814
|
|
|
765
|
-
|
|
766
|
-
|
|
815
|
+
const newState = new Map(state);
|
|
816
|
+
newState.set(action.clientId, { ...state.get(action.clientId),
|
|
767
817
|
...action.updates.attributes
|
|
768
|
-
}
|
|
769
|
-
|
|
818
|
+
});
|
|
819
|
+
return newState;
|
|
820
|
+
}
|
|
770
821
|
|
|
771
822
|
case 'UPDATE_BLOCK_ATTRIBUTES':
|
|
772
823
|
{
|
|
773
824
|
// Avoid a state change if none of the block IDs are known.
|
|
774
|
-
if (action.clientIds.every(id => !state
|
|
825
|
+
if (action.clientIds.every(id => !state.get(id))) {
|
|
775
826
|
return state;
|
|
776
827
|
}
|
|
777
828
|
|
|
778
|
-
|
|
779
|
-
|
|
829
|
+
let hasChange = false;
|
|
830
|
+
const newState = new Map(state);
|
|
780
831
|
|
|
781
|
-
|
|
782
|
-
|
|
783
|
-
let [key, value] = _ref3;
|
|
832
|
+
for (const clientId of action.clientIds) {
|
|
833
|
+
var _action$attributes;
|
|
784
834
|
|
|
785
|
-
|
|
786
|
-
if (value !== result[key]) {
|
|
787
|
-
result = getMutateSafeObject(state[id], result);
|
|
788
|
-
result[key] = value;
|
|
789
|
-
}
|
|
835
|
+
const updatedAttributeEntries = Object.entries(action.uniqueByBlock ? action.attributes[clientId] : (_action$attributes = action.attributes) !== null && _action$attributes !== void 0 ? _action$attributes : {});
|
|
790
836
|
|
|
791
|
-
|
|
792
|
-
|
|
793
|
-
}
|
|
794
|
-
}, {});
|
|
837
|
+
if (updatedAttributeEntries.length === 0) {
|
|
838
|
+
continue;
|
|
839
|
+
}
|
|
795
840
|
|
|
796
|
-
|
|
797
|
-
|
|
841
|
+
let hasUpdatedAttributes = false;
|
|
842
|
+
const existingAttributes = state.get(clientId);
|
|
843
|
+
const newAttributes = {};
|
|
844
|
+
updatedAttributeEntries.forEach(_ref5 => {
|
|
845
|
+
let [key, value] = _ref5;
|
|
846
|
+
|
|
847
|
+
if (existingAttributes[key] !== value) {
|
|
848
|
+
hasUpdatedAttributes = true;
|
|
849
|
+
newAttributes[key] = value;
|
|
850
|
+
}
|
|
851
|
+
});
|
|
852
|
+
hasChange = hasChange || hasUpdatedAttributes;
|
|
853
|
+
|
|
854
|
+
if (hasUpdatedAttributes) {
|
|
855
|
+
newState.set(clientId, { ...existingAttributes,
|
|
856
|
+
...newAttributes
|
|
857
|
+
});
|
|
858
|
+
}
|
|
798
859
|
}
|
|
799
860
|
|
|
800
|
-
return
|
|
801
|
-
...next
|
|
802
|
-
};
|
|
861
|
+
return hasChange ? newState : state;
|
|
803
862
|
}
|
|
804
863
|
|
|
805
864
|
case 'REPLACE_BLOCKS_AUGMENTED_WITH_CHILDREN':
|
|
806
|
-
|
|
807
|
-
|
|
808
|
-
|
|
865
|
+
{
|
|
866
|
+
if (!action.blocks) {
|
|
867
|
+
return state;
|
|
868
|
+
}
|
|
809
869
|
|
|
810
|
-
|
|
811
|
-
|
|
812
|
-
|
|
870
|
+
const newState = new Map(state);
|
|
871
|
+
action.replacedClientIds.forEach(clientId => {
|
|
872
|
+
newState.delete(clientId);
|
|
873
|
+
});
|
|
874
|
+
getFlattenedBlockAttributes(action.blocks).forEach(_ref6 => {
|
|
875
|
+
let [key, value] = _ref6;
|
|
876
|
+
newState.set(key, value);
|
|
877
|
+
});
|
|
878
|
+
return newState;
|
|
879
|
+
}
|
|
813
880
|
|
|
814
881
|
case 'REMOVE_BLOCKS_AUGMENTED_WITH_CHILDREN':
|
|
815
|
-
|
|
882
|
+
{
|
|
883
|
+
const newState = new Map(state);
|
|
884
|
+
action.removedClientIds.forEach(clientId => {
|
|
885
|
+
newState.delete(clientId);
|
|
886
|
+
});
|
|
887
|
+
return newState;
|
|
888
|
+
}
|
|
816
889
|
}
|
|
817
890
|
|
|
818
891
|
return state;
|
|
819
892
|
},
|
|
820
893
|
|
|
894
|
+
// The state is using a Map instead of a plain object for performance reasons.
|
|
895
|
+
// You can run the "./test/performance.js" unit test to check the impact
|
|
896
|
+
// code changes can have on this reducer.
|
|
821
897
|
order() {
|
|
822
|
-
let state = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] :
|
|
898
|
+
let state = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : new Map();
|
|
823
899
|
let action = arguments.length > 1 ? arguments[1] : undefined;
|
|
824
900
|
|
|
825
901
|
switch (action.type) {
|
|
826
902
|
case 'RECEIVE_BLOCKS':
|
|
827
903
|
{
|
|
904
|
+
var _state$get;
|
|
905
|
+
|
|
828
906
|
const blockOrder = mapBlockOrder(action.blocks);
|
|
829
|
-
|
|
830
|
-
|
|
831
|
-
|
|
832
|
-
|
|
907
|
+
const newState = new Map(state);
|
|
908
|
+
blockOrder.forEach((order, clientId) => {
|
|
909
|
+
if (clientId !== '') {
|
|
910
|
+
newState.set(clientId, order);
|
|
911
|
+
}
|
|
912
|
+
});
|
|
913
|
+
newState.set('', ((_state$get = state.get('')) !== null && _state$get !== void 0 ? _state$get : []).concat(blockOrder['']));
|
|
914
|
+
return newState;
|
|
833
915
|
}
|
|
834
916
|
|
|
835
917
|
case 'INSERT_BLOCKS':
|
|
@@ -837,20 +919,22 @@ withBlockReset, withPersistentBlockChange, withIgnoredBlockChange, withResetCont
|
|
|
837
919
|
const {
|
|
838
920
|
rootClientId = ''
|
|
839
921
|
} = action;
|
|
840
|
-
const subState = state
|
|
922
|
+
const subState = state.get(rootClientId) || [];
|
|
841
923
|
const mappedBlocks = mapBlockOrder(action.blocks, rootClientId);
|
|
842
924
|
const {
|
|
843
925
|
index = subState.length
|
|
844
926
|
} = action;
|
|
845
|
-
|
|
846
|
-
|
|
847
|
-
|
|
848
|
-
};
|
|
927
|
+
const newState = new Map(state);
|
|
928
|
+
mappedBlocks.forEach((order, clientId) => {
|
|
929
|
+
newState.set(clientId, order);
|
|
930
|
+
});
|
|
931
|
+
newState.set(rootClientId, insertAt(subState, mappedBlocks.get(rootClientId), index));
|
|
932
|
+
return newState;
|
|
849
933
|
}
|
|
850
934
|
|
|
851
935
|
case 'MOVE_BLOCKS_TO_POSITION':
|
|
852
936
|
{
|
|
853
|
-
var _state$
|
|
937
|
+
var _state$get$filter, _state$get2;
|
|
854
938
|
|
|
855
939
|
const {
|
|
856
940
|
fromRootClientId = '',
|
|
@@ -858,22 +942,22 @@ withBlockReset, withPersistentBlockChange, withIgnoredBlockChange, withResetCont
|
|
|
858
942
|
clientIds
|
|
859
943
|
} = action;
|
|
860
944
|
const {
|
|
861
|
-
index = state
|
|
945
|
+
index = state.get(toRootClientId).length
|
|
862
946
|
} = action; // Moving inside the same parent block.
|
|
863
947
|
|
|
864
948
|
if (fromRootClientId === toRootClientId) {
|
|
865
|
-
const subState = state
|
|
949
|
+
const subState = state.get(toRootClientId);
|
|
866
950
|
const fromIndex = subState.indexOf(clientIds[0]);
|
|
867
|
-
|
|
868
|
-
|
|
869
|
-
|
|
951
|
+
const newState = new Map(state);
|
|
952
|
+
newState.set(toRootClientId, moveTo(state.get(toRootClientId), fromIndex, index, clientIds.length));
|
|
953
|
+
return newState;
|
|
870
954
|
} // Moving from a parent block to another.
|
|
871
955
|
|
|
872
956
|
|
|
873
|
-
|
|
874
|
-
|
|
875
|
-
|
|
876
|
-
|
|
957
|
+
const newState = new Map(state);
|
|
958
|
+
newState.set(fromRootClientId, (_state$get$filter = (_state$get2 = state.get(fromRootClientId)) === null || _state$get2 === void 0 ? void 0 : _state$get2.filter(id => !clientIds.includes(id))) !== null && _state$get$filter !== void 0 ? _state$get$filter : []);
|
|
959
|
+
newState.set(toRootClientId, insertAt(state.get(toRootClientId), clientIds, index));
|
|
960
|
+
return newState;
|
|
877
961
|
}
|
|
878
962
|
|
|
879
963
|
case 'MOVE_BLOCKS_UP':
|
|
@@ -883,16 +967,16 @@ withBlockReset, withPersistentBlockChange, withIgnoredBlockChange, withResetCont
|
|
|
883
967
|
rootClientId = ''
|
|
884
968
|
} = action;
|
|
885
969
|
const firstClientId = clientIds[0];
|
|
886
|
-
const subState = state
|
|
970
|
+
const subState = state.get(rootClientId);
|
|
887
971
|
|
|
888
972
|
if (!subState.length || firstClientId === subState[0]) {
|
|
889
973
|
return state;
|
|
890
974
|
}
|
|
891
975
|
|
|
892
976
|
const firstIndex = subState.indexOf(firstClientId);
|
|
893
|
-
|
|
894
|
-
|
|
895
|
-
|
|
977
|
+
const newState = new Map(state);
|
|
978
|
+
newState.set(rootClientId, moveTo(subState, firstIndex, firstIndex - 1, clientIds.length));
|
|
979
|
+
return newState;
|
|
896
980
|
}
|
|
897
981
|
|
|
898
982
|
case 'MOVE_BLOCKS_DOWN':
|
|
@@ -903,16 +987,16 @@ withBlockReset, withPersistentBlockChange, withIgnoredBlockChange, withResetCont
|
|
|
903
987
|
} = action;
|
|
904
988
|
const firstClientId = clientIds[0];
|
|
905
989
|
const lastClientId = clientIds[clientIds.length - 1];
|
|
906
|
-
const subState = state
|
|
990
|
+
const subState = state.get(rootClientId);
|
|
907
991
|
|
|
908
992
|
if (!subState.length || lastClientId === subState[subState.length - 1]) {
|
|
909
993
|
return state;
|
|
910
994
|
}
|
|
911
995
|
|
|
912
996
|
const firstIndex = subState.indexOf(firstClientId);
|
|
913
|
-
|
|
914
|
-
|
|
915
|
-
|
|
997
|
+
const newState = new Map(state);
|
|
998
|
+
newState.set(rootClientId, moveTo(subState, firstIndex, firstIndex + 1, clientIds.length));
|
|
999
|
+
return newState;
|
|
916
1000
|
}
|
|
917
1001
|
|
|
918
1002
|
case 'REPLACE_BLOCKS_AUGMENTED_WITH_CHILDREN':
|
|
@@ -926,29 +1010,50 @@ withBlockReset, withPersistentBlockChange, withIgnoredBlockChange, withResetCont
|
|
|
926
1010
|
}
|
|
927
1011
|
|
|
928
1012
|
const mappedBlocks = mapBlockOrder(action.blocks);
|
|
929
|
-
|
|
930
|
-
|
|
931
|
-
|
|
932
|
-
|
|
933
|
-
|
|
1013
|
+
const newState = new Map(state);
|
|
1014
|
+
action.replacedClientIds.forEach(clientId => {
|
|
1015
|
+
newState.delete(clientId);
|
|
1016
|
+
});
|
|
1017
|
+
mappedBlocks.forEach((order, clientId) => {
|
|
1018
|
+
if (clientId !== '') {
|
|
1019
|
+
newState.set(clientId, order);
|
|
934
1020
|
}
|
|
935
|
-
|
|
936
|
-
|
|
937
|
-
|
|
938
|
-
|
|
939
|
-
|
|
940
|
-
|
|
941
|
-
|
|
1021
|
+
});
|
|
1022
|
+
newState.forEach((order, clientId) => {
|
|
1023
|
+
const newSubOrder = Object.values(order).reduce((result, subClientId) => {
|
|
1024
|
+
if (subClientId === clientIds[0]) {
|
|
1025
|
+
return [...result, ...mappedBlocks.get('')];
|
|
1026
|
+
}
|
|
1027
|
+
|
|
1028
|
+
if (clientIds.indexOf(subClientId) === -1) {
|
|
1029
|
+
result.push(subClientId);
|
|
1030
|
+
}
|
|
1031
|
+
|
|
1032
|
+
return result;
|
|
1033
|
+
}, []);
|
|
1034
|
+
newState.set(clientId, newSubOrder);
|
|
1035
|
+
});
|
|
1036
|
+
return newState;
|
|
942
1037
|
}
|
|
943
1038
|
|
|
944
1039
|
case 'REMOVE_BLOCKS_AUGMENTED_WITH_CHILDREN':
|
|
945
|
-
|
|
946
|
-
|
|
947
|
-
nextState => mapValues(nextState, subState => {
|
|
948
|
-
var _subState$filter;
|
|
1040
|
+
{
|
|
1041
|
+
const newState = new Map(state); // Remove inner block ordering for removed blocks.
|
|
949
1042
|
|
|
950
|
-
|
|
951
|
-
|
|
1043
|
+
action.removedClientIds.forEach(clientId => {
|
|
1044
|
+
newState.delete(clientId);
|
|
1045
|
+
});
|
|
1046
|
+
newState.forEach((order, clientId) => {
|
|
1047
|
+
var _order$filter;
|
|
1048
|
+
|
|
1049
|
+
const newSubOrder = (_order$filter = order === null || order === void 0 ? void 0 : order.filter(id => !action.removedClientIds.includes(id))) !== null && _order$filter !== void 0 ? _order$filter : [];
|
|
1050
|
+
|
|
1051
|
+
if (newSubOrder.length !== order.length) {
|
|
1052
|
+
newState.set(clientId, newSubOrder);
|
|
1053
|
+
}
|
|
1054
|
+
});
|
|
1055
|
+
return newState;
|
|
1056
|
+
}
|
|
952
1057
|
}
|
|
953
1058
|
|
|
954
1059
|
return state;
|
|
@@ -957,37 +1062,60 @@ withBlockReset, withPersistentBlockChange, withIgnoredBlockChange, withResetCont
|
|
|
957
1062
|
// While technically redundant data as the inverse of `order`, it serves as
|
|
958
1063
|
// an optimization for the selectors which derive the ancestry of a block.
|
|
959
1064
|
parents() {
|
|
960
|
-
let state = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] :
|
|
1065
|
+
let state = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : new Map();
|
|
961
1066
|
let action = arguments.length > 1 ? arguments[1] : undefined;
|
|
962
1067
|
|
|
963
1068
|
switch (action.type) {
|
|
964
1069
|
case 'RECEIVE_BLOCKS':
|
|
965
|
-
|
|
966
|
-
|
|
967
|
-
|
|
1070
|
+
{
|
|
1071
|
+
const newState = new Map(state);
|
|
1072
|
+
mapBlockParents(action.blocks).forEach(_ref7 => {
|
|
1073
|
+
let [key, value] = _ref7;
|
|
1074
|
+
newState.set(key, value);
|
|
1075
|
+
});
|
|
1076
|
+
return newState;
|
|
1077
|
+
}
|
|
968
1078
|
|
|
969
1079
|
case 'INSERT_BLOCKS':
|
|
970
|
-
|
|
971
|
-
|
|
972
|
-
|
|
1080
|
+
{
|
|
1081
|
+
const newState = new Map(state);
|
|
1082
|
+
mapBlockParents(action.blocks, action.rootClientId || '').forEach(_ref8 => {
|
|
1083
|
+
let [key, value] = _ref8;
|
|
1084
|
+
newState.set(key, value);
|
|
1085
|
+
});
|
|
1086
|
+
return newState;
|
|
1087
|
+
}
|
|
973
1088
|
|
|
974
1089
|
case 'MOVE_BLOCKS_TO_POSITION':
|
|
975
1090
|
{
|
|
976
|
-
|
|
977
|
-
|
|
978
|
-
|
|
979
|
-
|
|
980
|
-
|
|
981
|
-
};
|
|
1091
|
+
const newState = new Map(state);
|
|
1092
|
+
action.clientIds.forEach(id => {
|
|
1093
|
+
newState.set(id, action.toRootClientId || '');
|
|
1094
|
+
});
|
|
1095
|
+
return newState;
|
|
982
1096
|
}
|
|
983
1097
|
|
|
984
1098
|
case 'REPLACE_BLOCKS_AUGMENTED_WITH_CHILDREN':
|
|
985
|
-
|
|
986
|
-
|
|
987
|
-
|
|
1099
|
+
{
|
|
1100
|
+
const newState = new Map(state);
|
|
1101
|
+
action.replacedClientIds.forEach(clientId => {
|
|
1102
|
+
newState.delete(clientId);
|
|
1103
|
+
});
|
|
1104
|
+
mapBlockParents(action.blocks, state.get(action.clientIds[0])).forEach(_ref9 => {
|
|
1105
|
+
let [key, value] = _ref9;
|
|
1106
|
+
newState.set(key, value);
|
|
1107
|
+
});
|
|
1108
|
+
return newState;
|
|
1109
|
+
}
|
|
988
1110
|
|
|
989
1111
|
case 'REMOVE_BLOCKS_AUGMENTED_WITH_CHILDREN':
|
|
990
|
-
|
|
1112
|
+
{
|
|
1113
|
+
const newState = new Map(state);
|
|
1114
|
+
action.removedClientIds.forEach(clientId => {
|
|
1115
|
+
newState.delete(clientId);
|
|
1116
|
+
});
|
|
1117
|
+
return newState;
|
|
1118
|
+
}
|
|
991
1119
|
}
|
|
992
1120
|
|
|
993
1121
|
return state;
|
|
@@ -1388,7 +1516,7 @@ export function insertionPoint() {
|
|
|
1388
1516
|
operation
|
|
1389
1517
|
}; // Bail out updates if the states are the same.
|
|
1390
1518
|
|
|
1391
|
-
return
|
|
1519
|
+
return fastDeepEqual(state, nextState) ? state : nextState;
|
|
1392
1520
|
}
|
|
1393
1521
|
|
|
1394
1522
|
case 'HIDE_INSERTION_POINT':
|
|
@@ -1511,7 +1639,10 @@ export const blockListSettings = function () {
|
|
|
1511
1639
|
case 'REPLACE_BLOCKS':
|
|
1512
1640
|
case 'REMOVE_BLOCKS':
|
|
1513
1641
|
{
|
|
1514
|
-
return
|
|
1642
|
+
return Object.fromEntries(Object.entries(state).filter(_ref10 => {
|
|
1643
|
+
let [id] = _ref10;
|
|
1644
|
+
return !action.clientIds.includes(id);
|
|
1645
|
+
}));
|
|
1515
1646
|
}
|
|
1516
1647
|
|
|
1517
1648
|
case 'UPDATE_BLOCK_LIST_SETTINGS':
|
|
@@ -1522,13 +1653,17 @@ export const blockListSettings = function () {
|
|
|
1522
1653
|
|
|
1523
1654
|
if (!action.settings) {
|
|
1524
1655
|
if (state.hasOwnProperty(clientId)) {
|
|
1525
|
-
|
|
1656
|
+
const {
|
|
1657
|
+
[clientId]: removedBlock,
|
|
1658
|
+
...restBlocks
|
|
1659
|
+
} = state;
|
|
1660
|
+
return restBlocks;
|
|
1526
1661
|
}
|
|
1527
1662
|
|
|
1528
1663
|
return state;
|
|
1529
1664
|
}
|
|
1530
1665
|
|
|
1531
|
-
if (
|
|
1666
|
+
if (fastDeepEqual(state[clientId], action.settings)) {
|
|
1532
1667
|
return state;
|
|
1533
1668
|
}
|
|
1534
1669
|
|