@wordpress/block-editor 12.19.1 → 12.19.3
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/components/block-tools/insertion-point.js +4 -1
- package/build/components/block-tools/insertion-point.js.map +1 -1
- package/build/components/global-styles/advanced-panel.js +5 -10
- package/build/components/global-styles/advanced-panel.js.map +1 -1
- package/build/components/global-styles/border-panel.js +4 -3
- package/build/components/global-styles/border-panel.js.map +1 -1
- package/build/components/global-styles/get-global-styles-changes.js +61 -24
- package/build/components/global-styles/get-global-styles-changes.js.map +1 -1
- package/build/components/global-styles/shadow-panel-components.js +3 -3
- package/build/components/global-styles/shadow-panel-components.js.map +1 -1
- package/build/components/global-styles/typography-panel.js +8 -6
- package/build/components/global-styles/typography-panel.js.map +1 -1
- package/build/components/iframe/index.js +4 -1
- package/build/components/iframe/index.js.map +1 -1
- package/build/components/inserter/media-tab/media-preview.js +1 -1
- package/build/components/inserter/media-tab/media-preview.js.map +1 -1
- package/build/components/rich-text/index.js +7 -3
- package/build/components/rich-text/index.js.map +1 -1
- package/build/components/rich-text/index.native.js +1 -0
- package/build/components/rich-text/index.native.js.map +1 -1
- package/build/components/rich-text/use-enter.js +1 -0
- package/build/components/rich-text/use-enter.js.map +1 -1
- package/build/components/rich-text/use-paste-handler.js +25 -26
- package/build/components/rich-text/use-paste-handler.js.map +1 -1
- package/build/hooks/background.js +4 -2
- package/build/hooks/background.js.map +1 -1
- package/build/hooks/use-bindings-attributes.js +0 -17
- package/build/hooks/use-bindings-attributes.js.map +1 -1
- package/build/hooks/utils.js +8 -4
- package/build/hooks/utils.js.map +1 -1
- package/build/private-apis.js +3 -1
- package/build/private-apis.js.map +1 -1
- package/build/store/get-block-settings.js +17 -4
- package/build/store/get-block-settings.js.map +1 -1
- package/build/store/index.js +0 -2
- package/build/store/index.js.map +1 -1
- package/build/store/private-actions.js +5 -0
- package/build/store/private-actions.js.map +1 -1
- package/build/store/private-keys.js +8 -0
- package/build/store/private-keys.js.map +1 -0
- package/build/store/private-selectors.js +6 -9
- package/build/store/private-selectors.js.map +1 -1
- package/build/store/reducer.js +1 -9
- package/build/store/reducer.js.map +1 -1
- package/build/store/selectors.js +7 -12
- package/build/store/selectors.js.map +1 -1
- package/build/store/utils.js +7 -2
- package/build/store/utils.js.map +1 -1
- package/build-module/components/block-tools/insertion-point.js +4 -1
- package/build-module/components/block-tools/insertion-point.js.map +1 -1
- package/build-module/components/global-styles/advanced-panel.js +6 -11
- package/build-module/components/global-styles/advanced-panel.js.map +1 -1
- package/build-module/components/global-styles/border-panel.js +5 -4
- package/build-module/components/global-styles/border-panel.js.map +1 -1
- package/build-module/components/global-styles/get-global-styles-changes.js +61 -25
- package/build-module/components/global-styles/get-global-styles-changes.js.map +1 -1
- package/build-module/components/global-styles/shadow-panel-components.js +3 -3
- package/build-module/components/global-styles/shadow-panel-components.js.map +1 -1
- package/build-module/components/global-styles/typography-panel.js +9 -7
- package/build-module/components/global-styles/typography-panel.js.map +1 -1
- package/build-module/components/iframe/index.js +4 -1
- package/build-module/components/iframe/index.js.map +1 -1
- package/build-module/components/inserter/media-tab/media-preview.js +1 -1
- package/build-module/components/inserter/media-tab/media-preview.js.map +1 -1
- package/build-module/components/rich-text/index.js +7 -3
- package/build-module/components/rich-text/index.js.map +1 -1
- package/build-module/components/rich-text/index.native.js +1 -0
- package/build-module/components/rich-text/index.native.js.map +1 -1
- package/build-module/components/rich-text/use-enter.js +1 -0
- package/build-module/components/rich-text/use-enter.js.map +1 -1
- package/build-module/components/rich-text/use-paste-handler.js +25 -26
- package/build-module/components/rich-text/use-paste-handler.js.map +1 -1
- package/build-module/hooks/background.js +4 -2
- package/build-module/hooks/background.js.map +1 -1
- package/build-module/hooks/use-bindings-attributes.js +0 -17
- package/build-module/hooks/use-bindings-attributes.js.map +1 -1
- package/build-module/hooks/utils.js +8 -4
- package/build-module/hooks/utils.js.map +1 -1
- package/build-module/private-apis.js +3 -1
- package/build-module/private-apis.js.map +1 -1
- package/build-module/store/get-block-settings.js +16 -4
- package/build-module/store/get-block-settings.js.map +1 -1
- package/build-module/store/index.js +0 -2
- package/build-module/store/index.js.map +1 -1
- package/build-module/store/private-actions.js +5 -0
- package/build-module/store/private-actions.js.map +1 -1
- package/build-module/store/private-keys.js +2 -0
- package/build-module/store/private-keys.js.map +1 -0
- package/build-module/store/private-selectors.js +5 -6
- package/build-module/store/private-selectors.js.map +1 -1
- package/build-module/store/reducer.js +1 -9
- package/build-module/store/reducer.js.map +1 -1
- package/build-module/store/selectors.js +8 -13
- package/build-module/store/selectors.js.map +1 -1
- package/build-module/store/utils.js +6 -2
- package/build-module/store/utils.js.map +1 -1
- package/build-style/style-rtl.css +0 -10
- package/build-style/style.css +0 -10
- package/package.json +31 -31
- package/src/components/block-tools/insertion-point.js +6 -1
- package/src/components/global-styles/advanced-panel.js +6 -12
- package/src/components/global-styles/border-panel.js +4 -6
- package/src/components/global-styles/get-global-styles-changes.js +68 -28
- package/src/components/global-styles/shadow-panel-components.js +3 -3
- package/src/components/global-styles/style.scss +0 -10
- package/src/components/global-styles/test/get-global-styles-changes.js +114 -75
- package/src/components/global-styles/typography-panel.js +11 -7
- package/src/components/iframe/index.js +4 -1
- package/src/components/inserter/media-tab/media-preview.js +6 -1
- package/src/components/rich-text/index.js +12 -5
- package/src/components/rich-text/index.native.js +1 -0
- package/src/components/rich-text/use-enter.js +1 -0
- package/src/components/rich-text/use-paste-handler.js +26 -25
- package/src/hooks/background.js +5 -2
- package/src/hooks/use-bindings-attributes.js +0 -21
- package/src/hooks/utils.js +24 -8
- package/src/private-apis.js +2 -0
- package/src/store/get-block-settings.js +15 -4
- package/src/store/index.js +0 -2
- package/src/store/private-actions.js +9 -0
- package/src/store/private-keys.js +1 -0
- package/src/store/private-selectors.js +4 -7
- package/src/store/reducer.js +0 -10
- package/src/store/selectors.js +7 -15
- package/src/store/utils.js +7 -2
- package/build/store/resolvers.js +0 -27
- package/build/store/resolvers.js.map +0 -1
- package/build-module/store/resolvers.js +0 -20
- package/build-module/store/resolvers.js.map +0 -1
- package/src/store/resolvers.js +0 -17
|
@@ -13,7 +13,11 @@ import { useCallback } from '@wordpress/element';
|
|
|
13
13
|
/**
|
|
14
14
|
* Internal dependencies
|
|
15
15
|
*/
|
|
16
|
-
import {
|
|
16
|
+
import {
|
|
17
|
+
mergeOrigins,
|
|
18
|
+
overrideOrigins,
|
|
19
|
+
hasOriginValue,
|
|
20
|
+
} from '../../store/get-block-settings';
|
|
17
21
|
import FontFamilyControl from '../font-family';
|
|
18
22
|
import FontAppearanceControl from '../font-appearance-control';
|
|
19
23
|
import LineHeightControl from '../line-height-control';
|
|
@@ -53,13 +57,13 @@ export function useHasTypographyPanel( settings ) {
|
|
|
53
57
|
|
|
54
58
|
function useHasFontSizeControl( settings ) {
|
|
55
59
|
return (
|
|
56
|
-
|
|
60
|
+
hasOriginValue( settings?.typography?.fontSizes ) ||
|
|
57
61
|
settings?.typography?.customFontSize
|
|
58
62
|
);
|
|
59
63
|
}
|
|
60
64
|
|
|
61
65
|
function useHasFontFamilyControl( settings ) {
|
|
62
|
-
return
|
|
66
|
+
return hasOriginValue( settings?.typography?.fontFamilies );
|
|
63
67
|
}
|
|
64
68
|
|
|
65
69
|
function useHasLineHeightControl( settings ) {
|
|
@@ -101,10 +105,10 @@ function useHasTextColumnsControl( settings ) {
|
|
|
101
105
|
}
|
|
102
106
|
|
|
103
107
|
function getUniqueFontSizesBySlug( settings ) {
|
|
104
|
-
const fontSizes = settings?.typography?.fontSizes;
|
|
105
|
-
const
|
|
108
|
+
const fontSizes = settings?.typography?.fontSizes ?? {};
|
|
109
|
+
const overriddenFontSizes = overrideOrigins( fontSizes ) ?? [];
|
|
106
110
|
const uniqueSizes = [];
|
|
107
|
-
for ( const currentSize of
|
|
111
|
+
for ( const currentSize of overriddenFontSizes ) {
|
|
108
112
|
if ( ! uniqueSizes.some( ( { slug } ) => slug === currentSize.slug ) ) {
|
|
109
113
|
uniqueSizes.push( currentSize );
|
|
110
114
|
}
|
|
@@ -162,7 +166,7 @@ export default function TypographyPanel( {
|
|
|
162
166
|
|
|
163
167
|
// Font Family
|
|
164
168
|
const hasFontFamilyEnabled = useHasFontFamilyControl( settings );
|
|
165
|
-
const fontFamilies = settings?.typography?.fontFamilies;
|
|
169
|
+
const fontFamilies = settings?.typography?.fontFamilies ?? {};
|
|
166
170
|
const mergedFontFamilies = fontFamilies ? mergeOrigins( fontFamilies ) : [];
|
|
167
171
|
const fontFamily = decodeValue( inheritedValue?.typography?.fontFamily );
|
|
168
172
|
const setFontFamily = ( newValue ) => {
|
|
@@ -273,13 +273,16 @@ function Iframe( {
|
|
|
273
273
|
src={ src }
|
|
274
274
|
title={ __( 'Editor canvas' ) }
|
|
275
275
|
onKeyDown={ ( event ) => {
|
|
276
|
+
if ( props.onKeyDown ) {
|
|
277
|
+
props.onKeyDown( event );
|
|
278
|
+
}
|
|
276
279
|
// If the event originates from inside the iframe, it means
|
|
277
280
|
// it bubbled through the portal, but only with React
|
|
278
281
|
// events. We need to to bubble native events as well,
|
|
279
282
|
// though by doing so we also trigger another React event,
|
|
280
283
|
// so we need to stop the propagation of this event to avoid
|
|
281
284
|
// duplication.
|
|
282
|
-
if (
|
|
285
|
+
else if (
|
|
283
286
|
event.currentTarget.ownerDocument !==
|
|
284
287
|
event.target.ownerDocument
|
|
285
288
|
) {
|
|
@@ -195,7 +195,12 @@ export function MediaPreview( { media, onClick, category } ) {
|
|
|
195
195
|
createSuccessNotice,
|
|
196
196
|
]
|
|
197
197
|
);
|
|
198
|
-
|
|
198
|
+
|
|
199
|
+
const title =
|
|
200
|
+
typeof media.title === 'string'
|
|
201
|
+
? media.title
|
|
202
|
+
: media.title?.rendered || __( 'no title' );
|
|
203
|
+
|
|
199
204
|
let truncatedTitle;
|
|
200
205
|
if ( title.length > MAXIMUM_TITLE_LENGTH ) {
|
|
201
206
|
const omission = '...';
|
|
@@ -156,12 +156,19 @@ export function RichTextWrapper(
|
|
|
156
156
|
for ( const [ attribute, args ] of Object.entries(
|
|
157
157
|
blockBindings
|
|
158
158
|
) ) {
|
|
159
|
-
// If any of the attributes with source "rich-text" is part of the bindings,
|
|
160
|
-
// has a source with `lockAttributesEditing`, disable it.
|
|
161
159
|
if (
|
|
162
|
-
blockTypeAttributes?.[ attribute ]?.source
|
|
163
|
-
|
|
164
|
-
|
|
160
|
+
blockTypeAttributes?.[ attribute ]?.source !== 'rich-text'
|
|
161
|
+
) {
|
|
162
|
+
break;
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
// If the source is not defined, or if its value of `lockAttributesEditing` is `true`, disable it.
|
|
166
|
+
const blockBindingsSource = getBlockBindingsSource(
|
|
167
|
+
args.source
|
|
168
|
+
);
|
|
169
|
+
if (
|
|
170
|
+
! blockBindingsSource ||
|
|
171
|
+
blockBindingsSource.lockAttributesEditing
|
|
165
172
|
) {
|
|
166
173
|
shouldDisableEditing = true;
|
|
167
174
|
break;
|
|
@@ -58,13 +58,35 @@ export function usePasteHandler( props ) {
|
|
|
58
58
|
const isInternal =
|
|
59
59
|
event.clipboardData.getData( 'rich-text' ) === 'true';
|
|
60
60
|
|
|
61
|
+
function pasteInline( content ) {
|
|
62
|
+
const transformed = formatTypes.reduce(
|
|
63
|
+
( accumulator, { __unstablePasteRule } ) => {
|
|
64
|
+
// Only allow one transform.
|
|
65
|
+
if ( __unstablePasteRule && accumulator === value ) {
|
|
66
|
+
accumulator = __unstablePasteRule( value, {
|
|
67
|
+
html,
|
|
68
|
+
plainText,
|
|
69
|
+
} );
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
return accumulator;
|
|
73
|
+
},
|
|
74
|
+
value
|
|
75
|
+
);
|
|
76
|
+
if ( transformed !== value ) {
|
|
77
|
+
onChange( transformed );
|
|
78
|
+
} else {
|
|
79
|
+
const valueToInsert = create( { html: content } );
|
|
80
|
+
addActiveFormats( valueToInsert, value.activeFormats );
|
|
81
|
+
onChange( insert( value, valueToInsert ) );
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
|
|
61
85
|
// If the data comes from a rich text instance, we can directly use it
|
|
62
86
|
// without filtering the data. The filters are only meant for externally
|
|
63
87
|
// pasted content and remove inline styles.
|
|
64
88
|
if ( isInternal ) {
|
|
65
|
-
|
|
66
|
-
addActiveFormats( pastedValue, value.activeFormats );
|
|
67
|
-
onChange( insert( value, pastedValue ) );
|
|
89
|
+
pasteInline( html );
|
|
68
90
|
return;
|
|
69
91
|
}
|
|
70
92
|
|
|
@@ -135,28 +157,7 @@ export function usePasteHandler( props ) {
|
|
|
135
157
|
} );
|
|
136
158
|
|
|
137
159
|
if ( typeof content === 'string' ) {
|
|
138
|
-
|
|
139
|
-
( accumlator, { __unstablePasteRule } ) => {
|
|
140
|
-
// Only allow one transform.
|
|
141
|
-
if ( __unstablePasteRule && accumlator === value ) {
|
|
142
|
-
accumlator = __unstablePasteRule( value, {
|
|
143
|
-
html,
|
|
144
|
-
plainText,
|
|
145
|
-
} );
|
|
146
|
-
}
|
|
147
|
-
|
|
148
|
-
return accumlator;
|
|
149
|
-
},
|
|
150
|
-
value
|
|
151
|
-
);
|
|
152
|
-
|
|
153
|
-
if ( transformed !== value ) {
|
|
154
|
-
onChange( transformed );
|
|
155
|
-
} else {
|
|
156
|
-
const valueToInsert = create( { html: content } );
|
|
157
|
-
addActiveFormats( valueToInsert, value.activeFormats );
|
|
158
|
-
onChange( insert( value, valueToInsert ) );
|
|
159
|
-
}
|
|
160
|
+
pasteInline( content );
|
|
160
161
|
} else if ( content.length > 0 ) {
|
|
161
162
|
if ( onReplace && isEmpty( value ) ) {
|
|
162
163
|
onReplace( content, content.length - 1, -1 );
|
package/src/hooks/background.js
CHANGED
|
@@ -374,11 +374,14 @@ function backgroundSizeHelpText( value ) {
|
|
|
374
374
|
}
|
|
375
375
|
|
|
376
376
|
export const coordsToBackgroundPosition = ( value ) => {
|
|
377
|
-
if ( ! value || isNaN( value.x )
|
|
377
|
+
if ( ! value || ( isNaN( value.x ) && isNaN( value.y ) ) ) {
|
|
378
378
|
return undefined;
|
|
379
379
|
}
|
|
380
380
|
|
|
381
|
-
|
|
381
|
+
const x = isNaN( value.x ) ? 0.5 : value.x;
|
|
382
|
+
const y = isNaN( value.y ) ? 0.5 : value.y;
|
|
383
|
+
|
|
384
|
+
return `${ x * 100 }% ${ y * 100 }%`;
|
|
382
385
|
};
|
|
383
386
|
|
|
384
387
|
export const backgroundPositionToCoords = ( value ) => {
|
|
@@ -112,24 +112,3 @@ addFilter(
|
|
|
112
112
|
'core/editor/custom-sources-backwards-compatibility/shim-attribute-source',
|
|
113
113
|
shimAttributeSource
|
|
114
114
|
);
|
|
115
|
-
|
|
116
|
-
// Add the context to all blocks.
|
|
117
|
-
addFilter(
|
|
118
|
-
'blocks.registerBlockType',
|
|
119
|
-
'core/block-bindings-ui',
|
|
120
|
-
( settings, name ) => {
|
|
121
|
-
if ( ! ( name in BLOCK_BINDINGS_ALLOWED_BLOCKS ) ) {
|
|
122
|
-
return settings;
|
|
123
|
-
}
|
|
124
|
-
const contextItems = [ 'postId', 'postType', 'queryId' ];
|
|
125
|
-
const usesContextArray = settings.usesContext;
|
|
126
|
-
const oldUsesContextArray = new Set( usesContextArray );
|
|
127
|
-
contextItems.forEach( ( item ) => {
|
|
128
|
-
if ( ! oldUsesContextArray.has( item ) ) {
|
|
129
|
-
usesContextArray.push( item );
|
|
130
|
-
}
|
|
131
|
-
} );
|
|
132
|
-
settings.usesContext = usesContextArray;
|
|
133
|
-
return settings;
|
|
134
|
-
}
|
|
135
|
-
);
|
package/src/hooks/utils.js
CHANGED
|
@@ -176,8 +176,12 @@ export function useBlockSettings( name, parentLayout ) {
|
|
|
176
176
|
const [
|
|
177
177
|
backgroundImage,
|
|
178
178
|
backgroundSize,
|
|
179
|
-
|
|
180
|
-
|
|
179
|
+
customFontFamilies,
|
|
180
|
+
defaultFontFamilies,
|
|
181
|
+
themeFontFamilies,
|
|
182
|
+
customFontSizes,
|
|
183
|
+
defaultFontSizes,
|
|
184
|
+
themeFontSizes,
|
|
181
185
|
customFontSize,
|
|
182
186
|
fontStyle,
|
|
183
187
|
fontWeight,
|
|
@@ -223,8 +227,12 @@ export function useBlockSettings( name, parentLayout ) {
|
|
|
223
227
|
] = useSettings(
|
|
224
228
|
'background.backgroundImage',
|
|
225
229
|
'background.backgroundSize',
|
|
226
|
-
'typography.fontFamilies',
|
|
227
|
-
'typography.
|
|
230
|
+
'typography.fontFamilies.custom',
|
|
231
|
+
'typography.fontFamilies.default',
|
|
232
|
+
'typography.fontFamilies.theme',
|
|
233
|
+
'typography.fontSizes.custom',
|
|
234
|
+
'typography.fontSizes.default',
|
|
235
|
+
'typography.fontSizes.theme',
|
|
228
236
|
'typography.customFontSize',
|
|
229
237
|
'typography.fontStyle',
|
|
230
238
|
'typography.fontWeight',
|
|
@@ -305,10 +313,14 @@ export function useBlockSettings( name, parentLayout ) {
|
|
|
305
313
|
},
|
|
306
314
|
typography: {
|
|
307
315
|
fontFamilies: {
|
|
308
|
-
custom:
|
|
316
|
+
custom: customFontFamilies,
|
|
317
|
+
default: defaultFontFamilies,
|
|
318
|
+
theme: themeFontFamilies,
|
|
309
319
|
},
|
|
310
320
|
fontSizes: {
|
|
311
|
-
custom:
|
|
321
|
+
custom: customFontSizes,
|
|
322
|
+
default: defaultFontSizes,
|
|
323
|
+
theme: themeFontSizes,
|
|
312
324
|
},
|
|
313
325
|
customFontSize,
|
|
314
326
|
fontStyle,
|
|
@@ -346,8 +358,12 @@ export function useBlockSettings( name, parentLayout ) {
|
|
|
346
358
|
}, [
|
|
347
359
|
backgroundImage,
|
|
348
360
|
backgroundSize,
|
|
349
|
-
|
|
350
|
-
|
|
361
|
+
customFontFamilies,
|
|
362
|
+
defaultFontFamilies,
|
|
363
|
+
themeFontFamilies,
|
|
364
|
+
customFontSizes,
|
|
365
|
+
defaultFontSizes,
|
|
366
|
+
themeFontSizes,
|
|
351
367
|
customFontSize,
|
|
352
368
|
fontStyle,
|
|
353
369
|
fontWeight,
|
package/src/private-apis.js
CHANGED
|
@@ -26,6 +26,7 @@ import { usesContextKey } from './components/rich-text/format-edit';
|
|
|
26
26
|
import { ExperimentalBlockCanvas } from './components/block-canvas';
|
|
27
27
|
import { getDuotoneFilter } from './components/duotone/utils';
|
|
28
28
|
import { useFlashEditableBlocks } from './components/use-flash-editable-blocks';
|
|
29
|
+
import { selectBlockPatternsKey } from './store/private-keys';
|
|
29
30
|
|
|
30
31
|
/**
|
|
31
32
|
* Private @wordpress/block-editor APIs.
|
|
@@ -56,4 +57,5 @@ lock( privateApis, {
|
|
|
56
57
|
useReusableBlocksRenameHint,
|
|
57
58
|
usesContextKey,
|
|
58
59
|
useFlashEditableBlocks,
|
|
60
|
+
selectBlockPatternsKey,
|
|
59
61
|
} );
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
* WordPress dependencies
|
|
3
3
|
*/
|
|
4
4
|
import {
|
|
5
|
-
|
|
5
|
+
__EXPERIMENTAL_PATHS_WITH_OVERRIDE as PATHS_WITH_OVERRIDE,
|
|
6
6
|
hasBlockSupport,
|
|
7
7
|
} from '@wordpress/blocks';
|
|
8
8
|
import { applyFilters } from '@wordpress/hooks';
|
|
@@ -111,6 +111,17 @@ export function mergeOrigins( value ) {
|
|
|
111
111
|
}
|
|
112
112
|
const mergeCache = new WeakMap();
|
|
113
113
|
|
|
114
|
+
/**
|
|
115
|
+
* For settings like `color.palette`, which have a value that is an object
|
|
116
|
+
* with `default`, `theme`, `custom`, with field values that are arrays of
|
|
117
|
+
* items, returns the one with the highest priority among these three arrays.
|
|
118
|
+
* @param {Object} value Object to extract from
|
|
119
|
+
* @return {Array} Array of items extracted from the three origins
|
|
120
|
+
*/
|
|
121
|
+
export function overrideOrigins( value ) {
|
|
122
|
+
return value.custom ?? value.theme ?? value.default;
|
|
123
|
+
}
|
|
124
|
+
|
|
114
125
|
/**
|
|
115
126
|
* For settings like `color.palette`, which have a value that is an object
|
|
116
127
|
* with `default`, `theme`, `custom`, with field values that are arrays of
|
|
@@ -119,7 +130,7 @@ const mergeCache = new WeakMap();
|
|
|
119
130
|
* @param {Object} value Object to check
|
|
120
131
|
* @return {boolean} Whether the object has values in any of the three origins
|
|
121
132
|
*/
|
|
122
|
-
export function
|
|
133
|
+
export function hasOriginValue( value ) {
|
|
123
134
|
return [ 'default', 'theme', 'custom' ].some(
|
|
124
135
|
( key ) => value?.[ key ]?.length
|
|
125
136
|
);
|
|
@@ -203,8 +214,8 @@ export function getBlockSettings( state, clientId, ...paths ) {
|
|
|
203
214
|
|
|
204
215
|
// Return if the setting was found in either the block instance or the store.
|
|
205
216
|
if ( result !== undefined ) {
|
|
206
|
-
if (
|
|
207
|
-
return
|
|
217
|
+
if ( PATHS_WITH_OVERRIDE[ normalizedPath ] ) {
|
|
218
|
+
return overrideOrigins( result );
|
|
208
219
|
}
|
|
209
220
|
return result;
|
|
210
221
|
}
|
package/src/store/index.js
CHANGED
|
@@ -10,7 +10,6 @@ import reducer from './reducer';
|
|
|
10
10
|
import * as selectors from './selectors';
|
|
11
11
|
import * as privateActions from './private-actions';
|
|
12
12
|
import * as privateSelectors from './private-selectors';
|
|
13
|
-
import * as resolvers from './resolvers';
|
|
14
13
|
import * as actions from './actions';
|
|
15
14
|
import { STORE_NAME } from './constants';
|
|
16
15
|
import { unlock } from '../lock-unlock';
|
|
@@ -23,7 +22,6 @@ import { unlock } from '../lock-unlock';
|
|
|
23
22
|
export const storeConfig = {
|
|
24
23
|
reducer,
|
|
25
24
|
selectors,
|
|
26
|
-
resolvers,
|
|
27
25
|
actions,
|
|
28
26
|
};
|
|
29
27
|
|
|
@@ -140,6 +140,15 @@ export const privateRemoveBlocks =
|
|
|
140
140
|
}
|
|
141
141
|
|
|
142
142
|
if ( rules[ 'bindings/core/pattern-overrides' ] ) {
|
|
143
|
+
const parentPatternBlocks =
|
|
144
|
+
select.getBlockParentsByBlockName(
|
|
145
|
+
clientId,
|
|
146
|
+
'core/block'
|
|
147
|
+
);
|
|
148
|
+
// We only need to run this check when editing the original pattern, not pattern instances.
|
|
149
|
+
if ( parentPatternBlocks?.length > 0 ) {
|
|
150
|
+
continue;
|
|
151
|
+
}
|
|
143
152
|
const blockAttributes =
|
|
144
153
|
select.getBlockAttributes( clientId );
|
|
145
154
|
if (
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export const selectBlockPatternsKey = Symbol( 'selectBlockPatternsKey' );
|
|
@@ -22,6 +22,7 @@ import { checkAllowListRecursive, getAllPatternsDependants } from './utils';
|
|
|
22
22
|
import { INSERTER_PATTERN_TYPES } from '../components/inserter/block-patterns-tab/utils';
|
|
23
23
|
import { STORE_NAME } from './constants';
|
|
24
24
|
import { unlock } from '../lock-unlock';
|
|
25
|
+
import { selectBlockPatternsKey } from './private-keys';
|
|
25
26
|
|
|
26
27
|
export { getBlockSettings } from './get-block-settings';
|
|
27
28
|
|
|
@@ -250,10 +251,6 @@ export const getInserterMediaCategories = createSelector(
|
|
|
250
251
|
]
|
|
251
252
|
);
|
|
252
253
|
|
|
253
|
-
export function getFetchedPatterns( state ) {
|
|
254
|
-
return state.blockPatterns;
|
|
255
|
-
}
|
|
256
|
-
|
|
257
254
|
/**
|
|
258
255
|
* Returns whether there is at least one allowed pattern for inner blocks children.
|
|
259
256
|
* This is useful for deferring the parsing of all patterns until needed.
|
|
@@ -285,7 +282,7 @@ export const hasAllowedPatterns = createRegistrySelector( ( select ) =>
|
|
|
285
282
|
} );
|
|
286
283
|
},
|
|
287
284
|
( state, rootClientId ) => [
|
|
288
|
-
getAllPatternsDependants( state ),
|
|
285
|
+
getAllPatternsDependants( select )( state ),
|
|
289
286
|
state.settings.allowedBlockTypes,
|
|
290
287
|
state.settings.templateLock,
|
|
291
288
|
state.blockListSettings[ rootClientId ],
|
|
@@ -325,12 +322,12 @@ export const getAllPatterns = createRegistrySelector( ( select ) =>
|
|
|
325
322
|
return [
|
|
326
323
|
...userPatterns,
|
|
327
324
|
...__experimentalBlockPatterns,
|
|
328
|
-
...
|
|
325
|
+
...( state.settings[ selectBlockPatternsKey ]?.( select ) ?? [] ),
|
|
329
326
|
].filter(
|
|
330
327
|
( x, index, arr ) =>
|
|
331
328
|
index === arr.findIndex( ( y ) => x.name === y.name )
|
|
332
329
|
);
|
|
333
|
-
}, getAllPatternsDependants )
|
|
330
|
+
}, getAllPatternsDependants( select ) )
|
|
334
331
|
);
|
|
335
332
|
|
|
336
333
|
/**
|
package/src/store/reducer.js
CHANGED
|
@@ -2064,15 +2064,6 @@ function blockBindingsSources( state = {}, action ) {
|
|
|
2064
2064
|
return state;
|
|
2065
2065
|
}
|
|
2066
2066
|
|
|
2067
|
-
function blockPatterns( state = [], action ) {
|
|
2068
|
-
switch ( action.type ) {
|
|
2069
|
-
case 'RECEIVE_BLOCK_PATTERNS':
|
|
2070
|
-
return action.patterns;
|
|
2071
|
-
}
|
|
2072
|
-
|
|
2073
|
-
return state;
|
|
2074
|
-
}
|
|
2075
|
-
|
|
2076
2067
|
const combinedReducers = combineReducers( {
|
|
2077
2068
|
blocks,
|
|
2078
2069
|
isDragging,
|
|
@@ -2105,7 +2096,6 @@ const combinedReducers = combineReducers( {
|
|
|
2105
2096
|
openedBlockSettingsMenu,
|
|
2106
2097
|
registeredInserterMediaCategories,
|
|
2107
2098
|
blockBindingsSources,
|
|
2108
|
-
blockPatterns,
|
|
2109
2099
|
} );
|
|
2110
2100
|
|
|
2111
2101
|
function withAutomaticChangeReset( reducer ) {
|
package/src/store/selectors.js
CHANGED
|
@@ -10,7 +10,6 @@ import {
|
|
|
10
10
|
getBlockType,
|
|
11
11
|
getBlockTypes,
|
|
12
12
|
getBlockVariations,
|
|
13
|
-
getHookedBlocks,
|
|
14
13
|
hasBlockSupport,
|
|
15
14
|
getPossibleBlockTransformations,
|
|
16
15
|
parse,
|
|
@@ -1937,16 +1936,9 @@ const buildBlockTypeItem =
|
|
|
1937
1936
|
blockType.name,
|
|
1938
1937
|
'inserter'
|
|
1939
1938
|
);
|
|
1940
|
-
|
|
1941
|
-
const ignoredHookedBlocks = [
|
|
1942
|
-
...new Set( Object.values( getHookedBlocks( id ) ).flat() ),
|
|
1943
|
-
];
|
|
1944
|
-
|
|
1945
1939
|
return {
|
|
1946
1940
|
...blockItemBase,
|
|
1947
|
-
initialAttributes:
|
|
1948
|
-
? { metadata: { ignoredHookedBlocks } }
|
|
1949
|
-
: {},
|
|
1941
|
+
initialAttributes: {},
|
|
1950
1942
|
description: blockType.description,
|
|
1951
1943
|
category: blockType.category,
|
|
1952
1944
|
keywords: blockType.keywords,
|
|
@@ -2307,12 +2299,12 @@ export const __experimentalGetParsedPattern = createRegistrySelector(
|
|
|
2307
2299
|
__unstableSkipMigrationLogs: true,
|
|
2308
2300
|
} ),
|
|
2309
2301
|
};
|
|
2310
|
-
}, getAllPatternsDependants )
|
|
2302
|
+
}, getAllPatternsDependants( select ) )
|
|
2311
2303
|
);
|
|
2312
2304
|
|
|
2313
|
-
const getAllowedPatternsDependants = ( state, rootClientId ) => {
|
|
2305
|
+
const getAllowedPatternsDependants = ( select ) => ( state, rootClientId ) => {
|
|
2314
2306
|
return [
|
|
2315
|
-
...getAllPatternsDependants( state ),
|
|
2307
|
+
...getAllPatternsDependants( select )( state ),
|
|
2316
2308
|
state.settings.allowedBlockTypes,
|
|
2317
2309
|
state.settings.templateLock,
|
|
2318
2310
|
state.blockListSettings[ rootClientId ],
|
|
@@ -2353,7 +2345,7 @@ export const __experimentalGetAllowedPatterns = createRegistrySelector(
|
|
|
2353
2345
|
);
|
|
2354
2346
|
|
|
2355
2347
|
return patternsAllowed;
|
|
2356
|
-
}, getAllowedPatternsDependants );
|
|
2348
|
+
}, getAllowedPatternsDependants( select ) );
|
|
2357
2349
|
}
|
|
2358
2350
|
);
|
|
2359
2351
|
|
|
@@ -2392,7 +2384,7 @@ export const getPatternsByBlockTypes = createRegistrySelector( ( select ) =>
|
|
|
2392
2384
|
return filteredPatterns;
|
|
2393
2385
|
},
|
|
2394
2386
|
( state, blockNames, rootClientId ) =>
|
|
2395
|
-
getAllowedPatternsDependants( state, rootClientId )
|
|
2387
|
+
getAllowedPatternsDependants( select )( state, rootClientId )
|
|
2396
2388
|
)
|
|
2397
2389
|
);
|
|
2398
2390
|
|
|
@@ -2466,7 +2458,7 @@ export const __experimentalGetPatternTransformItems = createRegistrySelector(
|
|
|
2466
2458
|
);
|
|
2467
2459
|
},
|
|
2468
2460
|
( state, blocks, rootClientId ) =>
|
|
2469
|
-
getAllowedPatternsDependants( state, rootClientId )
|
|
2461
|
+
getAllowedPatternsDependants( select )( state, rootClientId )
|
|
2470
2462
|
)
|
|
2471
2463
|
);
|
|
2472
2464
|
|
package/src/store/utils.js
CHANGED
|
@@ -1,3 +1,8 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Internal dependencies
|
|
3
|
+
*/
|
|
4
|
+
import { selectBlockPatternsKey } from './private-keys';
|
|
5
|
+
|
|
1
6
|
export const checkAllowList = ( list, item, defaultResult = null ) => {
|
|
2
7
|
if ( typeof list === 'boolean' ) {
|
|
3
8
|
return list;
|
|
@@ -40,12 +45,12 @@ export const checkAllowListRecursive = ( blocks, allowedBlockTypes ) => {
|
|
|
40
45
|
return true;
|
|
41
46
|
};
|
|
42
47
|
|
|
43
|
-
export const getAllPatternsDependants = ( state ) => {
|
|
48
|
+
export const getAllPatternsDependants = ( select ) => ( state ) => {
|
|
44
49
|
return [
|
|
45
50
|
state.settings.__experimentalBlockPatterns,
|
|
46
51
|
state.settings.__experimentalUserPatternCategories,
|
|
47
52
|
state.settings.__experimentalReusableBlocks,
|
|
48
|
-
state.settings
|
|
53
|
+
state.settings[ selectBlockPatternsKey ]?.( select ),
|
|
49
54
|
state.blockPatterns,
|
|
50
55
|
];
|
|
51
56
|
};
|
package/build/store/resolvers.js
DELETED
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.getFetchedPatterns = void 0;
|
|
7
|
-
const getFetchedPatterns = () => async ({
|
|
8
|
-
dispatch,
|
|
9
|
-
select
|
|
10
|
-
}) => {
|
|
11
|
-
const {
|
|
12
|
-
__experimentalFetchBlockPatterns
|
|
13
|
-
} = select.getSettings();
|
|
14
|
-
if (!__experimentalFetchBlockPatterns) {
|
|
15
|
-
return [];
|
|
16
|
-
}
|
|
17
|
-
const patterns = await __experimentalFetchBlockPatterns();
|
|
18
|
-
dispatch({
|
|
19
|
-
type: 'RECEIVE_BLOCK_PATTERNS',
|
|
20
|
-
patterns
|
|
21
|
-
});
|
|
22
|
-
};
|
|
23
|
-
exports.getFetchedPatterns = getFetchedPatterns;
|
|
24
|
-
getFetchedPatterns.shouldInvalidate = action => {
|
|
25
|
-
return action.type === 'UPDATE_SETTINGS' && !!action.settings.__experimentalFetchBlockPatterns;
|
|
26
|
-
};
|
|
27
|
-
//# sourceMappingURL=resolvers.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"names":["getFetchedPatterns","dispatch","select","__experimentalFetchBlockPatterns","getSettings","patterns","type","exports","shouldInvalidate","action","settings"],"sources":["@wordpress/block-editor/src/store/resolvers.js"],"sourcesContent":["export const getFetchedPatterns =\n\t() =>\n\tasync ( { dispatch, select } ) => {\n\t\tconst { __experimentalFetchBlockPatterns } = select.getSettings();\n\t\tif ( ! __experimentalFetchBlockPatterns ) {\n\t\t\treturn [];\n\t\t}\n\t\tconst patterns = await __experimentalFetchBlockPatterns();\n\t\tdispatch( { type: 'RECEIVE_BLOCK_PATTERNS', patterns } );\n\t};\n\ngetFetchedPatterns.shouldInvalidate = ( action ) => {\n\treturn (\n\t\taction.type === 'UPDATE_SETTINGS' &&\n\t\t!! action.settings.__experimentalFetchBlockPatterns\n\t);\n};\n"],"mappings":";;;;;;AAAO,MAAMA,kBAAkB,GAC9BA,CAAA,KACA,OAAQ;EAAEC,QAAQ;EAAEC;AAAO,CAAC,KAAM;EACjC,MAAM;IAAEC;EAAiC,CAAC,GAAGD,MAAM,CAACE,WAAW,CAAC,CAAC;EACjE,IAAK,CAAED,gCAAgC,EAAG;IACzC,OAAO,EAAE;EACV;EACA,MAAME,QAAQ,GAAG,MAAMF,gCAAgC,CAAC,CAAC;EACzDF,QAAQ,CAAE;IAAEK,IAAI,EAAE,wBAAwB;IAAED;EAAS,CAAE,CAAC;AACzD,CAAC;AAACE,OAAA,CAAAP,kBAAA,GAAAA,kBAAA;AAEHA,kBAAkB,CAACQ,gBAAgB,GAAKC,MAAM,IAAM;EACnD,OACCA,MAAM,CAACH,IAAI,KAAK,iBAAiB,IACjC,CAAC,CAAEG,MAAM,CAACC,QAAQ,CAACP,gCAAgC;AAErD,CAAC"}
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
export const getFetchedPatterns = () => async ({
|
|
2
|
-
dispatch,
|
|
3
|
-
select
|
|
4
|
-
}) => {
|
|
5
|
-
const {
|
|
6
|
-
__experimentalFetchBlockPatterns
|
|
7
|
-
} = select.getSettings();
|
|
8
|
-
if (!__experimentalFetchBlockPatterns) {
|
|
9
|
-
return [];
|
|
10
|
-
}
|
|
11
|
-
const patterns = await __experimentalFetchBlockPatterns();
|
|
12
|
-
dispatch({
|
|
13
|
-
type: 'RECEIVE_BLOCK_PATTERNS',
|
|
14
|
-
patterns
|
|
15
|
-
});
|
|
16
|
-
};
|
|
17
|
-
getFetchedPatterns.shouldInvalidate = action => {
|
|
18
|
-
return action.type === 'UPDATE_SETTINGS' && !!action.settings.__experimentalFetchBlockPatterns;
|
|
19
|
-
};
|
|
20
|
-
//# sourceMappingURL=resolvers.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"names":["getFetchedPatterns","dispatch","select","__experimentalFetchBlockPatterns","getSettings","patterns","type","shouldInvalidate","action","settings"],"sources":["@wordpress/block-editor/src/store/resolvers.js"],"sourcesContent":["export const getFetchedPatterns =\n\t() =>\n\tasync ( { dispatch, select } ) => {\n\t\tconst { __experimentalFetchBlockPatterns } = select.getSettings();\n\t\tif ( ! __experimentalFetchBlockPatterns ) {\n\t\t\treturn [];\n\t\t}\n\t\tconst patterns = await __experimentalFetchBlockPatterns();\n\t\tdispatch( { type: 'RECEIVE_BLOCK_PATTERNS', patterns } );\n\t};\n\ngetFetchedPatterns.shouldInvalidate = ( action ) => {\n\treturn (\n\t\taction.type === 'UPDATE_SETTINGS' &&\n\t\t!! action.settings.__experimentalFetchBlockPatterns\n\t);\n};\n"],"mappings":"AAAA,OAAO,MAAMA,kBAAkB,GAC9BA,CAAA,KACA,OAAQ;EAAEC,QAAQ;EAAEC;AAAO,CAAC,KAAM;EACjC,MAAM;IAAEC;EAAiC,CAAC,GAAGD,MAAM,CAACE,WAAW,CAAC,CAAC;EACjE,IAAK,CAAED,gCAAgC,EAAG;IACzC,OAAO,EAAE;EACV;EACA,MAAME,QAAQ,GAAG,MAAMF,gCAAgC,CAAC,CAAC;EACzDF,QAAQ,CAAE;IAAEK,IAAI,EAAE,wBAAwB;IAAED;EAAS,CAAE,CAAC;AACzD,CAAC;AAEFL,kBAAkB,CAACO,gBAAgB,GAAKC,MAAM,IAAM;EACnD,OACCA,MAAM,CAACF,IAAI,KAAK,iBAAiB,IACjC,CAAC,CAAEE,MAAM,CAACC,QAAQ,CAACN,gCAAgC;AAErD,CAAC"}
|
package/src/store/resolvers.js
DELETED
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
export const getFetchedPatterns =
|
|
2
|
-
() =>
|
|
3
|
-
async ( { dispatch, select } ) => {
|
|
4
|
-
const { __experimentalFetchBlockPatterns } = select.getSettings();
|
|
5
|
-
if ( ! __experimentalFetchBlockPatterns ) {
|
|
6
|
-
return [];
|
|
7
|
-
}
|
|
8
|
-
const patterns = await __experimentalFetchBlockPatterns();
|
|
9
|
-
dispatch( { type: 'RECEIVE_BLOCK_PATTERNS', patterns } );
|
|
10
|
-
};
|
|
11
|
-
|
|
12
|
-
getFetchedPatterns.shouldInvalidate = ( action ) => {
|
|
13
|
-
return (
|
|
14
|
-
action.type === 'UPDATE_SETTINGS' &&
|
|
15
|
-
!! action.settings.__experimentalFetchBlockPatterns
|
|
16
|
-
);
|
|
17
|
-
};
|