@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
package/src/store/defaults.js
CHANGED
|
@@ -27,6 +27,7 @@ export const PREFERENCES_DEFAULTS = {
|
|
|
27
27
|
* @property {boolean} codeEditingEnabled Whether or not the user can switch to the code editor
|
|
28
28
|
* @property {boolean} generateAnchors Enable/Disable auto anchor generation for Heading blocks
|
|
29
29
|
* @property {boolean} __experimentalCanUserUseUnfilteredHTML Whether the user should be able to use unfiltered HTML or the HTML should be filtered e.g., to remove elements considered insecure like iframes.
|
|
30
|
+
* @property {boolean} __experimentalClearBlockSelection Whether the block editor should clear selection on mousedown when a block is not clicked.
|
|
30
31
|
* @property {boolean} __experimentalBlockDirectory Whether the user has enabled the Block Directory
|
|
31
32
|
* @property {Array} __experimentalBlockPatterns Array of objects representing the block patterns
|
|
32
33
|
* @property {Array} __experimentalBlockPatternCategories Array of objects representing the block pattern categories
|
|
@@ -156,11 +157,13 @@ export const SETTINGS_DEFAULTS = {
|
|
|
156
157
|
canLockBlocks: true,
|
|
157
158
|
|
|
158
159
|
__experimentalCanUserUseUnfilteredHTML: false,
|
|
160
|
+
__experimentalClearBlockSelection: true,
|
|
159
161
|
__experimentalBlockDirectory: false,
|
|
160
162
|
__mobileEnablePageTemplates: false,
|
|
161
163
|
__experimentalBlockPatterns: [],
|
|
162
164
|
__experimentalBlockPatternCategories: [],
|
|
163
165
|
__unstableGalleryWithImageBlocks: false,
|
|
166
|
+
__unstableIsPreviewMode: false,
|
|
164
167
|
|
|
165
168
|
generateAnchors: false,
|
|
166
169
|
// gradients setting is not used anymore now defaults are passed from theme.json on the server and core has its own defaults.
|
package/src/store/reducer.js
CHANGED
|
@@ -1,15 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* External dependencies
|
|
3
3
|
*/
|
|
4
|
-
import {
|
|
5
|
-
reduce,
|
|
6
|
-
omit,
|
|
7
|
-
without,
|
|
8
|
-
mapValues,
|
|
9
|
-
isEqual,
|
|
10
|
-
isEmpty,
|
|
11
|
-
omitBy,
|
|
12
|
-
} from 'lodash';
|
|
4
|
+
import { reduce, omit, mapValues, isEqual, isEmpty } from 'lodash';
|
|
13
5
|
|
|
14
6
|
/**
|
|
15
7
|
* WordPress dependencies
|
|
@@ -425,15 +417,15 @@ const withBlockTree =
|
|
|
425
417
|
break;
|
|
426
418
|
}
|
|
427
419
|
case 'SAVE_REUSABLE_BLOCK_SUCCESS': {
|
|
428
|
-
const updatedBlockUids = Object.
|
|
429
|
-
|
|
420
|
+
const updatedBlockUids = Object.entries( newState.attributes )
|
|
421
|
+
.filter( ( [ clientId, attributes ] ) => {
|
|
430
422
|
return (
|
|
431
|
-
newState.byClientId[ clientId ].name
|
|
432
|
-
'core/block'
|
|
433
|
-
attributes.ref
|
|
423
|
+
newState.byClientId[ clientId ].name ===
|
|
424
|
+
'core/block' &&
|
|
425
|
+
attributes.ref === action.updatedId
|
|
434
426
|
);
|
|
435
427
|
} )
|
|
436
|
-
|
|
428
|
+
.map( ( [ clientId ] ) => clientId );
|
|
437
429
|
|
|
438
430
|
newState.tree = updateParentInnerBlocksInTree(
|
|
439
431
|
newState,
|
|
@@ -987,10 +979,10 @@ export const blocks = pipe(
|
|
|
987
979
|
// Moving from a parent block to another.
|
|
988
980
|
return {
|
|
989
981
|
...state,
|
|
990
|
-
[ fromRootClientId ]:
|
|
991
|
-
state[ fromRootClientId ]
|
|
992
|
-
|
|
993
|
-
|
|
982
|
+
[ fromRootClientId ]:
|
|
983
|
+
state[ fromRootClientId ]?.filter(
|
|
984
|
+
( id ) => ! clientIds.includes( id )
|
|
985
|
+
) ?? [],
|
|
994
986
|
[ toRootClientId ]: insertAt(
|
|
995
987
|
state[ toRootClientId ],
|
|
996
988
|
clientIds,
|
|
@@ -1095,8 +1087,13 @@ export const blocks = pipe(
|
|
|
1095
1087
|
|
|
1096
1088
|
// Remove deleted blocks from other blocks' orderings.
|
|
1097
1089
|
( nextState ) =>
|
|
1098
|
-
mapValues(
|
|
1099
|
-
|
|
1090
|
+
mapValues(
|
|
1091
|
+
nextState,
|
|
1092
|
+
( subState ) =>
|
|
1093
|
+
subState?.filter(
|
|
1094
|
+
( id ) =>
|
|
1095
|
+
! action.removedClientIds.includes( id )
|
|
1096
|
+
) ?? []
|
|
1100
1097
|
),
|
|
1101
1098
|
] )( state );
|
|
1102
1099
|
}
|
|
@@ -1475,9 +1472,19 @@ export function blocksMode( state = {}, action ) {
|
|
|
1475
1472
|
*/
|
|
1476
1473
|
export function insertionPoint( state = null, action ) {
|
|
1477
1474
|
switch ( action.type ) {
|
|
1478
|
-
case 'SHOW_INSERTION_POINT':
|
|
1479
|
-
const { rootClientId, index, __unstableWithInserter } =
|
|
1480
|
-
|
|
1475
|
+
case 'SHOW_INSERTION_POINT': {
|
|
1476
|
+
const { rootClientId, index, __unstableWithInserter, operation } =
|
|
1477
|
+
action;
|
|
1478
|
+
const nextState = {
|
|
1479
|
+
rootClientId,
|
|
1480
|
+
index,
|
|
1481
|
+
__unstableWithInserter,
|
|
1482
|
+
operation,
|
|
1483
|
+
};
|
|
1484
|
+
|
|
1485
|
+
// Bail out updates if the states are the same.
|
|
1486
|
+
return isEqual( state, nextState ) ? state : nextState;
|
|
1487
|
+
}
|
|
1481
1488
|
|
|
1482
1489
|
case 'HIDE_INSERTION_POINT':
|
|
1483
1490
|
return null;
|
|
@@ -27,7 +27,6 @@ const noop = () => {};
|
|
|
27
27
|
|
|
28
28
|
const {
|
|
29
29
|
clearSelectedBlock,
|
|
30
|
-
hideInsertionPoint,
|
|
31
30
|
insertBlock,
|
|
32
31
|
insertBlocks,
|
|
33
32
|
mergeBlocks,
|
|
@@ -610,14 +609,6 @@ describe( 'actions', () => {
|
|
|
610
609
|
} );
|
|
611
610
|
} );
|
|
612
611
|
|
|
613
|
-
describe( 'hideInsertionPoint', () => {
|
|
614
|
-
it( 'should return the HIDE_INSERTION_POINT action', () => {
|
|
615
|
-
expect( hideInsertionPoint() ).toEqual( {
|
|
616
|
-
type: 'HIDE_INSERTION_POINT',
|
|
617
|
-
} );
|
|
618
|
-
} );
|
|
619
|
-
} );
|
|
620
|
-
|
|
621
612
|
describe( 'removeBlocks', () => {
|
|
622
613
|
it( 'should dispatch REMOVE_BLOCKS action', () => {
|
|
623
614
|
const clientId = 'clientId';
|
package/src/utils/math.js
CHANGED
|
@@ -89,3 +89,20 @@ export function getDistanceToNearestEdge(
|
|
|
89
89
|
|
|
90
90
|
return [ candidateDistance, candidateEdge ];
|
|
91
91
|
}
|
|
92
|
+
|
|
93
|
+
/**
|
|
94
|
+
* Is the point contained by the rectangle.
|
|
95
|
+
*
|
|
96
|
+
* @param {WPPoint} point The point.
|
|
97
|
+
* @param {DOMRect} rect The rectangle.
|
|
98
|
+
*
|
|
99
|
+
* @return {boolean} True if the point is contained by the rectangle, false otherwise.
|
|
100
|
+
*/
|
|
101
|
+
export function isPointContainedByRect( point, rect ) {
|
|
102
|
+
return (
|
|
103
|
+
rect.left <= point.x &&
|
|
104
|
+
rect.right >= point.x &&
|
|
105
|
+
rect.top <= point.y &&
|
|
106
|
+
rect.bottom >= point.y
|
|
107
|
+
);
|
|
108
|
+
}
|
|
@@ -28,14 +28,19 @@ const cancelIdleCallback = ( () => {
|
|
|
28
28
|
} )();
|
|
29
29
|
|
|
30
30
|
export function usePreParsePatterns() {
|
|
31
|
-
const patterns = useSelect(
|
|
32
|
-
|
|
33
|
-
_select( blockEditorStore ).getSettings()
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
31
|
+
const { patterns, isPreviewMode } = useSelect( ( _select ) => {
|
|
32
|
+
const { __experimentalBlockPatterns, __unstableIsPreviewMode } =
|
|
33
|
+
_select( blockEditorStore ).getSettings();
|
|
34
|
+
return {
|
|
35
|
+
patterns: __experimentalBlockPatterns,
|
|
36
|
+
isPreviewMode: __unstableIsPreviewMode,
|
|
37
|
+
};
|
|
38
|
+
}, [] );
|
|
37
39
|
|
|
38
40
|
useEffect( () => {
|
|
41
|
+
if ( isPreviewMode ) {
|
|
42
|
+
return;
|
|
43
|
+
}
|
|
39
44
|
if ( ! patterns?.length ) {
|
|
40
45
|
return;
|
|
41
46
|
}
|
|
@@ -58,7 +63,7 @@ export function usePreParsePatterns() {
|
|
|
58
63
|
|
|
59
64
|
handle = requestIdleCallback( callback );
|
|
60
65
|
return () => cancelIdleCallback( handle );
|
|
61
|
-
}, [ patterns ] );
|
|
66
|
+
}, [ patterns, isPreviewMode ] );
|
|
62
67
|
|
|
63
68
|
return null;
|
|
64
69
|
}
|
|
@@ -1,87 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
-
|
|
5
|
-
Object.defineProperty(exports, "__esModule", {
|
|
6
|
-
value: true
|
|
7
|
-
});
|
|
8
|
-
exports.default = void 0;
|
|
9
|
-
|
|
10
|
-
var _element = require("@wordpress/element");
|
|
11
|
-
|
|
12
|
-
var _classnames = _interopRequireDefault(require("classnames"));
|
|
13
|
-
|
|
14
|
-
var _components = require("@wordpress/components");
|
|
15
|
-
|
|
16
|
-
var _i18n = require("@wordpress/i18n");
|
|
17
|
-
|
|
18
|
-
var _compose = require("@wordpress/compose");
|
|
19
|
-
|
|
20
|
-
/**
|
|
21
|
-
* External dependencies
|
|
22
|
-
*/
|
|
23
|
-
|
|
24
|
-
/**
|
|
25
|
-
* WordPress dependencies
|
|
26
|
-
*/
|
|
27
|
-
function PatternInserterPanel(_ref) {
|
|
28
|
-
let {
|
|
29
|
-
selectedCategory,
|
|
30
|
-
patternCategories,
|
|
31
|
-
onClickCategory,
|
|
32
|
-
openPatternExplorer
|
|
33
|
-
} = _ref;
|
|
34
|
-
const isMobile = (0, _compose.useViewportMatch)('medium', '<');
|
|
35
|
-
|
|
36
|
-
const categoryOptions = () => {
|
|
37
|
-
const options = [];
|
|
38
|
-
patternCategories.map(patternCategory => {
|
|
39
|
-
return options.push({
|
|
40
|
-
value: patternCategory.name,
|
|
41
|
-
label: patternCategory.label
|
|
42
|
-
});
|
|
43
|
-
});
|
|
44
|
-
return options;
|
|
45
|
-
};
|
|
46
|
-
|
|
47
|
-
const onChangeSelect = selected => {
|
|
48
|
-
onClickCategory(patternCategories.find(patternCategory => selected === patternCategory.name));
|
|
49
|
-
};
|
|
50
|
-
|
|
51
|
-
const className = (0, _classnames.default)('block-editor-inserter__panel-header', 'block-editor-inserter__panel-header-patterns'); // In iOS-based mobile devices, the onBlur will fire when selecting an option
|
|
52
|
-
// from a Select element. To prevent closing the useDialog on iOS devices, we
|
|
53
|
-
// stop propagating the onBlur event if there is no relatedTarget, which means
|
|
54
|
-
// that the user most likely did not click on an element within the editor canvas.
|
|
55
|
-
|
|
56
|
-
const onBlur = event => {
|
|
57
|
-
if (!(event !== null && event !== void 0 && event.relatedTarget)) {
|
|
58
|
-
event.stopPropagation();
|
|
59
|
-
}
|
|
60
|
-
};
|
|
61
|
-
|
|
62
|
-
return (0, _element.createElement)(_components.Flex, {
|
|
63
|
-
justify: "space-between",
|
|
64
|
-
align: "start",
|
|
65
|
-
gap: "4",
|
|
66
|
-
className: className
|
|
67
|
-
}, (0, _element.createElement)(_components.FlexItem, {
|
|
68
|
-
isBlock: true
|
|
69
|
-
}, (0, _element.createElement)(_components.SelectControl, {
|
|
70
|
-
className: "block-editor-inserter__panel-dropdown",
|
|
71
|
-
label: (0, _i18n.__)('Filter patterns'),
|
|
72
|
-
hideLabelFromVision: true,
|
|
73
|
-
value: selectedCategory.name,
|
|
74
|
-
onChange: onChangeSelect,
|
|
75
|
-
onBlur: onBlur,
|
|
76
|
-
options: categoryOptions()
|
|
77
|
-
})), !isMobile && (0, _element.createElement)(_components.FlexItem, null, (0, _element.createElement)(_components.Button, {
|
|
78
|
-
variant: "secondary",
|
|
79
|
-
className: "block-editor-inserter__patterns-explorer-expand",
|
|
80
|
-
label: (0, _i18n.__)('Explore all patterns'),
|
|
81
|
-
onClick: () => openPatternExplorer()
|
|
82
|
-
}, (0, _i18n._x)('Explore', 'Label for showing all block patterns'))));
|
|
83
|
-
}
|
|
84
|
-
|
|
85
|
-
var _default = PatternInserterPanel;
|
|
86
|
-
exports.default = _default;
|
|
87
|
-
//# sourceMappingURL=pattern-panel.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["@wordpress/block-editor/src/components/inserter/pattern-panel.js"],"names":["PatternInserterPanel","selectedCategory","patternCategories","onClickCategory","openPatternExplorer","isMobile","categoryOptions","options","map","patternCategory","push","value","name","label","onChangeSelect","selected","find","className","onBlur","event","relatedTarget","stopPropagation"],"mappings":";;;;;;;;;;;AAGA;;AAKA;;AACA;;AACA;;AAVA;AACA;AACA;;AAGA;AACA;AACA;AAKA,SAASA,oBAAT,OAKI;AAAA,MAL2B;AAC9BC,IAAAA,gBAD8B;AAE9BC,IAAAA,iBAF8B;AAG9BC,IAAAA,eAH8B;AAI9BC,IAAAA;AAJ8B,GAK3B;AACH,QAAMC,QAAQ,GAAG,+BAAkB,QAAlB,EAA4B,GAA5B,CAAjB;;AACA,QAAMC,eAAe,GAAG,MAAM;AAC7B,UAAMC,OAAO,GAAG,EAAhB;AAEAL,IAAAA,iBAAiB,CAACM,GAAlB,CAAyBC,eAAF,IAAuB;AAC7C,aAAOF,OAAO,CAACG,IAAR,CAAc;AACpBC,QAAAA,KAAK,EAAEF,eAAe,CAACG,IADH;AAEpBC,QAAAA,KAAK,EAAEJ,eAAe,CAACI;AAFH,OAAd,CAAP;AAIA,KALD;AAOA,WAAON,OAAP;AACA,GAXD;;AAaA,QAAMO,cAAc,GAAKC,QAAF,IAAgB;AACtCZ,IAAAA,eAAe,CACdD,iBAAiB,CAACc,IAAlB,CACGP,eAAF,IAAuBM,QAAQ,KAAKN,eAAe,CAACG,IADrD,CADc,CAAf;AAKA,GAND;;AAQA,QAAMK,SAAS,GAAG,yBACjB,qCADiB,EAEjB,8CAFiB,CAAlB,CAvBG,CA4BH;AACA;AACA;AACA;;AACA,QAAMC,MAAM,GAAKC,KAAF,IAAa;AAC3B,QAAK,EAAEA,KAAF,aAAEA,KAAF,eAAEA,KAAK,CAAEC,aAAT,CAAL,EAA8B;AAC7BD,MAAAA,KAAK,CAACE,eAAN;AACA;AACD,GAJD;;AAMA,SACC,4BAAC,gBAAD;AACC,IAAA,OAAO,EAAC,eADT;AAEC,IAAA,KAAK,EAAC,OAFP;AAGC,IAAA,GAAG,EAAC,GAHL;AAIC,IAAA,SAAS,EAAGJ;AAJb,KAMC,4BAAC,oBAAD;AAAU,IAAA,OAAO;AAAjB,KACC,4BAAC,yBAAD;AACC,IAAA,SAAS,EAAC,uCADX;AAEC,IAAA,KAAK,EAAG,cAAI,iBAAJ,CAFT;AAGC,IAAA,mBAAmB,MAHpB;AAIC,IAAA,KAAK,EAAGhB,gBAAgB,CAACW,IAJ1B;AAKC,IAAA,QAAQ,EAAGE,cALZ;AAMC,IAAA,MAAM,EAAGI,MANV;AAOC,IAAA,OAAO,EAAGZ,eAAe;AAP1B,IADD,CAND,EAiBG,CAAED,QAAF,IACD,4BAAC,oBAAD,QACC,4BAAC,kBAAD;AACC,IAAA,OAAO,EAAC,WADT;AAEC,IAAA,SAAS,EAAC,iDAFX;AAGC,IAAA,KAAK,EAAG,cAAI,sBAAJ,CAHT;AAIC,IAAA,OAAO,EAAG,MAAMD,mBAAmB;AAJpC,KAMG,cACD,SADC,EAED,sCAFC,CANH,CADD,CAlBF,CADD;AAmCA;;eAEcJ,oB","sourcesContent":["/**\n * External dependencies\n */\nimport classnames from 'classnames';\n\n/**\n * WordPress dependencies\n */\nimport { Flex, FlexItem, SelectControl, Button } from '@wordpress/components';\nimport { __, _x } from '@wordpress/i18n';\nimport { useViewportMatch } from '@wordpress/compose';\n\nfunction PatternInserterPanel( {\n\tselectedCategory,\n\tpatternCategories,\n\tonClickCategory,\n\topenPatternExplorer,\n} ) {\n\tconst isMobile = useViewportMatch( 'medium', '<' );\n\tconst categoryOptions = () => {\n\t\tconst options = [];\n\n\t\tpatternCategories.map( ( patternCategory ) => {\n\t\t\treturn options.push( {\n\t\t\t\tvalue: patternCategory.name,\n\t\t\t\tlabel: patternCategory.label,\n\t\t\t} );\n\t\t} );\n\n\t\treturn options;\n\t};\n\n\tconst onChangeSelect = ( selected ) => {\n\t\tonClickCategory(\n\t\t\tpatternCategories.find(\n\t\t\t\t( patternCategory ) => selected === patternCategory.name\n\t\t\t)\n\t\t);\n\t};\n\n\tconst className = classnames(\n\t\t'block-editor-inserter__panel-header',\n\t\t'block-editor-inserter__panel-header-patterns'\n\t);\n\n\t// In iOS-based mobile devices, the onBlur will fire when selecting an option\n\t// from a Select element. To prevent closing the useDialog on iOS devices, we\n\t// stop propagating the onBlur event if there is no relatedTarget, which means\n\t// that the user most likely did not click on an element within the editor canvas.\n\tconst onBlur = ( event ) => {\n\t\tif ( ! event?.relatedTarget ) {\n\t\t\tevent.stopPropagation();\n\t\t}\n\t};\n\n\treturn (\n\t\t<Flex\n\t\t\tjustify=\"space-between\"\n\t\t\talign=\"start\"\n\t\t\tgap=\"4\"\n\t\t\tclassName={ className }\n\t\t>\n\t\t\t<FlexItem isBlock>\n\t\t\t\t<SelectControl\n\t\t\t\t\tclassName=\"block-editor-inserter__panel-dropdown\"\n\t\t\t\t\tlabel={ __( 'Filter patterns' ) }\n\t\t\t\t\thideLabelFromVision\n\t\t\t\t\tvalue={ selectedCategory.name }\n\t\t\t\t\tonChange={ onChangeSelect }\n\t\t\t\t\tonBlur={ onBlur }\n\t\t\t\t\toptions={ categoryOptions() }\n\t\t\t\t/>\n\t\t\t</FlexItem>\n\t\t\t{ ! isMobile && (\n\t\t\t\t<FlexItem>\n\t\t\t\t\t<Button\n\t\t\t\t\t\tvariant=\"secondary\"\n\t\t\t\t\t\tclassName=\"block-editor-inserter__patterns-explorer-expand\"\n\t\t\t\t\t\tlabel={ __( 'Explore all patterns' ) }\n\t\t\t\t\t\tonClick={ () => openPatternExplorer() }\n\t\t\t\t\t>\n\t\t\t\t\t\t{ _x(\n\t\t\t\t\t\t\t'Explore',\n\t\t\t\t\t\t\t'Label for showing all block patterns'\n\t\t\t\t\t\t) }\n\t\t\t\t\t</Button>\n\t\t\t\t</FlexItem>\n\t\t\t) }\n\t\t</Flex>\n\t);\n}\n\nexport default PatternInserterPanel;\n"]}
|
|
@@ -1,74 +0,0 @@
|
|
|
1
|
-
import { createElement } from "@wordpress/element";
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* External dependencies
|
|
5
|
-
*/
|
|
6
|
-
import classnames from 'classnames';
|
|
7
|
-
/**
|
|
8
|
-
* WordPress dependencies
|
|
9
|
-
*/
|
|
10
|
-
|
|
11
|
-
import { Flex, FlexItem, SelectControl, Button } from '@wordpress/components';
|
|
12
|
-
import { __, _x } from '@wordpress/i18n';
|
|
13
|
-
import { useViewportMatch } from '@wordpress/compose';
|
|
14
|
-
|
|
15
|
-
function PatternInserterPanel(_ref) {
|
|
16
|
-
let {
|
|
17
|
-
selectedCategory,
|
|
18
|
-
patternCategories,
|
|
19
|
-
onClickCategory,
|
|
20
|
-
openPatternExplorer
|
|
21
|
-
} = _ref;
|
|
22
|
-
const isMobile = useViewportMatch('medium', '<');
|
|
23
|
-
|
|
24
|
-
const categoryOptions = () => {
|
|
25
|
-
const options = [];
|
|
26
|
-
patternCategories.map(patternCategory => {
|
|
27
|
-
return options.push({
|
|
28
|
-
value: patternCategory.name,
|
|
29
|
-
label: patternCategory.label
|
|
30
|
-
});
|
|
31
|
-
});
|
|
32
|
-
return options;
|
|
33
|
-
};
|
|
34
|
-
|
|
35
|
-
const onChangeSelect = selected => {
|
|
36
|
-
onClickCategory(patternCategories.find(patternCategory => selected === patternCategory.name));
|
|
37
|
-
};
|
|
38
|
-
|
|
39
|
-
const className = classnames('block-editor-inserter__panel-header', 'block-editor-inserter__panel-header-patterns'); // In iOS-based mobile devices, the onBlur will fire when selecting an option
|
|
40
|
-
// from a Select element. To prevent closing the useDialog on iOS devices, we
|
|
41
|
-
// stop propagating the onBlur event if there is no relatedTarget, which means
|
|
42
|
-
// that the user most likely did not click on an element within the editor canvas.
|
|
43
|
-
|
|
44
|
-
const onBlur = event => {
|
|
45
|
-
if (!(event !== null && event !== void 0 && event.relatedTarget)) {
|
|
46
|
-
event.stopPropagation();
|
|
47
|
-
}
|
|
48
|
-
};
|
|
49
|
-
|
|
50
|
-
return createElement(Flex, {
|
|
51
|
-
justify: "space-between",
|
|
52
|
-
align: "start",
|
|
53
|
-
gap: "4",
|
|
54
|
-
className: className
|
|
55
|
-
}, createElement(FlexItem, {
|
|
56
|
-
isBlock: true
|
|
57
|
-
}, createElement(SelectControl, {
|
|
58
|
-
className: "block-editor-inserter__panel-dropdown",
|
|
59
|
-
label: __('Filter patterns'),
|
|
60
|
-
hideLabelFromVision: true,
|
|
61
|
-
value: selectedCategory.name,
|
|
62
|
-
onChange: onChangeSelect,
|
|
63
|
-
onBlur: onBlur,
|
|
64
|
-
options: categoryOptions()
|
|
65
|
-
})), !isMobile && createElement(FlexItem, null, createElement(Button, {
|
|
66
|
-
variant: "secondary",
|
|
67
|
-
className: "block-editor-inserter__patterns-explorer-expand",
|
|
68
|
-
label: __('Explore all patterns'),
|
|
69
|
-
onClick: () => openPatternExplorer()
|
|
70
|
-
}, _x('Explore', 'Label for showing all block patterns'))));
|
|
71
|
-
}
|
|
72
|
-
|
|
73
|
-
export default PatternInserterPanel;
|
|
74
|
-
//# sourceMappingURL=pattern-panel.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["@wordpress/block-editor/src/components/inserter/pattern-panel.js"],"names":["classnames","Flex","FlexItem","SelectControl","Button","__","_x","useViewportMatch","PatternInserterPanel","selectedCategory","patternCategories","onClickCategory","openPatternExplorer","isMobile","categoryOptions","options","map","patternCategory","push","value","name","label","onChangeSelect","selected","find","className","onBlur","event","relatedTarget","stopPropagation"],"mappings":";;AAAA;AACA;AACA;AACA,OAAOA,UAAP,MAAuB,YAAvB;AAEA;AACA;AACA;;AACA,SAASC,IAAT,EAAeC,QAAf,EAAyBC,aAAzB,EAAwCC,MAAxC,QAAsD,uBAAtD;AACA,SAASC,EAAT,EAAaC,EAAb,QAAuB,iBAAvB;AACA,SAASC,gBAAT,QAAiC,oBAAjC;;AAEA,SAASC,oBAAT,OAKI;AAAA,MAL2B;AAC9BC,IAAAA,gBAD8B;AAE9BC,IAAAA,iBAF8B;AAG9BC,IAAAA,eAH8B;AAI9BC,IAAAA;AAJ8B,GAK3B;AACH,QAAMC,QAAQ,GAAGN,gBAAgB,CAAE,QAAF,EAAY,GAAZ,CAAjC;;AACA,QAAMO,eAAe,GAAG,MAAM;AAC7B,UAAMC,OAAO,GAAG,EAAhB;AAEAL,IAAAA,iBAAiB,CAACM,GAAlB,CAAyBC,eAAF,IAAuB;AAC7C,aAAOF,OAAO,CAACG,IAAR,CAAc;AACpBC,QAAAA,KAAK,EAAEF,eAAe,CAACG,IADH;AAEpBC,QAAAA,KAAK,EAAEJ,eAAe,CAACI;AAFH,OAAd,CAAP;AAIA,KALD;AAOA,WAAON,OAAP;AACA,GAXD;;AAaA,QAAMO,cAAc,GAAKC,QAAF,IAAgB;AACtCZ,IAAAA,eAAe,CACdD,iBAAiB,CAACc,IAAlB,CACGP,eAAF,IAAuBM,QAAQ,KAAKN,eAAe,CAACG,IADrD,CADc,CAAf;AAKA,GAND;;AAQA,QAAMK,SAAS,GAAGzB,UAAU,CAC3B,qCAD2B,EAE3B,8CAF2B,CAA5B,CAvBG,CA4BH;AACA;AACA;AACA;;AACA,QAAM0B,MAAM,GAAKC,KAAF,IAAa;AAC3B,QAAK,EAAEA,KAAF,aAAEA,KAAF,eAAEA,KAAK,CAAEC,aAAT,CAAL,EAA8B;AAC7BD,MAAAA,KAAK,CAACE,eAAN;AACA;AACD,GAJD;;AAMA,SACC,cAAC,IAAD;AACC,IAAA,OAAO,EAAC,eADT;AAEC,IAAA,KAAK,EAAC,OAFP;AAGC,IAAA,GAAG,EAAC,GAHL;AAIC,IAAA,SAAS,EAAGJ;AAJb,KAMC,cAAC,QAAD;AAAU,IAAA,OAAO;AAAjB,KACC,cAAC,aAAD;AACC,IAAA,SAAS,EAAC,uCADX;AAEC,IAAA,KAAK,EAAGpB,EAAE,CAAE,iBAAF,CAFX;AAGC,IAAA,mBAAmB,MAHpB;AAIC,IAAA,KAAK,EAAGI,gBAAgB,CAACW,IAJ1B;AAKC,IAAA,QAAQ,EAAGE,cALZ;AAMC,IAAA,MAAM,EAAGI,MANV;AAOC,IAAA,OAAO,EAAGZ,eAAe;AAP1B,IADD,CAND,EAiBG,CAAED,QAAF,IACD,cAAC,QAAD,QACC,cAAC,MAAD;AACC,IAAA,OAAO,EAAC,WADT;AAEC,IAAA,SAAS,EAAC,iDAFX;AAGC,IAAA,KAAK,EAAGR,EAAE,CAAE,sBAAF,CAHX;AAIC,IAAA,OAAO,EAAG,MAAMO,mBAAmB;AAJpC,KAMGN,EAAE,CACH,SADG,EAEH,sCAFG,CANL,CADD,CAlBF,CADD;AAmCA;;AAED,eAAeE,oBAAf","sourcesContent":["/**\n * External dependencies\n */\nimport classnames from 'classnames';\n\n/**\n * WordPress dependencies\n */\nimport { Flex, FlexItem, SelectControl, Button } from '@wordpress/components';\nimport { __, _x } from '@wordpress/i18n';\nimport { useViewportMatch } from '@wordpress/compose';\n\nfunction PatternInserterPanel( {\n\tselectedCategory,\n\tpatternCategories,\n\tonClickCategory,\n\topenPatternExplorer,\n} ) {\n\tconst isMobile = useViewportMatch( 'medium', '<' );\n\tconst categoryOptions = () => {\n\t\tconst options = [];\n\n\t\tpatternCategories.map( ( patternCategory ) => {\n\t\t\treturn options.push( {\n\t\t\t\tvalue: patternCategory.name,\n\t\t\t\tlabel: patternCategory.label,\n\t\t\t} );\n\t\t} );\n\n\t\treturn options;\n\t};\n\n\tconst onChangeSelect = ( selected ) => {\n\t\tonClickCategory(\n\t\t\tpatternCategories.find(\n\t\t\t\t( patternCategory ) => selected === patternCategory.name\n\t\t\t)\n\t\t);\n\t};\n\n\tconst className = classnames(\n\t\t'block-editor-inserter__panel-header',\n\t\t'block-editor-inserter__panel-header-patterns'\n\t);\n\n\t// In iOS-based mobile devices, the onBlur will fire when selecting an option\n\t// from a Select element. To prevent closing the useDialog on iOS devices, we\n\t// stop propagating the onBlur event if there is no relatedTarget, which means\n\t// that the user most likely did not click on an element within the editor canvas.\n\tconst onBlur = ( event ) => {\n\t\tif ( ! event?.relatedTarget ) {\n\t\t\tevent.stopPropagation();\n\t\t}\n\t};\n\n\treturn (\n\t\t<Flex\n\t\t\tjustify=\"space-between\"\n\t\t\talign=\"start\"\n\t\t\tgap=\"4\"\n\t\t\tclassName={ className }\n\t\t>\n\t\t\t<FlexItem isBlock>\n\t\t\t\t<SelectControl\n\t\t\t\t\tclassName=\"block-editor-inserter__panel-dropdown\"\n\t\t\t\t\tlabel={ __( 'Filter patterns' ) }\n\t\t\t\t\thideLabelFromVision\n\t\t\t\t\tvalue={ selectedCategory.name }\n\t\t\t\t\tonChange={ onChangeSelect }\n\t\t\t\t\tonBlur={ onBlur }\n\t\t\t\t\toptions={ categoryOptions() }\n\t\t\t\t/>\n\t\t\t</FlexItem>\n\t\t\t{ ! isMobile && (\n\t\t\t\t<FlexItem>\n\t\t\t\t\t<Button\n\t\t\t\t\t\tvariant=\"secondary\"\n\t\t\t\t\t\tclassName=\"block-editor-inserter__patterns-explorer-expand\"\n\t\t\t\t\t\tlabel={ __( 'Explore all patterns' ) }\n\t\t\t\t\t\tonClick={ () => openPatternExplorer() }\n\t\t\t\t\t>\n\t\t\t\t\t\t{ _x(\n\t\t\t\t\t\t\t'Explore',\n\t\t\t\t\t\t\t'Label for showing all block patterns'\n\t\t\t\t\t\t) }\n\t\t\t\t\t</Button>\n\t\t\t\t</FlexItem>\n\t\t\t) }\n\t\t</Flex>\n\t);\n}\n\nexport default PatternInserterPanel;\n"]}
|
|
@@ -1,93 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* External dependencies
|
|
3
|
-
*/
|
|
4
|
-
import classnames from 'classnames';
|
|
5
|
-
|
|
6
|
-
/**
|
|
7
|
-
* WordPress dependencies
|
|
8
|
-
*/
|
|
9
|
-
import { Flex, FlexItem, SelectControl, Button } from '@wordpress/components';
|
|
10
|
-
import { __, _x } from '@wordpress/i18n';
|
|
11
|
-
import { useViewportMatch } from '@wordpress/compose';
|
|
12
|
-
|
|
13
|
-
function PatternInserterPanel( {
|
|
14
|
-
selectedCategory,
|
|
15
|
-
patternCategories,
|
|
16
|
-
onClickCategory,
|
|
17
|
-
openPatternExplorer,
|
|
18
|
-
} ) {
|
|
19
|
-
const isMobile = useViewportMatch( 'medium', '<' );
|
|
20
|
-
const categoryOptions = () => {
|
|
21
|
-
const options = [];
|
|
22
|
-
|
|
23
|
-
patternCategories.map( ( patternCategory ) => {
|
|
24
|
-
return options.push( {
|
|
25
|
-
value: patternCategory.name,
|
|
26
|
-
label: patternCategory.label,
|
|
27
|
-
} );
|
|
28
|
-
} );
|
|
29
|
-
|
|
30
|
-
return options;
|
|
31
|
-
};
|
|
32
|
-
|
|
33
|
-
const onChangeSelect = ( selected ) => {
|
|
34
|
-
onClickCategory(
|
|
35
|
-
patternCategories.find(
|
|
36
|
-
( patternCategory ) => selected === patternCategory.name
|
|
37
|
-
)
|
|
38
|
-
);
|
|
39
|
-
};
|
|
40
|
-
|
|
41
|
-
const className = classnames(
|
|
42
|
-
'block-editor-inserter__panel-header',
|
|
43
|
-
'block-editor-inserter__panel-header-patterns'
|
|
44
|
-
);
|
|
45
|
-
|
|
46
|
-
// In iOS-based mobile devices, the onBlur will fire when selecting an option
|
|
47
|
-
// from a Select element. To prevent closing the useDialog on iOS devices, we
|
|
48
|
-
// stop propagating the onBlur event if there is no relatedTarget, which means
|
|
49
|
-
// that the user most likely did not click on an element within the editor canvas.
|
|
50
|
-
const onBlur = ( event ) => {
|
|
51
|
-
if ( ! event?.relatedTarget ) {
|
|
52
|
-
event.stopPropagation();
|
|
53
|
-
}
|
|
54
|
-
};
|
|
55
|
-
|
|
56
|
-
return (
|
|
57
|
-
<Flex
|
|
58
|
-
justify="space-between"
|
|
59
|
-
align="start"
|
|
60
|
-
gap="4"
|
|
61
|
-
className={ className }
|
|
62
|
-
>
|
|
63
|
-
<FlexItem isBlock>
|
|
64
|
-
<SelectControl
|
|
65
|
-
className="block-editor-inserter__panel-dropdown"
|
|
66
|
-
label={ __( 'Filter patterns' ) }
|
|
67
|
-
hideLabelFromVision
|
|
68
|
-
value={ selectedCategory.name }
|
|
69
|
-
onChange={ onChangeSelect }
|
|
70
|
-
onBlur={ onBlur }
|
|
71
|
-
options={ categoryOptions() }
|
|
72
|
-
/>
|
|
73
|
-
</FlexItem>
|
|
74
|
-
{ ! isMobile && (
|
|
75
|
-
<FlexItem>
|
|
76
|
-
<Button
|
|
77
|
-
variant="secondary"
|
|
78
|
-
className="block-editor-inserter__patterns-explorer-expand"
|
|
79
|
-
label={ __( 'Explore all patterns' ) }
|
|
80
|
-
onClick={ () => openPatternExplorer() }
|
|
81
|
-
>
|
|
82
|
-
{ _x(
|
|
83
|
-
'Explore',
|
|
84
|
-
'Label for showing all block patterns'
|
|
85
|
-
) }
|
|
86
|
-
</Button>
|
|
87
|
-
</FlexItem>
|
|
88
|
-
) }
|
|
89
|
-
</Flex>
|
|
90
|
-
);
|
|
91
|
-
}
|
|
92
|
-
|
|
93
|
-
export default PatternInserterPanel;
|