@wordpress/edit-site 4.18.0 → 4.19.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/add-new-template/add-custom-template-modal.js +3 -1
- package/build/components/add-new-template/add-custom-template-modal.js.map +1 -1
- package/build/components/block-editor/resizable-editor.js +9 -47
- package/build/components/block-editor/resizable-editor.js.map +1 -1
- package/build/components/global-styles/dimensions-panel.js +46 -2
- package/build/components/global-styles/dimensions-panel.js.map +1 -1
- package/build/components/global-styles/hooks.js +32 -0
- package/build/components/global-styles/hooks.js.map +1 -1
- package/build/components/global-styles/palette.js +8 -1
- package/build/components/global-styles/palette.js.map +1 -1
- package/build/components/global-styles/typography-panel.js +52 -16
- package/build/components/global-styles/typography-panel.js.map +1 -1
- package/build/components/global-styles/use-global-styles-output.js +43 -8
- package/build/components/global-styles/use-global-styles-output.js.map +1 -1
- package/build/components/header-edit-mode/document-actions/index.js +3 -1
- package/build/components/header-edit-mode/document-actions/index.js.map +1 -1
- package/build/components/header-edit-mode/index.js +14 -7
- package/build/components/header-edit-mode/index.js.map +1 -1
- package/build/components/keyboard-shortcuts/index.js +3 -0
- package/build/components/keyboard-shortcuts/index.js.map +1 -1
- package/build/components/list/table.js +1 -1
- package/build/components/list/table.js.map +1 -1
- package/build/components/list/use-register-shortcuts.js +3 -0
- package/build/components/list/use-register-shortcuts.js.map +1 -1
- package/build/components/save-button/index.js +20 -2
- package/build/components/save-button/index.js.map +1 -1
- package/build/components/sidebar-edit-mode/template-card/index.js +4 -2
- package/build/components/sidebar-edit-mode/template-card/index.js.map +1 -1
- package/build/components/template-details/index.js +4 -2
- package/build/components/template-details/index.js.map +1 -1
- package/build-module/components/add-new-template/add-custom-template-modal.js +2 -1
- package/build-module/components/add-new-template/add-custom-template-modal.js.map +1 -1
- package/build-module/components/block-editor/resizable-editor.js +11 -49
- package/build-module/components/block-editor/resizable-editor.js.map +1 -1
- package/build-module/components/global-styles/dimensions-panel.js +46 -2
- package/build-module/components/global-styles/dimensions-panel.js.map +1 -1
- package/build-module/components/global-styles/hooks.js +27 -1
- package/build-module/components/global-styles/hooks.js.map +1 -1
- package/build-module/components/global-styles/palette.js +9 -3
- package/build-module/components/global-styles/palette.js.map +1 -1
- package/build-module/components/global-styles/typography-panel.js +53 -16
- package/build-module/components/global-styles/typography-panel.js.map +1 -1
- package/build-module/components/global-styles/use-global-styles-output.js +44 -9
- package/build-module/components/global-styles/use-global-styles-output.js.map +1 -1
- package/build-module/components/header-edit-mode/document-actions/index.js +2 -1
- package/build-module/components/header-edit-mode/document-actions/index.js.map +1 -1
- package/build-module/components/header-edit-mode/index.js +13 -7
- package/build-module/components/header-edit-mode/index.js.map +1 -1
- package/build-module/components/keyboard-shortcuts/index.js +3 -0
- package/build-module/components/keyboard-shortcuts/index.js.map +1 -1
- package/build-module/components/list/table.js +1 -1
- package/build-module/components/list/table.js.map +1 -1
- package/build-module/components/list/use-register-shortcuts.js +3 -0
- package/build-module/components/list/use-register-shortcuts.js.map +1 -1
- package/build-module/components/save-button/index.js +21 -2
- package/build-module/components/save-button/index.js.map +1 -1
- package/build-module/components/sidebar-edit-mode/template-card/index.js +3 -2
- package/build-module/components/sidebar-edit-mode/template-card/index.js.map +1 -1
- package/build-module/components/template-details/index.js +3 -2
- package/build-module/components/template-details/index.js.map +1 -1
- package/build-style/style-rtl.css +15 -15
- package/build-style/style.css +15 -15
- package/package.json +30 -29
- package/src/components/add-new-template/add-custom-template-modal.js +5 -1
- package/src/components/block-editor/resizable-editor.js +10 -55
- package/src/components/editor/style.scss +1 -7
- package/src/components/global-styles/dimensions-panel.js +59 -1
- package/src/components/global-styles/hooks.js +36 -0
- package/src/components/global-styles/palette.js +15 -1
- package/src/components/global-styles/test/typography-utils.js +82 -98
- package/src/components/global-styles/test/use-global-styles-output.js +6 -6
- package/src/components/global-styles/typography-panel.js +57 -15
- package/src/components/global-styles/use-global-styles-output.js +47 -10
- package/src/components/header-edit-mode/document-actions/index.js +2 -1
- package/src/components/header-edit-mode/index.js +8 -4
- package/src/components/keyboard-shortcuts/index.js +4 -0
- package/src/components/list/table.js +1 -1
- package/src/components/list/use-register-shortcuts.js +4 -0
- package/src/components/navigation-sidebar/navigation-panel/style.scss +0 -7
- package/src/components/navigation-sidebar/navigation-toggle/test/index.js +20 -24
- package/src/components/save-button/index.js +17 -1
- package/src/components/sidebar-edit-mode/template-card/index.js +3 -2
- package/src/components/template-details/index.js +3 -2
- package/src/components/navigation-sidebar/navigation-toggle/test/__snapshots__/index.js.snap +0 -41
|
@@ -7,7 +7,7 @@ describe( 'typography utils', () => {
|
|
|
7
7
|
describe( 'getTypographyFontSizeValue', () => {
|
|
8
8
|
[
|
|
9
9
|
{
|
|
10
|
-
message: '
|
|
10
|
+
message: 'returns value when fluid typography is deactivated',
|
|
11
11
|
preset: {
|
|
12
12
|
size: '28px',
|
|
13
13
|
},
|
|
@@ -16,7 +16,7 @@ describe( 'typography utils', () => {
|
|
|
16
16
|
},
|
|
17
17
|
|
|
18
18
|
{
|
|
19
|
-
message: '
|
|
19
|
+
message: 'returns value where font size is 0',
|
|
20
20
|
preset: {
|
|
21
21
|
size: 0,
|
|
22
22
|
},
|
|
@@ -25,7 +25,7 @@ describe( 'typography utils', () => {
|
|
|
25
25
|
},
|
|
26
26
|
|
|
27
27
|
{
|
|
28
|
-
message: "
|
|
28
|
+
message: "returns value where font size is '0'",
|
|
29
29
|
preset: {
|
|
30
30
|
size: '0',
|
|
31
31
|
},
|
|
@@ -34,17 +34,16 @@ describe( 'typography utils', () => {
|
|
|
34
34
|
},
|
|
35
35
|
|
|
36
36
|
{
|
|
37
|
-
message:
|
|
38
|
-
'Default return non-fluid value where `size` is undefined.',
|
|
37
|
+
message: 'returns value where `size` is `null`.',
|
|
39
38
|
preset: {
|
|
40
|
-
size:
|
|
39
|
+
size: null,
|
|
41
40
|
},
|
|
42
|
-
typographySettings:
|
|
43
|
-
expected:
|
|
41
|
+
typographySettings: null,
|
|
42
|
+
expected: null,
|
|
44
43
|
},
|
|
45
44
|
|
|
46
45
|
{
|
|
47
|
-
message: '
|
|
46
|
+
message: 'returns value when fluid is `false`',
|
|
48
47
|
preset: {
|
|
49
48
|
size: '28px',
|
|
50
49
|
fluid: false,
|
|
@@ -56,84 +55,94 @@ describe( 'typography utils', () => {
|
|
|
56
55
|
},
|
|
57
56
|
|
|
58
57
|
{
|
|
59
|
-
message:
|
|
60
|
-
'Should coerce integer to `px` and return fluid value.',
|
|
58
|
+
message: 'returns already clamped value',
|
|
61
59
|
preset: {
|
|
62
|
-
size:
|
|
63
|
-
fluid:
|
|
60
|
+
size: 'clamp(21px, 1.313rem + ((1vw - 7.68px) * 2.524), 42px)',
|
|
61
|
+
fluid: false,
|
|
64
62
|
},
|
|
65
63
|
typographySettings: {
|
|
66
64
|
fluid: true,
|
|
67
65
|
},
|
|
68
66
|
expected:
|
|
69
|
-
'clamp(
|
|
67
|
+
'clamp(21px, 1.313rem + ((1vw - 7.68px) * 2.524), 42px)',
|
|
70
68
|
},
|
|
71
69
|
|
|
72
70
|
{
|
|
73
|
-
message: '
|
|
71
|
+
message: 'returns value with unsupported unit',
|
|
74
72
|
preset: {
|
|
75
|
-
size:
|
|
73
|
+
size: '1000%',
|
|
74
|
+
fluid: false,
|
|
75
|
+
},
|
|
76
|
+
typographySettings: {
|
|
76
77
|
fluid: true,
|
|
77
78
|
},
|
|
79
|
+
expected: '1000%',
|
|
80
|
+
},
|
|
81
|
+
|
|
82
|
+
{
|
|
83
|
+
message: 'returns clamp value with rem min and max units',
|
|
84
|
+
preset: {
|
|
85
|
+
size: '1.75rem',
|
|
86
|
+
},
|
|
78
87
|
typographySettings: {
|
|
79
88
|
fluid: true,
|
|
80
89
|
},
|
|
81
90
|
expected:
|
|
82
|
-
'clamp(
|
|
91
|
+
'clamp(1.313rem, 1.313rem + ((1vw - 0.48rem) * 0.84), 1.75rem)',
|
|
83
92
|
},
|
|
84
93
|
|
|
85
94
|
{
|
|
86
|
-
message: '
|
|
95
|
+
message: 'returns clamp value with eem min and max units',
|
|
87
96
|
preset: {
|
|
88
|
-
size: '
|
|
89
|
-
fluid: false,
|
|
97
|
+
size: '1.75em',
|
|
90
98
|
},
|
|
91
99
|
typographySettings: {
|
|
92
100
|
fluid: true,
|
|
93
101
|
},
|
|
94
102
|
expected:
|
|
95
|
-
'clamp(
|
|
103
|
+
'clamp(1.313em, 1.313rem + ((1vw - 0.48em) * 0.84), 1.75em)',
|
|
96
104
|
},
|
|
97
105
|
|
|
98
106
|
{
|
|
99
|
-
message: '
|
|
107
|
+
message: 'returns clamp value for floats',
|
|
100
108
|
preset: {
|
|
101
|
-
size: '
|
|
102
|
-
fluid: false,
|
|
109
|
+
size: '100.175px',
|
|
103
110
|
},
|
|
104
111
|
typographySettings: {
|
|
105
112
|
fluid: true,
|
|
106
113
|
},
|
|
107
|
-
expected:
|
|
114
|
+
expected:
|
|
115
|
+
'clamp(75.131px, 4.696rem + ((1vw - 7.68px) * 3.01), 100.175px)',
|
|
108
116
|
},
|
|
109
117
|
|
|
110
118
|
{
|
|
111
|
-
message: '
|
|
119
|
+
message: 'coerces integer to `px` and returns clamp value',
|
|
112
120
|
preset: {
|
|
113
|
-
size:
|
|
121
|
+
size: 33,
|
|
122
|
+
fluid: true,
|
|
114
123
|
},
|
|
115
124
|
typographySettings: {
|
|
116
125
|
fluid: true,
|
|
117
126
|
},
|
|
118
127
|
expected:
|
|
119
|
-
'clamp(
|
|
128
|
+
'clamp(24.75px, 1.547rem + ((1vw - 7.68px) * 0.992), 33px)',
|
|
120
129
|
},
|
|
121
130
|
|
|
122
131
|
{
|
|
123
|
-
message: '
|
|
132
|
+
message: 'coerces float to `px` and returns clamp value',
|
|
124
133
|
preset: {
|
|
125
|
-
size:
|
|
134
|
+
size: 100.23,
|
|
135
|
+
fluid: true,
|
|
126
136
|
},
|
|
127
137
|
typographySettings: {
|
|
128
138
|
fluid: true,
|
|
129
139
|
},
|
|
130
140
|
expected:
|
|
131
|
-
'clamp(75.
|
|
141
|
+
'clamp(75.173px, 4.698rem + ((1vw - 7.68px) * 3.012), 100.23px)',
|
|
132
142
|
},
|
|
133
143
|
|
|
134
144
|
{
|
|
135
|
-
message:
|
|
136
|
-
'Should return default fluid values with empty fluid array.',
|
|
145
|
+
message: 'returns clamp value when `fluid` is empty array',
|
|
137
146
|
preset: {
|
|
138
147
|
size: '28px',
|
|
139
148
|
fluid: [],
|
|
@@ -142,11 +151,11 @@ describe( 'typography utils', () => {
|
|
|
142
151
|
fluid: true,
|
|
143
152
|
},
|
|
144
153
|
expected:
|
|
145
|
-
'clamp(21px, 1.313rem + ((1vw - 7.68px) *
|
|
154
|
+
'clamp(21px, 1.313rem + ((1vw - 7.68px) * 0.841), 28px)',
|
|
146
155
|
},
|
|
147
156
|
|
|
148
157
|
{
|
|
149
|
-
message: '
|
|
158
|
+
message: 'returns clamp value when `fluid` is `null`',
|
|
150
159
|
preset: {
|
|
151
160
|
size: '28px',
|
|
152
161
|
fluid: null,
|
|
@@ -155,12 +164,12 @@ describe( 'typography utils', () => {
|
|
|
155
164
|
fluid: true,
|
|
156
165
|
},
|
|
157
166
|
expected:
|
|
158
|
-
'clamp(21px, 1.313rem + ((1vw - 7.68px) *
|
|
167
|
+
'clamp(21px, 1.313rem + ((1vw - 7.68px) * 0.841), 28px)',
|
|
159
168
|
},
|
|
160
169
|
|
|
161
170
|
{
|
|
162
171
|
message:
|
|
163
|
-
'
|
|
172
|
+
'returns clamp value if min font size is greater than max',
|
|
164
173
|
preset: {
|
|
165
174
|
size: '3rem',
|
|
166
175
|
fluid: {
|
|
@@ -176,7 +185,7 @@ describe( 'typography utils', () => {
|
|
|
176
185
|
},
|
|
177
186
|
|
|
178
187
|
{
|
|
179
|
-
message: '
|
|
188
|
+
message: 'returns value with invalid min/max fluid units',
|
|
180
189
|
preset: {
|
|
181
190
|
size: '10em',
|
|
182
191
|
fluid: {
|
|
@@ -192,20 +201,30 @@ describe( 'typography utils', () => {
|
|
|
192
201
|
|
|
193
202
|
{
|
|
194
203
|
message:
|
|
195
|
-
'
|
|
204
|
+
'returns value when size is < lower bounds and no fluid min/max set',
|
|
196
205
|
preset: {
|
|
197
206
|
size: '3px',
|
|
198
207
|
},
|
|
199
208
|
typographySettings: {
|
|
200
209
|
fluid: true,
|
|
201
210
|
},
|
|
202
|
-
expected:
|
|
203
|
-
'clamp(3px, 0.188rem + ((1vw - 7.68px) * 0.18), 4.5px)',
|
|
211
|
+
expected: '3px',
|
|
204
212
|
},
|
|
205
213
|
|
|
206
214
|
{
|
|
207
215
|
message:
|
|
208
|
-
'
|
|
216
|
+
'returns value when size is equal to lower bounds and no fluid min/max set',
|
|
217
|
+
preset: {
|
|
218
|
+
size: '14px',
|
|
219
|
+
},
|
|
220
|
+
typographySettings: {
|
|
221
|
+
fluid: true,
|
|
222
|
+
},
|
|
223
|
+
expected: '14px',
|
|
224
|
+
},
|
|
225
|
+
|
|
226
|
+
{
|
|
227
|
+
message: 'returns clamp value with different min max units',
|
|
209
228
|
preset: {
|
|
210
229
|
size: '28px',
|
|
211
230
|
fluid: {
|
|
@@ -219,10 +238,9 @@ describe( 'typography utils', () => {
|
|
|
219
238
|
expected:
|
|
220
239
|
'clamp(20px, 1.25rem + ((1vw - 7.68px) * 93.75), 50rem)',
|
|
221
240
|
},
|
|
222
|
-
|
|
241
|
+
|
|
223
242
|
{
|
|
224
|
-
message:
|
|
225
|
-
' Should return clamp value with default fluid max value.',
|
|
243
|
+
message: 'returns clamp value where no fluid max size is set',
|
|
226
244
|
preset: {
|
|
227
245
|
size: '28px',
|
|
228
246
|
fluid: {
|
|
@@ -233,12 +251,11 @@ describe( 'typography utils', () => {
|
|
|
233
251
|
fluid: true,
|
|
234
252
|
},
|
|
235
253
|
expected:
|
|
236
|
-
'clamp(2.6rem, 2.6rem + ((1vw - 0.48rem) *
|
|
254
|
+
'clamp(2.6rem, 2.6rem + ((1vw - 0.48rem) * -1.635), 28px)',
|
|
237
255
|
},
|
|
238
256
|
|
|
239
257
|
{
|
|
240
|
-
message:
|
|
241
|
-
'Should return clamp value with default fluid min value.',
|
|
258
|
+
message: 'returns clamp value where no fluid min size is set',
|
|
242
259
|
preset: {
|
|
243
260
|
size: '28px',
|
|
244
261
|
fluid: {
|
|
@@ -253,90 +270,57 @@ describe( 'typography utils', () => {
|
|
|
253
270
|
},
|
|
254
271
|
|
|
255
272
|
{
|
|
256
|
-
message:
|
|
257
|
-
|
|
258
|
-
size: '14px',
|
|
259
|
-
},
|
|
260
|
-
typographySettings: {
|
|
261
|
-
fluid: true,
|
|
262
|
-
},
|
|
263
|
-
expected:
|
|
264
|
-
'clamp(14px, 0.875rem + ((1vw - 7.68px) * 0.841), 21px)',
|
|
265
|
-
},
|
|
266
|
-
|
|
267
|
-
{
|
|
268
|
-
message: 'adjust computed min in rem to min limit.',
|
|
269
|
-
preset: {
|
|
270
|
-
size: '1.1rem',
|
|
271
|
-
},
|
|
272
|
-
typographySettings: {
|
|
273
|
-
fluid: true,
|
|
274
|
-
},
|
|
275
|
-
expected:
|
|
276
|
-
'clamp(0.875rem, 0.875rem + ((1vw - 0.48rem) * 1.49), 1.65rem)',
|
|
277
|
-
},
|
|
278
|
-
|
|
279
|
-
{
|
|
280
|
-
message: 'adjust computed min in em to min limit.',
|
|
281
|
-
preset: {
|
|
282
|
-
size: '1.1em',
|
|
283
|
-
},
|
|
284
|
-
typographySettings: {
|
|
285
|
-
fluid: true,
|
|
286
|
-
},
|
|
287
|
-
expected:
|
|
288
|
-
'clamp(0.875em, 0.875rem + ((1vw - 0.48em) * 1.49), 1.65em)',
|
|
289
|
-
},
|
|
290
|
-
|
|
291
|
-
{
|
|
292
|
-
message: 'adjust fluid min value in px to min limit',
|
|
273
|
+
message:
|
|
274
|
+
'should not apply lower bound test when fluid values are set',
|
|
293
275
|
preset: {
|
|
294
|
-
size: '
|
|
276
|
+
size: '1.5rem',
|
|
295
277
|
fluid: {
|
|
296
|
-
min: '
|
|
278
|
+
min: '0.5rem',
|
|
279
|
+
max: '5rem',
|
|
297
280
|
},
|
|
298
281
|
},
|
|
299
282
|
typographySettings: {
|
|
300
283
|
fluid: true,
|
|
301
284
|
},
|
|
302
285
|
expected:
|
|
303
|
-
'clamp(
|
|
286
|
+
'clamp(0.5rem, 0.5rem + ((1vw - 0.48rem) * 8.654), 5rem)',
|
|
304
287
|
},
|
|
305
288
|
|
|
306
289
|
{
|
|
307
|
-
message:
|
|
290
|
+
message:
|
|
291
|
+
'should not apply lower bound test when only fluid min is set',
|
|
308
292
|
preset: {
|
|
309
|
-
size: '
|
|
293
|
+
size: '20px',
|
|
310
294
|
fluid: {
|
|
311
|
-
min: '
|
|
295
|
+
min: '12px',
|
|
312
296
|
},
|
|
313
297
|
},
|
|
314
298
|
typographySettings: {
|
|
315
299
|
fluid: true,
|
|
316
300
|
},
|
|
317
301
|
expected:
|
|
318
|
-
'clamp(
|
|
302
|
+
'clamp(12px, 0.75rem + ((1vw - 7.68px) * 0.962), 20px)',
|
|
319
303
|
},
|
|
320
304
|
|
|
321
305
|
{
|
|
322
|
-
message:
|
|
306
|
+
message:
|
|
307
|
+
'should not apply lower bound test when only fluid max is set',
|
|
323
308
|
preset: {
|
|
324
|
-
size: '
|
|
309
|
+
size: '0.875rem',
|
|
325
310
|
fluid: {
|
|
326
|
-
|
|
327
|
-
max: '5rem',
|
|
311
|
+
max: '20rem',
|
|
328
312
|
},
|
|
329
313
|
},
|
|
330
314
|
typographySettings: {
|
|
331
315
|
fluid: true,
|
|
332
316
|
},
|
|
333
317
|
expected:
|
|
334
|
-
'clamp(0.875rem, 0.875rem + ((1vw - 0.48rem) *
|
|
318
|
+
'clamp(0.875rem, 0.875rem + ((1vw - 0.48rem) * 36.779), 20rem)',
|
|
335
319
|
},
|
|
336
320
|
|
|
337
321
|
{
|
|
338
322
|
message:
|
|
339
|
-
'
|
|
323
|
+
'returns clamp value when min and max font sizes are equal',
|
|
340
324
|
preset: {
|
|
341
325
|
size: '4rem',
|
|
342
326
|
fluid: {
|
|
@@ -711,7 +711,7 @@ describe( 'global styles renderer', () => {
|
|
|
711
711
|
},
|
|
712
712
|
typography: {
|
|
713
713
|
fontFamily: 'sans-serif',
|
|
714
|
-
fontSize: '
|
|
714
|
+
fontSize: '15px',
|
|
715
715
|
},
|
|
716
716
|
};
|
|
717
717
|
|
|
@@ -725,7 +725,7 @@ describe( 'global styles renderer', () => {
|
|
|
725
725
|
'--wp--style--root--padding-left: 33px',
|
|
726
726
|
'background-color: var(--wp--preset--color--light-green-cyan)',
|
|
727
727
|
'font-family: sans-serif',
|
|
728
|
-
'font-size:
|
|
728
|
+
'font-size: 15px',
|
|
729
729
|
] );
|
|
730
730
|
} );
|
|
731
731
|
|
|
@@ -739,7 +739,7 @@ describe( 'global styles renderer', () => {
|
|
|
739
739
|
'padding-bottom: 33px',
|
|
740
740
|
'padding-left: 33px',
|
|
741
741
|
'font-family: sans-serif',
|
|
742
|
-
'font-size:
|
|
742
|
+
'font-size: 15px',
|
|
743
743
|
] );
|
|
744
744
|
} );
|
|
745
745
|
|
|
@@ -757,7 +757,7 @@ describe( 'global styles renderer', () => {
|
|
|
757
757
|
'padding-bottom: 33px',
|
|
758
758
|
'padding-left: 33px',
|
|
759
759
|
'font-family: sans-serif',
|
|
760
|
-
'font-size:
|
|
760
|
+
'font-size: 15px',
|
|
761
761
|
] );
|
|
762
762
|
} );
|
|
763
763
|
|
|
@@ -782,7 +782,7 @@ describe( 'global styles renderer', () => {
|
|
|
782
782
|
'padding-bottom: 33px',
|
|
783
783
|
'padding-left: 33px',
|
|
784
784
|
'font-family: sans-serif',
|
|
785
|
-
'font-size: clamp(14px, 0.875rem + ((1vw - 7.68px) * 0.
|
|
785
|
+
'font-size: clamp(14px, 0.875rem + ((1vw - 7.68px) * 0.12), 15px)',
|
|
786
786
|
] );
|
|
787
787
|
} );
|
|
788
788
|
|
|
@@ -807,7 +807,7 @@ describe( 'global styles renderer', () => {
|
|
|
807
807
|
'padding-bottom: 33px',
|
|
808
808
|
'padding-left: 33px',
|
|
809
809
|
'font-family: sans-serif',
|
|
810
|
-
'font-size:
|
|
810
|
+
'font-size: 15px',
|
|
811
811
|
] );
|
|
812
812
|
} );
|
|
813
813
|
} );
|
|
@@ -7,6 +7,7 @@ import {
|
|
|
7
7
|
__experimentalFontAppearanceControl as FontAppearanceControl,
|
|
8
8
|
__experimentalLetterSpacingControl as LetterSpacingControl,
|
|
9
9
|
__experimentalTextTransformControl as TextTransformControl,
|
|
10
|
+
__experimentalTextDecorationControl as TextDecorationControl,
|
|
10
11
|
} from '@wordpress/block-editor';
|
|
11
12
|
import {
|
|
12
13
|
FontSizePicker,
|
|
@@ -19,7 +20,6 @@ import { __ } from '@wordpress/i18n';
|
|
|
19
20
|
* Internal dependencies
|
|
20
21
|
*/
|
|
21
22
|
import { getSupportedGlobalStylesPanels, useSetting, useStyle } from './hooks';
|
|
22
|
-
import { getTypographyFontSizeValue } from './typography-utils';
|
|
23
23
|
|
|
24
24
|
export function useHasTypographyPanel( name ) {
|
|
25
25
|
const hasFontFamily = useHasFontFamilyControl( name );
|
|
@@ -102,6 +102,13 @@ function useHasTextTransformControl( name, element ) {
|
|
|
102
102
|
return supports.includes( 'textTransform' );
|
|
103
103
|
}
|
|
104
104
|
|
|
105
|
+
function useHasTextDecorationControl( name, element ) {
|
|
106
|
+
// This is an exception for link elements.
|
|
107
|
+
// We shouldn't allow other blocks or elements to set textDecoration
|
|
108
|
+
// because this will be inherited by their children.
|
|
109
|
+
return ! name && element === 'link';
|
|
110
|
+
}
|
|
111
|
+
|
|
105
112
|
function useStyleWithReset( path, blockName ) {
|
|
106
113
|
const [ style, setStyle ] = useStyle( path, blockName );
|
|
107
114
|
const [ userStyle ] = useStyle( path, blockName, 'user' );
|
|
@@ -110,6 +117,26 @@ function useStyleWithReset( path, blockName ) {
|
|
|
110
117
|
return [ style, setStyle, hasStyle, resetStyle ];
|
|
111
118
|
}
|
|
112
119
|
|
|
120
|
+
function useFontSizeWithReset( path, blockName ) {
|
|
121
|
+
const [ fontSize, setStyleCallback ] = useStyle( path, blockName );
|
|
122
|
+
const [ userStyle ] = useStyle( path, blockName, 'user' );
|
|
123
|
+
const hasFontSize = () => !! userStyle;
|
|
124
|
+
const resetFontSize = () => setStyleCallback( undefined );
|
|
125
|
+
const setFontSize = ( newValue, metadata ) => {
|
|
126
|
+
if ( !! metadata?.slug ) {
|
|
127
|
+
newValue = `var:preset|font-size|${ metadata?.slug }`;
|
|
128
|
+
}
|
|
129
|
+
setStyleCallback( newValue );
|
|
130
|
+
};
|
|
131
|
+
|
|
132
|
+
return {
|
|
133
|
+
fontSize,
|
|
134
|
+
setFontSize,
|
|
135
|
+
hasFontSize,
|
|
136
|
+
resetFontSize,
|
|
137
|
+
};
|
|
138
|
+
}
|
|
139
|
+
|
|
113
140
|
function useFontAppearance( prefix, name ) {
|
|
114
141
|
const [ fontStyle, setFontStyle ] = useStyle(
|
|
115
142
|
prefix + 'typography.fontStyle',
|
|
@@ -152,19 +179,8 @@ export default function TypographyPanel( { name, element, headingLevel } ) {
|
|
|
152
179
|
} else if ( element && element !== 'text' ) {
|
|
153
180
|
prefix = `elements.${ element }.`;
|
|
154
181
|
}
|
|
155
|
-
const [ fluidTypography ] = useSetting( 'typography.fluid', name );
|
|
156
182
|
const [ fontSizes ] = useSetting( 'typography.fontSizes', name );
|
|
157
183
|
|
|
158
|
-
// Convert static font size values to fluid font sizes if fluidTypography is activated.
|
|
159
|
-
const fontSizesWithFluidValues = fontSizes.map( ( font ) => {
|
|
160
|
-
if ( !! fluidTypography ) {
|
|
161
|
-
font.size = getTypographyFontSizeValue( font, {
|
|
162
|
-
fluid: fluidTypography,
|
|
163
|
-
} );
|
|
164
|
-
}
|
|
165
|
-
return font;
|
|
166
|
-
} );
|
|
167
|
-
|
|
168
184
|
const disableCustomFontSizes = ! useSetting(
|
|
169
185
|
'typography.customFontSize',
|
|
170
186
|
name
|
|
@@ -182,6 +198,10 @@ export default function TypographyPanel( { name, element, headingLevel } ) {
|
|
|
182
198
|
const appearanceControlLabel = useAppearanceControlLabel( name );
|
|
183
199
|
const hasLetterSpacingControl = useHasLetterSpacingControl( name, element );
|
|
184
200
|
const hasTextTransformControl = useHasTextTransformControl( name, element );
|
|
201
|
+
const hasTextDecorationControl = useHasTextDecorationControl(
|
|
202
|
+
name,
|
|
203
|
+
element
|
|
204
|
+
);
|
|
185
205
|
|
|
186
206
|
/* Disable font size controls when the option to style all headings is selected. */
|
|
187
207
|
let hasFontSizeEnabled = supports.includes( 'fontSize' );
|
|
@@ -191,8 +211,8 @@ export default function TypographyPanel( { name, element, headingLevel } ) {
|
|
|
191
211
|
|
|
192
212
|
const [ fontFamily, setFontFamily, hasFontFamily, resetFontFamily ] =
|
|
193
213
|
useStyleWithReset( prefix + 'typography.fontFamily', name );
|
|
194
|
-
const
|
|
195
|
-
|
|
214
|
+
const { fontSize, setFontSize, hasFontSize, resetFontSize } =
|
|
215
|
+
useFontSizeWithReset( prefix + 'typography.fontSize', name );
|
|
196
216
|
const {
|
|
197
217
|
fontStyle,
|
|
198
218
|
setFontStyle,
|
|
@@ -215,6 +235,12 @@ export default function TypographyPanel( { name, element, headingLevel } ) {
|
|
|
215
235
|
hasTextTransform,
|
|
216
236
|
resetTextTransform,
|
|
217
237
|
] = useStyleWithReset( prefix + 'typography.textTransform', name );
|
|
238
|
+
const [
|
|
239
|
+
textDecoration,
|
|
240
|
+
setTextDecoration,
|
|
241
|
+
hasTextDecoration,
|
|
242
|
+
resetTextDecoration,
|
|
243
|
+
] = useStyleWithReset( prefix + 'typography.textDecoration', name );
|
|
218
244
|
|
|
219
245
|
const resetAll = () => {
|
|
220
246
|
resetFontFamily();
|
|
@@ -253,7 +279,7 @@ export default function TypographyPanel( { name, element, headingLevel } ) {
|
|
|
253
279
|
<FontSizePicker
|
|
254
280
|
value={ fontSize }
|
|
255
281
|
onChange={ setFontSize }
|
|
256
|
-
fontSizes={
|
|
282
|
+
fontSizes={ fontSizes }
|
|
257
283
|
disableCustomFontSizes={ disableCustomFontSizes }
|
|
258
284
|
withReset={ false }
|
|
259
285
|
withSlider
|
|
@@ -339,6 +365,22 @@ export default function TypographyPanel( { name, element, headingLevel } ) {
|
|
|
339
365
|
/>
|
|
340
366
|
</ToolsPanelItem>
|
|
341
367
|
) }
|
|
368
|
+
{ hasTextDecorationControl && (
|
|
369
|
+
<ToolsPanelItem
|
|
370
|
+
className="single-column"
|
|
371
|
+
label={ __( 'Text decoration' ) }
|
|
372
|
+
hasValue={ hasTextDecoration }
|
|
373
|
+
onDeselect={ resetTextDecoration }
|
|
374
|
+
isShownByDefault
|
|
375
|
+
>
|
|
376
|
+
<TextDecorationControl
|
|
377
|
+
value={ textDecoration }
|
|
378
|
+
onChange={ setTextDecoration }
|
|
379
|
+
size="__unstable-large"
|
|
380
|
+
__unstableInputWidth="auto"
|
|
381
|
+
/>
|
|
382
|
+
</ToolsPanelItem>
|
|
383
|
+
) }
|
|
342
384
|
</ToolsPanel>
|
|
343
385
|
);
|
|
344
386
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* External dependencies
|
|
3
3
|
*/
|
|
4
|
-
import { get, isEmpty, kebabCase, pickBy,
|
|
4
|
+
import { get, isEmpty, kebabCase, pickBy, set } from 'lodash';
|
|
5
5
|
|
|
6
6
|
/**
|
|
7
7
|
* WordPress dependencies
|
|
@@ -61,8 +61,7 @@ function compileStyleValue( uncompiledValue ) {
|
|
|
61
61
|
* @return {Array<Object>} An array of style declarations.
|
|
62
62
|
*/
|
|
63
63
|
function getPresetsDeclarations( blockPresets = {}, mergedSettings ) {
|
|
64
|
-
return reduce(
|
|
65
|
-
PRESET_METADATA,
|
|
64
|
+
return PRESET_METADATA.reduce(
|
|
66
65
|
( declarations, { path, valueKey, valueFunc, cssVarInfix } ) => {
|
|
67
66
|
const presetByOrigin = get( blockPresets, path, [] );
|
|
68
67
|
[ 'default', 'theme', 'custom' ].forEach( ( origin ) => {
|
|
@@ -102,8 +101,7 @@ function getPresetsDeclarations( blockPresets = {}, mergedSettings ) {
|
|
|
102
101
|
* @return {string} CSS declarations for the preset classes.
|
|
103
102
|
*/
|
|
104
103
|
function getPresetsClasses( blockSelector, blockPresets = {} ) {
|
|
105
|
-
return reduce(
|
|
106
|
-
PRESET_METADATA,
|
|
104
|
+
return PRESET_METADATA.reduce(
|
|
107
105
|
( declarations, { path, cssVarInfix, classes } ) => {
|
|
108
106
|
if ( ! classes ) {
|
|
109
107
|
return declarations;
|
|
@@ -193,9 +191,11 @@ export function getStylesDeclarations(
|
|
|
193
191
|
tree = {}
|
|
194
192
|
) {
|
|
195
193
|
const isRoot = ROOT_BLOCK_SELECTOR === selector;
|
|
196
|
-
const output = reduce(
|
|
197
|
-
|
|
198
|
-
|
|
194
|
+
const output = Object.entries( STYLE_PROPERTY ).reduce(
|
|
195
|
+
(
|
|
196
|
+
declarations,
|
|
197
|
+
[ key, { value, properties, useEngine, rootOnly } ]
|
|
198
|
+
) => {
|
|
199
199
|
if ( rootOnly && ! isRoot ) {
|
|
200
200
|
return declarations;
|
|
201
201
|
}
|
|
@@ -453,6 +453,7 @@ export const getNodesWithStyles = ( tree, blockSelectors ) => {
|
|
|
453
453
|
[
|
|
454
454
|
'border',
|
|
455
455
|
'color',
|
|
456
|
+
'dimensions',
|
|
456
457
|
'spacing',
|
|
457
458
|
'typography',
|
|
458
459
|
'filter',
|
|
@@ -845,8 +846,44 @@ export const getBlockSelectors = ( blockTypes ) => {
|
|
|
845
846
|
return result;
|
|
846
847
|
};
|
|
847
848
|
|
|
849
|
+
/**
|
|
850
|
+
* If there is a separator block whose color is defined in theme.json via background,
|
|
851
|
+
* update the separator color to the same value by using border color.
|
|
852
|
+
*
|
|
853
|
+
* @param {Object} config Theme.json configuration file object.
|
|
854
|
+
* @return {Object} configTheme.json configuration file object updated.
|
|
855
|
+
*/
|
|
856
|
+
function updateConfigWithSeparator( config ) {
|
|
857
|
+
const needsSeparatorStyleUpdate =
|
|
858
|
+
config.styles?.blocks[ 'core/separator' ] &&
|
|
859
|
+
config.styles?.blocks[ 'core/separator' ].color?.background &&
|
|
860
|
+
! config.styles?.blocks[ 'core/separator' ].color?.text &&
|
|
861
|
+
! config.styles?.blocks[ 'core/separator' ].border?.color;
|
|
862
|
+
if ( needsSeparatorStyleUpdate ) {
|
|
863
|
+
return {
|
|
864
|
+
...config,
|
|
865
|
+
styles: {
|
|
866
|
+
...config.styles,
|
|
867
|
+
blocks: {
|
|
868
|
+
...config.styles.blocks,
|
|
869
|
+
'core/separator': {
|
|
870
|
+
...config.styles.blocks[ 'core/separator' ],
|
|
871
|
+
color: {
|
|
872
|
+
...config.styles.blocks[ 'core/separator' ].color,
|
|
873
|
+
text: config.styles?.blocks[ 'core/separator' ]
|
|
874
|
+
.color.background,
|
|
875
|
+
},
|
|
876
|
+
},
|
|
877
|
+
},
|
|
878
|
+
},
|
|
879
|
+
};
|
|
880
|
+
}
|
|
881
|
+
return config;
|
|
882
|
+
}
|
|
883
|
+
|
|
848
884
|
export function useGlobalStylesOutput() {
|
|
849
|
-
|
|
885
|
+
let { merged: mergedConfig } = useContext( GlobalStylesContext );
|
|
886
|
+
|
|
850
887
|
const [ blockGap ] = useSetting( 'spacing.blockGap' );
|
|
851
888
|
const hasBlockGapSupport = blockGap !== null;
|
|
852
889
|
const hasFallbackGapSupport = ! hasBlockGapSupport; // This setting isn't useful yet: it exists as a placeholder for a future explicit fallback styles support.
|
|
@@ -859,7 +896,7 @@ export function useGlobalStylesOutput() {
|
|
|
859
896
|
if ( ! mergedConfig?.styles || ! mergedConfig?.settings ) {
|
|
860
897
|
return [];
|
|
861
898
|
}
|
|
862
|
-
|
|
899
|
+
mergedConfig = updateConfigWithSeparator( mergedConfig );
|
|
863
900
|
const blockSelectors = getBlockSelectors( getBlockTypes() );
|
|
864
901
|
const customProperties = toCustomProperties(
|
|
865
902
|
mergedConfig,
|
|
@@ -24,6 +24,7 @@ import { store as blockEditorStore } from '@wordpress/block-editor';
|
|
|
24
24
|
import { store as coreStore } from '@wordpress/core-data';
|
|
25
25
|
import { store as editorStore } from '@wordpress/editor';
|
|
26
26
|
import { store as preferencesStore } from '@wordpress/preferences';
|
|
27
|
+
import { decodeEntities } from '@wordpress/html-entities';
|
|
27
28
|
|
|
28
29
|
/**
|
|
29
30
|
* Internal dependencies
|
|
@@ -147,7 +148,7 @@ export default function DocumentActions() {
|
|
|
147
148
|
entityLabel
|
|
148
149
|
) }
|
|
149
150
|
</VisuallyHidden>
|
|
150
|
-
{ entityTitle }
|
|
151
|
+
{ decodeEntities( entityTitle ) }
|
|
151
152
|
</Text>
|
|
152
153
|
|
|
153
154
|
<Text
|