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