@wordpress/block-editor 10.2.0 → 10.3.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 +12 -0
- package/README.md +41 -0
- 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-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 +72 -14
- 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/index.js +2 -1
- 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 +6 -9
- 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 +17 -11
- 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-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 +50 -20
- 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/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/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/index.js +0 -9
- package/build/components/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/menu.js +14 -3
- package/build/components/inserter/menu.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/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/preview-options/index.js +2 -3
- package/build/components/preview-options/index.js.map +1 -1
- package/build/components/spacing-sizes-control/spacing-input-control.js +35 -5
- package/build/components/spacing-sizes-control/spacing-input-control.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/font-size.js +60 -0
- package/build/hooks/font-size.js.map +1 -1
- package/build/hooks/margin.js +6 -5
- package/build/hooks/margin.js.map +1 -1
- package/build/hooks/padding.js +2 -1
- 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 +1 -1
- package/build/hooks/utils.js.map +1 -1
- package/build/store/actions.js +59 -45
- package/build/store/actions.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/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/block-draggable/draggable-chip.js +7 -3
- package/build-module/components/block-draggable/draggable-chip.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 +72 -14
- 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/index.js +2 -1
- 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 +6 -9
- 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 +18 -12
- 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-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 +48 -20
- 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/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/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/index.js +0 -1
- package/build-module/components/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/menu.js +10 -3
- package/build-module/components/inserter/menu.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/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/preview-options/index.js +2 -3
- package/build-module/components/preview-options/index.js.map +1 -1
- package/build-module/components/spacing-sizes-control/spacing-input-control.js +34 -5
- package/build-module/components/spacing-sizes-control/spacing-input-control.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/font-size.js +59 -1
- package/build-module/hooks/font-size.js.map +1 -1
- package/build-module/hooks/margin.js +6 -5
- package/build-module/hooks/margin.js.map +1 -1
- package/build-module/hooks/padding.js +2 -1
- 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 +2 -2
- package/build-module/hooks/utils.js.map +1 -1
- package/build-module/store/actions.js +55 -42
- package/build-module/store/actions.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/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 +243 -144
- package/build-style/style.css +243 -144
- package/package.json +28 -28
- package/src/components/block-breadcrumb/test/index.js +1 -1
- package/src/components/block-draggable/draggable-chip.js +4 -2
- 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 +111 -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/style.scss +0 -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/index.js +2 -1
- package/src/components/block-popover/style.scss +17 -1
- package/src/components/block-preview/auto.js +1 -1
- package/src/components/block-preview/index.js +7 -8
- 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 +25 -11
- 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/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 +42 -17
- package/src/components/block-tools/selected-block-popover.js +14 -1
- package/src/components/button-block-appender/style.scss +4 -2
- package/src/components/color-palette/test/__snapshots__/control.js.snap +32 -52
- 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/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/image-size-control/test/index.js +47 -60
- package/src/components/index.js +0 -1
- 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/menu.js +15 -2
- package/src/components/inserter/style.scss +94 -9
- package/src/components/inserter/test/reusable-blocks-tab.js +6 -6
- package/src/components/inserter-draggable-blocks/index.js +12 -2
- package/src/components/inserter-list-item/style.scss +20 -1
- package/src/components/link-control/test/index.js +1 -1
- package/src/components/list-view/use-list-view-drop-zone.js +4 -18
- 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/spacing-sizes-control/spacing-input-control.js +16 -2
- package/src/components/spacing-sizes-control/style.scss +26 -19
- 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/font-size.js +75 -0
- package/src/hooks/margin.js +5 -4
- package/src/hooks/padding.js +1 -0
- package/src/hooks/style.js +122 -3
- 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 +6 -2
- package/src/store/actions.js +20 -12
- package/src/store/defaults.js +3 -0
- package/src/store/reducer.js +31 -24
- package/src/store/test/actions.js +0 -9
- 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,8 +1,3 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* External dependencies
|
|
3
|
-
*/
|
|
4
|
-
import { without } from 'lodash';
|
|
5
|
-
|
|
6
1
|
/**
|
|
7
2
|
* WordPress dependencies
|
|
8
3
|
*/
|
|
@@ -28,9 +23,11 @@ addFilter(
|
|
|
28
23
|
settings.supports = {
|
|
29
24
|
...settings.supports,
|
|
30
25
|
align: Array.isArray( blockAlign )
|
|
31
|
-
?
|
|
32
|
-
|
|
33
|
-
|
|
26
|
+
? blockAlign.filter(
|
|
27
|
+
( alignment ) =>
|
|
28
|
+
! Object.values(
|
|
29
|
+
WIDE_ALIGNMENTS.alignments
|
|
30
|
+
).includes( alignment )
|
|
34
31
|
)
|
|
35
32
|
: blockAlign,
|
|
36
33
|
alignWide: false,
|
package/src/hooks/font-size.js
CHANGED
|
@@ -5,6 +5,7 @@ import { addFilter } from '@wordpress/hooks';
|
|
|
5
5
|
import { hasBlockSupport } from '@wordpress/blocks';
|
|
6
6
|
import TokenList from '@wordpress/token-list';
|
|
7
7
|
import { createHigherOrderComponent } from '@wordpress/compose';
|
|
8
|
+
import { select } from '@wordpress/data';
|
|
8
9
|
|
|
9
10
|
/**
|
|
10
11
|
* Internal dependencies
|
|
@@ -14,6 +15,7 @@ import {
|
|
|
14
15
|
getFontSizeClass,
|
|
15
16
|
getFontSizeObjectByValue,
|
|
16
17
|
FontSizePicker,
|
|
18
|
+
getComputedFluidTypographyValue,
|
|
17
19
|
} from '../components/font-sizes';
|
|
18
20
|
import { TYPOGRAPHY_SUPPORT_KEY } from './typography';
|
|
19
21
|
import {
|
|
@@ -22,6 +24,7 @@ import {
|
|
|
22
24
|
shouldSkipSerialization,
|
|
23
25
|
} from './utils';
|
|
24
26
|
import useSetting from '../components/use-setting';
|
|
27
|
+
import { store as blockEditorStore } from '../store';
|
|
25
28
|
|
|
26
29
|
export const FONT_SIZE_SUPPORT_KEY = 'typography.fontSize';
|
|
27
30
|
|
|
@@ -282,6 +285,69 @@ export function addTransforms( result, source, index, results ) {
|
|
|
282
285
|
);
|
|
283
286
|
}
|
|
284
287
|
|
|
288
|
+
/**
|
|
289
|
+
* Allow custom font sizes to appear fluid when fluid typography is enabled at
|
|
290
|
+
* the theme level.
|
|
291
|
+
*
|
|
292
|
+
* Adds a custom getEditWrapperProps() callback to all block types that support
|
|
293
|
+
* font sizes. Then, if fluid typography is enabled, this callback will swap any
|
|
294
|
+
* custom font size in style.fontSize with a fluid font size (i.e. one that uses
|
|
295
|
+
* clamp()).
|
|
296
|
+
*
|
|
297
|
+
* It's important that this hook runs after 'core/style/addEditProps' sets
|
|
298
|
+
* style.fontSize as otherwise fontSize will be overwritten.
|
|
299
|
+
*
|
|
300
|
+
* @param {Object} blockType Block settings object.
|
|
301
|
+
*/
|
|
302
|
+
function addEditPropsForFluidCustomFontSizes( blockType ) {
|
|
303
|
+
if (
|
|
304
|
+
! hasBlockSupport( blockType, FONT_SIZE_SUPPORT_KEY ) ||
|
|
305
|
+
shouldSkipSerialization( blockType, TYPOGRAPHY_SUPPORT_KEY, 'fontSize' )
|
|
306
|
+
) {
|
|
307
|
+
return blockType;
|
|
308
|
+
}
|
|
309
|
+
|
|
310
|
+
const existingGetEditWrapperProps = blockType.getEditWrapperProps;
|
|
311
|
+
|
|
312
|
+
blockType.getEditWrapperProps = ( attributes ) => {
|
|
313
|
+
const wrapperProps = existingGetEditWrapperProps
|
|
314
|
+
? existingGetEditWrapperProps( attributes )
|
|
315
|
+
: {};
|
|
316
|
+
|
|
317
|
+
const fontSize = wrapperProps?.style?.fontSize;
|
|
318
|
+
|
|
319
|
+
// TODO: This sucks! We should be using useSetting( 'typography.fluid' )
|
|
320
|
+
// or even useSelect( blockEditorStore ). We can't do either here
|
|
321
|
+
// because getEditWrapperProps is a plain JavaScript function called by
|
|
322
|
+
// BlockListBlock and not a React component rendered within
|
|
323
|
+
// BlockListContext.Provider. If we set fontSize using editor.
|
|
324
|
+
// BlockListBlock instead of using getEditWrapperProps then the value is
|
|
325
|
+
// clobbered when the core/style/addEditProps filter runs.
|
|
326
|
+
const isFluidTypographyEnabled =
|
|
327
|
+
!! select( blockEditorStore ).getSettings().__experimentalFeatures
|
|
328
|
+
?.typography?.fluid;
|
|
329
|
+
|
|
330
|
+
const newFontSize =
|
|
331
|
+
fontSize && isFluidTypographyEnabled
|
|
332
|
+
? getComputedFluidTypographyValue( { fontSize } )
|
|
333
|
+
: null;
|
|
334
|
+
|
|
335
|
+
if ( newFontSize === null ) {
|
|
336
|
+
return wrapperProps;
|
|
337
|
+
}
|
|
338
|
+
|
|
339
|
+
return {
|
|
340
|
+
...wrapperProps,
|
|
341
|
+
style: {
|
|
342
|
+
...wrapperProps?.style,
|
|
343
|
+
fontSize: newFontSize,
|
|
344
|
+
},
|
|
345
|
+
};
|
|
346
|
+
};
|
|
347
|
+
|
|
348
|
+
return blockType;
|
|
349
|
+
}
|
|
350
|
+
|
|
285
351
|
addFilter(
|
|
286
352
|
'blocks.registerBlockType',
|
|
287
353
|
'core/font/addAttribute',
|
|
@@ -307,3 +373,12 @@ addFilter(
|
|
|
307
373
|
'core/font-size/addTransforms',
|
|
308
374
|
addTransforms
|
|
309
375
|
);
|
|
376
|
+
|
|
377
|
+
addFilter(
|
|
378
|
+
'blocks.registerBlockType',
|
|
379
|
+
'core/font-size/addEditPropsForFluidCustomFontSizes',
|
|
380
|
+
addEditPropsForFluidCustomFontSizes,
|
|
381
|
+
// Run after 'core/style/addEditProps' so that the style object has already
|
|
382
|
+
// been translated into inline CSS.
|
|
383
|
+
11
|
|
384
|
+
);
|
package/src/hooks/margin.js
CHANGED
|
@@ -190,10 +190,10 @@ export function MarginVisualizer( { clientId, attributes } ) {
|
|
|
190
190
|
borderRightWidth: marginRight,
|
|
191
191
|
borderBottomWidth: marginBottom,
|
|
192
192
|
borderLeftWidth: marginLeft,
|
|
193
|
-
top: marginTop !== 0 ?
|
|
194
|
-
right: marginRight !== 0 ?
|
|
195
|
-
bottom: marginBottom !== 0 ?
|
|
196
|
-
left: marginLeft !== 0 ?
|
|
193
|
+
top: marginTop !== 0 ? `calc(${ marginTop } * -1)` : 0,
|
|
194
|
+
right: marginRight !== 0 ? `calc(${ marginRight } * -1)` : 0,
|
|
195
|
+
bottom: marginBottom !== 0 ? `calc(${ marginBottom } * -1)` : 0,
|
|
196
|
+
left: marginLeft !== 0 ? `calc(${ marginLeft } * -1)` : 0,
|
|
197
197
|
};
|
|
198
198
|
}, [ margin ] );
|
|
199
199
|
|
|
@@ -231,6 +231,7 @@ export function MarginVisualizer( { clientId, attributes } ) {
|
|
|
231
231
|
clientId={ clientId }
|
|
232
232
|
__unstableCoverTarget
|
|
233
233
|
__unstableRefreshSize={ margin }
|
|
234
|
+
shift={ false }
|
|
234
235
|
>
|
|
235
236
|
<div className="block-editor__padding-visualizer" style={ style } />
|
|
236
237
|
</BlockPopover>
|
package/src/hooks/padding.js
CHANGED
|
@@ -222,6 +222,7 @@ export function PaddingVisualizer( { clientId, attributes } ) {
|
|
|
222
222
|
clientId={ clientId }
|
|
223
223
|
__unstableCoverTarget
|
|
224
224
|
__unstableRefreshSize={ padding }
|
|
225
|
+
shift={ false }
|
|
225
226
|
>
|
|
226
227
|
<div className="block-editor__padding-visualizer" style={ style } />
|
|
227
228
|
</BlockPopover>
|
package/src/hooks/style.js
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* External dependencies
|
|
3
3
|
*/
|
|
4
|
-
import { omit } from 'lodash';
|
|
5
4
|
import classnames from 'classnames';
|
|
6
5
|
|
|
7
6
|
/**
|
|
@@ -134,6 +133,126 @@ const skipSerializationPathsSave = {
|
|
|
134
133
|
*/
|
|
135
134
|
const renamedFeatures = { gradients: 'gradient' };
|
|
136
135
|
|
|
136
|
+
/**
|
|
137
|
+
* A utility function used to remove one or more paths from a style object.
|
|
138
|
+
* Works in a way similar to Lodash's `omit()`. See unit tests and examples below.
|
|
139
|
+
*
|
|
140
|
+
* It supports a single string path:
|
|
141
|
+
*
|
|
142
|
+
* ```
|
|
143
|
+
* omitStyle( { color: 'red' }, 'color' ); // {}
|
|
144
|
+
* ```
|
|
145
|
+
*
|
|
146
|
+
* or an array of paths:
|
|
147
|
+
*
|
|
148
|
+
* ```
|
|
149
|
+
* omitStyle( { color: 'red', background: '#fff' }, [ 'color', 'background' ] ); // {}
|
|
150
|
+
* ```
|
|
151
|
+
*
|
|
152
|
+
* It also allows you to specify paths at multiple levels in a string.
|
|
153
|
+
*
|
|
154
|
+
* ```
|
|
155
|
+
* omitStyle( { typography: { textDecoration: 'underline' } }, 'typography.textDecoration' ); // {}
|
|
156
|
+
* ```
|
|
157
|
+
*
|
|
158
|
+
* You can remove multiple paths at the same time:
|
|
159
|
+
*
|
|
160
|
+
* ```
|
|
161
|
+
* omitStyle(
|
|
162
|
+
* {
|
|
163
|
+
* typography: {
|
|
164
|
+
* textDecoration: 'underline',
|
|
165
|
+
* textTransform: 'uppercase',
|
|
166
|
+
* }
|
|
167
|
+
* },
|
|
168
|
+
* [
|
|
169
|
+
* 'typography.textDecoration',
|
|
170
|
+
* 'typography.textTransform',
|
|
171
|
+
* ]
|
|
172
|
+
* );
|
|
173
|
+
* // {}
|
|
174
|
+
* ```
|
|
175
|
+
*
|
|
176
|
+
* You can also specify nested paths as arrays:
|
|
177
|
+
*
|
|
178
|
+
* ```
|
|
179
|
+
* omitStyle(
|
|
180
|
+
* {
|
|
181
|
+
* typography: {
|
|
182
|
+
* textDecoration: 'underline',
|
|
183
|
+
* textTransform: 'uppercase',
|
|
184
|
+
* }
|
|
185
|
+
* },
|
|
186
|
+
* [
|
|
187
|
+
* [ 'typography', 'textDecoration' ],
|
|
188
|
+
* [ 'typography', 'textTransform' ],
|
|
189
|
+
* ]
|
|
190
|
+
* );
|
|
191
|
+
* // {}
|
|
192
|
+
* ```
|
|
193
|
+
*
|
|
194
|
+
* With regards to nesting of styles, infinite depth is supported:
|
|
195
|
+
*
|
|
196
|
+
* ```
|
|
197
|
+
* omitStyle(
|
|
198
|
+
* {
|
|
199
|
+
* border: {
|
|
200
|
+
* radius: {
|
|
201
|
+
* topLeft: '10px',
|
|
202
|
+
* topRight: '0.5rem',
|
|
203
|
+
* }
|
|
204
|
+
* }
|
|
205
|
+
* },
|
|
206
|
+
* [
|
|
207
|
+
* [ 'border', 'radius', 'topRight' ],
|
|
208
|
+
* ]
|
|
209
|
+
* );
|
|
210
|
+
* // { border: { radius: { topLeft: '10px' } } }
|
|
211
|
+
* ```
|
|
212
|
+
*
|
|
213
|
+
* The third argument, `preserveReference`, defines how to treat the input style object.
|
|
214
|
+
* It is mostly necessary to properly handle mutation when recursively handling the style object.
|
|
215
|
+
* Defaulting to `false`, this will always create a new object, avoiding to mutate `style`.
|
|
216
|
+
* However, when recursing, we change that value to `true` in order to work with a single copy
|
|
217
|
+
* of the original style object.
|
|
218
|
+
*
|
|
219
|
+
* @see https://lodash.com/docs/4.17.15#omit
|
|
220
|
+
*
|
|
221
|
+
* @param {Object} style Styles object.
|
|
222
|
+
* @param {Array|string} paths Paths to remove.
|
|
223
|
+
* @param {boolean} preserveReference True to mutate the `style` object, false otherwise.
|
|
224
|
+
* @return {Object} Styles object with the specified paths removed.
|
|
225
|
+
*/
|
|
226
|
+
export function omitStyle( style, paths, preserveReference = false ) {
|
|
227
|
+
if ( ! style ) {
|
|
228
|
+
return style;
|
|
229
|
+
}
|
|
230
|
+
|
|
231
|
+
let newStyle = style;
|
|
232
|
+
if ( ! preserveReference ) {
|
|
233
|
+
newStyle = JSON.parse( JSON.stringify( style ) );
|
|
234
|
+
}
|
|
235
|
+
|
|
236
|
+
if ( ! Array.isArray( paths ) ) {
|
|
237
|
+
paths = [ paths ];
|
|
238
|
+
}
|
|
239
|
+
|
|
240
|
+
paths.forEach( ( path ) => {
|
|
241
|
+
if ( ! Array.isArray( path ) ) {
|
|
242
|
+
path = path.split( '.' );
|
|
243
|
+
}
|
|
244
|
+
|
|
245
|
+
if ( path.length > 1 ) {
|
|
246
|
+
const [ firstSubpath, ...restPath ] = path;
|
|
247
|
+
omitStyle( newStyle[ firstSubpath ], [ restPath ], true );
|
|
248
|
+
} else if ( path.length === 1 ) {
|
|
249
|
+
delete newStyle[ path[ 0 ] ];
|
|
250
|
+
}
|
|
251
|
+
} );
|
|
252
|
+
|
|
253
|
+
return newStyle;
|
|
254
|
+
}
|
|
255
|
+
|
|
137
256
|
/**
|
|
138
257
|
* Override props assigned to save component to inject the CSS variables definition.
|
|
139
258
|
*
|
|
@@ -159,13 +278,13 @@ export function addSaveProps(
|
|
|
159
278
|
const skipSerialization = getBlockSupport( blockType, indicator );
|
|
160
279
|
|
|
161
280
|
if ( skipSerialization === true ) {
|
|
162
|
-
style =
|
|
281
|
+
style = omitStyle( style, path );
|
|
163
282
|
}
|
|
164
283
|
|
|
165
284
|
if ( Array.isArray( skipSerialization ) ) {
|
|
166
285
|
skipSerialization.forEach( ( featureName ) => {
|
|
167
286
|
const feature = renamedFeatures[ featureName ] || featureName;
|
|
168
|
-
style =
|
|
287
|
+
style = omitStyle( style, [ [ ...path, feature ] ] );
|
|
169
288
|
} );
|
|
170
289
|
}
|
|
171
290
|
} );
|
package/src/hooks/test/style.js
CHANGED
|
@@ -6,7 +6,7 @@ import { applyFilters } from '@wordpress/hooks';
|
|
|
6
6
|
/**
|
|
7
7
|
* Internal dependencies
|
|
8
8
|
*/
|
|
9
|
-
import { getInlineStyles } from '../style';
|
|
9
|
+
import { getInlineStyles, omitStyle } from '../style';
|
|
10
10
|
|
|
11
11
|
describe( 'getInlineStyles', () => {
|
|
12
12
|
it( 'should return an empty object when called with undefined', () => {
|
|
@@ -202,3 +202,208 @@ describe( 'addSaveProps', () => {
|
|
|
202
202
|
} );
|
|
203
203
|
} );
|
|
204
204
|
} );
|
|
205
|
+
|
|
206
|
+
describe( 'omitStyle', () => {
|
|
207
|
+
it( 'should remove a single path', () => {
|
|
208
|
+
const style = { color: '#d92828', padding: '10px' };
|
|
209
|
+
const path = 'color';
|
|
210
|
+
const expected = { padding: '10px' };
|
|
211
|
+
|
|
212
|
+
expect( omitStyle( style, path ) ).toEqual( expected );
|
|
213
|
+
} );
|
|
214
|
+
|
|
215
|
+
it( 'should remove multiple paths', () => {
|
|
216
|
+
const style = { color: '#d92828', padding: '10px', background: 'red' };
|
|
217
|
+
const path = [ 'color', 'background' ];
|
|
218
|
+
const expected = { padding: '10px' };
|
|
219
|
+
|
|
220
|
+
expect( omitStyle( style, path ) ).toEqual( expected );
|
|
221
|
+
} );
|
|
222
|
+
|
|
223
|
+
it( 'should remove nested paths when specified as a string', () => {
|
|
224
|
+
const style = {
|
|
225
|
+
color: {
|
|
226
|
+
text: '#d92828',
|
|
227
|
+
},
|
|
228
|
+
typography: {
|
|
229
|
+
textDecoration: 'underline',
|
|
230
|
+
textTransform: 'uppercase',
|
|
231
|
+
},
|
|
232
|
+
};
|
|
233
|
+
const path = 'typography.textTransform';
|
|
234
|
+
const expected = {
|
|
235
|
+
color: {
|
|
236
|
+
text: '#d92828',
|
|
237
|
+
},
|
|
238
|
+
typography: {
|
|
239
|
+
textDecoration: 'underline',
|
|
240
|
+
},
|
|
241
|
+
};
|
|
242
|
+
|
|
243
|
+
expect( omitStyle( style, path ) ).toEqual( expected );
|
|
244
|
+
} );
|
|
245
|
+
|
|
246
|
+
it( 'should remove nested paths when specified as an array', () => {
|
|
247
|
+
const style = {
|
|
248
|
+
color: {
|
|
249
|
+
text: '#d92828',
|
|
250
|
+
},
|
|
251
|
+
typography: {
|
|
252
|
+
textDecoration: 'underline',
|
|
253
|
+
textTransform: 'uppercase',
|
|
254
|
+
},
|
|
255
|
+
};
|
|
256
|
+
const path = [ [ 'typography', 'textTransform' ] ];
|
|
257
|
+
const expected = {
|
|
258
|
+
color: {
|
|
259
|
+
text: '#d92828',
|
|
260
|
+
},
|
|
261
|
+
typography: {
|
|
262
|
+
textDecoration: 'underline',
|
|
263
|
+
},
|
|
264
|
+
};
|
|
265
|
+
|
|
266
|
+
expect( omitStyle( style, path ) ).toEqual( expected );
|
|
267
|
+
} );
|
|
268
|
+
|
|
269
|
+
it( 'should remove multiple nested paths', () => {
|
|
270
|
+
const style = {
|
|
271
|
+
color: {
|
|
272
|
+
text: '#d92828',
|
|
273
|
+
},
|
|
274
|
+
typography: {
|
|
275
|
+
textDecoration: 'underline',
|
|
276
|
+
textTransform: 'uppercase',
|
|
277
|
+
},
|
|
278
|
+
};
|
|
279
|
+
const path = [
|
|
280
|
+
[ 'typography', 'textTransform' ],
|
|
281
|
+
'typography.textDecoration',
|
|
282
|
+
];
|
|
283
|
+
const expected = {
|
|
284
|
+
color: {
|
|
285
|
+
text: '#d92828',
|
|
286
|
+
},
|
|
287
|
+
typography: {},
|
|
288
|
+
};
|
|
289
|
+
|
|
290
|
+
expect( omitStyle( style, path ) ).toEqual( expected );
|
|
291
|
+
} );
|
|
292
|
+
|
|
293
|
+
it( 'should remove paths with different nesting', () => {
|
|
294
|
+
const style = {
|
|
295
|
+
color: {
|
|
296
|
+
text: '#d92828',
|
|
297
|
+
},
|
|
298
|
+
typography: {
|
|
299
|
+
textDecoration: 'underline',
|
|
300
|
+
textTransform: 'uppercase',
|
|
301
|
+
},
|
|
302
|
+
};
|
|
303
|
+
const path = [
|
|
304
|
+
'color',
|
|
305
|
+
[ 'typography', 'textTransform' ],
|
|
306
|
+
'typography.textDecoration',
|
|
307
|
+
];
|
|
308
|
+
const expected = {
|
|
309
|
+
typography: {},
|
|
310
|
+
};
|
|
311
|
+
|
|
312
|
+
expect( omitStyle( style, path ) ).toEqual( expected );
|
|
313
|
+
} );
|
|
314
|
+
|
|
315
|
+
it( 'should support beyond 2 levels of nesting when passed as a single string', () => {
|
|
316
|
+
const style = {
|
|
317
|
+
border: {
|
|
318
|
+
radius: {
|
|
319
|
+
topLeft: '10px',
|
|
320
|
+
topRight: '0.5rem',
|
|
321
|
+
},
|
|
322
|
+
},
|
|
323
|
+
};
|
|
324
|
+
const path = 'border.radius.topRight';
|
|
325
|
+
const expected = {
|
|
326
|
+
border: {
|
|
327
|
+
radius: {
|
|
328
|
+
topLeft: '10px',
|
|
329
|
+
},
|
|
330
|
+
},
|
|
331
|
+
};
|
|
332
|
+
|
|
333
|
+
expect( omitStyle( style, path ) ).toEqual( expected );
|
|
334
|
+
} );
|
|
335
|
+
|
|
336
|
+
it( 'should support beyond 2 levels of nesting when passed as array of strings', () => {
|
|
337
|
+
const style = {
|
|
338
|
+
border: {
|
|
339
|
+
radius: {
|
|
340
|
+
topLeft: '10px',
|
|
341
|
+
topRight: '0.5rem',
|
|
342
|
+
},
|
|
343
|
+
},
|
|
344
|
+
};
|
|
345
|
+
const path = [ 'border.radius.topRight' ];
|
|
346
|
+
const expected = {
|
|
347
|
+
border: {
|
|
348
|
+
radius: {
|
|
349
|
+
topLeft: '10px',
|
|
350
|
+
},
|
|
351
|
+
},
|
|
352
|
+
};
|
|
353
|
+
|
|
354
|
+
expect( omitStyle( style, path ) ).toEqual( expected );
|
|
355
|
+
} );
|
|
356
|
+
|
|
357
|
+
it( 'should support beyond 2 levels of nesting when passed as array of arrays', () => {
|
|
358
|
+
const style = {
|
|
359
|
+
border: {
|
|
360
|
+
radius: {
|
|
361
|
+
topLeft: '10px',
|
|
362
|
+
topRight: '0.5rem',
|
|
363
|
+
},
|
|
364
|
+
},
|
|
365
|
+
};
|
|
366
|
+
const path = [ [ 'border', 'radius', 'topRight' ] ];
|
|
367
|
+
const expected = {
|
|
368
|
+
border: {
|
|
369
|
+
radius: {
|
|
370
|
+
topLeft: '10px',
|
|
371
|
+
},
|
|
372
|
+
},
|
|
373
|
+
};
|
|
374
|
+
|
|
375
|
+
expect( omitStyle( style, path ) ).toEqual( expected );
|
|
376
|
+
} );
|
|
377
|
+
|
|
378
|
+
it( 'should ignore a nullish style object', () => {
|
|
379
|
+
expect( omitStyle( undefined, 'color' ) ).toEqual( undefined );
|
|
380
|
+
expect( omitStyle( null, 'color' ) ).toEqual( null );
|
|
381
|
+
} );
|
|
382
|
+
|
|
383
|
+
it( 'should ignore a missing object property', () => {
|
|
384
|
+
const style1 = { typography: {} };
|
|
385
|
+
expect( omitStyle( style1, 'color' ) ).toEqual( style1 );
|
|
386
|
+
|
|
387
|
+
const style2 = { color: { text: '#d92828' } };
|
|
388
|
+
expect( omitStyle( style2, 'color.something' ) ).toEqual( style2 );
|
|
389
|
+
|
|
390
|
+
const style3 = {
|
|
391
|
+
border: {
|
|
392
|
+
radius: {
|
|
393
|
+
topLeft: '10px',
|
|
394
|
+
topRight: '0.5rem',
|
|
395
|
+
},
|
|
396
|
+
},
|
|
397
|
+
};
|
|
398
|
+
expect(
|
|
399
|
+
omitStyle( style3, [ [ 'border', 'radius', 'bottomLeft' ] ] )
|
|
400
|
+
).toEqual( style3 );
|
|
401
|
+
} );
|
|
402
|
+
|
|
403
|
+
it( 'should ignore an empty array path', () => {
|
|
404
|
+
const style = { typography: {}, '': 'test' };
|
|
405
|
+
|
|
406
|
+
expect( omitStyle( style, [] ) ).toEqual( style );
|
|
407
|
+
expect( omitStyle( style, [ [] ] ) ).toEqual( style );
|
|
408
|
+
} );
|
|
409
|
+
} );
|
|
@@ -25,4 +25,26 @@ describe( 'getTypographyClassesAndStyles', () => {
|
|
|
25
25
|
},
|
|
26
26
|
} );
|
|
27
27
|
} );
|
|
28
|
+
|
|
29
|
+
it( 'should return fluid font size styles', () => {
|
|
30
|
+
const attributes = {
|
|
31
|
+
fontFamily: 'tofu',
|
|
32
|
+
style: {
|
|
33
|
+
typography: {
|
|
34
|
+
letterSpacing: '22px',
|
|
35
|
+
fontSize: '2rem',
|
|
36
|
+
textTransform: 'uppercase',
|
|
37
|
+
},
|
|
38
|
+
},
|
|
39
|
+
};
|
|
40
|
+
expect( getTypographyClassesAndStyles( attributes, true ) ).toEqual( {
|
|
41
|
+
className: 'has-tofu-font-family',
|
|
42
|
+
style: {
|
|
43
|
+
letterSpacing: '22px',
|
|
44
|
+
fontSize:
|
|
45
|
+
'clamp(1.5rem, 1.5rem + ((1vw - 0.48rem) * 2.885), 3rem)',
|
|
46
|
+
textTransform: 'uppercase',
|
|
47
|
+
},
|
|
48
|
+
} );
|
|
49
|
+
} );
|
|
28
50
|
} );
|
|
@@ -9,6 +9,7 @@ import classnames from 'classnames';
|
|
|
9
9
|
*/
|
|
10
10
|
import { getInlineStyles } from './style';
|
|
11
11
|
import { getFontSizeClass } from '../components/font-sizes';
|
|
12
|
+
import { getComputedFluidTypographyValue } from '../components/font-sizes/fluid-utils';
|
|
12
13
|
|
|
13
14
|
// This utility is intended to assist where the serialization of the typography
|
|
14
15
|
// block support is being skipped for a block but the typography related CSS
|
|
@@ -18,12 +19,26 @@ import { getFontSizeClass } from '../components/font-sizes';
|
|
|
18
19
|
* Provides the CSS class names and inline styles for a block's typography support
|
|
19
20
|
* attributes.
|
|
20
21
|
*
|
|
21
|
-
* @param {Object}
|
|
22
|
+
* @param {Object} attributes Block attributes.
|
|
23
|
+
* @param {boolean} isFluidFontSizeActive Whether the function should try to convert font sizes to fluid values.
|
|
22
24
|
*
|
|
23
25
|
* @return {Object} Typography block support derived CSS classes & styles.
|
|
24
26
|
*/
|
|
25
|
-
export function getTypographyClassesAndStyles(
|
|
26
|
-
|
|
27
|
+
export function getTypographyClassesAndStyles(
|
|
28
|
+
attributes,
|
|
29
|
+
isFluidFontSizeActive
|
|
30
|
+
) {
|
|
31
|
+
let typographyStyles = attributes?.style?.typography || {};
|
|
32
|
+
|
|
33
|
+
if ( isFluidFontSizeActive ) {
|
|
34
|
+
typographyStyles = {
|
|
35
|
+
...typographyStyles,
|
|
36
|
+
fontSize: getComputedFluidTypographyValue( {
|
|
37
|
+
fontSize: attributes?.style?.typography?.fontSize,
|
|
38
|
+
} ),
|
|
39
|
+
};
|
|
40
|
+
}
|
|
41
|
+
|
|
27
42
|
const style = getInlineStyles( { typography: typographyStyles } );
|
|
28
43
|
const fontFamilyClassName = !! attributes?.fontFamily
|
|
29
44
|
? `has-${ kebabCase( attributes.fontFamily ) }-font-family`
|
package/src/hooks/utils.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* External dependencies
|
|
3
3
|
*/
|
|
4
|
-
import { pickBy, isEmpty, mapValues, get, setWith, clone
|
|
4
|
+
import { pickBy, isEmpty, mapValues, get, setWith, clone } from 'lodash';
|
|
5
5
|
|
|
6
6
|
/**
|
|
7
7
|
* WordPress dependencies
|
|
@@ -44,7 +44,11 @@ export function transformStyles(
|
|
|
44
44
|
results
|
|
45
45
|
) {
|
|
46
46
|
// If there are no active supports return early.
|
|
47
|
-
if (
|
|
47
|
+
if (
|
|
48
|
+
Object.values( activeSupports ?? {} ).every(
|
|
49
|
+
( isActive ) => ! isActive
|
|
50
|
+
)
|
|
51
|
+
) {
|
|
48
52
|
return result;
|
|
49
53
|
}
|
|
50
54
|
// If the condition verifies we are probably in the presence of a wrapping transform
|
package/src/store/actions.js
CHANGED
|
@@ -26,6 +26,8 @@ import {
|
|
|
26
26
|
START_OF_SELECTED_AREA,
|
|
27
27
|
} from '../utils/selection';
|
|
28
28
|
|
|
29
|
+
/** @typedef {import('../components/use-on-block-drop/types').WPDropOperation} WPDropOperation */
|
|
30
|
+
|
|
29
31
|
const castArray = ( maybeArray ) =>
|
|
30
32
|
Array.isArray( maybeArray ) ? maybeArray : [ maybeArray ];
|
|
31
33
|
|
|
@@ -624,10 +626,13 @@ export const insertBlocks =
|
|
|
624
626
|
/**
|
|
625
627
|
* Action that shows the insertion point.
|
|
626
628
|
*
|
|
627
|
-
* @param
|
|
628
|
-
*
|
|
629
|
-
* @param
|
|
630
|
-
* @param
|
|
629
|
+
* @param {?string} rootClientId Optional root client ID of block list on
|
|
630
|
+
* which to insert.
|
|
631
|
+
* @param {?number} index Index at which block should be inserted.
|
|
632
|
+
* @param {?Object} __unstableOptions Additional options.
|
|
633
|
+
* @property {boolean} __unstableWithInserter Whether or not to show an inserter button.
|
|
634
|
+
* @property {WPDropOperation} operation The operation to perform when applied,
|
|
635
|
+
* either 'insert' or 'replace' for now.
|
|
631
636
|
*
|
|
632
637
|
* @return {Object} Action object.
|
|
633
638
|
*/
|
|
@@ -636,25 +641,28 @@ export function showInsertionPoint(
|
|
|
636
641
|
index,
|
|
637
642
|
__unstableOptions = {}
|
|
638
643
|
) {
|
|
639
|
-
const { __unstableWithInserter } = __unstableOptions;
|
|
644
|
+
const { __unstableWithInserter, operation } = __unstableOptions;
|
|
640
645
|
return {
|
|
641
646
|
type: 'SHOW_INSERTION_POINT',
|
|
642
647
|
rootClientId,
|
|
643
648
|
index,
|
|
644
649
|
__unstableWithInserter,
|
|
650
|
+
operation,
|
|
645
651
|
};
|
|
646
652
|
}
|
|
647
|
-
|
|
648
653
|
/**
|
|
649
654
|
* Action that hides the insertion point.
|
|
650
|
-
*
|
|
651
|
-
* @return {Object} Action object.
|
|
652
655
|
*/
|
|
653
|
-
export
|
|
654
|
-
|
|
655
|
-
|
|
656
|
+
export const hideInsertionPoint =
|
|
657
|
+
() =>
|
|
658
|
+
( { select, dispatch } ) => {
|
|
659
|
+
if ( ! select.isBlockInsertionPointVisible() ) {
|
|
660
|
+
return;
|
|
661
|
+
}
|
|
662
|
+
dispatch( {
|
|
663
|
+
type: 'HIDE_INSERTION_POINT',
|
|
664
|
+
} );
|
|
656
665
|
};
|
|
657
|
-
}
|
|
658
666
|
|
|
659
667
|
/**
|
|
660
668
|
* Action that resets the template validity.
|