@wordpress/block-editor 10.3.0 → 10.5.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 +13 -0
- package/README.md +0 -1
- package/build/components/alignment-control/ui.js +1 -1
- package/build/components/alignment-control/ui.js.map +1 -1
- package/build/components/block-alignment-control/constants.js +1 -1
- package/build/components/block-alignment-control/constants.js.map +1 -1
- package/build/components/block-alignment-matrix-control/index.js +1 -1
- package/build/components/block-alignment-matrix-control/index.js.map +1 -1
- package/build/components/block-compare/index.js +1 -3
- package/build/components/block-compare/index.js.map +1 -1
- package/build/components/block-edit/index.js +4 -2
- package/build/components/block-edit/index.js.map +1 -1
- package/build/components/block-list/block.js +3 -1
- package/build/components/block-list/block.js.map +1 -1
- package/build/components/block-lock/menu-item.js +1 -1
- package/build/components/block-lock/menu-item.js.map +1 -1
- package/build/components/block-lock/modal.js +16 -9
- package/build/components/block-lock/modal.js.map +1 -1
- package/build/components/block-popover/inbetween.js +2 -1
- package/build/components/block-popover/inbetween.js.map +1 -1
- package/build/components/block-popover/index.js +2 -1
- package/build/components/block-popover/index.js.map +1 -1
- package/build/components/block-preview/index.js +2 -4
- package/build/components/block-preview/index.js.map +1 -1
- package/build/components/block-settings-menu/block-settings-dropdown.js +2 -8
- package/build/components/block-settings-menu/block-settings-dropdown.js.map +1 -1
- package/build/components/block-styles/utils.js +3 -3
- package/build/components/block-styles/utils.js.map +1 -1
- package/build/components/block-switcher/index.js +21 -12
- package/build/components/block-switcher/index.js.map +1 -1
- package/build/components/block-switcher/preview-block-popover.js +1 -1
- package/build/components/block-switcher/preview-block-popover.js.map +1 -1
- package/build/components/block-tools/insertion-point.js +12 -2
- package/build/components/block-tools/insertion-point.js.map +1 -1
- package/build/components/block-tools/selected-block-popover.js +27 -4
- package/build/components/block-tools/selected-block-popover.js.map +1 -1
- package/build/components/block-vertical-alignment-control/ui.js +1 -1
- package/build/components/block-vertical-alignment-control/ui.js.map +1 -1
- package/build/components/border-radius-control/all-input-control.js +2 -1
- package/build/components/border-radius-control/all-input-control.js.map +1 -1
- package/build/components/border-radius-control/index.js +2 -1
- package/build/components/border-radius-control/index.js.map +1 -1
- package/build/components/border-radius-control/input-controls.js +2 -1
- package/build/components/border-radius-control/input-controls.js.map +1 -1
- package/build/components/colors/with-colors.js +4 -3
- package/build/components/colors/with-colors.js.map +1 -1
- package/build/components/duotone-control/index.js +1 -1
- package/build/components/duotone-control/index.js.map +1 -1
- package/build/components/font-sizes/fluid-utils.js +24 -40
- package/build/components/font-sizes/fluid-utils.js.map +1 -1
- package/build/components/font-sizes/with-font-sizes.js +8 -6
- package/build/components/font-sizes/with-font-sizes.js.map +1 -1
- package/build/components/iframe/index.js +1 -1
- package/build/components/iframe/index.js.map +1 -1
- package/build/components/image-editor/constants.js +1 -1
- package/build/components/image-editor/constants.js.map +1 -1
- package/build/components/index.js +9 -0
- package/build/components/index.js.map +1 -1
- package/build/components/inner-blocks/index.js +10 -4
- package/build/components/inner-blocks/index.js.map +1 -1
- package/build/components/inserter/hooks/use-insertion-point.js +2 -7
- package/build/components/inserter/hooks/use-insertion-point.js.map +1 -1
- package/build/components/inserter/reusable-blocks-tab.js +4 -1
- package/build/components/inserter/reusable-blocks-tab.js.map +1 -1
- package/build/components/inserter/search-items.js +23 -2
- package/build/components/inserter/search-items.js.map +1 -1
- package/build/components/line-height-control/index.js +2 -1
- package/build/components/line-height-control/index.js.map +1 -1
- package/build/components/link-control/index.js +18 -34
- package/build/components/link-control/index.js.map +1 -1
- package/build/components/link-control/search-input.js +1 -1
- package/build/components/link-control/search-input.js.map +1 -1
- package/build/components/link-control/use-internal-input-value.js +26 -0
- package/build/components/link-control/use-internal-input-value.js.map +1 -0
- package/build/components/list-view/block.js +5 -3
- package/build/components/list-view/block.js.map +1 -1
- package/build/components/list-view/branch.js +9 -3
- package/build/components/list-view/branch.js.map +1 -1
- package/build/components/list-view/drop-indicator.js +2 -1
- package/build/components/list-view/drop-indicator.js.map +1 -1
- package/build/components/media-replace-flow/index.js +1 -1
- package/build/components/media-replace-flow/index.js.map +1 -1
- package/build/components/off-canvas-editor/block-contents.js +100 -0
- package/build/components/off-canvas-editor/block-contents.js.map +1 -0
- package/build/components/off-canvas-editor/block-select-button.js +119 -0
- package/build/components/off-canvas-editor/block-select-button.js.map +1 -0
- package/build/components/off-canvas-editor/block.js +292 -0
- package/build/components/off-canvas-editor/block.js.map +1 -0
- package/build/components/off-canvas-editor/branch.js +181 -0
- package/build/components/off-canvas-editor/branch.js.map +1 -0
- package/build/components/off-canvas-editor/context.js +19 -0
- package/build/components/off-canvas-editor/context.js.map +1 -0
- package/build/components/off-canvas-editor/drop-indicator.js +118 -0
- package/build/components/off-canvas-editor/drop-indicator.js.map +1 -0
- package/build/components/off-canvas-editor/expander.js +41 -0
- package/build/components/off-canvas-editor/expander.js.map +1 -0
- package/build/components/off-canvas-editor/index.js +204 -0
- package/build/components/off-canvas-editor/index.js.map +1 -0
- package/build/components/off-canvas-editor/leaf.js +60 -0
- package/build/components/off-canvas-editor/leaf.js.map +1 -0
- package/build/components/off-canvas-editor/use-block-selection.js +139 -0
- package/build/components/off-canvas-editor/use-block-selection.js.map +1 -0
- package/build/components/off-canvas-editor/use-list-view-client-ids.js +33 -0
- package/build/components/off-canvas-editor/use-list-view-client-ids.js.map +1 -0
- package/build/components/off-canvas-editor/use-list-view-drop-zone.js +235 -0
- package/build/components/off-canvas-editor/use-list-view-drop-zone.js.map +1 -0
- package/build/components/off-canvas-editor/use-list-view-expand-selected-item.js +60 -0
- package/build/components/off-canvas-editor/use-list-view-expand-selected-item.js.map +1 -0
- package/build/components/off-canvas-editor/utils.js +60 -0
- package/build/components/off-canvas-editor/utils.js.map +1 -0
- package/build/components/rich-text/format-toolbar/index.js +1 -1
- package/build/components/rich-text/format-toolbar/index.js.map +1 -1
- package/build/components/rich-text/format-toolbar-container.js +1 -1
- package/build/components/rich-text/format-toolbar-container.js.map +1 -1
- package/build/components/rich-text/use-paste-handler.js +1 -1
- package/build/components/rich-text/use-paste-handler.js.map +1 -1
- package/build/components/spacing-sizes-control/all-input-control.js +6 -2
- package/build/components/spacing-sizes-control/all-input-control.js.map +1 -1
- package/build/components/spacing-sizes-control/axial-input-controls.js +6 -2
- package/build/components/spacing-sizes-control/axial-input-controls.js.map +1 -1
- package/build/components/spacing-sizes-control/index.js +6 -2
- package/build/components/spacing-sizes-control/index.js.map +1 -1
- package/build/components/spacing-sizes-control/input-controls.js +6 -2
- package/build/components/spacing-sizes-control/input-controls.js.map +1 -1
- package/build/components/spacing-sizes-control/spacing-input-control.js +12 -5
- package/build/components/spacing-sizes-control/spacing-input-control.js.map +1 -1
- package/build/components/url-input/index.js +1 -1
- package/build/components/url-input/index.js.map +1 -1
- package/build/components/url-popover/index.js +31 -2
- package/build/components/url-popover/index.js.map +1 -1
- package/build/components/use-setting/index.js +1 -1
- package/build/components/use-setting/index.js.map +1 -1
- package/build/hooks/border.js +1 -0
- package/build/hooks/border.js.map +1 -1
- package/build/hooks/color-panel.js +17 -1
- package/build/hooks/color-panel.js.map +1 -1
- package/build/hooks/color.js +1 -1
- package/build/hooks/color.js.map +1 -1
- package/build/hooks/content-lock-ui.js +13 -6
- package/build/hooks/content-lock-ui.js.map +1 -1
- package/build/hooks/dimensions.js +72 -13
- package/build/hooks/dimensions.js.map +1 -1
- package/build/hooks/font-size.js +1 -0
- package/build/hooks/font-size.js.map +1 -1
- package/build/hooks/layout.js +5 -4
- package/build/hooks/layout.js.map +1 -1
- package/build/hooks/margin.js +26 -18
- package/build/hooks/margin.js.map +1 -1
- package/build/hooks/min-height.js +145 -0
- package/build/hooks/min-height.js.map +1 -0
- package/build/hooks/padding.js +22 -13
- package/build/hooks/padding.js.map +1 -1
- package/build/hooks/style.js +3 -2
- package/build/hooks/style.js.map +1 -1
- package/build/hooks/utils.js +7 -6
- package/build/hooks/utils.js.map +1 -1
- package/build/layouts/constrained.js +0 -1
- package/build/layouts/constrained.js.map +1 -1
- package/build/layouts/flex.js +23 -22
- package/build/layouts/flex.js.map +1 -1
- package/build/store/actions.js +30 -0
- package/build/store/actions.js.map +1 -1
- package/build/store/array.js +1 -7
- package/build/store/array.js.map +1 -1
- package/build/store/reducer.js +46 -14
- package/build/store/reducer.js.map +1 -1
- package/build/store/selectors.js +62 -31
- package/build/store/selectors.js.map +1 -1
- package/build-module/components/alignment-control/ui.js +1 -1
- package/build-module/components/alignment-control/ui.js.map +1 -1
- package/build-module/components/block-alignment-control/constants.js +1 -1
- package/build-module/components/block-alignment-control/constants.js.map +1 -1
- package/build-module/components/block-alignment-matrix-control/index.js +1 -1
- package/build-module/components/block-alignment-matrix-control/index.js.map +1 -1
- package/build-module/components/block-compare/index.js +2 -3
- package/build-module/components/block-compare/index.js.map +1 -1
- package/build-module/components/block-edit/index.js +4 -2
- package/build-module/components/block-edit/index.js.map +1 -1
- package/build-module/components/block-list/block.js +3 -1
- package/build-module/components/block-list/block.js.map +1 -1
- package/build-module/components/block-lock/menu-item.js +2 -2
- package/build-module/components/block-lock/menu-item.js.map +1 -1
- package/build-module/components/block-lock/modal.js +17 -10
- package/build-module/components/block-lock/modal.js.map +1 -1
- package/build-module/components/block-popover/inbetween.js +2 -1
- package/build-module/components/block-popover/inbetween.js.map +1 -1
- package/build-module/components/block-popover/index.js +2 -1
- package/build-module/components/block-popover/index.js.map +1 -1
- package/build-module/components/block-preview/index.js +2 -3
- package/build-module/components/block-preview/index.js.map +1 -1
- package/build-module/components/block-settings-menu/block-settings-dropdown.js +2 -7
- package/build-module/components/block-settings-menu/block-settings-dropdown.js.map +1 -1
- package/build-module/components/block-styles/utils.js +3 -3
- package/build-module/components/block-styles/utils.js.map +1 -1
- package/build-module/components/block-switcher/index.js +21 -11
- package/build-module/components/block-switcher/index.js.map +1 -1
- package/build-module/components/block-switcher/preview-block-popover.js +1 -1
- package/build-module/components/block-switcher/preview-block-popover.js.map +1 -1
- package/build-module/components/block-tools/insertion-point.js +12 -2
- package/build-module/components/block-tools/insertion-point.js.map +1 -1
- package/build-module/components/block-tools/selected-block-popover.js +27 -5
- package/build-module/components/block-tools/selected-block-popover.js.map +1 -1
- package/build-module/components/block-vertical-alignment-control/ui.js +1 -1
- package/build-module/components/block-vertical-alignment-control/ui.js.map +1 -1
- package/build-module/components/border-radius-control/all-input-control.js +2 -1
- package/build-module/components/border-radius-control/all-input-control.js.map +1 -1
- package/build-module/components/border-radius-control/index.js +2 -1
- package/build-module/components/border-radius-control/index.js.map +1 -1
- package/build-module/components/border-radius-control/input-controls.js +2 -1
- package/build-module/components/border-radius-control/input-controls.js.map +1 -1
- package/build-module/components/colors/with-colors.js +5 -4
- package/build-module/components/colors/with-colors.js.map +1 -1
- package/build-module/components/duotone-control/index.js +1 -1
- package/build-module/components/duotone-control/index.js.map +1 -1
- package/build-module/components/font-sizes/fluid-utils.js +24 -40
- package/build-module/components/font-sizes/fluid-utils.js.map +1 -1
- package/build-module/components/font-sizes/with-font-sizes.js +9 -7
- package/build-module/components/font-sizes/with-font-sizes.js.map +1 -1
- package/build-module/components/iframe/index.js +1 -1
- package/build-module/components/iframe/index.js.map +1 -1
- package/build-module/components/image-editor/constants.js +1 -1
- package/build-module/components/image-editor/constants.js.map +1 -1
- package/build-module/components/index.js +1 -0
- package/build-module/components/index.js.map +1 -1
- package/build-module/components/inner-blocks/index.js +10 -4
- package/build-module/components/inner-blocks/index.js.map +1 -1
- package/build-module/components/inserter/hooks/use-insertion-point.js +2 -6
- package/build-module/components/inserter/hooks/use-insertion-point.js.map +1 -1
- package/build-module/components/inserter/reusable-blocks-tab.js +3 -1
- package/build-module/components/inserter/reusable-blocks-tab.js.map +1 -1
- package/build-module/components/inserter/search-items.js +23 -3
- package/build-module/components/inserter/search-items.js.map +1 -1
- package/build-module/components/line-height-control/index.js +2 -1
- package/build-module/components/line-height-control/index.js.map +1 -1
- package/build-module/components/link-control/index.js +17 -34
- package/build-module/components/link-control/index.js.map +1 -1
- package/build-module/components/link-control/search-input.js +1 -1
- package/build-module/components/link-control/search-input.js.map +1 -1
- package/build-module/components/link-control/use-internal-input-value.js +18 -0
- package/build-module/components/link-control/use-internal-input-value.js.map +1 -0
- package/build-module/components/list-view/block.js +5 -3
- package/build-module/components/list-view/block.js.map +1 -1
- package/build-module/components/list-view/branch.js +9 -3
- package/build-module/components/list-view/branch.js.map +1 -1
- package/build-module/components/list-view/drop-indicator.js +2 -1
- package/build-module/components/list-view/drop-indicator.js.map +1 -1
- package/build-module/components/media-replace-flow/index.js +1 -1
- package/build-module/components/media-replace-flow/index.js.map +1 -1
- package/build-module/components/off-canvas-editor/block-contents.js +85 -0
- package/build-module/components/off-canvas-editor/block-contents.js.map +1 -0
- package/build-module/components/off-canvas-editor/block-select-button.js +101 -0
- package/build-module/components/off-canvas-editor/block-select-button.js.map +1 -0
- package/build-module/components/off-canvas-editor/block.js +268 -0
- package/build-module/components/off-canvas-editor/block.js.map +1 -0
- package/build-module/components/off-canvas-editor/branch.js +165 -0
- package/build-module/components/off-canvas-editor/branch.js.map +1 -0
- package/build-module/components/off-canvas-editor/context.js +7 -0
- package/build-module/components/off-canvas-editor/context.js.map +1 -0
- package/build-module/components/off-canvas-editor/drop-indicator.js +111 -0
- package/build-module/components/off-canvas-editor/drop-indicator.js.map +1 -0
- package/build-module/components/off-canvas-editor/expander.js +32 -0
- package/build-module/components/off-canvas-editor/expander.js.map +1 -0
- package/build-module/components/off-canvas-editor/index.js +181 -0
- package/build-module/components/off-canvas-editor/index.js.map +1 -0
- package/build-module/components/off-canvas-editor/leaf.js +45 -0
- package/build-module/components/off-canvas-editor/leaf.js.map +1 -0
- package/build-module/components/off-canvas-editor/use-block-selection.js +124 -0
- package/build-module/components/off-canvas-editor/use-block-selection.js.map +1 -0
- package/build-module/components/off-canvas-editor/use-list-view-client-ids.js +24 -0
- package/build-module/components/off-canvas-editor/use-list-view-client-ids.js.map +1 -0
- package/build-module/components/off-canvas-editor/use-list-view-drop-zone.js +220 -0
- package/build-module/components/off-canvas-editor/use-list-view-drop-zone.js.map +1 -0
- package/build-module/components/off-canvas-editor/use-list-view-expand-selected-item.js +50 -0
- package/build-module/components/off-canvas-editor/use-list-view-expand-selected-item.js.map +1 -0
- package/build-module/components/off-canvas-editor/utils.js +44 -0
- package/build-module/components/off-canvas-editor/utils.js.map +1 -0
- package/build-module/components/rich-text/format-toolbar/index.js +1 -1
- package/build-module/components/rich-text/format-toolbar/index.js.map +1 -1
- package/build-module/components/rich-text/format-toolbar-container.js +1 -1
- package/build-module/components/rich-text/format-toolbar-container.js.map +1 -1
- package/build-module/components/rich-text/use-paste-handler.js +1 -1
- package/build-module/components/rich-text/use-paste-handler.js.map +1 -1
- package/build-module/components/spacing-sizes-control/all-input-control.js +6 -2
- package/build-module/components/spacing-sizes-control/all-input-control.js.map +1 -1
- package/build-module/components/spacing-sizes-control/axial-input-controls.js +6 -2
- package/build-module/components/spacing-sizes-control/axial-input-controls.js.map +1 -1
- package/build-module/components/spacing-sizes-control/index.js +6 -2
- package/build-module/components/spacing-sizes-control/index.js.map +1 -1
- package/build-module/components/spacing-sizes-control/input-controls.js +6 -2
- package/build-module/components/spacing-sizes-control/input-controls.js.map +1 -1
- package/build-module/components/spacing-sizes-control/spacing-input-control.js +12 -5
- package/build-module/components/spacing-sizes-control/spacing-input-control.js.map +1 -1
- package/build-module/components/url-input/index.js +1 -1
- package/build-module/components/url-input/index.js.map +1 -1
- package/build-module/components/url-popover/index.js +30 -3
- package/build-module/components/url-popover/index.js.map +1 -1
- package/build-module/components/use-setting/index.js +1 -1
- package/build-module/components/use-setting/index.js.map +1 -1
- package/build-module/hooks/border.js +1 -0
- package/build-module/hooks/border.js.map +1 -1
- package/build-module/hooks/color-panel.js +17 -1
- package/build-module/hooks/color-panel.js.map +1 -1
- package/build-module/hooks/color.js +1 -1
- package/build-module/hooks/color.js.map +1 -1
- package/build-module/hooks/content-lock-ui.js +15 -8
- package/build-module/hooks/content-lock-ui.js.map +1 -1
- package/build-module/hooks/dimensions.js +67 -12
- package/build-module/hooks/dimensions.js.map +1 -1
- package/build-module/hooks/font-size.js +1 -0
- package/build-module/hooks/font-size.js.map +1 -1
- package/build-module/hooks/layout.js +6 -5
- package/build-module/hooks/layout.js.map +1 -1
- package/build-module/hooks/margin.js +27 -19
- package/build-module/hooks/margin.js.map +1 -1
- package/build-module/hooks/min-height.js +122 -0
- package/build-module/hooks/min-height.js.map +1 -0
- package/build-module/hooks/padding.js +23 -14
- package/build-module/hooks/padding.js.map +1 -1
- package/build-module/hooks/style.js +4 -3
- package/build-module/hooks/style.js.map +1 -1
- package/build-module/hooks/utils.js +7 -7
- package/build-module/hooks/utils.js.map +1 -1
- package/build-module/layouts/constrained.js +0 -1
- package/build-module/layouts/constrained.js.map +1 -1
- package/build-module/layouts/flex.js +24 -23
- package/build-module/layouts/flex.js.map +1 -1
- package/build-module/store/actions.js +26 -0
- package/build-module/store/actions.js.map +1 -1
- package/build-module/store/array.js +1 -6
- package/build-module/store/array.js.map +1 -1
- package/build-module/store/reducer.js +44 -14
- package/build-module/store/reducer.js.map +1 -1
- package/build-module/store/selectors.js +59 -31
- package/build-module/store/selectors.js.map +1 -1
- package/build-style/style-rtl.css +88 -88
- package/build-style/style.css +84 -84
- package/package.json +29 -28
- package/src/components/alignment-control/README.md +1 -1
- package/src/components/alignment-control/ui.js +1 -1
- package/src/components/block-alignment-control/constants.js +1 -1
- package/src/components/block-alignment-control/test/index.native.js +4 -4
- package/src/components/block-alignment-matrix-control/index.js +1 -1
- package/src/components/block-breadcrumb/test/__snapshots__/index.js.snap +13 -11
- package/src/components/block-breadcrumb/test/index.js +1 -1
- package/src/components/block-compare/index.js +3 -2
- package/src/components/block-draggable/test/helpers.native.js +3 -3
- package/src/components/block-draggable/test/index.native.js +27 -27
- package/src/components/block-edit/index.js +2 -1
- package/src/components/block-list/block.js +2 -0
- package/src/components/block-list/style.scss +11 -6
- package/src/components/block-lock/menu-item.js +5 -2
- package/src/components/block-lock/modal.js +19 -36
- package/src/components/block-lock/style.scss +8 -17
- package/src/components/block-mover/stories/index.js +1 -1
- package/src/components/block-mover/style.scss +35 -1
- package/src/components/block-popover/inbetween.js +1 -0
- package/src/components/block-popover/index.js +1 -0
- package/src/components/block-popover/style.scss +1 -5
- package/src/components/block-preview/index.js +8 -3
- package/src/components/block-settings-menu/block-settings-dropdown.js +4 -7
- package/src/components/block-styles/utils.js +3 -3
- package/src/components/block-switcher/index.js +21 -11
- package/src/components/block-switcher/preview-block-popover.js +1 -1
- package/src/components/block-tools/insertion-point.js +10 -1
- package/src/components/block-tools/selected-block-popover.js +80 -34
- package/src/components/block-tools/style.scss +15 -0
- package/src/components/block-variation-picker/README.md +1 -1
- package/src/components/block-vertical-alignment-control/ui.js +1 -1
- package/src/components/border-radius-control/all-input-control.js +1 -0
- package/src/components/border-radius-control/index.js +1 -0
- package/src/components/border-radius-control/input-controls.js +1 -0
- package/src/components/border-radius-control/style.scss +15 -24
- package/src/components/color-palette/test/__snapshots__/control.js.snap +85 -83
- package/src/components/color-palette/test/control.js +1 -1
- package/src/components/colors/with-colors.js +13 -23
- package/src/components/default-block-appender/style.scss +1 -0
- package/src/components/duotone-control/index.js +1 -1
- package/src/components/font-sizes/fluid-utils.js +37 -64
- package/src/components/font-sizes/test/fluid-utils.js +5 -5
- package/src/components/font-sizes/with-font-sizes.js +15 -13
- package/src/components/iframe/index.js +1 -1
- package/src/components/image-editor/constants.js +1 -1
- package/src/components/index.js +1 -0
- package/src/components/inner-blocks/index.js +11 -4
- package/src/components/inner-blocks/test/index.js +4 -0
- package/src/components/inserter/hooks/use-insertion-point.js +3 -11
- package/src/components/inserter/reusable-blocks-tab.js +4 -2
- package/src/components/inserter/search-items.js +23 -3
- package/src/components/inserter/style.scss +8 -7
- package/src/components/inserter/test/reusable-blocks-tab.js +14 -57
- package/src/components/inserter/test/search-items.js +6 -0
- package/src/components/inserter-list-item/style.scss +2 -0
- package/src/components/letter-spacing-control/README.md +55 -0
- package/src/components/line-height-control/index.js +1 -0
- package/src/components/link-control/README.md +3 -3
- package/src/components/link-control/index.js +23 -39
- package/src/components/link-control/search-input.js +1 -1
- package/src/components/link-control/test/index.js +272 -241
- package/src/components/link-control/use-internal-input-value.js +22 -0
- package/src/components/list-view/block.js +4 -3
- package/src/components/list-view/branch.js +11 -6
- package/src/components/list-view/drop-indicator.js +1 -0
- package/src/components/list-view/style.scss +1 -36
- package/src/components/media-replace-flow/index.js +1 -1
- package/src/components/media-replace-flow/test/index.js +69 -51
- package/src/components/off-canvas-editor/README.md +5 -0
- package/src/components/off-canvas-editor/block-contents.js +89 -0
- package/src/components/off-canvas-editor/block-select-button.js +113 -0
- package/src/components/off-canvas-editor/block.js +335 -0
- package/src/components/off-canvas-editor/branch.js +210 -0
- package/src/components/off-canvas-editor/context.js +8 -0
- package/src/components/off-canvas-editor/drop-indicator.js +126 -0
- package/src/components/off-canvas-editor/expander.js +26 -0
- package/src/components/off-canvas-editor/index.js +216 -0
- package/src/components/off-canvas-editor/leaf.js +48 -0
- package/src/components/off-canvas-editor/style.scss +397 -0
- package/src/components/off-canvas-editor/test/utils.js +50 -0
- package/src/components/off-canvas-editor/use-block-selection.js +169 -0
- package/src/components/off-canvas-editor/use-list-view-client-ids.js +29 -0
- package/src/components/off-canvas-editor/use-list-view-drop-zone.js +260 -0
- package/src/components/off-canvas-editor/use-list-view-expand-selected-item.js +58 -0
- package/src/components/off-canvas-editor/utils.js +58 -0
- package/src/components/responsive-block-control/test/index.js +69 -92
- package/src/components/rich-text/format-toolbar/index.js +1 -1
- package/src/components/rich-text/format-toolbar-container.js +1 -1
- package/src/components/rich-text/use-paste-handler.js +1 -1
- package/src/components/spacing-sizes-control/all-input-control.js +4 -0
- package/src/components/spacing-sizes-control/axial-input-controls.js +4 -0
- package/src/components/spacing-sizes-control/index.js +4 -0
- package/src/components/spacing-sizes-control/input-controls.js +4 -0
- package/src/components/spacing-sizes-control/spacing-input-control.js +10 -1
- package/src/components/spacing-sizes-control/style.scss +1 -0
- package/src/components/url-input/index.js +1 -1
- package/src/components/url-popover/README.md +12 -3
- package/src/components/url-popover/index.js +33 -3
- package/src/components/use-setting/index.js +7 -1
- package/src/hooks/border.js +1 -0
- package/src/hooks/color-panel.js +13 -1
- package/src/hooks/color.js +2 -0
- package/src/hooks/content-lock-ui.js +46 -34
- package/src/hooks/dimensions.js +106 -19
- package/src/hooks/font-size.js +1 -0
- package/src/hooks/layout.js +8 -11
- package/src/hooks/margin.js +23 -17
- package/src/hooks/min-height.js +121 -0
- package/src/hooks/padding.js +23 -19
- package/src/hooks/style.js +10 -2
- package/src/hooks/test/align.js +96 -72
- package/src/hooks/test/style.js +4 -0
- package/src/hooks/test/use-typography-props.js +1 -1
- package/src/hooks/utils.js +5 -6
- package/src/layouts/constrained.js +0 -1
- package/src/layouts/flex.js +44 -39
- package/src/store/actions.js +26 -0
- package/src/store/array.js +1 -6
- package/src/store/reducer.js +50 -40
- package/src/store/selectors.js +43 -29
- package/src/store/test/actions.js +18 -0
- package/src/store/test/reducer.js +40 -0
- package/src/store/test/selectors.js +20 -1
|
@@ -0,0 +1,111 @@
|
|
|
1
|
+
import { createElement } from "@wordpress/element";
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* WordPress dependencies
|
|
5
|
+
*/
|
|
6
|
+
import { Popover } from '@wordpress/components';
|
|
7
|
+
import { useCallback, useMemo } from '@wordpress/element';
|
|
8
|
+
export default function ListViewDropIndicator(_ref) {
|
|
9
|
+
let {
|
|
10
|
+
listViewRef,
|
|
11
|
+
blockDropTarget
|
|
12
|
+
} = _ref;
|
|
13
|
+
const {
|
|
14
|
+
rootClientId,
|
|
15
|
+
clientId,
|
|
16
|
+
dropPosition
|
|
17
|
+
} = blockDropTarget || {};
|
|
18
|
+
const [rootBlockElement, blockElement] = useMemo(() => {
|
|
19
|
+
if (!listViewRef.current) {
|
|
20
|
+
return [];
|
|
21
|
+
} // The rootClientId will be defined whenever dropping into inner
|
|
22
|
+
// block lists, but is undefined when dropping at the root level.
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
const _rootBlockElement = rootClientId ? listViewRef.current.querySelector(`[data-block="${rootClientId}"]`) : undefined; // The clientId represents the sibling block, the dragged block will
|
|
26
|
+
// usually be inserted adjacent to it. It will be undefined when
|
|
27
|
+
// dropping a block into an empty block list.
|
|
28
|
+
|
|
29
|
+
|
|
30
|
+
const _blockElement = clientId ? listViewRef.current.querySelector(`[data-block="${clientId}"]`) : undefined;
|
|
31
|
+
|
|
32
|
+
return [_rootBlockElement, _blockElement];
|
|
33
|
+
}, [rootClientId, clientId]); // The targetElement is the element that the drop indicator will appear
|
|
34
|
+
// before or after. When dropping into an empty block list, blockElement
|
|
35
|
+
// is undefined, so the indicator will appear after the rootBlockElement.
|
|
36
|
+
|
|
37
|
+
const targetElement = blockElement || rootBlockElement;
|
|
38
|
+
const getDropIndicatorIndent = useCallback(() => {
|
|
39
|
+
if (!rootBlockElement) {
|
|
40
|
+
return 0;
|
|
41
|
+
} // Calculate the indent using the block icon of the root block.
|
|
42
|
+
// Using a classname selector here might be flaky and could be
|
|
43
|
+
// improved.
|
|
44
|
+
|
|
45
|
+
|
|
46
|
+
const targetElementRect = targetElement.getBoundingClientRect();
|
|
47
|
+
const rootBlockIconElement = rootBlockElement.querySelector('.block-editor-block-icon');
|
|
48
|
+
const rootBlockIconRect = rootBlockIconElement.getBoundingClientRect();
|
|
49
|
+
return rootBlockIconRect.right - targetElementRect.left;
|
|
50
|
+
}, [rootBlockElement, targetElement]);
|
|
51
|
+
const style = useMemo(() => {
|
|
52
|
+
if (!targetElement) {
|
|
53
|
+
return {};
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
const indent = getDropIndicatorIndent();
|
|
57
|
+
return {
|
|
58
|
+
width: targetElement.offsetWidth - indent
|
|
59
|
+
};
|
|
60
|
+
}, [getDropIndicatorIndent, targetElement]);
|
|
61
|
+
const popoverAnchor = useMemo(() => {
|
|
62
|
+
const isValidDropPosition = dropPosition === 'top' || dropPosition === 'bottom' || dropPosition === 'inside';
|
|
63
|
+
|
|
64
|
+
if (!targetElement || !isValidDropPosition) {
|
|
65
|
+
return undefined;
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
return {
|
|
69
|
+
ownerDocument: targetElement.ownerDocument,
|
|
70
|
+
|
|
71
|
+
getBoundingClientRect() {
|
|
72
|
+
const rect = targetElement.getBoundingClientRect();
|
|
73
|
+
const indent = getDropIndicatorIndent();
|
|
74
|
+
const left = rect.left + indent;
|
|
75
|
+
const right = rect.right;
|
|
76
|
+
let top = 0;
|
|
77
|
+
let bottom = 0;
|
|
78
|
+
|
|
79
|
+
if (dropPosition === 'top') {
|
|
80
|
+
top = rect.top;
|
|
81
|
+
bottom = rect.top;
|
|
82
|
+
} else {
|
|
83
|
+
// `dropPosition` is either `bottom` or `inside`
|
|
84
|
+
top = rect.bottom;
|
|
85
|
+
bottom = rect.bottom;
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
const width = right - left;
|
|
89
|
+
const height = bottom - top;
|
|
90
|
+
return new window.DOMRect(left, top, width, height);
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
};
|
|
94
|
+
}, [targetElement, dropPosition, getDropIndicatorIndent]);
|
|
95
|
+
|
|
96
|
+
if (!targetElement) {
|
|
97
|
+
return null;
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
return createElement(Popover, {
|
|
101
|
+
animate: false,
|
|
102
|
+
anchor: popoverAnchor,
|
|
103
|
+
focusOnMount: false,
|
|
104
|
+
className: "block-editor-list-view-drop-indicator",
|
|
105
|
+
variant: "unstyled"
|
|
106
|
+
}, createElement("div", {
|
|
107
|
+
style: style,
|
|
108
|
+
className: "block-editor-list-view-drop-indicator__line"
|
|
109
|
+
}));
|
|
110
|
+
}
|
|
111
|
+
//# sourceMappingURL=drop-indicator.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["@wordpress/block-editor/src/components/off-canvas-editor/drop-indicator.js"],"names":["Popover","useCallback","useMemo","ListViewDropIndicator","listViewRef","blockDropTarget","rootClientId","clientId","dropPosition","rootBlockElement","blockElement","current","_rootBlockElement","querySelector","undefined","_blockElement","targetElement","getDropIndicatorIndent","targetElementRect","getBoundingClientRect","rootBlockIconElement","rootBlockIconRect","right","left","style","indent","width","offsetWidth","popoverAnchor","isValidDropPosition","ownerDocument","rect","top","bottom","height","window","DOMRect"],"mappings":";;AAAA;AACA;AACA;AACA,SAASA,OAAT,QAAwB,uBAAxB;AACA,SAASC,WAAT,EAAsBC,OAAtB,QAAqC,oBAArC;AAEA,eAAe,SAASC,qBAAT,OAGX;AAAA,MAH2C;AAC9CC,IAAAA,WAD8C;AAE9CC,IAAAA;AAF8C,GAG3C;AACH,QAAM;AAAEC,IAAAA,YAAF;AAAgBC,IAAAA,QAAhB;AAA0BC,IAAAA;AAA1B,MAA2CH,eAAe,IAAI,EAApE;AAEA,QAAM,CAAEI,gBAAF,EAAoBC,YAApB,IAAqCR,OAAO,CAAE,MAAM;AACzD,QAAK,CAAEE,WAAW,CAACO,OAAnB,EAA6B;AAC5B,aAAO,EAAP;AACA,KAHwD,CAKzD;AACA;;;AACA,UAAMC,iBAAiB,GAAGN,YAAY,GACnCF,WAAW,CAACO,OAAZ,CAAoBE,aAApB,CACC,gBAAgBP,YAAc,IAD/B,CADmC,GAInCQ,SAJH,CAPyD,CAazD;AACA;AACA;;;AACA,UAAMC,aAAa,GAAGR,QAAQ,GAC3BH,WAAW,CAACO,OAAZ,CAAoBE,aAApB,CACC,gBAAgBN,QAAU,IAD3B,CAD2B,GAI3BO,SAJH;;AAMA,WAAO,CAAEF,iBAAF,EAAqBG,aAArB,CAAP;AACA,GAvBiD,EAuB/C,CAAET,YAAF,EAAgBC,QAAhB,CAvB+C,CAAlD,CAHG,CA4BH;AACA;AACA;;AACA,QAAMS,aAAa,GAAGN,YAAY,IAAID,gBAAtC;AAEA,QAAMQ,sBAAsB,GAAGhB,WAAW,CAAE,MAAM;AACjD,QAAK,CAAEQ,gBAAP,EAA0B;AACzB,aAAO,CAA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KAAtB,EAA8B;AAC7BwB,UAAAA,GAAG,GAAGD,IAAI,CAACC,GAAX;AACAC,UAAAA,MAAM,GAAGF,IAAI,CAACC,GAAd;AACA,SAHD,MAGO;AACN;AACAA,UAAAA,GAAG,GAAGD,IAAI,CAACE,MAAX;AACAA,UAAAA,MAAM,GAAGF,IAAI,CAACE,MAAd;AACA;;AAED,cAAMP,KAAK,GAAGJ,KAAK,GAAGC,IAAtB;AACA,cAAMW,MAAM,GAAGD,MAAM,GAAGD,GAAxB;AAEA,eAAO,IAAIG,MAAM,CAACC,OAAX,CAAoBb,IAApB,EAA0BS,GAA1B,EAA+BN,KAA/B,EAAsCQ,MAAtC,CAAP;AACA;;AAxBK,KAAP;AA0BA,GAnC4B,EAmC1B,CAAElB,aAAF,EAAiBR,YAAjB,EAA+BS,sBAA/B,CAnC0B,CAA7B;;AAqCA,MAAK,CAAED,aAAP,EAAuB;AACtB,WAAO,IAAP;AACA;;AAED,SACC,cAAC,OAAD;AACC,IAAA,OAAO,EAAG,KADX;AAEC,IAAA,MAAM,EAAGY,aAFV;AAGC,IAAA,YAAY,EAAG,KAHhB;AAIC,IAAA,SAAS,EAAC,uCAJX;AAKC,IAAA,OAAO,EAAC;AALT,KAOC;AACC,IAAA,KAAK,EAAGJ,KADT;AAEC,IAAA,SAAS,EAAC;AAFX,IAPD,CADD;AAcA","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { Popover } from '@wordpress/components';\nimport { useCallback, useMemo } from '@wordpress/element';\n\nexport default function ListViewDropIndicator( {\n\tlistViewRef,\n\tblockDropTarget,\n} ) {\n\tconst { rootClientId, clientId, dropPosition } = blockDropTarget || {};\n\n\tconst [ rootBlockElement, blockElement ] = useMemo( () => {\n\t\tif ( ! listViewRef.current ) {\n\t\t\treturn [];\n\t\t}\n\n\t\t// The rootClientId will be defined whenever dropping into inner\n\t\t// block lists, but is undefined when dropping at the root level.\n\t\tconst _rootBlockElement = rootClientId\n\t\t\t? listViewRef.current.querySelector(\n\t\t\t\t\t`[data-block=\"${ rootClientId }\"]`\n\t\t\t )\n\t\t\t: undefined;\n\n\t\t// The clientId represents the sibling block, the dragged block will\n\t\t// usually be inserted adjacent to it. It will be undefined when\n\t\t// dropping a block into an empty block list.\n\t\tconst _blockElement = clientId\n\t\t\t? listViewRef.current.querySelector(\n\t\t\t\t\t`[data-block=\"${ clientId }\"]`\n\t\t\t )\n\t\t\t: undefined;\n\n\t\treturn [ _rootBlockElement, _blockElement ];\n\t}, [ rootClientId, clientId ] );\n\n\t// The targetElement is the element that the drop indicator will appear\n\t// before or after. When dropping into an empty block list, blockElement\n\t// is undefined, so the indicator will appear after the rootBlockElement.\n\tconst targetElement = blockElement || rootBlockElement;\n\n\tconst getDropIndicatorIndent = useCallback( () => {\n\t\tif ( ! rootBlockElement ) {\n\t\t\treturn 0;\n\t\t}\n\n\t\t// Calculate the indent using the block icon of the root block.\n\t\t// Using a classname selector here might be flaky and could be\n\t\t// improved.\n\t\tconst targetElementRect = targetElement.getBoundingClientRect();\n\t\tconst rootBlockIconElement = rootBlockElement.querySelector(\n\t\t\t'.block-editor-block-icon'\n\t\t);\n\t\tconst rootBlockIconRect = rootBlockIconElement.getBoundingClientRect();\n\t\treturn rootBlockIconRect.right - targetElementRect.left;\n\t}, [ rootBlockElement, targetElement ] );\n\n\tconst style = useMemo( () => {\n\t\tif ( ! targetElement ) {\n\t\t\treturn {};\n\t\t}\n\n\t\tconst indent = getDropIndicatorIndent();\n\n\t\treturn {\n\t\t\twidth: targetElement.offsetWidth - indent,\n\t\t};\n\t}, [ getDropIndicatorIndent, targetElement ] );\n\n\tconst popoverAnchor = useMemo( () => {\n\t\tconst isValidDropPosition =\n\t\t\tdropPosition === 'top' ||\n\t\t\tdropPosition === 'bottom' ||\n\t\t\tdropPosition === 'inside';\n\t\tif ( ! targetElement || ! isValidDropPosition ) {\n\t\t\treturn undefined;\n\t\t}\n\n\t\treturn {\n\t\t\townerDocument: targetElement.ownerDocument,\n\t\t\tgetBoundingClientRect() {\n\t\t\t\tconst rect = targetElement.getBoundingClientRect();\n\t\t\t\tconst indent = getDropIndicatorIndent();\n\n\t\t\t\tconst left = rect.left + indent;\n\t\t\t\tconst right = rect.right;\n\t\t\t\tlet top = 0;\n\t\t\t\tlet bottom = 0;\n\n\t\t\t\tif ( dropPosition === 'top' ) {\n\t\t\t\t\ttop = rect.top;\n\t\t\t\t\tbottom = rect.top;\n\t\t\t\t} else {\n\t\t\t\t\t// `dropPosition` is either `bottom` or `inside`\n\t\t\t\t\ttop = rect.bottom;\n\t\t\t\t\tbottom = rect.bottom;\n\t\t\t\t}\n\n\t\t\t\tconst width = right - left;\n\t\t\t\tconst height = bottom - top;\n\n\t\t\t\treturn new window.DOMRect( left, top, width, height );\n\t\t\t},\n\t\t};\n\t}, [ targetElement, dropPosition, getDropIndicatorIndent ] );\n\n\tif ( ! targetElement ) {\n\t\treturn null;\n\t}\n\n\treturn (\n\t\t<Popover\n\t\t\tanimate={ false }\n\t\t\tanchor={ popoverAnchor }\n\t\t\tfocusOnMount={ false }\n\t\t\tclassName=\"block-editor-list-view-drop-indicator\"\n\t\t\tvariant=\"unstyled\"\n\t\t>\n\t\t\t<div\n\t\t\t\tstyle={ style }\n\t\t\t\tclassName=\"block-editor-list-view-drop-indicator__line\"\n\t\t\t/>\n\t\t</Popover>\n\t);\n}\n"]}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { createElement } from "@wordpress/element";
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* WordPress dependencies
|
|
5
|
+
*/
|
|
6
|
+
import { chevronRightSmall, chevronLeftSmall, Icon } from '@wordpress/icons';
|
|
7
|
+
import { isRTL } from '@wordpress/i18n';
|
|
8
|
+
export default function ListViewExpander(_ref) {
|
|
9
|
+
let {
|
|
10
|
+
onClick
|
|
11
|
+
} = _ref;
|
|
12
|
+
return (// Keyboard events are handled by TreeGrid see: components/src/tree-grid/index.js
|
|
13
|
+
//
|
|
14
|
+
// The expander component is implemented as a pseudo element in the w3 example
|
|
15
|
+
// https://www.w3.org/TR/wai-aria-practices/examples/treegrid/treegrid-1.html
|
|
16
|
+
//
|
|
17
|
+
// We've mimicked this by adding an icon with aria-hidden set to true to hide this from the accessibility tree.
|
|
18
|
+
// For the current tree grid implementation, please do not try to make this a button.
|
|
19
|
+
//
|
|
20
|
+
// eslint-disable-next-line jsx-a11y/click-events-have-key-events,jsx-a11y/no-static-element-interactions
|
|
21
|
+
createElement("span", {
|
|
22
|
+
className: "block-editor-list-view__expander",
|
|
23
|
+
onClick: event => onClick(event, {
|
|
24
|
+
forceToggle: true
|
|
25
|
+
}),
|
|
26
|
+
"aria-hidden": "true"
|
|
27
|
+
}, createElement(Icon, {
|
|
28
|
+
icon: isRTL() ? chevronLeftSmall : chevronRightSmall
|
|
29
|
+
}))
|
|
30
|
+
);
|
|
31
|
+
}
|
|
32
|
+
//# sourceMappingURL=expander.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["@wordpress/block-editor/src/components/off-canvas-editor/expander.js"],"names":["chevronRightSmall","chevronLeftSmall","Icon","isRTL","ListViewExpander","onClick","event","forceToggle"],"mappings":";;AAAA;AACA;AACA;AACA,SAASA,iBAAT,EAA4BC,gBAA5B,EAA8CC,IAA9C,QAA0D,kBAA1D;AACA,SAASC,KAAT,QAAsB,iBAAtB;AAEA,eAAe,SAASC,gBAAT,OAAyC;AAAA,MAAd;AAAEC,IAAAA;AAAF,GAAc;AACvD,SACC;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACC,MAAA,SAAS,EAAC,kCADX;AAEC,MAAA,OAAO,EAAKC,KAAF,IAAaD,OAAO,CAAEC,KAAF,EAAS;AAAEC,QAAAA,WAAW,EAAE;AAAf,OAAT,CAF/B;AAGC,qBAAY;AAHb,OAKC,cAAC,IAAD;AAAM,MAAA,IAAI,EAAGJ,KAAK,KAAKF,gBAAL,GAAwBD;AAA1C,MALD;AAVD;AAkBA","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { chevronRightSmall, chevronLeftSmall, Icon } from '@wordpress/icons';\nimport { isRTL } from '@wordpress/i18n';\n\nexport default function ListViewExpander( { onClick } ) {\n\treturn (\n\t\t// Keyboard events are handled by TreeGrid see: components/src/tree-grid/index.js\n\t\t//\n\t\t// The expander component is implemented as a pseudo element in the w3 example\n\t\t// https://www.w3.org/TR/wai-aria-practices/examples/treegrid/treegrid-1.html\n\t\t//\n\t\t// We've mimicked this by adding an icon with aria-hidden set to true to hide this from the accessibility tree.\n\t\t// For the current tree grid implementation, please do not try to make this a button.\n\t\t//\n\t\t// eslint-disable-next-line jsx-a11y/click-events-have-key-events,jsx-a11y/no-static-element-interactions\n\t\t<span\n\t\t\tclassName=\"block-editor-list-view__expander\"\n\t\t\tonClick={ ( event ) => onClick( event, { forceToggle: true } ) }\n\t\t\taria-hidden=\"true\"\n\t\t>\n\t\t\t<Icon icon={ isRTL() ? chevronLeftSmall : chevronRightSmall } />\n\t\t</span>\n\t);\n}\n"]}
|
|
@@ -0,0 +1,181 @@
|
|
|
1
|
+
import { createElement } from "@wordpress/element";
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* WordPress dependencies
|
|
5
|
+
*/
|
|
6
|
+
import { useMergeRefs, __experimentalUseFixedWindowList as useFixedWindowList } from '@wordpress/compose';
|
|
7
|
+
import { __experimentalTreeGrid as TreeGrid } from '@wordpress/components';
|
|
8
|
+
import { AsyncModeProvider, useSelect } from '@wordpress/data';
|
|
9
|
+
import { useCallback, useEffect, useMemo, useRef, useReducer, forwardRef } from '@wordpress/element';
|
|
10
|
+
import { __ } from '@wordpress/i18n';
|
|
11
|
+
/**
|
|
12
|
+
* Internal dependencies
|
|
13
|
+
*/
|
|
14
|
+
|
|
15
|
+
import ListViewBranch from './branch';
|
|
16
|
+
import { ListViewContext } from './context';
|
|
17
|
+
import ListViewDropIndicator from './drop-indicator';
|
|
18
|
+
import useBlockSelection from './use-block-selection';
|
|
19
|
+
import useListViewClientIds from './use-list-view-client-ids';
|
|
20
|
+
import useListViewDropZone from './use-list-view-drop-zone';
|
|
21
|
+
import useListViewExpandSelectedItem from './use-list-view-expand-selected-item';
|
|
22
|
+
import { store as blockEditorStore } from '../../store';
|
|
23
|
+
|
|
24
|
+
const expanded = (state, action) => {
|
|
25
|
+
if (Array.isArray(action.clientIds)) {
|
|
26
|
+
return { ...state,
|
|
27
|
+
...action.clientIds.reduce((newState, id) => ({ ...newState,
|
|
28
|
+
[id]: action.type === 'expand'
|
|
29
|
+
}), {})
|
|
30
|
+
};
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
return state;
|
|
34
|
+
};
|
|
35
|
+
|
|
36
|
+
export const BLOCK_LIST_ITEM_HEIGHT = 36;
|
|
37
|
+
/**
|
|
38
|
+
* Show a hierarchical list of blocks.
|
|
39
|
+
*
|
|
40
|
+
* @param {Object} props Components props.
|
|
41
|
+
* @param {string} props.id An HTML element id for the root element of ListView.
|
|
42
|
+
* @param {Array} props.blocks Custom subset of block client IDs to be used instead of the default hierarchy.
|
|
43
|
+
* @param {boolean} props.showBlockMovers Flag to enable block movers
|
|
44
|
+
* @param {boolean} props.isExpanded Flag to determine whether nested levels are expanded by default.
|
|
45
|
+
* @param {boolean} props.selectBlockInCanvas Flag to determine whether the list view should be a block selection mechanism,.
|
|
46
|
+
* @param {Object} ref Forwarded ref
|
|
47
|
+
*/
|
|
48
|
+
|
|
49
|
+
function __ExperimentalOffCanvasEditor(_ref, ref) {
|
|
50
|
+
let {
|
|
51
|
+
id,
|
|
52
|
+
blocks,
|
|
53
|
+
showBlockMovers = false,
|
|
54
|
+
isExpanded = false,
|
|
55
|
+
selectBlockInCanvas = true
|
|
56
|
+
} = _ref;
|
|
57
|
+
const {
|
|
58
|
+
clientIdsTree,
|
|
59
|
+
draggedClientIds,
|
|
60
|
+
selectedClientIds
|
|
61
|
+
} = useListViewClientIds(blocks);
|
|
62
|
+
const {
|
|
63
|
+
visibleBlockCount,
|
|
64
|
+
shouldShowInnerBlocks
|
|
65
|
+
} = useSelect(select => {
|
|
66
|
+
const {
|
|
67
|
+
getGlobalBlockCount,
|
|
68
|
+
getClientIdsOfDescendants,
|
|
69
|
+
__unstableGetEditorMode
|
|
70
|
+
} = select(blockEditorStore);
|
|
71
|
+
const draggedBlockCount = (draggedClientIds === null || draggedClientIds === void 0 ? void 0 : draggedClientIds.length) > 0 ? getClientIdsOfDescendants(draggedClientIds).length + 1 : 0;
|
|
72
|
+
return {
|
|
73
|
+
visibleBlockCount: getGlobalBlockCount() - draggedBlockCount,
|
|
74
|
+
shouldShowInnerBlocks: __unstableGetEditorMode() !== 'zoom-out'
|
|
75
|
+
};
|
|
76
|
+
}, [draggedClientIds]);
|
|
77
|
+
const {
|
|
78
|
+
updateBlockSelection
|
|
79
|
+
} = useBlockSelection();
|
|
80
|
+
const [expandedState, setExpandedState] = useReducer(expanded, {});
|
|
81
|
+
const {
|
|
82
|
+
ref: dropZoneRef,
|
|
83
|
+
target: blockDropTarget
|
|
84
|
+
} = useListViewDropZone();
|
|
85
|
+
const elementRef = useRef();
|
|
86
|
+
const treeGridRef = useMergeRefs([elementRef, dropZoneRef, ref]);
|
|
87
|
+
const isMounted = useRef(false);
|
|
88
|
+
const {
|
|
89
|
+
setSelectedTreeId
|
|
90
|
+
} = useListViewExpandSelectedItem({
|
|
91
|
+
firstSelectedBlockClientId: selectedClientIds[0],
|
|
92
|
+
setExpandedState
|
|
93
|
+
});
|
|
94
|
+
const selectEditorBlock = useCallback((event, clientId) => {
|
|
95
|
+
updateBlockSelection(event, clientId);
|
|
96
|
+
setSelectedTreeId(clientId);
|
|
97
|
+
}, [setSelectedTreeId, updateBlockSelection]);
|
|
98
|
+
useEffect(() => {
|
|
99
|
+
isMounted.current = true;
|
|
100
|
+
}, []); // List View renders a fixed number of items and relies on each having a fixed item height of 36px.
|
|
101
|
+
// If this value changes, we should also change the itemHeight value set in useFixedWindowList.
|
|
102
|
+
// See: https://github.com/WordPress/gutenberg/pull/35230 for additional context.
|
|
103
|
+
|
|
104
|
+
const [fixedListWindow] = useFixedWindowList(elementRef, BLOCK_LIST_ITEM_HEIGHT, visibleBlockCount, {
|
|
105
|
+
useWindowing: true,
|
|
106
|
+
windowOverscan: 40
|
|
107
|
+
});
|
|
108
|
+
const expand = useCallback(clientId => {
|
|
109
|
+
if (!clientId) {
|
|
110
|
+
return;
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
setExpandedState({
|
|
114
|
+
type: 'expand',
|
|
115
|
+
clientIds: [clientId]
|
|
116
|
+
});
|
|
117
|
+
}, [setExpandedState]);
|
|
118
|
+
const collapse = useCallback(clientId => {
|
|
119
|
+
if (!clientId) {
|
|
120
|
+
return;
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
setExpandedState({
|
|
124
|
+
type: 'collapse',
|
|
125
|
+
clientIds: [clientId]
|
|
126
|
+
});
|
|
127
|
+
}, [setExpandedState]);
|
|
128
|
+
const expandRow = useCallback(row => {
|
|
129
|
+
var _row$dataset;
|
|
130
|
+
|
|
131
|
+
expand(row === null || row === void 0 ? void 0 : (_row$dataset = row.dataset) === null || _row$dataset === void 0 ? void 0 : _row$dataset.block);
|
|
132
|
+
}, [expand]);
|
|
133
|
+
const collapseRow = useCallback(row => {
|
|
134
|
+
var _row$dataset2;
|
|
135
|
+
|
|
136
|
+
collapse(row === null || row === void 0 ? void 0 : (_row$dataset2 = row.dataset) === null || _row$dataset2 === void 0 ? void 0 : _row$dataset2.block);
|
|
137
|
+
}, [collapse]);
|
|
138
|
+
const focusRow = useCallback((event, startRow, endRow) => {
|
|
139
|
+
if (event.shiftKey) {
|
|
140
|
+
var _startRow$dataset, _endRow$dataset;
|
|
141
|
+
|
|
142
|
+
updateBlockSelection(event, startRow === null || startRow === void 0 ? void 0 : (_startRow$dataset = startRow.dataset) === null || _startRow$dataset === void 0 ? void 0 : _startRow$dataset.block, endRow === null || endRow === void 0 ? void 0 : (_endRow$dataset = endRow.dataset) === null || _endRow$dataset === void 0 ? void 0 : _endRow$dataset.block);
|
|
143
|
+
}
|
|
144
|
+
}, [updateBlockSelection]);
|
|
145
|
+
const contextValue = useMemo(() => ({
|
|
146
|
+
isTreeGridMounted: isMounted.current,
|
|
147
|
+
draggedClientIds,
|
|
148
|
+
expandedState,
|
|
149
|
+
expand,
|
|
150
|
+
collapse
|
|
151
|
+
}), [isMounted.current, draggedClientIds, expandedState, expand, collapse]);
|
|
152
|
+
return createElement(AsyncModeProvider, {
|
|
153
|
+
value: true
|
|
154
|
+
}, createElement(ListViewDropIndicator, {
|
|
155
|
+
listViewRef: elementRef,
|
|
156
|
+
blockDropTarget: blockDropTarget
|
|
157
|
+
}), createElement(TreeGrid, {
|
|
158
|
+
id: id,
|
|
159
|
+
className: "block-editor-list-view-tree",
|
|
160
|
+
"aria-label": __('Block navigation structure'),
|
|
161
|
+
ref: treeGridRef,
|
|
162
|
+
onCollapseRow: collapseRow,
|
|
163
|
+
onExpandRow: expandRow,
|
|
164
|
+
onFocusRow: focusRow,
|
|
165
|
+
applicationAriaLabel: __('Block navigation structure')
|
|
166
|
+
}, createElement(ListViewContext.Provider, {
|
|
167
|
+
value: contextValue
|
|
168
|
+
}, createElement(ListViewBranch, {
|
|
169
|
+
blocks: clientIdsTree,
|
|
170
|
+
selectBlock: selectEditorBlock,
|
|
171
|
+
showBlockMovers: showBlockMovers,
|
|
172
|
+
fixedListWindow: fixedListWindow,
|
|
173
|
+
selectedClientIds: selectedClientIds,
|
|
174
|
+
isExpanded: isExpanded,
|
|
175
|
+
shouldShowInnerBlocks: shouldShowInnerBlocks,
|
|
176
|
+
selectBlockInCanvas: selectBlockInCanvas
|
|
177
|
+
}))));
|
|
178
|
+
}
|
|
179
|
+
|
|
180
|
+
export default forwardRef(__ExperimentalOffCanvasEditor);
|
|
181
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["@wordpress/block-editor/src/components/off-canvas-editor/index.js"],"names":["useMergeRefs","__experimentalUseFixedWindowList","useFixedWindowList","__experimentalTreeGrid","TreeGrid","AsyncModeProvider","useSelect","useCallback","useEffect","useMemo","useRef","useReducer","forwardRef","__","ListViewBranch","ListViewContext","ListViewDropIndicator","useBlockSelection","useListViewClientIds","useListViewDropZone","useListViewExpandSelectedItem","store","blockEditorStore","expanded","state","action","Array","isArray","clientIds","reduce","newState","id","type","BLOCK_LIST_ITEM_HEIGHT","__ExperimentalOffCanvasEditor","ref","blocks","showBlockMovers","isExpanded","selectBlockInCanvas","clientIdsTree","draggedClientIds","selectedClientIds","visibleBlockCount","shouldShowInnerBlocks","select","getGlobalBlockCount","getClientIdsOfDescendants","__unstableGetEditorMode","draggedBlockCount","length","updateBlockSelection","expandedState","setExpandedState","dropZoneRef","target","blockDropTarget","elementRef","treeGridRef","isMounted","setSelectedTreeId","firstSelectedBlockClientId","selectEditorBlock","event","clientId","current","fixedListWindow","useWindowing","windowOverscan","expand","collapse","expandRow","row","dataset","block","collapseRow","focusRow","startRow","endRow","shiftKey","contextValue","isTreeGridMounted"],"mappings":";;AAAA;AACA;AACA;AACA,SACCA,YADD,EAECC,gCAAgC,IAAIC,kBAFrC,QAGO,oBAHP;AAIA,SAASC,sBAAsB,IAAIC,QAAnC,QAAmD,uBAAnD;AACA,SAASC,iBAAT,EAA4BC,SAA5B,QAA6C,iBAA7C;AACA,SACCC,WADD,EAECC,SAFD,EAGCC,OAHD,EAICC,MAJD,EAKCC,UALD,EAMCC,UAND,QAOO,oBAPP;AAQA,SAASC,EAAT,QAAmB,iBAAnB;AAEA;AACA;AACA;;AACA,OAAOC,cAAP,MAA2B,UAA3B;AACA,SAASC,eAAT,QAAgC,WAAhC;AACA,OAAOC,qBAAP,MAAkC,kBAAlC;AACA,OAAOC,iBAAP,MAA8B,uBAA9B;AACA,OAAOC,oBAAP,MAAiC,4BAAjC;AACA,OAAOC,mBAAP,MAAgC,2BAAhC;AACA,OAAOC,6BAAP,MAA0C,sCAA1C;AACA,SAASC,KAAK,IAA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;AAMC,IAAA,UAAU,EAAGJ,UANd;AAOC,IAAA,qBAAqB,EAAGM,qBAPzB;AAQC,IAAA,mBAAmB,EAAGL;AARvB,IADD,CAVD,CALD,CADD;AA+BA;;AACD,eAAe3B,UAAU,CAAEsB,6BAAF,CAAzB","sourcesContent":["/**\n * WordPress dependencies\n */\nimport {\n\tuseMergeRefs,\n\t__experimentalUseFixedWindowList as useFixedWindowList,\n} from '@wordpress/compose';\nimport { __experimentalTreeGrid as TreeGrid } 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 {boolean} props.selectBlockInCanvas Flag to determine whether the list view should be a block selection mechanism,.\n * @param {Object} ref Forwarded ref\n */\nfunction __ExperimentalOffCanvasEditor(\n\t{\n\t\tid,\n\t\tblocks,\n\t\tshowBlockMovers = false,\n\t\tisExpanded = false,\n\t\tselectBlockInCanvas = true,\n\t},\n\tref\n) {\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, clientId ) => {\n\t\t\tupdateBlockSelection( event, clientId );\n\t\t\tsetSelectedTreeId( clientId );\n\t\t},\n\t\t[ setSelectedTreeId, updateBlockSelection ]\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( clientId ) => {\n\t\t\tif ( ! clientId ) {\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tsetExpandedState( { type: 'expand', clientIds: [ clientId ] } );\n\t\t},\n\t\t[ setExpandedState ]\n\t);\n\tconst collapse = useCallback(\n\t\t( clientId ) => {\n\t\t\tif ( ! clientId ) {\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tsetExpandedState( { type: 'collapse', clientIds: [ clientId ] } );\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} ),\n\t\t[ isMounted.current, draggedClientIds, expandedState, expand, collapse ]\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<TreeGrid\n\t\t\t\tid={ id }\n\t\t\t\tclassName=\"block-editor-list-view-tree\"\n\t\t\t\taria-label={ __( 'Block navigation structure' ) }\n\t\t\t\tref={ treeGridRef }\n\t\t\t\tonCollapseRow={ collapseRow }\n\t\t\t\tonExpandRow={ expandRow }\n\t\t\t\tonFocusRow={ focusRow }\n\t\t\t\tapplicationAriaLabel={ __( 'Block navigation structure' ) }\n\t\t\t>\n\t\t\t\t<ListViewContext.Provider value={ contextValue }>\n\t\t\t\t\t<ListViewBranch\n\t\t\t\t\t\tblocks={ clientIdsTree }\n\t\t\t\t\t\tselectBlock={ selectEditorBlock }\n\t\t\t\t\t\tshowBlockMovers={ showBlockMovers }\n\t\t\t\t\t\tfixedListWindow={ fixedListWindow }\n\t\t\t\t\t\tselectedClientIds={ selectedClientIds }\n\t\t\t\t\t\tisExpanded={ isExpanded }\n\t\t\t\t\t\tshouldShowInnerBlocks={ shouldShowInnerBlocks }\n\t\t\t\t\t\tselectBlockInCanvas={ selectBlockInCanvas }\n\t\t\t\t\t/>\n\t\t\t\t</ListViewContext.Provider>\n\t\t\t</TreeGrid>\n\t\t</AsyncModeProvider>\n\t);\n}\nexport default forwardRef( __ExperimentalOffCanvasEditor );\n"]}
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import _extends from "@babel/runtime/helpers/esm/extends";
|
|
2
|
+
import { createElement } from "@wordpress/element";
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* External dependencies
|
|
6
|
+
*/
|
|
7
|
+
import { animated } from '@react-spring/web';
|
|
8
|
+
import classnames from 'classnames';
|
|
9
|
+
/**
|
|
10
|
+
* WordPress dependencies
|
|
11
|
+
*/
|
|
12
|
+
|
|
13
|
+
import { __experimentalTreeGridRow as TreeGridRow } from '@wordpress/components';
|
|
14
|
+
/**
|
|
15
|
+
* Internal dependencies
|
|
16
|
+
*/
|
|
17
|
+
|
|
18
|
+
import useMovingAnimation from '../use-moving-animation';
|
|
19
|
+
const AnimatedTreeGridRow = animated(TreeGridRow);
|
|
20
|
+
export default function ListViewLeaf(_ref) {
|
|
21
|
+
let {
|
|
22
|
+
isSelected,
|
|
23
|
+
position,
|
|
24
|
+
level,
|
|
25
|
+
rowCount,
|
|
26
|
+
children,
|
|
27
|
+
className,
|
|
28
|
+
path,
|
|
29
|
+
...props
|
|
30
|
+
} = _ref;
|
|
31
|
+
const ref = useMovingAnimation({
|
|
32
|
+
isSelected,
|
|
33
|
+
adjustScrolling: false,
|
|
34
|
+
enableAnimation: true,
|
|
35
|
+
triggerAnimationOnChange: path
|
|
36
|
+
});
|
|
37
|
+
return createElement(AnimatedTreeGridRow, _extends({
|
|
38
|
+
ref: ref,
|
|
39
|
+
className: classnames('block-editor-list-view-leaf', className),
|
|
40
|
+
level: level,
|
|
41
|
+
positionInSet: position,
|
|
42
|
+
setSize: rowCount
|
|
43
|
+
}, props), children);
|
|
44
|
+
}
|
|
45
|
+
//# sourceMappingURL=leaf.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["@wordpress/block-editor/src/components/off-canvas-editor/leaf.js"],"names":["animated","classnames","__experimentalTreeGridRow","TreeGridRow","useMovingAnimation","AnimatedTreeGridRow","ListViewLeaf","isSelected","position","level","rowCount","children","className","path","props","ref","adjustScrolling","enableAnimation","triggerAnimationOnChange"],"mappings":";;;AAAA;AACA;AACA;AACA,SAASA,QAAT,QAAyB,mBAAzB;AACA,OAAOC,UAAP,MAAuB,YAAvB;AAEA;AACA;AACA;;AACA,SAASC,yBAAyB,IAAIC,WAAtC,QAAyD,uBAAzD;AAEA;AACA;AACA;;AACA,OAAOC,kBAAP,MAA+B,yBAA/B;AAEA,MAAMC,mBAAmB,GAAGL,QAAQ,CAAEG,WAAF,CAApC;AAEA,eAAe,SAASG,YAAT,OASX;AAAA,MATkC;AACrCC,IAAAA,UADqC;AAErCC,IAAAA,QAFqC;AAGrCC,IAAAA,KAHqC;AAIrCC,IAAAA,QAJqC;AAKrCC,IAAAA,QALqC;AAMrCC,IAAAA,SANqC;AAOrCC,IAAAA,IAPqC;AAQrC,OAAGC;AARkC,GASlC;AACH,QAAMC,GAAG,GAAGX,kBAAkB,CAAE;AAC/BG,IAAAA,UAD+B;AAE/BS,IAAAA,eAAe,EAAE,KAFc;AAG/BC,IAAAA,eAAe,EAAE,IAHc;AAI/BC,IAAAA,wBAAwB,EAAEL;AAJK,GAAF,CAA9B;AAOA,SACC,cAAC,mBAAD;AACC,IAAA,GAAG,EAAGE,GADP;AAEC,IAAA,SAAS,EAAGd,UAAU,CAAE,6BAAF,EAAiCW,SAAjC,CAFvB;AAGC,IAAA,KAAK,EAAGH,KAHT;AAIC,IAAA,aAAa,EAAGD,QAJjB;AAKC,IAAA,OAAO,EAAGE;AALX,KAMMI,KANN,GAQGH,QARH,CADD;AAYA","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';\n\n/**\n * Internal dependencies\n */\nimport useMovingAnimation from '../use-moving-animation';\n\nconst AnimatedTreeGridRow = animated( TreeGridRow );\n\nexport default function ListViewLeaf( {\n\tisSelected,\n\tposition,\n\tlevel,\n\trowCount,\n\tchildren,\n\tclassName,\n\tpath,\n\t...props\n} ) {\n\tconst ref = useMovingAnimation( {\n\t\tisSelected,\n\t\tadjustScrolling: false,\n\t\tenableAnimation: true,\n\t\ttriggerAnimationOnChange: path,\n\t} );\n\n\treturn (\n\t\t<AnimatedTreeGridRow\n\t\t\tref={ ref }\n\t\t\tclassName={ classnames( 'block-editor-list-view-leaf', className ) }\n\t\t\tlevel={ level }\n\t\t\tpositionInSet={ position }\n\t\t\tsetSize={ rowCount }\n\t\t\t{ ...props }\n\t\t>\n\t\t\t{ children }\n\t\t</AnimatedTreeGridRow>\n\t);\n}\n"]}
|
|
@@ -0,0 +1,124 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* WordPress dependencies
|
|
3
|
+
*/
|
|
4
|
+
import { speak } from '@wordpress/a11y';
|
|
5
|
+
import { __, sprintf } from '@wordpress/i18n';
|
|
6
|
+
import { useDispatch, useSelect } from '@wordpress/data';
|
|
7
|
+
import { useCallback } from '@wordpress/element';
|
|
8
|
+
import { UP, DOWN, HOME, END } from '@wordpress/keycodes';
|
|
9
|
+
import { store as blocksStore } from '@wordpress/blocks';
|
|
10
|
+
/**
|
|
11
|
+
* Internal dependencies
|
|
12
|
+
*/
|
|
13
|
+
|
|
14
|
+
import { store as blockEditorStore } from '../../store';
|
|
15
|
+
import { getCommonDepthClientIds } from './utils';
|
|
16
|
+
export default function useBlockSelection() {
|
|
17
|
+
const {
|
|
18
|
+
clearSelectedBlock,
|
|
19
|
+
multiSelect,
|
|
20
|
+
selectBlock
|
|
21
|
+
} = useDispatch(blockEditorStore);
|
|
22
|
+
const {
|
|
23
|
+
getBlockName,
|
|
24
|
+
getBlockParents,
|
|
25
|
+
getBlockSelectionStart,
|
|
26
|
+
getBlockSelectionEnd,
|
|
27
|
+
getSelectedBlockClientIds,
|
|
28
|
+
hasMultiSelection,
|
|
29
|
+
hasSelectedBlock
|
|
30
|
+
} = useSelect(blockEditorStore);
|
|
31
|
+
const {
|
|
32
|
+
getBlockType
|
|
33
|
+
} = useSelect(blocksStore);
|
|
34
|
+
const updateBlockSelection = useCallback(async (event, clientId, destinationClientId) => {
|
|
35
|
+
if (!(event !== null && event !== void 0 && event.shiftKey)) {
|
|
36
|
+
selectBlock(clientId);
|
|
37
|
+
return;
|
|
38
|
+
} // To handle multiple block selection via the `SHIFT` key, prevent
|
|
39
|
+
// the browser default behavior of opening the link in a new window.
|
|
40
|
+
|
|
41
|
+
|
|
42
|
+
event.preventDefault();
|
|
43
|
+
const isKeyPress = event.type === 'keydown' && (event.keyCode === UP || event.keyCode === DOWN || event.keyCode === HOME || event.keyCode === END); // Handle clicking on a block when no blocks are selected, and return early.
|
|
44
|
+
|
|
45
|
+
if (!isKeyPress && !hasSelectedBlock() && !hasMultiSelection()) {
|
|
46
|
+
selectBlock(clientId, null);
|
|
47
|
+
return;
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
const selectedBlocks = getSelectedBlockClientIds();
|
|
51
|
+
const clientIdWithParents = [...getBlockParents(clientId), clientId];
|
|
52
|
+
|
|
53
|
+
if (isKeyPress && !selectedBlocks.some(blockId => clientIdWithParents.includes(blockId))) {
|
|
54
|
+
// Ensure that shift-selecting blocks via the keyboard only
|
|
55
|
+
// expands the current selection if focusing over already
|
|
56
|
+
// selected blocks. Otherwise, clear the selection so that
|
|
57
|
+
// a user can create a new selection entirely by keyboard.
|
|
58
|
+
await clearSelectedBlock();
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
let startTarget = getBlockSelectionStart();
|
|
62
|
+
let endTarget = clientId; // Handle keyboard behavior for selecting multiple blocks.
|
|
63
|
+
|
|
64
|
+
if (isKeyPress) {
|
|
65
|
+
if (!hasSelectedBlock() && !hasMultiSelection()) {
|
|
66
|
+
// Set the starting point of the selection to the currently
|
|
67
|
+
// focused block, if there are no blocks currently selected.
|
|
68
|
+
// This ensures that as the selection is expanded or contracted,
|
|
69
|
+
// the starting point of the selection is anchored to that block.
|
|
70
|
+
startTarget = clientId;
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
if (destinationClientId) {
|
|
74
|
+
// If the user presses UP or DOWN, we want to ensure that the block they're
|
|
75
|
+
// moving to is the target for selection, and not the currently focused one.
|
|
76
|
+
endTarget = destinationClientId;
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
const startParents = getBlockParents(startTarget);
|
|
81
|
+
const endParents = getBlockParents(endTarget);
|
|
82
|
+
const {
|
|
83
|
+
start,
|
|
84
|
+
end
|
|
85
|
+
} = getCommonDepthClientIds(startTarget, endTarget, startParents, endParents);
|
|
86
|
+
await multiSelect(start, end, null); // Announce deselected block, or number of deselected blocks if
|
|
87
|
+
// the total number of blocks deselected is greater than one.
|
|
88
|
+
|
|
89
|
+
const updatedSelectedBlocks = getSelectedBlockClientIds(); // If the selection is greater than 1 and the Home or End keys
|
|
90
|
+
// were used to generate the selection, then skip announcing the
|
|
91
|
+
// deselected blocks.
|
|
92
|
+
|
|
93
|
+
if ((event.keyCode === HOME || event.keyCode === END) && updatedSelectedBlocks.length > 1) {
|
|
94
|
+
return;
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
const selectionDiff = selectedBlocks.filter(blockId => !updatedSelectedBlocks.includes(blockId));
|
|
98
|
+
let label;
|
|
99
|
+
|
|
100
|
+
if (selectionDiff.length === 1) {
|
|
101
|
+
var _getBlockType;
|
|
102
|
+
|
|
103
|
+
const title = (_getBlockType = getBlockType(getBlockName(selectionDiff[0]))) === null || _getBlockType === void 0 ? void 0 : _getBlockType.title;
|
|
104
|
+
|
|
105
|
+
if (title) {
|
|
106
|
+
label = sprintf(
|
|
107
|
+
/* translators: %s: block name */
|
|
108
|
+
__('%s deselected.'), title);
|
|
109
|
+
}
|
|
110
|
+
} else if (selectionDiff.length > 1) {
|
|
111
|
+
label = sprintf(
|
|
112
|
+
/* translators: %s: number of deselected blocks */
|
|
113
|
+
__('%s blocks deselected.'), selectionDiff.length);
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
if (label) {
|
|
117
|
+
speak(label);
|
|
118
|
+
}
|
|
119
|
+
}, [clearSelectedBlock, getBlockName, getBlockType, getBlockParents, getBlockSelectionStart, getBlockSelectionEnd, getSelectedBlockClientIds, hasMultiSelection, hasSelectedBlock, multiSelect, selectBlock]);
|
|
120
|
+
return {
|
|
121
|
+
updateBlockSelection
|
|
122
|
+
};
|
|
123
|
+
}
|
|
124
|
+
//# sourceMappingURL=use-block-selection.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["@wordpress/block-editor/src/components/off-canvas-editor/use-block-selection.js"],"names":["speak","__","sprintf","useDispatch","useSelect","useCallback","UP","DOWN","HOME","END","store","blocksStore","blockEditorStore","getCommonDepthClientIds","useBlockSelection","clearSelectedBlock","multiSelect","selectBlock","getBlockName","getBlockParents","getBlockSelectionStart","getBlockSelectionEnd","getSelectedBlockClientIds","hasMultiSelection","hasSelectedBlock","getBlockType","updateBlockSelection","event","clientId","destinationClientId","shiftKey","preventDefault","isKeyPress","type","keyCode","selectedBlocks","clientIdWithParents","some","blockId","includes","startTarget","endTarget","startParents","endParents","start","end","updatedSelectedBlocks","length","selectionDiff","filter","label","title"],"mappings":"AAAA;AACA;AACA;AACA,SAASA,KAAT,QAAsB,iBAAtB;AACA,SAASC,EAAT,EAAaC,OAAb,QAA4B,iBAA5B;AACA,SAASC,WAAT,EAAsBC,SAAtB,QAAuC,iBAAvC;AACA,SAASC,WAAT,QAA4B,oBAA5B;AACA,SAASC,EAAT,EAAaC,IAAb,EAAmBC,IAAnB,EAAyBC,GAAzB,QAAoC,qBAApC;AACA,SAASC,KAAK,IAAIC,WAAlB,QAAqC,mBAArC;AAEA;AACA;AACA;;AACA,SAASD,KAAK,IAAIE,gBAAlB,QAA0C,aAA1C;AACA,SAASC,uBAAT,QAAwC,SAAxC;AAEA,eAAe,SAASC,iBAAT,GAA6B;AAC3C,QAAM;AAAEC,IAAAA,kBAAF;AAAsBC,IAAAA,WAAtB;AAAmCC,IAAAA;AAAnC,MACLd,WAAW,CAAES,gBAAF,CADZ;AAEA,QAAM;AACLM,IAAAA,YADK;AAELC,IAAAA,eAFK;AAGLC,IAAAA,sBAHK;AAILC,IAAAA,oBAJK;AAKLC,IAAAA,yBALK;AAMLC,IAAAA,iBANK;AAOLC,IAAAA;AAPK,MAQFpB,SAAS,CAAEQ,gBAAF,CARb;AAUA,QAAM;AAAEa,IAAAA;AAAF,MAAmBrB,SAAS,CAAEO,WAAF,CAAlC;AAEA,QAAMe,oBAAoB,GAAGrB,WAAW,CAC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,QAAKG,KAAL,EAAa;AACZlD,MAAAA,KAAK,CAAEkD,KAAF,CAAL;AACA;AACD,GAtHsC,EAuHvC,CACCnC,kBADD,EAECG,YAFD,EAGCO,YAHD,EAICN,eAJD,EAKCC,sBALD,EAMCC,oBAND,EAOCC,yBAPD,EAQCC,iBARD,EASCC,gBATD,EAUCR,WAVD,EAWCC,WAXD,CAvHuC,CAAxC;AAsIA,SAAO;AACNS,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\tgetBlockSelectionEnd,\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\tgetBlockSelectionEnd,\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,24 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* WordPress dependencies
|
|
3
|
+
*/
|
|
4
|
+
import { useSelect } from '@wordpress/data';
|
|
5
|
+
/**
|
|
6
|
+
* Internal dependencies
|
|
7
|
+
*/
|
|
8
|
+
|
|
9
|
+
import { store as blockEditorStore } from '../../store';
|
|
10
|
+
export default function useListViewClientIds(blocks) {
|
|
11
|
+
return useSelect(select => {
|
|
12
|
+
const {
|
|
13
|
+
getDraggedBlockClientIds,
|
|
14
|
+
getSelectedBlockClientIds,
|
|
15
|
+
__unstableGetClientIdsTree
|
|
16
|
+
} = select(blockEditorStore);
|
|
17
|
+
return {
|
|
18
|
+
selectedClientIds: getSelectedBlockClientIds(),
|
|
19
|
+
draggedClientIds: getDraggedBlockClientIds(),
|
|
20
|
+
clientIdsTree: blocks ? blocks : __unstableGetClientIdsTree()
|
|
21
|
+
};
|
|
22
|
+
}, [blocks]);
|
|
23
|
+
}
|
|
24
|
+
//# sourceMappingURL=use-list-view-client-ids.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["@wordpress/block-editor/src/components/off-canvas-editor/use-list-view-client-ids.js"],"names":["useSelect","store","blockEditorStore","useListViewClientIds","blocks","select","getDraggedBlockClientIds","getSelectedBlockClientIds","__unstableGetClientIdsTree","selectedClientIds","draggedClientIds","clientIdsTree"],"mappings":"AAAA;AACA;AACA;AAEA,SAASA,SAAT,QAA0B,iBAA1B;AAEA;AACA;AACA;;AACA,SAASC,KAAK,IAAIC,gBAAlB,QAA0C,aAA1C;AAEA,eAAe,SAASC,oBAAT,CAA+BC,MAA/B,EAAwC;AACtD,SAAOJ,SAAS,CACbK,MAAF,IAAc;AACb,UAAM;AACLC,MAAAA,wBADK;AAELC,MAAAA,yBAFK;AAGLC,MAAAA;AAHK,QAIFH,MAAM,CAAEH,gBAAF,CAJV;AAMA,WAAO;AACNO,MAAAA,iBAAiB,EAAEF,yBAAyB,EADtC;AAENG,MAAAA,gBAAgB,EAAEJ,wBAAwB,EAFpC;AAGNK,MAAAA,aAAa,EAAEP,MAAM,GAAGA,MAAH,GAAYI,0BAA0B;AAHrD,KAAP;AAKA,GAbc,EAcf,CAAEJ,MAAF,CAde,CAAhB;AAgBA","sourcesContent":["/**\n * WordPress dependencies\n */\n\nimport { useSelect } from '@wordpress/data';\n\n/**\n * Internal dependencies\n */\nimport { store as blockEditorStore } from '../../store';\n\nexport default function useListViewClientIds( blocks ) {\n\treturn useSelect(\n\t\t( select ) => {\n\t\t\tconst {\n\t\t\t\tgetDraggedBlockClientIds,\n\t\t\t\tgetSelectedBlockClientIds,\n\t\t\t\t__unstableGetClientIdsTree,\n\t\t\t} = select( blockEditorStore );\n\n\t\t\treturn {\n\t\t\t\tselectedClientIds: getSelectedBlockClientIds(),\n\t\t\t\tdraggedClientIds: getDraggedBlockClientIds(),\n\t\t\t\tclientIdsTree: blocks ? blocks : __unstableGetClientIdsTree(),\n\t\t\t};\n\t\t},\n\t\t[ blocks ]\n\t);\n}\n"]}
|