@wordpress/block-editor 13.4.0 → 14.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +11 -0
- package/README.md +11 -1
- package/build/components/block-breadcrumb/index.js +3 -1
- package/build/components/block-breadcrumb/index.js.map +1 -1
- package/build/components/block-draggable/index.js +2 -2
- package/build/components/block-draggable/index.js.map +1 -1
- package/build/components/block-list/use-block-props/use-block-refs.js +24 -32
- package/build/components/block-list/use-block-props/use-block-refs.js.map +1 -1
- package/build/components/block-mover/index.js +1 -2
- package/build/components/block-mover/index.js.map +1 -1
- package/build/components/block-popover/cover.js +1 -1
- package/build/components/block-popover/cover.js.map +1 -1
- package/build/components/block-popover/inbetween.js +2 -2
- package/build/components/block-popover/inbetween.js.map +1 -1
- package/build/components/block-popover/index.js +2 -2
- package/build/components/block-popover/index.js.map +1 -1
- package/build/components/block-tools/block-selection-button.js +1 -2
- package/build/components/block-tools/block-selection-button.js.map +1 -1
- package/build/components/block-tools/index.js +1 -1
- package/build/components/block-tools/index.js.map +1 -1
- package/build/components/block-tools/use-block-toolbar-popover-props.js +1 -1
- package/build/components/block-tools/use-block-toolbar-popover-props.js.map +1 -1
- package/build/components/block-tools/zoom-out-mode-inserters.js +15 -16
- package/build/components/block-tools/zoom-out-mode-inserters.js.map +1 -1
- package/build/components/block-tools/zoom-out-toolbar.js +0 -1
- package/build/components/block-tools/zoom-out-toolbar.js.map +1 -1
- package/build/components/child-layout-control/index.js +3 -1
- package/build/components/child-layout-control/index.js.map +1 -1
- package/build/components/dimensions-tool/scale-tool.js +1 -0
- package/build/components/dimensions-tool/scale-tool.js.map +1 -1
- package/build/components/font-family/index.js +12 -0
- package/build/components/font-family/index.js.map +1 -1
- package/build/components/global-styles/background-panel.js +55 -51
- package/build/components/global-styles/background-panel.js.map +1 -1
- package/build/components/global-styles/image-settings-panel.js +1 -0
- package/build/components/global-styles/image-settings-panel.js.map +1 -1
- package/build/components/global-styles/theme-file-uri-utils.js +0 -59
- package/build/components/global-styles/theme-file-uri-utils.js.map +1 -1
- package/build/components/global-styles/typography-panel.js +0 -1
- package/build/components/global-styles/typography-panel.js.map +1 -1
- package/build/components/global-styles/use-global-styles-output.js +58 -39
- package/build/components/global-styles/use-global-styles-output.js.map +1 -1
- package/build/components/global-styles/utils.js +96 -0
- package/build/components/global-styles/utils.js.map +1 -1
- package/build/components/grid/grid-item-movers.js +30 -26
- package/build/components/grid/grid-item-movers.js.map +1 -1
- package/build/components/grid/grid-item-resizer.js +14 -15
- package/build/components/grid/grid-item-resizer.js.map +1 -1
- package/build/components/grid/grid-visualizer.js +1 -1
- package/build/components/grid/grid-visualizer.js.map +1 -1
- package/build/components/grid/use-grid-layout-sync.js +56 -20
- package/build/components/grid/use-grid-layout-sync.js.map +1 -1
- package/build/components/iframe/index.js +4 -8
- package/build/components/iframe/index.js.map +1 -1
- package/build/components/inserter/category-tabs/index.js +29 -2
- package/build/components/inserter/category-tabs/index.js.map +1 -1
- package/build/components/inserter/menu.js +2 -2
- package/build/components/inserter/menu.js.map +1 -1
- package/build/components/line-height-control/index.js +0 -15
- package/build/components/line-height-control/index.js.map +1 -1
- package/build/components/link-control/search-input.js +0 -1
- package/build/components/link-control/search-input.js.map +1 -1
- package/build/components/media-replace-flow/index.js +3 -1
- package/build/components/media-replace-flow/index.js.map +1 -1
- package/build/components/resolution-tool/index.js +1 -0
- package/build/components/resolution-tool/index.js.map +1 -1
- package/build/components/skip-to-selected-block/index.js +4 -2
- package/build/components/skip-to-selected-block/index.js.map +1 -1
- package/build/components/spacing-sizes-control/input-controls/spacing-input-control.js +4 -6
- package/build/components/spacing-sizes-control/input-controls/spacing-input-control.js.map +1 -1
- package/build/components/url-input/button.js +0 -1
- package/build/components/url-input/button.js.map +1 -1
- package/build/components/url-input/index.js +1 -11
- package/build/components/url-input/index.js.map +1 -1
- package/build/components/url-popover/link-editor.js +0 -1
- package/build/components/url-popover/link-editor.js.map +1 -1
- package/build/components/use-block-drop-zone/index.js +30 -4
- package/build/components/use-block-drop-zone/index.js.map +1 -1
- package/build/components/use-on-block-drop/index.js +3 -6
- package/build/components/use-on-block-drop/index.js.map +1 -1
- package/build/components/use-resize-canvas/index.js +1 -3
- package/build/components/use-resize-canvas/index.js.map +1 -1
- package/build/components/use-settings/index.js +2 -1
- package/build/components/use-settings/index.js.map +1 -1
- package/build/hooks/block-bindings.js +248 -36
- package/build/hooks/block-bindings.js.map +1 -1
- package/build/hooks/block-hooks.js +1 -0
- package/build/hooks/block-hooks.js.map +1 -1
- package/build/hooks/block-style-variation.js +2 -2
- package/build/hooks/block-style-variation.js.map +1 -1
- package/build/hooks/contrast-checker.js +6 -6
- package/build/hooks/contrast-checker.js.map +1 -1
- package/build/hooks/duotone.js +3 -3
- package/build/hooks/duotone.js.map +1 -1
- package/build/hooks/index.js +7 -1
- package/build/hooks/index.js.map +1 -1
- package/build/hooks/line-height.js +0 -1
- package/build/hooks/line-height.js.map +1 -1
- package/build/hooks/spacing-visualizer.js +1 -1
- package/build/hooks/spacing-visualizer.js.map +1 -1
- package/build/hooks/use-bindings-attributes.js +4 -0
- package/build/hooks/use-bindings-attributes.js.map +1 -1
- package/build/hooks/use-zoom-out.js +1 -1
- package/build/hooks/use-zoom-out.js.map +1 -1
- package/build/hooks/utils.js +20 -0
- package/build/hooks/utils.js.map +1 -1
- package/build/index.js +7 -0
- package/build/index.js.map +1 -1
- package/build/private-apis.js +0 -1
- package/build/private-apis.js.map +1 -1
- package/build/store/actions.js +9 -1
- package/build/store/actions.js.map +1 -1
- package/build/store/selectors.js +4 -4
- package/build/store/selectors.js.map +1 -1
- package/build/utils/get-editor-region.js +1 -1
- package/build/utils/get-editor-region.js.map +1 -1
- package/build/utils/get-px-from-css-unit.js +1 -1
- package/build/utils/get-px-from-css-unit.js.map +1 -1
- package/build-module/components/block-breadcrumb/index.js +4 -2
- package/build-module/components/block-breadcrumb/index.js.map +1 -1
- package/build-module/components/block-draggable/index.js +3 -3
- package/build-module/components/block-draggable/index.js.map +1 -1
- package/build-module/components/block-list/use-block-props/use-block-refs.js +24 -34
- package/build-module/components/block-list/use-block-props/use-block-refs.js.map +1 -1
- package/build-module/components/block-mover/index.js +1 -2
- package/build-module/components/block-mover/index.js.map +1 -1
- package/build-module/components/block-popover/cover.js +1 -1
- package/build-module/components/block-popover/cover.js.map +1 -1
- package/build-module/components/block-popover/inbetween.js +1 -1
- package/build-module/components/block-popover/inbetween.js.map +1 -1
- package/build-module/components/block-popover/index.js +1 -1
- package/build-module/components/block-popover/index.js.map +1 -1
- package/build-module/components/block-tools/block-selection-button.js +1 -2
- package/build-module/components/block-tools/block-selection-button.js.map +1 -1
- package/build-module/components/block-tools/index.js +1 -1
- package/build-module/components/block-tools/index.js.map +1 -1
- package/build-module/components/block-tools/use-block-toolbar-popover-props.js +1 -1
- package/build-module/components/block-tools/use-block-toolbar-popover-props.js.map +1 -1
- package/build-module/components/block-tools/zoom-out-mode-inserters.js +16 -17
- package/build-module/components/block-tools/zoom-out-mode-inserters.js.map +1 -1
- package/build-module/components/block-tools/zoom-out-toolbar.js +0 -1
- package/build-module/components/block-tools/zoom-out-toolbar.js.map +1 -1
- package/build-module/components/child-layout-control/index.js +3 -1
- package/build-module/components/child-layout-control/index.js.map +1 -1
- package/build-module/components/dimensions-tool/scale-tool.js +1 -0
- package/build-module/components/dimensions-tool/scale-tool.js.map +1 -1
- package/build-module/components/font-family/index.js +11 -0
- package/build-module/components/font-family/index.js.map +1 -1
- package/build-module/components/global-styles/background-panel.js +55 -51
- package/build-module/components/global-styles/background-panel.js.map +1 -1
- package/build-module/components/global-styles/image-settings-panel.js +1 -0
- package/build-module/components/global-styles/image-settings-panel.js.map +1 -1
- package/build-module/components/global-styles/theme-file-uri-utils.js +0 -58
- package/build-module/components/global-styles/theme-file-uri-utils.js.map +1 -1
- package/build-module/components/global-styles/typography-panel.js +0 -1
- package/build-module/components/global-styles/typography-panel.js.map +1 -1
- package/build-module/components/global-styles/use-global-styles-output.js +57 -38
- package/build-module/components/global-styles/use-global-styles-output.js.map +1 -1
- package/build-module/components/global-styles/utils.js +92 -0
- package/build-module/components/global-styles/utils.js.map +1 -1
- package/build-module/components/grid/grid-item-movers.js +30 -26
- package/build-module/components/grid/grid-item-movers.js.map +1 -1
- package/build-module/components/grid/grid-item-resizer.js +14 -15
- package/build-module/components/grid/grid-item-resizer.js.map +1 -1
- package/build-module/components/grid/grid-visualizer.js +1 -1
- package/build-module/components/grid/grid-visualizer.js.map +1 -1
- package/build-module/components/grid/use-grid-layout-sync.js +56 -20
- package/build-module/components/grid/use-grid-layout-sync.js.map +1 -1
- package/build-module/components/iframe/index.js +4 -8
- package/build-module/components/iframe/index.js.map +1 -1
- package/build-module/components/inserter/category-tabs/index.js +30 -3
- package/build-module/components/inserter/category-tabs/index.js.map +1 -1
- package/build-module/components/inserter/menu.js +2 -2
- package/build-module/components/inserter/menu.js.map +1 -1
- package/build-module/components/line-height-control/index.js +0 -14
- package/build-module/components/line-height-control/index.js.map +1 -1
- package/build-module/components/link-control/search-input.js +0 -1
- package/build-module/components/link-control/search-input.js.map +1 -1
- package/build-module/components/media-replace-flow/index.js +3 -1
- package/build-module/components/media-replace-flow/index.js.map +1 -1
- package/build-module/components/resolution-tool/index.js +1 -0
- package/build-module/components/resolution-tool/index.js.map +1 -1
- package/build-module/components/skip-to-selected-block/index.js +5 -3
- package/build-module/components/skip-to-selected-block/index.js.map +1 -1
- package/build-module/components/spacing-sizes-control/input-controls/spacing-input-control.js +4 -6
- package/build-module/components/spacing-sizes-control/input-controls/spacing-input-control.js.map +1 -1
- package/build-module/components/url-input/button.js +0 -1
- package/build-module/components/url-input/button.js.map +1 -1
- package/build-module/components/url-input/index.js +1 -11
- package/build-module/components/url-input/index.js.map +1 -1
- package/build-module/components/url-popover/link-editor.js +0 -1
- package/build-module/components/url-popover/link-editor.js.map +1 -1
- package/build-module/components/use-block-drop-zone/index.js +30 -4
- package/build-module/components/use-block-drop-zone/index.js.map +1 -1
- package/build-module/components/use-on-block-drop/index.js +3 -6
- package/build-module/components/use-on-block-drop/index.js.map +1 -1
- package/build-module/components/use-resize-canvas/index.js +1 -3
- package/build-module/components/use-resize-canvas/index.js.map +1 -1
- package/build-module/components/use-settings/index.js +2 -1
- package/build-module/components/use-settings/index.js.map +1 -1
- package/build-module/hooks/block-bindings.js +253 -40
- package/build-module/hooks/block-bindings.js.map +1 -1
- package/build-module/hooks/block-hooks.js +1 -0
- package/build-module/hooks/block-hooks.js.map +1 -1
- package/build-module/hooks/block-style-variation.js +3 -3
- package/build-module/hooks/block-style-variation.js.map +1 -1
- package/build-module/hooks/contrast-checker.js +7 -7
- package/build-module/hooks/contrast-checker.js.map +1 -1
- package/build-module/hooks/duotone.js +4 -4
- package/build-module/hooks/duotone.js.map +1 -1
- package/build-module/hooks/index.js +2 -1
- package/build-module/hooks/index.js.map +1 -1
- package/build-module/hooks/line-height.js +0 -1
- package/build-module/hooks/line-height.js.map +1 -1
- package/build-module/hooks/spacing-visualizer.js +1 -1
- package/build-module/hooks/spacing-visualizer.js.map +1 -1
- package/build-module/hooks/use-bindings-attributes.js +3 -0
- package/build-module/hooks/use-bindings-attributes.js.map +1 -1
- package/build-module/hooks/use-zoom-out.js +1 -1
- package/build-module/hooks/use-zoom-out.js.map +1 -1
- package/build-module/hooks/utils.js +19 -0
- package/build-module/hooks/utils.js.map +1 -1
- package/build-module/index.js +1 -1
- package/build-module/index.js.map +1 -1
- package/build-module/private-apis.js +1 -2
- package/build-module/private-apis.js.map +1 -1
- package/build-module/store/actions.js +9 -1
- package/build-module/store/actions.js.map +1 -1
- package/build-module/store/selectors.js +4 -4
- package/build-module/store/selectors.js.map +1 -1
- package/build-module/utils/get-editor-region.js +1 -1
- package/build-module/utils/get-editor-region.js.map +1 -1
- package/build-module/utils/get-px-from-css-unit.js +1 -1
- package/build-module/utils/get-px-from-css-unit.js.map +1 -1
- package/build-style/content-rtl.css +5 -12
- package/build-style/content.css +5 -12
- package/build-style/default-editor-styles-rtl.css +3 -0
- package/build-style/default-editor-styles.css +3 -0
- package/build-style/style-rtl.css +88 -46
- package/build-style/style.css +88 -46
- package/package.json +31 -31
- package/src/autocompleters/style.scss +4 -0
- package/src/components/block-breadcrumb/index.js +4 -2
- package/src/components/block-canvas/style.scss +1 -0
- package/src/components/block-draggable/index.js +3 -3
- package/src/components/block-list/use-block-props/use-block-refs.js +27 -43
- package/src/components/block-mover/index.js +5 -2
- package/src/components/block-popover/cover.js +1 -1
- package/src/components/block-popover/inbetween.js +1 -1
- package/src/components/block-popover/index.js +1 -1
- package/src/components/block-tools/block-selection-button.js +1 -2
- package/src/components/block-tools/index.js +5 -6
- package/src/components/block-tools/use-block-toolbar-popover-props.js +1 -1
- package/src/components/block-tools/zoom-out-mode-inserters.js +14 -18
- package/src/components/block-tools/zoom-out-toolbar.js +0 -1
- package/src/components/button-block-appender/content.scss +1 -1
- package/src/components/child-layout-control/index.js +2 -0
- package/src/components/color-palette/test/__snapshots__/control.js.snap +2 -2
- package/src/components/colors-gradients/test/control.js +3 -2
- package/src/components/dimensions-tool/scale-tool.js +1 -0
- package/src/components/font-family/README.md +8 -0
- package/src/components/font-family/index.js +16 -0
- package/src/components/font-family/stories/index.story.js +54 -0
- package/src/components/global-styles/background-panel.js +69 -61
- package/src/components/global-styles/image-settings-panel.js +1 -0
- package/src/components/global-styles/style.scss +0 -10
- package/src/components/global-styles/test/theme-file-uri-utils.js +1 -26
- package/src/components/global-styles/test/use-global-styles-output.js +49 -4
- package/src/components/global-styles/test/utils.js +120 -0
- package/src/components/global-styles/theme-file-uri-utils.js +0 -59
- package/src/components/global-styles/typography-panel.js +0 -1
- package/src/components/global-styles/use-global-styles-output.js +67 -48
- package/src/components/global-styles/utils.js +112 -0
- package/src/components/grid/grid-item-movers.js +46 -44
- package/src/components/grid/grid-item-resizer.js +11 -17
- package/src/components/grid/grid-visualizer.js +1 -1
- package/src/components/grid/style.scss +60 -10
- package/src/components/grid/use-grid-layout-sync.js +68 -14
- package/src/components/iframe/content.scss +2 -2
- package/src/components/iframe/index.js +3 -7
- package/src/components/inserter/category-tabs/index.js +35 -2
- package/src/components/inserter/menu.js +2 -2
- package/src/components/inserter/style.scss +16 -11
- package/src/components/inspector-controls/README.md +5 -0
- package/src/components/line-height-control/README.md +0 -8
- package/src/components/line-height-control/index.js +1 -21
- package/src/components/line-height-control/stories/index.story.js +0 -1
- package/src/components/line-height-control/test/index.js +1 -7
- package/src/components/link-control/search-input.js +0 -1
- package/src/components/media-replace-flow/README.md +7 -0
- package/src/components/media-replace-flow/index.js +3 -1
- package/src/components/resolution-tool/index.js +1 -0
- package/src/components/responsive-block-control/test/index.js +5 -1
- package/src/components/skip-to-selected-block/index.js +5 -3
- package/src/components/spacing-sizes-control/input-controls/spacing-input-control.js +3 -6
- package/src/components/tabbed-sidebar/style.scss +1 -19
- package/src/components/url-input/README.md +0 -5
- package/src/components/url-input/button.js +0 -1
- package/src/components/url-input/index.js +1 -15
- package/src/components/url-popover/link-editor.js +0 -1
- package/src/components/use-block-drop-zone/index.js +66 -14
- package/src/components/use-on-block-drop/index.js +1 -9
- package/src/components/use-resize-canvas/index.js +1 -3
- package/src/components/use-settings/index.js +2 -1
- package/src/hooks/block-bindings.js +303 -52
- package/src/hooks/block-bindings.scss +13 -2
- package/src/hooks/block-hooks.js +1 -0
- package/src/hooks/block-hooks.scss +1 -0
- package/src/hooks/block-style-variation.js +3 -3
- package/src/hooks/contrast-checker.js +7 -7
- package/src/hooks/duotone.js +4 -4
- package/src/hooks/index.js +2 -1
- package/src/hooks/line-height.js +0 -1
- package/src/hooks/spacing-visualizer.js +1 -1
- package/src/hooks/use-bindings-attributes.js +4 -0
- package/src/hooks/use-editor-wrapper-styles.native.scss +1 -0
- package/src/hooks/use-zoom-out.js +1 -1
- package/src/hooks/utils.js +14 -1
- package/src/index.js +1 -0
- package/src/private-apis.js +1 -2
- package/src/store/actions.js +13 -5
- package/src/store/selectors.js +4 -4
- package/src/style.scss +1 -1
- package/src/utils/get-editor-region.js +1 -1
- package/src/utils/get-px-from-css-unit.js +1 -1
- package/tsconfig.tsbuildinfo +1 -1
- package/build/components/inserter/block-patterns-tab/pattern-category-preview-panel.js +0 -30
- package/build/components/inserter/block-patterns-tab/pattern-category-preview-panel.js.map +0 -1
- package/build-module/components/inserter/block-patterns-tab/pattern-category-preview-panel.js +0 -23
- package/build-module/components/inserter/block-patterns-tab/pattern-category-preview-panel.js.map +0 -1
- package/src/components/inserter/block-patterns-tab/pattern-category-preview-panel.js +0 -25
package/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,17 @@
|
|
|
2
2
|
|
|
3
3
|
## Unreleased
|
|
4
4
|
|
|
5
|
+
## 14.0.0 (2024-08-07)
|
|
6
|
+
|
|
7
|
+
### Breaking Changes
|
|
8
|
+
|
|
9
|
+
- `URLInput`: Remove deprecated `__nextHasNoMarginBottom` prop and promote to default behavior ([#64282](https://github.com/WordPress/gutenberg/pull/64282)).
|
|
10
|
+
- `LineHeightControl`: Remove deprecated `__nextHasNoMarginBottom` prop and promote to default behavior ([#64281](https://github.com/WordPress/gutenberg/pull/64281)).
|
|
11
|
+
|
|
12
|
+
### Enhancements
|
|
13
|
+
|
|
14
|
+
- `FontFamilyControl`: Add `__nextHasNoMarginBottom` prop for opting into the new margin-free styles ([#64280](https://github.com/WordPress/gutenberg/pull/64280)).
|
|
15
|
+
|
|
5
16
|
## 13.4.0 (2024-07-24)
|
|
6
17
|
|
|
7
18
|
## 13.3.0 (2024-07-10)
|
package/README.md
CHANGED
|
@@ -547,7 +547,7 @@ _Returns_
|
|
|
547
547
|
|
|
548
548
|
> **Deprecated**
|
|
549
549
|
|
|
550
|
-
This function was
|
|
550
|
+
This function was accidentally exposed for mobile/native usage.
|
|
551
551
|
|
|
552
552
|
_Returns_
|
|
553
553
|
|
|
@@ -1029,6 +1029,16 @@ _Returns_
|
|
|
1029
1029
|
|
|
1030
1030
|
- `any[]`: Returns the values defined for the settings.
|
|
1031
1031
|
|
|
1032
|
+
### useStyleOverride
|
|
1033
|
+
|
|
1034
|
+
Override a block editor settings style. Leave the ID blank to create a new style.
|
|
1035
|
+
|
|
1036
|
+
_Parameters_
|
|
1037
|
+
|
|
1038
|
+
- _override_ `Object`: Override object.
|
|
1039
|
+
- _override.id_ `?string`: Id of the style override, leave blank to create a new style.
|
|
1040
|
+
- _override.css_ `string`: CSS to apply.
|
|
1041
|
+
|
|
1032
1042
|
### useZoomOut
|
|
1033
1043
|
|
|
1034
1044
|
A hook used to set the editor mode to zoomed out mode, invoking the hook sets the mode.
|
|
@@ -9,6 +9,7 @@ var _components = require("@wordpress/components");
|
|
|
9
9
|
var _data = require("@wordpress/data");
|
|
10
10
|
var _i18n = require("@wordpress/i18n");
|
|
11
11
|
var _icons = require("@wordpress/icons");
|
|
12
|
+
var _element = require("@wordpress/element");
|
|
12
13
|
var _blockTitle = _interopRequireDefault(require("../block-title"));
|
|
13
14
|
var _store = require("../../store");
|
|
14
15
|
var _lockUnlock = require("../../lock-unlock");
|
|
@@ -57,7 +58,8 @@ var _jsxRuntime = require("react/jsx-runtime");
|
|
|
57
58
|
|
|
58
59
|
// We don't care about this specific ref, but this is a way
|
|
59
60
|
// to get a ref within the editor canvas so we can focus it later.
|
|
60
|
-
const blockRef = (0,
|
|
61
|
+
const blockRef = (0, _element.useRef)();
|
|
62
|
+
(0, _useBlockRefs.useBlockElementRef)(clientId, blockRef);
|
|
61
63
|
|
|
62
64
|
/*
|
|
63
65
|
* Disable reason: The `list` ARIA role is redundant but
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_components","require","_data","_i18n","_icons","_blockTitle","_interopRequireDefault","_store","_lockUnlock","_useBlockRefs","_getEditorRegion","_jsxRuntime","BlockBreadcrumb","rootLabelText","selectBlock","clearSelectedBlock","useDispatch","blockEditorStore","clientId","parents","hasSelection","useSelect","select","getSelectionStart","getSelectedBlockClientId","getEnabledBlockParents","unlock","selectedBlockClientId","rootLabel","__","blockRef","
|
|
1
|
+
{"version":3,"names":["_components","require","_data","_i18n","_icons","_element","_blockTitle","_interopRequireDefault","_store","_lockUnlock","_useBlockRefs","_getEditorRegion","_jsxRuntime","BlockBreadcrumb","rootLabelText","selectBlock","clearSelectedBlock","useDispatch","blockEditorStore","clientId","parents","hasSelection","useSelect","select","getSelectionStart","getSelectedBlockClientId","getEnabledBlockParents","unlock","selectedBlockClientId","rootLabel","__","blockRef","useRef","useBlockElementRef","jsxs","className","role","children","undefined","jsx","Button","variant","onClick","blockEditor","current","closest","getEditorRegion","focus","Icon","icon","chevronRightSmall","map","parentClientId","default","maximumLength","_default","exports"],"sources":["@wordpress/block-editor/src/components/block-breadcrumb/index.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { Button } from '@wordpress/components';\nimport { useSelect, useDispatch } from '@wordpress/data';\nimport { __ } from '@wordpress/i18n';\nimport { chevronRightSmall, Icon } from '@wordpress/icons';\nimport { useRef } from '@wordpress/element';\n\n/**\n * Internal dependencies\n */\nimport BlockTitle from '../block-title';\nimport { store as blockEditorStore } from '../../store';\nimport { unlock } from '../../lock-unlock';\nimport { useBlockElementRef } from '../block-list/use-block-props/use-block-refs';\nimport getEditorRegion from '../../utils/get-editor-region';\n\n/**\n * Block breadcrumb component, displaying the hierarchy of the current block selection as a breadcrumb.\n *\n * @param {Object} props Component props.\n * @param {string} props.rootLabelText Translated label for the root element of the breadcrumb trail.\n * @return {Element} Block Breadcrumb.\n */\nfunction BlockBreadcrumb( { rootLabelText } ) {\n\tconst { selectBlock, clearSelectedBlock } = useDispatch( blockEditorStore );\n\tconst { clientId, parents, hasSelection } = useSelect( ( select ) => {\n\t\tconst {\n\t\t\tgetSelectionStart,\n\t\t\tgetSelectedBlockClientId,\n\t\t\tgetEnabledBlockParents,\n\t\t} = unlock( select( blockEditorStore ) );\n\t\tconst selectedBlockClientId = getSelectedBlockClientId();\n\t\treturn {\n\t\t\tparents: getEnabledBlockParents( selectedBlockClientId ),\n\t\t\tclientId: selectedBlockClientId,\n\t\t\thasSelection: !! getSelectionStart().clientId,\n\t\t};\n\t}, [] );\n\tconst rootLabel = rootLabelText || __( 'Document' );\n\n\t// We don't care about this specific ref, but this is a way\n\t// to get a ref within the editor canvas so we can focus it later.\n\tconst blockRef = useRef();\n\tuseBlockElementRef( clientId, blockRef );\n\n\t/*\n\t * Disable reason: The `list` ARIA role is redundant but\n\t * Safari+VoiceOver won't announce the list otherwise.\n\t */\n\t/* eslint-disable jsx-a11y/no-redundant-roles */\n\treturn (\n\t\t<ul\n\t\t\tclassName=\"block-editor-block-breadcrumb\"\n\t\t\trole=\"list\"\n\t\t\taria-label={ __( 'Block breadcrumb' ) }\n\t\t>\n\t\t\t<li\n\t\t\t\tclassName={\n\t\t\t\t\t! hasSelection\n\t\t\t\t\t\t? 'block-editor-block-breadcrumb__current'\n\t\t\t\t\t\t: undefined\n\t\t\t\t}\n\t\t\t\taria-current={ ! hasSelection ? 'true' : undefined }\n\t\t\t>\n\t\t\t\t{ hasSelection && (\n\t\t\t\t\t<Button\n\t\t\t\t\t\tclassName=\"block-editor-block-breadcrumb__button\"\n\t\t\t\t\t\tvariant=\"tertiary\"\n\t\t\t\t\t\tonClick={ () => {\n\t\t\t\t\t\t\t// Find the block editor wrapper for the selected block\n\t\t\t\t\t\t\tconst blockEditor = blockRef.current?.closest(\n\t\t\t\t\t\t\t\t'.editor-styles-wrapper'\n\t\t\t\t\t\t\t);\n\n\t\t\t\t\t\t\tclearSelectedBlock();\n\n\t\t\t\t\t\t\tgetEditorRegion( blockEditor )?.focus();\n\t\t\t\t\t\t} }\n\t\t\t\t\t>\n\t\t\t\t\t\t{ rootLabel }\n\t\t\t\t\t</Button>\n\t\t\t\t) }\n\t\t\t\t{ ! hasSelection && rootLabel }\n\t\t\t\t{ !! clientId && (\n\t\t\t\t\t<Icon\n\t\t\t\t\t\ticon={ chevronRightSmall }\n\t\t\t\t\t\tclassName=\"block-editor-block-breadcrumb__separator\"\n\t\t\t\t\t/>\n\t\t\t\t) }\n\t\t\t</li>\n\n\t\t\t{ parents.map( ( parentClientId ) => (\n\t\t\t\t<li key={ parentClientId }>\n\t\t\t\t\t<Button\n\t\t\t\t\t\tclassName=\"block-editor-block-breadcrumb__button\"\n\t\t\t\t\t\tvariant=\"tertiary\"\n\t\t\t\t\t\tonClick={ () => selectBlock( parentClientId ) }\n\t\t\t\t\t>\n\t\t\t\t\t\t<BlockTitle\n\t\t\t\t\t\t\tclientId={ parentClientId }\n\t\t\t\t\t\t\tmaximumLength={ 35 }\n\t\t\t\t\t\t/>\n\t\t\t\t\t</Button>\n\t\t\t\t\t<Icon\n\t\t\t\t\t\ticon={ chevronRightSmall }\n\t\t\t\t\t\tclassName=\"block-editor-block-breadcrumb__separator\"\n\t\t\t\t\t/>\n\t\t\t\t</li>\n\t\t\t) ) }\n\t\t\t{ !! clientId && (\n\t\t\t\t<li\n\t\t\t\t\tclassName=\"block-editor-block-breadcrumb__current\"\n\t\t\t\t\taria-current=\"true\"\n\t\t\t\t>\n\t\t\t\t\t<BlockTitle clientId={ clientId } maximumLength={ 35 } />\n\t\t\t\t</li>\n\t\t\t) }\n\t\t</ul>\n\t\t/* eslint-enable jsx-a11y/no-redundant-roles */\n\t);\n}\n\nexport default BlockBreadcrumb;\n"],"mappings":";;;;;;;AAGA,IAAAA,WAAA,GAAAC,OAAA;AACA,IAAAC,KAAA,GAAAD,OAAA;AACA,IAAAE,KAAA,GAAAF,OAAA;AACA,IAAAG,MAAA,GAAAH,OAAA;AACA,IAAAI,QAAA,GAAAJ,OAAA;AAKA,IAAAK,WAAA,GAAAC,sBAAA,CAAAN,OAAA;AACA,IAAAO,MAAA,GAAAP,OAAA;AACA,IAAAQ,WAAA,GAAAR,OAAA;AACA,IAAAS,aAAA,GAAAT,OAAA;AACA,IAAAU,gBAAA,GAAAJ,sBAAA,CAAAN,OAAA;AAA4D,IAAAW,WAAA,GAAAX,OAAA;AAhB5D;AACA;AACA;;AAOA;AACA;AACA;;AAOA;AACA;AACA;AACA;AACA;AACA;AACA,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,WAAA,CAAA+C,OAAU;QAAClC,QAAQ,EAAGA,QAAU;QAACmC,aAAa,EAAG;MAAI,CAAE;IAAC,CACtD,CACJ;EAAA,CACE;EACJ;AAEF;AAAC,IAAAC,QAAA,GAAAC,OAAA,CAAAH,OAAA,GAEcxC,eAAe","ignoreList":[]}
|
|
@@ -86,8 +86,8 @@ const BlockDraggable = ({
|
|
|
86
86
|
}, []);
|
|
87
87
|
|
|
88
88
|
// Find the root of the editor iframe.
|
|
89
|
-
const
|
|
90
|
-
const editorRoot =
|
|
89
|
+
const blockEl = (0, _useBlockRefs.useBlockElement)(clientIds[0]);
|
|
90
|
+
const editorRoot = blockEl?.closest('body');
|
|
91
91
|
|
|
92
92
|
/*
|
|
93
93
|
* Add a dragover event listener to the editor root to track the blocks being dragged over.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_blocks","require","_components","_data","_element","_compose","_draggableChip","_interopRequireDefault","_useScrollWhenDragging","_store","_useBlockRefs","_useBlockDropZone","_jsxRuntime","BlockDraggable","appendToOwnerDocument","children","clientIds","cloneClassname","elementId","onDragStart","onDragEnd","fadeWhenDisabled","dragComponent","srcRootClientId","isDraggable","icon","visibleInserter","getBlockType","useSelect","select","canMoveBlocks","getBlockRootClientId","getBlockName","getBlockAttributes","isBlockInsertionPointVisible","blockEditorStore","_getBlockType","getActiveBlockVariation","blocksStore","rootClientId","blockName","variation","isDragging","useRef","startScrolling","scrollOnDragOver","stopScrolling","useScrollWhenDragging","getAllowedBlocks","getBlockNamesByClientId","startDraggingBlocks","stopDraggingBlocks","useDispatch","useEffect","current","blockRef","useBlockRef","editorRoot","closest","onDragOver","event","target","draggedBlockNames","targetClientId","getAttribute","allowedBlocks","targetBlockName","dropTargetValid","length","targetRootClientId","targetRootBlockName","rootAllowedBlocks","isDropTargetValid","window","document","body","classList","add","remove","throttledOnDragOver","throttle","addEventListener","removeEventListener","draggable","transferData","type","srcClientIds","jsx","Draggable","__experimentalTransferDataType","requestAnimationFrame","__experimentalDragComponent","undefined","default","count","onDraggableStart","onDraggableEnd","_default","exports"],"sources":["@wordpress/block-editor/src/components/block-draggable/index.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { store as blocksStore } from '@wordpress/blocks';\nimport { Draggable } from '@wordpress/components';\nimport { useSelect, useDispatch } from '@wordpress/data';\nimport { useEffect, useRef } from '@wordpress/element';\nimport { throttle } from '@wordpress/compose';\n\n/**\n * Internal dependencies\n */\nimport BlockDraggableChip from './draggable-chip';\nimport useScrollWhenDragging from './use-scroll-when-dragging';\nimport { store as blockEditorStore } from '../../store';\nimport { __unstableUseBlockRef as useBlockRef } from '../block-list/use-block-props/use-block-refs';\nimport { isDropTargetValid } from '../use-block-drop-zone';\n\nconst BlockDraggable = ( {\n\tappendToOwnerDocument,\n\tchildren,\n\tclientIds,\n\tcloneClassname,\n\telementId,\n\tonDragStart,\n\tonDragEnd,\n\tfadeWhenDisabled = false,\n\tdragComponent,\n} ) => {\n\tconst {\n\t\tsrcRootClientId,\n\t\tisDraggable,\n\t\ticon,\n\t\tvisibleInserter,\n\t\tgetBlockType,\n\t} = useSelect(\n\t\t( select ) => {\n\t\t\tconst {\n\t\t\t\tcanMoveBlocks,\n\t\t\t\tgetBlockRootClientId,\n\t\t\t\tgetBlockName,\n\t\t\t\tgetBlockAttributes,\n\t\t\t\tisBlockInsertionPointVisible,\n\t\t\t} = select( blockEditorStore );\n\t\t\tconst { getBlockType: _getBlockType, getActiveBlockVariation } =\n\t\t\t\tselect( blocksStore );\n\t\t\tconst rootClientId = getBlockRootClientId( clientIds[ 0 ] );\n\t\t\tconst blockName = getBlockName( clientIds[ 0 ] );\n\t\t\tconst variation = getActiveBlockVariation(\n\t\t\t\tblockName,\n\t\t\t\tgetBlockAttributes( clientIds[ 0 ] )\n\t\t\t);\n\n\t\t\treturn {\n\t\t\t\tsrcRootClientId: rootClientId,\n\t\t\t\tisDraggable: canMoveBlocks( clientIds ),\n\t\t\t\ticon: variation?.icon || _getBlockType( blockName )?.icon,\n\t\t\t\tvisibleInserter: isBlockInsertionPointVisible(),\n\t\t\t\tgetBlockType: _getBlockType,\n\t\t\t};\n\t\t},\n\t\t[ clientIds ]\n\t);\n\n\tconst isDragging = useRef( false );\n\tconst [ startScrolling, scrollOnDragOver, stopScrolling ] =\n\t\tuseScrollWhenDragging();\n\n\tconst { getAllowedBlocks, getBlockNamesByClientId, getBlockRootClientId } =\n\t\tuseSelect( blockEditorStore );\n\n\tconst { startDraggingBlocks, stopDraggingBlocks } =\n\t\tuseDispatch( blockEditorStore );\n\n\t// Stop dragging blocks if the block draggable is unmounted.\n\tuseEffect( () => {\n\t\treturn () => {\n\t\t\tif ( isDragging.current ) {\n\t\t\t\tstopDraggingBlocks();\n\t\t\t}\n\t\t};\n\t}, [] );\n\n\t// Find the root of the editor iframe.\n\tconst blockRef = useBlockRef( clientIds[ 0 ] );\n\tconst editorRoot = blockRef.current?.closest( 'body' );\n\n\t/*\n\t * Add a dragover event listener to the editor root to track the blocks being dragged over.\n\t * The listener has to be inside the editor iframe otherwise the target isn't accessible.\n\t */\n\tuseEffect( () => {\n\t\tif ( ! editorRoot || ! fadeWhenDisabled ) {\n\t\t\treturn;\n\t\t}\n\n\t\tconst onDragOver = ( event ) => {\n\t\t\tif ( ! event.target.closest( '[data-block]' ) ) {\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tconst draggedBlockNames = getBlockNamesByClientId( clientIds );\n\t\t\tconst targetClientId = event.target\n\t\t\t\t.closest( '[data-block]' )\n\t\t\t\t.getAttribute( 'data-block' );\n\n\t\t\tconst allowedBlocks = getAllowedBlocks( targetClientId );\n\t\t\tconst targetBlockName = getBlockNamesByClientId( [\n\t\t\t\ttargetClientId,\n\t\t\t] )[ 0 ];\n\n\t\t\t/*\n\t\t\t * Check if the target is valid to drop in.\n\t\t\t * If the target's allowedBlocks is an empty array,\n\t\t\t * it isn't a container block, in which case we check\n\t\t\t * its parent's validity instead.\n\t\t\t */\n\t\t\tlet dropTargetValid;\n\t\t\tif ( allowedBlocks?.length === 0 ) {\n\t\t\t\tconst targetRootClientId =\n\t\t\t\t\tgetBlockRootClientId( targetClientId );\n\t\t\t\tconst targetRootBlockName = getBlockNamesByClientId( [\n\t\t\t\t\ttargetRootClientId,\n\t\t\t\t] )[ 0 ];\n\t\t\t\tconst rootAllowedBlocks =\n\t\t\t\t\tgetAllowedBlocks( targetRootClientId );\n\t\t\t\tdropTargetValid = isDropTargetValid(\n\t\t\t\t\tgetBlockType,\n\t\t\t\t\trootAllowedBlocks,\n\t\t\t\t\tdraggedBlockNames,\n\t\t\t\t\ttargetRootBlockName\n\t\t\t\t);\n\t\t\t} else {\n\t\t\t\tdropTargetValid = isDropTargetValid(\n\t\t\t\t\tgetBlockType,\n\t\t\t\t\tallowedBlocks,\n\t\t\t\t\tdraggedBlockNames,\n\t\t\t\t\ttargetBlockName\n\t\t\t\t);\n\t\t\t}\n\n\t\t\t/*\n\t\t\t * Update the body class to reflect if drop target is valid.\n\t\t\t * This has to be done on the document body because the draggable\n\t\t\t * chip is rendered outside of the editor iframe.\n\t\t\t */\n\t\t\tif ( ! dropTargetValid && ! visibleInserter ) {\n\t\t\t\twindow?.document?.body?.classList?.add(\n\t\t\t\t\t'block-draggable-invalid-drag-token'\n\t\t\t\t);\n\t\t\t} else {\n\t\t\t\twindow?.document?.body?.classList?.remove(\n\t\t\t\t\t'block-draggable-invalid-drag-token'\n\t\t\t\t);\n\t\t\t}\n\t\t};\n\n\t\tconst throttledOnDragOver = throttle( onDragOver, 200 );\n\n\t\teditorRoot.addEventListener( 'dragover', throttledOnDragOver );\n\n\t\treturn () => {\n\t\t\teditorRoot.removeEventListener( 'dragover', throttledOnDragOver );\n\t\t};\n\t}, [\n\t\tclientIds,\n\t\teditorRoot,\n\t\tfadeWhenDisabled,\n\t\tgetAllowedBlocks,\n\t\tgetBlockNamesByClientId,\n\t\tgetBlockRootClientId,\n\t\tgetBlockType,\n\t\tvisibleInserter,\n\t] );\n\n\tif ( ! isDraggable ) {\n\t\treturn children( { draggable: false } );\n\t}\n\n\tconst transferData = {\n\t\ttype: 'block',\n\t\tsrcClientIds: clientIds,\n\t\tsrcRootClientId,\n\t};\n\n\treturn (\n\t\t<Draggable\n\t\t\tappendToOwnerDocument={ appendToOwnerDocument }\n\t\t\tcloneClassname={ cloneClassname }\n\t\t\t__experimentalTransferDataType=\"wp-blocks\"\n\t\t\ttransferData={ transferData }\n\t\t\tonDragStart={ ( event ) => {\n\t\t\t\t// Defer hiding the dragged source element to the next\n\t\t\t\t// frame to enable dragging.\n\t\t\t\twindow.requestAnimationFrame( () => {\n\t\t\t\t\tstartDraggingBlocks( clientIds );\n\t\t\t\t\tisDragging.current = true;\n\n\t\t\t\t\tstartScrolling( event );\n\n\t\t\t\t\tif ( onDragStart ) {\n\t\t\t\t\t\tonDragStart();\n\t\t\t\t\t}\n\t\t\t\t} );\n\t\t\t} }\n\t\t\tonDragOver={ scrollOnDragOver }\n\t\t\tonDragEnd={ () => {\n\t\t\t\tstopDraggingBlocks();\n\t\t\t\tisDragging.current = false;\n\n\t\t\t\tstopScrolling();\n\n\t\t\t\tif ( onDragEnd ) {\n\t\t\t\t\tonDragEnd();\n\t\t\t\t}\n\t\t\t} }\n\t\t\t__experimentalDragComponent={\n\t\t\t\t// Check against `undefined` so that `null` can be used to disable\n\t\t\t\t// the default drag component.\n\t\t\t\tdragComponent !== undefined ? (\n\t\t\t\t\tdragComponent\n\t\t\t\t) : (\n\t\t\t\t\t<BlockDraggableChip\n\t\t\t\t\t\tcount={ clientIds.length }\n\t\t\t\t\t\ticon={ icon }\n\t\t\t\t\t\tfadeWhenDisabled\n\t\t\t\t\t/>\n\t\t\t\t)\n\t\t\t}\n\t\t\telementId={ elementId }\n\t\t>\n\t\t\t{ ( { onDraggableStart, onDraggableEnd } ) => {\n\t\t\t\treturn children( {\n\t\t\t\t\tdraggable: true,\n\t\t\t\t\tonDragStart: onDraggableStart,\n\t\t\t\t\tonDragEnd: onDraggableEnd,\n\t\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AA,CAAA2E,GAAA,EAACjF,cAAA,CAAAuF,OAAkB;MAClBC,KAAK,EAAG9E,SAAS,CAACoD,MAAQ;MAC1B3C,IAAI,EAAGA,IAAM;MACbJ,gBAAgB;IAAA,CAChB,CAEF;IACDH,SAAS,EAAGA,SAAW;IAAAH,QAAA,EAErBA,CAAE;MAAEgF,gBAAgB;MAAEC;IAAe,CAAC,KAAM;MAC7C,OAAOjF,QAAQ,CAAE;QAChBoE,SAAS,EAAE,IAAI;QACfhE,WAAW,EAAE4E,gBAAgB;QAC7B3E,SAAS,EAAE4E;MACZ,CAAE,CAAC;IACJ;EAAC,CACS,CAAC;AAEd,CAAC;AAAC,IAAAC,QAAA,GAAAC,OAAA,CAAAL,OAAA,GAEahF,cAAc","ignoreList":[]}
|
|
1
|
+
{"version":3,"names":["_blocks","require","_components","_data","_element","_compose","_draggableChip","_interopRequireDefault","_useScrollWhenDragging","_store","_useBlockRefs","_useBlockDropZone","_jsxRuntime","BlockDraggable","appendToOwnerDocument","children","clientIds","cloneClassname","elementId","onDragStart","onDragEnd","fadeWhenDisabled","dragComponent","srcRootClientId","isDraggable","icon","visibleInserter","getBlockType","useSelect","select","canMoveBlocks","getBlockRootClientId","getBlockName","getBlockAttributes","isBlockInsertionPointVisible","blockEditorStore","_getBlockType","getActiveBlockVariation","blocksStore","rootClientId","blockName","variation","isDragging","useRef","startScrolling","scrollOnDragOver","stopScrolling","useScrollWhenDragging","getAllowedBlocks","getBlockNamesByClientId","startDraggingBlocks","stopDraggingBlocks","useDispatch","useEffect","current","blockEl","useBlockElement","editorRoot","closest","onDragOver","event","target","draggedBlockNames","targetClientId","getAttribute","allowedBlocks","targetBlockName","dropTargetValid","length","targetRootClientId","targetRootBlockName","rootAllowedBlocks","isDropTargetValid","window","document","body","classList","add","remove","throttledOnDragOver","throttle","addEventListener","removeEventListener","draggable","transferData","type","srcClientIds","jsx","Draggable","__experimentalTransferDataType","requestAnimationFrame","__experimentalDragComponent","undefined","default","count","onDraggableStart","onDraggableEnd","_default","exports"],"sources":["@wordpress/block-editor/src/components/block-draggable/index.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { store as blocksStore } from '@wordpress/blocks';\nimport { Draggable } from '@wordpress/components';\nimport { useSelect, useDispatch } from '@wordpress/data';\nimport { useEffect, useRef } from '@wordpress/element';\nimport { throttle } from '@wordpress/compose';\n\n/**\n * Internal dependencies\n */\nimport BlockDraggableChip from './draggable-chip';\nimport useScrollWhenDragging from './use-scroll-when-dragging';\nimport { store as blockEditorStore } from '../../store';\nimport { useBlockElement } from '../block-list/use-block-props/use-block-refs';\nimport { isDropTargetValid } from '../use-block-drop-zone';\n\nconst BlockDraggable = ( {\n\tappendToOwnerDocument,\n\tchildren,\n\tclientIds,\n\tcloneClassname,\n\telementId,\n\tonDragStart,\n\tonDragEnd,\n\tfadeWhenDisabled = false,\n\tdragComponent,\n} ) => {\n\tconst {\n\t\tsrcRootClientId,\n\t\tisDraggable,\n\t\ticon,\n\t\tvisibleInserter,\n\t\tgetBlockType,\n\t} = useSelect(\n\t\t( select ) => {\n\t\t\tconst {\n\t\t\t\tcanMoveBlocks,\n\t\t\t\tgetBlockRootClientId,\n\t\t\t\tgetBlockName,\n\t\t\t\tgetBlockAttributes,\n\t\t\t\tisBlockInsertionPointVisible,\n\t\t\t} = select( blockEditorStore );\n\t\t\tconst { getBlockType: _getBlockType, getActiveBlockVariation } =\n\t\t\t\tselect( blocksStore );\n\t\t\tconst rootClientId = getBlockRootClientId( clientIds[ 0 ] );\n\t\t\tconst blockName = getBlockName( clientIds[ 0 ] );\n\t\t\tconst variation = getActiveBlockVariation(\n\t\t\t\tblockName,\n\t\t\t\tgetBlockAttributes( clientIds[ 0 ] )\n\t\t\t);\n\n\t\t\treturn {\n\t\t\t\tsrcRootClientId: rootClientId,\n\t\t\t\tisDraggable: canMoveBlocks( clientIds ),\n\t\t\t\ticon: variation?.icon || _getBlockType( blockName )?.icon,\n\t\t\t\tvisibleInserter: isBlockInsertionPointVisible(),\n\t\t\t\tgetBlockType: _getBlockType,\n\t\t\t};\n\t\t},\n\t\t[ clientIds ]\n\t);\n\n\tconst isDragging = useRef( false );\n\tconst [ startScrolling, scrollOnDragOver, stopScrolling ] =\n\t\tuseScrollWhenDragging();\n\n\tconst { getAllowedBlocks, getBlockNamesByClientId, getBlockRootClientId } =\n\t\tuseSelect( blockEditorStore );\n\n\tconst { startDraggingBlocks, stopDraggingBlocks } =\n\t\tuseDispatch( blockEditorStore );\n\n\t// Stop dragging blocks if the block draggable is unmounted.\n\tuseEffect( () => {\n\t\treturn () => {\n\t\t\tif ( isDragging.current ) {\n\t\t\t\tstopDraggingBlocks();\n\t\t\t}\n\t\t};\n\t}, [] );\n\n\t// Find the root of the editor iframe.\n\tconst blockEl = useBlockElement( clientIds[ 0 ] );\n\tconst editorRoot = blockEl?.closest( 'body' );\n\n\t/*\n\t * Add a dragover event listener to the editor root to track the blocks being dragged over.\n\t * The listener has to be inside the editor iframe otherwise the target isn't accessible.\n\t */\n\tuseEffect( () => {\n\t\tif ( ! editorRoot || ! fadeWhenDisabled ) {\n\t\t\treturn;\n\t\t}\n\n\t\tconst onDragOver = ( event ) => {\n\t\t\tif ( ! event.target.closest( '[data-block]' ) ) {\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tconst draggedBlockNames = getBlockNamesByClientId( clientIds );\n\t\t\tconst targetClientId = event.target\n\t\t\t\t.closest( '[data-block]' )\n\t\t\t\t.getAttribute( 'data-block' );\n\n\t\t\tconst allowedBlocks = getAllowedBlocks( targetClientId );\n\t\t\tconst targetBlockName = getBlockNamesByClientId( [\n\t\t\t\ttargetClientId,\n\t\t\t] )[ 0 ];\n\n\t\t\t/*\n\t\t\t * Check if the target is valid to drop in.\n\t\t\t * If the target's allowedBlocks is an empty array,\n\t\t\t * it isn't a container block, in which case we check\n\t\t\t * its parent's validity instead.\n\t\t\t */\n\t\t\tlet dropTargetValid;\n\t\t\tif ( allowedBlocks?.length === 0 ) {\n\t\t\t\tconst targetRootClientId =\n\t\t\t\t\tgetBlockRootClientId( targetClientId );\n\t\t\t\tconst targetRootBlockName = getBlockNamesByClientId( [\n\t\t\t\t\ttargetRootClientId,\n\t\t\t\t] )[ 0 ];\n\t\t\t\tconst rootAllowedBlocks =\n\t\t\t\t\tgetAllowedBlocks( targetRootClientId );\n\t\t\t\tdropTargetValid = isDropTargetValid(\n\t\t\t\t\tgetBlockType,\n\t\t\t\t\trootAllowedBlocks,\n\t\t\t\t\tdraggedBlockNames,\n\t\t\t\t\ttargetRootBlockName\n\t\t\t\t);\n\t\t\t} else {\n\t\t\t\tdropTargetValid = isDropTargetValid(\n\t\t\t\t\tgetBlockType,\n\t\t\t\t\tallowedBlocks,\n\t\t\t\t\tdraggedBlockNames,\n\t\t\t\t\ttargetBlockName\n\t\t\t\t);\n\t\t\t}\n\n\t\t\t/*\n\t\t\t * Update the body class to reflect if drop target is valid.\n\t\t\t * This has to be done on the document body because the draggable\n\t\t\t * chip is rendered outside of the editor iframe.\n\t\t\t */\n\t\t\tif ( ! dropTargetValid && ! visibleInserter ) {\n\t\t\t\twindow?.document?.body?.classList?.add(\n\t\t\t\t\t'block-draggable-invalid-drag-token'\n\t\t\t\t);\n\t\t\t} else {\n\t\t\t\twindow?.document?.body?.classList?.remove(\n\t\t\t\t\t'block-draggable-invalid-drag-token'\n\t\t\t\t);\n\t\t\t}\n\t\t};\n\n\t\tconst throttledOnDragOver = throttle( onDragOver, 200 );\n\n\t\teditorRoot.addEventListener( 'dragover', throttledOnDragOver );\n\n\t\treturn () => {\n\t\t\teditorRoot.removeEventListener( 'dragover', throttledOnDragOver );\n\t\t};\n\t}, [\n\t\tclientIds,\n\t\teditorRoot,\n\t\tfadeWhenDisabled,\n\t\tgetAllowedBlocks,\n\t\tgetBlockNamesByClientId,\n\t\tgetBlockRootClientId,\n\t\tgetBlockType,\n\t\tvisibleInserter,\n\t] );\n\n\tif ( ! isDraggable ) {\n\t\treturn children( { draggable: false } );\n\t}\n\n\tconst transferData = {\n\t\ttype: 'block',\n\t\tsrcClientIds: clientIds,\n\t\tsrcRootClientId,\n\t};\n\n\treturn (\n\t\t<Draggable\n\t\t\tappendToOwnerDocument={ appendToOwnerDocument }\n\t\t\tcloneClassname={ cloneClassname }\n\t\t\t__experimentalTransferDataType=\"wp-blocks\"\n\t\t\ttransferData={ transferData }\n\t\t\tonDragStart={ ( event ) => {\n\t\t\t\t// Defer hiding the dragged source element to the next\n\t\t\t\t// frame to enable dragging.\n\t\t\t\twindow.requestAnimationFrame( () => {\n\t\t\t\t\tstartDraggingBlocks( clientIds );\n\t\t\t\t\tisDragging.current = true;\n\n\t\t\t\t\tstartScrolling( event );\n\n\t\t\t\t\tif ( onDragStart ) {\n\t\t\t\t\t\tonDragStart();\n\t\t\t\t\t}\n\t\t\t\t} );\n\t\t\t} }\n\t\t\tonDragOver={ scrollOnDragOver }\n\t\t\tonDragEnd={ () => {\n\t\t\t\tstopDraggingBlocks();\n\t\t\t\tisDragging.current = false;\n\n\t\t\t\tstopScrolling();\n\n\t\t\t\tif ( onDragEnd ) {\n\t\t\t\t\tonDragEnd();\n\t\t\t\t}\n\t\t\t} }\n\t\t\t__experimentalDragComponent={\n\t\t\t\t// Check against `undefined` so that `null` can be used to disable\n\t\t\t\t// the default drag component.\n\t\t\t\tdragComponent !== undefined ? (\n\t\t\t\t\tdragComponent\n\t\t\t\t) : (\n\t\t\t\t\t<BlockDraggableChip\n\t\t\t\t\t\tcount={ clientIds.length }\n\t\t\t\t\t\ticon={ icon }\n\t\t\t\t\t\tfadeWhenDisabled\n\t\t\t\t\t/>\n\t\t\t\t)\n\t\t\t}\n\t\t\telementId={ elementId }\n\t\t>\n\t\t\t{ ( { onDraggableStart, onDraggableEnd } ) => {\n\t\t\t\treturn children( {\n\t\t\t\t\tdraggable: true,\n\t\t\t\t\tonDragStart: onDraggableStart,\n\t\t\t\t\tonDragEnd: onDraggableEnd,\n\t\t\t\t} );\n\t\t\t} }\n\t\t</Draggable>\n\t);\n};\n\nexport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,SAAS,CAACoD,MAAQ;MAC1B3C,IAAI,EAAGA,IAAM;MACbJ,gBAAgB;IAAA,CAChB,CAEF;IACDH,SAAS,EAAGA,SAAW;IAAAH,QAAA,EAErBA,CAAE;MAAEgF,gBAAgB;MAAEC;IAAe,CAAC,KAAM;MAC7C,OAAOjF,QAAQ,CAAE;QAChBoE,SAAS,EAAE,IAAI;QACfhE,WAAW,EAAE4E,gBAAgB;QAC7B3E,SAAS,EAAE4E;MACZ,CAAE,CAAC;IACJ;EAAC,CACS,CAAC;AAEd,CAAC;AAAC,IAAAC,QAAA,GAAAC,OAAA,CAAAL,OAAA,GAEahF,cAAc","ignoreList":[]}
|
|
@@ -3,8 +3,8 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
exports.
|
|
7
|
-
exports.
|
|
6
|
+
exports.useBlockElement = useBlockElement;
|
|
7
|
+
exports.useBlockElementRef = useBlockElementRef;
|
|
8
8
|
exports.useBlockRefProvider = useBlockRefProvider;
|
|
9
9
|
var _element = require("@wordpress/element");
|
|
10
10
|
var _compose = require("@wordpress/compose");
|
|
@@ -18,7 +18,7 @@ var _blockRefsProvider = require("../../provider/block-refs-provider");
|
|
|
18
18
|
*/
|
|
19
19
|
|
|
20
20
|
/** @typedef {import('@wordpress/element').RefCallback} RefCallback */
|
|
21
|
-
/** @typedef {import('@wordpress/element').
|
|
21
|
+
/** @typedef {import('@wordpress/element').Ref} Ref */
|
|
22
22
|
|
|
23
23
|
/**
|
|
24
24
|
* Provides a ref to the BlockRefs context.
|
|
@@ -36,32 +36,33 @@ function useBlockRefProvider(clientId) {
|
|
|
36
36
|
return () => refsMap.delete(clientId);
|
|
37
37
|
}, [clientId]);
|
|
38
38
|
}
|
|
39
|
+
function assignRef(ref, value) {
|
|
40
|
+
if (typeof ref === 'function') {
|
|
41
|
+
ref(value);
|
|
42
|
+
} else if (ref) {
|
|
43
|
+
ref.current = value;
|
|
44
|
+
}
|
|
45
|
+
}
|
|
39
46
|
|
|
40
47
|
/**
|
|
41
|
-
*
|
|
42
|
-
*
|
|
43
|
-
* reactive, i.e., it won't trigger a rerender of the calling component if the
|
|
44
|
-
* ref value changes. For reactive use cases there is the `useBlockElement` hook.
|
|
45
|
-
*
|
|
46
|
-
* @param {string} clientId The client ID to get a ref for.
|
|
48
|
+
* Tracks the DOM element for the block identified by `clientId` and assigns it to the `ref`
|
|
49
|
+
* whenever it changes.
|
|
47
50
|
*
|
|
48
|
-
* @
|
|
51
|
+
* @param {string} clientId The client ID to track.
|
|
52
|
+
* @param {Ref} ref The ref object/callback to assign to.
|
|
49
53
|
*/
|
|
50
|
-
function
|
|
54
|
+
function useBlockElementRef(clientId, ref) {
|
|
51
55
|
const {
|
|
52
56
|
refsMap
|
|
53
57
|
} = (0, _element.useContext)(_blockRefsProvider.BlockRefs);
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
return (_refsMap$get = refsMap.get(latestClientId.current)) !== null && _refsMap$get !== void 0 ? _refsMap$get : null;
|
|
63
|
-
}
|
|
64
|
-
}), [refsMap]);
|
|
58
|
+
(0, _element.useLayoutEffect)(() => {
|
|
59
|
+
assignRef(ref, refsMap.get(clientId));
|
|
60
|
+
const unsubscribe = refsMap.subscribe(clientId, () => assignRef(ref, refsMap.get(clientId)));
|
|
61
|
+
return () => {
|
|
62
|
+
unsubscribe();
|
|
63
|
+
assignRef(ref, null);
|
|
64
|
+
};
|
|
65
|
+
}, [refsMap, clientId, ref]);
|
|
65
66
|
}
|
|
66
67
|
|
|
67
68
|
/**
|
|
@@ -73,17 +74,8 @@ function useBlockRef(clientId) {
|
|
|
73
74
|
* @return {Element|null} The block's wrapper element.
|
|
74
75
|
*/
|
|
75
76
|
function useBlockElement(clientId) {
|
|
76
|
-
const {
|
|
77
|
-
refsMap
|
|
78
|
-
} = (0, _element.useContext)(_blockRefsProvider.BlockRefs);
|
|
79
77
|
const [blockElement, setBlockElement] = (0, _element.useState)(null);
|
|
80
|
-
|
|
81
|
-
// changes (i.e., the block is unmounted and re-mounted), this allows enough time
|
|
82
|
-
// for the ref callbacks to clean up the old element and set the new one.
|
|
83
|
-
(0, _element.useLayoutEffect)(() => {
|
|
84
|
-
setBlockElement(refsMap.get(clientId));
|
|
85
|
-
return refsMap.subscribe(clientId, () => setBlockElement(refsMap.get(clientId)));
|
|
86
|
-
}, [refsMap, clientId]);
|
|
78
|
+
useBlockElementRef(clientId, setBlockElement);
|
|
87
79
|
return blockElement;
|
|
88
80
|
}
|
|
89
81
|
//# sourceMappingURL=use-block-refs.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_element","require","_compose","_blockRefsProvider","useBlockRefProvider","clientId","refsMap","useContext","BlockRefs","useRefEffect","element","set","delete","
|
|
1
|
+
{"version":3,"names":["_element","require","_compose","_blockRefsProvider","useBlockRefProvider","clientId","refsMap","useContext","BlockRefs","useRefEffect","element","set","delete","assignRef","ref","value","current","useBlockElementRef","useLayoutEffect","get","unsubscribe","subscribe","useBlockElement","blockElement","setBlockElement","useState"],"sources":["@wordpress/block-editor/src/components/block-list/use-block-props/use-block-refs.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { useContext, useState, useLayoutEffect } from '@wordpress/element';\nimport { useRefEffect } from '@wordpress/compose';\n\n/**\n * Internal dependencies\n */\nimport { BlockRefs } from '../../provider/block-refs-provider';\n\n/** @typedef {import('@wordpress/element').RefCallback} RefCallback */\n/** @typedef {import('@wordpress/element').Ref} Ref */\n\n/**\n * Provides a ref to the BlockRefs context.\n *\n * @param {string} clientId The client ID of the element ref.\n *\n * @return {RefCallback} Ref callback.\n */\nexport function useBlockRefProvider( clientId ) {\n\tconst { refsMap } = useContext( BlockRefs );\n\treturn useRefEffect(\n\t\t( element ) => {\n\t\t\trefsMap.set( clientId, element );\n\t\t\treturn () => refsMap.delete( clientId );\n\t\t},\n\t\t[ clientId ]\n\t);\n}\n\nfunction assignRef( ref, value ) {\n\tif ( typeof ref === 'function' ) {\n\t\tref( value );\n\t} else if ( ref ) {\n\t\tref.current = value;\n\t}\n}\n\n/**\n * Tracks the DOM element for the block identified by `clientId` and assigns it to the `ref`\n * whenever it changes.\n *\n * @param {string} clientId The client ID to track.\n * @param {Ref} ref The ref object/callback to assign to.\n */\nexport function useBlockElementRef( clientId, ref ) {\n\tconst { refsMap } = useContext( BlockRefs );\n\tuseLayoutEffect( () => {\n\t\tassignRef( ref, refsMap.get( clientId ) );\n\t\tconst unsubscribe = refsMap.subscribe( clientId, () =>\n\t\t\tassignRef( ref, refsMap.get( clientId ) )\n\t\t);\n\t\treturn () => {\n\t\t\tunsubscribe();\n\t\t\tassignRef( ref, null );\n\t\t};\n\t}, [ refsMap, clientId, ref ] );\n}\n\n/**\n * Return the element for a given client ID. Updates whenever the element\n * changes, becomes available, or disappears.\n *\n * @param {string} clientId The client ID to an element for.\n *\n * @return {Element|null} The block's wrapper element.\n */\nexport function useBlockElement( clientId ) {\n\tconst [ blockElement, setBlockElement ] = useState( null );\n\tuseBlockElementRef( clientId, setBlockElement );\n\treturn blockElement;\n}\n"],"mappings":";;;;;;;;AAGA,IAAAA,QAAA,GAAAC,OAAA;AACA,IAAAC,QAAA,GAAAD,OAAA;AAKA,IAAAE,kBAAA,GAAAF,OAAA;AATA;AACA;AACA;;AAIA;AACA;AACA;;AAGA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,SAASG,mBAAmBA,CAAEC,QAAQ,EAAG;EAC/C,MAAM;IAAEC;EAAQ,CAAC,GAAG,IAAAC,mBAAU,EAAEC,4BAAU,CAAC;EAC3C,OAAO,IAAAC,qBAAY,EAChBC,OAAO,IAAM;IACdJ,OAAO,CAACK,GAAG,CAAEN,QAAQ,EAAEK,OAAQ,CAAC;IAChC,OAAO,MAAMJ,OAAO,CAACM,MAAM,CAAEP,QAAS,CAAC;EACxC,CAAC,EACD,CAAEA,QAAQ,CACX,CAAC;AACF;AAEA,SAASQ,SAASA,CAAEC,GAAG,EAAEC,KAAK,EAAG;EAChC,IAAK,OAAOD,GAAG,KAAK,UAAU,EAAG;IAChCA,GAAG,CAAEC,KAAM,CAAC;EACb,CAAC,MAAM,IAAKD,GAAG,EAAG;IACjBA,GAAG,CAACE,OAAO,GAAGD,KAAK;EACpB;AACD;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,SAASE,kBAAkBA,CAAEZ,QAAQ,EAAES,GAAG,EAAG;EACnD,MAAM;IAAER;EAAQ,CAAC,GAAG,IAAAC,mBAAU,EAAEC,4BAAU,CAAC;EAC3C,IAAAU,wBAAe,EAAE,MAAM;IACtBL,SAAS,CAAEC,GAAG,EAAER,OAAO,CAACa,GAAG,CAAEd,QAAS,CAAE,CAAC;IACzC,MAAMe,WAAW,GAAGd,OAAO,CAACe,SAAS,CAAEhB,QAAQ,EAAE,MAChDQ,SAAS,CAAEC,GAAG,EAAER,OAAO,CAACa,GAAG,CAAEd,QAAS,CAAE,CACzC,CAAC;IACD,OAAO,MAAM;MACZe,WAAW,CAAC,CAAC;MACbP,SAAS,CAAEC,GAAG,EAAE,IAAK,CAAC;IACvB,CAAC;EACF,CAAC,EAAE,CAAER,OAAO,EAAED,QAAQ,EAAES,GAAG,CAAG,CAAC;AAChC;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,SAASQ,eAAeA,CAAEjB,QAAQ,EAAG;EAC3C,MAAM,CAAEkB,YAAY,EAAEC,eAAe,CAAE,GAAG,IAAAC,iBAAQ,EAAE,IAAK,CAAC;EAC1DR,kBAAkB,CAAEZ,QAAQ,EAAEmB,eAAgB,CAAC;EAC/C,OAAOD,YAAY;AACpB","ignoreList":[]}
|
|
@@ -67,7 +67,7 @@ function BlockMover({
|
|
|
67
67
|
isManualGrid: layout.type === 'grid' && layout.isManualPlacement && window.__experimentalEnableGridInteractivity
|
|
68
68
|
};
|
|
69
69
|
}, [clientIds]);
|
|
70
|
-
if (!canMove || isFirst && isLast && !rootClientId) {
|
|
70
|
+
if (!canMove || isFirst && isLast && !rootClientId || hideDragHandle && isManualGrid) {
|
|
71
71
|
return null;
|
|
72
72
|
}
|
|
73
73
|
return /*#__PURE__*/(0, _jsxRuntime.jsxs)(_components.ToolbarGroup, {
|
|
@@ -80,7 +80,6 @@ function BlockMover({
|
|
|
80
80
|
children: draggableProps => /*#__PURE__*/(0, _jsxRuntime.jsx)(_components.Button, {
|
|
81
81
|
icon: _icons.dragHandle,
|
|
82
82
|
className: "block-editor-block-mover__drag-handle",
|
|
83
|
-
"aria-hidden": "true",
|
|
84
83
|
label: (0, _i18n.__)('Drag')
|
|
85
84
|
// Should not be able to tab to drag handle as this
|
|
86
85
|
// button can only be used with a pointer device.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_clsx","_interopRequireDefault","require","_icons","_components","_data","_i18n","_blockDraggable","_button","_store","_jsxRuntime","BlockMover","clientIds","hideDragHandle","isBlockMoverUpButtonDisabled","isBlockMoverDownButtonDisabled","canMove","rootClientId","isFirst","isLast","orientation","isManualGrid","useSelect","select","_getBlockAttributes","getBlockIndex","getBlockListSettings","canMoveBlocks","getBlockOrder","getBlockRootClientId","getBlockAttributes","blockEditorStore","normalizedClientIds","Array","isArray","firstClientId","_rootClientId","firstIndex","lastIndex","length","blockOrder","layout","type","isManualPlacement","window","__experimentalEnableGridInteractivity","jsxs","ToolbarGroup","className","clsx","children","jsx","default","fadeWhenDisabled","draggableProps","Button","icon","dragHandle","label","__","tabIndex","ToolbarItem","itemProps","BlockMoverUpButton","disabled","BlockMoverDownButton","_default","exports"],"sources":["@wordpress/block-editor/src/components/block-mover/index.js"],"sourcesContent":["/**\n * External dependencies\n */\nimport clsx from 'clsx';\n\n/**\n * WordPress dependencies\n */\n\nimport { dragHandle } from '@wordpress/icons';\nimport { ToolbarGroup, ToolbarItem, Button } from '@wordpress/components';\nimport { useSelect } from '@wordpress/data';\nimport { __ } from '@wordpress/i18n';\n\n/**\n * Internal dependencies\n */\nimport BlockDraggable from '../block-draggable';\nimport { BlockMoverUpButton, BlockMoverDownButton } from './button';\nimport { store as blockEditorStore } from '../../store';\n\nfunction BlockMover( {\n\tclientIds,\n\thideDragHandle,\n\tisBlockMoverUpButtonDisabled,\n\tisBlockMoverDownButtonDisabled,\n} ) {\n\tconst {\n\t\tcanMove,\n\t\trootClientId,\n\t\tisFirst,\n\t\tisLast,\n\t\torientation,\n\t\tisManualGrid,\n\t} = useSelect(\n\t\t( select ) => {\n\t\t\tconst {\n\t\t\t\tgetBlockIndex,\n\t\t\t\tgetBlockListSettings,\n\t\t\t\tcanMoveBlocks,\n\t\t\t\tgetBlockOrder,\n\t\t\t\tgetBlockRootClientId,\n\t\t\t\tgetBlockAttributes,\n\t\t\t} = select( blockEditorStore );\n\t\t\tconst normalizedClientIds = Array.isArray( clientIds )\n\t\t\t\t? clientIds\n\t\t\t\t: [ clientIds ];\n\t\t\tconst firstClientId = normalizedClientIds[ 0 ];\n\t\t\tconst _rootClientId = getBlockRootClientId( firstClientId );\n\t\t\tconst firstIndex = getBlockIndex( firstClientId );\n\t\t\tconst lastIndex = getBlockIndex(\n\t\t\t\tnormalizedClientIds[ normalizedClientIds.length - 1 ]\n\t\t\t);\n\t\t\tconst blockOrder = getBlockOrder( _rootClientId );\n\t\t\tconst { layout = {} } = getBlockAttributes( _rootClientId ) ?? {};\n\n\t\t\treturn {\n\t\t\t\tcanMove: canMoveBlocks( clientIds ),\n\t\t\t\trootClientId: _rootClientId,\n\t\t\t\tisFirst: firstIndex === 0,\n\t\t\t\tisLast: lastIndex === blockOrder.length - 1,\n\t\t\t\torientation: getBlockListSettings( _rootClientId )?.orientation,\n\t\t\t\tisManualGrid:\n\t\t\t\t\tlayout.type === 'grid' &&\n\t\t\t\t\tlayout.isManualPlacement &&\n\t\t\t\t\twindow.__experimentalEnableGridInteractivity,\n\t\t\t};\n\t\t},\n\t\t[ clientIds ]\n\t);\n\n\tif (
|
|
1
|
+
{"version":3,"names":["_clsx","_interopRequireDefault","require","_icons","_components","_data","_i18n","_blockDraggable","_button","_store","_jsxRuntime","BlockMover","clientIds","hideDragHandle","isBlockMoverUpButtonDisabled","isBlockMoverDownButtonDisabled","canMove","rootClientId","isFirst","isLast","orientation","isManualGrid","useSelect","select","_getBlockAttributes","getBlockIndex","getBlockListSettings","canMoveBlocks","getBlockOrder","getBlockRootClientId","getBlockAttributes","blockEditorStore","normalizedClientIds","Array","isArray","firstClientId","_rootClientId","firstIndex","lastIndex","length","blockOrder","layout","type","isManualPlacement","window","__experimentalEnableGridInteractivity","jsxs","ToolbarGroup","className","clsx","children","jsx","default","fadeWhenDisabled","draggableProps","Button","icon","dragHandle","label","__","tabIndex","ToolbarItem","itemProps","BlockMoverUpButton","disabled","BlockMoverDownButton","_default","exports"],"sources":["@wordpress/block-editor/src/components/block-mover/index.js"],"sourcesContent":["/**\n * External dependencies\n */\nimport clsx from 'clsx';\n\n/**\n * WordPress dependencies\n */\n\nimport { dragHandle } from '@wordpress/icons';\nimport { ToolbarGroup, ToolbarItem, Button } from '@wordpress/components';\nimport { useSelect } from '@wordpress/data';\nimport { __ } from '@wordpress/i18n';\n\n/**\n * Internal dependencies\n */\nimport BlockDraggable from '../block-draggable';\nimport { BlockMoverUpButton, BlockMoverDownButton } from './button';\nimport { store as blockEditorStore } from '../../store';\n\nfunction BlockMover( {\n\tclientIds,\n\thideDragHandle,\n\tisBlockMoverUpButtonDisabled,\n\tisBlockMoverDownButtonDisabled,\n} ) {\n\tconst {\n\t\tcanMove,\n\t\trootClientId,\n\t\tisFirst,\n\t\tisLast,\n\t\torientation,\n\t\tisManualGrid,\n\t} = useSelect(\n\t\t( select ) => {\n\t\t\tconst {\n\t\t\t\tgetBlockIndex,\n\t\t\t\tgetBlockListSettings,\n\t\t\t\tcanMoveBlocks,\n\t\t\t\tgetBlockOrder,\n\t\t\t\tgetBlockRootClientId,\n\t\t\t\tgetBlockAttributes,\n\t\t\t} = select( blockEditorStore );\n\t\t\tconst normalizedClientIds = Array.isArray( clientIds )\n\t\t\t\t? clientIds\n\t\t\t\t: [ clientIds ];\n\t\t\tconst firstClientId = normalizedClientIds[ 0 ];\n\t\t\tconst _rootClientId = getBlockRootClientId( firstClientId );\n\t\t\tconst firstIndex = getBlockIndex( firstClientId );\n\t\t\tconst lastIndex = getBlockIndex(\n\t\t\t\tnormalizedClientIds[ normalizedClientIds.length - 1 ]\n\t\t\t);\n\t\t\tconst blockOrder = getBlockOrder( _rootClientId );\n\t\t\tconst { layout = {} } = getBlockAttributes( _rootClientId ) ?? {};\n\n\t\t\treturn {\n\t\t\t\tcanMove: canMoveBlocks( clientIds ),\n\t\t\t\trootClientId: _rootClientId,\n\t\t\t\tisFirst: firstIndex === 0,\n\t\t\t\tisLast: lastIndex === blockOrder.length - 1,\n\t\t\t\torientation: getBlockListSettings( _rootClientId )?.orientation,\n\t\t\t\tisManualGrid:\n\t\t\t\t\tlayout.type === 'grid' &&\n\t\t\t\t\tlayout.isManualPlacement &&\n\t\t\t\t\twindow.__experimentalEnableGridInteractivity,\n\t\t\t};\n\t\t},\n\t\t[ clientIds ]\n\t);\n\n\tif (\n\t\t! canMove ||\n\t\t( isFirst && isLast && ! rootClientId ) ||\n\t\t( hideDragHandle && isManualGrid )\n\t) {\n\t\treturn null;\n\t}\n\n\treturn (\n\t\t<ToolbarGroup\n\t\t\tclassName={ clsx( 'block-editor-block-mover', {\n\t\t\t\t'is-horizontal': orientation === 'horizontal',\n\t\t\t} ) }\n\t\t>\n\t\t\t{ ! hideDragHandle && (\n\t\t\t\t<BlockDraggable clientIds={ clientIds } fadeWhenDisabled>\n\t\t\t\t\t{ ( draggableProps ) => (\n\t\t\t\t\t\t<Button\n\t\t\t\t\t\t\ticon={ dragHandle }\n\t\t\t\t\t\t\tclassName=\"block-editor-block-mover__drag-handle\"\n\t\t\t\t\t\t\tlabel={ __( 'Drag' ) }\n\t\t\t\t\t\t\t// Should not be able to tab to drag handle as this\n\t\t\t\t\t\t\t// button can only be used with a pointer device.\n\t\t\t\t\t\t\ttabIndex=\"-1\"\n\t\t\t\t\t\t\t{ ...draggableProps }\n\t\t\t\t\t\t/>\n\t\t\t\t\t) }\n\t\t\t\t</BlockDraggable>\n\t\t\t) }\n\t\t\t{ ! isManualGrid && (\n\t\t\t\t<div className=\"block-editor-block-mover__move-button-container\">\n\t\t\t\t\t<ToolbarItem>\n\t\t\t\t\t\t{ ( itemProps ) => (\n\t\t\t\t\t\t\t<BlockMoverUpButton\n\t\t\t\t\t\t\t\tdisabled={ isBlockMoverUpButtonDisabled }\n\t\t\t\t\t\t\t\tclientIds={ clientIds }\n\t\t\t\t\t\t\t\t{ ...itemProps }\n\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t) }\n\t\t\t\t\t</ToolbarItem>\n\t\t\t\t\t<ToolbarItem>\n\t\t\t\t\t\t{ ( itemProps ) => (\n\t\t\t\t\t\t\t<BlockMoverDownButton\n\t\t\t\t\t\t\t\tdisabled={ isBlockMoverDownButtonDisabled }\n\t\t\t\t\t\t\t\tclientIds={ clientIds }\n\t\t\t\t\t\t\t\t{ ...itemProps }\n\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t) }\n\t\t\t\t\t</ToolbarItem>\n\t\t\t\t</div>\n\t\t\t) }\n\t\t</ToolbarGroup>\n\t);\n}\n\n/**\n * @see https://github.com/WordPress/gutenberg/blob/HEAD/packages/block-editor/src/components/block-mover/README.md\n */\nexport default BlockMover;\n"],"mappings":";;;;;;;AAGA,IAAAA,KAAA,GAAAC,sBAAA,CAAAC,OAAA;AAMA,IAAAC,MAAA,GAAAD,OAAA;AACA,IAAAE,WAAA,GAAAF,OAAA;AACA,IAAAG,KAAA,GAAAH,OAAA;AACA,IAAAI,KAAA,GAAAJ,OAAA;AAKA,IAAAK,eAAA,GAAAN,sBAAA,CAAAC,OAAA;AACA,IAAAM,OAAA,GAAAN,OAAA;AACA,IAAAO,MAAA,GAAAP,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GAClBkD;QAAS,CACd;MACD,CACW,CAAC,eACd,IAAApD,WAAA,CAAAyC,GAAA,EAAC/C,WAAA,CAAAyD,WAAW;QAAAX,QAAA,EACPY,SAAS,iBACZ,IAAApD,WAAA,CAAAyC,GAAA,EAAC3C,OAAA,CAAAyD,oBAAoB;UACpBD,QAAQ,EAAGjD,8BAAgC;UAC3CH,SAAS,EAAGA,SAAW;UAAA,GAClBkD;QAAS,CACd;MACD,CACW,CAAC;IAAA,CACV,CACL;EAAA,CACY,CAAC;AAEjB;;AAEA;AACA;AACA;AAFA,IAAAI,QAAA,GAAAC,OAAA,CAAAf,OAAA,GAGezC,UAAU","ignoreList":[]}
|
|
@@ -26,7 +26,7 @@ function BlockPopoverCover({
|
|
|
26
26
|
}, ref) {
|
|
27
27
|
var _bottomClientId;
|
|
28
28
|
(_bottomClientId = bottomClientId) !== null && _bottomClientId !== void 0 ? _bottomClientId : bottomClientId = clientId;
|
|
29
|
-
const selectedElement = (0, _useBlockRefs.
|
|
29
|
+
const selectedElement = (0, _useBlockRefs.useBlockElement)(clientId);
|
|
30
30
|
return /*#__PURE__*/(0, _jsxRuntime.jsx)(_.PrivateBlockPopover, {
|
|
31
31
|
ref: ref,
|
|
32
32
|
clientId: clientId,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_element","require","_useBlockRefs","_","_jsxRuntime","BlockPopoverCover","clientId","bottomClientId","children","shift","additionalStyles","props","ref","_bottomClientId","selectedElement","useBlockElement","jsx","PrivateBlockPopover","CoverContainer","width","setWidth","useState","offsetWidth","height","setHeight","offsetHeight","useEffect","observer","window","ResizeObserver","observe","box","disconnect","style","useMemo","position","_default","exports","default","forwardRef"],"sources":["@wordpress/block-editor/src/components/block-popover/cover.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { useEffect, useState, useMemo, forwardRef } from '@wordpress/element';\n\n/**\n * Internal dependencies\n */\nimport {
|
|
1
|
+
{"version":3,"names":["_element","require","_useBlockRefs","_","_jsxRuntime","BlockPopoverCover","clientId","bottomClientId","children","shift","additionalStyles","props","ref","_bottomClientId","selectedElement","useBlockElement","jsx","PrivateBlockPopover","CoverContainer","width","setWidth","useState","offsetWidth","height","setHeight","offsetHeight","useEffect","observer","window","ResizeObserver","observe","box","disconnect","style","useMemo","position","_default","exports","default","forwardRef"],"sources":["@wordpress/block-editor/src/components/block-popover/cover.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { useEffect, useState, useMemo, forwardRef } from '@wordpress/element';\n\n/**\n * Internal dependencies\n */\nimport { useBlockElement } from '../block-list/use-block-props/use-block-refs';\nimport { PrivateBlockPopover } from '.';\n\nfunction BlockPopoverCover(\n\t{\n\t\tclientId,\n\t\tbottomClientId,\n\t\tchildren,\n\t\tshift = false,\n\t\tadditionalStyles,\n\t\t...props\n\t},\n\tref\n) {\n\tbottomClientId ??= clientId;\n\n\tconst selectedElement = useBlockElement( clientId );\n\n\treturn (\n\t\t<PrivateBlockPopover\n\t\t\tref={ ref }\n\t\t\tclientId={ clientId }\n\t\t\tbottomClientId={ bottomClientId }\n\t\t\tshift={ shift }\n\t\t\t{ ...props }\n\t\t>\n\t\t\t{ selectedElement && clientId === bottomClientId ? (\n\t\t\t\t<CoverContainer\n\t\t\t\t\tselectedElement={ selectedElement }\n\t\t\t\t\tadditionalStyles={ additionalStyles }\n\t\t\t\t>\n\t\t\t\t\t{ children }\n\t\t\t\t</CoverContainer>\n\t\t\t) : (\n\t\t\t\tchildren\n\t\t\t) }\n\t\t</PrivateBlockPopover>\n\t);\n}\n\nfunction CoverContainer( {\n\tselectedElement,\n\tadditionalStyles = {},\n\tchildren,\n} ) {\n\tconst [ width, setWidth ] = useState( selectedElement.offsetWidth );\n\tconst [ height, setHeight ] = useState( selectedElement.offsetHeight );\n\n\tuseEffect( () => {\n\t\tconst observer = new window.ResizeObserver( () => {\n\t\t\tsetWidth( selectedElement.offsetWidth );\n\t\t\tsetHeight( selectedElement.offsetHeight );\n\t\t} );\n\t\tobserver.observe( selectedElement, { box: 'border-box' } );\n\t\treturn () => observer.disconnect();\n\t}, [ selectedElement ] );\n\n\tconst style = useMemo( () => {\n\t\treturn {\n\t\t\tposition: 'absolute',\n\t\t\twidth,\n\t\t\theight,\n\t\t\t...additionalStyles,\n\t\t};\n\t}, [ width, height, additionalStyles ] );\n\n\treturn <div style={ style }>{ children }</div>;\n}\n\nexport default forwardRef( BlockPopoverCover );\n"],"mappings":";;;;;;AAGA,IAAAA,QAAA,GAAAC,OAAA;AAKA,IAAAC,aAAA,GAAAD,OAAA;AACA,IAAAE,CAAA,GAAAF,OAAA;AAAwC,IAAAG,WAAA,GAAAH,OAAA;AATxC;AACA;AACA;;AAGA;AACA;AACA;;AAIA,SAASI,iBAAiBA,CACzB;EACCC,QAAQ;EACRC,cAAc;EACdC,QAAQ;EACRC,KAAK,GAAG,KAAK;EACbC,gBAAgB;EAChB,GAAGC;AACJ,CAAC,EACDC,GAAG,EACF;EAAA,IAAAC,eAAA;EACD,CAAAA,eAAA,GAAAN,cAAc,cAAAM,eAAA,cAAAA,eAAA,GAAdN,cAAc,GAAKD,QAAQ;EAE3B,MAAMQ,eAAe,GAAG,IAAAC,6BAAe,EAAET,QAAS,CAAC;EAEnD,oBACC,IAAAF,WAAA,CAAAY,GAAA,EAACb,CAAA,CAAAc,mBAAmB;IACnBL,GAAG,EAAGA,GAAK;IACXN,QAAQ,EAAGA,QAAU;IACrBC,cAAc,EAAGA,cAAgB;IACjCE,KAAK,EAAGA,KAAO;IAAA,GACVE,KAAK;IAAAH,QAAA,EAERM,eAAe,IAAIR,QAAQ,KAAKC,cAAc,gBAC/C,IAAAH,WAAA,CAAAY,GAAA,EAACE,cAAc;MACdJ,eAAe,EAAGA,eAAiB;MACnCJ,gBAAgB,EAAGA,gBAAkB;MAAAF,QAAA,EAEnCA;IAAQ,CACK,CAAC,GAEjBA;EACA,CACmB,CAAC;AAExB;AAEA,SAASU,cAAcA,CAAE;EACxBJ,eAAe;EACfJ,gBAAgB,GAAG,CAAC,CAAC;EACrBF;AACD,CAAC,EAAG;EACH,MAAM,CAAEW,KAAK,EAAEC,QAAQ,CAAE,GAAG,IAAAC,iBAAQ,EAAEP,eAAe,CAACQ,WAAY,CAAC;EACnE,MAAM,CAAEC,MAAM,EAAEC,SAAS,CAAE,GAAG,IAAAH,iBAAQ,EAAEP,eAAe,CAACW,YAAa,CAAC;EAEtE,IAAAC,kBAAS,EAAE,MAAM;IAChB,MAAMC,QAAQ,GAAG,IAAIC,MAAM,CAACC,cAAc,CAAE,MAAM;MACjDT,QAAQ,CAAEN,eAAe,CAACQ,WAAY,CAAC;MACvCE,SAAS,CAAEV,eAAe,CAACW,YAAa,CAAC;IAC1C,CAAE,CAAC;IACHE,QAAQ,CAACG,OAAO,CAAEhB,eAAe,EAAE;MAAEiB,GAAG,EAAE;IAAa,CAAE,CAAC;IAC1D,OAAO,MAAMJ,QAAQ,CAACK,UAAU,CAAC,CAAC;EACnC,CAAC,EAAE,CAAElB,eAAe,CAAG,CAAC;EAExB,MAAMmB,KAAK,GAAG,IAAAC,gBAAO,EAAE,MAAM;IAC5B,OAAO;MACNC,QAAQ,EAAE,UAAU;MACpBhB,KAAK;MACLI,MAAM;MACN,GAAGb;IACJ,CAAC;EACF,CAAC,EAAE,CAAES,KAAK,EAAEI,MAAM,EAAEb,gBAAgB,CAAG,CAAC;EAExC,oBAAO,IAAAN,WAAA,CAAAY,GAAA;IAAKiB,KAAK,EAAGA,KAAO;IAAAzB,QAAA,EAAGA;EAAQ,CAAO,CAAC;AAC/C;AAAC,IAAA4B,QAAA,GAAAC,OAAA,CAAAC,OAAA,GAEc,IAAAC,mBAAU,EAAElC,iBAAkB,CAAC","ignoreList":[]}
|
|
@@ -59,8 +59,8 @@ function BlockPopoverInbetween({
|
|
|
59
59
|
isVisible: isBlockVisible(previousClientId) && isBlockVisible(nextClientId)
|
|
60
60
|
};
|
|
61
61
|
}, [previousClientId, nextClientId]);
|
|
62
|
-
const previousElement = (0, _useBlockRefs.
|
|
63
|
-
const nextElement = (0, _useBlockRefs.
|
|
62
|
+
const previousElement = (0, _useBlockRefs.useBlockElement)(previousClientId);
|
|
63
|
+
const nextElement = (0, _useBlockRefs.useBlockElement)(nextClientId);
|
|
64
64
|
const isVertical = orientation === 'vertical';
|
|
65
65
|
const popoverAnchor = (0, _element.useMemo)(() => {
|
|
66
66
|
if (
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_clsx","_interopRequireDefault","require","_data","_element","_components","_i18n","_store","_useBlockRefs","_usePopoverScroll","_jsxRuntime","MAX_POPOVER_RECOMPUTE_COUNTER","Number","MAX_SAFE_INTEGER","InsertionPointOpenRef","exports","createContext","BlockPopoverInbetween","previousClientId","nextClientId","children","__unstablePopoverSlot","__unstableContentRef","operation","nearestSide","props","popoverRecomputeCounter","forcePopoverRecompute","useReducer","s","orientation","rootClientId","isVisible","useSelect","select","getBlockListSettings","getBlockRootClientId","isBlockVisible","blockEditorStore","_rootClientId","previousElement","useBlockElement","nextElement","isVertical","popoverAnchor","useMemo","undefined","contextElement","getBoundingClientRect","previousRect","nextRect","left","top","width","height","targetRect","bottom","right","isRTL","window","DOMRect","popoverScrollRef","usePopoverScroll","useLayoutEffect","observer","MutationObserver","observe","attributes","disconnect","ownerDocument","defaultView","addEventListener","removeEventListener","jsx","Popover","ref","animate","anchor","focusOnMount","__unstableSlotName","inline","className","clsx","resize","flip","placement","variant","_default","default"],"sources":["@wordpress/block-editor/src/components/block-popover/inbetween.js"],"sourcesContent":["/**\n * External dependencies\n */\nimport clsx from 'clsx';\n\n/**\n * WordPress dependencies\n */\nimport { useSelect } from '@wordpress/data';\nimport {\n\tuseMemo,\n\tcreateContext,\n\tuseReducer,\n\tuseLayoutEffect,\n} from '@wordpress/element';\nimport { Popover } from '@wordpress/components';\nimport { isRTL } from '@wordpress/i18n';\n\n/**\n * Internal dependencies\n */\nimport { store as blockEditorStore } from '../../store';\nimport { __unstableUseBlockElement as useBlockElement } from '../block-list/use-block-props/use-block-refs';\nimport usePopoverScroll from './use-popover-scroll';\n\nconst MAX_POPOVER_RECOMPUTE_COUNTER = Number.MAX_SAFE_INTEGER;\n\nexport const InsertionPointOpenRef = createContext();\n\nfunction BlockPopoverInbetween( {\n\tpreviousClientId,\n\tnextClientId,\n\tchildren,\n\t__unstablePopoverSlot,\n\t__unstableContentRef,\n\toperation = 'insert',\n\tnearestSide = 'right',\n\t...props\n} ) {\n\t// This is a temporary hack to get the inbetween inserter to recompute properly.\n\tconst [ popoverRecomputeCounter, forcePopoverRecompute ] = useReducer(\n\t\t// Module is there to make sure that the counter doesn't overflow.\n\t\t( s ) => ( s + 1 ) % MAX_POPOVER_RECOMPUTE_COUNTER,\n\t\t0\n\t);\n\n\tconst { orientation, rootClientId, isVisible } = useSelect(\n\t\t( select ) => {\n\t\t\tconst {\n\t\t\t\tgetBlockListSettings,\n\t\t\t\tgetBlockRootClientId,\n\t\t\t\tisBlockVisible,\n\t\t\t} = select( blockEditorStore );\n\n\t\t\tconst _rootClientId = getBlockRootClientId(\n\t\t\t\tpreviousClientId ?? nextClientId\n\t\t\t);\n\t\t\treturn {\n\t\t\t\torientation:\n\t\t\t\t\tgetBlockListSettings( _rootClientId )?.orientation ||\n\t\t\t\t\t'vertical',\n\t\t\t\trootClientId: _rootClientId,\n\t\t\t\tisVisible:\n\t\t\t\t\tisBlockVisible( previousClientId ) &&\n\t\t\t\t\tisBlockVisible( nextClientId ),\n\t\t\t};\n\t\t},\n\t\t[ previousClientId, nextClientId ]\n\t);\n\tconst previousElement = useBlockElement( previousClientId );\n\tconst nextElement = useBlockElement( nextClientId );\n\tconst isVertical = orientation === 'vertical';\n\n\tconst popoverAnchor = useMemo( () => {\n\t\tif (\n\t\t\t// popoverRecomputeCounter is by definition always equal or greater than 0.\n\t\t\t// This check is only there to satisfy the correctness of the\n\t\t\t// exhaustive-deps rule for the `useMemo` hook.\n\t\t\tpopoverRecomputeCounter < 0 ||\n\t\t\t( ! previousElement && ! nextElement ) ||\n\t\t\t! isVisible\n\t\t) {\n\t\t\treturn undefined;\n\t\t}\n\n\t\tconst contextElement =\n\t\t\toperation === 'group'\n\t\t\t\t? nextElement || previousElement\n\t\t\t\t: previousElement || nextElement;\n\n\t\treturn {\n\t\t\tcontextElement,\n\t\t\tgetBoundingClientRect() {\n\t\t\t\tconst previousRect = previousElement\n\t\t\t\t\t? previousElement.getBoundingClientRect()\n\t\t\t\t\t: null;\n\t\t\t\tconst nextRect = nextElement\n\t\t\t\t\t? nextElement.getBoundingClientRect()\n\t\t\t\t\t: null;\n\n\t\t\t\tlet left = 0;\n\t\t\t\tlet top = 0;\n\t\t\t\tlet width = 0;\n\t\t\t\tlet height = 0;\n\n\t\t\t\tif ( operation === 'group' ) {\n\t\t\t\t\tconst targetRect = nextRect || previousRect;\n\t\t\t\t\ttop = targetRect.top;\n\t\t\t\t\t// No spacing is likely around blocks in this operation.\n\t\t\t\t\t// So width of the inserter containing rect is set to 0.\n\t\t\t\t\twidth = 0;\n\t\t\t\t\theight = targetRect.bottom - targetRect.top;\n\t\t\t\t\t// Popover calculates its distance from mid-block so some\n\t\t\t\t\t// adjustments are needed to make it appear in the right place.\n\t\t\t\t\tleft =\n\t\t\t\t\t\tnearestSide === 'left'\n\t\t\t\t\t\t\t? targetRect.left - 2\n\t\t\t\t\t\t\t: targetRect.right - 2;\n\t\t\t\t} else if ( isVertical ) {\n\t\t\t\t\t// vertical\n\t\t\t\t\ttop = previousRect ? previousRect.bottom : nextRect.top;\n\t\t\t\t\twidth = previousRect ? previousRect.width : nextRect.width;\n\t\t\t\t\theight =\n\t\t\t\t\t\tnextRect && previousRect\n\t\t\t\t\t\t\t? nextRect.top - previousRect.bottom\n\t\t\t\t\t\t\t: 0;\n\t\t\t\t\tleft = previousRect ? previousRect.left : nextRect.left;\n\t\t\t\t} else {\n\t\t\t\t\ttop = previousRect ? previousRect.top : nextRect.top;\n\t\t\t\t\theight = previousRect\n\t\t\t\t\t\t? previousRect.height\n\t\t\t\t\t\t: nextRect.height;\n\n\t\t\t\t\tif ( isRTL() ) {\n\t\t\t\t\t\t// non vertical, rtl\n\t\t\t\t\t\tleft = nextRect ? nextRect.right : previousRect.left;\n\t\t\t\t\t\twidth =\n\t\t\t\t\t\t\tpreviousRect && nextRect\n\t\t\t\t\t\t\t\t? previousRect.left - nextRect.right\n\t\t\t\t\t\t\t\t: 0;\n\t\t\t\t\t} else {\n\t\t\t\t\t\t// non vertical, ltr\n\t\t\t\t\t\tleft = previousRect\n\t\t\t\t\t\t\t? previousRect.right\n\t\t\t\t\t\t\t: nextRect.left;\n\t\t\t\t\t\twidth =\n\t\t\t\t\t\t\tpreviousRect && nextRect\n\t\t\t\t\t\t\t\t? nextRect.left - previousRect.right\n\t\t\t\t\t\t\t\t: 0;\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\treturn new window.DOMRect( left, top, width, height );\n\t\t\t},\n\t\t};\n\t}, [\n\t\tpreviousElement,\n\t\tnextElement,\n\t\tpopoverRecomputeCounter,\n\t\tisVertical,\n\t\tisVisible,\n\t\toperation,\n\t\tnearestSide,\n\t] );\n\n\tconst popoverScrollRef = usePopoverScroll( __unstableContentRef );\n\n\t// This is only needed for a smooth transition when moving blocks.\n\t// When blocks are moved up/down, their position can be set by\n\t// updating the `transform` property manually (i.e. without using CSS\n\t// transitions or animations). The animation, which can also scroll the block\n\t// editor, can sometimes cause the position of the Popover to get out of sync.\n\t// A MutationObserver is therefore used to make sure that changes to the\n\t// selectedElement's attribute (i.e. `transform`) can be tracked and used to\n\t// trigger the Popover to rerender.\n\tuseLayoutEffect( () => {\n\t\tif ( ! previousElement ) {\n\t\t\treturn;\n\t\t}\n\t\tconst observer = new window.MutationObserver( forcePopoverRecompute );\n\t\tobserver.observe( previousElement, { attributes: true } );\n\n\t\treturn () => {\n\t\t\tobserver.disconnect();\n\t\t};\n\t}, [ previousElement ] );\n\n\tuseLayoutEffect( () => {\n\t\tif ( ! nextElement ) {\n\t\t\treturn;\n\t\t}\n\t\tconst observer = new window.MutationObserver( forcePopoverRecompute );\n\t\tobserver.observe( nextElement, { attributes: true } );\n\n\t\treturn () => {\n\t\t\tobserver.disconnect();\n\t\t};\n\t}, [ nextElement ] );\n\n\tuseLayoutEffect( () => {\n\t\tif ( ! previousElement ) {\n\t\t\treturn;\n\t\t}\n\t\tpreviousElement.ownerDocument.defaultView.addEventListener(\n\t\t\t'resize',\n\t\t\tforcePopoverRecompute\n\t\t);\n\t\treturn () => {\n\t\t\tpreviousElement.ownerDocument.defaultView?.removeEventListener(\n\t\t\t\t'resize',\n\t\t\t\tforcePopoverRecompute\n\t\t\t);\n\t\t};\n\t}, [ previousElement ] );\n\n\t// If there's either a previous or a next element, show the inbetween popover.\n\t// Note that drag and drop uses the inbetween popover to show the drop indicator\n\t// before the first block and after the last block.\n\tif ( ( ! previousElement && ! nextElement ) || ! isVisible ) {\n\t\treturn null;\n\t}\n\n\t/* eslint-disable jsx-a11y/no-static-element-interactions, jsx-a11y/click-events-have-key-events */\n\t// While ideally it would be enough to capture the\n\t// bubbling focus event from the Inserter, due to the\n\t// characteristics of click focusing of `button`s in\n\t// Firefox and Safari, it is not reliable.\n\t//\n\t// See: https://developer.mozilla.org/en-US/docs/Web/HTML/Element/button#Clicking_and_focus\n\treturn (\n\t\t<Popover\n\t\t\tref={ popoverScrollRef }\n\t\t\tanimate={ false }\n\t\t\tanchor={ popoverAnchor }\n\t\t\tfocusOnMount={ false }\n\t\t\t// Render in the old slot if needed for backward compatibility,\n\t\t\t// otherwise render in place (not in the default popover slot).\n\t\t\t__unstableSlotName={ __unstablePopoverSlot }\n\t\t\tinline={ ! __unstablePopoverSlot }\n\t\t\t// Forces a remount of the popover when its position changes\n\t\t\t// This makes sure the popover doesn't animate from its previous position.\n\t\t\tkey={ nextClientId + '--' + rootClientId }\n\t\t\t{ ...props }\n\t\t\tclassName={ clsx(\n\t\t\t\t'block-editor-block-popover',\n\t\t\t\t'block-editor-block-popover__inbetween',\n\t\t\t\tprops.className\n\t\t\t) }\n\t\t\tresize={ false }\n\t\t\tflip={ false }\n\t\t\tplacement=\"overlay\"\n\t\t\tvariant=\"unstyled\"\n\t\t>\n\t\t\t<div className=\"block-editor-block-popover__inbetween-container\">\n\t\t\t\t{ children }\n\t\t\t</div>\n\t\t</Popover>\n\t);\n\t/* eslint-enable jsx-a11y/no-static-element-interactions, jsx-a11y/click-events-have-key-events */\n}\n\nexport default BlockPopoverInbetween;\n"],"mappings":";;;;;;;AAGA,IAAAA,KAAA,GAAAC,sBAAA,CAAAC,OAAA;AAKA,IAAAC,KAAA,GAAAD,OAAA;AACA,IAAAE,QAAA,GAAAF,OAAA;AAMA,IAAAG,WAAA,GAAAH,OAAA;AACA,IAAAI,KAAA,GAAAJ,OAAA;AAKA,IAAAK,MAAA,GAAAL,OAAA;AACA,IAAAM,aAAA,GAAAN,OAAA;AACA,IAAAO,iBAAA,GAAAR,sBAAA,CAAAC,OAAA;AAAoD,IAAAQ,WAAA,GAAAR,OAAA;AAvBpD;AACA;AACA;;AAGA;AACA;AACA;;AAWA;AACA;AACA;;AAKA,MAAMS,6BAA6B,GAAGC,MAAM,CAACC,gBAAgB;AAEtD,MAAMC,qBAAqB,GAAAC,OAAA,CAAAD,qBAAA,GAAG,IAAAE,sBAAa,EAAC,CAAC;AAEpD,SAASC,qBAAqBA,CAAE;EAC/BC,gBAAgB;EAChBC,YAAY;EACZC,QAAQ;EACRC,qBAAqB;EACrBC,oBAAoB;EACpBC,SAAS,GAAG,QAAQ;EACpBC,WAAW,GAAG,OAAO;EACrB,GAAGC;AACJ,CAAC,EAAG;EACH;EACA,MAAM,CAAEC,uBAAuB,EAAEC,qBAAqB,CAAE,GAAG,IAAAC,mBAAU;EACpE;EACEC,CAAC,IAAM,CAAEA,CAAC,GAAG,CAAC,IAAKlB,6BAA6B,EAClD,CACD,CAAC;EAED,MAAM;IAAEmB,WAAW;IAAEC,YAAY;IAAEC;EAAU,CAAC,GAAG,IAAAC,eAAS,EACvDC,MAAM,IAAM;IACb,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Ae,EAAG;MACxB;IACD;IACAA,eAAe,CAAC6B,aAAa,CAACC,WAAW,CAACC,gBAAgB,CACzD,QAAQ,EACR5C,qBACD,CAAC;IACD,OAAO,MAAM;MACZa,eAAe,CAAC6B,aAAa,CAACC,WAAW,EAAEE,mBAAmB,CAC7D,QAAQ,EACR7C,qBACD,CAAC;IACF,CAAC;EACF,CAAC,EAAE,CAAEa,eAAe,CAAG,CAAC;;EAExB;EACA;EACA;EACA,IAAO,CAAEA,eAAe,IAAI,CAAEE,WAAW,IAAM,CAAEV,SAAS,EAAG;IAC5D,OAAO,IAAI;EACZ;;EAEA;EACA;EACA;EACA;EACA;EACA;EACA;EACA,oBACC,IAAAtB,WAAA,CAAA+D,GAAA,EAACpE,WAAA,CAAAqE,OAAO;IACPC,GAAG,EAAGd,gBAAkB;IACxBe,OAAO,EAAG,KAAO;IACjBC,MAAM,EAAGjC,aAAe;IACxBkC,YAAY,EAAG;IACf;IACA;IAAA;IACAC,kBAAkB,EAAG1D,qBAAuB;IAC5C2D,MAAM,EAAG,CAAE3D;IACX;IACA;IAAA;IAAA,GAEKI,KAAK;IACVwD,SAAS,EAAG,IAAAC,aAAI,EACf,4BAA4B,EAC5B,uCAAuC,EACvCzD,KAAK,CAACwD,SACP,CAAG;IACHE,MAAM,EAAG,KAAO;IAChBC,IAAI,EAAG,KAAO;IACdC,SAAS,EAAC,SAAS;IACnBC,OAAO,EAAC,UAAU;IAAAlE,QAAA,eAElB,IAAAV,WAAA,CAAA+D,GAAA;MAAKQ,SAAS,EAAC,iDAAiD;MAAA7D,QAAA,EAC7DA;IAAQ,CACN;EAAC,GAdAD,YAAY,GAAG,IAAI,GAAGY,YAepB,CAAC;EAEX;AACD;AAAC,IAAAwD,QAAA,GAAAxE,OAAA,CAAAyE,OAAA,GAEcvE,qBAAqB","ignoreList":[]}
|
|
1
|
+
{"version":3,"names":["_clsx","_interopRequireDefault","require","_data","_element","_components","_i18n","_store","_useBlockRefs","_usePopoverScroll","_jsxRuntime","MAX_POPOVER_RECOMPUTE_COUNTER","Number","MAX_SAFE_INTEGER","InsertionPointOpenRef","exports","createContext","BlockPopoverInbetween","previousClientId","nextClientId","children","__unstablePopoverSlot","__unstableContentRef","operation","nearestSide","props","popoverRecomputeCounter","forcePopoverRecompute","useReducer","s","orientation","rootClientId","isVisible","useSelect","select","getBlockListSettings","getBlockRootClientId","isBlockVisible","blockEditorStore","_rootClientId","previousElement","useBlockElement","nextElement","isVertical","popoverAnchor","useMemo","undefined","contextElement","getBoundingClientRect","previousRect","nextRect","left","top","width","height","targetRect","bottom","right","isRTL","window","DOMRect","popoverScrollRef","usePopoverScroll","useLayoutEffect","observer","MutationObserver","observe","attributes","disconnect","ownerDocument","defaultView","addEventListener","removeEventListener","jsx","Popover","ref","animate","anchor","focusOnMount","__unstableSlotName","inline","className","clsx","resize","flip","placement","variant","_default","default"],"sources":["@wordpress/block-editor/src/components/block-popover/inbetween.js"],"sourcesContent":["/**\n * External dependencies\n */\nimport clsx from 'clsx';\n\n/**\n * WordPress dependencies\n */\nimport { useSelect } from '@wordpress/data';\nimport {\n\tuseMemo,\n\tcreateContext,\n\tuseReducer,\n\tuseLayoutEffect,\n} from '@wordpress/element';\nimport { Popover } from '@wordpress/components';\nimport { isRTL } from '@wordpress/i18n';\n\n/**\n * Internal dependencies\n */\nimport { store as blockEditorStore } from '../../store';\nimport { useBlockElement } from '../block-list/use-block-props/use-block-refs';\nimport usePopoverScroll from './use-popover-scroll';\n\nconst MAX_POPOVER_RECOMPUTE_COUNTER = Number.MAX_SAFE_INTEGER;\n\nexport const InsertionPointOpenRef = createContext();\n\nfunction BlockPopoverInbetween( {\n\tpreviousClientId,\n\tnextClientId,\n\tchildren,\n\t__unstablePopoverSlot,\n\t__unstableContentRef,\n\toperation = 'insert',\n\tnearestSide = 'right',\n\t...props\n} ) {\n\t// This is a temporary hack to get the inbetween inserter to recompute properly.\n\tconst [ popoverRecomputeCounter, forcePopoverRecompute ] = useReducer(\n\t\t// Module is there to make sure that the counter doesn't overflow.\n\t\t( s ) => ( s + 1 ) % MAX_POPOVER_RECOMPUTE_COUNTER,\n\t\t0\n\t);\n\n\tconst { orientation, rootClientId, isVisible } = useSelect(\n\t\t( select ) => {\n\t\t\tconst {\n\t\t\t\tgetBlockListSettings,\n\t\t\t\tgetBlockRootClientId,\n\t\t\t\tisBlockVisible,\n\t\t\t} = select( blockEditorStore );\n\n\t\t\tconst _rootClientId = getBlockRootClientId(\n\t\t\t\tpreviousClientId ?? nextClientId\n\t\t\t);\n\t\t\treturn {\n\t\t\t\torientation:\n\t\t\t\t\tgetBlockListSettings( _rootClientId )?.orientation ||\n\t\t\t\t\t'vertical',\n\t\t\t\trootClientId: _rootClientId,\n\t\t\t\tisVisible:\n\t\t\t\t\tisBlockVisible( previousClientId ) &&\n\t\t\t\t\tisBlockVisible( nextClientId ),\n\t\t\t};\n\t\t},\n\t\t[ previousClientId, nextClientId ]\n\t);\n\tconst previousElement = useBlockElement( previousClientId );\n\tconst nextElement = useBlockElement( nextClientId );\n\tconst isVertical = orientation === 'vertical';\n\n\tconst popoverAnchor = useMemo( () => {\n\t\tif (\n\t\t\t// popoverRecomputeCounter is by definition always equal or greater than 0.\n\t\t\t// This check is only there to satisfy the correctness of the\n\t\t\t// exhaustive-deps rule for the `useMemo` hook.\n\t\t\tpopoverRecomputeCounter < 0 ||\n\t\t\t( ! previousElement && ! nextElement ) ||\n\t\t\t! isVisible\n\t\t) {\n\t\t\treturn undefined;\n\t\t}\n\n\t\tconst contextElement =\n\t\t\toperation === 'group'\n\t\t\t\t? nextElement || previousElement\n\t\t\t\t: previousElement || nextElement;\n\n\t\treturn {\n\t\t\tcontextElement,\n\t\t\tgetBoundingClientRect() {\n\t\t\t\tconst previousRect = previousElement\n\t\t\t\t\t? previousElement.getBoundingClientRect()\n\t\t\t\t\t: null;\n\t\t\t\tconst nextRect = nextElement\n\t\t\t\t\t? nextElement.getBoundingClientRect()\n\t\t\t\t\t: null;\n\n\t\t\t\tlet left = 0;\n\t\t\t\tlet top = 0;\n\t\t\t\tlet width = 0;\n\t\t\t\tlet height = 0;\n\n\t\t\t\tif ( operation === 'group' ) {\n\t\t\t\t\tconst targetRect = nextRect || previousRect;\n\t\t\t\t\ttop = targetRect.top;\n\t\t\t\t\t// No spacing is likely around blocks in this operation.\n\t\t\t\t\t// So width of the inserter containing rect is set to 0.\n\t\t\t\t\twidth = 0;\n\t\t\t\t\theight = targetRect.bottom - targetRect.top;\n\t\t\t\t\t// Popover calculates its distance from mid-block so some\n\t\t\t\t\t// adjustments are needed to make it appear in the right place.\n\t\t\t\t\tleft =\n\t\t\t\t\t\tnearestSide === 'left'\n\t\t\t\t\t\t\t? targetRect.left - 2\n\t\t\t\t\t\t\t: targetRect.right - 2;\n\t\t\t\t} else if ( isVertical ) {\n\t\t\t\t\t// vertical\n\t\t\t\t\ttop = previousRect ? previousRect.bottom : nextRect.top;\n\t\t\t\t\twidth = previousRect ? previousRect.width : nextRect.width;\n\t\t\t\t\theight =\n\t\t\t\t\t\tnextRect && previousRect\n\t\t\t\t\t\t\t? nextRect.top - previousRect.bottom\n\t\t\t\t\t\t\t: 0;\n\t\t\t\t\tleft = previousRect ? previousRect.left : nextRect.left;\n\t\t\t\t} else {\n\t\t\t\t\ttop = previousRect ? previousRect.top : nextRect.top;\n\t\t\t\t\theight = previousRect\n\t\t\t\t\t\t? previousRect.height\n\t\t\t\t\t\t: nextRect.height;\n\n\t\t\t\t\tif ( isRTL() ) {\n\t\t\t\t\t\t// non vertical, rtl\n\t\t\t\t\t\tleft = nextRect ? nextRect.right : previousRect.left;\n\t\t\t\t\t\twidth =\n\t\t\t\t\t\t\tpreviousRect && nextRect\n\t\t\t\t\t\t\t\t? previousRect.left - nextRect.right\n\t\t\t\t\t\t\t\t: 0;\n\t\t\t\t\t} else {\n\t\t\t\t\t\t// non vertical, ltr\n\t\t\t\t\t\tleft = previousRect\n\t\t\t\t\t\t\t? previousRect.right\n\t\t\t\t\t\t\t: nextRect.left;\n\t\t\t\t\t\twidth =\n\t\t\t\t\t\t\tpreviousRect && nextRect\n\t\t\t\t\t\t\t\t? nextRect.left - previousRect.right\n\t\t\t\t\t\t\t\t: 0;\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\treturn new window.DOMRect( left, top, width, height );\n\t\t\t},\n\t\t};\n\t}, [\n\t\tpreviousElement,\n\t\tnextElement,\n\t\tpopoverRecomputeCounter,\n\t\tisVertical,\n\t\tisVisible,\n\t\toperation,\n\t\tnearestSide,\n\t] );\n\n\tconst popoverScrollRef = usePopoverScroll( __unstableContentRef );\n\n\t// This is only needed for a smooth transition when moving blocks.\n\t// When blocks are moved up/down, their position can be set by\n\t// updating the `transform` property manually (i.e. without using CSS\n\t// transitions or animations). The animation, which can also scroll the block\n\t// editor, can sometimes cause the position of the Popover to get out of sync.\n\t// A MutationObserver is therefore used to make sure that changes to the\n\t// selectedElement's attribute (i.e. `transform`) can be tracked and used to\n\t// trigger the Popover to rerender.\n\tuseLayoutEffect( () => {\n\t\tif ( ! previousElement ) {\n\t\t\treturn;\n\t\t}\n\t\tconst observer = new window.MutationObserver( forcePopoverRecompute );\n\t\tobserver.observe( previousElement, { attributes: true } );\n\n\t\treturn () => {\n\t\t\tobserver.disconnect();\n\t\t};\n\t}, [ previousElement ] );\n\n\tuseLayoutEffect( () => {\n\t\tif ( ! nextElement ) {\n\t\t\treturn;\n\t\t}\n\t\tconst observer = new window.MutationObserver( forcePopoverRecompute );\n\t\tobserver.observe( nextElement, { attributes: true } );\n\n\t\treturn () => {\n\t\t\tobserver.disconnect();\n\t\t};\n\t}, [ nextElement ] );\n\n\tuseLayoutEffect( () => {\n\t\tif ( ! previousElement ) {\n\t\t\treturn;\n\t\t}\n\t\tpreviousElement.ownerDocument.defaultView.addEventListener(\n\t\t\t'resize',\n\t\t\tforcePopoverRecompute\n\t\t);\n\t\treturn () => {\n\t\t\tpreviousElement.ownerDocument.defaultView?.removeEventListener(\n\t\t\t\t'resize',\n\t\t\t\tforcePopoverRecompute\n\t\t\t);\n\t\t};\n\t}, [ previousElement ] );\n\n\t// If there's either a previous or a next element, show the inbetween popover.\n\t// Note that drag and drop uses the inbetween popover to show the drop indicator\n\t// before the first block and after the last block.\n\tif ( ( ! previousElement && ! nextElement ) || ! isVisible ) {\n\t\treturn null;\n\t}\n\n\t/* eslint-disable jsx-a11y/no-static-element-interactions, jsx-a11y/click-events-have-key-events */\n\t// While ideally it would be enough to capture the\n\t// bubbling focus event from the Inserter, due to the\n\t// characteristics of click focusing of `button`s in\n\t// Firefox and Safari, it is not reliable.\n\t//\n\t// See: https://developer.mozilla.org/en-US/docs/Web/HTML/Element/button#Clicking_and_focus\n\treturn (\n\t\t<Popover\n\t\t\tref={ popoverScrollRef }\n\t\t\tanimate={ false }\n\t\t\tanchor={ popoverAnchor }\n\t\t\tfocusOnMount={ false }\n\t\t\t// Render in the old slot if needed for backward compatibility,\n\t\t\t// otherwise render in place (not in the default popover slot).\n\t\t\t__unstableSlotName={ __unstablePopoverSlot }\n\t\t\tinline={ ! __unstablePopoverSlot }\n\t\t\t// Forces a remount of the popover when its position changes\n\t\t\t// This makes sure the popover doesn't animate from its previous position.\n\t\t\tkey={ nextClientId + '--' + rootClientId }\n\t\t\t{ ...props }\n\t\t\tclassName={ clsx(\n\t\t\t\t'block-editor-block-popover',\n\t\t\t\t'block-editor-block-popover__inbetween',\n\t\t\t\tprops.className\n\t\t\t) }\n\t\t\tresize={ false }\n\t\t\tflip={ false }\n\t\t\tplacement=\"overlay\"\n\t\t\tvariant=\"unstyled\"\n\t\t>\n\t\t\t<div className=\"block-editor-block-popover__inbetween-container\">\n\t\t\t\t{ children }\n\t\t\t</div>\n\t\t</Popover>\n\t);\n\t/* eslint-enable jsx-a11y/no-static-element-interactions, jsx-a11y/click-events-have-key-events */\n}\n\nexport default BlockPopoverInbetween;\n"],"mappings":";;;;;;;AAGA,IAAAA,KAAA,GAAAC,sBAAA,CAAAC,OAAA;AAKA,IAAAC,KAAA,GAAAD,OAAA;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IAAI;EACZ;;EAEA;EACA;EACA;EACA;EACA;EACA;EACA;EACA,oBACC,IAAAtB,WAAA,CAAA+D,GAAA,EAACpE,WAAA,CAAAqE,OAAO;IACPC,GAAG,EAAGd,gBAAkB;IACxBe,OAAO,EAAG,KAAO;IACjBC,MAAM,EAAGjC,aAAe;IACxBkC,YAAY,EAAG;IACf;IACA;IAAA;IACAC,kBAAkB,EAAG1D,qBAAuB;IAC5C2D,MAAM,EAAG,CAAE3D;IACX;IACA;IAAA;IAAA,GAEKI,KAAK;IACVwD,SAAS,EAAG,IAAAC,aAAI,EACf,4BAA4B,EAC5B,uCAAuC,EACvCzD,KAAK,CAACwD,SACP,CAAG;IACHE,MAAM,EAAG,KAAO;IAChBC,IAAI,EAAG,KAAO;IACdC,SAAS,EAAC,SAAS;IACnBC,OAAO,EAAC,UAAU;IAAAlE,QAAA,eAElB,IAAAV,WAAA,CAAA+D,GAAA;MAAKQ,SAAS,EAAC,iDAAiD;MAAA7D,QAAA,EAC7DA;IAAQ,CACN;EAAC,GAdAD,YAAY,GAAG,IAAI,GAAGY,YAepB,CAAC;EAEX;AACD;AAAC,IAAAwD,QAAA,GAAAxE,OAAA,CAAAyE,OAAA,GAEcvE,qBAAqB","ignoreList":[]}
|
|
@@ -34,8 +34,8 @@ function BlockPopover({
|
|
|
34
34
|
shift = true,
|
|
35
35
|
...props
|
|
36
36
|
}, ref) {
|
|
37
|
-
const selectedElement = (0, _useBlockRefs.
|
|
38
|
-
const lastSelectedElement = (0, _useBlockRefs.
|
|
37
|
+
const selectedElement = (0, _useBlockRefs.useBlockElement)(clientId);
|
|
38
|
+
const lastSelectedElement = (0, _useBlockRefs.useBlockElement)(bottomClientId !== null && bottomClientId !== void 0 ? bottomClientId : clientId);
|
|
39
39
|
const mergedRefs = (0, _compose.useMergeRefs)([ref, (0, _usePopoverScroll.default)(__unstableContentRef)]);
|
|
40
40
|
const [popoverDimensionsRecomputeCounter, forceRecomputePopoverDimensions] = (0, _element.useReducer)(
|
|
41
41
|
// Module is there to make sure that the counter doesn't overflow.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_clsx","_interopRequireDefault","require","_compose","_components","_element","_useBlockRefs","_usePopoverScroll","_jsxRuntime","MAX_POPOVER_RECOMPUTE_COUNTER","Number","MAX_SAFE_INTEGER","BlockPopover","clientId","bottomClientId","children","__unstablePopoverSlot","__unstableContentRef","shift","props","ref","selectedElement","useBlockElement","lastSelectedElement","mergedRefs","useMergeRefs","usePopoverScroll","popoverDimensionsRecomputeCounter","forceRecomputePopoverDimensions","useReducer","s","useLayoutEffect","observer","window","MutationObserver","observe","attributes","disconnect","popoverAnchor","useMemo","undefined","getBoundingClientRect","_lastSelectedBCR$left","_lastSelectedBCR$top","_lastSelectedBCR$righ","_lastSelectedBCR$bott","selectedBCR","lastSelectedBCR","left","Math","min","Infinity","top","right","max","bottom","width","height","DOMRect","contextElement","jsx","Popover","animate","focusOnMount","anchor","__unstableSlotName","inline","placement","resize","flip","className","clsx","variant","PrivateBlockPopover","exports","forwardRef","PublicBlockPopover","_default","default"],"sources":["@wordpress/block-editor/src/components/block-popover/index.js"],"sourcesContent":["/**\n * External dependencies\n */\nimport clsx from 'clsx';\n\n/**\n * WordPress dependencies\n */\nimport { useMergeRefs } from '@wordpress/compose';\nimport { Popover } from '@wordpress/components';\nimport {\n\tforwardRef,\n\tuseMemo,\n\tuseReducer,\n\tuseLayoutEffect,\n} from '@wordpress/element';\n\n/**\n * Internal dependencies\n */\nimport {
|
|
1
|
+
{"version":3,"names":["_clsx","_interopRequireDefault","require","_compose","_components","_element","_useBlockRefs","_usePopoverScroll","_jsxRuntime","MAX_POPOVER_RECOMPUTE_COUNTER","Number","MAX_SAFE_INTEGER","BlockPopover","clientId","bottomClientId","children","__unstablePopoverSlot","__unstableContentRef","shift","props","ref","selectedElement","useBlockElement","lastSelectedElement","mergedRefs","useMergeRefs","usePopoverScroll","popoverDimensionsRecomputeCounter","forceRecomputePopoverDimensions","useReducer","s","useLayoutEffect","observer","window","MutationObserver","observe","attributes","disconnect","popoverAnchor","useMemo","undefined","getBoundingClientRect","_lastSelectedBCR$left","_lastSelectedBCR$top","_lastSelectedBCR$righ","_lastSelectedBCR$bott","selectedBCR","lastSelectedBCR","left","Math","min","Infinity","top","right","max","bottom","width","height","DOMRect","contextElement","jsx","Popover","animate","focusOnMount","anchor","__unstableSlotName","inline","placement","resize","flip","className","clsx","variant","PrivateBlockPopover","exports","forwardRef","PublicBlockPopover","_default","default"],"sources":["@wordpress/block-editor/src/components/block-popover/index.js"],"sourcesContent":["/**\n * External dependencies\n */\nimport clsx from 'clsx';\n\n/**\n * WordPress dependencies\n */\nimport { useMergeRefs } from '@wordpress/compose';\nimport { Popover } from '@wordpress/components';\nimport {\n\tforwardRef,\n\tuseMemo,\n\tuseReducer,\n\tuseLayoutEffect,\n} from '@wordpress/element';\n\n/**\n * Internal dependencies\n */\nimport { useBlockElement } from '../block-list/use-block-props/use-block-refs';\nimport usePopoverScroll from './use-popover-scroll';\n\nconst MAX_POPOVER_RECOMPUTE_COUNTER = Number.MAX_SAFE_INTEGER;\n\nfunction BlockPopover(\n\t{\n\t\tclientId,\n\t\tbottomClientId,\n\t\tchildren,\n\t\t__unstablePopoverSlot,\n\t\t__unstableContentRef,\n\t\tshift = true,\n\t\t...props\n\t},\n\tref\n) {\n\tconst selectedElement = useBlockElement( clientId );\n\tconst lastSelectedElement = useBlockElement( bottomClientId ?? clientId );\n\tconst mergedRefs = useMergeRefs( [\n\t\tref,\n\t\tusePopoverScroll( __unstableContentRef ),\n\t] );\n\n\tconst [\n\t\tpopoverDimensionsRecomputeCounter,\n\t\tforceRecomputePopoverDimensions,\n\t] = useReducer(\n\t\t// Module is there to make sure that the counter doesn't overflow.\n\t\t( s ) => ( s + 1 ) % MAX_POPOVER_RECOMPUTE_COUNTER,\n\t\t0\n\t);\n\n\t// When blocks are moved up/down, they are animated to their new position by\n\t// updating the `transform` property manually (i.e. without using CSS\n\t// transitions or animations). The animation, which can also scroll the block\n\t// editor, can sometimes cause the position of the Popover to get out of sync.\n\t// A MutationObserver is therefore used to make sure that changes to the\n\t// selectedElement's attribute (i.e. `transform`) can be tracked and used to\n\t// trigger the Popover to rerender.\n\tuseLayoutEffect( () => {\n\t\tif ( ! selectedElement ) {\n\t\t\treturn;\n\t\t}\n\n\t\tconst observer = new window.MutationObserver(\n\t\t\tforceRecomputePopoverDimensions\n\t\t);\n\t\tobserver.observe( selectedElement, { attributes: true } );\n\n\t\treturn () => {\n\t\t\tobserver.disconnect();\n\t\t};\n\t}, [ selectedElement ] );\n\n\tconst popoverAnchor = useMemo( () => {\n\t\tif (\n\t\t\t// popoverDimensionsRecomputeCounter is by definition always equal or greater\n\t\t\t// than 0. This check is only there to satisfy the correctness of the\n\t\t\t// exhaustive-deps rule for the `useMemo` hook.\n\t\t\tpopoverDimensionsRecomputeCounter < 0 ||\n\t\t\t! selectedElement ||\n\t\t\t( bottomClientId && ! lastSelectedElement )\n\t\t) {\n\t\t\treturn undefined;\n\t\t}\n\n\t\treturn {\n\t\t\tgetBoundingClientRect() {\n\t\t\t\tconst selectedBCR = selectedElement.getBoundingClientRect();\n\t\t\t\tconst lastSelectedBCR =\n\t\t\t\t\tlastSelectedElement?.getBoundingClientRect();\n\n\t\t\t\t// Get the biggest rectangle that encompasses completely the currently\n\t\t\t\t// selected element and the last selected element:\n\t\t\t\t// - for top/left coordinates, use the smaller numbers\n\t\t\t\t// - for the bottom/right coordinates, use the largest numbers\n\t\t\t\tconst left = Math.min(\n\t\t\t\t\tselectedBCR.left,\n\t\t\t\t\tlastSelectedBCR?.left ?? Infinity\n\t\t\t\t);\n\t\t\t\tconst top = Math.min(\n\t\t\t\t\tselectedBCR.top,\n\t\t\t\t\tlastSelectedBCR?.top ?? Infinity\n\t\t\t\t);\n\t\t\t\tconst right = Math.max(\n\t\t\t\t\tselectedBCR.right,\n\t\t\t\t\tlastSelectedBCR.right ?? -Infinity\n\t\t\t\t);\n\t\t\t\tconst bottom = Math.max(\n\t\t\t\t\tselectedBCR.bottom,\n\t\t\t\t\tlastSelectedBCR.bottom ?? -Infinity\n\t\t\t\t);\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\tcontextElement: selectedElement,\n\t\t};\n\t}, [\n\t\tbottomClientId,\n\t\tlastSelectedElement,\n\t\tselectedElement,\n\t\tpopoverDimensionsRecomputeCounter,\n\t] );\n\n\tif ( ! selectedElement || ( bottomClientId && ! lastSelectedElement ) ) {\n\t\treturn null;\n\t}\n\n\treturn (\n\t\t<Popover\n\t\t\tref={ mergedRefs }\n\t\t\tanimate={ false }\n\t\t\tfocusOnMount={ false }\n\t\t\tanchor={ popoverAnchor }\n\t\t\t// Render in the old slot if needed for backward compatibility,\n\t\t\t// otherwise render in place (not in the default popover slot).\n\t\t\t__unstableSlotName={ __unstablePopoverSlot }\n\t\t\tinline={ ! __unstablePopoverSlot }\n\t\t\tplacement=\"top-start\"\n\t\t\tresize={ false }\n\t\t\tflip={ false }\n\t\t\tshift={ shift }\n\t\t\t{ ...props }\n\t\t\tclassName={ clsx( 'block-editor-block-popover', props.className ) }\n\t\t\tvariant=\"unstyled\"\n\t\t>\n\t\t\t{ children }\n\t\t</Popover>\n\t);\n}\n\nexport const PrivateBlockPopover = forwardRef( BlockPopover );\n\nconst PublicBlockPopover = (\n\t{ clientId, bottomClientId, children, ...props },\n\tref\n) => (\n\t<PrivateBlockPopover\n\t\t{ ...props }\n\t\tbottomClientId={ bottomClientId }\n\t\tclientId={ clientId }\n\t\t__unstableContentRef={ undefined }\n\t\t__unstablePopoverSlot={ undefined }\n\t\tref={ ref }\n\t>\n\t\t{ children }\n\t</PrivateBlockPopover>\n);\n\n/**\n * @see https://github.com/WordPress/gutenberg/blob/HEAD/packages/block-editor/src/components/block-popover/README.md\n */\nexport default forwardRef( PublicBlockPopover );\n"],"mappings":";;;;;;;AAGA,IAAAA,KAA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AAqB,EAAGwB,SAAW;EACnCpB,GAAG,EAAGA,GAAK;EAAAL,QAAA,EAETA;AAAQ,CACU,CACrB;;AAED;AACA;AACA;AAFA,IAAA8D,QAAA,GAAAH,OAAA,CAAAI,OAAA,GAGe,IAAAH,mBAAU,EAAEC,kBAAmB,CAAC","ignoreList":[]}
|
|
@@ -99,7 +99,7 @@ var _jsxRuntime = require("react/jsx-runtime");
|
|
|
99
99
|
(0, _a11y.speak)(label);
|
|
100
100
|
}
|
|
101
101
|
}, [label, editorMode]);
|
|
102
|
-
const blockElement = (0, _useBlockRefs.
|
|
102
|
+
const blockElement = (0, _useBlockRefs.useBlockElement)(clientId);
|
|
103
103
|
const {
|
|
104
104
|
hasBlockMovingClientId,
|
|
105
105
|
getBlockIndex,
|
|
@@ -224,7 +224,6 @@ var _jsxRuntime = require("react/jsx-runtime");
|
|
|
224
224
|
children: draggableProps => /*#__PURE__*/(0, _jsxRuntime.jsx)(_components.Button, {
|
|
225
225
|
icon: _icons.dragHandle,
|
|
226
226
|
className: "block-selection-button_drag-handle",
|
|
227
|
-
"aria-hidden": "true",
|
|
228
227
|
label: dragHandleLabel
|
|
229
228
|
// Should not be able to tab to drag handle as this
|
|
230
229
|
// button can only be used with a pointer device.
|