@wordpress/block-editor 12.15.0 → 12.16.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 (500) hide show
  1. package/CHANGELOG.md +2 -0
  2. package/README.md +9 -4
  3. package/build/components/block-canvas/index.js +22 -6
  4. package/build/components/block-canvas/index.js.map +1 -1
  5. package/build/components/block-card/index.js +1 -1
  6. package/build/components/block-card/index.js.map +1 -1
  7. package/build/components/block-controls/hook.js +3 -23
  8. package/build/components/block-controls/hook.js.map +1 -1
  9. package/build/components/block-edit/context.js +5 -1
  10. package/build/components/block-edit/context.js.map +1 -1
  11. package/build/components/block-edit/index.js +18 -9
  12. package/build/components/block-edit/index.js.map +1 -1
  13. package/build/components/block-info-slot-fill/index.js +3 -4
  14. package/build/components/block-info-slot-fill/index.js.map +1 -1
  15. package/build/components/block-list/block.js +28 -9
  16. package/build/components/block-list/block.js.map +1 -1
  17. package/build/components/block-list/block.native.js +14 -5
  18. package/build/components/block-list/block.native.js.map +1 -1
  19. package/build/components/block-list/use-block-props/index.js +61 -18
  20. package/build/components/block-list/use-block-props/index.js.map +1 -1
  21. package/build/components/block-list/use-block-props/use-focus-first-element.js +4 -29
  22. package/build/components/block-list/use-block-props/use-focus-first-element.js.map +1 -1
  23. package/build/components/block-list/use-block-props/use-is-hovered.js +4 -14
  24. package/build/components/block-list/use-block-props/use-is-hovered.js.map +1 -1
  25. package/build/components/block-list/use-block-props/use-selected-block-event-handlers.js +4 -2
  26. package/build/components/block-list/use-block-props/use-selected-block-event-handlers.js.map +1 -1
  27. package/build/components/block-patterns-list/index.js +1 -1
  28. package/build/components/block-patterns-list/index.js.map +1 -1
  29. package/build/components/block-removal-warning-modal/index.js +2 -9
  30. package/build/components/block-removal-warning-modal/index.js.map +1 -1
  31. package/build/components/block-rename/modal.js +3 -0
  32. package/build/components/block-rename/modal.js.map +1 -1
  33. package/build/components/block-settings/container.native.js +6 -4
  34. package/build/components/block-settings/container.native.js.map +1 -1
  35. package/build/components/block-styles/index.js +1 -1
  36. package/build/components/block-styles/index.js.map +1 -1
  37. package/build/components/block-styles/index.native.js +3 -2
  38. package/build/components/block-styles/index.native.js.map +1 -1
  39. package/build/components/block-toolbar/index.js +89 -27
  40. package/build/components/block-toolbar/index.js.map +1 -1
  41. package/build/components/block-tools/block-toolbar-breadcrumb.js +49 -0
  42. package/build/components/block-tools/block-toolbar-breadcrumb.js.map +1 -0
  43. package/build/components/block-tools/block-toolbar-popover.js +86 -0
  44. package/build/components/block-tools/block-toolbar-popover.js.map +1 -0
  45. package/build/components/block-tools/index.js +27 -24
  46. package/build/components/block-tools/index.js.map +1 -1
  47. package/build/components/block-types-list/index.native.js +4 -3
  48. package/build/components/block-types-list/index.native.js.map +1 -1
  49. package/build/components/block-variation-picker/index.native.js +2 -1
  50. package/build/components/block-variation-picker/index.native.js.map +1 -1
  51. package/build/components/colors-gradients/control.js +28 -17
  52. package/build/components/colors-gradients/control.js.map +1 -1
  53. package/build/components/duotone-control/index.js +1 -4
  54. package/build/components/duotone-control/index.js.map +1 -1
  55. package/build/components/global-styles/color-panel.js +22 -20
  56. package/build/components/global-styles/color-panel.js.map +1 -1
  57. package/build/components/global-styles/filters-panel.js +9 -3
  58. package/build/components/global-styles/filters-panel.js.map +1 -1
  59. package/build/components/global-styles/typography-panel.js +20 -31
  60. package/build/components/global-styles/typography-panel.js.map +1 -1
  61. package/build/components/image-link-destinations/index.native.js +118 -0
  62. package/build/components/image-link-destinations/index.native.js.map +1 -0
  63. package/build/components/index.native.js +8 -0
  64. package/build/components/index.native.js.map +1 -1
  65. package/build/components/inserter/media-tab/media-panel.js +2 -2
  66. package/build/components/inserter/media-tab/media-panel.js.map +1 -1
  67. package/build/components/inserter/menu.js +14 -7
  68. package/build/components/inserter/menu.js.map +1 -1
  69. package/build/components/inserter/preview-panel.js +2 -2
  70. package/build/components/inserter/preview-panel.js.map +1 -1
  71. package/build/components/inserter-button/index.native.js +98 -0
  72. package/build/components/inserter-button/index.native.js.map +1 -0
  73. package/build/components/inserter-button/sparkles.js +23 -0
  74. package/build/components/inserter-button/sparkles.js.map +1 -0
  75. package/build/components/inserter-draggable-blocks/index.js +8 -4
  76. package/build/components/inserter-draggable-blocks/index.js.map +1 -1
  77. package/build/components/inspector-controls/fill.js +3 -3
  78. package/build/components/inspector-controls/fill.js.map +1 -1
  79. package/build/components/inspector-controls/fill.native.js +3 -3
  80. package/build/components/inspector-controls/fill.native.js.map +1 -1
  81. package/build/components/navigable-toolbar/index.js +2 -2
  82. package/build/components/navigable-toolbar/index.js.map +1 -1
  83. package/build/components/preview-options/index.js +6 -62
  84. package/build/components/preview-options/index.js.map +1 -1
  85. package/build/components/rich-text/content.js +26 -23
  86. package/build/components/rich-text/content.js.map +1 -1
  87. package/build/components/rich-text/get-rich-text-values.js +2 -1
  88. package/build/components/rich-text/get-rich-text-values.js.map +1 -1
  89. package/build/components/rich-text/index.js +2 -30
  90. package/build/components/rich-text/index.js.map +1 -1
  91. package/build/components/rich-text/index.native.js +9 -16
  92. package/build/components/rich-text/index.native.js.map +1 -1
  93. package/build/components/rich-text/native/get-format-colors.native.js +22 -24
  94. package/build/components/rich-text/native/get-format-colors.native.js.map +1 -1
  95. package/build/components/rich-text/native/index.native.js +7 -34
  96. package/build/components/rich-text/native/index.native.js.map +1 -1
  97. package/build/components/rich-text/use-input-rules.js +5 -1
  98. package/build/components/rich-text/use-input-rules.js.map +1 -1
  99. package/build/components/rich-text/with-deprecations.js +50 -0
  100. package/build/components/rich-text/with-deprecations.js.map +1 -0
  101. package/build/components/use-block-drop-zone/index.js +70 -8
  102. package/build/components/use-block-drop-zone/index.js.map +1 -1
  103. package/build/components/use-on-block-drop/index.js +1 -1
  104. package/build/components/use-on-block-drop/index.js.map +1 -1
  105. package/build/components/use-resize-canvas/index.js +4 -1
  106. package/build/components/use-resize-canvas/index.js.map +1 -1
  107. package/build/components/use-settings/index.js +14 -0
  108. package/build/components/use-settings/index.js.map +1 -1
  109. package/build/hooks/align.js +20 -68
  110. package/build/hooks/align.js.map +1 -1
  111. package/build/hooks/align.native.js +11 -1
  112. package/build/hooks/align.native.js.map +1 -1
  113. package/build/hooks/anchor.js +13 -29
  114. package/build/hooks/anchor.js.map +1 -1
  115. package/build/hooks/background.js +28 -31
  116. package/build/hooks/background.js.map +1 -1
  117. package/build/hooks/block-hooks.js +24 -32
  118. package/build/hooks/block-hooks.js.map +1 -1
  119. package/build/hooks/block-renaming.js +18 -22
  120. package/build/hooks/block-renaming.js.map +1 -1
  121. package/build/hooks/border.js +58 -80
  122. package/build/hooks/border.js.map +1 -1
  123. package/build/hooks/color.js +76 -89
  124. package/build/hooks/color.js.map +1 -1
  125. package/build/hooks/content-lock-ui.js +29 -29
  126. package/build/hooks/content-lock-ui.js.map +1 -1
  127. package/build/hooks/custom-class-name.js +12 -29
  128. package/build/hooks/custom-class-name.js.map +1 -1
  129. package/build/hooks/custom-fields.js +24 -38
  130. package/build/hooks/custom-fields.js.map +1 -1
  131. package/build/hooks/dimensions.js +21 -17
  132. package/build/hooks/dimensions.js.map +1 -1
  133. package/build/hooks/duotone.js +31 -61
  134. package/build/hooks/duotone.js.map +1 -1
  135. package/build/hooks/font-family.js +16 -25
  136. package/build/hooks/font-family.js.map +1 -1
  137. package/build/hooks/font-size.js +51 -119
  138. package/build/hooks/font-size.js.map +1 -1
  139. package/build/hooks/index.js +25 -14
  140. package/build/hooks/index.js.map +1 -1
  141. package/build/hooks/index.native.js +10 -3
  142. package/build/hooks/index.native.js.map +1 -1
  143. package/build/hooks/layout-child.js +68 -0
  144. package/build/hooks/layout-child.js.map +1 -0
  145. package/build/hooks/layout.js +16 -101
  146. package/build/hooks/layout.js.map +1 -1
  147. package/build/hooks/padding.js +2 -2
  148. package/build/hooks/padding.js.map +1 -1
  149. package/build/hooks/position.js +40 -62
  150. package/build/hooks/position.js.map +1 -1
  151. package/build/hooks/style.js +51 -88
  152. package/build/hooks/style.js.map +1 -1
  153. package/build/hooks/typography.js +34 -14
  154. package/build/hooks/typography.js.map +1 -1
  155. package/build/hooks/utils.js +154 -7
  156. package/build/hooks/utils.js.map +1 -1
  157. package/build/private-apis.js +0 -2
  158. package/build/private-apis.js.map +1 -1
  159. package/build/store/private-actions.js +8 -0
  160. package/build/store/private-actions.js.map +1 -1
  161. package/build/store/private-selectors.js +34 -0
  162. package/build/store/private-selectors.js.map +1 -1
  163. package/build/store/reducer.js +8 -0
  164. package/build/store/reducer.js.map +1 -1
  165. package/build/store/selectors.js +10 -60
  166. package/build/store/selectors.js.map +1 -1
  167. package/build/store/utils.js +66 -0
  168. package/build/store/utils.js.map +1 -0
  169. package/build/utils/object.js +21 -61
  170. package/build/utils/object.js.map +1 -1
  171. package/build/utils/selection.js +9 -1
  172. package/build/utils/selection.js.map +1 -1
  173. package/build-module/components/block-canvas/index.js +23 -7
  174. package/build-module/components/block-canvas/index.js.map +1 -1
  175. package/build-module/components/block-card/index.js +1 -1
  176. package/build-module/components/block-card/index.js.map +1 -1
  177. package/build-module/components/block-controls/hook.js +4 -24
  178. package/build-module/components/block-controls/hook.js.map +1 -1
  179. package/build-module/components/block-edit/context.js +2 -0
  180. package/build-module/components/block-edit/context.js.map +1 -1
  181. package/build-module/components/block-edit/index.js +19 -10
  182. package/build-module/components/block-edit/index.js.map +1 -1
  183. package/build-module/components/block-info-slot-fill/index.js +3 -3
  184. package/build-module/components/block-info-slot-fill/index.js.map +1 -1
  185. package/build-module/components/block-list/block.js +29 -10
  186. package/build-module/components/block-list/block.js.map +1 -1
  187. package/build-module/components/block-list/block.native.js +14 -5
  188. package/build-module/components/block-list/block.native.js.map +1 -1
  189. package/build-module/components/block-list/use-block-props/index.js +62 -19
  190. package/build-module/components/block-list/use-block-props/index.js.map +1 -1
  191. package/build-module/components/block-list/use-block-props/use-focus-first-element.js +4 -29
  192. package/build-module/components/block-list/use-block-props/use-focus-first-element.js.map +1 -1
  193. package/build-module/components/block-list/use-block-props/use-is-hovered.js +4 -14
  194. package/build-module/components/block-list/use-block-props/use-is-hovered.js.map +1 -1
  195. package/build-module/components/block-list/use-block-props/use-selected-block-event-handlers.js +4 -2
  196. package/build-module/components/block-list/use-block-props/use-selected-block-event-handlers.js.map +1 -1
  197. package/build-module/components/block-patterns-list/index.js +1 -1
  198. package/build-module/components/block-patterns-list/index.js.map +1 -1
  199. package/build-module/components/block-removal-warning-modal/index.js +3 -10
  200. package/build-module/components/block-removal-warning-modal/index.js.map +1 -1
  201. package/build-module/components/block-rename/modal.js +3 -0
  202. package/build-module/components/block-rename/modal.js.map +1 -1
  203. package/build-module/components/block-settings/container.native.js +4 -2
  204. package/build-module/components/block-settings/container.native.js.map +1 -1
  205. package/build-module/components/block-styles/index.js +1 -1
  206. package/build-module/components/block-styles/index.js.map +1 -1
  207. package/build-module/components/block-styles/index.native.js +3 -2
  208. package/build-module/components/block-styles/index.native.js.map +1 -1
  209. package/build-module/components/block-toolbar/index.js +88 -25
  210. package/build-module/components/block-toolbar/index.js.map +1 -1
  211. package/build-module/components/block-tools/block-toolbar-breadcrumb.js +41 -0
  212. package/build-module/components/block-tools/block-toolbar-breadcrumb.js.map +1 -0
  213. package/build-module/components/block-tools/block-toolbar-popover.js +76 -0
  214. package/build-module/components/block-tools/block-toolbar-popover.js.map +1 -0
  215. package/build-module/components/block-tools/index.js +27 -24
  216. package/build-module/components/block-tools/index.js.map +1 -1
  217. package/build-module/components/block-types-list/index.native.js +2 -1
  218. package/build-module/components/block-types-list/index.native.js.map +1 -1
  219. package/build-module/components/block-variation-picker/index.native.js +2 -1
  220. package/build-module/components/block-variation-picker/index.native.js.map +1 -1
  221. package/build-module/components/colors-gradients/control.js +29 -18
  222. package/build-module/components/colors-gradients/control.js.map +1 -1
  223. package/build-module/components/duotone-control/index.js +1 -4
  224. package/build-module/components/duotone-control/index.js.map +1 -1
  225. package/build-module/components/global-styles/color-panel.js +23 -21
  226. package/build-module/components/global-styles/color-panel.js.map +1 -1
  227. package/build-module/components/global-styles/filters-panel.js +10 -4
  228. package/build-module/components/global-styles/filters-panel.js.map +1 -1
  229. package/build-module/components/global-styles/typography-panel.js +20 -31
  230. package/build-module/components/global-styles/typography-panel.js.map +1 -1
  231. package/build-module/components/image-link-destinations/index.native.js +109 -0
  232. package/build-module/components/image-link-destinations/index.native.js.map +1 -0
  233. package/build-module/components/index.native.js +1 -0
  234. package/build-module/components/index.native.js.map +1 -1
  235. package/build-module/components/inserter/media-tab/media-panel.js +1 -1
  236. package/build-module/components/inserter/media-tab/media-panel.js.map +1 -1
  237. package/build-module/components/inserter/menu.js +14 -7
  238. package/build-module/components/inserter/menu.js.map +1 -1
  239. package/build-module/components/inserter/preview-panel.js +2 -2
  240. package/build-module/components/inserter/preview-panel.js.map +1 -1
  241. package/build-module/components/inserter-button/index.native.js +89 -0
  242. package/build-module/components/inserter-button/index.native.js.map +1 -0
  243. package/build-module/components/inserter-button/sparkles.js +15 -0
  244. package/build-module/components/inserter-button/sparkles.js.map +1 -0
  245. package/build-module/components/inserter-draggable-blocks/index.js +9 -5
  246. package/build-module/components/inserter-draggable-blocks/index.js.map +1 -1
  247. package/build-module/components/inspector-controls/fill.js +3 -3
  248. package/build-module/components/inspector-controls/fill.js.map +1 -1
  249. package/build-module/components/inspector-controls/fill.native.js +3 -3
  250. package/build-module/components/inspector-controls/fill.native.js.map +1 -1
  251. package/build-module/components/navigable-toolbar/index.js +2 -2
  252. package/build-module/components/navigable-toolbar/index.js.map +1 -1
  253. package/build-module/components/preview-options/index.js +6 -62
  254. package/build-module/components/preview-options/index.js.map +1 -1
  255. package/build-module/components/rich-text/content.js +25 -21
  256. package/build-module/components/rich-text/content.js.map +1 -1
  257. package/build-module/components/rich-text/get-rich-text-values.js +2 -1
  258. package/build-module/components/rich-text/get-rich-text-values.js.map +1 -1
  259. package/build-module/components/rich-text/index.js +4 -32
  260. package/build-module/components/rich-text/index.js.map +1 -1
  261. package/build-module/components/rich-text/index.native.js +10 -18
  262. package/build-module/components/rich-text/index.native.js.map +1 -1
  263. package/build-module/components/rich-text/native/get-format-colors.native.js +22 -24
  264. package/build-module/components/rich-text/native/get-format-colors.native.js.map +1 -1
  265. package/build-module/components/rich-text/native/index.native.js +7 -34
  266. package/build-module/components/rich-text/native/index.native.js.map +1 -1
  267. package/build-module/components/rich-text/use-input-rules.js +5 -1
  268. package/build-module/components/rich-text/use-input-rules.js.map +1 -1
  269. package/build-module/components/rich-text/with-deprecations.js +42 -0
  270. package/build-module/components/rich-text/with-deprecations.js.map +1 -0
  271. package/build-module/components/use-block-drop-zone/index.js +69 -8
  272. package/build-module/components/use-block-drop-zone/index.js.map +1 -1
  273. package/build-module/components/use-on-block-drop/index.js +1 -1
  274. package/build-module/components/use-on-block-drop/index.js.map +1 -1
  275. package/build-module/components/use-resize-canvas/index.js +4 -1
  276. package/build-module/components/use-resize-canvas/index.js.map +1 -1
  277. package/build-module/components/use-settings/index.js +13 -1
  278. package/build-module/components/use-settings/index.js.map +1 -1
  279. package/build-module/hooks/align.js +19 -66
  280. package/build-module/hooks/align.js.map +1 -1
  281. package/build-module/hooks/align.native.js +1 -0
  282. package/build-module/hooks/align.native.js.map +1 -1
  283. package/build-module/hooks/anchor.js +11 -26
  284. package/build-module/hooks/anchor.js.map +1 -1
  285. package/build-module/hooks/background.js +26 -28
  286. package/build-module/hooks/background.js.map +1 -1
  287. package/build-module/hooks/block-hooks.js +22 -30
  288. package/build-module/hooks/block-hooks.js.map +1 -1
  289. package/build-module/hooks/block-renaming.js +17 -21
  290. package/build-module/hooks/block-renaming.js.map +1 -1
  291. package/build-module/hooks/border.js +57 -78
  292. package/build-module/hooks/border.js.map +1 -1
  293. package/build-module/hooks/color.js +74 -86
  294. package/build-module/hooks/color.js.map +1 -1
  295. package/build-module/hooks/content-lock-ui.js +27 -27
  296. package/build-module/hooks/content-lock-ui.js.map +1 -1
  297. package/build-module/hooks/custom-class-name.js +11 -27
  298. package/build-module/hooks/custom-class-name.js.map +1 -1
  299. package/build-module/hooks/custom-fields.js +20 -39
  300. package/build-module/hooks/custom-fields.js.map +1 -1
  301. package/build-module/hooks/dimensions.js +21 -16
  302. package/build-module/hooks/dimensions.js.map +1 -1
  303. package/build-module/hooks/duotone.js +30 -61
  304. package/build-module/hooks/duotone.js.map +1 -1
  305. package/build-module/hooks/font-family.js +14 -23
  306. package/build-module/hooks/font-family.js.map +1 -1
  307. package/build-module/hooks/font-size.js +49 -119
  308. package/build-module/hooks/font-size.js.map +1 -1
  309. package/build-module/hooks/index.js +18 -14
  310. package/build-module/hooks/index.js.map +1 -1
  311. package/build-module/hooks/index.native.js +5 -3
  312. package/build-module/hooks/index.native.js.map +1 -1
  313. package/build-module/hooks/layout-child.js +60 -0
  314. package/build-module/hooks/layout-child.js.map +1 -0
  315. package/build-module/hooks/layout.js +13 -98
  316. package/build-module/hooks/layout.js.map +1 -1
  317. package/build-module/hooks/padding.js +2 -2
  318. package/build-module/hooks/padding.js.map +1 -1
  319. package/build-module/hooks/position.js +38 -59
  320. package/build-module/hooks/position.js.map +1 -1
  321. package/build-module/hooks/style.js +51 -84
  322. package/build-module/hooks/style.js.map +1 -1
  323. package/build-module/hooks/typography.js +33 -12
  324. package/build-module/hooks/typography.js.map +1 -1
  325. package/build-module/hooks/utils.js +149 -6
  326. package/build-module/hooks/utils.js.map +1 -1
  327. package/build-module/private-apis.js +0 -2
  328. package/build-module/private-apis.js.map +1 -1
  329. package/build-module/store/private-actions.js +7 -0
  330. package/build-module/store/private-actions.js.map +1 -1
  331. package/build-module/store/private-selectors.js +33 -1
  332. package/build-module/store/private-selectors.js.map +1 -1
  333. package/build-module/store/reducer.js +8 -0
  334. package/build-module/store/reducer.js.map +1 -1
  335. package/build-module/store/selectors.js +3 -53
  336. package/build-module/store/selectors.js.map +1 -1
  337. package/build-module/store/utils.js +56 -0
  338. package/build-module/store/utils.js.map +1 -0
  339. package/build-module/utils/object.js +21 -60
  340. package/build-module/utils/object.js.map +1 -1
  341. package/build-module/utils/selection.js +9 -1
  342. package/build-module/utils/selection.js.map +1 -1
  343. package/build-style/style-rtl.css +113 -293
  344. package/build-style/style.css +113 -293
  345. package/package.json +31 -31
  346. package/src/components/block-canvas/index.js +31 -17
  347. package/src/components/block-caption/README.md +2 -2
  348. package/src/components/block-card/index.js +5 -3
  349. package/src/components/block-card/style.scss +7 -3
  350. package/src/components/block-controls/hook.js +8 -30
  351. package/src/components/block-controls/test/index.js +3 -3
  352. package/src/components/block-edit/context.js +3 -0
  353. package/src/components/block-edit/index.js +36 -10
  354. package/src/components/block-info-slot-fill/index.js +6 -3
  355. package/src/components/block-inspector/style.scss +0 -4
  356. package/src/components/block-list/block.js +39 -5
  357. package/src/components/block-list/block.native.js +18 -4
  358. package/src/components/block-list/use-block-props/index.js +74 -21
  359. package/src/components/block-list/use-block-props/use-focus-first-element.js +1 -34
  360. package/src/components/block-list/use-block-props/use-is-hovered.js +2 -13
  361. package/src/components/block-list/use-block-props/use-selected-block-event-handlers.js +1 -5
  362. package/src/components/block-patterns-list/index.js +1 -1
  363. package/src/components/block-removal-warning-modal/index.js +7 -14
  364. package/src/components/block-rename/modal.js +7 -1
  365. package/src/components/block-settings/container.native.js +3 -5
  366. package/src/components/block-styles/index.js +1 -1
  367. package/src/components/block-styles/index.native.js +4 -2
  368. package/src/components/block-styles/style.scss +0 -11
  369. package/src/components/block-switcher/test/__snapshots__/index.js.snap +3 -1
  370. package/src/components/block-toolbar/index.js +180 -95
  371. package/src/components/block-toolbar/style.scss +50 -66
  372. package/src/components/block-tools/block-toolbar-breadcrumb.js +46 -0
  373. package/src/components/block-tools/block-toolbar-popover.js +90 -0
  374. package/src/components/block-tools/index.js +42 -29
  375. package/src/components/block-tools/style.scss +60 -172
  376. package/src/components/block-types-list/index.native.js +2 -1
  377. package/src/components/block-variation-picker/index.native.js +1 -1
  378. package/src/components/colors-gradients/control.js +49 -30
  379. package/src/components/colors-gradients/style.scss +0 -7
  380. package/src/components/duotone-control/index.js +2 -5
  381. package/src/components/duotone-control/style.scss +1 -6
  382. package/src/components/global-styles/color-panel.js +34 -25
  383. package/src/components/global-styles/filters-panel.js +8 -4
  384. package/src/components/global-styles/typography-panel.js +23 -43
  385. package/src/components/image-link-destinations/index.native.js +152 -0
  386. package/src/components/image-link-destinations/style.native.scss +16 -0
  387. package/src/components/index.native.js +1 -0
  388. package/src/components/inner-blocks/README.md +13 -2
  389. package/src/components/inserter/media-tab/media-panel.js +1 -1
  390. package/src/components/inserter/menu.js +16 -8
  391. package/src/components/inserter/preview-panel.js +2 -2
  392. package/src/components/inserter/style.scss +15 -17
  393. package/src/components/inserter-button/README.md +62 -0
  394. package/src/components/inserter-button/index.native.js +116 -0
  395. package/src/components/inserter-button/sparkles.js +15 -0
  396. package/src/components/inserter-button/style.native.scss +72 -0
  397. package/src/components/inserter-draggable-blocks/index.js +18 -5
  398. package/src/components/inspector-controls/fill.js +6 -3
  399. package/src/components/inspector-controls/fill.native.js +6 -3
  400. package/src/components/link-control/style.scss +1 -1
  401. package/src/components/link-control/test/index.js +1 -1
  402. package/src/components/navigable-toolbar/README.md +2 -0
  403. package/src/components/navigable-toolbar/index.js +2 -2
  404. package/src/components/preview-options/index.js +6 -86
  405. package/src/components/rich-text/content.js +27 -20
  406. package/src/components/rich-text/get-rich-text-values.js +6 -1
  407. package/src/components/rich-text/index.js +5 -46
  408. package/src/components/rich-text/index.native.js +8 -25
  409. package/src/components/rich-text/native/get-format-colors.native.js +33 -40
  410. package/src/components/rich-text/native/index.native.js +7 -48
  411. package/src/components/rich-text/use-input-rules.js +6 -1
  412. package/src/components/rich-text/with-deprecations.js +51 -0
  413. package/src/components/use-block-drop-zone/index.js +114 -14
  414. package/src/components/use-on-block-drop/index.js +2 -1
  415. package/src/components/use-resize-canvas/README.md +3 -3
  416. package/src/components/use-resize-canvas/index.js +4 -1
  417. package/src/components/use-settings/index.js +15 -1
  418. package/src/hooks/align.js +15 -76
  419. package/src/hooks/align.native.js +1 -0
  420. package/src/hooks/anchor.js +13 -33
  421. package/src/hooks/background.js +28 -23
  422. package/src/hooks/block-hooks.js +22 -51
  423. package/src/hooks/block-renaming.js +23 -37
  424. package/src/hooks/border.js +67 -118
  425. package/src/hooks/color.js +100 -132
  426. package/src/hooks/content-lock-ui.js +110 -122
  427. package/src/hooks/custom-class-name.js +8 -40
  428. package/src/hooks/custom-fields.js +20 -47
  429. package/src/hooks/dimensions.js +20 -16
  430. package/src/hooks/duotone.js +70 -127
  431. package/src/hooks/font-family.js +10 -29
  432. package/src/hooks/font-size.js +66 -162
  433. package/src/hooks/index.js +42 -14
  434. package/src/hooks/index.native.js +6 -3
  435. package/src/hooks/layout-child.js +53 -0
  436. package/src/hooks/layout.js +13 -102
  437. package/src/hooks/padding.js +2 -2
  438. package/src/hooks/position.js +50 -90
  439. package/src/hooks/style.js +117 -187
  440. package/src/hooks/test/align.js +1 -178
  441. package/src/hooks/typography.js +20 -16
  442. package/src/hooks/utils.js +187 -6
  443. package/src/private-apis.js +0 -2
  444. package/src/store/private-actions.js +8 -0
  445. package/src/store/private-selectors.js +45 -0
  446. package/src/store/reducer.js +8 -0
  447. package/src/store/selectors.js +5 -69
  448. package/src/store/utils.js +74 -0
  449. package/src/style.scss +0 -2
  450. package/src/utils/object.js +18 -69
  451. package/src/utils/selection.js +9 -2
  452. package/build/components/block-list/use-block-props/use-block-class-names.js +0 -67
  453. package/build/components/block-list/use-block-props/use-block-class-names.js.map +0 -1
  454. package/build/components/block-list/use-block-props/use-block-custom-class-name.js +0 -46
  455. package/build/components/block-list/use-block-props/use-block-custom-class-name.js.map +0 -1
  456. package/build/components/block-list/use-block-props/use-block-default-class-name.js +0 -37
  457. package/build/components/block-list/use-block-props/use-block-default-class-name.js.map +0 -1
  458. package/build/components/block-tools/back-compat.js +0 -45
  459. package/build/components/block-tools/back-compat.js.map +0 -1
  460. package/build/components/block-tools/block-contextual-toolbar.js +0 -91
  461. package/build/components/block-tools/block-contextual-toolbar.js.map +0 -1
  462. package/build/components/block-tools/selected-block-tools.js +0 -113
  463. package/build/components/block-tools/selected-block-tools.js.map +0 -1
  464. package/build/components/inserter/hooks/use-debounced-input.js +0 -22
  465. package/build/components/inserter/hooks/use-debounced-input.js.map +0 -1
  466. package/build/components/use-display-block-controls/index.js +0 -39
  467. package/build/components/use-display-block-controls/index.js.map +0 -1
  468. package/build/components/use-display-block-controls/index.native.js +0 -39
  469. package/build/components/use-display-block-controls/index.native.js.map +0 -1
  470. package/build-module/components/block-list/use-block-props/use-block-class-names.js +0 -60
  471. package/build-module/components/block-list/use-block-props/use-block-class-names.js.map +0 -1
  472. package/build-module/components/block-list/use-block-props/use-block-custom-class-name.js +0 -40
  473. package/build-module/components/block-list/use-block-props/use-block-custom-class-name.js.map +0 -1
  474. package/build-module/components/block-list/use-block-props/use-block-default-class-name.js +0 -31
  475. package/build-module/components/block-list/use-block-props/use-block-default-class-name.js.map +0 -1
  476. package/build-module/components/block-tools/back-compat.js +0 -35
  477. package/build-module/components/block-tools/back-compat.js.map +0 -1
  478. package/build-module/components/block-tools/block-contextual-toolbar.js +0 -83
  479. package/build-module/components/block-tools/block-contextual-toolbar.js.map +0 -1
  480. package/build-module/components/block-tools/selected-block-tools.js +0 -105
  481. package/build-module/components/block-tools/selected-block-tools.js.map +0 -1
  482. package/build-module/components/inserter/hooks/use-debounced-input.js +0 -15
  483. package/build-module/components/inserter/hooks/use-debounced-input.js.map +0 -1
  484. package/build-module/components/use-display-block-controls/index.js +0 -32
  485. package/build-module/components/use-display-block-controls/index.js.map +0 -1
  486. package/build-module/components/use-display-block-controls/index.native.js +0 -32
  487. package/build-module/components/use-display-block-controls/index.native.js.map +0 -1
  488. package/src/components/block-list/use-block-props/use-block-class-names.js +0 -66
  489. package/src/components/block-list/use-block-props/use-block-custom-class-name.js +0 -44
  490. package/src/components/block-list/use-block-props/use-block-default-class-name.js +0 -35
  491. package/src/components/block-parent-selector/style.scss +0 -11
  492. package/src/components/block-tools/back-compat.js +0 -35
  493. package/src/components/block-tools/block-contextual-toolbar.js +0 -100
  494. package/src/components/block-tools/selected-block-tools.js +0 -127
  495. package/src/components/inserter/hooks/use-debounced-input.js +0 -18
  496. package/src/components/preview-options/README.md +0 -94
  497. package/src/components/preview-options/style.scss +0 -64
  498. package/src/components/use-display-block-controls/index.js +0 -36
  499. package/src/components/use-display-block-controls/index.native.js +0 -37
  500. package/src/hooks/test/color.js +0 -112
@@ -1,10 +1,9 @@
1
- import { createElement, Fragment } from "react";
1
+ import { createElement } from "react";
2
2
  /**
3
3
  * WordPress dependencies
4
4
  */
5
5
  import { addFilter } from '@wordpress/hooks';
6
6
  import { hasBlockSupport } from '@wordpress/blocks';
7
- import { createHigherOrderComponent } from '@wordpress/compose';
8
7
  import { __ } from '@wordpress/i18n';
9
8
  import { TextControl } from '@wordpress/components';
10
9
 
@@ -12,7 +11,6 @@ import { TextControl } from '@wordpress/components';
12
11
  * Internal dependencies
13
12
  */
14
13
  import { InspectorControls } from '../components';
15
- import { useBlockRename } from '../components/block-rename';
16
14
 
17
15
  /**
18
16
  * Filters registered block settings, adding an `__experimentalLabel` callback if one does not already exist.
@@ -46,35 +44,33 @@ export function addLabelCallback(settings) {
46
44
  }
47
45
  return settings;
48
46
  }
49
- export const withBlockRenameControl = createHigherOrderComponent(BlockEdit => props => {
50
- const {
51
- name,
52
- attributes,
53
- setAttributes,
54
- isSelected
55
- } = props;
56
- const {
57
- canRename
58
- } = useBlockRename(name);
59
- return createElement(Fragment, null, isSelected && canRename && createElement(InspectorControls, {
47
+ function BlockRenameControlPure({
48
+ metadata,
49
+ setAttributes
50
+ }) {
51
+ return createElement(InspectorControls, {
60
52
  group: "advanced"
61
53
  }, createElement(TextControl, {
62
54
  __nextHasNoMarginBottom: true,
55
+ __next40pxDefaultSize: true,
63
56
  label: __('Block name'),
64
- value: attributes?.metadata?.name || '',
57
+ value: metadata?.name || '',
65
58
  onChange: newName => {
66
59
  setAttributes({
67
60
  metadata: {
68
- ...attributes?.metadata,
61
+ ...metadata,
69
62
  name: newName
70
63
  }
71
64
  });
72
65
  }
73
- })), createElement(BlockEdit, {
74
- key: "edit",
75
- ...props
76
66
  }));
77
- }, 'withToolbarControls');
78
- addFilter('editor.BlockEdit', 'core/block-rename-ui/with-block-rename-control', withBlockRenameControl);
67
+ }
68
+ export default {
69
+ edit: BlockRenameControlPure,
70
+ attributeKeys: ['metadata'],
71
+ hasSupport(name) {
72
+ return hasBlockSupport(name, 'renaming', true);
73
+ }
74
+ };
79
75
  addFilter('blocks.registerBlockType', 'core/metadata/addLabelCallback', addLabelCallback);
80
76
  //# sourceMappingURL=block-renaming.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["addFilter","hasBlockSupport","createHigherOrderComponent","__","TextControl","InspectorControls","useBlockRename","addLabelCallback","settings","__experimentalLabel","supportsBlockNaming","attributes","context","metadata","name","withBlockRenameControl","BlockEdit","props","setAttributes","isSelected","canRename","createElement","Fragment","group","__nextHasNoMarginBottom","label","value","onChange","newName","key"],"sources":["@wordpress/block-editor/src/hooks/block-renaming.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { addFilter } from '@wordpress/hooks';\nimport { hasBlockSupport } from '@wordpress/blocks';\nimport { createHigherOrderComponent } from '@wordpress/compose';\nimport { __ } from '@wordpress/i18n';\nimport { TextControl } from '@wordpress/components';\n\n/**\n * Internal dependencies\n */\nimport { InspectorControls } from '../components';\nimport { useBlockRename } from '../components/block-rename';\n\n/**\n * Filters registered block settings, adding an `__experimentalLabel` callback if one does not already exist.\n *\n * @param {Object} settings Original block settings.\n *\n * @return {Object} Filtered block settings.\n */\nexport function addLabelCallback( settings ) {\n\t// If blocks provide their own label callback, do not override it.\n\tif ( settings.__experimentalLabel ) {\n\t\treturn settings;\n\t}\n\n\tconst supportsBlockNaming = hasBlockSupport(\n\t\tsettings,\n\t\t'renaming',\n\t\ttrue // default value\n\t);\n\n\t// Check whether block metadata is supported before using it.\n\tif ( supportsBlockNaming ) {\n\t\tsettings.__experimentalLabel = ( attributes, { context } ) => {\n\t\t\tconst { metadata } = attributes;\n\n\t\t\t// In the list view, use the block's name attribute as the label.\n\t\t\tif ( context === 'list-view' && metadata?.name ) {\n\t\t\t\treturn metadata.name;\n\t\t\t}\n\t\t};\n\t}\n\n\treturn settings;\n}\n\nexport const withBlockRenameControl = createHigherOrderComponent(\n\t( BlockEdit ) => ( props ) => {\n\t\tconst { name, attributes, setAttributes, isSelected } = props;\n\n\t\tconst { canRename } = useBlockRename( name );\n\n\t\treturn (\n\t\t\t<>\n\t\t\t\t{ isSelected && canRename && (\n\t\t\t\t\t<InspectorControls group=\"advanced\">\n\t\t\t\t\t\t<TextControl\n\t\t\t\t\t\t\t__nextHasNoMarginBottom\n\t\t\t\t\t\t\tlabel={ __( 'Block name' ) }\n\t\t\t\t\t\t\tvalue={ attributes?.metadata?.name || '' }\n\t\t\t\t\t\t\tonChange={ ( newName ) => {\n\t\t\t\t\t\t\t\tsetAttributes( {\n\t\t\t\t\t\t\t\t\tmetadata: {\n\t\t\t\t\t\t\t\t\t\t...attributes?.metadata,\n\t\t\t\t\t\t\t\t\t\tname: newName,\n\t\t\t\t\t\t\t\t\t},\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</InspectorControls>\n\t\t\t\t) }\n\t\t\t\t<BlockEdit key=\"edit\" { ...props } />\n\t\t\t</>\n\t\t);\n\t},\n\t'withToolbarControls'\n);\n\naddFilter(\n\t'editor.BlockEdit',\n\t'core/block-rename-ui/with-block-rename-control',\n\twithBlockRenameControl\n);\n\naddFilter(\n\t'blocks.registerBlockType',\n\t'core/metadata/addLabelCallback',\n\taddLabelCallback\n);\n"],"mappings":";AAAA;AACA;AACA;AACA,SAASA,SAAS,QAAQ,kBAAkB;AAC5C,SAASC,eAAe,QAAQ,mBAAmB;AACnD,SAASC,0BAA0B,QAAQ,oBAAoB;AAC/D,SAASC,EAAE,QAAQ,iBAAiB;AACpC,SAASC,WAAW,QAAQ,uBAAuB;;AAEnD;AACA;AACA;AACA,SAASC,iBAAiB,QAAQ,eAAe;AACjD,SAASC,cAAc,QAAQ,4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B,CACnB,EACDP,aAAA,CAACL,SAAS;IAACa,GAAG,EAAC,MAAM;IAAA,GAAMZ;EAAK,CAAI,CACnC,CAAC;AAEL,CAAC,EACD,qBACD,CAAC;AAEDjB,SAAS,CACR,kBAAkB,EAClB,gDAAgD,EAChDe,sBACD,CAAC;AAEDf,SAAS,CACR,0BAA0B,EAC1B,gCAAgC,EAChCO,gBACD,CAAC"}
1
+ {"version":3,"names":["addFilter","hasBlockSupport","__","TextControl","InspectorControls","addLabelCallback","settings","__experimentalLabel","supportsBlockNaming","attributes","context","metadata","name","BlockRenameControlPure","setAttributes","createElement","group","__nextHasNoMarginBottom","__next40pxDefaultSize","label","value","onChange","newName","edit","attributeKeys","hasSupport"],"sources":["@wordpress/block-editor/src/hooks/block-renaming.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { addFilter } from '@wordpress/hooks';\nimport { hasBlockSupport } from '@wordpress/blocks';\nimport { __ } from '@wordpress/i18n';\nimport { TextControl } from '@wordpress/components';\n\n/**\n * Internal dependencies\n */\nimport { InspectorControls } from '../components';\n\n/**\n * Filters registered block settings, adding an `__experimentalLabel` callback if one does not already exist.\n *\n * @param {Object} settings Original block settings.\n *\n * @return {Object} Filtered block settings.\n */\nexport function addLabelCallback( settings ) {\n\t// If blocks provide their own label callback, do not override it.\n\tif ( settings.__experimentalLabel ) {\n\t\treturn settings;\n\t}\n\n\tconst supportsBlockNaming = hasBlockSupport(\n\t\tsettings,\n\t\t'renaming',\n\t\ttrue // default value\n\t);\n\n\t// Check whether block metadata is supported before using it.\n\tif ( supportsBlockNaming ) {\n\t\tsettings.__experimentalLabel = ( attributes, { context } ) => {\n\t\t\tconst { metadata } = attributes;\n\n\t\t\t// In the list view, use the block's name attribute as the label.\n\t\t\tif ( context === 'list-view' && metadata?.name ) {\n\t\t\t\treturn metadata.name;\n\t\t\t}\n\t\t};\n\t}\n\n\treturn settings;\n}\n\nfunction BlockRenameControlPure( { metadata, setAttributes } ) {\n\treturn (\n\t\t<InspectorControls group=\"advanced\">\n\t\t\t<TextControl\n\t\t\t\t__nextHasNoMarginBottom\n\t\t\t\t__next40pxDefaultSize\n\t\t\t\tlabel={ __( 'Block name' ) }\n\t\t\t\tvalue={ metadata?.name || '' }\n\t\t\t\tonChange={ ( newName ) => {\n\t\t\t\t\tsetAttributes( {\n\t\t\t\t\t\tmetadata: { ...metadata, name: newName },\n\t\t\t\t\t} );\n\t\t\t\t} }\n\t\t\t/>\n\t\t</InspectorControls>\n\t);\n}\n\nexport default {\n\tedit: BlockRenameControlPure,\n\tattributeKeys: [ 'metadata' ],\n\thasSupport( name ) {\n\t\treturn hasBlockSupport( name, 'renaming', true );\n\t},\n};\n\naddFilter(\n\t'blocks.registerBlockType',\n\t'core/metadata/addLabelCallback',\n\taddLabelCallback\n);\n"],"mappings":";AAAA;AACA;AACA;AACA,SAASA,SAAS,QAAQ,kBAAkB;AAC5C,SAASC,eAAe,QAAQ,mBAAmB;AACnD,SAASC,EAAE,QAAQ,iBAAiB;AACpC,SAASC,WAAW,QAAQ,uBAAuB;;AAEnD;AACA;AACA;AACA,SAASC,iBAAiB,QAAQ,eAAe;;AAEjD;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,SAASC,gBAAgBA,CAAEC,QAAQ,EAAG;EAC5C;EACA,IAAKA,QAAQ,CAACC,mBAAmB,EAAG;IACnC,OAAOD,QAAQ;EAChB;EAEA,MAAME,mBAAmB,GAAGP,eAAe,CAC1CK,QAAQ,EACR,UAAU,EACV,IAAI,CAAC;EACN,CAAC;;EAED;EACA,IAAKE,mBAAmB,EAAG;IAC1BF,QAAQ,CAACC,mBAAmB,GAAG,CAAEE,UAAU,EAAE;MAAEC;IAAQ,CAAC,KAAM;MAC7D,MAAM;QAAEC;MAAS,CAAC,GAAGF,UAAU;;MAE/B;MACA,IAAKC,OAAO,KAAK,WAAW,IAAIC,QAAQ,EAAEC,IAAI,EAAG;QAChD,OAAOD,QAAQ,CAACC,IAAI;MACrB;IACD,CAAC;EACF;EAEA,OAAON,QAAQ;AAChB;AAEA,SAASO,sBAAsBA,CAAE;EAAEF,QAAQ;EAAEG;AAAc,CAAC,EAAG;EAC9D,OACCC,aAAA,CAACX,iBAAiB;IAACY,KAAK,EAAC;EAAU,GAClCD,aAAA,CAACZ,WAAW;IACXc,uBAAuB;IACvBC,qBAAqB;IACrBC,KAAK,EAAGjB,EAAE,CAAE,YAAa,CAAG;IAC5BkB,KAAK,EAAGT,QAAQ,EAAEC,IAAI,IAAI,EAAI;IAC9BS,QAAQ,EAAKC,OAAO,IAAM;MACzBR,aAAa,CAAE;QACdH,QAAQ,EAAE;UAAE,GAAGA,QAAQ;UAAEC,IAAI,EAAEU;QAAQ;MACxC,CAAE,CAAC;IACJ;EAAG,CACH,CACiB,CAAC;AAEtB;AAEA,eAAe;EACdC,IAAI,EAAEV,sBAAsB;EAC5BW,aAAa,EAAE,CAAE,UAAU,CAAE;EAC7BC,UAAUA,CAAEb,IAAI,EAAG;IAClB,OAAOX,eAAe,CAAEW,IAAI,EAAE,UAAU,EAAE,IAAK,CAAC;EACjD;AACD,CAAC;AAEDZ,SAAS,CACR,0BAA0B,EAC1B,gCAAgC,EAChCK,gBACD,CAAC"}
@@ -9,9 +9,10 @@ import classnames from 'classnames';
9
9
  */
10
10
  import { getBlockSupport } from '@wordpress/blocks';
11
11
  import { __experimentalHasSplitBorders as hasSplitBorders } from '@wordpress/components';
12
- import { createHigherOrderComponent } from '@wordpress/compose';
12
+ import { pure } from '@wordpress/compose';
13
13
  import { Platform, useCallback, useMemo } from '@wordpress/element';
14
14
  import { addFilter } from '@wordpress/hooks';
15
+ import { useSelect } from '@wordpress/data';
15
16
 
16
17
  /**
17
18
  * Internal dependencies
@@ -19,8 +20,9 @@ import { addFilter } from '@wordpress/hooks';
19
20
  import { getColorClassName } from '../components/colors';
20
21
  import InspectorControls from '../components/inspector-controls';
21
22
  import useMultipleOriginColorsAndGradients from '../components/colors-gradients/use-multiple-origin-colors-and-gradients';
22
- import { cleanEmptyObject, shouldSkipSerialization, useBlockSettings } from './utils';
23
+ import { cleanEmptyObject, shouldSkipSerialization } from './utils';
23
24
  import { useHasBorderPanel, BorderPanel as StylesBorderPanel } from '../components/global-styles';
25
+ import { store as blockEditorStore } from '../store';
24
26
  export const BORDER_SUPPORT_KEY = '__experimentalBorder';
25
27
  const getColorByProperty = (colors, property, value) => {
26
28
  let matchedColor;
@@ -116,28 +118,40 @@ function BordersInspectorControl({
116
118
  resetAllFilter: attributesResetAllFilter
117
119
  }, children);
118
120
  }
119
- export function BorderPanel(props) {
120
- const {
121
- clientId,
122
- name,
123
- attributes,
124
- setAttributes
125
- } = props;
126
- const settings = useBlockSettings(name);
121
+ function BorderPanelPure({
122
+ clientId,
123
+ name,
124
+ setAttributes,
125
+ settings
126
+ }) {
127
127
  const isEnabled = useHasBorderPanel(settings);
128
+ function selector(select) {
129
+ const {
130
+ style,
131
+ borderColor
132
+ } = select(blockEditorStore).getBlockAttributes(clientId) || {};
133
+ return {
134
+ style,
135
+ borderColor
136
+ };
137
+ }
138
+ const {
139
+ style,
140
+ borderColor
141
+ } = useSelect(selector, [clientId]);
128
142
  const value = useMemo(() => {
129
143
  return attributesToStyle({
130
- style: attributes.style,
131
- borderColor: attributes.borderColor
144
+ style,
145
+ borderColor
132
146
  });
133
- }, [attributes.style, attributes.borderColor]);
147
+ }, [style, borderColor]);
134
148
  const onChange = newStyle => {
135
149
  setAttributes(styleToAttributes(newStyle));
136
150
  };
137
151
  if (!isEnabled) {
138
152
  return null;
139
153
  }
140
- const defaultControls = getBlockSupport(props.name, [BORDER_SUPPORT_KEY, '__experimentalDefaultControls']);
154
+ const defaultControls = getBlockSupport(name, [BORDER_SUPPORT_KEY, '__experimentalDefaultControls']);
141
155
  return createElement(StylesBorderPanel, {
142
156
  as: BordersInspectorControl,
143
157
  panelId: clientId,
@@ -148,6 +162,11 @@ export function BorderPanel(props) {
148
162
  });
149
163
  }
150
164
 
165
+ // We don't want block controls to re-render when typing inside a block. `pure`
166
+ // will prevent re-renders unless props change, so only pass the needed props
167
+ // and not the whole attributes object.
168
+ export const BorderPanel = pure(BorderPanelPure);
169
+
151
170
  /**
152
171
  * Determine whether there is block support for border properties.
153
172
  *
@@ -222,14 +241,14 @@ function addAttributes(settings) {
222
241
  /**
223
242
  * Override props assigned to save component to inject border color.
224
243
  *
225
- * @param {Object} props Additional props applied to save element.
226
- * @param {Object} blockType Block type definition.
227
- * @param {Object} attributes Block's attributes.
244
+ * @param {Object} props Additional props applied to save element.
245
+ * @param {Object|string} blockNameOrType Block type definition.
246
+ * @param {Object} attributes Block's attributes.
228
247
  *
229
248
  * @return {Object} Filtered props to apply to save element.
230
249
  */
231
- function addSaveProps(props, blockType, attributes) {
232
- if (!hasBorderSupport(blockType, 'color') || shouldSkipSerialization(blockType, BORDER_SUPPORT_KEY, 'color')) {
250
+ function addSaveProps(props, blockNameOrType, attributes) {
251
+ if (!hasBorderSupport(blockNameOrType, 'color') || shouldSkipSerialization(blockNameOrType, BORDER_SUPPORT_KEY, 'color')) {
233
252
  return props;
234
253
  }
235
254
  const borderClasses = getBorderClasses(attributes);
@@ -260,54 +279,16 @@ export function getBorderClasses(attributes) {
260
279
  [borderColorClass]: !!borderColorClass
261
280
  });
262
281
  }
263
-
264
- /**
265
- * Filters the registered block settings to apply border color styles and
266
- * classnames to the block edit wrapper.
267
- *
268
- * @param {Object} settings Original block settings.
269
- *
270
- * @return {Object} Filtered block settings.
271
- */
272
- function addEditProps(settings) {
273
- if (!hasBorderSupport(settings, 'color') || shouldSkipSerialization(settings, BORDER_SUPPORT_KEY, 'color')) {
274
- return settings;
275
- }
276
- const existingGetEditWrapperProps = settings.getEditWrapperProps;
277
- settings.getEditWrapperProps = attributes => {
278
- let props = {};
279
- if (existingGetEditWrapperProps) {
280
- props = existingGetEditWrapperProps(attributes);
281
- }
282
- return addSaveProps(props, settings, attributes);
283
- };
284
- return settings;
285
- }
286
-
287
- /**
288
- * This adds inline styles for color palette colors.
289
- * Ideally, this is not needed and themes should load their palettes on the editor.
290
- *
291
- * @param {Function} BlockListBlock Original component.
292
- *
293
- * @return {Function} Wrapped component.
294
- */
295
- export const withBorderColorPaletteStyles = createHigherOrderComponent(BlockListBlock => props => {
296
- const {
297
- name,
298
- attributes
299
- } = props;
300
- const {
301
- borderColor,
302
- style
303
- } = attributes;
282
+ function useBlockProps({
283
+ name,
284
+ borderColor,
285
+ style
286
+ }) {
304
287
  const {
305
288
  colors
306
289
  } = useMultipleOriginColorsAndGradients();
307
290
  if (!hasBorderSupport(name, 'color') || shouldSkipSerialization(name, BORDER_SUPPORT_KEY, 'color')) {
308
- return createElement(BlockListBlock, {
309
- ...props
310
- });
291
+ return {};
311
292
  }
312
293
  const {
313
294
  color: borderColorValue
@@ -345,22 +326,20 @@ export const withBorderColorPaletteStyles = createHigherOrderComponent(BlockList
345
326
  borderBottomColor: borderBottomColor || borderColorValue,
346
327
  borderLeftColor: borderLeftColor || borderColorValue
347
328
  };
348
- const cleanedExtraStyles = cleanEmptyObject(extraStyles) || {};
349
- let wrapperProps = props.wrapperProps;
350
- wrapperProps = {
351
- ...props.wrapperProps,
352
- style: {
353
- ...props.wrapperProps?.style,
354
- ...cleanedExtraStyles
355
- }
356
- };
357
- return createElement(BlockListBlock, {
358
- ...props,
359
- wrapperProps: wrapperProps
329
+ return addSaveProps({
330
+ style: cleanEmptyObject(extraStyles) || {}
331
+ }, name, {
332
+ borderColor,
333
+ style
360
334
  });
361
- }, 'withBorderColorPaletteStyles');
335
+ }
336
+ export default {
337
+ useBlockProps,
338
+ attributeKeys: ['borderColor', 'style'],
339
+ hasSupport(name) {
340
+ return hasBorderSupport(name, 'color');
341
+ }
342
+ };
362
343
  addFilter('blocks.registerBlockType', 'core/border/addAttributes', addAttributes);
363
344
  addFilter('blocks.getSaveContent.extraProps', 'core/border/addSaveProps', addSaveProps);
364
- addFilter('blocks.registerBlockType', 'core/border/addEditProps', addEditProps);
365
- addFilter('editor.BlockListBlock', 'core/border/with-border-color-palette-styles', withBorderColorPaletteStyles);
366
345
  //# sourceMappingURL=border.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["classnames","getBlockSupport","__experimentalHasSplitBorders","hasSplitBorders","createHigherOrderComponent","Platform","useCallback","useMemo","addFilter","getColorClassName","InspectorControls","useMultipleOriginColorsAndGradients","cleanEmptyObject","shouldSkipSerialization","useBlockSettings","useHasBorderPanel","BorderPanel","StylesBorderPanel","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","createElement","group","props","clientId","name","setAttributes","settings","isEnabled","onChange","newStyle","defaultControls","as","panelId","hasBorderSupport","blockName","feature","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","cleanedExtraStyles","wrapperProps"],"sources":["@wordpress/block-editor/src/hooks/border.js"],"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\t\tconst cleanedExtraStyles = cleanEmptyObject( extraStyles ) || {};\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...cleanedExtraStyles,\n\t\t\t},\n\t\t};\n\n\t\treturn <BlockListBlock { ...props } wrapperProps={ wrapperProps } />;\n\t},\n\t'withBorderColorPaletteStyles'\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"],"mappings":";AAAA;AACA;AACA;AACA,OAAOA,UAAU,MAAM,YAAY;;AAEnC;AACA;AACA;AACA,SAASC,eAAe,QAAQ,mBAAmB;AACnD,SAASC,6BAA6B,IAAIC,eAAe,QAAQ,uBAAuB;AACxF,SAASC,0BAA0B,QAAQ,oBAAoB;AAC/D,SAASC,QAAQ,EAAEC,WAAW,EAAEC,OAAO,QAAQ,oBAAoB;AACnE,SAASC,SAAS,QAAQ,kBAAkB;;AAE5C;AACA;AACA;AACA,SAASC,iBAAiB,QAAQ,sBAAsB;AACxD,OAAOC,iBAAiB,MAAM,kCAAkC;AAChE,OAAOC,mCAAmC,MAAM,yEAAyE;AACzH,SACCC,gBAAgB,EAChBC,uBAAuB,EACvBC,gBAAgB,QACV,SAAS;AAChB,SACCC,iBAAiB,EACjBC,WAAW,IAAIC,iBAAiB,QAC1B,6BAA6B;AAEpC,OAAO,MAAMC,kBAAkB,GAAG,sBAAsB;AAExD,MAAMC,kBAAkB,GAAGA,CAAEC,MAAM,EAAEC,QAAQ,EAAEC,KAAK,KAAM;EACzD,IAAIC,YAAY;EAEhBH,MAAM,CAACI,IAAI,CAAIC,MAAM,IACpBA,MAAM,CAACL,MAAM,CAACI,IAAI,CAAIE,KAAK,IAAM;IAChC,IAAKA,KAAK,CAAEL,QAAQ,CAAE,KAAKC,KAAK,EAAG;MAClCC,YAAY,GAAGG,KAAK;MACpB,OAAO,IAAI;IACZ;IAEA,OAAO,KAAK;EACb,CAAE,CACH,CAAC;EAED,OAAOH,YAAY;AACpB,CAAC;AAED,OAAO,MAAMI,mBAAmB,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BAAgB,IAAInD,gBAAgB;IACtDqD,iBAAiB,EAAEA,iBAAiB,IAAIrD,gBAAgB;IACxDuD,eAAe,EAAEA,eAAe,IAAIvD;EACrC,CAAC;EACD,MAAM0D,kBAAkB,GAAGpF,gBAAgB,CAAEmF,WAAY,CAAC,IAAI,CAAC,CAAC;EAEhE,IAAIE,YAAY,GAAG5C,KAAK,CAAC4C,YAAY;EACrCA,YAAY,GAAG;IACd,GAAG5C,KAAK,CAAC4C,YAAY;IACrB9D,KAAK,EAAE;MACN,GAAGkB,KAAK,CAAC4C,YAAY,EAAE9D,KAAK;MAC5B,GAAG6D;IACJ;EACD,CAAC;EAED,OAAO7C,aAAA,CAACmC,cAAc;IAAA,GAAMjC,KAAK;IAAG4C,YAAY,EAAGA;EAAc,CAAE,CAAC;AACrE,CAAC,EACD,8BACD,CAAC;AAEDzF,SAAS,CACR,0BAA0B,EAC1B,2BAA2B,EAC3BiE,aACD,CAAC;AAEDjE,SAAS,CACR,kCAAkC,EAClC,0BAA0B,EAC1BmE,YACD,CAAC;AAEDnE,SAAS,CACR,0BAA0B,EAC1B,0BAA0B,EAC1B0E,YACD,CAAC;AAED1E,SAAS,CACR,uBAAuB,EACvB,8CAA8C,EAC9C6E,4BACD,CAAC"}
1
+ {"version":3,"names":["classnames","getBlockSupport","__experimentalHasSplitBorders","hasSplitBorders","pure","Platform","useCallback","useMemo","addFilter","useSelect","getColorClassName","InspectorControls","useMultipleOriginColorsAndGradients","cleanEmptyObject","shouldSkipSerialization","useHasBorderPanel","BorderPanel","StylesBorderPanel","store","blockEditorStore","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","createElement","group","BorderPanelPure","clientId","name","setAttributes","settings","isEnabled","selector","select","getBlockAttributes","onChange","newStyle","defaultControls","as","panelId","hasBorderSupport","blockName","feature","OS","support","radius","width","removeBorderAttribute","attribute","addAttributes","type","addSaveProps","props","blockNameOrType","borderClasses","getBorderClasses","newClassName","className","borderColorClass","useBlockProps","borderTopColor","top","borderRightColor","right","borderBottomColor","bottom","borderLeftColor","left","extraStyles","attributeKeys","hasSupport"],"sources":["@wordpress/block-editor/src/hooks/border.js"],"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 { pure } from '@wordpress/compose';\nimport { Platform, useCallback, useMemo } from '@wordpress/element';\nimport { addFilter } from '@wordpress/hooks';\nimport { useSelect } from '@wordpress/data';\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 { cleanEmptyObject, shouldSkipSerialization } from './utils';\nimport {\n\tuseHasBorderPanel,\n\tBorderPanel as StylesBorderPanel,\n} from '../components/global-styles';\nimport { store as blockEditorStore } from '../store';\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\nfunction BorderPanelPure( { clientId, name, setAttributes, settings } ) {\n\tconst isEnabled = useHasBorderPanel( settings );\n\tfunction selector( select ) {\n\t\tconst { style, borderColor } =\n\t\t\tselect( blockEditorStore ).getBlockAttributes( clientId ) || {};\n\t\treturn { style, borderColor };\n\t}\n\tconst { style, borderColor } = useSelect( selector, [ clientId ] );\n\tconst value = useMemo( () => {\n\t\treturn attributesToStyle( { style, borderColor } );\n\t}, [ style, 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( 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// We don't want block controls to re-render when typing inside a block. `pure`\n// will prevent re-renders unless props change, so only pass the needed props\n// and not the whole attributes object.\nexport const BorderPanel = pure( BorderPanelPure );\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|string} blockNameOrType 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, blockNameOrType, attributes ) {\n\tif (\n\t\t! hasBorderSupport( blockNameOrType, 'color' ) ||\n\t\tshouldSkipSerialization( blockNameOrType, 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\nfunction useBlockProps( { name, borderColor, style } ) {\n\tconst { colors } = useMultipleOriginColorsAndGradients();\n\n\tif (\n\t\t! hasBorderSupport( name, 'color' ) ||\n\t\tshouldSkipSerialization( name, BORDER_SUPPORT_KEY, 'color' )\n\t) {\n\t\treturn {};\n\t}\n\n\tconst { color: borderColorValue } = getMultiOriginColor( {\n\t\tcolors,\n\t\tnamedColor: borderColor,\n\t} );\n\tconst { color: borderTopColor } = getMultiOriginColor( {\n\t\tcolors,\n\t\tnamedColor: getColorSlugFromVariable( style?.border?.top?.color ),\n\t} );\n\tconst { color: borderRightColor } = getMultiOriginColor( {\n\t\tcolors,\n\t\tnamedColor: getColorSlugFromVariable( style?.border?.right?.color ),\n\t} );\n\n\tconst { color: borderBottomColor } = getMultiOriginColor( {\n\t\tcolors,\n\t\tnamedColor: getColorSlugFromVariable( style?.border?.bottom?.color ),\n\t} );\n\tconst { color: borderLeftColor } = getMultiOriginColor( {\n\t\tcolors,\n\t\tnamedColor: getColorSlugFromVariable( style?.border?.left?.color ),\n\t} );\n\n\tconst extraStyles = {\n\t\tborderTopColor: borderTopColor || borderColorValue,\n\t\tborderRightColor: borderRightColor || borderColorValue,\n\t\tborderBottomColor: borderBottomColor || borderColorValue,\n\t\tborderLeftColor: borderLeftColor || borderColorValue,\n\t};\n\n\treturn addSaveProps(\n\t\t{ style: cleanEmptyObject( extraStyles ) || {} },\n\t\tname,\n\t\t{ borderColor, style }\n\t);\n}\n\nexport default {\n\tuseBlockProps,\n\tattributeKeys: [ 'borderColor', 'style' ],\n\thasSupport( name ) {\n\t\treturn hasBorderSupport( name, 'color' );\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"],"mappings":";AAAA;AACA;AACA;AACA,OAAOA,UAAU,MAAM,YAAY;;AAEnC;AACA;AACA;AACA,SAASC,eAAe,QAAQ,mBAAmB;AACnD,SAASC,6BAA6B,IAAIC,eAAe,QAAQ,uBAAuB;AACxF,SAASC,IAAI,QAAQ,oBAAoB;AACzC,SAASC,QAAQ,EAAEC,WAAW,EAAEC,OAAO,QAAQ,oBAAoB;AACnE,SAASC,SAAS,QAAQ,kBAAkB;AAC5C,SAASC,SAAS,QAAQ,iBAAiB;;AAE3C;AACA;AACA;AACA,SAASC,iBAAiB,QAAQ,sBAAsB;AACxD,OAAOC,iBAAiB,MAAM,kCAAkC;AAChE,OAAOC,mCAAmC,MAAM,yEAAyE;AACzH,SAASC,gBAAgB,EAAEC,uBAAuB,QAAQ,SAAS;AACnE,SACCC,iBAAiB,EACjBC,WAAW,IAAIC,iBAAiB,QAC1B,6BAA6B;AACpC,SAASC,KAAK,IAAIC,gBAAgB,QAAQ,UAAU;AAEpD,OAAO,MAAMC,kBAAkB,GAAG,sBAAsB;AAExD,MAAMC,kBAAkB,GAAGA,CAAEC,MAAM,EAAEC,QAAQ,EAAEC,KAAK,KAAM;EACzD,IAAIC,YAAY;EAEhBH,MAAM,CAACI,IAAI,CAAIC,MAAM,IACpBA,MAAM,CAACL,MAAM,CAACI,IAAI,CAAIE,KAAK,IAAM;IAChC,IAAKA,KAAK,CAAEL,QAAQ,CAAE,KAAKC,KAAK,EAAG;MAClCC,YAAY,GAAGG,KAAK;MACpB,OAAO,IAAI;IACZ;IAEA,OAAO,KAAK;EACb,CAAE,CACH,CAAC;EAED,OAAOH,YAAY;AACpB,CAAC;AAED,OAAO,MAAMI,mBAAmB,GAAGA,CAAE;EAAEP,MAAM;EAAEQ,UAAU;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