@wordpress/block-editor 8.0.13 → 8.1.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.
Files changed (441) hide show
  1. package/CHANGELOG.md +2 -0
  2. package/LICENSE.md +1 -1
  3. package/README.md +12 -1
  4. package/build/components/block-caption/index.native.js +14 -3
  5. package/build/components/block-caption/index.native.js.map +1 -1
  6. package/build/components/block-edit/index.js +9 -0
  7. package/build/components/block-edit/index.js.map +1 -1
  8. package/build/components/block-inspector/index.js +8 -20
  9. package/build/components/block-inspector/index.js.map +1 -1
  10. package/build/components/block-list-appender/index.js +3 -11
  11. package/build/components/block-list-appender/index.js.map +1 -1
  12. package/build/components/block-media-update-progress/index.native.js +2 -1
  13. package/build/components/block-media-update-progress/index.native.js.map +1 -1
  14. package/build/components/block-preview/auto.js +30 -6
  15. package/build/components/block-preview/auto.js.map +1 -1
  16. package/build/components/block-settings/container.native.js +2 -1
  17. package/build/components/block-settings/container.native.js.map +1 -1
  18. package/build/components/block-styles/index.js +110 -134
  19. package/build/components/block-styles/index.js.map +1 -1
  20. package/build/components/block-styles/menu-items.js +63 -0
  21. package/build/components/block-styles/menu-items.js.map +1 -0
  22. package/build/components/block-styles/preview-panel.js +45 -0
  23. package/build/components/block-styles/preview-panel.js.map +1 -0
  24. package/build/components/block-styles/preview.native.js +2 -2
  25. package/build/components/block-styles/preview.native.js.map +1 -1
  26. package/build/components/block-styles/use-styles-for-block.js +119 -0
  27. package/build/components/block-styles/use-styles-for-block.js.map +1 -0
  28. package/build/components/block-styles/utils.js +39 -0
  29. package/build/components/block-styles/utils.js.map +1 -1
  30. package/build/components/block-switcher/block-styles-menu.js +3 -23
  31. package/build/components/block-switcher/block-styles-menu.js.map +1 -1
  32. package/build/components/block-tools/back-compat.js +2 -1
  33. package/build/components/block-tools/back-compat.js.map +1 -1
  34. package/build/components/block-tools/block-selection-button.js +5 -1
  35. package/build/components/block-tools/block-selection-button.js.map +1 -1
  36. package/build/components/block-tools/insertion-point.js +11 -1
  37. package/build/components/block-tools/insertion-point.js.map +1 -1
  38. package/build/components/block-types-list/index.native.js +2 -2
  39. package/build/components/block-types-list/index.native.js.map +1 -1
  40. package/build/components/button-block-appender/index.js +2 -1
  41. package/build/components/button-block-appender/index.js.map +1 -1
  42. package/build/components/colors-gradients/dropdown.js +88 -0
  43. package/build/components/colors-gradients/dropdown.js.map +1 -0
  44. package/build/components/colors-gradients/panel-color-gradient-settings.js +6 -5
  45. package/build/components/colors-gradients/panel-color-gradient-settings.js.map +1 -1
  46. package/build/components/colors-gradients/panel-color-gradient-settings.native.js +6 -3
  47. package/build/components/colors-gradients/panel-color-gradient-settings.native.js.map +1 -1
  48. package/build/components/contrast-checker/index.js +34 -9
  49. package/build/components/contrast-checker/index.js.map +1 -1
  50. package/build/components/contrast-checker/index.native.js +108 -0
  51. package/build/components/contrast-checker/index.native.js.map +1 -0
  52. package/build/components/default-block-appender/index.js +16 -19
  53. package/build/components/default-block-appender/index.js.map +1 -1
  54. package/build/components/default-style-picker/index.js +18 -3
  55. package/build/components/default-style-picker/index.js.map +1 -1
  56. package/build/components/font-appearance-control/index.js +11 -11
  57. package/build/components/font-appearance-control/index.js.map +1 -1
  58. package/build/components/iframe/index.js +6 -9
  59. package/build/components/iframe/index.js.map +1 -1
  60. package/build/components/index.js +18 -9
  61. package/build/components/index.js.map +1 -1
  62. package/build/components/index.native.js +9 -0
  63. package/build/components/index.native.js.map +1 -1
  64. package/build/components/inner-blocks/default-block-appender.js +2 -4
  65. package/build/components/inner-blocks/default-block-appender.js.map +1 -1
  66. package/build/components/inner-blocks/use-nested-settings-update.js +16 -14
  67. package/build/components/inner-blocks/use-nested-settings-update.js.map +1 -1
  68. package/build/components/inserter/index.js +61 -3
  69. package/build/components/inserter/index.js.map +1 -1
  70. package/build/components/inserter/index.native.js +1 -1
  71. package/build/components/inserter/index.native.js.map +1 -1
  72. package/build/components/inserter/library.js +5 -3
  73. package/build/components/inserter/library.js.map +1 -1
  74. package/build/components/inserter/menu.js +11 -3
  75. package/build/components/inserter/menu.js.map +1 -1
  76. package/build/components/inserter/tabs.native.js +7 -4
  77. package/build/components/inserter/tabs.native.js.map +1 -1
  78. package/build/components/inspector-controls/block-support-slot-container.js +2 -1
  79. package/build/components/inspector-controls/block-support-slot-container.js.map +1 -1
  80. package/build/components/inspector-controls/block-support-tools-panel.js +11 -43
  81. package/build/components/inspector-controls/block-support-tools-panel.js.map +1 -1
  82. package/build/components/inspector-controls/fill.native.js +3 -5
  83. package/build/components/inspector-controls/fill.native.js.map +1 -1
  84. package/build/components/inspector-controls/groups.js +2 -0
  85. package/build/components/inspector-controls/groups.js.map +1 -1
  86. package/build/components/inspector-controls/slot.js +1 -3
  87. package/build/components/inspector-controls/slot.js.map +1 -1
  88. package/build/components/letter-spacing-control/index.js +6 -6
  89. package/build/components/letter-spacing-control/index.js.map +1 -1
  90. package/build/components/link-control/link-preview.js +1 -1
  91. package/build/components/link-control/link-preview.js.map +1 -1
  92. package/build/components/link-control/search-item.js +11 -1
  93. package/build/components/link-control/search-item.js.map +1 -1
  94. package/build/components/link-control/search-results.js +2 -1
  95. package/build/components/link-control/search-results.js.map +1 -1
  96. package/build/components/link-control/use-search-handler.js +18 -5
  97. package/build/components/link-control/use-search-handler.js.map +1 -1
  98. package/build/components/list-view/block-select-button.js +23 -3
  99. package/build/components/list-view/block-select-button.js.map +1 -1
  100. package/build/components/list-view/block.js +8 -0
  101. package/build/components/list-view/block.js.map +1 -1
  102. package/build/components/media-placeholder/index.js +2 -0
  103. package/build/components/media-placeholder/index.js.map +1 -1
  104. package/build/components/media-replace-flow/index.js +32 -6
  105. package/build/components/media-replace-flow/index.js.map +1 -1
  106. package/build/components/media-upload-progress/index.native.js +2 -1
  107. package/build/components/media-upload-progress/index.native.js.map +1 -1
  108. package/build/components/panel-color-settings/index.js +7 -3
  109. package/build/components/panel-color-settings/index.js.map +1 -1
  110. package/build/components/provider/block-refs-provider.js +4 -1
  111. package/build/components/provider/block-refs-provider.js.map +1 -1
  112. package/build/components/rich-text/file-paste-handler.js +1 -1
  113. package/build/components/rich-text/file-paste-handler.js.map +1 -1
  114. package/build/components/rich-text/prevent-event-discovery.js +33 -0
  115. package/build/components/rich-text/prevent-event-discovery.js.map +1 -0
  116. package/build/components/rich-text/use-input-rules.js +3 -1
  117. package/build/components/rich-text/use-input-rules.js.map +1 -1
  118. package/build/components/selection-scroll-into-view/index.js +2 -1
  119. package/build/components/selection-scroll-into-view/index.js.map +1 -1
  120. package/build/components/use-display-block-controls/index.native.js +45 -0
  121. package/build/components/use-display-block-controls/index.native.js.map +1 -0
  122. package/build/components/use-on-block-drop/index.js +7 -3
  123. package/build/components/use-on-block-drop/index.js.map +1 -1
  124. package/build/components/writing-flow/use-multi-selection.js +3 -1
  125. package/build/components/writing-flow/use-multi-selection.js.map +1 -1
  126. package/build/hooks/border-color.js +74 -10
  127. package/build/hooks/border-color.js.map +1 -1
  128. package/build/hooks/border-radius.js +47 -0
  129. package/build/hooks/border-radius.js.map +1 -1
  130. package/build/hooks/border-style.js +41 -0
  131. package/build/hooks/border-style.js.map +1 -1
  132. package/build/hooks/border-width.js +70 -31
  133. package/build/hooks/border-width.js.map +1 -1
  134. package/build/hooks/border.js +81 -11
  135. package/build/hooks/border.js.map +1 -1
  136. package/build/hooks/color-panel.js +4 -1
  137. package/build/hooks/color-panel.js.map +1 -1
  138. package/build/hooks/color-panel.native.js +77 -0
  139. package/build/hooks/color-panel.native.js.map +1 -0
  140. package/build/hooks/color.js +6 -5
  141. package/build/hooks/color.js.map +1 -1
  142. package/build/hooks/index.native.js +2 -0
  143. package/build/hooks/index.native.js.map +1 -1
  144. package/build/hooks/layout.native.js +20 -0
  145. package/build/hooks/layout.native.js.map +1 -0
  146. package/build/hooks/letter-spacing.js +1 -1
  147. package/build/hooks/letter-spacing.js.map +1 -1
  148. package/build/hooks/typography.js +1 -1
  149. package/build/hooks/typography.js.map +1 -1
  150. package/build/store/actions.js +1 -2
  151. package/build/store/actions.js.map +1 -1
  152. package/build/store/defaults.js +5 -1
  153. package/build/store/defaults.js.map +1 -1
  154. package/build/store/defaults.native.js +2 -6
  155. package/build/store/defaults.native.js.map +1 -1
  156. package/build/store/selectors.js +10 -5
  157. package/build/store/selectors.js.map +1 -1
  158. package/build/utils/get-paste-event-data.js +1 -1
  159. package/build/utils/get-paste-event-data.js.map +1 -1
  160. package/build/utils/parse-css-unit-to-px.js +1 -1
  161. package/build/utils/parse-css-unit-to-px.js.map +1 -1
  162. package/build-module/components/block-caption/index.native.js +13 -3
  163. package/build-module/components/block-caption/index.native.js.map +1 -1
  164. package/build-module/components/block-edit/index.js +9 -0
  165. package/build-module/components/block-edit/index.js.map +1 -1
  166. package/build-module/components/block-inspector/index.js +8 -20
  167. package/build-module/components/block-inspector/index.js.map +1 -1
  168. package/build-module/components/block-list-appender/index.js +3 -10
  169. package/build-module/components/block-list-appender/index.js.map +1 -1
  170. package/build-module/components/block-media-update-progress/index.native.js +2 -1
  171. package/build-module/components/block-media-update-progress/index.native.js.map +1 -1
  172. package/build-module/components/block-preview/auto.js +31 -6
  173. package/build-module/components/block-preview/auto.js.map +1 -1
  174. package/build-module/components/block-settings/container.native.js +2 -1
  175. package/build-module/components/block-settings/container.native.js.map +1 -1
  176. package/build-module/components/block-styles/index.js +112 -133
  177. package/build-module/components/block-styles/index.js.map +1 -1
  178. package/build-module/components/block-styles/menu-items.js +50 -0
  179. package/build-module/components/block-styles/menu-items.js.map +1 -0
  180. package/build-module/components/block-styles/preview-panel.js +35 -0
  181. package/build-module/components/block-styles/preview-panel.js.map +1 -0
  182. package/build-module/components/block-styles/preview.native.js +2 -2
  183. package/build-module/components/block-styles/preview.native.js.map +1 -1
  184. package/build-module/components/block-styles/use-styles-for-block.js +107 -0
  185. package/build-module/components/block-styles/use-styles-for-block.js.map +1 -0
  186. package/build-module/components/block-styles/utils.js +34 -0
  187. package/build-module/components/block-styles/utils.js.map +1 -1
  188. package/build-module/components/block-switcher/block-styles-menu.js +3 -21
  189. package/build-module/components/block-switcher/block-styles-menu.js.map +1 -1
  190. package/build-module/components/block-tools/back-compat.js +2 -1
  191. package/build-module/components/block-tools/back-compat.js.map +1 -1
  192. package/build-module/components/block-tools/block-selection-button.js +5 -1
  193. package/build-module/components/block-tools/block-selection-button.js.map +1 -1
  194. package/build-module/components/block-tools/insertion-point.js +11 -1
  195. package/build-module/components/block-tools/insertion-point.js.map +1 -1
  196. package/build-module/components/block-types-list/index.native.js +2 -2
  197. package/build-module/components/block-types-list/index.native.js.map +1 -1
  198. package/build-module/components/button-block-appender/index.js +2 -1
  199. package/build-module/components/button-block-appender/index.js.map +1 -1
  200. package/build-module/components/colors-gradients/dropdown.js +75 -0
  201. package/build-module/components/colors-gradients/dropdown.js.map +1 -0
  202. package/build-module/components/colors-gradients/panel-color-gradient-settings.js +8 -7
  203. package/build-module/components/colors-gradients/panel-color-gradient-settings.js.map +1 -1
  204. package/build-module/components/colors-gradients/panel-color-gradient-settings.native.js +7 -4
  205. package/build-module/components/colors-gradients/panel-color-gradient-settings.native.js.map +1 -1
  206. package/build-module/components/contrast-checker/index.js +34 -9
  207. package/build-module/components/contrast-checker/index.js.map +1 -1
  208. package/build-module/components/contrast-checker/index.native.js +90 -0
  209. package/build-module/components/contrast-checker/index.native.js.map +1 -0
  210. package/build-module/components/default-block-appender/index.js +15 -18
  211. package/build-module/components/default-block-appender/index.js.map +1 -1
  212. package/build-module/components/default-style-picker/index.js +17 -3
  213. package/build-module/components/default-style-picker/index.js.map +1 -1
  214. package/build-module/components/font-appearance-control/index.js +12 -12
  215. package/build-module/components/font-appearance-control/index.js.map +1 -1
  216. package/build-module/components/iframe/index.js +6 -9
  217. package/build-module/components/iframe/index.js.map +1 -1
  218. package/build-module/components/index.js +2 -1
  219. package/build-module/components/index.js.map +1 -1
  220. package/build-module/components/index.native.js +1 -0
  221. package/build-module/components/index.native.js.map +1 -1
  222. package/build-module/components/inner-blocks/default-block-appender.js +2 -4
  223. package/build-module/components/inner-blocks/default-block-appender.js.map +1 -1
  224. package/build-module/components/inner-blocks/use-nested-settings-update.js +16 -14
  225. package/build-module/components/inner-blocks/use-nested-settings-update.js.map +1 -1
  226. package/build-module/components/inserter/index.js +61 -3
  227. package/build-module/components/inserter/index.js.map +1 -1
  228. package/build-module/components/inserter/index.native.js +2 -2
  229. package/build-module/components/inserter/index.native.js.map +1 -1
  230. package/build-module/components/inserter/library.js +5 -3
  231. package/build-module/components/inserter/library.js.map +1 -1
  232. package/build-module/components/inserter/menu.js +11 -4
  233. package/build-module/components/inserter/menu.js.map +1 -1
  234. package/build-module/components/inserter/tabs.native.js +7 -4
  235. package/build-module/components/inserter/tabs.native.js.map +1 -1
  236. package/build-module/components/inspector-controls/block-support-slot-container.js +2 -1
  237. package/build-module/components/inspector-controls/block-support-slot-container.js.map +1 -1
  238. package/build-module/components/inspector-controls/block-support-tools-panel.js +12 -43
  239. package/build-module/components/inspector-controls/block-support-tools-panel.js.map +1 -1
  240. package/build-module/components/inspector-controls/fill.native.js +3 -5
  241. package/build-module/components/inspector-controls/fill.native.js.map +1 -1
  242. package/build-module/components/inspector-controls/groups.js +2 -0
  243. package/build-module/components/inspector-controls/groups.js.map +1 -1
  244. package/build-module/components/inspector-controls/slot.js +1 -3
  245. package/build-module/components/inspector-controls/slot.js.map +1 -1
  246. package/build-module/components/letter-spacing-control/index.js +6 -6
  247. package/build-module/components/letter-spacing-control/index.js.map +1 -1
  248. package/build-module/components/link-control/link-preview.js +1 -1
  249. package/build-module/components/link-control/link-preview.js.map +1 -1
  250. package/build-module/components/link-control/search-item.js +11 -1
  251. package/build-module/components/link-control/search-item.js.map +1 -1
  252. package/build-module/components/link-control/search-results.js +2 -1
  253. package/build-module/components/link-control/search-results.js.map +1 -1
  254. package/build-module/components/link-control/use-search-handler.js +18 -5
  255. package/build-module/components/link-control/use-search-handler.js.map +1 -1
  256. package/build-module/components/list-view/block-select-button.js +22 -3
  257. package/build-module/components/list-view/block-select-button.js.map +1 -1
  258. package/build-module/components/list-view/block.js +6 -0
  259. package/build-module/components/list-view/block.js.map +1 -1
  260. package/build-module/components/media-placeholder/index.js +2 -0
  261. package/build-module/components/media-placeholder/index.js.map +1 -1
  262. package/build-module/components/media-replace-flow/index.js +32 -6
  263. package/build-module/components/media-replace-flow/index.js.map +1 -1
  264. package/build-module/components/media-upload-progress/index.native.js +2 -1
  265. package/build-module/components/media-upload-progress/index.native.js.map +1 -1
  266. package/build-module/components/panel-color-settings/index.js +7 -3
  267. package/build-module/components/panel-color-settings/index.js.map +1 -1
  268. package/build-module/components/provider/block-refs-provider.js +4 -1
  269. package/build-module/components/provider/block-refs-provider.js.map +1 -1
  270. package/build-module/components/rich-text/file-paste-handler.js +1 -1
  271. package/build-module/components/rich-text/file-paste-handler.js.map +1 -1
  272. package/build-module/components/rich-text/prevent-event-discovery.js +25 -0
  273. package/build-module/components/rich-text/prevent-event-discovery.js.map +1 -0
  274. package/build-module/components/rich-text/use-input-rules.js +2 -1
  275. package/build-module/components/rich-text/use-input-rules.js.map +1 -1
  276. package/build-module/components/selection-scroll-into-view/index.js +2 -1
  277. package/build-module/components/selection-scroll-into-view/index.js.map +1 -1
  278. package/build-module/components/use-display-block-controls/index.native.js +34 -0
  279. package/build-module/components/use-display-block-controls/index.native.js.map +1 -0
  280. package/build-module/components/use-on-block-drop/index.js +7 -3
  281. package/build-module/components/use-on-block-drop/index.js.map +1 -1
  282. package/build-module/components/writing-flow/use-multi-selection.js +3 -4
  283. package/build-module/components/writing-flow/use-multi-selection.js.map +1 -1
  284. package/build-module/hooks/border-color.js +72 -12
  285. package/build-module/hooks/border-color.js.map +1 -1
  286. package/build-module/hooks/border-radius.js +42 -0
  287. package/build-module/hooks/border-radius.js.map +1 -1
  288. package/build-module/hooks/border-style.js +36 -0
  289. package/build-module/hooks/border-style.js.map +1 -1
  290. package/build-module/hooks/border-width.js +66 -32
  291. package/build-module/hooks/border-width.js.map +1 -1
  292. package/build-module/hooks/border.js +80 -12
  293. package/build-module/hooks/border.js.map +1 -1
  294. package/build-module/hooks/color-panel.js +4 -1
  295. package/build-module/hooks/color-panel.js.map +1 -1
  296. package/build-module/hooks/color-panel.native.js +62 -0
  297. package/build-module/hooks/color-panel.native.js.map +1 -0
  298. package/build-module/hooks/color.js +6 -5
  299. package/build-module/hooks/color.js.map +1 -1
  300. package/build-module/hooks/index.native.js +1 -0
  301. package/build-module/hooks/index.native.js.map +1 -1
  302. package/build-module/hooks/layout.native.js +16 -0
  303. package/build-module/hooks/layout.native.js.map +1 -0
  304. package/build-module/hooks/letter-spacing.js +1 -1
  305. package/build-module/hooks/letter-spacing.js.map +1 -1
  306. package/build-module/hooks/typography.js +1 -1
  307. package/build-module/hooks/typography.js.map +1 -1
  308. package/build-module/store/actions.js +1 -2
  309. package/build-module/store/actions.js.map +1 -1
  310. package/build-module/store/defaults.js +5 -1
  311. package/build-module/store/defaults.js.map +1 -1
  312. package/build-module/store/defaults.native.js +2 -5
  313. package/build-module/store/defaults.native.js.map +1 -1
  314. package/build-module/store/selectors.js +10 -5
  315. package/build-module/store/selectors.js.map +1 -1
  316. package/build-module/utils/get-paste-event-data.js +1 -1
  317. package/build-module/utils/get-paste-event-data.js.map +1 -1
  318. package/build-module/utils/parse-css-unit-to-px.js +1 -1
  319. package/build-module/utils/parse-css-unit-to-px.js.map +1 -1
  320. package/build-style/style-rtl.css +226 -181
  321. package/build-style/style.css +226 -181
  322. package/package.json +31 -27
  323. package/src/components/block-caption/index.native.js +22 -4
  324. package/src/components/block-card/README.md +1 -1
  325. package/src/components/block-edit/index.js +8 -0
  326. package/src/components/block-edit/test/edit.native.js +10 -9
  327. package/src/components/block-inspector/index.js +9 -16
  328. package/src/components/block-list-appender/index.js +5 -21
  329. package/src/components/block-media-update-progress/index.native.js +1 -1
  330. package/src/components/block-media-update-progress/test/index.native.js +136 -93
  331. package/src/components/block-mover/test/__snapshots__/index.native.js.snap +108 -47
  332. package/src/components/block-mover/test/index.native.js +5 -5
  333. package/src/components/block-preview/README.md +14 -26
  334. package/src/components/block-preview/auto.js +33 -3
  335. package/src/components/block-preview/test/index.js +2 -0
  336. package/src/components/block-settings/container.native.js +1 -0
  337. package/src/components/block-styles/index.js +125 -145
  338. package/src/components/block-styles/menu-items.js +49 -0
  339. package/src/components/block-styles/preview-panel.js +36 -0
  340. package/src/components/block-styles/preview.native.js +5 -2
  341. package/src/components/block-styles/style.scss +59 -51
  342. package/src/components/block-styles/test/{index.js → utils.js} +60 -1
  343. package/src/components/block-styles/use-styles-for-block.js +99 -0
  344. package/src/components/block-styles/utils.js +39 -0
  345. package/src/components/block-switcher/block-styles-menu.js +3 -38
  346. package/src/components/block-tools/back-compat.js +1 -0
  347. package/src/components/block-tools/block-selection-button.js +7 -1
  348. package/src/components/block-tools/insertion-point.js +10 -1
  349. package/src/components/block-types-list/index.native.js +5 -2
  350. package/src/components/border-radius-control/style.scss +1 -1
  351. package/src/components/border-style-control/style.scss +0 -1
  352. package/src/components/button-block-appender/index.js +1 -0
  353. package/src/components/color-palette/test/__snapshots__/control.js.snap +9 -4
  354. package/src/components/colors-gradients/dropdown.js +96 -0
  355. package/src/components/colors-gradients/panel-color-gradient-settings.js +23 -19
  356. package/src/components/colors-gradients/panel-color-gradient-settings.native.js +13 -2
  357. package/src/components/colors-gradients/style.scss +59 -5
  358. package/src/components/contrast-checker/README.md +3 -1
  359. package/src/components/contrast-checker/index.js +48 -20
  360. package/src/components/contrast-checker/index.native.js +113 -0
  361. package/src/components/contrast-checker/style.native.scss +26 -0
  362. package/src/components/contrast-checker/test/index.js +65 -0
  363. package/src/components/default-block-appender/index.js +17 -24
  364. package/src/components/default-block-appender/style.scss +4 -0
  365. package/src/components/default-block-appender/test/__snapshots__/index.js.snap +12 -24
  366. package/src/components/default-block-appender/test/index.js +4 -14
  367. package/src/components/default-style-picker/index.js +18 -6
  368. package/src/components/font-appearance-control/index.js +12 -12
  369. package/src/components/iframe/index.js +10 -10
  370. package/src/components/index.js +2 -1
  371. package/src/components/index.native.js +1 -0
  372. package/src/components/inner-blocks/README.md +2 -0
  373. package/src/components/inner-blocks/default-block-appender.js +2 -7
  374. package/src/components/inner-blocks/use-nested-settings-update.js +16 -14
  375. package/src/components/inserter/index.js +77 -5
  376. package/src/components/inserter/index.native.js +2 -2
  377. package/src/components/inserter/library.js +17 -12
  378. package/src/components/inserter/menu.js +31 -13
  379. package/src/components/inserter/tabs.native.js +5 -4
  380. package/src/components/inserter/test/block-types-tab.native.js +9 -10
  381. package/src/components/inserter/test/index.native.js +3 -7
  382. package/src/components/inserter/test/reusable-blocks-tab.native.js +8 -10
  383. package/src/components/inspector-controls/block-support-slot-container.js +3 -1
  384. package/src/components/inspector-controls/block-support-tools-panel.js +39 -58
  385. package/src/components/inspector-controls/fill.native.js +4 -3
  386. package/src/components/inspector-controls/groups.js +2 -0
  387. package/src/components/inspector-controls/slot.js +2 -7
  388. package/src/components/letter-spacing-control/index.js +6 -6
  389. package/src/components/link-control/README.md +1 -1
  390. package/src/components/link-control/link-preview.js +1 -1
  391. package/src/components/link-control/search-item.js +11 -2
  392. package/src/components/link-control/search-results.js +1 -0
  393. package/src/components/link-control/style.scss +2 -1
  394. package/src/components/link-control/test/index.js +4 -0
  395. package/src/components/link-control/use-search-handler.js +25 -4
  396. package/src/components/list-view/block-select-button.js +20 -1
  397. package/src/components/list-view/block.js +10 -0
  398. package/src/components/media-placeholder/index.js +2 -0
  399. package/src/components/media-replace-flow/index.js +35 -5
  400. package/src/components/media-upload/test/index.native.js +28 -47
  401. package/src/components/media-upload-progress/index.native.js +1 -0
  402. package/src/components/media-upload-progress/test/index.native.js +60 -47
  403. package/src/components/panel-color-settings/index.js +8 -4
  404. package/src/components/provider/block-refs-provider.js +4 -1
  405. package/src/components/rich-text/file-paste-handler.js +3 -1
  406. package/src/components/rich-text/prevent-event-discovery.js +23 -0
  407. package/src/components/rich-text/use-input-rules.js +2 -1
  408. package/src/components/selection-scroll-into-view/index.js +1 -0
  409. package/src/components/url-input/README.md +5 -0
  410. package/src/components/use-display-block-controls/index.native.js +38 -0
  411. package/src/components/use-on-block-drop/index.js +7 -3
  412. package/src/components/writing-flow/test/use-multi-selection.js +36 -0
  413. package/src/components/writing-flow/use-multi-selection.js +12 -9
  414. package/src/hooks/border-color.js +69 -9
  415. package/src/hooks/border-radius.js +32 -0
  416. package/src/hooks/border-style.js +26 -0
  417. package/src/hooks/border-width.js +56 -32
  418. package/src/hooks/border.js +115 -20
  419. package/src/hooks/border.scss +3 -17
  420. package/src/hooks/color-panel.js +3 -0
  421. package/src/hooks/color-panel.native.js +63 -0
  422. package/src/hooks/color.js +8 -7
  423. package/src/hooks/dimensions.scss +5 -0
  424. package/src/hooks/index.native.js +1 -0
  425. package/src/hooks/layout.native.js +23 -0
  426. package/src/hooks/letter-spacing.js +1 -1
  427. package/src/hooks/typography.js +1 -1
  428. package/src/store/actions.js +1 -2
  429. package/src/store/defaults.js +2 -0
  430. package/src/store/defaults.native.js +2 -6
  431. package/src/store/selectors.js +10 -5
  432. package/src/style.scss +4 -3
  433. package/src/utils/get-paste-event-data.js +1 -1
  434. package/src/utils/parse-css-unit-to-px.js +1 -1
  435. package/src/utils/test/parse-css-unit-to-px.js +3 -0
  436. package/tsconfig.tsbuildinfo +1 -1
  437. package/build/components/use-canvas-click-redirect/index.js +0 -66
  438. package/build/components/use-canvas-click-redirect/index.js.map +0 -1
  439. package/build-module/components/use-canvas-click-redirect/index.js +0 -54
  440. package/build-module/components/use-canvas-click-redirect/index.js.map +0 -1
  441. package/src/components/use-canvas-click-redirect/index.js +0 -57
@@ -9,12 +9,12 @@ import classnames from 'classnames';
9
9
  import { addFilter } from '@wordpress/hooks';
10
10
  import { __ } from '@wordpress/i18n';
11
11
  import { createHigherOrderComponent } from '@wordpress/compose';
12
- import { useState } from '@wordpress/element';
12
+ import { useEffect, useState } from '@wordpress/element';
13
13
 
14
14
  /**
15
15
  * Internal dependencies
16
16
  */
17
- import ColorGradientControl from '../components/colors-gradients/control';
17
+ import ColorGradientSettingsDropdown from '../components/colors-gradients/dropdown';
18
18
  import useMultipleOriginColorsAndGradients from '../components/colors-gradients/use-multiple-origin-colors-and-gradients';
19
19
  import {
20
20
  getColorClassName,
@@ -22,7 +22,11 @@ import {
22
22
  getColorObjectByAttributeValues,
23
23
  } from '../components/colors';
24
24
  import useSetting from '../components/use-setting';
25
- import { hasBorderSupport, shouldSkipSerialization } from './border';
25
+ import {
26
+ hasBorderSupport,
27
+ removeBorderAttribute,
28
+ shouldSkipSerialization,
29
+ } from './border';
26
30
  import { cleanEmptyObject } from './utils';
27
31
 
28
32
  // Defining empty array here instead of inline avoids unnecessary re-renders of
@@ -52,15 +56,30 @@ export function BorderColorEdit( props ) {
52
56
  ( colors, origin ) => colors.concat( origin.colors ),
53
57
  []
54
58
  );
59
+ const { color: customBorderColor } = style?.border || {};
55
60
  const [ colorValue, setColorValue ] = useState(
56
61
  () =>
57
62
  getColorObjectByAttributeValues(
58
63
  availableColors,
59
64
  borderColor,
60
- style?.border?.color
65
+ customBorderColor
61
66
  )?.color
62
67
  );
63
68
 
69
+ // Detect changes in the color attributes and update the colorValue to keep the
70
+ // UI in sync. This is necessary for situations when border controls interact with
71
+ // eachother: eg, setting the border width to zero causes the color and style
72
+ // selections to be cleared.
73
+ useEffect( () => {
74
+ setColorValue(
75
+ getColorObjectByAttributeValues(
76
+ availableColors,
77
+ borderColor,
78
+ customBorderColor
79
+ )?.color
80
+ );
81
+ }, [ borderColor, customBorderColor, availableColors ] );
82
+
64
83
  const onChangeColor = ( value ) => {
65
84
  setColorValue( value );
66
85
 
@@ -85,19 +104,60 @@ export function BorderColorEdit( props ) {
85
104
  } );
86
105
  };
87
106
 
107
+ const settings = [
108
+ {
109
+ label: __( 'Color' ),
110
+ onColorChange: onChangeColor,
111
+ colorValue,
112
+ clearable: false,
113
+ },
114
+ ];
88
115
  return (
89
- <ColorGradientControl
90
- label={ __( 'Color' ) }
91
- colorValue={ colorValue }
92
- onColorChange={ onChangeColor }
93
- clearable={ false }
116
+ <ColorGradientSettingsDropdown
117
+ settings={ settings }
118
+ disableCustomColors
119
+ disableCustomGradients
94
120
  __experimentalHasMultipleOrigins
95
121
  __experimentalIsRenderedInSidebar
122
+ enableAlpha
96
123
  { ...colorGradientSettings }
97
124
  />
98
125
  );
99
126
  }
100
127
 
128
+ /**
129
+ * Checks if there is a current value in the border color block support
130
+ * attributes.
131
+ *
132
+ * @param {Object} props Block props.
133
+ * @return {boolean} Whether or not the block has a border color value set.
134
+ */
135
+ export function hasBorderColorValue( props ) {
136
+ const {
137
+ attributes: { borderColor, style },
138
+ } = props;
139
+
140
+ return !! borderColor || !! style?.border?.color;
141
+ }
142
+
143
+ /**
144
+ * Resets the border color block support attributes. This can be used when
145
+ * disabling the border color support controls for a block via a progressive
146
+ * discovery panel.
147
+ *
148
+ * @param {Object} props Block props.
149
+ * @param {Object} props.attributes Block's attributes.
150
+ * @param {Object} props.setAttributes Function to set block's attributes.
151
+ */
152
+ export function resetBorderColor( { attributes = {}, setAttributes } ) {
153
+ const { style } = attributes;
154
+
155
+ setAttributes( {
156
+ borderColor: undefined,
157
+ style: removeBorderAttribute( style, 'color' ),
158
+ } );
159
+ }
160
+
101
161
  /**
102
162
  * Filters registered block settings, extending attributes to include
103
163
  * `borderColor` if needed.
@@ -3,6 +3,7 @@
3
3
  */
4
4
  import BorderRadiusControl from '../components/border-radius-control';
5
5
  import { cleanEmptyObject } from './utils';
6
+ import { removeBorderAttribute } from './border';
6
7
 
7
8
  /**
8
9
  * Inspector control panel containing the border radius related configuration.
@@ -40,3 +41,34 @@ export function BorderRadiusEdit( props ) {
40
41
  />
41
42
  );
42
43
  }
44
+
45
+ /**
46
+ * Checks if there is a current value in the border radius block support
47
+ * attributes.
48
+ *
49
+ * @param {Object} props Block props.
50
+ * @return {boolean} Whether or not the block has a border radius value set.
51
+ */
52
+ export function hasBorderRadiusValue( props ) {
53
+ const borderRadius = props.attributes.style?.border?.radius;
54
+
55
+ if ( typeof borderRadius === 'object' ) {
56
+ return Object.entries( borderRadius ).some( Boolean );
57
+ }
58
+
59
+ return !! borderRadius;
60
+ }
61
+
62
+ /**
63
+ * Resets the border radius block support attributes. This can be used when
64
+ * disabling the border radius support controls for a block via a progressive
65
+ * discovery panel.
66
+ *
67
+ * @param {Object} props Block props.
68
+ * @param {Object} props.attributes Block's attributes.
69
+ * @param {Object} props.setAttributes Function to set block's attributes.
70
+ */
71
+ export function resetBorderRadius( { attributes = {}, setAttributes } ) {
72
+ const { style } = attributes;
73
+ setAttributes( { style: removeBorderAttribute( style, 'radius' ) } );
74
+ }
@@ -3,6 +3,7 @@
3
3
  */
4
4
  import BorderStyleControl from '../components/border-style-control';
5
5
  import { cleanEmptyObject } from './utils';
6
+ import { removeBorderAttribute } from './border';
6
7
 
7
8
  /**
8
9
  * Inspector control for configuring border style property.
@@ -36,3 +37,28 @@ export const BorderStyleEdit = ( props ) => {
36
37
  />
37
38
  );
38
39
  };
40
+
41
+ /**
42
+ * Checks if there is a current value in the border style block support
43
+ * attributes.
44
+ *
45
+ * @param {Object} props Block props.
46
+ * @return {boolean} Whether or not the block has a border style value set.
47
+ */
48
+ export function hasBorderStyleValue( props ) {
49
+ return !! props.attributes.style?.border?.style;
50
+ }
51
+
52
+ /**
53
+ * Resets the border style block support attribute. This can be used when
54
+ * disabling the border style support control for a block via a progressive
55
+ * discovery panel.
56
+ *
57
+ * @param {Object} props Block props.
58
+ * @param {Object} props.attributes Block's attributes.
59
+ * @param {Object} props.setAttributes Function to set block's attributes.
60
+ */
61
+ export function resetBorderStyle( { attributes = {}, setAttributes } ) {
62
+ const { style } = attributes;
63
+ setAttributes( { style: removeBorderAttribute( style, 'style' ) } );
64
+ }
@@ -5,13 +5,14 @@ import {
5
5
  __experimentalUnitControl as UnitControl,
6
6
  __experimentalUseCustomUnits as useCustomUnits,
7
7
  } from '@wordpress/components';
8
- import { useEffect, useState } from '@wordpress/element';
8
+ import { useState } from '@wordpress/element';
9
9
  import { __ } from '@wordpress/i18n';
10
10
 
11
11
  /**
12
12
  * Internal dependencies
13
13
  */
14
14
  import { cleanEmptyObject } from './utils';
15
+ import { removeBorderAttribute } from './border';
15
16
  import useSetting from '../components/use-setting';
16
17
 
17
18
  const MIN_BORDER_WIDTH = 0;
@@ -31,25 +32,12 @@ export const BorderWidthEdit = ( props ) => {
31
32
 
32
33
  const { width, color: customBorderColor, style: borderStyle } =
33
34
  style?.border || {};
35
+
36
+ // Used to temporarily track previous border color & style selections to be
37
+ // able to restore them when border width changes from zero value.
34
38
  const [ styleSelection, setStyleSelection ] = useState();
35
39
  const [ colorSelection, setColorSelection ] = useState();
36
-
37
- // Temporarily track previous border color & style selections to be able to
38
- // restore them when border width changes from zero value.
39
- useEffect( () => {
40
- if ( borderStyle !== 'none' ) {
41
- setStyleSelection( borderStyle );
42
- }
43
- }, [ borderStyle ] );
44
-
45
- useEffect( () => {
46
- if ( borderColor || customBorderColor ) {
47
- setColorSelection( {
48
- name: !! borderColor ? borderColor : undefined,
49
- color: !! customBorderColor ? customBorderColor : undefined,
50
- } );
51
- }
52
- }, [ borderColor, customBorderColor ] );
40
+ const [ customColorSelection, setCustomColorSelection ] = useState();
53
41
 
54
42
  const onChange = ( newWidth ) => {
55
43
  let newStyle = {
@@ -64,28 +52,39 @@ export const BorderWidthEdit = ( props ) => {
64
52
  let borderPaletteColor = borderColor;
65
53
 
66
54
  const hasZeroWidth = parseFloat( newWidth ) === 0;
55
+ const hadPreviousZeroWidth = parseFloat( width ) === 0;
67
56
 
68
57
  // Setting the border width explicitly to zero will also set the
69
58
  // border style to `none` and clear border color attributes.
70
- if ( hasZeroWidth ) {
59
+ if ( hasZeroWidth && ! hadPreviousZeroWidth ) {
60
+ // Before clearing color and style selections, keep track of
61
+ // the current selections so they can be restored when the width
62
+ // changes to a non-zero value.
63
+ setColorSelection( borderColor );
64
+ setCustomColorSelection( customBorderColor );
65
+ setStyleSelection( borderStyle );
66
+
67
+ // Clear style and color attributes.
71
68
  borderPaletteColor = undefined;
72
69
  newStyle.border.color = undefined;
73
70
  newStyle.border.style = 'none';
74
71
  }
75
72
 
76
- // Restore previous border style selection if width is now not zero and
77
- // border style was 'none'. This is to support changes to the UI which
78
- // change the border style UI to a segmented control without a "none"
79
- // option.
80
- if ( ! hasZeroWidth && borderStyle === 'none' ) {
81
- newStyle.border.style = styleSelection;
82
- }
83
-
84
- // Restore previous border color selection if width is no longer zero
85
- // and current border color is undefined.
86
- if ( ! hasZeroWidth && borderColor === undefined ) {
87
- borderPaletteColor = colorSelection?.name;
88
- newStyle.border.color = colorSelection?.color;
73
+ if ( ! hasZeroWidth && hadPreviousZeroWidth ) {
74
+ // Restore previous border style selection if width is now not zero and
75
+ // border style was 'none'. This is to support changes to the UI which
76
+ // change the border style UI to a segmented control without a "none"
77
+ // option.
78
+ if ( borderStyle === 'none' ) {
79
+ newStyle.border.style = styleSelection;
80
+ }
81
+
82
+ // Restore previous border color selection if width is no longer zero
83
+ // and current border color is undefined.
84
+ if ( borderColor === undefined ) {
85
+ borderPaletteColor = colorSelection;
86
+ newStyle.border.color = customColorSelection;
87
+ }
89
88
  }
90
89
 
91
90
  // If width was reset, clean out undefined styles.
@@ -113,3 +112,28 @@ export const BorderWidthEdit = ( props ) => {
113
112
  />
114
113
  );
115
114
  };
115
+
116
+ /**
117
+ * Checks if there is a current value in the border width block support
118
+ * attributes.
119
+ *
120
+ * @param {Object} props Block props.
121
+ * @return {boolean} Whether or not the block has a border width value set.
122
+ */
123
+ export function hasBorderWidthValue( props ) {
124
+ return !! props.attributes.style?.border?.width;
125
+ }
126
+
127
+ /**
128
+ * Resets the border width block support attribute. This can be used when
129
+ * disabling the border width support control for a block via a progressive
130
+ * discovery panel.
131
+ *
132
+ * @param {Object} props Block props.
133
+ * @param {Object} props.attributes Block's attributes.
134
+ * @param {Object} props.setAttributes Function to set block's attributes.
135
+ */
136
+ export function resetBorderWidth( { attributes = {}, setAttributes } ) {
137
+ const { style } = attributes;
138
+ setAttributes( { style: removeBorderAttribute( style, 'width' ) } );
139
+ }
@@ -2,23 +2,41 @@
2
2
  * WordPress dependencies
3
3
  */
4
4
  import { getBlockSupport } from '@wordpress/blocks';
5
- import { PanelBody } from '@wordpress/components';
5
+ import { __experimentalToolsPanelItem as ToolsPanelItem } from '@wordpress/components';
6
6
  import { Platform } from '@wordpress/element';
7
7
  import { __ } from '@wordpress/i18n';
8
8
 
9
9
  /**
10
10
  * Internal dependencies
11
11
  */
12
+ import {
13
+ BorderColorEdit,
14
+ hasBorderColorValue,
15
+ resetBorderColor,
16
+ } from './border-color';
17
+ import {
18
+ BorderRadiusEdit,
19
+ hasBorderRadiusValue,
20
+ resetBorderRadius,
21
+ } from './border-radius';
22
+ import {
23
+ BorderStyleEdit,
24
+ hasBorderStyleValue,
25
+ resetBorderStyle,
26
+ } from './border-style';
27
+ import {
28
+ BorderWidthEdit,
29
+ hasBorderWidthValue,
30
+ resetBorderWidth,
31
+ } from './border-width';
12
32
  import InspectorControls from '../components/inspector-controls';
13
33
  import useSetting from '../components/use-setting';
14
- import { BorderColorEdit } from './border-color';
15
- import { BorderRadiusEdit } from './border-radius';
16
- import { BorderStyleEdit } from './border-style';
17
- import { BorderWidthEdit } from './border-width';
34
+ import { cleanEmptyObject } from './utils';
18
35
 
19
36
  export const BORDER_SUPPORT_KEY = '__experimentalBorder';
20
37
 
21
38
  export function BorderPanel( props ) {
39
+ const { clientId } = props;
22
40
  const isDisabled = useIsBorderDisabled( props );
23
41
  const isSupported = hasBorderSupport( props.name );
24
42
 
@@ -39,22 +57,80 @@ export function BorderPanel( props ) {
39
57
  return null;
40
58
  }
41
59
 
60
+ const defaultBorderControls = getBlockSupport( props.name, [
61
+ BORDER_SUPPORT_KEY,
62
+ '__experimentalDefaultControls',
63
+ ] );
64
+
65
+ const createResetAllFilter = (
66
+ borderAttribute,
67
+ topLevelAttributes = {}
68
+ ) => ( newAttributes ) => ( {
69
+ ...newAttributes,
70
+ ...topLevelAttributes,
71
+ style: {
72
+ ...newAttributes.style,
73
+ border: {
74
+ ...newAttributes.style?.border,
75
+ [ borderAttribute ]: undefined,
76
+ },
77
+ },
78
+ } );
79
+
42
80
  return (
43
- <InspectorControls>
44
- <PanelBody
45
- className="block-editor-hooks__border-controls"
46
- title={ __( 'Border' ) }
47
- initialOpen={ false }
48
- >
49
- { ( isWidthSupported || isStyleSupported ) && (
50
- <div className="block-editor-hooks__border-controls-row">
51
- { isWidthSupported && <BorderWidthEdit { ...props } /> }
52
- { isStyleSupported && <BorderStyleEdit { ...props } /> }
53
- </div>
54
- ) }
55
- { isColorSupported && <BorderColorEdit { ...props } /> }
56
- { isRadiusSupported && <BorderRadiusEdit { ...props } /> }
57
- </PanelBody>
81
+ <InspectorControls __experimentalGroup="border">
82
+ { isWidthSupported && (
83
+ <ToolsPanelItem
84
+ className="single-column"
85
+ hasValue={ () => hasBorderWidthValue( props ) }
86
+ label={ __( 'Width' ) }
87
+ onDeselect={ () => resetBorderWidth( props ) }
88
+ isShownByDefault={ defaultBorderControls?.width }
89
+ resetAllFilter={ createResetAllFilter( 'width' ) }
90
+ panelId={ clientId }
91
+ >
92
+ <BorderWidthEdit { ...props } />
93
+ </ToolsPanelItem>
94
+ ) }
95
+ { isStyleSupported && (
96
+ <ToolsPanelItem
97
+ className="single-column"
98
+ hasValue={ () => hasBorderStyleValue( props ) }
99
+ label={ __( 'Style' ) }
100
+ onDeselect={ () => resetBorderStyle( props ) }
101
+ isShownByDefault={ defaultBorderControls?.style }
102
+ resetAllFilter={ createResetAllFilter( 'style' ) }
103
+ panelId={ clientId }
104
+ >
105
+ <BorderStyleEdit { ...props } />
106
+ </ToolsPanelItem>
107
+ ) }
108
+ { isColorSupported && (
109
+ <ToolsPanelItem
110
+ hasValue={ () => hasBorderColorValue( props ) }
111
+ label={ __( 'Color' ) }
112
+ onDeselect={ () => resetBorderColor( props ) }
113
+ isShownByDefault={ defaultBorderControls?.color }
114
+ resetAllFilter={ createResetAllFilter( 'color', {
115
+ borderColor: undefined,
116
+ } ) }
117
+ panelId={ clientId }
118
+ >
119
+ <BorderColorEdit { ...props } />
120
+ </ToolsPanelItem>
121
+ ) }
122
+ { isRadiusSupported && (
123
+ <ToolsPanelItem
124
+ hasValue={ () => hasBorderRadiusValue( props ) }
125
+ label={ __( 'Radius' ) }
126
+ onDeselect={ () => resetBorderRadius( props ) }
127
+ isShownByDefault={ defaultBorderControls?.radius }
128
+ resetAllFilter={ createResetAllFilter( 'radius' ) }
129
+ panelId={ clientId }
130
+ >
131
+ <BorderRadiusEdit { ...props } />
132
+ </ToolsPanelItem>
133
+ ) }
58
134
  </InspectorControls>
59
135
  );
60
136
  }
@@ -118,3 +194,22 @@ const useIsBorderDisabled = () => {
118
194
 
119
195
  return configs.every( Boolean );
120
196
  };
197
+
198
+ /**
199
+ * Returns a new style object where the specified border attribute has been
200
+ * removed.
201
+ *
202
+ * @param {Object} style Styles from block attributes.
203
+ * @param {string} attribute The border style attribute to clear.
204
+ *
205
+ * @return {Object} Style object with the specified attribute removed.
206
+ */
207
+ export function removeBorderAttribute( style, attribute ) {
208
+ return cleanEmptyObject( {
209
+ ...style,
210
+ border: {
211
+ ...style?.border,
212
+ [ attribute ]: undefined,
213
+ },
214
+ } );
215
+ }
@@ -1,19 +1,5 @@
1
- .block-editor-hooks__border-controls {
2
- .block-editor-hooks__border-controls-row {
3
- display: flex;
4
- justify-content: space-between;
5
-
6
- > * {
7
- width: calc(50% - #{ $grid-unit-10 });
8
- }
9
- }
10
-
11
- .components-unit-control-wrapper {
12
- margin-bottom: $grid-unit-30;
13
-
14
- &:last-child {
15
- margin-bottom: $grid-unit-10;
16
- }
1
+ .border-block-support-panel {
2
+ .single-column {
3
+ grid-column: span 1;
17
4
  }
18
5
  }
19
-
@@ -17,6 +17,7 @@ function getComputedStyle( node ) {
17
17
  }
18
18
 
19
19
  export default function ColorPanel( {
20
+ enableAlpha = false,
20
21
  settings,
21
22
  clientId,
22
23
  enableContrastChecking = true,
@@ -60,6 +61,7 @@ export default function ColorPanel( {
60
61
  initialOpen={ false }
61
62
  settings={ settings }
62
63
  showTitle={ showTitle }
64
+ enableAlpha={ enableAlpha }
63
65
  __experimentalHasMultipleOrigins
64
66
  __experimentalIsRenderedInSidebar
65
67
  >
@@ -67,6 +69,7 @@ export default function ColorPanel( {
67
69
  <ContrastChecker
68
70
  backgroundColor={ detectedBackgroundColor }
69
71
  textColor={ detectedColor }
72
+ enableAlphaChecker={ enableAlpha }
70
73
  />
71
74
  ) }
72
75
  </PanelColorGradientSettings>
@@ -0,0 +1,63 @@
1
+ /**
2
+ * WordPress dependencies
3
+ */
4
+ import { useSelect } from '@wordpress/data';
5
+ import { useEffect, useState } from '@wordpress/element';
6
+ import { __ } from '@wordpress/i18n';
7
+ import { useGlobalStyles } from '@wordpress/components';
8
+ import { store as blockEditorStore } from '@wordpress/block-editor';
9
+
10
+ /**
11
+ * Internal dependencies
12
+ */
13
+ import PanelColorGradientSettings from '../components/colors-gradients/panel-color-gradient-settings';
14
+ import ContrastChecker from '../components/contrast-checker';
15
+ import InspectorControls from '../components/inspector-controls';
16
+
17
+ const ColorPanel = ( { settings } ) => {
18
+ const globalStyles = useGlobalStyles();
19
+
20
+ const [ detectedBackgroundColor, setDetectedBackgroundColor ] = useState();
21
+ const [ detectedTextColor, setDetectedTextColor ] = useState();
22
+
23
+ const { baseGlobalStyles } = useSelect( ( select ) => {
24
+ const { getSettings } = select( blockEditorStore );
25
+ return {
26
+ baseGlobalStyles: getSettings()
27
+ ?.__experimentalGlobalStylesBaseStyles?.color,
28
+ };
29
+ } );
30
+
31
+ useEffect( () => {
32
+ // The following logic is used to determine current text/background colors:
33
+ // 1. The globalStyles object is queried to determine whether a color has been
34
+ // set via a block's settings.
35
+ // 2. If a block-based theme is in use and no globalStyles exist, the theme's
36
+ // default/base colors are used.
37
+ // 3. If no globalStyles exist and a theme isn't block-based, there is no way
38
+ // to determine the default text/background color and the checker won't run.
39
+ const textColor = globalStyles?.color || baseGlobalStyles?.text;
40
+ const backgroundColor =
41
+ globalStyles?.backgroundColor || baseGlobalStyles?.background;
42
+
43
+ setDetectedTextColor( textColor );
44
+ setDetectedBackgroundColor( backgroundColor );
45
+ }, [ globalStyles, baseGlobalStyles ] );
46
+
47
+ return (
48
+ <InspectorControls>
49
+ <PanelColorGradientSettings
50
+ title={ __( 'Color' ) }
51
+ initialOpen={ false }
52
+ settings={ settings }
53
+ >
54
+ <ContrastChecker
55
+ backgroundColor={ detectedBackgroundColor }
56
+ textColor={ detectedTextColor }
57
+ />
58
+ </PanelColorGradientSettings>
59
+ </InspectorControls>
60
+ );
61
+ };
62
+
63
+ export default ColorPanel;
@@ -371,18 +371,19 @@ export function ColorEdit( props ) {
371
371
  props.setAttributes( { style: newStyle } );
372
372
  };
373
373
 
374
+ const enableContrastChecking =
375
+ Platform.OS === 'web' && ! gradient && ! style?.color?.gradient;
376
+
374
377
  return (
375
378
  <ColorPanel
376
- enableContrastChecking={
377
- // Turn on contrast checker for web only since it's not supported on mobile yet.
378
- Platform.OS === 'web' && ! gradient && ! style?.color?.gradient
379
- }
379
+ enableContrastChecking={ enableContrastChecking }
380
380
  clientId={ props.clientId }
381
+ enableAlpha={ true }
381
382
  settings={ [
382
383
  ...( hasTextColor
383
384
  ? [
384
385
  {
385
- label: __( 'Text color' ),
386
+ label: __( 'Text' ),
386
387
  onColorChange: onChangeColor( 'text' ),
387
388
  colorValue: getColorObjectByAttributeValues(
388
389
  allSolids,
@@ -395,7 +396,7 @@ export function ColorEdit( props ) {
395
396
  ...( hasBackgroundColor || hasGradientColor
396
397
  ? [
397
398
  {
398
- label: __( 'Background color' ),
399
+ label: __( 'Background' ),
399
400
  onColorChange: hasBackgroundColor
400
401
  ? onChangeColor( 'background' )
401
402
  : undefined,
@@ -414,7 +415,7 @@ export function ColorEdit( props ) {
414
415
  ...( hasLinkColor
415
416
  ? [
416
417
  {
417
- label: __( 'Link Color' ),
418
+ label: __( 'Link' ),
418
419
  onColorChange: onChangeLinkColor,
419
420
  colorValue: getLinkColorFromAttributeValue(
420
421
  allSolids,
@@ -0,0 +1,5 @@
1
+ .dimensions-block-support-panel {
2
+ .single-column {
3
+ grid-column: span 1;
4
+ }
5
+ }
@@ -9,6 +9,7 @@ import './generated-class-name';
9
9
  import './style';
10
10
  import './color';
11
11
  import './font-size';
12
+ import './layout';
12
13
 
13
14
  export { getBorderClassesAndStyles, useBorderProps } from './use-border-props';
14
15
  export { getColorClassesAndStyles, useColorProps } from './use-color-props';