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