@wordpress/block-editor 12.19.0 → 12.19.2
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/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/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/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-input-rules.js +1 -30
- package/build/components/rich-text/use-input-rules.js.map +1 -1
- package/build/hooks/use-bindings-attributes.js +1 -18
- 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/store/get-block-settings.js +17 -4
- package/build/store/get-block-settings.js.map +1 -1
- package/build/store/private-actions.js +5 -0
- package/build/store/private-actions.js.map +1 -1
- package/build/store/reducer.js +2 -1
- package/build/store/reducer.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/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/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-input-rules.js +2 -31
- package/build-module/components/rich-text/use-input-rules.js.map +1 -1
- package/build-module/hooks/use-bindings-attributes.js +1 -18
- 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/store/get-block-settings.js +16 -4
- package/build-module/store/get-block-settings.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/reducer.js +2 -1
- package/build-module/store/reducer.js.map +1 -1
- package/build-style/style-rtl.css +0 -12
- package/build-style/style.css +0 -12
- package/package.json +31 -31
- 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/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/link-control/style.scss +0 -7
- 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-input-rules.js +2 -30
- package/src/components/url-input/style.scss +0 -4
- package/src/hooks/use-bindings-attributes.js +1 -22
- package/src/hooks/utils.js +24 -8
- package/src/store/get-block-settings.js +15 -4
- package/src/store/private-actions.js +9 -0
- package/src/store/reducer.js +1 -1
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@wordpress/block-editor",
|
|
3
|
-
"version": "12.19.
|
|
3
|
+
"version": "12.19.2",
|
|
4
4
|
"description": "Generic block editor.",
|
|
5
5
|
"author": "The WordPress Contributors",
|
|
6
6
|
"license": "GPL-2.0-or-later",
|
|
@@ -35,35 +35,35 @@
|
|
|
35
35
|
"@emotion/react": "^11.7.1",
|
|
36
36
|
"@emotion/styled": "^11.6.0",
|
|
37
37
|
"@react-spring/web": "^9.4.5",
|
|
38
|
-
"@wordpress/a11y": "^3.51.
|
|
39
|
-
"@wordpress/api-fetch": "^6.48.
|
|
40
|
-
"@wordpress/blob": "^3.51.
|
|
41
|
-
"@wordpress/blocks": "^12.28.
|
|
42
|
-
"@wordpress/commands": "^0.22.
|
|
43
|
-
"@wordpress/components": "^26.0.
|
|
44
|
-
"@wordpress/compose": "^6.28.
|
|
45
|
-
"@wordpress/data": "^9.21.
|
|
46
|
-
"@wordpress/date": "^4.51.
|
|
47
|
-
"@wordpress/deprecated": "^3.51.
|
|
48
|
-
"@wordpress/dom": "^3.51.
|
|
49
|
-
"@wordpress/element": "^5.28.
|
|
50
|
-
"@wordpress/escape-html": "^2.51.
|
|
51
|
-
"@wordpress/hooks": "^3.51.
|
|
52
|
-
"@wordpress/html-entities": "^3.51.
|
|
53
|
-
"@wordpress/i18n": "^4.51.
|
|
54
|
-
"@wordpress/icons": "^9.42.
|
|
55
|
-
"@wordpress/is-shallow-equal": "^4.51.
|
|
56
|
-
"@wordpress/keyboard-shortcuts": "^4.28.
|
|
57
|
-
"@wordpress/keycodes": "^3.51.
|
|
58
|
-
"@wordpress/notices": "^4.19.
|
|
59
|
-
"@wordpress/preferences": "^3.28.
|
|
60
|
-
"@wordpress/private-apis": "^0.33.
|
|
61
|
-
"@wordpress/rich-text": "^6.28.
|
|
62
|
-
"@wordpress/style-engine": "^1.34.
|
|
63
|
-
"@wordpress/token-list": "^2.51.
|
|
64
|
-
"@wordpress/url": "^3.52.
|
|
65
|
-
"@wordpress/warning": "^2.51.
|
|
66
|
-
"@wordpress/wordcount": "^3.51.
|
|
38
|
+
"@wordpress/a11y": "^3.51.1",
|
|
39
|
+
"@wordpress/api-fetch": "^6.48.1",
|
|
40
|
+
"@wordpress/blob": "^3.51.1",
|
|
41
|
+
"@wordpress/blocks": "^12.28.2",
|
|
42
|
+
"@wordpress/commands": "^0.22.2",
|
|
43
|
+
"@wordpress/components": "^26.0.2",
|
|
44
|
+
"@wordpress/compose": "^6.28.1",
|
|
45
|
+
"@wordpress/data": "^9.21.1",
|
|
46
|
+
"@wordpress/date": "^4.51.1",
|
|
47
|
+
"@wordpress/deprecated": "^3.51.1",
|
|
48
|
+
"@wordpress/dom": "^3.51.1",
|
|
49
|
+
"@wordpress/element": "^5.28.1",
|
|
50
|
+
"@wordpress/escape-html": "^2.51.1",
|
|
51
|
+
"@wordpress/hooks": "^3.51.1",
|
|
52
|
+
"@wordpress/html-entities": "^3.51.1",
|
|
53
|
+
"@wordpress/i18n": "^4.51.1",
|
|
54
|
+
"@wordpress/icons": "^9.42.1",
|
|
55
|
+
"@wordpress/is-shallow-equal": "^4.51.1",
|
|
56
|
+
"@wordpress/keyboard-shortcuts": "^4.28.1",
|
|
57
|
+
"@wordpress/keycodes": "^3.51.1",
|
|
58
|
+
"@wordpress/notices": "^4.19.1",
|
|
59
|
+
"@wordpress/preferences": "^3.28.2",
|
|
60
|
+
"@wordpress/private-apis": "^0.33.1",
|
|
61
|
+
"@wordpress/rich-text": "^6.28.2",
|
|
62
|
+
"@wordpress/style-engine": "^1.34.1",
|
|
63
|
+
"@wordpress/token-list": "^2.51.1",
|
|
64
|
+
"@wordpress/url": "^3.52.1",
|
|
65
|
+
"@wordpress/warning": "^2.51.1",
|
|
66
|
+
"@wordpress/wordcount": "^3.51.1",
|
|
67
67
|
"change-case": "^4.1.2",
|
|
68
68
|
"classnames": "^2.3.1",
|
|
69
69
|
"colord": "^2.7.0",
|
|
@@ -87,5 +87,5 @@
|
|
|
87
87
|
"publishConfig": {
|
|
88
88
|
"access": "public"
|
|
89
89
|
},
|
|
90
|
-
"gitHead": "
|
|
90
|
+
"gitHead": "730beb7fd33d3382d6032c3f33e451625a0fcf36"
|
|
91
91
|
}
|
|
@@ -19,7 +19,7 @@ import { __ } from '@wordpress/i18n';
|
|
|
19
19
|
import BorderRadiusControl from '../border-radius-control';
|
|
20
20
|
import { useColorsPerOrigin } from './hooks';
|
|
21
21
|
import { getValueFromVariable, TOOLSPANEL_DROPDOWNMENU_PROPS } from './utils';
|
|
22
|
-
import {
|
|
22
|
+
import { overrideOrigins } from '../../store/get-block-settings';
|
|
23
23
|
import { setImmutably } from '../../utils/object';
|
|
24
24
|
import { getBorderPanelLabel } from '../../hooks/border';
|
|
25
25
|
import { ShadowPopover } from './shadow-panel-components';
|
|
@@ -154,12 +154,10 @@ export default function BorderPanel( {
|
|
|
154
154
|
|
|
155
155
|
// Shadow
|
|
156
156
|
const shadow = decodeValue( inheritedValue?.shadow );
|
|
157
|
-
const shadowPresets = settings?.shadow?.presets;
|
|
158
|
-
const
|
|
159
|
-
? mergeOrigins( shadowPresets )
|
|
160
|
-
: [];
|
|
157
|
+
const shadowPresets = settings?.shadow?.presets ?? {};
|
|
158
|
+
const overriddenShadowPresets = overrideOrigins( shadowPresets ) ?? [];
|
|
161
159
|
const setShadow = ( newValue ) => {
|
|
162
|
-
const slug =
|
|
160
|
+
const slug = overriddenShadowPresets?.find(
|
|
163
161
|
( { shadow: shadowName } ) => shadowName === newValue
|
|
164
162
|
)?.slug;
|
|
165
163
|
|
|
@@ -22,8 +22,8 @@ const translationMap = {
|
|
|
22
22
|
h4: __( 'H4' ),
|
|
23
23
|
h5: __( 'H5' ),
|
|
24
24
|
h6: __( 'H6' ),
|
|
25
|
-
'settings.color': __( 'Color
|
|
26
|
-
'settings.typography': __( 'Typography
|
|
25
|
+
'settings.color': __( 'Color' ),
|
|
26
|
+
'settings.typography': __( 'Typography' ),
|
|
27
27
|
'styles.color': __( 'Colors' ),
|
|
28
28
|
'styles.spacing': __( 'Spacing' ),
|
|
29
29
|
'styles.typography': __( 'Typography' ),
|
|
@@ -54,12 +54,7 @@ function getTranslation( key ) {
|
|
|
54
54
|
}
|
|
55
55
|
|
|
56
56
|
if ( keyArray?.[ 0 ] === 'elements' ) {
|
|
57
|
-
|
|
58
|
-
return sprintf(
|
|
59
|
-
// translators: %s: element name, e.g., heading button, link, caption.
|
|
60
|
-
__( '%s element' ),
|
|
61
|
-
elementName
|
|
62
|
-
);
|
|
57
|
+
return translationMap[ keyArray[ 1 ] ] || keyArray[ 1 ];
|
|
63
58
|
}
|
|
64
59
|
|
|
65
60
|
return undefined;
|
|
@@ -114,9 +109,9 @@ function deepCompare( changedObject, originalObject, parentPath = '' ) {
|
|
|
114
109
|
*
|
|
115
110
|
* @param {Object} next The changed object to compare.
|
|
116
111
|
* @param {Object} previous The original object to compare against.
|
|
117
|
-
* @return {
|
|
112
|
+
* @return {Array[]} A 2-dimensional array of tuples: [ "group", "translated change" ].
|
|
118
113
|
*/
|
|
119
|
-
function getGlobalStylesChangelist( next, previous ) {
|
|
114
|
+
export function getGlobalStylesChangelist( next, previous ) {
|
|
120
115
|
const cacheKey = JSON.stringify( { next, previous } );
|
|
121
116
|
|
|
122
117
|
if ( globalStylesChangesCache.has( cacheKey ) ) {
|
|
@@ -160,12 +155,12 @@ function getGlobalStylesChangelist( next, previous ) {
|
|
|
160
155
|
const result = [ ...new Set( changedValueTree ) ]
|
|
161
156
|
/*
|
|
162
157
|
* Translate the keys.
|
|
163
|
-
* Remove
|
|
158
|
+
* Remove empty translations.
|
|
164
159
|
*/
|
|
165
160
|
.reduce( ( acc, curr ) => {
|
|
166
161
|
const translation = getTranslation( curr );
|
|
167
|
-
if ( translation
|
|
168
|
-
acc.push( translation );
|
|
162
|
+
if ( translation ) {
|
|
163
|
+
acc.push( [ curr.split( '.' )[ 0 ], translation ] );
|
|
169
164
|
}
|
|
170
165
|
return acc;
|
|
171
166
|
}, [] );
|
|
@@ -176,29 +171,74 @@ function getGlobalStylesChangelist( next, previous ) {
|
|
|
176
171
|
}
|
|
177
172
|
|
|
178
173
|
/**
|
|
179
|
-
* From a getGlobalStylesChangelist() result, returns
|
|
180
|
-
*
|
|
174
|
+
* From a getGlobalStylesChangelist() result, returns an array of translated global styles changes, grouped by type.
|
|
175
|
+
* The types are 'blocks', 'elements', 'settings', and 'styles'.
|
|
181
176
|
*
|
|
182
177
|
* @param {Object} next The changed object to compare.
|
|
183
178
|
* @param {Object} previous The original object to compare against.
|
|
184
179
|
* @param {{maxResults:number}} options Options. maxResults: results to return before truncating.
|
|
185
|
-
* @return {string[]}
|
|
180
|
+
* @return {string[]} An array of translated changes.
|
|
186
181
|
*/
|
|
187
182
|
export default function getGlobalStylesChanges( next, previous, options = {} ) {
|
|
188
|
-
|
|
189
|
-
const changesLength =
|
|
183
|
+
let changeList = getGlobalStylesChangelist( next, previous );
|
|
184
|
+
const changesLength = changeList.length;
|
|
190
185
|
const { maxResults } = options;
|
|
191
186
|
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
187
|
+
if ( changesLength ) {
|
|
188
|
+
// Truncate to `n` results if necessary.
|
|
189
|
+
if ( !! maxResults && changesLength > maxResults ) {
|
|
190
|
+
changeList = changeList.slice( 0, maxResults );
|
|
191
|
+
}
|
|
192
|
+
return Object.entries(
|
|
193
|
+
changeList.reduce( ( acc, curr ) => {
|
|
194
|
+
const group = acc[ curr[ 0 ] ] || [];
|
|
195
|
+
if ( ! group.includes( curr[ 1 ] ) ) {
|
|
196
|
+
acc[ curr[ 0 ] ] = [ ...group, curr[ 1 ] ];
|
|
197
|
+
}
|
|
198
|
+
return acc;
|
|
199
|
+
}, {} )
|
|
200
|
+
).map( ( [ key, changeValues ] ) => {
|
|
201
|
+
const changeValuesLength = changeValues.length;
|
|
202
|
+
const joinedChangesValue = changeValues.join( __( ', ' ) );
|
|
203
|
+
switch ( key ) {
|
|
204
|
+
case 'blocks': {
|
|
205
|
+
return sprintf(
|
|
206
|
+
// translators: %s: a list of block names separated by a comma.
|
|
207
|
+
_n( '%s block.', '%s blocks.', changeValuesLength ),
|
|
208
|
+
joinedChangesValue
|
|
209
|
+
);
|
|
210
|
+
}
|
|
211
|
+
case 'elements': {
|
|
212
|
+
return sprintf(
|
|
213
|
+
// translators: %s: a list of element names separated by a comma.
|
|
214
|
+
_n( '%s element.', '%s elements.', changeValuesLength ),
|
|
215
|
+
joinedChangesValue
|
|
216
|
+
);
|
|
217
|
+
}
|
|
218
|
+
case 'settings': {
|
|
219
|
+
return sprintf(
|
|
220
|
+
// translators: %s: a list of theme.json setting labels separated by a comma.
|
|
221
|
+
__( '%s settings.' ),
|
|
222
|
+
joinedChangesValue
|
|
223
|
+
);
|
|
224
|
+
}
|
|
225
|
+
case 'styles': {
|
|
226
|
+
return sprintf(
|
|
227
|
+
// translators: %s: a list of theme.json top-level styles labels separated by a comma.
|
|
228
|
+
__( '%s styles.' ),
|
|
229
|
+
joinedChangesValue
|
|
230
|
+
);
|
|
231
|
+
}
|
|
232
|
+
default: {
|
|
233
|
+
return sprintf(
|
|
234
|
+
// translators: %s: a list of global styles changes separated by a comma.
|
|
235
|
+
__( '%s.' ),
|
|
236
|
+
joinedChangesValue
|
|
237
|
+
);
|
|
238
|
+
}
|
|
239
|
+
}
|
|
240
|
+
} );
|
|
201
241
|
}
|
|
202
242
|
|
|
203
|
-
return
|
|
243
|
+
return EMPTY_ARRAY;
|
|
204
244
|
}
|
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Internal dependencies
|
|
3
3
|
*/
|
|
4
|
-
import getGlobalStylesChanges
|
|
4
|
+
import getGlobalStylesChanges, {
|
|
5
|
+
getGlobalStylesChangelist,
|
|
6
|
+
} from '../get-global-styles-changes';
|
|
5
7
|
|
|
6
8
|
/**
|
|
7
9
|
* WordPress dependencies
|
|
@@ -12,24 +14,8 @@ import {
|
|
|
12
14
|
getBlockTypes,
|
|
13
15
|
} from '@wordpress/blocks';
|
|
14
16
|
|
|
15
|
-
describe( 'getGlobalStylesChanges', () => {
|
|
16
|
-
|
|
17
|
-
registerBlockType( 'core/test-fiori-di-zucca', {
|
|
18
|
-
save: () => {},
|
|
19
|
-
category: 'text',
|
|
20
|
-
title: 'Test pumpkin flowers',
|
|
21
|
-
edit: () => {},
|
|
22
|
-
} );
|
|
23
|
-
} );
|
|
24
|
-
|
|
25
|
-
afterEach( () => {
|
|
26
|
-
getBlockTypes().forEach( ( block ) => {
|
|
27
|
-
unregisterBlockType( block.name );
|
|
28
|
-
} );
|
|
29
|
-
} );
|
|
30
|
-
|
|
31
|
-
const revision = {
|
|
32
|
-
id: 10,
|
|
17
|
+
describe( 'getGlobalStylesChanges and utils', () => {
|
|
18
|
+
const next = {
|
|
33
19
|
styles: {
|
|
34
20
|
typography: {
|
|
35
21
|
fontSize: 'var(--wp--preset--font-size--potato)',
|
|
@@ -85,11 +71,18 @@ describe( 'getGlobalStylesChanges', () => {
|
|
|
85
71
|
},
|
|
86
72
|
],
|
|
87
73
|
},
|
|
74
|
+
gradients: [
|
|
75
|
+
{
|
|
76
|
+
name: 'Something something',
|
|
77
|
+
gradient:
|
|
78
|
+
'linear-gradient(105deg,rgba(6,147,100,1) 0%,rgb(155,81,100) 100%)',
|
|
79
|
+
slug: 'something-something',
|
|
80
|
+
},
|
|
81
|
+
],
|
|
88
82
|
},
|
|
89
83
|
},
|
|
90
84
|
};
|
|
91
|
-
const
|
|
92
|
-
id: 9,
|
|
85
|
+
const previous = {
|
|
93
86
|
styles: {
|
|
94
87
|
typography: {
|
|
95
88
|
fontSize: 'var(--wp--preset--font-size--fungus)',
|
|
@@ -161,74 +154,120 @@ describe( 'getGlobalStylesChanges', () => {
|
|
|
161
154
|
color: 'blue',
|
|
162
155
|
},
|
|
163
156
|
],
|
|
157
|
+
custom: [
|
|
158
|
+
{
|
|
159
|
+
slug: 'one',
|
|
160
|
+
color: 'tomato',
|
|
161
|
+
},
|
|
162
|
+
],
|
|
164
163
|
},
|
|
164
|
+
gradients: [
|
|
165
|
+
{
|
|
166
|
+
name: 'Vivid cyan blue to vivid purple',
|
|
167
|
+
gradient:
|
|
168
|
+
'linear-gradient(135deg,rgba(6,147,227,1) 0%,rgb(155,81,224) 100%)',
|
|
169
|
+
slug: 'vivid-cyan-blue-to-vivid-purple',
|
|
170
|
+
},
|
|
171
|
+
],
|
|
172
|
+
},
|
|
173
|
+
typography: {
|
|
174
|
+
fluid: true,
|
|
165
175
|
},
|
|
166
176
|
},
|
|
167
177
|
};
|
|
168
178
|
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
'
|
|
173
|
-
'
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
'Caption element',
|
|
177
|
-
'H6 element',
|
|
178
|
-
'Link element',
|
|
179
|
-
'Color settings',
|
|
180
|
-
] );
|
|
181
|
-
|
|
182
|
-
const resultB = getGlobalStylesChanges( revision, previousRevision );
|
|
183
|
-
|
|
184
|
-
expect( resultA ).toBe( resultB );
|
|
179
|
+
beforeEach( () => {
|
|
180
|
+
registerBlockType( 'core/test-fiori-di-zucca', {
|
|
181
|
+
save: () => {},
|
|
182
|
+
category: 'text',
|
|
183
|
+
title: 'Test pumpkin flowers',
|
|
184
|
+
edit: () => {},
|
|
185
|
+
} );
|
|
185
186
|
} );
|
|
186
187
|
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
188
|
+
afterEach( () => {
|
|
189
|
+
getBlockTypes().forEach( ( block ) => {
|
|
190
|
+
unregisterBlockType( block.name );
|
|
190
191
|
} );
|
|
191
|
-
expect( resultA ).toEqual( [
|
|
192
|
-
'Colors',
|
|
193
|
-
'Typography',
|
|
194
|
-
'Test pumpkin flowers',
|
|
195
|
-
'…and 5 more changes',
|
|
196
|
-
] );
|
|
197
192
|
} );
|
|
198
193
|
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
194
|
+
describe( 'getGlobalStylesChanges()', () => {
|
|
195
|
+
it( 'returns a list of changes', () => {
|
|
196
|
+
const result = getGlobalStylesChanges( next, previous );
|
|
197
|
+
expect( result ).toEqual( [
|
|
198
|
+
'Colors, Typography styles.',
|
|
199
|
+
'Test pumpkin flowers block.',
|
|
200
|
+
'H3, Caption, H6, Link elements.',
|
|
201
|
+
'Color, Typography settings.',
|
|
202
|
+
] );
|
|
203
|
+
} );
|
|
204
|
+
|
|
205
|
+
it( 'returns a list of truncated changes', () => {
|
|
206
|
+
const resultA = getGlobalStylesChanges( next, previous, {
|
|
207
|
+
maxResults: 3,
|
|
208
|
+
} );
|
|
209
|
+
expect( resultA ).toEqual( [
|
|
210
|
+
'Colors, Typography styles.',
|
|
211
|
+
'Test pumpkin flowers block.',
|
|
212
|
+
] );
|
|
213
|
+
} );
|
|
214
|
+
|
|
215
|
+
it( 'skips unknown and unchanged keys', () => {
|
|
216
|
+
const result = getGlobalStylesChanges(
|
|
217
|
+
{
|
|
218
|
+
styles: {
|
|
219
|
+
frogs: {
|
|
220
|
+
legs: 'green',
|
|
221
|
+
},
|
|
222
|
+
typography: {
|
|
223
|
+
fontSize: '1rem',
|
|
224
|
+
},
|
|
225
|
+
settings: {
|
|
226
|
+
'': {
|
|
227
|
+
'': 'foo',
|
|
228
|
+
},
|
|
212
229
|
},
|
|
213
230
|
},
|
|
214
231
|
},
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
232
|
+
{
|
|
233
|
+
styles: {
|
|
234
|
+
frogs: {
|
|
235
|
+
legs: 'yellow',
|
|
236
|
+
},
|
|
237
|
+
typography: {
|
|
238
|
+
fontSize: '1rem',
|
|
239
|
+
},
|
|
240
|
+
settings: {
|
|
241
|
+
'': {
|
|
242
|
+
'': 'bar',
|
|
243
|
+
},
|
|
227
244
|
},
|
|
228
245
|
},
|
|
229
|
-
}
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
246
|
+
}
|
|
247
|
+
);
|
|
248
|
+
expect( result ).toEqual( [] );
|
|
249
|
+
} );
|
|
250
|
+
} );
|
|
251
|
+
|
|
252
|
+
describe( 'getGlobalStylesChangelist()', () => {
|
|
253
|
+
it( 'compares two objects and returns a cached list of changed keys', () => {
|
|
254
|
+
const resultA = getGlobalStylesChangelist( next, previous );
|
|
255
|
+
|
|
256
|
+
expect( resultA ).toEqual( [
|
|
257
|
+
[ 'styles', 'Colors' ],
|
|
258
|
+
[ 'styles', 'Typography' ],
|
|
259
|
+
[ 'blocks', 'Test pumpkin flowers' ],
|
|
260
|
+
[ 'elements', 'H3' ],
|
|
261
|
+
[ 'elements', 'Caption' ],
|
|
262
|
+
[ 'elements', 'H6' ],
|
|
263
|
+
[ 'elements', 'Link' ],
|
|
264
|
+
[ 'settings', 'Color' ],
|
|
265
|
+
[ 'settings', 'Typography' ],
|
|
266
|
+
] );
|
|
267
|
+
|
|
268
|
+
const resultB = getGlobalStylesChangelist( next, previous );
|
|
269
|
+
|
|
270
|
+
expect( resultB ).toEqual( resultA );
|
|
271
|
+
} );
|
|
233
272
|
} );
|
|
234
273
|
} );
|
|
@@ -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
|
) {
|
|
@@ -340,13 +340,6 @@ $block-editor-link-control-number-of-actions: 1;
|
|
|
340
340
|
}
|
|
341
341
|
}
|
|
342
342
|
|
|
343
|
-
.block-editor-link-control__drawer {
|
|
344
|
-
display: flex; // allow for ordering.
|
|
345
|
-
order: 30;
|
|
346
|
-
flex-direction: column;
|
|
347
|
-
flex-basis: 100%; // occupy full width.
|
|
348
|
-
}
|
|
349
|
-
|
|
350
343
|
// Inner div required to avoid padding/margin
|
|
351
344
|
// causing janky animation.
|
|
352
345
|
.block-editor-link-control__drawer-inner {
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
*/
|
|
4
4
|
import { useRef } from '@wordpress/element';
|
|
5
5
|
import { useRefEffect } from '@wordpress/compose';
|
|
6
|
-
import { insert,
|
|
6
|
+
import { insert, toHTMLString } from '@wordpress/rich-text';
|
|
7
7
|
import { getBlockTransforms, findTransform } from '@wordpress/blocks';
|
|
8
8
|
import { useDispatch } from '@wordpress/data';
|
|
9
9
|
|
|
@@ -47,34 +47,6 @@ function findSelection( blocks ) {
|
|
|
47
47
|
return [];
|
|
48
48
|
}
|
|
49
49
|
|
|
50
|
-
/**
|
|
51
|
-
* An input rule that replaces two spaces with an en space, and an en space
|
|
52
|
-
* followed by a space with an em space.
|
|
53
|
-
*
|
|
54
|
-
* @param {Object} value Value to replace spaces in.
|
|
55
|
-
*
|
|
56
|
-
* @return {Object} Value with spaces replaced.
|
|
57
|
-
*/
|
|
58
|
-
function replacePrecedingSpaces( value ) {
|
|
59
|
-
if ( ! isCollapsed( value ) ) {
|
|
60
|
-
return value;
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
const { text, start } = value;
|
|
64
|
-
const lastTwoCharacters = text.slice( start - 2, start );
|
|
65
|
-
|
|
66
|
-
// Replace two spaces with an em space.
|
|
67
|
-
if ( lastTwoCharacters === ' ' ) {
|
|
68
|
-
return insert( value, '\u2002', start - 2, start );
|
|
69
|
-
}
|
|
70
|
-
// Replace an en space followed by a space with an em space.
|
|
71
|
-
else if ( lastTwoCharacters === '\u2002 ' ) {
|
|
72
|
-
return insert( value, '\u2003', start - 2, start );
|
|
73
|
-
}
|
|
74
|
-
|
|
75
|
-
return value;
|
|
76
|
-
}
|
|
77
|
-
|
|
78
50
|
export function useInputRules( props ) {
|
|
79
51
|
const {
|
|
80
52
|
__unstableMarkLastChangeAsPersistent,
|
|
@@ -155,7 +127,7 @@ export function useInputRules( props ) {
|
|
|
155
127
|
|
|
156
128
|
return accumlator;
|
|
157
129
|
},
|
|
158
|
-
preventEventDiscovery(
|
|
130
|
+
preventEventDiscovery( value )
|
|
159
131
|
);
|
|
160
132
|
|
|
161
133
|
if ( transformed !== value ) {
|