@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.
Files changed (145) hide show
  1. package/CHANGELOG.md +6 -0
  2. package/README.md +7 -5
  3. package/build/components/block-inspector/index.js +7 -0
  4. package/build/components/block-inspector/index.js.map +1 -1
  5. package/build/components/block-preview/auto.js +3 -1
  6. package/build/components/block-preview/auto.js.map +1 -1
  7. package/build/components/colors-gradients/tools-panel-color-dropdown.js +89 -0
  8. package/build/components/colors-gradients/tools-panel-color-dropdown.js.map +1 -0
  9. package/build/components/contrast-checker/index.js +75 -64
  10. package/build/components/contrast-checker/index.js.map +1 -1
  11. package/build/components/index.js +9 -9
  12. package/build/components/index.js.map +1 -1
  13. package/build/components/index.native.js +9 -0
  14. package/build/components/index.native.js.map +1 -1
  15. package/build/components/inserter/search-items.js +3 -1
  16. package/build/components/inserter/search-items.js.map +1 -1
  17. package/build/components/inspector-controls/block-support-tools-panel.js +3 -1
  18. package/build/components/inspector-controls/block-support-tools-panel.js.map +1 -1
  19. package/build/components/inspector-controls/groups.js +2 -0
  20. package/build/components/inspector-controls/groups.js.map +1 -1
  21. package/build/components/line-height-control/index.native.js +3 -2
  22. package/build/components/line-height-control/index.native.js.map +1 -1
  23. package/build/components/link-control/link-preview.js +5 -2
  24. package/build/components/link-control/link-preview.js.map +1 -1
  25. package/build/components/list-view/block-contents.js +3 -1
  26. package/build/components/list-view/block-contents.js.map +1 -1
  27. package/build/components/list-view/block-select-button.js +4 -2
  28. package/build/components/list-view/block-select-button.js.map +1 -1
  29. package/build/components/list-view/block.js +2 -1
  30. package/build/components/list-view/block.js.map +1 -1
  31. package/build/components/media-placeholder/index.js +1 -11
  32. package/build/components/media-placeholder/index.js.map +1 -1
  33. package/build/components/media-replace-flow/index.native.js +13 -0
  34. package/build/components/media-replace-flow/index.native.js.map +1 -0
  35. package/build/components/rich-text/index.js +2 -1
  36. package/build/components/rich-text/index.js.map +1 -1
  37. package/build/components/rich-text/index.native.js +2 -1
  38. package/build/components/rich-text/index.native.js.map +1 -1
  39. package/build/components/rich-text/use-paste-handler.js +14 -5
  40. package/build/components/rich-text/use-paste-handler.js.map +1 -1
  41. package/build/components/rich-text/utils.js +2 -1
  42. package/build/components/rich-text/utils.js.map +1 -1
  43. package/build/hooks/border-color.js +1 -1
  44. package/build/hooks/border-color.js.map +1 -1
  45. package/build/hooks/color-panel.js +23 -17
  46. package/build/hooks/color-panel.js.map +1 -1
  47. package/build/hooks/color.js +176 -10
  48. package/build/hooks/color.js.map +1 -1
  49. package/build/hooks/font-size.js +14 -0
  50. package/build/hooks/font-size.js.map +1 -1
  51. package/build/hooks/typography.native.js +2 -4
  52. package/build/hooks/typography.native.js.map +1 -1
  53. package/build/hooks/utils.js +55 -0
  54. package/build/hooks/utils.js.map +1 -1
  55. package/build-module/components/block-inspector/index.js +7 -0
  56. package/build-module/components/block-inspector/index.js.map +1 -1
  57. package/build-module/components/block-preview/auto.js +3 -1
  58. package/build-module/components/block-preview/auto.js.map +1 -1
  59. package/build-module/components/colors-gradients/tools-panel-color-dropdown.js +75 -0
  60. package/build-module/components/colors-gradients/tools-panel-color-dropdown.js.map +1 -0
  61. package/build-module/components/contrast-checker/index.js +75 -65
  62. package/build-module/components/contrast-checker/index.js.map +1 -1
  63. package/build-module/components/index.js +1 -1
  64. package/build-module/components/index.js.map +1 -1
  65. package/build-module/components/index.native.js +1 -0
  66. package/build-module/components/index.native.js.map +1 -1
  67. package/build-module/components/inserter/search-items.js +3 -1
  68. package/build-module/components/inserter/search-items.js.map +1 -1
  69. package/build-module/components/inspector-controls/block-support-tools-panel.js +3 -1
  70. package/build-module/components/inspector-controls/block-support-tools-panel.js.map +1 -1
  71. package/build-module/components/inspector-controls/groups.js +2 -0
  72. package/build-module/components/inspector-controls/groups.js.map +1 -1
  73. package/build-module/components/line-height-control/index.native.js +3 -2
  74. package/build-module/components/line-height-control/index.native.js.map +1 -1
  75. package/build-module/components/link-control/link-preview.js +5 -2
  76. package/build-module/components/link-control/link-preview.js.map +1 -1
  77. package/build-module/components/list-view/block-contents.js +3 -1
  78. package/build-module/components/list-view/block-contents.js.map +1 -1
  79. package/build-module/components/list-view/block-select-button.js +4 -2
  80. package/build-module/components/list-view/block-select-button.js.map +1 -1
  81. package/build-module/components/list-view/block.js +2 -1
  82. package/build-module/components/list-view/block.js.map +1 -1
  83. package/build-module/components/media-placeholder/index.js +1 -10
  84. package/build-module/components/media-placeholder/index.js.map +1 -1
  85. package/build-module/components/media-replace-flow/index.native.js +4 -0
  86. package/build-module/components/media-replace-flow/index.native.js.map +1 -0
  87. package/build-module/components/rich-text/index.js +2 -1
  88. package/build-module/components/rich-text/index.js.map +1 -1
  89. package/build-module/components/rich-text/index.native.js +2 -1
  90. package/build-module/components/rich-text/index.native.js.map +1 -1
  91. package/build-module/components/rich-text/use-paste-handler.js +14 -5
  92. package/build-module/components/rich-text/use-paste-handler.js.map +1 -1
  93. package/build-module/components/rich-text/utils.js +2 -1
  94. package/build-module/components/rich-text/utils.js.map +1 -1
  95. package/build-module/hooks/border-color.js +1 -1
  96. package/build-module/hooks/border-color.js.map +1 -1
  97. package/build-module/hooks/color-panel.js +22 -15
  98. package/build-module/hooks/color-panel.js.map +1 -1
  99. package/build-module/hooks/color.js +174 -11
  100. package/build-module/hooks/color.js.map +1 -1
  101. package/build-module/hooks/font-size.js +12 -1
  102. package/build-module/hooks/font-size.js.map +1 -1
  103. package/build-module/hooks/typography.native.js +2 -4
  104. package/build-module/hooks/typography.native.js.map +1 -1
  105. package/build-module/hooks/utils.js +52 -1
  106. package/build-module/hooks/utils.js.map +1 -1
  107. package/build-style/style-rtl.css +71 -9
  108. package/build-style/style.css +71 -9
  109. package/package.json +26 -30
  110. package/src/components/block-inspector/index.js +9 -0
  111. package/src/components/block-preview/auto.js +3 -0
  112. package/src/components/color-palette/test/__snapshots__/control.js.snap +0 -1
  113. package/src/components/colors-gradients/tools-panel-color-dropdown.js +85 -0
  114. package/src/components/contrast-checker/index.js +102 -87
  115. package/src/components/contrast-checker/test/index.js +176 -7
  116. package/src/components/index.js +1 -1
  117. package/src/components/index.native.js +1 -0
  118. package/src/components/inserter/search-items.js +3 -1
  119. package/src/components/inspector-controls/block-support-tools-panel.js +2 -0
  120. package/src/components/inspector-controls/groups.js +2 -0
  121. package/src/components/line-height-control/index.native.js +2 -1
  122. package/src/components/link-control/link-preview.js +2 -1
  123. package/src/components/link-control/style.scss +3 -9
  124. package/src/components/list-view/block-contents.js +2 -0
  125. package/src/components/list-view/block-select-button.js +2 -0
  126. package/src/components/list-view/block.js +1 -0
  127. package/src/components/media-placeholder/index.js +1 -10
  128. package/src/components/media-replace-flow/index.native.js +3 -0
  129. package/src/components/rich-text/index.js +1 -0
  130. package/src/components/rich-text/index.native.js +1 -0
  131. package/src/components/rich-text/use-paste-handler.js +16 -3
  132. package/src/components/rich-text/utils.js +1 -0
  133. package/src/hooks/border-color.js +1 -1
  134. package/src/hooks/color-panel.js +24 -21
  135. package/src/hooks/color.js +177 -8
  136. package/src/hooks/color.scss +85 -0
  137. package/src/hooks/font-size.js +29 -1
  138. package/src/hooks/typography.native.js +1 -3
  139. package/src/hooks/utils.js +69 -1
  140. package/src/style.scss +1 -0
  141. package/build/components/preserve-scroll-in-reorder/index.js +0 -22
  142. package/build/components/preserve-scroll-in-reorder/index.js.map +0 -1
  143. package/build-module/components/preserve-scroll-in-reorder/index.js +0 -12
  144. package/build-module/components/preserve-scroll-in-reorder/index.js.map +0 -1
  145. package/src/components/preserve-scroll-in-reorder/index.js +0 -12
@@ -1 +1 @@
1
- {"version":3,"sources":["@wordpress/block-editor/src/hooks/utils.js"],"names":["pickBy","isEmpty","isObject","identity","mapValues","cleanEmptyObject","object","Array","isArray","cleanedNestedObjects","undefined"],"mappings":"AAAA;AACA;AACA;AACA,SAASA,MAAT,EAAiBC,OAAjB,EAA0BC,QAA1B,EAAoCC,QAApC,EAA8CC,SAA9C,QAA+D,QAA/D;AAEA;AACA;AACA;AACA;AACA;AACA;;AACA,OAAO,MAAMC,gBAAgB,GAAKC,MAAF,IAAc;AAC7C,MAAK,CAAEJ,QAAQ,CAAEI,MAAF,CAAV,IAAwBC,KAAK,CAACC,OAAN,CAAeF,MAAf,CAA7B,EAAuD;AACtD,WAAOA,MAAP;AACA;;AACD,QAAMG,oBAAoB,GAAGT,MAAM,CAClCI,SAAS,CAAEE,MAAF,EAAUD,gBAAV,CADyB,EAElCF,QAFkC,CAAnC;AAIA,SAAOF,OAAO,CAAEQ,oBAAF,CAAP,GAAkCC,SAAlC,GAA8CD,oBAArD;AACA,CATM","sourcesContent":["/**\n * External dependencies\n */\nimport { pickBy, isEmpty, isObject, identity, mapValues } from 'lodash';\n\n/**\n * Removed falsy values from nested object.\n *\n * @param {*} object\n * @return {*} Object cleaned from falsy values\n */\nexport const cleanEmptyObject = ( object ) => {\n\tif ( ! isObject( object ) || Array.isArray( object ) ) {\n\t\treturn object;\n\t}\n\tconst cleanedNestedObjects = pickBy(\n\t\tmapValues( object, cleanEmptyObject ),\n\t\tidentity\n\t);\n\treturn isEmpty( cleanedNestedObjects ) ? undefined : cleanedNestedObjects;\n};\n"]}
1
+ {"version":3,"sources":["@wordpress/block-editor/src/hooks/utils.js"],"names":["pickBy","isEmpty","isObject","identity","mapValues","forEach","get","setWith","clone","every","cleanEmptyObject","object","Array","isArray","cleanedNestedObjects","undefined","immutableSet","path","value","transformStyles","activeSupports","migrationPaths","result","source","index","results","isActive","length","innerBlocks","referenceBlockAttributes","attributes","returnBlock","support","styleValue"],"mappings":"AAAA;AACA;AACA;AACA,SACCA,MADD,EAECC,OAFD,EAGCC,QAHD,EAICC,QAJD,EAKCC,SALD,EAMCC,OAND,EAOCC,GAPD,EAQCC,OARD,EASCC,KATD,EAUCC,KAVD,QAWO,QAXP;AAaA;AACA;AACA;AACA;AACA;AACA;;AACA,OAAO,MAAMC,gBAAgB,GAAKC,MAAF,IAAc;AAC7C,MAAK,CAAET,QAAQ,CAAES,MAAF,CAAV,IAAwBC,KAAK,CAACC,OAAN,CAAeF,MAAf,CAA7B,EAAuD;AACtD,WAAOA,MAAP;AACA;;AACD,QAAMG,oBAAoB,GAAGd,MAAM,CAClCI,SAAS,CAAEO,MAAF,EAAUD,gBAAV,CADyB,EAElCP,QAFkC,CAAnC;AAIA,SAAOF,OAAO,CAAEa,oBAAF,CAAP,GAAkCC,SAAlC,GAA8CD,oBAArD;AACA,CATM;AAWP,OAAO,SAASE,YAAT,CAAuBL,MAAvB,EAA+BM,IAA/B,EAAqCC,KAArC,EAA6C;AACnD,SAAOX,OAAO,CAAEI,MAAM,GAAGH,KAAK,CAAEG,MAAF,CAAR,GAAqB,EAA7B,EAAiCM,IAAjC,EAAuCC,KAAvC,EAA8CV,KAA9C,CAAd;AACA;AAED,OAAO,SAASW,eAAT,CACNC,cADM,EAENC,cAFM,EAGNC,MAHM,EAINC,MAJM,EAKNC,KALM,EAMNC,OANM,EAOL;AAAA;;AACD;AACA,MAAKhB,KAAK,CAAEW,cAAF,EAAoBM,QAAF,IAAgB,CAAEA,QAApC,CAAV,EAA2D;AAC1D,WAAOJ,MAAP;AACA,GAJA,CAKD;AACA;;;AACA,MAAKG,OAAO,CAACE,MAAR,KAAmB,CAAnB,IAAwBL,MAAM,CAACM,WAAP,CAAmBD,MAAnB,KAA8BJ,MAAM,CAACI,MAAlE,EAA2E;AAC1E,WAAOL,MAAP;AACA,GATA,CAUD;AACA;AACA;;;AACA,MAAIO,wBAAwB,eAAGN,MAAM,CAAE,CAAF,CAAT,6CAAG,SAAaO,UAA5C,CAbC,CAcD;AACA;AACA;AACA;;AACA,MAAKL,OAAO,CAACE,MAAR,GAAiB,CAAjB,IAAsBJ,MAAM,CAACI,MAAP,GAAgB,CAA3C,EAA+C;AAC9C,QAAKJ,MAAM,CAAEC,KAAF,CAAX,EAAuB;AAAA;;AACtBK,MAAAA,wBAAwB,oBAAGN,MAAM,CAAEC,KAAF,CAAT,kDAAG,cAAiBM,UAA5C;AACA,KAFD,MAEO;AACN,aAAOR,MAAP;AACA;AACD;;AACD,MAAIS,WAAW,GAAGT,MAAlB;AACAjB,EAAAA,OAAO,CAAEe,cAAF,EAAkB,CAAEM,QAAF,EAAYM,OAAZ,KAAyB;AACjD,QAAKN,QAAL,EAAgB;AACfL,MAAAA,cAAc,CAAEW,OAAF,CAAd,CAA0B3B,OAA1B,CAAqCY,IAAF,IAAY;AAC9C,cAAMgB,UAAU,GAAG3B,GAAG,CAAEuB,wBAAF,EAA4BZ,IAA5B,CAAtB;;AACA,YAAKgB,UAAL,EAAkB;AACjBF,UAAAA,WAAW,GAAG,EACb,GAAGA,WADU;AAEbD,YAAAA,UAAU,EAAEd,YAAY,CACvBe,WAAW,CAACD,UADW,EAEvBb,IAFuB,EAGvBgB,UAHuB;AAFX,WAAd;AAQA;AACD,OAZD;AAaA;AACD,GAhBM,CAAP;AAiBA,SAAOF,WAAP;AACA","sourcesContent":["/**\n * External dependencies\n */\nimport {\n\tpickBy,\n\tisEmpty,\n\tisObject,\n\tidentity,\n\tmapValues,\n\tforEach,\n\tget,\n\tsetWith,\n\tclone,\n\tevery,\n} from 'lodash';\n\n/**\n * Removed falsy values from nested object.\n *\n * @param {*} object\n * @return {*} Object cleaned from falsy values\n */\nexport const cleanEmptyObject = ( object ) => {\n\tif ( ! isObject( object ) || Array.isArray( object ) ) {\n\t\treturn object;\n\t}\n\tconst cleanedNestedObjects = pickBy(\n\t\tmapValues( object, cleanEmptyObject ),\n\t\tidentity\n\t);\n\treturn isEmpty( cleanedNestedObjects ) ? undefined : cleanedNestedObjects;\n};\n\nexport function immutableSet( object, path, value ) {\n\treturn setWith( object ? clone( object ) : {}, path, value, clone );\n}\n\nexport function transformStyles(\n\tactiveSupports,\n\tmigrationPaths,\n\tresult,\n\tsource,\n\tindex,\n\tresults\n) {\n\t// If there are no active supports return early.\n\tif ( every( activeSupports, ( isActive ) => ! isActive ) ) {\n\t\treturn result;\n\t}\n\t// If the condition verifies we are probably in the presence of a wrapping transform\n\t// e.g: nesting paragraphs in a group or columns and in that case the styles should not be transformed.\n\tif ( results.length === 1 && result.innerBlocks.length === source.length ) {\n\t\treturn result;\n\t}\n\t// For cases where we have a transform from one block to multiple blocks\n\t// or multiple blocks to one block we apply the styles of the first source block\n\t// to the result(s).\n\tlet referenceBlockAttributes = source[ 0 ]?.attributes;\n\t// If we are in presence of transform between more than one block in the source\n\t// that has more than one block in the result\n\t// we apply the styles on source N to the result N,\n\t// if source N does not exists we do nothing.\n\tif ( results.length > 1 && source.length > 1 ) {\n\t\tif ( source[ index ] ) {\n\t\t\treferenceBlockAttributes = source[ index ]?.attributes;\n\t\t} else {\n\t\t\treturn result;\n\t\t}\n\t}\n\tlet returnBlock = result;\n\tforEach( activeSupports, ( isActive, support ) => {\n\t\tif ( isActive ) {\n\t\t\tmigrationPaths[ support ].forEach( ( path ) => {\n\t\t\t\tconst styleValue = get( referenceBlockAttributes, path );\n\t\t\t\tif ( styleValue ) {\n\t\t\t\t\treturnBlock = {\n\t\t\t\t\t\t...returnBlock,\n\t\t\t\t\t\tattributes: immutableSet(\n\t\t\t\t\t\t\treturnBlock.attributes,\n\t\t\t\t\t\t\tpath,\n\t\t\t\t\t\t\tstyleValue\n\t\t\t\t\t\t),\n\t\t\t\t\t};\n\t\t\t\t}\n\t\t\t} );\n\t\t}\n\t} );\n\treturn returnBlock;\n}\n"]}
@@ -2533,16 +2533,10 @@
2533
2533
  * Position spinner to the left of the actions.
2534
2534
  *
2535
2535
  * Compensate for:
2536
- * - Input margin ($grid-unit-20)
2537
- * - Border (1px)
2538
- * - Vertically, for the difference in height between the input (40px)
2539
- * and the spinner.
2540
- * - Horizontally, adjust for the width occupied by the icon buttons,
2541
- * then artificially create spacing that mimics as if the spinner
2542
- * were center-padded to the same width as an icon button.
2536
+ * - Input padding right ($button-size)
2543
2537
  */
2544
- top: 28px;
2545
- left: 62px;
2538
+ top: calc(50% - 16px / 2);
2539
+ left: 36px;
2546
2540
  }
2547
2541
 
2548
2542
  .block-editor-link-control__search-item-action {
@@ -3600,6 +3594,74 @@ figcaption.block-editor-rich-text__editable [data-rich-text-placeholder]::before
3600
3594
  grid-column: span 1;
3601
3595
  }
3602
3596
 
3597
+ .color-block-support-panel {
3598
+ /* Increased specificity required to remove the slot wrapper's row gap */
3599
+ /**
3600
+ * The following styles replicate the separated border of the
3601
+ * `ItemGroup` component but allows for hidden items. This is because
3602
+ * to maintain the order of `ToolsPanel` controls, each `ToolsPanelItem`
3603
+ * must at least render a placeholder which would otherwise interfere
3604
+ * with the `:last-child` styles.
3605
+ */
3606
+ /**
3607
+ * The following few styles fix the layout and spacing for the due to the
3608
+ * introduced wrapper element by the `Item` component.
3609
+ */
3610
+ }
3611
+ .color-block-support-panel .block-editor-contrast-checker {
3612
+ /**
3613
+ * Contrast checkers are forced to the bottom of the panel so all
3614
+ * injected color controls can appear as a single item group without
3615
+ * the contrast checkers suddenly appearing between items.
3616
+ */
3617
+ order: 9999;
3618
+ grid-column: span 2;
3619
+ margin-top: 16px;
3620
+ }
3621
+ .color-block-support-panel .block-editor-contrast-checker .components-notice__content {
3622
+ margin-left: 0;
3623
+ }
3624
+ .color-block-support-panel.color-block-support-panel .color-block-support-panel__inner-wrapper {
3625
+ row-gap: 0;
3626
+ }
3627
+ .color-block-support-panel .block-editor-tools-panel-color-gradient-settings__item {
3628
+ padding: 0;
3629
+ border-right: 1px solid rgba(0, 0, 0, 0.1);
3630
+ border-left: 1px solid rgba(0, 0, 0, 0.1);
3631
+ border-bottom: 1px solid rgba(0, 0, 0, 0.1);
3632
+ }
3633
+ .color-block-support-panel .block-editor-tools-panel-color-gradient-settings__item.first {
3634
+ border-top-right-radius: 2px;
3635
+ border-top-left-radius: 2px;
3636
+ border-top: 1px solid rgba(0, 0, 0, 0.1);
3637
+ }
3638
+ .color-block-support-panel .block-editor-tools-panel-color-gradient-settings__item.last {
3639
+ border-bottom-right-radius: 2px;
3640
+ border-bottom-left-radius: 2px;
3641
+ }
3642
+ .color-block-support-panel .block-editor-tools-panel-color-gradient-settings__item > div,
3643
+ .color-block-support-panel .block-editor-tools-panel-color-gradient-settings__item > div > button {
3644
+ border-radius: inherit;
3645
+ }
3646
+ .color-block-support-panel .block-editor-panel-color-gradient-settings__color-indicator {
3647
+ background: linear-gradient(45deg, transparent 48%, #ddd 48%, #ddd 52%, transparent 52%);
3648
+ }
3649
+ .color-block-support-panel .block-editor-tools-panel-color-dropdown {
3650
+ display: block;
3651
+ padding: 0;
3652
+ }
3653
+ .color-block-support-panel .block-editor-tools-panel-color-dropdown > button {
3654
+ height: 46px;
3655
+ }
3656
+ .color-block-support-panel .block-editor-tools-panel-color-dropdown > button.is-open {
3657
+ background: #f0f0f0;
3658
+ color: var(--wp-admin-theme-color);
3659
+ }
3660
+ .color-block-support-panel .color-block-support-panel__item-group > div {
3661
+ grid-column: span 2;
3662
+ border-radius: inherit;
3663
+ }
3664
+
3603
3665
  /**
3604
3666
  * Block Toolbar
3605
3667
  */
@@ -2533,16 +2533,10 @@
2533
2533
  * Position spinner to the left of the actions.
2534
2534
  *
2535
2535
  * Compensate for:
2536
- * - Input margin ($grid-unit-20)
2537
- * - Border (1px)
2538
- * - Vertically, for the difference in height between the input (40px)
2539
- * and the spinner.
2540
- * - Horizontally, adjust for the width occupied by the icon buttons,
2541
- * then artificially create spacing that mimics as if the spinner
2542
- * were center-padded to the same width as an icon button.
2536
+ * - Input padding right ($button-size)
2543
2537
  */
2544
- top: 28px;
2545
- right: 62px;
2538
+ top: calc(50% - 16px / 2);
2539
+ right: 36px;
2546
2540
  }
2547
2541
 
2548
2542
  .block-editor-link-control__search-item-action {
@@ -3600,6 +3594,74 @@ figcaption.block-editor-rich-text__editable [data-rich-text-placeholder]::before
3600
3594
  grid-column: span 1;
3601
3595
  }
3602
3596
 
3597
+ .color-block-support-panel {
3598
+ /* Increased specificity required to remove the slot wrapper's row gap */
3599
+ /**
3600
+ * The following styles replicate the separated border of the
3601
+ * `ItemGroup` component but allows for hidden items. This is because
3602
+ * to maintain the order of `ToolsPanel` controls, each `ToolsPanelItem`
3603
+ * must at least render a placeholder which would otherwise interfere
3604
+ * with the `:last-child` styles.
3605
+ */
3606
+ /**
3607
+ * The following few styles fix the layout and spacing for the due to the
3608
+ * introduced wrapper element by the `Item` component.
3609
+ */
3610
+ }
3611
+ .color-block-support-panel .block-editor-contrast-checker {
3612
+ /**
3613
+ * Contrast checkers are forced to the bottom of the panel so all
3614
+ * injected color controls can appear as a single item group without
3615
+ * the contrast checkers suddenly appearing between items.
3616
+ */
3617
+ order: 9999;
3618
+ grid-column: span 2;
3619
+ margin-top: 16px;
3620
+ }
3621
+ .color-block-support-panel .block-editor-contrast-checker .components-notice__content {
3622
+ margin-right: 0;
3623
+ }
3624
+ .color-block-support-panel.color-block-support-panel .color-block-support-panel__inner-wrapper {
3625
+ row-gap: 0;
3626
+ }
3627
+ .color-block-support-panel .block-editor-tools-panel-color-gradient-settings__item {
3628
+ padding: 0;
3629
+ border-left: 1px solid rgba(0, 0, 0, 0.1);
3630
+ border-right: 1px solid rgba(0, 0, 0, 0.1);
3631
+ border-bottom: 1px solid rgba(0, 0, 0, 0.1);
3632
+ }
3633
+ .color-block-support-panel .block-editor-tools-panel-color-gradient-settings__item.first {
3634
+ border-top-left-radius: 2px;
3635
+ border-top-right-radius: 2px;
3636
+ border-top: 1px solid rgba(0, 0, 0, 0.1);
3637
+ }
3638
+ .color-block-support-panel .block-editor-tools-panel-color-gradient-settings__item.last {
3639
+ border-bottom-left-radius: 2px;
3640
+ border-bottom-right-radius: 2px;
3641
+ }
3642
+ .color-block-support-panel .block-editor-tools-panel-color-gradient-settings__item > div,
3643
+ .color-block-support-panel .block-editor-tools-panel-color-gradient-settings__item > div > button {
3644
+ border-radius: inherit;
3645
+ }
3646
+ .color-block-support-panel .block-editor-panel-color-gradient-settings__color-indicator {
3647
+ background: linear-gradient(-45deg, transparent 48%, #ddd 48%, #ddd 52%, transparent 52%);
3648
+ }
3649
+ .color-block-support-panel .block-editor-tools-panel-color-dropdown {
3650
+ display: block;
3651
+ padding: 0;
3652
+ }
3653
+ .color-block-support-panel .block-editor-tools-panel-color-dropdown > button {
3654
+ height: 46px;
3655
+ }
3656
+ .color-block-support-panel .block-editor-tools-panel-color-dropdown > button.is-open {
3657
+ background: #f0f0f0;
3658
+ color: var(--wp-admin-theme-color);
3659
+ }
3660
+ .color-block-support-panel .color-block-support-panel__item-group > div {
3661
+ grid-column: span 2;
3662
+ border-radius: inherit;
3663
+ }
3664
+
3603
3665
  /**
3604
3666
  * Block Toolbar
3605
3667
  */
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@wordpress/block-editor",
3
- "version": "8.1.0",
3
+ "version": "8.1.2",
4
4
  "description": "Generic block editor.",
5
5
  "author": "The WordPress Contributors",
6
6
  "license": "GPL-2.0-or-later",
@@ -33,42 +33,38 @@
33
33
  "dependencies": {
34
34
  "@babel/runtime": "^7.16.0",
35
35
  "@react-spring/web": "^9.2.4",
36
- "@wordpress/a11y": "^3.3.0",
37
- "@wordpress/api-fetch": "^6.0.0",
38
- "@wordpress/blob": "^3.3.0",
39
- "@wordpress/block-serialization-default-parser": "^4.3.0",
40
- "@wordpress/blocks": "^11.2.0",
41
- "@wordpress/components": "^19.3.0",
42
- "@wordpress/compose": "^5.1.0",
43
- "@wordpress/data": "^6.2.0",
44
- "@wordpress/deprecated": "^3.3.0",
45
- "@wordpress/dom": "^3.3.0",
46
- "@wordpress/element": "^4.1.0",
47
- "@wordpress/hooks": "^3.3.0",
48
- "@wordpress/html-entities": "^3.3.0",
49
- "@wordpress/i18n": "^4.3.0",
50
- "@wordpress/icons": "^6.2.0",
51
- "@wordpress/is-shallow-equal": "^4.3.0",
52
- "@wordpress/keyboard-shortcuts": "^3.1.0",
53
- "@wordpress/keycodes": "^3.3.0",
54
- "@wordpress/notices": "^3.3.0",
55
- "@wordpress/rich-text": "^5.1.0",
56
- "@wordpress/shortcode": "^3.3.0",
57
- "@wordpress/token-list": "^2.3.0",
58
- "@wordpress/url": "^3.4.0",
59
- "@wordpress/warning": "^2.3.0",
60
- "@wordpress/wordcount": "^3.3.0",
36
+ "@wordpress/a11y": "^3.3.1",
37
+ "@wordpress/api-fetch": "^6.0.1",
38
+ "@wordpress/blob": "^3.3.1",
39
+ "@wordpress/blocks": "^11.2.1",
40
+ "@wordpress/components": "^19.4.1",
41
+ "@wordpress/compose": "^5.1.1",
42
+ "@wordpress/data": "^6.2.1",
43
+ "@wordpress/deprecated": "^3.3.1",
44
+ "@wordpress/dom": "^3.3.1",
45
+ "@wordpress/element": "^4.1.1",
46
+ "@wordpress/hooks": "^3.3.1",
47
+ "@wordpress/html-entities": "^3.3.1",
48
+ "@wordpress/i18n": "^4.3.1",
49
+ "@wordpress/icons": "^7.0.0",
50
+ "@wordpress/is-shallow-equal": "^4.3.1",
51
+ "@wordpress/keyboard-shortcuts": "^3.1.1",
52
+ "@wordpress/keycodes": "^3.3.1",
53
+ "@wordpress/notices": "^3.3.1",
54
+ "@wordpress/rich-text": "^5.1.1",
55
+ "@wordpress/shortcode": "^3.3.1",
56
+ "@wordpress/token-list": "^2.3.1",
57
+ "@wordpress/url": "^3.4.1",
58
+ "@wordpress/warning": "^2.3.1",
59
+ "@wordpress/wordcount": "^3.3.1",
61
60
  "classnames": "^2.3.1",
62
61
  "colord": "^2.7.0",
63
- "css-mediaquery": "^0.1.2",
64
62
  "diff": "^4.0.2",
65
63
  "dom-scroll-into-view": "^1.2.1",
66
64
  "inherits": "^2.0.3",
67
65
  "lodash": "^4.17.21",
68
- "memize": "^1.1.0",
69
66
  "react-autosize-textarea": "^7.1.0",
70
67
  "react-easy-crop": "^3.0.0",
71
- "redux-multi": "^0.1.12",
72
68
  "rememo": "^3.0.0",
73
69
  "traverse": "^0.6.6"
74
70
  },
@@ -79,5 +75,5 @@
79
75
  "publishConfig": {
80
76
  "access": "public"
81
77
  },
82
- "gitHead": "d95ccb9366e249133cdb1d7b25c382446b9ee502"
78
+ "gitHead": "0f838547f37472e46e6d5a9d2e84b6c61f4bd3f0"
83
79
  }
@@ -67,6 +67,10 @@ const BlockInspector = ( { showNoBlockSelectedMessage = true } ) => {
67
67
  <div className="block-editor-block-inspector">
68
68
  <MultiSelectionInspector />
69
69
  <InspectorControls.Slot />
70
+ <InspectorControls.Slot
71
+ __experimentalGroup="color"
72
+ label={ __( 'Color' ) }
73
+ />
70
74
  <InspectorControls.Slot
71
75
  __experimentalGroup="typography"
72
76
  label={ __( 'Typography' ) }
@@ -139,6 +143,11 @@ const BlockInspectorSingleBlock = ( {
139
143
  </div>
140
144
  ) }
141
145
  <InspectorControls.Slot />
146
+ <InspectorControls.Slot
147
+ __experimentalGroup="color"
148
+ label={ __( 'Color' ) }
149
+ className="color-block-support-panel__inner-wrapper"
150
+ />
142
151
  <InspectorControls.Slot
143
152
  __experimentalGroup="typography"
144
153
  label={ __( 'Typography' ) }
@@ -84,6 +84,9 @@ function AutoBlockPreview( { viewportWidth, __experimentalPadding } ) {
84
84
  documentElement.style.width = '100%';
85
85
  bodyElement.style.padding =
86
86
  __experimentalPadding + 'px';
87
+
88
+ // necessary for contentResizeListener to work.
89
+ bodyElement.style.position = 'relative';
87
90
  }, [] ) }
88
91
  aria-hidden
89
92
  tabIndex={ -1 }
@@ -150,7 +150,6 @@ exports[`ColorPaletteControl matches the snapshot 1`] = `
150
150
  fill="#000"
151
151
  focusable={false}
152
152
  height={24}
153
- role="img"
154
153
  viewBox="0 0 24 24"
155
154
  width={24}
156
155
  xmlns="http://www.w3.org/2000/svg"
@@ -0,0 +1,85 @@
1
+ /**
2
+ * External dependencies
3
+ */
4
+ import classnames from 'classnames';
5
+
6
+ /**
7
+ * WordPress dependencies
8
+ */
9
+ import {
10
+ Button,
11
+ ColorIndicator,
12
+ Dropdown,
13
+ FlexItem,
14
+ __experimentalHStack as HStack,
15
+ __experimentalToolsPanelItem as ToolsPanelItem,
16
+ } from '@wordpress/components';
17
+
18
+ /**
19
+ * Internal dependencies
20
+ */
21
+ import ColorGradientControl from './control';
22
+ import useMultipleOriginColorsAndGradients from './use-multiple-origin-colors-and-gradients';
23
+
24
+ export default function ToolsPanelColorDropdown( {
25
+ settings,
26
+ enableAlpha,
27
+ ...otherProps
28
+ } ) {
29
+ const colorGradientSettings = useMultipleOriginColorsAndGradients();
30
+ const controlSettings = {
31
+ ...colorGradientSettings,
32
+ clearable: false,
33
+ enableAlpha,
34
+ label: settings.label,
35
+ onColorChange: settings.onColorChange,
36
+ onGradientChange: settings.onGradientChange,
37
+ colorValue: settings.colorValue,
38
+ gradientValue: settings.gradientValue,
39
+ };
40
+ const selectedColor = settings.gradientValue ?? settings.colorValue;
41
+
42
+ return (
43
+ <ToolsPanelItem
44
+ hasValue={ settings.hasValue }
45
+ label={ settings.label }
46
+ onDeselect={ settings.onDeselect }
47
+ isShownByDefault={ settings.isShownByDefault }
48
+ resetAllFilter={ settings.resetAllFilter }
49
+ { ...otherProps }
50
+ className="block-editor-tools-panel-color-gradient-settings__item"
51
+ >
52
+ <Dropdown
53
+ className="block-editor-tools-panel-color-dropdown"
54
+ contentClassName="block-editor-panel-color-gradient-settings__dropdown-content"
55
+ renderToggle={ ( { isOpen, onToggle } ) => (
56
+ <Button
57
+ onClick={ onToggle }
58
+ aria-expanded={ isOpen }
59
+ className={ classnames(
60
+ 'block-editor-panel-color-gradient-settings__dropdown',
61
+ { 'is-open': isOpen }
62
+ ) }
63
+ >
64
+ <HStack justify="flex-start">
65
+ <ColorIndicator
66
+ className="block-editor-panel-color-gradient-settings__color-indicator"
67
+ colorValue={ selectedColor }
68
+ />
69
+ <FlexItem>{ settings.label }</FlexItem>
70
+ </HStack>
71
+ </Button>
72
+ ) }
73
+ renderContent={ () => (
74
+ <ColorGradientControl
75
+ showTitle={ false }
76
+ __experimentalHasMultipleOrigins
77
+ __experimentalIsRenderedInSidebar
78
+ enableAlpha
79
+ { ...controlSettings }
80
+ />
81
+ ) }
82
+ />
83
+ </ToolsPanelItem>
84
+ );
85
+ }
@@ -1,125 +1,140 @@
1
1
  /**
2
2
  * External dependencies
3
3
  */
4
- import { colord, extend } from 'colord';
5
- import namesPlugin from 'colord/plugins/names';
6
4
  import a11yPlugin from 'colord/plugins/a11y';
5
+ import namesPlugin from 'colord/plugins/names';
6
+ import { colord, extend } from 'colord';
7
7
 
8
8
  /**
9
9
  * WordPress dependencies
10
10
  */
11
- import { speak } from '@wordpress/a11y';
12
- import { __ } from '@wordpress/i18n';
11
+ import { __, sprintf } from '@wordpress/i18n';
13
12
  import { Notice } from '@wordpress/components';
14
- import { useEffect } from '@wordpress/element';
13
+ import { speak } from '@wordpress/a11y';
15
14
 
16
15
  extend( [ namesPlugin, a11yPlugin ] );
17
16
 
18
- function ContrastCheckerMessage( {
19
- colordBackgroundColor,
20
- colordTextColor,
21
- backgroundColor,
22
- textColor,
23
- shouldShowTransparencyWarning,
24
- } ) {
25
- let msg = '';
26
- if ( shouldShowTransparencyWarning ) {
27
- msg = __( 'Transparent text may be hard for people to read.' );
28
- } else {
29
- msg =
30
- colordBackgroundColor.brightness() < colordTextColor.brightness()
31
- ? __(
32
- 'This color combination may be hard for people to read. Try using a darker background color and/or a brighter text color.'
33
- )
34
- : __(
35
- 'This color combination may be hard for people to read. Try using a brighter background color and/or a darker text color.'
36
- );
37
- }
38
-
39
- // Note: The `Notice` component can speak messages via its `spokenMessage`
40
- // prop, but the contrast checker requires granular control over when the
41
- // announcements are made. Notably, the message will be re-announced if a
42
- // new color combination is selected and the contrast is still insufficient.
43
- useEffect( () => {
44
- const speakMsg = shouldShowTransparencyWarning
45
- ? __( 'Transparent text may be hard for people to read.' )
46
- : __( 'This color combination may be hard for people to read.' );
47
- speak( speakMsg );
48
- }, [ backgroundColor, textColor ] );
49
-
50
- return (
51
- <div className="block-editor-contrast-checker">
52
- <Notice
53
- spokenMessage={ null }
54
- status="warning"
55
- isDismissible={ false }
56
- >
57
- { msg }
58
- </Notice>
59
- </div>
60
- );
61
- }
62
-
63
17
  function ContrastChecker( {
64
18
  backgroundColor,
65
19
  fallbackBackgroundColor,
66
20
  fallbackTextColor,
21
+ fallbackLinkColor,
67
22
  fontSize, // font size value in pixels
68
23
  isLargeText,
69
24
  textColor,
25
+ linkColor,
70
26
  enableAlphaChecker = false,
71
27
  } ) {
72
- if (
73
- ! ( backgroundColor || fallbackBackgroundColor ) ||
74
- ! ( textColor || fallbackTextColor )
75
- ) {
28
+ const currentBackgroundColor = backgroundColor || fallbackBackgroundColor;
29
+
30
+ // Must have a background color.
31
+ if ( ! currentBackgroundColor ) {
76
32
  return null;
77
33
  }
78
- const colordBackgroundColor = colord(
79
- backgroundColor || fallbackBackgroundColor
80
- );
81
- const colordTextColor = colord( textColor || fallbackTextColor );
82
- const textColorHasTransparency = colordTextColor.alpha() < 1;
34
+
35
+ const currentTextColor = textColor || fallbackTextColor;
36
+ const currentLinkColor = linkColor || fallbackLinkColor;
37
+
38
+ // Must have at least one text color.
39
+ if ( ! currentTextColor && ! currentLinkColor ) {
40
+ return null;
41
+ }
42
+
43
+ const textColors = [
44
+ {
45
+ color: currentTextColor,
46
+ description: __( 'text color' ),
47
+ },
48
+ {
49
+ color: currentLinkColor,
50
+ description: __( 'link color' ),
51
+ },
52
+ ];
53
+ const colordBackgroundColor = colord( currentBackgroundColor );
83
54
  const backgroundColorHasTransparency = colordBackgroundColor.alpha() < 1;
84
- const hasTransparency =
85
- textColorHasTransparency || backgroundColorHasTransparency;
86
- const isReadable = colordTextColor.isReadable( colordBackgroundColor, {
55
+ const backgroundColorBrightness = colordBackgroundColor.brightness();
56
+ const isReadableOptions = {
87
57
  level: 'AA',
88
58
  size:
89
59
  isLargeText || ( isLargeText !== false && fontSize >= 24 )
90
60
  ? 'large'
91
61
  : 'small',
92
- } );
62
+ };
93
63
 
94
- // Don't show the message if the text is readable AND there's no transparency.
95
- // This is the default.
96
- if ( isReadable && ! hasTransparency ) {
97
- return null;
98
- }
64
+ let message = '';
65
+ let speakMessage = '';
66
+ for ( const item of textColors ) {
67
+ // If there is no color, go no further.
68
+ if ( ! item.color ) {
69
+ continue;
70
+ }
71
+ const colordTextColor = colord( item.color );
72
+ const isColordTextReadable = colordTextColor.isReadable(
73
+ colordBackgroundColor,
74
+ isReadableOptions
75
+ );
76
+ const textHasTransparency = colordTextColor.alpha() < 1;
77
+
78
+ // If the contrast is not readable.
79
+ if ( ! isColordTextReadable ) {
80
+ // Don't show the message if the background or text is transparent.
81
+ if ( backgroundColorHasTransparency || textHasTransparency ) {
82
+ continue;
83
+ }
84
+ message =
85
+ backgroundColorBrightness < colordTextColor.brightness()
86
+ ? sprintf(
87
+ // translators: %s is a type of text color, e.g., "text color" or "link color"
88
+ __(
89
+ 'This color combination may be hard for people to read. Try using a darker background color and/or a brighter %s.'
90
+ ),
91
+ item.description
92
+ )
93
+ : sprintf(
94
+ // translators: %s is a type of text color, e.g., "text color" or "link color"
95
+ __(
96
+ 'This color combination may be hard for people to read. Try using a brighter background color and/or a darker %s.'
97
+ ),
98
+ item.description
99
+ );
100
+ speakMessage = __(
101
+ 'This color combination may be hard for people to read.'
102
+ );
103
+ // Break from the loop when we have a contrast warning.
104
+ // These messages take priority over the transparency warning.
105
+ break;
106
+ }
99
107
 
100
- if ( hasTransparency ) {
101
- if (
102
- // If there's transparency, don't show the message if the alpha checker is disabled.
103
- ! enableAlphaChecker ||
104
- // If the alpha checker is enabled, we only show the warning if the text has transparency.
105
- ( isReadable && ! textColorHasTransparency )
106
- ) {
107
- return null;
108
+ // If there is no contrast warning and the text is transparent,
109
+ // show the transparent warning if alpha check is enabled.
110
+ if ( textHasTransparency && enableAlphaChecker ) {
111
+ message = __( 'Transparent text may be hard for people to read.' );
112
+ speakMessage = __(
113
+ 'Transparent text may be hard for people to read.'
114
+ );
108
115
  }
109
116
  }
110
117
 
118
+ if ( ! message ) {
119
+ return null;
120
+ }
121
+
122
+ // Note: The `Notice` component can speak messages via its `spokenMessage`
123
+ // prop, but the contrast checker requires granular control over when the
124
+ // announcements are made. Notably, the message will be re-announced if a
125
+ // new color combination is selected and the contrast is still insufficient.
126
+ speak( speakMessage );
127
+
111
128
  return (
112
- <ContrastCheckerMessage
113
- backgroundColor={ backgroundColor }
114
- textColor={ textColor }
115
- colordBackgroundColor={ colordBackgroundColor }
116
- colordTextColor={ colordTextColor }
117
- // Flag to warn about transparency only if the text is otherwise readable according to colord
118
- // to ensure the readability warnings take precedence.
119
- shouldShowTransparencyWarning={
120
- isReadable && textColorHasTransparency
121
- }
122
- />
129
+ <div className="block-editor-contrast-checker">
130
+ <Notice
131
+ spokenMessage={ null }
132
+ status="warning"
133
+ isDismissible={ false }
134
+ >
135
+ { message }
136
+ </Notice>
137
+ </div>
123
138
  );
124
139
  }
125
140