@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
|
@@ -0,0 +1,298 @@
|
|
|
1
|
+
import _extends from "@babel/runtime/helpers/esm/extends";
|
|
2
|
+
import { createElement, Fragment } from "@wordpress/element";
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* External dependencies
|
|
6
|
+
*/
|
|
7
|
+
import classnames from 'classnames';
|
|
8
|
+
/**
|
|
9
|
+
* WordPress dependencies
|
|
10
|
+
*/
|
|
11
|
+
|
|
12
|
+
import { createBlock, hasBlockSupport } from '@wordpress/blocks';
|
|
13
|
+
import { __experimentalTreeGridCell as TreeGridCell, __experimentalTreeGridItem as TreeGridItem, MenuItem } from '@wordpress/components';
|
|
14
|
+
import { useInstanceId } from '@wordpress/compose';
|
|
15
|
+
import { moreVertical } from '@wordpress/icons';
|
|
16
|
+
import { useState, useRef, useEffect, useCallback, memo } from '@wordpress/element';
|
|
17
|
+
import { useDispatch, useSelect } from '@wordpress/data';
|
|
18
|
+
import { sprintf, __ } from '@wordpress/i18n';
|
|
19
|
+
/**
|
|
20
|
+
* Internal dependencies
|
|
21
|
+
*/
|
|
22
|
+
|
|
23
|
+
import ListViewLeaf from './leaf';
|
|
24
|
+
import { BlockMoverUpButton, BlockMoverDownButton } from '../block-mover/button';
|
|
25
|
+
import ListViewBlockContents from './block-contents';
|
|
26
|
+
import BlockSettingsDropdown from '../block-settings-menu/block-settings-dropdown';
|
|
27
|
+
import BlockEditButton from './block-edit-button';
|
|
28
|
+
import { useListViewContext } from './context';
|
|
29
|
+
import { getBlockPositionDescription } from './utils';
|
|
30
|
+
import { store as blockEditorStore } from '../../store';
|
|
31
|
+
import useBlockDisplayInformation from '../use-block-display-information';
|
|
32
|
+
import { useBlockLock } from '../block-lock';
|
|
33
|
+
|
|
34
|
+
function ListViewBlock(_ref) {
|
|
35
|
+
let {
|
|
36
|
+
block,
|
|
37
|
+
isDragged,
|
|
38
|
+
isSelected,
|
|
39
|
+
isBranchSelected,
|
|
40
|
+
selectBlock,
|
|
41
|
+
position,
|
|
42
|
+
level,
|
|
43
|
+
rowCount,
|
|
44
|
+
siblingBlockCount,
|
|
45
|
+
showBlockMovers,
|
|
46
|
+
path,
|
|
47
|
+
isExpanded,
|
|
48
|
+
selectedClientIds,
|
|
49
|
+
preventAnnouncement,
|
|
50
|
+
selectBlockInCanvas
|
|
51
|
+
} = _ref;
|
|
52
|
+
const cellRef = useRef(null);
|
|
53
|
+
const [isHovered, setIsHovered] = useState(false);
|
|
54
|
+
const {
|
|
55
|
+
clientId,
|
|
56
|
+
attributes
|
|
57
|
+
} = block;
|
|
58
|
+
const {
|
|
59
|
+
isLocked,
|
|
60
|
+
isContentLocked
|
|
61
|
+
} = useBlockLock(clientId);
|
|
62
|
+
const forceSelectionContentLock = useSelect(select => {
|
|
63
|
+
if (isSelected) {
|
|
64
|
+
return false;
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
if (!isContentLocked) {
|
|
68
|
+
return false;
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
return select(blockEditorStore).hasSelectedInnerBlock(clientId, true);
|
|
72
|
+
}, [isContentLocked, clientId, isSelected]);
|
|
73
|
+
const isFirstSelectedBlock = forceSelectionContentLock || isSelected && selectedClientIds[0] === clientId;
|
|
74
|
+
const isLastSelectedBlock = forceSelectionContentLock || isSelected && selectedClientIds[selectedClientIds.length - 1] === clientId;
|
|
75
|
+
const {
|
|
76
|
+
replaceBlock,
|
|
77
|
+
toggleBlockHighlight
|
|
78
|
+
} = useDispatch(blockEditorStore);
|
|
79
|
+
const blockInformation = useBlockDisplayInformation(clientId);
|
|
80
|
+
const blockName = useSelect(select => select(blockEditorStore).getBlockName(clientId), [clientId]); // When a block hides its toolbar it also hides the block settings menu,
|
|
81
|
+
// since that menu is part of the toolbar in the editor canvas.
|
|
82
|
+
// List View respects this by also hiding the block settings menu.
|
|
83
|
+
|
|
84
|
+
const showBlockActions = hasBlockSupport(blockName, '__experimentalToolbar', true);
|
|
85
|
+
const instanceId = useInstanceId(ListViewBlock);
|
|
86
|
+
const descriptionId = `list-view-block-select-button__${instanceId}`;
|
|
87
|
+
const blockPositionDescription = getBlockPositionDescription(position, siblingBlockCount, level);
|
|
88
|
+
|
|
89
|
+
let blockAriaLabel = __('Link');
|
|
90
|
+
|
|
91
|
+
if (blockInformation) {
|
|
92
|
+
blockAriaLabel = isLocked ? sprintf( // translators: %s: The title of the block. This string indicates a link to select the locked block.
|
|
93
|
+
__('%s link (locked)'), blockInformation.title) : sprintf( // translators: %s: The title of the block. This string indicates a link to select the block.
|
|
94
|
+
__('%s link'), blockInformation.title);
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
const settingsAriaLabel = blockInformation ? sprintf( // translators: %s: The title of the block.
|
|
98
|
+
__('Options for %s block'), blockInformation.title) : __('Options');
|
|
99
|
+
const editAriaLabel = blockInformation ? sprintf( // translators: %s: The title of the block.
|
|
100
|
+
__('Edit %s block'), blockInformation.title) : __('Edit');
|
|
101
|
+
const {
|
|
102
|
+
isTreeGridMounted,
|
|
103
|
+
expand,
|
|
104
|
+
collapse
|
|
105
|
+
} = useListViewContext();
|
|
106
|
+
const isEditable = block.name !== 'core/page-list-item';
|
|
107
|
+
const hasSiblings = siblingBlockCount > 0;
|
|
108
|
+
const hasRenderedMovers = showBlockMovers && hasSiblings;
|
|
109
|
+
const moverCellClassName = classnames('block-editor-list-view-block__mover-cell', {
|
|
110
|
+
'is-visible': isHovered || isSelected
|
|
111
|
+
});
|
|
112
|
+
const listViewBlockSettingsClassName = classnames('block-editor-list-view-block__menu-cell', {
|
|
113
|
+
'is-visible': isHovered || isFirstSelectedBlock
|
|
114
|
+
});
|
|
115
|
+
const listViewBlockEditClassName = classnames('block-editor-list-view-block__menu-cell', {
|
|
116
|
+
'is-visible': isHovered || isFirstSelectedBlock
|
|
117
|
+
}); // If ListView has experimental features related to the Persistent List View,
|
|
118
|
+
// only focus the selected list item on mount; otherwise the list would always
|
|
119
|
+
// try to steal the focus from the editor canvas.
|
|
120
|
+
|
|
121
|
+
useEffect(() => {
|
|
122
|
+
if (!isTreeGridMounted && isSelected) {
|
|
123
|
+
cellRef.current.focus();
|
|
124
|
+
}
|
|
125
|
+
}, []);
|
|
126
|
+
const onMouseEnter = useCallback(() => {
|
|
127
|
+
setIsHovered(true);
|
|
128
|
+
toggleBlockHighlight(clientId, true);
|
|
129
|
+
}, [clientId, setIsHovered, toggleBlockHighlight]);
|
|
130
|
+
const onMouseLeave = useCallback(() => {
|
|
131
|
+
setIsHovered(false);
|
|
132
|
+
toggleBlockHighlight(clientId, false);
|
|
133
|
+
}, [clientId, setIsHovered, toggleBlockHighlight]);
|
|
134
|
+
const selectEditorBlock = useCallback(event => {
|
|
135
|
+
selectBlock(event, clientId);
|
|
136
|
+
event.preventDefault();
|
|
137
|
+
}, [clientId, selectBlock]);
|
|
138
|
+
const updateSelection = useCallback(newClientId => {
|
|
139
|
+
selectBlock(undefined, newClientId);
|
|
140
|
+
}, [selectBlock]);
|
|
141
|
+
const toggleExpanded = useCallback(event => {
|
|
142
|
+
// Prevent shift+click from opening link in a new window when toggling.
|
|
143
|
+
event.preventDefault();
|
|
144
|
+
event.stopPropagation();
|
|
145
|
+
|
|
146
|
+
if (isExpanded === true) {
|
|
147
|
+
collapse(clientId);
|
|
148
|
+
} else if (isExpanded === false) {
|
|
149
|
+
expand(clientId);
|
|
150
|
+
}
|
|
151
|
+
}, [clientId, expand, collapse, isExpanded]);
|
|
152
|
+
let colSpan;
|
|
153
|
+
|
|
154
|
+
if (hasRenderedMovers) {
|
|
155
|
+
colSpan = 2;
|
|
156
|
+
} else if (!showBlockActions) {
|
|
157
|
+
colSpan = 3;
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
const classes = classnames({
|
|
161
|
+
'is-selected': isSelected || forceSelectionContentLock,
|
|
162
|
+
'is-first-selected': isFirstSelectedBlock,
|
|
163
|
+
'is-last-selected': isLastSelectedBlock,
|
|
164
|
+
'is-branch-selected': isBranchSelected,
|
|
165
|
+
'is-dragging': isDragged,
|
|
166
|
+
'has-single-cell': !showBlockActions
|
|
167
|
+
}); // Only include all selected blocks if the currently clicked on block
|
|
168
|
+
// is one of the selected blocks. This ensures that if a user attempts
|
|
169
|
+
// to alter a block that isn't part of the selection, they're still able
|
|
170
|
+
// to do so.
|
|
171
|
+
|
|
172
|
+
const dropdownClientIds = selectedClientIds.includes(clientId) ? selectedClientIds : [clientId];
|
|
173
|
+
return createElement(ListViewLeaf, {
|
|
174
|
+
className: classes,
|
|
175
|
+
onMouseEnter: onMouseEnter,
|
|
176
|
+
onMouseLeave: onMouseLeave,
|
|
177
|
+
onFocus: onMouseEnter,
|
|
178
|
+
onBlur: onMouseLeave,
|
|
179
|
+
level: level,
|
|
180
|
+
position: position,
|
|
181
|
+
rowCount: rowCount,
|
|
182
|
+
path: path,
|
|
183
|
+
id: `list-view-block-${clientId}`,
|
|
184
|
+
"data-block": clientId,
|
|
185
|
+
isExpanded: isContentLocked ? undefined : isExpanded,
|
|
186
|
+
"aria-selected": !!isSelected || forceSelectionContentLock
|
|
187
|
+
}, createElement(TreeGridCell, {
|
|
188
|
+
className: "block-editor-list-view-block__contents-cell",
|
|
189
|
+
colSpan: colSpan,
|
|
190
|
+
ref: cellRef,
|
|
191
|
+
"aria-label": blockAriaLabel,
|
|
192
|
+
"aria-selected": !!isSelected || forceSelectionContentLock,
|
|
193
|
+
"aria-expanded": isContentLocked ? undefined : isExpanded,
|
|
194
|
+
"aria-describedby": descriptionId
|
|
195
|
+
}, _ref2 => {
|
|
196
|
+
let {
|
|
197
|
+
ref,
|
|
198
|
+
tabIndex,
|
|
199
|
+
onFocus
|
|
200
|
+
} = _ref2;
|
|
201
|
+
return createElement("div", {
|
|
202
|
+
className: "block-editor-list-view-block__contents-container"
|
|
203
|
+
}, createElement(ListViewBlockContents, {
|
|
204
|
+
block: block,
|
|
205
|
+
onClick: selectBlockInCanvas ? selectEditorBlock : event => {
|
|
206
|
+
event.preventDefault();
|
|
207
|
+
},
|
|
208
|
+
onToggleExpanded: toggleExpanded,
|
|
209
|
+
isSelected: isSelected,
|
|
210
|
+
position: position,
|
|
211
|
+
siblingBlockCount: siblingBlockCount,
|
|
212
|
+
level: level,
|
|
213
|
+
ref: ref,
|
|
214
|
+
tabIndex: tabIndex,
|
|
215
|
+
onFocus: onFocus,
|
|
216
|
+
isExpanded: isExpanded,
|
|
217
|
+
selectedClientIds: selectedClientIds,
|
|
218
|
+
preventAnnouncement: preventAnnouncement
|
|
219
|
+
}), createElement("div", {
|
|
220
|
+
className: "block-editor-list-view-block-select-button__description",
|
|
221
|
+
id: descriptionId
|
|
222
|
+
}, blockPositionDescription));
|
|
223
|
+
}), hasRenderedMovers && createElement(Fragment, null, createElement(TreeGridCell, {
|
|
224
|
+
className: moverCellClassName,
|
|
225
|
+
withoutGridItem: true
|
|
226
|
+
}, createElement(TreeGridItem, null, _ref3 => {
|
|
227
|
+
let {
|
|
228
|
+
ref,
|
|
229
|
+
tabIndex,
|
|
230
|
+
onFocus
|
|
231
|
+
} = _ref3;
|
|
232
|
+
return createElement(BlockMoverUpButton, {
|
|
233
|
+
orientation: "vertical",
|
|
234
|
+
clientIds: [clientId],
|
|
235
|
+
ref: ref,
|
|
236
|
+
tabIndex: tabIndex,
|
|
237
|
+
onFocus: onFocus
|
|
238
|
+
});
|
|
239
|
+
}), createElement(TreeGridItem, null, _ref4 => {
|
|
240
|
+
let {
|
|
241
|
+
ref,
|
|
242
|
+
tabIndex,
|
|
243
|
+
onFocus
|
|
244
|
+
} = _ref4;
|
|
245
|
+
return createElement(BlockMoverDownButton, {
|
|
246
|
+
orientation: "vertical",
|
|
247
|
+
clientIds: [clientId],
|
|
248
|
+
ref: ref,
|
|
249
|
+
tabIndex: tabIndex,
|
|
250
|
+
onFocus: onFocus
|
|
251
|
+
});
|
|
252
|
+
}))), showBlockActions && createElement(Fragment, null, isEditable && createElement(TreeGridCell, {
|
|
253
|
+
className: listViewBlockEditClassName,
|
|
254
|
+
"aria-selected": !!isSelected || forceSelectionContentLock
|
|
255
|
+
}, props => createElement(BlockEditButton, _extends({}, props, {
|
|
256
|
+
label: editAriaLabel,
|
|
257
|
+
clientId: clientId
|
|
258
|
+
}))), createElement(TreeGridCell, {
|
|
259
|
+
className: listViewBlockSettingsClassName,
|
|
260
|
+
"aria-selected": !!isSelected || forceSelectionContentLock,
|
|
261
|
+
colSpan: isEditable ? 1 : 2 // When an item is not editable then we don't output the cell for the edit button, so we need to adjust the colspan so that the HTML is valid.
|
|
262
|
+
|
|
263
|
+
}, _ref5 => {
|
|
264
|
+
let {
|
|
265
|
+
ref,
|
|
266
|
+
tabIndex,
|
|
267
|
+
onFocus
|
|
268
|
+
} = _ref5;
|
|
269
|
+
return createElement(BlockSettingsDropdown, {
|
|
270
|
+
clientIds: dropdownClientIds,
|
|
271
|
+
icon: moreVertical,
|
|
272
|
+
label: settingsAriaLabel,
|
|
273
|
+
toggleProps: {
|
|
274
|
+
ref,
|
|
275
|
+
className: 'block-editor-list-view-block__menu',
|
|
276
|
+
tabIndex,
|
|
277
|
+
onFocus
|
|
278
|
+
},
|
|
279
|
+
disableOpenOnArrowDown: true,
|
|
280
|
+
__experimentalSelectBlock: updateSelection
|
|
281
|
+
}, _ref6 => {
|
|
282
|
+
let {
|
|
283
|
+
onClose
|
|
284
|
+
} = _ref6;
|
|
285
|
+
return createElement(MenuItem, {
|
|
286
|
+
onClick: () => {
|
|
287
|
+
const newLink = createBlock('core/navigation-link');
|
|
288
|
+
const newSubmenu = createBlock('core/navigation-submenu', attributes, block.innerBlocks ? [...block.innerBlocks, newLink] : [newLink]);
|
|
289
|
+
replaceBlock(clientId, newSubmenu);
|
|
290
|
+
onClose();
|
|
291
|
+
}
|
|
292
|
+
}, __('Add a submenu item'));
|
|
293
|
+
});
|
|
294
|
+
})));
|
|
295
|
+
}
|
|
296
|
+
|
|
297
|
+
export default memo(ListViewBlock);
|
|
298
|
+
//# sourceMappingURL=block.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["@wordpress/block-editor/src/components/off-canvas-editor/block.js"],"names":["classnames","createBlock","hasBlockSupport","__experimentalTreeGridCell","TreeGridCell","__experimentalTreeGridItem","TreeGridItem","MenuItem","useInstanceId","moreVertical","useState","useRef","useEffect","useCallback","memo","useDispatch","useSelect","sprintf","__","ListViewLeaf","BlockMoverUpButton","BlockMoverDownButton","ListViewBlockContents","BlockSettingsDropdown","BlockEditButton","useListViewContext","getBlockPositionDescription","store","blockEditorStore","useBlockDisplayInformation","useBlockLock","ListViewBlock","block","isDragged","isSelected","isBranchSelected","selectBlock","position","level","rowCount","siblingBlockCount","showBlockMovers","path","isExpanded","selectedClientIds","preventAnnouncement","selectBlockInCanvas","cellRef","isHovered","setIsHovered","clientId","attributes","isLocked","isContentLocked","forceSelectionContentLock","select","hasSelectedInnerBlock","isFirstSelectedBlock","isLastSelectedBlock","length","replaceBlock","toggleBlockHighlight","blockInformation","blockName","getBlockName","showBlockActions","instanceId","descriptionId","blockPositionDescription","blockAriaLabel","title","settingsAriaLabel","editAriaLabel","isTreeGridMounted","expand","collapse","isEditable","name","hasSiblings","hasRenderedMovers","moverCellClassName","listViewBlockSettingsClassName","listViewBlockEditClassName","current","focus","onMouseEnter","onMouseLeave","selectEditorBlock","event","preventDefault","updateSelection","newClientId","undefined","toggleExpanded","stopPropagation","colSpan","classes","dropdownClientIds","includes","ref","tabIndex","onFocus","props","className","onClose","newLink","newSubmenu","innerBlocks"],"mappings":";;;AAAA;AACA;AACA;AACA,OAAOA,UAAP,MAAuB,YAAvB;AAEA;AACA;AACA;;AACA,SAASC,WAAT,EAAsBC,eAAtB,QAA6C,mBAA7C;AACA,SACCC,0BAA0B,IAAIC,YAD/B,EAECC,0BAA0B,IAAIC,YAF/B,EAGCC,QAHD,QAIO,uBAJP;AAKA,SAASC,aAAT,QAA8B,oBAA9B;AACA,SAASC,YAAT,QAA6B,kBAA7B;AACA,SACCC,QADD,EAECC,MAFD,EAGCC,SAHD,EAICC,WAJD,EAKCC,IALD,QAMO,oBANP;AAOA,SAASC,WAAT,EAAsBC,SAAtB,QAAuC,iBAAvC;AACA,SAASC,OAAT,EAAkBC,EAAlB,QAA4B,iBAA5B;AAEA;AACA;AACA;;AACA,OAAOC,YAAP,MAAyB,QAAzB;AACA,SACCC,kBADD,EAECC,oBAFD,QAGO,uBAHP;AAIA,OAAOC,qBAAP,MAAkC,kBAAlC;AACA,OAAOC,qBAAP,MAAkC,gDAAlC;AACA,OAAOC,eAAP,MAA4B,qBAA5B;AACA,SAASC,kBAAT,QAAmC,WAAnC;AACA,SAASC,2BAAT,QAA4C,SAA5C;AACA,SAASC,KAAK,IAAIC,gBAAlB,QAA0C,aAA1C;AACA,OAAOC,0BAAP,MAAuC,kCAAvC;AACA,SAASC,YAAT,QAA6B,eAA7B;;AAEA,SAASC,aAAT,OAgBI;AAAA,MAhBoB;AACvBC,IAAAA,KADuB;AAEvBC,IAAAA,SAFuB;AAGvBC,IAAAA,UAHuB;AAIvBC,IAAAA,gBAJuB;AAKvBC,IAAAA,WALuB;AAMvBC,IAAAA,QANuB;AAOvBC,IAAAA,KAPuB;AAQvBC,IAAAA,QARuB;AASvBC,IAAAA,iBATuB;AAUvBC,IAAAA,eAVuB;AAWvBC,IAAAA,IAX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5B,CAKgC;;AALhC,KAOG;AAAA,QAAE;AAAEuB,MAAAA,GAAF;AAAOC,MAAAA,QAAP;AAAiBC,MAAAA;AAAjB,KAAF;AAAA,WACD,cAAC,qBAAD;AACC,MAAA,SAAS,EAAGJ,iBADb;AAEC,MAAA,IAAI,EAAGxF,YAFR;AAGC,MAAA,KAAK,EAAG8D,iBAHT;AAIC,MAAA,WAAW,EAAG;AACb4B,QAAAA,GADa;AAEbI,QAAAA,SAAS,EACR,oCAHY;AAIbH,QAAAA,QAJa;AAKbC,QAAAA;AALa,OAJf;AAWC,MAAA,sBAAsB,MAXvB;AAYC,MAAA,yBAAyB,EAAGX;AAZ7B,OAcG;AAAA,UAAE;AAAEc,QAAAA;AAAF,OAAF;AAAA,aACD,cAAC,QAAD;AACC,QAAA,OAAO,EAAG,MAAM;AACf,gBAAMC,OAAO,GAAGxG,WAAW,CAC1B,sBAD0B,CAA3B;AAGA,gBAAMyG,UAAU,GAAGzG,WAAW,CAC7B,yBAD6B,EAE7BkD,UAF6B,EAG7BnB,KAAK,CAAC2E,WAAN,GACG,CACA,GAAG3E,KAAK,CAAC2E,WADT,EAEAF,OAFA,CADH,GAKG,CAAEA,OAAF,CAR0B,CAA9B;AAUA7C,UAAAA,YAAY,CACXV,QADW,EAEXwD,UAFW,CAAZ;AAIAF,UAAAA,OAAO;AACP;AApBF,SAsBGtF,EAAE,CAAE,oBAAF,CAtBL,CADC;AAAA,KAdH,CADC;AAAA,GAPH,CAjBD,CAzFF,CADD;AAkKA;;AAED,eAAeJ,IAAI,CAAEiB,aAAF,CAAnB","sourcesContent":["/**\n * External dependencies\n */\nimport classnames from 'classnames';\n\n/**\n * WordPress dependencies\n */\nimport { createBlock, hasBlockSupport } from '@wordpress/blocks';\nimport {\n\t__experimentalTreeGridCell as TreeGridCell,\n\t__experimentalTreeGridItem as TreeGridItem,\n\tMenuItem,\n} from '@wordpress/components';\nimport { useInstanceId } from '@wordpress/compose';\nimport { moreVertical } from '@wordpress/icons';\nimport {\n\tuseState,\n\tuseRef,\n\tuseEffect,\n\tuseCallback,\n\tmemo,\n} from '@wordpress/element';\nimport { useDispatch, useSelect } from '@wordpress/data';\nimport { sprintf, __ } from '@wordpress/i18n';\n\n/**\n * Internal dependencies\n */\nimport ListViewLeaf from './leaf';\nimport {\n\tBlockMoverUpButton,\n\tBlockMoverDownButton,\n} from '../block-mover/button';\nimport ListViewBlockContents from './block-contents';\nimport BlockSettingsDropdown from '../block-settings-menu/block-settings-dropdown';\nimport BlockEditButton from './block-edit-button';\nimport { useListViewContext } from './context';\nimport { getBlockPositionDescription } from './utils';\nimport { store as blockEditorStore } from '../../store';\nimport useBlockDisplayInformation from '../use-block-display-information';\nimport { useBlockLock } from '../block-lock';\n\nfunction ListViewBlock( {\n\tblock,\n\tisDragged,\n\tisSelected,\n\tisBranchSelected,\n\tselectBlock,\n\tposition,\n\tlevel,\n\trowCount,\n\tsiblingBlockCount,\n\tshowBlockMovers,\n\tpath,\n\tisExpanded,\n\tselectedClientIds,\n\tpreventAnnouncement,\n\tselectBlockInCanvas,\n} ) {\n\tconst cellRef = useRef( null );\n\tconst [ isHovered, setIsHovered ] = useState( false );\n\tconst { clientId, attributes } = block;\n\n\tconst { isLocked, isContentLocked } = useBlockLock( clientId );\n\tconst forceSelectionContentLock = useSelect(\n\t\t( select ) => {\n\t\t\tif ( isSelected ) {\n\t\t\t\treturn false;\n\t\t\t}\n\t\t\tif ( ! isContentLocked ) {\n\t\t\t\treturn false;\n\t\t\t}\n\t\t\treturn select( blockEditorStore ).hasSelectedInnerBlock(\n\t\t\t\tclientId,\n\t\t\t\ttrue\n\t\t\t);\n\t\t},\n\t\t[ isContentLocked, clientId, isSelected ]\n\t);\n\n\tconst isFirstSelectedBlock =\n\t\tforceSelectionContentLock ||\n\t\t( isSelected && selectedClientIds[ 0 ] === clientId );\n\tconst isLastSelectedBlock =\n\t\tforceSelectionContentLock ||\n\t\t( isSelected &&\n\t\t\tselectedClientIds[ selectedClientIds.length - 1 ] === clientId );\n\n\tconst { replaceBlock, toggleBlockHighlight } =\n\t\tuseDispatch( blockEditorStore );\n\n\tconst blockInformation = useBlockDisplayInformation( clientId );\n\tconst blockName = useSelect(\n\t\t( select ) => select( blockEditorStore ).getBlockName( clientId ),\n\t\t[ clientId ]\n\t);\n\n\t// When a block hides its toolbar it also hides the block settings menu,\n\t// since that menu is part of the toolbar in the editor canvas.\n\t// List View respects this by also hiding the block settings menu.\n\tconst showBlockActions = hasBlockSupport(\n\t\tblockName,\n\t\t'__experimentalToolbar',\n\t\ttrue\n\t);\n\tconst instanceId = useInstanceId( ListViewBlock );\n\tconst descriptionId = `list-view-block-select-button__${ instanceId }`;\n\tconst blockPositionDescription = getBlockPositionDescription(\n\t\tposition,\n\t\tsiblingBlockCount,\n\t\tlevel\n\t);\n\n\tlet blockAriaLabel = __( 'Link' );\n\tif ( blockInformation ) {\n\t\tblockAriaLabel = isLocked\n\t\t\t? sprintf(\n\t\t\t\t\t// translators: %s: The title of the block. This string indicates a link to select the locked block.\n\t\t\t\t\t__( '%s link (locked)' ),\n\t\t\t\t\tblockInformation.title\n\t\t\t )\n\t\t\t: sprintf(\n\t\t\t\t\t// translators: %s: The title of the block. This string indicates a link to select the block.\n\t\t\t\t\t__( '%s link' ),\n\t\t\t\t\tblockInformation.title\n\t\t\t );\n\t}\n\n\tconst settingsAriaLabel = blockInformation\n\t\t? sprintf(\n\t\t\t\t// translators: %s: The title of the block.\n\t\t\t\t__( 'Options for %s block' ),\n\t\t\t\tblockInformation.title\n\t\t )\n\t\t: __( 'Options' );\n\n\tconst editAriaLabel = blockInformation\n\t\t? sprintf(\n\t\t\t\t// translators: %s: The title of the block.\n\t\t\t\t__( 'Edit %s block' ),\n\t\t\t\tblockInformation.title\n\t\t )\n\t\t: __( 'Edit' );\n\n\tconst { isTreeGridMounted, expand, collapse } = useListViewContext();\n\n\tconst isEditable = block.name !== 'core/page-list-item';\n\tconst hasSiblings = siblingBlockCount > 0;\n\tconst hasRenderedMovers = showBlockMovers && hasSiblings;\n\tconst moverCellClassName = classnames(\n\t\t'block-editor-list-view-block__mover-cell',\n\t\t{ 'is-visible': isHovered || isSelected }\n\t);\n\n\tconst listViewBlockSettingsClassName = classnames(\n\t\t'block-editor-list-view-block__menu-cell',\n\t\t{ 'is-visible': isHovered || isFirstSelectedBlock }\n\t);\n\n\tconst listViewBlockEditClassName = classnames(\n\t\t'block-editor-list-view-block__menu-cell',\n\t\t{ 'is-visible': isHovered || isFirstSelectedBlock }\n\t);\n\n\t// If ListView has experimental features related to the Persistent List View,\n\t// only focus the selected list item on mount; otherwise the list would always\n\t// try to steal the focus from the editor canvas.\n\tuseEffect( () => {\n\t\tif ( ! isTreeGridMounted && isSelected ) {\n\t\t\tcellRef.current.focus();\n\t\t}\n\t}, [] );\n\n\tconst onMouseEnter = useCallback( () => {\n\t\tsetIsHovered( true );\n\t\ttoggleBlockHighlight( clientId, true );\n\t}, [ clientId, setIsHovered, toggleBlockHighlight ] );\n\tconst onMouseLeave = useCallback( () => {\n\t\tsetIsHovered( false );\n\t\ttoggleBlockHighlight( clientId, false );\n\t}, [ clientId, setIsHovered, toggleBlockHighlight ] );\n\n\tconst selectEditorBlock = useCallback(\n\t\t( event ) => {\n\t\t\tselectBlock( event, clientId );\n\t\t\tevent.preventDefault();\n\t\t},\n\t\t[ clientId, selectBlock ]\n\t);\n\n\tconst updateSelection = useCallback(\n\t\t( newClientId ) => {\n\t\t\tselectBlock( undefined, newClientId );\n\t\t},\n\t\t[ selectBlock ]\n\t);\n\n\tconst toggleExpanded = useCallback(\n\t\t( event ) => {\n\t\t\t// Prevent shift+click from opening link in a new window when toggling.\n\t\t\tevent.preventDefault();\n\t\t\tevent.stopPropagation();\n\t\t\tif ( isExpanded === true ) {\n\t\t\t\tcollapse( clientId );\n\t\t\t} else if ( isExpanded === false ) {\n\t\t\t\texpand( clientId );\n\t\t\t}\n\t\t},\n\t\t[ clientId, expand, collapse, isExpanded ]\n\t);\n\n\tlet colSpan;\n\tif ( hasRenderedMovers ) {\n\t\tcolSpan = 2;\n\t} else if ( ! showBlockActions ) {\n\t\tcolSpan = 3;\n\t}\n\n\tconst classes = classnames( {\n\t\t'is-selected': isSelected || forceSelectionContentLock,\n\t\t'is-first-selected': isFirstSelectedBlock,\n\t\t'is-last-selected': isLastSelectedBlock,\n\t\t'is-branch-selected': isBranchSelected,\n\t\t'is-dragging': isDragged,\n\t\t'has-single-cell': ! showBlockActions,\n\t} );\n\n\t// Only include all selected blocks if the currently clicked on block\n\t// is one of the selected blocks. This ensures that if a user attempts\n\t// to alter a block that isn't part of the selection, they're still able\n\t// to do so.\n\tconst dropdownClientIds = selectedClientIds.includes( clientId )\n\t\t? selectedClientIds\n\t\t: [ clientId ];\n\n\treturn (\n\t\t<ListViewLeaf\n\t\t\tclassName={ classes }\n\t\t\tonMouseEnter={ onMouseEnter }\n\t\t\tonMouseLeave={ onMouseLeave }\n\t\t\tonFocus={ onMouseEnter }\n\t\t\tonBlur={ onMouseLeave }\n\t\t\tlevel={ level }\n\t\t\tposition={ position }\n\t\t\trowCount={ rowCount }\n\t\t\tpath={ path }\n\t\t\tid={ `list-view-block-${ clientId }` }\n\t\t\tdata-block={ clientId }\n\t\t\tisExpanded={ isContentLocked ? undefined : isExpanded }\n\t\t\taria-selected={ !! isSelected || forceSelectionContentLock }\n\t\t>\n\t\t\t<TreeGridCell\n\t\t\t\tclassName=\"block-editor-list-view-block__contents-cell\"\n\t\t\t\tcolSpan={ colSpan }\n\t\t\t\tref={ cellRef }\n\t\t\t\taria-label={ blockAriaLabel }\n\t\t\t\taria-selected={ !! isSelected || forceSelectionContentLock }\n\t\t\t\taria-expanded={ isContentLocked ? undefined : isExpanded }\n\t\t\t\taria-describedby={ descriptionId }\n\t\t\t>\n\t\t\t\t{ ( { ref, tabIndex, onFocus } ) => (\n\t\t\t\t\t<div className=\"block-editor-list-view-block__contents-container\">\n\t\t\t\t\t\t<ListViewBlockContents\n\t\t\t\t\t\t\tblock={ block }\n\t\t\t\t\t\t\tonClick={\n\t\t\t\t\t\t\t\tselectBlockInCanvas\n\t\t\t\t\t\t\t\t\t? selectEditorBlock\n\t\t\t\t\t\t\t\t\t: ( event ) => {\n\t\t\t\t\t\t\t\t\t\t\tevent.preventDefault();\n\t\t\t\t\t\t\t\t\t }\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\tonToggleExpanded={ toggleExpanded }\n\t\t\t\t\t\t\tisSelected={ isSelected }\n\t\t\t\t\t\t\tposition={ position }\n\t\t\t\t\t\t\tsiblingBlockCount={ siblingBlockCount }\n\t\t\t\t\t\t\tlevel={ level }\n\t\t\t\t\t\t\tref={ ref }\n\t\t\t\t\t\t\ttabIndex={ tabIndex }\n\t\t\t\t\t\t\tonFocus={ onFocus }\n\t\t\t\t\t\t\tisExpanded={ isExpanded }\n\t\t\t\t\t\t\tselectedClientIds={ selectedClientIds }\n\t\t\t\t\t\t\tpreventAnnouncement={ preventAnnouncement }\n\t\t\t\t\t\t/>\n\t\t\t\t\t\t<div\n\t\t\t\t\t\t\tclassName=\"block-editor-list-view-block-select-button__description\"\n\t\t\t\t\t\t\tid={ descriptionId }\n\t\t\t\t\t\t>\n\t\t\t\t\t\t\t{ blockPositionDescription }\n\t\t\t\t\t\t</div>\n\t\t\t\t\t</div>\n\t\t\t\t) }\n\t\t\t</TreeGridCell>\n\t\t\t{ hasRenderedMovers && (\n\t\t\t\t<>\n\t\t\t\t\t<TreeGridCell\n\t\t\t\t\t\tclassName={ moverCellClassName }\n\t\t\t\t\t\twithoutGridItem\n\t\t\t\t\t>\n\t\t\t\t\t\t<TreeGridItem>\n\t\t\t\t\t\t\t{ ( { ref, tabIndex, onFocus } ) => (\n\t\t\t\t\t\t\t\t<BlockMoverUpButton\n\t\t\t\t\t\t\t\t\torientation=\"vertical\"\n\t\t\t\t\t\t\t\t\tclientIds={ [ clientId ] }\n\t\t\t\t\t\t\t\t\tref={ ref }\n\t\t\t\t\t\t\t\t\ttabIndex={ tabIndex }\n\t\t\t\t\t\t\t\t\tonFocus={ onFocus }\n\t\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t</TreeGridItem>\n\t\t\t\t\t\t<TreeGridItem>\n\t\t\t\t\t\t\t{ ( { ref, tabIndex, onFocus } ) => (\n\t\t\t\t\t\t\t\t<BlockMoverDownButton\n\t\t\t\t\t\t\t\t\torientation=\"vertical\"\n\t\t\t\t\t\t\t\t\tclientIds={ [ clientId ] }\n\t\t\t\t\t\t\t\t\tref={ ref }\n\t\t\t\t\t\t\t\t\ttabIndex={ tabIndex }\n\t\t\t\t\t\t\t\t\tonFocus={ onFocus }\n\t\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t</TreeGridItem>\n\t\t\t\t\t</TreeGridCell>\n\t\t\t\t</>\n\t\t\t) }\n\n\t\t\t{ showBlockActions && (\n\t\t\t\t<>\n\t\t\t\t\t{ isEditable && (\n\t\t\t\t\t\t<TreeGridCell\n\t\t\t\t\t\t\tclassName={ listViewBlockEditClassName }\n\t\t\t\t\t\t\taria-selected={\n\t\t\t\t\t\t\t\t!! isSelected || forceSelectionContentLock\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t>\n\t\t\t\t\t\t\t{ ( props ) => (\n\t\t\t\t\t\t\t\t<BlockEditButton\n\t\t\t\t\t\t\t\t\t{ ...props }\n\t\t\t\t\t\t\t\t\tlabel={ editAriaLabel }\n\t\t\t\t\t\t\t\t\tclientId={ clientId }\n\t\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t</TreeGridCell>\n\t\t\t\t\t) }\n\t\t\t\t\t<TreeGridCell\n\t\t\t\t\t\tclassName={ listViewBlockSettingsClassName }\n\t\t\t\t\t\taria-selected={\n\t\t\t\t\t\t\t!! isSelected || forceSelectionContentLock\n\t\t\t\t\t\t}\n\t\t\t\t\t\tcolSpan={ isEditable ? 1 : 2 } // When an item is not editable then we don't output the cell for the edit button, so we need to adjust the colspan so that the HTML is valid.\n\t\t\t\t\t>\n\t\t\t\t\t\t{ ( { ref, tabIndex, onFocus } ) => (\n\t\t\t\t\t\t\t<BlockSettingsDropdown\n\t\t\t\t\t\t\t\tclientIds={ dropdownClientIds }\n\t\t\t\t\t\t\t\ticon={ moreVertical }\n\t\t\t\t\t\t\t\tlabel={ settingsAriaLabel }\n\t\t\t\t\t\t\t\ttoggleProps={ {\n\t\t\t\t\t\t\t\t\tref,\n\t\t\t\t\t\t\t\t\tclassName:\n\t\t\t\t\t\t\t\t\t\t'block-editor-list-view-block__menu',\n\t\t\t\t\t\t\t\t\ttabIndex,\n\t\t\t\t\t\t\t\t\tonFocus,\n\t\t\t\t\t\t\t\t} }\n\t\t\t\t\t\t\t\tdisableOpenOnArrowDown\n\t\t\t\t\t\t\t\t__experimentalSelectBlock={ updateSelection }\n\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t{ ( { onClose } ) => (\n\t\t\t\t\t\t\t\t\t<MenuItem\n\t\t\t\t\t\t\t\t\t\tonClick={ () => {\n\t\t\t\t\t\t\t\t\t\t\tconst newLink = createBlock(\n\t\t\t\t\t\t\t\t\t\t\t\t'core/navigation-link'\n\t\t\t\t\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\t\t\t\t\tconst newSubmenu = createBlock(\n\t\t\t\t\t\t\t\t\t\t\t\t'core/navigation-submenu',\n\t\t\t\t\t\t\t\t\t\t\t\tattributes,\n\t\t\t\t\t\t\t\t\t\t\t\tblock.innerBlocks\n\t\t\t\t\t\t\t\t\t\t\t\t\t? [\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t...block.innerBlocks,\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tnewLink,\n\t\t\t\t\t\t\t\t\t\t\t\t\t ]\n\t\t\t\t\t\t\t\t\t\t\t\t\t: [ newLink ]\n\t\t\t\t\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\t\t\t\t\treplaceBlock(\n\t\t\t\t\t\t\t\t\t\t\t\tclientId,\n\t\t\t\t\t\t\t\t\t\t\t\tnewSubmenu\n\t\t\t\t\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\t\t\t\t\tonClose();\n\t\t\t\t\t\t\t\t\t\t} }\n\t\t\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t\t\t{ __( 'Add a submenu item' ) }\n\t\t\t\t\t\t\t\t\t</MenuItem>\n\t\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\t</BlockSettingsDropdown>\n\t\t\t\t\t\t) }\n\t\t\t\t\t</TreeGridCell>\n\t\t\t\t</>\n\t\t\t) }\n\t\t</ListViewLeaf>\n\t);\n}\n\nexport default memo( ListViewBlock );\n"]}
|
|
@@ -0,0 +1,164 @@
|
|
|
1
|
+
import { createElement, Fragment } from "@wordpress/element";
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* WordPress dependencies
|
|
5
|
+
*/
|
|
6
|
+
import { memo } from '@wordpress/element';
|
|
7
|
+
import { AsyncModeProvider, useSelect } from '@wordpress/data';
|
|
8
|
+
/**
|
|
9
|
+
* Internal dependencies
|
|
10
|
+
*/
|
|
11
|
+
|
|
12
|
+
import ListViewBlock from './block';
|
|
13
|
+
import { useListViewContext } from './context';
|
|
14
|
+
import { isClientIdSelected } from './utils';
|
|
15
|
+
import { store as blockEditorStore } from '../../store';
|
|
16
|
+
/**
|
|
17
|
+
* Given a block, returns the total number of blocks in that subtree. This is used to help determine
|
|
18
|
+
* the list position of a block.
|
|
19
|
+
*
|
|
20
|
+
* When a block is collapsed, we do not count their children as part of that total. In the current drag
|
|
21
|
+
* implementation dragged blocks and their children are not counted.
|
|
22
|
+
*
|
|
23
|
+
* @param {Object} block block tree
|
|
24
|
+
* @param {Object} expandedState state that notes which branches are collapsed
|
|
25
|
+
* @param {Array} draggedClientIds a list of dragged client ids
|
|
26
|
+
* @param {boolean} isExpandedByDefault flag to determine the default fallback expanded state.
|
|
27
|
+
* @return {number} block count
|
|
28
|
+
*/
|
|
29
|
+
|
|
30
|
+
function countBlocks(block, expandedState, draggedClientIds, isExpandedByDefault) {
|
|
31
|
+
var _expandedState$block$;
|
|
32
|
+
|
|
33
|
+
const isDragged = draggedClientIds === null || draggedClientIds === void 0 ? void 0 : draggedClientIds.includes(block.clientId);
|
|
34
|
+
|
|
35
|
+
if (isDragged) {
|
|
36
|
+
return 0;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
const isExpanded = (_expandedState$block$ = expandedState[block.clientId]) !== null && _expandedState$block$ !== void 0 ? _expandedState$block$ : isExpandedByDefault;
|
|
40
|
+
|
|
41
|
+
if (isExpanded) {
|
|
42
|
+
return 1 + block.innerBlocks.reduce(countReducer(expandedState, draggedClientIds, isExpandedByDefault), 0);
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
return 1;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
const countReducer = (expandedState, draggedClientIds, isExpandedByDefault) => (count, block) => {
|
|
49
|
+
var _expandedState$block$2;
|
|
50
|
+
|
|
51
|
+
const isDragged = draggedClientIds === null || draggedClientIds === void 0 ? void 0 : draggedClientIds.includes(block.clientId);
|
|
52
|
+
|
|
53
|
+
if (isDragged) {
|
|
54
|
+
return count;
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
const isExpanded = (_expandedState$block$2 = expandedState[block.clientId]) !== null && _expandedState$block$2 !== void 0 ? _expandedState$block$2 : isExpandedByDefault;
|
|
58
|
+
|
|
59
|
+
if (isExpanded && block.innerBlocks.length > 0) {
|
|
60
|
+
return count + countBlocks(block, expandedState, draggedClientIds, isExpandedByDefault);
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
return count + 1;
|
|
64
|
+
};
|
|
65
|
+
|
|
66
|
+
const noop = () => {};
|
|
67
|
+
|
|
68
|
+
function ListViewBranch(props) {
|
|
69
|
+
const {
|
|
70
|
+
blocks,
|
|
71
|
+
selectBlock = noop,
|
|
72
|
+
showBlockMovers,
|
|
73
|
+
selectedClientIds,
|
|
74
|
+
level = 1,
|
|
75
|
+
path = '',
|
|
76
|
+
isBranchSelected = false,
|
|
77
|
+
listPosition = 0,
|
|
78
|
+
fixedListWindow,
|
|
79
|
+
isExpanded,
|
|
80
|
+
parentId,
|
|
81
|
+
shouldShowInnerBlocks = true,
|
|
82
|
+
selectBlockInCanvas
|
|
83
|
+
} = props;
|
|
84
|
+
const isContentLocked = useSelect(select => {
|
|
85
|
+
return !!(parentId && select(blockEditorStore).getTemplateLock(parentId) === 'contentOnly');
|
|
86
|
+
}, [parentId]);
|
|
87
|
+
const {
|
|
88
|
+
expandedState,
|
|
89
|
+
draggedClientIds
|
|
90
|
+
} = useListViewContext();
|
|
91
|
+
|
|
92
|
+
if (isContentLocked) {
|
|
93
|
+
return null;
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
const filteredBlocks = blocks.filter(Boolean);
|
|
97
|
+
const blockCount = filteredBlocks.length;
|
|
98
|
+
let nextPosition = listPosition;
|
|
99
|
+
return createElement(Fragment, null, filteredBlocks.map((block, index) => {
|
|
100
|
+
var _expandedState$client;
|
|
101
|
+
|
|
102
|
+
const {
|
|
103
|
+
clientId,
|
|
104
|
+
innerBlocks
|
|
105
|
+
} = block;
|
|
106
|
+
|
|
107
|
+
if (index > 0) {
|
|
108
|
+
nextPosition += countBlocks(filteredBlocks[index - 1], expandedState, draggedClientIds, isExpanded);
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
const {
|
|
112
|
+
itemInView
|
|
113
|
+
} = fixedListWindow;
|
|
114
|
+
const blockInView = itemInView(nextPosition);
|
|
115
|
+
const position = index + 1;
|
|
116
|
+
const updatedPath = path.length > 0 ? `${path}_${position}` : `${position}`;
|
|
117
|
+
const hasNestedBlocks = !!(innerBlocks !== null && innerBlocks !== void 0 && innerBlocks.length);
|
|
118
|
+
const shouldExpand = hasNestedBlocks && shouldShowInnerBlocks ? (_expandedState$client = expandedState[clientId]) !== null && _expandedState$client !== void 0 ? _expandedState$client : isExpanded : undefined;
|
|
119
|
+
const isDragged = !!(draggedClientIds !== null && draggedClientIds !== void 0 && draggedClientIds.includes(clientId));
|
|
120
|
+
const showBlock = isDragged || blockInView; // Make updates to the selected or dragged blocks synchronous,
|
|
121
|
+
// but asynchronous for any other block.
|
|
122
|
+
|
|
123
|
+
const isSelected = isClientIdSelected(clientId, selectedClientIds);
|
|
124
|
+
const isSelectedBranch = isBranchSelected || isSelected && hasNestedBlocks;
|
|
125
|
+
return createElement(AsyncModeProvider, {
|
|
126
|
+
key: clientId,
|
|
127
|
+
value: !isSelected
|
|
128
|
+
}, showBlock && createElement(ListViewBlock, {
|
|
129
|
+
block: block,
|
|
130
|
+
selectBlock: selectBlock,
|
|
131
|
+
isSelected: isSelected,
|
|
132
|
+
isBranchSelected: isSelectedBranch,
|
|
133
|
+
isDragged: isDragged,
|
|
134
|
+
level: level,
|
|
135
|
+
position: position,
|
|
136
|
+
rowCount: blockCount,
|
|
137
|
+
siblingBlockCount: blockCount,
|
|
138
|
+
showBlockMovers: showBlockMovers,
|
|
139
|
+
path: updatedPath,
|
|
140
|
+
isExpanded: shouldExpand,
|
|
141
|
+
listPosition: nextPosition,
|
|
142
|
+
selectedClientIds: selectedClientIds,
|
|
143
|
+
selectBlockInCanvas: selectBlockInCanvas
|
|
144
|
+
}), !showBlock && createElement("tr", null, createElement("td", {
|
|
145
|
+
className: "block-editor-list-view-placeholder"
|
|
146
|
+
})), hasNestedBlocks && shouldExpand && !isDragged && createElement(ListViewBranch, {
|
|
147
|
+
parentId: clientId,
|
|
148
|
+
blocks: innerBlocks,
|
|
149
|
+
selectBlock: selectBlock,
|
|
150
|
+
showBlockMovers: showBlockMovers,
|
|
151
|
+
level: level + 1,
|
|
152
|
+
path: updatedPath,
|
|
153
|
+
listPosition: nextPosition + 1,
|
|
154
|
+
fixedListWindow: fixedListWindow,
|
|
155
|
+
isBranchSelected: isSelectedBranch,
|
|
156
|
+
selectedClientIds: selectedClientIds,
|
|
157
|
+
isExpanded: isExpanded,
|
|
158
|
+
selectBlockInCanvas: selectBlockInCanvas
|
|
159
|
+
}));
|
|
160
|
+
}));
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
export default memo(ListViewBranch);
|
|
164
|
+
//# sourceMappingURL=branch.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["@wordpress/block-editor/src/components/off-canvas-editor/branch.js"],"names":["memo","AsyncModeProvider","useSelect","ListViewBlock","useListViewContext","isClientIdSelected","store","blockEditorStore","countBlocks","block","expandedState","draggedClientIds","isExpandedByDefault","isDragged","includes","clientId","isExpanded","innerBlocks","reduce","countReducer","count","length","noop","ListViewBranch","props","blocks","selectBlock","showBlockMovers","selectedClientIds","level","path","isBranchSelected","listPosition","fixedListWindow","parentId","shouldShowInnerBlocks","selectBlockInCanvas","isContentLocked","select","getTemplateLock","filteredBlocks","filter","Boolean","blockCount","nextPosition","map","index","itemInView","blockInView","position","updatedPath","hasNestedBlocks","shouldExpand","undefined","showBlock","isSelected","isSelectedBranch"],"mappings":";;AAAA;AACA;AACA;AACA,SAASA,IAAT,QAAqB,oBAArB;AACA,SAASC,iBAAT,EAA4BC,SAA5B,QAA6C,iBAA7C;AAEA;AACA;AACA;;AACA,OAAOC,aAAP,MAA0B,SAA1B;AACA,SAASC,kBAAT,QAAmC,WAAnC;AACA,SAASC,kBAAT,QAAmC,SAAnC;AACA,SAASC,KAAK,IAAIC,gBAAlB,QAA0C,aAA1C;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AACA,SAASC,WAAT,CACCC,KADD,EAECC,aAFD,EAGCC,gBAHD,EAICC,mBAJD,EAKE;AAAA;;AACD,QAAMC,SAAS,GAAGF,gBAAH,aAAGA,gBAAH,uBAAGA,gBAAgB,CAAEG,QAAlB,CAA4BL,KAAK,CAACM,QAAlC,CAAlB;;AACA,MAAKF,SAAL,EAAiB;AAChB,WAAO,CAAP;AACA;;AACD,QAAMG,UAAU,4BA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ACC,MAAA,QAAQ,EAAGE,QADZ;AAEC,MAAA,MAAM,EAAGE,WAFV;AAGC,MAAA,WAAW,EAAGS,WAHf;AAIC,MAAA,eAAe,EAAGC,eAJnB;AAKC,MAAA,KAAK,EAAGE,KAAK,GAAG,CALjB;AAMC,MAAA,IAAI,EAAGqB,WANR;AAOC,MAAA,YAAY,EAAGN,YAAY,GAAG,CAP/B;AAQC,MAAA,eAAe,EAAGX,eARnB;AASC,MAAA,gBAAgB,EAAGuB,gBATpB;AAUC,MAAA,iBAAiB,EAAG5B,iBAVrB;AAWC,MAAA,UAAU,EAAGZ,UAXd;AAYC,MAAA,mBAAmB,EAAGoB;AAZvB,MA1BF,CADD;AA4CA,GAnFC,CADH,CADD;AAwFA;;AAED,eAAepC,IAAI,CAAEuB,cAAF,CAAnB","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { memo } from '@wordpress/element';\nimport { AsyncModeProvider, useSelect } from '@wordpress/data';\n\n/**\n * Internal dependencies\n */\nimport ListViewBlock from './block';\nimport { useListViewContext } from './context';\nimport { isClientIdSelected } from './utils';\nimport { store as blockEditorStore } from '../../store';\n\n/**\n * Given a block, returns the total number of blocks in that subtree. This is used to help determine\n * the list position of a block.\n *\n * When a block is collapsed, we do not count their children as part of that total. In the current drag\n * implementation dragged blocks and their children are not counted.\n *\n * @param {Object} block block tree\n * @param {Object} expandedState state that notes which branches are collapsed\n * @param {Array} draggedClientIds a list of dragged client ids\n * @param {boolean} isExpandedByDefault flag to determine the default fallback expanded state.\n * @return {number} block count\n */\nfunction countBlocks(\n\tblock,\n\texpandedState,\n\tdraggedClientIds,\n\tisExpandedByDefault\n) {\n\tconst isDragged = draggedClientIds?.includes( block.clientId );\n\tif ( isDragged ) {\n\t\treturn 0;\n\t}\n\tconst isExpanded = expandedState[ block.clientId ] ?? isExpandedByDefault;\n\n\tif ( isExpanded ) {\n\t\treturn (\n\t\t\t1 +\n\t\t\tblock.innerBlocks.reduce(\n\t\t\t\tcountReducer(\n\t\t\t\t\texpandedState,\n\t\t\t\t\tdraggedClientIds,\n\t\t\t\t\tisExpandedByDefault\n\t\t\t\t),\n\t\t\t\t0\n\t\t\t)\n\t\t);\n\t}\n\treturn 1;\n}\nconst countReducer =\n\t( expandedState, draggedClientIds, isExpandedByDefault ) =>\n\t( count, block ) => {\n\t\tconst isDragged = draggedClientIds?.includes( block.clientId );\n\t\tif ( isDragged ) {\n\t\t\treturn count;\n\t\t}\n\t\tconst isExpanded =\n\t\t\texpandedState[ block.clientId ] ?? isExpandedByDefault;\n\t\tif ( isExpanded && block.innerBlocks.length > 0 ) {\n\t\t\treturn (\n\t\t\t\tcount +\n\t\t\t\tcountBlocks(\n\t\t\t\t\tblock,\n\t\t\t\t\texpandedState,\n\t\t\t\t\tdraggedClientIds,\n\t\t\t\t\tisExpandedByDefault\n\t\t\t\t)\n\t\t\t);\n\t\t}\n\t\treturn count + 1;\n\t};\n\nconst noop = () => {};\n\nfunction ListViewBranch( props ) {\n\tconst {\n\t\tblocks,\n\t\tselectBlock = noop,\n\t\tshowBlockMovers,\n\t\tselectedClientIds,\n\t\tlevel = 1,\n\t\tpath = '',\n\t\tisBranchSelected = false,\n\t\tlistPosition = 0,\n\t\tfixedListWindow,\n\t\tisExpanded,\n\t\tparentId,\n\t\tshouldShowInnerBlocks = true,\n\t\tselectBlockInCanvas,\n\t} = props;\n\n\tconst isContentLocked = useSelect(\n\t\t( select ) => {\n\t\t\treturn !! (\n\t\t\t\tparentId &&\n\t\t\t\tselect( blockEditorStore ).getTemplateLock( parentId ) ===\n\t\t\t\t\t'contentOnly'\n\t\t\t);\n\t\t},\n\t\t[ parentId ]\n\t);\n\n\tconst { expandedState, draggedClientIds } = useListViewContext();\n\n\tif ( isContentLocked ) {\n\t\treturn null;\n\t}\n\n\tconst filteredBlocks = blocks.filter( Boolean );\n\tconst blockCount = filteredBlocks.length;\n\tlet nextPosition = listPosition;\n\n\treturn (\n\t\t<>\n\t\t\t{ filteredBlocks.map( ( block, index ) => {\n\t\t\t\tconst { clientId, innerBlocks } = block;\n\n\t\t\t\tif ( index > 0 ) {\n\t\t\t\t\tnextPosition += countBlocks(\n\t\t\t\t\t\tfilteredBlocks[ index - 1 ],\n\t\t\t\t\t\texpandedState,\n\t\t\t\t\t\tdraggedClientIds,\n\t\t\t\t\t\tisExpanded\n\t\t\t\t\t);\n\t\t\t\t}\n\n\t\t\t\tconst { itemInView } = fixedListWindow;\n\t\t\t\tconst blockInView = itemInView( nextPosition );\n\n\t\t\t\tconst position = index + 1;\n\t\t\t\tconst updatedPath =\n\t\t\t\t\tpath.length > 0\n\t\t\t\t\t\t? `${ path }_${ position }`\n\t\t\t\t\t\t: `${ position }`;\n\t\t\t\tconst hasNestedBlocks = !! innerBlocks?.length;\n\n\t\t\t\tconst shouldExpand =\n\t\t\t\t\thasNestedBlocks && shouldShowInnerBlocks\n\t\t\t\t\t\t? expandedState[ clientId ] ?? isExpanded\n\t\t\t\t\t\t: undefined;\n\n\t\t\t\tconst isDragged = !! draggedClientIds?.includes( clientId );\n\n\t\t\t\tconst showBlock = isDragged || blockInView;\n\n\t\t\t\t// Make updates to the selected or dragged blocks synchronous,\n\t\t\t\t// but asynchronous for any other block.\n\t\t\t\tconst isSelected = isClientIdSelected(\n\t\t\t\t\tclientId,\n\t\t\t\t\tselectedClientIds\n\t\t\t\t);\n\t\t\t\tconst isSelectedBranch =\n\t\t\t\t\tisBranchSelected || ( isSelected && hasNestedBlocks );\n\t\t\t\treturn (\n\t\t\t\t\t<AsyncModeProvider key={ clientId } value={ ! isSelected }>\n\t\t\t\t\t\t{ showBlock && (\n\t\t\t\t\t\t\t<ListViewBlock\n\t\t\t\t\t\t\t\tblock={ block }\n\t\t\t\t\t\t\t\tselectBlock={ selectBlock }\n\t\t\t\t\t\t\t\tisSelected={ isSelected }\n\t\t\t\t\t\t\t\tisBranchSelected={ isSelectedBranch }\n\t\t\t\t\t\t\t\tisDragged={ isDragged }\n\t\t\t\t\t\t\t\tlevel={ level }\n\t\t\t\t\t\t\t\tposition={ position }\n\t\t\t\t\t\t\t\trowCount={ blockCount }\n\t\t\t\t\t\t\t\tsiblingBlockCount={ blockCount }\n\t\t\t\t\t\t\t\tshowBlockMovers={ showBlockMovers }\n\t\t\t\t\t\t\t\tpath={ updatedPath }\n\t\t\t\t\t\t\t\tisExpanded={ shouldExpand }\n\t\t\t\t\t\t\t\tlistPosition={ nextPosition }\n\t\t\t\t\t\t\t\tselectedClientIds={ selectedClientIds }\n\t\t\t\t\t\t\t\tselectBlockInCanvas={ selectBlockInCanvas }\n\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t) }\n\t\t\t\t\t\t{ ! showBlock && (\n\t\t\t\t\t\t\t<tr>\n\t\t\t\t\t\t\t\t<td className=\"block-editor-list-view-placeholder\" />\n\t\t\t\t\t\t\t</tr>\n\t\t\t\t\t\t) }\n\t\t\t\t\t\t{ hasNestedBlocks && shouldExpand && ! isDragged && (\n\t\t\t\t\t\t\t<ListViewBranch\n\t\t\t\t\t\t\t\tparentId={ clientId }\n\t\t\t\t\t\t\t\tblocks={ innerBlocks }\n\t\t\t\t\t\t\t\tselectBlock={ selectBlock }\n\t\t\t\t\t\t\t\tshowBlockMovers={ showBlockMovers }\n\t\t\t\t\t\t\t\tlevel={ level + 1 }\n\t\t\t\t\t\t\t\tpath={ updatedPath }\n\t\t\t\t\t\t\t\tlistPosition={ nextPosition + 1 }\n\t\t\t\t\t\t\t\tfixedListWindow={ fixedListWindow }\n\t\t\t\t\t\t\t\tisBranchSelected={ isSelectedBranch }\n\t\t\t\t\t\t\t\tselectedClientIds={ selectedClientIds }\n\t\t\t\t\t\t\t\tisExpanded={ isExpanded }\n\t\t\t\t\t\t\t\tselectBlockInCanvas={ selectBlockInCanvas }\n\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t) }\n\t\t\t\t\t</AsyncModeProvider>\n\t\t\t\t);\n\t\t\t} ) }\n\t\t</>\n\t);\n}\n\nexport default memo( ListViewBranch );\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["@wordpress/block-editor/src/components/off-canvas-editor/context.js"],"names":["createContext","useContext","ListViewContext","useListViewContext"],"mappings":"AAAA;AACA;AACA;AACA,SAASA,aAAT,EAAwBC,UAAxB,QAA0C,oBAA1C;AAEA,OAAO,MAAMC,eAAe,GAAGF,aAAa,CAAE,EAAF,CAArC;AAEP,OAAO,MAAMG,kBAAkB,GAAG,MAAMF,UAAU,CAAEC,eAAF,CAA3C","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { createContext, useContext } from '@wordpress/element';\n\nexport const ListViewContext = createContext( {} );\n\nexport const useListViewContext = () => useContext( ListViewContext );\n"]}
|
|
@@ -0,0 +1,111 @@
|
|
|
1
|
+
import { createElement } from "@wordpress/element";
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* WordPress dependencies
|
|
5
|
+
*/
|
|
6
|
+
import { Popover } from '@wordpress/components';
|
|
7
|
+
import { useCallback, useMemo } from '@wordpress/element';
|
|
8
|
+
export default function ListViewDropIndicator(_ref) {
|
|
9
|
+
let {
|
|
10
|
+
listViewRef,
|
|
11
|
+
blockDropTarget
|
|
12
|
+
} = _ref;
|
|
13
|
+
const {
|
|
14
|
+
rootClientId,
|
|
15
|
+
clientId,
|
|
16
|
+
dropPosition
|
|
17
|
+
} = blockDropTarget || {};
|
|
18
|
+
const [rootBlockElement, blockElement] = useMemo(() => {
|
|
19
|
+
if (!listViewRef.current) {
|
|
20
|
+
return [];
|
|
21
|
+
} // The rootClientId will be defined whenever dropping into inner
|
|
22
|
+
// block lists, but is undefined when dropping at the root level.
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
const _rootBlockElement = rootClientId ? listViewRef.current.querySelector(`[data-block="${rootClientId}"]`) : undefined; // The clientId represents the sibling block, the dragged block will
|
|
26
|
+
// usually be inserted adjacent to it. It will be undefined when
|
|
27
|
+
// dropping a block into an empty block list.
|
|
28
|
+
|
|
29
|
+
|
|
30
|
+
const _blockElement = clientId ? listViewRef.current.querySelector(`[data-block="${clientId}"]`) : undefined;
|
|
31
|
+
|
|
32
|
+
return [_rootBlockElement, _blockElement];
|
|
33
|
+
}, [rootClientId, clientId]); // The targetElement is the element that the drop indicator will appear
|
|
34
|
+
// before or after. When dropping into an empty block list, blockElement
|
|
35
|
+
// is undefined, so the indicator will appear after the rootBlockElement.
|
|
36
|
+
|
|
37
|
+
const targetElement = blockElement || rootBlockElement;
|
|
38
|
+
const getDropIndicatorIndent = useCallback(() => {
|
|
39
|
+
if (!rootBlockElement) {
|
|
40
|
+
return 0;
|
|
41
|
+
} // Calculate the indent using the block icon of the root block.
|
|
42
|
+
// Using a classname selector here might be flaky and could be
|
|
43
|
+
// improved.
|
|
44
|
+
|
|
45
|
+
|
|
46
|
+
const targetElementRect = targetElement.getBoundingClientRect();
|
|
47
|
+
const rootBlockIconElement = rootBlockElement.querySelector('.block-editor-block-icon');
|
|
48
|
+
const rootBlockIconRect = rootBlockIconElement.getBoundingClientRect();
|
|
49
|
+
return rootBlockIconRect.right - targetElementRect.left;
|
|
50
|
+
}, [rootBlockElement, targetElement]);
|
|
51
|
+
const style = useMemo(() => {
|
|
52
|
+
if (!targetElement) {
|
|
53
|
+
return {};
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
const indent = getDropIndicatorIndent();
|
|
57
|
+
return {
|
|
58
|
+
width: targetElement.offsetWidth - indent
|
|
59
|
+
};
|
|
60
|
+
}, [getDropIndicatorIndent, targetElement]);
|
|
61
|
+
const popoverAnchor = useMemo(() => {
|
|
62
|
+
const isValidDropPosition = dropPosition === 'top' || dropPosition === 'bottom' || dropPosition === 'inside';
|
|
63
|
+
|
|
64
|
+
if (!targetElement || !isValidDropPosition) {
|
|
65
|
+
return undefined;
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
return {
|
|
69
|
+
ownerDocument: targetElement.ownerDocument,
|
|
70
|
+
|
|
71
|
+
getBoundingClientRect() {
|
|
72
|
+
const rect = targetElement.getBoundingClientRect();
|
|
73
|
+
const indent = getDropIndicatorIndent();
|
|
74
|
+
const left = rect.left + indent;
|
|
75
|
+
const right = rect.right;
|
|
76
|
+
let top = 0;
|
|
77
|
+
let bottom = 0;
|
|
78
|
+
|
|
79
|
+
if (dropPosition === 'top') {
|
|
80
|
+
top = rect.top;
|
|
81
|
+
bottom = rect.top;
|
|
82
|
+
} else {
|
|
83
|
+
// `dropPosition` is either `bottom` or `inside`
|
|
84
|
+
top = rect.bottom;
|
|
85
|
+
bottom = rect.bottom;
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
const width = right - left;
|
|
89
|
+
const height = bottom - top;
|
|
90
|
+
return new window.DOMRect(left, top, width, height);
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
};
|
|
94
|
+
}, [targetElement, dropPosition, getDropIndicatorIndent]);
|
|
95
|
+
|
|
96
|
+
if (!targetElement) {
|
|
97
|
+
return null;
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
return createElement(Popover, {
|
|
101
|
+
animate: false,
|
|
102
|
+
anchor: popoverAnchor,
|
|
103
|
+
focusOnMount: false,
|
|
104
|
+
className: "block-editor-list-view-drop-indicator",
|
|
105
|
+
variant: "unstyled"
|
|
106
|
+
}, createElement("div", {
|
|
107
|
+
style: style,
|
|
108
|
+
className: "block-editor-list-view-drop-indicator__line"
|
|
109
|
+
}));
|
|
110
|
+
}
|
|
111
|
+
//# sourceMappingURL=drop-indicator.js.map
|