@wordpress/block-editor 10.5.0 → 11.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +10 -0
- package/build/autocompleters/block.js +2 -6
- package/build/autocompleters/block.js.map +1 -1
- package/build/autocompleters/link.js +2 -0
- package/build/autocompleters/link.js.map +1 -1
- package/build/components/block-card/index.js +51 -3
- package/build/components/block-card/index.js.map +1 -1
- package/build/components/block-draggable/index.native.js +46 -39
- package/build/components/block-draggable/index.native.js.map +1 -1
- package/build/components/block-edit/edit.js +4 -3
- package/build/components/block-edit/edit.js.map +1 -1
- package/build/components/block-edit/edit.native.js +4 -7
- package/build/components/block-edit/edit.native.js.map +1 -1
- package/build/components/block-inspector/index.js +35 -33
- package/build/components/block-inspector/index.js.map +1 -1
- package/build/components/block-list/block-list-context.native.js +5 -8
- package/build/components/block-list/block-list-context.native.js.map +1 -1
- package/build/components/block-list/block.js +55 -24
- package/build/components/block-list/block.js.map +1 -1
- package/build/components/block-list/block.native.js +61 -28
- package/build/components/block-list/block.native.js.map +1 -1
- package/build/components/block-mobile-toolbar/block-actions-menu.native.js +12 -4
- package/build/components/block-mobile-toolbar/block-actions-menu.native.js.map +1 -1
- package/build/components/block-pattern-setup/index.js +3 -2
- package/build/components/block-pattern-setup/index.js.map +1 -1
- package/build/components/block-patterns-list/index.js +33 -11
- package/build/components/block-patterns-list/index.js.map +1 -1
- package/build/components/block-preview/auto.js +9 -3
- package/build/components/block-preview/auto.js.map +1 -1
- package/build/components/block-preview/index.js +5 -9
- package/build/components/block-preview/index.js.map +1 -1
- package/build/components/block-settings-menu/block-settings-dropdown.js +5 -2
- package/build/components/block-settings-menu/block-settings-dropdown.js.map +1 -1
- package/build/components/block-toolbar/index.js +5 -1
- package/build/components/block-toolbar/index.js.map +1 -1
- package/build/components/block-tools/insertion-point.js +8 -49
- package/build/components/block-tools/insertion-point.js.map +1 -1
- package/build/components/block-variation-picker/index.js +1 -2
- package/build/components/block-variation-picker/index.js.map +1 -1
- package/build/components/height-control/index.js +115 -0
- package/build/components/height-control/index.js.map +1 -0
- package/build/components/iframe/index.js +11 -8
- package/build/components/iframe/index.js.map +1 -1
- package/build/components/image-editor/use-save-image.js +2 -0
- package/build/components/image-editor/use-save-image.js.map +1 -1
- package/build/components/image-editor/zoom-dropdown.js +1 -0
- package/build/components/image-editor/zoom-dropdown.js.map +1 -1
- package/build/components/index.js +9 -0
- package/build/components/index.js.map +1 -1
- package/build/components/inner-blocks/index.js +20 -6
- package/build/components/inner-blocks/index.js.map +1 -1
- package/build/components/inner-blocks/use-inner-block-template-sync.js +25 -10
- package/build/components/inner-blocks/use-inner-block-template-sync.js.map +1 -1
- package/build/components/inserter/block-patterns-explorer/sidebar.js +1 -0
- package/build/components/inserter/block-patterns-explorer/sidebar.js.map +1 -1
- package/build/components/inserter/block-patterns-tab.js +25 -46
- package/build/components/inserter/block-patterns-tab.js.map +1 -1
- package/build/components/inserter/block-types-tab.js +3 -1
- package/build/components/inserter/block-types-tab.js.map +1 -1
- package/build/components/inserter/hooks/use-debounced-input.js +27 -0
- package/build/components/inserter/hooks/use-debounced-input.js.map +1 -0
- package/build/components/inserter/index.js +8 -3
- package/build/components/inserter/index.js.map +1 -1
- package/build/components/inserter/index.native.js +3 -4
- package/build/components/inserter/index.native.js.map +1 -1
- package/build/components/inserter/media-tab/hooks.js +103 -0
- package/build/components/inserter/media-tab/hooks.js.map +1 -0
- package/build/components/inserter/media-tab/index.js +32 -0
- package/build/components/inserter/media-tab/index.js.map +1 -0
- package/build/components/inserter/media-tab/media-list.js +100 -0
- package/build/components/inserter/media-tab/media-list.js.map +1 -0
- package/build/components/inserter/media-tab/media-panel.js +96 -0
- package/build/components/inserter/media-tab/media-panel.js.map +1 -0
- package/build/components/inserter/media-tab/media-tab.js +120 -0
- package/build/components/inserter/media-tab/media-tab.js.map +1 -0
- package/build/components/inserter/media-tab/utils.js +54 -0
- package/build/components/inserter/media-tab/utils.js.map +1 -0
- package/build/components/inserter/menu.js +35 -12
- package/build/components/inserter/menu.js.map +1 -1
- package/build/components/inserter/mobile-tab-navigation.js +70 -0
- package/build/components/inserter/mobile-tab-navigation.js.map +1 -0
- package/build/components/inserter/quick-inserter.js +1 -0
- package/build/components/inserter/quick-inserter.js.map +1 -1
- package/build/components/inserter/search-results.js +3 -1
- package/build/components/inserter/search-results.js.map +1 -1
- package/build/components/inserter/tabs.js +16 -2
- package/build/components/inserter/tabs.js.map +1 -1
- package/build/components/inserter-list-item/index.js +4 -1
- package/build/components/inserter-list-item/index.js.map +1 -1
- package/build/components/inspector-controls/groups.js +2 -0
- package/build/components/inspector-controls/groups.js.map +1 -1
- package/build/components/inspector-controls-tabs/advanced-controls-panel.js +46 -0
- package/build/components/inspector-controls-tabs/advanced-controls-panel.js.map +1 -0
- package/build/components/inspector-controls-tabs/index.js +71 -0
- package/build/components/inspector-controls-tabs/index.js.map +1 -0
- package/build/components/inspector-controls-tabs/settings-tab.js +28 -0
- package/build/components/inspector-controls-tabs/settings-tab.js.map +1 -0
- package/build/components/inspector-controls-tabs/styles-tab.js +61 -0
- package/build/components/inspector-controls-tabs/styles-tab.js.map +1 -0
- package/build/components/inspector-controls-tabs/use-inspector-controls-tabs.js +97 -0
- package/build/components/inspector-controls-tabs/use-inspector-controls-tabs.js.map +1 -0
- package/build/components/inspector-controls-tabs/use-is-list-view-tab-disabled.js +18 -0
- package/build/components/inspector-controls-tabs/use-is-list-view-tab-disabled.js.map +1 -0
- package/build/components/inspector-controls-tabs/utils.js +37 -0
- package/build/components/inspector-controls-tabs/utils.js.map +1 -0
- package/build/components/link-control/index.js +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.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 +104 -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.js +36 -4
- 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 +20 -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/rich-text/format-toolbar/index.js +8 -4
- package/build/components/rich-text/format-toolbar/index.js.map +1 -1
- package/build/components/rich-text/index.js +3 -3
- package/build/components/rich-text/index.js.map +1 -1
- package/build/components/rich-text/index.native.js +0 -2
- package/build/components/rich-text/index.native.js.map +1 -1
- package/build/components/rich-text/use-insert-replacement-text.js +43 -0
- package/build/components/rich-text/use-insert-replacement-text.js.map +1 -0
- package/build/components/rich-text/use-undo-automatic-change.js +9 -1
- package/build/components/rich-text/use-undo-automatic-change.js.map +1 -1
- package/build/components/rich-text/utils.js +1 -19
- package/build/components/rich-text/utils.js.map +1 -1
- package/build/components/spacing-sizes-control/spacing-input-control.js +12 -3
- package/build/components/spacing-sizes-control/spacing-input-control.js.map +1 -1
- package/build/components/ungroup-button/index.native.js +4 -2
- package/build/components/ungroup-button/index.native.js.map +1 -1
- package/build/components/url-input/index.js +46 -43
- package/build/components/url-input/index.js.map +1 -1
- package/build/components/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/hooks/child-layout.js +209 -0
- package/build/hooks/child-layout.js.map +1 -0
- 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/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/store/reducer.js +393 -270
- package/build/store/reducer.js.map +1 -1
- package/build/store/selectors.js +57 -47
- package/build/store/selectors.js.map +1 -1
- package/build/utils/sorting.js +63 -0
- package/build/utils/sorting.js.map +1 -0
- package/build-module/autocompleters/block.js +2 -6
- package/build-module/autocompleters/block.js.map +1 -1
- package/build-module/autocompleters/link.js +2 -0
- package/build-module/autocompleters/link.js.map +1 -1
- package/build-module/components/block-card/index.js +45 -3
- package/build-module/components/block-card/index.js.map +1 -1
- package/build-module/components/block-draggable/index.native.js +40 -31
- package/build-module/components/block-draggable/index.native.js.map +1 -1
- package/build-module/components/block-edit/edit.js +4 -2
- package/build-module/components/block-edit/edit.js.map +1 -1
- package/build-module/components/block-edit/edit.native.js +4 -6
- package/build-module/components/block-edit/edit.native.js.map +1 -1
- package/build-module/components/block-inspector/index.js +32 -30
- package/build-module/components/block-inspector/index.js.map +1 -1
- package/build-module/components/block-list/block-list-context.native.js +5 -8
- package/build-module/components/block-list/block-list-context.native.js.map +1 -1
- package/build-module/components/block-list/block.js +55 -25
- package/build-module/components/block-list/block.js.map +1 -1
- package/build-module/components/block-list/block.native.js +61 -28
- package/build-module/components/block-list/block.native.js.map +1 -1
- package/build-module/components/block-mobile-toolbar/block-actions-menu.native.js +13 -6
- package/build-module/components/block-mobile-toolbar/block-actions-menu.native.js.map +1 -1
- package/build-module/components/block-pattern-setup/index.js +3 -2
- package/build-module/components/block-pattern-setup/index.js.map +1 -1
- package/build-module/components/block-patterns-list/index.js +35 -13
- package/build-module/components/block-patterns-list/index.js.map +1 -1
- package/build-module/components/block-preview/auto.js +9 -3
- package/build-module/components/block-preview/auto.js.map +1 -1
- package/build-module/components/block-preview/index.js +5 -8
- package/build-module/components/block-preview/index.js.map +1 -1
- package/build-module/components/block-settings-menu/block-settings-dropdown.js +5 -2
- package/build-module/components/block-settings-menu/block-settings-dropdown.js.map +1 -1
- package/build-module/components/block-toolbar/index.js +6 -2
- package/build-module/components/block-toolbar/index.js.map +1 -1
- package/build-module/components/block-tools/insertion-point.js +8 -49
- package/build-module/components/block-tools/insertion-point.js.map +1 -1
- package/build-module/components/block-variation-picker/index.js +1 -2
- package/build-module/components/block-variation-picker/index.js.map +1 -1
- package/build-module/components/height-control/index.js +103 -0
- package/build-module/components/height-control/index.js.map +1 -0
- package/build-module/components/iframe/index.js +11 -8
- package/build-module/components/iframe/index.js.map +1 -1
- package/build-module/components/image-editor/use-save-image.js +2 -0
- package/build-module/components/image-editor/use-save-image.js.map +1 -1
- package/build-module/components/image-editor/zoom-dropdown.js +1 -0
- package/build-module/components/image-editor/zoom-dropdown.js.map +1 -1
- package/build-module/components/index.js +1 -0
- package/build-module/components/index.js.map +1 -1
- package/build-module/components/inner-blocks/index.js +22 -8
- package/build-module/components/inner-blocks/index.js.map +1 -1
- package/build-module/components/inner-blocks/use-inner-block-template-sync.js +23 -10
- package/build-module/components/inner-blocks/use-inner-block-template-sync.js.map +1 -1
- package/build-module/components/inserter/block-patterns-explorer/sidebar.js +1 -0
- package/build-module/components/inserter/block-patterns-explorer/sidebar.js.map +1 -1
- package/build-module/components/inserter/block-patterns-tab.js +27 -49
- package/build-module/components/inserter/block-patterns-tab.js.map +1 -1
- package/build-module/components/inserter/block-types-tab.js +3 -2
- package/build-module/components/inserter/block-types-tab.js.map +1 -1
- package/build-module/components/inserter/hooks/use-debounced-input.js +18 -0
- package/build-module/components/inserter/hooks/use-debounced-input.js.map +1 -0
- package/build-module/components/inserter/index.js +8 -3
- package/build-module/components/inserter/index.js.map +1 -1
- package/build-module/components/inserter/index.native.js +3 -5
- package/build-module/components/inserter/index.native.js.map +1 -1
- package/build-module/components/inserter/media-tab/hooks.js +89 -0
- package/build-module/components/inserter/media-tab/hooks.js.map +1 -0
- package/build-module/components/inserter/media-tab/index.js +4 -0
- package/build-module/components/inserter/media-tab/index.js.map +1 -0
- package/build-module/components/inserter/media-tab/media-list.js +86 -0
- package/build-module/components/inserter/media-tab/media-list.js.map +1 -0
- package/build-module/components/inserter/media-tab/media-panel.js +77 -0
- package/build-module/components/inserter/media-tab/media-panel.js.map +1 -0
- package/build-module/components/inserter/media-tab/media-tab.js +100 -0
- package/build-module/components/inserter/media-tab/media-tab.js.map +1 -0
- package/build-module/components/inserter/media-tab/utils.js +45 -0
- package/build-module/components/inserter/media-tab/utils.js.map +1 -0
- package/build-module/components/inserter/menu.js +33 -12
- package/build-module/components/inserter/menu.js.map +1 -1
- package/build-module/components/inserter/mobile-tab-navigation.js +61 -0
- package/build-module/components/inserter/mobile-tab-navigation.js.map +1 -0
- package/build-module/components/inserter/quick-inserter.js +1 -0
- package/build-module/components/inserter/quick-inserter.js.map +1 -1
- package/build-module/components/inserter/search-results.js +3 -2
- package/build-module/components/inserter/search-results.js.map +1 -1
- package/build-module/components/inserter/tabs.js +15 -2
- package/build-module/components/inserter/tabs.js.map +1 -1
- package/build-module/components/inserter-list-item/index.js +5 -2
- package/build-module/components/inserter-list-item/index.js.map +1 -1
- package/build-module/components/inspector-controls/groups.js +2 -0
- package/build-module/components/inspector-controls/groups.js.map +1 -1
- package/build-module/components/inspector-controls-tabs/advanced-controls-panel.js +32 -0
- package/build-module/components/inspector-controls-tabs/advanced-controls-panel.js.map +1 -0
- package/build-module/components/inspector-controls-tabs/index.js +56 -0
- package/build-module/components/inspector-controls-tabs/index.js.map +1 -0
- package/build-module/components/inspector-controls-tabs/settings-tab.js +17 -0
- package/build-module/components/inspector-controls-tabs/settings-tab.js.map +1 -0
- package/build-module/components/inspector-controls-tabs/styles-tab.js +46 -0
- package/build-module/components/inspector-controls-tabs/styles-tab.js.map +1 -0
- package/build-module/components/inspector-controls-tabs/use-inspector-controls-tabs.js +81 -0
- package/build-module/components/inspector-controls-tabs/use-inspector-controls-tabs.js.map +1 -0
- package/build-module/components/inspector-controls-tabs/use-is-list-view-tab-disabled.js +8 -0
- package/build-module/components/inspector-controls-tabs/use-is-list-view-tab-disabled.js.map +1 -0
- package/build-module/components/inspector-controls-tabs/utils.js +26 -0
- package/build-module/components/inspector-controls-tabs/utils.js.map +1 -0
- package/build-module/components/link-control/index.js +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.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 +89 -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.js +36 -6
- 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 +20 -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/rich-text/format-toolbar/index.js +6 -2
- package/build-module/components/rich-text/format-toolbar/index.js.map +1 -1
- package/build-module/components/rich-text/index.js +2 -3
- package/build-module/components/rich-text/index.js.map +1 -1
- package/build-module/components/rich-text/index.native.js +0 -2
- package/build-module/components/rich-text/index.native.js.map +1 -1
- package/build-module/components/rich-text/use-insert-replacement-text.js +33 -0
- package/build-module/components/rich-text/use-insert-replacement-text.js.map +1 -0
- package/build-module/components/rich-text/use-undo-automatic-change.js +9 -1
- package/build-module/components/rich-text/use-undo-automatic-change.js.map +1 -1
- package/build-module/components/rich-text/utils.js +1 -16
- package/build-module/components/rich-text/utils.js.map +1 -1
- package/build-module/components/spacing-sizes-control/spacing-input-control.js +12 -3
- package/build-module/components/spacing-sizes-control/spacing-input-control.js.map +1 -1
- package/build-module/components/ungroup-button/index.native.js +3 -2
- package/build-module/components/ungroup-button/index.native.js.map +1 -1
- package/build-module/components/url-input/index.js +46 -43
- package/build-module/components/url-input/index.js.map +1 -1
- package/build-module/components/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/hooks/child-layout.js +189 -0
- package/build-module/hooks/child-layout.js.map +1 -0
- 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/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/store/reducer.js +391 -271
- package/build-module/store/reducer.js.map +1 -1
- package/build-module/store/selectors.js +54 -47
- package/build-module/store/selectors.js.map +1 -1
- package/build-module/utils/sorting.js +56 -0
- package/build-module/utils/sorting.js.map +1 -0
- package/build-style/content-rtl.css +701 -0
- package/build-style/content.css +701 -0
- package/build-style/default-editor-styles-rtl.css +14 -0
- package/build-style/default-editor-styles.css +14 -0
- package/build-style/style-rtl.css +286 -662
- package/build-style/style.css +286 -662
- 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 +4 -1
- package/src/components/block-alignment-control/test/index.js +4 -1
- package/src/components/block-card/index.js +46 -2
- package/src/components/block-card/style.scss +4 -0
- package/src/components/block-content-overlay/{style.scss → content.scss} +7 -1
- package/src/components/block-draggable/content.scss +20 -0
- package/src/components/block-draggable/index.native.js +54 -40
- package/src/components/block-draggable/style.scss +0 -21
- package/src/components/block-draggable/test/helpers.native.js +7 -9
- package/src/components/block-draggable/test/index.native.js +35 -45
- package/src/components/block-edit/edit.js +5 -2
- package/src/components/block-edit/edit.native.js +5 -6
- package/src/components/block-inspector/index.js +96 -81
- package/src/components/block-inspector/style.scss +9 -1
- package/src/components/block-list/block-list-context.native.js +5 -8
- package/src/components/block-list/block.js +74 -23
- package/src/components/block-list/block.native.js +78 -23
- package/src/components/block-list/{style.scss → content.scss} +1 -15
- package/src/components/block-list-appender/{style.scss → content.scss} +0 -0
- package/src/components/block-mobile-toolbar/block-actions-menu.native.js +24 -6
- package/src/components/block-mover/test/__snapshots__/index.native.js.snap +0 -2
- package/src/components/block-pattern-setup/index.js +2 -1
- package/src/components/block-patterns-list/index.js +47 -24
- package/src/components/block-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-switcher/test/index.js +4 -0
- package/src/components/block-toolbar/index.js +12 -5
- package/src/components/block-toolbar/style.scss +10 -0
- package/src/components/block-tools/insertion-point.js +3 -47
- package/src/components/block-tools/style.scss +12 -5
- package/src/components/block-variation-picker/index.js +1 -4
- package/src/components/block-vertical-alignment-control/test/index.js +4 -1
- package/src/components/default-block-appender/{style.scss → content.scss} +0 -0
- package/src/components/height-control/index.js +123 -0
- package/src/components/height-control/stories/index.js +21 -0
- package/src/components/height-control/style.scss +5 -0
- package/src/components/iframe/index.js +25 -18
- package/src/components/image-editor/use-save-image.js +2 -0
- package/src/components/image-editor/zoom-dropdown.js +1 -0
- package/src/components/index.js +1 -0
- package/src/components/inner-blocks/{style.scss → content.scss} +0 -0
- package/src/components/inner-blocks/index.js +23 -6
- package/src/components/inner-blocks/use-inner-block-template-sync.js +28 -10
- package/src/components/inserter/block-patterns-explorer/sidebar.js +1 -0
- package/src/components/inserter/block-patterns-tab.js +28 -71
- package/src/components/inserter/block-types-tab.js +3 -2
- package/src/components/inserter/hooks/use-debounced-input.js +17 -0
- package/src/components/inserter/index.js +10 -2
- package/src/components/inserter/index.native.js +1 -1
- package/src/components/inserter/media-tab/hooks.js +88 -0
- package/src/components/inserter/media-tab/index.js +3 -0
- package/src/components/inserter/media-tab/media-list.js +93 -0
- package/src/components/inserter/media-tab/media-panel.js +83 -0
- package/src/components/inserter/media-tab/media-tab.js +135 -0
- package/src/components/inserter/media-tab/utils.js +37 -0
- package/src/components/inserter/menu.js +55 -13
- package/src/components/inserter/mobile-tab-navigation.js +85 -0
- package/src/components/inserter/quick-inserter.js +1 -0
- package/src/components/inserter/search-results.js +3 -2
- package/src/components/inserter/stories/index.js +1 -1
- package/src/components/inserter/stories/{fixtures.js → utils/fixtures.js} +0 -0
- package/src/components/inserter/style.scss +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 +188 -401
- package/src/components/link-control/use-internal-input-value.js +3 -3
- 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 +20 -9
- package/src/components/media-placeholder/{style.scss → content.scss} +0 -0
- package/src/components/media-replace-flow/test/index.js +37 -9
- package/src/components/media-upload/test/index.native.js +2 -0
- package/src/components/off-canvas-editor/appender.js +93 -0
- package/src/components/off-canvas-editor/block-edit-button.js +27 -0
- package/src/components/off-canvas-editor/block.js +88 -22
- package/src/components/off-canvas-editor/branch.js +3 -5
- package/src/components/off-canvas-editor/index.js +59 -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 +17 -388
- package/src/components/off-canvas-editor/update-attributes.js +99 -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/rich-text/content.scss +42 -0
- package/src/components/rich-text/format-toolbar/index.js +6 -4
- package/src/components/rich-text/index.js +2 -2
- package/src/components/rich-text/index.native.js +0 -2
- package/src/components/rich-text/style.scss +0 -43
- package/src/components/rich-text/use-insert-replacement-text.js +31 -0
- package/src/components/rich-text/use-undo-automatic-change.js +7 -1
- package/src/components/rich-text/utils.js +2 -21
- package/src/components/spacing-sizes-control/spacing-input-control.js +9 -0
- package/src/components/ungroup-button/index.native.js +6 -2
- package/src/components/url-input/index.js +57 -73
- package/src/components/url-popover/test/__snapshots__/index.js.snap +8 -6
- package/src/components/url-popover/test/index.js +21 -9
- package/src/components/use-block-display-information/index.js +14 -5
- package/src/components/use-setting/index.js +13 -1
- package/src/components/use-setting/test/index.js +99 -0
- package/src/content.scss +10 -0
- package/src/hooks/child-layout.js +190 -0
- package/src/hooks/content-lock-ui.js +1 -1
- package/src/hooks/dimensions.js +45 -7
- package/src/hooks/layout.js +60 -0
- package/src/hooks/min-height.js +2 -19
- package/src/store/reducer.js +459 -423
- package/src/store/selectors.js +56 -57
- 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/sorting.js +54 -0
- package/src/utils/test/sorting.js +49 -0
- package/tsconfig.tsbuildinfo +1 -1
- package/build/components/block-preview/live.js +0 -30
- package/build/components/block-preview/live.js.map +0 -1
- package/build-module/components/block-preview/live.js +0 -20
- package/build-module/components/block-preview/live.js.map +0 -1
- package/src/components/block-preview/live.js +0 -19
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* External dependencies
|
|
3
3
|
*/
|
|
4
|
-
import
|
|
4
|
+
import fastDeepEqual from 'fast-deep-equal/es6';
|
|
5
|
+
import { omit, isEmpty } from 'lodash';
|
|
5
6
|
/**
|
|
6
7
|
* WordPress dependencies
|
|
7
8
|
*/
|
|
@@ -31,16 +32,18 @@ const identity = x => x;
|
|
|
31
32
|
|
|
32
33
|
function mapBlockOrder(blocks) {
|
|
33
34
|
let rootClientId = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : '';
|
|
34
|
-
const result =
|
|
35
|
-
|
|
36
|
-
|
|
35
|
+
const result = new Map();
|
|
36
|
+
const current = [];
|
|
37
|
+
result.set(rootClientId, current);
|
|
37
38
|
blocks.forEach(block => {
|
|
38
39
|
const {
|
|
39
40
|
clientId,
|
|
40
41
|
innerBlocks
|
|
41
42
|
} = block;
|
|
42
|
-
|
|
43
|
-
|
|
43
|
+
current.push(clientId);
|
|
44
|
+
mapBlockOrder(innerBlocks, clientId).forEach((order, subClientId) => {
|
|
45
|
+
result.set(subClientId, order);
|
|
46
|
+
});
|
|
44
47
|
});
|
|
45
48
|
return result;
|
|
46
49
|
}
|
|
@@ -57,9 +60,25 @@ function mapBlockOrder(blocks) {
|
|
|
57
60
|
|
|
58
61
|
function mapBlockParents(blocks) {
|
|
59
62
|
let rootClientId = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : '';
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
+
const result = [];
|
|
64
|
+
const stack = [[rootClientId, blocks]];
|
|
65
|
+
|
|
66
|
+
while (stack.length) {
|
|
67
|
+
const [parent, currentBlocks] = stack.shift();
|
|
68
|
+
currentBlocks.forEach(_ref => {
|
|
69
|
+
let {
|
|
70
|
+
innerBlocks,
|
|
71
|
+
...block
|
|
72
|
+
} = _ref;
|
|
73
|
+
result.push([block.clientId, parent]);
|
|
74
|
+
|
|
75
|
+
if (innerBlocks !== null && innerBlocks !== void 0 && innerBlocks.length) {
|
|
76
|
+
stack.push([block.clientId, innerBlocks]);
|
|
77
|
+
}
|
|
78
|
+
});
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
return result;
|
|
63
82
|
}
|
|
64
83
|
/**
|
|
65
84
|
* Helper method to iterate through all blocks, recursing into inner blocks,
|
|
@@ -69,12 +88,28 @@ function mapBlockParents(blocks) {
|
|
|
69
88
|
* @param {Array} blocks Blocks to flatten.
|
|
70
89
|
* @param {Function} transform Transforming function to be applied to each block.
|
|
71
90
|
*
|
|
72
|
-
* @return {
|
|
91
|
+
* @return {Array} Flattened object.
|
|
73
92
|
*/
|
|
74
93
|
|
|
75
94
|
|
|
76
95
|
function flattenBlocks(blocks) {
|
|
77
96
|
let transform = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : identity;
|
|
97
|
+
const result = [];
|
|
98
|
+
const stack = [...blocks];
|
|
99
|
+
|
|
100
|
+
while (stack.length) {
|
|
101
|
+
const {
|
|
102
|
+
innerBlocks,
|
|
103
|
+
...block
|
|
104
|
+
} = stack.shift();
|
|
105
|
+
stack.push(...innerBlocks);
|
|
106
|
+
result.push([block.clientId, transform(block)]);
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
return result;
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
function getFlattenedClientIds(blocks) {
|
|
78
113
|
const result = {};
|
|
79
114
|
const stack = [...blocks];
|
|
80
115
|
|
|
@@ -84,7 +119,7 @@ function flattenBlocks(blocks) {
|
|
|
84
119
|
...block
|
|
85
120
|
} = stack.shift();
|
|
86
121
|
stack.push(...innerBlocks);
|
|
87
|
-
result[block.clientId] =
|
|
122
|
+
result[block.clientId] = true;
|
|
88
123
|
}
|
|
89
124
|
|
|
90
125
|
return result;
|
|
@@ -96,7 +131,7 @@ function flattenBlocks(blocks) {
|
|
|
96
131
|
*
|
|
97
132
|
* @param {Array} blocks Blocks to flatten.
|
|
98
133
|
*
|
|
99
|
-
* @return {
|
|
134
|
+
* @return {Array} Flattened block attributes object.
|
|
100
135
|
*/
|
|
101
136
|
|
|
102
137
|
|
|
@@ -110,32 +145,13 @@ function getFlattenedBlocksWithoutAttributes(blocks) {
|
|
|
110
145
|
*
|
|
111
146
|
* @param {Array} blocks Blocks to flatten.
|
|
112
147
|
*
|
|
113
|
-
* @return {
|
|
148
|
+
* @return {Array} Flattened block attributes object.
|
|
114
149
|
*/
|
|
115
150
|
|
|
116
151
|
|
|
117
152
|
function getFlattenedBlockAttributes(blocks) {
|
|
118
153
|
return flattenBlocks(blocks, block => block.attributes);
|
|
119
154
|
}
|
|
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
155
|
/**
|
|
140
156
|
* Returns true if the two object arguments have the same keys, or false
|
|
141
157
|
* otherwise.
|
|
@@ -148,7 +164,7 @@ function getMutateSafeObject(original, working) {
|
|
|
148
164
|
|
|
149
165
|
|
|
150
166
|
export function hasSameKeys(a, b) {
|
|
151
|
-
return
|
|
167
|
+
return fastDeepEqual(Object.keys(a), Object.keys(b));
|
|
152
168
|
}
|
|
153
169
|
/**
|
|
154
170
|
* Returns true if, given the currently dispatching action and the previously
|
|
@@ -162,11 +178,11 @@ export function hasSameKeys(a, b) {
|
|
|
162
178
|
*/
|
|
163
179
|
|
|
164
180
|
export function isUpdatingSameBlockAttribute(action, lastAction) {
|
|
165
|
-
return action.type === 'UPDATE_BLOCK_ATTRIBUTES' && lastAction !== undefined && lastAction.type === 'UPDATE_BLOCK_ATTRIBUTES' &&
|
|
181
|
+
return action.type === 'UPDATE_BLOCK_ATTRIBUTES' && lastAction !== undefined && lastAction.type === 'UPDATE_BLOCK_ATTRIBUTES' && fastDeepEqual(action.clientIds, lastAction.clientIds) && hasSameKeys(action.attributes, lastAction.attributes);
|
|
166
182
|
}
|
|
167
183
|
|
|
168
|
-
function
|
|
169
|
-
const
|
|
184
|
+
function updateBlockTreeForBlocks(state, blocks) {
|
|
185
|
+
const treeToUpdate = state.tree;
|
|
170
186
|
const stack = [...blocks];
|
|
171
187
|
const flattenedBlocks = [...blocks];
|
|
172
188
|
|
|
@@ -178,26 +194,25 @@ function buildBlockTree(state, blocks) {
|
|
|
178
194
|
|
|
179
195
|
|
|
180
196
|
for (const block of flattenedBlocks) {
|
|
181
|
-
|
|
197
|
+
treeToUpdate.set(block.clientId, {});
|
|
182
198
|
}
|
|
183
199
|
|
|
184
200
|
for (const block of flattenedBlocks) {
|
|
185
|
-
|
|
186
|
-
attributes: state.attributes
|
|
187
|
-
innerBlocks: block.innerBlocks.map(subBlock =>
|
|
188
|
-
});
|
|
201
|
+
treeToUpdate.set(block.clientId, Object.assign(treeToUpdate.get(block.clientId), { ...state.byClientId.get(block.clientId),
|
|
202
|
+
attributes: state.attributes.get(block.clientId),
|
|
203
|
+
innerBlocks: block.innerBlocks.map(subBlock => treeToUpdate.get(subBlock.clientId))
|
|
204
|
+
}));
|
|
189
205
|
}
|
|
190
|
-
|
|
191
|
-
return result;
|
|
192
206
|
}
|
|
193
207
|
|
|
194
|
-
function updateParentInnerBlocksInTree(state,
|
|
195
|
-
let updateChildrenOfUpdatedClientIds = arguments.length >
|
|
208
|
+
function updateParentInnerBlocksInTree(state, updatedClientIds) {
|
|
209
|
+
let updateChildrenOfUpdatedClientIds = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
|
|
210
|
+
const treeToUpdate = state.tree;
|
|
196
211
|
const uncontrolledParents = new Set([]);
|
|
197
212
|
const controlledParents = new Set();
|
|
198
213
|
|
|
199
214
|
for (const clientId of updatedClientIds) {
|
|
200
|
-
let current = updateChildrenOfUpdatedClientIds ? clientId : state.parents
|
|
215
|
+
let current = updateChildrenOfUpdatedClientIds ? clientId : state.parents.get(clientId);
|
|
201
216
|
|
|
202
217
|
do {
|
|
203
218
|
if (state.controlledInnerBlocks[current]) {
|
|
@@ -208,7 +223,7 @@ function updateParentInnerBlocksInTree(state, tree, updatedClientIds) {
|
|
|
208
223
|
} else {
|
|
209
224
|
// Else continue traversing up through parents.
|
|
210
225
|
uncontrolledParents.add(current);
|
|
211
|
-
current = state.parents
|
|
226
|
+
current = state.parents.get(current);
|
|
212
227
|
}
|
|
213
228
|
} while (current !== undefined);
|
|
214
229
|
} // To make sure the order of assignments doesn't matter,
|
|
@@ -216,23 +231,21 @@ function updateParentInnerBlocksInTree(state, tree, updatedClientIds) {
|
|
|
216
231
|
|
|
217
232
|
|
|
218
233
|
for (const clientId of uncontrolledParents) {
|
|
219
|
-
|
|
220
|
-
};
|
|
234
|
+
treeToUpdate.set(clientId, { ...treeToUpdate.get(clientId)
|
|
235
|
+
});
|
|
221
236
|
}
|
|
222
237
|
|
|
223
238
|
for (const clientId of uncontrolledParents) {
|
|
224
|
-
|
|
239
|
+
treeToUpdate.get(clientId).innerBlocks = (state.order.get(clientId) || []).map(subClientId => treeToUpdate.get(subClientId));
|
|
225
240
|
} // Controlled parent blocks, need a dedicated key for their inner blocks
|
|
226
241
|
// to be used when doing getBlocks( controlledBlockClientId ).
|
|
227
242
|
|
|
228
243
|
|
|
229
244
|
for (const clientId of controlledParents) {
|
|
230
|
-
|
|
231
|
-
innerBlocks: (state.order
|
|
232
|
-
};
|
|
245
|
+
treeToUpdate.set('controlled||' + clientId, {
|
|
246
|
+
innerBlocks: (state.order.get(clientId) || []).map(subClientId => treeToUpdate.get(subClientId))
|
|
247
|
+
});
|
|
233
248
|
}
|
|
234
|
-
|
|
235
|
-
return tree;
|
|
236
249
|
}
|
|
237
250
|
/**
|
|
238
251
|
* Higher-order reducer intended to compute full block objects key for each block in the post.
|
|
@@ -254,61 +267,61 @@ const withBlockTree = reducer => function () {
|
|
|
254
267
|
return state;
|
|
255
268
|
}
|
|
256
269
|
|
|
257
|
-
newState.tree = state.tree ? state.tree :
|
|
270
|
+
newState.tree = state.tree ? state.tree : new Map();
|
|
258
271
|
|
|
259
272
|
switch (action.type) {
|
|
260
273
|
case 'RECEIVE_BLOCKS':
|
|
261
274
|
case 'INSERT_BLOCKS':
|
|
262
275
|
{
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
}, action.rootClientId ? [action.rootClientId] : [''], true);
|
|
276
|
+
newState.tree = new Map(newState.tree);
|
|
277
|
+
updateBlockTreeForBlocks(newState, action.blocks);
|
|
278
|
+
updateParentInnerBlocksInTree(newState, action.rootClientId ? [action.rootClientId] : [''], true);
|
|
267
279
|
break;
|
|
268
280
|
}
|
|
269
281
|
|
|
270
282
|
case 'UPDATE_BLOCK':
|
|
271
|
-
newState.tree =
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
283
|
+
newState.tree = new Map(newState.tree);
|
|
284
|
+
newState.tree.set(action.clientId, { ...newState.tree.get(action.clientId),
|
|
285
|
+
...newState.byClientId.get(action.clientId),
|
|
286
|
+
attributes: newState.attributes.get(action.clientId)
|
|
287
|
+
});
|
|
288
|
+
updateParentInnerBlocksInTree(newState, [action.clientId], false);
|
|
277
289
|
break;
|
|
278
290
|
|
|
279
291
|
case 'UPDATE_BLOCK_ATTRIBUTES':
|
|
280
292
|
{
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
}
|
|
287
|
-
|
|
288
|
-
...newSubTree
|
|
289
|
-
}, action.clientIds, false);
|
|
293
|
+
newState.tree = new Map(newState.tree);
|
|
294
|
+
action.clientIds.forEach(clientId => {
|
|
295
|
+
newState.tree.set(clientId, { ...newState.tree.get(clientId),
|
|
296
|
+
attributes: newState.attributes.get(clientId)
|
|
297
|
+
});
|
|
298
|
+
});
|
|
299
|
+
updateParentInnerBlocksInTree(newState, action.clientIds, false);
|
|
290
300
|
break;
|
|
291
301
|
}
|
|
292
302
|
|
|
293
303
|
case 'REPLACE_BLOCKS_AUGMENTED_WITH_CHILDREN':
|
|
294
304
|
{
|
|
295
|
-
const
|
|
296
|
-
newState.tree =
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
305
|
+
const inserterClientIds = getFlattenedClientIds(action.blocks);
|
|
306
|
+
newState.tree = new Map(newState.tree);
|
|
307
|
+
action.replacedClientIds.concat( // Controlled inner blocks are only removed
|
|
308
|
+
// if the block doesn't move to another position
|
|
309
|
+
// otherwise their content will be lost.
|
|
310
|
+
action.replacedClientIds.filter(clientId => !inserterClientIds[clientId]).map(clientId => 'controlled||' + clientId)).forEach(key => {
|
|
311
|
+
newState.tree.delete(key);
|
|
312
|
+
});
|
|
313
|
+
updateBlockTreeForBlocks(newState, action.blocks);
|
|
314
|
+
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
315
|
|
|
303
316
|
const parentsOfRemovedBlocks = [];
|
|
304
317
|
|
|
305
318
|
for (const clientId of action.clientIds) {
|
|
306
|
-
if (state.parents
|
|
307
|
-
parentsOfRemovedBlocks.push(state.parents
|
|
319
|
+
if (state.parents.get(clientId) !== undefined && (state.parents.get(clientId) === '' || newState.byClientId.get(state.parents.get(clientId)))) {
|
|
320
|
+
parentsOfRemovedBlocks.push(state.parents.get(clientId));
|
|
308
321
|
}
|
|
309
322
|
}
|
|
310
323
|
|
|
311
|
-
|
|
324
|
+
updateParentInnerBlocksInTree(newState, parentsOfRemovedBlocks, true);
|
|
312
325
|
break;
|
|
313
326
|
}
|
|
314
327
|
|
|
@@ -316,12 +329,16 @@ const withBlockTree = reducer => function () {
|
|
|
316
329
|
const parentsOfRemovedBlocks = [];
|
|
317
330
|
|
|
318
331
|
for (const clientId of action.clientIds) {
|
|
319
|
-
if (state.parents
|
|
320
|
-
parentsOfRemovedBlocks.push(state.parents
|
|
332
|
+
if (state.parents.get(clientId) !== undefined && (state.parents.get(clientId) === '' || newState.byClientId.get(state.parents.get(clientId)))) {
|
|
333
|
+
parentsOfRemovedBlocks.push(state.parents.get(clientId));
|
|
321
334
|
}
|
|
322
335
|
}
|
|
323
336
|
|
|
324
|
-
newState.tree =
|
|
337
|
+
newState.tree = new Map(newState.tree);
|
|
338
|
+
action.removedClientIds.concat(action.removedClientIds.map(clientId => 'controlled||' + clientId)).forEach(key => {
|
|
339
|
+
newState.tree.delete(key);
|
|
340
|
+
});
|
|
341
|
+
updateParentInnerBlocksInTree(newState, parentsOfRemovedBlocks, true);
|
|
325
342
|
break;
|
|
326
343
|
|
|
327
344
|
case 'MOVE_BLOCKS_TO_POSITION':
|
|
@@ -338,7 +355,8 @@ const withBlockTree = reducer => function () {
|
|
|
338
355
|
updatedBlockUids.push(action.toRootClientId);
|
|
339
356
|
}
|
|
340
357
|
|
|
341
|
-
newState.tree =
|
|
358
|
+
newState.tree = new Map(newState.tree);
|
|
359
|
+
updateParentInnerBlocksInTree(newState, updatedBlockUids, true);
|
|
342
360
|
break;
|
|
343
361
|
}
|
|
344
362
|
|
|
@@ -346,28 +364,27 @@ const withBlockTree = reducer => function () {
|
|
|
346
364
|
case 'MOVE_BLOCKS_DOWN':
|
|
347
365
|
{
|
|
348
366
|
const updatedBlockUids = [action.rootClientId ? action.rootClientId : ''];
|
|
349
|
-
newState.tree =
|
|
367
|
+
newState.tree = new Map(newState.tree);
|
|
368
|
+
updateParentInnerBlocksInTree(newState, updatedBlockUids, true);
|
|
350
369
|
break;
|
|
351
370
|
}
|
|
352
371
|
|
|
353
372
|
case 'SAVE_REUSABLE_BLOCK_SUCCESS':
|
|
354
373
|
{
|
|
355
|
-
const updatedBlockUids =
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
return clientId;
|
|
374
|
+
const updatedBlockUids = [];
|
|
375
|
+
newState.attributes.forEach((attributes, clientId) => {
|
|
376
|
+
if (newState.byClientId.get(clientId).name === 'core/block' && attributes.ref === action.updatedId) {
|
|
377
|
+
updatedBlockUids.push(clientId);
|
|
378
|
+
}
|
|
361
379
|
});
|
|
362
|
-
newState.tree =
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
}, updatedBlockUids, false);
|
|
380
|
+
newState.tree = new Map(newState.tree);
|
|
381
|
+
updatedBlockUids.forEach(clientId => {
|
|
382
|
+
newState.tree.set(clientId, { ...newState.byClientId.get(clientId),
|
|
383
|
+
attributes: newState.attributes.get(clientId),
|
|
384
|
+
innerBlocks: newState.tree.get(clientId).innerBlocks
|
|
385
|
+
});
|
|
386
|
+
});
|
|
387
|
+
updateParentInnerBlocksInTree(newState, updatedBlockUids, false);
|
|
371
388
|
}
|
|
372
389
|
}
|
|
373
390
|
|
|
@@ -464,7 +481,7 @@ const withInnerBlocksRemoveCascade = reducer => (state, action) => {
|
|
|
464
481
|
let result = clientIds;
|
|
465
482
|
|
|
466
483
|
for (let i = 0; i < result.length; i++) {
|
|
467
|
-
if (!state.order
|
|
484
|
+
if (!state.order.get(result[i]) || action.keepControlledInnerBlocks && action.keepControlledInnerBlocks[result[i]]) {
|
|
468
485
|
continue;
|
|
469
486
|
}
|
|
470
487
|
|
|
@@ -472,7 +489,7 @@ const withInnerBlocksRemoveCascade = reducer => (state, action) => {
|
|
|
472
489
|
result = [...result];
|
|
473
490
|
}
|
|
474
491
|
|
|
475
|
-
result.push(...state.order
|
|
492
|
+
result.push(...state.order.get(result[i]));
|
|
476
493
|
}
|
|
477
494
|
|
|
478
495
|
return result;
|
|
@@ -513,19 +530,17 @@ const withInnerBlocksRemoveCascade = reducer => (state, action) => {
|
|
|
513
530
|
const withBlockReset = reducer => (state, action) => {
|
|
514
531
|
if (action.type === 'RESET_BLOCKS') {
|
|
515
532
|
const newState = { ...state,
|
|
516
|
-
byClientId: getFlattenedBlocksWithoutAttributes(action.blocks),
|
|
517
|
-
attributes: getFlattenedBlockAttributes(action.blocks),
|
|
533
|
+
byClientId: new Map(getFlattenedBlocksWithoutAttributes(action.blocks)),
|
|
534
|
+
attributes: new Map(getFlattenedBlockAttributes(action.blocks)),
|
|
518
535
|
order: mapBlockOrder(action.blocks),
|
|
519
|
-
parents: mapBlockParents(action.blocks),
|
|
536
|
+
parents: new Map(mapBlockParents(action.blocks)),
|
|
520
537
|
controlledInnerBlocks: {}
|
|
521
538
|
};
|
|
522
|
-
|
|
523
|
-
newState.
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
}
|
|
528
|
-
};
|
|
539
|
+
newState.tree = new Map(state === null || state === void 0 ? void 0 : state.tree);
|
|
540
|
+
updateBlockTreeForBlocks(newState, action.blocks);
|
|
541
|
+
newState.tree.set('', {
|
|
542
|
+
innerBlocks: action.blocks.map(subBlock => newState.tree.get(subBlock.clientId))
|
|
543
|
+
});
|
|
529
544
|
return newState;
|
|
530
545
|
}
|
|
531
546
|
|
|
@@ -578,11 +593,11 @@ const withReplaceInnerBlocks = reducer => (state, action) => {
|
|
|
578
593
|
|
|
579
594
|
let stateAfterBlocksRemoval = state;
|
|
580
595
|
|
|
581
|
-
if (state.order
|
|
596
|
+
if (state.order.get(action.rootClientId)) {
|
|
582
597
|
stateAfterBlocksRemoval = reducer(stateAfterBlocksRemoval, {
|
|
583
598
|
type: 'REMOVE_BLOCKS',
|
|
584
599
|
keepControlledInnerBlocks: nestedControllers,
|
|
585
|
-
clientIds: state.order
|
|
600
|
+
clientIds: state.order.get(action.rootClientId)
|
|
586
601
|
});
|
|
587
602
|
}
|
|
588
603
|
|
|
@@ -596,26 +611,21 @@ const withReplaceInnerBlocks = reducer => (state, action) => {
|
|
|
596
611
|
// preserve their block order. Otherwise, an inner block controller's blocks
|
|
597
612
|
// will be deleted entirely from its entity.
|
|
598
613
|
|
|
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
|
-
}
|
|
614
|
+
const stateAfterInsertOrder = new Map(stateAfterInsert.order);
|
|
615
|
+
Object.keys(nestedControllers).forEach(key => {
|
|
616
|
+
if (state.order.get(key)) {
|
|
617
|
+
stateAfterInsertOrder.set(key, state.order.get(key));
|
|
618
|
+
}
|
|
619
|
+
});
|
|
620
|
+
stateAfterInsert.order = stateAfterInsertOrder;
|
|
621
|
+
stateAfterInsert.tree = new Map(stateAfterInsert.tree);
|
|
622
|
+
Object.keys(nestedControllers).forEach(_key => {
|
|
623
|
+
const key = `controlled||${_key}`;
|
|
615
624
|
|
|
616
|
-
|
|
617
|
-
|
|
618
|
-
|
|
625
|
+
if (state.tree.has(key)) {
|
|
626
|
+
stateAfterInsert.tree.set(key, state.tree.get(key));
|
|
627
|
+
}
|
|
628
|
+
});
|
|
619
629
|
}
|
|
620
630
|
|
|
621
631
|
return stateAfterInsert;
|
|
@@ -645,18 +655,17 @@ const withSaveReusableBlock = reducer => (state, action) => {
|
|
|
645
655
|
|
|
646
656
|
state = { ...state
|
|
647
657
|
};
|
|
648
|
-
state.attributes =
|
|
658
|
+
state.attributes = new Map(state.attributes);
|
|
659
|
+
state.attributes.forEach((attributes, clientId) => {
|
|
649
660
|
const {
|
|
650
661
|
name
|
|
651
|
-
} = state.byClientId
|
|
662
|
+
} = state.byClientId.get(clientId);
|
|
652
663
|
|
|
653
664
|
if (name === 'core/block' && attributes.ref === id) {
|
|
654
|
-
|
|
665
|
+
state.attributes.set(clientId, { ...attributes,
|
|
655
666
|
ref: updatedId
|
|
656
|
-
};
|
|
667
|
+
});
|
|
657
668
|
}
|
|
658
|
-
|
|
659
|
-
return attributes;
|
|
660
669
|
});
|
|
661
670
|
}
|
|
662
671
|
|
|
@@ -699,137 +708,202 @@ export const blocks = pipe(combineReducers, withSaveReusableBlock, // Needs to b
|
|
|
699
708
|
withBlockTree, // Needs to be before withInnerBlocksRemoveCascade.
|
|
700
709
|
withInnerBlocksRemoveCascade, withReplaceInnerBlocks, // Needs to be after withInnerBlocksRemoveCascade.
|
|
701
710
|
withBlockReset, withPersistentBlockChange, withIgnoredBlockChange, withResetControlledBlocks)({
|
|
711
|
+
// The state is using a Map instead of a plain object for performance reasons.
|
|
712
|
+
// You can run the "./test/performance.js" unit test to check the impact
|
|
713
|
+
// code changes can have on this reducer.
|
|
702
714
|
byClientId() {
|
|
703
|
-
let state = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] :
|
|
715
|
+
let state = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : new Map();
|
|
704
716
|
let action = arguments.length > 1 ? arguments[1] : undefined;
|
|
705
717
|
|
|
706
718
|
switch (action.type) {
|
|
707
719
|
case 'RECEIVE_BLOCKS':
|
|
708
720
|
case 'INSERT_BLOCKS':
|
|
709
|
-
|
|
710
|
-
|
|
711
|
-
|
|
721
|
+
{
|
|
722
|
+
const newState = new Map(state);
|
|
723
|
+
getFlattenedBlocksWithoutAttributes(action.blocks).forEach(_ref2 => {
|
|
724
|
+
let [key, value] = _ref2;
|
|
725
|
+
newState.set(key, value);
|
|
726
|
+
});
|
|
727
|
+
return newState;
|
|
728
|
+
}
|
|
712
729
|
|
|
713
730
|
case 'UPDATE_BLOCK':
|
|
714
|
-
|
|
715
|
-
|
|
716
|
-
|
|
717
|
-
|
|
731
|
+
{
|
|
732
|
+
// Ignore updates if block isn't known.
|
|
733
|
+
if (!state.has(action.clientId)) {
|
|
734
|
+
return state;
|
|
735
|
+
} // Do nothing if only attributes change.
|
|
718
736
|
|
|
719
737
|
|
|
720
|
-
|
|
738
|
+
const changes = omit(action.updates, 'attributes');
|
|
721
739
|
|
|
722
|
-
|
|
723
|
-
|
|
724
|
-
|
|
740
|
+
if (isEmpty(changes)) {
|
|
741
|
+
return state;
|
|
742
|
+
}
|
|
725
743
|
|
|
726
|
-
|
|
727
|
-
|
|
744
|
+
const newState = new Map(state);
|
|
745
|
+
newState.set(action.clientId, { ...state.get(action.clientId),
|
|
728
746
|
...changes
|
|
729
|
-
}
|
|
730
|
-
|
|
747
|
+
});
|
|
748
|
+
return newState;
|
|
749
|
+
}
|
|
731
750
|
|
|
732
751
|
case 'REPLACE_BLOCKS_AUGMENTED_WITH_CHILDREN':
|
|
733
|
-
|
|
734
|
-
|
|
735
|
-
|
|
752
|
+
{
|
|
753
|
+
if (!action.blocks) {
|
|
754
|
+
return state;
|
|
755
|
+
}
|
|
736
756
|
|
|
737
|
-
|
|
738
|
-
|
|
739
|
-
|
|
757
|
+
const newState = new Map(state);
|
|
758
|
+
action.replacedClientIds.forEach(clientId => {
|
|
759
|
+
newState.delete(clientId);
|
|
760
|
+
});
|
|
761
|
+
getFlattenedBlocksWithoutAttributes(action.blocks).forEach(_ref3 => {
|
|
762
|
+
let [key, value] = _ref3;
|
|
763
|
+
newState.set(key, value);
|
|
764
|
+
});
|
|
765
|
+
return newState;
|
|
766
|
+
}
|
|
740
767
|
|
|
741
768
|
case 'REMOVE_BLOCKS_AUGMENTED_WITH_CHILDREN':
|
|
742
|
-
|
|
769
|
+
{
|
|
770
|
+
const newState = new Map(state);
|
|
771
|
+
action.removedClientIds.forEach(clientId => {
|
|
772
|
+
newState.delete(clientId);
|
|
773
|
+
});
|
|
774
|
+
return newState;
|
|
775
|
+
}
|
|
743
776
|
}
|
|
744
777
|
|
|
745
778
|
return state;
|
|
746
779
|
},
|
|
747
780
|
|
|
781
|
+
// The state is using a Map instead of a plain object for performance reasons.
|
|
782
|
+
// You can run the "./test/performance.js" unit test to check the impact
|
|
783
|
+
// code changes can have on this reducer.
|
|
748
784
|
attributes() {
|
|
749
|
-
let state = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] :
|
|
785
|
+
let state = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : new Map();
|
|
750
786
|
let action = arguments.length > 1 ? arguments[1] : undefined;
|
|
751
787
|
|
|
752
788
|
switch (action.type) {
|
|
753
789
|
case 'RECEIVE_BLOCKS':
|
|
754
790
|
case 'INSERT_BLOCKS':
|
|
755
|
-
|
|
756
|
-
|
|
757
|
-
|
|
791
|
+
{
|
|
792
|
+
const newState = new Map(state);
|
|
793
|
+
getFlattenedBlockAttributes(action.blocks).forEach(_ref4 => {
|
|
794
|
+
let [key, value] = _ref4;
|
|
795
|
+
newState.set(key, value);
|
|
796
|
+
});
|
|
797
|
+
return newState;
|
|
798
|
+
}
|
|
758
799
|
|
|
759
800
|
case 'UPDATE_BLOCK':
|
|
760
|
-
|
|
761
|
-
|
|
762
|
-
|
|
763
|
-
|
|
801
|
+
{
|
|
802
|
+
// Ignore updates if block isn't known or there are no attribute changes.
|
|
803
|
+
if (!state.get(action.clientId) || !action.updates.attributes) {
|
|
804
|
+
return state;
|
|
805
|
+
}
|
|
764
806
|
|
|
765
|
-
|
|
766
|
-
|
|
807
|
+
const newState = new Map(state);
|
|
808
|
+
newState.set(action.clientId, { ...state.get(action.clientId),
|
|
767
809
|
...action.updates.attributes
|
|
768
|
-
}
|
|
769
|
-
|
|
810
|
+
});
|
|
811
|
+
return newState;
|
|
812
|
+
}
|
|
770
813
|
|
|
771
814
|
case 'UPDATE_BLOCK_ATTRIBUTES':
|
|
772
815
|
{
|
|
773
816
|
// Avoid a state change if none of the block IDs are known.
|
|
774
|
-
if (action.clientIds.every(id => !state
|
|
817
|
+
if (action.clientIds.every(id => !state.get(id))) {
|
|
775
818
|
return state;
|
|
776
819
|
}
|
|
777
820
|
|
|
778
|
-
|
|
779
|
-
|
|
821
|
+
let hasChange = false;
|
|
822
|
+
const newState = new Map(state);
|
|
780
823
|
|
|
781
|
-
|
|
782
|
-
|
|
783
|
-
let [key, value] = _ref3;
|
|
824
|
+
for (const clientId of action.clientIds) {
|
|
825
|
+
var _action$attributes;
|
|
784
826
|
|
|
785
|
-
|
|
786
|
-
if (value !== result[key]) {
|
|
787
|
-
result = getMutateSafeObject(state[id], result);
|
|
788
|
-
result[key] = value;
|
|
789
|
-
}
|
|
827
|
+
const updatedAttributeEntries = Object.entries(action.uniqueByBlock ? action.attributes[clientId] : (_action$attributes = action.attributes) !== null && _action$attributes !== void 0 ? _action$attributes : {});
|
|
790
828
|
|
|
791
|
-
|
|
792
|
-
|
|
793
|
-
}
|
|
794
|
-
}, {});
|
|
829
|
+
if (updatedAttributeEntries.length === 0) {
|
|
830
|
+
continue;
|
|
831
|
+
}
|
|
795
832
|
|
|
796
|
-
|
|
797
|
-
|
|
833
|
+
let hasUpdatedAttributes = false;
|
|
834
|
+
const existingAttributes = state.get(clientId);
|
|
835
|
+
const newAttributes = {};
|
|
836
|
+
updatedAttributeEntries.forEach(_ref5 => {
|
|
837
|
+
let [key, value] = _ref5;
|
|
838
|
+
|
|
839
|
+
if (existingAttributes[key] !== value) {
|
|
840
|
+
hasUpdatedAttributes = true;
|
|
841
|
+
newAttributes[key] = value;
|
|
842
|
+
}
|
|
843
|
+
});
|
|
844
|
+
hasChange = hasChange || hasUpdatedAttributes;
|
|
845
|
+
|
|
846
|
+
if (hasUpdatedAttributes) {
|
|
847
|
+
newState.set(clientId, { ...existingAttributes,
|
|
848
|
+
...newAttributes
|
|
849
|
+
});
|
|
850
|
+
}
|
|
798
851
|
}
|
|
799
852
|
|
|
800
|
-
return
|
|
801
|
-
...next
|
|
802
|
-
};
|
|
853
|
+
return hasChange ? newState : state;
|
|
803
854
|
}
|
|
804
855
|
|
|
805
856
|
case 'REPLACE_BLOCKS_AUGMENTED_WITH_CHILDREN':
|
|
806
|
-
|
|
807
|
-
|
|
808
|
-
|
|
857
|
+
{
|
|
858
|
+
if (!action.blocks) {
|
|
859
|
+
return state;
|
|
860
|
+
}
|
|
809
861
|
|
|
810
|
-
|
|
811
|
-
|
|
812
|
-
|
|
862
|
+
const newState = new Map(state);
|
|
863
|
+
action.replacedClientIds.forEach(clientId => {
|
|
864
|
+
newState.delete(clientId);
|
|
865
|
+
});
|
|
866
|
+
getFlattenedBlockAttributes(action.blocks).forEach(_ref6 => {
|
|
867
|
+
let [key, value] = _ref6;
|
|
868
|
+
newState.set(key, value);
|
|
869
|
+
});
|
|
870
|
+
return newState;
|
|
871
|
+
}
|
|
813
872
|
|
|
814
873
|
case 'REMOVE_BLOCKS_AUGMENTED_WITH_CHILDREN':
|
|
815
|
-
|
|
874
|
+
{
|
|
875
|
+
const newState = new Map(state);
|
|
876
|
+
action.removedClientIds.forEach(clientId => {
|
|
877
|
+
newState.delete(clientId);
|
|
878
|
+
});
|
|
879
|
+
return newState;
|
|
880
|
+
}
|
|
816
881
|
}
|
|
817
882
|
|
|
818
883
|
return state;
|
|
819
884
|
},
|
|
820
885
|
|
|
886
|
+
// The state is using a Map instead of a plain object for performance reasons.
|
|
887
|
+
// You can run the "./test/performance.js" unit test to check the impact
|
|
888
|
+
// code changes can have on this reducer.
|
|
821
889
|
order() {
|
|
822
|
-
let state = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] :
|
|
890
|
+
let state = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : new Map();
|
|
823
891
|
let action = arguments.length > 1 ? arguments[1] : undefined;
|
|
824
892
|
|
|
825
893
|
switch (action.type) {
|
|
826
894
|
case 'RECEIVE_BLOCKS':
|
|
827
895
|
{
|
|
896
|
+
var _state$get;
|
|
897
|
+
|
|
828
898
|
const blockOrder = mapBlockOrder(action.blocks);
|
|
829
|
-
|
|
830
|
-
|
|
831
|
-
|
|
832
|
-
|
|
899
|
+
const newState = new Map(state);
|
|
900
|
+
blockOrder.forEach((order, clientId) => {
|
|
901
|
+
if (clientId !== '') {
|
|
902
|
+
newState.set(clientId, order);
|
|
903
|
+
}
|
|
904
|
+
});
|
|
905
|
+
newState.set('', ((_state$get = state.get('')) !== null && _state$get !== void 0 ? _state$get : []).concat(blockOrder['']));
|
|
906
|
+
return newState;
|
|
833
907
|
}
|
|
834
908
|
|
|
835
909
|
case 'INSERT_BLOCKS':
|
|
@@ -837,20 +911,22 @@ withBlockReset, withPersistentBlockChange, withIgnoredBlockChange, withResetCont
|
|
|
837
911
|
const {
|
|
838
912
|
rootClientId = ''
|
|
839
913
|
} = action;
|
|
840
|
-
const subState = state
|
|
914
|
+
const subState = state.get(rootClientId) || [];
|
|
841
915
|
const mappedBlocks = mapBlockOrder(action.blocks, rootClientId);
|
|
842
916
|
const {
|
|
843
917
|
index = subState.length
|
|
844
918
|
} = action;
|
|
845
|
-
|
|
846
|
-
|
|
847
|
-
|
|
848
|
-
};
|
|
919
|
+
const newState = new Map(state);
|
|
920
|
+
mappedBlocks.forEach((order, clientId) => {
|
|
921
|
+
newState.set(clientId, order);
|
|
922
|
+
});
|
|
923
|
+
newState.set(rootClientId, insertAt(subState, mappedBlocks.get(rootClientId), index));
|
|
924
|
+
return newState;
|
|
849
925
|
}
|
|
850
926
|
|
|
851
927
|
case 'MOVE_BLOCKS_TO_POSITION':
|
|
852
928
|
{
|
|
853
|
-
var _state$
|
|
929
|
+
var _state$get$filter, _state$get2;
|
|
854
930
|
|
|
855
931
|
const {
|
|
856
932
|
fromRootClientId = '',
|
|
@@ -858,22 +934,22 @@ withBlockReset, withPersistentBlockChange, withIgnoredBlockChange, withResetCont
|
|
|
858
934
|
clientIds
|
|
859
935
|
} = action;
|
|
860
936
|
const {
|
|
861
|
-
index = state
|
|
937
|
+
index = state.get(toRootClientId).length
|
|
862
938
|
} = action; // Moving inside the same parent block.
|
|
863
939
|
|
|
864
940
|
if (fromRootClientId === toRootClientId) {
|
|
865
|
-
const subState = state
|
|
941
|
+
const subState = state.get(toRootClientId);
|
|
866
942
|
const fromIndex = subState.indexOf(clientIds[0]);
|
|
867
|
-
|
|
868
|
-
|
|
869
|
-
|
|
943
|
+
const newState = new Map(state);
|
|
944
|
+
newState.set(toRootClientId, moveTo(state.get(toRootClientId), fromIndex, index, clientIds.length));
|
|
945
|
+
return newState;
|
|
870
946
|
} // Moving from a parent block to another.
|
|
871
947
|
|
|
872
948
|
|
|
873
|
-
|
|
874
|
-
|
|
875
|
-
|
|
876
|
-
|
|
949
|
+
const newState = new Map(state);
|
|
950
|
+
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 : []);
|
|
951
|
+
newState.set(toRootClientId, insertAt(state.get(toRootClientId), clientIds, index));
|
|
952
|
+
return newState;
|
|
877
953
|
}
|
|
878
954
|
|
|
879
955
|
case 'MOVE_BLOCKS_UP':
|
|
@@ -883,16 +959,16 @@ withBlockReset, withPersistentBlockChange, withIgnoredBlockChange, withResetCont
|
|
|
883
959
|
rootClientId = ''
|
|
884
960
|
} = action;
|
|
885
961
|
const firstClientId = clientIds[0];
|
|
886
|
-
const subState = state
|
|
962
|
+
const subState = state.get(rootClientId);
|
|
887
963
|
|
|
888
964
|
if (!subState.length || firstClientId === subState[0]) {
|
|
889
965
|
return state;
|
|
890
966
|
}
|
|
891
967
|
|
|
892
968
|
const firstIndex = subState.indexOf(firstClientId);
|
|
893
|
-
|
|
894
|
-
|
|
895
|
-
|
|
969
|
+
const newState = new Map(state);
|
|
970
|
+
newState.set(rootClientId, moveTo(subState, firstIndex, firstIndex - 1, clientIds.length));
|
|
971
|
+
return newState;
|
|
896
972
|
}
|
|
897
973
|
|
|
898
974
|
case 'MOVE_BLOCKS_DOWN':
|
|
@@ -903,16 +979,16 @@ withBlockReset, withPersistentBlockChange, withIgnoredBlockChange, withResetCont
|
|
|
903
979
|
} = action;
|
|
904
980
|
const firstClientId = clientIds[0];
|
|
905
981
|
const lastClientId = clientIds[clientIds.length - 1];
|
|
906
|
-
const subState = state
|
|
982
|
+
const subState = state.get(rootClientId);
|
|
907
983
|
|
|
908
984
|
if (!subState.length || lastClientId === subState[subState.length - 1]) {
|
|
909
985
|
return state;
|
|
910
986
|
}
|
|
911
987
|
|
|
912
988
|
const firstIndex = subState.indexOf(firstClientId);
|
|
913
|
-
|
|
914
|
-
|
|
915
|
-
|
|
989
|
+
const newState = new Map(state);
|
|
990
|
+
newState.set(rootClientId, moveTo(subState, firstIndex, firstIndex + 1, clientIds.length));
|
|
991
|
+
return newState;
|
|
916
992
|
}
|
|
917
993
|
|
|
918
994
|
case 'REPLACE_BLOCKS_AUGMENTED_WITH_CHILDREN':
|
|
@@ -926,29 +1002,50 @@ withBlockReset, withPersistentBlockChange, withIgnoredBlockChange, withResetCont
|
|
|
926
1002
|
}
|
|
927
1003
|
|
|
928
1004
|
const mappedBlocks = mapBlockOrder(action.blocks);
|
|
929
|
-
|
|
930
|
-
|
|
931
|
-
|
|
932
|
-
|
|
933
|
-
|
|
1005
|
+
const newState = new Map(state);
|
|
1006
|
+
action.replacedClientIds.forEach(clientId => {
|
|
1007
|
+
newState.delete(clientId);
|
|
1008
|
+
});
|
|
1009
|
+
mappedBlocks.forEach((order, clientId) => {
|
|
1010
|
+
if (clientId !== '') {
|
|
1011
|
+
newState.set(clientId, order);
|
|
934
1012
|
}
|
|
935
|
-
|
|
936
|
-
|
|
937
|
-
|
|
938
|
-
|
|
939
|
-
|
|
940
|
-
|
|
941
|
-
|
|
1013
|
+
});
|
|
1014
|
+
newState.forEach((order, clientId) => {
|
|
1015
|
+
const newSubOrder = Object.values(order).reduce((result, subClientId) => {
|
|
1016
|
+
if (subClientId === clientIds[0]) {
|
|
1017
|
+
return [...result, ...mappedBlocks.get('')];
|
|
1018
|
+
}
|
|
1019
|
+
|
|
1020
|
+
if (clientIds.indexOf(subClientId) === -1) {
|
|
1021
|
+
result.push(subClientId);
|
|
1022
|
+
}
|
|
1023
|
+
|
|
1024
|
+
return result;
|
|
1025
|
+
}, []);
|
|
1026
|
+
newState.set(clientId, newSubOrder);
|
|
1027
|
+
});
|
|
1028
|
+
return newState;
|
|
942
1029
|
}
|
|
943
1030
|
|
|
944
1031
|
case 'REMOVE_BLOCKS_AUGMENTED_WITH_CHILDREN':
|
|
945
|
-
|
|
946
|
-
|
|
947
|
-
nextState => mapValues(nextState, subState => {
|
|
948
|
-
var _subState$filter;
|
|
1032
|
+
{
|
|
1033
|
+
const newState = new Map(state); // Remove inner block ordering for removed blocks.
|
|
949
1034
|
|
|
950
|
-
|
|
951
|
-
|
|
1035
|
+
action.removedClientIds.forEach(clientId => {
|
|
1036
|
+
newState.delete(clientId);
|
|
1037
|
+
});
|
|
1038
|
+
newState.forEach((order, clientId) => {
|
|
1039
|
+
var _order$filter;
|
|
1040
|
+
|
|
1041
|
+
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 : [];
|
|
1042
|
+
|
|
1043
|
+
if (newSubOrder.length !== order.length) {
|
|
1044
|
+
newState.set(clientId, newSubOrder);
|
|
1045
|
+
}
|
|
1046
|
+
});
|
|
1047
|
+
return newState;
|
|
1048
|
+
}
|
|
952
1049
|
}
|
|
953
1050
|
|
|
954
1051
|
return state;
|
|
@@ -957,37 +1054,60 @@ withBlockReset, withPersistentBlockChange, withIgnoredBlockChange, withResetCont
|
|
|
957
1054
|
// While technically redundant data as the inverse of `order`, it serves as
|
|
958
1055
|
// an optimization for the selectors which derive the ancestry of a block.
|
|
959
1056
|
parents() {
|
|
960
|
-
let state = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] :
|
|
1057
|
+
let state = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : new Map();
|
|
961
1058
|
let action = arguments.length > 1 ? arguments[1] : undefined;
|
|
962
1059
|
|
|
963
1060
|
switch (action.type) {
|
|
964
1061
|
case 'RECEIVE_BLOCKS':
|
|
965
|
-
|
|
966
|
-
|
|
967
|
-
|
|
1062
|
+
{
|
|
1063
|
+
const newState = new Map(state);
|
|
1064
|
+
mapBlockParents(action.blocks).forEach(_ref7 => {
|
|
1065
|
+
let [key, value] = _ref7;
|
|
1066
|
+
newState.set(key, value);
|
|
1067
|
+
});
|
|
1068
|
+
return newState;
|
|
1069
|
+
}
|
|
968
1070
|
|
|
969
1071
|
case 'INSERT_BLOCKS':
|
|
970
|
-
|
|
971
|
-
|
|
972
|
-
|
|
1072
|
+
{
|
|
1073
|
+
const newState = new Map(state);
|
|
1074
|
+
mapBlockParents(action.blocks, action.rootClientId || '').forEach(_ref8 => {
|
|
1075
|
+
let [key, value] = _ref8;
|
|
1076
|
+
newState.set(key, value);
|
|
1077
|
+
});
|
|
1078
|
+
return newState;
|
|
1079
|
+
}
|
|
973
1080
|
|
|
974
1081
|
case 'MOVE_BLOCKS_TO_POSITION':
|
|
975
1082
|
{
|
|
976
|
-
|
|
977
|
-
|
|
978
|
-
|
|
979
|
-
|
|
980
|
-
|
|
981
|
-
};
|
|
1083
|
+
const newState = new Map(state);
|
|
1084
|
+
action.clientIds.forEach(id => {
|
|
1085
|
+
newState.set(id, action.toRootClientId || '');
|
|
1086
|
+
});
|
|
1087
|
+
return newState;
|
|
982
1088
|
}
|
|
983
1089
|
|
|
984
1090
|
case 'REPLACE_BLOCKS_AUGMENTED_WITH_CHILDREN':
|
|
985
|
-
|
|
986
|
-
|
|
987
|
-
|
|
1091
|
+
{
|
|
1092
|
+
const newState = new Map(state);
|
|
1093
|
+
action.replacedClientIds.forEach(clientId => {
|
|
1094
|
+
newState.delete(clientId);
|
|
1095
|
+
});
|
|
1096
|
+
mapBlockParents(action.blocks, state.get(action.clientIds[0])).forEach(_ref9 => {
|
|
1097
|
+
let [key, value] = _ref9;
|
|
1098
|
+
newState.set(key, value);
|
|
1099
|
+
});
|
|
1100
|
+
return newState;
|
|
1101
|
+
}
|
|
988
1102
|
|
|
989
1103
|
case 'REMOVE_BLOCKS_AUGMENTED_WITH_CHILDREN':
|
|
990
|
-
|
|
1104
|
+
{
|
|
1105
|
+
const newState = new Map(state);
|
|
1106
|
+
action.removedClientIds.forEach(clientId => {
|
|
1107
|
+
newState.delete(clientId);
|
|
1108
|
+
});
|
|
1109
|
+
return newState;
|
|
1110
|
+
}
|
|
991
1111
|
}
|
|
992
1112
|
|
|
993
1113
|
return state;
|
|
@@ -1388,7 +1508,7 @@ export function insertionPoint() {
|
|
|
1388
1508
|
operation
|
|
1389
1509
|
}; // Bail out updates if the states are the same.
|
|
1390
1510
|
|
|
1391
|
-
return
|
|
1511
|
+
return fastDeepEqual(state, nextState) ? state : nextState;
|
|
1392
1512
|
}
|
|
1393
1513
|
|
|
1394
1514
|
case 'HIDE_INSERTION_POINT':
|
|
@@ -1528,7 +1648,7 @@ export const blockListSettings = function () {
|
|
|
1528
1648
|
return state;
|
|
1529
1649
|
}
|
|
1530
1650
|
|
|
1531
|
-
if (
|
|
1651
|
+
if (fastDeepEqual(state[clientId], action.settings)) {
|
|
1532
1652
|
return state;
|
|
1533
1653
|
}
|
|
1534
1654
|
|