@wordpress/block-editor 10.2.0 → 10.4.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 +18 -0
- package/README.md +41 -0
- package/build/components/alignment-control/ui.js +1 -1
- package/build/components/alignment-control/ui.js.map +1 -1
- package/build/components/block-alignment-control/constants.js +1 -1
- package/build/components/block-alignment-control/constants.js.map +1 -1
- package/build/components/block-alignment-matrix-control/index.js +1 -1
- package/build/components/block-alignment-matrix-control/index.js.map +1 -1
- package/build/components/block-compare/index.js +1 -3
- package/build/components/block-compare/index.js.map +1 -1
- package/build/components/block-draggable/draggable-chip.js +4 -2
- package/build/components/block-draggable/draggable-chip.js.map +1 -1
- package/build/components/block-edit/index.js +4 -2
- package/build/components/block-edit/index.js.map +1 -1
- package/build/components/block-inspector/index.js +4 -4
- package/build/components/block-inspector/index.js.map +1 -1
- package/build/components/block-list/block-list-compact.native.js +1 -0
- package/build/components/block-list/block-list-compact.native.js.map +1 -1
- package/build/components/block-list/block.js +75 -15
- package/build/components/block-list/block.js.map +1 -1
- package/build/components/block-list/block.native.js +79 -12
- package/build/components/block-list/block.native.js.map +1 -1
- package/build/components/block-list/use-in-between-inserter.js +7 -23
- package/build/components/block-list/use-in-between-inserter.js.map +1 -1
- package/build/components/block-lock/modal.js +9 -6
- package/build/components/block-lock/modal.js.map +1 -1
- package/build/components/block-parent-selector/index.js +3 -3
- package/build/components/block-parent-selector/index.js.map +1 -1
- package/build/components/block-patterns-list/index.js +5 -4
- package/build/components/block-patterns-list/index.js.map +1 -1
- package/build/components/block-popover/drop-zone.js +85 -0
- package/build/components/block-popover/drop-zone.js.map +1 -0
- package/build/components/block-popover/inbetween.js +2 -1
- package/build/components/block-popover/inbetween.js.map +1 -1
- package/build/components/block-popover/index.js +4 -2
- package/build/components/block-popover/index.js.map +1 -1
- package/build/components/block-preview/auto.js +2 -2
- package/build/components/block-preview/auto.js.map +1 -1
- package/build/components/block-preview/index.js +8 -13
- package/build/components/block-preview/index.js.map +1 -1
- package/build/components/block-preview/live.js +3 -7
- package/build/components/block-preview/live.js.map +1 -1
- package/build/components/block-selection-clearer/index.js +9 -1
- package/build/components/block-selection-clearer/index.js.map +1 -1
- package/build/components/block-settings-menu/block-settings-dropdown.js +19 -19
- package/build/components/block-settings-menu/block-settings-dropdown.js.map +1 -1
- package/build/components/block-styles/index.js +18 -42
- package/build/components/block-styles/index.js.map +1 -1
- package/build/components/block-switcher/index.js +2 -8
- package/build/components/block-switcher/index.js.map +1 -1
- package/build/components/block-switcher/preview-block-popover.js +1 -1
- package/build/components/block-switcher/preview-block-popover.js.map +1 -1
- package/build/components/block-toolbar/index.js +4 -4
- package/build/components/block-toolbar/index.js.map +1 -1
- package/build/components/block-tools/back-compat.js +2 -1
- package/build/components/block-tools/back-compat.js.map +1 -1
- package/build/components/block-tools/insertion-point.js +56 -16
- package/build/components/block-tools/insertion-point.js.map +1 -1
- package/build/components/block-tools/selected-block-popover.js +15 -3
- package/build/components/block-tools/selected-block-popover.js.map +1 -1
- package/build/components/block-vertical-alignment-control/ui.js +1 -1
- package/build/components/block-vertical-alignment-control/ui.js.map +1 -1
- package/build/components/border-radius-control/all-input-control.js +2 -1
- package/build/components/border-radius-control/all-input-control.js.map +1 -1
- package/build/components/border-radius-control/index.js +2 -1
- package/build/components/border-radius-control/index.js.map +1 -1
- package/build/components/border-radius-control/input-controls.js +2 -1
- package/build/components/border-radius-control/input-controls.js.map +1 -1
- package/build/components/colors-gradients/control.js +1 -1
- package/build/components/colors-gradients/control.js.map +1 -1
- package/build/components/colors-gradients/panel-color-gradient-settings.js +2 -2
- package/build/components/colors-gradients/panel-color-gradient-settings.js.map +1 -1
- package/build/components/duotone-control/index.js +1 -1
- package/build/components/duotone-control/index.js.map +1 -1
- package/build/components/font-sizes/fluid-utils.js +256 -0
- package/build/components/font-sizes/fluid-utils.js.map +1 -0
- package/build/components/font-sizes/index.js +8 -0
- package/build/components/font-sizes/index.js.map +1 -1
- package/build/components/font-sizes/with-font-sizes.js +1 -1
- package/build/components/font-sizes/with-font-sizes.js.map +1 -1
- package/build/components/iframe/index.js +1 -1
- package/build/components/iframe/index.js.map +1 -1
- package/build/components/image-editor/constants.js +1 -1
- package/build/components/image-editor/constants.js.map +1 -1
- package/build/components/index.js +0 -9
- package/build/components/index.js.map +1 -1
- package/build/components/inner-blocks/index.js +6 -2
- package/build/components/inner-blocks/index.js.map +1 -1
- package/build/components/inner-blocks/use-inner-block-template-sync.js +3 -2
- package/build/components/inner-blocks/use-inner-block-template-sync.js.map +1 -1
- package/build/components/inserter/block-patterns-tab.js +151 -78
- package/build/components/inserter/block-patterns-tab.js.map +1 -1
- package/build/components/inserter/hooks/use-insertion-point.js +2 -7
- package/build/components/inserter/hooks/use-insertion-point.js.map +1 -1
- package/build/components/inserter/menu.js +14 -3
- package/build/components/inserter/menu.js.map +1 -1
- package/build/components/inserter/search-items.js +23 -2
- package/build/components/inserter/search-items.js.map +1 -1
- package/build/components/inserter-draggable-blocks/index.js +4 -2
- package/build/components/inserter-draggable-blocks/index.js.map +1 -1
- package/build/components/line-height-control/index.js +2 -1
- package/build/components/line-height-control/index.js.map +1 -1
- package/build/components/list-view/drop-indicator.js +2 -1
- package/build/components/list-view/drop-indicator.js.map +1 -1
- package/build/components/list-view/use-list-view-drop-zone.js +1 -14
- package/build/components/list-view/use-list-view-drop-zone.js.map +1 -1
- package/build/components/media-replace-flow/index.js +1 -1
- package/build/components/media-replace-flow/index.js.map +1 -1
- package/build/components/preview-options/index.js +2 -3
- package/build/components/preview-options/index.js.map +1 -1
- package/build/components/rich-text/format-toolbar/index.js +1 -1
- package/build/components/rich-text/format-toolbar/index.js.map +1 -1
- package/build/components/rich-text/format-toolbar-container.js +1 -1
- package/build/components/rich-text/format-toolbar-container.js.map +1 -1
- package/build/components/rich-text/use-paste-handler.js +1 -1
- package/build/components/rich-text/use-paste-handler.js.map +1 -1
- package/build/components/spacing-sizes-control/all-input-control.js +6 -2
- package/build/components/spacing-sizes-control/all-input-control.js.map +1 -1
- package/build/components/spacing-sizes-control/axial-input-controls.js +6 -2
- package/build/components/spacing-sizes-control/axial-input-controls.js.map +1 -1
- package/build/components/spacing-sizes-control/index.js +6 -2
- package/build/components/spacing-sizes-control/index.js.map +1 -1
- package/build/components/spacing-sizes-control/input-controls.js +6 -2
- package/build/components/spacing-sizes-control/input-controls.js.map +1 -1
- package/build/components/spacing-sizes-control/spacing-input-control.js +45 -8
- package/build/components/spacing-sizes-control/spacing-input-control.js.map +1 -1
- package/build/components/url-input/index.js +1 -1
- package/build/components/url-input/index.js.map +1 -1
- package/build/components/use-block-drop-zone/index.js +98 -57
- package/build/components/use-block-drop-zone/index.js.map +1 -1
- package/build/components/use-on-block-drop/index.js +12 -12
- package/build/components/use-on-block-drop/index.js.map +1 -1
- package/build/components/use-on-block-drop/types.js +6 -0
- package/build/components/use-on-block-drop/types.js.map +1 -0
- package/build/hooks/align.js +1 -3
- package/build/hooks/align.js.map +1 -1
- package/build/hooks/align.native.js +1 -7
- package/build/hooks/align.native.js.map +1 -1
- package/build/hooks/border.js +1 -0
- package/build/hooks/border.js.map +1 -1
- package/build/hooks/dimensions.js +32 -4
- package/build/hooks/dimensions.js.map +1 -1
- package/build/hooks/font-size.js +61 -0
- package/build/hooks/font-size.js.map +1 -1
- package/build/hooks/layout.js +4 -3
- package/build/hooks/layout.js.map +1 -1
- package/build/hooks/margin.js +24 -17
- package/build/hooks/margin.js.map +1 -1
- package/build/hooks/padding.js +20 -12
- package/build/hooks/padding.js.map +1 -1
- package/build/hooks/style.js +126 -4
- package/build/hooks/style.js.map +1 -1
- package/build/hooks/use-typography-props.js +17 -3
- package/build/hooks/use-typography-props.js.map +1 -1
- package/build/hooks/utils.js +8 -7
- package/build/hooks/utils.js.map +1 -1
- package/build/layouts/constrained.js +0 -1
- package/build/layouts/constrained.js.map +1 -1
- package/build/layouts/flex.js +1 -1
- package/build/layouts/flex.js.map +1 -1
- package/build/store/actions.js +63 -45
- package/build/store/actions.js.map +1 -1
- package/build/store/array.js +1 -7
- package/build/store/array.js.map +1 -1
- package/build/store/defaults.js +3 -0
- package/build/store/defaults.js.map +1 -1
- package/build/store/reducer.js +31 -15
- package/build/store/reducer.js.map +1 -1
- package/build/store/selectors.js +46 -29
- package/build/store/selectors.js.map +1 -1
- package/build/utils/math.js +14 -0
- package/build/utils/math.js.map +1 -1
- package/build/utils/pre-parse-patterns.js +19 -2
- package/build/utils/pre-parse-patterns.js.map +1 -1
- package/build-module/components/alignment-control/ui.js +1 -1
- package/build-module/components/alignment-control/ui.js.map +1 -1
- package/build-module/components/block-alignment-control/constants.js +1 -1
- package/build-module/components/block-alignment-control/constants.js.map +1 -1
- package/build-module/components/block-alignment-matrix-control/index.js +1 -1
- package/build-module/components/block-alignment-matrix-control/index.js.map +1 -1
- package/build-module/components/block-compare/index.js +2 -3
- package/build-module/components/block-compare/index.js.map +1 -1
- package/build-module/components/block-draggable/draggable-chip.js +7 -3
- package/build-module/components/block-draggable/draggable-chip.js.map +1 -1
- package/build-module/components/block-edit/index.js +4 -2
- package/build-module/components/block-edit/index.js.map +1 -1
- package/build-module/components/block-inspector/index.js +4 -4
- package/build-module/components/block-inspector/index.js.map +1 -1
- package/build-module/components/block-list/block-list-compact.native.js +1 -0
- package/build-module/components/block-list/block-list-compact.native.js.map +1 -1
- package/build-module/components/block-list/block.js +75 -15
- package/build-module/components/block-list/block.js.map +1 -1
- package/build-module/components/block-list/block.native.js +80 -13
- package/build-module/components/block-list/block.native.js.map +1 -1
- package/build-module/components/block-list/use-in-between-inserter.js +8 -24
- package/build-module/components/block-list/use-in-between-inserter.js.map +1 -1
- package/build-module/components/block-lock/modal.js +10 -8
- package/build-module/components/block-lock/modal.js.map +1 -1
- package/build-module/components/block-parent-selector/index.js +3 -3
- package/build-module/components/block-parent-selector/index.js.map +1 -1
- package/build-module/components/block-patterns-list/index.js +5 -4
- package/build-module/components/block-patterns-list/index.js.map +1 -1
- package/build-module/components/block-popover/drop-zone.js +70 -0
- package/build-module/components/block-popover/drop-zone.js.map +1 -0
- package/build-module/components/block-popover/inbetween.js +2 -1
- package/build-module/components/block-popover/inbetween.js.map +1 -1
- package/build-module/components/block-popover/index.js +4 -2
- package/build-module/components/block-popover/index.js.map +1 -1
- package/build-module/components/block-preview/auto.js +1 -1
- package/build-module/components/block-preview/auto.js.map +1 -1
- package/build-module/components/block-preview/index.js +8 -12
- package/build-module/components/block-preview/index.js.map +1 -1
- package/build-module/components/block-preview/live.js +3 -6
- package/build-module/components/block-preview/live.js.map +1 -1
- package/build-module/components/block-selection-clearer/index.js +9 -1
- package/build-module/components/block-selection-clearer/index.js.map +1 -1
- package/build-module/components/block-settings-menu/block-settings-dropdown.js +20 -19
- package/build-module/components/block-settings-menu/block-settings-dropdown.js.map +1 -1
- package/build-module/components/block-styles/index.js +19 -44
- package/build-module/components/block-styles/index.js.map +1 -1
- package/build-module/components/block-switcher/index.js +2 -7
- package/build-module/components/block-switcher/index.js.map +1 -1
- package/build-module/components/block-switcher/preview-block-popover.js +1 -1
- package/build-module/components/block-switcher/preview-block-popover.js.map +1 -1
- package/build-module/components/block-toolbar/index.js +4 -4
- package/build-module/components/block-toolbar/index.js.map +1 -1
- package/build-module/components/block-tools/back-compat.js +2 -1
- package/build-module/components/block-tools/back-compat.js.map +1 -1
- package/build-module/components/block-tools/insertion-point.js +54 -16
- package/build-module/components/block-tools/insertion-point.js.map +1 -1
- package/build-module/components/block-tools/selected-block-popover.js +15 -3
- package/build-module/components/block-tools/selected-block-popover.js.map +1 -1
- package/build-module/components/block-vertical-alignment-control/ui.js +1 -1
- package/build-module/components/block-vertical-alignment-control/ui.js.map +1 -1
- package/build-module/components/border-radius-control/all-input-control.js +2 -1
- package/build-module/components/border-radius-control/all-input-control.js.map +1 -1
- package/build-module/components/border-radius-control/index.js +2 -1
- package/build-module/components/border-radius-control/index.js.map +1 -1
- package/build-module/components/border-radius-control/input-controls.js +2 -1
- package/build-module/components/border-radius-control/input-controls.js.map +1 -1
- package/build-module/components/colors-gradients/control.js +2 -2
- package/build-module/components/colors-gradients/control.js.map +1 -1
- package/build-module/components/colors-gradients/panel-color-gradient-settings.js +3 -3
- package/build-module/components/colors-gradients/panel-color-gradient-settings.js.map +1 -1
- package/build-module/components/duotone-control/index.js +1 -1
- package/build-module/components/duotone-control/index.js.map +1 -1
- package/build-module/components/font-sizes/fluid-utils.js +245 -0
- package/build-module/components/font-sizes/fluid-utils.js.map +1 -0
- package/build-module/components/font-sizes/index.js +1 -0
- package/build-module/components/font-sizes/index.js.map +1 -1
- package/build-module/components/font-sizes/with-font-sizes.js +2 -2
- package/build-module/components/font-sizes/with-font-sizes.js.map +1 -1
- package/build-module/components/iframe/index.js +1 -1
- package/build-module/components/iframe/index.js.map +1 -1
- package/build-module/components/image-editor/constants.js +1 -1
- package/build-module/components/image-editor/constants.js.map +1 -1
- package/build-module/components/index.js +0 -1
- package/build-module/components/index.js.map +1 -1
- package/build-module/components/inner-blocks/index.js +6 -2
- package/build-module/components/inner-blocks/index.js.map +1 -1
- package/build-module/components/inner-blocks/use-inner-block-template-sync.js +3 -2
- package/build-module/components/inner-blocks/use-inner-block-template-sync.js.map +1 -1
- package/build-module/components/inserter/block-patterns-tab.js +148 -81
- package/build-module/components/inserter/block-patterns-tab.js.map +1 -1
- package/build-module/components/inserter/hooks/use-insertion-point.js +2 -6
- package/build-module/components/inserter/hooks/use-insertion-point.js.map +1 -1
- package/build-module/components/inserter/menu.js +10 -3
- package/build-module/components/inserter/menu.js.map +1 -1
- package/build-module/components/inserter/search-items.js +23 -3
- package/build-module/components/inserter/search-items.js.map +1 -1
- package/build-module/components/inserter-draggable-blocks/index.js +4 -2
- package/build-module/components/inserter-draggable-blocks/index.js.map +1 -1
- package/build-module/components/line-height-control/index.js +2 -1
- package/build-module/components/line-height-control/index.js.map +1 -1
- package/build-module/components/list-view/drop-indicator.js +2 -1
- package/build-module/components/list-view/drop-indicator.js.map +1 -1
- package/build-module/components/list-view/use-list-view-drop-zone.js +1 -14
- package/build-module/components/list-view/use-list-view-drop-zone.js.map +1 -1
- package/build-module/components/media-replace-flow/index.js +1 -1
- package/build-module/components/media-replace-flow/index.js.map +1 -1
- package/build-module/components/preview-options/index.js +2 -3
- package/build-module/components/preview-options/index.js.map +1 -1
- package/build-module/components/rich-text/format-toolbar/index.js +1 -1
- package/build-module/components/rich-text/format-toolbar/index.js.map +1 -1
- package/build-module/components/rich-text/format-toolbar-container.js +1 -1
- package/build-module/components/rich-text/format-toolbar-container.js.map +1 -1
- package/build-module/components/rich-text/use-paste-handler.js +1 -1
- package/build-module/components/rich-text/use-paste-handler.js.map +1 -1
- package/build-module/components/spacing-sizes-control/all-input-control.js +6 -2
- package/build-module/components/spacing-sizes-control/all-input-control.js.map +1 -1
- package/build-module/components/spacing-sizes-control/axial-input-controls.js +6 -2
- package/build-module/components/spacing-sizes-control/axial-input-controls.js.map +1 -1
- package/build-module/components/spacing-sizes-control/index.js +6 -2
- package/build-module/components/spacing-sizes-control/index.js.map +1 -1
- package/build-module/components/spacing-sizes-control/input-controls.js +6 -2
- package/build-module/components/spacing-sizes-control/input-controls.js.map +1 -1
- package/build-module/components/spacing-sizes-control/spacing-input-control.js +44 -8
- package/build-module/components/spacing-sizes-control/spacing-input-control.js.map +1 -1
- package/build-module/components/url-input/index.js +1 -1
- package/build-module/components/url-input/index.js.map +1 -1
- package/build-module/components/use-block-drop-zone/index.js +98 -58
- package/build-module/components/use-block-drop-zone/index.js.map +1 -1
- package/build-module/components/use-on-block-drop/index.js +12 -12
- package/build-module/components/use-on-block-drop/index.js.map +1 -1
- package/build-module/components/use-on-block-drop/types.js +2 -0
- package/build-module/components/use-on-block-drop/types.js.map +1 -0
- package/build-module/hooks/align.js +1 -2
- package/build-module/hooks/align.js.map +1 -1
- package/build-module/hooks/align.native.js +1 -6
- package/build-module/hooks/align.native.js.map +1 -1
- package/build-module/hooks/border.js +1 -0
- package/build-module/hooks/border.js.map +1 -1
- package/build-module/hooks/dimensions.js +32 -4
- package/build-module/hooks/dimensions.js.map +1 -1
- package/build-module/hooks/font-size.js +60 -1
- package/build-module/hooks/font-size.js.map +1 -1
- package/build-module/hooks/layout.js +5 -4
- package/build-module/hooks/layout.js.map +1 -1
- package/build-module/hooks/margin.js +25 -18
- package/build-module/hooks/margin.js.map +1 -1
- package/build-module/hooks/padding.js +21 -13
- package/build-module/hooks/padding.js.map +1 -1
- package/build-module/hooks/style.js +124 -3
- package/build-module/hooks/style.js.map +1 -1
- package/build-module/hooks/use-typography-props.js +17 -4
- package/build-module/hooks/use-typography-props.js.map +1 -1
- package/build-module/hooks/utils.js +8 -8
- package/build-module/hooks/utils.js.map +1 -1
- package/build-module/layouts/constrained.js +0 -1
- package/build-module/layouts/constrained.js.map +1 -1
- package/build-module/layouts/flex.js +1 -1
- package/build-module/layouts/flex.js.map +1 -1
- package/build-module/store/actions.js +59 -42
- package/build-module/store/actions.js.map +1 -1
- package/build-module/store/array.js +1 -6
- package/build-module/store/array.js.map +1 -1
- package/build-module/store/defaults.js +3 -0
- package/build-module/store/defaults.js.map +1 -1
- package/build-module/store/reducer.js +32 -16
- package/build-module/store/reducer.js.map +1 -1
- package/build-module/store/selectors.js +47 -30
- package/build-module/store/selectors.js.map +1 -1
- package/build-module/utils/math.js +12 -0
- package/build-module/utils/math.js.map +1 -1
- package/build-module/utils/pre-parse-patterns.js +19 -2
- package/build-module/utils/pre-parse-patterns.js.map +1 -1
- package/build-style/style-rtl.css +292 -206
- package/build-style/style.css +288 -202
- package/package.json +29 -28
- package/src/components/alignment-control/ui.js +1 -1
- package/src/components/block-alignment-control/constants.js +1 -1
- package/src/components/block-alignment-matrix-control/index.js +1 -1
- package/src/components/block-breadcrumb/test/__snapshots__/index.js.snap +13 -11
- package/src/components/block-breadcrumb/test/index.js +2 -2
- package/src/components/block-compare/index.js +3 -2
- package/src/components/block-draggable/draggable-chip.js +4 -2
- package/src/components/block-edit/index.js +2 -1
- package/src/components/block-inspector/index.js +8 -7
- package/src/components/block-list/block-list-compact.native.js +1 -0
- package/src/components/block-list/block.js +113 -7
- package/src/components/block-list/block.native.js +123 -9
- package/src/components/block-list/style.scss +93 -126
- package/src/components/block-list/use-in-between-inserter.js +8 -19
- package/src/components/block-lock/modal.js +12 -7
- package/src/components/block-mover/stories/index.js +1 -1
- package/src/components/block-mover/style.scss +35 -1
- package/src/components/block-parent-selector/index.js +3 -3
- package/src/components/block-patterns-list/index.js +9 -5
- package/src/components/block-patterns-list/style.scss +7 -3
- package/src/components/block-popover/README.md +8 -0
- package/src/components/block-popover/drop-zone.js +63 -0
- package/src/components/block-popover/inbetween.js +1 -0
- package/src/components/block-popover/index.js +3 -1
- package/src/components/block-popover/style.scss +17 -5
- package/src/components/block-preview/auto.js +1 -1
- package/src/components/block-preview/index.js +15 -11
- package/src/components/block-preview/live.js +2 -7
- package/src/components/block-preview/test/index.js +1 -7
- package/src/components/block-selection-clearer/index.js +7 -2
- package/src/components/block-selection-clearer/test/index.js +118 -0
- package/src/components/block-settings-menu/block-settings-dropdown.js +29 -18
- package/src/components/block-settings-menu/test/block-mode-toggle.js +17 -17
- package/src/components/block-styles/index.js +26 -49
- package/src/components/block-switcher/index.js +2 -7
- package/src/components/block-switcher/preview-block-popover.js +1 -1
- package/src/components/block-switcher/test/index.js +2 -2
- package/src/components/block-toolbar/index.js +4 -6
- package/src/components/block-toolbar/style.scss +38 -14
- package/src/components/block-tools/back-compat.js +1 -0
- package/src/components/block-tools/insertion-point.js +49 -15
- package/src/components/block-tools/selected-block-popover.js +14 -1
- package/src/components/block-variation-picker/README.md +1 -1
- package/src/components/block-vertical-alignment-control/ui.js +1 -1
- package/src/components/border-radius-control/all-input-control.js +1 -0
- package/src/components/border-radius-control/index.js +1 -0
- package/src/components/border-radius-control/input-controls.js +1 -0
- package/src/components/border-radius-control/style.scss +15 -24
- package/src/components/button-block-appender/style.scss +4 -2
- package/src/components/color-palette/test/__snapshots__/control.js.snap +86 -104
- package/src/components/color-palette/test/control.js +11 -15
- package/src/components/colors-gradients/control.js +2 -2
- package/src/components/colors-gradients/panel-color-gradient-settings.js +3 -4
- package/src/components/colors-gradients/test/control.js +49 -77
- package/src/components/duotone-control/index.js +1 -1
- package/src/components/font-sizes/fluid-utils.js +296 -0
- package/src/components/font-sizes/index.js +1 -0
- package/src/components/font-sizes/test/fluid-utils.js +168 -0
- package/src/components/font-sizes/with-font-sizes.js +2 -3
- package/src/components/iframe/index.js +1 -1
- package/src/components/image-editor/constants.js +1 -1
- package/src/components/image-size-control/test/index.js +47 -60
- package/src/components/index.js +0 -1
- package/src/components/inner-blocks/index.js +5 -1
- package/src/components/inner-blocks/test/index.js +4 -0
- package/src/components/inner-blocks/use-inner-block-template-sync.js +3 -2
- package/src/components/inserter/block-patterns-tab.js +232 -98
- package/src/components/inserter/hooks/use-insertion-point.js +3 -11
- package/src/components/inserter/menu.js +15 -2
- package/src/components/inserter/search-items.js +23 -3
- package/src/components/inserter/style.scss +94 -9
- package/src/components/inserter/test/reusable-blocks-tab.js +6 -6
- package/src/components/inserter/test/search-items.js +6 -0
- package/src/components/inserter-draggable-blocks/index.js +12 -2
- package/src/components/inserter-list-item/style.scss +22 -1
- package/src/components/letter-spacing-control/README.md +55 -0
- package/src/components/line-height-control/index.js +1 -0
- package/src/components/link-control/README.md +3 -3
- package/src/components/link-control/test/index.js +1 -1
- package/src/components/list-view/drop-indicator.js +1 -0
- package/src/components/list-view/style.scss +1 -36
- package/src/components/list-view/use-list-view-drop-zone.js +4 -18
- package/src/components/media-replace-flow/index.js +1 -1
- package/src/components/media-replace-flow/test/index.js +69 -51
- package/src/components/panel-color-settings/test/index.js +4 -4
- package/src/components/preview-options/index.js +2 -2
- package/src/components/preview-options/style.scss +1 -1
- package/src/components/provider/test/use-block-sync.js +131 -165
- package/src/components/responsive-block-control/test/index.js +4 -4
- package/src/components/rich-text/format-toolbar/index.js +1 -1
- package/src/components/rich-text/format-toolbar-container.js +1 -1
- package/src/components/rich-text/use-paste-handler.js +1 -1
- package/src/components/spacing-sizes-control/all-input-control.js +4 -0
- package/src/components/spacing-sizes-control/axial-input-controls.js +4 -0
- package/src/components/spacing-sizes-control/index.js +4 -0
- package/src/components/spacing-sizes-control/input-controls.js +4 -0
- package/src/components/spacing-sizes-control/spacing-input-control.js +26 -3
- package/src/components/spacing-sizes-control/style.scss +27 -19
- package/src/components/url-input/index.js +1 -1
- package/src/components/use-block-drop-zone/index.js +136 -79
- package/src/components/use-block-drop-zone/test/index.js +333 -81
- package/src/components/use-on-block-drop/index.js +11 -12
- package/src/components/use-on-block-drop/types.ts +1 -0
- package/src/hooks/align.js +3 -2
- package/src/hooks/align.native.js +5 -8
- package/src/hooks/border.js +1 -0
- package/src/hooks/dimensions.js +32 -5
- package/src/hooks/font-size.js +76 -0
- package/src/hooks/layout.js +7 -9
- package/src/hooks/margin.js +20 -14
- package/src/hooks/padding.js +20 -16
- package/src/hooks/style.js +122 -3
- package/src/hooks/test/align.js +96 -72
- package/src/hooks/test/style.js +206 -1
- package/src/hooks/test/use-typography-props.js +22 -0
- package/src/hooks/use-typography-props.js +18 -3
- package/src/hooks/utils.js +10 -7
- package/src/layouts/constrained.js +0 -1
- package/src/layouts/flex.js +1 -1
- package/src/store/actions.js +24 -12
- package/src/store/array.js +1 -6
- package/src/store/defaults.js +3 -0
- package/src/store/reducer.js +31 -24
- package/src/store/selectors.js +28 -21
- package/src/store/test/actions.js +0 -9
- package/src/store/test/selectors.js +1 -1
- package/src/utils/math.js +17 -0
- package/src/utils/pre-parse-patterns.js +12 -7
- package/build/components/inserter/pattern-panel.js +0 -87
- package/build/components/inserter/pattern-panel.js.map +0 -1
- package/build-module/components/inserter/pattern-panel.js +0 -74
- package/build-module/components/inserter/pattern-panel.js.map +0 -1
- package/src/components/inserter/pattern-panel.js +0 -93
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* WordPress dependencies
|
|
3
3
|
*/
|
|
4
|
-
import { useRefEffect
|
|
4
|
+
import { useRefEffect } from '@wordpress/compose';
|
|
5
5
|
import { useSelect, useDispatch } from '@wordpress/data';
|
|
6
6
|
import { useContext } from '@wordpress/element';
|
|
7
7
|
/**
|
|
@@ -12,7 +12,7 @@ import { store as blockEditorStore } from '../../store';
|
|
|
12
12
|
import { InsertionPointOpenRef } from '../block-tools/insertion-point';
|
|
13
13
|
export function useInBetweenInserter() {
|
|
14
14
|
const openRef = useContext(InsertionPointOpenRef);
|
|
15
|
-
const isInBetweenInserterDisabled = useSelect(select => select(blockEditorStore).getSettings().
|
|
15
|
+
const isInBetweenInserterDisabled = useSelect(select => select(blockEditorStore).getSettings().isDistractionFree || select(blockEditorStore).__unstableGetEditorMode() === 'zoom-out', []);
|
|
16
16
|
const {
|
|
17
17
|
getBlockListSettings,
|
|
18
18
|
getBlockRootClientId,
|
|
@@ -27,9 +27,6 @@ export function useInBetweenInserter() {
|
|
|
27
27
|
showInsertionPoint,
|
|
28
28
|
hideInsertionPoint
|
|
29
29
|
} = useDispatch(blockEditorStore);
|
|
30
|
-
const delayedShowInsertionPoint = useDebounce(showInsertionPoint, 500, {
|
|
31
|
-
trailing: true
|
|
32
|
-
});
|
|
33
30
|
return useRefEffect(node => {
|
|
34
31
|
if (isInBetweenInserterDisabled) {
|
|
35
32
|
return;
|
|
@@ -47,12 +44,7 @@ export function useInBetweenInserter() {
|
|
|
47
44
|
}
|
|
48
45
|
|
|
49
46
|
if (!event.target.classList.contains('block-editor-block-list__layout')) {
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
if (isBlockInsertionPointVisible()) {
|
|
53
|
-
hideInsertionPoint();
|
|
54
|
-
}
|
|
55
|
-
|
|
47
|
+
hideInsertionPoint();
|
|
56
48
|
return;
|
|
57
49
|
}
|
|
58
50
|
|
|
@@ -78,6 +70,7 @@ export function useInBetweenInserter() {
|
|
|
78
70
|
});
|
|
79
71
|
|
|
80
72
|
if (!element) {
|
|
73
|
+
hideInsertionPoint();
|
|
81
74
|
return;
|
|
82
75
|
} // The block may be in an alignment wrapper, so check the first direct
|
|
83
76
|
// child if the element has no ID.
|
|
@@ -87,6 +80,7 @@ export function useInBetweenInserter() {
|
|
|
87
80
|
element = element.firstElementChild;
|
|
88
81
|
|
|
89
82
|
if (!element) {
|
|
83
|
+
hideInsertionPoint();
|
|
90
84
|
return;
|
|
91
85
|
}
|
|
92
86
|
} // Don't show the insertion point if a parent block has an "overlay"
|
|
@@ -108,12 +102,7 @@ export function useInBetweenInserter() {
|
|
|
108
102
|
const elementRect = element.getBoundingClientRect();
|
|
109
103
|
|
|
110
104
|
if (orientation === 'horizontal' && (event.clientY > elementRect.bottom || event.clientY < elementRect.top) || orientation === 'vertical' && (event.clientX > elementRect.right || event.clientX < elementRect.left)) {
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
if (isBlockInsertionPointVisible()) {
|
|
114
|
-
hideInsertionPoint();
|
|
115
|
-
}
|
|
116
|
-
|
|
105
|
+
hideInsertionPoint();
|
|
117
106
|
return;
|
|
118
107
|
}
|
|
119
108
|
|
|
@@ -121,16 +110,11 @@ export function useInBetweenInserter() {
|
|
|
121
110
|
// the list (preserves the original behaviour).
|
|
122
111
|
|
|
123
112
|
if (index === 0) {
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
if (isBlockInsertionPointVisible()) {
|
|
127
|
-
hideInsertionPoint();
|
|
128
|
-
}
|
|
129
|
-
|
|
113
|
+
hideInsertionPoint();
|
|
130
114
|
return;
|
|
131
115
|
}
|
|
132
116
|
|
|
133
|
-
|
|
117
|
+
showInsertionPoint(rootClientId, index, {
|
|
134
118
|
__unstableWithInserter: true
|
|
135
119
|
});
|
|
136
120
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["@wordpress/block-editor/src/components/block-list/use-in-between-inserter.js"],"names":["useRefEffect","useDebounce","useSelect","useDispatch","useContext","store","blockEditorStore","InsertionPointOpenRef","useInBetweenInserter","openRef","isInBetweenInserterDisabled","select","getSettings","hasReducedUI","__unstableGetEditorMode","getBlockListSettings","getBlockRootClientId","getBlockIndex","isBlockInsertionPointVisible","isMultiSelecting","getSelectedBlockClientIds","getTemplateLock","__unstableIsWithinBlockOverlay","showInsertionPoint","hideInsertionPoint","delayedShowInsertionPoint","trailing","node","onMouseMove","event","current","target","classList","contains","cancel","rootClientId","blockElement","getAttribute","closest","orientation","offsetTop","clientY","offsetLeft","clientX","children","Array","from","element","find","blockEl","blockElRect","getBoundingClientRect","top","left","id","firstElementChild","clientId","slice","length","includes","elementRect","bottom","right","index","__unstableWithInserter","addEventListener","removeEventListener"],"mappings":"AAAA;AACA;AACA;AACA,SAASA,YAAT,EAAuBC,WAAvB,QAA0C,oBAA1C;AACA,SAASC,SAAT,EAAoBC,WAApB,QAAuC,iBAAvC;AACA,SAASC,UAAT,QAA2B,oBAA3B;AAEA;AACA;AACA;;AACA,SAASC,KAAK,IAAIC,gBAAlB,QAA0C,aAA1C;AACA,SAASC,qBAAT,QAAsC,gCAAtC;AAEA,OAAO,SAASC,oBAAT,GAAgC;AACtC,QAAMC,OAAO,GAAGL,UAAU,CAAEG,qBAAF,CAA1B;AACA,QAAMG,2BAA2B,GAAGR,SAAS,CAC1CS,MAAF,IACCA,MAAM,CAAEL,gBAAF,CAAN,CAA2BM,WAA3B,GAAyCC,YAAzC,IACAF,MAAM,CAAEL,gBAAF,CAAN,CAA2BQ,uBAA3B,OAAyD,UAHd,EAI5C,EAJ4C,CAA7C;AAMA,QAAM;AACLC,IAAAA,oBADK;AAELC,IAAAA,oBAFK;AAGLC,IAAAA,aAHK;AAILC,IAAAA,4BAJK;AAKLC,IAAAA,gBALK;AAMLC,IAAAA,yBANK;AAOLC,IAAAA,eAPK;AAQLC,IAAAA;AARK,MASFpB,SAAS,CAAEI,gBAAF,CATb;AAUA,QAAM;AAAEiB,IAAAA,kBAAF;AAAsBC,IAAAA;AAAtB,MACLrB,WAAW,CAAEG,gBAAF,CADZ;AAGA,QAAMmB,yBAAyB,GAAGxB,WAAW,CAAEsB,kBAAF,EAAsB,GAAtB,EAA2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,EAAjC,EAAsC;AACrCM,UAAAA,kBAAkB;AAClB;;AACD;AACA;;AAED,YAAMuC,KAAK,GAAG9C,aAAa,CAAEuC,QAAF,CAA3B,CAvG6B,CAyG7B;AACA;;AACA,UAAKO,KAAK,KAAK,CAAf,EAAmB;AAClBtC,QAAAA,yBAAyB,CAACS,MAA1B;;AACA,YAAKhB,4BAA4B,EAAjC,EAAsC;AACrCM,UAAAA,kBAAkB;AAClB;;AACD;AACA;;AAEDC,MAAAA,yBAAyB,CAAEU,YAAF,EAAgB4B,KAAhB,EAAuB;AAC/CC,QAAAA,sBAAsB,EAAE;AADuB,OAAvB,CAAzB;AAGA;;AAEDrC,IAAAA,IAAI,CAACsC,gBAAL,CAAuB,WAAvB,EAAoCrC,WAApC;AAEA,WAAO,MAAM;AACZD,MAAAA,IAAI,CAACuC,mBAAL,CAA0B,WAA1B,EAAuCtC,WAAvC;AACA,KAFD;AAGA,GAnIiB,EAoIlB,CACCnB,OADD,EAECM,oBAFD,EAGCC,oBAHD,EAICC,aAJD,EAKCC,4BALD,EAMCC,gBAND,EAOCI,kBAPD,EAQCC,kBARD,EASCJ,yBATD,EAUCV,2BAVD,CApIkB,CAAnB;AAiJA","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { useRefEffect, useDebounce } from '@wordpress/compose';\nimport { useSelect, useDispatch } from '@wordpress/data';\nimport { useContext } from '@wordpress/element';\n\n/**\n * Internal dependencies\n */\nimport { store as blockEditorStore } from '../../store';\nimport { InsertionPointOpenRef } from '../block-tools/insertion-point';\n\nexport function useInBetweenInserter() {\n\tconst openRef = useContext( InsertionPointOpenRef );\n\tconst isInBetweenInserterDisabled = useSelect(\n\t\t( select ) =>\n\t\t\tselect( blockEditorStore ).getSettings().hasReducedUI ||\n\t\t\tselect( blockEditorStore ).__unstableGetEditorMode() === 'zoom-out',\n\t\t[]\n\t);\n\tconst {\n\t\tgetBlockListSettings,\n\t\tgetBlockRootClientId,\n\t\tgetBlockIndex,\n\t\tisBlockInsertionPointVisible,\n\t\tisMultiSelecting,\n\t\tgetSelectedBlockClientIds,\n\t\tgetTemplateLock,\n\t\t__unstableIsWithinBlockOverlay,\n\t} = useSelect( blockEditorStore );\n\tconst { showInsertionPoint, hideInsertionPoint } =\n\t\tuseDispatch( blockEditorStore );\n\n\tconst delayedShowInsertionPoint = useDebounce( showInsertionPoint, 500, {\n\t\ttrailing: true,\n\t} );\n\n\treturn useRefEffect(\n\t\t( node ) => {\n\t\t\tif ( isInBetweenInserterDisabled ) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tfunction onMouseMove( event ) {\n\t\t\t\tif ( openRef.current ) {\n\t\t\t\t\treturn;\n\t\t\t\t}\n\n\t\t\t\tif ( isMultiSelecting() ) {\n\t\t\t\t\treturn;\n\t\t\t\t}\n\n\t\t\t\tif (\n\t\t\t\t\t! event.target.classList.contains(\n\t\t\t\t\t\t'block-editor-block-list__layout'\n\t\t\t\t\t)\n\t\t\t\t) {\n\t\t\t\t\tdelayedShowInsertionPoint.cancel();\n\t\t\t\t\tif ( isBlockInsertionPointVisible() ) {\n\t\t\t\t\t\thideInsertionPoint();\n\t\t\t\t\t}\n\t\t\t\t\treturn;\n\t\t\t\t}\n\n\t\t\t\tlet rootClientId;\n\t\t\t\tif (\n\t\t\t\t\t! event.target.classList.contains( 'is-root-container' )\n\t\t\t\t) {\n\t\t\t\t\tconst blockElement = !! event.target.getAttribute(\n\t\t\t\t\t\t'data-block'\n\t\t\t\t\t)\n\t\t\t\t\t\t? event.target\n\t\t\t\t\t\t: event.target.closest( '[data-block]' );\n\t\t\t\t\trootClientId = blockElement.getAttribute( 'data-block' );\n\t\t\t\t}\n\n\t\t\t\t// Don't set the insertion point if the template is locked.\n\t\t\t\tif ( getTemplateLock( rootClientId ) ) {\n\t\t\t\t\treturn;\n\t\t\t\t}\n\n\t\t\t\tconst orientation =\n\t\t\t\t\tgetBlockListSettings( rootClientId )?.orientation ||\n\t\t\t\t\t'vertical';\n\t\t\t\tconst offsetTop = event.clientY;\n\t\t\t\tconst offsetLeft = event.clientX;\n\n\t\t\t\tconst children = Array.from( event.target.children );\n\t\t\t\tlet element = children.find( ( blockEl ) => {\n\t\t\t\t\tconst blockElRect = blockEl.getBoundingClientRect();\n\t\t\t\t\treturn (\n\t\t\t\t\t\t( blockEl.classList.contains( 'wp-block' ) &&\n\t\t\t\t\t\t\torientation === 'vertical' &&\n\t\t\t\t\t\t\tblockElRect.top > offsetTop ) ||\n\t\t\t\t\t\t( blockEl.classList.contains( 'wp-block' ) &&\n\t\t\t\t\t\t\torientation === 'horizontal' &&\n\t\t\t\t\t\t\tblockElRect.left > offsetLeft )\n\t\t\t\t\t);\n\t\t\t\t} );\n\n\t\t\t\tif ( ! element ) {\n\t\t\t\t\treturn;\n\t\t\t\t}\n\n\t\t\t\t// The block may be in an alignment wrapper, so check the first direct\n\t\t\t\t// child if the element has no ID.\n\t\t\t\tif ( ! element.id ) {\n\t\t\t\t\telement = element.firstElementChild;\n\n\t\t\t\t\tif ( ! element ) {\n\t\t\t\t\t\treturn;\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\t// Don't show the insertion point if a parent block has an \"overlay\"\n\t\t\t\t// See https://github.com/WordPress/gutenberg/pull/34012#pullrequestreview-727762337\n\t\t\t\tconst clientId = element.id.slice( 'block-'.length );\n\t\t\t\tif (\n\t\t\t\t\t! clientId ||\n\t\t\t\t\t__unstableIsWithinBlockOverlay( clientId )\n\t\t\t\t) {\n\t\t\t\t\treturn;\n\t\t\t\t}\n\n\t\t\t\t// Don't show the inserter when hovering above (conflicts with\n\t\t\t\t// block toolbar) or inside selected block(s).\n\t\t\t\tif ( getSelectedBlockClientIds().includes( clientId ) ) {\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t\tconst elementRect = element.getBoundingClientRect();\n\n\t\t\t\tif (\n\t\t\t\t\t( orientation === 'horizontal' &&\n\t\t\t\t\t\t( event.clientY > elementRect.bottom ||\n\t\t\t\t\t\t\tevent.clientY < elementRect.top ) ) ||\n\t\t\t\t\t( orientation === 'vertical' &&\n\t\t\t\t\t\t( event.clientX > elementRect.right ||\n\t\t\t\t\t\t\tevent.clientX < elementRect.left ) )\n\t\t\t\t) {\n\t\t\t\t\tdelayedShowInsertionPoint.cancel();\n\t\t\t\t\tif ( isBlockInsertionPointVisible() ) {\n\t\t\t\t\t\thideInsertionPoint();\n\t\t\t\t\t}\n\t\t\t\t\treturn;\n\t\t\t\t}\n\n\t\t\t\tconst index = getBlockIndex( clientId );\n\n\t\t\t\t// Don't show the in-between inserter before the first block in\n\t\t\t\t// the list (preserves the original behaviour).\n\t\t\t\tif ( index === 0 ) {\n\t\t\t\t\tdelayedShowInsertionPoint.cancel();\n\t\t\t\t\tif ( isBlockInsertionPointVisible() ) {\n\t\t\t\t\t\thideInsertionPoint();\n\t\t\t\t\t}\n\t\t\t\t\treturn;\n\t\t\t\t}\n\n\t\t\t\tdelayedShowInsertionPoint( rootClientId, index, {\n\t\t\t\t\t__unstableWithInserter: true,\n\t\t\t\t} );\n\t\t\t}\n\n\t\t\tnode.addEventListener( 'mousemove', onMouseMove );\n\n\t\t\treturn () => {\n\t\t\t\tnode.removeEventListener( 'mousemove', onMouseMove );\n\t\t\t};\n\t\t},\n\t\t[\n\t\t\topenRef,\n\t\t\tgetBlockListSettings,\n\t\t\tgetBlockRootClientId,\n\t\t\tgetBlockIndex,\n\t\t\tisBlockInsertionPointVisible,\n\t\t\tisMultiSelecting,\n\t\t\tshowInsertionPoint,\n\t\t\thideInsertionPoint,\n\t\t\tgetSelectedBlockClientIds,\n\t\t\tisInBetweenInserterDisabled,\n\t\t]\n\t);\n}\n"]}
|
|
1
|
+
{"version":3,"sources":["@wordpress/block-editor/src/components/block-list/use-in-between-inserter.js"],"names":["useRefEffect","useSelect","useDispatch","useContext","store","blockEditorStore","InsertionPointOpenRef","useInBetweenInserter","openRef","isInBetweenInserterDisabled","select","getSettings","isDistractionFree","__unstableGetEditorMode","getBlockListSettings","getBlockRootClientId","getBlockIndex","isBlockInsertionPointVisible","isMultiSelecting","getSelectedBlockClientIds","getTemplateLock","__unstableIsWithinBlockOverlay","showInsertionPoint","hideInsertionPoint","node","onMouseMove","event","current","target","classList","contains","rootClientId","blockElement","getAttribute","closest","orientation","offsetTop","clientY","offsetLeft","clientX","children","Array","from","element","find","blockEl","blockElRect","getBoundingClientRect","top","left","id","firstElementChild","clientId","slice","length","includes","elementRect","bottom","right","index","__unstableWithInserter","addEventListener","removeEventListener"],"mappings":"AAAA;AACA;AACA;AACA,SAASA,YAAT,QAA6B,oBAA7B;AACA,SAASC,SAAT,EAAoBC,WAApB,QAAuC,iBAAvC;AACA,SAASC,UAAT,QAA2B,oBAA3B;AAEA;AACA;AACA;;AACA,SAASC,KAAK,IAAIC,gBAAlB,QAA0C,aAA1C;AACA,SAASC,qBAAT,QAAsC,gCAAtC;AAEA,OAAO,SAASC,oBAAT,GAAgC;AACtC,QAAMC,OAAO,GAAGL,UAAU,CAAEG,qBAAF,CAA1B;AACA,QAAMG,2BAA2B,GAAGR,SAAS,CAC1CS,MAAF,IACCA,MAAM,CAAEL,gBAAF,CAAN,CAA2BM,WAA3B,GAAyCC,iBAAzC,IACAF,MAAM,CAAEL,gBAAF,CAAN,CAA2BQ,uBAA3B,OAAyD,UAHd,EAI5C,EAJ4C,CAA7C;AAMA,QAAM;AACLC,IAAAA,oBADK;AAELC,IAAAA,oBAFK;AAGLC,IAAAA,aAHK;AAILC,IAAAA,4BAJK;AAKLC,IAAAA,gBALK;AAMLC,IAAAA,yBANK;AAOLC,IAAAA,eAPK;AAQLC,IAAAA;AARK,MASFpB,SAAS,CAAEI,gBAAF,CATb;AAUA,QAAM;AAAEiB,IAAAA,kBAAF;AAAsBC,IAAAA;AAAtB,MACLrB,WAAW,CAAEG,gBAAF,CADZ;AAGA,SAAOL,YAAY,CAChBwB,IAAF,IAAY;AACX,QAAKf,2BAAL,EAAmC;AAClC;AACA;;AAED,aAASgB,WAAT,CAAsBC,KAAtB,EAA8B;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sBAAsB,EAAE;AADgB,OAAvB,CAAlB;AAGA;;AAEDpC,IAAAA,IAAI,CAACqC,gBAAL,CAAuB,WAAvB,EAAoCpC,WAApC;AAEA,WAAO,MAAM;AACZD,MAAAA,IAAI,CAACsC,mBAAL,CAA0B,WAA1B,EAAuCrC,WAAvC;AACA,KAFD;AAGA,GA5HiB,EA6HlB,CACCjB,OADD,EAECM,oBAFD,EAGCC,oBAHD,EAICC,aAJD,EAKCC,4BALD,EAMCC,gBAND,EAOCI,kBAPD,EAQCC,kBARD,EASCJ,yBATD,EAUCV,2BAVD,CA7HkB,CAAnB;AA0IA","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { useRefEffect } from '@wordpress/compose';\nimport { useSelect, useDispatch } from '@wordpress/data';\nimport { useContext } from '@wordpress/element';\n\n/**\n * Internal dependencies\n */\nimport { store as blockEditorStore } from '../../store';\nimport { InsertionPointOpenRef } from '../block-tools/insertion-point';\n\nexport function useInBetweenInserter() {\n\tconst openRef = useContext( InsertionPointOpenRef );\n\tconst isInBetweenInserterDisabled = useSelect(\n\t\t( select ) =>\n\t\t\tselect( blockEditorStore ).getSettings().isDistractionFree ||\n\t\t\tselect( blockEditorStore ).__unstableGetEditorMode() === 'zoom-out',\n\t\t[]\n\t);\n\tconst {\n\t\tgetBlockListSettings,\n\t\tgetBlockRootClientId,\n\t\tgetBlockIndex,\n\t\tisBlockInsertionPointVisible,\n\t\tisMultiSelecting,\n\t\tgetSelectedBlockClientIds,\n\t\tgetTemplateLock,\n\t\t__unstableIsWithinBlockOverlay,\n\t} = useSelect( blockEditorStore );\n\tconst { showInsertionPoint, hideInsertionPoint } =\n\t\tuseDispatch( blockEditorStore );\n\n\treturn useRefEffect(\n\t\t( node ) => {\n\t\t\tif ( isInBetweenInserterDisabled ) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tfunction onMouseMove( event ) {\n\t\t\t\tif ( openRef.current ) {\n\t\t\t\t\treturn;\n\t\t\t\t}\n\n\t\t\t\tif ( isMultiSelecting() ) {\n\t\t\t\t\treturn;\n\t\t\t\t}\n\n\t\t\t\tif (\n\t\t\t\t\t! event.target.classList.contains(\n\t\t\t\t\t\t'block-editor-block-list__layout'\n\t\t\t\t\t)\n\t\t\t\t) {\n\t\t\t\t\thideInsertionPoint();\n\t\t\t\t\treturn;\n\t\t\t\t}\n\n\t\t\t\tlet rootClientId;\n\t\t\t\tif (\n\t\t\t\t\t! event.target.classList.contains( 'is-root-container' )\n\t\t\t\t) {\n\t\t\t\t\tconst blockElement = !! event.target.getAttribute(\n\t\t\t\t\t\t'data-block'\n\t\t\t\t\t)\n\t\t\t\t\t\t? event.target\n\t\t\t\t\t\t: event.target.closest( '[data-block]' );\n\t\t\t\t\trootClientId = blockElement.getAttribute( 'data-block' );\n\t\t\t\t}\n\n\t\t\t\t// Don't set the insertion point if the template is locked.\n\t\t\t\tif ( getTemplateLock( rootClientId ) ) {\n\t\t\t\t\treturn;\n\t\t\t\t}\n\n\t\t\t\tconst orientation =\n\t\t\t\t\tgetBlockListSettings( rootClientId )?.orientation ||\n\t\t\t\t\t'vertical';\n\t\t\t\tconst offsetTop = event.clientY;\n\t\t\t\tconst offsetLeft = event.clientX;\n\n\t\t\t\tconst children = Array.from( event.target.children );\n\t\t\t\tlet element = children.find( ( blockEl ) => {\n\t\t\t\t\tconst blockElRect = blockEl.getBoundingClientRect();\n\t\t\t\t\treturn (\n\t\t\t\t\t\t( blockEl.classList.contains( 'wp-block' ) &&\n\t\t\t\t\t\t\torientation === 'vertical' &&\n\t\t\t\t\t\t\tblockElRect.top > offsetTop ) ||\n\t\t\t\t\t\t( blockEl.classList.contains( 'wp-block' ) &&\n\t\t\t\t\t\t\torientation === 'horizontal' &&\n\t\t\t\t\t\t\tblockElRect.left > offsetLeft )\n\t\t\t\t\t);\n\t\t\t\t} );\n\n\t\t\t\tif ( ! element ) {\n\t\t\t\t\thideInsertionPoint();\n\t\t\t\t\treturn;\n\t\t\t\t}\n\n\t\t\t\t// The block may be in an alignment wrapper, so check the first direct\n\t\t\t\t// child if the element has no ID.\n\t\t\t\tif ( ! element.id ) {\n\t\t\t\t\telement = element.firstElementChild;\n\n\t\t\t\t\tif ( ! element ) {\n\t\t\t\t\t\thideInsertionPoint();\n\t\t\t\t\t\treturn;\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\t// Don't show the insertion point if a parent block has an \"overlay\"\n\t\t\t\t// See https://github.com/WordPress/gutenberg/pull/34012#pullrequestreview-727762337\n\t\t\t\tconst clientId = element.id.slice( 'block-'.length );\n\t\t\t\tif (\n\t\t\t\t\t! clientId ||\n\t\t\t\t\t__unstableIsWithinBlockOverlay( clientId )\n\t\t\t\t) {\n\t\t\t\t\treturn;\n\t\t\t\t}\n\n\t\t\t\t// Don't show the inserter when hovering above (conflicts with\n\t\t\t\t// block toolbar) or inside selected block(s).\n\t\t\t\tif ( getSelectedBlockClientIds().includes( clientId ) ) {\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t\tconst elementRect = element.getBoundingClientRect();\n\n\t\t\t\tif (\n\t\t\t\t\t( orientation === 'horizontal' &&\n\t\t\t\t\t\t( event.clientY > elementRect.bottom ||\n\t\t\t\t\t\t\tevent.clientY < elementRect.top ) ) ||\n\t\t\t\t\t( orientation === 'vertical' &&\n\t\t\t\t\t\t( event.clientX > elementRect.right ||\n\t\t\t\t\t\t\tevent.clientX < elementRect.left ) )\n\t\t\t\t) {\n\t\t\t\t\thideInsertionPoint();\n\t\t\t\t\treturn;\n\t\t\t\t}\n\n\t\t\t\tconst index = getBlockIndex( clientId );\n\n\t\t\t\t// Don't show the in-between inserter before the first block in\n\t\t\t\t// the list (preserves the original behaviour).\n\t\t\t\tif ( index === 0 ) {\n\t\t\t\t\thideInsertionPoint();\n\t\t\t\t\treturn;\n\t\t\t\t}\n\n\t\t\t\tshowInsertionPoint( rootClientId, index, {\n\t\t\t\t\t__unstableWithInserter: true,\n\t\t\t\t} );\n\t\t\t}\n\n\t\t\tnode.addEventListener( 'mousemove', onMouseMove );\n\n\t\t\treturn () => {\n\t\t\t\tnode.removeEventListener( 'mousemove', onMouseMove );\n\t\t\t};\n\t\t},\n\t\t[\n\t\t\topenRef,\n\t\t\tgetBlockListSettings,\n\t\t\tgetBlockRootClientId,\n\t\t\tgetBlockIndex,\n\t\t\tisBlockInsertionPointVisible,\n\t\t\tisMultiSelecting,\n\t\t\tshowInsertionPoint,\n\t\t\thideInsertionPoint,\n\t\t\tgetSelectedBlockClientIds,\n\t\t\tisInBetweenInserterDisabled,\n\t\t]\n\t);\n}\n"]}
|
|
@@ -9,14 +9,16 @@ import { Button, CheckboxControl, Flex, FlexItem, Icon, Modal, ToggleControl } f
|
|
|
9
9
|
import { lock as lockIcon, unlock as unlockIcon } from '@wordpress/icons';
|
|
10
10
|
import { useInstanceId } from '@wordpress/compose';
|
|
11
11
|
import { useDispatch, useSelect } from '@wordpress/data';
|
|
12
|
-
import {
|
|
12
|
+
import { getBlockType } from '@wordpress/blocks';
|
|
13
13
|
/**
|
|
14
14
|
* Internal dependencies
|
|
15
15
|
*/
|
|
16
16
|
|
|
17
17
|
import useBlockLock from './use-block-lock';
|
|
18
18
|
import useBlockDisplayInformation from '../use-block-display-information';
|
|
19
|
-
import { store as blockEditorStore } from '../../store';
|
|
19
|
+
import { store as blockEditorStore } from '../../store'; // Entity based blocks which allow edit locking
|
|
20
|
+
|
|
21
|
+
const ALLOWS_EDIT_LOCKING = ['core/block', 'core/navigation'];
|
|
20
22
|
|
|
21
23
|
function getTemplateLockValue(lock) {
|
|
22
24
|
// Prevents all operations.
|
|
@@ -47,7 +49,7 @@ export default function BlockLockModal(_ref) {
|
|
|
47
49
|
canRemove
|
|
48
50
|
} = useBlockLock(clientId);
|
|
49
51
|
const {
|
|
50
|
-
|
|
52
|
+
allowsEditLocking,
|
|
51
53
|
templateLock,
|
|
52
54
|
hasTemplateLock
|
|
53
55
|
} = useSelect(select => {
|
|
@@ -60,7 +62,7 @@ export default function BlockLockModal(_ref) {
|
|
|
60
62
|
const blockName = getBlockName(clientId);
|
|
61
63
|
const blockType = getBlockType(blockName);
|
|
62
64
|
return {
|
|
63
|
-
|
|
65
|
+
allowsEditLocking: ALLOWS_EDIT_LOCKING.includes(blockName),
|
|
64
66
|
templateLock: (_getBlockAttributes = getBlockAttributes(clientId)) === null || _getBlockAttributes === void 0 ? void 0 : _getBlockAttributes.templateLock,
|
|
65
67
|
hasTemplateLock: !!(blockType !== null && blockType !== void 0 && (_blockType$attributes = blockType.attributes) !== null && _blockType$attributes !== void 0 && _blockType$attributes.templateLock)
|
|
66
68
|
};
|
|
@@ -75,11 +77,11 @@ export default function BlockLockModal(_ref) {
|
|
|
75
77
|
setLock({
|
|
76
78
|
move: !canMove,
|
|
77
79
|
remove: !canRemove,
|
|
78
|
-
...(
|
|
80
|
+
...(allowsEditLocking ? {
|
|
79
81
|
edit: !canEdit
|
|
80
82
|
} : {})
|
|
81
83
|
});
|
|
82
|
-
}, [canEdit, canMove, canRemove,
|
|
84
|
+
}, [canEdit, canMove, canRemove, allowsEditLocking]);
|
|
83
85
|
const isAllChecked = Object.values(lock).every(Boolean);
|
|
84
86
|
const isMixed = Object.values(lock).some(Boolean) && !isAllChecked;
|
|
85
87
|
return createElement(Modal, {
|
|
@@ -112,13 +114,13 @@ export default function BlockLockModal(_ref) {
|
|
|
112
114
|
onChange: newValue => setLock({
|
|
113
115
|
move: newValue,
|
|
114
116
|
remove: newValue,
|
|
115
|
-
...(
|
|
117
|
+
...(allowsEditLocking ? {
|
|
116
118
|
edit: newValue
|
|
117
119
|
} : {})
|
|
118
120
|
})
|
|
119
121
|
}), createElement("ul", {
|
|
120
122
|
className: "block-editor-block-lock-modal__checklist"
|
|
121
|
-
},
|
|
123
|
+
}, allowsEditLocking && createElement("li", {
|
|
122
124
|
className: "block-editor-block-lock-modal__checklist-item"
|
|
123
125
|
}, createElement(CheckboxControl, {
|
|
124
126
|
label: createElement(Fragment, null, __('Restrict editing'), createElement(Icon, {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["@wordpress/block-editor/src/components/block-lock/modal.js"],"names":["__","sprintf","useEffect","useState","Button","CheckboxControl","Flex","FlexItem","Icon","Modal","ToggleControl","lock","lockIcon","unlock","unlockIcon","useInstanceId","useDispatch","useSelect","isReusableBlock","getBlockType","useBlockLock","useBlockDisplayInformation","store","blockEditorStore","getTemplateLockValue","remove","move","BlockLockModal","clientId","onClose","setLock","canEdit","canMove","canRemove","isReusable","templateLock","hasTemplateLock","select","getBlockName","getBlockAttributes","blockName","blockType","attributes","applyTemplateLock","setApplyTemplateLock","updateBlockAttributes","blockInformation","instanceId","edit","isAllChecked","Object","values","every","Boolean","isMixed","some","title","event","preventDefault","undefined","newValue","prevLock"],"mappings":";;AAAA;AACA;AACA;AACA,SAASA,EAAT,EAAaC,OAAb,QAA4B,iBAA5B;AACA,SAASC,SAAT,EAAoBC,QAApB,QAAoC,oBAApC;AACA,SACCC,MADD,EAECC,eAFD,EAGCC,IAHD,EAICC,QAJD,EAKCC,IALD,EAMCC,KAND,EAOCC,aAPD,QAQO,uBARP;AASA,SAASC,IAAI,IAAIC,QAAjB,EAA2BC,MAAM,IAAIC,UAArC,QAAuD,kBAAvD;AACA,SAASC,aAAT,QAA8B,oBAA9B;AACA,SAASC,WAAT,EAAsBC,SAAtB,QAAuC,iBAAvC;AACA,SAASC,eAAT,EAA0BC,YAA1B,QAA8C,mBAA9C;AAEA;AACA;AACA;;AACA,OAAOC,YAAP,MAAyB,kBAAzB;AACA,OAAOC,0BAAP,MAAuC,kCAAvC;AACA,SAASC,KAAK,IAAIC,gBAAlB,QAA0C,aAA1C;;AAEA,SAASC,oBAAT,CAA+Bb,IAA/B,EAAsC;AACrC;AACA,MAAKA,IAAI,CAACc,MAAL,IAAed,IAAI,CAACe,IAAzB,EAAgC;AAC/B,WAAO,KAAP;AACA,GAJoC,CAMrC;;;AACA,MAAKf,IAAI,CAACc,MAAL,IAAe,CAAEd,IAAI,CAACe,IAA3B,EAAk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Content":["/**\n * WordPress dependencies\n */\nimport { __, sprintf } from '@wordpress/i18n';\nimport { useEffect, useState } from '@wordpress/element';\nimport {\n\tButton,\n\tCheckboxControl,\n\tFlex,\n\tFlexItem,\n\tIcon,\n\tModal,\n\tToggleControl,\n} from '@wordpress/components';\nimport { lock as lockIcon, unlock as unlockIcon } from '@wordpress/icons';\nimport { useInstanceId } from '@wordpress/compose';\nimport { useDispatch, useSelect } from '@wordpress/data';\nimport { isReusableBlock, getBlockType } from '@wordpress/blocks';\n\n/**\n * Internal dependencies\n */\nimport useBlockLock from './use-block-lock';\nimport useBlockDisplayInformation from '../use-block-display-information';\nimport { store as blockEditorStore } from '../../store';\n\nfunction getTemplateLockValue( lock ) {\n\t// Prevents all operations.\n\tif ( lock.remove && lock.move ) {\n\t\treturn 'all';\n\t}\n\n\t// Prevents inserting or removing blocks, but allows moving existing blocks.\n\tif ( lock.remove && ! lock.move ) {\n\t\treturn 'insert';\n\t}\n\n\treturn false;\n}\n\nexport default function BlockLockModal( { clientId, onClose } ) {\n\tconst [ lock, setLock ] = useState( { move: false, remove: false } );\n\tconst { canEdit, canMove, canRemove } = useBlockLock( clientId );\n\tconst { isReusable, templateLock, hasTemplateLock } = useSelect(\n\t\t( select ) => {\n\t\t\tconst { getBlockName, getBlockAttributes } =\n\t\t\t\tselect( blockEditorStore );\n\t\t\tconst blockName = getBlockName( clientId );\n\t\t\tconst blockType = getBlockType( blockName );\n\n\t\t\treturn {\n\t\t\t\tisReusable: isReusableBlock( blockType ),\n\t\t\t\ttemplateLock: getBlockAttributes( clientId )?.templateLock,\n\t\t\t\thasTemplateLock: !! blockType?.attributes?.templateLock,\n\t\t\t};\n\t\t},\n\t\t[ clientId ]\n\t);\n\tconst [ applyTemplateLock, setApplyTemplateLock ] = useState(\n\t\t!! templateLock\n\t);\n\tconst { updateBlockAttributes } = useDispatch( blockEditorStore );\n\tconst blockInformation = useBlockDisplayInformation( clientId );\n\tconst instanceId = useInstanceId(\n\t\tBlockLockModal,\n\t\t'block-editor-block-lock-modal__options-title'\n\t);\n\n\tuseEffect( () => {\n\t\tsetLock( {\n\t\t\tmove: ! canMove,\n\t\t\tremove: ! canRemove,\n\t\t\t...( isReusable ? { edit: ! canEdit } : {} ),\n\t\t} );\n\t}, [ canEdit, canMove, canRemove, isReusable ] );\n\n\tconst isAllChecked = Object.values( lock ).every( Boolean );\n\tconst isMixed = Object.values( lock ).some( Boolean ) && ! isAllChecked;\n\n\treturn (\n\t\t<Modal\n\t\t\ttitle={ sprintf(\n\t\t\t\t/* translators: %s: Name of the block. */\n\t\t\t\t__( 'Lock %s' ),\n\t\t\t\tblockInformation.title\n\t\t\t) }\n\t\t\toverlayClassName=\"block-editor-block-lock-modal\"\n\t\t\tcloseLabel={ __( 'Close' ) }\n\t\t\tonRequestClose={ onClose }\n\t\t>\n\t\t\t<p>\n\t\t\t\t{ __(\n\t\t\t\t\t'Choose specific attributes to restrict or lock all available options.'\n\t\t\t\t) }\n\t\t\t</p>\n\t\t\t<form\n\t\t\t\tonSubmit={ ( event ) => {\n\t\t\t\t\tevent.preventDefault();\n\t\t\t\t\tupdateBlockAttributes( [ clientId ], {\n\t\t\t\t\t\tlock,\n\t\t\t\t\t\ttemplateLock: applyTemplateLock\n\t\t\t\t\t\t\t? getTemplateLockValue( lock )\n\t\t\t\t\t\t\t: undefined,\n\t\t\t\t\t} );\n\t\t\t\t\tonClose();\n\t\t\t\t} }\n\t\t\t>\n\t\t\t\t<div\n\t\t\t\t\trole=\"group\"\n\t\t\t\t\taria-labelledby={ instanceId }\n\t\t\t\t\tclassName=\"block-editor-block-lock-modal__options\"\n\t\t\t\t>\n\t\t\t\t\t<CheckboxControl\n\t\t\t\t\t\tclassName=\"block-editor-block-lock-modal__options-title\"\n\t\t\t\t\t\tlabel={\n\t\t\t\t\t\t\t<span id={ instanceId }>{ __( 'Lock all' ) }</span>\n\t\t\t\t\t\t}\n\t\t\t\t\t\tchecked={ isAllChecked }\n\t\t\t\t\t\tindeterminate={ isMixed }\n\t\t\t\t\t\tonChange={ ( newValue ) =>\n\t\t\t\t\t\t\tsetLock( {\n\t\t\t\t\t\t\t\tmove: newValue,\n\t\t\t\t\t\t\t\tremove: newValue,\n\t\t\t\t\t\t\t\t...( isReusable ? { edit: newValue } : {} ),\n\t\t\t\t\t\t\t} )\n\t\t\t\t\t\t}\n\t\t\t\t\t/>\n\t\t\t\t\t<ul className=\"block-editor-block-lock-modal__checklist\">\n\t\t\t\t\t\t{ isReusable && (\n\t\t\t\t\t\t\t<li className=\"block-editor-block-lock-modal__checklist-item\">\n\t\t\t\t\t\t\t\t<CheckboxControl\n\t\t\t\t\t\t\t\t\tlabel={\n\t\t\t\t\t\t\t\t\t\t<>\n\t\t\t\t\t\t\t\t\t\t\t{ __( 'Restrict editing' ) }\n\t\t\t\t\t\t\t\t\t\t\t<Icon\n\t\t\t\t\t\t\t\t\t\t\t\ticon={\n\t\t\t\t\t\t\t\t\t\t\t\t\tlock.edit\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t? lockIcon\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t: unlockIcon\n\t\t\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t\t\t\t</>\n\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\tchecked={ !! lock.edit }\n\t\t\t\t\t\t\t\t\tonChange={ ( edit ) =>\n\t\t\t\t\t\t\t\t\t\tsetLock( ( prevLock ) => ( {\n\t\t\t\t\t\t\t\t\t\t\t...prevLock,\n\t\t\t\t\t\t\t\t\t\t\tedit,\n\t\t\t\t\t\t\t\t\t\t} ) )\n\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t</li>\n\t\t\t\t\t\t) }\n\t\t\t\t\t\t<li className=\"block-editor-block-lock-modal__checklist-item\">\n\t\t\t\t\t\t\t<CheckboxControl\n\t\t\t\t\t\t\t\tlabel={\n\t\t\t\t\t\t\t\t\t<>\n\t\t\t\t\t\t\t\t\t\t{ __( 'Disable movement' ) }\n\t\t\t\t\t\t\t\t\t\t<Icon\n\t\t\t\t\t\t\t\t\t\t\ticon={\n\t\t\t\t\t\t\t\t\t\t\t\tlock.move\n\t\t\t\t\t\t\t\t\t\t\t\t\t? lockIcon\n\t\t\t\t\t\t\t\t\t\t\t\t\t: unlockIcon\n\t\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t\t\t</>\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\tchecked={ lock.move }\n\t\t\t\t\t\t\t\tonChange={ ( move ) =>\n\t\t\t\t\t\t\t\t\tsetLock( ( prevLock ) => ( {\n\t\t\t\t\t\t\t\t\t\t...prevLock,\n\t\t\t\t\t\t\t\t\t\tmove,\n\t\t\t\t\t\t\t\t\t} ) )\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t</li>\n\t\t\t\t\t\t<li className=\"block-editor-block-lock-modal__checklist-item\">\n\t\t\t\t\t\t\t<CheckboxControl\n\t\t\t\t\t\t\t\tlabel={\n\t\t\t\t\t\t\t\t\t<>\n\t\t\t\t\t\t\t\t\t\t{ __( 'Prevent removal' ) }\n\t\t\t\t\t\t\t\t\t\t<Icon\n\t\t\t\t\t\t\t\t\t\t\ticon={\n\t\t\t\t\t\t\t\t\t\t\t\tlock.remove\n\t\t\t\t\t\t\t\t\t\t\t\t\t? lockIcon\n\t\t\t\t\t\t\t\t\t\t\t\t\t: unlockIcon\n\t\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t\t\t</>\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\tchecked={ lock.remove }\n\t\t\t\t\t\t\t\tonChange={ ( remove ) =>\n\t\t\t\t\t\t\t\t\tsetLock( ( prevLock ) => ( {\n\t\t\t\t\t\t\t\t\t\t...prevLock,\n\t\t\t\t\t\t\t\t\t\tremove,\n\t\t\t\t\t\t\t\t\t} ) )\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t</li>\n\t\t\t\t\t</ul>\n\t\t\t\t\t{ hasTemplateLock && (\n\t\t\t\t\t\t<ToggleControl\n\t\t\t\t\t\t\tclassName=\"block-editor-block-lock-modal__template-lock\"\n\t\t\t\t\t\t\tlabel={ __( 'Apply to all blocks inside' ) }\n\t\t\t\t\t\t\tchecked={ applyTemplateLock }\n\t\t\t\t\t\t\tdisabled={ lock.move && ! lock.remove }\n\t\t\t\t\t\t\tonChange={ () =>\n\t\t\t\t\t\t\t\tsetApplyTemplateLock( ! applyTemplateLock )\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t/>\n\t\t\t\t\t) }\n\t\t\t\t</div>\n\t\t\t\t<Flex\n\t\t\t\t\tclassName=\"block-editor-block-lock-modal__actions\"\n\t\t\t\t\tjustify=\"flex-end\"\n\t\t\t\t\texpanded={ false }\n\t\t\t\t>\n\t\t\t\t\t<FlexItem>\n\t\t\t\t\t\t<Button variant=\"tertiary\" onClick={ onClose }>\n\t\t\t\t\t\t\t{ __( 'Cancel' ) }\n\t\t\t\t\t\t</Button>\n\t\t\t\t\t</FlexItem>\n\t\t\t\t\t<FlexItem>\n\t\t\t\t\t\t<Button variant=\"primary\" type=\"submit\">\n\t\t\t\t\t\t\t{ __( 'Apply' ) }\n\t\t\t\t\t\t</Button>\n\t\t\t\t\t</FlexItem>\n\t\t\t\t</Flex>\n\t\t\t</form>\n\t\t</Modal>\n\t);\n}\n"]}
|
|
1
|
+
{"version":3,"sources":["@wordpress/block-editor/src/components/block-lock/modal.js"],"names":["__","sprintf","useEffect","useState","Button","CheckboxControl","Flex","FlexItem","Icon","Modal","ToggleControl","lock","lockIcon","unlock","unlockIcon","useInstanceId","useDispatch","useSelect","getBlockType","useBlockLock","useBlockDisplayInformation","store","blockEditorStore","ALLOWS_EDIT_LOCKING","getTemplateLockValue","remove","move","BlockLockModal","clientId","onClose","setLock","canEdit","canMove","canRemove","allowsEditLocking","templateLock","hasTemplateLock","select","getBlockName","getBlockAttributes","blockName","blockType","includes","attributes","applyTemplateLock","setApplyTemplateLock","updateBlockAttributes","blockInformation","instanceId","edit","isAllChecked","Object","values","every","Boolean","isMixed","some","title","event","preventDefault","undefined","newValue","prevLock"],"mappings":";;AAAA;AACA;AACA;AACA,SAASA,EAAT,EAAaC,OAAb,QAA4B,iBAA5B;AACA,SAASC,SAAT,EAAoBC,QAApB,QAAoC,oBAApC;AACA,SACCC,MADD,EAECC,eAFD,EAGCC,IAHD,EAICC,QAJD,EAKCC,IALD,EAMCC,KAND,EAOCC,aAPD,QAQO,uBARP;AASA,SAASC,IAAI,IAAIC,QAAjB,EAA2BC,MAAM,IAAIC,UAArC,QAAuD,kBAAvD;AACA,SAASC,aAAT,QAA8B,oBAA9B;AACA,SAASC,WAAT,EAAsBC,SAAtB,QAAuC,iBAAvC;AACA,SAASC,YAAT,QAA6B,mBAA7B;AAEA;AACA;AACA;;AACA,OAAOC,YAAP,MAAyB,kBAAzB;AACA,OAAOC,0BAAP,MAAuC,kCAAvC;AACA,SAASC,KAAK,IAAIC,gBAAlB,QAA0C,aAA1C,C,CAEA;;AACA,MAAMC,mBAAmB,GAAG,CAAE,YAAF,EAAgB,iBAAhB,CAA5B;;AAEA,SAASC,oBAAT,CAA+Bb,IAA/B,EAAsC;AACrC;AACA,MAAKA,IAAI,CAACc,MAAL,IAAed,IAAI,CAACe,IAAzB,EAAgC;AAC/B,WAAO,KAAP;AACA,GAJoC,CAMrC;;;AACA,MAAKf,IAAI,CAACc,MAAL,IAAe,CAAEd,IAAI,CAACe,IAA3B,EAAkC;AACjC,WAAO,QAAP;AACA;;AAED,SAAO,KAAP;AACA;;AAED,eAAe,SAASC,cAAT,OAAiD;AAAA,MAAxB;AAAEC,IAAAA,QAAF;AAAYC,IAAAA;AAAZ,GAAwB;AAC/D,QA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SAAS,EAAC;AAAd,KACC,cAAC,eAAD;AACC,IAAA,KAAK,EACJ,8BACG1B,EAAE,CAAE,iBAAF,CADL,EAEC,cAAC,IAAD;AACC,MAAA,IAAI,EACHW,IAAI,CAACc,MAAL,GACGb,QADH,GAEGE;AAJL,MAFD,CAFF;AAaC,IAAA,OAAO,EAAGH,IAAI,CAACc,MAbhB;AAcC,IAAA,QAAQ,EAAKA,MAAF,IACVK,OAAO,CAAIgC,QAAF,KAAkB,EAC1B,GAAGA,QADuB;AAE1BrC,MAAAA;AAF0B,KAAlB,CAAF;AAfT,IADD,CAjDD,CAtBD,EA+FGW,eAAe,IAChB,cAAC,aAAD;AACC,IAAA,SAAS,EAAC,8CADX;AAEC,IAAA,KAAK,EAAGpC,EAAE,CAAE,4BAAF,CAFX;AAGC,IAAA,OAAO,EAAG4C,iBAHX;AAIC,IAAA,QAAQ,EAAGjC,IAAI,CAACe,IAAL,IAAa,CAAEf,IAAI,CAACc,MAJhC;AAKC,IAAA,QAAQ,EAAG,MACVoB,oBAAoB,CAAE,CAAED,iBAAJ;AANtB,IAhGF,CAZD,EAuHC,cAAC,IAAD;AACC,IAAA,SAAS,EAAC,wCADX;AAEC,IAAA,OAAO,EAAC,UAFT;AAGC,IAAA,QAAQ,EAAG;AAHZ,KAKC,cAAC,QAAD,QACC,cAAC,MAAD;AAAQ,IAAA,OAAO,EAAC,UAAhB;AAA2B,IAAA,OAAO,EAAGf;AAArC,KACG7B,EAAE,CAAE,QAAF,CADL,CADD,CALD,EAUC,cAAC,QAAD,QACC,cAAC,MAAD;AAAQ,IAAA,OAAO,EAAC,SAAhB;AAA0B,IAAA,IAAI,EAAC;AAA/B,KACGA,EAAE,CAAE,OAAF,CADL,CADD,CAVD,CAvHD,CAfD,CADD;AA0JA","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { __, sprintf } from '@wordpress/i18n';\nimport { useEffect, useState } from '@wordpress/element';\nimport {\n\tButton,\n\tCheckboxControl,\n\tFlex,\n\tFlexItem,\n\tIcon,\n\tModal,\n\tToggleControl,\n} from '@wordpress/components';\nimport { lock as lockIcon, unlock as unlockIcon } from '@wordpress/icons';\nimport { useInstanceId } from '@wordpress/compose';\nimport { useDispatch, useSelect } from '@wordpress/data';\nimport { getBlockType } from '@wordpress/blocks';\n\n/**\n * Internal dependencies\n */\nimport useBlockLock from './use-block-lock';\nimport useBlockDisplayInformation from '../use-block-display-information';\nimport { store as blockEditorStore } from '../../store';\n\n// Entity based blocks which allow edit locking\nconst ALLOWS_EDIT_LOCKING = [ 'core/block', 'core/navigation' ];\n\nfunction getTemplateLockValue( lock ) {\n\t// Prevents all operations.\n\tif ( lock.remove && lock.move ) {\n\t\treturn 'all';\n\t}\n\n\t// Prevents inserting or removing blocks, but allows moving existing blocks.\n\tif ( lock.remove && ! lock.move ) {\n\t\treturn 'insert';\n\t}\n\n\treturn false;\n}\n\nexport default function BlockLockModal( { clientId, onClose } ) {\n\tconst [ lock, setLock ] = useState( { move: false, remove: false } );\n\tconst { canEdit, canMove, canRemove } = useBlockLock( clientId );\n\tconst { allowsEditLocking, templateLock, hasTemplateLock } = useSelect(\n\t\t( select ) => {\n\t\t\tconst { getBlockName, getBlockAttributes } =\n\t\t\t\tselect( blockEditorStore );\n\t\t\tconst blockName = getBlockName( clientId );\n\t\t\tconst blockType = getBlockType( blockName );\n\n\t\t\treturn {\n\t\t\t\tallowsEditLocking: ALLOWS_EDIT_LOCKING.includes( blockName ),\n\t\t\t\ttemplateLock: getBlockAttributes( clientId )?.templateLock,\n\t\t\t\thasTemplateLock: !! blockType?.attributes?.templateLock,\n\t\t\t};\n\t\t},\n\t\t[ clientId ]\n\t);\n\tconst [ applyTemplateLock, setApplyTemplateLock ] = useState(\n\t\t!! templateLock\n\t);\n\tconst { updateBlockAttributes } = useDispatch( blockEditorStore );\n\tconst blockInformation = useBlockDisplayInformation( clientId );\n\tconst instanceId = useInstanceId(\n\t\tBlockLockModal,\n\t\t'block-editor-block-lock-modal__options-title'\n\t);\n\n\tuseEffect( () => {\n\t\tsetLock( {\n\t\t\tmove: ! canMove,\n\t\t\tremove: ! canRemove,\n\t\t\t...( allowsEditLocking ? { edit: ! canEdit } : {} ),\n\t\t} );\n\t}, [ canEdit, canMove, canRemove, allowsEditLocking ] );\n\n\tconst isAllChecked = Object.values( lock ).every( Boolean );\n\tconst isMixed = Object.values( lock ).some( Boolean ) && ! isAllChecked;\n\n\treturn (\n\t\t<Modal\n\t\t\ttitle={ sprintf(\n\t\t\t\t/* translators: %s: Name of the block. */\n\t\t\t\t__( 'Lock %s' ),\n\t\t\t\tblockInformation.title\n\t\t\t) }\n\t\t\toverlayClassName=\"block-editor-block-lock-modal\"\n\t\t\tcloseLabel={ __( 'Close' ) }\n\t\t\tonRequestClose={ onClose }\n\t\t>\n\t\t\t<p>\n\t\t\t\t{ __(\n\t\t\t\t\t'Choose specific attributes to restrict or lock all available options.'\n\t\t\t\t) }\n\t\t\t</p>\n\t\t\t<form\n\t\t\t\tonSubmit={ ( event ) => {\n\t\t\t\t\tevent.preventDefault();\n\t\t\t\t\tupdateBlockAttributes( [ clientId ], {\n\t\t\t\t\t\tlock,\n\t\t\t\t\t\ttemplateLock: applyTemplateLock\n\t\t\t\t\t\t\t? getTemplateLockValue( lock )\n\t\t\t\t\t\t\t: undefined,\n\t\t\t\t\t} );\n\t\t\t\t\tonClose();\n\t\t\t\t} }\n\t\t\t>\n\t\t\t\t<div\n\t\t\t\t\trole=\"group\"\n\t\t\t\t\taria-labelledby={ instanceId }\n\t\t\t\t\tclassName=\"block-editor-block-lock-modal__options\"\n\t\t\t\t>\n\t\t\t\t\t<CheckboxControl\n\t\t\t\t\t\tclassName=\"block-editor-block-lock-modal__options-title\"\n\t\t\t\t\t\tlabel={\n\t\t\t\t\t\t\t<span id={ instanceId }>{ __( 'Lock all' ) }</span>\n\t\t\t\t\t\t}\n\t\t\t\t\t\tchecked={ isAllChecked }\n\t\t\t\t\t\tindeterminate={ isMixed }\n\t\t\t\t\t\tonChange={ ( newValue ) =>\n\t\t\t\t\t\t\tsetLock( {\n\t\t\t\t\t\t\t\tmove: newValue,\n\t\t\t\t\t\t\t\tremove: newValue,\n\t\t\t\t\t\t\t\t...( allowsEditLocking\n\t\t\t\t\t\t\t\t\t? { edit: newValue }\n\t\t\t\t\t\t\t\t\t: {} ),\n\t\t\t\t\t\t\t} )\n\t\t\t\t\t\t}\n\t\t\t\t\t/>\n\t\t\t\t\t<ul className=\"block-editor-block-lock-modal__checklist\">\n\t\t\t\t\t\t{ allowsEditLocking && (\n\t\t\t\t\t\t\t<li className=\"block-editor-block-lock-modal__checklist-item\">\n\t\t\t\t\t\t\t\t<CheckboxControl\n\t\t\t\t\t\t\t\t\tlabel={\n\t\t\t\t\t\t\t\t\t\t<>\n\t\t\t\t\t\t\t\t\t\t\t{ __( 'Restrict editing' ) }\n\t\t\t\t\t\t\t\t\t\t\t<Icon\n\t\t\t\t\t\t\t\t\t\t\t\ticon={\n\t\t\t\t\t\t\t\t\t\t\t\t\tlock.edit\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t? lockIcon\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t: unlockIcon\n\t\t\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t\t\t\t</>\n\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\tchecked={ !! lock.edit }\n\t\t\t\t\t\t\t\t\tonChange={ ( edit ) =>\n\t\t\t\t\t\t\t\t\t\tsetLock( ( prevLock ) => ( {\n\t\t\t\t\t\t\t\t\t\t\t...prevLock,\n\t\t\t\t\t\t\t\t\t\t\tedit,\n\t\t\t\t\t\t\t\t\t\t} ) )\n\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t</li>\n\t\t\t\t\t\t) }\n\t\t\t\t\t\t<li className=\"block-editor-block-lock-modal__checklist-item\">\n\t\t\t\t\t\t\t<CheckboxControl\n\t\t\t\t\t\t\t\tlabel={\n\t\t\t\t\t\t\t\t\t<>\n\t\t\t\t\t\t\t\t\t\t{ __( 'Disable movement' ) }\n\t\t\t\t\t\t\t\t\t\t<Icon\n\t\t\t\t\t\t\t\t\t\t\ticon={\n\t\t\t\t\t\t\t\t\t\t\t\tlock.move\n\t\t\t\t\t\t\t\t\t\t\t\t\t? lockIcon\n\t\t\t\t\t\t\t\t\t\t\t\t\t: unlockIcon\n\t\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t\t\t</>\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\tchecked={ lock.move }\n\t\t\t\t\t\t\t\tonChange={ ( move ) =>\n\t\t\t\t\t\t\t\t\tsetLock( ( prevLock ) => ( {\n\t\t\t\t\t\t\t\t\t\t...prevLock,\n\t\t\t\t\t\t\t\t\t\tmove,\n\t\t\t\t\t\t\t\t\t} ) )\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t</li>\n\t\t\t\t\t\t<li className=\"block-editor-block-lock-modal__checklist-item\">\n\t\t\t\t\t\t\t<CheckboxControl\n\t\t\t\t\t\t\t\tlabel={\n\t\t\t\t\t\t\t\t\t<>\n\t\t\t\t\t\t\t\t\t\t{ __( 'Prevent removal' ) }\n\t\t\t\t\t\t\t\t\t\t<Icon\n\t\t\t\t\t\t\t\t\t\t\ticon={\n\t\t\t\t\t\t\t\t\t\t\t\tlock.remove\n\t\t\t\t\t\t\t\t\t\t\t\t\t? lockIcon\n\t\t\t\t\t\t\t\t\t\t\t\t\t: unlockIcon\n\t\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t\t\t</>\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\tchecked={ lock.remove }\n\t\t\t\t\t\t\t\tonChange={ ( remove ) =>\n\t\t\t\t\t\t\t\t\tsetLock( ( prevLock ) => ( {\n\t\t\t\t\t\t\t\t\t\t...prevLock,\n\t\t\t\t\t\t\t\t\t\tremove,\n\t\t\t\t\t\t\t\t\t} ) )\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t</li>\n\t\t\t\t\t</ul>\n\t\t\t\t\t{ hasTemplateLock && (\n\t\t\t\t\t\t<ToggleControl\n\t\t\t\t\t\t\tclassName=\"block-editor-block-lock-modal__template-lock\"\n\t\t\t\t\t\t\tlabel={ __( 'Apply to all blocks inside' ) }\n\t\t\t\t\t\t\tchecked={ applyTemplateLock }\n\t\t\t\t\t\t\tdisabled={ lock.move && ! lock.remove }\n\t\t\t\t\t\t\tonChange={ () =>\n\t\t\t\t\t\t\t\tsetApplyTemplateLock( ! applyTemplateLock )\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t/>\n\t\t\t\t\t) }\n\t\t\t\t</div>\n\t\t\t\t<Flex\n\t\t\t\t\tclassName=\"block-editor-block-lock-modal__actions\"\n\t\t\t\t\tjustify=\"flex-end\"\n\t\t\t\t\texpanded={ false }\n\t\t\t\t>\n\t\t\t\t\t<FlexItem>\n\t\t\t\t\t\t<Button variant=\"tertiary\" onClick={ onClose }>\n\t\t\t\t\t\t\t{ __( 'Cancel' ) }\n\t\t\t\t\t\t</Button>\n\t\t\t\t\t</FlexItem>\n\t\t\t\t\t<FlexItem>\n\t\t\t\t\t\t<Button variant=\"primary\" type=\"submit\">\n\t\t\t\t\t\t\t{ __( 'Apply' ) }\n\t\t\t\t\t\t</Button>\n\t\t\t\t\t</FlexItem>\n\t\t\t\t</Flex>\n\t\t\t</form>\n\t\t</Modal>\n\t);\n}\n"]}
|
|
@@ -32,7 +32,7 @@ export default function BlockParentSelector() {
|
|
|
32
32
|
const {
|
|
33
33
|
firstParentClientId,
|
|
34
34
|
shouldHide,
|
|
35
|
-
|
|
35
|
+
isDistractionFree
|
|
36
36
|
} = useSelect(select => {
|
|
37
37
|
const {
|
|
38
38
|
getBlockName,
|
|
@@ -54,7 +54,7 @@ export default function BlockParentSelector() {
|
|
|
54
54
|
return {
|
|
55
55
|
firstParentClientId: _firstParentClientId,
|
|
56
56
|
shouldHide: !hasBlockSupport(_parentBlockType, '__experimentalParentSelector', true),
|
|
57
|
-
|
|
57
|
+
isDistractionFree: settings.isDistractionFree
|
|
58
58
|
};
|
|
59
59
|
}, []);
|
|
60
60
|
const blockInformation = useBlockDisplayInformation(firstParentClientId); // Allows highlighting the parent block outline when focusing or hovering
|
|
@@ -67,7 +67,7 @@ export default function BlockParentSelector() {
|
|
|
67
67
|
ref: nodeRef,
|
|
68
68
|
|
|
69
69
|
onChange(isFocused) {
|
|
70
|
-
if (isFocused &&
|
|
70
|
+
if (isFocused && isDistractionFree) {
|
|
71
71
|
return;
|
|
72
72
|
}
|
|
73
73
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["@wordpress/block-editor/src/components/block-parent-selector/index.js"],"names":["getBlockType","store","blocksStore","ToolbarButton","useSelect","useDispatch","__","sprintf","useRef","useBlockDisplayInformation","BlockIcon","useShowMoversGestures","blockEditorStore","BlockParentSelector","selectBlock","toggleBlockHighlight","firstParentClientId","shouldHide","
|
|
1
|
+
{"version":3,"sources":["@wordpress/block-editor/src/components/block-parent-selector/index.js"],"names":["getBlockType","store","blocksStore","ToolbarButton","useSelect","useDispatch","__","sprintf","useRef","useBlockDisplayInformation","BlockIcon","useShowMoversGestures","blockEditorStore","BlockParentSelector","selectBlock","toggleBlockHighlight","firstParentClientId","shouldHide","isDistractionFree","select","getBlockName","getBlockParents","getSelectedBlockClientId","getSettings","hasBlockSupport","selectedBlockClientId","parents","_firstParentClientId","length","parentBlockName","_parentBlockType","settings","blockInformation","nodeRef","gestures","showMoversGestures","ref","onChange","isFocused","undefined","title","icon"],"mappings":";;;AAAA;AACA;AACA;AACA,SAASA,YAAT,EAAuBC,KAAK,IAAIC,WAAhC,QAAmD,mBAAnD;AACA,SAASC,aAAT,QAA8B,uBAA9B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AEa,QAAQ,CAACb;AAPtB,KAAP;AASA,GAxBsE,EAyBvE,EAzBuE,CAAxE;AA2BA,QAAMc,gBAAgB,GAAGvB,0BAA0B,CAAEO,mBAAF,CAAnD,CA9B6C,CAgC7C;AACA;;AACA,QAAMiB,OAAO,GAAGzB,MAAM,EAAtB;AACA,QAAM;AAAE0B,IAAAA,QAAQ,EAAEC;AAAZ,MAAmCxB,qBAAqB,CAAE;AAC/DyB,IAAAA,GAAG,EAAEH,OAD0D;;AAE/DI,IAAAA,QAAQ,CAAEC,SAAF,EAAc;AACrB,UAAKA,SAAS,IAAIpB,iBAAlB,EAAsC;AACrC;AACA;;AACDH,MAAAA,oBAAoB,CAAEC,mBAAF,EAAuBsB,SAAvB,CAApB;AACA;;AAP8D,GAAF,CAA9D;;AAUA,MAAKrB,UAAU,IAAID,mBAAmB,KAAKuB,SAA3C,EAAuD;AACtD,WAAO,IAAP;AACA;;AAED,SACC;AACC,IAAA,SAAS,EAAC,oCADX;AAEC,IAAA,GAAG,EAAGvB,mBAFP;AAGC,IAAA,GAAG,EAAGiB;AAHP,KAIME,kBAJN,GAMC,cAAC,aAAD;AACC,IAAA,SAAS,EAAC,4CADX;AAEC,IAAA,OAAO,EAAG,MAAMrB,WAAW,CAAEE,mBAAF,CAF5B;AAGC,IAAA,KAAK,EAAGT,OAAO;AACd;AACAD,IAAAA,EAAE,CAAE,WAAF,CAFY,EAGd0B,gBAHc,aAGdA,gBAHc,uBAGdA,gBAAgB,CAAEQ,KAHJ,CAHhB;AAQC,IAAA,WAAW,MARZ;AASC,IAAA,IAAI,EAAG,cAAC,SAAD;AAAW,MAAA,IAAI,EAAGR,gBAAH,aAAGA,gBAAH,uBAAGA,gBAAgB,CAAES;AAApC;AATR,IAND,CADD;AAoBA","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { getBlockType, store as blocksStore } from '@wordpress/blocks';\nimport { ToolbarButton } from '@wordpress/components';\nimport { useSelect, useDispatch } from '@wordpress/data';\nimport { __, sprintf } from '@wordpress/i18n';\nimport { useRef } from '@wordpress/element';\n\n/**\n * Internal dependencies\n */\nimport useBlockDisplayInformation from '../use-block-display-information';\nimport BlockIcon from '../block-icon';\nimport { useShowMoversGestures } from '../block-toolbar/utils';\nimport { store as blockEditorStore } from '../../store';\n\n/**\n * Block parent selector component, displaying the hierarchy of the\n * current block selection as a single icon to \"go up\" a level.\n *\n * @return {WPComponent} Parent block selector.\n */\nexport default function BlockParentSelector() {\n\tconst { selectBlock, toggleBlockHighlight } =\n\t\tuseDispatch( blockEditorStore );\n\tconst { firstParentClientId, shouldHide, isDistractionFree } = useSelect(\n\t\t( select ) => {\n\t\t\tconst {\n\t\t\t\tgetBlockName,\n\t\t\t\tgetBlockParents,\n\t\t\t\tgetSelectedBlockClientId,\n\t\t\t\tgetSettings,\n\t\t\t} = select( blockEditorStore );\n\t\t\tconst { hasBlockSupport } = select( blocksStore );\n\t\t\tconst selectedBlockClientId = getSelectedBlockClientId();\n\t\t\tconst parents = getBlockParents( selectedBlockClientId );\n\t\t\tconst _firstParentClientId = parents[ parents.length - 1 ];\n\t\t\tconst parentBlockName = getBlockName( _firstParentClientId );\n\t\t\tconst _parentBlockType = getBlockType( parentBlockName );\n\t\t\tconst settings = getSettings();\n\t\t\treturn {\n\t\t\t\tfirstParentClientId: _firstParentClientId,\n\t\t\t\tshouldHide: ! hasBlockSupport(\n\t\t\t\t\t_parentBlockType,\n\t\t\t\t\t'__experimentalParentSelector',\n\t\t\t\t\ttrue\n\t\t\t\t),\n\t\t\t\tisDistractionFree: settings.isDistractionFree,\n\t\t\t};\n\t\t},\n\t\t[]\n\t);\n\tconst blockInformation = useBlockDisplayInformation( firstParentClientId );\n\n\t// Allows highlighting the parent block outline when focusing or hovering\n\t// the parent block selector within the child.\n\tconst nodeRef = useRef();\n\tconst { gestures: showMoversGestures } = useShowMoversGestures( {\n\t\tref: nodeRef,\n\t\tonChange( isFocused ) {\n\t\t\tif ( isFocused && isDistractionFree ) {\n\t\t\t\treturn;\n\t\t\t}\n\t\t\ttoggleBlockHighlight( firstParentClientId, isFocused );\n\t\t},\n\t} );\n\n\tif ( shouldHide || firstParentClientId === undefined ) {\n\t\treturn null;\n\t}\n\n\treturn (\n\t\t<div\n\t\t\tclassName=\"block-editor-block-parent-selector\"\n\t\t\tkey={ firstParentClientId }\n\t\t\tref={ nodeRef }\n\t\t\t{ ...showMoversGestures }\n\t\t>\n\t\t\t<ToolbarButton\n\t\t\t\tclassName=\"block-editor-block-parent-selector__button\"\n\t\t\t\tonClick={ () => selectBlock( firstParentClientId ) }\n\t\t\t\tlabel={ sprintf(\n\t\t\t\t\t/* translators: %s: Name of the block's parent. */\n\t\t\t\t\t__( 'Select %s' ),\n\t\t\t\t\tblockInformation?.title\n\t\t\t\t) }\n\t\t\t\tshowTooltip\n\t\t\t\ticon={ <BlockIcon icon={ blockInformation?.icon } /> }\n\t\t\t/>\n\t\t</div>\n\t);\n}\n"]}
|
|
@@ -29,7 +29,8 @@ function BlockPattern(_ref) {
|
|
|
29
29
|
const descriptionId = `block-editor-block-patterns-list__item-description-${instanceId}`;
|
|
30
30
|
return createElement(InserterDraggableBlocks, {
|
|
31
31
|
isEnabled: isDraggable,
|
|
32
|
-
blocks: blocks
|
|
32
|
+
blocks: blocks,
|
|
33
|
+
isPattern: !!pattern
|
|
33
34
|
}, _ref2 => {
|
|
34
35
|
let {
|
|
35
36
|
draggable,
|
|
@@ -38,8 +39,6 @@ function BlockPattern(_ref) {
|
|
|
38
39
|
} = _ref2;
|
|
39
40
|
return createElement("div", {
|
|
40
41
|
className: "block-editor-block-patterns-list__list-item",
|
|
41
|
-
"aria-label": pattern.title,
|
|
42
|
-
"aria-describedby": pattern.description ? descriptionId : undefined,
|
|
43
42
|
draggable: draggable,
|
|
44
43
|
onDragStart: onDragStart,
|
|
45
44
|
onDragEnd: onDragEnd
|
|
@@ -48,7 +47,9 @@ function BlockPattern(_ref) {
|
|
|
48
47
|
as: "div"
|
|
49
48
|
}, composite, {
|
|
50
49
|
className: "block-editor-block-patterns-list__item",
|
|
51
|
-
onClick: () => onClick(pattern, blocks)
|
|
50
|
+
onClick: () => onClick(pattern, blocks),
|
|
51
|
+
"aria-label": pattern.title,
|
|
52
|
+
"aria-describedby": pattern.description ? descriptionId : undefined
|
|
52
53
|
}), createElement(BlockPreview, {
|
|
53
54
|
blocks: blocks,
|
|
54
55
|
viewportWidth: viewportWidth
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["@wordpress/block-editor/src/components/block-patterns-list/index.js"],"names":["VisuallyHidden","__unstableComposite","Composite","__unstableUseCompositeState","useCompositeState","__unstableCompositeItem","CompositeItem","useInstanceId","__","BlockPreview","InserterDraggableBlocks","BlockPattern","isDraggable","pattern","onClick","composite","blocks","viewportWidth","instanceId","descriptionId","draggable","onDragStart","onDragEnd","title","description","undefined","BlockPatternPlaceholder","BlockPatternList","blockPatterns","shownPatterns","onClickPattern","orientation","label","map","isShown","includes","name"],"mappings":";;;AAAA;AACA;AACA;AACA,SACCA,cADD,EAECC,mBAAmB,IAAIC,SAFxB,EAGCC,2BAA2B,IAAIC,iBAHhC,EAICC,uBAAuB,IAAIC,aAJ5B,QAKO,uBALP;AAMA,SAASC,aAAT,QAA8B,oBAA9B;AACA,SAASC,EAAT,QAAmB,iBAAnB;AAEA;AACA;AACA;;AACA,OAAOC,YAAP,MAAyB,kBAAzB;AACA,OAAOC,uBAAP,MAAoC,8BAApC;;AAEA,SAASC,YAAT,OAAsE;AAAA,MAA/C;AAAEC,IAAAA,WAAF;AAAeC,IAAAA,OAAf;AAAwBC,IAAAA,OAAxB;AAAiCC,IAAAA;AAAjC,GAA+C;AACrE,QAAM;AAAEC,IAAAA,MAAF;AAAUC,IAAAA;AAAV,MAA4BJ,OAAlC;AACA,QAAMK,UAAU,GAAGX,aAAa,CAAEI,YAAF,CAAhC;AACA,QAAMQ,aAAa,GAAI,sDAAsDD,UAAY,EAAzF;AAEA,SACC,cAAC,uBAAD;
|
|
1
|
+
{"version":3,"sources":["@wordpress/block-editor/src/components/block-patterns-list/index.js"],"names":["VisuallyHidden","__unstableComposite","Composite","__unstableUseCompositeState","useCompositeState","__unstableCompositeItem","CompositeItem","useInstanceId","__","BlockPreview","InserterDraggableBlocks","BlockPattern","isDraggable","pattern","onClick","composite","blocks","viewportWidth","instanceId","descriptionId","draggable","onDragStart","onDragEnd","title","description","undefined","BlockPatternPlaceholder","BlockPatternList","blockPatterns","shownPatterns","onClickPattern","orientation","label","map","isShown","includes","name"],"mappings":";;;AAAA;AACA;AACA;AACA,SACCA,cADD,EAECC,mBAAmB,IAAIC,SAFxB,EAGCC,2BAA2B,IAAIC,iBAHhC,EAICC,uBAAuB,IAAIC,aAJ5B,QAKO,uBALP;AAMA,SAASC,aAAT,QAA8B,oBAA9B;AACA,SAASC,EAAT,QAAmB,iBAAnB;AAEA;AACA;AACA;;AACA,OAAOC,YAAP,MAAyB,kBAAzB;AACA,OAAOC,uBAAP,MAAoC,8BAApC;;AAEA,SAASC,YAAT,OAAsE;AAAA,MAA/C;AAAEC,IAAAA,WAAF;AAAeC,IAAAA,OAAf;AAAwBC,IAAAA,OAAxB;AAAiCC,IAAAA;AAAjC,GAA+C;AACrE,QAAM;AAAEC,IAAAA,MAAF;AAAUC,IAAAA;AAAV,MAA4BJ,OAAlC;AACA,QAAMK,UAAU,GAAGX,aAAa,CAAEI,YAAF,CAAhC;AACA,QAAMQ,aAAa,GAAI,sDAAsDD,UAAY,EAAzF;AAEA,SACC,cAAC,uBAAD;AACC,IAAA,SAAS,EAAGN,WADb;AAEC,IAAA,MAAM,EAAGI,MAFV;AAGC,IAAA,SAAS,EAAG,CAAC,CAAEH;AAHhB,KAKG;AAAA,QAAE;AAAEO,MAAAA,SAAF;AAAaC,MAAAA,WAAb;AAA0BC,MAAAA;AAA1B,KAAF;AAAA,WACD;AACC,MAAA,SAAS,EAAC,6CADX;AAEC,MAAA,SAAS,EAAGF,SAFb;AAGC,MAAA,WAAW,EAAGC,WAHf;AAIC,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AAO,GACb,cAAC,YAAD;AACC,MAAA,GAAG,EAAGrB,OAAO,CAACuB,IADf;AAEC,MAAA,OAAO,EAAGvB,OAFX;AAGC,MAAA,OAAO,EAAGiB,cAHX;AAIC,MAAA,WAAW,EAAGlB,WAJf;AAKC,MAAA,SAAS,EAAGG;AALb,MADa,GASb,cAAC,uBAAD;AAAyB,MAAA,GAAG,EAAGF,OAAO,CAACuB;AAAvC,MATD;AAWA,GAbC,CANH,CADD;AAuBA;;AAED,eAAeT,gBAAf","sourcesContent":["/**\n * WordPress dependencies\n */\nimport {\n\tVisuallyHidden,\n\t__unstableComposite as Composite,\n\t__unstableUseCompositeState as useCompositeState,\n\t__unstableCompositeItem as CompositeItem,\n} from '@wordpress/components';\nimport { useInstanceId } from '@wordpress/compose';\nimport { __ } from '@wordpress/i18n';\n\n/**\n * Internal dependencies\n */\nimport BlockPreview from '../block-preview';\nimport InserterDraggableBlocks from '../inserter-draggable-blocks';\n\nfunction BlockPattern( { isDraggable, pattern, onClick, composite } ) {\n\tconst { blocks, viewportWidth } = pattern;\n\tconst instanceId = useInstanceId( BlockPattern );\n\tconst descriptionId = `block-editor-block-patterns-list__item-description-${ instanceId }`;\n\n\treturn (\n\t\t<InserterDraggableBlocks\n\t\t\tisEnabled={ isDraggable }\n\t\t\tblocks={ blocks }\n\t\t\tisPattern={ !! pattern }\n\t\t>\n\t\t\t{ ( { draggable, onDragStart, onDragEnd } ) => (\n\t\t\t\t<div\n\t\t\t\t\tclassName=\"block-editor-block-patterns-list__list-item\"\n\t\t\t\t\tdraggable={ draggable }\n\t\t\t\t\tonDragStart={ onDragStart }\n\t\t\t\t\tonDragEnd={ onDragEnd }\n\t\t\t\t>\n\t\t\t\t\t<CompositeItem\n\t\t\t\t\t\trole=\"option\"\n\t\t\t\t\t\tas=\"div\"\n\t\t\t\t\t\t{ ...composite }\n\t\t\t\t\t\tclassName=\"block-editor-block-patterns-list__item\"\n\t\t\t\t\t\tonClick={ () => onClick( pattern, blocks ) }\n\t\t\t\t\t\taria-label={ pattern.title }\n\t\t\t\t\t\taria-describedby={\n\t\t\t\t\t\t\tpattern.description ? descriptionId : undefined\n\t\t\t\t\t\t}\n\t\t\t\t\t>\n\t\t\t\t\t\t<BlockPreview\n\t\t\t\t\t\t\tblocks={ blocks }\n\t\t\t\t\t\t\tviewportWidth={ viewportWidth }\n\t\t\t\t\t\t/>\n\t\t\t\t\t\t<div className=\"block-editor-block-patterns-list__item-title\">\n\t\t\t\t\t\t\t{ pattern.title }\n\t\t\t\t\t\t</div>\n\t\t\t\t\t\t{ !! pattern.description && (\n\t\t\t\t\t\t\t<VisuallyHidden id={ descriptionId }>\n\t\t\t\t\t\t\t\t{ pattern.description }\n\t\t\t\t\t\t\t</VisuallyHidden>\n\t\t\t\t\t\t) }\n\t\t\t\t\t</CompositeItem>\n\t\t\t\t</div>\n\t\t\t) }\n\t\t</InserterDraggableBlocks>\n\t);\n}\n\nfunction BlockPatternPlaceholder() {\n\treturn (\n\t\t<div className=\"block-editor-block-patterns-list__item is-placeholder\" />\n\t);\n}\n\nfunction BlockPatternList( {\n\tisDraggable,\n\tblockPatterns,\n\tshownPatterns,\n\tonClickPattern,\n\torientation,\n\tlabel = __( 'Block Patterns' ),\n} ) {\n\tconst composite = useCompositeState( { orientation } );\n\treturn (\n\t\t<Composite\n\t\t\t{ ...composite }\n\t\t\trole=\"listbox\"\n\t\t\tclassName=\"block-editor-block-patterns-list\"\n\t\t\taria-label={ label }\n\t\t>\n\t\t\t{ blockPatterns.map( ( pattern ) => {\n\t\t\t\tconst isShown = shownPatterns.includes( pattern );\n\t\t\t\treturn isShown ? (\n\t\t\t\t\t<BlockPattern\n\t\t\t\t\t\tkey={ pattern.name }\n\t\t\t\t\t\tpattern={ pattern }\n\t\t\t\t\t\tonClick={ onClickPattern }\n\t\t\t\t\t\tisDraggable={ isDraggable }\n\t\t\t\t\t\tcomposite={ composite }\n\t\t\t\t\t/>\n\t\t\t\t) : (\n\t\t\t\t\t<BlockPatternPlaceholder key={ pattern.name } />\n\t\t\t\t);\n\t\t\t} ) }\n\t\t</Composite>\n\t);\n}\n\nexport default BlockPatternList;\n"]}
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
import { createElement } from "@wordpress/element";
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* WordPress dependencies
|
|
5
|
+
*/
|
|
6
|
+
import { useSelect } from '@wordpress/data';
|
|
7
|
+
import { useReducedMotion } from '@wordpress/compose';
|
|
8
|
+
import { __unstableMotion as motion } from '@wordpress/components';
|
|
9
|
+
/**
|
|
10
|
+
* Internal dependencies
|
|
11
|
+
*/
|
|
12
|
+
|
|
13
|
+
import { store as blockEditorStore } from '../../store';
|
|
14
|
+
import BlockPopover from './index';
|
|
15
|
+
const animateVariants = {
|
|
16
|
+
hide: {
|
|
17
|
+
opacity: 0,
|
|
18
|
+
scaleY: 0.75
|
|
19
|
+
},
|
|
20
|
+
show: {
|
|
21
|
+
opacity: 1,
|
|
22
|
+
scaleY: 1
|
|
23
|
+
},
|
|
24
|
+
exit: {
|
|
25
|
+
opacity: 0,
|
|
26
|
+
scaleY: 0.9
|
|
27
|
+
}
|
|
28
|
+
};
|
|
29
|
+
|
|
30
|
+
function BlockDropZonePopover(_ref) {
|
|
31
|
+
let {
|
|
32
|
+
__unstablePopoverSlot,
|
|
33
|
+
__unstableContentRef
|
|
34
|
+
} = _ref;
|
|
35
|
+
const {
|
|
36
|
+
clientId
|
|
37
|
+
} = useSelect(select => {
|
|
38
|
+
const {
|
|
39
|
+
getBlockOrder,
|
|
40
|
+
getBlockInsertionPoint
|
|
41
|
+
} = select(blockEditorStore);
|
|
42
|
+
const insertionPoint = getBlockInsertionPoint();
|
|
43
|
+
const order = getBlockOrder(insertionPoint.rootClientId);
|
|
44
|
+
|
|
45
|
+
if (!order.length) {
|
|
46
|
+
return {};
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
return {
|
|
50
|
+
clientId: order[insertionPoint.index]
|
|
51
|
+
};
|
|
52
|
+
}, []);
|
|
53
|
+
const reducedMotion = useReducedMotion();
|
|
54
|
+
return createElement(BlockPopover, {
|
|
55
|
+
clientId: clientId,
|
|
56
|
+
__unstableCoverTarget: true,
|
|
57
|
+
__unstablePopoverSlot: __unstablePopoverSlot,
|
|
58
|
+
__unstableContentRef: __unstableContentRef,
|
|
59
|
+
className: "block-editor-block-popover__drop-zone"
|
|
60
|
+
}, createElement(motion.div, {
|
|
61
|
+
"data-testid": "block-popover-drop-zone",
|
|
62
|
+
initial: reducedMotion ? animateVariants.show : animateVariants.hide,
|
|
63
|
+
animate: animateVariants.show,
|
|
64
|
+
exit: reducedMotion ? animateVariants.show : animateVariants.exit,
|
|
65
|
+
className: "block-editor-block-popover__drop-zone-foreground"
|
|
66
|
+
}));
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
export default BlockDropZonePopover;
|
|
70
|
+
//# sourceMappingURL=drop-zone.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["@wordpress/block-editor/src/components/block-popover/drop-zone.js"],"names":["useSelect","useReducedMotion","__unstableMotion","motion","store","blockEditorStore","BlockPopover","animateVariants","hide","opacity","scaleY","show","exit","BlockDropZonePopover","__unstablePopoverSlot","__unstableContentRef","clientId","select","getBlockOrder","getBlockInsertionPoint","insertionPoint","order","rootClientId","length","index","reducedMotion"],"mappings":";;AAAA;AACA;AACA;AACA,SAASA,SAAT,QAA0B,iBAA1B;AACA,SAASC,gBAAT,QAAiC,oBAAjC;AACA,SAASC,gBAAgB,IAAIC,MAA7B,QAA2C,uBAA3C;AAEA;AACA;AACA;;AACA,SAASC,KAAK,IAAIC,gBAAlB,QAA0C,aAA1C;AACA,OAAOC,YAAP,MAAyB,SAAzB;AAEA,MAAMC,eAAe,GAAG;AACvBC,EAAAA,IAAI,EAAE;AAAEC,IAAAA,OAAO,EAAE,CAAX;AAAcC,IAAAA,MAAM,EAAE;AAAtB,GADiB;AAEvBC,EAAAA,IAAI,EAAE;A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C;AATX,IAPD,CADD;AAqBA;;AAED,eAAeC,oBAAf","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { useSelect } from '@wordpress/data';\nimport { useReducedMotion } from '@wordpress/compose';\nimport { __unstableMotion as motion } from '@wordpress/components';\n\n/**\n * Internal dependencies\n */\nimport { store as blockEditorStore } from '../../store';\nimport BlockPopover from './index';\n\nconst animateVariants = {\n\thide: { opacity: 0, scaleY: 0.75 },\n\tshow: { opacity: 1, scaleY: 1 },\n\texit: { opacity: 0, scaleY: 0.9 },\n};\n\nfunction BlockDropZonePopover( {\n\t__unstablePopoverSlot,\n\t__unstableContentRef,\n} ) {\n\tconst { clientId } = useSelect( ( select ) => {\n\t\tconst { getBlockOrder, getBlockInsertionPoint } =\n\t\t\tselect( blockEditorStore );\n\t\tconst insertionPoint = getBlockInsertionPoint();\n\t\tconst order = getBlockOrder( insertionPoint.rootClientId );\n\n\t\tif ( ! order.length ) {\n\t\t\treturn {};\n\t\t}\n\n\t\treturn {\n\t\t\tclientId: order[ insertionPoint.index ],\n\t\t};\n\t}, [] );\n\tconst reducedMotion = useReducedMotion();\n\n\treturn (\n\t\t<BlockPopover\n\t\t\tclientId={ clientId }\n\t\t\t__unstableCoverTarget\n\t\t\t__unstablePopoverSlot={ __unstablePopoverSlot }\n\t\t\t__unstableContentRef={ __unstableContentRef }\n\t\t\tclassName=\"block-editor-block-popover__drop-zone\"\n\t\t>\n\t\t\t<motion.div\n\t\t\t\tdata-testid=\"block-popover-drop-zone\"\n\t\t\t\tinitial={\n\t\t\t\t\treducedMotion ? animateVariants.show : animateVariants.hide\n\t\t\t\t}\n\t\t\t\tanimate={ animateVariants.show }\n\t\t\t\texit={\n\t\t\t\t\treducedMotion ? animateVariants.show : animateVariants.exit\n\t\t\t\t}\n\t\t\t\tclassName=\"block-editor-block-popover__drop-zone-foreground\"\n\t\t\t/>\n\t\t</BlockPopover>\n\t);\n}\n\nexport default BlockDropZonePopover;\n"]}
|
|
@@ -213,7 +213,8 @@ function BlockPopoverInbetween(_ref) {
|
|
|
213
213
|
className: classnames('block-editor-block-popover', 'block-editor-block-popover__inbetween', props.className),
|
|
214
214
|
resize: false,
|
|
215
215
|
flip: false,
|
|
216
|
-
placement: "bottom-start"
|
|
216
|
+
placement: "bottom-start",
|
|
217
|
+
variant: "unstyled"
|
|
217
218
|
}), createElement("div", {
|
|
218
219
|
className: "block-editor-block-popover__inbetween-container",
|
|
219
220
|
style: style
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["@wordpress/block-editor/src/components/block-popover/inbetween.js"],"names":["classnames","useSelect","useMemo","createContext","useReducer","useLayoutEffect","Popover","isRTL","store","blockEditorStore","__unstableUseBlockElement","useBlockElement","usePopoverScroll","MAX_POPOVER_RECOMPUTE_COUNTER","Number","MAX_SAFE_INTEGER","InsertionPointOpenRef","BlockPopoverInbetween","previousClientId","nextClientId","children","__unstablePopoverSlot","__unstableContentRef","props","popoverRecomputeCounter","forcePopoverRecompute","s","orientation","rootClientId","isVisible","select","getBlockListSettings","getBlockRootClientId","isBlockVisible","_rootClientId","previousElement","nextElement","isVertical","style","previousRect","getBoundingClientRect","nextRect","width","height","top","bottom","left","right","popoverAnchor","undefined","ownerDocument","window","DOMRect","popoverScrollRef","observer","MutationObserver","observe","attributes","disconnect","defaultView","addEventListener","removeEventListener","className"],"mappings":";;;AAAA;AACA;AACA;AACA,OAAOA,UAAP,MAAuB,YAAvB;AAEA;AACA;AACA;;AACA,SAASC,SAAT,QAA0B,iBAA1B;AACA,SACCC,OADD,EAECC,aAFD,EAGCC,UAHD,EAICC,eAJD,QAKO,oBALP;AAMA,SAASC,OAAT,QAAwB,uBAAxB;AACA,SAASC,KAAT,QAAsB,iBAAtB;AAEA;AACA;AACA;;AACA,SAASC,KAAK,IAAIC,gBAAlB,QAA0C,aAA1C;AACA,SAASC,yBAAyB,IAAIC,eAAtC,QAA6D,8CAA7D;AACA,OAAOC,gBAAP,MAA6B,sBAA7B;AAEA,MAAMC,6BAA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,eAAF,IAAqB,CAAEC,WAAzB,IAA0C,CAAEP,SAAjD,EAA6D;AAC5D,WAAO,IAAP;AACA;AAED;AACA;AACA;AACA;AACA;AACA;AACA;;;AACA,SACC,cAAC,OAAD;AACC,IAAA,GAAG,EAAGwB,gBADP;AAEC,IAAA,OAAO,EAAG,KAFX;AAGC,IAAA,MAAM,EAAGL,aAHV;AAIC,IAAA,YAAY,EAAG,KAJhB,CAKC;AACA;AAND;AAOC,IAAA,kBAAkB,EAAG3B,qBAAqB,IAAI,IAP/C,CAQC;AACA;AATD;AAUC,IAAA,GAAG,EAAGF,YAAY,GAAG,IAAf,GAAsBS;AAV7B,KAWML,KAXN;AAYC,IAAA,SAAS,EAAGvB,UAAU,CACrB,4BADqB,EAErB,uCAFqB,EAGrBuB,KAAK,CAACuC,SAHe,CAZvB;AAiBC,IAAA,MAAM,EAAG,KAjBV;AAkBC,IAAA,IAAI,EAAG,KAlBR;AAmBC,IAAA,SAAS,EAAC;AAnBX,MAqBC;AACC,IAAA,SAAS,EAAC,iDADX;AAEC,IAAA,KAAK,EAAGxB;AAFT,KAIGlB,QAJH,CArBD,CADD;AA8BA;AACA;;AAED,eAAeH,qBAAf","sourcesContent":["/**\n * External dependencies\n */\nimport classnames from 'classnames';\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\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\tconst style = 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 {};\n\t\t}\n\n\t\tconst previousRect = previousElement\n\t\t\t? previousElement.getBoundingClientRect()\n\t\t\t: null;\n\t\tconst nextRect = nextElement\n\t\t\t? nextElement.getBoundingClientRect()\n\t\t\t: null;\n\n\t\tif ( isVertical ) {\n\t\t\treturn {\n\t\t\t\twidth: previousRect ? previousRect.width : nextRect.width,\n\t\t\t\theight:\n\t\t\t\t\tnextRect && previousRect\n\t\t\t\t\t\t? nextRect.top - previousRect.bottom\n\t\t\t\t\t\t: 0,\n\t\t\t};\n\t\t}\n\n\t\tlet width = 0;\n\t\tif ( previousRect && nextRect ) {\n\t\t\twidth = isRTL()\n\t\t\t\t? previousRect.left - nextRect.right\n\t\t\t\t: nextRect.left - previousRect.right;\n\t\t}\n\n\t\treturn {\n\t\t\twidth,\n\t\t\theight: previousRect ? previousRect.height : nextRect.height,\n\t\t};\n\t}, [\n\t\tpreviousElement,\n\t\tnextElement,\n\t\tisVertical,\n\t\tpopoverRecomputeCounter,\n\t\tisVisible,\n\t] );\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 { ownerDocument } = previousElement || nextElement;\n\n\t\treturn {\n\t\t\townerDocument,\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\n\t\t\t\tif ( isVertical ) {\n\t\t\t\t\t// vertical\n\t\t\t\t\ttop = previousRect ? previousRect.bottom : nextRect.top;\n\n\t\t\t\t\tif ( isRTL() ) {\n\t\t\t\t\t\t// vertical, rtl\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.right;\n\t\t\t\t\t} else {\n\t\t\t\t\t\t// vertical, ltr\n\t\t\t\t\t\tleft = previousRect ? previousRect.left : nextRect.left;\n\t\t\t\t\t}\n\t\t\t\t} else {\n\t\t\t\t\ttop = previousRect ? previousRect.top : nextRect.top;\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 = previousRect\n\t\t\t\t\t\t\t? previousRect.left\n\t\t\t\t\t\t\t: nextRect.right;\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}\n\t\t\t\t}\n\n\t\t\t\treturn new window.DOMRect( left, top, 0, 0 );\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] );\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 || null }\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={ classnames(\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=\"bottom-start\"\n\t\t>\n\t\t\t<div\n\t\t\t\tclassName=\"block-editor-block-popover__inbetween-container\"\n\t\t\t\tstyle={ style }\n\t\t\t>\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"]}
|
|
1
|
+
{"version":3,"sources":["@wordpress/block-editor/src/components/block-popover/inbetween.js"],"names":["classnames","useSelect","useMemo","createContext","useReducer","useLayoutEffect","Popover","isRTL","store","blockEditorStore","__unstableUseBlockElement","useBlockElement","usePopoverScroll","MAX_POPOVER_RECOMPUTE_COUNTER","Number","MAX_SAFE_INTEGER","InsertionPointOpenRef","BlockPopoverInbetween","previousClientId","nextClientId","children","__unstablePopoverSlot","__unstableContentRef","props","popoverRecomputeCounter","forcePopoverRecompute","s","orientation","rootClientId","isVisible","select","getBlockListSettings","getBlockRootClientId","isBlockVisible","_rootClientId","previousElement","nextElement","isVertical","style","previousRect","getBoundingClientRect","nextRect","width","height","top","bottom","left","right","popoverAnchor","undefined","ownerDocument","window","DOMRect","popoverScrollRef","observer","MutationObserver","observe","attributes","disconnect","defaultView","addEventListener","removeEventListener","className"],"mappings":";;;AAAA;AACA;AACA;AACA,OAAOA,UAAP,MAAuB,YAAvB;AAEA;AACA;AACA;;AACA,SAASC,SAAT,QAA0B,iBAA1B;AACA,SACCC,OADD,EAECC,aAFD,EAGCC,UAHD,EAICC,eAJD,QAKO,oBALP;AAMA,SAASC,OAAT,QAAwB,uBAAxB;AACA,SAASC,KAAT,QAAsB,iBAAtB;AAEA;AACA;AACA;;AACA,SAASC,KAAK,IAAIC,gBAAlB,QAA0C,aAA1C;AACA,SAASC,yBAAyB,IAAIC,eAAtC,QAA6D,8CAA7D;AACA,OAAOC,gBAAP,MAA6B,sBAA7B;AAEA,MAAMC,6BAA6B,GAAGC,MAAM,CAACC,gBAA7C;AAEA,OAAO,MAAMC,qBAAqB,GAAGb,aAAa,EAA3C;;AAEP,SAASc,qBAAT,OAOI;AAAA,MAP4B;AAC/BC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,cAAC,OAAD;AACC,IAAA,GAAG,EAAGwB,gBADP;AAEC,IAAA,OAAO,EAAG,KAFX;AAGC,IAAA,MAAM,EAAGL,aAHV;AAIC,IAAA,YAAY,EAAG,KAJhB,CAKC;AACA;AAND;AAOC,IAAA,kBAAkB,EAAG3B,qBAAqB,IAAI,IAP/C,CAQC;AACA;AATD;AAUC,IAAA,GAAG,EAAGF,YAAY,GAAG,IAAf,GAAsBS;AAV7B,KAWML,KAXN;AAYC,IAAA,SAAS,EAAGvB,UAAU,CACrB,4BADqB,EAErB,uCAFqB,EAGrBuB,KAAK,CAACuC,SAHe,CAZvB;AAiBC,IAAA,MAAM,EAAG,KAjBV;AAkBC,IAAA,IAAI,EAAG,KAlBR;AAmBC,IAAA,SAAS,EAAC,cAnBX;AAoBC,IAAA,OAAO,EAAC;AApBT,MAsBC;AACC,IAAA,SAAS,EAAC,iDADX;AAEC,IAAA,KAAK,EAAGxB;AAFT,KAIGlB,QAJH,CAtBD,CADD;AA+BA;AACA;;AAED,eAAeH,qBAAf","sourcesContent":["/**\n * External dependencies\n */\nimport classnames from 'classnames';\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\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\tconst style = 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 {};\n\t\t}\n\n\t\tconst previousRect = previousElement\n\t\t\t? previousElement.getBoundingClientRect()\n\t\t\t: null;\n\t\tconst nextRect = nextElement\n\t\t\t? nextElement.getBoundingClientRect()\n\t\t\t: null;\n\n\t\tif ( isVertical ) {\n\t\t\treturn {\n\t\t\t\twidth: previousRect ? previousRect.width : nextRect.width,\n\t\t\t\theight:\n\t\t\t\t\tnextRect && previousRect\n\t\t\t\t\t\t? nextRect.top - previousRect.bottom\n\t\t\t\t\t\t: 0,\n\t\t\t};\n\t\t}\n\n\t\tlet width = 0;\n\t\tif ( previousRect && nextRect ) {\n\t\t\twidth = isRTL()\n\t\t\t\t? previousRect.left - nextRect.right\n\t\t\t\t: nextRect.left - previousRect.right;\n\t\t}\n\n\t\treturn {\n\t\t\twidth,\n\t\t\theight: previousRect ? previousRect.height : nextRect.height,\n\t\t};\n\t}, [\n\t\tpreviousElement,\n\t\tnextElement,\n\t\tisVertical,\n\t\tpopoverRecomputeCounter,\n\t\tisVisible,\n\t] );\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 { ownerDocument } = previousElement || nextElement;\n\n\t\treturn {\n\t\t\townerDocument,\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\n\t\t\t\tif ( isVertical ) {\n\t\t\t\t\t// vertical\n\t\t\t\t\ttop = previousRect ? previousRect.bottom : nextRect.top;\n\n\t\t\t\t\tif ( isRTL() ) {\n\t\t\t\t\t\t// vertical, rtl\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.right;\n\t\t\t\t\t} else {\n\t\t\t\t\t\t// vertical, ltr\n\t\t\t\t\t\tleft = previousRect ? previousRect.left : nextRect.left;\n\t\t\t\t\t}\n\t\t\t\t} else {\n\t\t\t\t\ttop = previousRect ? previousRect.top : nextRect.top;\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 = previousRect\n\t\t\t\t\t\t\t? previousRect.left\n\t\t\t\t\t\t\t: nextRect.right;\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}\n\t\t\t\t}\n\n\t\t\t\treturn new window.DOMRect( left, top, 0, 0 );\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] );\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 || null }\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={ classnames(\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=\"bottom-start\"\n\t\t\tvariant=\"unstyled\"\n\t\t>\n\t\t\t<div\n\t\t\t\tclassName=\"block-editor-block-popover__inbetween-container\"\n\t\t\t\tstyle={ style }\n\t\t\t>\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"]}
|
|
@@ -29,6 +29,7 @@ function BlockPopover(_ref, ref) {
|
|
|
29
29
|
__unstableCoverTarget = false,
|
|
30
30
|
__unstablePopoverSlot,
|
|
31
31
|
__unstableContentRef,
|
|
32
|
+
shift = true,
|
|
32
33
|
...props
|
|
33
34
|
} = _ref;
|
|
34
35
|
const selectedElement = useBlockElement(clientId);
|
|
@@ -116,9 +117,10 @@ function BlockPopover(_ref, ref) {
|
|
|
116
117
|
placement: "top-start",
|
|
117
118
|
resize: false,
|
|
118
119
|
flip: false,
|
|
119
|
-
shift:
|
|
120
|
+
shift: shift
|
|
120
121
|
}, props, {
|
|
121
|
-
className: classnames('block-editor-block-popover', props.className)
|
|
122
|
+
className: classnames('block-editor-block-popover', props.className),
|
|
123
|
+
variant: "unstyled"
|
|
122
124
|
}), __unstableCoverTarget && createElement("div", {
|
|
123
125
|
style: style
|
|
124
126
|
}, children), !__unstableCoverTarget && children);
|