@wordpress/block-editor 11.8.0 → 12.0.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 +6 -0
- package/README.md +15 -3
- package/build/components/block-info-slot-fill/index.js +47 -0
- package/build/components/block-info-slot-fill/index.js.map +1 -0
- package/build/components/block-inspector/index.js +4 -2
- package/build/components/block-inspector/index.js.map +1 -1
- package/build/components/block-list/block.native.js +3 -4
- package/build/components/block-list/block.native.js.map +1 -1
- package/build/components/block-toolbar/index.js +2 -1
- package/build/components/block-toolbar/index.js.map +1 -1
- package/build/components/block-tools/block-contextual-toolbar.js +83 -9
- package/build/components/block-tools/block-contextual-toolbar.js.map +1 -1
- package/build/components/block-tools/selected-block-popover.js +11 -28
- package/build/components/block-tools/selected-block-popover.js.map +1 -1
- package/build/components/editor-styles/index.js +4 -3
- package/build/components/editor-styles/index.js.map +1 -1
- package/build/components/font-sizes/fluid-utils.js +21 -14
- package/build/components/font-sizes/fluid-utils.js.map +1 -1
- package/build/components/global-styles/border-panel.js +2 -32
- package/build/components/global-styles/border-panel.js.map +1 -1
- package/build/components/global-styles/color-panel.js +12 -12
- package/build/components/global-styles/color-panel.js.map +1 -1
- package/build/components/global-styles/color-panel.native.js +174 -0
- package/build/components/global-styles/color-panel.native.js.map +1 -0
- package/build/components/global-styles/dimensions-panel.js +6 -6
- package/build/components/global-styles/dimensions-panel.js.map +1 -1
- package/build/components/global-styles/effects-panel.js +1 -1
- package/build/components/global-styles/effects-panel.js.map +1 -1
- package/build/components/global-styles/filters-panel.js +78 -14
- package/build/components/global-styles/filters-panel.js.map +1 -1
- package/build/components/global-styles/typography-panel.js +9 -9
- package/build/components/global-styles/typography-panel.js.map +1 -1
- package/build/components/global-styles/use-global-styles-output.js +87 -77
- package/build/components/global-styles/use-global-styles-output.js.map +1 -1
- package/build/components/index.js +7 -0
- package/build/components/index.js.map +1 -1
- package/build/components/inserter/block-types-tab.js +12 -7
- package/build/components/inserter/block-types-tab.js.map +1 -1
- package/build/components/inserter/index.js +2 -1
- package/build/components/inserter/index.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/inspector-controls-tabs/styles-tab.js +2 -0
- package/build/components/inspector-controls-tabs/styles-tab.js.map +1 -1
- package/build/components/list-view/block-select-button.js +7 -2
- package/build/components/list-view/block-select-button.js.map +1 -1
- package/build/components/list-view/block.js +12 -21
- package/build/components/list-view/block.js.map +1 -1
- package/build/components/list-view/drop-indicator.js +37 -10
- package/build/components/list-view/drop-indicator.js.map +1 -1
- package/build/components/list-view/index.js +10 -4
- package/build/components/list-view/index.js.map +1 -1
- package/build/components/list-view/leaf.js +2 -1
- package/build/components/list-view/leaf.js.map +1 -1
- package/build/components/list-view/use-block-selection.js +1 -1
- package/build/components/list-view/use-block-selection.js.map +1 -1
- package/build/components/media-replace-flow/index.js +5 -5
- package/build/components/media-replace-flow/index.js.map +1 -1
- package/build/components/navigable-toolbar/index.js +12 -4
- package/build/components/navigable-toolbar/index.js.map +1 -1
- package/build/components/off-canvas-editor/appender.js +2 -7
- package/build/components/off-canvas-editor/appender.js.map +1 -1
- package/build/hooks/duotone.js +29 -4
- package/build/hooks/duotone.js.map +1 -1
- package/build/hooks/utils.js +15 -3
- package/build/hooks/utils.js.map +1 -1
- package/build/private-apis.js +10 -1
- package/build/private-apis.js.map +1 -1
- package/build/store/actions.js +7 -0
- package/build/store/actions.js.map +1 -1
- package/build/utils/object.js +5 -5
- package/build/utils/object.js.map +1 -1
- package/build/utils/transform-styles/index.js +2 -2
- package/build/utils/transform-styles/index.js.map +1 -1
- package/build/utils/use-should-contextual-toolbar-show.js +68 -0
- package/build/utils/use-should-contextual-toolbar-show.js.map +1 -0
- package/build-module/components/block-info-slot-fill/index.js +34 -0
- package/build-module/components/block-info-slot-fill/index.js.map +1 -0
- package/build-module/components/block-inspector/index.js +3 -2
- package/build-module/components/block-inspector/index.js.map +1 -1
- package/build-module/components/block-list/block.native.js +3 -4
- package/build-module/components/block-list/block.native.js.map +1 -1
- package/build-module/components/block-toolbar/index.js +2 -1
- package/build-module/components/block-toolbar/index.js.map +1 -1
- package/build-module/components/block-tools/block-contextual-toolbar.js +79 -9
- package/build-module/components/block-tools/block-contextual-toolbar.js.map +1 -1
- package/build-module/components/block-tools/selected-block-popover.js +10 -27
- package/build-module/components/block-tools/selected-block-popover.js.map +1 -1
- package/build-module/components/editor-styles/index.js +4 -3
- package/build-module/components/editor-styles/index.js.map +1 -1
- package/build-module/components/font-sizes/fluid-utils.js +21 -14
- package/build-module/components/font-sizes/fluid-utils.js.map +1 -1
- package/build-module/components/global-styles/border-panel.js +2 -32
- package/build-module/components/global-styles/border-panel.js.map +1 -1
- package/build-module/components/global-styles/color-panel.js +13 -13
- package/build-module/components/global-styles/color-panel.js.map +1 -1
- package/build-module/components/global-styles/color-panel.native.js +150 -0
- package/build-module/components/global-styles/color-panel.native.js.map +1 -0
- package/build-module/components/global-styles/dimensions-panel.js +7 -7
- package/build-module/components/global-styles/dimensions-panel.js.map +1 -1
- package/build-module/components/global-styles/effects-panel.js +2 -2
- package/build-module/components/global-styles/effects-panel.js.map +1 -1
- package/build-module/components/global-styles/filters-panel.js +78 -16
- package/build-module/components/global-styles/filters-panel.js.map +1 -1
- package/build-module/components/global-styles/typography-panel.js +10 -10
- package/build-module/components/global-styles/typography-panel.js.map +1 -1
- package/build-module/components/global-styles/use-global-styles-output.js +87 -77
- package/build-module/components/global-styles/use-global-styles-output.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/inserter/block-types-tab.js +12 -6
- package/build-module/components/inserter/block-types-tab.js.map +1 -1
- package/build-module/components/inserter/index.js +2 -1
- package/build-module/components/inserter/index.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/inspector-controls-tabs/styles-tab.js +2 -0
- package/build-module/components/inspector-controls-tabs/styles-tab.js.map +1 -1
- package/build-module/components/list-view/block-select-button.js +7 -2
- package/build-module/components/list-view/block-select-button.js.map +1 -1
- package/build-module/components/list-view/block.js +14 -22
- package/build-module/components/list-view/block.js.map +1 -1
- package/build-module/components/list-view/drop-indicator.js +36 -10
- package/build-module/components/list-view/drop-indicator.js.map +1 -1
- package/build-module/components/list-view/index.js +11 -5
- package/build-module/components/list-view/index.js.map +1 -1
- package/build-module/components/list-view/leaf.js +2 -1
- package/build-module/components/list-view/leaf.js.map +1 -1
- package/build-module/components/list-view/use-block-selection.js +1 -1
- package/build-module/components/list-view/use-block-selection.js.map +1 -1
- package/build-module/components/media-replace-flow/index.js +5 -5
- package/build-module/components/media-replace-flow/index.js.map +1 -1
- package/build-module/components/navigable-toolbar/index.js +12 -4
- package/build-module/components/navigable-toolbar/index.js.map +1 -1
- package/build-module/components/off-canvas-editor/appender.js +1 -5
- package/build-module/components/off-canvas-editor/appender.js.map +1 -1
- package/build-module/hooks/duotone.js +28 -5
- package/build-module/hooks/duotone.js.map +1 -1
- package/build-module/hooks/utils.js +16 -4
- package/build-module/hooks/utils.js.map +1 -1
- package/build-module/private-apis.js +7 -1
- package/build-module/private-apis.js.map +1 -1
- package/build-module/store/actions.js +7 -0
- package/build-module/store/actions.js.map +1 -1
- package/build-module/utils/object.js +4 -4
- package/build-module/utils/object.js.map +1 -1
- package/build-module/utils/transform-styles/index.js +2 -2
- package/build-module/utils/transform-styles/index.js.map +1 -1
- package/build-module/utils/use-should-contextual-toolbar-show.js +56 -0
- package/build-module/utils/use-should-contextual-toolbar-show.js.map +1 -0
- package/build-style/content-rtl.css +9 -6
- package/build-style/content.css +9 -6
- package/build-style/style-rtl.css +223 -46
- package/build-style/style.css +223 -46
- package/package.json +32 -32
- package/src/components/block-info-slot-fill/index.js +24 -0
- package/src/components/block-inspector/index.js +3 -0
- package/src/components/block-list/block.native.js +2 -3
- package/src/components/block-list/content.scss +16 -15
- package/src/components/block-mobile-toolbar/test/block-actions-menu.native.js +9 -9
- package/src/components/block-mover/style.scss +10 -4
- package/src/components/block-mover/test/index.native.js +4 -4
- package/src/components/block-toolbar/index.js +4 -3
- package/src/components/block-toolbar/style.scss +56 -33
- package/src/components/block-tools/block-contextual-toolbar.js +94 -11
- package/src/components/block-tools/selected-block-popover.js +11 -44
- package/src/components/block-tools/style.scss +157 -3
- package/src/components/editor-styles/index.js +9 -5
- package/src/components/font-sizes/fluid-utils.js +31 -14
- package/src/components/font-sizes/test/fluid-utils.js +5 -16
- package/src/components/global-styles/border-panel.js +1 -30
- package/src/components/global-styles/color-panel.js +13 -13
- package/src/components/global-styles/color-panel.native.js +207 -0
- package/src/components/global-styles/dimensions-panel.js +17 -7
- package/src/components/global-styles/effects-panel.js +2 -2
- package/src/components/global-styles/filters-panel.js +90 -17
- package/src/components/global-styles/style.scss +2 -1
- package/src/components/global-styles/test/typography-utils.js +63 -22
- package/src/components/global-styles/test/use-global-styles-output.js +126 -4
- package/src/components/global-styles/typography-panel.js +37 -11
- package/src/components/global-styles/use-global-styles-output.js +64 -64
- package/src/components/index.js +1 -0
- package/src/components/inserter/block-types-tab.js +9 -6
- package/src/components/inserter/index.js +1 -1
- package/src/components/inspector-controls/groups.js +2 -0
- package/src/components/inspector-controls-tabs/styles-tab.js +1 -0
- package/src/components/list-view/block-select-button.js +6 -1
- package/src/components/list-view/block.js +23 -31
- package/src/components/list-view/drop-indicator.js +67 -22
- package/src/components/list-view/index.js +8 -1
- package/src/components/list-view/leaf.js +1 -0
- package/src/components/list-view/style.scss +15 -3
- package/src/components/list-view/use-block-selection.js +1 -1
- package/src/components/media-replace-flow/README.md +3 -2
- package/src/components/media-replace-flow/index.js +4 -5
- package/src/components/navigable-toolbar/index.js +12 -3
- package/src/components/off-canvas-editor/appender.js +1 -4
- package/src/components/url-popover/test/__snapshots__/index.js.snap +3 -3
- package/src/hooks/duotone.js +46 -25
- package/src/hooks/test/anchor.js +113 -0
- package/src/hooks/test/color.js +0 -9
- package/src/hooks/test/use-typography-props.js +2 -2
- package/src/hooks/test/utils.js +20 -101
- package/src/hooks/utils.js +20 -3
- package/src/private-apis.js +6 -0
- package/src/store/actions.js +7 -0
- package/src/utils/object.js +4 -4
- package/src/utils/test/object.js +21 -21
- package/src/utils/transform-styles/index.js +2 -2
- package/src/utils/use-should-contextual-toolbar-show.js +75 -0
- package/tsconfig.json +1 -0
- package/build/hooks/color-panel.native.js +0 -77
- package/build/hooks/color-panel.native.js.map +0 -1
- package/build-module/hooks/color-panel.native.js +0 -62
- package/build-module/hooks/color-panel.native.js.map +0 -1
- package/src/hooks/color-panel.native.js +0 -63
|
@@ -480,10 +480,128 @@ describe( 'global styles renderer', () => {
|
|
|
480
480
|
expect( toStyles( tree, blockSelectors ) ).toEqual(
|
|
481
481
|
'body {margin: 0;}' +
|
|
482
482
|
'body{background-color: red;margin: 10px;padding: 10px;}a{color: blue;}a:hover{color: orange;}a:focus{color: orange;}h1{font-size: 42px;}.wp-block-group{margin-top: 10px;margin-right: 20px;margin-bottom: 30px;margin-left: 40px;padding-top: 11px;padding-right: 22px;padding-bottom: 33px;padding-left: 44px;}h1,h2,h3,h4,h5,h6{color: orange;}h1 a,h2 a,h3 a,h4 a,h5 a,h6 a{color: hotpink;}h1 a:hover,h2 a:hover,h3 a:hover,h4 a:hover,h5 a:hover,h6 a:hover{color: red;}h1 a:focus,h2 a:focus,h3 a:focus,h4 a:focus,h5 a:focus,h6 a:focus{color: red;}' +
|
|
483
|
-
'.wp-block-image img, .wp-block-image .wp-crop-area{border-radius: 9999px}.wp-block-image{color: red;}.wp-site-blocks > .alignleft { float: left; margin-right: 2em; }.wp-site-blocks > .alignright { float: right; margin-left: 2em; }.wp-site-blocks > .aligncenter { justify-content: center; margin-left: auto; margin-right: auto; }' +
|
|
483
|
+
'.wp-block-image img, .wp-block-image .wp-crop-area{border-radius: 9999px;}.wp-block-image{color: red;}.wp-site-blocks > .alignleft { float: left; margin-right: 2em; }.wp-site-blocks > .alignright { float: right; margin-left: 2em; }.wp-site-blocks > .aligncenter { justify-content: center; margin-left: auto; margin-right: auto; }' +
|
|
484
484
|
'.has-white-color{color: var(--wp--preset--color--white) !important;}.has-white-background-color{background-color: var(--wp--preset--color--white) !important;}.has-white-border-color{border-color: var(--wp--preset--color--white) !important;}.has-black-color{color: var(--wp--preset--color--black) !important;}.has-black-background-color{background-color: var(--wp--preset--color--black) !important;}.has-black-border-color{border-color: var(--wp--preset--color--black) !important;}h1.has-blue-color,h2.has-blue-color,h3.has-blue-color,h4.has-blue-color,h5.has-blue-color,h6.has-blue-color{color: var(--wp--preset--color--blue) !important;}h1.has-blue-background-color,h2.has-blue-background-color,h3.has-blue-background-color,h4.has-blue-background-color,h5.has-blue-background-color,h6.has-blue-background-color{background-color: var(--wp--preset--color--blue) !important;}h1.has-blue-border-color,h2.has-blue-border-color,h3.has-blue-border-color,h4.has-blue-border-color,h5.has-blue-border-color,h6.has-blue-border-color{border-color: var(--wp--preset--color--blue) !important;}'
|
|
485
485
|
);
|
|
486
486
|
} );
|
|
487
|
+
|
|
488
|
+
it( 'should handle feature selectors', () => {
|
|
489
|
+
const tree = {
|
|
490
|
+
styles: {
|
|
491
|
+
blocks: {
|
|
492
|
+
'core/image': {
|
|
493
|
+
color: {
|
|
494
|
+
text: 'red',
|
|
495
|
+
},
|
|
496
|
+
spacing: {
|
|
497
|
+
padding: {
|
|
498
|
+
top: '1px',
|
|
499
|
+
},
|
|
500
|
+
},
|
|
501
|
+
border: {
|
|
502
|
+
color: 'red',
|
|
503
|
+
radius: '9999px',
|
|
504
|
+
},
|
|
505
|
+
},
|
|
506
|
+
},
|
|
507
|
+
},
|
|
508
|
+
};
|
|
509
|
+
|
|
510
|
+
const blockSelectors = {
|
|
511
|
+
'core/image': {
|
|
512
|
+
selector: '.wp-image',
|
|
513
|
+
featureSelectors: {
|
|
514
|
+
spacing: '.wp-image-spacing',
|
|
515
|
+
border: {
|
|
516
|
+
root: '.wp-image-border',
|
|
517
|
+
color: '.wp-image-border-color',
|
|
518
|
+
},
|
|
519
|
+
},
|
|
520
|
+
},
|
|
521
|
+
};
|
|
522
|
+
|
|
523
|
+
expect( toStyles( Object.freeze( tree ), blockSelectors ) ).toEqual(
|
|
524
|
+
'body {margin: 0;}' +
|
|
525
|
+
'.wp-image-spacing{padding-top: 1px;}.wp-image-border-color{border-color: red;}.wp-image-border{border-radius: 9999px;}.wp-image{color: red;}' +
|
|
526
|
+
'.wp-site-blocks > .alignleft { float: left; margin-right: 2em; }.wp-site-blocks > .alignright { float: right; margin-left: 2em; }.wp-site-blocks > .aligncenter { justify-content: center; margin-left: auto; margin-right: auto; }'
|
|
527
|
+
);
|
|
528
|
+
} );
|
|
529
|
+
|
|
530
|
+
it( 'should handle block variations', () => {
|
|
531
|
+
const tree = {
|
|
532
|
+
styles: {
|
|
533
|
+
blocks: {
|
|
534
|
+
'core/image': {
|
|
535
|
+
variations: {
|
|
536
|
+
foo: {
|
|
537
|
+
color: {
|
|
538
|
+
text: 'blue',
|
|
539
|
+
},
|
|
540
|
+
spacing: {
|
|
541
|
+
padding: {
|
|
542
|
+
top: '2px',
|
|
543
|
+
},
|
|
544
|
+
},
|
|
545
|
+
border: {
|
|
546
|
+
color: 'blue',
|
|
547
|
+
},
|
|
548
|
+
},
|
|
549
|
+
},
|
|
550
|
+
},
|
|
551
|
+
},
|
|
552
|
+
},
|
|
553
|
+
};
|
|
554
|
+
|
|
555
|
+
const blockSelectors = {
|
|
556
|
+
'core/image': {
|
|
557
|
+
selector: '.wp-image',
|
|
558
|
+
featureSelectors: {
|
|
559
|
+
spacing: '.wp-image-spacing',
|
|
560
|
+
border: {
|
|
561
|
+
root: '.wp-image-border',
|
|
562
|
+
color: '.wp-image-border-color',
|
|
563
|
+
},
|
|
564
|
+
},
|
|
565
|
+
styleVariationSelectors: {
|
|
566
|
+
foo: '.is-style-foo.wp-image',
|
|
567
|
+
},
|
|
568
|
+
},
|
|
569
|
+
};
|
|
570
|
+
|
|
571
|
+
expect( toStyles( Object.freeze( tree ), blockSelectors ) ).toEqual(
|
|
572
|
+
'body {margin: 0;}' +
|
|
573
|
+
'.is-style-foo.wp-image.wp-image-spacing{padding-top: 2px;}.is-style-foo.wp-image.wp-image-border-color{border-color: blue;}.is-style-foo.wp-image{color: blue;}' +
|
|
574
|
+
'.wp-site-blocks > .alignleft { float: left; margin-right: 2em; }.wp-site-blocks > .alignright { float: right; margin-left: 2em; }.wp-site-blocks > .aligncenter { justify-content: center; margin-left: auto; margin-right: auto; }'
|
|
575
|
+
);
|
|
576
|
+
} );
|
|
577
|
+
|
|
578
|
+
it( 'should handle duotone filter', () => {
|
|
579
|
+
const tree = {
|
|
580
|
+
styles: {
|
|
581
|
+
blocks: {
|
|
582
|
+
'core/image': {
|
|
583
|
+
filter: {
|
|
584
|
+
duotone: 'blur(5px)',
|
|
585
|
+
},
|
|
586
|
+
},
|
|
587
|
+
},
|
|
588
|
+
},
|
|
589
|
+
};
|
|
590
|
+
|
|
591
|
+
const blockSelectors = {
|
|
592
|
+
'core/image': {
|
|
593
|
+
selector: '.wp-image',
|
|
594
|
+
duotoneSelector: '.wp-image img',
|
|
595
|
+
},
|
|
596
|
+
};
|
|
597
|
+
|
|
598
|
+
expect( toStyles( Object.freeze( tree ), blockSelectors ) ).toEqual(
|
|
599
|
+
'body {margin: 0;}' +
|
|
600
|
+
'.wp-image img{filter: blur(5px);}' +
|
|
601
|
+
'.wp-site-blocks > .alignleft { float: left; margin-right: 2em; }.wp-site-blocks > .alignright { float: right; margin-left: 2em; }.wp-site-blocks > .aligncenter { justify-content: center; margin-left: auto; margin-right: auto; }'
|
|
602
|
+
);
|
|
603
|
+
} );
|
|
604
|
+
|
|
487
605
|
it( 'should output content and wide size variables if values are specified', () => {
|
|
488
606
|
const tree = {
|
|
489
607
|
settings: {
|
|
@@ -493,7 +611,7 @@ describe( 'global styles renderer', () => {
|
|
|
493
611
|
},
|
|
494
612
|
},
|
|
495
613
|
};
|
|
496
|
-
expect( toStyles( tree, 'body' ) ).toEqual(
|
|
614
|
+
expect( toStyles( Object.freeze( tree ), 'body' ) ).toEqual(
|
|
497
615
|
'body {margin: 0; --wp--style--global--content-size: 840px; --wp--style--global--wide-size: 1100px;}.wp-site-blocks > .alignleft { float: left; margin-right: 2em; }.wp-site-blocks > .alignright { float: right; margin-left: 2em; }.wp-site-blocks > .aligncenter { justify-content: center; margin-left: auto; margin-right: auto; }'
|
|
498
616
|
);
|
|
499
617
|
} );
|
|
@@ -678,8 +796,9 @@ describe( 'global styles renderer', () => {
|
|
|
678
796
|
selectors: imageSelectors,
|
|
679
797
|
};
|
|
680
798
|
const blockTypes = [ imageBlock ];
|
|
799
|
+
const getBlockStyles = () => [ { name: 'foo' } ];
|
|
681
800
|
|
|
682
|
-
expect( getBlockSelectors( blockTypes,
|
|
801
|
+
expect( getBlockSelectors( blockTypes, getBlockStyles ) ).toEqual( {
|
|
683
802
|
'core/image': {
|
|
684
803
|
name: imageBlock.name,
|
|
685
804
|
selector: imageSelectors.root,
|
|
@@ -690,6 +809,9 @@ describe( 'global styles renderer', () => {
|
|
|
690
809
|
border: '.my-image img, .my-image .crop-area',
|
|
691
810
|
filter: { duotone: 'img' },
|
|
692
811
|
},
|
|
812
|
+
styleVariationSelectors: {
|
|
813
|
+
foo: '.is-style-foo.my-image',
|
|
814
|
+
},
|
|
693
815
|
hasLayoutSupport: false,
|
|
694
816
|
},
|
|
695
817
|
} );
|
|
@@ -811,7 +933,7 @@ describe( 'global styles renderer', () => {
|
|
|
811
933
|
'padding-bottom: 33px',
|
|
812
934
|
'padding-left: 33px',
|
|
813
935
|
'font-family: sans-serif',
|
|
814
|
-
'font-size: clamp(14px, 0.875rem + ((1vw -
|
|
936
|
+
'font-size: clamp(14px, 0.875rem + ((1vw - 3.2px) * 0.078), 15px)',
|
|
815
937
|
] );
|
|
816
938
|
} );
|
|
817
939
|
|
|
@@ -20,7 +20,7 @@ import LetterSpacingControl from '../letter-spacing-control';
|
|
|
20
20
|
import TextTransformControl from '../text-transform-control';
|
|
21
21
|
import TextDecorationControl from '../text-decoration-control';
|
|
22
22
|
import { getValueFromVariable } from './utils';
|
|
23
|
-
import {
|
|
23
|
+
import { setImmutably } from '../../utils/object';
|
|
24
24
|
|
|
25
25
|
const MIN_TEXT_COLUMNS = 1;
|
|
26
26
|
const MAX_TEXT_COLUMNS = 6;
|
|
@@ -163,10 +163,12 @@ export default function TypographyPanel( {
|
|
|
163
163
|
( { fontFamily: f } ) => f === newValue
|
|
164
164
|
)?.slug;
|
|
165
165
|
onChange(
|
|
166
|
-
|
|
166
|
+
setImmutably(
|
|
167
167
|
value,
|
|
168
168
|
[ 'typography', 'fontFamily' ],
|
|
169
|
-
slug
|
|
169
|
+
slug
|
|
170
|
+
? `var:preset|font-family|${ slug }`
|
|
171
|
+
: newValue || undefined
|
|
170
172
|
)
|
|
171
173
|
);
|
|
172
174
|
};
|
|
@@ -188,7 +190,11 @@ export default function TypographyPanel( {
|
|
|
188
190
|
: newValue;
|
|
189
191
|
|
|
190
192
|
onChange(
|
|
191
|
-
|
|
193
|
+
setImmutably(
|
|
194
|
+
value,
|
|
195
|
+
[ 'typography', 'fontSize' ],
|
|
196
|
+
actualValue || undefined
|
|
197
|
+
)
|
|
192
198
|
);
|
|
193
199
|
};
|
|
194
200
|
const hasFontSize = () => !! value?.typography?.fontSize;
|
|
@@ -209,8 +215,8 @@ export default function TypographyPanel( {
|
|
|
209
215
|
...value,
|
|
210
216
|
typography: {
|
|
211
217
|
...value?.typography,
|
|
212
|
-
fontStyle: newFontStyle,
|
|
213
|
-
fontWeight: newFontWeight,
|
|
218
|
+
fontStyle: newFontStyle || undefined,
|
|
219
|
+
fontWeight: newFontWeight || undefined,
|
|
214
220
|
},
|
|
215
221
|
} );
|
|
216
222
|
};
|
|
@@ -225,7 +231,11 @@ export default function TypographyPanel( {
|
|
|
225
231
|
const lineHeight = decodeValue( inheritedValue?.typography?.lineHeight );
|
|
226
232
|
const setLineHeight = ( newValue ) => {
|
|
227
233
|
onChange(
|
|
228
|
-
|
|
234
|
+
setImmutably(
|
|
235
|
+
value,
|
|
236
|
+
[ 'typography', 'lineHeight' ],
|
|
237
|
+
newValue || undefined
|
|
238
|
+
)
|
|
229
239
|
);
|
|
230
240
|
};
|
|
231
241
|
const hasLineHeight = () => !! value?.typography?.lineHeight;
|
|
@@ -238,7 +248,11 @@ export default function TypographyPanel( {
|
|
|
238
248
|
);
|
|
239
249
|
const setLetterSpacing = ( newValue ) => {
|
|
240
250
|
onChange(
|
|
241
|
-
|
|
251
|
+
setImmutably(
|
|
252
|
+
value,
|
|
253
|
+
[ 'typography', 'letterSpacing' ],
|
|
254
|
+
newValue || undefined
|
|
255
|
+
)
|
|
242
256
|
);
|
|
243
257
|
};
|
|
244
258
|
const hasLetterSpacing = () => !! value?.typography?.letterSpacing;
|
|
@@ -249,7 +263,11 @@ export default function TypographyPanel( {
|
|
|
249
263
|
const textColumns = decodeValue( inheritedValue?.typography?.textColumns );
|
|
250
264
|
const setTextColumns = ( newValue ) => {
|
|
251
265
|
onChange(
|
|
252
|
-
|
|
266
|
+
setImmutably(
|
|
267
|
+
value,
|
|
268
|
+
[ 'typography', 'textColumns' ],
|
|
269
|
+
newValue || undefined
|
|
270
|
+
)
|
|
253
271
|
);
|
|
254
272
|
};
|
|
255
273
|
const hasTextColumns = () => !! value?.typography?.textColumns;
|
|
@@ -262,7 +280,11 @@ export default function TypographyPanel( {
|
|
|
262
280
|
);
|
|
263
281
|
const setTextTransform = ( newValue ) => {
|
|
264
282
|
onChange(
|
|
265
|
-
|
|
283
|
+
setImmutably(
|
|
284
|
+
value,
|
|
285
|
+
[ 'typography', 'textTransform' ],
|
|
286
|
+
newValue || undefined
|
|
287
|
+
)
|
|
266
288
|
);
|
|
267
289
|
};
|
|
268
290
|
const hasTextTransform = () => !! value?.typography?.textTransform;
|
|
@@ -275,7 +297,11 @@ export default function TypographyPanel( {
|
|
|
275
297
|
);
|
|
276
298
|
const setTextDecoration = ( newValue ) => {
|
|
277
299
|
onChange(
|
|
278
|
-
|
|
300
|
+
setImmutably(
|
|
301
|
+
value,
|
|
302
|
+
[ 'typography', 'textDecoration' ],
|
|
303
|
+
newValue || undefined
|
|
304
|
+
)
|
|
279
305
|
);
|
|
280
306
|
};
|
|
281
307
|
const hasTextDecoration = () => !! value?.typography?.textDecoration;
|
|
@@ -325,7 +325,7 @@ export function getStylesDeclarations(
|
|
|
325
325
|
return declarations;
|
|
326
326
|
}
|
|
327
327
|
|
|
328
|
-
if (
|
|
328
|
+
if ( properties && typeof styleValue !== 'string' ) {
|
|
329
329
|
Object.entries( properties ).forEach( ( entry ) => {
|
|
330
330
|
const [ name, prop ] = entry;
|
|
331
331
|
|
|
@@ -382,7 +382,7 @@ export function getStylesDeclarations(
|
|
|
382
382
|
ruleValue = get( tree, refPath );
|
|
383
383
|
// Presence of another ref indicates a reference to another dynamic value.
|
|
384
384
|
// Pointing to another dynamic value is not supported.
|
|
385
|
-
if ( ! ruleValue ||
|
|
385
|
+
if ( ! ruleValue || ruleValue?.ref ) {
|
|
386
386
|
return;
|
|
387
387
|
}
|
|
388
388
|
}
|
|
@@ -551,6 +551,33 @@ export function getLayoutStyles( {
|
|
|
551
551
|
return ruleset;
|
|
552
552
|
}
|
|
553
553
|
|
|
554
|
+
const STYLE_KEYS = [
|
|
555
|
+
'border',
|
|
556
|
+
'color',
|
|
557
|
+
'dimensions',
|
|
558
|
+
'spacing',
|
|
559
|
+
'typography',
|
|
560
|
+
'filter',
|
|
561
|
+
'outline',
|
|
562
|
+
'shadow',
|
|
563
|
+
];
|
|
564
|
+
|
|
565
|
+
function pickStyleKeys( treeToPickFrom ) {
|
|
566
|
+
if ( ! treeToPickFrom ) {
|
|
567
|
+
return {};
|
|
568
|
+
}
|
|
569
|
+
const entries = Object.entries( treeToPickFrom );
|
|
570
|
+
const pickedEntries = entries.filter( ( [ key ] ) =>
|
|
571
|
+
STYLE_KEYS.includes( key )
|
|
572
|
+
);
|
|
573
|
+
// clone the style objects so that `getFeatureDeclarations` can remove consumed keys from it
|
|
574
|
+
const clonedEntries = pickedEntries.map( ( [ key, style ] ) => [
|
|
575
|
+
key,
|
|
576
|
+
JSON.parse( JSON.stringify( style ) ),
|
|
577
|
+
] );
|
|
578
|
+
return Object.fromEntries( clonedEntries );
|
|
579
|
+
}
|
|
580
|
+
|
|
554
581
|
export const getNodesWithStyles = ( tree, blockSelectors ) => {
|
|
555
582
|
const nodes = [];
|
|
556
583
|
|
|
@@ -558,25 +585,9 @@ export const getNodesWithStyles = ( tree, blockSelectors ) => {
|
|
|
558
585
|
return nodes;
|
|
559
586
|
}
|
|
560
587
|
|
|
561
|
-
const pickStyleKeys = ( treeToPickFrom ) =>
|
|
562
|
-
Object.fromEntries(
|
|
563
|
-
Object.entries( treeToPickFrom ?? {} ).filter( ( [ key ] ) =>
|
|
564
|
-
[
|
|
565
|
-
'border',
|
|
566
|
-
'color',
|
|
567
|
-
'dimensions',
|
|
568
|
-
'spacing',
|
|
569
|
-
'typography',
|
|
570
|
-
'filter',
|
|
571
|
-
'outline',
|
|
572
|
-
'shadow',
|
|
573
|
-
].includes( key )
|
|
574
|
-
)
|
|
575
|
-
);
|
|
576
|
-
|
|
577
588
|
// Top-level.
|
|
578
589
|
const styles = pickStyleKeys( tree.styles );
|
|
579
|
-
if (
|
|
590
|
+
if ( styles ) {
|
|
580
591
|
nodes.push( {
|
|
581
592
|
styles,
|
|
582
593
|
selector: ROOT_BLOCK_SELECTOR,
|
|
@@ -584,7 +595,7 @@ export const getNodesWithStyles = ( tree, blockSelectors ) => {
|
|
|
584
595
|
}
|
|
585
596
|
|
|
586
597
|
Object.entries( ELEMENTS ).forEach( ( [ name, selector ] ) => {
|
|
587
|
-
if (
|
|
598
|
+
if ( tree.styles?.elements?.[ name ] ) {
|
|
588
599
|
nodes.push( {
|
|
589
600
|
styles: tree.styles?.elements?.[ name ],
|
|
590
601
|
selector,
|
|
@@ -606,10 +617,7 @@ export const getNodesWithStyles = ( tree, blockSelectors ) => {
|
|
|
606
617
|
} );
|
|
607
618
|
blockStyles.variations = variations;
|
|
608
619
|
}
|
|
609
|
-
if (
|
|
610
|
-
!! blockStyles &&
|
|
611
|
-
!! blockSelectors?.[ blockName ]?.selector
|
|
612
|
-
) {
|
|
620
|
+
if ( blockStyles && blockSelectors?.[ blockName ]?.selector ) {
|
|
613
621
|
nodes.push( {
|
|
614
622
|
duotoneSelector:
|
|
615
623
|
blockSelectors[ blockName ].duotoneSelector,
|
|
@@ -617,7 +625,7 @@ export const getNodesWithStyles = ( tree, blockSelectors ) => {
|
|
|
617
625
|
blockSelectors[ blockName ].fallbackGapValue,
|
|
618
626
|
hasLayoutSupport:
|
|
619
627
|
blockSelectors[ blockName ].hasLayoutSupport,
|
|
620
|
-
selector: blockSelectors[ blockName ]
|
|
628
|
+
selector: blockSelectors[ blockName ].selector,
|
|
621
629
|
styles: blockStyles,
|
|
622
630
|
featureSelectors:
|
|
623
631
|
blockSelectors[ blockName ].featureSelectors,
|
|
@@ -629,9 +637,9 @@ export const getNodesWithStyles = ( tree, blockSelectors ) => {
|
|
|
629
637
|
Object.entries( node?.elements ?? {} ).forEach(
|
|
630
638
|
( [ elementName, value ] ) => {
|
|
631
639
|
if (
|
|
632
|
-
|
|
633
|
-
|
|
634
|
-
|
|
640
|
+
value &&
|
|
641
|
+
blockSelectors?.[ blockName ] &&
|
|
642
|
+
ELEMENTS[ elementName ]
|
|
635
643
|
) {
|
|
636
644
|
nodes.push( {
|
|
637
645
|
styles: value,
|
|
@@ -677,7 +685,7 @@ export const getNodesWithSettings = ( tree, blockSelectors ) => {
|
|
|
677
685
|
// Top-level.
|
|
678
686
|
const presets = pickPresets( tree.settings );
|
|
679
687
|
const custom = tree.settings?.custom;
|
|
680
|
-
if ( ! isEmpty( presets ) ||
|
|
688
|
+
if ( ! isEmpty( presets ) || custom ) {
|
|
681
689
|
nodes.push( {
|
|
682
690
|
presets,
|
|
683
691
|
custom,
|
|
@@ -690,7 +698,7 @@ export const getNodesWithSettings = ( tree, blockSelectors ) => {
|
|
|
690
698
|
( [ blockName, node ] ) => {
|
|
691
699
|
const blockPresets = pickPresets( node );
|
|
692
700
|
const blockCustom = node.custom;
|
|
693
|
-
if ( ! isEmpty( blockPresets ) ||
|
|
701
|
+
if ( ! isEmpty( blockPresets ) || blockCustom ) {
|
|
694
702
|
nodes.push( {
|
|
695
703
|
presets: blockPresets,
|
|
696
704
|
custom: blockCustom,
|
|
@@ -714,7 +722,7 @@ export const toCustomProperties = ( tree, blockSelectors ) => {
|
|
|
714
722
|
}
|
|
715
723
|
|
|
716
724
|
if ( declarations.length > 0 ) {
|
|
717
|
-
ruleset
|
|
725
|
+
ruleset += `${ selector }{${ declarations.join( ';' ) };}`;
|
|
718
726
|
}
|
|
719
727
|
} );
|
|
720
728
|
|
|
@@ -787,9 +795,9 @@ export const toStyles = (
|
|
|
787
795
|
|
|
788
796
|
Object.entries( featureDeclarations ).forEach(
|
|
789
797
|
( [ cssSelector, declarations ] ) => {
|
|
790
|
-
if (
|
|
798
|
+
if ( declarations.length ) {
|
|
791
799
|
const rules = declarations.join( ';' );
|
|
792
|
-
ruleset
|
|
800
|
+
ruleset += `${ cssSelector }{${ rules };}`;
|
|
793
801
|
}
|
|
794
802
|
}
|
|
795
803
|
);
|
|
@@ -798,20 +806,20 @@ export const toStyles = (
|
|
|
798
806
|
if ( styleVariationSelectors ) {
|
|
799
807
|
Object.entries( styleVariationSelectors ).forEach(
|
|
800
808
|
( [ styleVariationName, styleVariationSelector ] ) => {
|
|
801
|
-
|
|
809
|
+
const styleVariations =
|
|
810
|
+
styles?.variations?.[ styleVariationName ];
|
|
811
|
+
if ( styleVariations ) {
|
|
802
812
|
// If the block uses any custom selectors for block support, add those first.
|
|
803
813
|
if ( featureSelectors ) {
|
|
804
814
|
const featureDeclarations =
|
|
805
815
|
getFeatureDeclarations(
|
|
806
816
|
featureSelectors,
|
|
807
|
-
|
|
808
|
-
styleVariationName
|
|
809
|
-
]
|
|
817
|
+
styleVariations
|
|
810
818
|
);
|
|
811
819
|
|
|
812
820
|
Object.entries( featureDeclarations ).forEach(
|
|
813
821
|
( [ baseSelector, declarations ] ) => {
|
|
814
|
-
if (
|
|
822
|
+
if ( declarations.length ) {
|
|
815
823
|
const cssSelector =
|
|
816
824
|
concatFeatureVariationSelectorString(
|
|
817
825
|
baseSelector,
|
|
@@ -819,9 +827,7 @@ export const toStyles = (
|
|
|
819
827
|
);
|
|
820
828
|
const rules =
|
|
821
829
|
declarations.join( ';' );
|
|
822
|
-
ruleset
|
|
823
|
-
ruleset +
|
|
824
|
-
`${ cssSelector }{${ rules }}`;
|
|
830
|
+
ruleset += `${ cssSelector }{${ rules };}`;
|
|
825
831
|
}
|
|
826
832
|
}
|
|
827
833
|
);
|
|
@@ -830,39 +836,34 @@ export const toStyles = (
|
|
|
830
836
|
// Otherwise add regular selectors.
|
|
831
837
|
const styleVariationDeclarations =
|
|
832
838
|
getStylesDeclarations(
|
|
833
|
-
|
|
839
|
+
styleVariations,
|
|
834
840
|
styleVariationSelector,
|
|
835
841
|
useRootPaddingAlign,
|
|
836
842
|
tree
|
|
837
843
|
);
|
|
838
|
-
if (
|
|
839
|
-
ruleset
|
|
840
|
-
|
|
841
|
-
|
|
842
|
-
';'
|
|
843
|
-
) }}`;
|
|
844
|
+
if ( styleVariationDeclarations.length ) {
|
|
845
|
+
ruleset += `${ styleVariationSelector }{${ styleVariationDeclarations.join(
|
|
846
|
+
';'
|
|
847
|
+
) };}`;
|
|
844
848
|
}
|
|
845
849
|
}
|
|
846
850
|
}
|
|
847
851
|
);
|
|
848
852
|
}
|
|
849
853
|
|
|
850
|
-
const duotoneStyles = {};
|
|
851
|
-
if ( styles?.filter ) {
|
|
852
|
-
duotoneStyles.filter = styles.filter;
|
|
853
|
-
delete styles.filter;
|
|
854
|
-
}
|
|
855
|
-
|
|
856
854
|
// Process duotone styles.
|
|
857
855
|
if ( duotoneSelector ) {
|
|
856
|
+
const duotoneStyles = {};
|
|
857
|
+
if ( styles?.filter ) {
|
|
858
|
+
duotoneStyles.filter = styles.filter;
|
|
859
|
+
delete styles.filter;
|
|
860
|
+
}
|
|
858
861
|
const duotoneDeclarations =
|
|
859
862
|
getStylesDeclarations( duotoneStyles );
|
|
860
|
-
if ( duotoneDeclarations.length
|
|
861
|
-
ruleset
|
|
862
|
-
|
|
863
|
-
|
|
864
|
-
';'
|
|
865
|
-
) };}`;
|
|
863
|
+
if ( duotoneDeclarations.length ) {
|
|
864
|
+
ruleset += `${ duotoneSelector }{${ duotoneDeclarations.join(
|
|
865
|
+
';'
|
|
866
|
+
) };}`;
|
|
866
867
|
}
|
|
867
868
|
}
|
|
868
869
|
|
|
@@ -889,8 +890,7 @@ export const toStyles = (
|
|
|
889
890
|
tree
|
|
890
891
|
);
|
|
891
892
|
if ( declarations?.length ) {
|
|
892
|
-
ruleset
|
|
893
|
-
ruleset + `${ selector }{${ declarations.join( ';' ) };}`;
|
|
893
|
+
ruleset += `${ selector }{${ declarations.join( ';' ) };}`;
|
|
894
894
|
}
|
|
895
895
|
|
|
896
896
|
// Check for pseudo selector in `styles` and handle separately.
|
|
@@ -924,7 +924,7 @@ export const toStyles = (
|
|
|
924
924
|
';'
|
|
925
925
|
) };}`;
|
|
926
926
|
|
|
927
|
-
ruleset
|
|
927
|
+
ruleset += pseudoRule;
|
|
928
928
|
}
|
|
929
929
|
);
|
|
930
930
|
}
|
|
@@ -965,7 +965,7 @@ export const toStyles = (
|
|
|
965
965
|
|
|
966
966
|
const classes = getPresetsClasses( selector, presets );
|
|
967
967
|
if ( ! isEmpty( classes ) ) {
|
|
968
|
-
ruleset
|
|
968
|
+
ruleset += classes;
|
|
969
969
|
}
|
|
970
970
|
} );
|
|
971
971
|
|
package/src/components/index.js
CHANGED
|
@@ -1,8 +1,3 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* External dependencies
|
|
3
|
-
*/
|
|
4
|
-
import { groupBy } from 'lodash';
|
|
5
|
-
|
|
6
1
|
/**
|
|
7
2
|
* WordPress dependencies
|
|
8
3
|
*/
|
|
@@ -59,7 +54,15 @@ export function BlockTypesTab( {
|
|
|
59
54
|
itemList.filter(
|
|
60
55
|
( item ) => item.category && item.category !== 'reusable'
|
|
61
56
|
),
|
|
62
|
-
( itemList ) =>
|
|
57
|
+
( itemList ) =>
|
|
58
|
+
itemList.reduce( ( acc, item ) => {
|
|
59
|
+
const { category } = item;
|
|
60
|
+
if ( ! acc[ category ] ) {
|
|
61
|
+
acc[ category ] = [];
|
|
62
|
+
}
|
|
63
|
+
acc[ category ].push( item );
|
|
64
|
+
return acc;
|
|
65
|
+
}, {} )
|
|
63
66
|
)( items );
|
|
64
67
|
}, [ items ] );
|
|
65
68
|
|
|
@@ -214,7 +214,7 @@ class PrivateInserter extends Component {
|
|
|
214
214
|
'block-editor-inserter__popover',
|
|
215
215
|
{ 'is-quick': isQuick }
|
|
216
216
|
) }
|
|
217
|
-
popoverProps={ { position } }
|
|
217
|
+
popoverProps={ { position, shift: true } }
|
|
218
218
|
onToggle={ this.onToggle }
|
|
219
219
|
expandOnMobile
|
|
220
220
|
headerTitle={ __( 'Add a block' ) }
|
|
@@ -7,6 +7,7 @@ const InspectorControlsDefault = createSlotFill( 'InspectorControls' );
|
|
|
7
7
|
const InspectorControlsAdvanced = createSlotFill( 'InspectorAdvancedControls' );
|
|
8
8
|
const InspectorControlsBorder = createSlotFill( 'InspectorControlsBorder' );
|
|
9
9
|
const InspectorControlsColor = createSlotFill( 'InspectorControlsColor' );
|
|
10
|
+
const InspectorControlsFilter = createSlotFill( 'InspectorControlsFilter' );
|
|
10
11
|
const InspectorControlsDimensions = createSlotFill(
|
|
11
12
|
'InspectorControlsDimensions'
|
|
12
13
|
);
|
|
@@ -22,6 +23,7 @@ const groups = {
|
|
|
22
23
|
advanced: InspectorControlsAdvanced,
|
|
23
24
|
border: InspectorControlsBorder,
|
|
24
25
|
color: InspectorControlsColor,
|
|
26
|
+
filter: InspectorControlsFilter,
|
|
25
27
|
dimensions: InspectorControlsDimensions,
|
|
26
28
|
list: InspectorControlsListView,
|
|
27
29
|
settings: InspectorControlsDefault, // Alias for default.
|
|
@@ -32,6 +32,7 @@ const StylesTab = ( { blockName, clientId, hasBlockStyles } ) => {
|
|
|
32
32
|
label={ __( 'Color' ) }
|
|
33
33
|
className="color-block-support-panel__inner-wrapper"
|
|
34
34
|
/>
|
|
35
|
+
<InspectorControls.Slot group="filter" />
|
|
35
36
|
<InspectorControls.Slot
|
|
36
37
|
group="typography"
|
|
37
38
|
label={ __( 'Typography' ) }
|
|
@@ -35,6 +35,9 @@ function ListViewBlockSelectButton(
|
|
|
35
35
|
onDragStart,
|
|
36
36
|
onDragEnd,
|
|
37
37
|
draggable,
|
|
38
|
+
isExpanded,
|
|
39
|
+
ariaLabel,
|
|
40
|
+
ariaDescribedBy,
|
|
38
41
|
},
|
|
39
42
|
ref
|
|
40
43
|
) {
|
|
@@ -76,7 +79,9 @@ function ListViewBlockSelectButton(
|
|
|
76
79
|
onDragEnd={ onDragEnd }
|
|
77
80
|
draggable={ draggable }
|
|
78
81
|
href={ `#block-${ clientId }` }
|
|
79
|
-
aria-
|
|
82
|
+
aria-label={ ariaLabel }
|
|
83
|
+
aria-describedby={ ariaDescribedBy }
|
|
84
|
+
aria-expanded={ isExpanded }
|
|
80
85
|
>
|
|
81
86
|
<ListViewExpander onClick={ onToggleExpanded } />
|
|
82
87
|
<BlockIcon icon={ blockInformation?.icon } showColors />
|