@wordpress/block-editor 15.3.1-next.836ecdcae.0 → 15.3.1-next.a730c9c8c.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/build/autocompleters/block.js +2 -4
- package/build/autocompleters/block.js.map +1 -1
- package/build/components/block-card/index.js +4 -2
- package/build/components/block-card/index.js.map +1 -1
- package/build/components/block-inspector/edit-contents-button.js +54 -0
- package/build/components/block-inspector/edit-contents-button.js.map +1 -0
- package/build/components/block-inspector/index.js +5 -1
- package/build/components/block-inspector/index.js.map +1 -1
- package/build/components/block-list/index.js +3 -1
- package/build/components/block-list/index.js.map +1 -1
- package/build/components/block-popover/use-popover-scroll.js +11 -2
- package/build/components/block-popover/use-popover-scroll.js.map +1 -1
- package/build/components/block-switcher/index.js +13 -8
- package/build/components/block-switcher/index.js.map +1 -1
- package/build/components/block-toolbar/index.js +5 -2
- package/build/components/block-toolbar/index.js.map +1 -1
- package/build/components/block-tools/insertion-point.js +10 -0
- package/build/components/block-tools/insertion-point.js.map +1 -1
- package/build/components/block-variation-transforms/index.js +10 -6
- package/build/components/block-variation-transforms/index.js.map +1 -1
- package/build/components/border-radius-control/utils.js.map +1 -1
- package/build/components/global-styles/border-panel.js +6 -6
- package/build/components/global-styles/border-panel.js.map +1 -1
- package/build/components/link-control/search-item.js +30 -12
- package/build/components/link-control/search-item.js.map +1 -1
- package/build/components/url-popover/image-url-input-ui.js +7 -2
- package/build/components/url-popover/image-url-input-ui.js.map +1 -1
- package/build/components/writing-flow/use-clipboard-handler.js +6 -1
- package/build/components/writing-flow/use-clipboard-handler.js.map +1 -1
- package/build/store/private-selectors.js +9 -21
- package/build/store/private-selectors.js.map +1 -1
- package/build/store/reducer.js +114 -0
- package/build/store/reducer.js.map +1 -1
- package/build/store/selectors.js +16 -30
- package/build/store/selectors.js.map +1 -1
- package/build/store/utils.js +18 -0
- package/build/store/utils.js.map +1 -1
- package/build/utils/block-bindings.js +1 -1
- package/build/utils/block-bindings.js.map +1 -1
- package/build-module/autocompleters/block.js +3 -5
- package/build-module/autocompleters/block.js.map +1 -1
- package/build-module/components/block-card/index.js +4 -2
- package/build-module/components/block-card/index.js.map +1 -1
- package/build-module/components/block-inspector/edit-contents-button.js +47 -0
- package/build-module/components/block-inspector/edit-contents-button.js.map +1 -0
- package/build-module/components/block-inspector/index.js +5 -1
- package/build-module/components/block-inspector/index.js.map +1 -1
- package/build-module/components/block-list/index.js +3 -1
- package/build-module/components/block-list/index.js.map +1 -1
- package/build-module/components/block-popover/use-popover-scroll.js +11 -2
- package/build-module/components/block-popover/use-popover-scroll.js.map +1 -1
- package/build-module/components/block-switcher/index.js +13 -8
- package/build-module/components/block-switcher/index.js.map +1 -1
- package/build-module/components/block-toolbar/index.js +5 -2
- package/build-module/components/block-toolbar/index.js.map +1 -1
- package/build-module/components/block-tools/insertion-point.js +11 -1
- package/build-module/components/block-tools/insertion-point.js.map +1 -1
- package/build-module/components/block-variation-transforms/index.js +10 -6
- package/build-module/components/block-variation-transforms/index.js.map +1 -1
- package/build-module/components/border-radius-control/utils.js.map +1 -1
- package/build-module/components/global-styles/border-panel.js +6 -6
- package/build-module/components/global-styles/border-panel.js.map +1 -1
- package/build-module/components/link-control/search-item.js +30 -12
- package/build-module/components/link-control/search-item.js.map +1 -1
- package/build-module/components/url-popover/image-url-input-ui.js +9 -4
- package/build-module/components/url-popover/image-url-input-ui.js.map +1 -1
- package/build-module/components/writing-flow/use-clipboard-handler.js +6 -1
- package/build-module/components/writing-flow/use-clipboard-handler.js.map +1 -1
- package/build-module/store/private-selectors.js +9 -21
- package/build-module/store/private-selectors.js.map +1 -1
- package/build-module/store/reducer.js +114 -0
- package/build-module/store/reducer.js.map +1 -1
- package/build-module/store/selectors.js +16 -30
- package/build-module/store/selectors.js.map +1 -1
- package/build-module/store/utils.js +17 -0
- package/build-module/store/utils.js.map +1 -1
- package/build-module/utils/block-bindings.js +1 -1
- package/build-module/utils/block-bindings.js.map +1 -1
- package/build-style/style-rtl.css +9 -5
- package/build-style/style.css +9 -5
- package/package.json +34 -34
- package/src/autocompleters/block.js +6 -11
- package/src/components/block-card/index.js +11 -1
- package/src/components/block-inspector/edit-contents-button.js +46 -0
- package/src/components/block-inspector/index.js +6 -1
- package/src/components/block-inspector/style.scss +5 -0
- package/src/components/block-list/index.js +7 -1
- package/src/components/block-popover/use-popover-scroll.js +10 -2
- package/src/components/block-switcher/index.js +13 -4
- package/src/components/block-toolbar/index.js +11 -5
- package/src/components/block-toolbar/style.scss +3 -5
- package/src/components/block-tools/insertion-point.js +19 -1
- package/src/components/block-variation-transforms/index.js +39 -27
- package/src/components/border-radius-control/test/utils.js +71 -0
- package/src/components/border-radius-control/utils.js +1 -0
- package/src/components/global-styles/border-panel.js +7 -6
- package/src/components/link-control/search-item.js +31 -12
- package/src/components/link-control/style.scss +0 -1
- package/src/components/link-control/test/index.js +14 -2
- package/src/components/url-popover/image-url-input-ui.js +18 -2
- package/src/components/writing-flow/use-clipboard-handler.js +6 -0
- package/src/store/private-selectors.js +12 -24
- package/src/store/reducer.js +188 -0
- package/src/store/selectors.js +38 -59
- package/src/store/test/reducer.js +398 -0
- package/src/store/test/selectors.js +65 -192
- package/src/store/utils.js +21 -0
- package/src/utils/block-bindings.js +1 -1
|
@@ -52,10 +52,8 @@
|
|
|
52
52
|
color: var(--wp-block-synced-color);
|
|
53
53
|
}
|
|
54
54
|
|
|
55
|
-
.
|
|
56
|
-
|
|
57
|
-
color: var(--wp-block-synced-color);
|
|
58
|
-
}
|
|
55
|
+
.block-editor-block-switcher__no-switcher-icon[aria-disabled="true"] .block-editor-block-icon {
|
|
56
|
+
color: var(--wp-block-synced-color);
|
|
59
57
|
}
|
|
60
58
|
}
|
|
61
59
|
|
|
@@ -175,7 +173,7 @@
|
|
|
175
173
|
|
|
176
174
|
.show-icon-labels {
|
|
177
175
|
.block-editor-block-toolbar {
|
|
178
|
-
.components-button.has-icon {
|
|
176
|
+
.components-button.has-icon:where(:not(.has-text)) {
|
|
179
177
|
width: auto;
|
|
180
178
|
|
|
181
179
|
// Hide the button icons when labels are set to display...
|
|
@@ -7,7 +7,12 @@ import clsx from 'clsx';
|
|
|
7
7
|
* WordPress dependencies
|
|
8
8
|
*/
|
|
9
9
|
import { useSelect, useDispatch } from '@wordpress/data';
|
|
10
|
-
import {
|
|
10
|
+
import {
|
|
11
|
+
useRef,
|
|
12
|
+
createContext,
|
|
13
|
+
useContext,
|
|
14
|
+
useCallback,
|
|
15
|
+
} from '@wordpress/element';
|
|
11
16
|
import { __unstableMotion as motion } from '@wordpress/components';
|
|
12
17
|
import { useReducedMotion } from '@wordpress/compose';
|
|
13
18
|
|
|
@@ -113,6 +118,18 @@ function InbetweenInsertionPointPopover( {
|
|
|
113
118
|
}
|
|
114
119
|
}
|
|
115
120
|
|
|
121
|
+
// Reset the insertion point reference when the Inserter unmounts,
|
|
122
|
+
// avoids stale references when `onSelectOrClose` is not called.
|
|
123
|
+
// See: https://github.com/WordPress/gutenberg/issues/65598#issuecomment-3249229264.
|
|
124
|
+
const maybeResetOpenRef = useCallback(
|
|
125
|
+
( node ) => {
|
|
126
|
+
if ( ! node && openRef.current ) {
|
|
127
|
+
openRef.current = false;
|
|
128
|
+
}
|
|
129
|
+
},
|
|
130
|
+
[ openRef ]
|
|
131
|
+
);
|
|
132
|
+
|
|
116
133
|
const lineVariants = {
|
|
117
134
|
// Initial position starts from the center and invisible.
|
|
118
135
|
start: {
|
|
@@ -203,6 +220,7 @@ function InbetweenInsertionPointPopover( {
|
|
|
203
220
|
) }
|
|
204
221
|
>
|
|
205
222
|
<Inserter
|
|
223
|
+
ref={ maybeResetOpenRef }
|
|
206
224
|
position="bottom center"
|
|
207
225
|
clientId={ nextClientId }
|
|
208
226
|
rootClientId={ rootClientId }
|
|
@@ -139,32 +139,41 @@ function VariationsToggleGroupControl( {
|
|
|
139
139
|
|
|
140
140
|
function __experimentalBlockVariationTransforms( { blockClientId } ) {
|
|
141
141
|
const { updateBlockAttributes } = useDispatch( blockEditorStore );
|
|
142
|
-
const { activeBlockVariation, variations, isContentOnly } =
|
|
143
|
-
(
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
)
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
142
|
+
const { activeBlockVariation, variations, isContentOnly, isSection } =
|
|
143
|
+
useSelect(
|
|
144
|
+
( select ) => {
|
|
145
|
+
const { getActiveBlockVariation, getBlockVariations } =
|
|
146
|
+
select( blocksStore );
|
|
147
|
+
|
|
148
|
+
const {
|
|
149
|
+
getBlockName,
|
|
150
|
+
getBlockAttributes,
|
|
151
|
+
getBlockEditingMode,
|
|
152
|
+
isSectionBlock,
|
|
153
|
+
} = unlock( select( blockEditorStore ) );
|
|
154
|
+
|
|
155
|
+
const name = blockClientId && getBlockName( blockClientId );
|
|
156
|
+
|
|
157
|
+
const { hasContentRoleAttribute } = unlock(
|
|
158
|
+
select( blocksStore )
|
|
159
|
+
);
|
|
160
|
+
const isContentBlock = hasContentRoleAttribute( name );
|
|
161
|
+
|
|
162
|
+
return {
|
|
163
|
+
activeBlockVariation: getActiveBlockVariation(
|
|
164
|
+
name,
|
|
165
|
+
getBlockAttributes( blockClientId ),
|
|
166
|
+
'transform'
|
|
167
|
+
),
|
|
168
|
+
variations: name && getBlockVariations( name, 'transform' ),
|
|
169
|
+
isContentOnly:
|
|
170
|
+
getBlockEditingMode( blockClientId ) ===
|
|
171
|
+
'contentOnly' && ! isContentBlock,
|
|
172
|
+
isSection: isSectionBlock( blockClientId ),
|
|
173
|
+
};
|
|
174
|
+
},
|
|
175
|
+
[ blockClientId ]
|
|
176
|
+
);
|
|
168
177
|
|
|
169
178
|
const selectedValue = activeBlockVariation?.name;
|
|
170
179
|
|
|
@@ -189,7 +198,10 @@ function __experimentalBlockVariationTransforms( { blockClientId } ) {
|
|
|
189
198
|
} );
|
|
190
199
|
};
|
|
191
200
|
|
|
192
|
-
|
|
201
|
+
const hideVariationsForSections =
|
|
202
|
+
window?.__experimentalContentOnlyPatternInsertion && isSection;
|
|
203
|
+
|
|
204
|
+
if ( ! variations?.length || isContentOnly || hideVariationsForSections ) {
|
|
193
205
|
return null;
|
|
194
206
|
}
|
|
195
207
|
|
|
@@ -7,6 +7,8 @@ import {
|
|
|
7
7
|
hasMixedValues,
|
|
8
8
|
hasDefinedValues,
|
|
9
9
|
mode,
|
|
10
|
+
getPresetValueFromCustomValue,
|
|
11
|
+
getPresetValueFromControlValue,
|
|
10
12
|
} from '../utils';
|
|
11
13
|
|
|
12
14
|
const defaultUnitSelections = {
|
|
@@ -180,3 +182,72 @@ describe( 'mode', () => {
|
|
|
180
182
|
expect( mode( values ) ).toBe( 'a' );
|
|
181
183
|
} );
|
|
182
184
|
} );
|
|
185
|
+
|
|
186
|
+
describe( 'getPresetValueFromCustomValue', () => {
|
|
187
|
+
const presets = [
|
|
188
|
+
{ name: 'None', slug: '0', size: 0 },
|
|
189
|
+
{ name: 'Small', slug: 'sm', size: '4px' },
|
|
190
|
+
{ name: 'Medium', slug: 'md', size: 'clamp(2px, 1vw, 8px)' },
|
|
191
|
+
];
|
|
192
|
+
|
|
193
|
+
it( 'should return "0" if value is "0"', () => {
|
|
194
|
+
expect( getPresetValueFromCustomValue( '0', presets ) ).toBe( '0' );
|
|
195
|
+
} );
|
|
196
|
+
|
|
197
|
+
it( 'should return preset reference if value matches a preset', () => {
|
|
198
|
+
expect( getPresetValueFromCustomValue( '4px', presets ) ).toBe(
|
|
199
|
+
'var:preset|border-radius|sm'
|
|
200
|
+
);
|
|
201
|
+
expect(
|
|
202
|
+
getPresetValueFromCustomValue( 'clamp(2px, 1vw, 8px)', presets )
|
|
203
|
+
).toBe( 'var:preset|border-radius|md' );
|
|
204
|
+
} );
|
|
205
|
+
|
|
206
|
+
it( 'should return value as-is if no matching preset', () => {
|
|
207
|
+
expect( getPresetValueFromCustomValue( '7px', presets ) ).toBe( '7px' );
|
|
208
|
+
} );
|
|
209
|
+
|
|
210
|
+
it( 'should return value as-is if already a preset reference', () => {
|
|
211
|
+
expect(
|
|
212
|
+
getPresetValueFromCustomValue(
|
|
213
|
+
'var:preset|border-radius|md',
|
|
214
|
+
presets
|
|
215
|
+
)
|
|
216
|
+
).toBe( 'var:preset|border-radius|md' );
|
|
217
|
+
} );
|
|
218
|
+
|
|
219
|
+
it( 'should return undefined if value is undefined', () => {
|
|
220
|
+
expect(
|
|
221
|
+
getPresetValueFromCustomValue( undefined, presets )
|
|
222
|
+
).toBeUndefined();
|
|
223
|
+
} );
|
|
224
|
+
} );
|
|
225
|
+
|
|
226
|
+
describe( 'getPresetValueFromControlValue', () => {
|
|
227
|
+
const presets = [
|
|
228
|
+
{ name: 'None', slug: '0', size: 0 },
|
|
229
|
+
{ name: 'Small', slug: 'sm', size: '4px' },
|
|
230
|
+
{ name: 'Medium', slug: 'md', size: 'clamp(2px, 1vw, 8px)' },
|
|
231
|
+
];
|
|
232
|
+
|
|
233
|
+
it( 'should return "0" if control value is 0 and not selectList', () => {
|
|
234
|
+
expect( getPresetValueFromControlValue( 0, 'slider', presets ) ).toBe(
|
|
235
|
+
'0'
|
|
236
|
+
);
|
|
237
|
+
} );
|
|
238
|
+
|
|
239
|
+
it( 'should return undefined if control value is 0 and controlType is selectList', () => {
|
|
240
|
+
expect(
|
|
241
|
+
getPresetValueFromControlValue( 0, 'selectList', presets )
|
|
242
|
+
).toBeUndefined();
|
|
243
|
+
} );
|
|
244
|
+
|
|
245
|
+
it( 'should return preset reference for other values', () => {
|
|
246
|
+
expect( getPresetValueFromControlValue( 1, 'slider', presets ) ).toBe(
|
|
247
|
+
'var:preset|border-radius|sm'
|
|
248
|
+
);
|
|
249
|
+
expect( getPresetValueFromControlValue( 2, 'slider', presets ) ).toBe(
|
|
250
|
+
'var:preset|border-radius|md'
|
|
251
|
+
);
|
|
252
|
+
} );
|
|
253
|
+
} );
|
|
@@ -147,15 +147,16 @@ export default function BorderPanel( {
|
|
|
147
147
|
const showBorderRadius = useHasBorderRadiusControl( settings );
|
|
148
148
|
const borderRadiusValues = useMemo( () => {
|
|
149
149
|
if ( typeof border?.radius !== 'object' ) {
|
|
150
|
-
return
|
|
150
|
+
return border?.radius;
|
|
151
151
|
}
|
|
152
|
+
|
|
152
153
|
return {
|
|
153
|
-
topLeft:
|
|
154
|
-
topRight:
|
|
155
|
-
bottomLeft:
|
|
156
|
-
bottomRight:
|
|
154
|
+
topLeft: border?.radius?.topLeft,
|
|
155
|
+
topRight: border?.radius?.topRight,
|
|
156
|
+
bottomLeft: border?.radius?.bottomLeft,
|
|
157
|
+
bottomRight: border?.radius?.bottomRight,
|
|
157
158
|
};
|
|
158
|
-
}, [ border?.radius
|
|
159
|
+
}, [ border?.radius ] );
|
|
159
160
|
const setBorderRadius = ( newBorderRadius ) =>
|
|
160
161
|
setBorder( { ...border, radius: newBorderRadius } );
|
|
161
162
|
const hasBorderRadius = () => {
|
|
@@ -19,12 +19,27 @@ import { safeDecodeURI, filterURLForDisplay, getPath } from '@wordpress/url';
|
|
|
19
19
|
import { pipe } from '@wordpress/compose';
|
|
20
20
|
import deprecated from '@wordpress/deprecated';
|
|
21
21
|
|
|
22
|
-
const
|
|
23
|
-
post:
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
22
|
+
const TYPES = {
|
|
23
|
+
post: {
|
|
24
|
+
icon: postList,
|
|
25
|
+
label: __( 'Post' ),
|
|
26
|
+
},
|
|
27
|
+
page: {
|
|
28
|
+
icon: page,
|
|
29
|
+
label: __( 'Page' ),
|
|
30
|
+
},
|
|
31
|
+
post_tag: {
|
|
32
|
+
icon: tag,
|
|
33
|
+
label: __( 'Tag' ),
|
|
34
|
+
},
|
|
35
|
+
category: {
|
|
36
|
+
icon: category,
|
|
37
|
+
label: __( 'Category' ),
|
|
38
|
+
},
|
|
39
|
+
attachment: {
|
|
40
|
+
icon: file,
|
|
41
|
+
label: __( 'Attachment' ),
|
|
42
|
+
},
|
|
28
43
|
};
|
|
29
44
|
|
|
30
45
|
function SearchItemIcon( { isURL, suggestion } ) {
|
|
@@ -32,8 +47,8 @@ function SearchItemIcon( { isURL, suggestion } ) {
|
|
|
32
47
|
|
|
33
48
|
if ( isURL ) {
|
|
34
49
|
icon = globe;
|
|
35
|
-
} else if ( suggestion.type in
|
|
36
|
-
icon =
|
|
50
|
+
} else if ( suggestion.type in TYPES ) {
|
|
51
|
+
icon = TYPES[ suggestion.type ].icon;
|
|
37
52
|
if ( suggestion.type === 'page' ) {
|
|
38
53
|
if ( suggestion.isFrontPage ) {
|
|
39
54
|
icon = home;
|
|
@@ -149,15 +164,19 @@ export const LinkControlSearchItem = ( {
|
|
|
149
164
|
|
|
150
165
|
function getVisualTypeName( suggestion ) {
|
|
151
166
|
if ( suggestion.isFrontPage ) {
|
|
152
|
-
return '
|
|
167
|
+
return __( 'Front page' );
|
|
153
168
|
}
|
|
154
169
|
|
|
155
170
|
if ( suggestion.isBlogHome ) {
|
|
156
|
-
return '
|
|
171
|
+
return __( 'Blog home' );
|
|
172
|
+
}
|
|
173
|
+
|
|
174
|
+
// Provide translated labels for built-in post types. Ideally, the API would return the localised CPT or taxonomy label.
|
|
175
|
+
if ( suggestion.type in TYPES ) {
|
|
176
|
+
return TYPES[ suggestion.type ].label;
|
|
157
177
|
}
|
|
158
178
|
|
|
159
|
-
|
|
160
|
-
return suggestion.type === 'post_tag' ? 'tag' : suggestion.type;
|
|
179
|
+
return suggestion.type;
|
|
161
180
|
}
|
|
162
181
|
|
|
163
182
|
export default LinkControlSearchItem;
|
|
@@ -28,6 +28,18 @@ import {
|
|
|
28
28
|
|
|
29
29
|
const mockFetchSearchSuggestions = jest.fn();
|
|
30
30
|
|
|
31
|
+
function getExpectedVisualTypeName( type ) {
|
|
32
|
+
const builtInLabels = {
|
|
33
|
+
post: 'Post',
|
|
34
|
+
page: 'Page',
|
|
35
|
+
post_tag: 'Tag',
|
|
36
|
+
category: 'Category',
|
|
37
|
+
attachment: 'Attachment',
|
|
38
|
+
};
|
|
39
|
+
|
|
40
|
+
return builtInLabels[ type ] || type;
|
|
41
|
+
}
|
|
42
|
+
|
|
31
43
|
/**
|
|
32
44
|
* The call to the real method `fetchRichUrlData` is wrapped in a promise in order to make it cancellable.
|
|
33
45
|
* Therefore if we pass any value as the mock of `fetchRichUrlData` then ALL of the tests will require
|
|
@@ -510,7 +522,7 @@ describe( 'Searching for a link', () => {
|
|
|
510
522
|
firstSuggestion.title
|
|
511
523
|
);
|
|
512
524
|
expect( searchResultElements[ 0 ] ).toHaveTextContent(
|
|
513
|
-
firstSuggestion.type
|
|
525
|
+
getExpectedVisualTypeName( firstSuggestion.type )
|
|
514
526
|
);
|
|
515
527
|
|
|
516
528
|
// The fallback URL suggestion should not be shown when input is not URL-like.
|
|
@@ -2078,7 +2090,7 @@ describe( 'Post types', () => {
|
|
|
2078
2090
|
|
|
2079
2091
|
searchResultElements.forEach( ( resultItem, index ) => {
|
|
2080
2092
|
expect( resultItem ).toHaveTextContent(
|
|
2081
|
-
fauxEntitySuggestions[ index ].type
|
|
2093
|
+
getExpectedVisualTypeName( fauxEntitySuggestions[ index ].type )
|
|
2082
2094
|
);
|
|
2083
2095
|
} );
|
|
2084
2096
|
} );
|
|
@@ -2,7 +2,12 @@
|
|
|
2
2
|
* WordPress dependencies
|
|
3
3
|
*/
|
|
4
4
|
import { __ } from '@wordpress/i18n';
|
|
5
|
-
import {
|
|
5
|
+
import {
|
|
6
|
+
useRef,
|
|
7
|
+
useEffect,
|
|
8
|
+
useState,
|
|
9
|
+
createInterpolateElement,
|
|
10
|
+
} from '@wordpress/element';
|
|
6
11
|
import { focus } from '@wordpress/dom';
|
|
7
12
|
import {
|
|
8
13
|
ToolbarButton,
|
|
@@ -12,6 +17,7 @@ import {
|
|
|
12
17
|
ToggleControl,
|
|
13
18
|
TextControl,
|
|
14
19
|
__experimentalVStack as VStack,
|
|
20
|
+
ExternalLink,
|
|
15
21
|
} from '@wordpress/components';
|
|
16
22
|
import {
|
|
17
23
|
Icon,
|
|
@@ -230,9 +236,19 @@ const ImageURLInputUI = ( {
|
|
|
230
236
|
<TextControl
|
|
231
237
|
__next40pxDefaultSize
|
|
232
238
|
__nextHasNoMarginBottom
|
|
233
|
-
label={ __( 'Link
|
|
239
|
+
label={ __( 'Link relation' ) }
|
|
234
240
|
value={ rel ?? '' }
|
|
235
241
|
onChange={ onSetLinkRel }
|
|
242
|
+
help={ createInterpolateElement(
|
|
243
|
+
__(
|
|
244
|
+
'The <a>Link Relation</a> attribute defines the relationship between a linked resource and the current document.'
|
|
245
|
+
),
|
|
246
|
+
{
|
|
247
|
+
a: (
|
|
248
|
+
<ExternalLink href="https://developer.mozilla.org/docs/Web/HTML/Attributes/rel" />
|
|
249
|
+
),
|
|
250
|
+
}
|
|
251
|
+
) }
|
|
236
252
|
/>
|
|
237
253
|
<TextControl
|
|
238
254
|
__next40pxDefaultSize
|
|
@@ -137,6 +137,7 @@ export default function useClipboardHandler() {
|
|
|
137
137
|
const {
|
|
138
138
|
__experimentalCanUserUseUnfilteredHTML:
|
|
139
139
|
canUserUseUnfilteredHTML,
|
|
140
|
+
mediaUpload,
|
|
140
141
|
} = getSettings();
|
|
141
142
|
const isInternal =
|
|
142
143
|
event.clipboardData.getData( 'rich-text' ) === 'true';
|
|
@@ -148,6 +149,11 @@ export default function useClipboardHandler() {
|
|
|
148
149
|
let blocks = [];
|
|
149
150
|
|
|
150
151
|
if ( files.length ) {
|
|
152
|
+
if ( ! mediaUpload ) {
|
|
153
|
+
event.preventDefault();
|
|
154
|
+
return;
|
|
155
|
+
}
|
|
156
|
+
|
|
151
157
|
const fromTransforms = getBlockTransforms( 'from' );
|
|
152
158
|
blocks = files
|
|
153
159
|
.reduce( ( accumulator, file ) => {
|
|
@@ -18,14 +18,15 @@ import {
|
|
|
18
18
|
getClientIdsWithDescendants,
|
|
19
19
|
isNavigationMode,
|
|
20
20
|
getBlockRootClientId,
|
|
21
|
+
getBlockAttributes,
|
|
21
22
|
} from './selectors';
|
|
22
23
|
import {
|
|
23
24
|
checkAllowListRecursive,
|
|
24
25
|
getAllPatternsDependants,
|
|
25
26
|
getInsertBlockTypeDependants,
|
|
26
27
|
getGrammar,
|
|
28
|
+
mapUserPattern,
|
|
27
29
|
} from './utils';
|
|
28
|
-
import { INSERTER_PATTERN_TYPES } from '../components/inserter/block-patterns-tab/utils';
|
|
29
30
|
import { STORE_NAME } from './constants';
|
|
30
31
|
import { unlock } from '../lock-unlock';
|
|
31
32
|
import {
|
|
@@ -144,8 +145,6 @@ export const getEnabledClientIdsTree = createRegistrySelector( ( select ) =>
|
|
|
144
145
|
state.derivedBlockEditingModes,
|
|
145
146
|
state.derivedNavModeBlockEditingModes,
|
|
146
147
|
state.blockEditingModes,
|
|
147
|
-
state.settings.templateLock,
|
|
148
|
-
state.blockListSettings,
|
|
149
148
|
select( STORE_NAME ).__unstableGetEditorMode( state ),
|
|
150
149
|
] )
|
|
151
150
|
);
|
|
@@ -350,26 +349,6 @@ export const hasAllowedPatterns = createRegistrySelector( ( select ) =>
|
|
|
350
349
|
)
|
|
351
350
|
);
|
|
352
351
|
|
|
353
|
-
function mapUserPattern(
|
|
354
|
-
userPattern,
|
|
355
|
-
__experimentalUserPatternCategories = []
|
|
356
|
-
) {
|
|
357
|
-
return {
|
|
358
|
-
name: `core/block/${ userPattern.id }`,
|
|
359
|
-
id: userPattern.id,
|
|
360
|
-
type: INSERTER_PATTERN_TYPES.user,
|
|
361
|
-
title: userPattern.title.raw,
|
|
362
|
-
categories: userPattern.wp_pattern_category?.map( ( catId ) => {
|
|
363
|
-
const category = __experimentalUserPatternCategories.find(
|
|
364
|
-
( { id } ) => id === catId
|
|
365
|
-
);
|
|
366
|
-
return category ? category.slug : catId;
|
|
367
|
-
} ),
|
|
368
|
-
content: userPattern.content.raw,
|
|
369
|
-
syncStatus: userPattern.wp_pattern_sync_status,
|
|
370
|
-
};
|
|
371
|
-
}
|
|
372
|
-
|
|
373
352
|
export const getPatternBySlug = createRegistrySelector( ( select ) =>
|
|
374
353
|
createSelector(
|
|
375
354
|
( state, patternName ) => {
|
|
@@ -539,9 +518,18 @@ export function isSectionBlock( state, clientId ) {
|
|
|
539
518
|
return true;
|
|
540
519
|
}
|
|
541
520
|
|
|
521
|
+
const attributes = getBlockAttributes( state, clientId );
|
|
522
|
+
const isTemplatePart = blockName === 'core/template-part';
|
|
523
|
+
if (
|
|
524
|
+
( attributes?.metadata?.patternName || isTemplatePart ) &&
|
|
525
|
+
!! window?.__experimentalContentOnlyPatternInsertion
|
|
526
|
+
) {
|
|
527
|
+
return true;
|
|
528
|
+
}
|
|
529
|
+
|
|
542
530
|
// Template parts become sections in navigation mode.
|
|
543
531
|
const _isNavigationMode = isNavigationMode( state );
|
|
544
|
-
if ( _isNavigationMode &&
|
|
532
|
+
if ( _isNavigationMode && isTemplatePart ) {
|
|
545
533
|
return true;
|
|
546
534
|
}
|
|
547
535
|
|