@wordpress/block-editor 14.6.0 → 14.7.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 +2 -0
- package/build/components/block-list/block.js +14 -28
- package/build/components/block-list/block.js.map +1 -1
- package/build/components/block-patterns-list/index.js +23 -26
- package/build/components/block-patterns-list/index.js.map +1 -1
- package/build/components/block-popover/index.js +1 -1
- package/build/components/block-popover/index.js.map +1 -1
- package/build/components/block-preview/async.js +51 -0
- package/build/components/block-preview/async.js.map +1 -0
- package/build/components/block-preview/index.js +4 -1
- package/build/components/block-preview/index.js.map +1 -1
- package/build/components/block-toolbar/change-design.js +1 -4
- package/build/components/block-toolbar/change-design.js.map +1 -1
- package/build/components/block-tools/index.js +12 -9
- package/build/components/block-tools/index.js.map +1 -1
- package/build/components/block-tools/use-block-toolbar-popover-props.js +1 -1
- package/build/components/block-tools/use-block-toolbar-popover-props.js.map +1 -1
- package/build/components/block-tools/use-show-block-tools.js +4 -1
- package/build/components/block-tools/use-show-block-tools.js.map +1 -1
- package/build/components/global-styles/dimensions-panel.js +26 -14
- package/build/components/global-styles/dimensions-panel.js.map +1 -1
- package/build/components/iframe/get-compatibility-styles.js +4 -4
- package/build/components/iframe/get-compatibility-styles.js.map +1 -1
- package/build/components/iframe/index.js +16 -0
- package/build/components/iframe/index.js.map +1 -1
- package/build/components/inserter/block-patterns-explorer/pattern-list.js +2 -2
- package/build/components/inserter/block-patterns-explorer/pattern-list.js.map +1 -1
- package/build/components/inserter/block-patterns-tab/index.js +1 -2
- package/build/components/inserter/block-patterns-tab/index.js.map +1 -1
- package/build/components/inserter/block-patterns-tab/pattern-category-previews.js +3 -1
- package/build/components/inserter/block-patterns-tab/pattern-category-previews.js.map +1 -1
- package/build/components/inserter/block-patterns-tab/use-pattern-categories.js +3 -0
- package/build/components/inserter/block-patterns-tab/use-pattern-categories.js.map +1 -1
- package/build/components/inserter/block-patterns-tab/utils.js +5 -1
- package/build/components/inserter/block-patterns-tab/utils.js.map +1 -1
- package/build/components/inserter/hooks/use-block-types-state.js +1 -1
- package/build/components/inserter/hooks/use-block-types-state.js.map +1 -1
- package/build/components/inserter/hooks/use-patterns-paging.js +0 -5
- package/build/components/inserter/hooks/use-patterns-paging.js.map +1 -1
- package/build/components/inserter/search-results.js +0 -2
- package/build/components/inserter/search-results.js.map +1 -1
- package/build/components/media-placeholder/index.js +4 -4
- package/build/components/media-placeholder/index.js.map +1 -1
- package/build/components/rich-text/index.js +1 -1
- package/build/components/rich-text/index.js.map +1 -1
- package/build/components/tabbed-sidebar/index.js +1 -1
- package/build/components/tabbed-sidebar/index.js.map +1 -1
- package/build/components/url-input/index.js +3 -1
- package/build/components/url-input/index.js.map +1 -1
- package/build/components/use-block-commands/index.js +5 -6
- package/build/components/use-block-commands/index.js.map +1 -1
- package/build/hooks/font-family.js +1 -1
- package/build/hooks/font-family.js.map +1 -1
- package/build/hooks/supports.js +6 -6
- package/build/hooks/supports.js.map +1 -1
- package/build/hooks/typography.js +5 -5
- package/build/hooks/typography.js.map +1 -1
- package/build/hooks/utils.js +2 -2
- package/build/hooks/utils.js.map +1 -1
- package/build/lock-unlock.js.map +1 -1
- package/build/store/private-selectors.js +2 -2
- package/build/store/private-selectors.js.map +1 -1
- package/build/store/selectors.js +9 -8
- package/build/store/selectors.js.map +1 -1
- package/build/store/utils.js +5 -4
- package/build/store/utils.js.map +1 -1
- package/build/utils/dom.js +27 -22
- package/build/utils/dom.js.map +1 -1
- package/build-module/components/block-list/block.js +15 -27
- package/build-module/components/block-list/block.js.map +1 -1
- package/build-module/components/block-patterns-list/index.js +23 -26
- package/build-module/components/block-patterns-list/index.js.map +1 -1
- package/build-module/components/block-popover/index.js +2 -2
- package/build-module/components/block-popover/index.js.map +1 -1
- package/build-module/components/block-preview/async.js +44 -0
- package/build-module/components/block-preview/async.js.map +1 -0
- package/build-module/components/block-preview/index.js +4 -1
- package/build-module/components/block-preview/index.js.map +1 -1
- package/build-module/components/block-toolbar/change-design.js +1 -4
- package/build-module/components/block-toolbar/change-design.js.map +1 -1
- package/build-module/components/block-tools/index.js +13 -10
- package/build-module/components/block-tools/index.js.map +1 -1
- package/build-module/components/block-tools/use-block-toolbar-popover-props.js +2 -2
- package/build-module/components/block-tools/use-block-toolbar-popover-props.js.map +1 -1
- package/build-module/components/block-tools/use-show-block-tools.js +4 -1
- package/build-module/components/block-tools/use-show-block-tools.js.map +1 -1
- package/build-module/components/global-styles/dimensions-panel.js +26 -14
- package/build-module/components/global-styles/dimensions-panel.js.map +1 -1
- package/build-module/components/iframe/get-compatibility-styles.js +4 -4
- package/build-module/components/iframe/get-compatibility-styles.js.map +1 -1
- package/build-module/components/iframe/index.js +16 -0
- package/build-module/components/iframe/index.js.map +1 -1
- package/build-module/components/inserter/block-patterns-explorer/pattern-list.js +2 -2
- package/build-module/components/inserter/block-patterns-explorer/pattern-list.js.map +1 -1
- package/build-module/components/inserter/block-patterns-tab/index.js +1 -2
- package/build-module/components/inserter/block-patterns-tab/index.js.map +1 -1
- package/build-module/components/inserter/block-patterns-tab/pattern-category-previews.js +4 -2
- package/build-module/components/inserter/block-patterns-tab/pattern-category-previews.js.map +1 -1
- package/build-module/components/inserter/block-patterns-tab/use-pattern-categories.js +4 -1
- package/build-module/components/inserter/block-patterns-tab/use-pattern-categories.js.map +1 -1
- package/build-module/components/inserter/block-patterns-tab/utils.js +4 -0
- package/build-module/components/inserter/block-patterns-tab/utils.js.map +1 -1
- package/build-module/components/inserter/hooks/use-block-types-state.js +1 -1
- package/build-module/components/inserter/hooks/use-block-types-state.js.map +1 -1
- package/build-module/components/inserter/hooks/use-patterns-paging.js +1 -6
- package/build-module/components/inserter/hooks/use-patterns-paging.js.map +1 -1
- package/build-module/components/inserter/search-results.js +0 -2
- package/build-module/components/inserter/search-results.js.map +1 -1
- package/build-module/components/media-placeholder/index.js +4 -4
- package/build-module/components/media-placeholder/index.js.map +1 -1
- package/build-module/components/rich-text/index.js +1 -1
- package/build-module/components/rich-text/index.js.map +1 -1
- package/build-module/components/tabbed-sidebar/index.js +1 -1
- package/build-module/components/tabbed-sidebar/index.js.map +1 -1
- package/build-module/components/url-input/index.js +3 -1
- package/build-module/components/url-input/index.js.map +1 -1
- package/build-module/components/use-block-commands/index.js +4 -4
- package/build-module/components/use-block-commands/index.js.map +1 -1
- package/build-module/hooks/font-family.js +1 -1
- package/build-module/hooks/font-family.js.map +1 -1
- package/build-module/hooks/supports.js +6 -6
- package/build-module/hooks/supports.js.map +1 -1
- package/build-module/hooks/typography.js +5 -5
- package/build-module/hooks/typography.js.map +1 -1
- package/build-module/hooks/utils.js +2 -2
- package/build-module/hooks/utils.js.map +1 -1
- package/build-module/lock-unlock.js.map +1 -1
- package/build-module/store/private-selectors.js +2 -2
- package/build-module/store/private-selectors.js.map +1 -1
- package/build-module/store/selectors.js +9 -8
- package/build-module/store/selectors.js.map +1 -1
- package/build-module/store/utils.js +3 -3
- package/build-module/store/utils.js.map +1 -1
- package/build-module/utils/dom.js +25 -21
- package/build-module/utils/dom.js.map +1 -1
- package/build-style/content-rtl.css +7 -6
- package/build-style/content.css +7 -6
- package/build-style/style-rtl.css +14 -3
- package/build-style/style.css +14 -3
- package/build-types/utils/dom.d.ts +7 -9
- package/build-types/utils/dom.d.ts.map +1 -1
- package/package.json +4 -3
- package/src/components/block-canvas/style.scss +1 -1
- package/src/components/block-inspector/style.scss +2 -1
- package/src/components/block-list/block.js +28 -48
- package/src/components/block-patterns-list/README.md +8 -8
- package/src/components/block-patterns-list/index.js +35 -51
- package/src/components/block-patterns-list/stories/index.story.js +2 -19
- package/src/components/block-popover/index.js +4 -4
- package/src/components/block-preview/async.js +43 -0
- package/src/components/block-preview/index.js +6 -1
- package/src/components/block-toolbar/change-design.js +1 -7
- package/src/components/block-tools/index.js +26 -10
- package/src/components/block-tools/style.scss +12 -0
- package/src/components/block-tools/use-block-toolbar-popover-props.js +2 -2
- package/src/components/block-tools/use-show-block-tools.js +3 -1
- package/src/components/default-block-appender/content.scss +13 -19
- package/src/components/global-styles/dimensions-panel.js +22 -16
- package/src/components/iframe/get-compatibility-styles.js +4 -9
- package/src/components/iframe/index.js +17 -0
- package/src/components/inserter/block-patterns-explorer/pattern-list.js +3 -6
- package/src/components/inserter/block-patterns-tab/index.js +0 -1
- package/src/components/inserter/block-patterns-tab/pattern-category-previews.js +8 -1
- package/src/components/inserter/block-patterns-tab/use-pattern-categories.js +8 -0
- package/src/components/inserter/block-patterns-tab/utils.js +5 -0
- package/src/components/inserter/hooks/use-block-types-state.js +6 -1
- package/src/components/inserter/hooks/use-patterns-paging.js +1 -6
- package/src/components/inserter/search-results.js +0 -6
- package/src/components/media-placeholder/index.js +4 -4
- package/src/components/rich-text/index.js +8 -1
- package/src/components/tabbed-sidebar/index.js +1 -1
- package/src/components/tabbed-sidebar/style.scss +1 -1
- package/src/components/url-input/index.js +3 -4
- package/src/components/use-block-commands/index.js +245 -234
- package/src/hooks/font-family.js +1 -1
- package/src/hooks/supports.js +6 -6
- package/src/hooks/typography.js +5 -5
- package/src/hooks/utils.js +7 -2
- package/src/store/private-selectors.js +5 -6
- package/src/store/selectors.js +57 -45
- package/src/store/test/private-selectors.js +5 -0
- package/src/store/utils.js +12 -11
- package/src/utils/dom.js +26 -21
- package/src/utils/test/dom.js +224 -0
- package/tsconfig.json +1 -0
- package/tsconfig.tsbuildinfo +1 -1
- /package/src/{lock-unlock.js → lock-unlock.ts} +0 -0
|
@@ -24,275 +24,286 @@ import {
|
|
|
24
24
|
import BlockIcon from '../block-icon';
|
|
25
25
|
import { store as blockEditorStore } from '../../store';
|
|
26
26
|
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
blocks,
|
|
31
|
-
clientIds,
|
|
32
|
-
canRemove,
|
|
33
|
-
possibleBlockTransformations,
|
|
34
|
-
invalidSelection,
|
|
35
|
-
} = useSelect( ( select ) => {
|
|
27
|
+
const getTransformCommands = () =>
|
|
28
|
+
function useTransformCommands() {
|
|
29
|
+
const { replaceBlocks, multiSelect } = useDispatch( blockEditorStore );
|
|
36
30
|
const {
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
} =
|
|
31
|
+
blocks,
|
|
32
|
+
clientIds,
|
|
33
|
+
canRemove,
|
|
34
|
+
possibleBlockTransformations,
|
|
35
|
+
invalidSelection,
|
|
36
|
+
} = useSelect( ( select ) => {
|
|
37
|
+
const {
|
|
38
|
+
getBlockRootClientId,
|
|
39
|
+
getBlockTransformItems,
|
|
40
|
+
getSelectedBlockClientIds,
|
|
41
|
+
getBlocksByClientId,
|
|
42
|
+
canRemoveBlocks,
|
|
43
|
+
} = select( blockEditorStore );
|
|
44
|
+
|
|
45
|
+
const selectedBlockClientIds = getSelectedBlockClientIds();
|
|
46
|
+
const selectedBlocks = getBlocksByClientId(
|
|
47
|
+
selectedBlockClientIds
|
|
48
|
+
);
|
|
49
|
+
|
|
50
|
+
// selectedBlocks can have `null`s when something tries to call `selectBlock` with an inexistent clientId.
|
|
51
|
+
// These nulls will cause fatal errors down the line.
|
|
52
|
+
// In order to prevent discrepancies between selectedBlockClientIds and selectedBlocks, we effectively treat the entire selection as invalid.
|
|
53
|
+
// @see https://github.com/WordPress/gutenberg/pull/59410#issuecomment-2006304536
|
|
54
|
+
if ( selectedBlocks.filter( ( block ) => ! block ).length > 0 ) {
|
|
55
|
+
return {
|
|
56
|
+
invalidSelection: true,
|
|
57
|
+
};
|
|
58
|
+
}
|
|
43
59
|
|
|
44
|
-
|
|
45
|
-
|
|
60
|
+
const rootClientId = getBlockRootClientId(
|
|
61
|
+
selectedBlockClientIds[ 0 ]
|
|
62
|
+
);
|
|
63
|
+
return {
|
|
64
|
+
blocks: selectedBlocks,
|
|
65
|
+
clientIds: selectedBlockClientIds,
|
|
66
|
+
possibleBlockTransformations: getBlockTransformItems(
|
|
67
|
+
selectedBlocks,
|
|
68
|
+
rootClientId
|
|
69
|
+
),
|
|
70
|
+
canRemove: canRemoveBlocks( selectedBlockClientIds ),
|
|
71
|
+
invalidSelection: false,
|
|
72
|
+
};
|
|
73
|
+
}, [] );
|
|
46
74
|
|
|
47
|
-
|
|
48
|
-
// These nulls will cause fatal errors down the line.
|
|
49
|
-
// In order to prevent discrepancies between selectedBlockClientIds and selectedBlocks, we effectively treat the entire selection as invalid.
|
|
50
|
-
// @see https://github.com/WordPress/gutenberg/pull/59410#issuecomment-2006304536
|
|
51
|
-
if ( selectedBlocks.filter( ( block ) => ! block ).length > 0 ) {
|
|
75
|
+
if ( invalidSelection ) {
|
|
52
76
|
return {
|
|
53
|
-
|
|
77
|
+
isLoading: false,
|
|
78
|
+
commands: [],
|
|
54
79
|
};
|
|
55
80
|
}
|
|
81
|
+
const isTemplate = blocks.length === 1 && isTemplatePart( blocks[ 0 ] );
|
|
82
|
+
|
|
83
|
+
function selectForMultipleBlocks( insertedBlocks ) {
|
|
84
|
+
if ( insertedBlocks.length > 1 ) {
|
|
85
|
+
multiSelect(
|
|
86
|
+
insertedBlocks[ 0 ].clientId,
|
|
87
|
+
insertedBlocks[ insertedBlocks.length - 1 ].clientId
|
|
88
|
+
);
|
|
89
|
+
}
|
|
90
|
+
}
|
|
56
91
|
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
possibleBlockTransformations: getBlockTransformItems(
|
|
64
|
-
selectedBlocks,
|
|
65
|
-
rootClientId
|
|
66
|
-
),
|
|
67
|
-
canRemove: canRemoveBlocks( selectedBlockClientIds ),
|
|
68
|
-
invalidSelection: false,
|
|
69
|
-
};
|
|
70
|
-
}, [] );
|
|
92
|
+
// Simple block tranformation based on the `Block Transforms` API.
|
|
93
|
+
function onBlockTransform( name ) {
|
|
94
|
+
const newBlocks = switchToBlockType( blocks, name );
|
|
95
|
+
replaceBlocks( clientIds, newBlocks );
|
|
96
|
+
selectForMultipleBlocks( newBlocks );
|
|
97
|
+
}
|
|
71
98
|
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
99
|
+
/**
|
|
100
|
+
* The `isTemplate` check is a stopgap solution here.
|
|
101
|
+
* Ideally, the Transforms API should handle this
|
|
102
|
+
* by allowing to exclude blocks from wildcard transformations.
|
|
103
|
+
*/
|
|
104
|
+
const hasPossibleBlockTransformations =
|
|
105
|
+
!! possibleBlockTransformations.length && canRemove && ! isTemplate;
|
|
106
|
+
|
|
107
|
+
if (
|
|
108
|
+
! clientIds ||
|
|
109
|
+
clientIds.length < 1 ||
|
|
110
|
+
! hasPossibleBlockTransformations
|
|
111
|
+
) {
|
|
112
|
+
return { isLoading: false, commands: [] };
|
|
86
113
|
}
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
114
|
+
|
|
115
|
+
const commands = possibleBlockTransformations.map(
|
|
116
|
+
( transformation ) => {
|
|
117
|
+
const { name, title, icon } = transformation;
|
|
118
|
+
return {
|
|
119
|
+
name:
|
|
120
|
+
'core/block-editor/transform-to-' +
|
|
121
|
+
name.replace( '/', '-' ),
|
|
122
|
+
/* translators: %s: Block or block variation name. */
|
|
123
|
+
label: sprintf( __( 'Transform to %s' ), title ),
|
|
124
|
+
icon: <BlockIcon icon={ icon } />,
|
|
125
|
+
callback: ( { close } ) => {
|
|
126
|
+
onBlockTransform( name );
|
|
127
|
+
close();
|
|
128
|
+
},
|
|
129
|
+
};
|
|
130
|
+
}
|
|
131
|
+
);
|
|
132
|
+
|
|
133
|
+
return { isLoading: false, commands };
|
|
134
|
+
};
|
|
135
|
+
|
|
136
|
+
const getQuickActionsCommands = () =>
|
|
137
|
+
function useQuickActionsCommands() {
|
|
138
|
+
const { clientIds, isUngroupable, isGroupable } = useSelect(
|
|
139
|
+
( select ) => {
|
|
140
|
+
const {
|
|
141
|
+
getSelectedBlockClientIds,
|
|
142
|
+
isUngroupable: _isUngroupable,
|
|
143
|
+
isGroupable: _isGroupable,
|
|
144
|
+
} = select( blockEditorStore );
|
|
145
|
+
const selectedBlockClientIds = getSelectedBlockClientIds();
|
|
146
|
+
|
|
147
|
+
return {
|
|
148
|
+
clientIds: selectedBlockClientIds,
|
|
149
|
+
isUngroupable: _isUngroupable(),
|
|
150
|
+
isGroupable: _isGroupable(),
|
|
151
|
+
};
|
|
122
152
|
},
|
|
123
|
-
|
|
124
|
-
|
|
153
|
+
[]
|
|
154
|
+
);
|
|
155
|
+
const {
|
|
156
|
+
canInsertBlockType,
|
|
157
|
+
getBlockRootClientId,
|
|
158
|
+
getBlocksByClientId,
|
|
159
|
+
canRemoveBlocks,
|
|
160
|
+
} = useSelect( blockEditorStore );
|
|
161
|
+
const { getDefaultBlockName, getGroupingBlockName } =
|
|
162
|
+
useSelect( blocksStore );
|
|
125
163
|
|
|
126
|
-
|
|
127
|
-
};
|
|
164
|
+
const blocks = getBlocksByClientId( clientIds );
|
|
128
165
|
|
|
129
|
-
const useQuickActionsCommands = () => {
|
|
130
|
-
const { clientIds, isUngroupable, isGroupable } = useSelect( ( select ) => {
|
|
131
166
|
const {
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
167
|
+
removeBlocks,
|
|
168
|
+
replaceBlocks,
|
|
169
|
+
duplicateBlocks,
|
|
170
|
+
insertAfterBlock,
|
|
171
|
+
insertBeforeBlock,
|
|
172
|
+
} = useDispatch( blockEditorStore );
|
|
173
|
+
|
|
174
|
+
const onGroup = () => {
|
|
175
|
+
if ( ! blocks.length ) {
|
|
176
|
+
return;
|
|
177
|
+
}
|
|
137
178
|
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
179
|
+
const groupingBlockName = getGroupingBlockName();
|
|
180
|
+
|
|
181
|
+
// Activate the `transform` on `core/group` which does the conversion.
|
|
182
|
+
const newBlocks = switchToBlockType( blocks, groupingBlockName );
|
|
183
|
+
|
|
184
|
+
if ( ! newBlocks ) {
|
|
185
|
+
return;
|
|
186
|
+
}
|
|
187
|
+
replaceBlocks( clientIds, newBlocks );
|
|
142
188
|
};
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
getBlocksByClientId,
|
|
148
|
-
canRemoveBlocks,
|
|
149
|
-
} = useSelect( blockEditorStore );
|
|
150
|
-
const { getDefaultBlockName, getGroupingBlockName } =
|
|
151
|
-
useSelect( blocksStore );
|
|
152
|
-
|
|
153
|
-
const blocks = getBlocksByClientId( clientIds );
|
|
154
|
-
|
|
155
|
-
const {
|
|
156
|
-
removeBlocks,
|
|
157
|
-
replaceBlocks,
|
|
158
|
-
duplicateBlocks,
|
|
159
|
-
insertAfterBlock,
|
|
160
|
-
insertBeforeBlock,
|
|
161
|
-
} = useDispatch( blockEditorStore );
|
|
162
|
-
|
|
163
|
-
const onGroup = () => {
|
|
164
|
-
if ( ! blocks.length ) {
|
|
165
|
-
return;
|
|
166
|
-
}
|
|
189
|
+
const onUngroup = () => {
|
|
190
|
+
if ( ! blocks.length ) {
|
|
191
|
+
return;
|
|
192
|
+
}
|
|
167
193
|
|
|
168
|
-
|
|
194
|
+
const innerBlocks = blocks[ 0 ].innerBlocks;
|
|
169
195
|
|
|
170
|
-
|
|
171
|
-
|
|
196
|
+
if ( ! innerBlocks.length ) {
|
|
197
|
+
return;
|
|
198
|
+
}
|
|
172
199
|
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
const onUngroup = () => {
|
|
179
|
-
if ( ! blocks.length ) {
|
|
180
|
-
return;
|
|
200
|
+
replaceBlocks( clientIds, innerBlocks );
|
|
201
|
+
};
|
|
202
|
+
|
|
203
|
+
if ( ! clientIds || clientIds.length < 1 ) {
|
|
204
|
+
return { isLoading: false, commands: [] };
|
|
181
205
|
}
|
|
182
206
|
|
|
183
|
-
const
|
|
207
|
+
const rootClientId = getBlockRootClientId( clientIds[ 0 ] );
|
|
208
|
+
const canInsertDefaultBlock = canInsertBlockType(
|
|
209
|
+
getDefaultBlockName(),
|
|
210
|
+
rootClientId
|
|
211
|
+
);
|
|
212
|
+
const canDuplicate = blocks.every( ( block ) => {
|
|
213
|
+
return (
|
|
214
|
+
!! block &&
|
|
215
|
+
hasBlockSupport( block.name, 'multiple', true ) &&
|
|
216
|
+
canInsertBlockType( block.name, rootClientId )
|
|
217
|
+
);
|
|
218
|
+
} );
|
|
219
|
+
const canRemove = canRemoveBlocks( clientIds );
|
|
184
220
|
|
|
185
|
-
|
|
186
|
-
|
|
221
|
+
const commands = [];
|
|
222
|
+
|
|
223
|
+
if ( canDuplicate ) {
|
|
224
|
+
commands.push( {
|
|
225
|
+
name: 'duplicate',
|
|
226
|
+
label: __( 'Duplicate' ),
|
|
227
|
+
callback: () => duplicateBlocks( clientIds, true ),
|
|
228
|
+
icon: copy,
|
|
229
|
+
} );
|
|
187
230
|
}
|
|
188
231
|
|
|
189
|
-
|
|
190
|
-
|
|
232
|
+
if ( canInsertDefaultBlock ) {
|
|
233
|
+
commands.push(
|
|
234
|
+
{
|
|
235
|
+
name: 'add-before',
|
|
236
|
+
label: __( 'Add before' ),
|
|
237
|
+
callback: () => {
|
|
238
|
+
const clientId = Array.isArray( clientIds )
|
|
239
|
+
? clientIds[ 0 ]
|
|
240
|
+
: clientId;
|
|
241
|
+
insertBeforeBlock( clientId );
|
|
242
|
+
},
|
|
243
|
+
icon: add,
|
|
244
|
+
},
|
|
245
|
+
{
|
|
246
|
+
name: 'add-after',
|
|
247
|
+
label: __( 'Add after' ),
|
|
248
|
+
callback: () => {
|
|
249
|
+
const clientId = Array.isArray( clientIds )
|
|
250
|
+
? clientIds[ clientIds.length - 1 ]
|
|
251
|
+
: clientId;
|
|
252
|
+
insertAfterBlock( clientId );
|
|
253
|
+
},
|
|
254
|
+
icon: add,
|
|
255
|
+
}
|
|
256
|
+
);
|
|
257
|
+
}
|
|
191
258
|
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
);
|
|
201
|
-
const canDuplicate = blocks.every( ( block ) => {
|
|
202
|
-
return (
|
|
203
|
-
!! block &&
|
|
204
|
-
hasBlockSupport( block.name, 'multiple', true ) &&
|
|
205
|
-
canInsertBlockType( block.name, rootClientId )
|
|
206
|
-
);
|
|
207
|
-
} );
|
|
208
|
-
const canRemove = canRemoveBlocks( clientIds );
|
|
259
|
+
if ( isGroupable ) {
|
|
260
|
+
commands.push( {
|
|
261
|
+
name: 'Group',
|
|
262
|
+
label: __( 'Group' ),
|
|
263
|
+
callback: onGroup,
|
|
264
|
+
icon: group,
|
|
265
|
+
} );
|
|
266
|
+
}
|
|
209
267
|
|
|
210
|
-
|
|
268
|
+
if ( isUngroupable ) {
|
|
269
|
+
commands.push( {
|
|
270
|
+
name: 'ungroup',
|
|
271
|
+
label: __( 'Ungroup' ),
|
|
272
|
+
callback: onUngroup,
|
|
273
|
+
icon: ungroup,
|
|
274
|
+
} );
|
|
275
|
+
}
|
|
211
276
|
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
{
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
callback: () => {
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
: clientId;
|
|
230
|
-
insertBeforeBlock( clientId );
|
|
231
|
-
},
|
|
232
|
-
icon: add,
|
|
233
|
-
},
|
|
234
|
-
{
|
|
235
|
-
name: 'add-after',
|
|
236
|
-
label: __( 'Add after' ),
|
|
237
|
-
callback: () => {
|
|
238
|
-
const clientId = Array.isArray( clientIds )
|
|
239
|
-
? clientIds[ clientIds.length - 1 ]
|
|
240
|
-
: clientId;
|
|
241
|
-
insertAfterBlock( clientId );
|
|
277
|
+
if ( canRemove ) {
|
|
278
|
+
commands.push( {
|
|
279
|
+
name: 'remove',
|
|
280
|
+
label: __( 'Delete' ),
|
|
281
|
+
callback: () => removeBlocks( clientIds, true ),
|
|
282
|
+
icon: remove,
|
|
283
|
+
} );
|
|
284
|
+
}
|
|
285
|
+
|
|
286
|
+
return {
|
|
287
|
+
isLoading: false,
|
|
288
|
+
commands: commands.map( ( command ) => ( {
|
|
289
|
+
...command,
|
|
290
|
+
name: 'core/block-editor/action-' + command.name,
|
|
291
|
+
callback: ( { close } ) => {
|
|
292
|
+
command.callback();
|
|
293
|
+
close();
|
|
242
294
|
},
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
);
|
|
246
|
-
}
|
|
247
|
-
|
|
248
|
-
if ( isGroupable ) {
|
|
249
|
-
commands.push( {
|
|
250
|
-
name: 'Group',
|
|
251
|
-
label: __( 'Group' ),
|
|
252
|
-
callback: onGroup,
|
|
253
|
-
icon: group,
|
|
254
|
-
} );
|
|
255
|
-
}
|
|
256
|
-
|
|
257
|
-
if ( isUngroupable ) {
|
|
258
|
-
commands.push( {
|
|
259
|
-
name: 'ungroup',
|
|
260
|
-
label: __( 'Ungroup' ),
|
|
261
|
-
callback: onUngroup,
|
|
262
|
-
icon: ungroup,
|
|
263
|
-
} );
|
|
264
|
-
}
|
|
265
|
-
|
|
266
|
-
if ( canRemove ) {
|
|
267
|
-
commands.push( {
|
|
268
|
-
name: 'remove',
|
|
269
|
-
label: __( 'Delete' ),
|
|
270
|
-
callback: () => removeBlocks( clientIds, true ),
|
|
271
|
-
icon: remove,
|
|
272
|
-
} );
|
|
273
|
-
}
|
|
274
|
-
|
|
275
|
-
return {
|
|
276
|
-
isLoading: false,
|
|
277
|
-
commands: commands.map( ( command ) => ( {
|
|
278
|
-
...command,
|
|
279
|
-
name: 'core/block-editor/action-' + command.name,
|
|
280
|
-
callback: ( { close } ) => {
|
|
281
|
-
command.callback();
|
|
282
|
-
close();
|
|
283
|
-
},
|
|
284
|
-
} ) ),
|
|
295
|
+
} ) ),
|
|
296
|
+
};
|
|
285
297
|
};
|
|
286
|
-
};
|
|
287
298
|
|
|
288
299
|
export const useBlockCommands = () => {
|
|
289
300
|
useCommandLoader( {
|
|
290
301
|
name: 'core/block-editor/blockTransforms',
|
|
291
|
-
hook:
|
|
302
|
+
hook: getTransformCommands(),
|
|
292
303
|
} );
|
|
293
304
|
useCommandLoader( {
|
|
294
305
|
name: 'core/block-editor/blockQuickActions',
|
|
295
|
-
hook:
|
|
306
|
+
hook: getQuickActionsCommands(),
|
|
296
307
|
context: 'block-selection-edit',
|
|
297
308
|
} );
|
|
298
309
|
};
|
package/src/hooks/font-family.js
CHANGED
|
@@ -13,7 +13,7 @@ import { shouldSkipSerialization } from './utils';
|
|
|
13
13
|
import { TYPOGRAPHY_SUPPORT_KEY } from './typography';
|
|
14
14
|
import { unlock } from '../lock-unlock';
|
|
15
15
|
|
|
16
|
-
export const FONT_FAMILY_SUPPORT_KEY = 'typography.
|
|
16
|
+
export const FONT_FAMILY_SUPPORT_KEY = 'typography.fontFamily';
|
|
17
17
|
const { kebabCase } = unlock( componentsPrivateApis );
|
|
18
18
|
|
|
19
19
|
/**
|
package/src/hooks/supports.js
CHANGED
|
@@ -9,17 +9,17 @@ const ALIGN_WIDE_SUPPORT_KEY = 'alignWide';
|
|
|
9
9
|
const BORDER_SUPPORT_KEY = '__experimentalBorder';
|
|
10
10
|
const COLOR_SUPPORT_KEY = 'color';
|
|
11
11
|
const CUSTOM_CLASS_NAME_SUPPORT_KEY = 'customClassName';
|
|
12
|
-
const FONT_FAMILY_SUPPORT_KEY = 'typography.
|
|
12
|
+
const FONT_FAMILY_SUPPORT_KEY = 'typography.fontFamily';
|
|
13
13
|
const FONT_SIZE_SUPPORT_KEY = 'typography.fontSize';
|
|
14
14
|
const LINE_HEIGHT_SUPPORT_KEY = 'typography.lineHeight';
|
|
15
15
|
/**
|
|
16
16
|
* Key within block settings' support array indicating support for font style.
|
|
17
17
|
*/
|
|
18
|
-
const FONT_STYLE_SUPPORT_KEY = 'typography.
|
|
18
|
+
const FONT_STYLE_SUPPORT_KEY = 'typography.fontStyle';
|
|
19
19
|
/**
|
|
20
20
|
* Key within block settings' support array indicating support for font weight.
|
|
21
21
|
*/
|
|
22
|
-
const FONT_WEIGHT_SUPPORT_KEY = 'typography.
|
|
22
|
+
const FONT_WEIGHT_SUPPORT_KEY = 'typography.fontWeight';
|
|
23
23
|
/**
|
|
24
24
|
* Key within block settings' supports array indicating support for text
|
|
25
25
|
* align e.g. settings found in `block.json`.
|
|
@@ -34,7 +34,7 @@ const TEXT_COLUMNS_SUPPORT_KEY = 'typography.textColumns';
|
|
|
34
34
|
* Key within block settings' supports array indicating support for text
|
|
35
35
|
* decorations e.g. settings found in `block.json`.
|
|
36
36
|
*/
|
|
37
|
-
const TEXT_DECORATION_SUPPORT_KEY = 'typography.
|
|
37
|
+
const TEXT_DECORATION_SUPPORT_KEY = 'typography.textDecoration';
|
|
38
38
|
/**
|
|
39
39
|
* Key within block settings' supports array indicating support for writing mode
|
|
40
40
|
* e.g. settings found in `block.json`.
|
|
@@ -44,13 +44,13 @@ const WRITING_MODE_SUPPORT_KEY = 'typography.__experimentalWritingMode';
|
|
|
44
44
|
* Key within block settings' supports array indicating support for text
|
|
45
45
|
* transforms e.g. settings found in `block.json`.
|
|
46
46
|
*/
|
|
47
|
-
const TEXT_TRANSFORM_SUPPORT_KEY = 'typography.
|
|
47
|
+
const TEXT_TRANSFORM_SUPPORT_KEY = 'typography.textTransform';
|
|
48
48
|
|
|
49
49
|
/**
|
|
50
50
|
* Key within block settings' supports array indicating support for letter-spacing
|
|
51
51
|
* e.g. settings found in `block.json`.
|
|
52
52
|
*/
|
|
53
|
-
const LETTER_SPACING_SUPPORT_KEY = 'typography.
|
|
53
|
+
const LETTER_SPACING_SUPPORT_KEY = 'typography.letterSpacing';
|
|
54
54
|
const LAYOUT_SUPPORT_KEY = 'layout';
|
|
55
55
|
const TYPOGRAPHY_SUPPORT_KEYS = [
|
|
56
56
|
LINE_HEIGHT_SUPPORT_KEY,
|
package/src/hooks/typography.js
CHANGED
|
@@ -27,12 +27,12 @@ function omit( object, keys ) {
|
|
|
27
27
|
);
|
|
28
28
|
}
|
|
29
29
|
|
|
30
|
-
const LETTER_SPACING_SUPPORT_KEY = 'typography.
|
|
31
|
-
const TEXT_TRANSFORM_SUPPORT_KEY = 'typography.
|
|
32
|
-
const TEXT_DECORATION_SUPPORT_KEY = 'typography.
|
|
30
|
+
const LETTER_SPACING_SUPPORT_KEY = 'typography.letterSpacing';
|
|
31
|
+
const TEXT_TRANSFORM_SUPPORT_KEY = 'typography.textTransform';
|
|
32
|
+
const TEXT_DECORATION_SUPPORT_KEY = 'typography.textDecoration';
|
|
33
33
|
const TEXT_COLUMNS_SUPPORT_KEY = 'typography.textColumns';
|
|
34
|
-
const FONT_STYLE_SUPPORT_KEY = 'typography.
|
|
35
|
-
const FONT_WEIGHT_SUPPORT_KEY = 'typography.
|
|
34
|
+
const FONT_STYLE_SUPPORT_KEY = 'typography.fontStyle';
|
|
35
|
+
const FONT_WEIGHT_SUPPORT_KEY = 'typography.fontWeight';
|
|
36
36
|
const WRITING_MODE_SUPPORT_KEY = 'typography.__experimentalWritingMode';
|
|
37
37
|
export const TYPOGRAPHY_SUPPORT_KEY = 'typography';
|
|
38
38
|
export const TYPOGRAPHY_SUPPORT_KEYS = [
|
package/src/hooks/utils.js
CHANGED
|
@@ -562,8 +562,13 @@ export function createBlockEditFilter( features ) {
|
|
|
562
562
|
addFilter( 'editor.BlockEdit', 'core/editor/hooks', withBlockEditHooks );
|
|
563
563
|
}
|
|
564
564
|
|
|
565
|
-
function BlockProps( {
|
|
566
|
-
|
|
565
|
+
function BlockProps( {
|
|
566
|
+
index,
|
|
567
|
+
useBlockProps: hook,
|
|
568
|
+
setAllWrapperProps,
|
|
569
|
+
...props
|
|
570
|
+
} ) {
|
|
571
|
+
const wrapperProps = hook( props );
|
|
567
572
|
const setWrapperProps = ( next ) =>
|
|
568
573
|
setAllWrapperProps( ( prev ) => {
|
|
569
574
|
const nextAll = [ ...prev ];
|
|
@@ -109,17 +109,16 @@ function getEnabledClientIdsTreeUnmemoized( state, rootClientId ) {
|
|
|
109
109
|
*
|
|
110
110
|
* @return {Object[]} Tree of block objects with only clientID and innerBlocks set.
|
|
111
111
|
*/
|
|
112
|
-
export const getEnabledClientIdsTree =
|
|
113
|
-
getEnabledClientIdsTreeUnmemoized,
|
|
114
|
-
( state ) => [
|
|
112
|
+
export const getEnabledClientIdsTree = createRegistrySelector( ( select ) =>
|
|
113
|
+
createSelector( getEnabledClientIdsTreeUnmemoized, ( state ) => [
|
|
115
114
|
state.blocks.order,
|
|
116
115
|
state.blockEditingModes,
|
|
117
116
|
state.settings.templateLock,
|
|
118
117
|
state.blockListSettings,
|
|
119
|
-
state
|
|
118
|
+
select( STORE_NAME ).__unstableGetEditorMode( state ),
|
|
120
119
|
state.zoomLevel,
|
|
121
120
|
getSectionRootClientId( state ),
|
|
122
|
-
]
|
|
121
|
+
] )
|
|
123
122
|
);
|
|
124
123
|
|
|
125
124
|
/**
|
|
@@ -317,7 +316,7 @@ export const hasAllowedPatterns = createRegistrySelector( ( select ) =>
|
|
|
317
316
|
},
|
|
318
317
|
( state, rootClientId ) => [
|
|
319
318
|
...getAllPatternsDependants( select )( state ),
|
|
320
|
-
...getInsertBlockTypeDependants( state, rootClientId ),
|
|
319
|
+
...getInsertBlockTypeDependants( select )( state, rootClientId ),
|
|
321
320
|
]
|
|
322
321
|
)
|
|
323
322
|
);
|