@wordpress/block-editor 10.4.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 +17 -0
- package/README.md +0 -1
- package/build/autocompleters/block.js +2 -6
- package/build/autocompleters/block.js.map +1 -1
- package/build/autocompleters/link.js +2 -0
- package/build/autocompleters/link.js.map +1 -1
- package/build/components/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-lock/menu-item.js +1 -1
- package/build/components/block-lock/menu-item.js.map +1 -1
- package/build/components/block-lock/modal.js +16 -9
- package/build/components/block-lock/modal.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-styles/utils.js +3 -3
- package/build/components/block-styles/utils.js.map +1 -1
- package/build/components/block-switcher/index.js +19 -4
- package/build/components/block-switcher/index.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-tools/selected-block-popover.js +27 -4
- package/build/components/block-tools/selected-block-popover.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/colors/with-colors.js +4 -3
- package/build/components/colors/with-colors.js.map +1 -1
- package/build/components/font-sizes/fluid-utils.js +24 -40
- package/build/components/font-sizes/fluid-utils.js.map +1 -1
- package/build/components/font-sizes/with-font-sizes.js +7 -5
- package/build/components/font-sizes/with-font-sizes.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 +18 -0
- package/build/components/index.js.map +1 -1
- package/build/components/inner-blocks/index.js +25 -9
- 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/reusable-blocks-tab.js +4 -1
- package/build/components/inserter/reusable-blocks-tab.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 +19 -34
- package/build/components/link-control/index.js.map +1 -1
- package/build/components/link-control/search-input.js +1 -2
- package/build/components/link-control/search-input.js.map +1 -1
- package/build/components/link-control/use-internal-input-value.js +26 -0
- package/build/components/link-control/use-internal-input-value.js.map +1 -0
- package/build/components/list-view/block.js +10 -5
- package/build/components/list-view/block.js.map +1 -1
- package/build/components/list-view/branch.js +22 -15
- 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-contents.js +100 -0
- package/build/components/off-canvas-editor/block-contents.js.map +1 -0
- package/build/components/off-canvas-editor/block-edit-button.js +50 -0
- package/build/components/off-canvas-editor/block-edit-button.js.map +1 -0
- package/build/components/off-canvas-editor/block-select-button.js +119 -0
- package/build/components/off-canvas-editor/block-select-button.js.map +1 -0
- package/build/components/off-canvas-editor/block.js +324 -0
- package/build/components/off-canvas-editor/block.js.map +1 -0
- package/build/components/off-canvas-editor/branch.js +179 -0
- package/build/components/off-canvas-editor/branch.js.map +1 -0
- package/build/components/off-canvas-editor/context.js +19 -0
- package/build/components/off-canvas-editor/context.js.map +1 -0
- package/build/components/off-canvas-editor/drop-indicator.js +118 -0
- package/build/components/off-canvas-editor/drop-indicator.js.map +1 -0
- package/build/components/off-canvas-editor/expander.js +41 -0
- package/build/components/off-canvas-editor/expander.js.map +1 -0
- package/build/components/off-canvas-editor/index.js +213 -0
- package/build/components/off-canvas-editor/index.js.map +1 -0
- package/build/components/off-canvas-editor/leaf.js +60 -0
- package/build/components/off-canvas-editor/leaf.js.map +1 -0
- package/build/components/off-canvas-editor/link-ui.js +185 -0
- package/build/components/off-canvas-editor/link-ui.js.map +1 -0
- package/build/components/off-canvas-editor/update-attributes.js +108 -0
- package/build/components/off-canvas-editor/update-attributes.js.map +1 -0
- package/build/components/off-canvas-editor/use-block-selection.js +139 -0
- package/build/components/off-canvas-editor/use-block-selection.js.map +1 -0
- package/build/components/off-canvas-editor/use-list-view-client-ids.js +33 -0
- package/build/components/off-canvas-editor/use-list-view-client-ids.js.map +1 -0
- package/build/components/off-canvas-editor/use-list-view-drop-zone.js +235 -0
- package/build/components/off-canvas-editor/use-list-view-drop-zone.js.map +1 -0
- package/build/components/off-canvas-editor/use-list-view-expand-selected-item.js +60 -0
- package/build/components/off-canvas-editor/use-list-view-expand-selected-item.js.map +1 -0
- package/build/components/off-canvas-editor/utils.js +60 -0
- package/build/components/off-canvas-editor/utils.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/url-popover/index.js +31 -2
- package/build/components/url-popover/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 +10 -2
- 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/color-panel.js +17 -1
- package/build/hooks/color-panel.js.map +1 -1
- package/build/hooks/color.js +1 -1
- package/build/hooks/color.js.map +1 -1
- package/build/hooks/content-lock-ui.js +14 -7
- package/build/hooks/content-lock-ui.js.map +1 -1
- package/build/hooks/dimensions.js +65 -16
- package/build/hooks/dimensions.js.map +1 -1
- package/build/hooks/layout.js +59 -3
- package/build/hooks/layout.js.map +1 -1
- package/build/hooks/margin.js +4 -2
- package/build/hooks/margin.js.map +1 -1
- package/build/hooks/min-height.js +139 -0
- package/build/hooks/min-height.js.map +1 -0
- package/build/hooks/padding.js +4 -2
- package/build/hooks/padding.js.map +1 -1
- package/build/hooks/style.js +3 -2
- package/build/hooks/style.js.map +1 -1
- package/build/layouts/flex.js +22 -21
- package/build/layouts/flex.js.map +1 -1
- package/build/store/actions.js +26 -0
- package/build/store/actions.js.map +1 -1
- package/build/store/reducer.js +420 -265
- package/build/store/reducer.js.map +1 -1
- package/build/store/selectors.js +73 -49
- 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-lock/menu-item.js +2 -2
- package/build-module/components/block-lock/menu-item.js.map +1 -1
- package/build-module/components/block-lock/modal.js +17 -10
- package/build-module/components/block-lock/modal.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-styles/utils.js +3 -3
- package/build-module/components/block-styles/utils.js.map +1 -1
- package/build-module/components/block-switcher/index.js +19 -4
- package/build-module/components/block-switcher/index.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-tools/selected-block-popover.js +27 -5
- package/build-module/components/block-tools/selected-block-popover.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/colors/with-colors.js +5 -4
- package/build-module/components/colors/with-colors.js.map +1 -1
- package/build-module/components/font-sizes/fluid-utils.js +24 -40
- package/build-module/components/font-sizes/fluid-utils.js.map +1 -1
- package/build-module/components/font-sizes/with-font-sizes.js +8 -6
- package/build-module/components/font-sizes/with-font-sizes.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 +2 -0
- package/build-module/components/index.js.map +1 -1
- package/build-module/components/inner-blocks/index.js +27 -11
- 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/reusable-blocks-tab.js +3 -1
- package/build-module/components/inserter/reusable-blocks-tab.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 +18 -34
- package/build-module/components/link-control/index.js.map +1 -1
- package/build-module/components/link-control/search-input.js +1 -2
- package/build-module/components/link-control/search-input.js.map +1 -1
- package/build-module/components/link-control/use-internal-input-value.js +18 -0
- package/build-module/components/link-control/use-internal-input-value.js.map +1 -0
- package/build-module/components/list-view/block.js +10 -5
- package/build-module/components/list-view/block.js.map +1 -1
- package/build-module/components/list-view/branch.js +21 -14
- 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-contents.js +85 -0
- package/build-module/components/off-canvas-editor/block-contents.js.map +1 -0
- package/build-module/components/off-canvas-editor/block-edit-button.js +35 -0
- package/build-module/components/off-canvas-editor/block-edit-button.js.map +1 -0
- package/build-module/components/off-canvas-editor/block-select-button.js +101 -0
- package/build-module/components/off-canvas-editor/block-select-button.js.map +1 -0
- package/build-module/components/off-canvas-editor/block.js +298 -0
- package/build-module/components/off-canvas-editor/block.js.map +1 -0
- package/build-module/components/off-canvas-editor/branch.js +164 -0
- package/build-module/components/off-canvas-editor/branch.js.map +1 -0
- package/build-module/components/off-canvas-editor/context.js +7 -0
- package/build-module/components/off-canvas-editor/context.js.map +1 -0
- package/build-module/components/off-canvas-editor/drop-indicator.js +111 -0
- package/build-module/components/off-canvas-editor/drop-indicator.js.map +1 -0
- package/build-module/components/off-canvas-editor/expander.js +32 -0
- package/build-module/components/off-canvas-editor/expander.js.map +1 -0
- package/build-module/components/off-canvas-editor/index.js +189 -0
- package/build-module/components/off-canvas-editor/index.js.map +1 -0
- package/build-module/components/off-canvas-editor/leaf.js +45 -0
- package/build-module/components/off-canvas-editor/leaf.js.map +1 -0
- package/build-module/components/off-canvas-editor/link-ui.js +165 -0
- package/build-module/components/off-canvas-editor/link-ui.js.map +1 -0
- package/build-module/components/off-canvas-editor/update-attributes.js +97 -0
- package/build-module/components/off-canvas-editor/update-attributes.js.map +1 -0
- package/build-module/components/off-canvas-editor/use-block-selection.js +124 -0
- package/build-module/components/off-canvas-editor/use-block-selection.js.map +1 -0
- package/build-module/components/off-canvas-editor/use-list-view-client-ids.js +24 -0
- package/build-module/components/off-canvas-editor/use-list-view-client-ids.js.map +1 -0
- package/build-module/components/off-canvas-editor/use-list-view-drop-zone.js +220 -0
- package/build-module/components/off-canvas-editor/use-list-view-drop-zone.js.map +1 -0
- package/build-module/components/off-canvas-editor/use-list-view-expand-selected-item.js +50 -0
- package/build-module/components/off-canvas-editor/use-list-view-expand-selected-item.js.map +1 -0
- package/build-module/components/off-canvas-editor/utils.js +44 -0
- package/build-module/components/off-canvas-editor/utils.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/url-popover/index.js +30 -3
- package/build-module/components/url-popover/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 +9 -2
- 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/color-panel.js +17 -1
- package/build-module/hooks/color-panel.js.map +1 -1
- package/build-module/hooks/color.js +1 -1
- package/build-module/hooks/color.js.map +1 -1
- package/build-module/hooks/content-lock-ui.js +16 -9
- package/build-module/hooks/content-lock-ui.js.map +1 -1
- package/build-module/hooks/dimensions.js +60 -16
- package/build-module/hooks/dimensions.js.map +1 -1
- package/build-module/hooks/layout.js +57 -2
- package/build-module/hooks/layout.js.map +1 -1
- package/build-module/hooks/margin.js +4 -2
- package/build-module/hooks/margin.js.map +1 -1
- package/build-module/hooks/min-height.js +116 -0
- package/build-module/hooks/min-height.js.map +1 -0
- package/build-module/hooks/padding.js +4 -2
- package/build-module/hooks/padding.js.map +1 -1
- package/build-module/hooks/style.js +4 -3
- package/build-module/hooks/style.js.map +1 -1
- package/build-module/layouts/flex.js +23 -22
- package/build-module/layouts/flex.js.map +1 -1
- package/build-module/store/actions.js +22 -0
- package/build-module/store/actions.js.map +1 -1
- package/build-module/store/reducer.js +415 -265
- package/build-module/store/reducer.js.map +1 -1
- package/build-module/store/selectors.js +66 -48
- 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 +305 -668
- package/build-style/style.css +305 -668
- package/package.json +32 -30
- package/src/autocompleters/block.js +2 -6
- package/src/autocompleters/link.js +2 -0
- package/src/components/alignment-control/README.md +1 -1
- 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-alignment-control/test/index.native.js +4 -4
- 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} +11 -20
- package/src/components/block-list-appender/{style.scss → content.scss} +0 -0
- package/src/components/block-lock/menu-item.js +5 -2
- package/src/components/block-lock/modal.js +19 -36
- package/src/components/block-lock/style.scss +8 -17
- package/src/components/block-mobile-toolbar/block-actions-menu.native.js +24 -6
- package/src/components/block-mover/style.scss +0 -1
- 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-popover/style.scss +1 -1
- package/src/components/block-preview/README.md +15 -10
- package/src/components/block-preview/auto.js +7 -1
- package/src/components/block-preview/content.scss +4 -0
- package/src/components/block-preview/index.js +7 -12
- package/src/components/block-preview/style.scss +0 -7
- package/src/components/block-preview/test/index.js +18 -35
- package/src/components/block-selection-clearer/test/index.js +12 -12
- package/src/components/block-settings-menu/block-settings-dropdown.js +32 -20
- package/src/components/block-styles/utils.js +3 -3
- package/src/components/block-switcher/index.js +19 -4
- 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/selected-block-popover.js +80 -34
- package/src/components/block-tools/style.scss +27 -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/colors/with-colors.js +13 -23
- package/src/components/default-block-appender/{style.scss → content.scss} +1 -0
- package/src/components/font-sizes/fluid-utils.js +37 -64
- package/src/components/font-sizes/test/fluid-utils.js +5 -5
- package/src/components/font-sizes/with-font-sizes.js +14 -11
- 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 +2 -0
- package/src/components/inner-blocks/{style.scss → content.scss} +0 -0
- package/src/components/inner-blocks/index.js +30 -10
- 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/reusable-blocks-tab.js +4 -2
- 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 +184 -18
- package/src/components/inserter/tabs.js +12 -1
- package/src/components/inserter/test/reusable-blocks-tab.js +14 -57
- 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 +24 -39
- package/src/components/link-control/search-input.js +1 -2
- package/src/components/link-control/test/index.js +400 -582
- package/src/components/link-control/use-internal-input-value.js +22 -0
- package/src/components/list-view/block.js +7 -3
- package/src/components/list-view/branch.js +21 -14
- 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/README.md +5 -0
- package/src/components/off-canvas-editor/appender.js +93 -0
- package/src/components/off-canvas-editor/block-contents.js +89 -0
- package/src/components/off-canvas-editor/block-edit-button.js +27 -0
- package/src/components/off-canvas-editor/block-select-button.js +113 -0
- package/src/components/off-canvas-editor/block.js +401 -0
- package/src/components/off-canvas-editor/branch.js +208 -0
- package/src/components/off-canvas-editor/context.js +8 -0
- package/src/components/off-canvas-editor/drop-indicator.js +126 -0
- package/src/components/off-canvas-editor/expander.js +26 -0
- package/src/components/off-canvas-editor/index.js +242 -0
- package/src/components/off-canvas-editor/leaf.js +52 -0
- package/src/components/off-canvas-editor/link-ui.js +166 -0
- package/src/components/off-canvas-editor/style.scss +26 -0
- package/src/components/off-canvas-editor/test/utils.js +50 -0
- package/src/components/off-canvas-editor/update-attributes.js +99 -0
- package/src/components/off-canvas-editor/use-block-selection.js +169 -0
- package/src/components/off-canvas-editor/use-list-view-client-ids.js +29 -0
- package/src/components/off-canvas-editor/use-list-view-drop-zone.js +260 -0
- package/src/components/off-canvas-editor/use-list-view-expand-selected-item.js +58 -0
- package/src/components/off-canvas-editor/utils.js +58 -0
- package/src/components/plain-text/{style.scss → content.scss} +0 -0
- package/src/components/recursion-provider/test/index.js +27 -29
- package/src/components/responsive-block-control/test/index.js +69 -92
- 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/README.md +12 -3
- package/src/components/url-popover/index.js +33 -3
- 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 +20 -2
- 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/color-panel.js +13 -1
- package/src/hooks/color.js +2 -0
- package/src/hooks/content-lock-ui.js +47 -35
- package/src/hooks/dimensions.js +119 -21
- package/src/hooks/layout.js +62 -3
- package/src/hooks/margin.js +4 -3
- package/src/hooks/min-height.js +104 -0
- package/src/hooks/padding.js +4 -3
- package/src/hooks/style.js +10 -2
- package/src/hooks/test/style.js +4 -0
- package/src/hooks/test/use-typography-props.js +1 -1
- package/src/layouts/flex.js +43 -38
- package/src/store/actions.js +22 -0
- package/src/store/reducer.js +480 -434
- package/src/store/selectors.js +70 -64
- package/src/store/test/actions.js +18 -0
- package/src/store/test/performance.js +71 -0
- package/src/store/test/reducer.js +662 -490
- package/src/store/test/selectors.js +1839 -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
|
-
...reduce(nestedControllers, (result, value, _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,131 +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
|
-
|
|
780
|
-
// Consider as updates only changed values.
|
|
781
|
-
if (value !== result[key]) {
|
|
782
|
-
result = getMutateSafeObject(state[id], result);
|
|
783
|
-
result[key] = value;
|
|
784
|
-
}
|
|
821
|
+
let hasChange = false;
|
|
822
|
+
const newState = new Map(state);
|
|
785
823
|
|
|
786
|
-
|
|
787
|
-
|
|
788
|
-
}), {});
|
|
824
|
+
for (const clientId of action.clientIds) {
|
|
825
|
+
var _action$attributes;
|
|
789
826
|
|
|
790
|
-
|
|
791
|
-
|
|
827
|
+
const updatedAttributeEntries = Object.entries(action.uniqueByBlock ? action.attributes[clientId] : (_action$attributes = action.attributes) !== null && _action$attributes !== void 0 ? _action$attributes : {});
|
|
828
|
+
|
|
829
|
+
if (updatedAttributeEntries.length === 0) {
|
|
830
|
+
continue;
|
|
831
|
+
}
|
|
832
|
+
|
|
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
|
+
}
|
|
792
851
|
}
|
|
793
852
|
|
|
794
|
-
return
|
|
795
|
-
...next
|
|
796
|
-
};
|
|
853
|
+
return hasChange ? newState : state;
|
|
797
854
|
}
|
|
798
855
|
|
|
799
856
|
case 'REPLACE_BLOCKS_AUGMENTED_WITH_CHILDREN':
|
|
800
|
-
|
|
801
|
-
|
|
802
|
-
|
|
857
|
+
{
|
|
858
|
+
if (!action.blocks) {
|
|
859
|
+
return state;
|
|
860
|
+
}
|
|
803
861
|
|
|
804
|
-
|
|
805
|
-
|
|
806
|
-
|
|
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
|
+
}
|
|
807
872
|
|
|
808
873
|
case 'REMOVE_BLOCKS_AUGMENTED_WITH_CHILDREN':
|
|
809
|
-
|
|
874
|
+
{
|
|
875
|
+
const newState = new Map(state);
|
|
876
|
+
action.removedClientIds.forEach(clientId => {
|
|
877
|
+
newState.delete(clientId);
|
|
878
|
+
});
|
|
879
|
+
return newState;
|
|
880
|
+
}
|
|
810
881
|
}
|
|
811
882
|
|
|
812
883
|
return state;
|
|
813
884
|
},
|
|
814
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.
|
|
815
889
|
order() {
|
|
816
|
-
let state = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] :
|
|
890
|
+
let state = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : new Map();
|
|
817
891
|
let action = arguments.length > 1 ? arguments[1] : undefined;
|
|
818
892
|
|
|
819
893
|
switch (action.type) {
|
|
820
894
|
case 'RECEIVE_BLOCKS':
|
|
821
895
|
{
|
|
896
|
+
var _state$get;
|
|
897
|
+
|
|
822
898
|
const blockOrder = mapBlockOrder(action.blocks);
|
|
823
|
-
|
|
824
|
-
|
|
825
|
-
|
|
826
|
-
|
|
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;
|
|
827
907
|
}
|
|
828
908
|
|
|
829
909
|
case 'INSERT_BLOCKS':
|
|
@@ -831,20 +911,22 @@ withBlockReset, withPersistentBlockChange, withIgnoredBlockChange, withResetCont
|
|
|
831
911
|
const {
|
|
832
912
|
rootClientId = ''
|
|
833
913
|
} = action;
|
|
834
|
-
const subState = state
|
|
914
|
+
const subState = state.get(rootClientId) || [];
|
|
835
915
|
const mappedBlocks = mapBlockOrder(action.blocks, rootClientId);
|
|
836
916
|
const {
|
|
837
917
|
index = subState.length
|
|
838
918
|
} = action;
|
|
839
|
-
|
|
840
|
-
|
|
841
|
-
|
|
842
|
-
};
|
|
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;
|
|
843
925
|
}
|
|
844
926
|
|
|
845
927
|
case 'MOVE_BLOCKS_TO_POSITION':
|
|
846
928
|
{
|
|
847
|
-
var _state$
|
|
929
|
+
var _state$get$filter, _state$get2;
|
|
848
930
|
|
|
849
931
|
const {
|
|
850
932
|
fromRootClientId = '',
|
|
@@ -852,22 +934,22 @@ withBlockReset, withPersistentBlockChange, withIgnoredBlockChange, withResetCont
|
|
|
852
934
|
clientIds
|
|
853
935
|
} = action;
|
|
854
936
|
const {
|
|
855
|
-
index = state
|
|
937
|
+
index = state.get(toRootClientId).length
|
|
856
938
|
} = action; // Moving inside the same parent block.
|
|
857
939
|
|
|
858
940
|
if (fromRootClientId === toRootClientId) {
|
|
859
|
-
const subState = state
|
|
941
|
+
const subState = state.get(toRootClientId);
|
|
860
942
|
const fromIndex = subState.indexOf(clientIds[0]);
|
|
861
|
-
|
|
862
|
-
|
|
863
|
-
|
|
943
|
+
const newState = new Map(state);
|
|
944
|
+
newState.set(toRootClientId, moveTo(state.get(toRootClientId), fromIndex, index, clientIds.length));
|
|
945
|
+
return newState;
|
|
864
946
|
} // Moving from a parent block to another.
|
|
865
947
|
|
|
866
948
|
|
|
867
|
-
|
|
868
|
-
|
|
869
|
-
|
|
870
|
-
|
|
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;
|
|
871
953
|
}
|
|
872
954
|
|
|
873
955
|
case 'MOVE_BLOCKS_UP':
|
|
@@ -877,16 +959,16 @@ withBlockReset, withPersistentBlockChange, withIgnoredBlockChange, withResetCont
|
|
|
877
959
|
rootClientId = ''
|
|
878
960
|
} = action;
|
|
879
961
|
const firstClientId = clientIds[0];
|
|
880
|
-
const subState = state
|
|
962
|
+
const subState = state.get(rootClientId);
|
|
881
963
|
|
|
882
964
|
if (!subState.length || firstClientId === subState[0]) {
|
|
883
965
|
return state;
|
|
884
966
|
}
|
|
885
967
|
|
|
886
968
|
const firstIndex = subState.indexOf(firstClientId);
|
|
887
|
-
|
|
888
|
-
|
|
889
|
-
|
|
969
|
+
const newState = new Map(state);
|
|
970
|
+
newState.set(rootClientId, moveTo(subState, firstIndex, firstIndex - 1, clientIds.length));
|
|
971
|
+
return newState;
|
|
890
972
|
}
|
|
891
973
|
|
|
892
974
|
case 'MOVE_BLOCKS_DOWN':
|
|
@@ -897,16 +979,16 @@ withBlockReset, withPersistentBlockChange, withIgnoredBlockChange, withResetCont
|
|
|
897
979
|
} = action;
|
|
898
980
|
const firstClientId = clientIds[0];
|
|
899
981
|
const lastClientId = clientIds[clientIds.length - 1];
|
|
900
|
-
const subState = state
|
|
982
|
+
const subState = state.get(rootClientId);
|
|
901
983
|
|
|
902
984
|
if (!subState.length || lastClientId === subState[subState.length - 1]) {
|
|
903
985
|
return state;
|
|
904
986
|
}
|
|
905
987
|
|
|
906
988
|
const firstIndex = subState.indexOf(firstClientId);
|
|
907
|
-
|
|
908
|
-
|
|
909
|
-
|
|
989
|
+
const newState = new Map(state);
|
|
990
|
+
newState.set(rootClientId, moveTo(subState, firstIndex, firstIndex + 1, clientIds.length));
|
|
991
|
+
return newState;
|
|
910
992
|
}
|
|
911
993
|
|
|
912
994
|
case 'REPLACE_BLOCKS_AUGMENTED_WITH_CHILDREN':
|
|
@@ -920,29 +1002,50 @@ withBlockReset, withPersistentBlockChange, withIgnoredBlockChange, withResetCont
|
|
|
920
1002
|
}
|
|
921
1003
|
|
|
922
1004
|
const mappedBlocks = mapBlockOrder(action.blocks);
|
|
923
|
-
|
|
924
|
-
|
|
925
|
-
|
|
926
|
-
|
|
927
|
-
|
|
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);
|
|
928
1012
|
}
|
|
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
|
+
}
|
|
929
1019
|
|
|
930
|
-
|
|
931
|
-
|
|
932
|
-
|
|
1020
|
+
if (clientIds.indexOf(subClientId) === -1) {
|
|
1021
|
+
result.push(subClientId);
|
|
1022
|
+
}
|
|
933
1023
|
|
|
934
|
-
|
|
935
|
-
|
|
1024
|
+
return result;
|
|
1025
|
+
}, []);
|
|
1026
|
+
newState.set(clientId, newSubOrder);
|
|
1027
|
+
});
|
|
1028
|
+
return newState;
|
|
936
1029
|
}
|
|
937
1030
|
|
|
938
1031
|
case 'REMOVE_BLOCKS_AUGMENTED_WITH_CHILDREN':
|
|
939
|
-
|
|
940
|
-
|
|
941
|
-
|
|
942
|
-
|
|
1032
|
+
{
|
|
1033
|
+
const newState = new Map(state); // Remove inner block ordering for removed blocks.
|
|
1034
|
+
|
|
1035
|
+
action.removedClientIds.forEach(clientId => {
|
|
1036
|
+
newState.delete(clientId);
|
|
1037
|
+
});
|
|
1038
|
+
newState.forEach((order, clientId) => {
|
|
1039
|
+
var _order$filter;
|
|
943
1040
|
|
|
944
|
-
|
|
945
|
-
|
|
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
|
+
}
|
|
946
1049
|
}
|
|
947
1050
|
|
|
948
1051
|
return state;
|
|
@@ -951,37 +1054,60 @@ withBlockReset, withPersistentBlockChange, withIgnoredBlockChange, withResetCont
|
|
|
951
1054
|
// While technically redundant data as the inverse of `order`, it serves as
|
|
952
1055
|
// an optimization for the selectors which derive the ancestry of a block.
|
|
953
1056
|
parents() {
|
|
954
|
-
let state = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] :
|
|
1057
|
+
let state = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : new Map();
|
|
955
1058
|
let action = arguments.length > 1 ? arguments[1] : undefined;
|
|
956
1059
|
|
|
957
1060
|
switch (action.type) {
|
|
958
1061
|
case 'RECEIVE_BLOCKS':
|
|
959
|
-
|
|
960
|
-
|
|
961
|
-
|
|
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
|
+
}
|
|
962
1070
|
|
|
963
1071
|
case 'INSERT_BLOCKS':
|
|
964
|
-
|
|
965
|
-
|
|
966
|
-
|
|
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
|
+
}
|
|
967
1080
|
|
|
968
1081
|
case 'MOVE_BLOCKS_TO_POSITION':
|
|
969
1082
|
{
|
|
970
|
-
|
|
971
|
-
|
|
972
|
-
|
|
973
|
-
|
|
974
|
-
|
|
975
|
-
};
|
|
1083
|
+
const newState = new Map(state);
|
|
1084
|
+
action.clientIds.forEach(id => {
|
|
1085
|
+
newState.set(id, action.toRootClientId || '');
|
|
1086
|
+
});
|
|
1087
|
+
return newState;
|
|
976
1088
|
}
|
|
977
1089
|
|
|
978
1090
|
case 'REPLACE_BLOCKS_AUGMENTED_WITH_CHILDREN':
|
|
979
|
-
|
|
980
|
-
|
|
981
|
-
|
|
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
|
+
}
|
|
982
1102
|
|
|
983
1103
|
case 'REMOVE_BLOCKS_AUGMENTED_WITH_CHILDREN':
|
|
984
|
-
|
|
1104
|
+
{
|
|
1105
|
+
const newState = new Map(state);
|
|
1106
|
+
action.removedClientIds.forEach(clientId => {
|
|
1107
|
+
newState.delete(clientId);
|
|
1108
|
+
});
|
|
1109
|
+
return newState;
|
|
1110
|
+
}
|
|
985
1111
|
}
|
|
986
1112
|
|
|
987
1113
|
return state;
|
|
@@ -1005,6 +1131,29 @@ withBlockReset, withPersistentBlockChange, withIgnoredBlockChange, withResetCont
|
|
|
1005
1131
|
}
|
|
1006
1132
|
|
|
1007
1133
|
});
|
|
1134
|
+
/**
|
|
1135
|
+
* Reducer returning visibility status of block interface.
|
|
1136
|
+
*
|
|
1137
|
+
* @param {boolean} state Current state.
|
|
1138
|
+
* @param {Object} action Dispatched action.
|
|
1139
|
+
*
|
|
1140
|
+
* @return {boolean} Updated state.
|
|
1141
|
+
*/
|
|
1142
|
+
|
|
1143
|
+
export function isBlockInterfaceHidden() {
|
|
1144
|
+
let state = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
|
|
1145
|
+
let action = arguments.length > 1 ? arguments[1] : undefined;
|
|
1146
|
+
|
|
1147
|
+
switch (action.type) {
|
|
1148
|
+
case 'HIDE_BLOCK_INTERFACE':
|
|
1149
|
+
return true;
|
|
1150
|
+
|
|
1151
|
+
case 'SHOW_BLOCK_INTERFACE':
|
|
1152
|
+
return false;
|
|
1153
|
+
}
|
|
1154
|
+
|
|
1155
|
+
return state;
|
|
1156
|
+
}
|
|
1008
1157
|
/**
|
|
1009
1158
|
* Reducer returning typing state.
|
|
1010
1159
|
*
|
|
@@ -1359,7 +1508,7 @@ export function insertionPoint() {
|
|
|
1359
1508
|
operation
|
|
1360
1509
|
}; // Bail out updates if the states are the same.
|
|
1361
1510
|
|
|
1362
|
-
return
|
|
1511
|
+
return fastDeepEqual(state, nextState) ? state : nextState;
|
|
1363
1512
|
}
|
|
1364
1513
|
|
|
1365
1514
|
case 'HIDE_INSERTION_POINT':
|
|
@@ -1499,7 +1648,7 @@ export const blockListSettings = function () {
|
|
|
1499
1648
|
return state;
|
|
1500
1649
|
}
|
|
1501
1650
|
|
|
1502
|
-
if (
|
|
1651
|
+
if (fastDeepEqual(state[clientId], action.settings)) {
|
|
1503
1652
|
return state;
|
|
1504
1653
|
}
|
|
1505
1654
|
|
|
@@ -1724,6 +1873,7 @@ export function temporarilyEditingAsBlocks() {
|
|
|
1724
1873
|
export default combineReducers({
|
|
1725
1874
|
blocks,
|
|
1726
1875
|
isTyping,
|
|
1876
|
+
isBlockInterfaceHidden,
|
|
1727
1877
|
draggedBlocks,
|
|
1728
1878
|
selection,
|
|
1729
1879
|
isMultiSelecting,
|