@wordpress/block-editor 11.4.0 → 11.6.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 (400) hide show
  1. package/CHANGELOG.md +8 -0
  2. package/build/components/block-inspector/index.js +11 -10
  3. package/build/components/block-inspector/index.js.map +1 -1
  4. package/build/components/block-inspector/useBlockInspectorAnimationSettings.js +46 -0
  5. package/build/components/block-inspector/useBlockInspectorAnimationSettings.js.map +1 -0
  6. package/build/components/block-list/block-invalid-warning.js +63 -80
  7. package/build/components/block-list/block-invalid-warning.js.map +1 -1
  8. package/build/components/block-lock/modal.js +1 -0
  9. package/build/components/block-lock/modal.js.map +1 -1
  10. package/build/components/block-settings-menu/block-settings-dropdown.js +2 -2
  11. package/build/components/block-settings-menu/block-settings-dropdown.js.map +1 -1
  12. package/build/components/block-settings-menu-controls/index.js +1 -1
  13. package/build/components/block-settings-menu-controls/index.js.map +1 -1
  14. package/build/components/block-styles/index.js +2 -1
  15. package/build/components/block-styles/index.js.map +1 -1
  16. package/build/components/block-switcher/block-transformations-menu.native.js +1 -0
  17. package/build/components/block-switcher/block-transformations-menu.native.js.map +1 -1
  18. package/build/components/child-layout-control/index.js +107 -0
  19. package/build/components/child-layout-control/index.js.map +1 -0
  20. package/build/components/convert-to-group-buttons/use-convert-to-group-button-props.js +6 -3
  21. package/build/components/convert-to-group-buttons/use-convert-to-group-button-props.js.map +1 -1
  22. package/build/components/date-format-picker/index.js +3 -3
  23. package/build/components/date-format-picker/index.js.map +1 -1
  24. package/build/components/global-styles/border-panel.js +306 -0
  25. package/build/components/global-styles/border-panel.js.map +1 -0
  26. package/build/components/global-styles/dimensions-panel.js +594 -0
  27. package/build/components/global-styles/dimensions-panel.js.map +1 -0
  28. package/build/components/global-styles/hooks.js +127 -37
  29. package/build/components/global-styles/hooks.js.map +1 -1
  30. package/build/components/global-styles/index.js +36 -2
  31. package/build/components/global-styles/index.js.map +1 -1
  32. package/build/components/global-styles/typography-panel.js +87 -27
  33. package/build/components/global-styles/typography-panel.js.map +1 -1
  34. package/build/components/global-styles/use-global-styles-output.js +21 -14
  35. package/build/components/global-styles/use-global-styles-output.js.map +1 -1
  36. package/build/components/global-styles/utils.js +2 -0
  37. package/build/components/global-styles/utils.js.map +1 -1
  38. package/build/components/index.native.js +23 -0
  39. package/build/components/index.native.js.map +1 -1
  40. package/build/components/inserter/index.js +29 -17
  41. package/build/components/inserter/index.js.map +1 -1
  42. package/build/components/inserter/media-tab/hooks.js +10 -11
  43. package/build/components/inserter/media-tab/hooks.js.map +1 -1
  44. package/build/components/inserter/media-tab/media-list.js +5 -108
  45. package/build/components/inserter/media-tab/media-list.js.map +1 -1
  46. package/build/components/inserter/media-tab/media-preview.js +242 -0
  47. package/build/components/inserter/media-tab/media-preview.js.map +1 -0
  48. package/build/components/inserter/menu.js +1 -1
  49. package/build/components/inserter/menu.js.map +1 -1
  50. package/build/components/inserter/quick-inserter.js +4 -2
  51. package/build/components/inserter/quick-inserter.js.map +1 -1
  52. package/build/components/inserter/search-results.js +10 -3
  53. package/build/components/inserter/search-results.js.map +1 -1
  54. package/build/components/inserter/tabs.js +1 -1
  55. package/build/components/inserter/tabs.js.map +1 -1
  56. package/build/components/inspector-controls/block-support-tools-panel.js +1 -1
  57. package/build/components/inspector-controls/block-support-tools-panel.js.map +1 -1
  58. package/build/components/inspector-controls/fill.js +38 -9
  59. package/build/components/inspector-controls/fill.js.map +1 -1
  60. package/build/components/link-control/index.js +1 -1
  61. package/build/components/link-control/index.js.map +1 -1
  62. package/build/components/link-control/search-item.js +5 -2
  63. package/build/components/link-control/search-item.js.map +1 -1
  64. package/build/components/link-control/settings-drawer.js +1 -1
  65. package/build/components/link-control/settings-drawer.js.map +1 -1
  66. package/build/components/link-control/settings.js +1 -0
  67. package/build/components/link-control/settings.js.map +1 -1
  68. package/build/components/list-view/block.js +17 -3
  69. package/build/components/list-view/block.js.map +1 -1
  70. package/build/components/list-view/branch.js +2 -2
  71. package/build/components/list-view/branch.js.map +1 -1
  72. package/build/components/list-view/expander.js +2 -1
  73. package/build/components/list-view/expander.js.map +1 -1
  74. package/build/components/list-view/leaf.js +10 -6
  75. package/build/components/list-view/leaf.js.map +1 -1
  76. package/build/components/list-view/use-block-selection.js +1 -2
  77. package/build/components/list-view/use-block-selection.js.map +1 -1
  78. package/build/components/list-view/use-list-view-scroll-into-view.js +51 -0
  79. package/build/components/list-view/use-list-view-scroll-into-view.js.map +1 -0
  80. package/build/components/off-canvas-editor/appender.js +33 -13
  81. package/build/components/off-canvas-editor/appender.js.map +1 -1
  82. package/build/components/off-canvas-editor/branch.js +6 -3
  83. package/build/components/off-canvas-editor/branch.js.map +1 -1
  84. package/build/components/off-canvas-editor/index.js +8 -2
  85. package/build/components/off-canvas-editor/index.js.map +1 -1
  86. package/build/components/off-canvas-editor/leaf-more-menu.js +34 -4
  87. package/build/components/off-canvas-editor/leaf-more-menu.js.map +1 -1
  88. package/build/components/provider/use-block-sync.js +17 -3
  89. package/build/components/provider/use-block-sync.js.map +1 -1
  90. package/build/components/responsive-block-control/index.js +1 -0
  91. package/build/components/responsive-block-control/index.js.map +1 -1
  92. package/build/components/rich-text/format-toolbar-container.js +0 -3
  93. package/build/components/rich-text/format-toolbar-container.js.map +1 -1
  94. package/build/components/rich-text/index.js +9 -43
  95. package/build/components/rich-text/index.js.map +1 -1
  96. package/build/components/rich-text/use-delete.js +73 -0
  97. package/build/components/rich-text/use-delete.js.map +1 -0
  98. package/build/components/rich-text/use-input-rules.js +14 -6
  99. package/build/components/rich-text/use-input-rules.js.map +1 -1
  100. package/build/components/writing-flow/use-selection-observer.js +4 -1
  101. package/build/components/writing-flow/use-selection-observer.js.map +1 -1
  102. package/build/hooks/align.js +3 -1
  103. package/build/hooks/align.js.map +1 -1
  104. package/build/hooks/border.js +91 -240
  105. package/build/hooks/border.js.map +1 -1
  106. package/build/hooks/custom-class-name.js +4 -4
  107. package/build/hooks/custom-class-name.js.map +1 -1
  108. package/build/hooks/custom-class-name.native.js +3 -4
  109. package/build/hooks/custom-class-name.native.js.map +1 -1
  110. package/build/hooks/dimensions.js +72 -190
  111. package/build/hooks/dimensions.js.map +1 -1
  112. package/build/hooks/duotone.js +94 -25
  113. package/build/hooks/duotone.js.map +1 -1
  114. package/build/hooks/gap.js +0 -202
  115. package/build/hooks/gap.js.map +1 -1
  116. package/build/hooks/layout.js +33 -27
  117. package/build/hooks/layout.js.map +1 -1
  118. package/build/hooks/margin.js +7 -163
  119. package/build/hooks/margin.js.map +1 -1
  120. package/build/hooks/padding.js +7 -163
  121. package/build/hooks/padding.js.map +1 -1
  122. package/build/hooks/supports.js +7 -1
  123. package/build/hooks/supports.js.map +1 -1
  124. package/build/hooks/typography.js +52 -66
  125. package/build/hooks/typography.js.map +1 -1
  126. package/build/hooks/utils.js +101 -0
  127. package/build/hooks/utils.js.map +1 -1
  128. package/build/layouts/constrained.js +6 -2
  129. package/build/layouts/constrained.js.map +1 -1
  130. package/build/layouts/flex.js +1 -0
  131. package/build/layouts/flex.js.map +1 -1
  132. package/build/private-apis.js +4 -1
  133. package/build/private-apis.js.map +1 -1
  134. package/build/store/actions.js +28 -14
  135. package/build/store/actions.js.map +1 -1
  136. package/build/store/defaults.js +28 -1
  137. package/build/store/defaults.js.map +1 -1
  138. package/build/store/reducer.js +53 -47
  139. package/build/store/reducer.js.map +1 -1
  140. package/build/store/selectors.js +24 -4
  141. package/build/store/selectors.js.map +1 -1
  142. package/build/utils/parse-css-unit-to-px.js +49 -10
  143. package/build/utils/parse-css-unit-to-px.js.map +1 -1
  144. package/build-module/components/block-inspector/index.js +9 -9
  145. package/build-module/components/block-inspector/index.js.map +1 -1
  146. package/build-module/components/block-inspector/useBlockInspectorAnimationSettings.js +37 -0
  147. package/build-module/components/block-inspector/useBlockInspectorAnimationSettings.js.map +1 -0
  148. package/build-module/components/block-list/block-invalid-warning.js +66 -78
  149. package/build-module/components/block-list/block-invalid-warning.js.map +1 -1
  150. package/build-module/components/block-lock/modal.js +1 -0
  151. package/build-module/components/block-lock/modal.js.map +1 -1
  152. package/build-module/components/block-settings-menu/block-settings-dropdown.js +2 -2
  153. package/build-module/components/block-settings-menu/block-settings-dropdown.js.map +1 -1
  154. package/build-module/components/block-settings-menu-controls/index.js +1 -1
  155. package/build-module/components/block-settings-menu-controls/index.js.map +1 -1
  156. package/build-module/components/block-styles/index.js +2 -1
  157. package/build-module/components/block-styles/index.js.map +1 -1
  158. package/build-module/components/block-switcher/block-transformations-menu.native.js +1 -0
  159. package/build-module/components/block-switcher/block-transformations-menu.native.js.map +1 -1
  160. package/build-module/components/child-layout-control/index.js +98 -0
  161. package/build-module/components/child-layout-control/index.js.map +1 -0
  162. package/build-module/components/convert-to-group-buttons/use-convert-to-group-button-props.js +6 -3
  163. package/build-module/components/convert-to-group-buttons/use-convert-to-group-button-props.js.map +1 -1
  164. package/build-module/components/date-format-picker/index.js +4 -4
  165. package/build-module/components/date-format-picker/index.js.map +1 -1
  166. package/build-module/components/global-styles/border-panel.js +291 -0
  167. package/build-module/components/global-styles/border-panel.js.map +1 -0
  168. package/build-module/components/global-styles/dimensions-panel.js +574 -0
  169. package/build-module/components/global-styles/dimensions-panel.js.map +1 -0
  170. package/build-module/components/global-styles/hooks.js +123 -34
  171. package/build-module/components/global-styles/hooks.js.map +1 -1
  172. package/build-module/components/global-styles/index.js +3 -1
  173. package/build-module/components/global-styles/index.js.map +1 -1
  174. package/build-module/components/global-styles/typography-panel.js +88 -27
  175. package/build-module/components/global-styles/typography-panel.js.map +1 -1
  176. package/build-module/components/global-styles/use-global-styles-output.js +21 -14
  177. package/build-module/components/global-styles/use-global-styles-output.js.map +1 -1
  178. package/build-module/components/global-styles/utils.js +2 -0
  179. package/build-module/components/global-styles/utils.js.map +1 -1
  180. package/build-module/components/index.native.js +2 -1
  181. package/build-module/components/index.native.js.map +1 -1
  182. package/build-module/components/inserter/index.js +28 -16
  183. package/build-module/components/inserter/index.js.map +1 -1
  184. package/build-module/components/inserter/media-tab/hooks.js +10 -11
  185. package/build-module/components/inserter/media-tab/hooks.js.map +1 -1
  186. package/build-module/components/inserter/media-tab/media-list.js +6 -105
  187. package/build-module/components/inserter/media-tab/media-list.js.map +1 -1
  188. package/build-module/components/inserter/media-tab/media-preview.js +222 -0
  189. package/build-module/components/inserter/media-tab/media-preview.js.map +1 -0
  190. package/build-module/components/inserter/menu.js +1 -1
  191. package/build-module/components/inserter/menu.js.map +1 -1
  192. package/build-module/components/inserter/quick-inserter.js +4 -2
  193. package/build-module/components/inserter/quick-inserter.js.map +1 -1
  194. package/build-module/components/inserter/search-results.js +10 -3
  195. package/build-module/components/inserter/search-results.js.map +1 -1
  196. package/build-module/components/inserter/tabs.js +1 -1
  197. package/build-module/components/inserter/tabs.js.map +1 -1
  198. package/build-module/components/inspector-controls/block-support-tools-panel.js +1 -1
  199. package/build-module/components/inspector-controls/block-support-tools-panel.js.map +1 -1
  200. package/build-module/components/inspector-controls/fill.js +39 -9
  201. package/build-module/components/inspector-controls/fill.js.map +1 -1
  202. package/build-module/components/link-control/index.js +1 -1
  203. package/build-module/components/link-control/index.js.map +1 -1
  204. package/build-module/components/link-control/search-item.js +4 -2
  205. package/build-module/components/link-control/search-item.js.map +1 -1
  206. package/build-module/components/link-control/settings-drawer.js +1 -1
  207. package/build-module/components/link-control/settings-drawer.js.map +1 -1
  208. package/build-module/components/link-control/settings.js +1 -0
  209. package/build-module/components/link-control/settings.js.map +1 -1
  210. package/build-module/components/list-view/block.js +16 -3
  211. package/build-module/components/list-view/block.js.map +1 -1
  212. package/build-module/components/list-view/branch.js +2 -2
  213. package/build-module/components/list-view/branch.js.map +1 -1
  214. package/build-module/components/list-view/expander.js +2 -1
  215. package/build-module/components/list-view/expander.js.map +1 -1
  216. package/build-module/components/list-view/leaf.js +8 -4
  217. package/build-module/components/list-view/leaf.js.map +1 -1
  218. package/build-module/components/list-view/use-block-selection.js +1 -2
  219. package/build-module/components/list-view/use-block-selection.js.map +1 -1
  220. package/build-module/components/list-view/use-list-view-scroll-into-view.js +42 -0
  221. package/build-module/components/list-view/use-list-view-scroll-into-view.js.map +1 -0
  222. package/build-module/components/off-canvas-editor/appender.js +33 -14
  223. package/build-module/components/off-canvas-editor/appender.js.map +1 -1
  224. package/build-module/components/off-canvas-editor/branch.js +6 -3
  225. package/build-module/components/off-canvas-editor/branch.js.map +1 -1
  226. package/build-module/components/off-canvas-editor/index.js +8 -2
  227. package/build-module/components/off-canvas-editor/index.js.map +1 -1
  228. package/build-module/components/off-canvas-editor/leaf-more-menu.js +36 -7
  229. package/build-module/components/off-canvas-editor/leaf-more-menu.js.map +1 -1
  230. package/build-module/components/provider/use-block-sync.js +17 -3
  231. package/build-module/components/provider/use-block-sync.js.map +1 -1
  232. package/build-module/components/responsive-block-control/index.js +1 -0
  233. package/build-module/components/responsive-block-control/index.js.map +1 -1
  234. package/build-module/components/rich-text/format-toolbar-container.js +0 -3
  235. package/build-module/components/rich-text/format-toolbar-container.js.map +1 -1
  236. package/build-module/components/rich-text/index.js +9 -43
  237. package/build-module/components/rich-text/index.js.map +1 -1
  238. package/build-module/components/rich-text/use-delete.js +62 -0
  239. package/build-module/components/rich-text/use-delete.js.map +1 -0
  240. package/build-module/components/rich-text/use-input-rules.js +14 -6
  241. package/build-module/components/rich-text/use-input-rules.js.map +1 -1
  242. package/build-module/components/writing-flow/use-selection-observer.js +4 -1
  243. package/build-module/components/writing-flow/use-selection-observer.js.map +1 -1
  244. package/build-module/hooks/align.js +3 -1
  245. package/build-module/hooks/align.js.map +1 -1
  246. package/build-module/hooks/border.js +93 -240
  247. package/build-module/hooks/border.js.map +1 -1
  248. package/build-module/hooks/custom-class-name.js +4 -4
  249. package/build-module/hooks/custom-class-name.js.map +1 -1
  250. package/build-module/hooks/custom-class-name.native.js +3 -4
  251. package/build-module/hooks/custom-class-name.native.js.map +1 -1
  252. package/build-module/hooks/dimensions.js +75 -187
  253. package/build-module/hooks/dimensions.js.map +1 -1
  254. package/build-module/hooks/duotone.js +86 -24
  255. package/build-module/hooks/duotone.js.map +1 -1
  256. package/build-module/hooks/gap.js +0 -183
  257. package/build-module/hooks/gap.js.map +1 -1
  258. package/build-module/hooks/layout.js +33 -27
  259. package/build-module/hooks/layout.js.map +1 -1
  260. package/build-module/hooks/margin.js +4 -143
  261. package/build-module/hooks/margin.js.map +1 -1
  262. package/build-module/hooks/padding.js +4 -143
  263. package/build-module/hooks/padding.js.map +1 -1
  264. package/build-module/hooks/supports.js +7 -1
  265. package/build-module/hooks/supports.js.map +1 -1
  266. package/build-module/hooks/typography.js +54 -66
  267. package/build-module/hooks/typography.js.map +1 -1
  268. package/build-module/hooks/utils.js +96 -0
  269. package/build-module/hooks/utils.js.map +1 -1
  270. package/build-module/layouts/constrained.js +6 -2
  271. package/build-module/layouts/constrained.js.map +1 -1
  272. package/build-module/layouts/flex.js +1 -0
  273. package/build-module/layouts/flex.js.map +1 -1
  274. package/build-module/private-apis.js +3 -1
  275. package/build-module/private-apis.js.map +1 -1
  276. package/build-module/store/actions.js +28 -14
  277. package/build-module/store/actions.js.map +1 -1
  278. package/build-module/store/defaults.js +28 -1
  279. package/build-module/store/defaults.js.map +1 -1
  280. package/build-module/store/reducer.js +53 -45
  281. package/build-module/store/reducer.js.map +1 -1
  282. package/build-module/store/selectors.js +22 -4
  283. package/build-module/store/selectors.js.map +1 -1
  284. package/build-module/utils/parse-css-unit-to-px.js +49 -10
  285. package/build-module/utils/parse-css-unit-to-px.js.map +1 -1
  286. package/build-style/style-rtl.css +39 -27
  287. package/build-style/style.css +39 -27
  288. package/package.json +31 -31
  289. package/src/components/block-draggable/test/__snapshots__/index.native.js.snap +24 -24
  290. package/src/components/block-inspector/index.js +11 -14
  291. package/src/components/block-inspector/style.scss +3 -0
  292. package/src/components/block-inspector/useBlockInspectorAnimationSettings.js +53 -0
  293. package/src/components/block-list/block-invalid-warning.js +72 -64
  294. package/src/components/block-lock/modal.js +1 -0
  295. package/src/components/block-lock/style.scss +0 -9
  296. package/src/components/block-mobile-toolbar/test/__snapshots__/block-actions-menu.native.js.snap +20 -20
  297. package/src/components/block-mover/test/__snapshots__/index.native.js.snap +35 -17
  298. package/src/components/block-preview/test/index.js +0 -2
  299. package/src/components/block-settings-menu/block-settings-dropdown.js +4 -1
  300. package/src/components/block-settings-menu-controls/index.js +2 -1
  301. package/src/components/block-styles/index.js +5 -1
  302. package/src/components/block-styles/style.scss +2 -2
  303. package/src/components/block-switcher/block-transformations-menu.native.js +1 -0
  304. package/src/components/child-layout-control/index.js +106 -0
  305. package/src/components/color-palette/test/__snapshots__/control.js.snap +17 -15
  306. package/src/components/convert-to-group-buttons/use-convert-to-group-button-props.js +48 -38
  307. package/src/components/date-format-picker/index.js +6 -8
  308. package/src/components/date-format-picker/style.scss +0 -5
  309. package/src/components/global-styles/border-panel.js +285 -0
  310. package/src/components/global-styles/dimensions-panel.js +627 -0
  311. package/src/components/global-styles/hooks.js +160 -44
  312. package/src/components/global-styles/index.js +7 -1
  313. package/src/components/global-styles/test/use-global-styles-output.js +1 -1
  314. package/src/components/global-styles/typography-panel.js +81 -9
  315. package/src/components/global-styles/use-global-styles-output.js +17 -16
  316. package/src/components/global-styles/utils.js +2 -0
  317. package/src/components/index.native.js +5 -0
  318. package/src/components/inner-blocks/test/__snapshots__/index.js.snap +1 -1
  319. package/src/components/inserter/index.js +30 -11
  320. package/src/components/inserter/media-tab/hooks.js +9 -8
  321. package/src/components/inserter/media-tab/media-list.js +3 -122
  322. package/src/components/inserter/media-tab/media-preview.js +268 -0
  323. package/src/components/inserter/menu.js +0 -1
  324. package/src/components/inserter/quick-inserter.js +2 -0
  325. package/src/components/inserter/search-results.js +7 -1
  326. package/src/components/inserter/style.scss +25 -0
  327. package/src/components/inserter/tabs.js +1 -9
  328. package/src/components/inserter/test/__snapshots__/index.native.js.snap +15 -15
  329. package/src/components/inspector-controls/block-support-tools-panel.js +0 -1
  330. package/src/components/inspector-controls/fill.js +32 -8
  331. package/src/components/link-control/index.js +1 -1
  332. package/src/components/link-control/search-item.js +3 -1
  333. package/src/components/link-control/settings-drawer.js +2 -1
  334. package/src/components/link-control/settings.js +1 -0
  335. package/src/components/link-control/style.scss +18 -12
  336. package/src/components/link-control/test/index.js +3 -5
  337. package/src/components/list-view/block.js +19 -1
  338. package/src/components/list-view/branch.js +1 -2
  339. package/src/components/list-view/expander.js +1 -0
  340. package/src/components/list-view/leaf.js +43 -29
  341. package/src/components/list-view/use-block-selection.js +0 -2
  342. package/src/components/list-view/use-list-view-scroll-into-view.js +48 -0
  343. package/src/components/media-replace-flow/style.scss +7 -9
  344. package/src/components/off-canvas-editor/appender.js +44 -21
  345. package/src/components/off-canvas-editor/branch.js +4 -1
  346. package/src/components/off-canvas-editor/index.js +7 -1
  347. package/src/components/off-canvas-editor/leaf-more-menu.js +57 -15
  348. package/src/components/provider/use-block-sync.js +21 -4
  349. package/src/components/responsive-block-control/index.js +1 -0
  350. package/src/components/rich-text/format-toolbar-container.js +1 -7
  351. package/src/components/rich-text/index.js +8 -44
  352. package/src/components/rich-text/use-delete.js +59 -0
  353. package/src/components/rich-text/use-input-rules.js +13 -5
  354. package/src/components/spacing-sizes-control/style.scss +1 -1
  355. package/src/components/url-popover/stories/index.js +1 -0
  356. package/src/components/url-popover/test/index.js +0 -2
  357. package/src/components/writing-flow/use-selection-observer.js +5 -1
  358. package/src/hooks/align.js +1 -1
  359. package/src/hooks/border.js +94 -225
  360. package/src/hooks/custom-class-name.js +4 -4
  361. package/src/hooks/custom-class-name.native.js +3 -4
  362. package/src/hooks/dimensions.js +85 -269
  363. package/src/hooks/duotone.js +100 -30
  364. package/src/hooks/gap.js +0 -208
  365. package/src/hooks/layout.js +38 -22
  366. package/src/hooks/margin.js +1 -164
  367. package/src/hooks/padding.js +1 -163
  368. package/src/hooks/supports.js +6 -0
  369. package/src/hooks/test/__snapshots__/align.native.js.snap +24 -24
  370. package/src/hooks/test/duotone.js +102 -0
  371. package/src/hooks/test/style.js +2 -1
  372. package/src/hooks/test/use-typography-props.js +2 -0
  373. package/src/hooks/typography.js +68 -88
  374. package/src/hooks/utils.js +126 -0
  375. package/src/layouts/constrained.js +23 -17
  376. package/src/layouts/flex.js +1 -0
  377. package/src/private-apis.js +2 -0
  378. package/src/store/actions.js +16 -6
  379. package/src/store/defaults.js +14 -1
  380. package/src/store/reducer.js +68 -43
  381. package/src/store/selectors.js +28 -4
  382. package/src/store/test/actions.js +4 -2
  383. package/src/utils/parse-css-unit-to-px.js +48 -13
  384. package/src/utils/test/parse-css-unit-to-px.js +13 -2
  385. package/tsconfig.tsbuildinfo +1 -1
  386. package/build/hooks/border-radius.js +0 -100
  387. package/build/hooks/border-radius.js.map +0 -1
  388. package/build/hooks/child-layout.js +0 -213
  389. package/build/hooks/child-layout.js.map +0 -1
  390. package/build/hooks/min-height.js +0 -139
  391. package/build/hooks/min-height.js.map +0 -1
  392. package/build-module/hooks/border-radius.js +0 -84
  393. package/build-module/hooks/border-radius.js.map +0 -1
  394. package/build-module/hooks/child-layout.js +0 -193
  395. package/build-module/hooks/child-layout.js.map +0 -1
  396. package/build-module/hooks/min-height.js +0 -116
  397. package/build-module/hooks/min-height.js.map +0 -1
  398. package/src/hooks/border-radius.js +0 -70
  399. package/src/hooks/child-layout.js +0 -195
  400. package/src/hooks/min-height.js +0 -104
@@ -27,20 +27,16 @@ var _compose = require("@wordpress/compose");
27
27
 
28
28
  var _hooks = require("@wordpress/hooks");
29
29
 
30
- var _i18n = require("@wordpress/i18n");
31
-
32
- var _borderRadius = require("./border-radius");
33
-
34
30
  var _colors = require("../components/colors");
35
31
 
36
32
  var _inspectorControls = _interopRequireDefault(require("../components/inspector-controls"));
37
33
 
38
34
  var _useMultipleOriginColorsAndGradients = _interopRequireDefault(require("../components/colors-gradients/use-multiple-origin-colors-and-gradients"));
39
35
 
40
- var _useSetting = _interopRequireDefault(require("../components/use-setting"));
41
-
42
36
  var _utils = require("./utils");
43
37
 
38
+ var _globalStyles = require("../components/global-styles");
39
+
44
40
  /**
45
41
  * External dependencies
46
42
  */
@@ -54,50 +50,6 @@ var _utils = require("./utils");
54
50
  */
55
51
  const BORDER_SUPPORT_KEY = '__experimentalBorder';
56
52
  exports.BORDER_SUPPORT_KEY = BORDER_SUPPORT_KEY;
57
- const borderSides = ['top', 'right', 'bottom', 'left'];
58
-
59
- const hasBorderValue = props => {
60
- const {
61
- borderColor,
62
- style
63
- } = props.attributes;
64
- return (0, _components.__experimentalIsDefinedBorder)(style === null || style === void 0 ? void 0 : style.border) || !!borderColor;
65
- }; // The border color, style, and width are omitted so they get undefined. The
66
- // border radius is separate and must retain its selection.
67
-
68
-
69
- const resetBorder = _ref => {
70
- var _style$border;
71
-
72
- let {
73
- attributes = {},
74
- setAttributes
75
- } = _ref;
76
- const {
77
- style
78
- } = attributes;
79
- setAttributes({
80
- borderColor: undefined,
81
- style: { ...style,
82
- border: (0, _utils.cleanEmptyObject)({
83
- radius: style === null || style === void 0 ? void 0 : (_style$border = style.border) === null || _style$border === void 0 ? void 0 : _style$border.radius
84
- })
85
- }
86
- });
87
- };
88
-
89
- const resetBorderFilter = newAttributes => {
90
- var _newAttributes$style, _newAttributes$style$;
91
-
92
- return { ...newAttributes,
93
- borderColor: undefined,
94
- style: { ...newAttributes.style,
95
- border: {
96
- radius: (_newAttributes$style = newAttributes.style) === null || _newAttributes$style === void 0 ? void 0 : (_newAttributes$style$ = _newAttributes$style.border) === null || _newAttributes$style$ === void 0 ? void 0 : _newAttributes$style$.radius
97
- }
98
- }
99
- };
100
- };
101
53
 
102
54
  const getColorByProperty = (colors, property, value) => {
103
55
  let matchedColor;
@@ -112,12 +64,12 @@ const getColorByProperty = (colors, property, value) => {
112
64
  return matchedColor;
113
65
  };
114
66
 
115
- const getMultiOriginColor = _ref2 => {
67
+ const getMultiOriginColor = _ref => {
116
68
  let {
117
69
  colors,
118
70
  namedColor,
119
71
  customColor
120
- } = _ref2;
72
+ } = _ref;
121
73
 
122
74
  // Search each origin (default, theme, or user) for matching color by name.
123
75
  if (namedColor) {
@@ -144,60 +96,6 @@ const getMultiOriginColor = _ref2 => {
144
96
 
145
97
  exports.getMultiOriginColor = getMultiOriginColor;
146
98
 
147
- const getBorderObject = (attributes, colors) => {
148
- const {
149
- borderColor,
150
- style
151
- } = attributes;
152
- const {
153
- border: borderStyles
154
- } = style || {}; // If we have a named color for a flat border. Fetch that color object and
155
- // apply that color's value to the color property within the style object.
156
-
157
- if (borderColor) {
158
- const {
159
- color
160
- } = getMultiOriginColor({
161
- colors,
162
- namedColor: borderColor
163
- });
164
- return color ? { ...borderStyles,
165
- color
166
- } : borderStyles;
167
- } // Individual side border color slugs are stored within the border style
168
- // object. If we don't have a border styles object we have nothing further
169
- // to hydrate.
170
-
171
-
172
- if (!borderStyles) {
173
- return borderStyles;
174
- } // If we have named colors for the individual side borders, retrieve their
175
- // related color objects and apply the real color values to the split
176
- // border objects.
177
-
178
-
179
- const hydratedBorderStyles = { ...borderStyles
180
- };
181
- borderSides.forEach(side => {
182
- var _hydratedBorderStyles;
183
-
184
- const colorSlug = getColorSlugFromVariable((_hydratedBorderStyles = hydratedBorderStyles[side]) === null || _hydratedBorderStyles === void 0 ? void 0 : _hydratedBorderStyles.color);
185
-
186
- if (colorSlug) {
187
- const {
188
- color
189
- } = getMultiOriginColor({
190
- colors,
191
- namedColor: colorSlug
192
- });
193
- hydratedBorderStyles[side] = { ...hydratedBorderStyles[side],
194
- color
195
- };
196
- }
197
- });
198
- return hydratedBorderStyles;
199
- };
200
-
201
99
  function getColorSlugFromVariable(value) {
202
100
  const namedColor = /var:preset\|color\|(.+)/.exec(value);
203
101
 
@@ -208,142 +106,95 @@ function getColorSlugFromVariable(value) {
208
106
  return null;
209
107
  }
210
108
 
211
- function BorderPanel(props) {
212
- const {
213
- attributes,
214
- clientId,
215
- setAttributes
216
- } = props;
217
- const {
218
- style
219
- } = attributes;
220
- const {
221
- colors
222
- } = (0, _useMultipleOriginColorsAndGradients.default)();
223
- const isSupported = hasBorderSupport(props.name);
224
- const isColorSupported = (0, _useSetting.default)('border.color') && hasBorderSupport(props.name, 'color');
225
- const isRadiusSupported = (0, _useSetting.default)('border.radius') && hasBorderSupport(props.name, 'radius');
226
- const isStyleSupported = (0, _useSetting.default)('border.style') && hasBorderSupport(props.name, 'style');
227
- const isWidthSupported = (0, _useSetting.default)('border.width') && hasBorderSupport(props.name, 'width');
228
- const isDisabled = [!isColorSupported, !isRadiusSupported, !isStyleSupported, !isWidthSupported].every(Boolean);
229
-
230
- if (isDisabled || !isSupported) {
231
- return null;
109
+ function styleToAttributes(style) {
110
+ var _style$border;
111
+
112
+ if ((0, _components.__experimentalHasSplitBorders)(style === null || style === void 0 ? void 0 : style.border)) {
113
+ return {
114
+ style,
115
+ borderColor: undefined
116
+ };
232
117
  }
233
118
 
234
- const defaultBorderControls = (0, _blocks.getBlockSupport)(props.name, [BORDER_SUPPORT_KEY, '__experimentalDefaultControls']);
235
- const showBorderByDefault = (defaultBorderControls === null || defaultBorderControls === void 0 ? void 0 : defaultBorderControls.color) || (defaultBorderControls === null || defaultBorderControls === void 0 ? void 0 : defaultBorderControls.width);
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;
121
+ const updatedStyle = { ...style
122
+ };
123
+ updatedStyle.border = { ...updatedStyle.border,
124
+ color: borderColorSlug ? undefined : borderColorValue
125
+ };
126
+ return {
127
+ style: (0, _utils.cleanEmptyObject)(updatedStyle),
128
+ borderColor: borderColorSlug
129
+ };
130
+ }
236
131
 
237
- const onBorderChange = newBorder => {
238
- var _style$border2;
132
+ function attributesToStyle(attributes) {
133
+ var _attributes$style, _attributes$style2, _attributes$style3, _attributes$style3$bo;
239
134
 
240
- // Filter out named colors and apply them to appropriate block
241
- // attributes so that CSS classes can be used to apply those colors.
242
- // e.g. has-primary-border-top-color.
243
- let newBorderStyles = { ...newBorder
244
- };
245
- let newBorderColor;
246
-
247
- if ((0, _components.__experimentalHasSplitBorders)(newBorder)) {
248
- // For each side check if the side has a color value set
249
- // If so, determine if it belongs to a named color, in which case
250
- // we update the color property.
251
- //
252
- // This deliberately overwrites `newBorderStyles` to avoid mutating
253
- // the passed object which causes problems otherwise.
254
- newBorderStyles = {
255
- top: { ...newBorder.top
256
- },
257
- right: { ...newBorder.right
258
- },
259
- bottom: { ...newBorder.bottom
260
- },
261
- left: { ...newBorder.left
262
- }
263
- };
264
- borderSides.forEach(side => {
265
- var _newBorder$side;
266
-
267
- if ((_newBorder$side = newBorder[side]) !== null && _newBorder$side !== void 0 && _newBorder$side.color) {
268
- var _newBorder$side2;
269
-
270
- const colorObject = getMultiOriginColor({
271
- colors,
272
- customColor: (_newBorder$side2 = newBorder[side]) === null || _newBorder$side2 === void 0 ? void 0 : _newBorder$side2.color
273
- });
274
-
275
- if (colorObject.slug) {
276
- newBorderStyles[side].color = `var:preset|color|${colorObject.slug}`;
277
- }
278
- }
279
- });
280
- } else if (newBorder !== null && newBorder !== void 0 && newBorder.color) {
281
- // We have a flat border configuration. Apply named color slug to
282
- // `borderColor` attribute and clear color style property if found.
283
- const customColor = newBorder === null || newBorder === void 0 ? void 0 : newBorder.color;
284
- const colorObject = getMultiOriginColor({
285
- colors,
286
- customColor
287
- });
288
-
289
- if (colorObject.slug) {
290
- newBorderColor = colorObject.slug;
291
- newBorderStyles.color = undefined;
292
- }
293
- } // Ensure previous border radius styles are maintained and clean
294
- // overall result for empty objects or properties.
135
+ if ((0, _components.__experimentalHasSplitBorders)((_attributes$style = attributes.style) === null || _attributes$style === void 0 ? void 0 : _attributes$style.border)) {
136
+ return attributes.style;
137
+ }
138
+
139
+ return { ...attributes.style,
140
+ border: { ...((_attributes$style2 = attributes.style) === null || _attributes$style2 === void 0 ? void 0 : _attributes$style2.border),
141
+ color: attributes.borderColor ? 'var:preset|color|' + attributes.borderColor : (_attributes$style3 = attributes.style) === null || _attributes$style3 === void 0 ? void 0 : (_attributes$style3$bo = _attributes$style3.border) === null || _attributes$style3$bo === void 0 ? void 0 : _attributes$style3$bo.color
142
+ }
143
+ };
144
+ }
295
145
 
146
+ function BordersInspectorControl(_ref2) {
147
+ let {
148
+ children,
149
+ resetAllFilter
150
+ } = _ref2;
151
+ const attributesResetAllFilter = (0, _element.useCallback)(attributes => {
152
+ const existingStyle = attributesToStyle(attributes);
153
+ const updatedStyle = resetAllFilter(existingStyle);
154
+ return { ...attributes,
155
+ ...styleToAttributes(updatedStyle)
156
+ };
157
+ }, [resetAllFilter]);
158
+ return (0, _element.createElement)(_inspectorControls.default, {
159
+ group: "border",
160
+ resetAllFilter: attributesResetAllFilter
161
+ }, children);
162
+ }
296
163
 
297
- const newStyle = (0, _utils.cleanEmptyObject)({ ...style,
298
- border: {
299
- radius: style === null || style === void 0 ? void 0 : (_style$border2 = style.border) === null || _style$border2 === void 0 ? void 0 : _style$border2.radius,
300
- ...newBorderStyles
301
- }
302
- });
303
- setAttributes({
304
- style: newStyle,
305
- borderColor: newBorderColor
164
+ function BorderPanel(props) {
165
+ const {
166
+ clientId,
167
+ name,
168
+ attributes,
169
+ setAttributes
170
+ } = props;
171
+ const settings = (0, _utils.useBlockSettings)(name);
172
+ const isEnabled = (0, _globalStyles.useHasBorderPanel)(settings);
173
+ const value = (0, _element.useMemo)(() => {
174
+ return attributesToStyle({
175
+ style: attributes.style,
176
+ borderColor: attributes.borderColor
306
177
  });
178
+ }, [attributes.style, attributes.borderColor]);
179
+
180
+ const onChange = newStyle => {
181
+ setAttributes(styleToAttributes(newStyle));
307
182
  };
308
183
 
309
- const hydratedBorder = getBorderObject(attributes, colors);
310
- return (0, _element.createElement)(_inspectorControls.default, {
311
- group: "border"
312
- }, (isWidthSupported || isColorSupported) && (0, _element.createElement)(_components.__experimentalToolsPanelItem, {
313
- hasValue: () => hasBorderValue(props),
314
- label: (0, _i18n.__)('Border'),
315
- onDeselect: () => resetBorder(props),
316
- isShownByDefault: showBorderByDefault,
317
- resetAllFilter: resetBorderFilter,
318
- panelId: clientId
319
- }, (0, _element.createElement)(_components.__experimentalBorderBoxControl, {
320
- colors: colors,
321
- enableAlpha: true,
322
- enableStyle: isStyleSupported,
323
- onChange: onBorderChange,
324
- popoverOffset: 40,
325
- popoverPlacement: "left-start",
326
- size: "__unstable-large",
327
- value: hydratedBorder,
328
- __experimentalIsRenderedInSidebar: true
329
- })), isRadiusSupported && (0, _element.createElement)(_components.__experimentalToolsPanelItem, {
330
- hasValue: () => (0, _borderRadius.hasBorderRadiusValue)(props),
331
- label: (0, _i18n.__)('Radius'),
332
- onDeselect: () => (0, _borderRadius.resetBorderRadius)(props),
333
- isShownByDefault: defaultBorderControls === null || defaultBorderControls === void 0 ? void 0 : defaultBorderControls.radius,
334
- resetAllFilter: newAttributes => {
335
- var _newAttributes$style2;
336
-
337
- return { ...newAttributes,
338
- style: { ...newAttributes.style,
339
- border: { ...((_newAttributes$style2 = newAttributes.style) === null || _newAttributes$style2 === void 0 ? void 0 : _newAttributes$style2.border),
340
- radius: undefined
341
- }
342
- }
343
- };
344
- },
345
- panelId: clientId
346
- }, (0, _element.createElement)(_borderRadius.BorderRadiusEdit, props)));
184
+ if (!isEnabled) {
185
+ return null;
186
+ }
187
+
188
+ const defaultControls = (0, _blocks.getBlockSupport)(props.name, [BORDER_SUPPORT_KEY, '__experimentalDefaultControls']);
189
+ return (0, _element.createElement)(_globalStyles.BorderPanel, {
190
+ as: BordersInspectorControl,
191
+ panelId: clientId,
192
+ name: name,
193
+ settings: settings,
194
+ value: value,
195
+ onChange: onChange,
196
+ defaultControls: defaultControls
197
+ });
347
198
  }
348
199
  /**
349
200
  * Determine whether there is block support for border properties.
@@ -455,7 +306,7 @@ function addSaveProps(props, blockType, attributes) {
455
306
 
456
307
 
457
308
  function getBorderClasses(attributes) {
458
- var _style$border3;
309
+ var _style$border2;
459
310
 
460
311
  const {
461
312
  borderColor,
@@ -463,7 +314,7 @@ function getBorderClasses(attributes) {
463
314
  } = attributes;
464
315
  const borderColorClass = (0, _colors.getColorClassName)('border-color', borderColor);
465
316
  return (0, _classnames.default)({
466
- 'has-border-color': borderColor || (style === null || style === void 0 ? void 0 : (_style$border3 = style.border) === null || _style$border3 === void 0 ? void 0 : _style$border3.color),
317
+ 'has-border-color': borderColor || (style === null || style === void 0 ? void 0 : (_style$border2 = style.border) === null || _style$border2 === void 0 ? void 0 : _style$border2.color),
467
318
  [borderColorClass]: !!borderColorClass
468
319
  });
469
320
  }
@@ -507,7 +358,7 @@ function addEditProps(settings) {
507
358
 
508
359
 
509
360
  const withBorderColorPaletteStyles = (0, _compose.createHigherOrderComponent)(BlockListBlock => props => {
510
- var _style$border4, _style$border4$top, _style$border5, _style$border5$right, _style$border6, _style$border6$bottom, _style$border7, _style$border7$left, _props$wrapperProps;
361
+ var _style$border3, _style$border3$top, _style$border4, _style$border4$right, _style$border5, _style$border5$bottom, _style$border6, _style$border6$left, _props$wrapperProps;
511
362
 
512
363
  const {
513
364
  name,
@@ -535,25 +386,25 @@ const withBorderColorPaletteStyles = (0, _compose.createHigherOrderComponent)(Bl
535
386
  color: borderTopColor
536
387
  } = getMultiOriginColor({
537
388
  colors,
538
- namedColor: getColorSlugFromVariable(style === null || style === void 0 ? void 0 : (_style$border4 = style.border) === null || _style$border4 === void 0 ? void 0 : (_style$border4$top = _style$border4.top) === null || _style$border4$top === void 0 ? void 0 : _style$border4$top.color)
389
+ namedColor: getColorSlugFromVariable(style === null || style === void 0 ? void 0 : (_style$border3 = style.border) === null || _style$border3 === void 0 ? void 0 : (_style$border3$top = _style$border3.top) === null || _style$border3$top === void 0 ? void 0 : _style$border3$top.color)
539
390
  });
540
391
  const {
541
392
  color: borderRightColor
542
393
  } = getMultiOriginColor({
543
394
  colors,
544
- namedColor: getColorSlugFromVariable(style === null || style === void 0 ? void 0 : (_style$border5 = style.border) === null || _style$border5 === void 0 ? void 0 : (_style$border5$right = _style$border5.right) === null || _style$border5$right === void 0 ? void 0 : _style$border5$right.color)
395
+ namedColor: getColorSlugFromVariable(style === null || style === void 0 ? void 0 : (_style$border4 = style.border) === null || _style$border4 === void 0 ? void 0 : (_style$border4$right = _style$border4.right) === null || _style$border4$right === void 0 ? void 0 : _style$border4$right.color)
545
396
  });
546
397
  const {
547
398
  color: borderBottomColor
548
399
  } = getMultiOriginColor({
549
400
  colors,
550
- namedColor: getColorSlugFromVariable(style === null || style === void 0 ? void 0 : (_style$border6 = style.border) === null || _style$border6 === void 0 ? void 0 : (_style$border6$bottom = _style$border6.bottom) === null || _style$border6$bottom === void 0 ? void 0 : _style$border6$bottom.color)
401
+ namedColor: getColorSlugFromVariable(style === null || style === void 0 ? void 0 : (_style$border5 = style.border) === null || _style$border5 === void 0 ? void 0 : (_style$border5$bottom = _style$border5.bottom) === null || _style$border5$bottom === void 0 ? void 0 : _style$border5$bottom.color)
551
402
  });
552
403
  const {
553
404
  color: borderLeftColor
554
405
  } = getMultiOriginColor({
555
406
  colors,
556
- namedColor: getColorSlugFromVariable(style === null || style === void 0 ? void 0 : (_style$border7 = style.border) === null || _style$border7 === void 0 ? void 0 : (_style$border7$left = _style$border7.left) === null || _style$border7$left === void 0 ? void 0 : _style$border7$left.color)
407
+ namedColor: getColorSlugFromVariable(style === null || style === void 0 ? void 0 : (_style$border6 = style.border) === null || _style$border6 === void 0 ? void 0 : (_style$border6$left = _style$border6.left) === null || _style$border6$left === void 0 ? void 0 : _style$border6$left.color)
557
408
  });
558
409
  const extraStyles = {
559
410
  borderTopColor: borderTopColor || borderColorValue,
@@ -1 +1 @@
1
- {"version":3,"sources":["@wordpress/block-editor/src/hooks/border.js"],"names":["BORDER_SUPPORT_KEY","borderSides","hasBorderValue","props","borderColor","style","attributes","border","resetBorder","setAttributes","undefined","radius","resetBorderFilter","newAttributes","getColorByProperty","colors","property","value","matchedColor","some","origin","color","getMultiOriginColor","namedColor","customColor","colorObject","getBorderObject","borderStyles","hydratedBorderStyles","forEach","side","colorSlug","getColorSlugFromVariable","exec","BorderPanel","clientId","isSupported","hasBorderSupport","name","isColorSupported","isRadiusSupported","isStyleSupported","isWidthSupported","isDisabled","every","Boolean","defaultBorderControls","showBorderByDefault","width","onBorderChange","newBorder","newBorderStyles","newBorderColor","top","right","bottom","left","slug","newStyle","hydratedBorder","blockName","feature","Platform","OS","support","removeBorderAttribute","attribute","addAttributes","settings","type","addSaveProps","blockType","borderClasses","getBorderClasses","newClassName","className","borderColorClass","addEditProps","existingGetEditWrapperProps","getEditWrapperProps","withBorderColorPaletteStyles","BlockListBlock","borderColorValue","borderTopColor","borderRightColor","borderBottomColor","borderLeftColor","extraStyles","wrapperProps"],"mappings":";;;;;;;;;;;;;;;AAgBA;;;;AAbA;;AAKA;;AACA;;AAMA;;AAEA;;AACA;;AAKA;;AAKA;;AACA;;AACA;;AACA;;AACA;;AAhCA;AACA;AACA;;AAGA;AACA;AACA;;AAaA;AACA;AACA;AAYO,MAAMA,kBAAkB,GAAG,sBAA3B;;AAEP,MAAMC,WAAW,GAAG,CAAE,KAAF,EAAS,OAAT,EAAkB,QAAlB,EAA4B,MAA5B,CAApB;;AAEA,MAAMC,cAAc,GAAKC,KAAF,IAAa;AACnC,QAAM;AAAEC,IAAAA,WAAF;AAAeC,IAAAA;AAAf,MAAyBF,KAAK,CAACG,UAArC;AACA,SAAO,+CAAiBD,KAAjB,aAAiBA,KAAjB,uBAAiBA,KAAK,CAAEE,MAAxB,KAAoC,CAAC,CAAEH,WAA9C;AACA,CAHD,C,CAKA;AACA;;;AACA,MAAMI,WAAW,GAAG,QAA0C;AAAA;;AAAA,MAAxC;AAAEF,IAAAA,UAAU,GAAG,EAAf;AAAmBG,IAAAA;AAAnB,GAAwC;AAC7D,QAAM;AAAEJ,IAAAA;AAAF,MAAYC,UAAlB;AACAG,EAAAA,aAAa,CAAE;AACdL,IAAAA,WAAW,EAAEM,SADC;AAEdL,IAAAA,KAAK,EAAE,EACN,GAAGA,KADG;AAENE,MAAAA,MAAM,EAAE,6BAAkB;AACzBI,QAAAA,MAAM,EAAE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yDP,sBACC,0BADD,EAEC,2BAFD,EAGCrB,aAHD;AAMA,sBACC,kCADD,EAEC,0BAFD,EAGCG,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 {\n\t__experimentalBorderBoxControl as BorderBoxControl,\n\t__experimentalHasSplitBorders as hasSplitBorders,\n\t__experimentalIsDefinedBorder as isDefinedBorder,\n\t__experimentalToolsPanelItem as ToolsPanelItem,\n} from '@wordpress/components';\nimport { createHigherOrderComponent } from '@wordpress/compose';\nimport { Platform } from '@wordpress/element';\nimport { addFilter } from '@wordpress/hooks';\nimport { __ } from '@wordpress/i18n';\n\n/**\n * Internal dependencies\n */\nimport {\n\tBorderRadiusEdit,\n\thasBorderRadiusValue,\n\tresetBorderRadius,\n} from './border-radius';\nimport { getColorClassName } from '../components/colors';\nimport InspectorControls from '../components/inspector-controls';\nimport useMultipleOriginColorsAndGradients from '../components/colors-gradients/use-multiple-origin-colors-and-gradients';\nimport useSetting from '../components/use-setting';\nimport { cleanEmptyObject, shouldSkipSerialization } from './utils';\n\nexport const BORDER_SUPPORT_KEY = '__experimentalBorder';\n\nconst borderSides = [ 'top', 'right', 'bottom', 'left' ];\n\nconst hasBorderValue = ( props ) => {\n\tconst { borderColor, style } = props.attributes;\n\treturn isDefinedBorder( style?.border ) || !! borderColor;\n};\n\n// The border color, style, and width are omitted so they get undefined. The\n// border radius is separate and must retain its selection.\nconst resetBorder = ( { attributes = {}, setAttributes } ) => {\n\tconst { style } = attributes;\n\tsetAttributes( {\n\t\tborderColor: undefined,\n\t\tstyle: {\n\t\t\t...style,\n\t\t\tborder: cleanEmptyObject( {\n\t\t\t\tradius: style?.border?.radius,\n\t\t\t} ),\n\t\t},\n\t} );\n};\n\nconst resetBorderFilter = ( newAttributes ) => ( {\n\t...newAttributes,\n\tborderColor: undefined,\n\tstyle: {\n\t\t...newAttributes.style,\n\t\tborder: {\n\t\t\tradius: newAttributes.style?.border?.radius,\n\t\t},\n\t},\n} );\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\nconst getBorderObject = ( attributes, colors ) => {\n\tconst { borderColor, style } = attributes;\n\tconst { border: borderStyles } = style || {};\n\n\t// If we have a named color for a flat border. Fetch that color object and\n\t// apply that color's value to the color property within the style object.\n\tif ( borderColor ) {\n\t\tconst { color } = getMultiOriginColor( {\n\t\t\tcolors,\n\t\t\tnamedColor: borderColor,\n\t\t} );\n\n\t\treturn color ? { ...borderStyles, color } : borderStyles;\n\t}\n\n\t// Individual side border color slugs are stored within the border style\n\t// object. If we don't have a border styles object we have nothing further\n\t// to hydrate.\n\tif ( ! borderStyles ) {\n\t\treturn borderStyles;\n\t}\n\n\t// If we have named colors for the individual side borders, retrieve their\n\t// related color objects and apply the real color values to the split\n\t// border objects.\n\tconst hydratedBorderStyles = { ...borderStyles };\n\tborderSides.forEach( ( side ) => {\n\t\tconst colorSlug = getColorSlugFromVariable(\n\t\t\thydratedBorderStyles[ side ]?.color\n\t\t);\n\t\tif ( colorSlug ) {\n\t\t\tconst { color } = getMultiOriginColor( {\n\t\t\t\tcolors,\n\t\t\t\tnamedColor: colorSlug,\n\t\t\t} );\n\t\t\thydratedBorderStyles[ side ] = {\n\t\t\t\t...hydratedBorderStyles[ side ],\n\t\t\t\tcolor,\n\t\t\t};\n\t\t}\n\t} );\n\n\treturn hydratedBorderStyles;\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\nexport function BorderPanel( props ) {\n\tconst { attributes, clientId, setAttributes } = props;\n\tconst { style } = attributes;\n\tconst { colors } = useMultipleOriginColorsAndGradients();\n\n\tconst isSupported = hasBorderSupport( props.name );\n\tconst isColorSupported =\n\t\tuseSetting( 'border.color' ) && hasBorderSupport( props.name, 'color' );\n\tconst isRadiusSupported =\n\t\tuseSetting( 'border.radius' ) &&\n\t\thasBorderSupport( props.name, 'radius' );\n\tconst isStyleSupported =\n\t\tuseSetting( 'border.style' ) && hasBorderSupport( props.name, 'style' );\n\tconst isWidthSupported =\n\t\tuseSetting( 'border.width' ) && hasBorderSupport( props.name, 'width' );\n\n\tconst isDisabled = [\n\t\t! isColorSupported,\n\t\t! isRadiusSupported,\n\t\t! isStyleSupported,\n\t\t! isWidthSupported,\n\t].every( Boolean );\n\n\tif ( isDisabled || ! isSupported ) {\n\t\treturn null;\n\t}\n\n\tconst defaultBorderControls = getBlockSupport( props.name, [\n\t\tBORDER_SUPPORT_KEY,\n\t\t'__experimentalDefaultControls',\n\t] );\n\n\tconst showBorderByDefault =\n\t\tdefaultBorderControls?.color || defaultBorderControls?.width;\n\n\tconst onBorderChange = ( newBorder ) => {\n\t\t// Filter out named colors and apply them to appropriate block\n\t\t// attributes so that CSS classes can be used to apply those colors.\n\t\t// e.g. has-primary-border-top-color.\n\n\t\tlet newBorderStyles = { ...newBorder };\n\t\tlet newBorderColor;\n\n\t\tif ( hasSplitBorders( newBorder ) ) {\n\t\t\t// For each side check if the side has a color value set\n\t\t\t// If so, determine if it belongs to a named color, in which case\n\t\t\t// we update the color property.\n\t\t\t//\n\t\t\t// This deliberately overwrites `newBorderStyles` to avoid mutating\n\t\t\t// the passed object which causes problems otherwise.\n\t\t\tnewBorderStyles = {\n\t\t\t\ttop: { ...newBorder.top },\n\t\t\t\tright: { ...newBorder.right },\n\t\t\t\tbottom: { ...newBorder.bottom },\n\t\t\t\tleft: { ...newBorder.left },\n\t\t\t};\n\n\t\t\tborderSides.forEach( ( side ) => {\n\t\t\t\tif ( newBorder[ side ]?.color ) {\n\t\t\t\t\tconst colorObject = getMultiOriginColor( {\n\t\t\t\t\t\tcolors,\n\t\t\t\t\t\tcustomColor: newBorder[ side ]?.color,\n\t\t\t\t\t} );\n\n\t\t\t\t\tif ( colorObject.slug ) {\n\t\t\t\t\t\tnewBorderStyles[\n\t\t\t\t\t\t\tside\n\t\t\t\t\t\t].color = `var:preset|color|${ colorObject.slug }`;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t} );\n\t\t} else if ( newBorder?.color ) {\n\t\t\t// We have a flat border configuration. Apply named color slug to\n\t\t\t// `borderColor` attribute and clear color style property if found.\n\t\t\tconst customColor = newBorder?.color;\n\t\t\tconst colorObject = getMultiOriginColor( { colors, customColor } );\n\n\t\t\tif ( colorObject.slug ) {\n\t\t\t\tnewBorderColor = colorObject.slug;\n\t\t\t\tnewBorderStyles.color = undefined;\n\t\t\t}\n\t\t}\n\n\t\t// Ensure previous border radius styles are maintained and clean\n\t\t// overall result for empty objects or properties.\n\t\tconst newStyle = cleanEmptyObject( {\n\t\t\t...style,\n\t\t\tborder: { radius: style?.border?.radius, ...newBorderStyles },\n\t\t} );\n\n\t\tsetAttributes( {\n\t\t\tstyle: newStyle,\n\t\t\tborderColor: newBorderColor,\n\t\t} );\n\t};\n\n\tconst hydratedBorder = getBorderObject( attributes, colors );\n\n\treturn (\n\t\t<InspectorControls group=\"border\">\n\t\t\t{ ( isWidthSupported || isColorSupported ) && (\n\t\t\t\t<ToolsPanelItem\n\t\t\t\t\thasValue={ () => hasBorderValue( props ) }\n\t\t\t\t\tlabel={ __( 'Border' ) }\n\t\t\t\t\tonDeselect={ () => resetBorder( props ) }\n\t\t\t\t\tisShownByDefault={ showBorderByDefault }\n\t\t\t\t\tresetAllFilter={ resetBorderFilter }\n\t\t\t\t\tpanelId={ clientId }\n\t\t\t\t>\n\t\t\t\t\t<BorderBoxControl\n\t\t\t\t\t\tcolors={ colors }\n\t\t\t\t\t\tenableAlpha={ true }\n\t\t\t\t\t\tenableStyle={ isStyleSupported }\n\t\t\t\t\t\tonChange={ onBorderChange }\n\t\t\t\t\t\tpopoverOffset={ 40 }\n\t\t\t\t\t\tpopoverPlacement=\"left-start\"\n\t\t\t\t\t\tsize=\"__unstable-large\"\n\t\t\t\t\t\tvalue={ hydratedBorder }\n\t\t\t\t\t\t__experimentalIsRenderedInSidebar={ true }\n\t\t\t\t\t/>\n\t\t\t\t</ToolsPanelItem>\n\t\t\t) }\n\t\t\t{ isRadiusSupported && (\n\t\t\t\t<ToolsPanelItem\n\t\t\t\t\thasValue={ () => hasBorderRadiusValue( props ) }\n\t\t\t\t\tlabel={ __( 'Radius' ) }\n\t\t\t\t\tonDeselect={ () => resetBorderRadius( props ) }\n\t\t\t\t\tisShownByDefault={ defaultBorderControls?.radius }\n\t\t\t\t\tresetAllFilter={ ( newAttributes ) => ( {\n\t\t\t\t\t\t...newAttributes,\n\t\t\t\t\t\tstyle: {\n\t\t\t\t\t\t\t...newAttributes.style,\n\t\t\t\t\t\t\tborder: {\n\t\t\t\t\t\t\t\t...newAttributes.style?.border,\n\t\t\t\t\t\t\t\tradius: undefined,\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t},\n\t\t\t\t\t} ) }\n\t\t\t\t\tpanelId={ clientId }\n\t\t\t\t>\n\t\t\t\t\t<BorderRadiusEdit { ...props } />\n\t\t\t\t</ToolsPanelItem>\n\t\t\t) }\n\t\t</InspectorControls>\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,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KAAK,CAAC0C,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"]}
@@ -39,8 +39,7 @@ var _components2 = require("../components");
39
39
  */
40
40
 
41
41
  /**
42
- * Filters registered block settings, extending attributes with anchor using ID
43
- * of the first node.
42
+ * Filters registered block settings, extending attributes to include `className`.
44
43
  *
45
44
  * @param {Object} settings Original block settings.
46
45
  *
@@ -61,6 +60,7 @@ function addAttribute(settings) {
61
60
  /**
62
61
  * Override the default edit UI to include a new block inspector control for
63
62
  * assigning the custom class name, if block supports custom class name.
63
+ * The control is displayed within the Advanced panel in the block inspector.
64
64
  *
65
65
  * @param {WPComponent} BlockEdit Original component.
66
66
  *
@@ -93,8 +93,8 @@ const withInspectorControl = (0, _compose.createHigherOrderComponent)(BlockEdit
93
93
  };
94
94
  }, 'withInspectorControl');
95
95
  /**
96
- * Override props assigned to save component to inject anchor ID, if block
97
- * supports anchor. This is only applied if the block's save result is an
96
+ * Override props assigned to save component to inject the className, if block
97
+ * supports customClassName. This is only applied if the block's save result is an
98
98
  * element and not a markup string.
99
99
  *
100
100
  * @param {Object} extraProps Additional props applied to save element.
@@ -1 +1 @@
1
- {"version":3,"sources":["@wordpress/block-editor/src/hooks/custom-class-name.js"],"names":["addAttribute","settings","attributes","className","type","withInspectorControl","BlockEdit","props","hasCustomClassName","name","isSelected","nextValue","setAttributes","undefined","addSaveProps","extraProps","blockType","addTransforms","result","source","index","results","length","innerBlocks","originClassName"],"mappings":";;;;;;;;;;;;;;AAGA;;AAKA;;AACA;;AACA;;AACA;;AACA;;AAKA;;AAjBA;AACA;AACA;;AAGA;AACA;AACA;;AAOA;AACA;AACA;;AAGA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,SAASA,YAAT,CAAuBC,QAAvB,EAAkC;AACxC,MAAK,6BAAiBA,QAAjB,EAA2B,iBAA3B,EAA8C,IAA9C,CAAL,EAA4D;AAC3D;AACAA,IAAAA,QAAQ,CAACC,UAAT,GAAsB,EACrB,GAAGD,QAAQ,CAACC,UADS;AAErBC,MAAAA,SAAS,EAAE;AACVC,QAAAA,IAAI,EAAE;AADI;AAFU,KAAtB;AAMA;;AAED,SAAOH,QAAP;AACA;AAED;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;AACO,MAAMI,oBAAoB,GAAG,yCACjCC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C,EAA+CC,OAA/C,EAAyD;AAC/D,MAAK,CAAE,6BAAiBH,MAAM,CAACT,IAAxB,EAA8B,iBAA9B,EAAiD,IAAjD,CAAP,EAAiE;AAChE,WAAOS,MAAP;AACA,GAH8D,CAK/D;AACA;;;AACA,MAAKG,OAAO,CAACC,MAAR,KAAmB,CAAnB,IAAwBJ,MAAM,CAACK,WAAP,CAAmBD,MAAnB,KAA8BH,MAAM,CAACG,MAAlE,EAA2E;AAC1E,WAAOJ,MAAP;AACA,GAT8D,CAW/D;AACA;;;AACA,MACGG,OAAO,CAACC,MAAR,KAAmB,CAAnB,IAAwBH,MAAM,CAACG,MAAP,GAAgB,CAA1C,IACED,OAAO,CAACC,MAAR,GAAiB,CAAjB,IAAsBH,MAAM,CAACG,MAAP,KAAkB,CAF3C,EAGE;AACD,WAAOJ,MAAP;AACA,GAlB8D,CAoB/D;AACA;AACA;AACA;;;AACA,MAAKC,MAAM,CAAEC,KAAF,CAAX,EAAuB;AAAA;;AACtB,UAAMI,eAAe,oBAAGL,MAAM,CAAEC,KAAF,CAAT,kDAAG,cAAiBlB,UAAjB,CAA4BC,SAApD;;AACA,QAAKqB,eAAL,EAAuB;AACtB,aAAO,EACN,GAAGN,MADG;AAENhB,QAAAA,UAAU,EAAE,EACX,GAAGgB,MAAM,CAAChB,UADC;AAEXC,UAAAA,SAAS,EAAEqB;AAFA;AAFN,OAAP;AAOA;AACD;;AACD,SAAON,MAAP;AACA;;AAED,sBACC,0BADD,EAEC,kCAFD,EAGClB,YAHD;AAKA,sBACC,kBADD,EAEC,sDAFD,EAGCK,oBAHD;AAKA,sBACC,kCADD,EAEC,mCAFD,EAGCS,YAHD;AAMA,sBACC,2CADD,EAEC,0BAFD,EAGCG,aAHD","sourcesContent":["/**\n * External dependencies\n */\nimport classnames from 'classnames';\n\n/**\n * WordPress dependencies\n */\nimport { addFilter } from '@wordpress/hooks';\nimport { TextControl } from '@wordpress/components';\nimport { __ } from '@wordpress/i18n';\nimport { hasBlockSupport } from '@wordpress/blocks';\nimport { createHigherOrderComponent } from '@wordpress/compose';\n\n/**\n * Internal dependencies\n */\nimport { InspectorControls } from '../components';\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\tif ( hasBlockSupport( settings, 'customClassName', true ) ) {\n\t\t// Gracefully handle if settings.attributes is undefined.\n\t\tsettings.attributes = {\n\t\t\t...settings.attributes,\n\t\t\tclassName: {\n\t\t\t\ttype: 'string',\n\t\t\t},\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 custom class name, if block supports custom class name.\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 hasCustomClassName = hasBlockSupport(\n\t\t\t\tprops.name,\n\t\t\t\t'customClassName',\n\t\t\t\ttrue\n\t\t\t);\n\t\t\tif ( hasCustomClassName && props.isSelected ) {\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<InspectorControls group=\"advanced\">\n\t\t\t\t\t\t\t<TextControl\n\t\t\t\t\t\t\t\t__nextHasNoMarginBottom\n\t\t\t\t\t\t\t\tautoComplete=\"off\"\n\t\t\t\t\t\t\t\tlabel={ __( 'Additional CSS class(es)' ) }\n\t\t\t\t\t\t\t\tvalue={ props.attributes.className || '' }\n\t\t\t\t\t\t\t\tonChange={ ( nextValue ) => {\n\t\t\t\t\t\t\t\t\tprops.setAttributes( {\n\t\t\t\t\t\t\t\t\t\tclassName:\n\t\t\t\t\t\t\t\t\t\t\tnextValue !== ''\n\t\t\t\t\t\t\t\t\t\t\t\t? nextValue\n\t\t\t\t\t\t\t\t\t\t\t\t: undefined,\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\thelp={ __(\n\t\t\t\t\t\t\t\t\t'Separate multiple classes with spaces.'\n\t\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t</InspectorControls>\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 (\n\t\thasBlockSupport( blockType, 'customClassName', true ) &&\n\t\tattributes.className\n\t) {\n\t\textraProps.className = classnames(\n\t\t\textraProps.className,\n\t\t\tattributes.className\n\t\t);\n\t}\n\n\treturn extraProps;\n}\n\nexport function addTransforms( result, source, index, results ) {\n\tif ( ! hasBlockSupport( result.name, 'customClassName', true ) ) {\n\t\treturn result;\n\t}\n\n\t// If the condition verifies we are probably in the presence of a wrapping transform\n\t// e.g: nesting paragraphs in a group or columns and in that case the class should not be kept.\n\tif ( results.length === 1 && result.innerBlocks.length === source.length ) {\n\t\treturn result;\n\t}\n\n\t// If we are transforming one block to multiple blocks or multiple blocks to one block,\n\t// we ignore the class during the transform.\n\tif (\n\t\t( results.length === 1 && source.length > 1 ) ||\n\t\t( results.length > 1 && source.length === 1 )\n\t) {\n\t\treturn result;\n\t}\n\n\t// If we are in presence of transform between one or more block in the source\n\t// that have one or more blocks in the result\n\t// we apply the class on source N to the result N,\n\t// if source N does not exists we do nothing.\n\tif ( source[ index ] ) {\n\t\tconst originClassName = source[ index ]?.attributes.className;\n\t\tif ( originClassName ) {\n\t\t\treturn {\n\t\t\t\t...result,\n\t\t\t\tattributes: {\n\t\t\t\t\t...result.attributes,\n\t\t\t\t\tclassName: originClassName,\n\t\t\t\t},\n\t\t\t};\n\t\t}\n\t}\n\treturn result;\n}\n\naddFilter(\n\t'blocks.registerBlockType',\n\t'core/custom-class-name/attribute',\n\taddAttribute\n);\naddFilter(\n\t'editor.BlockEdit',\n\t'core/editor/custom-class-name/with-inspector-control',\n\twithInspectorControl\n);\naddFilter(\n\t'blocks.getSaveContent.extraProps',\n\t'core/custom-class-name/save-props',\n\taddSaveProps\n);\n\naddFilter(\n\t'blocks.switchToBlockType.transformedBlock',\n\t'core/color/addTransforms',\n\taddTransforms\n);\n"]}
1
+ {"version":3,"sources":["@wordpress/block-editor/src/hooks/custom-class-name.js"],"names":["addAttribute","settings","attributes","className","type","withInspectorControl","BlockEdit","props","hasCustomClassName","name","isSelected","nextValue","setAttributes","undefined","addSaveProps","extraProps","blockType","addTransforms","result","source","index","results","length","innerBlocks","originClassName"],"mappings":";;;;;;;;;;;;;;AAGA;;AAKA;;AACA;;AACA;;AACA;;AACA;;AAKA;;AAjBA;AACA;AACA;;AAGA;AACA;AACA;;AAOA;AACA;AACA;;AAGA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,SAASA,YAAT,CAAuBC,QAAvB,EAAkC;AACxC,MAAK,6BAAiBA,QAAjB,EAA2B,iBAA3B,EAA8C,IAA9C,CAAL,EAA4D;AAC3D;AACAA,IAAAA,QAAQ,CAACC,UAAT,GAAsB,EACrB,GAAGD,QAAQ,CAACC,UADS;AAErBC,MAAAA,SAAS,EAAE;AACVC,QAAAA,IAAI,EAAE;AADI;AAFU,KAAtB;AAMA;;AAED,SAAOH,QAAP;AACA;AAED;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;AACO,MAAMI,oBAAoB,GAAG,yCACjCC,SAAF,IAAiB;AAChB,SAASC,KAAF,IAAa;AACnB,UAAMC,kBAAkB,GAAG,6BAC1BD,KAAK,CAACE,IADoB,EAE1B,iBAF0B,EAG1B,IAH0B,CAA3B;;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AP;AACA,GAH8D,CAK/D;AACA;;;AACA,MAAKG,OAAO,CAACC,MAAR,KAAmB,CAAnB,IAAwBJ,MAAM,CAACK,WAAP,CAAmBD,MAAnB,KAA8BH,MAAM,CAACG,MAAlE,EAA2E;AAC1E,WAAOJ,MAAP;AACA,GAT8D,CAW/D;AACA;;;AACA,MACGG,OAAO,CAACC,MAAR,KAAmB,CAAnB,IAAwBH,MAAM,CAACG,MAAP,GAAgB,CAA1C,IACED,OAAO,CAACC,MAAR,GAAiB,CAAjB,IAAsBH,MAAM,CAACG,MAAP,KAAkB,CAF3C,EAGE;AACD,WAAOJ,MAAP;AACA,GAlB8D,CAoB/D;AACA;AACA;AACA;;;AACA,MAAKC,MAAM,CAAEC,KAAF,CAAX,EAAuB;AAAA;;AACtB,UAAMI,eAAe,oBAAGL,MAAM,CAAEC,KAAF,CAAT,kDAAG,cAAiBlB,UAAjB,CAA4BC,SAApD;;AACA,QAAKqB,eAAL,EAAuB;AACtB,aAAO,EACN,GAAGN,MADG;AAENhB,QAAAA,UAAU,EAAE,EACX,GAAGgB,MAAM,CAAChB,UADC;AAEXC,UAAAA,SAAS,EAAEqB;AAFA;AAFN,OAAP;AAOA;AACD;;AACD,SAAON,MAAP;AACA;;AAED,sBACC,0BADD,EAEC,kCAFD,EAGClB,YAHD;AAKA,sBACC,kBADD,EAEC,sDAFD,EAGCK,oBAHD;AAKA,sBACC,kCADD,EAEC,mCAFD,EAGCS,YAHD;AAMA,sBACC,2CADD,EAEC,0BAFD,EAGCG,aAHD","sourcesContent":["/**\n * External dependencies\n */\nimport classnames from 'classnames';\n\n/**\n * WordPress dependencies\n */\nimport { addFilter } from '@wordpress/hooks';\nimport { TextControl } from '@wordpress/components';\nimport { __ } from '@wordpress/i18n';\nimport { hasBlockSupport } from '@wordpress/blocks';\nimport { createHigherOrderComponent } from '@wordpress/compose';\n\n/**\n * Internal dependencies\n */\nimport { InspectorControls } from '../components';\n\n/**\n * Filters registered block settings, extending attributes to include `className`.\n *\n * @param {Object} settings Original block settings.\n *\n * @return {Object} Filtered block settings.\n */\nexport function addAttribute( settings ) {\n\tif ( hasBlockSupport( settings, 'customClassName', true ) ) {\n\t\t// Gracefully handle if settings.attributes is undefined.\n\t\tsettings.attributes = {\n\t\t\t...settings.attributes,\n\t\t\tclassName: {\n\t\t\t\ttype: 'string',\n\t\t\t},\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 custom class name, if block supports custom class name.\n * The control is displayed within the Advanced panel in the block inspector.\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 hasCustomClassName = hasBlockSupport(\n\t\t\t\tprops.name,\n\t\t\t\t'customClassName',\n\t\t\t\ttrue\n\t\t\t);\n\t\t\tif ( hasCustomClassName && props.isSelected ) {\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<InspectorControls group=\"advanced\">\n\t\t\t\t\t\t\t<TextControl\n\t\t\t\t\t\t\t\t__nextHasNoMarginBottom\n\t\t\t\t\t\t\t\tautoComplete=\"off\"\n\t\t\t\t\t\t\t\tlabel={ __( 'Additional CSS class(es)' ) }\n\t\t\t\t\t\t\t\tvalue={ props.attributes.className || '' }\n\t\t\t\t\t\t\t\tonChange={ ( nextValue ) => {\n\t\t\t\t\t\t\t\t\tprops.setAttributes( {\n\t\t\t\t\t\t\t\t\t\tclassName:\n\t\t\t\t\t\t\t\t\t\t\tnextValue !== ''\n\t\t\t\t\t\t\t\t\t\t\t\t? nextValue\n\t\t\t\t\t\t\t\t\t\t\t\t: undefined,\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\thelp={ __(\n\t\t\t\t\t\t\t\t\t'Separate multiple classes with spaces.'\n\t\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t</InspectorControls>\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 the className, if block\n * supports customClassName. 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 (\n\t\thasBlockSupport( blockType, 'customClassName', true ) &&\n\t\tattributes.className\n\t) {\n\t\textraProps.className = classnames(\n\t\t\textraProps.className,\n\t\t\tattributes.className\n\t\t);\n\t}\n\n\treturn extraProps;\n}\n\nexport function addTransforms( result, source, index, results ) {\n\tif ( ! hasBlockSupport( result.name, 'customClassName', true ) ) {\n\t\treturn result;\n\t}\n\n\t// If the condition verifies we are probably in the presence of a wrapping transform\n\t// e.g: nesting paragraphs in a group or columns and in that case the class should not be kept.\n\tif ( results.length === 1 && result.innerBlocks.length === source.length ) {\n\t\treturn result;\n\t}\n\n\t// If we are transforming one block to multiple blocks or multiple blocks to one block,\n\t// we ignore the class during the transform.\n\tif (\n\t\t( results.length === 1 && source.length > 1 ) ||\n\t\t( results.length > 1 && source.length === 1 )\n\t) {\n\t\treturn result;\n\t}\n\n\t// If we are in presence of transform between one or more block in the source\n\t// that have one or more blocks in the result\n\t// we apply the class on source N to the result N,\n\t// if source N does not exists we do nothing.\n\tif ( source[ index ] ) {\n\t\tconst originClassName = source[ index ]?.attributes.className;\n\t\tif ( originClassName ) {\n\t\t\treturn {\n\t\t\t\t...result,\n\t\t\t\tattributes: {\n\t\t\t\t\t...result.attributes,\n\t\t\t\t\tclassName: originClassName,\n\t\t\t\t},\n\t\t\t};\n\t\t}\n\t}\n\treturn result;\n}\n\naddFilter(\n\t'blocks.registerBlockType',\n\t'core/custom-class-name/attribute',\n\taddAttribute\n);\naddFilter(\n\t'editor.BlockEdit',\n\t'core/editor/custom-class-name/with-inspector-control',\n\twithInspectorControl\n);\naddFilter(\n\t'blocks.getSaveContent.extraProps',\n\t'core/custom-class-name/save-props',\n\taddSaveProps\n);\n\naddFilter(\n\t'blocks.switchToBlockType.transformedBlock',\n\t'core/color/addTransforms',\n\taddTransforms\n);\n"]}
@@ -23,8 +23,7 @@ var _blocks = require("@wordpress/blocks");
23
23
  */
24
24
 
25
25
  /**
26
- * Filters registered block settings, extending attributes with anchor using ID
27
- * of the first node.
26
+ * Filters registered block settings, extending attributes to include `className`.
28
27
  *
29
28
  * @param {Object} settings Original block settings.
30
29
  *
@@ -43,8 +42,8 @@ function addAttribute(settings) {
43
42
  return settings;
44
43
  }
45
44
  /**
46
- * Override props assigned to save component to inject anchor ID, if block
47
- * supports anchor. This is only applied if the block's save result is an
45
+ * Override props assigned to save component to inject the className, if block
46
+ * supports customClassName. This is only applied if the block's save result is an
48
47
  * element and not a markup string.
49
48
  *
50
49
  * @param {Object} extraProps Additional props applied to save element.