@wordpress/block-editor 11.4.0 → 11.6.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 +8 -0
- package/build/components/block-inspector/index.js +11 -10
- package/build/components/block-inspector/index.js.map +1 -1
- package/build/components/block-inspector/useBlockInspectorAnimationSettings.js +46 -0
- package/build/components/block-inspector/useBlockInspectorAnimationSettings.js.map +1 -0
- package/build/components/block-list/block-invalid-warning.js +63 -80
- package/build/components/block-list/block-invalid-warning.js.map +1 -1
- package/build/components/block-lock/modal.js +1 -0
- package/build/components/block-lock/modal.js.map +1 -1
- package/build/components/block-settings-menu/block-settings-dropdown.js +2 -2
- package/build/components/block-settings-menu/block-settings-dropdown.js.map +1 -1
- package/build/components/block-settings-menu-controls/index.js +1 -1
- package/build/components/block-settings-menu-controls/index.js.map +1 -1
- package/build/components/block-styles/index.js +2 -1
- package/build/components/block-styles/index.js.map +1 -1
- package/build/components/block-switcher/block-transformations-menu.native.js +1 -0
- package/build/components/block-switcher/block-transformations-menu.native.js.map +1 -1
- package/build/components/child-layout-control/index.js +107 -0
- package/build/components/child-layout-control/index.js.map +1 -0
- package/build/components/convert-to-group-buttons/use-convert-to-group-button-props.js +6 -3
- package/build/components/convert-to-group-buttons/use-convert-to-group-button-props.js.map +1 -1
- package/build/components/date-format-picker/index.js +3 -3
- package/build/components/date-format-picker/index.js.map +1 -1
- package/build/components/global-styles/border-panel.js +306 -0
- package/build/components/global-styles/border-panel.js.map +1 -0
- package/build/components/global-styles/dimensions-panel.js +594 -0
- package/build/components/global-styles/dimensions-panel.js.map +1 -0
- package/build/components/global-styles/hooks.js +127 -37
- package/build/components/global-styles/hooks.js.map +1 -1
- package/build/components/global-styles/index.js +36 -2
- package/build/components/global-styles/index.js.map +1 -1
- package/build/components/global-styles/typography-panel.js +87 -27
- package/build/components/global-styles/typography-panel.js.map +1 -1
- package/build/components/global-styles/use-global-styles-output.js +21 -14
- package/build/components/global-styles/use-global-styles-output.js.map +1 -1
- package/build/components/global-styles/utils.js +2 -0
- package/build/components/global-styles/utils.js.map +1 -1
- package/build/components/index.native.js +23 -0
- package/build/components/index.native.js.map +1 -1
- package/build/components/inserter/index.js +29 -17
- package/build/components/inserter/index.js.map +1 -1
- package/build/components/inserter/media-tab/hooks.js +10 -11
- package/build/components/inserter/media-tab/hooks.js.map +1 -1
- package/build/components/inserter/media-tab/media-list.js +5 -108
- package/build/components/inserter/media-tab/media-list.js.map +1 -1
- package/build/components/inserter/media-tab/media-preview.js +242 -0
- package/build/components/inserter/media-tab/media-preview.js.map +1 -0
- package/build/components/inserter/menu.js +1 -1
- package/build/components/inserter/menu.js.map +1 -1
- package/build/components/inserter/quick-inserter.js +4 -2
- package/build/components/inserter/quick-inserter.js.map +1 -1
- package/build/components/inserter/search-results.js +10 -3
- package/build/components/inserter/search-results.js.map +1 -1
- package/build/components/inserter/tabs.js +1 -1
- package/build/components/inserter/tabs.js.map +1 -1
- package/build/components/inspector-controls/block-support-tools-panel.js +1 -1
- package/build/components/inspector-controls/block-support-tools-panel.js.map +1 -1
- package/build/components/inspector-controls/fill.js +38 -9
- package/build/components/inspector-controls/fill.js.map +1 -1
- package/build/components/link-control/index.js +1 -1
- package/build/components/link-control/index.js.map +1 -1
- package/build/components/link-control/search-item.js +5 -2
- package/build/components/link-control/search-item.js.map +1 -1
- package/build/components/link-control/settings-drawer.js +1 -1
- package/build/components/link-control/settings-drawer.js.map +1 -1
- package/build/components/link-control/settings.js +1 -0
- package/build/components/link-control/settings.js.map +1 -1
- package/build/components/list-view/block.js +17 -3
- package/build/components/list-view/block.js.map +1 -1
- package/build/components/list-view/branch.js +2 -2
- package/build/components/list-view/branch.js.map +1 -1
- package/build/components/list-view/expander.js +2 -1
- package/build/components/list-view/expander.js.map +1 -1
- package/build/components/list-view/leaf.js +10 -6
- package/build/components/list-view/leaf.js.map +1 -1
- package/build/components/list-view/use-block-selection.js +1 -2
- package/build/components/list-view/use-block-selection.js.map +1 -1
- package/build/components/list-view/use-list-view-scroll-into-view.js +51 -0
- package/build/components/list-view/use-list-view-scroll-into-view.js.map +1 -0
- package/build/components/off-canvas-editor/appender.js +33 -13
- package/build/components/off-canvas-editor/appender.js.map +1 -1
- package/build/components/off-canvas-editor/branch.js +6 -3
- package/build/components/off-canvas-editor/branch.js.map +1 -1
- package/build/components/off-canvas-editor/index.js +8 -2
- package/build/components/off-canvas-editor/index.js.map +1 -1
- package/build/components/off-canvas-editor/leaf-more-menu.js +34 -4
- package/build/components/off-canvas-editor/leaf-more-menu.js.map +1 -1
- package/build/components/provider/use-block-sync.js +17 -3
- package/build/components/provider/use-block-sync.js.map +1 -1
- package/build/components/responsive-block-control/index.js +1 -0
- package/build/components/responsive-block-control/index.js.map +1 -1
- package/build/components/rich-text/format-toolbar-container.js +0 -3
- package/build/components/rich-text/format-toolbar-container.js.map +1 -1
- package/build/components/rich-text/index.js +9 -43
- package/build/components/rich-text/index.js.map +1 -1
- package/build/components/rich-text/use-delete.js +73 -0
- package/build/components/rich-text/use-delete.js.map +1 -0
- package/build/components/rich-text/use-input-rules.js +14 -6
- package/build/components/rich-text/use-input-rules.js.map +1 -1
- package/build/components/writing-flow/use-selection-observer.js +4 -1
- package/build/components/writing-flow/use-selection-observer.js.map +1 -1
- package/build/hooks/align.js +3 -1
- package/build/hooks/align.js.map +1 -1
- package/build/hooks/border.js +91 -240
- package/build/hooks/border.js.map +1 -1
- package/build/hooks/custom-class-name.js +4 -4
- package/build/hooks/custom-class-name.js.map +1 -1
- package/build/hooks/custom-class-name.native.js +3 -4
- package/build/hooks/custom-class-name.native.js.map +1 -1
- package/build/hooks/dimensions.js +72 -190
- package/build/hooks/dimensions.js.map +1 -1
- package/build/hooks/duotone.js +94 -25
- package/build/hooks/duotone.js.map +1 -1
- package/build/hooks/gap.js +0 -202
- package/build/hooks/gap.js.map +1 -1
- package/build/hooks/layout.js +33 -27
- package/build/hooks/layout.js.map +1 -1
- package/build/hooks/margin.js +7 -163
- package/build/hooks/margin.js.map +1 -1
- package/build/hooks/padding.js +7 -163
- package/build/hooks/padding.js.map +1 -1
- package/build/hooks/supports.js +7 -1
- package/build/hooks/supports.js.map +1 -1
- package/build/hooks/typography.js +52 -66
- package/build/hooks/typography.js.map +1 -1
- package/build/hooks/utils.js +101 -0
- package/build/hooks/utils.js.map +1 -1
- package/build/layouts/constrained.js +6 -2
- package/build/layouts/constrained.js.map +1 -1
- package/build/layouts/flex.js +1 -0
- package/build/layouts/flex.js.map +1 -1
- package/build/private-apis.js +4 -1
- package/build/private-apis.js.map +1 -1
- package/build/store/actions.js +28 -14
- package/build/store/actions.js.map +1 -1
- package/build/store/defaults.js +28 -1
- package/build/store/defaults.js.map +1 -1
- package/build/store/reducer.js +53 -47
- package/build/store/reducer.js.map +1 -1
- package/build/store/selectors.js +24 -4
- package/build/store/selectors.js.map +1 -1
- package/build/utils/parse-css-unit-to-px.js +49 -10
- package/build/utils/parse-css-unit-to-px.js.map +1 -1
- package/build-module/components/block-inspector/index.js +9 -9
- package/build-module/components/block-inspector/index.js.map +1 -1
- package/build-module/components/block-inspector/useBlockInspectorAnimationSettings.js +37 -0
- package/build-module/components/block-inspector/useBlockInspectorAnimationSettings.js.map +1 -0
- package/build-module/components/block-list/block-invalid-warning.js +66 -78
- package/build-module/components/block-list/block-invalid-warning.js.map +1 -1
- package/build-module/components/block-lock/modal.js +1 -0
- package/build-module/components/block-lock/modal.js.map +1 -1
- package/build-module/components/block-settings-menu/block-settings-dropdown.js +2 -2
- package/build-module/components/block-settings-menu/block-settings-dropdown.js.map +1 -1
- package/build-module/components/block-settings-menu-controls/index.js +1 -1
- package/build-module/components/block-settings-menu-controls/index.js.map +1 -1
- package/build-module/components/block-styles/index.js +2 -1
- package/build-module/components/block-styles/index.js.map +1 -1
- package/build-module/components/block-switcher/block-transformations-menu.native.js +1 -0
- package/build-module/components/block-switcher/block-transformations-menu.native.js.map +1 -1
- package/build-module/components/child-layout-control/index.js +98 -0
- package/build-module/components/child-layout-control/index.js.map +1 -0
- package/build-module/components/convert-to-group-buttons/use-convert-to-group-button-props.js +6 -3
- package/build-module/components/convert-to-group-buttons/use-convert-to-group-button-props.js.map +1 -1
- package/build-module/components/date-format-picker/index.js +4 -4
- package/build-module/components/date-format-picker/index.js.map +1 -1
- package/build-module/components/global-styles/border-panel.js +291 -0
- package/build-module/components/global-styles/border-panel.js.map +1 -0
- package/build-module/components/global-styles/dimensions-panel.js +574 -0
- package/build-module/components/global-styles/dimensions-panel.js.map +1 -0
- package/build-module/components/global-styles/hooks.js +123 -34
- package/build-module/components/global-styles/hooks.js.map +1 -1
- package/build-module/components/global-styles/index.js +3 -1
- package/build-module/components/global-styles/index.js.map +1 -1
- package/build-module/components/global-styles/typography-panel.js +88 -27
- package/build-module/components/global-styles/typography-panel.js.map +1 -1
- package/build-module/components/global-styles/use-global-styles-output.js +21 -14
- package/build-module/components/global-styles/use-global-styles-output.js.map +1 -1
- package/build-module/components/global-styles/utils.js +2 -0
- package/build-module/components/global-styles/utils.js.map +1 -1
- package/build-module/components/index.native.js +2 -1
- package/build-module/components/index.native.js.map +1 -1
- package/build-module/components/inserter/index.js +28 -16
- package/build-module/components/inserter/index.js.map +1 -1
- package/build-module/components/inserter/media-tab/hooks.js +10 -11
- package/build-module/components/inserter/media-tab/hooks.js.map +1 -1
- package/build-module/components/inserter/media-tab/media-list.js +6 -105
- package/build-module/components/inserter/media-tab/media-list.js.map +1 -1
- package/build-module/components/inserter/media-tab/media-preview.js +222 -0
- package/build-module/components/inserter/media-tab/media-preview.js.map +1 -0
- package/build-module/components/inserter/menu.js +1 -1
- package/build-module/components/inserter/menu.js.map +1 -1
- package/build-module/components/inserter/quick-inserter.js +4 -2
- package/build-module/components/inserter/quick-inserter.js.map +1 -1
- package/build-module/components/inserter/search-results.js +10 -3
- package/build-module/components/inserter/search-results.js.map +1 -1
- package/build-module/components/inserter/tabs.js +1 -1
- package/build-module/components/inserter/tabs.js.map +1 -1
- package/build-module/components/inspector-controls/block-support-tools-panel.js +1 -1
- package/build-module/components/inspector-controls/block-support-tools-panel.js.map +1 -1
- package/build-module/components/inspector-controls/fill.js +39 -9
- package/build-module/components/inspector-controls/fill.js.map +1 -1
- package/build-module/components/link-control/index.js +1 -1
- package/build-module/components/link-control/index.js.map +1 -1
- package/build-module/components/link-control/search-item.js +4 -2
- package/build-module/components/link-control/search-item.js.map +1 -1
- package/build-module/components/link-control/settings-drawer.js +1 -1
- package/build-module/components/link-control/settings-drawer.js.map +1 -1
- package/build-module/components/link-control/settings.js +1 -0
- package/build-module/components/link-control/settings.js.map +1 -1
- package/build-module/components/list-view/block.js +16 -3
- package/build-module/components/list-view/block.js.map +1 -1
- package/build-module/components/list-view/branch.js +2 -2
- package/build-module/components/list-view/branch.js.map +1 -1
- package/build-module/components/list-view/expander.js +2 -1
- package/build-module/components/list-view/expander.js.map +1 -1
- package/build-module/components/list-view/leaf.js +8 -4
- package/build-module/components/list-view/leaf.js.map +1 -1
- package/build-module/components/list-view/use-block-selection.js +1 -2
- package/build-module/components/list-view/use-block-selection.js.map +1 -1
- package/build-module/components/list-view/use-list-view-scroll-into-view.js +42 -0
- package/build-module/components/list-view/use-list-view-scroll-into-view.js.map +1 -0
- package/build-module/components/off-canvas-editor/appender.js +33 -14
- package/build-module/components/off-canvas-editor/appender.js.map +1 -1
- package/build-module/components/off-canvas-editor/branch.js +6 -3
- package/build-module/components/off-canvas-editor/branch.js.map +1 -1
- package/build-module/components/off-canvas-editor/index.js +8 -2
- package/build-module/components/off-canvas-editor/index.js.map +1 -1
- package/build-module/components/off-canvas-editor/leaf-more-menu.js +36 -7
- package/build-module/components/off-canvas-editor/leaf-more-menu.js.map +1 -1
- package/build-module/components/provider/use-block-sync.js +17 -3
- package/build-module/components/provider/use-block-sync.js.map +1 -1
- package/build-module/components/responsive-block-control/index.js +1 -0
- package/build-module/components/responsive-block-control/index.js.map +1 -1
- package/build-module/components/rich-text/format-toolbar-container.js +0 -3
- package/build-module/components/rich-text/format-toolbar-container.js.map +1 -1
- package/build-module/components/rich-text/index.js +9 -43
- package/build-module/components/rich-text/index.js.map +1 -1
- package/build-module/components/rich-text/use-delete.js +62 -0
- package/build-module/components/rich-text/use-delete.js.map +1 -0
- package/build-module/components/rich-text/use-input-rules.js +14 -6
- package/build-module/components/rich-text/use-input-rules.js.map +1 -1
- package/build-module/components/writing-flow/use-selection-observer.js +4 -1
- package/build-module/components/writing-flow/use-selection-observer.js.map +1 -1
- package/build-module/hooks/align.js +3 -1
- package/build-module/hooks/align.js.map +1 -1
- package/build-module/hooks/border.js +93 -240
- package/build-module/hooks/border.js.map +1 -1
- package/build-module/hooks/custom-class-name.js +4 -4
- package/build-module/hooks/custom-class-name.js.map +1 -1
- package/build-module/hooks/custom-class-name.native.js +3 -4
- package/build-module/hooks/custom-class-name.native.js.map +1 -1
- package/build-module/hooks/dimensions.js +75 -187
- package/build-module/hooks/dimensions.js.map +1 -1
- package/build-module/hooks/duotone.js +86 -24
- package/build-module/hooks/duotone.js.map +1 -1
- package/build-module/hooks/gap.js +0 -183
- package/build-module/hooks/gap.js.map +1 -1
- package/build-module/hooks/layout.js +33 -27
- package/build-module/hooks/layout.js.map +1 -1
- package/build-module/hooks/margin.js +4 -143
- package/build-module/hooks/margin.js.map +1 -1
- package/build-module/hooks/padding.js +4 -143
- package/build-module/hooks/padding.js.map +1 -1
- package/build-module/hooks/supports.js +7 -1
- package/build-module/hooks/supports.js.map +1 -1
- package/build-module/hooks/typography.js +54 -66
- package/build-module/hooks/typography.js.map +1 -1
- package/build-module/hooks/utils.js +96 -0
- package/build-module/hooks/utils.js.map +1 -1
- package/build-module/layouts/constrained.js +6 -2
- package/build-module/layouts/constrained.js.map +1 -1
- package/build-module/layouts/flex.js +1 -0
- package/build-module/layouts/flex.js.map +1 -1
- package/build-module/private-apis.js +3 -1
- package/build-module/private-apis.js.map +1 -1
- package/build-module/store/actions.js +28 -14
- package/build-module/store/actions.js.map +1 -1
- package/build-module/store/defaults.js +28 -1
- package/build-module/store/defaults.js.map +1 -1
- package/build-module/store/reducer.js +53 -45
- package/build-module/store/reducer.js.map +1 -1
- package/build-module/store/selectors.js +22 -4
- package/build-module/store/selectors.js.map +1 -1
- package/build-module/utils/parse-css-unit-to-px.js +49 -10
- package/build-module/utils/parse-css-unit-to-px.js.map +1 -1
- package/build-style/style-rtl.css +39 -27
- package/build-style/style.css +39 -27
- package/package.json +31 -31
- package/src/components/block-draggable/test/__snapshots__/index.native.js.snap +24 -24
- package/src/components/block-inspector/index.js +11 -14
- package/src/components/block-inspector/style.scss +3 -0
- package/src/components/block-inspector/useBlockInspectorAnimationSettings.js +53 -0
- package/src/components/block-list/block-invalid-warning.js +72 -64
- package/src/components/block-lock/modal.js +1 -0
- package/src/components/block-lock/style.scss +0 -9
- package/src/components/block-mobile-toolbar/test/__snapshots__/block-actions-menu.native.js.snap +20 -20
- package/src/components/block-mover/test/__snapshots__/index.native.js.snap +35 -17
- package/src/components/block-preview/test/index.js +0 -2
- package/src/components/block-settings-menu/block-settings-dropdown.js +4 -1
- package/src/components/block-settings-menu-controls/index.js +2 -1
- package/src/components/block-styles/index.js +5 -1
- package/src/components/block-styles/style.scss +2 -2
- package/src/components/block-switcher/block-transformations-menu.native.js +1 -0
- package/src/components/child-layout-control/index.js +106 -0
- package/src/components/color-palette/test/__snapshots__/control.js.snap +17 -15
- package/src/components/convert-to-group-buttons/use-convert-to-group-button-props.js +48 -38
- package/src/components/date-format-picker/index.js +6 -8
- package/src/components/date-format-picker/style.scss +0 -5
- package/src/components/global-styles/border-panel.js +285 -0
- package/src/components/global-styles/dimensions-panel.js +627 -0
- package/src/components/global-styles/hooks.js +160 -44
- package/src/components/global-styles/index.js +7 -1
- package/src/components/global-styles/test/use-global-styles-output.js +1 -1
- package/src/components/global-styles/typography-panel.js +81 -9
- package/src/components/global-styles/use-global-styles-output.js +17 -16
- package/src/components/global-styles/utils.js +2 -0
- package/src/components/index.native.js +5 -0
- package/src/components/inner-blocks/test/__snapshots__/index.js.snap +1 -1
- package/src/components/inserter/index.js +30 -11
- package/src/components/inserter/media-tab/hooks.js +9 -8
- package/src/components/inserter/media-tab/media-list.js +3 -122
- package/src/components/inserter/media-tab/media-preview.js +268 -0
- package/src/components/inserter/menu.js +0 -1
- package/src/components/inserter/quick-inserter.js +2 -0
- package/src/components/inserter/search-results.js +7 -1
- package/src/components/inserter/style.scss +25 -0
- package/src/components/inserter/tabs.js +1 -9
- package/src/components/inserter/test/__snapshots__/index.native.js.snap +15 -15
- package/src/components/inspector-controls/block-support-tools-panel.js +0 -1
- package/src/components/inspector-controls/fill.js +32 -8
- package/src/components/link-control/index.js +1 -1
- package/src/components/link-control/search-item.js +3 -1
- package/src/components/link-control/settings-drawer.js +2 -1
- package/src/components/link-control/settings.js +1 -0
- package/src/components/link-control/style.scss +18 -12
- package/src/components/link-control/test/index.js +3 -5
- package/src/components/list-view/block.js +19 -1
- package/src/components/list-view/branch.js +1 -2
- package/src/components/list-view/expander.js +1 -0
- package/src/components/list-view/leaf.js +43 -29
- package/src/components/list-view/use-block-selection.js +0 -2
- package/src/components/list-view/use-list-view-scroll-into-view.js +48 -0
- package/src/components/media-replace-flow/style.scss +7 -9
- package/src/components/off-canvas-editor/appender.js +44 -21
- package/src/components/off-canvas-editor/branch.js +4 -1
- package/src/components/off-canvas-editor/index.js +7 -1
- package/src/components/off-canvas-editor/leaf-more-menu.js +57 -15
- package/src/components/provider/use-block-sync.js +21 -4
- package/src/components/responsive-block-control/index.js +1 -0
- package/src/components/rich-text/format-toolbar-container.js +1 -7
- package/src/components/rich-text/index.js +8 -44
- package/src/components/rich-text/use-delete.js +59 -0
- package/src/components/rich-text/use-input-rules.js +13 -5
- package/src/components/spacing-sizes-control/style.scss +1 -1
- package/src/components/url-popover/stories/index.js +1 -0
- package/src/components/url-popover/test/index.js +0 -2
- package/src/components/writing-flow/use-selection-observer.js +5 -1
- package/src/hooks/align.js +1 -1
- package/src/hooks/border.js +94 -225
- package/src/hooks/custom-class-name.js +4 -4
- package/src/hooks/custom-class-name.native.js +3 -4
- package/src/hooks/dimensions.js +85 -269
- package/src/hooks/duotone.js +100 -30
- package/src/hooks/gap.js +0 -208
- package/src/hooks/layout.js +38 -22
- package/src/hooks/margin.js +1 -164
- package/src/hooks/padding.js +1 -163
- package/src/hooks/supports.js +6 -0
- package/src/hooks/test/__snapshots__/align.native.js.snap +24 -24
- package/src/hooks/test/duotone.js +102 -0
- package/src/hooks/test/style.js +2 -1
- package/src/hooks/test/use-typography-props.js +2 -0
- package/src/hooks/typography.js +68 -88
- package/src/hooks/utils.js +126 -0
- package/src/layouts/constrained.js +23 -17
- package/src/layouts/flex.js +1 -0
- package/src/private-apis.js +2 -0
- package/src/store/actions.js +16 -6
- package/src/store/defaults.js +14 -1
- package/src/store/reducer.js +68 -43
- package/src/store/selectors.js +28 -4
- package/src/store/test/actions.js +4 -2
- package/src/utils/parse-css-unit-to-px.js +48 -13
- package/src/utils/test/parse-css-unit-to-px.js +13 -2
- package/tsconfig.tsbuildinfo +1 -1
- package/build/hooks/border-radius.js +0 -100
- package/build/hooks/border-radius.js.map +0 -1
- package/build/hooks/child-layout.js +0 -213
- package/build/hooks/child-layout.js.map +0 -1
- package/build/hooks/min-height.js +0 -139
- package/build/hooks/min-height.js.map +0 -1
- package/build-module/hooks/border-radius.js +0 -84
- package/build-module/hooks/border-radius.js.map +0 -1
- package/build-module/hooks/child-layout.js +0 -193
- package/build-module/hooks/child-layout.js.map +0 -1
- package/build-module/hooks/min-height.js +0 -116
- package/build-module/hooks/min-height.js.map +0 -1
- package/src/hooks/border-radius.js +0 -70
- package/src/hooks/child-layout.js +0 -195
- package/src/hooks/min-height.js +0 -104
|
@@ -5,7 +5,7 @@ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefau
|
|
|
5
5
|
Object.defineProperty(exports, "__esModule", {
|
|
6
6
|
value: true
|
|
7
7
|
});
|
|
8
|
-
exports.default =
|
|
8
|
+
exports.default = void 0;
|
|
9
9
|
|
|
10
10
|
var _element = require("@wordpress/element");
|
|
11
11
|
|
|
@@ -17,6 +17,8 @@ var _classnames = _interopRequireDefault(require("classnames"));
|
|
|
17
17
|
|
|
18
18
|
var _components = require("@wordpress/components");
|
|
19
19
|
|
|
20
|
+
var _compose = require("@wordpress/compose");
|
|
21
|
+
|
|
20
22
|
var _useMovingAnimation = _interopRequireDefault(require("../use-moving-animation"));
|
|
21
23
|
|
|
22
24
|
/**
|
|
@@ -31,8 +33,7 @@ var _useMovingAnimation = _interopRequireDefault(require("../use-moving-animatio
|
|
|
31
33
|
* Internal dependencies
|
|
32
34
|
*/
|
|
33
35
|
const AnimatedTreeGridRow = (0, _web.animated)(_components.__experimentalTreeGridRow);
|
|
34
|
-
|
|
35
|
-
function ListViewLeaf(_ref) {
|
|
36
|
+
const ListViewLeaf = (0, _element.forwardRef)((_ref, ref) => {
|
|
36
37
|
let {
|
|
37
38
|
isSelected,
|
|
38
39
|
position,
|
|
@@ -43,18 +44,21 @@ function ListViewLeaf(_ref) {
|
|
|
43
44
|
path,
|
|
44
45
|
...props
|
|
45
46
|
} = _ref;
|
|
46
|
-
const
|
|
47
|
+
const animationRef = (0, _useMovingAnimation.default)({
|
|
47
48
|
isSelected,
|
|
48
49
|
adjustScrolling: false,
|
|
49
50
|
enableAnimation: true,
|
|
50
51
|
triggerAnimationOnChange: path
|
|
51
52
|
});
|
|
53
|
+
const mergedRef = (0, _compose.useMergeRefs)([ref, animationRef]);
|
|
52
54
|
return (0, _element.createElement)(AnimatedTreeGridRow, (0, _extends2.default)({
|
|
53
|
-
ref:
|
|
55
|
+
ref: mergedRef,
|
|
54
56
|
className: (0, _classnames.default)('block-editor-list-view-leaf', className),
|
|
55
57
|
level: level,
|
|
56
58
|
positionInSet: position,
|
|
57
59
|
setSize: rowCount
|
|
58
60
|
}, props), children);
|
|
59
|
-
}
|
|
61
|
+
});
|
|
62
|
+
var _default = ListViewLeaf;
|
|
63
|
+
exports.default = _default;
|
|
60
64
|
//# sourceMappingURL=leaf.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["@wordpress/block-editor/src/components/list-view/leaf.js"],"names":["AnimatedTreeGridRow","TreeGridRow","ListViewLeaf","isSelected","position","level","rowCount","children","className","path","props","
|
|
1
|
+
{"version":3,"sources":["@wordpress/block-editor/src/components/list-view/leaf.js"],"names":["AnimatedTreeGridRow","TreeGridRow","ListViewLeaf","ref","isSelected","position","level","rowCount","children","className","path","props","animationRef","adjustScrolling","enableAnimation","triggerAnimationOnChange","mergedRef"],"mappings":";;;;;;;;;AAWA;;;;AARA;;AACA;;AAKA;;AACA;;AAMA;;AAhBA;AACA;AACA;;AAIA;AACA;AACA;;AAKA;AACA;AACA;AAGA,MAAMA,mBAAmB,GAAG,mBAAUC,qCAAV,CAA5B;AAEA,MAAMC,YAAY,GAAG,yBACpB,OAWCC,GAXD,KAYK;AAAA,MAXJ;AACCC,IAAAA,UADD;AAECC,IAAAA,QAFD;AAGCC,IAAAA,KAHD;AAICC,IAAAA,QAJD;AAKCC,IAAAA,QALD;AAMCC,IAAAA,SAND;AAOCC,IAAAA,IAPD;AAQC,OAAGC;AARJ,GAWI;AACJ,QAAMC,YAAY,GAAG,iCAAoB;AACxCR,IAAAA,UADwC;AAExCS,IAAAA,eAAe,EAAE,KAFuB;AAGxCC,IAAAA,eAAe,EAAE,IAHuB;AAIxCC,IAAAA,wBAAwB,EAAEL;AAJc,GAApB,CAArB;AAOA,QAAMM,SAAS,GAAG,2BAAc,CAAEb,GAAF,EAAOS,YAAP,CAAd,CAAlB;AAEA,SACC,4BAAC,mBAAD;AACC,IAAA,GAAG,EAAGI,SADP;AAEC,IAAA,SAAS,EAAG,yBACX,6BADW,EAEXP,SAFW,CAFb;AAMC,IAAA,KAAK,EAAGH,KANT;AAOC,IAAA,aAAa,EAAGD,QAPjB;AAQC,IAAA,OAAO,EAAGE;AARX,KASMI,KATN,GAWGH,QAXH,CADD;AAeA,CAtCmB,CAArB;eAyCeN,Y","sourcesContent":["/**\n * External dependencies\n */\nimport { animated } from '@react-spring/web';\nimport classnames from 'classnames';\n\n/**\n * WordPress dependencies\n */\nimport { __experimentalTreeGridRow as TreeGridRow } from '@wordpress/components';\nimport { useMergeRefs } from '@wordpress/compose';\nimport { forwardRef } from '@wordpress/element';\n\n/**\n * Internal dependencies\n */\nimport useMovingAnimation from '../use-moving-animation';\n\nconst AnimatedTreeGridRow = animated( TreeGridRow );\n\nconst ListViewLeaf = forwardRef(\n\t(\n\t\t{\n\t\t\tisSelected,\n\t\t\tposition,\n\t\t\tlevel,\n\t\t\trowCount,\n\t\t\tchildren,\n\t\t\tclassName,\n\t\t\tpath,\n\t\t\t...props\n\t\t},\n\t\tref\n\t) => {\n\t\tconst animationRef = useMovingAnimation( {\n\t\t\tisSelected,\n\t\t\tadjustScrolling: false,\n\t\t\tenableAnimation: true,\n\t\t\ttriggerAnimationOnChange: path,\n\t\t} );\n\n\t\tconst mergedRef = useMergeRefs( [ ref, animationRef ] );\n\n\t\treturn (\n\t\t\t<AnimatedTreeGridRow\n\t\t\t\tref={ mergedRef }\n\t\t\t\tclassName={ classnames(\n\t\t\t\t\t'block-editor-list-view-leaf',\n\t\t\t\t\tclassName\n\t\t\t\t) }\n\t\t\t\tlevel={ level }\n\t\t\t\tpositionInSet={ position }\n\t\t\t\tsetSize={ rowCount }\n\t\t\t\t{ ...props }\n\t\t\t>\n\t\t\t\t{ children }\n\t\t\t</AnimatedTreeGridRow>\n\t\t);\n\t}\n);\n\nexport default ListViewLeaf;\n"]}
|
|
@@ -38,7 +38,6 @@ function useBlockSelection() {
|
|
|
38
38
|
getBlockName,
|
|
39
39
|
getBlockParents,
|
|
40
40
|
getBlockSelectionStart,
|
|
41
|
-
getBlockSelectionEnd,
|
|
42
41
|
getSelectedBlockClientIds,
|
|
43
42
|
hasMultiSelection,
|
|
44
43
|
hasSelectedBlock
|
|
@@ -131,7 +130,7 @@ function useBlockSelection() {
|
|
|
131
130
|
if (label) {
|
|
132
131
|
(0, _a11y.speak)(label);
|
|
133
132
|
}
|
|
134
|
-
}, [clearSelectedBlock, getBlockName, getBlockType, getBlockParents, getBlockSelectionStart,
|
|
133
|
+
}, [clearSelectedBlock, getBlockName, getBlockType, getBlockParents, getBlockSelectionStart, getSelectedBlockClientIds, hasMultiSelection, hasSelectedBlock, multiSelect, selectBlock]);
|
|
135
134
|
return {
|
|
136
135
|
updateBlockSelection
|
|
137
136
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["@wordpress/block-editor/src/components/list-view/use-block-selection.js"],"names":["useBlockSelection","clearSelectedBlock","multiSelect","selectBlock","blockEditorStore","getBlockName","getBlockParents","getBlockSelectionStart","
|
|
1
|
+
{"version":3,"sources":["@wordpress/block-editor/src/components/list-view/use-block-selection.js"],"names":["useBlockSelection","clearSelectedBlock","multiSelect","selectBlock","blockEditorStore","getBlockName","getBlockParents","getBlockSelectionStart","getSelectedBlockClientIds","hasMultiSelection","hasSelectedBlock","getBlockType","blocksStore","updateBlockSelection","event","clientId","destinationClientId","shiftKey","preventDefault","isKeyPress","type","keyCode","UP","DOWN","HOME","END","selectedBlocks","clientIdWithParents","some","blockId","includes","startTarget","endTarget","startParents","endParents","start","end","updatedSelectedBlocks","length","selectionDiff","filter","label","title"],"mappings":";;;;;;;AAGA;;AACA;;AACA;;AACA;;AACA;;AACA;;AAKA;;AACA;;AAdA;AACA;AACA;;AAQA;AACA;AACA;AAIe,SAASA,iBAAT,GAA6B;AAC3C,QAAM;AAAEC,IAAAA,kBAAF;AAAsBC,IAAAA,WAAtB;AAAmCC,IAAAA;AAAnC,MACL,uBAAaC,YAAb,CADD;AAEA,QAAM;AACLC,IAAAA,YADK;AAELC,IAAAA,eAFK;AAGLC,IAAAA,sBAHK;AAILC,IAAAA,yBAJK;AAKLC,IAAAA,iBALK;AAMLC,IAAAA;AANK,MAOF,qBAAWN,YAAX,CAPJ;AASA,QAAM;AAAEO,IAAAA;AAAF,MAAmB,qBAAWC,aAAX,CAAzB;AAEA,QAA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AACD,GAtH2B,EAuH5B,CACCxC,kBADD,EAECI,YAFD,EAGCM,YAHD,EAICL,eAJD,EAKCC,sBALD,EAMCC,yBAND,EAOCC,iBAPD,EAQCC,gBARD,EASCR,WATD,EAUCC,WAVD,CAvH4B,CAA7B;AAqIA,SAAO;AACNU,IAAAA;AADM,GAAP;AAGA","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { speak } from '@wordpress/a11y';\nimport { __, sprintf } from '@wordpress/i18n';\nimport { useDispatch, useSelect } from '@wordpress/data';\nimport { useCallback } from '@wordpress/element';\nimport { UP, DOWN, HOME, END } from '@wordpress/keycodes';\nimport { store as blocksStore } from '@wordpress/blocks';\n\n/**\n * Internal dependencies\n */\nimport { store as blockEditorStore } from '../../store';\nimport { getCommonDepthClientIds } from './utils';\n\nexport default function useBlockSelection() {\n\tconst { clearSelectedBlock, multiSelect, selectBlock } =\n\t\tuseDispatch( blockEditorStore );\n\tconst {\n\t\tgetBlockName,\n\t\tgetBlockParents,\n\t\tgetBlockSelectionStart,\n\t\tgetSelectedBlockClientIds,\n\t\thasMultiSelection,\n\t\thasSelectedBlock,\n\t} = useSelect( blockEditorStore );\n\n\tconst { getBlockType } = useSelect( blocksStore );\n\n\tconst updateBlockSelection = useCallback(\n\t\tasync ( event, clientId, destinationClientId ) => {\n\t\t\tif ( ! event?.shiftKey ) {\n\t\t\t\tselectBlock( clientId );\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\t// To handle multiple block selection via the `SHIFT` key, prevent\n\t\t\t// the browser default behavior of opening the link in a new window.\n\t\t\tevent.preventDefault();\n\n\t\t\tconst isKeyPress =\n\t\t\t\tevent.type === 'keydown' &&\n\t\t\t\t( event.keyCode === UP ||\n\t\t\t\t\tevent.keyCode === DOWN ||\n\t\t\t\t\tevent.keyCode === HOME ||\n\t\t\t\t\tevent.keyCode === END );\n\n\t\t\t// Handle clicking on a block when no blocks are selected, and return early.\n\t\t\tif (\n\t\t\t\t! isKeyPress &&\n\t\t\t\t! hasSelectedBlock() &&\n\t\t\t\t! hasMultiSelection()\n\t\t\t) {\n\t\t\t\tselectBlock( clientId, null );\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tconst selectedBlocks = getSelectedBlockClientIds();\n\t\t\tconst clientIdWithParents = [\n\t\t\t\t...getBlockParents( clientId ),\n\t\t\t\tclientId,\n\t\t\t];\n\n\t\t\tif (\n\t\t\t\tisKeyPress &&\n\t\t\t\t! selectedBlocks.some( ( blockId ) =>\n\t\t\t\t\tclientIdWithParents.includes( blockId )\n\t\t\t\t)\n\t\t\t) {\n\t\t\t\t// Ensure that shift-selecting blocks via the keyboard only\n\t\t\t\t// expands the current selection if focusing over already\n\t\t\t\t// selected blocks. Otherwise, clear the selection so that\n\t\t\t\t// a user can create a new selection entirely by keyboard.\n\t\t\t\tawait clearSelectedBlock();\n\t\t\t}\n\n\t\t\tlet startTarget = getBlockSelectionStart();\n\t\t\tlet endTarget = clientId;\n\n\t\t\t// Handle keyboard behavior for selecting multiple blocks.\n\t\t\tif ( isKeyPress ) {\n\t\t\t\tif ( ! hasSelectedBlock() && ! hasMultiSelection() ) {\n\t\t\t\t\t// Set the starting point of the selection to the currently\n\t\t\t\t\t// focused block, if there are no blocks currently selected.\n\t\t\t\t\t// This ensures that as the selection is expanded or contracted,\n\t\t\t\t\t// the starting point of the selection is anchored to that block.\n\t\t\t\t\tstartTarget = clientId;\n\t\t\t\t}\n\t\t\t\tif ( destinationClientId ) {\n\t\t\t\t\t// If the user presses UP or DOWN, we want to ensure that the block they're\n\t\t\t\t\t// moving to is the target for selection, and not the currently focused one.\n\t\t\t\t\tendTarget = destinationClientId;\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tconst startParents = getBlockParents( startTarget );\n\t\t\tconst endParents = getBlockParents( endTarget );\n\n\t\t\tconst { start, end } = getCommonDepthClientIds(\n\t\t\t\tstartTarget,\n\t\t\t\tendTarget,\n\t\t\t\tstartParents,\n\t\t\t\tendParents\n\t\t\t);\n\t\t\tawait multiSelect( start, end, null );\n\n\t\t\t// Announce deselected block, or number of deselected blocks if\n\t\t\t// the total number of blocks deselected is greater than one.\n\t\t\tconst updatedSelectedBlocks = getSelectedBlockClientIds();\n\n\t\t\t// If the selection is greater than 1 and the Home or End keys\n\t\t\t// were used to generate the selection, then skip announcing the\n\t\t\t// deselected blocks.\n\t\t\tif (\n\t\t\t\t( event.keyCode === HOME || event.keyCode === END ) &&\n\t\t\t\tupdatedSelectedBlocks.length > 1\n\t\t\t) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tconst selectionDiff = selectedBlocks.filter(\n\t\t\t\t( blockId ) => ! updatedSelectedBlocks.includes( blockId )\n\t\t\t);\n\n\t\t\tlet label;\n\t\t\tif ( selectionDiff.length === 1 ) {\n\t\t\t\tconst title = getBlockType(\n\t\t\t\t\tgetBlockName( selectionDiff[ 0 ] )\n\t\t\t\t)?.title;\n\t\t\t\tif ( title ) {\n\t\t\t\t\tlabel = sprintf(\n\t\t\t\t\t\t/* translators: %s: block name */\n\t\t\t\t\t\t__( '%s deselected.' ),\n\t\t\t\t\t\ttitle\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t} else if ( selectionDiff.length > 1 ) {\n\t\t\t\tlabel = sprintf(\n\t\t\t\t\t/* translators: %s: number of deselected blocks */\n\t\t\t\t\t__( '%s blocks deselected.' ),\n\t\t\t\t\tselectionDiff.length\n\t\t\t\t);\n\t\t\t}\n\n\t\t\tif ( label ) {\n\t\t\t\tspeak( label );\n\t\t\t}\n\t\t},\n\t\t[\n\t\t\tclearSelectedBlock,\n\t\t\tgetBlockName,\n\t\t\tgetBlockType,\n\t\t\tgetBlockParents,\n\t\t\tgetBlockSelectionStart,\n\t\t\tgetSelectedBlockClientIds,\n\t\t\thasMultiSelection,\n\t\t\thasSelectedBlock,\n\t\t\tmultiSelect,\n\t\t\tselectBlock,\n\t\t]\n\t);\n\n\treturn {\n\t\tupdateBlockSelection,\n\t};\n}\n"]}
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.default = useListViewScrollIntoView;
|
|
7
|
+
|
|
8
|
+
var _dom = require("@wordpress/dom");
|
|
9
|
+
|
|
10
|
+
var _element = require("@wordpress/element");
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* WordPress dependencies
|
|
14
|
+
*/
|
|
15
|
+
function useListViewScrollIntoView(_ref) {
|
|
16
|
+
let {
|
|
17
|
+
isSelected,
|
|
18
|
+
selectedClientIds,
|
|
19
|
+
rowItemRef
|
|
20
|
+
} = _ref;
|
|
21
|
+
const isSingleSelection = selectedClientIds.length === 1;
|
|
22
|
+
(0, _element.useLayoutEffect)(() => {
|
|
23
|
+
// Skip scrolling into view if this particular block isn't selected,
|
|
24
|
+
// or if more than one block is selected overall. This is to avoid
|
|
25
|
+
// scrolling the view in a multi selection where the user has intentionally
|
|
26
|
+
// selected multiple blocks within the list view, but the initially
|
|
27
|
+
// selected block may be out of view.
|
|
28
|
+
if (!isSelected || !isSingleSelection || !rowItemRef.current) {
|
|
29
|
+
return;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
const scrollContainer = (0, _dom.getScrollContainer)(rowItemRef.current);
|
|
33
|
+
const {
|
|
34
|
+
ownerDocument
|
|
35
|
+
} = rowItemRef.current;
|
|
36
|
+
const windowScroll = scrollContainer === ownerDocument.body || scrollContainer === ownerDocument.documentElement; // If the there is no scroll container, of if the scroll container is the window,
|
|
37
|
+
// do not scroll into view, as the block is already in view.
|
|
38
|
+
|
|
39
|
+
if (windowScroll || !scrollContainer) {
|
|
40
|
+
return;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
const rowRect = rowItemRef.current.getBoundingClientRect();
|
|
44
|
+
const scrollContainerRect = scrollContainer.getBoundingClientRect(); // If the selected block is not currently visible, scroll to it.
|
|
45
|
+
|
|
46
|
+
if (rowRect.top < scrollContainerRect.top || rowRect.bottom > scrollContainerRect.bottom) {
|
|
47
|
+
rowItemRef.current.scrollIntoView();
|
|
48
|
+
}
|
|
49
|
+
}, [isSelected, isSingleSelection, rowItemRef]);
|
|
50
|
+
}
|
|
51
|
+
//# sourceMappingURL=use-list-view-scroll-into-view.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["@wordpress/block-editor/src/components/list-view/use-list-view-scroll-into-view.js"],"names":["useListViewScrollIntoView","isSelected","selectedClientIds","rowItemRef","isSingleSelection","length","current","scrollContainer","ownerDocument","windowScroll","body","documentElement","rowRect","getBoundingClientRect","scrollContainerRect","top","bottom","scrollIntoView"],"mappings":";;;;;;;AAGA;;AACA;;AAJA;AACA;AACA;AAIe,SAASA,yBAAT,OAIX;AAAA,MAJ+C;AAClDC,IAAAA,UADkD;AAElDC,IAAAA,iBAFkD;AAGlDC,IAAAA;AAHkD,GAI/C;AACH,QAAMC,iBAAiB,GAAGF,iBAAiB,CAACG,MAAlB,KAA6B,CAAvD;AAEA,gCAAiB,MAAM;AACtB;AACA;AACA;AACA;AACA;AACA,QAAK,CAAEJ,UAAF,IAAgB,CAAEG,iBAAlB,IAAuC,CAAED,UAAU,CAACG,OAAzD,EAAmE;AAClE;AACA;;AAED,UAAMC,eAAe,GAAG,6BAAoBJ,UAAU,CAACG,OAA/B,CAAxB;AACA,UAAM;AAAEE,MAAAA;AAAF,QAAoBL,UAAU,CAACG,OAArC;AAEA,UAAMG,YAAY,GACjBF,eAAe,KAAKC,aAAa,CAACE,IAAlC,IACAH,eAAe,KAAKC,aAAa,CAACG,eAFnC,CAbsB,CAiBtB;AACA;;AACA,QAAKF,YAAY,IAAI,CAAEF,eAAvB,EAAyC;AACxC;AACA;;AAED,UAAMK,OAAO,GAAGT,UAAU,CAACG,OAAX,CAAmBO,qBAAnB,EAAhB;AACA,UAAMC,mBAAmB,GAAGP,eAAe,CAACM,qBAAhB,EAA5B,CAxBsB,CA0BtB;;AACA,QACCD,OAAO,CAACG,GAAR,GAAcD,mBAAmB,CAACC,GAAlC,IACAH,OAAO,CAACI,MAAR,GAAiBF,mBAAmB,CAACE,MAFtC,EAGE;AACDb,MAAAA,UAAU,CAACG,OAAX,CAAmBW,cAAnB;AACA;AACD,GAjCD,EAiCG,CAAEhB,UAAF,EAAcG,iBAAd,EAAiCD,UAAjC,CAjCH;AAkCA","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { getScrollContainer } from '@wordpress/dom';\nimport { useLayoutEffect } from '@wordpress/element';\n\nexport default function useListViewScrollIntoView( {\n\tisSelected,\n\tselectedClientIds,\n\trowItemRef,\n} ) {\n\tconst isSingleSelection = selectedClientIds.length === 1;\n\n\tuseLayoutEffect( () => {\n\t\t// Skip scrolling into view if this particular block isn't selected,\n\t\t// or if more than one block is selected overall. This is to avoid\n\t\t// scrolling the view in a multi selection where the user has intentionally\n\t\t// selected multiple blocks within the list view, but the initially\n\t\t// selected block may be out of view.\n\t\tif ( ! isSelected || ! isSingleSelection || ! rowItemRef.current ) {\n\t\t\treturn;\n\t\t}\n\n\t\tconst scrollContainer = getScrollContainer( rowItemRef.current );\n\t\tconst { ownerDocument } = rowItemRef.current;\n\n\t\tconst windowScroll =\n\t\t\tscrollContainer === ownerDocument.body ||\n\t\t\tscrollContainer === ownerDocument.documentElement;\n\n\t\t// If the there is no scroll container, of if the scroll container is the window,\n\t\t// do not scroll into view, as the block is already in view.\n\t\tif ( windowScroll || ! scrollContainer ) {\n\t\t\treturn;\n\t\t}\n\n\t\tconst rowRect = rowItemRef.current.getBoundingClientRect();\n\t\tconst scrollContainerRect = scrollContainer.getBoundingClientRect();\n\n\t\t// If the selected block is not currently visible, scroll to it.\n\t\tif (\n\t\t\trowRect.top < scrollContainerRect.top ||\n\t\t\trowRect.bottom > scrollContainerRect.bottom\n\t\t) {\n\t\t\trowItemRef.current.scrollIntoView();\n\t\t}\n\t}, [ isSelected, isSingleSelection, rowItemRef ] );\n}\n"]}
|
|
@@ -23,7 +23,9 @@ var _store = require("../../store");
|
|
|
23
23
|
|
|
24
24
|
var _useBlockDisplayTitle = _interopRequireDefault(require("../block-title/use-block-display-title"));
|
|
25
25
|
|
|
26
|
-
var
|
|
26
|
+
var _lockUnlock = require("../../lock-unlock");
|
|
27
|
+
|
|
28
|
+
var _privateApis = require("../../private-apis");
|
|
27
29
|
|
|
28
30
|
/**
|
|
29
31
|
* WordPress dependencies
|
|
@@ -32,31 +34,27 @@ var _inserter = _interopRequireDefault(require("../inserter"));
|
|
|
32
34
|
/**
|
|
33
35
|
* Internal dependencies
|
|
34
36
|
*/
|
|
37
|
+
const prioritizedInserterBlocks = ['core/navigation-link/page', 'core/navigation-link'];
|
|
35
38
|
const Appender = (0, _element.forwardRef)((_ref, ref) => {
|
|
36
39
|
let {
|
|
37
40
|
nestingLevel,
|
|
38
41
|
blockCount,
|
|
42
|
+
clientId,
|
|
39
43
|
...props
|
|
40
44
|
} = _ref;
|
|
41
45
|
const [insertedBlock, setInsertedBlock] = (0, _element.useState)(null);
|
|
42
46
|
const instanceId = (0, _compose.useInstanceId)(Appender);
|
|
43
47
|
const {
|
|
44
|
-
hideInserter
|
|
45
|
-
clientId
|
|
48
|
+
hideInserter
|
|
46
49
|
} = (0, _data.useSelect)(select => {
|
|
47
50
|
const {
|
|
48
51
|
getTemplateLock,
|
|
49
|
-
__unstableGetEditorMode
|
|
50
|
-
getSelectedBlockClientId
|
|
52
|
+
__unstableGetEditorMode
|
|
51
53
|
} = select(_store.store);
|
|
52
|
-
|
|
53
|
-
const _clientId = getSelectedBlockClientId();
|
|
54
|
-
|
|
55
54
|
return {
|
|
56
|
-
|
|
57
|
-
hideInserter: !!getTemplateLock(_clientId) || __unstableGetEditorMode() === 'zoom-out'
|
|
55
|
+
hideInserter: !!getTemplateLock(clientId) || __unstableGetEditorMode() === 'zoom-out'
|
|
58
56
|
};
|
|
59
|
-
}, []);
|
|
57
|
+
}, [clientId]);
|
|
60
58
|
const blockTitle = (0, _useBlockDisplayTitle.default)({
|
|
61
59
|
clientId,
|
|
62
60
|
context: 'list-view'
|
|
@@ -73,18 +71,39 @@ const Appender = (0, _element.forwardRef)((_ref, ref) => {
|
|
|
73
71
|
(0, _a11y.speak)((0, _i18n.sprintf)( // translators: %s: name of block being inserted (i.e. Paragraph, Image, Group etc)
|
|
74
72
|
(0, _i18n.__)('%s block inserted'), insertedBlockTitle), 'assertive');
|
|
75
73
|
}, [insertedBlockTitle]);
|
|
74
|
+
const orderInitialBlockItems = (0, _element.useCallback)(items => {
|
|
75
|
+
items.sort((_ref2, _ref3) => {
|
|
76
|
+
let {
|
|
77
|
+
id: aName
|
|
78
|
+
} = _ref2;
|
|
79
|
+
let {
|
|
80
|
+
id: bName
|
|
81
|
+
} = _ref3;
|
|
82
|
+
// Sort block items according to `prioritizedInserterBlocks`.
|
|
83
|
+
let aIndex = prioritizedInserterBlocks.indexOf(aName);
|
|
84
|
+
let bIndex = prioritizedInserterBlocks.indexOf(bName); // All other block items should come after that.
|
|
85
|
+
|
|
86
|
+
if (aIndex < 0) aIndex = prioritizedInserterBlocks.length;
|
|
87
|
+
if (bIndex < 0) bIndex = prioritizedInserterBlocks.length;
|
|
88
|
+
return aIndex - bIndex;
|
|
89
|
+
});
|
|
90
|
+
return items;
|
|
91
|
+
}, []);
|
|
76
92
|
|
|
77
93
|
if (hideInserter) {
|
|
78
94
|
return null;
|
|
79
95
|
}
|
|
80
96
|
|
|
97
|
+
const {
|
|
98
|
+
PrivateInserter
|
|
99
|
+
} = (0, _lockUnlock.unlock)(_privateApis.privateApis);
|
|
81
100
|
const descriptionId = `off-canvas-editor-appender__${instanceId}`;
|
|
82
101
|
const description = (0, _i18n.sprintf)(
|
|
83
102
|
/* translators: 1: The name of the block. 2: The numerical position of the block. 3: The level of nesting for the block. */
|
|
84
103
|
(0, _i18n.__)('Append to %1$s block at position %2$d, Level %3$d'), blockTitle, blockCount + 1, nestingLevel);
|
|
85
104
|
return (0, _element.createElement)("div", {
|
|
86
105
|
className: "offcanvas-editor-appender"
|
|
87
|
-
}, (0, _element.createElement)(
|
|
106
|
+
}, (0, _element.createElement)(PrivateInserter, (0, _extends2.default)({
|
|
88
107
|
ref: ref,
|
|
89
108
|
rootClientId: clientId,
|
|
90
109
|
position: "bottom right",
|
|
@@ -100,7 +119,8 @@ const Appender = (0, _element.forwardRef)((_ref, ref) => {
|
|
|
100
119
|
if (maybeInsertedBlock !== null && maybeInsertedBlock !== void 0 && maybeInsertedBlock.clientId) {
|
|
101
120
|
setInsertedBlock(maybeInsertedBlock);
|
|
102
121
|
}
|
|
103
|
-
}
|
|
122
|
+
},
|
|
123
|
+
orderInitialBlockItems: orderInitialBlockItems
|
|
104
124
|
})), (0, _element.createElement)("div", {
|
|
105
125
|
className: "offcanvas-editor-appender__description",
|
|
106
126
|
id: descriptionId
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["@wordpress/block-editor/src/components/off-canvas-editor/appender.js"],"names":["Appender","ref","nestingLevel","blockCount","props","insertedBlock","setInsertedBlock","instanceId","hideInserter","
|
|
1
|
+
{"version":3,"sources":["@wordpress/block-editor/src/components/off-canvas-editor/appender.js"],"names":["prioritizedInserterBlocks","Appender","ref","nestingLevel","blockCount","clientId","props","insertedBlock","setInsertedBlock","instanceId","hideInserter","select","getTemplateLock","__unstableGetEditorMode","blockEditorStore","blockTitle","context","insertedBlockTitle","length","orderInitialBlockItems","items","sort","id","aName","bName","aIndex","indexOf","bIndex","PrivateInserter","blockEditorPrivateApis","descriptionId","description","maybeInsertedBlock"],"mappings":";;;;;;;;;AAMA;;;;AAHA;;AACA;;AACA;;AAOA;;AAKA;;AACA;;AAEA;;AACA;;AArBA;AACA;AACA;;AAYA;AACA;AACA;AAOA,MAAMA,yBAAyB,GAAG,CACjC,2BADiC,EAEjC,sBAFiC,CAAlC;AAKO,MAAMC,QAAQ,GAAG,yBACvB,OAAoDC,GAApD,KAA6D;AAAA,MAA3D;AAAEC,IAAAA,YAAF;AAAgBC,IA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AAA,EAAE,EAAGW;AAFN,KAIGC,WAJH,CAlBD,CADD;AA2BA,CAjGsB,CAAjB","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { useInstanceId } from '@wordpress/compose';\nimport { speak } from '@wordpress/a11y';\nimport { useSelect } from '@wordpress/data';\nimport {\n\tforwardRef,\n\tuseState,\n\tuseEffect,\n\tuseCallback,\n} from '@wordpress/element';\nimport { __, sprintf } from '@wordpress/i18n';\n\n/**\n * Internal dependencies\n */\nimport { store as blockEditorStore } from '../../store';\nimport useBlockDisplayTitle from '../block-title/use-block-display-title';\n\nimport { unlock } from '../../lock-unlock';\nimport { privateApis as blockEditorPrivateApis } from '../../private-apis';\n\nconst prioritizedInserterBlocks = [\n\t'core/navigation-link/page',\n\t'core/navigation-link',\n];\n\nexport const Appender = forwardRef(\n\t( { nestingLevel, blockCount, clientId, ...props }, ref ) => {\n\t\tconst [ insertedBlock, setInsertedBlock ] = useState( null );\n\n\t\tconst instanceId = useInstanceId( Appender );\n\t\tconst { hideInserter } = useSelect(\n\t\t\t( select ) => {\n\t\t\t\tconst { getTemplateLock, __unstableGetEditorMode } =\n\t\t\t\t\tselect( blockEditorStore );\n\n\t\t\t\treturn {\n\t\t\t\t\thideInserter:\n\t\t\t\t\t\t!! getTemplateLock( clientId ) ||\n\t\t\t\t\t\t__unstableGetEditorMode() === 'zoom-out',\n\t\t\t\t};\n\t\t\t},\n\t\t\t[ clientId ]\n\t\t);\n\n\t\tconst blockTitle = useBlockDisplayTitle( {\n\t\t\tclientId,\n\t\t\tcontext: 'list-view',\n\t\t} );\n\n\t\tconst insertedBlockTitle = useBlockDisplayTitle( {\n\t\t\tclientId: insertedBlock?.clientId,\n\t\t\tcontext: 'list-view',\n\t\t} );\n\n\t\tuseEffect( () => {\n\t\t\tif ( ! insertedBlockTitle?.length ) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tspeak(\n\t\t\t\tsprintf(\n\t\t\t\t\t// translators: %s: name of block being inserted (i.e. Paragraph, Image, Group etc)\n\t\t\t\t\t__( '%s block inserted' ),\n\t\t\t\t\tinsertedBlockTitle\n\t\t\t\t),\n\t\t\t\t'assertive'\n\t\t\t);\n\t\t}, [ insertedBlockTitle ] );\n\n\t\tconst orderInitialBlockItems = useCallback( ( items ) => {\n\t\t\titems.sort( ( { id: aName }, { id: bName } ) => {\n\t\t\t\t// Sort block items according to `prioritizedInserterBlocks`.\n\t\t\t\tlet aIndex = prioritizedInserterBlocks.indexOf( aName );\n\t\t\t\tlet bIndex = prioritizedInserterBlocks.indexOf( bName );\n\t\t\t\t// All other block items should come after that.\n\t\t\t\tif ( aIndex < 0 ) aIndex = prioritizedInserterBlocks.length;\n\t\t\t\tif ( bIndex < 0 ) bIndex = prioritizedInserterBlocks.length;\n\t\t\t\treturn aIndex - bIndex;\n\t\t\t} );\n\t\t\treturn items;\n\t\t}, [] );\n\n\t\tif ( hideInserter ) {\n\t\t\treturn null;\n\t\t}\n\t\tconst { PrivateInserter } = unlock( blockEditorPrivateApis );\n\t\tconst descriptionId = `off-canvas-editor-appender__${ instanceId }`;\n\t\tconst description = sprintf(\n\t\t\t/* translators: 1: The name of the block. 2: The numerical position of the block. 3: The level of nesting for the block. */\n\t\t\t__( 'Append to %1$s block at position %2$d, Level %3$d' ),\n\t\t\tblockTitle,\n\t\t\tblockCount + 1,\n\t\t\tnestingLevel\n\t\t);\n\n\t\treturn (\n\t\t\t<div className=\"offcanvas-editor-appender\">\n\t\t\t\t<PrivateInserter\n\t\t\t\t\tref={ ref }\n\t\t\t\t\trootClientId={ clientId }\n\t\t\t\t\tposition=\"bottom right\"\n\t\t\t\t\tisAppender\n\t\t\t\t\tselectBlockOnInsert={ false }\n\t\t\t\t\tshouldDirectInsert={ false }\n\t\t\t\t\t__experimentalIsQuick\n\t\t\t\t\t{ ...props }\n\t\t\t\t\ttoggleProps={ { 'aria-describedby': descriptionId } }\n\t\t\t\t\tonSelectOrClose={ ( maybeInsertedBlock ) => {\n\t\t\t\t\t\tif ( maybeInsertedBlock?.clientId ) {\n\t\t\t\t\t\t\tsetInsertedBlock( maybeInsertedBlock );\n\t\t\t\t\t\t}\n\t\t\t\t\t} }\n\t\t\t\t\torderInitialBlockItems={ orderInitialBlockItems }\n\t\t\t\t/>\n\t\t\t\t<div\n\t\t\t\t\tclassName=\"offcanvas-editor-appender__description\"\n\t\t\t\t\tid={ descriptionId }\n\t\t\t\t>\n\t\t\t\t\t{ description }\n\t\t\t\t</div>\n\t\t\t</div>\n\t\t);\n\t}\n);\n"]}
|
|
@@ -97,7 +97,8 @@ function ListViewBranch(props) {
|
|
|
97
97
|
fixedListWindow,
|
|
98
98
|
isExpanded,
|
|
99
99
|
parentId,
|
|
100
|
-
shouldShowInnerBlocks = true
|
|
100
|
+
shouldShowInnerBlocks = true,
|
|
101
|
+
showAppender: showAppenderProp = true
|
|
101
102
|
} = props;
|
|
102
103
|
const isContentLocked = (0, _data.useSelect)(select => {
|
|
103
104
|
return !!(parentId && select(_store.store).getTemplateLock(parentId) === 'contentOnly');
|
|
@@ -112,7 +113,7 @@ function ListViewBranch(props) {
|
|
|
112
113
|
} // Only show the appender at the first level.
|
|
113
114
|
|
|
114
115
|
|
|
115
|
-
const showAppender = level === 1;
|
|
116
|
+
const showAppender = showAppenderProp && level === 1;
|
|
116
117
|
const filteredBlocks = blocks.filter(Boolean);
|
|
117
118
|
const blockCount = filteredBlocks.length; // The appender means an extra row in List View, so add 1 to the row count.
|
|
118
119
|
|
|
@@ -175,7 +176,8 @@ function ListViewBranch(props) {
|
|
|
175
176
|
fixedListWindow: fixedListWindow,
|
|
176
177
|
isBranchSelected: isSelectedBranch,
|
|
177
178
|
selectedClientIds: selectedClientIds,
|
|
178
|
-
isExpanded: isExpanded
|
|
179
|
+
isExpanded: isExpanded,
|
|
180
|
+
showAppender: showAppenderProp
|
|
179
181
|
}));
|
|
180
182
|
}), showAppender && (0, _element.createElement)(_components.__experimentalTreeGridRow, {
|
|
181
183
|
level: level,
|
|
@@ -183,6 +185,7 @@ function ListViewBranch(props) {
|
|
|
183
185
|
positionInSet: rowCount,
|
|
184
186
|
isExpanded: true
|
|
185
187
|
}, (0, _element.createElement)(_components.__experimentalTreeGridCell, null, treeGridCellProps => (0, _element.createElement)(_appender.Appender, (0, _extends2.default)({
|
|
188
|
+
clientId: parentId,
|
|
186
189
|
nestingLevel: level,
|
|
187
190
|
blockCount: blockCount
|
|
188
191
|
}, treeGridCellProps)))));
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["@wordpress/block-editor/src/components/off-canvas-editor/branch.js"],"names":["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","isContentLocked","select","blockEditorStore","getTemplateLock","showAppender","filteredBlocks","filter","Boolean","blockCount","rowCount","nextPosition","map","index","itemInView","blockInView","position","updatedPath","hasNestedBlocks","shouldExpand","undefined","showBlock","isSelected","isSelectedBranch","treeGridCellProps"],"mappings":";;;;;;;;;AAQA;;;;AALA;;AAIA;;AAOA;;AACA;;AACA;;AACA;;AACA;;AAlBA;AACA;AACA;;AAQA;AACA;AACA;;AAQA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,SAASA,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,4BAAGN,aAAa,CAAED,KAAK,CAACM,QAAR,CAAhB,yEAAsCH,mBAAtD;;AAEA,MAAKI,UAAL,EAAkB;AACjB,WACC,I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AEC,MAAA,MAAM,EAAGE,WAFV;AAGC,MAAA,WAAW,EAAGS,WAHf;AAIC,MAAA,eAAe,EAAGC,eAJnB;AAKC,MAAA,KAAK,EAAGE,KAAK,GAAG,CALjB;AAMC,MAAA,IAAI,EAAGuB,WANR;AAOC,MAAA,YAAY,EAAGN,YAAY,GAAG,CAP/B;AAQC,MAAA,eAAe,EAAGb,eARnB;AASC,MAAA,gBAAgB,EAAGyB,gBATpB;AAUC,MAAA,iBAAiB,EAAG9B,iBAVrB;AAWC,MAAA,UAAU,EAAGZ;AAXd,MAzBF,CADD;AA0CA,GAjFC,CADH,EAmFGwB,YAAY,IACb,4BAAC,qCAAD;AACC,IAAA,KAAK,EAAGX,KADT;AAEC,IAAA,OAAO,EAAGgB,QAFX;AAGC,IAAA,aAAa,EAAGA,QAHjB;AAIC,IAAA,UAAU,EAAG;AAJd,KAMC,4BAAC,sCAAD,QACKc,iBAAF,IACD,4BAAC,kBAAD;AACC,IAAA,YAAY,EAAG9B,KADhB;AAEC,IAAA,UAAU,EAAGe;AAFd,KAGMe,iBAHN,EAFF,CAND,CApFF,CADD;AAwGA;;eAEc,mBAAMpC,cAAN,C","sourcesContent":["/**\n * WordPress dependencies\n */\nimport {\n\t__experimentalTreeGridRow as TreeGridRow,\n\t__experimentalTreeGridCell as TreeGridCell,\n} from '@wordpress/components';\nimport { AsyncModeProvider, useSelect } from '@wordpress/data';\nimport { memo } from '@wordpress/element';\n\n/**\n * Internal dependencies\n */\n\nimport { Appender } from './appender';\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} = 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\t// Only show the appender at the first level.\n\tconst showAppender = level === 1;\n\n\tconst filteredBlocks = blocks.filter( Boolean );\n\tconst blockCount = filteredBlocks.length;\n\n\t// The appender means an extra row in List View, so add 1 to the row count.\n\tconst rowCount = showAppender ? blockCount + 1 : blockCount;\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={ rowCount }\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/>\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/>\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\t{ showAppender && (\n\t\t\t\t<TreeGridRow\n\t\t\t\t\tlevel={ level }\n\t\t\t\t\tsetSize={ rowCount }\n\t\t\t\t\tpositionInSet={ rowCount }\n\t\t\t\t\tisExpanded={ true }\n\t\t\t\t>\n\t\t\t\t\t<TreeGridCell>\n\t\t\t\t\t\t{ ( treeGridCellProps ) => (\n\t\t\t\t\t\t\t<Appender\n\t\t\t\t\t\t\t\tnestingLevel={ level }\n\t\t\t\t\t\t\t\tblockCount={ blockCount }\n\t\t\t\t\t\t\t\t{ ...treeGridCellProps }\n\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t) }\n\t\t\t\t\t</TreeGridCell>\n\t\t\t\t</TreeGridRow>\n\t\t\t) }\n\t\t</>\n\t);\n}\n\nexport default memo( ListViewBranch );\n"]}
|
|
1
|
+
{"version":3,"sources":["@wordpress/block-editor/src/components/off-canvas-editor/branch.js"],"names":["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","showAppender","showAppenderProp","isContentLocked","select","blockEditorStore","getTemplateLock","filteredBlocks","filter","Boolean","blockCount","rowCount","nextPosition","map","index","itemInView","blockInView","position","updatedPath","hasNestedBlocks","shouldExpand","undefined","showBlock","isSelected","isSelectedBranch","treeGridCellProps"],"mappings":";;;;;;;;;AAQA;;;;AALA;;AAIA;;AAOA;;AACA;;AACA;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AAGC,IAAA,UAAU,EAAGgB;AAHd,KAIMe,iBAJN,EAFF,CAND,CArFF,CADD;AA0GA;;eAEc,mBAAMrC,cAAN,C","sourcesContent":["/**\n * WordPress dependencies\n */\nimport {\n\t__experimentalTreeGridRow as TreeGridRow,\n\t__experimentalTreeGridCell as TreeGridCell,\n} from '@wordpress/components';\nimport { AsyncModeProvider, useSelect } from '@wordpress/data';\nimport { memo } from '@wordpress/element';\n\n/**\n * Internal dependencies\n */\n\nimport { Appender } from './appender';\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\tshowAppender: showAppenderProp = true,\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\t// Only show the appender at the first level.\n\tconst showAppender = showAppenderProp && level === 1;\n\n\tconst filteredBlocks = blocks.filter( Boolean );\n\tconst blockCount = filteredBlocks.length;\n\n\t// The appender means an extra row in List View, so add 1 to the row count.\n\tconst rowCount = showAppender ? blockCount + 1 : blockCount;\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={ rowCount }\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/>\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\tshowAppender={ showAppenderProp }\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\t{ showAppender && (\n\t\t\t\t<TreeGridRow\n\t\t\t\t\tlevel={ level }\n\t\t\t\t\tsetSize={ rowCount }\n\t\t\t\t\tpositionInSet={ rowCount }\n\t\t\t\t\tisExpanded={ true }\n\t\t\t\t>\n\t\t\t\t\t<TreeGridCell>\n\t\t\t\t\t\t{ ( treeGridCellProps ) => (\n\t\t\t\t\t\t\t<Appender\n\t\t\t\t\t\t\t\tclientId={ parentId }\n\t\t\t\t\t\t\t\tnestingLevel={ level }\n\t\t\t\t\t\t\t\tblockCount={ blockCount }\n\t\t\t\t\t\t\t\t{ ...treeGridCellProps }\n\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t) }\n\t\t\t\t\t</TreeGridCell>\n\t\t\t\t</TreeGridRow>\n\t\t\t) }\n\t\t</>\n\t);\n}\n\nexport default memo( ListViewBranch );\n"]}
|
|
@@ -58,12 +58,14 @@ const BLOCK_LIST_ITEM_HEIGHT = 36;
|
|
|
58
58
|
*
|
|
59
59
|
* @param {Object} props Components props.
|
|
60
60
|
* @param {string} props.id An HTML element id for the root element of ListView.
|
|
61
|
+
* @param {string} props.parentClientId The client id of the parent block.
|
|
61
62
|
* @param {Array} props.blocks Custom subset of block client IDs to be used instead of the default hierarchy.
|
|
62
63
|
* @param {boolean} props.showBlockMovers Flag to enable block movers
|
|
63
64
|
* @param {boolean} props.isExpanded Flag to determine whether nested levels are expanded by default.
|
|
64
65
|
* @param {Object} props.LeafMoreMenu Optional more menu substitution.
|
|
65
66
|
* @param {string} props.description Optional accessible description for the tree grid component.
|
|
66
67
|
* @param {string} props.onSelect Optional callback to be invoked when a block is selected.
|
|
68
|
+
* @param {string} props.showAppender Flag to show or hide the block appender.
|
|
67
69
|
* @param {Object} ref Forwarded ref
|
|
68
70
|
*/
|
|
69
71
|
|
|
@@ -72,9 +74,11 @@ exports.BLOCK_LIST_ITEM_HEIGHT = BLOCK_LIST_ITEM_HEIGHT;
|
|
|
72
74
|
function OffCanvasEditor(_ref, ref) {
|
|
73
75
|
let {
|
|
74
76
|
id,
|
|
77
|
+
parentClientId,
|
|
75
78
|
blocks,
|
|
76
79
|
showBlockMovers = false,
|
|
77
80
|
isExpanded = false,
|
|
81
|
+
showAppender = true,
|
|
78
82
|
LeafMoreMenu,
|
|
79
83
|
description = (0, _i18n.__)('Block navigation structure'),
|
|
80
84
|
onSelect
|
|
@@ -101,7 +105,7 @@ function OffCanvasEditor(_ref, ref) {
|
|
|
101
105
|
visibleBlockCount: getGlobalBlockCount() - draggedBlockCount,
|
|
102
106
|
shouldShowInnerBlocks: __unstableGetEditorMode() !== 'zoom-out'
|
|
103
107
|
};
|
|
104
|
-
}, [draggedClientIds]);
|
|
108
|
+
}, [draggedClientIds, blocks]);
|
|
105
109
|
const {
|
|
106
110
|
updateBlockSelection
|
|
107
111
|
} = (0, _useBlockSelection.default)();
|
|
@@ -202,13 +206,15 @@ function OffCanvasEditor(_ref, ref) {
|
|
|
202
206
|
}, (0, _element.createElement)(_context.ListViewContext.Provider, {
|
|
203
207
|
value: contextValue
|
|
204
208
|
}, (0, _element.createElement)(_branch.default, {
|
|
209
|
+
parentId: parentClientId,
|
|
205
210
|
blocks: clientIdsTree,
|
|
206
211
|
selectBlock: selectEditorBlock,
|
|
207
212
|
showBlockMovers: showBlockMovers,
|
|
208
213
|
fixedListWindow: fixedListWindow,
|
|
209
214
|
selectedClientIds: selectedClientIds,
|
|
210
215
|
isExpanded: isExpanded,
|
|
211
|
-
shouldShowInnerBlocks: shouldShowInnerBlocks
|
|
216
|
+
shouldShowInnerBlocks: shouldShowInnerBlocks,
|
|
217
|
+
showAppender: showAppender
|
|
212
218
|
}), (0, _element.createElement)(_components.__experimentalTreeGridRow, {
|
|
213
219
|
level: 1,
|
|
214
220
|
setSize: 1,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["@wordpress/block-editor/src/components/off-canvas-editor/index.js"],"names":["expanded","state","action","Array","isArray","clientIds","reduce","newState","id","type","BLOCK_LIST_ITEM_HEIGHT","OffCanvasEditor","ref","blocks","showBlockMovers","isExpanded","LeafMoreMenu","description","onSelect","getBlock","blockEditorStore","clientIdsTree","draggedClientIds","selectedClientIds","visibleBlockCount","shouldShowInnerBlocks","select","getGlobalBlockCount","getClientIdsOfDescendants","__unstableGetEditorMode","draggedBlockCount","length","updateBlockSelection","expandedState","setExpandedState","dropZoneRef","target","blockDropTarget","elementRef","treeGridRef","isMounted","setSelectedTreeId","firstSelectedBlockClientId","selectEditorBlock","event","blockClientId","current","fixedListWindow","useWindowing","windowOverscan","expand","collapse","expandRow","row","dataset","block","collapseRow","focusRow","startRow","endRow","shiftKey","contextValue","isTreeGridMounted"],"mappings":";;;;;;;;;AAaA;;AAVA;;AAIA;;AAKA;;AASA;;AAKA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AAjCA;AACA;AACA;;AAqBA;AACA;AACA;AAUA,MAAMA,QAAQ,GAAG,CAAEC,KAAF,EAASC,MAAT,KAAqB;AACrC,MAAKC,KAAK,CAACC,OAAN,CAAeF,MAAM,CAACG,SAAtB,CAAL,EAAyC;AACxC,WAAO,EACN,GAAGJ,KADG;AAEN,SAAGC,MAAM,CAACG,SAAP,CAAiBC,MAAjB,CACF,CAAEC,QAAF,EAAYC,EAAZ,MAAsB,EACrB,GAAGD,QADkB;AAErB,SAAEC,EAAF,GAAQN,MAAM,CAACO,IAAP,KAAgB;AAFH,OAAtB,CADE,EAKF,EALE;AAFG,KAAP;AAUA;;AACD,SAAOR,KAAP;AACA,CAdD;;AAgBO,MAAMS,sBAAsB,GAAG,EAA/B;AAEP;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;;AACA,SAASC,eAAT,OAUCC,GAVD,EAWE;AAAA,MAVD;AACCJ,IAAAA,EADD;AAECK,IAAAA,MAFD;AAGCC,IAAAA,eAAe,GAAG,KAHnB;AAICC,IAAAA,UAAU,GAAG,KAJd;AAKCC,IAAAA,YALD;AAMCC,IAAAA,WAAW,GAAG,cAAI,4BAAJ,CANf;AAOCC,IAAAA;AAPD,GAUC;AACD,QAAM;AAAEC,IAAAA;AAAF,MAAe,qBAAWC,YAAX,CAArB;AACA,QAAM;AAAEC,IAAAA,aAAF;AAAiBC,IAAAA,gBAAjB;AAAmCC,IAAAA;AAAnC,MACL,mCAAsBV,MAAtB,CADD;AAGA,QAAM;AAAEW,IAAAA,iBAAF;AAAqBC,IAAAA;AAArB,MAA+C,qBA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AAOC,IAAA,UAAU,EAAGK,QAPd,CAQC;AARD;AASC,wBAAmBxC;AATpB,KAWC,4BAAC,wBAAD,CAAiB,QAAjB;AAA0B,IAAA,KAAK,EAAG4C;AAAlC,KACC,4BAAC,eAAD;AACC,IAAA,MAAM,EAAGxC,aADV;AAEC,IAAA,WAAW,EAAGsB,iBAFf;AAGC,IAAA,eAAe,EAAG7B,eAHnB;AAIC,IAAA,eAAe,EAAGiC,eAJnB;AAKC,IAAA,iBAAiB,EAAGxB,iBALrB;AAMC,IAAA,UAAU,EAAGR,UANd;AAOC,IAAA,qBAAqB,EAAGU;AAPzB,IADD,EAUC,4BAAC,qCAAD;AACC,IAAA,KAAK,EAAG,CADT;AAEC,IAAA,OAAO,EAAG,CAFX;AAGC,IAAA,aAAa,EAAG,CAHjB;AAIC,IAAA,UAAU,EAAG;AAJd,KAMG,CAAEJ,aAAa,CAACU,MAAhB,IACD,4BAAC,sCAAD;AAAc,IAAA,eAAe;AAA7B,KACC;AAAK,IAAA,SAAS,EAAC;AAAf,KACG,cACD,wEADC,CADH,CADD,CAPF,CAVD,CAXD,CADD,CALD,CADD;AAiDA;;eAEc,yBAAYpB,eAAZ,C","sourcesContent":["/**\n * WordPress dependencies\n */\nimport {\n\tuseMergeRefs,\n\t__experimentalUseFixedWindowList as useFixedWindowList,\n} from '@wordpress/compose';\nimport {\n\t__experimentalTreeGrid as TreeGrid,\n\t__experimentalTreeGridRow as TreeGridRow,\n\t__experimentalTreeGridCell as TreeGridCell,\n} from '@wordpress/components';\nimport { AsyncModeProvider, useSelect } from '@wordpress/data';\nimport {\n\tuseCallback,\n\tuseEffect,\n\tuseMemo,\n\tuseRef,\n\tuseReducer,\n\tforwardRef,\n} from '@wordpress/element';\nimport { __ } from '@wordpress/i18n';\n\n/**\n * Internal dependencies\n */\nimport ListViewBranch from './branch';\nimport { ListViewContext } from './context';\nimport ListViewDropIndicator from './drop-indicator';\nimport useBlockSelection from './use-block-selection';\nimport useListViewClientIds from './use-list-view-client-ids';\nimport useListViewDropZone from './use-list-view-drop-zone';\nimport useListViewExpandSelectedItem from './use-list-view-expand-selected-item';\nimport { store as blockEditorStore } from '../../store';\n\nconst expanded = ( state, action ) => {\n\tif ( Array.isArray( action.clientIds ) ) {\n\t\treturn {\n\t\t\t...state,\n\t\t\t...action.clientIds.reduce(\n\t\t\t\t( newState, id ) => ( {\n\t\t\t\t\t...newState,\n\t\t\t\t\t[ id ]: action.type === 'expand',\n\t\t\t\t} ),\n\t\t\t\t{}\n\t\t\t),\n\t\t};\n\t}\n\treturn state;\n};\n\nexport const BLOCK_LIST_ITEM_HEIGHT = 36;\n\n/**\n * Show a hierarchical list of blocks.\n *\n * @param {Object} props Components props.\n * @param {string} props.id An HTML element id for the root element of ListView.\n * @param {Array} props.blocks Custom subset of block client IDs to be used instead of the default hierarchy.\n * @param {boolean} props.showBlockMovers Flag to enable block movers\n * @param {boolean} props.isExpanded Flag to determine whether nested levels are expanded by default.\n * @param {Object} props.LeafMoreMenu Optional more menu substitution.\n * @param {string} props.description Optional accessible description for the tree grid component.\n * @param {string} props.onSelect Optional callback to be invoked when a block is selected.\n * @param {Object} ref Forwarded ref\n */\nfunction OffCanvasEditor(\n\t{\n\t\tid,\n\t\tblocks,\n\t\tshowBlockMovers = false,\n\t\tisExpanded = false,\n\t\tLeafMoreMenu,\n\t\tdescription = __( 'Block navigation structure' ),\n\t\tonSelect,\n\t},\n\tref\n) {\n\tconst { getBlock } = useSelect( blockEditorStore );\n\tconst { clientIdsTree, draggedClientIds, selectedClientIds } =\n\t\tuseListViewClientIds( blocks );\n\n\tconst { visibleBlockCount, shouldShowInnerBlocks } = useSelect(\n\t\t( select ) => {\n\t\t\tconst {\n\t\t\t\tgetGlobalBlockCount,\n\t\t\t\tgetClientIdsOfDescendants,\n\t\t\t\t__unstableGetEditorMode,\n\t\t\t} = select( blockEditorStore );\n\t\t\tconst draggedBlockCount =\n\t\t\t\tdraggedClientIds?.length > 0\n\t\t\t\t\t? getClientIdsOfDescendants( draggedClientIds ).length + 1\n\t\t\t\t\t: 0;\n\t\t\treturn {\n\t\t\t\tvisibleBlockCount: getGlobalBlockCount() - draggedBlockCount,\n\t\t\t\tshouldShowInnerBlocks: __unstableGetEditorMode() !== 'zoom-out',\n\t\t\t};\n\t\t},\n\t\t[ draggedClientIds ]\n\t);\n\n\tconst { updateBlockSelection } = useBlockSelection();\n\n\tconst [ expandedState, setExpandedState ] = useReducer( expanded, {} );\n\n\tconst { ref: dropZoneRef, target: blockDropTarget } = useListViewDropZone();\n\tconst elementRef = useRef();\n\tconst treeGridRef = useMergeRefs( [ elementRef, dropZoneRef, ref ] );\n\n\tconst isMounted = useRef( false );\n\tconst { setSelectedTreeId } = useListViewExpandSelectedItem( {\n\t\tfirstSelectedBlockClientId: selectedClientIds[ 0 ],\n\t\tsetExpandedState,\n\t} );\n\tconst selectEditorBlock = useCallback(\n\t\t( event, blockClientId ) => {\n\t\t\tupdateBlockSelection( event, blockClientId );\n\t\t\tsetSelectedTreeId( blockClientId );\n\t\t\tif ( onSelect ) {\n\t\t\t\tonSelect( getBlock( blockClientId ) );\n\t\t\t}\n\t\t},\n\t\t[ setSelectedTreeId, updateBlockSelection, onSelect, getBlock ]\n\t);\n\tuseEffect( () => {\n\t\tisMounted.current = true;\n\t}, [] );\n\n\t// List View renders a fixed number of items and relies on each having a fixed item height of 36px.\n\t// If this value changes, we should also change the itemHeight value set in useFixedWindowList.\n\t// See: https://github.com/WordPress/gutenberg/pull/35230 for additional context.\n\tconst [ fixedListWindow ] = useFixedWindowList(\n\t\telementRef,\n\t\tBLOCK_LIST_ITEM_HEIGHT,\n\t\tvisibleBlockCount,\n\t\t{\n\t\t\tuseWindowing: true,\n\t\t\twindowOverscan: 40,\n\t\t}\n\t);\n\n\tconst expand = useCallback(\n\t\t( blockClientId ) => {\n\t\t\tif ( ! blockClientId ) {\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tsetExpandedState( {\n\t\t\t\ttype: 'expand',\n\t\t\t\tclientIds: [ blockClientId ],\n\t\t\t} );\n\t\t},\n\t\t[ setExpandedState ]\n\t);\n\tconst collapse = useCallback(\n\t\t( blockClientId ) => {\n\t\t\tif ( ! blockClientId ) {\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tsetExpandedState( {\n\t\t\t\ttype: 'collapse',\n\t\t\t\tclientIds: [ blockClientId ],\n\t\t\t} );\n\t\t},\n\t\t[ setExpandedState ]\n\t);\n\tconst expandRow = useCallback(\n\t\t( row ) => {\n\t\t\texpand( row?.dataset?.block );\n\t\t},\n\t\t[ expand ]\n\t);\n\tconst collapseRow = useCallback(\n\t\t( row ) => {\n\t\t\tcollapse( row?.dataset?.block );\n\t\t},\n\t\t[ collapse ]\n\t);\n\tconst focusRow = useCallback(\n\t\t( event, startRow, endRow ) => {\n\t\t\tif ( event.shiftKey ) {\n\t\t\t\tupdateBlockSelection(\n\t\t\t\t\tevent,\n\t\t\t\t\tstartRow?.dataset?.block,\n\t\t\t\t\tendRow?.dataset?.block\n\t\t\t\t);\n\t\t\t}\n\t\t},\n\t\t[ updateBlockSelection ]\n\t);\n\n\tconst contextValue = useMemo(\n\t\t() => ( {\n\t\t\tisTreeGridMounted: isMounted.current,\n\t\t\tdraggedClientIds,\n\t\t\texpandedState,\n\t\t\texpand,\n\t\t\tcollapse,\n\t\t\tLeafMoreMenu,\n\t\t} ),\n\t\t[\n\t\t\tisMounted.current,\n\t\t\tdraggedClientIds,\n\t\t\texpandedState,\n\t\t\texpand,\n\t\t\tcollapse,\n\t\t\tLeafMoreMenu,\n\t\t]\n\t);\n\n\treturn (\n\t\t<AsyncModeProvider value={ true }>\n\t\t\t<ListViewDropIndicator\n\t\t\t\tlistViewRef={ elementRef }\n\t\t\t\tblockDropTarget={ blockDropTarget }\n\t\t\t/>\n\t\t\t<div className=\"offcanvas-editor-list-view-tree-wrapper\">\n\t\t\t\t<TreeGrid\n\t\t\t\t\tid={ id }\n\t\t\t\t\tclassName=\"block-editor-list-view-tree\"\n\t\t\t\t\taria-label={ __( 'Block navigation structure' ) }\n\t\t\t\t\tref={ treeGridRef }\n\t\t\t\t\tonCollapseRow={ collapseRow }\n\t\t\t\t\tonExpandRow={ expandRow }\n\t\t\t\t\tonFocusRow={ focusRow }\n\t\t\t\t\t// eslint-disable-next-line jsx-a11y/aria-props\n\t\t\t\t\taria-description={ description }\n\t\t\t\t>\n\t\t\t\t\t<ListViewContext.Provider value={ contextValue }>\n\t\t\t\t\t\t<ListViewBranch\n\t\t\t\t\t\t\tblocks={ clientIdsTree }\n\t\t\t\t\t\t\tselectBlock={ selectEditorBlock }\n\t\t\t\t\t\t\tshowBlockMovers={ showBlockMovers }\n\t\t\t\t\t\t\tfixedListWindow={ fixedListWindow }\n\t\t\t\t\t\t\tselectedClientIds={ selectedClientIds }\n\t\t\t\t\t\t\tisExpanded={ isExpanded }\n\t\t\t\t\t\t\tshouldShowInnerBlocks={ shouldShowInnerBlocks }\n\t\t\t\t\t\t/>\n\t\t\t\t\t\t<TreeGridRow\n\t\t\t\t\t\t\tlevel={ 1 }\n\t\t\t\t\t\t\tsetSize={ 1 }\n\t\t\t\t\t\t\tpositionInSet={ 1 }\n\t\t\t\t\t\t\tisExpanded={ true }\n\t\t\t\t\t\t>\n\t\t\t\t\t\t\t{ ! clientIdsTree.length && (\n\t\t\t\t\t\t\t\t<TreeGridCell withoutGridItem>\n\t\t\t\t\t\t\t\t\t<div className=\"offcanvas-editor-list-view-is-empty\">\n\t\t\t\t\t\t\t\t\t\t{ __(\n\t\t\t\t\t\t\t\t\t\t\t'Your menu is currently empty. Add your first menu item to get started.'\n\t\t\t\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\t\t\t</div>\n\t\t\t\t\t\t\t\t</TreeGridCell>\n\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t</TreeGridRow>\n\t\t\t\t\t</ListViewContext.Provider>\n\t\t\t\t</TreeGrid>\n\t\t\t</div>\n\t\t</AsyncModeProvider>\n\t);\n}\n\nexport default forwardRef( OffCanvasEditor );\n"]}
|
|
1
|
+
{"version":3,"sources":["@wordpress/block-editor/src/components/off-canvas-editor/index.js"],"names":["expanded","state","action","Array","isArray","clientIds","reduce","newState","id","type","BLOCK_LIST_ITEM_HEIGHT","OffCanvasEditor","ref","parentClientId","blocks","showBlockMovers","isExpanded","showAppender","LeafMoreMenu","description","onSelect","getBlock","blockEditorStore","clientIdsTree","draggedClientIds","selectedClientIds","visibleBlockCount","shouldShowInnerBlocks","select","getGlobalBlockCount","getClientIdsOfDescendants","__unstableGetEditorMode","draggedBlockCount","length","updateBlockSelection","expandedState","setExpandedState","dropZoneRef","target","blockDropTarget","elementRef","treeGridRef","isMounted","setSelectedTreeId","firstSelectedBlockClientId","selectEditorBlock","event","blockClientId","current","fixedListWindow","useWindowing","windowOverscan","expand","collapse","expandRow","row","dataset","block","collapseRow","focusRow","startRow","endRow","shiftKey","contextValue","isTreeGridMounted"],"mappings":";;;;;;;;;AAaA;;AAVA;;AAIA;;AAKA;;AASA;;AAKA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AAjCA;AACA;AACA;;AAqBA;AACA;AACA;AAUA,MAAMA,QAAQ,GAAG,CAAEC,KAAF,EAASC,MAAT,KAAqB;AACrC,MAAKC,KAAK,CAACC,OAAN,CAAeF,MAAM,CAACG,SAAtB,CAAL,EAAyC;AACxC,WAAO,EACN,GAAGJ,KADG;AAEN,SAAGC,MAAM,CAACG,SAAP,CAAiBC,MAAjB,CACF,CAAEC,QAAF,EAAYC,EAAZ,MAAsB,EACrB,GAAGD,QADkB;AAErB,SAAEC,EAAF,GAAQN,MAAM,CAACO,IAAP,KAAgB;AAFH,OAAtB,CADE,EAKF,EALE;AAFG,KAAP;AAUA;;AACD,SAAOR,KAAP;AACA,CAdD;;AAgBO,MAAMS,sBAAsB,GAAG,EAA/B;AAEP;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;;AACA,SAASC,eAAT,OAYCC,GA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ADH,CADD,CAPF,CAZD,CAXD,CADD,CALD,CADD;AAmDA;;eAEc,yBAAYtB,eAAZ,C","sourcesContent":["/**\n * WordPress dependencies\n */\nimport {\n\tuseMergeRefs,\n\t__experimentalUseFixedWindowList as useFixedWindowList,\n} from '@wordpress/compose';\nimport {\n\t__experimentalTreeGrid as TreeGrid,\n\t__experimentalTreeGridRow as TreeGridRow,\n\t__experimentalTreeGridCell as TreeGridCell,\n} from '@wordpress/components';\nimport { AsyncModeProvider, useSelect } from '@wordpress/data';\nimport {\n\tuseCallback,\n\tuseEffect,\n\tuseMemo,\n\tuseRef,\n\tuseReducer,\n\tforwardRef,\n} from '@wordpress/element';\nimport { __ } from '@wordpress/i18n';\n\n/**\n * Internal dependencies\n */\nimport ListViewBranch from './branch';\nimport { ListViewContext } from './context';\nimport ListViewDropIndicator from './drop-indicator';\nimport useBlockSelection from './use-block-selection';\nimport useListViewClientIds from './use-list-view-client-ids';\nimport useListViewDropZone from './use-list-view-drop-zone';\nimport useListViewExpandSelectedItem from './use-list-view-expand-selected-item';\nimport { store as blockEditorStore } from '../../store';\n\nconst expanded = ( state, action ) => {\n\tif ( Array.isArray( action.clientIds ) ) {\n\t\treturn {\n\t\t\t...state,\n\t\t\t...action.clientIds.reduce(\n\t\t\t\t( newState, id ) => ( {\n\t\t\t\t\t...newState,\n\t\t\t\t\t[ id ]: action.type === 'expand',\n\t\t\t\t} ),\n\t\t\t\t{}\n\t\t\t),\n\t\t};\n\t}\n\treturn state;\n};\n\nexport const BLOCK_LIST_ITEM_HEIGHT = 36;\n\n/**\n * Show a hierarchical list of blocks.\n *\n * @param {Object} props Components props.\n * @param {string} props.id An HTML element id for the root element of ListView.\n * @param {string} props.parentClientId The client id of the parent block.\n * @param {Array} props.blocks Custom subset of block client IDs to be used instead of the default hierarchy.\n * @param {boolean} props.showBlockMovers Flag to enable block movers\n * @param {boolean} props.isExpanded Flag to determine whether nested levels are expanded by default.\n * @param {Object} props.LeafMoreMenu Optional more menu substitution.\n * @param {string} props.description Optional accessible description for the tree grid component.\n * @param {string} props.onSelect Optional callback to be invoked when a block is selected.\n * @param {string} props.showAppender Flag to show or hide the block appender.\n * @param {Object} ref Forwarded ref\n */\nfunction OffCanvasEditor(\n\t{\n\t\tid,\n\t\tparentClientId,\n\t\tblocks,\n\t\tshowBlockMovers = false,\n\t\tisExpanded = false,\n\t\tshowAppender = true,\n\t\tLeafMoreMenu,\n\t\tdescription = __( 'Block navigation structure' ),\n\t\tonSelect,\n\t},\n\tref\n) {\n\tconst { getBlock } = useSelect( blockEditorStore );\n\tconst { clientIdsTree, draggedClientIds, selectedClientIds } =\n\t\tuseListViewClientIds( blocks );\n\n\tconst { visibleBlockCount, shouldShowInnerBlocks } = useSelect(\n\t\t( select ) => {\n\t\t\tconst {\n\t\t\t\tgetGlobalBlockCount,\n\t\t\t\tgetClientIdsOfDescendants,\n\t\t\t\t__unstableGetEditorMode,\n\t\t\t} = select( blockEditorStore );\n\t\t\tconst draggedBlockCount =\n\t\t\t\tdraggedClientIds?.length > 0\n\t\t\t\t\t? getClientIdsOfDescendants( draggedClientIds ).length + 1\n\t\t\t\t\t: 0;\n\t\t\treturn {\n\t\t\t\tvisibleBlockCount: getGlobalBlockCount() - draggedBlockCount,\n\t\t\t\tshouldShowInnerBlocks: __unstableGetEditorMode() !== 'zoom-out',\n\t\t\t};\n\t\t},\n\t\t[ draggedClientIds, blocks ]\n\t);\n\n\tconst { updateBlockSelection } = useBlockSelection();\n\n\tconst [ expandedState, setExpandedState ] = useReducer( expanded, {} );\n\n\tconst { ref: dropZoneRef, target: blockDropTarget } = useListViewDropZone();\n\tconst elementRef = useRef();\n\tconst treeGridRef = useMergeRefs( [ elementRef, dropZoneRef, ref ] );\n\n\tconst isMounted = useRef( false );\n\tconst { setSelectedTreeId } = useListViewExpandSelectedItem( {\n\t\tfirstSelectedBlockClientId: selectedClientIds[ 0 ],\n\t\tsetExpandedState,\n\t} );\n\tconst selectEditorBlock = useCallback(\n\t\t( event, blockClientId ) => {\n\t\t\tupdateBlockSelection( event, blockClientId );\n\t\t\tsetSelectedTreeId( blockClientId );\n\t\t\tif ( onSelect ) {\n\t\t\t\tonSelect( getBlock( blockClientId ) );\n\t\t\t}\n\t\t},\n\t\t[ setSelectedTreeId, updateBlockSelection, onSelect, getBlock ]\n\t);\n\tuseEffect( () => {\n\t\tisMounted.current = true;\n\t}, [] );\n\n\t// List View renders a fixed number of items and relies on each having a fixed item height of 36px.\n\t// If this value changes, we should also change the itemHeight value set in useFixedWindowList.\n\t// See: https://github.com/WordPress/gutenberg/pull/35230 for additional context.\n\tconst [ fixedListWindow ] = useFixedWindowList(\n\t\telementRef,\n\t\tBLOCK_LIST_ITEM_HEIGHT,\n\t\tvisibleBlockCount,\n\t\t{\n\t\t\tuseWindowing: true,\n\t\t\twindowOverscan: 40,\n\t\t}\n\t);\n\n\tconst expand = useCallback(\n\t\t( blockClientId ) => {\n\t\t\tif ( ! blockClientId ) {\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tsetExpandedState( {\n\t\t\t\ttype: 'expand',\n\t\t\t\tclientIds: [ blockClientId ],\n\t\t\t} );\n\t\t},\n\t\t[ setExpandedState ]\n\t);\n\tconst collapse = useCallback(\n\t\t( blockClientId ) => {\n\t\t\tif ( ! blockClientId ) {\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tsetExpandedState( {\n\t\t\t\ttype: 'collapse',\n\t\t\t\tclientIds: [ blockClientId ],\n\t\t\t} );\n\t\t},\n\t\t[ setExpandedState ]\n\t);\n\tconst expandRow = useCallback(\n\t\t( row ) => {\n\t\t\texpand( row?.dataset?.block );\n\t\t},\n\t\t[ expand ]\n\t);\n\tconst collapseRow = useCallback(\n\t\t( row ) => {\n\t\t\tcollapse( row?.dataset?.block );\n\t\t},\n\t\t[ collapse ]\n\t);\n\tconst focusRow = useCallback(\n\t\t( event, startRow, endRow ) => {\n\t\t\tif ( event.shiftKey ) {\n\t\t\t\tupdateBlockSelection(\n\t\t\t\t\tevent,\n\t\t\t\t\tstartRow?.dataset?.block,\n\t\t\t\t\tendRow?.dataset?.block\n\t\t\t\t);\n\t\t\t}\n\t\t},\n\t\t[ updateBlockSelection ]\n\t);\n\n\tconst contextValue = useMemo(\n\t\t() => ( {\n\t\t\tisTreeGridMounted: isMounted.current,\n\t\t\tdraggedClientIds,\n\t\t\texpandedState,\n\t\t\texpand,\n\t\t\tcollapse,\n\t\t\tLeafMoreMenu,\n\t\t} ),\n\t\t[\n\t\t\tisMounted.current,\n\t\t\tdraggedClientIds,\n\t\t\texpandedState,\n\t\t\texpand,\n\t\t\tcollapse,\n\t\t\tLeafMoreMenu,\n\t\t]\n\t);\n\n\treturn (\n\t\t<AsyncModeProvider value={ true }>\n\t\t\t<ListViewDropIndicator\n\t\t\t\tlistViewRef={ elementRef }\n\t\t\t\tblockDropTarget={ blockDropTarget }\n\t\t\t/>\n\t\t\t<div className=\"offcanvas-editor-list-view-tree-wrapper\">\n\t\t\t\t<TreeGrid\n\t\t\t\t\tid={ id }\n\t\t\t\t\tclassName=\"block-editor-list-view-tree\"\n\t\t\t\t\taria-label={ __( 'Block navigation structure' ) }\n\t\t\t\t\tref={ treeGridRef }\n\t\t\t\t\tonCollapseRow={ collapseRow }\n\t\t\t\t\tonExpandRow={ expandRow }\n\t\t\t\t\tonFocusRow={ focusRow }\n\t\t\t\t\t// eslint-disable-next-line jsx-a11y/aria-props\n\t\t\t\t\taria-description={ description }\n\t\t\t\t>\n\t\t\t\t\t<ListViewContext.Provider value={ contextValue }>\n\t\t\t\t\t\t<ListViewBranch\n\t\t\t\t\t\t\tparentId={ parentClientId }\n\t\t\t\t\t\t\tblocks={ clientIdsTree }\n\t\t\t\t\t\t\tselectBlock={ selectEditorBlock }\n\t\t\t\t\t\t\tshowBlockMovers={ showBlockMovers }\n\t\t\t\t\t\t\tfixedListWindow={ fixedListWindow }\n\t\t\t\t\t\t\tselectedClientIds={ selectedClientIds }\n\t\t\t\t\t\t\tisExpanded={ isExpanded }\n\t\t\t\t\t\t\tshouldShowInnerBlocks={ shouldShowInnerBlocks }\n\t\t\t\t\t\t\tshowAppender={ showAppender }\n\t\t\t\t\t\t/>\n\t\t\t\t\t\t<TreeGridRow\n\t\t\t\t\t\t\tlevel={ 1 }\n\t\t\t\t\t\t\tsetSize={ 1 }\n\t\t\t\t\t\t\tpositionInSet={ 1 }\n\t\t\t\t\t\t\tisExpanded={ true }\n\t\t\t\t\t\t>\n\t\t\t\t\t\t\t{ ! clientIdsTree.length && (\n\t\t\t\t\t\t\t\t<TreeGridCell withoutGridItem>\n\t\t\t\t\t\t\t\t\t<div className=\"offcanvas-editor-list-view-is-empty\">\n\t\t\t\t\t\t\t\t\t\t{ __(\n\t\t\t\t\t\t\t\t\t\t\t'Your menu is currently empty. Add your first menu item to get started.'\n\t\t\t\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\t\t\t</div>\n\t\t\t\t\t\t\t\t</TreeGridCell>\n\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t</TreeGridRow>\n\t\t\t\t\t</ListViewContext.Provider>\n\t\t\t\t</TreeGrid>\n\t\t\t</div>\n\t\t</AsyncModeProvider>\n\t);\n}\n\nexport default forwardRef( OffCanvasEditor );\n"]}
|