@wordpress/block-editor 11.6.0 → 11.8.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 (350) hide show
  1. package/CHANGELOG.md +6 -0
  2. package/README.md +46 -55
  3. package/build/components/block-list/block-html.js +1 -3
  4. package/build/components/block-list/block-html.js.map +1 -1
  5. package/build/components/block-list/block.native.js +4 -3
  6. package/build/components/block-list/block.native.js.map +1 -1
  7. package/build/components/block-list/index.native.js +11 -21
  8. package/build/components/block-list/index.native.js.map +1 -1
  9. package/build/components/block-list/use-in-between-inserter.js +3 -1
  10. package/build/components/block-list/use-in-between-inserter.js.map +1 -1
  11. package/build/components/block-popover/inbetween.js +2 -9
  12. package/build/components/block-popover/inbetween.js.map +1 -1
  13. package/build/components/block-preview/auto.js +6 -23
  14. package/build/components/block-preview/auto.js.map +1 -1
  15. package/build/components/block-settings-menu/block-settings-dropdown.js +1 -10
  16. package/build/components/block-settings-menu/block-settings-dropdown.js.map +1 -1
  17. package/build/components/caption/index.native.js +0 -1
  18. package/build/components/caption/index.native.js.map +1 -1
  19. package/build/components/date-format-picker/index.js +1 -1
  20. package/build/components/date-format-picker/index.js.map +1 -1
  21. package/build/components/editor-styles/index.js +20 -2
  22. package/build/components/editor-styles/index.js.map +1 -1
  23. package/build/components/global-styles/border-panel.js +15 -29
  24. package/build/components/global-styles/border-panel.js.map +1 -1
  25. package/build/components/global-styles/color-panel.js +583 -0
  26. package/build/components/global-styles/color-panel.js.map +1 -0
  27. package/build/components/global-styles/dimensions-panel.js +23 -44
  28. package/build/components/global-styles/dimensions-panel.js.map +1 -1
  29. package/build/components/global-styles/effects-panel.js +244 -0
  30. package/build/components/global-styles/effects-panel.js.map +1 -0
  31. package/build/components/global-styles/filters-panel.js +151 -0
  32. package/build/components/global-styles/filters-panel.js.map +1 -0
  33. package/build/components/global-styles/get-block-css-selector.js +118 -0
  34. package/build/components/global-styles/get-block-css-selector.js.map +1 -0
  35. package/build/components/global-styles/hooks.js +60 -1
  36. package/build/components/global-styles/hooks.js.map +1 -1
  37. package/build/components/global-styles/index.js +46 -2
  38. package/build/components/global-styles/index.js.map +1 -1
  39. package/build/components/global-styles/typography-panel.js +9 -35
  40. package/build/components/global-styles/typography-panel.js.map +1 -1
  41. package/build/components/global-styles/use-global-styles-output.js +173 -91
  42. package/build/components/global-styles/use-global-styles-output.js.map +1 -1
  43. package/build/components/global-styles/utils.js +2 -1
  44. package/build/components/global-styles/utils.js.map +1 -1
  45. package/build/components/iframe/index.js +1 -1
  46. package/build/components/iframe/index.js.map +1 -1
  47. package/build/components/image-size-control/index.js +8 -5
  48. package/build/components/image-size-control/index.js.map +1 -1
  49. package/build/components/image-size-control/use-dimension-handler.js +5 -3
  50. package/build/components/image-size-control/use-dimension-handler.js.map +1 -1
  51. package/build/components/index.js +16 -0
  52. package/build/components/index.js.map +1 -1
  53. package/build/components/inserter/block-patterns-tab.js +4 -2
  54. package/build/components/inserter/block-patterns-tab.js.map +1 -1
  55. package/build/components/inspector-controls-tabs/position-controls-panel.js +43 -7
  56. package/build/components/inspector-controls-tabs/position-controls-panel.js.map +1 -1
  57. package/build/components/inspector-controls-tabs/utils.js +5 -3
  58. package/build/components/inspector-controls-tabs/utils.js.map +1 -1
  59. package/build/components/line-height-control/index.js +15 -1
  60. package/build/components/line-height-control/index.js.map +1 -1
  61. package/build/components/list-view/appender.js +105 -0
  62. package/build/components/list-view/appender.js.map +1 -0
  63. package/build/components/list-view/block.js +6 -5
  64. package/build/components/list-view/block.js.map +1 -1
  65. package/build/components/list-view/branch.js +25 -5
  66. package/build/components/list-view/branch.js.map +1 -1
  67. package/build/components/list-view/index.js +56 -14
  68. package/build/components/list-view/index.js.map +1 -1
  69. package/build/components/list-view/use-list-view-client-ids.js +7 -3
  70. package/build/components/list-view/use-list-view-client-ids.js.map +1 -1
  71. package/build/components/list-view/use-list-view-drop-zone.js +8 -2
  72. package/build/components/list-view/use-list-view-drop-zone.js.map +1 -1
  73. package/build/components/media-replace-flow/index.js +13 -4
  74. package/build/components/media-replace-flow/index.js.map +1 -1
  75. package/build/components/off-canvas-editor/block-contents.js +6 -1
  76. package/build/components/off-canvas-editor/block-contents.js.map +1 -1
  77. package/build/components/off-canvas-editor/index.js +17 -14
  78. package/build/components/off-canvas-editor/index.js.map +1 -1
  79. package/build/components/resizable-box-popover/index.js +38 -0
  80. package/build/components/resizable-box-popover/index.js.map +1 -0
  81. package/build/components/rich-text/format-edit.js +2 -30
  82. package/build/components/rich-text/format-edit.js.map +1 -1
  83. package/build/components/rich-text/index.js +0 -1
  84. package/build/components/rich-text/index.js.map +1 -1
  85. package/build/components/rich-text/index.native.js +7 -11
  86. package/build/components/rich-text/index.native.js.map +1 -1
  87. package/build/components/spacing-sizes-control/spacing-input-control.js +8 -0
  88. package/build/components/spacing-sizes-control/spacing-input-control.js.map +1 -1
  89. package/build/components/writing-flow/use-input.js +4 -8
  90. package/build/components/writing-flow/use-input.js.map +1 -1
  91. package/build/hooks/anchor.js +1 -1
  92. package/build/hooks/anchor.js.map +1 -1
  93. package/build/hooks/border.js +1 -2
  94. package/build/hooks/border.js.map +1 -1
  95. package/build/hooks/color.js +92 -229
  96. package/build/hooks/color.js.map +1 -1
  97. package/build/hooks/content-lock-ui.js +4 -2
  98. package/build/hooks/content-lock-ui.js.map +1 -1
  99. package/build/hooks/{color-panel.js → contrast-checker.js} +11 -49
  100. package/build/hooks/contrast-checker.js.map +1 -0
  101. package/build/hooks/dimensions.js +0 -1
  102. package/build/hooks/dimensions.js.map +1 -1
  103. package/build/hooks/duotone.js +92 -64
  104. package/build/hooks/duotone.js.map +1 -1
  105. package/build/hooks/margin.js +27 -17
  106. package/build/hooks/margin.js.map +1 -1
  107. package/build/hooks/padding.js +19 -9
  108. package/build/hooks/padding.js.map +1 -1
  109. package/build/hooks/position.js +2 -2
  110. package/build/hooks/position.js.map +1 -1
  111. package/build/hooks/style.js +23 -26
  112. package/build/hooks/style.js.map +1 -1
  113. package/build/hooks/typography.js +0 -1
  114. package/build/hooks/typography.js.map +1 -1
  115. package/build/hooks/utils.js +28 -76
  116. package/build/hooks/utils.js.map +1 -1
  117. package/build/layouts/grid.js +165 -0
  118. package/build/layouts/grid.js.map +1 -0
  119. package/build/layouts/index.js +3 -1
  120. package/build/layouts/index.js.map +1 -1
  121. package/build/layouts/utils.js +3 -2
  122. package/build/layouts/utils.js.map +1 -1
  123. package/build/private-apis.js +7 -1
  124. package/build/private-apis.js.map +1 -1
  125. package/build/store/actions.js +1 -1
  126. package/build/store/actions.js.map +1 -1
  127. package/build/utils/object.js +76 -0
  128. package/build/utils/object.js.map +1 -0
  129. package/build-module/components/block-list/block-html.js +1 -3
  130. package/build-module/components/block-list/block-html.js.map +1 -1
  131. package/build-module/components/block-list/block.native.js +4 -3
  132. package/build-module/components/block-list/block.native.js.map +1 -1
  133. package/build-module/components/block-list/index.native.js +11 -19
  134. package/build-module/components/block-list/index.native.js.map +1 -1
  135. package/build-module/components/block-list/use-in-between-inserter.js +2 -1
  136. package/build-module/components/block-list/use-in-between-inserter.js.map +1 -1
  137. package/build-module/components/block-popover/inbetween.js +2 -9
  138. package/build-module/components/block-popover/inbetween.js.map +1 -1
  139. package/build-module/components/block-preview/auto.js +6 -22
  140. package/build-module/components/block-preview/auto.js.map +1 -1
  141. package/build-module/components/block-settings-menu/block-settings-dropdown.js +1 -9
  142. package/build-module/components/block-settings-menu/block-settings-dropdown.js.map +1 -1
  143. package/build-module/components/caption/index.native.js +0 -1
  144. package/build-module/components/caption/index.native.js.map +1 -1
  145. package/build-module/components/date-format-picker/index.js +1 -1
  146. package/build-module/components/date-format-picker/index.js.map +1 -1
  147. package/build-module/components/editor-styles/index.js +19 -2
  148. package/build-module/components/editor-styles/index.js.map +1 -1
  149. package/build-module/components/global-styles/border-panel.js +15 -29
  150. package/build-module/components/global-styles/border-panel.js.map +1 -1
  151. package/build-module/components/global-styles/color-panel.js +554 -0
  152. package/build-module/components/global-styles/color-panel.js.map +1 -0
  153. package/build-module/components/global-styles/dimensions-panel.js +22 -44
  154. package/build-module/components/global-styles/dimensions-panel.js.map +1 -1
  155. package/build-module/components/global-styles/effects-panel.js +228 -0
  156. package/build-module/components/global-styles/effects-panel.js.map +1 -0
  157. package/build-module/components/global-styles/filters-panel.js +139 -0
  158. package/build-module/components/global-styles/filters-panel.js.map +1 -0
  159. package/build-module/components/global-styles/get-block-css-selector.js +109 -0
  160. package/build-module/components/global-styles/get-block-css-selector.js.map +1 -0
  161. package/build-module/components/global-styles/hooks.js +58 -1
  162. package/build-module/components/global-styles/hooks.js.map +1 -1
  163. package/build-module/components/global-styles/index.js +5 -1
  164. package/build-module/components/global-styles/index.js.map +1 -1
  165. package/build-module/components/global-styles/typography-panel.js +8 -35
  166. package/build-module/components/global-styles/typography-panel.js.map +1 -1
  167. package/build-module/components/global-styles/use-global-styles-output.js +175 -93
  168. package/build-module/components/global-styles/use-global-styles-output.js.map +1 -1
  169. package/build-module/components/global-styles/utils.js +2 -1
  170. package/build-module/components/global-styles/utils.js.map +1 -1
  171. package/build-module/components/iframe/index.js +1 -1
  172. package/build-module/components/iframe/index.js.map +1 -1
  173. package/build-module/components/image-size-control/index.js +8 -5
  174. package/build-module/components/image-size-control/index.js.map +1 -1
  175. package/build-module/components/image-size-control/use-dimension-handler.js +5 -3
  176. package/build-module/components/image-size-control/use-dimension-handler.js.map +1 -1
  177. package/build-module/components/index.js +1 -0
  178. package/build-module/components/index.js.map +1 -1
  179. package/build-module/components/inserter/block-patterns-tab.js +5 -2
  180. package/build-module/components/inserter/block-patterns-tab.js.map +1 -1
  181. package/build-module/components/inspector-controls-tabs/position-controls-panel.js +42 -7
  182. package/build-module/components/inspector-controls-tabs/position-controls-panel.js.map +1 -1
  183. package/build-module/components/inspector-controls-tabs/utils.js +4 -3
  184. package/build-module/components/inspector-controls-tabs/utils.js.map +1 -1
  185. package/build-module/components/line-height-control/index.js +15 -1
  186. package/build-module/components/line-height-control/index.js.map +1 -1
  187. package/build-module/components/list-view/appender.js +88 -0
  188. package/build-module/components/list-view/appender.js.map +1 -0
  189. package/build-module/components/list-view/block.js +6 -4
  190. package/build-module/components/list-view/block.js.map +1 -1
  191. package/build-module/components/list-view/branch.js +22 -5
  192. package/build-module/components/list-view/branch.js.map +1 -1
  193. package/build-module/components/list-view/index.js +50 -13
  194. package/build-module/components/list-view/index.js.map +1 -1
  195. package/build-module/components/list-view/use-list-view-client-ids.js +7 -3
  196. package/build-module/components/list-view/use-list-view-client-ids.js.map +1 -1
  197. package/build-module/components/list-view/use-list-view-drop-zone.js +8 -4
  198. package/build-module/components/list-view/use-list-view-drop-zone.js.map +1 -1
  199. package/build-module/components/media-replace-flow/index.js +12 -4
  200. package/build-module/components/media-replace-flow/index.js.map +1 -1
  201. package/build-module/components/off-canvas-editor/block-contents.js +5 -1
  202. package/build-module/components/off-canvas-editor/block-contents.js.map +1 -1
  203. package/build-module/components/off-canvas-editor/index.js +17 -14
  204. package/build-module/components/off-canvas-editor/index.js.map +1 -1
  205. package/build-module/components/resizable-box-popover/index.js +26 -0
  206. package/build-module/components/resizable-box-popover/index.js.map +1 -0
  207. package/build-module/components/rich-text/format-edit.js +3 -31
  208. package/build-module/components/rich-text/format-edit.js.map +1 -1
  209. package/build-module/components/rich-text/index.js +0 -1
  210. package/build-module/components/rich-text/index.js.map +1 -1
  211. package/build-module/components/rich-text/index.native.js +7 -10
  212. package/build-module/components/rich-text/index.native.js.map +1 -1
  213. package/build-module/components/spacing-sizes-control/spacing-input-control.js +7 -0
  214. package/build-module/components/spacing-sizes-control/spacing-input-control.js.map +1 -1
  215. package/build-module/components/writing-flow/use-input.js +4 -8
  216. package/build-module/components/writing-flow/use-input.js.map +1 -1
  217. package/build-module/hooks/anchor.js +1 -1
  218. package/build-module/hooks/anchor.js.map +1 -1
  219. package/build-module/hooks/border.js +1 -2
  220. package/build-module/hooks/border.js.map +1 -1
  221. package/build-module/hooks/color.js +90 -232
  222. package/build-module/hooks/color.js.map +1 -1
  223. package/build-module/hooks/content-lock-ui.js +4 -2
  224. package/build-module/hooks/content-lock-ui.js.map +1 -1
  225. package/build-module/hooks/{color-panel.js → contrast-checker.js} +10 -44
  226. package/build-module/hooks/contrast-checker.js.map +1 -0
  227. package/build-module/hooks/dimensions.js +0 -1
  228. package/build-module/hooks/dimensions.js.map +1 -1
  229. package/build-module/hooks/duotone.js +91 -65
  230. package/build-module/hooks/duotone.js.map +1 -1
  231. package/build-module/hooks/margin.js +29 -18
  232. package/build-module/hooks/margin.js.map +1 -1
  233. package/build-module/hooks/padding.js +21 -10
  234. package/build-module/hooks/padding.js.map +1 -1
  235. package/build-module/hooks/position.js +3 -3
  236. package/build-module/hooks/position.js.map +1 -1
  237. package/build-module/hooks/style.js +23 -26
  238. package/build-module/hooks/style.js.map +1 -1
  239. package/build-module/hooks/typography.js +0 -1
  240. package/build-module/hooks/typography.js.map +1 -1
  241. package/build-module/hooks/utils.js +27 -74
  242. package/build-module/hooks/utils.js.map +1 -1
  243. package/build-module/layouts/grid.js +151 -0
  244. package/build-module/layouts/grid.js.map +1 -0
  245. package/build-module/layouts/index.js +2 -1
  246. package/build-module/layouts/index.js.map +1 -1
  247. package/build-module/layouts/utils.js +3 -2
  248. package/build-module/layouts/utils.js.map +1 -1
  249. package/build-module/private-apis.js +5 -1
  250. package/build-module/private-apis.js.map +1 -1
  251. package/build-module/store/actions.js +1 -1
  252. package/build-module/store/actions.js.map +1 -1
  253. package/build-module/utils/object.js +69 -0
  254. package/build-module/utils/object.js.map +1 -0
  255. package/build-style/style-rtl.css +77 -16
  256. package/build-style/style.css +77 -16
  257. package/package.json +31 -31
  258. package/src/components/block-draggable/content.scss +1 -1
  259. package/src/components/block-inspector/style.scss +6 -4
  260. package/src/components/block-list/block-html.js +1 -1
  261. package/src/components/block-list/block.native.js +3 -2
  262. package/src/components/block-list/index.native.js +19 -38
  263. package/src/components/block-list/use-in-between-inserter.js +4 -1
  264. package/src/components/block-popover/inbetween.js +2 -13
  265. package/src/components/block-preview/auto.js +2 -17
  266. package/src/components/block-settings-menu/block-settings-dropdown.js +2 -12
  267. package/src/components/caption/index.native.js +0 -1
  268. package/src/components/colors-gradients/style.scss +8 -8
  269. package/src/components/date-format-picker/index.js +1 -1
  270. package/src/components/editor-styles/index.js +29 -1
  271. package/src/components/global-styles/README.md +129 -16
  272. package/src/components/global-styles/border-panel.js +13 -32
  273. package/src/components/global-styles/color-panel.js +706 -0
  274. package/src/components/global-styles/dimensions-panel.js +43 -55
  275. package/src/components/global-styles/effects-panel.js +228 -0
  276. package/src/components/global-styles/filters-panel.js +157 -0
  277. package/src/components/global-styles/get-block-css-selector.js +118 -0
  278. package/src/components/global-styles/hooks.js +90 -0
  279. package/src/components/global-styles/index.js +4 -1
  280. package/src/components/global-styles/style.scss +42 -0
  281. package/src/components/global-styles/test/use-global-styles-output.js +34 -5
  282. package/src/components/global-styles/typography-panel.js +26 -51
  283. package/src/components/global-styles/use-global-styles-output.js +188 -89
  284. package/src/components/global-styles/utils.js +3 -0
  285. package/src/components/iframe/index.js +1 -1
  286. package/src/components/image-size-control/index.js +4 -3
  287. package/src/components/image-size-control/test/index.js +2 -2
  288. package/src/components/image-size-control/use-dimension-handler.js +4 -3
  289. package/src/components/index.js +4 -1
  290. package/src/components/inner-blocks/README.md +1 -1
  291. package/src/components/inserter/block-patterns-tab.js +3 -1
  292. package/src/components/inspector-controls-tabs/position-controls-panel.js +40 -9
  293. package/src/components/inspector-controls-tabs/utils.js +4 -3
  294. package/src/components/line-height-control/index.js +10 -1
  295. package/src/components/list-view/README.md +2 -0
  296. package/src/components/list-view/appender.js +101 -0
  297. package/src/components/list-view/block.js +6 -4
  298. package/src/components/list-view/branch.js +30 -1
  299. package/src/components/list-view/index.js +60 -11
  300. package/src/components/list-view/style.scss +22 -1
  301. package/src/components/list-view/test/use-list-view-drop-zone.js +188 -0
  302. package/src/components/list-view/use-list-view-client-ids.js +5 -3
  303. package/src/components/list-view/use-list-view-drop-zone.js +9 -3
  304. package/src/components/media-replace-flow/index.js +36 -24
  305. package/src/components/media-replace-flow/style.scss +5 -2
  306. package/src/components/off-canvas-editor/block-contents.js +4 -0
  307. package/src/components/off-canvas-editor/index.js +15 -11
  308. package/src/components/resizable-box-popover/index.js +27 -0
  309. package/src/components/rich-text/format-edit.js +2 -32
  310. package/src/components/rich-text/index.js +0 -1
  311. package/src/components/rich-text/index.native.js +2 -5
  312. package/src/components/spacing-sizes-control/spacing-input-control.js +10 -0
  313. package/src/components/spacing-sizes-control/style.scss +7 -7
  314. package/src/components/writing-flow/use-input.js +4 -5
  315. package/src/hooks/anchor.js +1 -1
  316. package/src/hooks/border.js +1 -2
  317. package/src/hooks/color.js +120 -296
  318. package/src/hooks/content-lock-ui.js +6 -2
  319. package/src/hooks/{color-panel.js → contrast-checker.js} +10 -46
  320. package/src/hooks/dimensions.js +0 -1
  321. package/src/hooks/duotone.js +121 -76
  322. package/src/hooks/margin.js +31 -26
  323. package/src/hooks/padding.js +24 -18
  324. package/src/hooks/position.js +3 -3
  325. package/src/hooks/style.js +29 -28
  326. package/src/hooks/test/utils.js +0 -104
  327. package/src/hooks/typography.js +0 -1
  328. package/src/hooks/utils.js +31 -74
  329. package/src/layouts/grid.js +172 -0
  330. package/src/layouts/index.js +2 -1
  331. package/src/layouts/test/grid.js +21 -0
  332. package/src/layouts/utils.js +2 -2
  333. package/src/private-apis.js +4 -0
  334. package/src/store/actions.js +1 -1
  335. package/src/style.scss +1 -0
  336. package/src/utils/object.js +69 -0
  337. package/src/utils/test/object.js +145 -0
  338. package/tsconfig.tsbuildinfo +1 -1
  339. package/build/components/rich-text/use-native-props.js +0 -11
  340. package/build/components/rich-text/use-native-props.js.map +0 -1
  341. package/build/components/rich-text/use-native-props.native.js +0 -24
  342. package/build/components/rich-text/use-native-props.native.js.map +0 -1
  343. package/build/hooks/color-panel.js.map +0 -1
  344. package/build-module/components/rich-text/use-native-props.js +0 -4
  345. package/build-module/components/rich-text/use-native-props.js.map +0 -1
  346. package/build-module/components/rich-text/use-native-props.native.js +0 -15
  347. package/build-module/components/rich-text/use-native-props.native.js.map +0 -1
  348. package/build-module/hooks/color-panel.js.map +0 -1
  349. package/src/components/rich-text/use-native-props.js +0 -3
  350. package/src/components/rich-text/use-native-props.native.js +0 -17
@@ -88,7 +88,7 @@ const withInspectorControl = (0, _compose.createHigherOrderComponent)(BlockEdit
88
88
  className: "html-anchor-control",
89
89
  label: (0, _i18n.__)('HTML anchor'),
90
90
  help: (0, _element.createElement)(_element.Fragment, null, (0, _i18n.__)('Enter a word or two — without spaces — to make a unique web address just for this block, called an “anchor.” Then, you’ll be able to link directly to this section of your page.'), isWeb && (0, _element.createElement)(_components.ExternalLink, {
91
- href: (0, _i18n.__)('https://wordpress.org/support/article/page-jumps/')
91
+ href: (0, _i18n.__)('https://wordpress.org/documentation/article/page-jumps/')
92
92
  }, (0, _i18n.__)('Learn more about anchors'))),
93
93
  value: props.attributes.anchor || '',
94
94
  placeholder: !isWeb ? (0, _i18n.__)('Add an anchor') : null,
@@ -1 +1 @@
1
- {"version":3,"sources":["@wordpress/block-editor/src/hooks/anchor.js"],"names":["ANCHOR_REGEX","ANCHOR_SCHEMA","type","source","attribute","selector","addAttribute","settings","attributes","anchor","withInspectorControl","BlockEdit","props","hasAnchor","name","isSelected","isWeb","Platform","OS","textControl","nextValue","replace","setAttributes","addSaveProps","extraProps","blockType","id"],"mappings":";;;;;;;;;AAQA;;AALA;;AACA;;AACA;;AACA;;AACA;;AAMA;;AAbA;AACA;AACA;;AAQA;AACA;AACA;;AAGA;AACA;AACA;AACA;AACA;AACA,MAAMA,YAAY,GAAG,QAArB;AAEA,MAAMC,aAAa,GAAG;AACrBC,EAAAA,IAAI,EAAE,QADe;AAErBC,EAAAA,MAAM,EAAE,WAFa;AAGrBC,EAAAA,SAAS,EAAE,IAHU;AAIrBC,EAAAA,QAAQ,EAAE;AAJW,CAAtB;AAOA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AACO,SAASC,YAAT,CAAuBC,QAAvB,EAAkC;AAA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qB;AACpBb,YAAAA,MAAM,EAAEW;AADY,WAArB;AAGA,SA5BF;AA6BC,QAAA,cAAc,EAAC,MA7BhB;AA8BC,QAAA,YAAY,EAAC;AA9Bd,QADD;AAmCA,aACC,qDACC,4BAAC,SAAD,EAAgBR,KAAhB,CADD,EAEGI,KAAK,IACN,4BAAC,8BAAD;AAAmB,QAAA,KAAK,EAAC;AAAzB,SACGG,WADH,CAHF,EAaG,CAAEH,KAAF,IAAWJ,KAAK,CAACE,IAAN,KAAe,cAA1B,IACD,4BAAC,8BAAD,QACC,4BAAC,qBAAD;AAAW,QAAA,KAAK,EAAG,cAAI,kBAAJ;AAAnB,SACGK,WADH,CADD,CAdF,CADD;AAuBA;;AAED,WAAO,4BAAC,SAAD,EAAgBP,KAAhB,CAAP;AACA,GAlED;AAmEA,CArEkC,EAsEnC,sBAtEmC,CAA7B;AAyEP;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;;AACO,SAASW,YAAT,CAAuBC,UAAvB,EAAmCC,SAAnC,EAA8CjB,UAA9C,EAA2D;AACjE,MAAK,6BAAiBiB,SAAjB,EAA4B,QAA5B,CAAL,EAA8C;AAC7CD,IAAAA,UAAU,CAACE,EAAX,GAAgBlB,UAAU,CAACC,MAAX,KAAsB,EAAtB,GAA2B,IAA3B,GAAkCD,UAAU,CAACC,MAA7D;AACA;;AAED,SAAOe,UAAP;AACA;;AAED,sBAAW,0BAAX,EAAuC,uBAAvC,EAAgElB,YAAhE;AACA,sBACC,kBADD,EAEC,2CAFD,EAGCI,oBAHD;AAKA,sBACC,kCADD,EAEC,wBAFD,EAGCa,YAHD","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { addFilter } from '@wordpress/hooks';\nimport { PanelBody, TextControl, ExternalLink } from '@wordpress/components';\nimport { __ } from '@wordpress/i18n';\nimport { hasBlockSupport } from '@wordpress/blocks';\nimport { createHigherOrderComponent } from '@wordpress/compose';\nimport { Platform } from '@wordpress/element';\n\n/**\n * Internal dependencies\n */\nimport { InspectorControls } from '../components';\n\n/**\n * Regular expression matching invalid anchor characters for replacement.\n *\n * @type {RegExp}\n */\nconst ANCHOR_REGEX = /[\\s#]/g;\n\nconst ANCHOR_SCHEMA = {\n\ttype: 'string',\n\tsource: 'attribute',\n\tattribute: 'id',\n\tselector: '*',\n};\n\n/**\n * Filters registered block settings, extending attributes with anchor using ID\n * of the first node.\n *\n * @param {Object} settings Original block settings.\n *\n * @return {Object} Filtered block settings.\n */\nexport function addAttribute( settings ) {\n\t// Allow blocks to specify their own attribute definition with default values if needed.\n\tif ( 'type' in ( settings.attributes?.anchor ?? {} ) ) {\n\t\treturn settings;\n\t}\n\tif ( hasBlockSupport( settings, 'anchor' ) ) {\n\t\t// Gracefully handle if settings.attributes is undefined.\n\t\tsettings.attributes = {\n\t\t\t...settings.attributes,\n\t\t\tanchor: ANCHOR_SCHEMA,\n\t\t};\n\t}\n\n\treturn settings;\n}\n\n/**\n * Override the default edit UI to include a new block inspector control for\n * assigning the anchor ID, if block supports anchor.\n *\n * @param {WPComponent} BlockEdit Original component.\n *\n * @return {WPComponent} Wrapped component.\n */\nexport const withInspectorControl = createHigherOrderComponent(\n\t( BlockEdit ) => {\n\t\treturn ( props ) => {\n\t\t\tconst hasAnchor = hasBlockSupport( props.name, 'anchor' );\n\n\t\t\tif ( hasAnchor && props.isSelected ) {\n\t\t\t\tconst isWeb = Platform.OS === 'web';\n\t\t\t\tconst textControl = (\n\t\t\t\t\t<TextControl\n\t\t\t\t\t\t__nextHasNoMarginBottom\n\t\t\t\t\t\tclassName=\"html-anchor-control\"\n\t\t\t\t\t\tlabel={ __( 'HTML anchor' ) }\n\t\t\t\t\t\thelp={\n\t\t\t\t\t\t\t<>\n\t\t\t\t\t\t\t\t{ __(\n\t\t\t\t\t\t\t\t\t'Enter a word or two — without spaces — to make a unique web address just for this block, called an “anchor.” Then, you’ll be able to link directly to this section of your page.'\n\t\t\t\t\t\t\t\t) }\n\n\t\t\t\t\t\t\t\t{ isWeb && (\n\t\t\t\t\t\t\t\t\t<ExternalLink\n\t\t\t\t\t\t\t\t\t\thref={ __(\n\t\t\t\t\t\t\t\t\t\t\t'https://wordpress.org/support/article/page-jumps/'\n\t\t\t\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t\t\t{ __( 'Learn more about anchors' ) }\n\t\t\t\t\t\t\t\t\t</ExternalLink>\n\t\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\t</>\n\t\t\t\t\t\t}\n\t\t\t\t\t\tvalue={ props.attributes.anchor || '' }\n\t\t\t\t\t\tplaceholder={ ! isWeb ? __( 'Add an anchor' ) : null }\n\t\t\t\t\t\tonChange={ ( nextValue ) => {\n\t\t\t\t\t\t\tnextValue = nextValue.replace( ANCHOR_REGEX, '-' );\n\t\t\t\t\t\t\tprops.setAttributes( {\n\t\t\t\t\t\t\t\tanchor: nextValue,\n\t\t\t\t\t\t\t} );\n\t\t\t\t\t\t} }\n\t\t\t\t\t\tautoCapitalize=\"none\"\n\t\t\t\t\t\tautoComplete=\"off\"\n\t\t\t\t\t/>\n\t\t\t\t);\n\n\t\t\t\treturn (\n\t\t\t\t\t<>\n\t\t\t\t\t\t<BlockEdit { ...props } />\n\t\t\t\t\t\t{ isWeb && (\n\t\t\t\t\t\t\t<InspectorControls group=\"advanced\">\n\t\t\t\t\t\t\t\t{ textControl }\n\t\t\t\t\t\t\t</InspectorControls>\n\t\t\t\t\t\t) }\n\t\t\t\t\t\t{ /*\n\t\t\t\t\t\t * We plan to remove scoping anchors to 'core/heading' to support\n\t\t\t\t\t\t * anchors for all eligble blocks. Additionally we plan to explore\n\t\t\t\t\t\t * leveraging InspectorAdvancedControls instead of a custom\n\t\t\t\t\t\t * PanelBody title. https://github.com/WordPress/gutenberg/issues/28363\n\t\t\t\t\t\t */ }\n\t\t\t\t\t\t{ ! isWeb && props.name === 'core/heading' && (\n\t\t\t\t\t\t\t<InspectorControls>\n\t\t\t\t\t\t\t\t<PanelBody title={ __( 'Heading settings' ) }>\n\t\t\t\t\t\t\t\t\t{ textControl }\n\t\t\t\t\t\t\t\t</PanelBody>\n\t\t\t\t\t\t\t</InspectorControls>\n\t\t\t\t\t\t) }\n\t\t\t\t\t</>\n\t\t\t\t);\n\t\t\t}\n\n\t\t\treturn <BlockEdit { ...props } />;\n\t\t};\n\t},\n\t'withInspectorControl'\n);\n\n/**\n * Override props assigned to save component to inject anchor ID, if block\n * supports anchor. This is only applied if the block's save result is an\n * element and not a markup string.\n *\n * @param {Object} extraProps Additional props applied to save element.\n * @param {Object} blockType Block type.\n * @param {Object} attributes Current block attributes.\n *\n * @return {Object} Filtered props applied to save element.\n */\nexport function addSaveProps( extraProps, blockType, attributes ) {\n\tif ( hasBlockSupport( blockType, 'anchor' ) ) {\n\t\textraProps.id = attributes.anchor === '' ? null : attributes.anchor;\n\t}\n\n\treturn extraProps;\n}\n\naddFilter( 'blocks.registerBlockType', 'core/anchor/attribute', addAttribute );\naddFilter(\n\t'editor.BlockEdit',\n\t'core/editor/anchor/with-inspector-control',\n\twithInspectorControl\n);\naddFilter(\n\t'blocks.getSaveContent.extraProps',\n\t'core/anchor/save-props',\n\taddSaveProps\n);\n"]}
1
+ {"version":3,"sources":["@wordpress/block-editor/src/hooks/anchor.js"],"names":["ANCHOR_REGEX","ANCHOR_SCHEMA","type","source","attribute","selector","addAttribute","settings","attributes","anchor","withInspectorControl","BlockEdit","props","hasAnchor","name","isSelected","isWeb","Platform","OS","textControl","nextValue","replace","setAttributes","addSaveProps","extraProps","blockType","id"],"mappings":";;;;;;;;;AAQA;;AALA;;AACA;;AACA;;AACA;;AACA;;AAMA;;AAbA;AACA;AACA;;AAQA;AACA;AACA;;AAGA;AACA;AACA;AACA;AACA;AACA,MAAMA,YAAY,GAAG,QAArB;AAEA,MAAMC,aAAa,GAAG;AACrBC,EAAAA,IAAI,EAAE,QADe;AAErBC,EAAAA,MAAM,EAAE,WAFa;AAGrBC,EAAAA,SAAS,EAA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,SAAF,IAAiB;AAC3BA,UAAAA,SAAS,GAAGA,SAAS,CAACC,OAAV,CAAmBrB,YAAnB,EAAiC,GAAjC,CAAZ;AACAY,UAAAA,KAAK,CAACU,aAAN,CAAqB;AACpBb,YAAAA,MAAM,EAAEW;AADY,WAArB;AAGA,SA5BF;AA6BC,QAAA,cAAc,EAAC,MA7BhB;AA8BC,QAAA,YAAY,EAAC;AA9Bd,QADD;AAmCA,aACC,qDACC,4BAAC,SAAD,EAAgBR,KAAhB,CADD,EAEGI,KAAK,IACN,4BAAC,8BAAD;AAAmB,QAAA,KAAK,EAAC;AAAzB,SACGG,WADH,CAHF,EAaG,CAAEH,KAAF,IAAWJ,KAAK,CAACE,IAAN,KAAe,cAA1B,IACD,4BAAC,8BAAD,QACC,4BAAC,qBAAD;AAAW,QAAA,KAAK,EAAG,cAAI,kBAAJ;AAAnB,SACGK,WADH,CADD,CAdF,CADD;AAuBA;;AAED,WAAO,4BAAC,SAAD,EAAgBP,KAAhB,CAAP;AACA,GAlED;AAmEA,CArEkC,EAsEnC,sBAtEmC,CAA7B;AAyEP;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;;AACO,SAASW,YAAT,CAAuBC,UAAvB,EAAmCC,SAAnC,EAA8CjB,UAA9C,EAA2D;AACjE,MAAK,6BAAiBiB,SAAjB,EAA4B,QAA5B,CAAL,EAA8C;AAC7CD,IAAAA,UAAU,CAACE,EAAX,GAAgBlB,UAAU,CAACC,MAAX,KAAsB,EAAtB,GAA2B,IAA3B,GAAkCD,UAAU,CAACC,MAA7D;AACA;;AAED,SAAOe,UAAP;AACA;;AAED,sBAAW,0BAAX,EAAuC,uBAAvC,EAAgElB,YAAhE;AACA,sBACC,kBADD,EAEC,2CAFD,EAGCI,oBAHD;AAKA,sBACC,kCADD,EAEC,wBAFD,EAGCa,YAHD","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { addFilter } from '@wordpress/hooks';\nimport { PanelBody, TextControl, ExternalLink } from '@wordpress/components';\nimport { __ } from '@wordpress/i18n';\nimport { hasBlockSupport } from '@wordpress/blocks';\nimport { createHigherOrderComponent } from '@wordpress/compose';\nimport { Platform } from '@wordpress/element';\n\n/**\n * Internal dependencies\n */\nimport { InspectorControls } from '../components';\n\n/**\n * Regular expression matching invalid anchor characters for replacement.\n *\n * @type {RegExp}\n */\nconst ANCHOR_REGEX = /[\\s#]/g;\n\nconst ANCHOR_SCHEMA = {\n\ttype: 'string',\n\tsource: 'attribute',\n\tattribute: 'id',\n\tselector: '*',\n};\n\n/**\n * Filters registered block settings, extending attributes with anchor using ID\n * of the first node.\n *\n * @param {Object} settings Original block settings.\n *\n * @return {Object} Filtered block settings.\n */\nexport function addAttribute( settings ) {\n\t// Allow blocks to specify their own attribute definition with default values if needed.\n\tif ( 'type' in ( settings.attributes?.anchor ?? {} ) ) {\n\t\treturn settings;\n\t}\n\tif ( hasBlockSupport( settings, 'anchor' ) ) {\n\t\t// Gracefully handle if settings.attributes is undefined.\n\t\tsettings.attributes = {\n\t\t\t...settings.attributes,\n\t\t\tanchor: ANCHOR_SCHEMA,\n\t\t};\n\t}\n\n\treturn settings;\n}\n\n/**\n * Override the default edit UI to include a new block inspector control for\n * assigning the anchor ID, if block supports anchor.\n *\n * @param {WPComponent} BlockEdit Original component.\n *\n * @return {WPComponent} Wrapped component.\n */\nexport const withInspectorControl = createHigherOrderComponent(\n\t( BlockEdit ) => {\n\t\treturn ( props ) => {\n\t\t\tconst hasAnchor = hasBlockSupport( props.name, 'anchor' );\n\n\t\t\tif ( hasAnchor && props.isSelected ) {\n\t\t\t\tconst isWeb = Platform.OS === 'web';\n\t\t\t\tconst textControl = (\n\t\t\t\t\t<TextControl\n\t\t\t\t\t\t__nextHasNoMarginBottom\n\t\t\t\t\t\tclassName=\"html-anchor-control\"\n\t\t\t\t\t\tlabel={ __( 'HTML anchor' ) }\n\t\t\t\t\t\thelp={\n\t\t\t\t\t\t\t<>\n\t\t\t\t\t\t\t\t{ __(\n\t\t\t\t\t\t\t\t\t'Enter a word or two — without spaces — to make a unique web address just for this block, called an “anchor.” Then, you’ll be able to link directly to this section of your page.'\n\t\t\t\t\t\t\t\t) }\n\n\t\t\t\t\t\t\t\t{ isWeb && (\n\t\t\t\t\t\t\t\t\t<ExternalLink\n\t\t\t\t\t\t\t\t\t\thref={ __(\n\t\t\t\t\t\t\t\t\t\t\t'https://wordpress.org/documentation/article/page-jumps/'\n\t\t\t\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t\t\t{ __( 'Learn more about anchors' ) }\n\t\t\t\t\t\t\t\t\t</ExternalLink>\n\t\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\t</>\n\t\t\t\t\t\t}\n\t\t\t\t\t\tvalue={ props.attributes.anchor || '' }\n\t\t\t\t\t\tplaceholder={ ! isWeb ? __( 'Add an anchor' ) : null }\n\t\t\t\t\t\tonChange={ ( nextValue ) => {\n\t\t\t\t\t\t\tnextValue = nextValue.replace( ANCHOR_REGEX, '-' );\n\t\t\t\t\t\t\tprops.setAttributes( {\n\t\t\t\t\t\t\t\tanchor: nextValue,\n\t\t\t\t\t\t\t} );\n\t\t\t\t\t\t} }\n\t\t\t\t\t\tautoCapitalize=\"none\"\n\t\t\t\t\t\tautoComplete=\"off\"\n\t\t\t\t\t/>\n\t\t\t\t);\n\n\t\t\t\treturn (\n\t\t\t\t\t<>\n\t\t\t\t\t\t<BlockEdit { ...props } />\n\t\t\t\t\t\t{ isWeb && (\n\t\t\t\t\t\t\t<InspectorControls group=\"advanced\">\n\t\t\t\t\t\t\t\t{ textControl }\n\t\t\t\t\t\t\t</InspectorControls>\n\t\t\t\t\t\t) }\n\t\t\t\t\t\t{ /*\n\t\t\t\t\t\t * We plan to remove scoping anchors to 'core/heading' to support\n\t\t\t\t\t\t * anchors for all eligble blocks. Additionally we plan to explore\n\t\t\t\t\t\t * leveraging InspectorAdvancedControls instead of a custom\n\t\t\t\t\t\t * PanelBody title. https://github.com/WordPress/gutenberg/issues/28363\n\t\t\t\t\t\t */ }\n\t\t\t\t\t\t{ ! isWeb && props.name === 'core/heading' && (\n\t\t\t\t\t\t\t<InspectorControls>\n\t\t\t\t\t\t\t\t<PanelBody title={ __( 'Heading settings' ) }>\n\t\t\t\t\t\t\t\t\t{ textControl }\n\t\t\t\t\t\t\t\t</PanelBody>\n\t\t\t\t\t\t\t</InspectorControls>\n\t\t\t\t\t\t) }\n\t\t\t\t\t</>\n\t\t\t\t);\n\t\t\t}\n\n\t\t\treturn <BlockEdit { ...props } />;\n\t\t};\n\t},\n\t'withInspectorControl'\n);\n\n/**\n * Override props assigned to save component to inject anchor ID, if block\n * supports anchor. This is only applied if the block's save result is an\n * element and not a markup string.\n *\n * @param {Object} extraProps Additional props applied to save element.\n * @param {Object} blockType Block type.\n * @param {Object} attributes Current block attributes.\n *\n * @return {Object} Filtered props applied to save element.\n */\nexport function addSaveProps( extraProps, blockType, attributes ) {\n\tif ( hasBlockSupport( blockType, 'anchor' ) ) {\n\t\textraProps.id = attributes.anchor === '' ? null : attributes.anchor;\n\t}\n\n\treturn extraProps;\n}\n\naddFilter( 'blocks.registerBlockType', 'core/anchor/attribute', addAttribute );\naddFilter(\n\t'editor.BlockEdit',\n\t'core/editor/anchor/with-inspector-control',\n\twithInspectorControl\n);\naddFilter(\n\t'blocks.getSaveContent.extraProps',\n\t'core/anchor/save-props',\n\taddSaveProps\n);\n"]}
@@ -117,7 +117,7 @@ function styleToAttributes(style) {
117
117
  }
118
118
 
119
119
  const borderColorValue = style === null || style === void 0 ? void 0 : (_style$border = style.border) === null || _style$border === void 0 ? void 0 : _style$border.color;
120
- const borderColorSlug = borderColorValue !== null && borderColorValue !== void 0 && borderColorValue.startsWith('var:preset|color|') ? borderColorSlug.substring('var:preset|color|'.length) : undefined;
120
+ const borderColorSlug = borderColorValue !== null && borderColorValue !== void 0 && borderColorValue.startsWith('var:preset|color|') ? borderColorValue.substring('var:preset|color|'.length) : undefined;
121
121
  const updatedStyle = { ...style
122
122
  };
123
123
  updatedStyle.border = { ...updatedStyle.border,
@@ -189,7 +189,6 @@ function BorderPanel(props) {
189
189
  return (0, _element.createElement)(_globalStyles.BorderPanel, {
190
190
  as: BordersInspectorControl,
191
191
  panelId: clientId,
192
- name: name,
193
192
  settings: settings,
194
193
  value: value,
195
194
  onChange: onChange,
@@ -1 +1 @@
1
- {"version":3,"sources":["@wordpress/block-editor/src/hooks/border.js"],"names":["BORDER_SUPPORT_KEY","getColorByProperty","colors","property","value","matchedColor","some","origin","color","getMultiOriginColor","namedColor","customColor","colorObject","undefined","getColorSlugFromVariable","exec","styleToAttributes","style","border","borderColor","borderColorValue","borderColorSlug","startsWith","substring","length","updatedStyle","attributesToStyle","attributes","BordersInspectorControl","children","resetAllFilter","attributesResetAllFilter","existingStyle","BorderPanel","props","clientId","name","setAttributes","settings","isEnabled","onChange","newStyle","defaultControls","hasBorderSupport","blockName","feature","Platform","OS","support","radius","width","removeBorderAttribute","attribute","addAttributes","type","addSaveProps","blockType","borderClasses","getBorderClasses","newClassName","className","borderColorClass","addEditProps","existingGetEditWrapperProps","getEditWrapperProps","withBorderColorPaletteStyles","BlockListBlock","borderTopColor","top","borderRightColor","right","borderBottomColor","bottom","borderLeftColor","left","extraStyles","wrapperProps"],"mappings":";;;;;;;;;;;;;;;AAWA;;;;AARA;;AAKA;;AACA;;AACA;;AAEA;;AAKA;;AACA;;AACA;;AACA;;AAKA;;AAzBA;AACA;AACA;;AAGA;AACA;AACA;;AAOA;AACA;AACA;AAcO,MAAMA,kBAAkB,GAAG,sBAA3B;;;AAEP,MAAMC,kBAAkB,GAAG,CAAEC,MAAF,EAAUC,QAAV,EAAoBC,KAApB,KAA+B;AACzD,MAAIC,YAAJ;AAEAH,EAAAA,MAAM,CAACI,IAAP,CAAeC,MAAF,IACZA,MAAM,CAACL,MAAP,CAAcI,IAAd,CAAsBE,KAAF,IAAa;AAChC,QAAKA,KAAK,CAAEL,QAAF,CAAL,KAAsBC,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YAAzB;AACAA,EAAAA,YAAY,GAAG,EACd,GAAG1C,KAAK,CAAC0C,YADK;AAEd3D,IAAAA,KAAK,EAAE,EACN,2BAAGiB,KAAK,CAAC0C,YAAT,wDAAG,oBAAoB3D,KAAvB,CADM;AAEN,SAAG0D;AAFG;AAFO,GAAf;AAQA,SAAO,4BAAC,cAAD,6BAAqBzC,KAArB;AAA6B,IAAA,YAAY,EAAG0C;AAA5C,KAAP;AACA,CAtD0C,CAArC;;AAyDP,sBACC,0BADD,EAEC,2BAFD,EAGCvB,aAHD;AAMA,sBACC,kCADD,EAEC,0BAFD,EAGCE,YAHD;AAMA,sBACC,0BADD,EAEC,0BAFD,EAGCO,YAHD;AAMA,sBACC,uBADD,EAEC,8CAFD,EAGCG,4BAHD","sourcesContent":["/**\n * External dependencies\n */\nimport classnames from 'classnames';\n\n/**\n * WordPress dependencies\n */\nimport { getBlockSupport } from '@wordpress/blocks';\nimport { __experimentalHasSplitBorders as hasSplitBorders } from '@wordpress/components';\nimport { createHigherOrderComponent } from '@wordpress/compose';\nimport { Platform, useCallback, useMemo } from '@wordpress/element';\nimport { addFilter } from '@wordpress/hooks';\n\n/**\n * Internal dependencies\n */\nimport { getColorClassName } from '../components/colors';\nimport InspectorControls from '../components/inspector-controls';\nimport useMultipleOriginColorsAndGradients from '../components/colors-gradients/use-multiple-origin-colors-and-gradients';\nimport {\n\tcleanEmptyObject,\n\tshouldSkipSerialization,\n\tuseBlockSettings,\n} from './utils';\nimport {\n\tuseHasBorderPanel,\n\tBorderPanel as StylesBorderPanel,\n} from '../components/global-styles';\n\nexport const BORDER_SUPPORT_KEY = '__experimentalBorder';\n\nconst getColorByProperty = ( colors, property, value ) => {\n\tlet matchedColor;\n\n\tcolors.some( ( origin ) =>\n\t\torigin.colors.some( ( color ) => {\n\t\t\tif ( color[ property ] === value ) {\n\t\t\t\tmatchedColor = color;\n\t\t\t\treturn true;\n\t\t\t}\n\n\t\t\treturn false;\n\t\t} )\n\t);\n\n\treturn matchedColor;\n};\n\nexport const getMultiOriginColor = ( { colors, namedColor, customColor } ) => {\n\t// Search each origin (default, theme, or user) for matching color by name.\n\tif ( namedColor ) {\n\t\tconst colorObject = getColorByProperty( colors, 'slug', namedColor );\n\t\tif ( colorObject ) {\n\t\t\treturn colorObject;\n\t\t}\n\t}\n\n\t// Skip if no custom color or matching named color.\n\tif ( ! customColor ) {\n\t\treturn { color: undefined };\n\t}\n\n\t// Attempt to find color via custom color value or build new object.\n\tconst colorObject = getColorByProperty( colors, 'color', customColor );\n\treturn colorObject ? colorObject : { color: customColor };\n};\n\nfunction getColorSlugFromVariable( value ) {\n\tconst namedColor = /var:preset\\|color\\|(.+)/.exec( value );\n\tif ( namedColor && namedColor[ 1 ] ) {\n\t\treturn namedColor[ 1 ];\n\t}\n\treturn null;\n}\n\nfunction styleToAttributes( style ) {\n\tif ( hasSplitBorders( style?.border ) ) {\n\t\treturn {\n\t\t\tstyle,\n\t\t\tborderColor: undefined,\n\t\t};\n\t}\n\n\tconst borderColorValue = style?.border?.color;\n\tconst borderColorSlug = borderColorValue?.startsWith( 'var:preset|color|' )\n\t\t? borderColorSlug.substring( 'var:preset|color|'.length )\n\t\t: undefined;\n\tconst updatedStyle = { ...style };\n\tupdatedStyle.border = {\n\t\t...updatedStyle.border,\n\t\tcolor: borderColorSlug ? undefined : borderColorValue,\n\t};\n\treturn {\n\t\tstyle: cleanEmptyObject( updatedStyle ),\n\t\tborderColor: borderColorSlug,\n\t};\n}\n\nfunction attributesToStyle( attributes ) {\n\tif ( hasSplitBorders( attributes.style?.border ) ) {\n\t\treturn attributes.style;\n\t}\n\treturn {\n\t\t...attributes.style,\n\t\tborder: {\n\t\t\t...attributes.style?.border,\n\t\t\tcolor: attributes.borderColor\n\t\t\t\t? 'var:preset|color|' + attributes.borderColor\n\t\t\t\t: attributes.style?.border?.color,\n\t\t},\n\t};\n}\n\nfunction BordersInspectorControl( { children, resetAllFilter } ) {\n\tconst attributesResetAllFilter = useCallback(\n\t\t( attributes ) => {\n\t\t\tconst existingStyle = attributesToStyle( attributes );\n\t\t\tconst updatedStyle = resetAllFilter( existingStyle );\n\t\t\treturn {\n\t\t\t\t...attributes,\n\t\t\t\t...styleToAttributes( updatedStyle ),\n\t\t\t};\n\t\t},\n\t\t[ resetAllFilter ]\n\t);\n\n\treturn (\n\t\t<InspectorControls\n\t\t\tgroup=\"border\"\n\t\t\tresetAllFilter={ attributesResetAllFilter }\n\t\t>\n\t\t\t{ children }\n\t\t</InspectorControls>\n\t);\n}\n\nexport function BorderPanel( props ) {\n\tconst { clientId, name, attributes, setAttributes } = props;\n\tconst settings = useBlockSettings( name );\n\tconst isEnabled = useHasBorderPanel( settings );\n\tconst value = useMemo( () => {\n\t\treturn attributesToStyle( {\n\t\t\tstyle: attributes.style,\n\t\t\tborderColor: attributes.borderColor,\n\t\t} );\n\t}, [ attributes.style, attributes.borderColor ] );\n\n\tconst onChange = ( newStyle ) => {\n\t\tsetAttributes( styleToAttributes( newStyle ) );\n\t};\n\n\tif ( ! isEnabled ) {\n\t\treturn null;\n\t}\n\n\tconst defaultControls = getBlockSupport( props.name, [\n\t\tBORDER_SUPPORT_KEY,\n\t\t'__experimentalDefaultControls',\n\t] );\n\n\treturn (\n\t\t<StylesBorderPanel\n\t\t\tas={ BordersInspectorControl }\n\t\t\tpanelId={ clientId }\n\t\t\tname={ name }\n\t\t\tsettings={ settings }\n\t\t\tvalue={ value }\n\t\t\tonChange={ onChange }\n\t\t\tdefaultControls={ defaultControls }\n\t\t/>\n\t);\n}\n\n/**\n * Determine whether there is block support for border properties.\n *\n * @param {string} blockName Block name.\n * @param {string} feature Border feature to check support for.\n *\n * @return {boolean} Whether there is support.\n */\nexport function hasBorderSupport( blockName, feature = 'any' ) {\n\tif ( Platform.OS !== 'web' ) {\n\t\treturn false;\n\t}\n\n\tconst support = getBlockSupport( blockName, BORDER_SUPPORT_KEY );\n\n\tif ( support === true ) {\n\t\treturn true;\n\t}\n\n\tif ( feature === 'any' ) {\n\t\treturn !! (\n\t\t\tsupport?.color ||\n\t\t\tsupport?.radius ||\n\t\t\tsupport?.width ||\n\t\t\tsupport?.style\n\t\t);\n\t}\n\n\treturn !! support?.[ feature ];\n}\n\n/**\n * Returns a new style object where the specified border attribute has been\n * removed.\n *\n * @param {Object} style Styles from block attributes.\n * @param {string} attribute The border style attribute to clear.\n *\n * @return {Object} Style object with the specified attribute removed.\n */\nexport function removeBorderAttribute( style, attribute ) {\n\treturn cleanEmptyObject( {\n\t\t...style,\n\t\tborder: {\n\t\t\t...style?.border,\n\t\t\t[ attribute ]: undefined,\n\t\t},\n\t} );\n}\n\n/**\n * Filters registered block settings, extending attributes to include\n * `borderColor` if needed.\n *\n * @param {Object} settings Original block settings.\n *\n * @return {Object} Updated block settings.\n */\nfunction addAttributes( settings ) {\n\tif ( ! hasBorderSupport( settings, 'color' ) ) {\n\t\treturn settings;\n\t}\n\n\t// Allow blocks to specify default value if needed.\n\tif ( settings.attributes.borderColor ) {\n\t\treturn settings;\n\t}\n\n\t// Add new borderColor attribute to block settings.\n\treturn {\n\t\t...settings,\n\t\tattributes: {\n\t\t\t...settings.attributes,\n\t\t\tborderColor: {\n\t\t\t\ttype: 'string',\n\t\t\t},\n\t\t},\n\t};\n}\n\n/**\n * Override props assigned to save component to inject border color.\n *\n * @param {Object} props Additional props applied to save element.\n * @param {Object} blockType Block type definition.\n * @param {Object} attributes Block's attributes.\n *\n * @return {Object} Filtered props to apply to save element.\n */\nfunction addSaveProps( props, blockType, attributes ) {\n\tif (\n\t\t! hasBorderSupport( blockType, 'color' ) ||\n\t\tshouldSkipSerialization( blockType, BORDER_SUPPORT_KEY, 'color' )\n\t) {\n\t\treturn props;\n\t}\n\n\tconst borderClasses = getBorderClasses( attributes );\n\tconst newClassName = classnames( props.className, borderClasses );\n\n\t// If we are clearing the last of the previous classes in `className`\n\t// set it to `undefined` to avoid rendering empty DOM attributes.\n\tprops.className = newClassName ? newClassName : undefined;\n\n\treturn props;\n}\n\n/**\n * Generates a CSS class name consisting of all the applicable border color\n * classes given the current block attributes.\n *\n * @param {Object} attributes Block's attributes.\n *\n * @return {string} CSS class name.\n */\nexport function getBorderClasses( attributes ) {\n\tconst { borderColor, style } = attributes;\n\tconst borderColorClass = getColorClassName( 'border-color', borderColor );\n\n\treturn classnames( {\n\t\t'has-border-color': borderColor || style?.border?.color,\n\t\t[ borderColorClass ]: !! borderColorClass,\n\t} );\n}\n\n/**\n * Filters the registered block settings to apply border color styles and\n * classnames to the block edit wrapper.\n *\n * @param {Object} settings Original block settings.\n *\n * @return {Object} Filtered block settings.\n */\nfunction addEditProps( settings ) {\n\tif (\n\t\t! hasBorderSupport( settings, 'color' ) ||\n\t\tshouldSkipSerialization( settings, BORDER_SUPPORT_KEY, 'color' )\n\t) {\n\t\treturn settings;\n\t}\n\n\tconst existingGetEditWrapperProps = settings.getEditWrapperProps;\n\tsettings.getEditWrapperProps = ( attributes ) => {\n\t\tlet props = {};\n\n\t\tif ( existingGetEditWrapperProps ) {\n\t\t\tprops = existingGetEditWrapperProps( attributes );\n\t\t}\n\n\t\treturn addSaveProps( props, settings, attributes );\n\t};\n\n\treturn settings;\n}\n\n/**\n * This adds inline styles for color palette colors.\n * Ideally, this is not needed and themes should load their palettes on the editor.\n *\n * @param {Function} BlockListBlock Original component.\n *\n * @return {Function} Wrapped component.\n */\nexport const withBorderColorPaletteStyles = createHigherOrderComponent(\n\t( BlockListBlock ) => ( props ) => {\n\t\tconst { name, attributes } = props;\n\t\tconst { borderColor, style } = attributes;\n\t\tconst { colors } = useMultipleOriginColorsAndGradients();\n\n\t\tif (\n\t\t\t! hasBorderSupport( name, 'color' ) ||\n\t\t\tshouldSkipSerialization( name, BORDER_SUPPORT_KEY, 'color' )\n\t\t) {\n\t\t\treturn <BlockListBlock { ...props } />;\n\t\t}\n\n\t\tconst { color: borderColorValue } = getMultiOriginColor( {\n\t\t\tcolors,\n\t\t\tnamedColor: borderColor,\n\t\t} );\n\t\tconst { color: borderTopColor } = getMultiOriginColor( {\n\t\t\tcolors,\n\t\t\tnamedColor: getColorSlugFromVariable( style?.border?.top?.color ),\n\t\t} );\n\t\tconst { color: borderRightColor } = getMultiOriginColor( {\n\t\t\tcolors,\n\t\t\tnamedColor: getColorSlugFromVariable( style?.border?.right?.color ),\n\t\t} );\n\n\t\tconst { color: borderBottomColor } = getMultiOriginColor( {\n\t\t\tcolors,\n\t\t\tnamedColor: getColorSlugFromVariable(\n\t\t\t\tstyle?.border?.bottom?.color\n\t\t\t),\n\t\t} );\n\t\tconst { color: borderLeftColor } = getMultiOriginColor( {\n\t\t\tcolors,\n\t\t\tnamedColor: getColorSlugFromVariable( style?.border?.left?.color ),\n\t\t} );\n\n\t\tconst extraStyles = {\n\t\t\tborderTopColor: borderTopColor || borderColorValue,\n\t\t\tborderRightColor: borderRightColor || borderColorValue,\n\t\t\tborderBottomColor: borderBottomColor || borderColorValue,\n\t\t\tborderLeftColor: borderLeftColor || borderColorValue,\n\t\t};\n\n\t\tlet wrapperProps = props.wrapperProps;\n\t\twrapperProps = {\n\t\t\t...props.wrapperProps,\n\t\t\tstyle: {\n\t\t\t\t...props.wrapperProps?.style,\n\t\t\t\t...extraStyles,\n\t\t\t},\n\t\t};\n\n\t\treturn <BlockListBlock { ...props } wrapperProps={ wrapperProps } />;\n\t}\n);\n\naddFilter(\n\t'blocks.registerBlockType',\n\t'core/border/addAttributes',\n\taddAttributes\n);\n\naddFilter(\n\t'blocks.getSaveContent.extraProps',\n\t'core/border/addSaveProps',\n\taddSaveProps\n);\n\naddFilter(\n\t'blocks.registerBlockType',\n\t'core/border/addEditProps',\n\taddEditProps\n);\n\naddFilter(\n\t'editor.BlockListBlock',\n\t'core/border/with-border-color-palette-styles',\n\twithBorderColorPaletteStyles\n);\n"]}
1
+ {"version":3,"sources":["@wordpress/block-editor/src/hooks/border.js"],"names":["BORDER_SUPPORT_KEY","getColorByProperty","colors","property","value","matchedColor","some","origin","color","getMultiOriginColor","namedColor","customColor","colorObject","undefined","getColorSlugFromVariable","exec","styleToAttributes","style","border","borderColor","borderColorValue","borderColorSlug","startsWith","substring","length","updatedStyle","attributesToStyle","attributes","BordersInspectorControl","children","resetAllFilter","attributesResetAllFilter","existingStyle","BorderPanel","props","clientId","name","setAttributes","settings","isEnabled","onChange","newStyle","defaultControls","hasBorderSupport","blockName","feature","Platform","OS","support","radius","width","removeBorderAttribute","attribute","addAttributes","type","addSaveProps","blockType","borderClasses","getBorderClasses","newClassName","className","borderColorClass","addEditProps","existingGetEditWrapperProps","getEditWrapperProps","withBorderColorPaletteStyles","BlockListBlock","borderTopColor","top","borderRightColor","right","borderBottomColor","bottom","borderLeftColor","left","extraStyles","wrapperProps"],"mappings":";;;;;;;;;;;;;;;AAWA;;;;AARA;;AAKA;;AACA;;AACA;;AAEA;;AAKA;;AACA;;AACA;;AACA;;AAKA;;AAzBA;AACA;AACA;;AAGA;AACA;AACA;;AAOA;AACA;AACA;AAcO,MAAMA,kBAAkB,GAAG,sBAA3B;;;AAEP,MAAMC,kBAAkB,GAAG,CAAEC,MAAF,EAAUC,QAAV,EAAoBC,KAApB,KAA+B;AACzD,MAAIC,YAAJ;AAEAH,EAAAA,MAAM,CAACI,IAAP,CAAeC,MAAF,IACZA,MAAM,CAACL,MAAP,CAAcI,IAAd,CAAsBE,KAAF,IAAa;AAChC,QAAKA,KAAK,CAAEL,QAAF,CAAL,KAAsBC,KAA3B,EAAmC;AAClCC,MAAAA,YAAY,GAAGG,KAAf;AACA,aAAO,IAAP;AACA;;AAED,WAAO,KAAP;AACA,GAPD,CADD;AAWA,SAAOH,YAAP;AACA,CAfD;;AAiBO,MAAMI,mBAAmB,GAAG,QAA2C;AAAA,MAAzC;AAAEP,IAAAA,MAAF;AAAUQ,IAAAA,UAAV;AAAsBC,IAAAA;AAAtB,GAAyC;;AAC7E;AACA,MAAKD,UAAL,EAAkB;AACjB,UAAME,WAAW,GAAGX,kBAAkB,CAAEC,MAAF,EAAU,MAAV,EAAkBQ,UAAlB,CAAtC;;AACA,QA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BAFD,EAGCO,YAHD;AAMA,sBACC,uBADD,EAEC,8CAFD,EAGCG,4BAHD","sourcesContent":["/**\n * External dependencies\n */\nimport classnames from 'classnames';\n\n/**\n * WordPress dependencies\n */\nimport { getBlockSupport } from '@wordpress/blocks';\nimport { __experimentalHasSplitBorders as hasSplitBorders } from '@wordpress/components';\nimport { createHigherOrderComponent } from '@wordpress/compose';\nimport { Platform, useCallback, useMemo } from '@wordpress/element';\nimport { addFilter } from '@wordpress/hooks';\n\n/**\n * Internal dependencies\n */\nimport { getColorClassName } from '../components/colors';\nimport InspectorControls from '../components/inspector-controls';\nimport useMultipleOriginColorsAndGradients from '../components/colors-gradients/use-multiple-origin-colors-and-gradients';\nimport {\n\tcleanEmptyObject,\n\tshouldSkipSerialization,\n\tuseBlockSettings,\n} from './utils';\nimport {\n\tuseHasBorderPanel,\n\tBorderPanel as StylesBorderPanel,\n} from '../components/global-styles';\n\nexport const BORDER_SUPPORT_KEY = '__experimentalBorder';\n\nconst getColorByProperty = ( colors, property, value ) => {\n\tlet matchedColor;\n\n\tcolors.some( ( origin ) =>\n\t\torigin.colors.some( ( color ) => {\n\t\t\tif ( color[ property ] === value ) {\n\t\t\t\tmatchedColor = color;\n\t\t\t\treturn true;\n\t\t\t}\n\n\t\t\treturn false;\n\t\t} )\n\t);\n\n\treturn matchedColor;\n};\n\nexport const getMultiOriginColor = ( { colors, namedColor, customColor } ) => {\n\t// Search each origin (default, theme, or user) for matching color by name.\n\tif ( namedColor ) {\n\t\tconst colorObject = getColorByProperty( colors, 'slug', namedColor );\n\t\tif ( colorObject ) {\n\t\t\treturn colorObject;\n\t\t}\n\t}\n\n\t// Skip if no custom color or matching named color.\n\tif ( ! customColor ) {\n\t\treturn { color: undefined };\n\t}\n\n\t// Attempt to find color via custom color value or build new object.\n\tconst colorObject = getColorByProperty( colors, 'color', customColor );\n\treturn colorObject ? colorObject : { color: customColor };\n};\n\nfunction getColorSlugFromVariable( value ) {\n\tconst namedColor = /var:preset\\|color\\|(.+)/.exec( value );\n\tif ( namedColor && namedColor[ 1 ] ) {\n\t\treturn namedColor[ 1 ];\n\t}\n\treturn null;\n}\n\nfunction styleToAttributes( style ) {\n\tif ( hasSplitBorders( style?.border ) ) {\n\t\treturn {\n\t\t\tstyle,\n\t\t\tborderColor: undefined,\n\t\t};\n\t}\n\n\tconst borderColorValue = style?.border?.color;\n\tconst borderColorSlug = borderColorValue?.startsWith( 'var:preset|color|' )\n\t\t? borderColorValue.substring( 'var:preset|color|'.length )\n\t\t: undefined;\n\tconst updatedStyle = { ...style };\n\tupdatedStyle.border = {\n\t\t...updatedStyle.border,\n\t\tcolor: borderColorSlug ? undefined : borderColorValue,\n\t};\n\treturn {\n\t\tstyle: cleanEmptyObject( updatedStyle ),\n\t\tborderColor: borderColorSlug,\n\t};\n}\n\nfunction attributesToStyle( attributes ) {\n\tif ( hasSplitBorders( attributes.style?.border ) ) {\n\t\treturn attributes.style;\n\t}\n\treturn {\n\t\t...attributes.style,\n\t\tborder: {\n\t\t\t...attributes.style?.border,\n\t\t\tcolor: attributes.borderColor\n\t\t\t\t? 'var:preset|color|' + attributes.borderColor\n\t\t\t\t: attributes.style?.border?.color,\n\t\t},\n\t};\n}\n\nfunction BordersInspectorControl( { children, resetAllFilter } ) {\n\tconst attributesResetAllFilter = useCallback(\n\t\t( attributes ) => {\n\t\t\tconst existingStyle = attributesToStyle( attributes );\n\t\t\tconst updatedStyle = resetAllFilter( existingStyle );\n\t\t\treturn {\n\t\t\t\t...attributes,\n\t\t\t\t...styleToAttributes( updatedStyle ),\n\t\t\t};\n\t\t},\n\t\t[ resetAllFilter ]\n\t);\n\n\treturn (\n\t\t<InspectorControls\n\t\t\tgroup=\"border\"\n\t\t\tresetAllFilter={ attributesResetAllFilter }\n\t\t>\n\t\t\t{ children }\n\t\t</InspectorControls>\n\t);\n}\n\nexport function BorderPanel( props ) {\n\tconst { clientId, name, attributes, setAttributes } = props;\n\tconst settings = useBlockSettings( name );\n\tconst isEnabled = useHasBorderPanel( settings );\n\tconst value = useMemo( () => {\n\t\treturn attributesToStyle( {\n\t\t\tstyle: attributes.style,\n\t\t\tborderColor: attributes.borderColor,\n\t\t} );\n\t}, [ attributes.style, attributes.borderColor ] );\n\n\tconst onChange = ( newStyle ) => {\n\t\tsetAttributes( styleToAttributes( newStyle ) );\n\t};\n\n\tif ( ! isEnabled ) {\n\t\treturn null;\n\t}\n\n\tconst defaultControls = getBlockSupport( props.name, [\n\t\tBORDER_SUPPORT_KEY,\n\t\t'__experimentalDefaultControls',\n\t] );\n\n\treturn (\n\t\t<StylesBorderPanel\n\t\t\tas={ BordersInspectorControl }\n\t\t\tpanelId={ clientId }\n\t\t\tsettings={ settings }\n\t\t\tvalue={ value }\n\t\t\tonChange={ onChange }\n\t\t\tdefaultControls={ defaultControls }\n\t\t/>\n\t);\n}\n\n/**\n * Determine whether there is block support for border properties.\n *\n * @param {string} blockName Block name.\n * @param {string} feature Border feature to check support for.\n *\n * @return {boolean} Whether there is support.\n */\nexport function hasBorderSupport( blockName, feature = 'any' ) {\n\tif ( Platform.OS !== 'web' ) {\n\t\treturn false;\n\t}\n\n\tconst support = getBlockSupport( blockName, BORDER_SUPPORT_KEY );\n\n\tif ( support === true ) {\n\t\treturn true;\n\t}\n\n\tif ( feature === 'any' ) {\n\t\treturn !! (\n\t\t\tsupport?.color ||\n\t\t\tsupport?.radius ||\n\t\t\tsupport?.width ||\n\t\t\tsupport?.style\n\t\t);\n\t}\n\n\treturn !! support?.[ feature ];\n}\n\n/**\n * Returns a new style object where the specified border attribute has been\n * removed.\n *\n * @param {Object} style Styles from block attributes.\n * @param {string} attribute The border style attribute to clear.\n *\n * @return {Object} Style object with the specified attribute removed.\n */\nexport function removeBorderAttribute( style, attribute ) {\n\treturn cleanEmptyObject( {\n\t\t...style,\n\t\tborder: {\n\t\t\t...style?.border,\n\t\t\t[ attribute ]: undefined,\n\t\t},\n\t} );\n}\n\n/**\n * Filters registered block settings, extending attributes to include\n * `borderColor` if needed.\n *\n * @param {Object} settings Original block settings.\n *\n * @return {Object} Updated block settings.\n */\nfunction addAttributes( settings ) {\n\tif ( ! hasBorderSupport( settings, 'color' ) ) {\n\t\treturn settings;\n\t}\n\n\t// Allow blocks to specify default value if needed.\n\tif ( settings.attributes.borderColor ) {\n\t\treturn settings;\n\t}\n\n\t// Add new borderColor attribute to block settings.\n\treturn {\n\t\t...settings,\n\t\tattributes: {\n\t\t\t...settings.attributes,\n\t\t\tborderColor: {\n\t\t\t\ttype: 'string',\n\t\t\t},\n\t\t},\n\t};\n}\n\n/**\n * Override props assigned to save component to inject border color.\n *\n * @param {Object} props Additional props applied to save element.\n * @param {Object} blockType Block type definition.\n * @param {Object} attributes Block's attributes.\n *\n * @return {Object} Filtered props to apply to save element.\n */\nfunction addSaveProps( props, blockType, attributes ) {\n\tif (\n\t\t! hasBorderSupport( blockType, 'color' ) ||\n\t\tshouldSkipSerialization( blockType, BORDER_SUPPORT_KEY, 'color' )\n\t) {\n\t\treturn props;\n\t}\n\n\tconst borderClasses = getBorderClasses( attributes );\n\tconst newClassName = classnames( props.className, borderClasses );\n\n\t// If we are clearing the last of the previous classes in `className`\n\t// set it to `undefined` to avoid rendering empty DOM attributes.\n\tprops.className = newClassName ? newClassName : undefined;\n\n\treturn props;\n}\n\n/**\n * Generates a CSS class name consisting of all the applicable border color\n * classes given the current block attributes.\n *\n * @param {Object} attributes Block's attributes.\n *\n * @return {string} CSS class name.\n */\nexport function getBorderClasses( attributes ) {\n\tconst { borderColor, style } = attributes;\n\tconst borderColorClass = getColorClassName( 'border-color', borderColor );\n\n\treturn classnames( {\n\t\t'has-border-color': borderColor || style?.border?.color,\n\t\t[ borderColorClass ]: !! borderColorClass,\n\t} );\n}\n\n/**\n * Filters the registered block settings to apply border color styles and\n * classnames to the block edit wrapper.\n *\n * @param {Object} settings Original block settings.\n *\n * @return {Object} Filtered block settings.\n */\nfunction addEditProps( settings ) {\n\tif (\n\t\t! hasBorderSupport( settings, 'color' ) ||\n\t\tshouldSkipSerialization( settings, BORDER_SUPPORT_KEY, 'color' )\n\t) {\n\t\treturn settings;\n\t}\n\n\tconst existingGetEditWrapperProps = settings.getEditWrapperProps;\n\tsettings.getEditWrapperProps = ( attributes ) => {\n\t\tlet props = {};\n\n\t\tif ( existingGetEditWrapperProps ) {\n\t\t\tprops = existingGetEditWrapperProps( attributes );\n\t\t}\n\n\t\treturn addSaveProps( props, settings, attributes );\n\t};\n\n\treturn settings;\n}\n\n/**\n * This adds inline styles for color palette colors.\n * Ideally, this is not needed and themes should load their palettes on the editor.\n *\n * @param {Function} BlockListBlock Original component.\n *\n * @return {Function} Wrapped component.\n */\nexport const withBorderColorPaletteStyles = createHigherOrderComponent(\n\t( BlockListBlock ) => ( props ) => {\n\t\tconst { name, attributes } = props;\n\t\tconst { borderColor, style } = attributes;\n\t\tconst { colors } = useMultipleOriginColorsAndGradients();\n\n\t\tif (\n\t\t\t! hasBorderSupport( name, 'color' ) ||\n\t\t\tshouldSkipSerialization( name, BORDER_SUPPORT_KEY, 'color' )\n\t\t) {\n\t\t\treturn <BlockListBlock { ...props } />;\n\t\t}\n\n\t\tconst { color: borderColorValue } = getMultiOriginColor( {\n\t\t\tcolors,\n\t\t\tnamedColor: borderColor,\n\t\t} );\n\t\tconst { color: borderTopColor } = getMultiOriginColor( {\n\t\t\tcolors,\n\t\t\tnamedColor: getColorSlugFromVariable( style?.border?.top?.color ),\n\t\t} );\n\t\tconst { color: borderRightColor } = getMultiOriginColor( {\n\t\t\tcolors,\n\t\t\tnamedColor: getColorSlugFromVariable( style?.border?.right?.color ),\n\t\t} );\n\n\t\tconst { color: borderBottomColor } = getMultiOriginColor( {\n\t\t\tcolors,\n\t\t\tnamedColor: getColorSlugFromVariable(\n\t\t\t\tstyle?.border?.bottom?.color\n\t\t\t),\n\t\t} );\n\t\tconst { color: borderLeftColor } = getMultiOriginColor( {\n\t\t\tcolors,\n\t\t\tnamedColor: getColorSlugFromVariable( style?.border?.left?.color ),\n\t\t} );\n\n\t\tconst extraStyles = {\n\t\t\tborderTopColor: borderTopColor || borderColorValue,\n\t\t\tborderRightColor: borderRightColor || borderColorValue,\n\t\t\tborderBottomColor: borderBottomColor || borderColorValue,\n\t\t\tborderLeftColor: borderLeftColor || borderColorValue,\n\t\t};\n\n\t\tlet wrapperProps = props.wrapperProps;\n\t\twrapperProps = {\n\t\t\t...props.wrapperProps,\n\t\t\tstyle: {\n\t\t\t\t...props.wrapperProps?.style,\n\t\t\t\t...extraStyles,\n\t\t\t},\n\t\t};\n\n\t\treturn <BlockListBlock { ...props } wrapperProps={ wrapperProps } />;\n\t}\n);\n\naddFilter(\n\t'blocks.registerBlockType',\n\t'core/border/addAttributes',\n\taddAttributes\n);\n\naddFilter(\n\t'blocks.getSaveContent.extraProps',\n\t'core/border/addSaveProps',\n\taddSaveProps\n);\n\naddFilter(\n\t'blocks.registerBlockType',\n\t'core/border/addEditProps',\n\taddEditProps\n);\n\naddFilter(\n\t'editor.BlockListBlock',\n\t'core/border/with-border-color-palette-styles',\n\twithBorderColorPaletteStyles\n);\n"]}
@@ -22,8 +22,6 @@ var _hooks = require("@wordpress/hooks");
22
22
 
23
23
  var _blocks = require("@wordpress/blocks");
24
24
 
25
- var _i18n = require("@wordpress/i18n");
26
-
27
25
  var _compose = require("@wordpress/compose");
28
26
 
29
27
  var _colors = require("../components/colors");
@@ -32,10 +30,18 @@ var _gradients = require("../components/gradients");
32
30
 
33
31
  var _utils = require("./utils");
34
32
 
35
- var _colorPanel = _interopRequireDefault(require("./color-panel"));
36
-
37
33
  var _useSetting = _interopRequireDefault(require("../components/use-setting"));
38
34
 
35
+ var _inspectorControls = _interopRequireDefault(require("../components/inspector-controls"));
36
+
37
+ var _colorPanel = _interopRequireWildcard(require("../components/global-styles/color-panel"));
38
+
39
+ var _contrastChecker = _interopRequireDefault(require("./contrast-checker"));
40
+
41
+ function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
42
+
43
+ function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
44
+
39
45
  /**
40
46
  * External dependencies
41
47
  */
@@ -78,62 +84,6 @@ const hasTextColorSupport = blockType => {
78
84
  const colorSupport = (0, _blocks.getBlockSupport)(blockType, COLOR_SUPPORT_KEY);
79
85
  return colorSupport && colorSupport.text !== false;
80
86
  };
81
- /**
82
- * Clears a single color property from a style object.
83
- *
84
- * @param {Array} path Path to color property to clear within styles object.
85
- * @param {Object} style Block attributes style object.
86
- * @return {Object} Styles with the color property omitted.
87
- */
88
-
89
-
90
- const clearColorFromStyles = (path, style) => (0, _utils.cleanEmptyObject)((0, _utils.immutableSet)(style, path, undefined));
91
- /**
92
- * Clears text color related properties from supplied attributes.
93
- *
94
- * @param {Object} attributes Block attributes.
95
- * @return {Object} Update block attributes with text color properties omitted.
96
- */
97
-
98
-
99
- const resetAllTextFilter = attributes => ({
100
- textColor: undefined,
101
- style: clearColorFromStyles(['color', 'text'], attributes.style)
102
- });
103
- /**
104
- * Clears link color related properties from supplied attributes.
105
- *
106
- * @param {Object} attributes Block attributes.
107
- * @return {Object} Update block attributes with link color properties omitted.
108
- */
109
-
110
-
111
- const resetAllLinkFilter = attributes => ({
112
- style: clearColorFromStyles(['elements', 'link', 'color', 'text'], attributes.style)
113
- });
114
- /**
115
- * Clears all background color related properties including gradients from
116
- * supplied block attributes.
117
- *
118
- * @param {Object} attributes Block attributes.
119
- * @return {Object} Block attributes with background and gradient omitted.
120
- */
121
-
122
-
123
- const clearBackgroundAndGradient = attributes => {
124
- var _attributes$style;
125
-
126
- return {
127
- backgroundColor: undefined,
128
- gradient: undefined,
129
- style: { ...attributes.style,
130
- color: { ...((_attributes$style = attributes.style) === null || _attributes$style === void 0 ? void 0 : _attributes$style.color),
131
- background: undefined,
132
- gradient: undefined
133
- }
134
- }
135
- };
136
- };
137
87
  /**
138
88
  * Filters registered block settings, extending attributes to include
139
89
  * `backgroundColor` and `textColor` attribute.
@@ -253,191 +203,104 @@ function addEditProps(settings) {
253
203
  return settings;
254
204
  }
255
205
 
256
- const getLinkColorFromAttributeValue = (colors, value) => {
257
- const attributeParsed = /var:preset\|color\|(.+)/.exec(value);
206
+ function styleToAttributes(style) {
207
+ var _style$color5, _style$color6, _style$color7;
258
208
 
259
- if (attributeParsed && attributeParsed[1]) {
260
- return (0, _colors.getColorObjectByAttributeValues)(colors, attributeParsed[1]).color;
261
- }
209
+ const textColorValue = style === null || style === void 0 ? void 0 : (_style$color5 = style.color) === null || _style$color5 === void 0 ? void 0 : _style$color5.text;
210
+ const textColorSlug = textColorValue !== null && textColorValue !== void 0 && textColorValue.startsWith('var:preset|color|') ? textColorValue.substring('var:preset|color|'.length) : undefined;
211
+ const backgroundColorValue = style === null || style === void 0 ? void 0 : (_style$color6 = style.color) === null || _style$color6 === void 0 ? void 0 : _style$color6.background;
212
+ const backgroundColorSlug = backgroundColorValue !== null && backgroundColorValue !== void 0 && backgroundColorValue.startsWith('var:preset|color|') ? backgroundColorValue.substring('var:preset|color|'.length) : undefined;
213
+ const gradientValue = style === null || style === void 0 ? void 0 : (_style$color7 = style.color) === null || _style$color7 === void 0 ? void 0 : _style$color7.gradient;
214
+ const gradientSlug = gradientValue !== null && gradientValue !== void 0 && gradientValue.startsWith('var:preset|gradient|') ? gradientValue.substring('var:preset|gradient|'.length) : undefined;
215
+ const updatedStyle = { ...style
216
+ };
217
+ updatedStyle.color = { ...updatedStyle.color,
218
+ text: textColorSlug ? undefined : textColorValue,
219
+ background: backgroundColorSlug ? undefined : backgroundColorValue,
220
+ gradient: gradientSlug ? undefined : gradientValue
221
+ };
222
+ return {
223
+ style: (0, _utils.cleanEmptyObject)(updatedStyle),
224
+ textColor: textColorSlug,
225
+ backgroundColor: backgroundColorSlug,
226
+ gradient: gradientSlug
227
+ };
228
+ }
262
229
 
263
- return value;
264
- };
265
- /**
266
- * Inspector control panel containing the color related configuration
267
- *
268
- * @param {Object} props
269
- *
270
- * @return {WPElement} Color edit element.
271
- */
230
+ function attributesToStyle(attributes) {
231
+ var _attributes$style, _attributes$style2, _attributes$style2$co, _attributes$style3, _attributes$style3$co, _attributes$style4, _attributes$style4$co;
232
+
233
+ return { ...attributes.style,
234
+ color: { ...((_attributes$style = attributes.style) === null || _attributes$style === void 0 ? void 0 : _attributes$style.color),
235
+ text: attributes.textColor ? 'var:preset|color|' + attributes.textColor : (_attributes$style2 = attributes.style) === null || _attributes$style2 === void 0 ? void 0 : (_attributes$style2$co = _attributes$style2.color) === null || _attributes$style2$co === void 0 ? void 0 : _attributes$style2$co.text,
236
+ background: attributes.backgroundColor ? 'var:preset|color|' + attributes.backgroundColor : (_attributes$style3 = attributes.style) === null || _attributes$style3 === void 0 ? void 0 : (_attributes$style3$co = _attributes$style3.color) === null || _attributes$style3$co === void 0 ? void 0 : _attributes$style3$co.background,
237
+ gradient: attributes.gradient ? 'var:preset|gradient|' + attributes.gradient : (_attributes$style4 = attributes.style) === null || _attributes$style4 === void 0 ? void 0 : (_attributes$style4$co = _attributes$style4.color) === null || _attributes$style4$co === void 0 ? void 0 : _attributes$style4$co.gradient
238
+ }
239
+ };
240
+ }
272
241
 
242
+ function ColorInspectorControl(_ref) {
243
+ let {
244
+ children,
245
+ resetAllFilter
246
+ } = _ref;
247
+ const attributesResetAllFilter = (0, _element.useCallback)(attributes => {
248
+ const existingStyle = attributesToStyle(attributes);
249
+ const updatedStyle = resetAllFilter(existingStyle);
250
+ return { ...attributes,
251
+ ...styleToAttributes(updatedStyle)
252
+ };
253
+ }, [resetAllFilter]);
254
+ return (0, _element.createElement)(_inspectorControls.default, {
255
+ group: "color",
256
+ resetAllFilter: attributesResetAllFilter
257
+ }, children);
258
+ }
273
259
 
274
260
  function ColorEdit(props) {
275
- var _style$color6, _style$color7, _style$color8, _style$elements2, _style$elements2$link, _style$elements2$link2;
261
+ var _value$color, _settings$color, _settings$color2;
276
262
 
277
263
  const {
278
- name: blockName,
279
- attributes
280
- } = props; // Some color settings have a special handling for deprecated flags in `useSetting`,
281
- // so we can't unwrap them by doing const { ... } = useSetting('color')
282
- // until https://github.com/WordPress/gutenberg/issues/37094 is fixed.
283
-
284
- const userPalette = (0, _useSetting.default)('color.palette.custom');
285
- const themePalette = (0, _useSetting.default)('color.palette.theme');
286
- const defaultPalette = (0, _useSetting.default)('color.palette.default');
287
- const allSolids = (0, _element.useMemo)(() => [...(userPalette || []), ...(themePalette || []), ...(defaultPalette || [])], [userPalette, themePalette, defaultPalette]);
288
- const userGradientPalette = (0, _useSetting.default)('color.gradients.custom');
289
- const themeGradientPalette = (0, _useSetting.default)('color.gradients.theme');
290
- const defaultGradientPalette = (0, _useSetting.default)('color.gradients.default');
291
- const allGradients = (0, _element.useMemo)(() => [...(userGradientPalette || []), ...(themeGradientPalette || []), ...(defaultGradientPalette || [])], [userGradientPalette, themeGradientPalette, defaultGradientPalette]);
292
- const areCustomSolidsEnabled = (0, _useSetting.default)('color.custom');
293
- const areCustomGradientsEnabled = (0, _useSetting.default)('color.customGradient');
294
- const isBackgroundEnabled = (0, _useSetting.default)('color.background');
295
- const isLinkEnabled = (0, _useSetting.default)('color.link');
296
- const isTextEnabled = (0, _useSetting.default)('color.text');
297
- const solidsEnabled = areCustomSolidsEnabled || !themePalette || (themePalette === null || themePalette === void 0 ? void 0 : themePalette.length) > 0;
298
- const gradientsEnabled = areCustomGradientsEnabled || !themeGradientPalette || (themeGradientPalette === null || themeGradientPalette === void 0 ? void 0 : themeGradientPalette.length) > 0; // Shouldn't be needed but right now the ColorGradientsPanel
299
- // can trigger both onChangeColor and onChangeBackground
300
- // synchronously causing our two callbacks to override changes
301
- // from each other.
302
-
303
- const localAttributes = (0, _element.useRef)(attributes);
304
- (0, _element.useEffect)(() => {
305
- localAttributes.current = attributes;
306
- }, [attributes]);
307
-
308
- if (!hasColorSupport(blockName)) {
309
- return null;
310
- }
264
+ clientId,
265
+ name,
266
+ attributes,
267
+ setAttributes
268
+ } = props;
269
+ const settings = (0, _utils.useBlockSettings)(name);
270
+ const isEnabled = (0, _colorPanel.useHasColorPanel)(settings);
271
+ const value = (0, _element.useMemo)(() => {
272
+ return attributesToStyle({
273
+ style: attributes.style,
274
+ textColor: attributes.textColor,
275
+ backgroundColor: attributes.backgroundColor,
276
+ gradient: attributes.gradient
277
+ });
278
+ }, [attributes.style, attributes.textColor, attributes.backgroundColor, attributes.gradient]);
311
279
 
312
- const hasLinkColor = hasLinkColorSupport(blockName) && isLinkEnabled && solidsEnabled;
313
- const hasTextColor = hasTextColorSupport(blockName) && isTextEnabled && solidsEnabled;
314
- const hasBackgroundColor = hasBackgroundColorSupport(blockName) && isBackgroundEnabled && solidsEnabled;
315
- const hasGradientColor = hasGradientSupport(blockName) && gradientsEnabled;
280
+ const onChange = newStyle => {
281
+ setAttributes(styleToAttributes(newStyle));
282
+ };
316
283
 
317
- if (!hasLinkColor && !hasTextColor && !hasBackgroundColor && !hasGradientColor) {
284
+ if (!isEnabled) {
318
285
  return null;
319
286
  }
320
287
 
321
- const {
322
- style,
323
- textColor,
324
- backgroundColor,
325
- gradient
326
- } = attributes;
327
- let gradientValue;
328
-
329
- if (hasGradientColor && gradient) {
330
- gradientValue = (0, _gradients.getGradientValueBySlug)(allGradients, gradient);
331
- } else if (hasGradientColor) {
332
- var _style$color5;
333
-
334
- gradientValue = style === null || style === void 0 ? void 0 : (_style$color5 = style.color) === null || _style$color5 === void 0 ? void 0 : _style$color5.gradient;
335
- }
336
-
337
- const onChangeColor = name => value => {
338
- var _localAttributes$curr, _localAttributes$curr2;
339
-
340
- const colorObject = (0, _colors.getColorObjectByColorValue)(allSolids, value);
341
- const attributeName = name + 'Color';
342
- const newStyle = { ...localAttributes.current.style,
343
- color: { ...((_localAttributes$curr = localAttributes.current) === null || _localAttributes$curr === void 0 ? void 0 : (_localAttributes$curr2 = _localAttributes$curr.style) === null || _localAttributes$curr2 === void 0 ? void 0 : _localAttributes$curr2.color),
344
- [name]: colorObject !== null && colorObject !== void 0 && colorObject.slug ? undefined : value
345
- }
346
- };
347
- const newNamedColor = colorObject !== null && colorObject !== void 0 && colorObject.slug ? colorObject.slug : undefined;
348
- const newAttributes = {
349
- style: (0, _utils.cleanEmptyObject)(newStyle),
350
- [attributeName]: newNamedColor
351
- };
352
- props.setAttributes(newAttributes);
353
- localAttributes.current = { ...localAttributes.current,
354
- ...newAttributes
355
- };
356
- };
357
-
358
- const onChangeGradient = value => {
359
- const slug = (0, _gradients.getGradientSlugByValue)(allGradients, value);
360
- let newAttributes;
361
-
362
- if (slug) {
363
- var _localAttributes$curr3, _localAttributes$curr4, _localAttributes$curr5;
364
-
365
- const newStyle = { ...((_localAttributes$curr3 = localAttributes.current) === null || _localAttributes$curr3 === void 0 ? void 0 : _localAttributes$curr3.style),
366
- color: { ...((_localAttributes$curr4 = localAttributes.current) === null || _localAttributes$curr4 === void 0 ? void 0 : (_localAttributes$curr5 = _localAttributes$curr4.style) === null || _localAttributes$curr5 === void 0 ? void 0 : _localAttributes$curr5.color),
367
- gradient: undefined
368
- }
369
- };
370
- newAttributes = {
371
- style: (0, _utils.cleanEmptyObject)(newStyle),
372
- gradient: slug
373
- };
374
- } else {
375
- var _localAttributes$curr6, _localAttributes$curr7, _localAttributes$curr8;
376
-
377
- const newStyle = { ...((_localAttributes$curr6 = localAttributes.current) === null || _localAttributes$curr6 === void 0 ? void 0 : _localAttributes$curr6.style),
378
- color: { ...((_localAttributes$curr7 = localAttributes.current) === null || _localAttributes$curr7 === void 0 ? void 0 : (_localAttributes$curr8 = _localAttributes$curr7.style) === null || _localAttributes$curr8 === void 0 ? void 0 : _localAttributes$curr8.color),
379
- gradient: value
380
- }
381
- };
382
- newAttributes = {
383
- style: (0, _utils.cleanEmptyObject)(newStyle),
384
- gradient: undefined
385
- };
386
- }
387
-
388
- props.setAttributes(newAttributes);
389
- localAttributes.current = { ...localAttributes.current,
390
- ...newAttributes
391
- };
392
- };
393
-
394
- const onChangeLinkColor = value => {
395
- var _localAttributes$curr9;
396
-
397
- const colorObject = (0, _colors.getColorObjectByColorValue)(allSolids, value);
398
- const newLinkColorValue = colorObject !== null && colorObject !== void 0 && colorObject.slug ? `var:preset|color|${colorObject.slug}` : value;
399
- const newStyle = (0, _utils.cleanEmptyObject)((0, _utils.immutableSet)((_localAttributes$curr9 = localAttributes.current) === null || _localAttributes$curr9 === void 0 ? void 0 : _localAttributes$curr9.style, ['elements', 'link', 'color', 'text'], newLinkColorValue));
400
- props.setAttributes({
401
- style: newStyle
402
- });
403
- localAttributes.current = { ...localAttributes.current,
404
- ...{
405
- style: newStyle
406
- }
407
- };
408
- };
409
-
410
- const defaultColorControls = (0, _blocks.getBlockSupport)(props.name, [COLOR_SUPPORT_KEY, '__experimentalDefaultControls']);
411
- const enableContrastChecking = _element.Platform.OS === 'web' && !gradient && !(style !== null && style !== void 0 && (_style$color6 = style.color) !== null && _style$color6 !== void 0 && _style$color6.gradient) && hasBackgroundColor && (hasLinkColor || hasTextColor) && // Contrast checking is enabled by default.
288
+ const defaultControls = (0, _blocks.getBlockSupport)(props.name, [COLOR_SUPPORT_KEY, '__experimentalDefaultControls']);
289
+ const enableContrastChecking = _element.Platform.OS === 'web' && !(value !== null && value !== void 0 && (_value$color = value.color) !== null && _value$color !== void 0 && _value$color.gradient) && ((settings === null || settings === void 0 ? void 0 : (_settings$color = settings.color) === null || _settings$color === void 0 ? void 0 : _settings$color.text) || (settings === null || settings === void 0 ? void 0 : (_settings$color2 = settings.color) === null || _settings$color2 === void 0 ? void 0 : _settings$color2.link)) && // Contrast checking is enabled by default.
412
290
  // Deactivating it requires `enableContrastChecker` to have
413
291
  // an explicit value of `false`.
414
292
  false !== (0, _blocks.getBlockSupport)(props.name, [COLOR_SUPPORT_KEY, 'enableContrastChecker']);
415
293
  return (0, _element.createElement)(_colorPanel.default, {
416
- enableContrastChecking: enableContrastChecking,
417
- clientId: props.clientId,
418
- enableAlpha: true,
419
- settings: [...(hasTextColor ? [{
420
- label: (0, _i18n.__)('Text'),
421
- onColorChange: onChangeColor('text'),
422
- colorValue: (0, _colors.getColorObjectByAttributeValues)(allSolids, textColor, style === null || style === void 0 ? void 0 : (_style$color7 = style.color) === null || _style$color7 === void 0 ? void 0 : _style$color7.text).color,
423
- isShownByDefault: defaultColorControls === null || defaultColorControls === void 0 ? void 0 : defaultColorControls.text,
424
- resetAllFilter: resetAllTextFilter
425
- }] : []), ...(hasBackgroundColor || hasGradientColor ? [{
426
- label: (0, _i18n.__)('Background'),
427
- onColorChange: hasBackgroundColor ? onChangeColor('background') : undefined,
428
- colorValue: (0, _colors.getColorObjectByAttributeValues)(allSolids, backgroundColor, style === null || style === void 0 ? void 0 : (_style$color8 = style.color) === null || _style$color8 === void 0 ? void 0 : _style$color8.background).color,
429
- gradientValue,
430
- onGradientChange: hasGradientColor ? onChangeGradient : undefined,
431
- isShownByDefault: defaultColorControls === null || defaultColorControls === void 0 ? void 0 : defaultColorControls.background,
432
- resetAllFilter: clearBackgroundAndGradient
433
- }] : []), ...(hasLinkColor ? [{
434
- label: (0, _i18n.__)('Link'),
435
- onColorChange: onChangeLinkColor,
436
- colorValue: getLinkColorFromAttributeValue(allSolids, style === null || style === void 0 ? void 0 : (_style$elements2 = style.elements) === null || _style$elements2 === void 0 ? void 0 : (_style$elements2$link = _style$elements2.link) === null || _style$elements2$link === void 0 ? void 0 : (_style$elements2$link2 = _style$elements2$link.color) === null || _style$elements2$link2 === void 0 ? void 0 : _style$elements2$link2.text),
437
- isShownByDefault: defaultColorControls === null || defaultColorControls === void 0 ? void 0 : defaultColorControls.link,
438
- resetAllFilter: resetAllLinkFilter
439
- }] : [])]
440
- });
294
+ as: ColorInspectorControl,
295
+ panelId: clientId,
296
+ settings: settings,
297
+ value: value,
298
+ onChange: onChange,
299
+ defaultControls: defaultControls,
300
+ enableContrastChecker: false !== (0, _blocks.getBlockSupport)(props.name, [COLOR_SUPPORT_KEY, 'enableContrastChecker'])
301
+ }, enableContrastChecking && (0, _element.createElement)(_contrastChecker.default, {
302
+ clientId: clientId
303
+ }));
441
304
  }
442
305
  /**
443
306
  * This adds inline styles for color palette colors.