@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/build/store/reducer.js
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
+
|
|
3
5
|
Object.defineProperty(exports, "__esModule", {
|
|
4
6
|
value: true
|
|
5
7
|
});
|
|
@@ -29,7 +31,7 @@ exports.settings = settings;
|
|
|
29
31
|
exports.template = template;
|
|
30
32
|
exports.temporarilyEditingAsBlocks = temporarilyEditingAsBlocks;
|
|
31
33
|
|
|
32
|
-
var
|
|
34
|
+
var _es = _interopRequireDefault(require("fast-deep-equal/es6"));
|
|
33
35
|
|
|
34
36
|
var _compose = require("@wordpress/compose");
|
|
35
37
|
|
|
@@ -67,16 +69,18 @@ const identity = x => x;
|
|
|
67
69
|
|
|
68
70
|
function mapBlockOrder(blocks) {
|
|
69
71
|
let rootClientId = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : '';
|
|
70
|
-
const result =
|
|
71
|
-
|
|
72
|
-
|
|
72
|
+
const result = new Map();
|
|
73
|
+
const current = [];
|
|
74
|
+
result.set(rootClientId, current);
|
|
73
75
|
blocks.forEach(block => {
|
|
74
76
|
const {
|
|
75
77
|
clientId,
|
|
76
78
|
innerBlocks
|
|
77
79
|
} = block;
|
|
78
|
-
|
|
79
|
-
|
|
80
|
+
current.push(clientId);
|
|
81
|
+
mapBlockOrder(innerBlocks, clientId).forEach((order, subClientId) => {
|
|
82
|
+
result.set(subClientId, order);
|
|
83
|
+
});
|
|
80
84
|
});
|
|
81
85
|
return result;
|
|
82
86
|
}
|
|
@@ -93,9 +97,25 @@ function mapBlockOrder(blocks) {
|
|
|
93
97
|
|
|
94
98
|
function mapBlockParents(blocks) {
|
|
95
99
|
let rootClientId = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : '';
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
100
|
+
const result = [];
|
|
101
|
+
const stack = [[rootClientId, blocks]];
|
|
102
|
+
|
|
103
|
+
while (stack.length) {
|
|
104
|
+
const [parent, currentBlocks] = stack.shift();
|
|
105
|
+
currentBlocks.forEach(_ref => {
|
|
106
|
+
let {
|
|
107
|
+
innerBlocks,
|
|
108
|
+
...block
|
|
109
|
+
} = _ref;
|
|
110
|
+
result.push([block.clientId, parent]);
|
|
111
|
+
|
|
112
|
+
if (innerBlocks !== null && innerBlocks !== void 0 && innerBlocks.length) {
|
|
113
|
+
stack.push([block.clientId, innerBlocks]);
|
|
114
|
+
}
|
|
115
|
+
});
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
return result;
|
|
99
119
|
}
|
|
100
120
|
/**
|
|
101
121
|
* Helper method to iterate through all blocks, recursing into inner blocks,
|
|
@@ -105,12 +125,28 @@ function mapBlockParents(blocks) {
|
|
|
105
125
|
* @param {Array} blocks Blocks to flatten.
|
|
106
126
|
* @param {Function} transform Transforming function to be applied to each block.
|
|
107
127
|
*
|
|
108
|
-
* @return {
|
|
128
|
+
* @return {Array} Flattened object.
|
|
109
129
|
*/
|
|
110
130
|
|
|
111
131
|
|
|
112
132
|
function flattenBlocks(blocks) {
|
|
113
133
|
let transform = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : identity;
|
|
134
|
+
const result = [];
|
|
135
|
+
const stack = [...blocks];
|
|
136
|
+
|
|
137
|
+
while (stack.length) {
|
|
138
|
+
const {
|
|
139
|
+
innerBlocks,
|
|
140
|
+
...block
|
|
141
|
+
} = stack.shift();
|
|
142
|
+
stack.push(...innerBlocks);
|
|
143
|
+
result.push([block.clientId, transform(block)]);
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
return result;
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
function getFlattenedClientIds(blocks) {
|
|
114
150
|
const result = {};
|
|
115
151
|
const stack = [...blocks];
|
|
116
152
|
|
|
@@ -120,7 +156,7 @@ function flattenBlocks(blocks) {
|
|
|
120
156
|
...block
|
|
121
157
|
} = stack.shift();
|
|
122
158
|
stack.push(...innerBlocks);
|
|
123
|
-
result[block.clientId] =
|
|
159
|
+
result[block.clientId] = true;
|
|
124
160
|
}
|
|
125
161
|
|
|
126
162
|
return result;
|
|
@@ -132,12 +168,18 @@ function flattenBlocks(blocks) {
|
|
|
132
168
|
*
|
|
133
169
|
* @param {Array} blocks Blocks to flatten.
|
|
134
170
|
*
|
|
135
|
-
* @return {
|
|
171
|
+
* @return {Array} Flattened block attributes object.
|
|
136
172
|
*/
|
|
137
173
|
|
|
138
174
|
|
|
139
175
|
function getFlattenedBlocksWithoutAttributes(blocks) {
|
|
140
|
-
return flattenBlocks(blocks, block =>
|
|
176
|
+
return flattenBlocks(blocks, block => {
|
|
177
|
+
const {
|
|
178
|
+
attributes,
|
|
179
|
+
...restBlock
|
|
180
|
+
} = block;
|
|
181
|
+
return restBlock;
|
|
182
|
+
});
|
|
141
183
|
}
|
|
142
184
|
/**
|
|
143
185
|
* Given an array of blocks, returns an object containing all block attributes,
|
|
@@ -146,32 +188,13 @@ function getFlattenedBlocksWithoutAttributes(blocks) {
|
|
|
146
188
|
*
|
|
147
189
|
* @param {Array} blocks Blocks to flatten.
|
|
148
190
|
*
|
|
149
|
-
* @return {
|
|
191
|
+
* @return {Array} Flattened block attributes object.
|
|
150
192
|
*/
|
|
151
193
|
|
|
152
194
|
|
|
153
195
|
function getFlattenedBlockAttributes(blocks) {
|
|
154
196
|
return flattenBlocks(blocks, block => block.attributes);
|
|
155
197
|
}
|
|
156
|
-
/**
|
|
157
|
-
* Returns an object against which it is safe to perform mutating operations,
|
|
158
|
-
* given the original object and its current working copy.
|
|
159
|
-
*
|
|
160
|
-
* @param {Object} original Original object.
|
|
161
|
-
* @param {Object} working Working object.
|
|
162
|
-
*
|
|
163
|
-
* @return {Object} Mutation-safe object.
|
|
164
|
-
*/
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
function getMutateSafeObject(original, working) {
|
|
168
|
-
if (original === working) {
|
|
169
|
-
return { ...original
|
|
170
|
-
};
|
|
171
|
-
}
|
|
172
|
-
|
|
173
|
-
return working;
|
|
174
|
-
}
|
|
175
198
|
/**
|
|
176
199
|
* Returns true if the two object arguments have the same keys, or false
|
|
177
200
|
* otherwise.
|
|
@@ -184,7 +207,7 @@ function getMutateSafeObject(original, working) {
|
|
|
184
207
|
|
|
185
208
|
|
|
186
209
|
function hasSameKeys(a, b) {
|
|
187
|
-
return (0,
|
|
210
|
+
return (0, _es.default)(Object.keys(a), Object.keys(b));
|
|
188
211
|
}
|
|
189
212
|
/**
|
|
190
213
|
* Returns true if, given the currently dispatching action and the previously
|
|
@@ -199,11 +222,11 @@ function hasSameKeys(a, b) {
|
|
|
199
222
|
|
|
200
223
|
|
|
201
224
|
function isUpdatingSameBlockAttribute(action, lastAction) {
|
|
202
|
-
return action.type === 'UPDATE_BLOCK_ATTRIBUTES' && lastAction !== undefined && lastAction.type === 'UPDATE_BLOCK_ATTRIBUTES' && (0,
|
|
225
|
+
return action.type === 'UPDATE_BLOCK_ATTRIBUTES' && lastAction !== undefined && lastAction.type === 'UPDATE_BLOCK_ATTRIBUTES' && (0, _es.default)(action.clientIds, lastAction.clientIds) && hasSameKeys(action.attributes, lastAction.attributes);
|
|
203
226
|
}
|
|
204
227
|
|
|
205
|
-
function
|
|
206
|
-
const
|
|
228
|
+
function updateBlockTreeForBlocks(state, blocks) {
|
|
229
|
+
const treeToUpdate = state.tree;
|
|
207
230
|
const stack = [...blocks];
|
|
208
231
|
const flattenedBlocks = [...blocks];
|
|
209
232
|
|
|
@@ -215,26 +238,25 @@ function buildBlockTree(state, blocks) {
|
|
|
215
238
|
|
|
216
239
|
|
|
217
240
|
for (const block of flattenedBlocks) {
|
|
218
|
-
|
|
241
|
+
treeToUpdate.set(block.clientId, {});
|
|
219
242
|
}
|
|
220
243
|
|
|
221
244
|
for (const block of flattenedBlocks) {
|
|
222
|
-
|
|
223
|
-
attributes: state.attributes
|
|
224
|
-
innerBlocks: block.innerBlocks.map(subBlock =>
|
|
225
|
-
});
|
|
245
|
+
treeToUpdate.set(block.clientId, Object.assign(treeToUpdate.get(block.clientId), { ...state.byClientId.get(block.clientId),
|
|
246
|
+
attributes: state.attributes.get(block.clientId),
|
|
247
|
+
innerBlocks: block.innerBlocks.map(subBlock => treeToUpdate.get(subBlock.clientId))
|
|
248
|
+
}));
|
|
226
249
|
}
|
|
227
|
-
|
|
228
|
-
return result;
|
|
229
250
|
}
|
|
230
251
|
|
|
231
|
-
function updateParentInnerBlocksInTree(state,
|
|
232
|
-
let updateChildrenOfUpdatedClientIds = arguments.length >
|
|
252
|
+
function updateParentInnerBlocksInTree(state, updatedClientIds) {
|
|
253
|
+
let updateChildrenOfUpdatedClientIds = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
|
|
254
|
+
const treeToUpdate = state.tree;
|
|
233
255
|
const uncontrolledParents = new Set([]);
|
|
234
256
|
const controlledParents = new Set();
|
|
235
257
|
|
|
236
258
|
for (const clientId of updatedClientIds) {
|
|
237
|
-
let current = updateChildrenOfUpdatedClientIds ? clientId : state.parents
|
|
259
|
+
let current = updateChildrenOfUpdatedClientIds ? clientId : state.parents.get(clientId);
|
|
238
260
|
|
|
239
261
|
do {
|
|
240
262
|
if (state.controlledInnerBlocks[current]) {
|
|
@@ -245,7 +267,7 @@ function updateParentInnerBlocksInTree(state, tree, updatedClientIds) {
|
|
|
245
267
|
} else {
|
|
246
268
|
// Else continue traversing up through parents.
|
|
247
269
|
uncontrolledParents.add(current);
|
|
248
|
-
current = state.parents
|
|
270
|
+
current = state.parents.get(current);
|
|
249
271
|
}
|
|
250
272
|
} while (current !== undefined);
|
|
251
273
|
} // To make sure the order of assignments doesn't matter,
|
|
@@ -253,23 +275,21 @@ function updateParentInnerBlocksInTree(state, tree, updatedClientIds) {
|
|
|
253
275
|
|
|
254
276
|
|
|
255
277
|
for (const clientId of uncontrolledParents) {
|
|
256
|
-
|
|
257
|
-
};
|
|
278
|
+
treeToUpdate.set(clientId, { ...treeToUpdate.get(clientId)
|
|
279
|
+
});
|
|
258
280
|
}
|
|
259
281
|
|
|
260
282
|
for (const clientId of uncontrolledParents) {
|
|
261
|
-
|
|
283
|
+
treeToUpdate.get(clientId).innerBlocks = (state.order.get(clientId) || []).map(subClientId => treeToUpdate.get(subClientId));
|
|
262
284
|
} // Controlled parent blocks, need a dedicated key for their inner blocks
|
|
263
285
|
// to be used when doing getBlocks( controlledBlockClientId ).
|
|
264
286
|
|
|
265
287
|
|
|
266
288
|
for (const clientId of controlledParents) {
|
|
267
|
-
|
|
268
|
-
innerBlocks: (state.order
|
|
269
|
-
};
|
|
289
|
+
treeToUpdate.set('controlled||' + clientId, {
|
|
290
|
+
innerBlocks: (state.order.get(clientId) || []).map(subClientId => treeToUpdate.get(subClientId))
|
|
291
|
+
});
|
|
270
292
|
}
|
|
271
|
-
|
|
272
|
-
return tree;
|
|
273
293
|
}
|
|
274
294
|
/**
|
|
275
295
|
* Higher-order reducer intended to compute full block objects key for each block in the post.
|
|
@@ -291,61 +311,61 @@ const withBlockTree = reducer => function () {
|
|
|
291
311
|
return state;
|
|
292
312
|
}
|
|
293
313
|
|
|
294
|
-
newState.tree = state.tree ? state.tree :
|
|
314
|
+
newState.tree = state.tree ? state.tree : new Map();
|
|
295
315
|
|
|
296
316
|
switch (action.type) {
|
|
297
317
|
case 'RECEIVE_BLOCKS':
|
|
298
318
|
case 'INSERT_BLOCKS':
|
|
299
319
|
{
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
}, action.rootClientId ? [action.rootClientId] : [''], true);
|
|
320
|
+
newState.tree = new Map(newState.tree);
|
|
321
|
+
updateBlockTreeForBlocks(newState, action.blocks);
|
|
322
|
+
updateParentInnerBlocksInTree(newState, action.rootClientId ? [action.rootClientId] : [''], true);
|
|
304
323
|
break;
|
|
305
324
|
}
|
|
306
325
|
|
|
307
326
|
case 'UPDATE_BLOCK':
|
|
308
|
-
newState.tree =
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
327
|
+
newState.tree = new Map(newState.tree);
|
|
328
|
+
newState.tree.set(action.clientId, { ...newState.tree.get(action.clientId),
|
|
329
|
+
...newState.byClientId.get(action.clientId),
|
|
330
|
+
attributes: newState.attributes.get(action.clientId)
|
|
331
|
+
});
|
|
332
|
+
updateParentInnerBlocksInTree(newState, [action.clientId], false);
|
|
314
333
|
break;
|
|
315
334
|
|
|
316
335
|
case 'UPDATE_BLOCK_ATTRIBUTES':
|
|
317
336
|
{
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
}
|
|
324
|
-
|
|
325
|
-
...newSubTree
|
|
326
|
-
}, action.clientIds, false);
|
|
337
|
+
newState.tree = new Map(newState.tree);
|
|
338
|
+
action.clientIds.forEach(clientId => {
|
|
339
|
+
newState.tree.set(clientId, { ...newState.tree.get(clientId),
|
|
340
|
+
attributes: newState.attributes.get(clientId)
|
|
341
|
+
});
|
|
342
|
+
});
|
|
343
|
+
updateParentInnerBlocksInTree(newState, action.clientIds, false);
|
|
327
344
|
break;
|
|
328
345
|
}
|
|
329
346
|
|
|
330
347
|
case 'REPLACE_BLOCKS_AUGMENTED_WITH_CHILDREN':
|
|
331
348
|
{
|
|
332
|
-
const
|
|
333
|
-
newState.tree =
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
349
|
+
const inserterClientIds = getFlattenedClientIds(action.blocks);
|
|
350
|
+
newState.tree = new Map(newState.tree);
|
|
351
|
+
action.replacedClientIds.concat( // Controlled inner blocks are only removed
|
|
352
|
+
// if the block doesn't move to another position
|
|
353
|
+
// otherwise their content will be lost.
|
|
354
|
+
action.replacedClientIds.filter(clientId => !inserterClientIds[clientId]).map(clientId => 'controlled||' + clientId)).forEach(key => {
|
|
355
|
+
newState.tree.delete(key);
|
|
356
|
+
});
|
|
357
|
+
updateBlockTreeForBlocks(newState, action.blocks);
|
|
358
|
+
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.
|
|
339
359
|
|
|
340
360
|
const parentsOfRemovedBlocks = [];
|
|
341
361
|
|
|
342
362
|
for (const clientId of action.clientIds) {
|
|
343
|
-
if (state.parents
|
|
344
|
-
parentsOfRemovedBlocks.push(state.parents
|
|
363
|
+
if (state.parents.get(clientId) !== undefined && (state.parents.get(clientId) === '' || newState.byClientId.get(state.parents.get(clientId)))) {
|
|
364
|
+
parentsOfRemovedBlocks.push(state.parents.get(clientId));
|
|
345
365
|
}
|
|
346
366
|
}
|
|
347
367
|
|
|
348
|
-
|
|
368
|
+
updateParentInnerBlocksInTree(newState, parentsOfRemovedBlocks, true);
|
|
349
369
|
break;
|
|
350
370
|
}
|
|
351
371
|
|
|
@@ -353,12 +373,16 @@ const withBlockTree = reducer => function () {
|
|
|
353
373
|
const parentsOfRemovedBlocks = [];
|
|
354
374
|
|
|
355
375
|
for (const clientId of action.clientIds) {
|
|
356
|
-
if (state.parents
|
|
357
|
-
parentsOfRemovedBlocks.push(state.parents
|
|
376
|
+
if (state.parents.get(clientId) !== undefined && (state.parents.get(clientId) === '' || newState.byClientId.get(state.parents.get(clientId)))) {
|
|
377
|
+
parentsOfRemovedBlocks.push(state.parents.get(clientId));
|
|
358
378
|
}
|
|
359
379
|
}
|
|
360
380
|
|
|
361
|
-
newState.tree =
|
|
381
|
+
newState.tree = new Map(newState.tree);
|
|
382
|
+
action.removedClientIds.concat(action.removedClientIds.map(clientId => 'controlled||' + clientId)).forEach(key => {
|
|
383
|
+
newState.tree.delete(key);
|
|
384
|
+
});
|
|
385
|
+
updateParentInnerBlocksInTree(newState, parentsOfRemovedBlocks, true);
|
|
362
386
|
break;
|
|
363
387
|
|
|
364
388
|
case 'MOVE_BLOCKS_TO_POSITION':
|
|
@@ -375,7 +399,8 @@ const withBlockTree = reducer => function () {
|
|
|
375
399
|
updatedBlockUids.push(action.toRootClientId);
|
|
376
400
|
}
|
|
377
401
|
|
|
378
|
-
newState.tree =
|
|
402
|
+
newState.tree = new Map(newState.tree);
|
|
403
|
+
updateParentInnerBlocksInTree(newState, updatedBlockUids, true);
|
|
379
404
|
break;
|
|
380
405
|
}
|
|
381
406
|
|
|
@@ -383,28 +408,27 @@ const withBlockTree = reducer => function () {
|
|
|
383
408
|
case 'MOVE_BLOCKS_DOWN':
|
|
384
409
|
{
|
|
385
410
|
const updatedBlockUids = [action.rootClientId ? action.rootClientId : ''];
|
|
386
|
-
newState.tree =
|
|
411
|
+
newState.tree = new Map(newState.tree);
|
|
412
|
+
updateParentInnerBlocksInTree(newState, updatedBlockUids, true);
|
|
387
413
|
break;
|
|
388
414
|
}
|
|
389
415
|
|
|
390
416
|
case 'SAVE_REUSABLE_BLOCK_SUCCESS':
|
|
391
417
|
{
|
|
392
|
-
const updatedBlockUids =
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
return clientId;
|
|
418
|
+
const updatedBlockUids = [];
|
|
419
|
+
newState.attributes.forEach((attributes, clientId) => {
|
|
420
|
+
if (newState.byClientId.get(clientId).name === 'core/block' && attributes.ref === action.updatedId) {
|
|
421
|
+
updatedBlockUids.push(clientId);
|
|
422
|
+
}
|
|
398
423
|
});
|
|
399
|
-
newState.tree =
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
}, updatedBlockUids, false);
|
|
424
|
+
newState.tree = new Map(newState.tree);
|
|
425
|
+
updatedBlockUids.forEach(clientId => {
|
|
426
|
+
newState.tree.set(clientId, { ...newState.byClientId.get(clientId),
|
|
427
|
+
attributes: newState.attributes.get(clientId),
|
|
428
|
+
innerBlocks: newState.tree.get(clientId).innerBlocks
|
|
429
|
+
});
|
|
430
|
+
});
|
|
431
|
+
updateParentInnerBlocksInTree(newState, updatedBlockUids, false);
|
|
408
432
|
}
|
|
409
433
|
}
|
|
410
434
|
|
|
@@ -501,7 +525,7 @@ const withInnerBlocksRemoveCascade = reducer => (state, action) => {
|
|
|
501
525
|
let result = clientIds;
|
|
502
526
|
|
|
503
527
|
for (let i = 0; i < result.length; i++) {
|
|
504
|
-
if (!state.order
|
|
528
|
+
if (!state.order.get(result[i]) || action.keepControlledInnerBlocks && action.keepControlledInnerBlocks[result[i]]) {
|
|
505
529
|
continue;
|
|
506
530
|
}
|
|
507
531
|
|
|
@@ -509,7 +533,7 @@ const withInnerBlocksRemoveCascade = reducer => (state, action) => {
|
|
|
509
533
|
result = [...result];
|
|
510
534
|
}
|
|
511
535
|
|
|
512
|
-
result.push(...state.order
|
|
536
|
+
result.push(...state.order.get(result[i]));
|
|
513
537
|
}
|
|
514
538
|
|
|
515
539
|
return result;
|
|
@@ -550,19 +574,17 @@ const withInnerBlocksRemoveCascade = reducer => (state, action) => {
|
|
|
550
574
|
const withBlockReset = reducer => (state, action) => {
|
|
551
575
|
if (action.type === 'RESET_BLOCKS') {
|
|
552
576
|
const newState = { ...state,
|
|
553
|
-
byClientId: getFlattenedBlocksWithoutAttributes(action.blocks),
|
|
554
|
-
attributes: getFlattenedBlockAttributes(action.blocks),
|
|
577
|
+
byClientId: new Map(getFlattenedBlocksWithoutAttributes(action.blocks)),
|
|
578
|
+
attributes: new Map(getFlattenedBlockAttributes(action.blocks)),
|
|
555
579
|
order: mapBlockOrder(action.blocks),
|
|
556
|
-
parents: mapBlockParents(action.blocks),
|
|
580
|
+
parents: new Map(mapBlockParents(action.blocks)),
|
|
557
581
|
controlledInnerBlocks: {}
|
|
558
582
|
};
|
|
559
|
-
|
|
560
|
-
newState.
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
|
|
564
|
-
}
|
|
565
|
-
};
|
|
583
|
+
newState.tree = new Map(state === null || state === void 0 ? void 0 : state.tree);
|
|
584
|
+
updateBlockTreeForBlocks(newState, action.blocks);
|
|
585
|
+
newState.tree.set('', {
|
|
586
|
+
innerBlocks: action.blocks.map(subBlock => newState.tree.get(subBlock.clientId))
|
|
587
|
+
});
|
|
566
588
|
return newState;
|
|
567
589
|
}
|
|
568
590
|
|
|
@@ -615,11 +637,11 @@ const withReplaceInnerBlocks = reducer => (state, action) => {
|
|
|
615
637
|
|
|
616
638
|
let stateAfterBlocksRemoval = state;
|
|
617
639
|
|
|
618
|
-
if (state.order
|
|
640
|
+
if (state.order.get(action.rootClientId)) {
|
|
619
641
|
stateAfterBlocksRemoval = reducer(stateAfterBlocksRemoval, {
|
|
620
642
|
type: 'REMOVE_BLOCKS',
|
|
621
643
|
keepControlledInnerBlocks: nestedControllers,
|
|
622
|
-
clientIds: state.order
|
|
644
|
+
clientIds: state.order.get(action.rootClientId)
|
|
623
645
|
});
|
|
624
646
|
}
|
|
625
647
|
|
|
@@ -633,26 +655,21 @@ const withReplaceInnerBlocks = reducer => (state, action) => {
|
|
|
633
655
|
// preserve their block order. Otherwise, an inner block controller's blocks
|
|
634
656
|
// will be deleted entirely from its entity.
|
|
635
657
|
|
|
636
|
-
|
|
637
|
-
|
|
638
|
-
|
|
639
|
-
|
|
640
|
-
|
|
641
|
-
|
|
642
|
-
|
|
643
|
-
|
|
644
|
-
|
|
645
|
-
|
|
646
|
-
...Object.keys(nestedControllers).reduce((result, _key) => {
|
|
647
|
-
const key = `controlled||${_key}`;
|
|
648
|
-
|
|
649
|
-
if (state.tree[key]) {
|
|
650
|
-
result[key] = state.tree[key];
|
|
651
|
-
}
|
|
658
|
+
const stateAfterInsertOrder = new Map(stateAfterInsert.order);
|
|
659
|
+
Object.keys(nestedControllers).forEach(key => {
|
|
660
|
+
if (state.order.get(key)) {
|
|
661
|
+
stateAfterInsertOrder.set(key, state.order.get(key));
|
|
662
|
+
}
|
|
663
|
+
});
|
|
664
|
+
stateAfterInsert.order = stateAfterInsertOrder;
|
|
665
|
+
stateAfterInsert.tree = new Map(stateAfterInsert.tree);
|
|
666
|
+
Object.keys(nestedControllers).forEach(_key => {
|
|
667
|
+
const key = `controlled||${_key}`;
|
|
652
668
|
|
|
653
|
-
|
|
654
|
-
|
|
655
|
-
|
|
669
|
+
if (state.tree.has(key)) {
|
|
670
|
+
stateAfterInsert.tree.set(key, state.tree.get(key));
|
|
671
|
+
}
|
|
672
|
+
});
|
|
656
673
|
}
|
|
657
674
|
|
|
658
675
|
return stateAfterInsert;
|
|
@@ -682,18 +699,17 @@ const withSaveReusableBlock = reducer => (state, action) => {
|
|
|
682
699
|
|
|
683
700
|
state = { ...state
|
|
684
701
|
};
|
|
685
|
-
state.attributes =
|
|
702
|
+
state.attributes = new Map(state.attributes);
|
|
703
|
+
state.attributes.forEach((attributes, clientId) => {
|
|
686
704
|
const {
|
|
687
705
|
name
|
|
688
|
-
} = state.byClientId
|
|
706
|
+
} = state.byClientId.get(clientId);
|
|
689
707
|
|
|
690
708
|
if (name === 'core/block' && attributes.ref === id) {
|
|
691
|
-
|
|
709
|
+
state.attributes.set(clientId, { ...attributes,
|
|
692
710
|
ref: updatedId
|
|
693
|
-
};
|
|
711
|
+
});
|
|
694
712
|
}
|
|
695
|
-
|
|
696
|
-
return attributes;
|
|
697
713
|
});
|
|
698
714
|
}
|
|
699
715
|
|
|
@@ -736,137 +752,205 @@ const blocks = (0, _compose.pipe)(_data.combineReducers, withSaveReusableBlock,
|
|
|
736
752
|
withBlockTree, // Needs to be before withInnerBlocksRemoveCascade.
|
|
737
753
|
withInnerBlocksRemoveCascade, withReplaceInnerBlocks, // Needs to be after withInnerBlocksRemoveCascade.
|
|
738
754
|
withBlockReset, withPersistentBlockChange, withIgnoredBlockChange, withResetControlledBlocks)({
|
|
755
|
+
// The state is using a Map instead of a plain object for performance reasons.
|
|
756
|
+
// You can run the "./test/performance.js" unit test to check the impact
|
|
757
|
+
// code changes can have on this reducer.
|
|
739
758
|
byClientId() {
|
|
740
|
-
let state = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] :
|
|
759
|
+
let state = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : new Map();
|
|
741
760
|
let action = arguments.length > 1 ? arguments[1] : undefined;
|
|
742
761
|
|
|
743
762
|
switch (action.type) {
|
|
744
763
|
case 'RECEIVE_BLOCKS':
|
|
745
764
|
case 'INSERT_BLOCKS':
|
|
746
|
-
|
|
747
|
-
|
|
748
|
-
|
|
765
|
+
{
|
|
766
|
+
const newState = new Map(state);
|
|
767
|
+
getFlattenedBlocksWithoutAttributes(action.blocks).forEach(_ref2 => {
|
|
768
|
+
let [key, value] = _ref2;
|
|
769
|
+
newState.set(key, value);
|
|
770
|
+
});
|
|
771
|
+
return newState;
|
|
772
|
+
}
|
|
749
773
|
|
|
750
774
|
case 'UPDATE_BLOCK':
|
|
751
|
-
|
|
752
|
-
|
|
753
|
-
|
|
754
|
-
|
|
775
|
+
{
|
|
776
|
+
// Ignore updates if block isn't known.
|
|
777
|
+
if (!state.has(action.clientId)) {
|
|
778
|
+
return state;
|
|
779
|
+
} // Do nothing if only attributes change.
|
|
755
780
|
|
|
756
781
|
|
|
757
|
-
|
|
782
|
+
const {
|
|
783
|
+
attributes,
|
|
784
|
+
...changes
|
|
785
|
+
} = action.updates;
|
|
758
786
|
|
|
759
|
-
|
|
760
|
-
|
|
761
|
-
|
|
787
|
+
if (Object.values(changes).length === 0) {
|
|
788
|
+
return state;
|
|
789
|
+
}
|
|
762
790
|
|
|
763
|
-
|
|
764
|
-
|
|
791
|
+
const newState = new Map(state);
|
|
792
|
+
newState.set(action.clientId, { ...state.get(action.clientId),
|
|
765
793
|
...changes
|
|
766
|
-
}
|
|
767
|
-
|
|
794
|
+
});
|
|
795
|
+
return newState;
|
|
796
|
+
}
|
|
768
797
|
|
|
769
798
|
case 'REPLACE_BLOCKS_AUGMENTED_WITH_CHILDREN':
|
|
770
|
-
|
|
771
|
-
|
|
772
|
-
|
|
799
|
+
{
|
|
800
|
+
if (!action.blocks) {
|
|
801
|
+
return state;
|
|
802
|
+
}
|
|
773
803
|
|
|
774
|
-
|
|
775
|
-
|
|
776
|
-
|
|
804
|
+
const newState = new Map(state);
|
|
805
|
+
action.replacedClientIds.forEach(clientId => {
|
|
806
|
+
newState.delete(clientId);
|
|
807
|
+
});
|
|
808
|
+
getFlattenedBlocksWithoutAttributes(action.blocks).forEach(_ref3 => {
|
|
809
|
+
let [key, value] = _ref3;
|
|
810
|
+
newState.set(key, value);
|
|
811
|
+
});
|
|
812
|
+
return newState;
|
|
813
|
+
}
|
|
777
814
|
|
|
778
815
|
case 'REMOVE_BLOCKS_AUGMENTED_WITH_CHILDREN':
|
|
779
|
-
|
|
816
|
+
{
|
|
817
|
+
const newState = new Map(state);
|
|
818
|
+
action.removedClientIds.forEach(clientId => {
|
|
819
|
+
newState.delete(clientId);
|
|
820
|
+
});
|
|
821
|
+
return newState;
|
|
822
|
+
}
|
|
780
823
|
}
|
|
781
824
|
|
|
782
825
|
return state;
|
|
783
826
|
},
|
|
784
827
|
|
|
828
|
+
// The state is using a Map instead of a plain object for performance reasons.
|
|
829
|
+
// You can run the "./test/performance.js" unit test to check the impact
|
|
830
|
+
// code changes can have on this reducer.
|
|
785
831
|
attributes() {
|
|
786
|
-
let state = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] :
|
|
832
|
+
let state = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : new Map();
|
|
787
833
|
let action = arguments.length > 1 ? arguments[1] : undefined;
|
|
788
834
|
|
|
789
835
|
switch (action.type) {
|
|
790
836
|
case 'RECEIVE_BLOCKS':
|
|
791
837
|
case 'INSERT_BLOCKS':
|
|
792
|
-
|
|
793
|
-
|
|
794
|
-
|
|
838
|
+
{
|
|
839
|
+
const newState = new Map(state);
|
|
840
|
+
getFlattenedBlockAttributes(action.blocks).forEach(_ref4 => {
|
|
841
|
+
let [key, value] = _ref4;
|
|
842
|
+
newState.set(key, value);
|
|
843
|
+
});
|
|
844
|
+
return newState;
|
|
845
|
+
}
|
|
795
846
|
|
|
796
847
|
case 'UPDATE_BLOCK':
|
|
797
|
-
|
|
798
|
-
|
|
799
|
-
|
|
800
|
-
|
|
848
|
+
{
|
|
849
|
+
// Ignore updates if block isn't known or there are no attribute changes.
|
|
850
|
+
if (!state.get(action.clientId) || !action.updates.attributes) {
|
|
851
|
+
return state;
|
|
852
|
+
}
|
|
801
853
|
|
|
802
|
-
|
|
803
|
-
|
|
854
|
+
const newState = new Map(state);
|
|
855
|
+
newState.set(action.clientId, { ...state.get(action.clientId),
|
|
804
856
|
...action.updates.attributes
|
|
805
|
-
}
|
|
806
|
-
|
|
857
|
+
});
|
|
858
|
+
return newState;
|
|
859
|
+
}
|
|
807
860
|
|
|
808
861
|
case 'UPDATE_BLOCK_ATTRIBUTES':
|
|
809
862
|
{
|
|
810
863
|
// Avoid a state change if none of the block IDs are known.
|
|
811
|
-
if (action.clientIds.every(id => !state
|
|
864
|
+
if (action.clientIds.every(id => !state.get(id))) {
|
|
812
865
|
return state;
|
|
813
866
|
}
|
|
814
867
|
|
|
815
|
-
|
|
816
|
-
|
|
868
|
+
let hasChange = false;
|
|
869
|
+
const newState = new Map(state);
|
|
817
870
|
|
|
818
|
-
|
|
819
|
-
|
|
820
|
-
let [key, value] = _ref3;
|
|
871
|
+
for (const clientId of action.clientIds) {
|
|
872
|
+
var _action$attributes;
|
|
821
873
|
|
|
822
|
-
|
|
823
|
-
if (value !== result[key]) {
|
|
824
|
-
result = getMutateSafeObject(state[id], result);
|
|
825
|
-
result[key] = value;
|
|
826
|
-
}
|
|
874
|
+
const updatedAttributeEntries = Object.entries(action.uniqueByBlock ? action.attributes[clientId] : (_action$attributes = action.attributes) !== null && _action$attributes !== void 0 ? _action$attributes : {});
|
|
827
875
|
|
|
828
|
-
|
|
829
|
-
|
|
830
|
-
}
|
|
831
|
-
}, {});
|
|
876
|
+
if (updatedAttributeEntries.length === 0) {
|
|
877
|
+
continue;
|
|
878
|
+
}
|
|
832
879
|
|
|
833
|
-
|
|
834
|
-
|
|
880
|
+
let hasUpdatedAttributes = false;
|
|
881
|
+
const existingAttributes = state.get(clientId);
|
|
882
|
+
const newAttributes = {};
|
|
883
|
+
updatedAttributeEntries.forEach(_ref5 => {
|
|
884
|
+
let [key, value] = _ref5;
|
|
885
|
+
|
|
886
|
+
if (existingAttributes[key] !== value) {
|
|
887
|
+
hasUpdatedAttributes = true;
|
|
888
|
+
newAttributes[key] = value;
|
|
889
|
+
}
|
|
890
|
+
});
|
|
891
|
+
hasChange = hasChange || hasUpdatedAttributes;
|
|
892
|
+
|
|
893
|
+
if (hasUpdatedAttributes) {
|
|
894
|
+
newState.set(clientId, { ...existingAttributes,
|
|
895
|
+
...newAttributes
|
|
896
|
+
});
|
|
897
|
+
}
|
|
835
898
|
}
|
|
836
899
|
|
|
837
|
-
return
|
|
838
|
-
...next
|
|
839
|
-
};
|
|
900
|
+
return hasChange ? newState : state;
|
|
840
901
|
}
|
|
841
902
|
|
|
842
903
|
case 'REPLACE_BLOCKS_AUGMENTED_WITH_CHILDREN':
|
|
843
|
-
|
|
844
|
-
|
|
845
|
-
|
|
904
|
+
{
|
|
905
|
+
if (!action.blocks) {
|
|
906
|
+
return state;
|
|
907
|
+
}
|
|
846
908
|
|
|
847
|
-
|
|
848
|
-
|
|
849
|
-
|
|
909
|
+
const newState = new Map(state);
|
|
910
|
+
action.replacedClientIds.forEach(clientId => {
|
|
911
|
+
newState.delete(clientId);
|
|
912
|
+
});
|
|
913
|
+
getFlattenedBlockAttributes(action.blocks).forEach(_ref6 => {
|
|
914
|
+
let [key, value] = _ref6;
|
|
915
|
+
newState.set(key, value);
|
|
916
|
+
});
|
|
917
|
+
return newState;
|
|
918
|
+
}
|
|
850
919
|
|
|
851
920
|
case 'REMOVE_BLOCKS_AUGMENTED_WITH_CHILDREN':
|
|
852
|
-
|
|
921
|
+
{
|
|
922
|
+
const newState = new Map(state);
|
|
923
|
+
action.removedClientIds.forEach(clientId => {
|
|
924
|
+
newState.delete(clientId);
|
|
925
|
+
});
|
|
926
|
+
return newState;
|
|
927
|
+
}
|
|
853
928
|
}
|
|
854
929
|
|
|
855
930
|
return state;
|
|
856
931
|
},
|
|
857
932
|
|
|
933
|
+
// The state is using a Map instead of a plain object for performance reasons.
|
|
934
|
+
// You can run the "./test/performance.js" unit test to check the impact
|
|
935
|
+
// code changes can have on this reducer.
|
|
858
936
|
order() {
|
|
859
|
-
let state = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] :
|
|
937
|
+
let state = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : new Map();
|
|
860
938
|
let action = arguments.length > 1 ? arguments[1] : undefined;
|
|
861
939
|
|
|
862
940
|
switch (action.type) {
|
|
863
941
|
case 'RECEIVE_BLOCKS':
|
|
864
942
|
{
|
|
943
|
+
var _state$get;
|
|
944
|
+
|
|
865
945
|
const blockOrder = mapBlockOrder(action.blocks);
|
|
866
|
-
|
|
867
|
-
|
|
868
|
-
|
|
869
|
-
|
|
946
|
+
const newState = new Map(state);
|
|
947
|
+
blockOrder.forEach((order, clientId) => {
|
|
948
|
+
if (clientId !== '') {
|
|
949
|
+
newState.set(clientId, order);
|
|
950
|
+
}
|
|
951
|
+
});
|
|
952
|
+
newState.set('', ((_state$get = state.get('')) !== null && _state$get !== void 0 ? _state$get : []).concat(blockOrder['']));
|
|
953
|
+
return newState;
|
|
870
954
|
}
|
|
871
955
|
|
|
872
956
|
case 'INSERT_BLOCKS':
|
|
@@ -874,20 +958,22 @@ withBlockReset, withPersistentBlockChange, withIgnoredBlockChange, withResetCont
|
|
|
874
958
|
const {
|
|
875
959
|
rootClientId = ''
|
|
876
960
|
} = action;
|
|
877
|
-
const subState = state
|
|
961
|
+
const subState = state.get(rootClientId) || [];
|
|
878
962
|
const mappedBlocks = mapBlockOrder(action.blocks, rootClientId);
|
|
879
963
|
const {
|
|
880
964
|
index = subState.length
|
|
881
965
|
} = action;
|
|
882
|
-
|
|
883
|
-
|
|
884
|
-
|
|
885
|
-
};
|
|
966
|
+
const newState = new Map(state);
|
|
967
|
+
mappedBlocks.forEach((order, clientId) => {
|
|
968
|
+
newState.set(clientId, order);
|
|
969
|
+
});
|
|
970
|
+
newState.set(rootClientId, (0, _array.insertAt)(subState, mappedBlocks.get(rootClientId), index));
|
|
971
|
+
return newState;
|
|
886
972
|
}
|
|
887
973
|
|
|
888
974
|
case 'MOVE_BLOCKS_TO_POSITION':
|
|
889
975
|
{
|
|
890
|
-
var _state$
|
|
976
|
+
var _state$get$filter, _state$get2;
|
|
891
977
|
|
|
892
978
|
const {
|
|
893
979
|
fromRootClientId = '',
|
|
@@ -895,22 +981,22 @@ withBlockReset, withPersistentBlockChange, withIgnoredBlockChange, withResetCont
|
|
|
895
981
|
clientIds
|
|
896
982
|
} = action;
|
|
897
983
|
const {
|
|
898
|
-
index = state
|
|
984
|
+
index = state.get(toRootClientId).length
|
|
899
985
|
} = action; // Moving inside the same parent block.
|
|
900
986
|
|
|
901
987
|
if (fromRootClientId === toRootClientId) {
|
|
902
|
-
const subState = state
|
|
988
|
+
const subState = state.get(toRootClientId);
|
|
903
989
|
const fromIndex = subState.indexOf(clientIds[0]);
|
|
904
|
-
|
|
905
|
-
|
|
906
|
-
|
|
990
|
+
const newState = new Map(state);
|
|
991
|
+
newState.set(toRootClientId, (0, _array.moveTo)(state.get(toRootClientId), fromIndex, index, clientIds.length));
|
|
992
|
+
return newState;
|
|
907
993
|
} // Moving from a parent block to another.
|
|
908
994
|
|
|
909
995
|
|
|
910
|
-
|
|
911
|
-
|
|
912
|
-
|
|
913
|
-
|
|
996
|
+
const newState = new Map(state);
|
|
997
|
+
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 : []);
|
|
998
|
+
newState.set(toRootClientId, (0, _array.insertAt)(state.get(toRootClientId), clientIds, index));
|
|
999
|
+
return newState;
|
|
914
1000
|
}
|
|
915
1001
|
|
|
916
1002
|
case 'MOVE_BLOCKS_UP':
|
|
@@ -920,16 +1006,16 @@ withBlockReset, withPersistentBlockChange, withIgnoredBlockChange, withResetCont
|
|
|
920
1006
|
rootClientId = ''
|
|
921
1007
|
} = action;
|
|
922
1008
|
const firstClientId = clientIds[0];
|
|
923
|
-
const subState = state
|
|
1009
|
+
const subState = state.get(rootClientId);
|
|
924
1010
|
|
|
925
1011
|
if (!subState.length || firstClientId === subState[0]) {
|
|
926
1012
|
return state;
|
|
927
1013
|
}
|
|
928
1014
|
|
|
929
1015
|
const firstIndex = subState.indexOf(firstClientId);
|
|
930
|
-
|
|
931
|
-
|
|
932
|
-
|
|
1016
|
+
const newState = new Map(state);
|
|
1017
|
+
newState.set(rootClientId, (0, _array.moveTo)(subState, firstIndex, firstIndex - 1, clientIds.length));
|
|
1018
|
+
return newState;
|
|
933
1019
|
}
|
|
934
1020
|
|
|
935
1021
|
case 'MOVE_BLOCKS_DOWN':
|
|
@@ -940,16 +1026,16 @@ withBlockReset, withPersistentBlockChange, withIgnoredBlockChange, withResetCont
|
|
|
940
1026
|
} = action;
|
|
941
1027
|
const firstClientId = clientIds[0];
|
|
942
1028
|
const lastClientId = clientIds[clientIds.length - 1];
|
|
943
|
-
const subState = state
|
|
1029
|
+
const subState = state.get(rootClientId);
|
|
944
1030
|
|
|
945
1031
|
if (!subState.length || lastClientId === subState[subState.length - 1]) {
|
|
946
1032
|
return state;
|
|
947
1033
|
}
|
|
948
1034
|
|
|
949
1035
|
const firstIndex = subState.indexOf(firstClientId);
|
|
950
|
-
|
|
951
|
-
|
|
952
|
-
|
|
1036
|
+
const newState = new Map(state);
|
|
1037
|
+
newState.set(rootClientId, (0, _array.moveTo)(subState, firstIndex, firstIndex + 1, clientIds.length));
|
|
1038
|
+
return newState;
|
|
953
1039
|
}
|
|
954
1040
|
|
|
955
1041
|
case 'REPLACE_BLOCKS_AUGMENTED_WITH_CHILDREN':
|
|
@@ -963,29 +1049,50 @@ withBlockReset, withPersistentBlockChange, withIgnoredBlockChange, withResetCont
|
|
|
963
1049
|
}
|
|
964
1050
|
|
|
965
1051
|
const mappedBlocks = mapBlockOrder(action.blocks);
|
|
966
|
-
|
|
967
|
-
|
|
968
|
-
|
|
969
|
-
|
|
970
|
-
|
|
971
|
-
|
|
972
|
-
|
|
973
|
-
if (clientIds.indexOf(clientId) === -1) {
|
|
974
|
-
result.push(clientId);
|
|
1052
|
+
const newState = new Map(state);
|
|
1053
|
+
action.replacedClientIds.forEach(clientId => {
|
|
1054
|
+
newState.delete(clientId);
|
|
1055
|
+
});
|
|
1056
|
+
mappedBlocks.forEach((order, clientId) => {
|
|
1057
|
+
if (clientId !== '') {
|
|
1058
|
+
newState.set(clientId, order);
|
|
975
1059
|
}
|
|
976
|
-
|
|
977
|
-
|
|
978
|
-
|
|
1060
|
+
});
|
|
1061
|
+
newState.forEach((order, clientId) => {
|
|
1062
|
+
const newSubOrder = Object.values(order).reduce((result, subClientId) => {
|
|
1063
|
+
if (subClientId === clientIds[0]) {
|
|
1064
|
+
return [...result, ...mappedBlocks.get('')];
|
|
1065
|
+
}
|
|
1066
|
+
|
|
1067
|
+
if (clientIds.indexOf(subClientId) === -1) {
|
|
1068
|
+
result.push(subClientId);
|
|
1069
|
+
}
|
|
1070
|
+
|
|
1071
|
+
return result;
|
|
1072
|
+
}, []);
|
|
1073
|
+
newState.set(clientId, newSubOrder);
|
|
1074
|
+
});
|
|
1075
|
+
return newState;
|
|
979
1076
|
}
|
|
980
1077
|
|
|
981
1078
|
case 'REMOVE_BLOCKS_AUGMENTED_WITH_CHILDREN':
|
|
982
|
-
|
|
983
|
-
|
|
984
|
-
|
|
985
|
-
|
|
1079
|
+
{
|
|
1080
|
+
const newState = new Map(state); // Remove inner block ordering for removed blocks.
|
|
1081
|
+
|
|
1082
|
+
action.removedClientIds.forEach(clientId => {
|
|
1083
|
+
newState.delete(clientId);
|
|
1084
|
+
});
|
|
1085
|
+
newState.forEach((order, clientId) => {
|
|
1086
|
+
var _order$filter;
|
|
1087
|
+
|
|
1088
|
+
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 : [];
|
|
986
1089
|
|
|
987
|
-
|
|
988
|
-
|
|
1090
|
+
if (newSubOrder.length !== order.length) {
|
|
1091
|
+
newState.set(clientId, newSubOrder);
|
|
1092
|
+
}
|
|
1093
|
+
});
|
|
1094
|
+
return newState;
|
|
1095
|
+
}
|
|
989
1096
|
}
|
|
990
1097
|
|
|
991
1098
|
return state;
|
|
@@ -994,37 +1101,60 @@ withBlockReset, withPersistentBlockChange, withIgnoredBlockChange, withResetCont
|
|
|
994
1101
|
// While technically redundant data as the inverse of `order`, it serves as
|
|
995
1102
|
// an optimization for the selectors which derive the ancestry of a block.
|
|
996
1103
|
parents() {
|
|
997
|
-
let state = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] :
|
|
1104
|
+
let state = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : new Map();
|
|
998
1105
|
let action = arguments.length > 1 ? arguments[1] : undefined;
|
|
999
1106
|
|
|
1000
1107
|
switch (action.type) {
|
|
1001
1108
|
case 'RECEIVE_BLOCKS':
|
|
1002
|
-
|
|
1003
|
-
|
|
1004
|
-
|
|
1109
|
+
{
|
|
1110
|
+
const newState = new Map(state);
|
|
1111
|
+
mapBlockParents(action.blocks).forEach(_ref7 => {
|
|
1112
|
+
let [key, value] = _ref7;
|
|
1113
|
+
newState.set(key, value);
|
|
1114
|
+
});
|
|
1115
|
+
return newState;
|
|
1116
|
+
}
|
|
1005
1117
|
|
|
1006
1118
|
case 'INSERT_BLOCKS':
|
|
1007
|
-
|
|
1008
|
-
|
|
1009
|
-
|
|
1119
|
+
{
|
|
1120
|
+
const newState = new Map(state);
|
|
1121
|
+
mapBlockParents(action.blocks, action.rootClientId || '').forEach(_ref8 => {
|
|
1122
|
+
let [key, value] = _ref8;
|
|
1123
|
+
newState.set(key, value);
|
|
1124
|
+
});
|
|
1125
|
+
return newState;
|
|
1126
|
+
}
|
|
1010
1127
|
|
|
1011
1128
|
case 'MOVE_BLOCKS_TO_POSITION':
|
|
1012
1129
|
{
|
|
1013
|
-
|
|
1014
|
-
|
|
1015
|
-
|
|
1016
|
-
|
|
1017
|
-
|
|
1018
|
-
};
|
|
1130
|
+
const newState = new Map(state);
|
|
1131
|
+
action.clientIds.forEach(id => {
|
|
1132
|
+
newState.set(id, action.toRootClientId || '');
|
|
1133
|
+
});
|
|
1134
|
+
return newState;
|
|
1019
1135
|
}
|
|
1020
1136
|
|
|
1021
1137
|
case 'REPLACE_BLOCKS_AUGMENTED_WITH_CHILDREN':
|
|
1022
|
-
|
|
1023
|
-
|
|
1024
|
-
|
|
1138
|
+
{
|
|
1139
|
+
const newState = new Map(state);
|
|
1140
|
+
action.replacedClientIds.forEach(clientId => {
|
|
1141
|
+
newState.delete(clientId);
|
|
1142
|
+
});
|
|
1143
|
+
mapBlockParents(action.blocks, state.get(action.clientIds[0])).forEach(_ref9 => {
|
|
1144
|
+
let [key, value] = _ref9;
|
|
1145
|
+
newState.set(key, value);
|
|
1146
|
+
});
|
|
1147
|
+
return newState;
|
|
1148
|
+
}
|
|
1025
1149
|
|
|
1026
1150
|
case 'REMOVE_BLOCKS_AUGMENTED_WITH_CHILDREN':
|
|
1027
|
-
|
|
1151
|
+
{
|
|
1152
|
+
const newState = new Map(state);
|
|
1153
|
+
action.removedClientIds.forEach(clientId => {
|
|
1154
|
+
newState.delete(clientId);
|
|
1155
|
+
});
|
|
1156
|
+
return newState;
|
|
1157
|
+
}
|
|
1028
1158
|
}
|
|
1029
1159
|
|
|
1030
1160
|
return state;
|
|
@@ -1436,7 +1566,7 @@ function insertionPoint() {
|
|
|
1436
1566
|
operation
|
|
1437
1567
|
}; // Bail out updates if the states are the same.
|
|
1438
1568
|
|
|
1439
|
-
return (0,
|
|
1569
|
+
return (0, _es.default)(state, nextState) ? state : nextState;
|
|
1440
1570
|
}
|
|
1441
1571
|
|
|
1442
1572
|
case 'HIDE_INSERTION_POINT':
|
|
@@ -1563,7 +1693,10 @@ const blockListSettings = function () {
|
|
|
1563
1693
|
case 'REPLACE_BLOCKS':
|
|
1564
1694
|
case 'REMOVE_BLOCKS':
|
|
1565
1695
|
{
|
|
1566
|
-
return (
|
|
1696
|
+
return Object.fromEntries(Object.entries(state).filter(_ref10 => {
|
|
1697
|
+
let [id] = _ref10;
|
|
1698
|
+
return !action.clientIds.includes(id);
|
|
1699
|
+
}));
|
|
1567
1700
|
}
|
|
1568
1701
|
|
|
1569
1702
|
case 'UPDATE_BLOCK_LIST_SETTINGS':
|
|
@@ -1574,13 +1707,17 @@ const blockListSettings = function () {
|
|
|
1574
1707
|
|
|
1575
1708
|
if (!action.settings) {
|
|
1576
1709
|
if (state.hasOwnProperty(clientId)) {
|
|
1577
|
-
|
|
1710
|
+
const {
|
|
1711
|
+
[clientId]: removedBlock,
|
|
1712
|
+
...restBlocks
|
|
1713
|
+
} = state;
|
|
1714
|
+
return restBlocks;
|
|
1578
1715
|
}
|
|
1579
1716
|
|
|
1580
1717
|
return state;
|
|
1581
1718
|
}
|
|
1582
1719
|
|
|
1583
|
-
if ((0,
|
|
1720
|
+
if ((0, _es.default)(state[clientId], action.settings)) {
|
|
1584
1721
|
return state;
|
|
1585
1722
|
}
|
|
1586
1723
|
|