@wordpress/block-editor 11.7.0 → 12.0.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 (357) hide show
  1. package/CHANGELOG.md +8 -0
  2. package/README.md +56 -57
  3. package/build/components/block-info-slot-fill/index.js +47 -0
  4. package/build/components/block-info-slot-fill/index.js.map +1 -0
  5. package/build/components/block-inspector/index.js +4 -2
  6. package/build/components/block-inspector/index.js.map +1 -1
  7. package/build/components/block-list/index.native.js +11 -21
  8. package/build/components/block-list/index.native.js.map +1 -1
  9. package/build/components/block-list/use-in-between-inserter.js +3 -1
  10. package/build/components/block-list/use-in-between-inserter.js.map +1 -1
  11. package/build/components/block-popover/inbetween.js +2 -9
  12. package/build/components/block-popover/inbetween.js.map +1 -1
  13. package/build/components/block-settings-menu/block-settings-dropdown.js +1 -10
  14. package/build/components/block-settings-menu/block-settings-dropdown.js.map +1 -1
  15. package/build/components/block-toolbar/index.js +2 -1
  16. package/build/components/block-toolbar/index.js.map +1 -1
  17. package/build/components/block-tools/block-contextual-toolbar.js +83 -9
  18. package/build/components/block-tools/block-contextual-toolbar.js.map +1 -1
  19. package/build/components/block-tools/selected-block-popover.js +11 -28
  20. package/build/components/block-tools/selected-block-popover.js.map +1 -1
  21. package/build/components/caption/index.native.js +0 -1
  22. package/build/components/caption/index.native.js.map +1 -1
  23. package/build/components/date-format-picker/index.js +1 -1
  24. package/build/components/date-format-picker/index.js.map +1 -1
  25. package/build/components/editor-styles/index.js +4 -3
  26. package/build/components/editor-styles/index.js.map +1 -1
  27. package/build/components/font-sizes/fluid-utils.js +21 -14
  28. package/build/components/font-sizes/fluid-utils.js.map +1 -1
  29. package/build/components/global-styles/border-panel.js +15 -59
  30. package/build/components/global-styles/border-panel.js.map +1 -1
  31. package/build/components/global-styles/color-panel.js +12 -12
  32. package/build/components/global-styles/color-panel.js.map +1 -1
  33. package/build/components/global-styles/color-panel.native.js +174 -0
  34. package/build/components/global-styles/color-panel.native.js.map +1 -0
  35. package/build/components/global-styles/dimensions-panel.js +21 -20
  36. package/build/components/global-styles/dimensions-panel.js.map +1 -1
  37. package/build/components/global-styles/effects-panel.js +244 -0
  38. package/build/components/global-styles/effects-panel.js.map +1 -0
  39. package/build/components/global-styles/filters-panel.js +215 -0
  40. package/build/components/global-styles/filters-panel.js.map +1 -0
  41. package/build/components/global-styles/get-block-css-selector.js +1 -12
  42. package/build/components/global-styles/get-block-css-selector.js.map +1 -1
  43. package/build/components/global-styles/hooks.js +7 -0
  44. package/build/components/global-styles/hooks.js.map +1 -1
  45. package/build/components/global-styles/index.js +28 -0
  46. package/build/components/global-styles/index.js.map +1 -1
  47. package/build/components/global-styles/typography-panel.js +9 -9
  48. package/build/components/global-styles/typography-panel.js.map +1 -1
  49. package/build/components/global-styles/use-global-styles-output.js +100 -82
  50. package/build/components/global-styles/use-global-styles-output.js.map +1 -1
  51. package/build/components/iframe/index.js +1 -1
  52. package/build/components/iframe/index.js.map +1 -1
  53. package/build/components/image-size-control/use-dimension-handler.js +5 -3
  54. package/build/components/image-size-control/use-dimension-handler.js.map +1 -1
  55. package/build/components/index.js +23 -0
  56. package/build/components/index.js.map +1 -1
  57. package/build/components/inserter/block-patterns-tab.js +4 -2
  58. package/build/components/inserter/block-patterns-tab.js.map +1 -1
  59. package/build/components/inserter/block-types-tab.js +12 -7
  60. package/build/components/inserter/block-types-tab.js.map +1 -1
  61. package/build/components/inserter/index.js +2 -1
  62. package/build/components/inserter/index.js.map +1 -1
  63. package/build/components/inspector-controls/groups.js +2 -0
  64. package/build/components/inspector-controls/groups.js.map +1 -1
  65. package/build/components/inspector-controls-tabs/styles-tab.js +2 -0
  66. package/build/components/inspector-controls-tabs/styles-tab.js.map +1 -1
  67. package/build/components/inspector-controls-tabs/utils.js +5 -3
  68. package/build/components/inspector-controls-tabs/utils.js.map +1 -1
  69. package/build/components/list-view/block-select-button.js +7 -2
  70. package/build/components/list-view/block-select-button.js.map +1 -1
  71. package/build/components/list-view/block.js +13 -21
  72. package/build/components/list-view/block.js.map +1 -1
  73. package/build/components/list-view/drop-indicator.js +37 -10
  74. package/build/components/list-view/drop-indicator.js.map +1 -1
  75. package/build/components/list-view/index.js +31 -7
  76. package/build/components/list-view/index.js.map +1 -1
  77. package/build/components/list-view/leaf.js +2 -1
  78. package/build/components/list-view/leaf.js.map +1 -1
  79. package/build/components/list-view/use-block-selection.js +1 -1
  80. package/build/components/list-view/use-block-selection.js.map +1 -1
  81. package/build/components/list-view/use-list-view-client-ids.js +7 -3
  82. package/build/components/list-view/use-list-view-client-ids.js.map +1 -1
  83. package/build/components/list-view/use-list-view-drop-zone.js +8 -2
  84. package/build/components/list-view/use-list-view-drop-zone.js.map +1 -1
  85. package/build/components/media-replace-flow/index.js +5 -5
  86. package/build/components/media-replace-flow/index.js.map +1 -1
  87. package/build/components/navigable-toolbar/index.js +12 -4
  88. package/build/components/navigable-toolbar/index.js.map +1 -1
  89. package/build/components/off-canvas-editor/appender.js +2 -7
  90. package/build/components/off-canvas-editor/appender.js.map +1 -1
  91. package/build/components/off-canvas-editor/block-contents.js +6 -1
  92. package/build/components/off-canvas-editor/block-contents.js.map +1 -1
  93. package/build/components/off-canvas-editor/index.js +17 -14
  94. package/build/components/off-canvas-editor/index.js.map +1 -1
  95. package/build/components/resizable-box-popover/index.js +38 -0
  96. package/build/components/resizable-box-popover/index.js.map +1 -0
  97. package/build/components/rich-text/index.js +0 -1
  98. package/build/components/rich-text/index.js.map +1 -1
  99. package/build/components/rich-text/index.native.js +7 -11
  100. package/build/components/rich-text/index.native.js.map +1 -1
  101. package/build/components/spacing-sizes-control/spacing-input-control.js +8 -0
  102. package/build/components/spacing-sizes-control/spacing-input-control.js.map +1 -1
  103. package/build/hooks/anchor.js +1 -1
  104. package/build/hooks/anchor.js.map +1 -1
  105. package/build/hooks/border.js +1 -1
  106. package/build/hooks/border.js.map +1 -1
  107. package/build/hooks/duotone.js +121 -70
  108. package/build/hooks/duotone.js.map +1 -1
  109. package/build/hooks/margin.js +27 -17
  110. package/build/hooks/margin.js.map +1 -1
  111. package/build/hooks/padding.js +19 -9
  112. package/build/hooks/padding.js.map +1 -1
  113. package/build/hooks/utils.js +22 -7
  114. package/build/hooks/utils.js.map +1 -1
  115. package/build/layouts/utils.js +3 -2
  116. package/build/layouts/utils.js.map +1 -1
  117. package/build/private-apis.js +13 -1
  118. package/build/private-apis.js.map +1 -1
  119. package/build/store/actions.js +8 -1
  120. package/build/store/actions.js.map +1 -1
  121. package/build/utils/object.js +6 -6
  122. package/build/utils/object.js.map +1 -1
  123. package/build/utils/transform-styles/index.js +2 -2
  124. package/build/utils/transform-styles/index.js.map +1 -1
  125. package/build/utils/use-should-contextual-toolbar-show.js +68 -0
  126. package/build/utils/use-should-contextual-toolbar-show.js.map +1 -0
  127. package/build-module/components/block-info-slot-fill/index.js +34 -0
  128. package/build-module/components/block-info-slot-fill/index.js.map +1 -0
  129. package/build-module/components/block-inspector/index.js +3 -2
  130. package/build-module/components/block-inspector/index.js.map +1 -1
  131. package/build-module/components/block-list/index.native.js +11 -19
  132. package/build-module/components/block-list/index.native.js.map +1 -1
  133. package/build-module/components/block-list/use-in-between-inserter.js +2 -1
  134. package/build-module/components/block-list/use-in-between-inserter.js.map +1 -1
  135. package/build-module/components/block-popover/inbetween.js +2 -9
  136. package/build-module/components/block-popover/inbetween.js.map +1 -1
  137. package/build-module/components/block-settings-menu/block-settings-dropdown.js +1 -9
  138. package/build-module/components/block-settings-menu/block-settings-dropdown.js.map +1 -1
  139. package/build-module/components/block-toolbar/index.js +2 -1
  140. package/build-module/components/block-toolbar/index.js.map +1 -1
  141. package/build-module/components/block-tools/block-contextual-toolbar.js +79 -9
  142. package/build-module/components/block-tools/block-contextual-toolbar.js.map +1 -1
  143. package/build-module/components/block-tools/selected-block-popover.js +10 -27
  144. package/build-module/components/block-tools/selected-block-popover.js.map +1 -1
  145. package/build-module/components/caption/index.native.js +0 -1
  146. package/build-module/components/caption/index.native.js.map +1 -1
  147. package/build-module/components/date-format-picker/index.js +1 -1
  148. package/build-module/components/date-format-picker/index.js.map +1 -1
  149. package/build-module/components/editor-styles/index.js +4 -3
  150. package/build-module/components/editor-styles/index.js.map +1 -1
  151. package/build-module/components/font-sizes/fluid-utils.js +21 -14
  152. package/build-module/components/font-sizes/fluid-utils.js.map +1 -1
  153. package/build-module/components/global-styles/border-panel.js +15 -59
  154. package/build-module/components/global-styles/border-panel.js.map +1 -1
  155. package/build-module/components/global-styles/color-panel.js +13 -13
  156. package/build-module/components/global-styles/color-panel.js.map +1 -1
  157. package/build-module/components/global-styles/color-panel.native.js +150 -0
  158. package/build-module/components/global-styles/color-panel.native.js.map +1 -0
  159. package/build-module/components/global-styles/dimensions-panel.js +22 -21
  160. package/build-module/components/global-styles/dimensions-panel.js.map +1 -1
  161. package/build-module/components/global-styles/effects-panel.js +228 -0
  162. package/build-module/components/global-styles/effects-panel.js.map +1 -0
  163. package/build-module/components/global-styles/filters-panel.js +201 -0
  164. package/build-module/components/global-styles/filters-panel.js.map +1 -0
  165. package/build-module/components/global-styles/get-block-css-selector.js +1 -12
  166. package/build-module/components/global-styles/get-block-css-selector.js.map +1 -1
  167. package/build-module/components/global-styles/hooks.js +7 -0
  168. package/build-module/components/global-styles/hooks.js.map +1 -1
  169. package/build-module/components/global-styles/index.js +2 -0
  170. package/build-module/components/global-styles/index.js.map +1 -1
  171. package/build-module/components/global-styles/typography-panel.js +10 -10
  172. package/build-module/components/global-styles/typography-panel.js.map +1 -1
  173. package/build-module/components/global-styles/use-global-styles-output.js +101 -83
  174. package/build-module/components/global-styles/use-global-styles-output.js.map +1 -1
  175. package/build-module/components/iframe/index.js +1 -1
  176. package/build-module/components/iframe/index.js.map +1 -1
  177. package/build-module/components/image-size-control/use-dimension-handler.js +5 -3
  178. package/build-module/components/image-size-control/use-dimension-handler.js.map +1 -1
  179. package/build-module/components/index.js +1 -0
  180. package/build-module/components/index.js.map +1 -1
  181. package/build-module/components/inserter/block-patterns-tab.js +5 -2
  182. package/build-module/components/inserter/block-patterns-tab.js.map +1 -1
  183. package/build-module/components/inserter/block-types-tab.js +12 -6
  184. package/build-module/components/inserter/block-types-tab.js.map +1 -1
  185. package/build-module/components/inserter/index.js +2 -1
  186. package/build-module/components/inserter/index.js.map +1 -1
  187. package/build-module/components/inspector-controls/groups.js +2 -0
  188. package/build-module/components/inspector-controls/groups.js.map +1 -1
  189. package/build-module/components/inspector-controls-tabs/styles-tab.js +2 -0
  190. package/build-module/components/inspector-controls-tabs/styles-tab.js.map +1 -1
  191. package/build-module/components/inspector-controls-tabs/utils.js +4 -3
  192. package/build-module/components/inspector-controls-tabs/utils.js.map +1 -1
  193. package/build-module/components/list-view/block-select-button.js +7 -2
  194. package/build-module/components/list-view/block-select-button.js.map +1 -1
  195. package/build-module/components/list-view/block.js +15 -22
  196. package/build-module/components/list-view/block.js.map +1 -1
  197. package/build-module/components/list-view/drop-indicator.js +36 -10
  198. package/build-module/components/list-view/drop-indicator.js.map +1 -1
  199. package/build-module/components/list-view/index.js +31 -8
  200. package/build-module/components/list-view/index.js.map +1 -1
  201. package/build-module/components/list-view/leaf.js +2 -1
  202. package/build-module/components/list-view/leaf.js.map +1 -1
  203. package/build-module/components/list-view/use-block-selection.js +1 -1
  204. package/build-module/components/list-view/use-block-selection.js.map +1 -1
  205. package/build-module/components/list-view/use-list-view-client-ids.js +7 -3
  206. package/build-module/components/list-view/use-list-view-client-ids.js.map +1 -1
  207. package/build-module/components/list-view/use-list-view-drop-zone.js +8 -4
  208. package/build-module/components/list-view/use-list-view-drop-zone.js.map +1 -1
  209. package/build-module/components/media-replace-flow/index.js +5 -5
  210. package/build-module/components/media-replace-flow/index.js.map +1 -1
  211. package/build-module/components/navigable-toolbar/index.js +12 -4
  212. package/build-module/components/navigable-toolbar/index.js.map +1 -1
  213. package/build-module/components/off-canvas-editor/appender.js +1 -5
  214. package/build-module/components/off-canvas-editor/appender.js.map +1 -1
  215. package/build-module/components/off-canvas-editor/block-contents.js +5 -1
  216. package/build-module/components/off-canvas-editor/block-contents.js.map +1 -1
  217. package/build-module/components/off-canvas-editor/index.js +17 -14
  218. package/build-module/components/off-canvas-editor/index.js.map +1 -1
  219. package/build-module/components/resizable-box-popover/index.js +26 -0
  220. package/build-module/components/resizable-box-popover/index.js.map +1 -0
  221. package/build-module/components/rich-text/index.js +0 -1
  222. package/build-module/components/rich-text/index.js.map +1 -1
  223. package/build-module/components/rich-text/index.native.js +7 -10
  224. package/build-module/components/rich-text/index.native.js.map +1 -1
  225. package/build-module/components/spacing-sizes-control/spacing-input-control.js +7 -0
  226. package/build-module/components/spacing-sizes-control/spacing-input-control.js.map +1 -1
  227. package/build-module/hooks/anchor.js +1 -1
  228. package/build-module/hooks/anchor.js.map +1 -1
  229. package/build-module/hooks/border.js +1 -1
  230. package/build-module/hooks/border.js.map +1 -1
  231. package/build-module/hooks/duotone.js +118 -71
  232. package/build-module/hooks/duotone.js.map +1 -1
  233. package/build-module/hooks/margin.js +29 -18
  234. package/build-module/hooks/margin.js.map +1 -1
  235. package/build-module/hooks/padding.js +21 -10
  236. package/build-module/hooks/padding.js.map +1 -1
  237. package/build-module/hooks/utils.js +24 -9
  238. package/build-module/hooks/utils.js.map +1 -1
  239. package/build-module/layouts/utils.js +3 -2
  240. package/build-module/layouts/utils.js.map +1 -1
  241. package/build-module/private-apis.js +9 -1
  242. package/build-module/private-apis.js.map +1 -1
  243. package/build-module/store/actions.js +8 -1
  244. package/build-module/store/actions.js.map +1 -1
  245. package/build-module/utils/object.js +5 -5
  246. package/build-module/utils/object.js.map +1 -1
  247. package/build-module/utils/transform-styles/index.js +2 -2
  248. package/build-module/utils/transform-styles/index.js.map +1 -1
  249. package/build-module/utils/use-should-contextual-toolbar-show.js +56 -0
  250. package/build-module/utils/use-should-contextual-toolbar-show.js.map +1 -0
  251. package/build-style/content-rtl.css +9 -6
  252. package/build-style/content.css +9 -6
  253. package/build-style/style-rtl.css +272 -54
  254. package/build-style/style.css +272 -54
  255. package/package.json +32 -32
  256. package/src/components/block-info-slot-fill/index.js +24 -0
  257. package/src/components/block-inspector/index.js +3 -0
  258. package/src/components/block-inspector/style.scss +6 -4
  259. package/src/components/block-list/content.scss +16 -15
  260. package/src/components/block-list/index.native.js +19 -38
  261. package/src/components/block-list/use-in-between-inserter.js +4 -1
  262. package/src/components/block-mobile-toolbar/test/block-actions-menu.native.js +9 -9
  263. package/src/components/block-mover/style.scss +10 -4
  264. package/src/components/block-mover/test/index.native.js +4 -4
  265. package/src/components/block-popover/inbetween.js +2 -13
  266. package/src/components/block-settings-menu/block-settings-dropdown.js +2 -12
  267. package/src/components/block-toolbar/index.js +4 -3
  268. package/src/components/block-toolbar/style.scss +56 -33
  269. package/src/components/block-tools/block-contextual-toolbar.js +94 -11
  270. package/src/components/block-tools/selected-block-popover.js +11 -44
  271. package/src/components/block-tools/style.scss +157 -3
  272. package/src/components/caption/index.native.js +0 -1
  273. package/src/components/date-format-picker/index.js +1 -1
  274. package/src/components/editor-styles/index.js +9 -5
  275. package/src/components/font-sizes/fluid-utils.js +31 -14
  276. package/src/components/font-sizes/test/fluid-utils.js +5 -16
  277. package/src/components/global-styles/README.md +129 -16
  278. package/src/components/global-styles/border-panel.js +13 -61
  279. package/src/components/global-styles/color-panel.js +13 -13
  280. package/src/components/global-styles/color-panel.native.js +207 -0
  281. package/src/components/global-styles/dimensions-panel.js +47 -20
  282. package/src/components/global-styles/effects-panel.js +228 -0
  283. package/src/components/global-styles/filters-panel.js +230 -0
  284. package/src/components/global-styles/get-block-css-selector.js +0 -11
  285. package/src/components/global-styles/hooks.js +10 -0
  286. package/src/components/global-styles/index.js +2 -0
  287. package/src/components/global-styles/style.scss +43 -0
  288. package/src/components/global-styles/test/typography-utils.js +63 -22
  289. package/src/components/global-styles/test/use-global-styles-output.js +130 -8
  290. package/src/components/global-styles/typography-panel.js +37 -11
  291. package/src/components/global-styles/use-global-styles-output.js +88 -72
  292. package/src/components/iframe/index.js +1 -1
  293. package/src/components/image-size-control/use-dimension-handler.js +4 -3
  294. package/src/components/index.js +5 -1
  295. package/src/components/inserter/block-patterns-tab.js +3 -1
  296. package/src/components/inserter/block-types-tab.js +9 -6
  297. package/src/components/inserter/index.js +1 -1
  298. package/src/components/inspector-controls/groups.js +2 -0
  299. package/src/components/inspector-controls-tabs/styles-tab.js +1 -0
  300. package/src/components/inspector-controls-tabs/utils.js +4 -3
  301. package/src/components/list-view/README.md +2 -0
  302. package/src/components/list-view/block-select-button.js +6 -1
  303. package/src/components/list-view/block.js +24 -31
  304. package/src/components/list-view/drop-indicator.js +67 -22
  305. package/src/components/list-view/index.js +26 -3
  306. package/src/components/list-view/leaf.js +1 -0
  307. package/src/components/list-view/style.scss +18 -4
  308. package/src/components/list-view/test/use-list-view-drop-zone.js +188 -0
  309. package/src/components/list-view/use-block-selection.js +1 -1
  310. package/src/components/list-view/use-list-view-client-ids.js +5 -3
  311. package/src/components/list-view/use-list-view-drop-zone.js +9 -3
  312. package/src/components/media-replace-flow/README.md +3 -2
  313. package/src/components/media-replace-flow/index.js +4 -5
  314. package/src/components/navigable-toolbar/index.js +12 -3
  315. package/src/components/off-canvas-editor/appender.js +1 -4
  316. package/src/components/off-canvas-editor/block-contents.js +4 -0
  317. package/src/components/off-canvas-editor/index.js +15 -11
  318. package/src/components/resizable-box-popover/index.js +27 -0
  319. package/src/components/rich-text/index.js +0 -1
  320. package/src/components/rich-text/index.native.js +2 -5
  321. package/src/components/spacing-sizes-control/spacing-input-control.js +10 -0
  322. package/src/components/spacing-sizes-control/style.scss +7 -7
  323. package/src/components/url-popover/test/__snapshots__/index.js.snap +3 -3
  324. package/src/hooks/anchor.js +1 -1
  325. package/src/hooks/border.js +1 -1
  326. package/src/hooks/duotone.js +162 -99
  327. package/src/hooks/margin.js +31 -26
  328. package/src/hooks/padding.js +24 -18
  329. package/src/hooks/test/anchor.js +113 -0
  330. package/src/hooks/test/color.js +0 -9
  331. package/src/hooks/test/use-typography-props.js +2 -2
  332. package/src/hooks/test/utils.js +20 -101
  333. package/src/hooks/utils.js +23 -6
  334. package/src/layouts/utils.js +2 -2
  335. package/src/private-apis.js +8 -0
  336. package/src/store/actions.js +8 -1
  337. package/src/style.scss +1 -0
  338. package/src/utils/object.js +5 -5
  339. package/src/utils/test/object.js +53 -15
  340. package/src/utils/transform-styles/index.js +2 -2
  341. package/src/utils/use-should-contextual-toolbar-show.js +75 -0
  342. package/tsconfig.json +1 -0
  343. package/build/components/rich-text/use-native-props.js +0 -11
  344. package/build/components/rich-text/use-native-props.js.map +0 -1
  345. package/build/components/rich-text/use-native-props.native.js +0 -24
  346. package/build/components/rich-text/use-native-props.native.js.map +0 -1
  347. package/build/hooks/color-panel.native.js +0 -77
  348. package/build/hooks/color-panel.native.js.map +0 -1
  349. package/build-module/components/rich-text/use-native-props.js +0 -4
  350. package/build-module/components/rich-text/use-native-props.js.map +0 -1
  351. package/build-module/components/rich-text/use-native-props.native.js +0 -15
  352. package/build-module/components/rich-text/use-native-props.native.js.map +0 -1
  353. package/build-module/hooks/color-panel.native.js +0 -62
  354. package/build-module/hooks/color-panel.native.js.map +0 -1
  355. package/src/components/rich-text/use-native-props.js +0 -3
  356. package/src/components/rich-text/use-native-props.native.js +0 -17
  357. package/src/hooks/color-panel.native.js +0 -63
@@ -1 +1 @@
1
- {"version":3,"sources":["@wordpress/block-editor/src/components/spacing-sizes-control/spacing-input-control.js"],"names":["classnames","useState","useMemo","useSelect","BaseControl","Button","RangeControl","CustomSelectControl","__experimentalUnitControl","UnitControl","__experimentalHStack","HStack","__experimentalUseCustomUnits","useCustomUnits","__experimentalParseQuantityAndUnitFromRawValue","parseQuantityAndUnitFromRawValue","__","sprintf","settings","useSetting","store","blockEditorStore","LABELS","getSliderValueFromPreset","getCustomValueFromPreset","getPresetValueFromCustomValue","isValueSpacingPreset","CUSTOM_VALUE_SETTINGS","px","max","steps","vw","vh","em","rm","SpacingInputControl","spacingSizes","value","side","onChange","isMixed","type","minimumCustomValue","onMouseOver","onMouseOut","selectListSizes","showRangeControl","length","disableCustomSpacingSizes","select","editorSettings","getSettings","showCustomValueControl","setShowCustomValueControl","undefined","units","availableUnits","currentValue","showCustomValueInSelectList","name","slug","size","selectedUnit","setInitialValue","customTooltipContent","newValue","customRangeValue","parseFloat","getNewCustomValue","newSize","isNumeric","isNaN","nextValue","getNewPresetValue","controlType","parseInt","handleCustomValueSliderChange","next","join","allPlaceholder","currentValueHint","options","map","index","key","marks","label","ariaLabel","toLowerCase","showHint","event","nativeEvent","offsetX","find","option","selection","selectedItem"],"mappings":";;AAAA;AACA;AACA;AACA,OAAOA,UAAP,MAAuB,YAAvB;AAEA;AACA;AACA;;AACA,SAASC,QAAT,EAAmBC,OAAnB,QAAkC,oBAAlC;AACA,SAASC,SAAT,QAA0B,iBAA1B;AACA,SACCC,WADD,EAECC,MAFD,EAGCC,YAHD,EAICC,mBAJD,EAKCC,yBAAyB,IAAIC,WAL9B,EAMCC,oBAAoB,IAAIC,MANzB,EAOCC,4BAA4B,IAAIC,cAPjC,EAQCC,8CAA8C,IAAIC,gCARnD,QASO,uBATP;AAUA,SAASC,EAAT,EAAaC,OAAb,QAA4B,iBAA5B;AACA,SAASC,QAAT,QAAyB,kBAAzB;AAEA;AACA;AACA;;AACA,OAAOC,UAAP,MAAuB,gBAAvB;AACA,SAASC,KAAK,IAAIC,gBAAlB,QAA0C,aAA1C;AACA,SACCC,MADD,EAECC,wBAFD,EAGCC,wBAHD,EAICC,6BAJD,EAKCC,oBALD,QAMO,SANP;AAQA,MAAMC,qBAAqB,GAAG;AAC7BC,EAAAA,EAAE,EAAE;AAAEC,IAAAA,GAAG,EAAE,GAAP;AAAYC,IAAAA,KAAK,EAAE;AAAnB,GADyB;AAE7B,OAAK;AAAED,IAAAA,GAAG,EAAE,GAAP;AAAYC,IAAAA,KAAK,EAAE;AAAnB,GAFwB;AAG7BC,EAAAA,EAAE,EAAE;AAAEF,IAAAA,GAAG,EAAE,GAAP;AAAYC,IAAAA,KAAK,EAAE;AAAnB,GAHyB;AAI7BE,EAAAA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B,KAEK,EAHD,CAGI;AALV;AAOC,IAAA,QAAQ,EAAKsC,SAAF,IAAiB;AAC3BxD,MAAAA,QAAQ,CACPkC,iBAAiB,CAChBsB,SAAS,CAACC,YAAV,CAAuBZ,GADP,EAEhB,YAFgB,CADV,CAAR;AAMA,KAdF;AAeC,IAAA,OAAO,EAAGH,OAfX;AAgBC,IAAA,KAAK,EAAGM,SAhBT;AAiBC,IAAA,mBAAmB,EAAG,IAjBvB;AAkBC,IAAA,wBAAwB,EAAG,IAlB5B;AAmBC,IAAA,IAAI,EAAG,kBAnBR;AAoBC,IAAA,WAAW,EAAG5C,WApBf;AAqBC,IAAA,UAAU,EAAGC,UArBd;AAsBC,IAAA,OAAO,EAAGD,WAtBX;AAuBC,IAAA,MAAM,EAAGC;AAvBV,IAhHF,CADD;AA6IA","sourcesContent":["/**\n * External dependencies\n */\nimport classnames from 'classnames';\n\n/**\n * WordPress dependencies\n */\nimport { useState, useMemo } from '@wordpress/element';\nimport { useSelect } from '@wordpress/data';\nimport {\n\tBaseControl,\n\tButton,\n\tRangeControl,\n\tCustomSelectControl,\n\t__experimentalUnitControl as UnitControl,\n\t__experimentalHStack as HStack,\n\t__experimentalUseCustomUnits as useCustomUnits,\n\t__experimentalParseQuantityAndUnitFromRawValue as parseQuantityAndUnitFromRawValue,\n} from '@wordpress/components';\nimport { __, sprintf } from '@wordpress/i18n';\nimport { settings } from '@wordpress/icons';\n\n/**\n * Internal dependencies\n */\nimport useSetting from '../use-setting';\nimport { store as blockEditorStore } from '../../store';\nimport {\n\tLABELS,\n\tgetSliderValueFromPreset,\n\tgetCustomValueFromPreset,\n\tgetPresetValueFromCustomValue,\n\tisValueSpacingPreset,\n} from './utils';\n\nconst CUSTOM_VALUE_SETTINGS = {\n\tpx: { max: 300, steps: 1 },\n\t'%': { max: 100, steps: 1 },\n\tvw: { max: 100, steps: 1 },\n\tvh: { max: 100, steps: 1 },\n\tem: { max: 10, steps: 0.1 },\n\trm: { max: 10, steps: 0.1 },\n};\n\nexport default function SpacingInputControl( {\n\tspacingSizes,\n\tvalue,\n\tside,\n\tonChange,\n\tisMixed = false,\n\ttype,\n\tminimumCustomValue,\n\tonMouseOver,\n\tonMouseOut,\n} ) {\n\t// Treat value as a preset value if the passed in value matches the value of one of the spacingSizes.\n\tvalue = getPresetValueFromCustomValue( value, spacingSizes );\n\n\tlet selectListSizes = spacingSizes;\n\tconst showRangeControl = spacingSizes.length <= 8;\n\n\tconst disableCustomSpacingSizes = useSelect( ( select ) => {\n\t\tconst editorSettings = select( blockEditorStore ).getSettings();\n\t\treturn editorSettings?.disableCustomSpacingSizes;\n\t} );\n\n\tconst [ showCustomValueControl, setShowCustomValueControl ] = useState(\n\t\t! disableCustomSpacingSizes &&\n\t\t\tvalue !== undefined &&\n\t\t\t! isValueSpacingPreset( value )\n\t);\n\n\tconst units = useCustomUnits( {\n\t\tavailableUnits: useSetting( 'spacing.units' ) || [ 'px', 'em', 'rem' ],\n\t} );\n\n\tlet currentValue = null;\n\n\tconst showCustomValueInSelectList =\n\t\t! showRangeControl &&\n\t\t! showCustomValueControl &&\n\t\tvalue !== undefined &&\n\t\t( ! isValueSpacingPreset( value ) ||\n\t\t\t( isValueSpacingPreset( value ) && isMixed ) );\n\n\tif ( showCustomValueInSelectList ) {\n\t\tselectListSizes = [\n\t\t\t...spacingSizes,\n\t\t\t{\n\t\t\t\tname: ! isMixed\n\t\t\t\t\t? // translators: A custom measurement, eg. a number followed by a unit like 12px.\n\t\t\t\t\t sprintf( __( 'Custom (%s)' ), value )\n\t\t\t\t\t: __( 'Mixed' ),\n\t\t\t\tslug: 'custom',\n\t\t\t\tsize: value,\n\t\t\t},\n\t\t];\n\t\tcurrentValue = selectListSizes.length - 1;\n\t} else if ( ! isMixed ) {\n\t\tcurrentValue = ! showCustomValueControl\n\t\t\t? getSliderValueFromPreset( value, spacingSizes )\n\t\t\t: getCustomValueFromPreset( value, spacingSizes );\n\t}\n\n\tconst selectedUnit =\n\t\tuseMemo(\n\t\t\t() => parseQuantityAndUnitFromRawValue( currentValue ),\n\t\t\t[ currentValue ]\n\t\t)[ 1 ] || units[ 0 ].value;\n\n\tconst setInitialValue = () => {\n\t\tif ( value === undefined ) {\n\t\t\tonChange( '0' );\n\t\t}\n\t};\n\n\tconst customTooltipContent = ( newValue ) =>\n\t\tvalue === undefined ? undefined : spacingSizes[ newValue ]?.name;\n\n\tconst customRangeValue = parseFloat( currentValue, 10 );\n\n\tconst getNewCustomValue = ( newSize ) => {\n\t\tconst isNumeric = ! isNaN( parseFloat( newSize ) );\n\t\tconst nextValue = isNumeric ? newSize : undefined;\n\t\treturn nextValue;\n\t};\n\n\tconst getNewPresetValue = ( newSize, controlType ) => {\n\t\tconst size = parseInt( newSize, 10 );\n\n\t\tif ( controlType === 'selectList' ) {\n\t\t\tif ( size === 0 ) {\n\t\t\t\treturn undefined;\n\t\t\t}\n\t\t\tif ( size === 1 ) {\n\t\t\t\treturn '0';\n\t\t\t}\n\t\t} else if ( size === 0 ) {\n\t\t\treturn '0';\n\t\t}\n\t\treturn `var:preset|spacing|${ spacingSizes[ newSize ]?.slug }`;\n\t};\n\n\tconst handleCustomValueSliderChange = ( next ) => {\n\t\tonChange( [ next, selectedUnit ].join( '' ) );\n\t};\n\n\tconst allPlaceholder = isMixed ? __( 'Mixed' ) : null;\n\n\tconst currentValueHint = ! isMixed\n\t\t? customTooltipContent( currentValue )\n\t\t: __( 'Mixed' );\n\n\tconst options = selectListSizes.map( ( size, index ) => ( {\n\t\tkey: index,\n\t\tname: size.name,\n\t} ) );\n\n\tconst marks = spacingSizes.map( ( newValue, index ) => ( {\n\t\tvalue: index,\n\t\tlabel: undefined,\n\t} ) );\n\n\tconst ariaLabel = sprintf(\n\t\t// translators: 1: The side of the block being modified (top, bottom, left, etc.). 2. Type of spacing being modified (Padding, margin, etc)\n\t\t__( '%1$s %2$s' ),\n\t\tLABELS[ side ],\n\t\ttype?.toLowerCase()\n\t);\n\n\tconst showHint =\n\t\tshowRangeControl &&\n\t\t! showCustomValueControl &&\n\t\tcurrentValueHint !== undefined;\n\n\treturn (\n\t\t<>\n\t\t\t{ side !== 'all' && (\n\t\t\t\t<HStack className=\"components-spacing-sizes-control__side-labels\">\n\t\t\t\t\t<BaseControl.VisualLabel className=\"components-spacing-sizes-control__side-label\">\n\t\t\t\t\t\t{ LABELS[ side ] }\n\t\t\t\t\t</BaseControl.VisualLabel>\n\n\t\t\t\t\t{ showHint && (\n\t\t\t\t\t\t<BaseControl.VisualLabel className=\"components-spacing-sizes-control__hint-single\">\n\t\t\t\t\t\t\t{ currentValueHint }\n\t\t\t\t\t\t</BaseControl.VisualLabel>\n\t\t\t\t\t) }\n\t\t\t\t</HStack>\n\t\t\t) }\n\t\t\t{ side === 'all' && showHint && (\n\t\t\t\t<BaseControl.VisualLabel className=\"components-spacing-sizes-control__hint-all\">\n\t\t\t\t\t{ currentValueHint }\n\t\t\t\t</BaseControl.VisualLabel>\n\t\t\t) }\n\n\t\t\t{ ! disableCustomSpacingSizes && (\n\t\t\t\t<Button\n\t\t\t\t\tlabel={\n\t\t\t\t\t\tshowCustomValueControl\n\t\t\t\t\t\t\t? __( 'Use size preset' )\n\t\t\t\t\t\t\t: __( 'Set custom size' )\n\t\t\t\t\t}\n\t\t\t\t\ticon={ settings }\n\t\t\t\t\tonClick={ () => {\n\t\t\t\t\t\tsetShowCustomValueControl( ! showCustomValueControl );\n\t\t\t\t\t} }\n\t\t\t\t\tisPressed={ showCustomValueControl }\n\t\t\t\t\tisSmall\n\t\t\t\t\tclassName={ classnames( {\n\t\t\t\t\t\t'components-spacing-sizes-control__custom-toggle-all':\n\t\t\t\t\t\t\tside === 'all',\n\t\t\t\t\t\t'components-spacing-sizes-control__custom-toggle-single':\n\t\t\t\t\t\t\tside !== 'all',\n\t\t\t\t\t} ) }\n\t\t\t\t\ticonSize={ 24 }\n\t\t\t\t/>\n\t\t\t) }\n\t\t\t{ showCustomValueControl && (\n\t\t\t\t<>\n\t\t\t\t\t<UnitControl\n\t\t\t\t\t\tonMouseOver={ onMouseOver }\n\t\t\t\t\t\tonMouseOut={ onMouseOut }\n\t\t\t\t\t\tonFocus={ onMouseOver }\n\t\t\t\t\t\tonBlur={ onMouseOut }\n\t\t\t\t\t\tonChange={ ( newSize ) =>\n\t\t\t\t\t\t\tonChange( getNewCustomValue( newSize ) )\n\t\t\t\t\t\t}\n\t\t\t\t\t\tvalue={ currentValue }\n\t\t\t\t\t\tunits={ units }\n\t\t\t\t\t\tmin={ minimumCustomValue }\n\t\t\t\t\t\tplaceholder={ allPlaceholder }\n\t\t\t\t\t\tdisableUnits={ isMixed }\n\t\t\t\t\t\tlabel={ ariaLabel }\n\t\t\t\t\t\thideLabelFromVision={ true }\n\t\t\t\t\t\tclassName=\"components-spacing-sizes-control__custom-value-input\"\n\t\t\t\t\t\tsize={ '__unstable-large' }\n\t\t\t\t\t/>\n\n\t\t\t\t\t<RangeControl\n\t\t\t\t\t\tonMouseOver={ onMouseOver }\n\t\t\t\t\t\tonMouseOut={ onMouseOut }\n\t\t\t\t\t\tonFocus={ onMouseOver }\n\t\t\t\t\t\tonBlur={ onMouseOut }\n\t\t\t\t\t\tvalue={ customRangeValue }\n\t\t\t\t\t\tmin={ 0 }\n\t\t\t\t\t\tmax={ CUSTOM_VALUE_SETTINGS[ selectedUnit ]?.max ?? 10 }\n\t\t\t\t\t\tstep={\n\t\t\t\t\t\t\tCUSTOM_VALUE_SETTINGS[ selectedUnit ]?.steps ?? 0.1\n\t\t\t\t\t\t}\n\t\t\t\t\t\twithInputField={ false }\n\t\t\t\t\t\tonChange={ handleCustomValueSliderChange }\n\t\t\t\t\t\tclassName=\"components-spacing-sizes-control__custom-value-range\"\n\t\t\t\t\t\t__nextHasNoMarginBottom\n\t\t\t\t\t/>\n\t\t\t\t</>\n\t\t\t) }\n\t\t\t{ showRangeControl && ! showCustomValueControl && (\n\t\t\t\t<RangeControl\n\t\t\t\t\tonMouseOver={ onMouseOver }\n\t\t\t\t\tonMouseOut={ onMouseOut }\n\t\t\t\t\tclassName=\"components-spacing-sizes-control__range-control\"\n\t\t\t\t\tvalue={ currentValue }\n\t\t\t\t\tonChange={ ( newSize ) =>\n\t\t\t\t\t\tonChange( getNewPresetValue( newSize ) )\n\t\t\t\t\t}\n\t\t\t\t\tonMouseDown={ ( event ) => {\n\t\t\t\t\t\t// If mouse down is near start of range set initial value to 0, which\n\t\t\t\t\t\t// prevents the user have to drag right then left to get 0 setting.\n\t\t\t\t\t\tif ( event?.nativeEvent?.offsetX < 35 ) {\n\t\t\t\t\t\t\tsetInitialValue();\n\t\t\t\t\t\t}\n\t\t\t\t\t} }\n\t\t\t\t\twithInputField={ false }\n\t\t\t\t\taria-valuenow={ currentValue }\n\t\t\t\t\taria-valuetext={ spacingSizes[ currentValue ]?.name }\n\t\t\t\t\trenderTooltipContent={ customTooltipContent }\n\t\t\t\t\tmin={ 0 }\n\t\t\t\t\tmax={ spacingSizes.length - 1 }\n\t\t\t\t\tmarks={ marks }\n\t\t\t\t\tlabel={ ariaLabel }\n\t\t\t\t\thideLabelFromVision={ true }\n\t\t\t\t\t__nextHasNoMarginBottom={ true }\n\t\t\t\t\tonFocus={ onMouseOver }\n\t\t\t\t\tonBlur={ onMouseOut }\n\t\t\t\t/>\n\t\t\t) }\n\t\t\t{ ! showRangeControl && ! showCustomValueControl && (\n\t\t\t\t<CustomSelectControl\n\t\t\t\t\tclassName=\"components-spacing-sizes-control__custom-select-control\"\n\t\t\t\t\tvalue={\n\t\t\t\t\t\toptions.find(\n\t\t\t\t\t\t\t( option ) => option.key === currentValue\n\t\t\t\t\t\t) || '' // passing undefined here causes a downshift controlled/uncontrolled warning\n\t\t\t\t\t}\n\t\t\t\t\tonChange={ ( selection ) => {\n\t\t\t\t\t\tonChange(\n\t\t\t\t\t\t\tgetNewPresetValue(\n\t\t\t\t\t\t\t\tselection.selectedItem.key,\n\t\t\t\t\t\t\t\t'selectList'\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\toptions={ options }\n\t\t\t\t\tlabel={ ariaLabel }\n\t\t\t\t\thideLabelFromVision={ true }\n\t\t\t\t\t__nextUnconstrainedWidth={ true }\n\t\t\t\t\tsize={ '__unstable-large' }\n\t\t\t\t\tonMouseOver={ onMouseOver }\n\t\t\t\t\tonMouseOut={ onMouseOut }\n\t\t\t\t\tonFocus={ onMouseOver }\n\t\t\t\t\tonBlur={ onMouseOut }\n\t\t\t\t/>\n\t\t\t) }\n\t\t</>\n\t);\n}\n"]}
1
+ {"version":3,"sources":["@wordpress/block-editor/src/components/spacing-sizes-control/spacing-input-control.js"],"names":["classnames","useState","useMemo","useSelect","BaseControl","Button","RangeControl","CustomSelectControl","__experimentalUnitControl","UnitControl","__experimentalHStack","HStack","__experimentalUseCustomUnits","useCustomUnits","__experimentalParseQuantityAndUnitFromRawValue","parseQuantityAndUnitFromRawValue","__","sprintf","settings","usePrevious","useSetting","store","blockEditorStore","LABELS","getSliderValueFromPreset","getCustomValueFromPreset","getPresetValueFromCustomValue","isValueSpacingPreset","CUSTOM_VALUE_SETTINGS","px","max","steps","vw","vh","em","rm","SpacingInputControl","spacingSizes","value","side","onChange","isMixed","type","minimumCustomValue","onMouseOver","onMouseOut","selectListSizes","showRangeControl","length","disableCustomSpacingSizes","select","editorSettings","getSettings","showCustomValueControl","setShowCustomValueControl","undefined","previousValue","units","availableUnits","currentValue","showCustomValueInSelectList","name","slug","size","selectedUnit","setInitialValue","customTooltipContent","newValue","customRangeValue","parseFloat","getNewCustomValue","newSize","isNumeric","isNaN","nextValue","getNewPresetValue","controlType","parseInt","handleCustomValueSliderChange","next","join","allPlaceholder","currentValueHint","options","map","index","key","marks","label","ariaLabel","toLowerCase","showHint","event","nativeEvent","offsetX","find","option","selection","selectedItem"],"mappings":";;AAAA;AACA;AACA;AACA,OAAOA,UAAP,MAAuB,YAAvB;AAEA;AACA;AACA;;AACA,SAASC,QAAT,EAAmBC,OAAnB,QAAkC,oBAAlC;AACA,SAASC,S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AAO,EAAGH,OAfX;AAgBC,IAAA,KAAK,EAAGM,SAhBT;AAiBC,IAAA,mBAAmB,EAAG,IAjBvB;AAkBC,IAAA,wBAAwB,EAAG,IAlB5B;AAmBC,IAAA,IAAI,EAAG,kBAnBR;AAoBC,IAAA,WAAW,EAAG7C,WApBf;AAqBC,IAAA,UAAU,EAAGC,UArBd;AAsBC,IAAA,OAAO,EAAGD,WAtBX;AAuBC,IAAA,MAAM,EAAGC;AAvBV,IAhHF,CADD;AA6IA","sourcesContent":["/**\n * External dependencies\n */\nimport classnames from 'classnames';\n\n/**\n * WordPress dependencies\n */\nimport { useState, useMemo } from '@wordpress/element';\nimport { useSelect } from '@wordpress/data';\nimport {\n\tBaseControl,\n\tButton,\n\tRangeControl,\n\tCustomSelectControl,\n\t__experimentalUnitControl as UnitControl,\n\t__experimentalHStack as HStack,\n\t__experimentalUseCustomUnits as useCustomUnits,\n\t__experimentalParseQuantityAndUnitFromRawValue as parseQuantityAndUnitFromRawValue,\n} from '@wordpress/components';\nimport { __, sprintf } from '@wordpress/i18n';\nimport { settings } from '@wordpress/icons';\nimport { usePrevious } from '@wordpress/compose';\n\n/**\n * Internal dependencies\n */\nimport useSetting from '../use-setting';\nimport { store as blockEditorStore } from '../../store';\nimport {\n\tLABELS,\n\tgetSliderValueFromPreset,\n\tgetCustomValueFromPreset,\n\tgetPresetValueFromCustomValue,\n\tisValueSpacingPreset,\n} from './utils';\n\nconst CUSTOM_VALUE_SETTINGS = {\n\tpx: { max: 300, steps: 1 },\n\t'%': { max: 100, steps: 1 },\n\tvw: { max: 100, steps: 1 },\n\tvh: { max: 100, steps: 1 },\n\tem: { max: 10, steps: 0.1 },\n\trm: { max: 10, steps: 0.1 },\n};\n\nexport default function SpacingInputControl( {\n\tspacingSizes,\n\tvalue,\n\tside,\n\tonChange,\n\tisMixed = false,\n\ttype,\n\tminimumCustomValue,\n\tonMouseOver,\n\tonMouseOut,\n} ) {\n\t// Treat value as a preset value if the passed in value matches the value of one of the spacingSizes.\n\tvalue = getPresetValueFromCustomValue( value, spacingSizes );\n\n\tlet selectListSizes = spacingSizes;\n\tconst showRangeControl = spacingSizes.length <= 8;\n\n\tconst disableCustomSpacingSizes = useSelect( ( select ) => {\n\t\tconst editorSettings = select( blockEditorStore ).getSettings();\n\t\treturn editorSettings?.disableCustomSpacingSizes;\n\t} );\n\n\tconst [ showCustomValueControl, setShowCustomValueControl ] = useState(\n\t\t! disableCustomSpacingSizes &&\n\t\t\tvalue !== undefined &&\n\t\t\t! isValueSpacingPreset( value )\n\t);\n\n\tconst previousValue = usePrevious( value );\n\tif (\n\t\tpreviousValue !== value &&\n\t\t! isValueSpacingPreset( value ) &&\n\t\tshowCustomValueControl !== true\n\t) {\n\t\tsetShowCustomValueControl( true );\n\t}\n\n\tconst units = useCustomUnits( {\n\t\tavailableUnits: useSetting( 'spacing.units' ) || [ 'px', 'em', 'rem' ],\n\t} );\n\n\tlet currentValue = null;\n\n\tconst showCustomValueInSelectList =\n\t\t! showRangeControl &&\n\t\t! showCustomValueControl &&\n\t\tvalue !== undefined &&\n\t\t( ! isValueSpacingPreset( value ) ||\n\t\t\t( isValueSpacingPreset( value ) && isMixed ) );\n\n\tif ( showCustomValueInSelectList ) {\n\t\tselectListSizes = [\n\t\t\t...spacingSizes,\n\t\t\t{\n\t\t\t\tname: ! isMixed\n\t\t\t\t\t? // translators: A custom measurement, eg. a number followed by a unit like 12px.\n\t\t\t\t\t sprintf( __( 'Custom (%s)' ), value )\n\t\t\t\t\t: __( 'Mixed' ),\n\t\t\t\tslug: 'custom',\n\t\t\t\tsize: value,\n\t\t\t},\n\t\t];\n\t\tcurrentValue = selectListSizes.length - 1;\n\t} else if ( ! isMixed ) {\n\t\tcurrentValue = ! showCustomValueControl\n\t\t\t? getSliderValueFromPreset( value, spacingSizes )\n\t\t\t: getCustomValueFromPreset( value, spacingSizes );\n\t}\n\n\tconst selectedUnit =\n\t\tuseMemo(\n\t\t\t() => parseQuantityAndUnitFromRawValue( currentValue ),\n\t\t\t[ currentValue ]\n\t\t)[ 1 ] || units[ 0 ].value;\n\n\tconst setInitialValue = () => {\n\t\tif ( value === undefined ) {\n\t\t\tonChange( '0' );\n\t\t}\n\t};\n\n\tconst customTooltipContent = ( newValue ) =>\n\t\tvalue === undefined ? undefined : spacingSizes[ newValue ]?.name;\n\n\tconst customRangeValue = parseFloat( currentValue, 10 );\n\n\tconst getNewCustomValue = ( newSize ) => {\n\t\tconst isNumeric = ! isNaN( parseFloat( newSize ) );\n\t\tconst nextValue = isNumeric ? newSize : undefined;\n\t\treturn nextValue;\n\t};\n\n\tconst getNewPresetValue = ( newSize, controlType ) => {\n\t\tconst size = parseInt( newSize, 10 );\n\n\t\tif ( controlType === 'selectList' ) {\n\t\t\tif ( size === 0 ) {\n\t\t\t\treturn undefined;\n\t\t\t}\n\t\t\tif ( size === 1 ) {\n\t\t\t\treturn '0';\n\t\t\t}\n\t\t} else if ( size === 0 ) {\n\t\t\treturn '0';\n\t\t}\n\t\treturn `var:preset|spacing|${ spacingSizes[ newSize ]?.slug }`;\n\t};\n\n\tconst handleCustomValueSliderChange = ( next ) => {\n\t\tonChange( [ next, selectedUnit ].join( '' ) );\n\t};\n\n\tconst allPlaceholder = isMixed ? __( 'Mixed' ) : null;\n\n\tconst currentValueHint = ! isMixed\n\t\t? customTooltipContent( currentValue )\n\t\t: __( 'Mixed' );\n\n\tconst options = selectListSizes.map( ( size, index ) => ( {\n\t\tkey: index,\n\t\tname: size.name,\n\t} ) );\n\n\tconst marks = spacingSizes.map( ( newValue, index ) => ( {\n\t\tvalue: index,\n\t\tlabel: undefined,\n\t} ) );\n\n\tconst ariaLabel = sprintf(\n\t\t// translators: 1: The side of the block being modified (top, bottom, left, etc.). 2. Type of spacing being modified (Padding, margin, etc)\n\t\t__( '%1$s %2$s' ),\n\t\tLABELS[ side ],\n\t\ttype?.toLowerCase()\n\t);\n\n\tconst showHint =\n\t\tshowRangeControl &&\n\t\t! showCustomValueControl &&\n\t\tcurrentValueHint !== undefined;\n\n\treturn (\n\t\t<>\n\t\t\t{ side !== 'all' && (\n\t\t\t\t<HStack className=\"components-spacing-sizes-control__side-labels\">\n\t\t\t\t\t<BaseControl.VisualLabel className=\"components-spacing-sizes-control__side-label\">\n\t\t\t\t\t\t{ LABELS[ side ] }\n\t\t\t\t\t</BaseControl.VisualLabel>\n\n\t\t\t\t\t{ showHint && (\n\t\t\t\t\t\t<BaseControl.VisualLabel className=\"components-spacing-sizes-control__hint-single\">\n\t\t\t\t\t\t\t{ currentValueHint }\n\t\t\t\t\t\t</BaseControl.VisualLabel>\n\t\t\t\t\t) }\n\t\t\t\t</HStack>\n\t\t\t) }\n\t\t\t{ side === 'all' && showHint && (\n\t\t\t\t<BaseControl.VisualLabel className=\"components-spacing-sizes-control__hint-all\">\n\t\t\t\t\t{ currentValueHint }\n\t\t\t\t</BaseControl.VisualLabel>\n\t\t\t) }\n\n\t\t\t{ ! disableCustomSpacingSizes && (\n\t\t\t\t<Button\n\t\t\t\t\tlabel={\n\t\t\t\t\t\tshowCustomValueControl\n\t\t\t\t\t\t\t? __( 'Use size preset' )\n\t\t\t\t\t\t\t: __( 'Set custom size' )\n\t\t\t\t\t}\n\t\t\t\t\ticon={ settings }\n\t\t\t\t\tonClick={ () => {\n\t\t\t\t\t\tsetShowCustomValueControl( ! showCustomValueControl );\n\t\t\t\t\t} }\n\t\t\t\t\tisPressed={ showCustomValueControl }\n\t\t\t\t\tisSmall\n\t\t\t\t\tclassName={ classnames( {\n\t\t\t\t\t\t'components-spacing-sizes-control__custom-toggle-all':\n\t\t\t\t\t\t\tside === 'all',\n\t\t\t\t\t\t'components-spacing-sizes-control__custom-toggle-single':\n\t\t\t\t\t\t\tside !== 'all',\n\t\t\t\t\t} ) }\n\t\t\t\t\ticonSize={ 24 }\n\t\t\t\t/>\n\t\t\t) }\n\t\t\t{ showCustomValueControl && (\n\t\t\t\t<>\n\t\t\t\t\t<UnitControl\n\t\t\t\t\t\tonMouseOver={ onMouseOver }\n\t\t\t\t\t\tonMouseOut={ onMouseOut }\n\t\t\t\t\t\tonFocus={ onMouseOver }\n\t\t\t\t\t\tonBlur={ onMouseOut }\n\t\t\t\t\t\tonChange={ ( newSize ) =>\n\t\t\t\t\t\t\tonChange( getNewCustomValue( newSize ) )\n\t\t\t\t\t\t}\n\t\t\t\t\t\tvalue={ currentValue }\n\t\t\t\t\t\tunits={ units }\n\t\t\t\t\t\tmin={ minimumCustomValue }\n\t\t\t\t\t\tplaceholder={ allPlaceholder }\n\t\t\t\t\t\tdisableUnits={ isMixed }\n\t\t\t\t\t\tlabel={ ariaLabel }\n\t\t\t\t\t\thideLabelFromVision={ true }\n\t\t\t\t\t\tclassName=\"components-spacing-sizes-control__custom-value-input\"\n\t\t\t\t\t\tsize={ '__unstable-large' }\n\t\t\t\t\t/>\n\n\t\t\t\t\t<RangeControl\n\t\t\t\t\t\tonMouseOver={ onMouseOver }\n\t\t\t\t\t\tonMouseOut={ onMouseOut }\n\t\t\t\t\t\tonFocus={ onMouseOver }\n\t\t\t\t\t\tonBlur={ onMouseOut }\n\t\t\t\t\t\tvalue={ customRangeValue }\n\t\t\t\t\t\tmin={ 0 }\n\t\t\t\t\t\tmax={ CUSTOM_VALUE_SETTINGS[ selectedUnit ]?.max ?? 10 }\n\t\t\t\t\t\tstep={\n\t\t\t\t\t\t\tCUSTOM_VALUE_SETTINGS[ selectedUnit ]?.steps ?? 0.1\n\t\t\t\t\t\t}\n\t\t\t\t\t\twithInputField={ false }\n\t\t\t\t\t\tonChange={ handleCustomValueSliderChange }\n\t\t\t\t\t\tclassName=\"components-spacing-sizes-control__custom-value-range\"\n\t\t\t\t\t\t__nextHasNoMarginBottom\n\t\t\t\t\t/>\n\t\t\t\t</>\n\t\t\t) }\n\t\t\t{ showRangeControl && ! showCustomValueControl && (\n\t\t\t\t<RangeControl\n\t\t\t\t\tonMouseOver={ onMouseOver }\n\t\t\t\t\tonMouseOut={ onMouseOut }\n\t\t\t\t\tclassName=\"components-spacing-sizes-control__range-control\"\n\t\t\t\t\tvalue={ currentValue }\n\t\t\t\t\tonChange={ ( newSize ) =>\n\t\t\t\t\t\tonChange( getNewPresetValue( newSize ) )\n\t\t\t\t\t}\n\t\t\t\t\tonMouseDown={ ( event ) => {\n\t\t\t\t\t\t// If mouse down is near start of range set initial value to 0, which\n\t\t\t\t\t\t// prevents the user have to drag right then left to get 0 setting.\n\t\t\t\t\t\tif ( event?.nativeEvent?.offsetX < 35 ) {\n\t\t\t\t\t\t\tsetInitialValue();\n\t\t\t\t\t\t}\n\t\t\t\t\t} }\n\t\t\t\t\twithInputField={ false }\n\t\t\t\t\taria-valuenow={ currentValue }\n\t\t\t\t\taria-valuetext={ spacingSizes[ currentValue ]?.name }\n\t\t\t\t\trenderTooltipContent={ customTooltipContent }\n\t\t\t\t\tmin={ 0 }\n\t\t\t\t\tmax={ spacingSizes.length - 1 }\n\t\t\t\t\tmarks={ marks }\n\t\t\t\t\tlabel={ ariaLabel }\n\t\t\t\t\thideLabelFromVision={ true }\n\t\t\t\t\t__nextHasNoMarginBottom={ true }\n\t\t\t\t\tonFocus={ onMouseOver }\n\t\t\t\t\tonBlur={ onMouseOut }\n\t\t\t\t/>\n\t\t\t) }\n\t\t\t{ ! showRangeControl && ! showCustomValueControl && (\n\t\t\t\t<CustomSelectControl\n\t\t\t\t\tclassName=\"components-spacing-sizes-control__custom-select-control\"\n\t\t\t\t\tvalue={\n\t\t\t\t\t\toptions.find(\n\t\t\t\t\t\t\t( option ) => option.key === currentValue\n\t\t\t\t\t\t) || '' // passing undefined here causes a downshift controlled/uncontrolled warning\n\t\t\t\t\t}\n\t\t\t\t\tonChange={ ( selection ) => {\n\t\t\t\t\t\tonChange(\n\t\t\t\t\t\t\tgetNewPresetValue(\n\t\t\t\t\t\t\t\tselection.selectedItem.key,\n\t\t\t\t\t\t\t\t'selectList'\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\toptions={ options }\n\t\t\t\t\tlabel={ ariaLabel }\n\t\t\t\t\thideLabelFromVision={ true }\n\t\t\t\t\t__nextUnconstrainedWidth={ true }\n\t\t\t\t\tsize={ '__unstable-large' }\n\t\t\t\t\tonMouseOver={ onMouseOver }\n\t\t\t\t\tonMouseOut={ onMouseOut }\n\t\t\t\t\tonFocus={ onMouseOver }\n\t\t\t\t\tonBlur={ onMouseOut }\n\t\t\t\t/>\n\t\t\t) }\n\t\t</>\n\t);\n}\n"]}
@@ -73,7 +73,7 @@ export const withInspectorControl = createHigherOrderComponent(BlockEdit => {
73
73
  className: "html-anchor-control",
74
74
  label: __('HTML anchor'),
75
75
  help: createElement(Fragment, null, __('Enter a word or two — without spaces — to make a unique web address just for this block, called an “anchor.” Then, you’ll be able to link directly to this section of your page.'), isWeb && createElement(ExternalLink, {
76
- href: __('https://wordpress.org/support/article/page-jumps/')
76
+ href: __('https://wordpress.org/documentation/article/page-jumps/')
77
77
  }, __('Learn more about anchors'))),
78
78
  value: props.attributes.anchor || '',
79
79
  placeholder: !isWeb ? __('Add an anchor') : null,
@@ -1 +1 @@
1
- {"version":3,"sources":["@wordpress/block-editor/src/hooks/anchor.js"],"names":["addFilter","PanelBody","TextControl","ExternalLink","__","hasBlockSupport","createHigherOrderComponent","Platform","InspectorControls","ANCHOR_REGEX","ANCHOR_SCHEMA","type","source","attribute","selector","addAttribute","settings","attributes","anchor","withInspectorControl","BlockEdit","props","hasAnchor","name","isSelected","isWeb","OS","textControl","nextValue","replace","setAttributes","addSaveProps","extraProps","blockType","id"],"mappings":";;AAAA;AACA;AACA;AACA,SAASA,SAAT,QAA0B,kBAA1B;AACA,SAASC,SAAT,EAAoBC,WAApB,EAAiCC,YAAjC,QAAqD,uBAArD;AACA,SAASC,EAAT,QAAmB,iBAAnB;AACA,SAASC,eAAT,QAAgC,mBAAhC;AACA,SAASC,0BAAT,QAA2C,oBAA3C;AACA,SAASC,QAAT,QAAyB,oBAAzB;AAEA;AACA;AACA;;AACA,SAASC,iBAAT,QA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MAA7D;AACA;;AAED,SAAOc,UAAP;AACA;AAEDhC,SAAS,CAAE,0BAAF,EAA8B,uBAA9B,EAAuDe,YAAvD,CAAT;AACAf,SAAS,CACR,kBADQ,EAER,2CAFQ,EAGRmB,oBAHQ,CAAT;AAKAnB,SAAS,CACR,kCADQ,EAER,wBAFQ,EAGR+B,YAHQ,CAAT","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { addFilter } from '@wordpress/hooks';\nimport { PanelBody, TextControl, ExternalLink } from '@wordpress/components';\nimport { __ } from '@wordpress/i18n';\nimport { hasBlockSupport } from '@wordpress/blocks';\nimport { createHigherOrderComponent } from '@wordpress/compose';\nimport { Platform } from '@wordpress/element';\n\n/**\n * Internal dependencies\n */\nimport { InspectorControls } from '../components';\n\n/**\n * Regular expression matching invalid anchor characters for replacement.\n *\n * @type {RegExp}\n */\nconst ANCHOR_REGEX = /[\\s#]/g;\n\nconst ANCHOR_SCHEMA = {\n\ttype: 'string',\n\tsource: 'attribute',\n\tattribute: 'id',\n\tselector: '*',\n};\n\n/**\n * Filters registered block settings, extending attributes with anchor using ID\n * of the first node.\n *\n * @param {Object} settings Original block settings.\n *\n * @return {Object} Filtered block settings.\n */\nexport function addAttribute( settings ) {\n\t// Allow blocks to specify their own attribute definition with default values if needed.\n\tif ( 'type' in ( settings.attributes?.anchor ?? {} ) ) {\n\t\treturn settings;\n\t}\n\tif ( hasBlockSupport( settings, 'anchor' ) ) {\n\t\t// Gracefully handle if settings.attributes is undefined.\n\t\tsettings.attributes = {\n\t\t\t...settings.attributes,\n\t\t\tanchor: ANCHOR_SCHEMA,\n\t\t};\n\t}\n\n\treturn settings;\n}\n\n/**\n * Override the default edit UI to include a new block inspector control for\n * assigning the anchor ID, if block supports anchor.\n *\n * @param {WPComponent} BlockEdit Original component.\n *\n * @return {WPComponent} Wrapped component.\n */\nexport const withInspectorControl = createHigherOrderComponent(\n\t( BlockEdit ) => {\n\t\treturn ( props ) => {\n\t\t\tconst hasAnchor = hasBlockSupport( props.name, 'anchor' );\n\n\t\t\tif ( hasAnchor && props.isSelected ) {\n\t\t\t\tconst isWeb = Platform.OS === 'web';\n\t\t\t\tconst textControl = (\n\t\t\t\t\t<TextControl\n\t\t\t\t\t\t__nextHasNoMarginBottom\n\t\t\t\t\t\tclassName=\"html-anchor-control\"\n\t\t\t\t\t\tlabel={ __( 'HTML anchor' ) }\n\t\t\t\t\t\thelp={\n\t\t\t\t\t\t\t<>\n\t\t\t\t\t\t\t\t{ __(\n\t\t\t\t\t\t\t\t\t'Enter a word or two — without spaces — to make a unique web address just for this block, called an “anchor.” Then, you’ll be able to link directly to this section of your page.'\n\t\t\t\t\t\t\t\t) }\n\n\t\t\t\t\t\t\t\t{ isWeb && (\n\t\t\t\t\t\t\t\t\t<ExternalLink\n\t\t\t\t\t\t\t\t\t\thref={ __(\n\t\t\t\t\t\t\t\t\t\t\t'https://wordpress.org/support/article/page-jumps/'\n\t\t\t\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t\t\t{ __( 'Learn more about anchors' ) }\n\t\t\t\t\t\t\t\t\t</ExternalLink>\n\t\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\t</>\n\t\t\t\t\t\t}\n\t\t\t\t\t\tvalue={ props.attributes.anchor || '' }\n\t\t\t\t\t\tplaceholder={ ! isWeb ? __( 'Add an anchor' ) : null }\n\t\t\t\t\t\tonChange={ ( nextValue ) => {\n\t\t\t\t\t\t\tnextValue = nextValue.replace( ANCHOR_REGEX, '-' );\n\t\t\t\t\t\t\tprops.setAttributes( {\n\t\t\t\t\t\t\t\tanchor: nextValue,\n\t\t\t\t\t\t\t} );\n\t\t\t\t\t\t} }\n\t\t\t\t\t\tautoCapitalize=\"none\"\n\t\t\t\t\t\tautoComplete=\"off\"\n\t\t\t\t\t/>\n\t\t\t\t);\n\n\t\t\t\treturn (\n\t\t\t\t\t<>\n\t\t\t\t\t\t<BlockEdit { ...props } />\n\t\t\t\t\t\t{ isWeb && (\n\t\t\t\t\t\t\t<InspectorControls group=\"advanced\">\n\t\t\t\t\t\t\t\t{ textControl }\n\t\t\t\t\t\t\t</InspectorControls>\n\t\t\t\t\t\t) }\n\t\t\t\t\t\t{ /*\n\t\t\t\t\t\t * We plan to remove scoping anchors to 'core/heading' to support\n\t\t\t\t\t\t * anchors for all eligble blocks. Additionally we plan to explore\n\t\t\t\t\t\t * leveraging InspectorAdvancedControls instead of a custom\n\t\t\t\t\t\t * PanelBody title. https://github.com/WordPress/gutenberg/issues/28363\n\t\t\t\t\t\t */ }\n\t\t\t\t\t\t{ ! isWeb && props.name === 'core/heading' && (\n\t\t\t\t\t\t\t<InspectorControls>\n\t\t\t\t\t\t\t\t<PanelBody title={ __( 'Heading settings' ) }>\n\t\t\t\t\t\t\t\t\t{ textControl }\n\t\t\t\t\t\t\t\t</PanelBody>\n\t\t\t\t\t\t\t</InspectorControls>\n\t\t\t\t\t\t) }\n\t\t\t\t\t</>\n\t\t\t\t);\n\t\t\t}\n\n\t\t\treturn <BlockEdit { ...props } />;\n\t\t};\n\t},\n\t'withInspectorControl'\n);\n\n/**\n * Override props assigned to save component to inject anchor ID, if block\n * supports anchor. This is only applied if the block's save result is an\n * element and not a markup string.\n *\n * @param {Object} extraProps Additional props applied to save element.\n * @param {Object} blockType Block type.\n * @param {Object} attributes Current block attributes.\n *\n * @return {Object} Filtered props applied to save element.\n */\nexport function addSaveProps( extraProps, blockType, attributes ) {\n\tif ( hasBlockSupport( blockType, 'anchor' ) ) {\n\t\textraProps.id = attributes.anchor === '' ? null : attributes.anchor;\n\t}\n\n\treturn extraProps;\n}\n\naddFilter( 'blocks.registerBlockType', 'core/anchor/attribute', addAttribute );\naddFilter(\n\t'editor.BlockEdit',\n\t'core/editor/anchor/with-inspector-control',\n\twithInspectorControl\n);\naddFilter(\n\t'blocks.getSaveContent.extraProps',\n\t'core/anchor/save-props',\n\taddSaveProps\n);\n"]}
1
+ {"version":3,"sources":["@wordpress/block-editor/src/hooks/anchor.js"],"names":["addFilter","PanelBody","TextControl","ExternalLink","__","hasBlockSupport","createHigherOrderComponent","Platform","InspectorControls","ANCHOR_REGEX","ANCHOR_SCHEMA","type","source","attribute","selector","addAttribute","settings","attributes","anchor","withInspectorControl","BlockEdit","props","hasAnchor","name","isSelected","isWeb","OS","textControl","nextValue","replace","setAttributes","addSaveProps","extraProps","blockType","id"],"mappings":";;AAAA;AACA;AACA;AACA,SAASA,SAAT,QAA0B,kBAA1B;AACA,SAASC,SAAT,EAAoBC,WAApB,EAAiCC,YAAjC,QAAqD,uBAArD;AACA,SAASC,EAAT,QAAmB,iBAAnB;AACA,SAASC,eAAT,QAAgC,mBAAhC;AACA,SAASC,0BAAT,QAA2C,oBAA3C;AACA,SAASC,QAAT,QAAyB,oBAAzB;AAEA;AACA;AACA;;AACA,SAASC,iBAAT,QAAkC,eAAlC;AAEA;AACA;AACA;AACA;AACA;;AACA,MAAMC,YAAY,GAAG,QAArB;AAEA,MAAMC,aAAa,GAAG;AACrBC,EAAAA,IAAI,EAAE,QADe;AAErBC,EAAAA,MAAM,EAAE,WAFa;AAGrBC,EAAAA,SAAS,EAAE,IAHU;AAIrBC,EAAAA,QAAQ,EAAE;AAJW,CAAtB;AAOA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AACA,OAAO,SAASC,YAAT,CAAuBC,QAAvB,EAAkC;AAAA;;AACxC;AACA,MAAK,4DAAYA,QAAQ,CAACC,UAArB,yDAAY,qBAAqBC,MAAjC,yEAA2C,EAA3C,CAAL,EAAuD;AACtD,WAAOF,QAAP;AACA;;AACD,MAAKX,eAAe,CAAEW,QAAF,EAAY,QAAZ,CAApB,EAA6C;AAC5C;AACAA,IAAAA,QAAQ,CAACC,UAAT,GAAsB,EACrB,GAAGD,QAAQ,CAACC,UADS;AAErBC,MAAAA,MAAM,EAAER;AAFa,KAAtB;AAIA;;AAED,SAAOM,QAAP;AACA;AAED;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AACA,OAAO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1B,IACD,cAAC,iBAAD,QACC,cAAC,SAAD;AAAW,QAAA,KAAK,EAAGnB,EAAE,CAAE,kBAAF;AAArB,SACGuB,WADH,CADD,CAdF,CADD;AAuBA;;AAED,WAAO,cAAC,SAAD,EAAgBN,KAAhB,CAAP;AACA,GAlED;AAmEA,CArE4D,EAsE7D,sBAtE6D,CAAvD;AAyEP;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AACA,OAAO,SAASU,YAAT,CAAuBC,UAAvB,EAAmCC,SAAnC,EAA8ChB,UAA9C,EAA2D;AACjE,MAAKZ,eAAe,CAAE4B,SAAF,EAAa,QAAb,CAApB,EAA8C;AAC7CD,IAAAA,UAAU,CAACE,EAAX,GAAgBjB,UAAU,CAACC,MAAX,KAAsB,EAAtB,GAA2B,IAA3B,GAAkCD,UAAU,CAACC,MAA7D;AACA;;AAED,SAAOc,UAAP;AACA;AAEDhC,SAAS,CAAE,0BAAF,EAA8B,uBAA9B,EAAuDe,YAAvD,CAAT;AACAf,SAAS,CACR,kBADQ,EAER,2CAFQ,EAGRmB,oBAHQ,CAAT;AAKAnB,SAAS,CACR,kCADQ,EAER,wBAFQ,EAGR+B,YAHQ,CAAT","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { addFilter } from '@wordpress/hooks';\nimport { PanelBody, TextControl, ExternalLink } from '@wordpress/components';\nimport { __ } from '@wordpress/i18n';\nimport { hasBlockSupport } from '@wordpress/blocks';\nimport { createHigherOrderComponent } from '@wordpress/compose';\nimport { Platform } from '@wordpress/element';\n\n/**\n * Internal dependencies\n */\nimport { InspectorControls } from '../components';\n\n/**\n * Regular expression matching invalid anchor characters for replacement.\n *\n * @type {RegExp}\n */\nconst ANCHOR_REGEX = /[\\s#]/g;\n\nconst ANCHOR_SCHEMA = {\n\ttype: 'string',\n\tsource: 'attribute',\n\tattribute: 'id',\n\tselector: '*',\n};\n\n/**\n * Filters registered block settings, extending attributes with anchor using ID\n * of the first node.\n *\n * @param {Object} settings Original block settings.\n *\n * @return {Object} Filtered block settings.\n */\nexport function addAttribute( settings ) {\n\t// Allow blocks to specify their own attribute definition with default values if needed.\n\tif ( 'type' in ( settings.attributes?.anchor ?? {} ) ) {\n\t\treturn settings;\n\t}\n\tif ( hasBlockSupport( settings, 'anchor' ) ) {\n\t\t// Gracefully handle if settings.attributes is undefined.\n\t\tsettings.attributes = {\n\t\t\t...settings.attributes,\n\t\t\tanchor: ANCHOR_SCHEMA,\n\t\t};\n\t}\n\n\treturn settings;\n}\n\n/**\n * Override the default edit UI to include a new block inspector control for\n * assigning the anchor ID, if block supports anchor.\n *\n * @param {WPComponent} BlockEdit Original component.\n *\n * @return {WPComponent} Wrapped component.\n */\nexport const withInspectorControl = createHigherOrderComponent(\n\t( BlockEdit ) => {\n\t\treturn ( props ) => {\n\t\t\tconst hasAnchor = hasBlockSupport( props.name, 'anchor' );\n\n\t\t\tif ( hasAnchor && props.isSelected ) {\n\t\t\t\tconst isWeb = Platform.OS === 'web';\n\t\t\t\tconst textControl = (\n\t\t\t\t\t<TextControl\n\t\t\t\t\t\t__nextHasNoMarginBottom\n\t\t\t\t\t\tclassName=\"html-anchor-control\"\n\t\t\t\t\t\tlabel={ __( 'HTML anchor' ) }\n\t\t\t\t\t\thelp={\n\t\t\t\t\t\t\t<>\n\t\t\t\t\t\t\t\t{ __(\n\t\t\t\t\t\t\t\t\t'Enter a word or two — without spaces — to make a unique web address just for this block, called an “anchor.” Then, you’ll be able to link directly to this section of your page.'\n\t\t\t\t\t\t\t\t) }\n\n\t\t\t\t\t\t\t\t{ isWeb && (\n\t\t\t\t\t\t\t\t\t<ExternalLink\n\t\t\t\t\t\t\t\t\t\thref={ __(\n\t\t\t\t\t\t\t\t\t\t\t'https://wordpress.org/documentation/article/page-jumps/'\n\t\t\t\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t\t\t{ __( 'Learn more about anchors' ) }\n\t\t\t\t\t\t\t\t\t</ExternalLink>\n\t\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\t</>\n\t\t\t\t\t\t}\n\t\t\t\t\t\tvalue={ props.attributes.anchor || '' }\n\t\t\t\t\t\tplaceholder={ ! isWeb ? __( 'Add an anchor' ) : null }\n\t\t\t\t\t\tonChange={ ( nextValue ) => {\n\t\t\t\t\t\t\tnextValue = nextValue.replace( ANCHOR_REGEX, '-' );\n\t\t\t\t\t\t\tprops.setAttributes( {\n\t\t\t\t\t\t\t\tanchor: nextValue,\n\t\t\t\t\t\t\t} );\n\t\t\t\t\t\t} }\n\t\t\t\t\t\tautoCapitalize=\"none\"\n\t\t\t\t\t\tautoComplete=\"off\"\n\t\t\t\t\t/>\n\t\t\t\t);\n\n\t\t\t\treturn (\n\t\t\t\t\t<>\n\t\t\t\t\t\t<BlockEdit { ...props } />\n\t\t\t\t\t\t{ isWeb && (\n\t\t\t\t\t\t\t<InspectorControls group=\"advanced\">\n\t\t\t\t\t\t\t\t{ textControl }\n\t\t\t\t\t\t\t</InspectorControls>\n\t\t\t\t\t\t) }\n\t\t\t\t\t\t{ /*\n\t\t\t\t\t\t * We plan to remove scoping anchors to 'core/heading' to support\n\t\t\t\t\t\t * anchors for all eligble blocks. Additionally we plan to explore\n\t\t\t\t\t\t * leveraging InspectorAdvancedControls instead of a custom\n\t\t\t\t\t\t * PanelBody title. https://github.com/WordPress/gutenberg/issues/28363\n\t\t\t\t\t\t */ }\n\t\t\t\t\t\t{ ! isWeb && props.name === 'core/heading' && (\n\t\t\t\t\t\t\t<InspectorControls>\n\t\t\t\t\t\t\t\t<PanelBody title={ __( 'Heading settings' ) }>\n\t\t\t\t\t\t\t\t\t{ textControl }\n\t\t\t\t\t\t\t\t</PanelBody>\n\t\t\t\t\t\t\t</InspectorControls>\n\t\t\t\t\t\t) }\n\t\t\t\t\t</>\n\t\t\t\t);\n\t\t\t}\n\n\t\t\treturn <BlockEdit { ...props } />;\n\t\t};\n\t},\n\t'withInspectorControl'\n);\n\n/**\n * Override props assigned to save component to inject anchor ID, if block\n * supports anchor. This is only applied if the block's save result is an\n * element and not a markup string.\n *\n * @param {Object} extraProps Additional props applied to save element.\n * @param {Object} blockType Block type.\n * @param {Object} attributes Current block attributes.\n *\n * @return {Object} Filtered props applied to save element.\n */\nexport function addSaveProps( extraProps, blockType, attributes ) {\n\tif ( hasBlockSupport( blockType, 'anchor' ) ) {\n\t\textraProps.id = attributes.anchor === '' ? null : attributes.anchor;\n\t}\n\n\treturn extraProps;\n}\n\naddFilter( 'blocks.registerBlockType', 'core/anchor/attribute', addAttribute );\naddFilter(\n\t'editor.BlockEdit',\n\t'core/editor/anchor/with-inspector-control',\n\twithInspectorControl\n);\naddFilter(\n\t'blocks.getSaveContent.extraProps',\n\t'core/anchor/save-props',\n\taddSaveProps\n);\n"]}
@@ -89,7 +89,7 @@ function styleToAttributes(style) {
89
89
  }
90
90
 
91
91
  const borderColorValue = style === null || style === void 0 ? void 0 : (_style$border = style.border) === null || _style$border === void 0 ? void 0 : _style$border.color;
92
- const borderColorSlug = borderColorValue !== null && borderColorValue !== void 0 && borderColorValue.startsWith('var:preset|color|') ? borderColorSlug.substring('var:preset|color|'.length) : undefined;
92
+ const borderColorSlug = borderColorValue !== null && borderColorValue !== void 0 && borderColorValue.startsWith('var:preset|color|') ? borderColorValue.substring('var:preset|color|'.length) : undefined;
93
93
  const updatedStyle = { ...style
94
94
  };
95
95
  updatedStyle.border = { ...updatedStyle.border,
@@ -1 +1 @@
1
- {"version":3,"sources":["@wordpress/block-editor/src/hooks/border.js"],"names":["classnames","getBlockSupport","__experimentalHasSplitBorders","hasSplitBorders","createHigherOrderComponent","Platform","useCallback","useMemo","addFilter","getColorClassName","InspectorControls","useMultipleOriginColorsAndGradients","cleanEmptyObject","shouldSkipSerialization","useBlockSettings","useHasBorderPanel","BorderPanel","StylesBorderPanel","BORDER_SUPPORT_KEY","getColorByProperty","colors","property","value","matchedColor","some","origin","color","getMultiOriginColor","namedColor","customColor","colorObject","undefined","getColorSlugFromVariable","exec","styleToAttributes","style","border","borderColor","borderColorValue","borderColorSlug","startsWith","substring","length","updatedStyle","attributesToStyle","attributes","BordersInspectorControl","children","resetAllFilter","attributesResetAllFilter","existingStyle","props","clientId","name","setAttributes","settings","isEnabled","onChange","newStyle","defaultControls","hasBorderSupport","blockName","feature","OS","support","radius","width","removeBorderAttribute","attribute","addAttributes","type","addSaveProps","blockType","borderClasses","getBorderClasses","newClassName","className","borderColorClass","addEditProps","existingGetEditWrapperProps","getEditWrapperProps","withBorderColorPaletteStyles","BlockListBlock","borderTopColor","top","borderRightColor","right","borderBottomColor","bottom","borderLeftColor","left","extraStyles","wrapperProps"],"mappings":";;;AAAA;AACA;AACA;AACA,OAAOA,UAAP,MAAuB,YAAvB;AAEA;AACA;AACA;;AACA,SAASC,eAAT,QAAgC,mBAAhC;AACA,SAASC,6BAA6B,IAAIC,eAA1C,QAAiE,uBAAjE;AACA,SAASC,0BAAT,QAA2C,oBAA3C;AACA,SAASC,QAAT,EAAmBC,WAAnB,EAAgCC,OAAhC,QAA+C,oBAA/C;AACA,SAASC,SAAT,QAA0B,kBAA1B;AAEA;AACA;AACA;;AACA,SAASC,iBAAT,QAAkC,sBAAlC;AACA,OAAOC,iBAAP,MAA8B,kCAA9B;AACA,OAAOC,mCAAP,MAAgD,yEAAhD;AACA,SACCC,gBADD,EAECC,uBAFD,EAGCC,gBAHD,QAIO,SAJP;AAKA,SACCC,iBADD,EAECC,WAAW,IAAIC,iBAFhB,QAGO,6BAHP;AAKA,OAAO,MAAMC,kBAAkB,GAAG,sBAA3B;;AAEP,MAAMC,kBAAkB,GAAG,CAAEC,MAAF,EAAUC,QAAV,EAAoBC,KAApB,KAA+B;AACzD,MAAIC,YAAJ;AAEAH,EAAAA,MAAM,CAACI,IAAP,CAAeC,MAAF,IACZA,MAAM,CAACL,MAAP,CAAcI,IAAd,CAAsBE,KAAF,IAAa;AAChC,QAAKA,KAAK,CAAEL,QAAF,CAAL,KAAsBC,KAA3B,EAAmC;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,IAAIjD,gBAHrB;AAInBmD,IAAAA,eAAe,EAAEA,eAAe,IAAInD;AAJjB,GAApB;AAOA,MAAIsD,YAAY,GAAGzC,KAAK,CAACyC,YAAzB;AACAA,EAAAA,YAAY,GAAG,EACd,GAAGzC,KAAK,CAACyC,YADK;AAEdzD,IAAAA,KAAK,EAAE,EACN,2BAAGgB,KAAK,CAACyC,YAAT,wDAAG,oBAAoBzD,KAAvB,CADM;AAEN,SAAGwD;AAFG;AAFO,GAAf;AAQA,SAAO,cAAC,cAAD,eAAqBxC,KAArB;AAA6B,IAAA,YAAY,EAAGyC;AAA5C,KAAP;AACA,CAtDoE,CAA/D;AAyDPpF,SAAS,CACR,0BADQ,EAER,2BAFQ,EAGR6D,aAHQ,CAAT;AAMA7D,SAAS,CACR,kCADQ,EAER,0BAFQ,EAGR+D,YAHQ,CAAT;AAMA/D,SAAS,CACR,0BADQ,EAER,0BAFQ,EAGRsE,YAHQ,CAAT;AAMAtE,SAAS,CACR,uBADQ,EAER,8CAFQ,EAGRyE,4BAHQ,CAAT","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\tsettings={ settings }\n\t\t\tvalue={ value }\n\t\t\tonChange={ onChange }\n\t\t\tdefaultControls={ defaultControls }\n\t\t/>\n\t);\n}\n\n/**\n * Determine whether there is block support for border properties.\n *\n * @param {string} blockName Block name.\n * @param {string} feature Border feature to check support for.\n *\n * @return {boolean} Whether there is support.\n */\nexport function hasBorderSupport( blockName, feature = 'any' ) {\n\tif ( Platform.OS !== 'web' ) {\n\t\treturn false;\n\t}\n\n\tconst support = getBlockSupport( blockName, BORDER_SUPPORT_KEY );\n\n\tif ( support === true ) {\n\t\treturn true;\n\t}\n\n\tif ( feature === 'any' ) {\n\t\treturn !! (\n\t\t\tsupport?.color ||\n\t\t\tsupport?.radius ||\n\t\t\tsupport?.width ||\n\t\t\tsupport?.style\n\t\t);\n\t}\n\n\treturn !! support?.[ feature ];\n}\n\n/**\n * Returns a new style object where the specified border attribute has been\n * removed.\n *\n * @param {Object} style Styles from block attributes.\n * @param {string} attribute The border style attribute to clear.\n *\n * @return {Object} Style object with the specified attribute removed.\n */\nexport function removeBorderAttribute( style, attribute ) {\n\treturn cleanEmptyObject( {\n\t\t...style,\n\t\tborder: {\n\t\t\t...style?.border,\n\t\t\t[ attribute ]: undefined,\n\t\t},\n\t} );\n}\n\n/**\n * Filters registered block settings, extending attributes to include\n * `borderColor` if needed.\n *\n * @param {Object} settings Original block settings.\n *\n * @return {Object} Updated block settings.\n */\nfunction addAttributes( settings ) {\n\tif ( ! hasBorderSupport( settings, 'color' ) ) {\n\t\treturn settings;\n\t}\n\n\t// Allow blocks to specify default value if needed.\n\tif ( settings.attributes.borderColor ) {\n\t\treturn settings;\n\t}\n\n\t// Add new borderColor attribute to block settings.\n\treturn {\n\t\t...settings,\n\t\tattributes: {\n\t\t\t...settings.attributes,\n\t\t\tborderColor: {\n\t\t\t\ttype: 'string',\n\t\t\t},\n\t\t},\n\t};\n}\n\n/**\n * Override props assigned to save component to inject border color.\n *\n * @param {Object} props Additional props applied to save element.\n * @param {Object} blockType Block type definition.\n * @param {Object} attributes Block's attributes.\n *\n * @return {Object} Filtered props to apply to save element.\n */\nfunction addSaveProps( props, blockType, attributes ) {\n\tif (\n\t\t! hasBorderSupport( blockType, 'color' ) ||\n\t\tshouldSkipSerialization( blockType, BORDER_SUPPORT_KEY, 'color' )\n\t) {\n\t\treturn props;\n\t}\n\n\tconst borderClasses = getBorderClasses( attributes );\n\tconst newClassName = classnames( props.className, borderClasses );\n\n\t// If we are clearing the last of the previous classes in `className`\n\t// set it to `undefined` to avoid rendering empty DOM attributes.\n\tprops.className = newClassName ? newClassName : undefined;\n\n\treturn props;\n}\n\n/**\n * Generates a CSS class name consisting of all the applicable border color\n * classes given the current block attributes.\n *\n * @param {Object} attributes Block's attributes.\n *\n * @return {string} CSS class name.\n */\nexport function getBorderClasses( attributes ) {\n\tconst { borderColor, style } = attributes;\n\tconst borderColorClass = getColorClassName( 'border-color', borderColor );\n\n\treturn classnames( {\n\t\t'has-border-color': borderColor || style?.border?.color,\n\t\t[ borderColorClass ]: !! borderColorClass,\n\t} );\n}\n\n/**\n * Filters the registered block settings to apply border color styles and\n * classnames to the block edit wrapper.\n *\n * @param {Object} settings Original block settings.\n *\n * @return {Object} Filtered block settings.\n */\nfunction addEditProps( settings ) {\n\tif (\n\t\t! hasBorderSupport( settings, 'color' ) ||\n\t\tshouldSkipSerialization( settings, BORDER_SUPPORT_KEY, 'color' )\n\t) {\n\t\treturn settings;\n\t}\n\n\tconst existingGetEditWrapperProps = settings.getEditWrapperProps;\n\tsettings.getEditWrapperProps = ( attributes ) => {\n\t\tlet props = {};\n\n\t\tif ( existingGetEditWrapperProps ) {\n\t\t\tprops = existingGetEditWrapperProps( attributes );\n\t\t}\n\n\t\treturn addSaveProps( props, settings, attributes );\n\t};\n\n\treturn settings;\n}\n\n/**\n * This adds inline styles for color palette colors.\n * Ideally, this is not needed and themes should load their palettes on the editor.\n *\n * @param {Function} BlockListBlock Original component.\n *\n * @return {Function} Wrapped component.\n */\nexport const withBorderColorPaletteStyles = createHigherOrderComponent(\n\t( BlockListBlock ) => ( props ) => {\n\t\tconst { name, attributes } = props;\n\t\tconst { borderColor, style } = attributes;\n\t\tconst { colors } = useMultipleOriginColorsAndGradients();\n\n\t\tif (\n\t\t\t! hasBorderSupport( name, 'color' ) ||\n\t\t\tshouldSkipSerialization( name, BORDER_SUPPORT_KEY, 'color' )\n\t\t) {\n\t\t\treturn <BlockListBlock { ...props } />;\n\t\t}\n\n\t\tconst { color: borderColorValue } = getMultiOriginColor( {\n\t\t\tcolors,\n\t\t\tnamedColor: borderColor,\n\t\t} );\n\t\tconst { color: borderTopColor } = getMultiOriginColor( {\n\t\t\tcolors,\n\t\t\tnamedColor: getColorSlugFromVariable( style?.border?.top?.color ),\n\t\t} );\n\t\tconst { color: borderRightColor } = getMultiOriginColor( {\n\t\t\tcolors,\n\t\t\tnamedColor: getColorSlugFromVariable( style?.border?.right?.color ),\n\t\t} );\n\n\t\tconst { color: borderBottomColor } = getMultiOriginColor( {\n\t\t\tcolors,\n\t\t\tnamedColor: getColorSlugFromVariable(\n\t\t\t\tstyle?.border?.bottom?.color\n\t\t\t),\n\t\t} );\n\t\tconst { color: borderLeftColor } = getMultiOriginColor( {\n\t\t\tcolors,\n\t\t\tnamedColor: getColorSlugFromVariable( style?.border?.left?.color ),\n\t\t} );\n\n\t\tconst extraStyles = {\n\t\t\tborderTopColor: borderTopColor || borderColorValue,\n\t\t\tborderRightColor: borderRightColor || borderColorValue,\n\t\t\tborderBottomColor: borderBottomColor || borderColorValue,\n\t\t\tborderLeftColor: borderLeftColor || borderColorValue,\n\t\t};\n\n\t\tlet wrapperProps = props.wrapperProps;\n\t\twrapperProps = {\n\t\t\t...props.wrapperProps,\n\t\t\tstyle: {\n\t\t\t\t...props.wrapperProps?.style,\n\t\t\t\t...extraStyles,\n\t\t\t},\n\t\t};\n\n\t\treturn <BlockListBlock { ...props } wrapperProps={ wrapperProps } />;\n\t}\n);\n\naddFilter(\n\t'blocks.registerBlockType',\n\t'core/border/addAttributes',\n\taddAttributes\n);\n\naddFilter(\n\t'blocks.getSaveContent.extraProps',\n\t'core/border/addSaveProps',\n\taddSaveProps\n);\n\naddFilter(\n\t'blocks.registerBlockType',\n\t'core/border/addEditProps',\n\taddEditProps\n);\n\naddFilter(\n\t'editor.BlockListBlock',\n\t'core/border/with-border-color-palette-styles',\n\twithBorderColorPaletteStyles\n);\n"]}
1
+ {"version":3,"sources":["@wordpress/block-editor/src/hooks/border.js"],"names":["classnames","getBlockSupport","__experimentalHasSplitBorders","hasSplitBorders","createHigherOrderComponent","Platform","useCallback","useMemo","addFilter","getColorClassName","InspectorControls","useMultipleOriginColorsAndGradients","cleanEmptyObject","shouldSkipSerialization","useBlockSettings","useHasBorderPanel","BorderPanel","StylesBorderPanel","BORDER_SUPPORT_KEY","getColorByProperty","colors","property","value","matchedColor","some","origin","color","getMultiOriginColor","namedColor","customColor","colorObject","undefined","getColorSlugFromVariable","exec","styleToAttributes","style","border","borderColor","borderColorValue","borderColorSlug","startsWith","substring","length","updatedStyle","attributesToStyle","attributes","BordersInspectorControl","children","resetAllFilter","attributesResetAllFilter","existingStyle","props","clientId","name","setAttributes","settings","isEnabled","onChange","newStyle","defaultControls","hasBorderSupport","blockName","feature","OS","support","radius","width","removeBorderAttribute","attribute","addAttributes","type","addSaveProps","blockType","borderClasses","getBorderClasses","newClassName","className","borderColorClass","addEditProps","existingGetEditWrapperProps","getEditWrapperProps","withBorderColorPaletteStyles","BlockListBlock","borderTopColor","top","borderRightColor","right","borderBottomColor","bottom","borderLeftColor","left","extraStyles","wrapperProps"],"mappings":";;;AAAA;AACA;AACA;AACA,OAAOA,UAAP,MAAuB,YAAvB;AAEA;AACA;AACA;;AACA,SAASC,eAAT,QAAgC,mBAAhC;AACA,SAASC,6BAA6B,IAAIC,eAA1C,QAAiE,uBAAjE;AACA,SAASC,0BAAT,QAA2C,oBAA3C;AACA,SAASC,QAAT,EAAmBC,WAAnB,EAAgCC,OAAhC,QAA+C,oBAA/C;AACA,SAASC,SAAT,QAA0B,kBAA1B;AAEA;AACA;AACA;;AACA,SAASC,iBAAT,QAAkC,sBAAlC;AACA,OAAOC,iBAAP,MAA8B,kCAA9B;AACA,OAAOC,mCAAP,MAAgD,yEAAhD;AACA,SACCC,gBADD,EAECC,uBAFD,EAGCC,gBAHD,QAIO,SAJP;AAKA,SACCC,iBADD,EAEC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AAAA,MADuD;AAEvDQ,IAAAA,UAAU,EAAEI,wBAAwB,CAAEG,KAAF,aAAEA,KAAF,yCAAEA,KAAK,CAAEC,MAAT,0EAAE,eAAesD,IAAjB,wDAAE,oBAAqBhE,KAAvB;AAFmB,GAAF,CAAtD;AAKA,QAAMiE,WAAW,GAAG;AACnBR,IAAAA,cAAc,EAAEA,cAAc,IAAI7C,gBADf;AAEnB+C,IAAAA,gBAAgB,EAAEA,gBAAgB,IAAI/C,gBAFnB;AAGnBiD,IAAAA,iBAAiB,EAAEA,iBAAiB,IAAIjD,gBAHrB;AAInBmD,IAAAA,eAAe,EAAEA,eAAe,IAAInD;AAJjB,GAApB;AAOA,MAAIsD,YAAY,GAAGzC,KAAK,CAACyC,YAAzB;AACAA,EAAAA,YAAY,GAAG,EACd,GAAGzC,KAAK,CAACyC,YADK;AAEdzD,IAAAA,KAAK,EAAE,EACN,2BAAGgB,KAAK,CAACyC,YAAT,wDAAG,oBAAoBzD,KAAvB,CADM;AAEN,SAAGwD;AAFG;AAFO,GAAf;AAQA,SAAO,cAAC,cAAD,eAAqBxC,KAArB;AAA6B,IAAA,YAAY,EAAGyC;AAA5C,KAAP;AACA,CAtDoE,CAA/D;AAyDPpF,SAAS,CACR,0BADQ,EAER,2BAFQ,EAGR6D,aAHQ,CAAT;AAMA7D,SAAS,CACR,kCADQ,EAER,0BAFQ,EAGR+D,YAHQ,CAAT;AAMA/D,SAAS,CACR,0BADQ,EAER,0BAFQ,EAGRsE,YAHQ,CAAT;AAMAtE,SAAS,CACR,uBADQ,EAER,8CAFQ,EAGRyE,4BAHQ,CAAT","sourcesContent":["/**\n * External dependencies\n */\nimport classnames from 'classnames';\n\n/**\n * WordPress dependencies\n */\nimport { getBlockSupport } from '@wordpress/blocks';\nimport { __experimentalHasSplitBorders as hasSplitBorders } from '@wordpress/components';\nimport { createHigherOrderComponent } from '@wordpress/compose';\nimport { Platform, useCallback, useMemo } from '@wordpress/element';\nimport { addFilter } from '@wordpress/hooks';\n\n/**\n * Internal dependencies\n */\nimport { getColorClassName } from '../components/colors';\nimport InspectorControls from '../components/inspector-controls';\nimport useMultipleOriginColorsAndGradients from '../components/colors-gradients/use-multiple-origin-colors-and-gradients';\nimport {\n\tcleanEmptyObject,\n\tshouldSkipSerialization,\n\tuseBlockSettings,\n} from './utils';\nimport {\n\tuseHasBorderPanel,\n\tBorderPanel as StylesBorderPanel,\n} from '../components/global-styles';\n\nexport const BORDER_SUPPORT_KEY = '__experimentalBorder';\n\nconst getColorByProperty = ( colors, property, value ) => {\n\tlet matchedColor;\n\n\tcolors.some( ( origin ) =>\n\t\torigin.colors.some( ( color ) => {\n\t\t\tif ( color[ property ] === value ) {\n\t\t\t\tmatchedColor = color;\n\t\t\t\treturn true;\n\t\t\t}\n\n\t\t\treturn false;\n\t\t} )\n\t);\n\n\treturn matchedColor;\n};\n\nexport const getMultiOriginColor = ( { colors, namedColor, customColor } ) => {\n\t// Search each origin (default, theme, or user) for matching color by name.\n\tif ( namedColor ) {\n\t\tconst colorObject = getColorByProperty( colors, 'slug', namedColor );\n\t\tif ( colorObject ) {\n\t\t\treturn colorObject;\n\t\t}\n\t}\n\n\t// Skip if no custom color or matching named color.\n\tif ( ! customColor ) {\n\t\treturn { color: undefined };\n\t}\n\n\t// Attempt to find color via custom color value or build new object.\n\tconst colorObject = getColorByProperty( colors, 'color', customColor );\n\treturn colorObject ? colorObject : { color: customColor };\n};\n\nfunction getColorSlugFromVariable( value ) {\n\tconst namedColor = /var:preset\\|color\\|(.+)/.exec( value );\n\tif ( namedColor && namedColor[ 1 ] ) {\n\t\treturn namedColor[ 1 ];\n\t}\n\treturn null;\n}\n\nfunction styleToAttributes( style ) {\n\tif ( hasSplitBorders( style?.border ) ) {\n\t\treturn {\n\t\t\tstyle,\n\t\t\tborderColor: undefined,\n\t\t};\n\t}\n\n\tconst borderColorValue = style?.border?.color;\n\tconst borderColorSlug = borderColorValue?.startsWith( 'var:preset|color|' )\n\t\t? borderColorValue.substring( 'var:preset|color|'.length )\n\t\t: undefined;\n\tconst updatedStyle = { ...style };\n\tupdatedStyle.border = {\n\t\t...updatedStyle.border,\n\t\tcolor: borderColorSlug ? undefined : borderColorValue,\n\t};\n\treturn {\n\t\tstyle: cleanEmptyObject( updatedStyle ),\n\t\tborderColor: borderColorSlug,\n\t};\n}\n\nfunction attributesToStyle( attributes ) {\n\tif ( hasSplitBorders( attributes.style?.border ) ) {\n\t\treturn attributes.style;\n\t}\n\treturn {\n\t\t...attributes.style,\n\t\tborder: {\n\t\t\t...attributes.style?.border,\n\t\t\tcolor: attributes.borderColor\n\t\t\t\t? 'var:preset|color|' + attributes.borderColor\n\t\t\t\t: attributes.style?.border?.color,\n\t\t},\n\t};\n}\n\nfunction BordersInspectorControl( { children, resetAllFilter } ) {\n\tconst attributesResetAllFilter = useCallback(\n\t\t( attributes ) => {\n\t\t\tconst existingStyle = attributesToStyle( attributes );\n\t\t\tconst updatedStyle = resetAllFilter( existingStyle );\n\t\t\treturn {\n\t\t\t\t...attributes,\n\t\t\t\t...styleToAttributes( updatedStyle ),\n\t\t\t};\n\t\t},\n\t\t[ resetAllFilter ]\n\t);\n\n\treturn (\n\t\t<InspectorControls\n\t\t\tgroup=\"border\"\n\t\t\tresetAllFilter={ attributesResetAllFilter }\n\t\t>\n\t\t\t{ children }\n\t\t</InspectorControls>\n\t);\n}\n\nexport function BorderPanel( props ) {\n\tconst { clientId, name, attributes, setAttributes } = props;\n\tconst settings = useBlockSettings( name );\n\tconst isEnabled = useHasBorderPanel( settings );\n\tconst value = useMemo( () => {\n\t\treturn attributesToStyle( {\n\t\t\tstyle: attributes.style,\n\t\t\tborderColor: attributes.borderColor,\n\t\t} );\n\t}, [ attributes.style, attributes.borderColor ] );\n\n\tconst onChange = ( newStyle ) => {\n\t\tsetAttributes( styleToAttributes( newStyle ) );\n\t};\n\n\tif ( ! isEnabled ) {\n\t\treturn null;\n\t}\n\n\tconst defaultControls = getBlockSupport( props.name, [\n\t\tBORDER_SUPPORT_KEY,\n\t\t'__experimentalDefaultControls',\n\t] );\n\n\treturn (\n\t\t<StylesBorderPanel\n\t\t\tas={ BordersInspectorControl }\n\t\t\tpanelId={ clientId }\n\t\t\tsettings={ settings }\n\t\t\tvalue={ value }\n\t\t\tonChange={ onChange }\n\t\t\tdefaultControls={ defaultControls }\n\t\t/>\n\t);\n}\n\n/**\n * Determine whether there is block support for border properties.\n *\n * @param {string} blockName Block name.\n * @param {string} feature Border feature to check support for.\n *\n * @return {boolean} Whether there is support.\n */\nexport function hasBorderSupport( blockName, feature = 'any' ) {\n\tif ( Platform.OS !== 'web' ) {\n\t\treturn false;\n\t}\n\n\tconst support = getBlockSupport( blockName, BORDER_SUPPORT_KEY );\n\n\tif ( support === true ) {\n\t\treturn true;\n\t}\n\n\tif ( feature === 'any' ) {\n\t\treturn !! (\n\t\t\tsupport?.color ||\n\t\t\tsupport?.radius ||\n\t\t\tsupport?.width ||\n\t\t\tsupport?.style\n\t\t);\n\t}\n\n\treturn !! support?.[ feature ];\n}\n\n/**\n * Returns a new style object where the specified border attribute has been\n * removed.\n *\n * @param {Object} style Styles from block attributes.\n * @param {string} attribute The border style attribute to clear.\n *\n * @return {Object} Style object with the specified attribute removed.\n */\nexport function removeBorderAttribute( style, attribute ) {\n\treturn cleanEmptyObject( {\n\t\t...style,\n\t\tborder: {\n\t\t\t...style?.border,\n\t\t\t[ attribute ]: undefined,\n\t\t},\n\t} );\n}\n\n/**\n * Filters registered block settings, extending attributes to include\n * `borderColor` if needed.\n *\n * @param {Object} settings Original block settings.\n *\n * @return {Object} Updated block settings.\n */\nfunction addAttributes( settings ) {\n\tif ( ! hasBorderSupport( settings, 'color' ) ) {\n\t\treturn settings;\n\t}\n\n\t// Allow blocks to specify default value if needed.\n\tif ( settings.attributes.borderColor ) {\n\t\treturn settings;\n\t}\n\n\t// Add new borderColor attribute to block settings.\n\treturn {\n\t\t...settings,\n\t\tattributes: {\n\t\t\t...settings.attributes,\n\t\t\tborderColor: {\n\t\t\t\ttype: 'string',\n\t\t\t},\n\t\t},\n\t};\n}\n\n/**\n * Override props assigned to save component to inject border color.\n *\n * @param {Object} props Additional props applied to save element.\n * @param {Object} blockType Block type definition.\n * @param {Object} attributes Block's attributes.\n *\n * @return {Object} Filtered props to apply to save element.\n */\nfunction addSaveProps( props, blockType, attributes ) {\n\tif (\n\t\t! hasBorderSupport( blockType, 'color' ) ||\n\t\tshouldSkipSerialization( blockType, BORDER_SUPPORT_KEY, 'color' )\n\t) {\n\t\treturn props;\n\t}\n\n\tconst borderClasses = getBorderClasses( attributes );\n\tconst newClassName = classnames( props.className, borderClasses );\n\n\t// If we are clearing the last of the previous classes in `className`\n\t// set it to `undefined` to avoid rendering empty DOM attributes.\n\tprops.className = newClassName ? newClassName : undefined;\n\n\treturn props;\n}\n\n/**\n * Generates a CSS class name consisting of all the applicable border color\n * classes given the current block attributes.\n *\n * @param {Object} attributes Block's attributes.\n *\n * @return {string} CSS class name.\n */\nexport function getBorderClasses( attributes ) {\n\tconst { borderColor, style } = attributes;\n\tconst borderColorClass = getColorClassName( 'border-color', borderColor );\n\n\treturn classnames( {\n\t\t'has-border-color': borderColor || style?.border?.color,\n\t\t[ borderColorClass ]: !! borderColorClass,\n\t} );\n}\n\n/**\n * Filters the registered block settings to apply border color styles and\n * classnames to the block edit wrapper.\n *\n * @param {Object} settings Original block settings.\n *\n * @return {Object} Filtered block settings.\n */\nfunction addEditProps( settings ) {\n\tif (\n\t\t! hasBorderSupport( settings, 'color' ) ||\n\t\tshouldSkipSerialization( settings, BORDER_SUPPORT_KEY, 'color' )\n\t) {\n\t\treturn settings;\n\t}\n\n\tconst existingGetEditWrapperProps = settings.getEditWrapperProps;\n\tsettings.getEditWrapperProps = ( attributes ) => {\n\t\tlet props = {};\n\n\t\tif ( existingGetEditWrapperProps ) {\n\t\t\tprops = existingGetEditWrapperProps( attributes );\n\t\t}\n\n\t\treturn addSaveProps( props, settings, attributes );\n\t};\n\n\treturn settings;\n}\n\n/**\n * This adds inline styles for color palette colors.\n * Ideally, this is not needed and themes should load their palettes on the editor.\n *\n * @param {Function} BlockListBlock Original component.\n *\n * @return {Function} Wrapped component.\n */\nexport const withBorderColorPaletteStyles = createHigherOrderComponent(\n\t( BlockListBlock ) => ( props ) => {\n\t\tconst { name, attributes } = props;\n\t\tconst { borderColor, style } = attributes;\n\t\tconst { colors } = useMultipleOriginColorsAndGradients();\n\n\t\tif (\n\t\t\t! hasBorderSupport( name, 'color' ) ||\n\t\t\tshouldSkipSerialization( name, BORDER_SUPPORT_KEY, 'color' )\n\t\t) {\n\t\t\treturn <BlockListBlock { ...props } />;\n\t\t}\n\n\t\tconst { color: borderColorValue } = getMultiOriginColor( {\n\t\t\tcolors,\n\t\t\tnamedColor: borderColor,\n\t\t} );\n\t\tconst { color: borderTopColor } = getMultiOriginColor( {\n\t\t\tcolors,\n\t\t\tnamedColor: getColorSlugFromVariable( style?.border?.top?.color ),\n\t\t} );\n\t\tconst { color: borderRightColor } = getMultiOriginColor( {\n\t\t\tcolors,\n\t\t\tnamedColor: getColorSlugFromVariable( style?.border?.right?.color ),\n\t\t} );\n\n\t\tconst { color: borderBottomColor } = getMultiOriginColor( {\n\t\t\tcolors,\n\t\t\tnamedColor: getColorSlugFromVariable(\n\t\t\t\tstyle?.border?.bottom?.color\n\t\t\t),\n\t\t} );\n\t\tconst { color: borderLeftColor } = getMultiOriginColor( {\n\t\t\tcolors,\n\t\t\tnamedColor: getColorSlugFromVariable( style?.border?.left?.color ),\n\t\t} );\n\n\t\tconst extraStyles = {\n\t\t\tborderTopColor: borderTopColor || borderColorValue,\n\t\t\tborderRightColor: borderRightColor || borderColorValue,\n\t\t\tborderBottomColor: borderBottomColor || borderColorValue,\n\t\t\tborderLeftColor: borderLeftColor || borderColorValue,\n\t\t};\n\n\t\tlet wrapperProps = props.wrapperProps;\n\t\twrapperProps = {\n\t\t\t...props.wrapperProps,\n\t\t\tstyle: {\n\t\t\t\t...props.wrapperProps?.style,\n\t\t\t\t...extraStyles,\n\t\t\t},\n\t\t};\n\n\t\treturn <BlockListBlock { ...props } wrapperProps={ wrapperProps } />;\n\t}\n);\n\naddFilter(\n\t'blocks.registerBlockType',\n\t'core/border/addAttributes',\n\taddAttributes\n);\n\naddFilter(\n\t'blocks.getSaveContent.extraProps',\n\t'core/border/addSaveProps',\n\taddSaveProps\n);\n\naddFilter(\n\t'blocks.registerBlockType',\n\t'core/border/addEditProps',\n\taddEditProps\n);\n\naddFilter(\n\t'editor.BlockListBlock',\n\t'core/border/with-border-color-palette-styles',\n\twithBorderColorPaletteStyles\n);\n"]}
@@ -20,10 +20,14 @@ import { useSelect } from '@wordpress/data';
20
20
  * Internal dependencies
21
21
  */
22
22
 
23
- import { BlockControls, __experimentalDuotoneControl as DuotoneControl, useSetting } from '../components';
23
+ import { BlockControls, InspectorControls, __experimentalDuotoneControl as DuotoneControl, useSetting } from '../components';
24
24
  import BlockList from '../components/block-list';
25
25
  import { __unstableDuotoneFilter as DuotoneFilter, __unstableDuotoneStylesheet as DuotoneStylesheet, __unstableDuotoneUnsetStylesheet as DuotoneUnsetStylesheet } from '../components/duotone';
26
+ import { getBlockCSSSelector } from '../components/global-styles/get-block-css-selector';
27
+ import { scopeSelector } from '../components/global-styles/utils';
28
+ import { useBlockSettings } from './utils';
26
29
  import { store as blockEditorStore } from '../store';
30
+ import { default as StylesFiltersPanel } from '../components/global-styles/filters-panel';
27
31
  const EMPTY_ARRAY = [];
28
32
  extend([namesPlugin]);
29
33
  /**
@@ -102,10 +106,12 @@ function DuotonePanel(_ref4) {
102
106
 
103
107
  let {
104
108
  attributes,
105
- setAttributes
109
+ setAttributes,
110
+ name
106
111
  } = _ref4;
107
112
  const style = attributes === null || attributes === void 0 ? void 0 : attributes.style;
108
113
  const duotoneStyle = style === null || style === void 0 ? void 0 : (_style$color = style.color) === null || _style$color === void 0 ? void 0 : _style$color.duotone;
114
+ const settings = useBlockSettings(name);
109
115
  const duotonePalette = useMultiOriginPresets({
110
116
  presetSetting: 'color.duotone',
111
117
  defaultSetting: 'color.defaultDuotone'
@@ -122,7 +128,25 @@ function DuotonePanel(_ref4) {
122
128
  }
123
129
 
124
130
  const duotonePresetOrColors = !Array.isArray(duotoneStyle) ? getColorsFromDuotonePreset(duotoneStyle, duotonePalette) : duotoneStyle;
125
- return createElement(BlockControls, {
131
+ return createElement(Fragment, null, createElement(InspectorControls, {
132
+ group: "filter"
133
+ }, createElement(StylesFiltersPanel, {
134
+ value: {
135
+ filter: {
136
+ duotone: duotonePresetOrColors
137
+ }
138
+ },
139
+ onChange: newDuotone => {
140
+ const newStyle = {
141
+ color: { ...(newDuotone === null || newDuotone === void 0 ? void 0 : newDuotone.filter)
142
+ }
143
+ };
144
+ setAttributes({
145
+ style: newStyle
146
+ });
147
+ },
148
+ settings: settings
149
+ })), createElement(BlockControls, {
126
150
  group: "block",
127
151
  __experimentalShareWithChildBlocks: true
128
152
  }, createElement(DuotoneControl, {
@@ -142,8 +166,9 @@ function DuotonePanel(_ref4) {
142
166
  setAttributes({
143
167
  style: newStyle
144
168
  });
145
- }
146
- }));
169
+ },
170
+ settings: settings
171
+ })));
147
172
  }
148
173
  /**
149
174
  * Filters registered block settings, extending attributes to include
@@ -156,7 +181,9 @@ function DuotonePanel(_ref4) {
156
181
 
157
182
 
158
183
  function addDuotoneAttributes(settings) {
159
- if (!hasBlockSupport(settings, 'color.__experimentalDuotone')) {
184
+ // Previous `color.__experimentalDuotone` support flag is migrated via
185
+ // block_type_metadata_settings filter in `lib/block-supports/duotone.php`.
186
+ if (!hasBlockSupport(settings, 'filter.duotone')) {
160
187
  return settings;
161
188
  } // Allow blocks to specify their own attribute definition with default
162
189
  // values if needed.
@@ -183,7 +210,9 @@ function addDuotoneAttributes(settings) {
183
210
 
184
211
 
185
212
  const withDuotoneControls = createHigherOrderComponent(BlockEdit => props => {
186
- const hasDuotoneSupport = hasBlockSupport(props.name, 'color.__experimentalDuotone');
213
+ // Previous `color.__experimentalDuotone` support flag is migrated via
214
+ // block_type_metadata_settings filter in `lib/block-supports/duotone.php`.
215
+ const hasDuotoneSupport = hasBlockSupport(props.name, 'filter.duotone');
187
216
  const isContentLocked = useSelect(select => {
188
217
  return select(blockEditorStore).__unstableGetContentLockingParent(props.clientId);
189
218
  }, [props.clientId]); // CAUTION: code added before this line will be executed
@@ -193,69 +222,56 @@ const withDuotoneControls = createHigherOrderComponent(BlockEdit => props => {
193
222
 
194
223
  return createElement(Fragment, null, hasDuotoneSupport && !isContentLocked && createElement(DuotonePanel, props), createElement(BlockEdit, props));
195
224
  }, 'withDuotoneControls');
196
- /**
197
- * Function that scopes a selector with another one. This works a bit like
198
- * SCSS nesting except the `&` operator isn't supported.
199
- *
200
- * @example
201
- * ```js
202
- * const scope = '.a, .b .c';
203
- * const selector = '> .x, .y';
204
- * const merged = scopeSelector( scope, selector );
205
- * // merged is '.a > .x, .a .y, .b .c > .x, .b .c .y'
206
- * ```
207
- *
208
- * @param {string} scope Selector to scope to.
209
- * @param {string} selector Original selector.
210
- *
211
- * @return {string} Scoped selector.
212
- */
213
-
214
- function scopeSelector(scope, selector) {
215
- const scopes = scope.split(',');
216
- const selectors = selector.split(',');
217
- const selectorsScoped = [];
218
- scopes.forEach(outer => {
219
- selectors.forEach(inner => {
220
- selectorsScoped.push(`${outer.trim()} ${inner.trim()}`);
221
- });
222
- });
223
- return selectorsScoped.join(', ');
224
- }
225
-
226
- function BlockDuotoneStyles(_ref5) {
227
- var _getBlockType$selecto, _getBlockType$selecto2;
228
225
 
226
+ function DuotoneStyles(_ref5) {
229
227
  let {
230
- name,
231
- duotoneStyle,
232
- id
228
+ id: filterId,
229
+ selector: duotoneSelector,
230
+ attribute: duotoneAttr
233
231
  } = _ref5;
232
+ const element = useContext(BlockList.__unstableElementContext);
234
233
  const duotonePalette = useMultiOriginPresets({
235
234
  presetSetting: 'color.duotone',
236
235
  defaultSetting: 'color.defaultDuotone'
236
+ }); // Possible values for duotone attribute:
237
+ // 1. Array of colors - e.g. ['#000000', '#ffffff'].
238
+ // 2. Variable for an existing Duotone preset - e.g. 'var:preset|duotone|green-blue' or 'var(--wp--preset--duotone--green-blue)''
239
+ // 3. A CSS string - e.g. 'unset' to remove globally applied duotone.
240
+
241
+ const isCustom = Array.isArray(duotoneAttr);
242
+ const duotonePreset = isCustom ? undefined : getColorsFromDuotonePreset(duotoneAttr, duotonePalette);
243
+ const isPreset = typeof duotoneAttr === 'string' && duotonePreset;
244
+ const isCSS = typeof duotoneAttr === 'string' && !isPreset; // Match the structure of WP_Duotone_Gutenberg::render_duotone_support() in PHP.
245
+
246
+ let colors = null;
247
+
248
+ if (isPreset) {
249
+ // Array of colors.
250
+ colors = duotonePreset;
251
+ } else if (isCSS) {
252
+ // CSS filter property string (e.g. 'unset').
253
+ colors = duotoneAttr;
254
+ } else if (isCustom) {
255
+ // Array of colors.
256
+ colors = duotoneAttr;
257
+ } // Build the CSS selectors to which the filter will be applied.
258
+
259
+
260
+ const selectors = duotoneSelector.split(',');
261
+ const selectorsScoped = selectors.map(selectorPart => {
262
+ // Extra .editor-styles-wrapper specificity is needed in the editor
263
+ // since we're not using inline styles to apply the filter. We need to
264
+ // override duotone applied by global styles and theme.json.
265
+ // Assuming the selector part is a subclass selector (not a tag name)
266
+ // so we can prepend the filter id class. If we want to support elements
267
+ // such as `img` or namespaces, we'll need to add a case for that here.
268
+ return `.editor-styles-wrapper .${filterId}${selectorPart.trim()}`;
237
269
  });
238
- const element = useContext(BlockList.__unstableElementContext); // Portals cannot exist without a container.
239
- // Guard against empty Duotone styles.
240
-
241
- if (!element || !duotoneStyle) {
242
- return null;
243
- }
244
-
245
- let colors = duotoneStyle;
246
-
247
- if (!Array.isArray(colors) && colors !== 'unset') {
248
- colors = getColorsFromDuotonePreset(colors, duotonePalette);
249
- }
250
-
251
- const duotoneSupportSelectors = ((_getBlockType$selecto = getBlockType(name).selectors) === null || _getBlockType$selecto === void 0 ? void 0 : (_getBlockType$selecto2 = _getBlockType$selecto.filter) === null || _getBlockType$selecto2 === void 0 ? void 0 : _getBlockType$selecto2.duotone) || getBlockSupport(name, 'color.__experimentalDuotone'); // Extra .editor-styles-wrapper specificity is needed in the editor
252
- // since we're not using inline styles to apply the filter. We need to
253
- // override duotone applied by global styles and theme.json.
254
-
255
- const selectorsGroup = scopeSelector(`.editor-styles-wrapper .${id}`, duotoneSupportSelectors);
256
- return createPortal(createElement(InlineDuotone, {
257
- selector: selectorsGroup,
258
- id: id,
270
+ const selector = selectorsScoped.join(', ');
271
+ const isValidFilter = Array.isArray(colors) || colors === 'unset';
272
+ return element && isValidFilter && createPortal(createElement(InlineDuotone, {
273
+ selector: selector,
274
+ id: filterId,
259
275
  colors: colors
260
276
  }), element);
261
277
  }
@@ -271,18 +287,49 @@ function BlockDuotoneStyles(_ref5) {
271
287
  const withDuotoneStyles = createHigherOrderComponent(BlockListBlock => props => {
272
288
  var _props$attributes, _props$attributes$sty, _props$attributes$sty2;
273
289
 
274
- const duotoneSupport = getBlockSupport(props.name, 'color.__experimentalDuotone');
275
- const id = `wp-duotone-${useInstanceId(BlockListBlock)}`;
276
- const className = duotoneSupport ? classnames(props === null || props === void 0 ? void 0 : props.className, id) : props === null || props === void 0 ? void 0 : props.className;
277
- const duotoneStyle = props === null || props === void 0 ? void 0 : (_props$attributes = props.attributes) === null || _props$attributes === void 0 ? void 0 : (_props$attributes$sty = _props$attributes.style) === null || _props$attributes$sty === void 0 ? void 0 : (_props$attributes$sty2 = _props$attributes$sty.color) === null || _props$attributes$sty2 === void 0 ? void 0 : _props$attributes$sty2.duotone; // CAUTION: code added before this line will be executed
290
+ const id = useInstanceId(BlockListBlock);
291
+ const selector = useMemo(() => {
292
+ const blockType = getBlockType(props.name);
293
+
294
+ if (blockType) {
295
+ // Backwards compatibility for `supports.color.__experimentalDuotone`
296
+ // is provided via the `block_type_metadata_settings` filter. If
297
+ // `supports.filter.duotone` has not been set and the
298
+ // experimental property has been, the experimental property
299
+ // value is copied into `supports.filter.duotone`.
300
+ const duotoneSupport = getBlockSupport(blockType, 'filter.duotone', false);
301
+
302
+ if (!duotoneSupport) {
303
+ return null;
304
+ } // If the experimental duotone support was set, that value is
305
+ // to be treated as a selector and requires scoping.
306
+
307
+
308
+ const experimentalDuotone = getBlockSupport(blockType, 'color.__experimentalDuotone', false);
309
+
310
+ if (experimentalDuotone) {
311
+ const rootSelector = getBlockCSSSelector(blockType);
312
+ return typeof experimentalDuotone === 'string' ? scopeSelector(rootSelector, experimentalDuotone) : rootSelector;
313
+ } // Regular filter.duotone support uses filter.duotone selectors with fallbacks.
314
+
315
+
316
+ return getBlockCSSSelector(blockType, 'filter.duotone', {
317
+ fallback: true
318
+ });
319
+ }
320
+ }, [props.name]);
321
+ const attribute = props === null || props === void 0 ? void 0 : (_props$attributes = props.attributes) === null || _props$attributes === void 0 ? void 0 : (_props$attributes$sty = _props$attributes.style) === null || _props$attributes$sty === void 0 ? void 0 : (_props$attributes$sty2 = _props$attributes$sty.color) === null || _props$attributes$sty2 === void 0 ? void 0 : _props$attributes$sty2.duotone;
322
+ const filterClass = `wp-duotone-${id}`;
323
+ const shouldRender = selector && attribute;
324
+ const className = shouldRender ? classnames(props === null || props === void 0 ? void 0 : props.className, filterClass) : props === null || props === void 0 ? void 0 : props.className; // CAUTION: code added before this line will be executed
278
325
  // for all blocks, not just those that support duotone. Code added
279
326
  // above this line should be carefully evaluated for its impact on
280
327
  // performance.
281
328
 
282
- return createElement(Fragment, null, duotoneSupport && duotoneStyle && createElement(BlockDuotoneStyles, {
283
- name: props === null || props === void 0 ? void 0 : props.name,
284
- duotoneStyle: duotoneStyle,
285
- id: id
329
+ return createElement(Fragment, null, shouldRender && createElement(DuotoneStyles, {
330
+ id: filterClass,
331
+ selector: selector,
332
+ attribute: attribute
286
333
  }), createElement(BlockListBlock, _extends({}, props, {
287
334
  className: className
288
335
  })));