@wordpress/block-editor 8.1.0 → 8.1.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/CHANGELOG.md +6 -0
- package/README.md +7 -5
- package/build/components/block-inspector/index.js +7 -0
- package/build/components/block-inspector/index.js.map +1 -1
- package/build/components/block-preview/auto.js +3 -1
- package/build/components/block-preview/auto.js.map +1 -1
- package/build/components/colors-gradients/tools-panel-color-dropdown.js +89 -0
- package/build/components/colors-gradients/tools-panel-color-dropdown.js.map +1 -0
- package/build/components/contrast-checker/index.js +75 -64
- package/build/components/contrast-checker/index.js.map +1 -1
- package/build/components/index.js +9 -9
- package/build/components/index.js.map +1 -1
- package/build/components/index.native.js +9 -0
- package/build/components/index.native.js.map +1 -1
- package/build/components/inserter/search-items.js +3 -1
- package/build/components/inserter/search-items.js.map +1 -1
- package/build/components/inspector-controls/block-support-tools-panel.js +3 -1
- package/build/components/inspector-controls/block-support-tools-panel.js.map +1 -1
- package/build/components/inspector-controls/groups.js +2 -0
- package/build/components/inspector-controls/groups.js.map +1 -1
- package/build/components/line-height-control/index.native.js +3 -2
- package/build/components/line-height-control/index.native.js.map +1 -1
- package/build/components/link-control/link-preview.js +5 -2
- package/build/components/link-control/link-preview.js.map +1 -1
- package/build/components/list-view/block-contents.js +3 -1
- package/build/components/list-view/block-contents.js.map +1 -1
- package/build/components/list-view/block-select-button.js +4 -2
- package/build/components/list-view/block-select-button.js.map +1 -1
- package/build/components/list-view/block.js +2 -1
- package/build/components/list-view/block.js.map +1 -1
- package/build/components/media-placeholder/index.js +1 -11
- package/build/components/media-placeholder/index.js.map +1 -1
- package/build/components/media-replace-flow/index.native.js +13 -0
- package/build/components/media-replace-flow/index.native.js.map +1 -0
- package/build/components/rich-text/index.js +2 -1
- package/build/components/rich-text/index.js.map +1 -1
- package/build/components/rich-text/index.native.js +2 -1
- package/build/components/rich-text/index.native.js.map +1 -1
- package/build/components/rich-text/use-paste-handler.js +14 -5
- package/build/components/rich-text/use-paste-handler.js.map +1 -1
- package/build/components/rich-text/utils.js +2 -1
- package/build/components/rich-text/utils.js.map +1 -1
- package/build/hooks/border-color.js +1 -1
- package/build/hooks/border-color.js.map +1 -1
- package/build/hooks/color-panel.js +23 -17
- package/build/hooks/color-panel.js.map +1 -1
- package/build/hooks/color.js +176 -10
- package/build/hooks/color.js.map +1 -1
- package/build/hooks/font-size.js +14 -0
- package/build/hooks/font-size.js.map +1 -1
- package/build/hooks/typography.native.js +2 -4
- package/build/hooks/typography.native.js.map +1 -1
- package/build/hooks/utils.js +55 -0
- package/build/hooks/utils.js.map +1 -1
- package/build-module/components/block-inspector/index.js +7 -0
- package/build-module/components/block-inspector/index.js.map +1 -1
- package/build-module/components/block-preview/auto.js +3 -1
- package/build-module/components/block-preview/auto.js.map +1 -1
- package/build-module/components/colors-gradients/tools-panel-color-dropdown.js +75 -0
- package/build-module/components/colors-gradients/tools-panel-color-dropdown.js.map +1 -0
- package/build-module/components/contrast-checker/index.js +75 -65
- package/build-module/components/contrast-checker/index.js.map +1 -1
- package/build-module/components/index.js +1 -1
- package/build-module/components/index.js.map +1 -1
- package/build-module/components/index.native.js +1 -0
- package/build-module/components/index.native.js.map +1 -1
- package/build-module/components/inserter/search-items.js +3 -1
- package/build-module/components/inserter/search-items.js.map +1 -1
- package/build-module/components/inspector-controls/block-support-tools-panel.js +3 -1
- package/build-module/components/inspector-controls/block-support-tools-panel.js.map +1 -1
- package/build-module/components/inspector-controls/groups.js +2 -0
- package/build-module/components/inspector-controls/groups.js.map +1 -1
- package/build-module/components/line-height-control/index.native.js +3 -2
- package/build-module/components/line-height-control/index.native.js.map +1 -1
- package/build-module/components/link-control/link-preview.js +5 -2
- package/build-module/components/link-control/link-preview.js.map +1 -1
- package/build-module/components/list-view/block-contents.js +3 -1
- package/build-module/components/list-view/block-contents.js.map +1 -1
- package/build-module/components/list-view/block-select-button.js +4 -2
- package/build-module/components/list-view/block-select-button.js.map +1 -1
- package/build-module/components/list-view/block.js +2 -1
- package/build-module/components/list-view/block.js.map +1 -1
- package/build-module/components/media-placeholder/index.js +1 -10
- package/build-module/components/media-placeholder/index.js.map +1 -1
- package/build-module/components/media-replace-flow/index.native.js +4 -0
- package/build-module/components/media-replace-flow/index.native.js.map +1 -0
- package/build-module/components/rich-text/index.js +2 -1
- package/build-module/components/rich-text/index.js.map +1 -1
- package/build-module/components/rich-text/index.native.js +2 -1
- package/build-module/components/rich-text/index.native.js.map +1 -1
- package/build-module/components/rich-text/use-paste-handler.js +14 -5
- package/build-module/components/rich-text/use-paste-handler.js.map +1 -1
- package/build-module/components/rich-text/utils.js +2 -1
- package/build-module/components/rich-text/utils.js.map +1 -1
- package/build-module/hooks/border-color.js +1 -1
- package/build-module/hooks/border-color.js.map +1 -1
- package/build-module/hooks/color-panel.js +22 -15
- package/build-module/hooks/color-panel.js.map +1 -1
- package/build-module/hooks/color.js +174 -11
- package/build-module/hooks/color.js.map +1 -1
- package/build-module/hooks/font-size.js +12 -1
- package/build-module/hooks/font-size.js.map +1 -1
- package/build-module/hooks/typography.native.js +2 -4
- package/build-module/hooks/typography.native.js.map +1 -1
- package/build-module/hooks/utils.js +52 -1
- package/build-module/hooks/utils.js.map +1 -1
- package/build-style/style-rtl.css +71 -9
- package/build-style/style.css +71 -9
- package/package.json +26 -30
- package/src/components/block-inspector/index.js +9 -0
- package/src/components/block-preview/auto.js +3 -0
- package/src/components/color-palette/test/__snapshots__/control.js.snap +0 -1
- package/src/components/colors-gradients/tools-panel-color-dropdown.js +85 -0
- package/src/components/contrast-checker/index.js +102 -87
- package/src/components/contrast-checker/test/index.js +176 -7
- package/src/components/index.js +1 -1
- package/src/components/index.native.js +1 -0
- package/src/components/inserter/search-items.js +3 -1
- package/src/components/inspector-controls/block-support-tools-panel.js +2 -0
- package/src/components/inspector-controls/groups.js +2 -0
- package/src/components/line-height-control/index.native.js +2 -1
- package/src/components/link-control/link-preview.js +2 -1
- package/src/components/link-control/style.scss +3 -9
- package/src/components/list-view/block-contents.js +2 -0
- package/src/components/list-view/block-select-button.js +2 -0
- package/src/components/list-view/block.js +1 -0
- package/src/components/media-placeholder/index.js +1 -10
- package/src/components/media-replace-flow/index.native.js +3 -0
- package/src/components/rich-text/index.js +1 -0
- package/src/components/rich-text/index.native.js +1 -0
- package/src/components/rich-text/use-paste-handler.js +16 -3
- package/src/components/rich-text/utils.js +1 -0
- package/src/hooks/border-color.js +1 -1
- package/src/hooks/color-panel.js +24 -21
- package/src/hooks/color.js +177 -8
- package/src/hooks/color.scss +85 -0
- package/src/hooks/font-size.js +29 -1
- package/src/hooks/typography.native.js +1 -3
- package/src/hooks/utils.js +69 -1
- package/src/style.scss +1 -0
- package/build/components/preserve-scroll-in-reorder/index.js +0 -22
- package/build/components/preserve-scroll-in-reorder/index.js.map +0 -1
- package/build-module/components/preserve-scroll-in-reorder/index.js +0 -12
- package/build-module/components/preserve-scroll-in-reorder/index.js.map +0 -1
- package/src/components/preserve-scroll-in-reorder/index.js +0 -12
|
@@ -21,11 +21,12 @@ jest.mock( '@wordpress/a11y', () => ( { speak: jest.fn() } ) );
|
|
|
21
21
|
describe( 'ContrastChecker', () => {
|
|
22
22
|
const backgroundColor = '#ffffff';
|
|
23
23
|
const textColor = '#000000';
|
|
24
|
+
const linkColor = '#0040ff';
|
|
24
25
|
const isLargeText = true;
|
|
25
26
|
const fallbackBackgroundColor = '#fff';
|
|
26
27
|
const fallbackTextColor = '#000';
|
|
27
28
|
const sameShade = '#666';
|
|
28
|
-
const colorWithTransparency = 'rgba(102,102,102,0.5)';
|
|
29
|
+
const colorWithTransparency = 'rgba(102,102,102,0.5)'; // #666 with opacity.
|
|
29
30
|
|
|
30
31
|
beforeEach( () => {
|
|
31
32
|
speak.mockReset();
|
|
@@ -35,11 +36,25 @@ describe( 'ContrastChecker', () => {
|
|
|
35
36
|
expect( mount( <ContrastChecker /> ).html() ).toBeNull();
|
|
36
37
|
} );
|
|
37
38
|
|
|
39
|
+
test( 'should render null when no background or fallback background color is provided', () => {
|
|
40
|
+
const wrapper = mount(
|
|
41
|
+
<ContrastChecker
|
|
42
|
+
textColor={ textColor }
|
|
43
|
+
linkColor={ linkColor }
|
|
44
|
+
isLargeText={ isLargeText }
|
|
45
|
+
/>
|
|
46
|
+
);
|
|
47
|
+
|
|
48
|
+
expect( speak ).not.toHaveBeenCalled();
|
|
49
|
+
expect( wrapper.html() ).toBeNull();
|
|
50
|
+
} );
|
|
51
|
+
|
|
38
52
|
test( 'should render null when the colors meet AA WCAG guidelines.', () => {
|
|
39
53
|
const wrapper = mount(
|
|
40
54
|
<ContrastChecker
|
|
41
55
|
backgroundColor={ backgroundColor }
|
|
42
56
|
textColor={ textColor }
|
|
57
|
+
linkColor={ linkColor }
|
|
43
58
|
isLargeText={ isLargeText }
|
|
44
59
|
fallbackBackgroundColor={ fallbackBackgroundColor }
|
|
45
60
|
fallbackTextColor={ fallbackTextColor }
|
|
@@ -50,25 +65,51 @@ describe( 'ContrastChecker', () => {
|
|
|
50
65
|
expect( wrapper.html() ).toBeNull();
|
|
51
66
|
} );
|
|
52
67
|
|
|
53
|
-
test( 'should render
|
|
68
|
+
test( 'should render component when the text and background colors do not meet AA WCAG guidelines.', () => {
|
|
54
69
|
const wrapper = mount(
|
|
55
70
|
<ContrastChecker
|
|
56
|
-
backgroundColor={
|
|
71
|
+
backgroundColor={ sameShade }
|
|
72
|
+
textColor={ sameShade }
|
|
73
|
+
isLargeText={ isLargeText }
|
|
74
|
+
fallbackBackgroundColor={ fallbackBackgroundColor }
|
|
75
|
+
fallbackTextColor={ fallbackTextColor }
|
|
76
|
+
/>
|
|
77
|
+
);
|
|
78
|
+
|
|
79
|
+
expect( speak ).toHaveBeenCalledWith(
|
|
80
|
+
'This color combination may be hard for people to read.'
|
|
81
|
+
);
|
|
82
|
+
expect( wrapper.find( Notice ).children().text() ).toBe(
|
|
83
|
+
'This color combination may be hard for people to read. Try using a brighter background color and/or a darker text color.'
|
|
84
|
+
);
|
|
85
|
+
} );
|
|
86
|
+
|
|
87
|
+
test( 'should render component when the link and background colors do not meet AA WCAG guidelines.', () => {
|
|
88
|
+
const wrapper = mount(
|
|
89
|
+
<ContrastChecker
|
|
90
|
+
backgroundColor={ sameShade }
|
|
57
91
|
textColor={ textColor }
|
|
92
|
+
linkColor={ sameShade }
|
|
58
93
|
isLargeText={ isLargeText }
|
|
59
|
-
|
|
94
|
+
fallbackBackgroundColor={ fallbackBackgroundColor }
|
|
95
|
+
fallbackTextColor={ fallbackTextColor }
|
|
60
96
|
/>
|
|
61
97
|
);
|
|
62
98
|
|
|
63
|
-
expect( speak ).
|
|
64
|
-
|
|
99
|
+
expect( speak ).toHaveBeenCalledWith(
|
|
100
|
+
'This color combination may be hard for people to read.'
|
|
101
|
+
);
|
|
102
|
+
expect( wrapper.find( Notice ).children().text() ).toBe(
|
|
103
|
+
'This color combination may be hard for people to read. Try using a brighter background color and/or a darker link color.'
|
|
104
|
+
);
|
|
65
105
|
} );
|
|
66
106
|
|
|
67
|
-
test( 'should render component when the colors do not meet AA WCAG guidelines.', () => {
|
|
107
|
+
test( 'should render component when the link and text and background colors do not meet AA WCAG guidelines.', () => {
|
|
68
108
|
const wrapper = mount(
|
|
69
109
|
<ContrastChecker
|
|
70
110
|
backgroundColor={ sameShade }
|
|
71
111
|
textColor={ sameShade }
|
|
112
|
+
linkColor={ sameShade }
|
|
72
113
|
isLargeText={ isLargeText }
|
|
73
114
|
fallbackBackgroundColor={ fallbackBackgroundColor }
|
|
74
115
|
fallbackTextColor={ fallbackTextColor }
|
|
@@ -88,6 +129,7 @@ describe( 'ContrastChecker', () => {
|
|
|
88
129
|
<ContrastChecker
|
|
89
130
|
backgroundColor={ colorWithTransparency }
|
|
90
131
|
textColor={ sameShade }
|
|
132
|
+
linkColor={ sameShade }
|
|
91
133
|
isLargeText={ isLargeText }
|
|
92
134
|
fallbackBackgroundColor={ fallbackBackgroundColor }
|
|
93
135
|
fallbackTextColor={ fallbackTextColor }
|
|
@@ -113,6 +155,22 @@ describe( 'ContrastChecker', () => {
|
|
|
113
155
|
expect( wrapper.html() ).toBeNull();
|
|
114
156
|
} );
|
|
115
157
|
|
|
158
|
+
test( 'should render render null if link color contains a transparency', () => {
|
|
159
|
+
const wrapper = mount(
|
|
160
|
+
<ContrastChecker
|
|
161
|
+
backgroundColor={ backgroundColor }
|
|
162
|
+
textColor={ textColor }
|
|
163
|
+
linkColor={ colorWithTransparency }
|
|
164
|
+
isLargeText={ isLargeText }
|
|
165
|
+
fallbackBackgroundColor={ fallbackBackgroundColor }
|
|
166
|
+
fallbackTextColor={ fallbackTextColor }
|
|
167
|
+
/>
|
|
168
|
+
);
|
|
169
|
+
|
|
170
|
+
expect( speak ).not.toHaveBeenCalled();
|
|
171
|
+
expect( wrapper.html() ).toBeNull();
|
|
172
|
+
} );
|
|
173
|
+
|
|
116
174
|
test( 'should render different message matching snapshot when background color has less brightness than text color.', () => {
|
|
117
175
|
const darkerShade = '#555';
|
|
118
176
|
|
|
@@ -247,6 +305,22 @@ describe( 'ContrastChecker', () => {
|
|
|
247
305
|
);
|
|
248
306
|
} );
|
|
249
307
|
|
|
308
|
+
test( 'should render messages when the linkColor is valid, but the fallback backgroundColor conflicts.', () => {
|
|
309
|
+
const wrapper = mount(
|
|
310
|
+
<ContrastChecker
|
|
311
|
+
linkColor={ linkColor }
|
|
312
|
+
fallbackBackgroundColor={ linkColor }
|
|
313
|
+
/>
|
|
314
|
+
);
|
|
315
|
+
|
|
316
|
+
expect( speak ).toHaveBeenCalledWith(
|
|
317
|
+
'This color combination may be hard for people to read.'
|
|
318
|
+
);
|
|
319
|
+
expect( wrapper.find( Notice ).children().text() ).toBe(
|
|
320
|
+
'This color combination may be hard for people to read. Try using a brighter background color and/or a darker link color.'
|
|
321
|
+
);
|
|
322
|
+
} );
|
|
323
|
+
|
|
250
324
|
test( 'should re-announce if colors change, but still insufficient contrast', () => {
|
|
251
325
|
const appRoot = document.createElement( 'div' );
|
|
252
326
|
|
|
@@ -274,11 +348,45 @@ describe( 'ContrastChecker', () => {
|
|
|
274
348
|
} );
|
|
275
349
|
|
|
276
350
|
// enableAlphaChecker tests
|
|
351
|
+
test( 'should render null when the colors meet AA WCAG guidelines and alpha checker enabled.', () => {
|
|
352
|
+
const wrapper = mount(
|
|
353
|
+
<ContrastChecker
|
|
354
|
+
backgroundColor={ backgroundColor }
|
|
355
|
+
textColor={ textColor }
|
|
356
|
+
isLargeText={ isLargeText }
|
|
357
|
+
enableAlphaChecker={ true }
|
|
358
|
+
/>
|
|
359
|
+
);
|
|
360
|
+
|
|
361
|
+
expect( speak ).not.toHaveBeenCalled();
|
|
362
|
+
expect( wrapper.html() ).toBeNull();
|
|
363
|
+
} );
|
|
364
|
+
|
|
277
365
|
test( 'should render component when the colors meet AA WCAG guidelines but the text color only has alpha transparency with alpha checker enabled.', () => {
|
|
278
366
|
const wrapper = mount(
|
|
279
367
|
<ContrastChecker
|
|
280
368
|
backgroundColor={ backgroundColor }
|
|
281
369
|
textColor={ 'rgba(0,0,0,0.9)' }
|
|
370
|
+
linkColor={ linkColor }
|
|
371
|
+
isLargeText={ isLargeText }
|
|
372
|
+
enableAlphaChecker={ true }
|
|
373
|
+
/>
|
|
374
|
+
);
|
|
375
|
+
|
|
376
|
+
expect( speak ).toHaveBeenCalledWith(
|
|
377
|
+
'Transparent text may be hard for people to read.'
|
|
378
|
+
);
|
|
379
|
+
expect( wrapper.find( Notice ).children().text() ).toBe(
|
|
380
|
+
'Transparent text may be hard for people to read.'
|
|
381
|
+
);
|
|
382
|
+
} );
|
|
383
|
+
|
|
384
|
+
test( 'should render component when the colors meet AA WCAG guidelines but the link color only has alpha transparency with alpha checker enabled.', () => {
|
|
385
|
+
const wrapper = mount(
|
|
386
|
+
<ContrastChecker
|
|
387
|
+
backgroundColor={ backgroundColor }
|
|
388
|
+
linkColor={ 'rgba(0,0,0,0.9)' }
|
|
389
|
+
textColor={ textColor }
|
|
282
390
|
isLargeText={ isLargeText }
|
|
283
391
|
enableAlphaChecker={ true }
|
|
284
392
|
/>
|
|
@@ -297,6 +405,7 @@ describe( 'ContrastChecker', () => {
|
|
|
297
405
|
<ContrastChecker
|
|
298
406
|
backgroundColor={ 'rgba(255,255,255,0.7)' }
|
|
299
407
|
textColor={ textColor }
|
|
408
|
+
linkColor={ linkColor }
|
|
300
409
|
isLargeText={ isLargeText }
|
|
301
410
|
enableAlphaChecker={ true }
|
|
302
411
|
/>
|
|
@@ -306,10 +415,70 @@ describe( 'ContrastChecker', () => {
|
|
|
306
415
|
expect( wrapper.html() ).toBeNull();
|
|
307
416
|
} );
|
|
308
417
|
|
|
418
|
+
test( 'should render null if background color contains a transparency with alpha checker enabled.', () => {
|
|
419
|
+
const wrapper = mount(
|
|
420
|
+
<ContrastChecker
|
|
421
|
+
backgroundColor={ colorWithTransparency }
|
|
422
|
+
textColor={ sameShade }
|
|
423
|
+
linkColor={ sameShade }
|
|
424
|
+
isLargeText={ isLargeText }
|
|
425
|
+
fallbackBackgroundColor={ fallbackBackgroundColor }
|
|
426
|
+
fallbackTextColor={ fallbackTextColor }
|
|
427
|
+
enableAlphaChecker={ true }
|
|
428
|
+
/>
|
|
429
|
+
);
|
|
430
|
+
|
|
431
|
+
expect( speak ).not.toHaveBeenCalled();
|
|
432
|
+
expect( wrapper.html() ).toBeNull();
|
|
433
|
+
} );
|
|
434
|
+
|
|
435
|
+
test( 'should render transparency warning only if one text is not readable but the other is transparent and the background color contains a transparency with alpha checker enabled.', () => {
|
|
436
|
+
const wrapper = mount(
|
|
437
|
+
<ContrastChecker
|
|
438
|
+
backgroundColor={ colorWithTransparency }
|
|
439
|
+
textColor={ sameShade }
|
|
440
|
+
linkColor={ 'rgba(0,0,0,0.9)' }
|
|
441
|
+
isLargeText={ isLargeText }
|
|
442
|
+
fallbackBackgroundColor={ fallbackBackgroundColor }
|
|
443
|
+
fallbackTextColor={ fallbackTextColor }
|
|
444
|
+
enableAlphaChecker={ true }
|
|
445
|
+
/>
|
|
446
|
+
);
|
|
447
|
+
|
|
448
|
+
expect( speak ).toHaveBeenCalledWith(
|
|
449
|
+
'Transparent text may be hard for people to read.'
|
|
450
|
+
);
|
|
451
|
+
expect( wrapper.find( Notice ).children().text() ).toBe(
|
|
452
|
+
'Transparent text may be hard for people to read.'
|
|
453
|
+
);
|
|
454
|
+
} );
|
|
455
|
+
|
|
456
|
+
test( 'should render component and prioritize contrast warning when the colors do no meet AA WCAG guidelines and text has alpha transparency with the alpha checker enabled.', () => {
|
|
457
|
+
const wrapper = mount(
|
|
458
|
+
<ContrastChecker
|
|
459
|
+
backgroundColor={ sameShade }
|
|
460
|
+
textColor={ 'rgba(0,0,0,0.9)' }
|
|
461
|
+
linkColor={ sameShade }
|
|
462
|
+
isLargeText={ isLargeText }
|
|
463
|
+
fallbackBackgroundColor={ fallbackBackgroundColor }
|
|
464
|
+
fallbackTextColor={ fallbackTextColor }
|
|
465
|
+
enableAlphaChecker={ true }
|
|
466
|
+
/>
|
|
467
|
+
);
|
|
468
|
+
|
|
469
|
+
expect( speak ).toHaveBeenCalledWith(
|
|
470
|
+
'This color combination may be hard for people to read.'
|
|
471
|
+
);
|
|
472
|
+
expect( wrapper.find( Notice ).children().text() ).toBe(
|
|
473
|
+
'This color combination may be hard for people to read. Try using a brighter background color and/or a darker link color.'
|
|
474
|
+
);
|
|
475
|
+
} );
|
|
476
|
+
|
|
309
477
|
test( 'should render component when the colors meet AA WCAG guidelines but all colors have alpha transparency with alpha checker enabled.', () => {
|
|
310
478
|
const wrapper = mount(
|
|
311
479
|
<ContrastChecker
|
|
312
480
|
backgroundColor={ 'rgba(255,255,255,0.7)' }
|
|
481
|
+
linkColor={ 'rgba(0,0,0,0.7)' }
|
|
313
482
|
textColor={ 'rgba(0,0,0,0.7)' }
|
|
314
483
|
isLargeText={ isLargeText }
|
|
315
484
|
enableAlphaChecker={ true }
|
package/src/components/index.js
CHANGED
|
@@ -51,6 +51,7 @@ export { default as __experimentalTextTransformControl } from './text-transform-
|
|
|
51
51
|
export { default as __experimentalColorGradientControl } from './colors-gradients/control';
|
|
52
52
|
export { default as __experimentalColorGradientSettingsDropdown } from './colors-gradients/dropdown';
|
|
53
53
|
export { default as __experimentalPanelColorGradientSettings } from './colors-gradients/panel-color-gradient-settings';
|
|
54
|
+
export { default as __experimentalToolsPanelColorDropdown } from './colors-gradients/tools-panel-color-dropdown';
|
|
54
55
|
export {
|
|
55
56
|
default as __experimentalImageEditor,
|
|
56
57
|
ImageEditingProvider as __experimentalImageEditingProvider,
|
|
@@ -134,7 +135,6 @@ export {
|
|
|
134
135
|
useTypingObserver as __unstableUseTypingObserver,
|
|
135
136
|
useMouseMoveTypingReset as __unstableUseMouseMoveTypingReset,
|
|
136
137
|
} from './observe-typing';
|
|
137
|
-
export { default as PreserveScrollInReorder } from './preserve-scroll-in-reorder';
|
|
138
138
|
export { default as SkipToSelectedBlock } from './skip-to-selected-block';
|
|
139
139
|
export {
|
|
140
140
|
default as Typewriter,
|
|
@@ -35,6 +35,7 @@ export {
|
|
|
35
35
|
RichTextToolbarButton,
|
|
36
36
|
__unstableRichTextInputEvent,
|
|
37
37
|
} from './rich-text';
|
|
38
|
+
export { default as MediaReplaceFlow } from './media-replace-flow';
|
|
38
39
|
export { default as MediaPlaceholder } from './media-placeholder';
|
|
39
40
|
export {
|
|
40
41
|
default as MediaUpload,
|
|
@@ -163,7 +163,9 @@ export function getItemSearchRank( item, searchTerm, config = {} ) {
|
|
|
163
163
|
|
|
164
164
|
// Give a better rank to "core" namespaced items.
|
|
165
165
|
if ( rank !== 0 && name.startsWith( 'core/' ) ) {
|
|
166
|
-
|
|
166
|
+
const isCoreBlockVariation = name !== item.id;
|
|
167
|
+
// Give a bit better rank to "core" blocks over "core" block variations.
|
|
168
|
+
rank += isCoreBlockVariation ? 1 : 2;
|
|
167
169
|
}
|
|
168
170
|
|
|
169
171
|
return rank;
|
|
@@ -70,6 +70,8 @@ export default function BlockSupportToolsPanel( { children, group, label } ) {
|
|
|
70
70
|
panelId={ panelId }
|
|
71
71
|
hasInnerWrapper={ true }
|
|
72
72
|
shouldRenderPlaceholderItems={ true } // Required to maintain fills ordering.
|
|
73
|
+
__experimentalFirstVisibleItemClass="first"
|
|
74
|
+
__experimentalLastVisibleItemClass="last"
|
|
73
75
|
>
|
|
74
76
|
{ children }
|
|
75
77
|
</ToolsPanel>
|
|
@@ -6,6 +6,7 @@ import { createSlotFill } from '@wordpress/components';
|
|
|
6
6
|
const InspectorControlsDefault = createSlotFill( 'InspectorControls' );
|
|
7
7
|
const InspectorControlsAdvanced = createSlotFill( 'InspectorAdvancedControls' );
|
|
8
8
|
const InspectorControlsBorder = createSlotFill( 'InspectorControlsBorder' );
|
|
9
|
+
const InspectorControlsColor = createSlotFill( 'InspectorControlsColor' );
|
|
9
10
|
const InspectorControlsDimensions = createSlotFill(
|
|
10
11
|
'InspectorControlsDimensions'
|
|
11
12
|
);
|
|
@@ -17,6 +18,7 @@ const groups = {
|
|
|
17
18
|
default: InspectorControlsDefault,
|
|
18
19
|
advanced: InspectorControlsAdvanced,
|
|
19
20
|
border: InspectorControlsBorder,
|
|
21
|
+
color: InspectorControlsColor,
|
|
20
22
|
dimensions: InspectorControlsDimensions,
|
|
21
23
|
typography: InspectorControlsTypography,
|
|
22
24
|
};
|
|
@@ -14,7 +14,8 @@ export default function LineHeightControl( { value: lineHeight, onChange } ) {
|
|
|
14
14
|
return (
|
|
15
15
|
<UnitControl
|
|
16
16
|
label={ __( 'Line Height' ) }
|
|
17
|
-
|
|
17
|
+
// Set minimun value of 1 since lower values break on Android
|
|
18
|
+
min={ 1 }
|
|
18
19
|
max={ 5 }
|
|
19
20
|
step={ STEP }
|
|
20
21
|
value={ value }
|
|
@@ -44,7 +44,8 @@ export default function LinkPreview( {
|
|
|
44
44
|
|
|
45
45
|
const displayTitle = richData?.title || value?.title || displayURL;
|
|
46
46
|
|
|
47
|
-
|
|
47
|
+
// url can be undefined if the href attribute is unset
|
|
48
|
+
const isEmptyURL = ! value?.url?.length;
|
|
48
49
|
|
|
49
50
|
let icon;
|
|
50
51
|
|
|
@@ -483,16 +483,10 @@ $preview-image-height: 140px;
|
|
|
483
483
|
* Position spinner to the left of the actions.
|
|
484
484
|
*
|
|
485
485
|
* Compensate for:
|
|
486
|
-
* - Input
|
|
487
|
-
* - Border (1px)
|
|
488
|
-
* - Vertically, for the difference in height between the input (40px)
|
|
489
|
-
* and the spinner.
|
|
490
|
-
* - Horizontally, adjust for the width occupied by the icon buttons,
|
|
491
|
-
* then artificially create spacing that mimics as if the spinner
|
|
492
|
-
* were center-padded to the same width as an icon button.
|
|
486
|
+
* - Input padding right ($button-size)
|
|
493
487
|
*/
|
|
494
|
-
top:
|
|
495
|
-
right: $
|
|
488
|
+
top: calc(50% - #{$spinner-size} / 2);
|
|
489
|
+
right: $button-size;
|
|
496
490
|
}
|
|
497
491
|
}
|
|
498
492
|
|
|
@@ -26,6 +26,7 @@ const ListViewBlockContents = forwardRef(
|
|
|
26
26
|
position,
|
|
27
27
|
siblingBlockCount,
|
|
28
28
|
level,
|
|
29
|
+
isExpanded,
|
|
29
30
|
...props
|
|
30
31
|
},
|
|
31
32
|
ref
|
|
@@ -71,6 +72,7 @@ const ListViewBlockContents = forwardRef(
|
|
|
71
72
|
draggable={ draggable }
|
|
72
73
|
onDragStart={ onDragStart }
|
|
73
74
|
onDragEnd={ onDragEnd }
|
|
75
|
+
isExpanded={ isExpanded }
|
|
74
76
|
{ ...props }
|
|
75
77
|
/>
|
|
76
78
|
) }
|
|
@@ -36,6 +36,7 @@ function ListViewBlockSelectButton(
|
|
|
36
36
|
onDragStart,
|
|
37
37
|
onDragEnd,
|
|
38
38
|
draggable,
|
|
39
|
+
isExpanded,
|
|
39
40
|
},
|
|
40
41
|
ref
|
|
41
42
|
) {
|
|
@@ -81,6 +82,7 @@ function ListViewBlockSelectButton(
|
|
|
81
82
|
onDragEnd={ onDragEnd }
|
|
82
83
|
draggable={ draggable }
|
|
83
84
|
href={ `#block-${ clientId }` }
|
|
85
|
+
aria-expanded={ isExpanded }
|
|
84
86
|
>
|
|
85
87
|
<ListViewExpander onClick={ onToggleExpanded } />
|
|
86
88
|
<BlockIcon icon={ blockInformation?.icon } showColors />
|
|
@@ -17,7 +17,6 @@ import {
|
|
|
17
17
|
import { __ } from '@wordpress/i18n';
|
|
18
18
|
import { useState, useEffect } from '@wordpress/element';
|
|
19
19
|
import { useSelect } from '@wordpress/data';
|
|
20
|
-
import deprecated from '@wordpress/deprecated';
|
|
21
20
|
import { keyboardReturn } from '@wordpress/icons';
|
|
22
21
|
|
|
23
22
|
/**
|
|
@@ -65,7 +64,6 @@ export function MediaPlaceholder( {
|
|
|
65
64
|
addToGallery,
|
|
66
65
|
multiple = false,
|
|
67
66
|
handleUpload = true,
|
|
68
|
-
dropZoneUIOnly,
|
|
69
67
|
disableDropZone,
|
|
70
68
|
disableMediaButtons,
|
|
71
69
|
onError,
|
|
@@ -400,14 +398,7 @@ export function MediaPlaceholder( {
|
|
|
400
398
|
return renderPlaceholder( uploadMediaLibraryButton );
|
|
401
399
|
};
|
|
402
400
|
|
|
403
|
-
if (
|
|
404
|
-
if ( dropZoneUIOnly ) {
|
|
405
|
-
deprecated( 'wp.blockEditor.MediaPlaceholder dropZoneUIOnly prop', {
|
|
406
|
-
since: '5.4',
|
|
407
|
-
alternative: 'disableMediaButtons',
|
|
408
|
-
} );
|
|
409
|
-
}
|
|
410
|
-
|
|
401
|
+
if ( disableMediaButtons ) {
|
|
411
402
|
return <MediaUploadCheck>{ renderDropZone() }</MediaUploadCheck>;
|
|
412
403
|
}
|
|
413
404
|
|
|
@@ -400,6 +400,7 @@ function RichTextWrapper(
|
|
|
400
400
|
deprecated( 'wp.blockEditor.RichText wrapperClassName prop', {
|
|
401
401
|
since: '5.4',
|
|
402
402
|
alternative: 'className prop or create your own wrapper div',
|
|
403
|
+
version: '6.2',
|
|
403
404
|
} );
|
|
404
405
|
|
|
405
406
|
const className = classnames( 'block-editor-rich-text', wrapperClassName );
|
|
@@ -155,9 +155,22 @@ export function usePasteHandler( props ) {
|
|
|
155
155
|
return;
|
|
156
156
|
}
|
|
157
157
|
|
|
158
|
-
//
|
|
159
|
-
//
|
|
160
|
-
|
|
158
|
+
// Process any attached files, unless we detect Microsoft Office as
|
|
159
|
+
// the source.
|
|
160
|
+
//
|
|
161
|
+
// When content is copied from Microsoft Office, an image of the
|
|
162
|
+
// content is rendered and attached to the clipboard along with the
|
|
163
|
+
// plain-text and HTML content. This artifact is a distraction from
|
|
164
|
+
// the relevant clipboard data, so we ignore it.
|
|
165
|
+
//
|
|
166
|
+
// Props https://github.com/pubpub/pubpub/commit/2f933277a15a263a1ab4bbd36b96d3a106544aec
|
|
167
|
+
if (
|
|
168
|
+
files &&
|
|
169
|
+
files.length &&
|
|
170
|
+
! html?.includes(
|
|
171
|
+
'xmlns:o="urn:schemas-microsoft-com:office:office'
|
|
172
|
+
)
|
|
173
|
+
) {
|
|
161
174
|
const content = pasteHandler( {
|
|
162
175
|
HTML: filePasteHandler( files ),
|
|
163
176
|
mode: 'BLOCKS',
|
|
@@ -68,7 +68,7 @@ export function BorderColorEdit( props ) {
|
|
|
68
68
|
|
|
69
69
|
// Detect changes in the color attributes and update the colorValue to keep the
|
|
70
70
|
// UI in sync. This is necessary for situations when border controls interact with
|
|
71
|
-
//
|
|
71
|
+
// each other: eg, setting the border width to zero causes the color and style
|
|
72
72
|
// selections to be cleared.
|
|
73
73
|
useEffect( () => {
|
|
74
74
|
setColorValue(
|
package/src/hooks/color-panel.js
CHANGED
|
@@ -2,13 +2,12 @@
|
|
|
2
2
|
* WordPress dependencies
|
|
3
3
|
*/
|
|
4
4
|
import { useState, useEffect } from '@wordpress/element';
|
|
5
|
-
import { __ } from '@wordpress/i18n';
|
|
6
5
|
|
|
7
6
|
/**
|
|
8
7
|
* Internal dependencies
|
|
9
8
|
*/
|
|
10
|
-
import PanelColorGradientSettings from '../components/colors-gradients/panel-color-gradient-settings';
|
|
11
9
|
import ContrastChecker from '../components/contrast-checker';
|
|
10
|
+
import ToolsPanelColorDropdown from '../components/colors-gradients/tools-panel-color-dropdown';
|
|
12
11
|
import InspectorControls from '../components/inspector-controls';
|
|
13
12
|
import { __unstableUseBlockRef as useBlockRef } from '../components/block-list/use-block-props/use-block-refs';
|
|
14
13
|
|
|
@@ -21,10 +20,10 @@ export default function ColorPanel( {
|
|
|
21
20
|
settings,
|
|
22
21
|
clientId,
|
|
23
22
|
enableContrastChecking = true,
|
|
24
|
-
showTitle = true,
|
|
25
23
|
} ) {
|
|
26
24
|
const [ detectedBackgroundColor, setDetectedBackgroundColor ] = useState();
|
|
27
25
|
const [ detectedColor, setDetectedColor ] = useState();
|
|
26
|
+
const [ detectedLinkColor, setDetectedLinkColor ] = useState();
|
|
28
27
|
const ref = useBlockRef( clientId );
|
|
29
28
|
|
|
30
29
|
useEffect( () => {
|
|
@@ -37,6 +36,11 @@ export default function ColorPanel( {
|
|
|
37
36
|
}
|
|
38
37
|
setDetectedColor( getComputedStyle( ref.current ).color );
|
|
39
38
|
|
|
39
|
+
const firstLinkElement = ref.current?.querySelector( 'a' );
|
|
40
|
+
if ( firstLinkElement && !! firstLinkElement.innerText ) {
|
|
41
|
+
setDetectedLinkColor( getComputedStyle( firstLinkElement ).color );
|
|
42
|
+
}
|
|
43
|
+
|
|
40
44
|
let backgroundColorNode = ref.current;
|
|
41
45
|
let backgroundColor = getComputedStyle( backgroundColorNode )
|
|
42
46
|
.backgroundColor;
|
|
@@ -55,24 +59,23 @@ export default function ColorPanel( {
|
|
|
55
59
|
} );
|
|
56
60
|
|
|
57
61
|
return (
|
|
58
|
-
<InspectorControls>
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
</PanelColorGradientSettings>
|
|
62
|
+
<InspectorControls __experimentalGroup="color">
|
|
63
|
+
{ settings.map( ( setting, index ) => (
|
|
64
|
+
<ToolsPanelColorDropdown
|
|
65
|
+
key={ index }
|
|
66
|
+
settings={ setting }
|
|
67
|
+
panelId={ clientId }
|
|
68
|
+
enableAlpha={ enableAlpha }
|
|
69
|
+
/>
|
|
70
|
+
) ) }
|
|
71
|
+
{ enableContrastChecking && (
|
|
72
|
+
<ContrastChecker
|
|
73
|
+
backgroundColor={ detectedBackgroundColor }
|
|
74
|
+
textColor={ detectedColor }
|
|
75
|
+
enableAlphaChecker={ enableAlpha }
|
|
76
|
+
linkColor={ detectedLinkColor }
|
|
77
|
+
/>
|
|
78
|
+
) }
|
|
76
79
|
</InspectorControls>
|
|
77
80
|
);
|
|
78
81
|
}
|