@wordpress/block-editor 16.2.0 → 17.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 (328) hide show
  1. package/CHANGELOG.md +39 -0
  2. package/build/components/block-inspector/index.cjs +9 -6
  3. package/build/components/block-inspector/index.cjs.map +2 -2
  4. package/build/components/block-keyboard-shortcuts/index.cjs +201 -0
  5. package/build/components/block-keyboard-shortcuts/index.cjs.map +7 -0
  6. package/build/components/block-list/block.cjs +10 -3
  7. package/build/components/block-list/block.cjs.map +2 -2
  8. package/build/components/block-list/index.cjs +6 -1
  9. package/build/components/block-list/index.cjs.map +2 -2
  10. package/build/components/block-list/use-block-props/use-focus-first-element.cjs +4 -0
  11. package/build/components/block-list/use-block-props/use-focus-first-element.cjs.map +2 -2
  12. package/build/components/block-list/use-block-props/use-selected-block-event-handlers.cjs +6 -7
  13. package/build/components/block-list/use-block-props/use-selected-block-event-handlers.cjs.map +2 -2
  14. package/build/components/block-parent-selector/index.cjs +98 -29
  15. package/build/components/block-parent-selector/index.cjs.map +3 -3
  16. package/build/components/block-popover/inbetween.cjs +2 -2
  17. package/build/components/block-popover/inbetween.cjs.map +2 -2
  18. package/build/components/block-preview/index.cjs +0 -4
  19. package/build/components/block-preview/index.cjs.map +2 -2
  20. package/build/components/block-styles/index.cjs +77 -33
  21. package/build/components/block-styles/index.cjs.map +3 -3
  22. package/build/components/block-visibility/constants.cjs.map +2 -2
  23. package/build/components/child-layout-control/index.cjs.map +2 -2
  24. package/build/components/colors/with-colors.cjs +55 -71
  25. package/build/components/colors/with-colors.cjs.map +2 -2
  26. package/build/components/dimensions-tool/aspect-ratio-tool.cjs +4 -2
  27. package/build/components/dimensions-tool/aspect-ratio-tool.cjs.map +2 -2
  28. package/build/components/dimensions-tool/index.cjs +18 -16
  29. package/build/components/dimensions-tool/index.cjs.map +2 -2
  30. package/build/components/dimensions-tool/utils.cjs +61 -0
  31. package/build/components/dimensions-tool/utils.cjs.map +7 -0
  32. package/build/components/duotone-control/index.cjs +2 -0
  33. package/build/components/duotone-control/index.cjs.map +2 -2
  34. package/build/components/global-styles/advanced-panel.cjs.map +3 -3
  35. package/build/components/global-styles/border-panel.cjs +2 -5
  36. package/build/components/global-styles/border-panel.cjs.map +2 -2
  37. package/build/components/global-styles/color-panel.cjs +14 -2
  38. package/build/components/global-styles/color-panel.cjs.map +2 -2
  39. package/build/components/global-styles/dimensions-panel.cjs +9 -5
  40. package/build/components/global-styles/dimensions-panel.cjs.map +2 -2
  41. package/build/components/global-styles/filters-panel.cjs +12 -8
  42. package/build/components/global-styles/filters-panel.cjs.map +2 -2
  43. package/build/components/global-styles/shadow-panel-components.cjs +16 -11
  44. package/build/components/global-styles/shadow-panel-components.cjs.map +2 -2
  45. package/build/components/global-styles/utils.cjs +9 -0
  46. package/build/components/global-styles/utils.cjs.map +2 -2
  47. package/build/components/inner-blocks/index.cjs +5 -3
  48. package/build/components/inner-blocks/index.cjs.map +2 -2
  49. package/build/components/inserter/block-patterns-explorer/index.cjs +39 -22
  50. package/build/components/inserter/block-patterns-explorer/index.cjs.map +2 -2
  51. package/build/components/inserter/block-patterns-explorer/pattern-explorer-sidebar.cjs +21 -55
  52. package/build/components/inserter/block-patterns-explorer/pattern-explorer-sidebar.cjs.map +2 -2
  53. package/build/components/inserter/block-patterns-explorer/pattern-list.cjs +19 -44
  54. package/build/components/inserter/block-patterns-explorer/pattern-list.cjs.map +3 -3
  55. package/build/components/inserter/hooks/use-insertion-point.cjs +4 -4
  56. package/build/components/inserter/hooks/use-insertion-point.cjs.map +2 -2
  57. package/build/components/inserter/menu.cjs +18 -7
  58. package/build/components/inserter/menu.cjs.map +2 -2
  59. package/build/components/inserter/quick-inserter.cjs +30 -27
  60. package/build/components/inserter/quick-inserter.cjs.map +2 -2
  61. package/build/components/inspector-controls-tabs/styles-tab.cjs +1 -1
  62. package/build/components/inspector-controls-tabs/styles-tab.cjs.map +2 -2
  63. package/build/components/list-view/index.cjs +31 -5
  64. package/build/components/list-view/index.cjs.map +3 -3
  65. package/build/components/list-view/utils.cjs +13 -1
  66. package/build/components/list-view/utils.cjs.map +2 -2
  67. package/build/components/media-placeholder/index.cjs +1 -1
  68. package/build/components/media-placeholder/index.cjs.map +3 -3
  69. package/build/components/provider/index.cjs +5 -1
  70. package/build/components/provider/index.cjs.map +3 -3
  71. package/build/components/publish-date-time-picker/index.cjs +3 -2
  72. package/build/components/publish-date-time-picker/index.cjs.map +2 -2
  73. package/build/components/rich-text/event-listeners/enter.cjs +46 -39
  74. package/build/components/rich-text/event-listeners/enter.cjs.map +2 -2
  75. package/build/components/rich-text/index.cjs +7 -5
  76. package/build/components/rich-text/index.cjs.map +2 -2
  77. package/build/components/rich-text/multiline.cjs +105 -70
  78. package/build/components/rich-text/multiline.cjs.map +3 -3
  79. package/build/components/url-input/index.cjs.map +2 -2
  80. package/build/components/writing-flow/use-input.cjs +65 -13
  81. package/build/components/writing-flow/use-input.cjs.map +3 -3
  82. package/build/hooks/border.cjs +25 -3
  83. package/build/hooks/border.cjs.map +2 -2
  84. package/build/hooks/dimensions.cjs +9 -2
  85. package/build/hooks/dimensions.cjs.map +2 -2
  86. package/build/hooks/duotone.cjs +4 -3
  87. package/build/hooks/duotone.cjs.map +2 -2
  88. package/build/hooks/gap.cjs +8 -2
  89. package/build/hooks/gap.cjs.map +2 -2
  90. package/build/hooks/layout-child.cjs +35 -13
  91. package/build/hooks/layout-child.cjs.map +2 -2
  92. package/build/hooks/layout.cjs +23 -1
  93. package/build/hooks/layout.cjs.map +2 -2
  94. package/build/hooks/states.cjs +7 -4
  95. package/build/hooks/states.cjs.map +2 -2
  96. package/build/layouts/constrained.cjs +8 -1
  97. package/build/layouts/constrained.cjs.map +2 -2
  98. package/build/layouts/flex.cjs +9 -0
  99. package/build/layouts/flex.cjs.map +2 -2
  100. package/build/layouts/flow.cjs +4 -1
  101. package/build/layouts/flow.cjs.map +2 -2
  102. package/build/layouts/grid.cjs +5 -1
  103. package/build/layouts/grid.cjs.map +2 -2
  104. package/build/private-apis.cjs +3 -1
  105. package/build/private-apis.cjs.map +2 -2
  106. package/build/store/actions.cjs +1 -1
  107. package/build/store/actions.cjs.map +2 -2
  108. package/build-module/components/block-inspector/index.mjs +9 -6
  109. package/build-module/components/block-inspector/index.mjs.map +2 -2
  110. package/build-module/components/block-keyboard-shortcuts/index.mjs +173 -0
  111. package/build-module/components/block-keyboard-shortcuts/index.mjs.map +7 -0
  112. package/build-module/components/block-list/block.mjs +10 -3
  113. package/build-module/components/block-list/block.mjs.map +2 -2
  114. package/build-module/components/block-list/index.mjs +6 -1
  115. package/build-module/components/block-list/index.mjs.map +2 -2
  116. package/build-module/components/block-list/use-block-props/use-focus-first-element.mjs +4 -0
  117. package/build-module/components/block-list/use-block-props/use-focus-first-element.mjs.map +2 -2
  118. package/build-module/components/block-list/use-block-props/use-selected-block-event-handlers.mjs +6 -7
  119. package/build-module/components/block-list/use-block-props/use-selected-block-event-handlers.mjs.map +2 -2
  120. package/build-module/components/block-parent-selector/index.mjs +101 -32
  121. package/build-module/components/block-parent-selector/index.mjs.map +2 -2
  122. package/build-module/components/block-popover/inbetween.mjs +2 -2
  123. package/build-module/components/block-popover/inbetween.mjs.map +2 -2
  124. package/build-module/components/block-preview/index.mjs +0 -4
  125. package/build-module/components/block-preview/index.mjs.map +2 -2
  126. package/build-module/components/block-styles/index.mjs +79 -35
  127. package/build-module/components/block-styles/index.mjs.map +2 -2
  128. package/build-module/components/block-visibility/constants.mjs.map +2 -2
  129. package/build-module/components/child-layout-control/index.mjs +5 -5
  130. package/build-module/components/child-layout-control/index.mjs.map +1 -1
  131. package/build-module/components/colors/with-colors.mjs +56 -72
  132. package/build-module/components/colors/with-colors.mjs.map +2 -2
  133. package/build-module/components/dimensions-tool/aspect-ratio-tool.mjs +4 -2
  134. package/build-module/components/dimensions-tool/aspect-ratio-tool.mjs.map +2 -2
  135. package/build-module/components/dimensions-tool/index.mjs +19 -17
  136. package/build-module/components/dimensions-tool/index.mjs.map +2 -2
  137. package/build-module/components/dimensions-tool/utils.mjs +35 -0
  138. package/build-module/components/dimensions-tool/utils.mjs.map +7 -0
  139. package/build-module/components/duotone-control/index.mjs +2 -0
  140. package/build-module/components/duotone-control/index.mjs.map +2 -2
  141. package/build-module/components/global-styles/advanced-panel.mjs +5 -2
  142. package/build-module/components/global-styles/advanced-panel.mjs.map +2 -2
  143. package/build-module/components/global-styles/border-panel.mjs +2 -5
  144. package/build-module/components/global-styles/border-panel.mjs.map +2 -2
  145. package/build-module/components/global-styles/color-panel.mjs +14 -2
  146. package/build-module/components/global-styles/color-panel.mjs.map +2 -2
  147. package/build-module/components/global-styles/dimensions-panel.mjs +9 -5
  148. package/build-module/components/global-styles/dimensions-panel.mjs.map +2 -2
  149. package/build-module/components/global-styles/filters-panel.mjs +16 -9
  150. package/build-module/components/global-styles/filters-panel.mjs.map +2 -2
  151. package/build-module/components/global-styles/shadow-panel-components.mjs +16 -11
  152. package/build-module/components/global-styles/shadow-panel-components.mjs.map +2 -2
  153. package/build-module/components/global-styles/utils.mjs +8 -0
  154. package/build-module/components/global-styles/utils.mjs.map +2 -2
  155. package/build-module/components/inner-blocks/index.mjs +5 -3
  156. package/build-module/components/inner-blocks/index.mjs.map +2 -2
  157. package/build-module/components/inserter/block-patterns-explorer/index.mjs +39 -22
  158. package/build-module/components/inserter/block-patterns-explorer/index.mjs.map +2 -2
  159. package/build-module/components/inserter/block-patterns-explorer/pattern-explorer-sidebar.mjs +22 -56
  160. package/build-module/components/inserter/block-patterns-explorer/pattern-explorer-sidebar.mjs.map +2 -2
  161. package/build-module/components/inserter/block-patterns-explorer/pattern-list.mjs +20 -45
  162. package/build-module/components/inserter/block-patterns-explorer/pattern-list.mjs.map +2 -2
  163. package/build-module/components/inserter/hooks/use-insertion-point.mjs +4 -4
  164. package/build-module/components/inserter/hooks/use-insertion-point.mjs.map +2 -2
  165. package/build-module/components/inserter/menu.mjs +19 -8
  166. package/build-module/components/inserter/menu.mjs.map +2 -2
  167. package/build-module/components/inserter/quick-inserter.mjs +30 -27
  168. package/build-module/components/inserter/quick-inserter.mjs.map +2 -2
  169. package/build-module/components/inspector-controls-tabs/styles-tab.mjs +1 -1
  170. package/build-module/components/inspector-controls-tabs/styles-tab.mjs.map +2 -2
  171. package/build-module/components/list-view/index.mjs +32 -5
  172. package/build-module/components/list-view/index.mjs.map +3 -3
  173. package/build-module/components/list-view/utils.mjs +13 -1
  174. package/build-module/components/list-view/utils.mjs.map +2 -2
  175. package/build-module/components/media-placeholder/index.mjs +3 -3
  176. package/build-module/components/media-placeholder/index.mjs.map +2 -2
  177. package/build-module/components/provider/index.mjs +6 -2
  178. package/build-module/components/provider/index.mjs.map +2 -2
  179. package/build-module/components/publish-date-time-picker/index.mjs +3 -2
  180. package/build-module/components/publish-date-time-picker/index.mjs.map +2 -2
  181. package/build-module/components/rich-text/event-listeners/enter.mjs +46 -39
  182. package/build-module/components/rich-text/event-listeners/enter.mjs.map +2 -2
  183. package/build-module/components/rich-text/index.mjs +7 -5
  184. package/build-module/components/rich-text/index.mjs.map +2 -2
  185. package/build-module/components/rich-text/multiline.mjs +112 -72
  186. package/build-module/components/rich-text/multiline.mjs.map +2 -2
  187. package/build-module/components/url-input/index.mjs +2 -2
  188. package/build-module/components/url-input/index.mjs.map +1 -1
  189. package/build-module/components/writing-flow/use-input.mjs +66 -14
  190. package/build-module/components/writing-flow/use-input.mjs.map +3 -3
  191. package/build-module/hooks/border.mjs +26 -8
  192. package/build-module/hooks/border.mjs.map +2 -2
  193. package/build-module/hooks/dimensions.mjs +9 -2
  194. package/build-module/hooks/dimensions.mjs.map +2 -2
  195. package/build-module/hooks/duotone.mjs +8 -4
  196. package/build-module/hooks/duotone.mjs.map +2 -2
  197. package/build-module/hooks/gap.mjs +6 -1
  198. package/build-module/hooks/gap.mjs.map +2 -2
  199. package/build-module/hooks/layout-child.mjs +36 -13
  200. package/build-module/hooks/layout-child.mjs.map +2 -2
  201. package/build-module/hooks/layout.mjs +22 -1
  202. package/build-module/hooks/layout.mjs.map +2 -2
  203. package/build-module/hooks/states.mjs +8 -5
  204. package/build-module/hooks/states.mjs.map +2 -2
  205. package/build-module/layouts/constrained.mjs +8 -1
  206. package/build-module/layouts/constrained.mjs.map +2 -2
  207. package/build-module/layouts/flex.mjs +9 -0
  208. package/build-module/layouts/flex.mjs.map +2 -2
  209. package/build-module/layouts/flow.mjs +4 -1
  210. package/build-module/layouts/flow.mjs.map +2 -2
  211. package/build-module/layouts/grid.mjs +5 -1
  212. package/build-module/layouts/grid.mjs.map +2 -2
  213. package/build-module/private-apis.mjs +3 -1
  214. package/build-module/private-apis.mjs.map +2 -2
  215. package/build-module/store/actions.mjs +1 -1
  216. package/build-module/store/actions.mjs.map +2 -2
  217. package/build-style/style-rtl.css +108 -71
  218. package/build-style/style.css +108 -71
  219. package/build-types/components/block-visibility/constants.d.ts +4 -3
  220. package/build-types/components/block-visibility/constants.d.ts.map +1 -1
  221. package/package.json +43 -43
  222. package/src/components/background-image-control/README.md +122 -0
  223. package/src/components/block-edit-visually-button/README.md +39 -0
  224. package/src/components/block-editing-mode/README.md +72 -0
  225. package/src/components/block-inspector/index.js +6 -6
  226. package/src/components/block-keyboard-shortcuts/index.js +256 -0
  227. package/src/components/block-list/block.js +7 -0
  228. package/src/components/block-list/index.js +7 -1
  229. package/src/components/block-list/use-block-props/use-focus-first-element.js +5 -0
  230. package/src/components/block-list/use-block-props/use-selected-block-event-handlers.js +6 -8
  231. package/src/components/block-parent-selector/index.js +111 -30
  232. package/src/components/block-popover/README.md +10 -3
  233. package/src/components/block-popover/inbetween.js +8 -2
  234. package/src/components/block-popover/stories/index.story.jsx +143 -0
  235. package/src/components/block-preview/index.js +0 -2
  236. package/src/components/block-styles/index.js +95 -43
  237. package/src/components/block-styles/style.scss +5 -34
  238. package/src/components/block-tools/style.scss +94 -0
  239. package/src/components/block-visibility/constants.ts +4 -3
  240. package/src/components/child-layout-control/index.js +5 -5
  241. package/src/components/color-palette/test/__snapshots__/control.js.snap +3 -29
  242. package/src/components/colors/test/with-colors.js +6 -7
  243. package/src/components/colors/with-colors.js +79 -105
  244. package/src/components/dimensions-tool/aspect-ratio-tool.js +16 -4
  245. package/src/components/dimensions-tool/index.js +34 -22
  246. package/src/components/dimensions-tool/test/index.js +166 -2
  247. package/src/components/dimensions-tool/test/utils.js +51 -0
  248. package/src/components/dimensions-tool/utils.js +67 -0
  249. package/src/components/duotone-control/index.js +2 -0
  250. package/src/components/duotone-control/test/index.js +100 -0
  251. package/src/components/global-styles/advanced-panel.js +5 -2
  252. package/src/components/global-styles/border-panel.js +11 -9
  253. package/src/components/global-styles/color-panel.js +13 -1
  254. package/src/components/global-styles/dimensions-panel.js +17 -5
  255. package/src/components/global-styles/filters-panel.js +24 -10
  256. package/src/components/global-styles/shadow-panel-components.js +38 -11
  257. package/src/components/global-styles/test/border-panel.js +230 -0
  258. package/src/components/global-styles/test/color-panel.js +24 -0
  259. package/src/components/global-styles/test/dimensions-panel.js +98 -7
  260. package/src/components/global-styles/test/filters-panel.js +84 -0
  261. package/src/components/global-styles/test/utils.js +30 -0
  262. package/src/components/global-styles/utils.js +23 -0
  263. package/src/components/inner-blocks/index.js +11 -2
  264. package/src/components/inner-blocks/stories/index.story.jsx +246 -0
  265. package/src/components/inserter/block-patterns-explorer/index.js +24 -11
  266. package/src/components/inserter/block-patterns-explorer/pattern-explorer-sidebar.js +18 -56
  267. package/src/components/inserter/block-patterns-explorer/pattern-list.js +22 -47
  268. package/src/components/inserter/hooks/use-insertion-point.js +9 -4
  269. package/src/components/inserter/menu.js +23 -10
  270. package/src/components/inserter/quick-inserter.js +15 -13
  271. package/src/components/inserter/style.scss +44 -62
  272. package/src/components/inspector-controls-tabs/README.md +92 -0
  273. package/src/components/inspector-controls-tabs/styles-tab.js +1 -1
  274. package/src/components/link-control/test/index.js +5 -0
  275. package/src/components/list-view/index.js +50 -7
  276. package/src/components/list-view/utils.js +16 -1
  277. package/src/components/media-placeholder/index.js +9 -4
  278. package/src/components/plain-text/stories/index.story.jsx +3 -0
  279. package/src/components/provider/index.js +7 -1
  280. package/src/components/publish-date-time-picker/README.md +10 -0
  281. package/src/components/publish-date-time-picker/index.js +17 -14
  282. package/src/components/rich-text/event-listeners/enter.js +58 -45
  283. package/src/components/rich-text/index.js +9 -4
  284. package/src/components/rich-text/multiline.js +126 -86
  285. package/src/components/url-input/index.js +2 -2
  286. package/src/components/url-input/test/fixtures/validated-input-control-deprecation.js +27 -0
  287. package/src/components/url-input/test/index.js +5 -0
  288. package/src/components/url-popover/README.md +7 -0
  289. package/src/components/url-popover/stories/index.story.jsx +133 -47
  290. package/src/components/writing-flow/use-input.js +105 -15
  291. package/src/hooks/border.js +27 -8
  292. package/src/hooks/dimensions.js +8 -1
  293. package/src/hooks/duotone.js +23 -7
  294. package/src/hooks/gap.js +16 -0
  295. package/src/hooks/layout-child.js +41 -9
  296. package/src/hooks/layout.js +117 -71
  297. package/src/hooks/states.js +8 -5
  298. package/src/hooks/test/gap.js +31 -1
  299. package/src/hooks/test/layout-child.js +60 -1
  300. package/src/hooks/test/layout.js +27 -0
  301. package/src/layouts/constrained.js +9 -1
  302. package/src/layouts/flex.js +15 -0
  303. package/src/layouts/flow.js +4 -1
  304. package/src/layouts/grid.js +9 -1
  305. package/src/layouts/test/constrained.js +26 -0
  306. package/src/layouts/test/flow.js +26 -0
  307. package/src/layouts/test/grid.js +46 -0
  308. package/src/private-apis.js +2 -0
  309. package/src/store/actions.js +14 -1
  310. package/build/components/floating-toolbar/nav-up-icon.cjs +0 -52
  311. package/build/components/floating-toolbar/nav-up-icon.cjs.map +0 -7
  312. package/build/components/gradients/with-gradient.cjs +0 -36
  313. package/build/components/gradients/with-gradient.cjs.map +0 -7
  314. package/build/components/inserter-button/sparkles.cjs +0 -36
  315. package/build/components/inserter-button/sparkles.cjs.map +0 -7
  316. package/build-module/components/floating-toolbar/nav-up-icon.mjs +0 -31
  317. package/build-module/components/floating-toolbar/nav-up-icon.mjs.map +0 -7
  318. package/build-module/components/gradients/with-gradient.mjs +0 -11
  319. package/build-module/components/gradients/with-gradient.mjs.map +0 -7
  320. package/build-module/components/inserter-button/sparkles.mjs +0 -15
  321. package/build-module/components/inserter-button/sparkles.mjs.map +0 -7
  322. package/build-style/default-editor-styles-rtl.css +0 -68
  323. package/build-style/default-editor-styles.css +0 -68
  324. package/src/components/floating-toolbar/nav-up-icon.js +0 -22
  325. package/src/components/gradients/with-gradient.js +0 -9
  326. package/src/components/inserter-button/README.md +0 -62
  327. package/src/components/inserter-button/sparkles.js +0 -12
  328. package/src/default-editor-styles.scss +0 -25
@@ -11,7 +11,7 @@ import {
11
11
  } from "@wordpress/blocks";
12
12
  import { store as blockEditorStore } from "../../store/index.mjs";
13
13
  import { setContentEditableWrapper } from "./utils.mjs";
14
- import { getSelectionEditableElement } from "../../utils/dom.mjs";
14
+ import { getBlockClientId, getSelectionEditableElement } from "../../utils/dom.mjs";
15
15
  function useInput() {
16
16
  const {
17
17
  __unstableIsFullySelected,
@@ -24,7 +24,11 @@ function useInput() {
24
24
  getBlockRootClientId,
25
25
  getSelectionStart,
26
26
  getSelectionEnd,
27
- getBlockAttributes
27
+ getBlockAttributes,
28
+ getNextBlockClientId,
29
+ getBlockOrder,
30
+ getBlockEditingMode,
31
+ getBlockListSettings
28
32
  } = useSelect(blockEditorStore);
29
33
  const {
30
34
  replaceBlocks,
@@ -32,7 +36,10 @@ function useInput() {
32
36
  removeBlocks,
33
37
  __unstableDeleteSelection,
34
38
  __unstableExpandSelection,
35
- __unstableMarkAutomaticChange
39
+ __unstableMarkAutomaticChange,
40
+ insertAfterBlock,
41
+ insertBlock,
42
+ selectBlock
36
43
  } = useDispatch(blockEditorStore);
37
44
  return useRefEffect((node) => {
38
45
  function onBeforeInput(event) {
@@ -54,7 +61,7 @@ function useInput() {
54
61
  }
55
62
  if (!hasMultiSelection()) {
56
63
  if (event.keyCode === ENTER) {
57
- if (event.shiftKey || __unstableIsFullySelected()) {
64
+ if (event.shiftKey) {
58
65
  return;
59
66
  }
60
67
  const clientId = getSelectedBlockClientId();
@@ -85,18 +92,63 @@ function useInput() {
85
92
  return;
86
93
  }
87
94
  }
88
- if (!hasBlockSupport(blockName, "splitting", false) && !event.__deprecatedOnSplit) {
89
- return;
90
- }
91
- if (canInsertBlockType(
95
+ const rootClientId = getBlockRootClientId(clientId);
96
+ const { activeElement } = event.target.ownerDocument;
97
+ if (!__unstableIsFullySelected() && (canInsertBlockType(
92
98
  getDefaultBlockName(),
93
- getBlockRootClientId(clientId)
94
- ) || canInsertBlockType(
95
- blockName,
96
- getBlockRootClientId(clientId)
97
- )) {
98
- __unstableSplitSelection();
99
+ rootClientId
100
+ ) || canInsertBlockType(blockName, rootClientId)) && (hasBlockSupport(blockName, "splitting", false) || event.__deprecatedOnSplit)) {
99
101
  event.preventDefault();
102
+ __unstableSplitSelection();
103
+ } else if (
104
+ // Handle Enter only on the block wrapper itself or
105
+ // an editable element within the block, which may be
106
+ // nested within the wrapper (e.g. Site Title). Other
107
+ // focusable elements (an embed's URL field, an
108
+ // appender button) keep their native Enter behavior.
109
+ (activeElement.getAttribute("data-block") === clientId || activeElement.isContentEditable) && getBlockClientId(activeElement) === clientId
110
+ ) {
111
+ const { defaultBlock: directInsertBlock } = rootClientId && getBlockListSettings(rootClientId) || {};
112
+ if (canInsertBlockType(
113
+ directInsertBlock?.name ?? getDefaultBlockName(),
114
+ rootClientId
115
+ )) {
116
+ event.preventDefault();
117
+ insertAfterBlock(clientId);
118
+ } else {
119
+ let getNextClientId2 = function(id) {
120
+ let nextClientId2 = null;
121
+ while (typeof id === "string" && !(nextClientId2 = getNextBlockClientId(id))) {
122
+ id = getBlockRootClientId(id);
123
+ }
124
+ return nextClientId2;
125
+ };
126
+ var getNextClientId = getNextClientId2;
127
+ if (!getBlockOrder(clientId).length) {
128
+ const { defaultBlock } = getBlockListSettings(clientId) ?? {};
129
+ const name = defaultBlock?.name ?? getDefaultBlockName();
130
+ if (canInsertBlockType(name, clientId)) {
131
+ event.preventDefault();
132
+ insertBlock(
133
+ createBlock(
134
+ name,
135
+ defaultBlock?.attributes
136
+ ),
137
+ 0,
138
+ clientId
139
+ );
140
+ return;
141
+ }
142
+ }
143
+ let nextClientId = getBlockOrder(clientId)[0] ?? getNextClientId2(clientId);
144
+ while (nextClientId && getBlockEditingMode(nextClientId) === "disabled") {
145
+ nextClientId = getNextClientId2(nextClientId);
146
+ }
147
+ if (nextClientId) {
148
+ event.preventDefault();
149
+ selectBlock(nextClientId, true);
150
+ }
151
+ }
100
152
  }
101
153
  }
102
154
  return;
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../src/components/writing-flow/use-input.js"],
4
- "sourcesContent": ["import { useSelect, useDispatch } from '@wordpress/data';\nimport { useRefEffect } from '@wordpress/compose';\nimport { ENTER, BACKSPACE, DELETE } from '@wordpress/keycodes';\nimport {\n\tcreateBlock,\n\tgetDefaultBlockName,\n\thasBlockSupport,\n\tgetBlockTransforms,\n\tfindTransform,\n} from '@wordpress/blocks';\nimport { store as blockEditorStore } from '../../store';\nimport { setContentEditableWrapper } from './utils';\nimport { getSelectionEditableElement } from '../../utils/dom';\n\n/**\n * Handles input for selections across blocks.\n */\nexport default function useInput() {\n\tconst {\n\t\t__unstableIsFullySelected,\n\t\tgetSelectedBlockClientIds,\n\t\tgetSelectedBlockClientId,\n\t\t__unstableIsSelectionMergeable,\n\t\thasMultiSelection,\n\t\tgetBlockName,\n\t\tcanInsertBlockType,\n\t\tgetBlockRootClientId,\n\t\tgetSelectionStart,\n\t\tgetSelectionEnd,\n\t\tgetBlockAttributes,\n\t} = useSelect( blockEditorStore );\n\tconst {\n\t\treplaceBlocks,\n\t\t__unstableSplitSelection,\n\t\tremoveBlocks,\n\t\t__unstableDeleteSelection,\n\t\t__unstableExpandSelection,\n\t\t__unstableMarkAutomaticChange,\n\t} = useDispatch( blockEditorStore );\n\n\treturn useRefEffect( ( node ) => {\n\t\tfunction onBeforeInput( event ) {\n\t\t\t// If writing flow is editable, never allow the browser to alter\n\t\t\t// the DOM outside of an editable element within a block. This\n\t\t\t// will cause React errors (and the DOM should only be altered in\n\t\t\t// a controlled fashion). The wrapper can be contentEditable with\n\t\t\t// a single selection when the selected block supports\n\t\t\t// `editableRoot`; in that case edits within the block's editable\n\t\t\t// element are handled by its rich text instance.\n\t\t\tif ( node.contentEditable !== 'true' ) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tif ( hasMultiSelection() ) {\n\t\t\t\tevent.preventDefault();\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tconst selection = node.ownerDocument.defaultView.getSelection();\n\n\t\t\tif ( ! getSelectionEditableElement( selection, node ) ) {\n\t\t\t\tevent.preventDefault();\n\t\t\t}\n\t\t}\n\n\t\tfunction onKeyDown( event ) {\n\t\t\tif ( event.defaultPrevented ) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tif ( ! hasMultiSelection() ) {\n\t\t\t\tif ( event.keyCode === ENTER ) {\n\t\t\t\t\tif ( event.shiftKey || __unstableIsFullySelected() ) {\n\t\t\t\t\t\treturn;\n\t\t\t\t\t}\n\n\t\t\t\t\tconst clientId = getSelectedBlockClientId();\n\t\t\t\t\tconst blockName = getBlockName( clientId );\n\t\t\t\t\tconst selectionStart = getSelectionStart();\n\t\t\t\t\tconst selectionEnd = getSelectionEnd();\n\n\t\t\t\t\tif (\n\t\t\t\t\t\tselectionStart.attributeKey ===\n\t\t\t\t\t\tselectionEnd.attributeKey\n\t\t\t\t\t) {\n\t\t\t\t\t\tconst selectedAttributeValue =\n\t\t\t\t\t\t\tgetBlockAttributes( clientId )[\n\t\t\t\t\t\t\t\tselectionStart.attributeKey\n\t\t\t\t\t\t\t];\n\t\t\t\t\t\tconst transforms = getBlockTransforms( 'from' ).filter(\n\t\t\t\t\t\t\t( { type } ) => type === 'enter'\n\t\t\t\t\t\t);\n\t\t\t\t\t\tconst transformation = findTransform(\n\t\t\t\t\t\t\ttransforms,\n\t\t\t\t\t\t\t( item ) => {\n\t\t\t\t\t\t\t\treturn item.regExp.test(\n\t\t\t\t\t\t\t\t\tselectedAttributeValue\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\n\t\t\t\t\t\tif ( transformation ) {\n\t\t\t\t\t\t\treplaceBlocks(\n\t\t\t\t\t\t\t\tclientId,\n\t\t\t\t\t\t\t\ttransformation.transform( {\n\t\t\t\t\t\t\t\t\tcontent: selectedAttributeValue,\n\t\t\t\t\t\t\t\t} )\n\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\t__unstableMarkAutomaticChange();\n\t\t\t\t\t\t\treturn;\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\n\t\t\t\t\tif (\n\t\t\t\t\t\t! hasBlockSupport( blockName, 'splitting', false ) &&\n\t\t\t\t\t\t! event.__deprecatedOnSplit\n\t\t\t\t\t) {\n\t\t\t\t\t\treturn;\n\t\t\t\t\t}\n\n\t\t\t\t\t// Ensure template is not locked.\n\t\t\t\t\tif (\n\t\t\t\t\t\tcanInsertBlockType(\n\t\t\t\t\t\t\tgetDefaultBlockName(),\n\t\t\t\t\t\t\tgetBlockRootClientId( clientId )\n\t\t\t\t\t\t) ||\n\t\t\t\t\t\tcanInsertBlockType(\n\t\t\t\t\t\t\tblockName,\n\t\t\t\t\t\t\tgetBlockRootClientId( clientId )\n\t\t\t\t\t\t)\n\t\t\t\t\t) {\n\t\t\t\t\t\t__unstableSplitSelection();\n\t\t\t\t\t\tevent.preventDefault();\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tif ( event.keyCode === ENTER ) {\n\t\t\t\tsetContentEditableWrapper( node, false );\n\t\t\t\tevent.preventDefault();\n\t\t\t\tif ( __unstableIsFullySelected() ) {\n\t\t\t\t\treplaceBlocks(\n\t\t\t\t\t\tgetSelectedBlockClientIds(),\n\t\t\t\t\t\tcreateBlock( getDefaultBlockName() )\n\t\t\t\t\t);\n\t\t\t\t} else {\n\t\t\t\t\t__unstableSplitSelection();\n\t\t\t\t}\n\t\t\t} else if (\n\t\t\t\tevent.keyCode === BACKSPACE ||\n\t\t\t\tevent.keyCode === DELETE\n\t\t\t) {\n\t\t\t\tsetContentEditableWrapper( node, false );\n\t\t\t\tevent.preventDefault();\n\t\t\t\tif ( __unstableIsFullySelected() ) {\n\t\t\t\t\tremoveBlocks( getSelectedBlockClientIds() );\n\t\t\t\t} else if ( __unstableIsSelectionMergeable() ) {\n\t\t\t\t\t__unstableDeleteSelection( event.keyCode === DELETE );\n\t\t\t\t} else {\n\t\t\t\t\t__unstableExpandSelection();\n\t\t\t\t}\n\t\t\t} else if (\n\t\t\t\t// If key.length is longer than 1, it's a control key that doesn't\n\t\t\t\t// input anything.\n\t\t\t\tevent.key.length === 1 &&\n\t\t\t\t! ( event.metaKey || event.ctrlKey )\n\t\t\t) {\n\t\t\t\tsetContentEditableWrapper( node, false );\n\t\t\t\tif ( __unstableIsSelectionMergeable() ) {\n\t\t\t\t\t__unstableDeleteSelection( event.keyCode === DELETE );\n\t\t\t\t} else {\n\t\t\t\t\tevent.preventDefault();\n\t\t\t\t\t// Safari does not stop default behaviour with either\n\t\t\t\t\t// event.preventDefault() or node.contentEditable = false, so\n\t\t\t\t\t// remove the selection to stop browser manipulation.\n\t\t\t\t\tnode.ownerDocument.defaultView\n\t\t\t\t\t\t.getSelection()\n\t\t\t\t\t\t.removeAllRanges();\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\tfunction onCompositionStart( event ) {\n\t\t\tif ( ! hasMultiSelection() ) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tsetContentEditableWrapper( node, false );\n\n\t\t\tif ( __unstableIsSelectionMergeable() ) {\n\t\t\t\t__unstableDeleteSelection();\n\t\t\t} else {\n\t\t\t\tevent.preventDefault();\n\t\t\t\t// Safari does not stop default behaviour with either\n\t\t\t\t// event.preventDefault() or node.contentEditable = false, so\n\t\t\t\t// remove the selection to stop browser manipulation.\n\t\t\t\tnode.ownerDocument.defaultView.getSelection().removeAllRanges();\n\t\t\t}\n\t\t}\n\n\t\tnode.addEventListener( 'beforeinput', onBeforeInput );\n\t\tnode.addEventListener( 'keydown', onKeyDown );\n\t\tnode.addEventListener( 'compositionstart', onCompositionStart );\n\t\treturn () => {\n\t\t\tnode.removeEventListener( 'beforeinput', onBeforeInput );\n\t\t\tnode.removeEventListener( 'keydown', onKeyDown );\n\t\t\tnode.removeEventListener( 'compositionstart', onCompositionStart );\n\t\t};\n\t}, [] );\n}\n"],
5
- "mappings": ";AAAA,SAAS,WAAW,mBAAmB;AACvC,SAAS,oBAAoB;AAC7B,SAAS,OAAO,WAAW,cAAc;AACzC;AAAA,EACC;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACM;AACP,SAAS,SAAS,wBAAwB;AAC1C,SAAS,iCAAiC;AAC1C,SAAS,mCAAmC;AAK7B,SAAR,WAA4B;AAClC,QAAM;AAAA,IACL;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,EACD,IAAI,UAAW,gBAAiB;AAChC,QAAM;AAAA,IACL;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,EACD,IAAI,YAAa,gBAAiB;AAElC,SAAO,aAAc,CAAE,SAAU;AAChC,aAAS,cAAe,OAAQ;AAQ/B,UAAK,KAAK,oBAAoB,QAAS;AACtC;AAAA,MACD;AAEA,UAAK,kBAAkB,GAAI;AAC1B,cAAM,eAAe;AACrB;AAAA,MACD;AAEA,YAAM,YAAY,KAAK,cAAc,YAAY,aAAa;AAE9D,UAAK,CAAE,4BAA6B,WAAW,IAAK,GAAI;AACvD,cAAM,eAAe;AAAA,MACtB;AAAA,IACD;AAEA,aAAS,UAAW,OAAQ;AAC3B,UAAK,MAAM,kBAAmB;AAC7B;A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AAY,aAClB,MAAM,YAAY,QACjB;AACD,kCAA2B,MAAM,KAAM;AACvC,cAAM,eAAe;AACrB,YAAK,0BAA0B,GAAI;AAClC,uBAAc,0BAA0B,CAAE;AAAA,QAC3C,WAAY,+BAA+B,GAAI;AAC9C,oCAA2B,MAAM,YAAY,MAAO;AAAA,QACrD,OAAO;AACN,oCAA0B;AAAA,QAC3B;AAAA,MACD;AAAA;AAAA;AAAA,QAGC,MAAM,IAAI,WAAW,KACrB,EAAI,MAAM,WAAW,MAAM;AAAA,QAC1B;AACD,kCAA2B,MAAM,KAAM;AACvC,YAAK,+BAA+B,GAAI;AACvC,oCAA2B,MAAM,YAAY,MAAO;AAAA,QACrD,OAAO;AACN,gBAAM,eAAe;AAIrB,eAAK,cAAc,YACjB,aAAa,EACb,gBAAgB;AAAA,QACnB;AAAA,MACD;AAAA,IACD;AAEA,aAAS,mBAAoB,OAAQ;AACpC,UAAK,CAAE,kBAAkB,GAAI;AAC5B;AAAA,MACD;AAEA,gCAA2B,MAAM,KAAM;AAEvC,UAAK,+BAA+B,GAAI;AACvC,kCAA0B;AAAA,MAC3B,OAAO;AACN,cAAM,eAAe;AAIrB,aAAK,cAAc,YAAY,aAAa,EAAE,gBAAgB;AAAA,MAC/D;AAAA,IACD;AAEA,SAAK,iBAAkB,eAAe,aAAc;AACpD,SAAK,iBAAkB,WAAW,SAAU;AAC5C,SAAK,iBAAkB,oBAAoB,kBAAmB;AAC9D,WAAO,MAAM;AACZ,WAAK,oBAAqB,eAAe,aAAc;AACvD,WAAK,oBAAqB,WAAW,SAAU;AAC/C,WAAK,oBAAqB,oBAAoB,kBAAmB;AAAA,IAClE;AAAA,EACD,GAAG,CAAC,CAAE;AACP;",
6
- "names": []
4
+ "sourcesContent": ["import { useSelect, useDispatch } from '@wordpress/data';\nimport { useRefEffect } from '@wordpress/compose';\nimport { ENTER, BACKSPACE, DELETE } from '@wordpress/keycodes';\nimport {\n\tcreateBlock,\n\tgetDefaultBlockName,\n\thasBlockSupport,\n\tgetBlockTransforms,\n\tfindTransform,\n} from '@wordpress/blocks';\nimport { store as blockEditorStore } from '../../store';\nimport { setContentEditableWrapper } from './utils';\nimport { getBlockClientId, getSelectionEditableElement } from '../../utils/dom';\n\n/**\n * Handles input for selections across blocks.\n */\nexport default function useInput() {\n\tconst {\n\t\t__unstableIsFullySelected,\n\t\tgetSelectedBlockClientIds,\n\t\tgetSelectedBlockClientId,\n\t\t__unstableIsSelectionMergeable,\n\t\thasMultiSelection,\n\t\tgetBlockName,\n\t\tcanInsertBlockType,\n\t\tgetBlockRootClientId,\n\t\tgetSelectionStart,\n\t\tgetSelectionEnd,\n\t\tgetBlockAttributes,\n\t\tgetNextBlockClientId,\n\t\tgetBlockOrder,\n\t\tgetBlockEditingMode,\n\t\tgetBlockListSettings,\n\t} = useSelect( blockEditorStore );\n\tconst {\n\t\treplaceBlocks,\n\t\t__unstableSplitSelection,\n\t\tremoveBlocks,\n\t\t__unstableDeleteSelection,\n\t\t__unstableExpandSelection,\n\t\t__unstableMarkAutomaticChange,\n\t\tinsertAfterBlock,\n\t\tinsertBlock,\n\t\tselectBlock,\n\t} = useDispatch( blockEditorStore );\n\n\treturn useRefEffect( ( node ) => {\n\t\tfunction onBeforeInput( event ) {\n\t\t\t// If writing flow is editable, never allow the browser to alter\n\t\t\t// the DOM outside of an editable element within a block. This\n\t\t\t// will cause React errors (and the DOM should only be altered in\n\t\t\t// a controlled fashion). The wrapper can be contentEditable with\n\t\t\t// a single selection when the selected block supports\n\t\t\t// `editableRoot`; in that case edits within the block's editable\n\t\t\t// element are handled by its rich text instance.\n\t\t\tif ( node.contentEditable !== 'true' ) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tif ( hasMultiSelection() ) {\n\t\t\t\tevent.preventDefault();\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tconst selection = node.ownerDocument.defaultView.getSelection();\n\n\t\t\tif ( ! getSelectionEditableElement( selection, node ) ) {\n\t\t\t\tevent.preventDefault();\n\t\t\t}\n\t\t}\n\n\t\tfunction onKeyDown( event ) {\n\t\t\tif ( event.defaultPrevented ) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tif ( ! hasMultiSelection() ) {\n\t\t\t\tif ( event.keyCode === ENTER ) {\n\t\t\t\t\tif ( event.shiftKey ) {\n\t\t\t\t\t\treturn;\n\t\t\t\t\t}\n\n\t\t\t\t\tconst clientId = getSelectedBlockClientId();\n\t\t\t\t\tconst blockName = getBlockName( clientId );\n\t\t\t\t\tconst selectionStart = getSelectionStart();\n\t\t\t\t\tconst selectionEnd = getSelectionEnd();\n\n\t\t\t\t\tif (\n\t\t\t\t\t\tselectionStart.attributeKey ===\n\t\t\t\t\t\tselectionEnd.attributeKey\n\t\t\t\t\t) {\n\t\t\t\t\t\tconst selectedAttributeValue =\n\t\t\t\t\t\t\tgetBlockAttributes( clientId )[\n\t\t\t\t\t\t\t\tselectionStart.attributeKey\n\t\t\t\t\t\t\t];\n\t\t\t\t\t\tconst transforms = getBlockTransforms( 'from' ).filter(\n\t\t\t\t\t\t\t( { type } ) => type === 'enter'\n\t\t\t\t\t\t);\n\t\t\t\t\t\tconst transformation = findTransform(\n\t\t\t\t\t\t\ttransforms,\n\t\t\t\t\t\t\t( item ) => {\n\t\t\t\t\t\t\t\treturn item.regExp.test(\n\t\t\t\t\t\t\t\t\tselectedAttributeValue\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\n\t\t\t\t\t\tif ( transformation ) {\n\t\t\t\t\t\t\treplaceBlocks(\n\t\t\t\t\t\t\t\tclientId,\n\t\t\t\t\t\t\t\ttransformation.transform( {\n\t\t\t\t\t\t\t\t\tcontent: selectedAttributeValue,\n\t\t\t\t\t\t\t\t} )\n\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\t__unstableMarkAutomaticChange();\n\t\t\t\t\t\t\treturn;\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\n\t\t\t\t\tconst rootClientId = getBlockRootClientId( clientId );\n\t\t\t\t\tconst { activeElement } = event.target.ownerDocument;\n\n\t\t\t\t\t// Ensure template is not locked.\n\t\t\t\t\tif (\n\t\t\t\t\t\t! __unstableIsFullySelected() &&\n\t\t\t\t\t\t( canInsertBlockType(\n\t\t\t\t\t\t\tgetDefaultBlockName(),\n\t\t\t\t\t\t\trootClientId\n\t\t\t\t\t\t) ||\n\t\t\t\t\t\t\tcanInsertBlockType( blockName, rootClientId ) ) &&\n\t\t\t\t\t\t( hasBlockSupport( blockName, 'splitting', false ) ||\n\t\t\t\t\t\t\tevent.__deprecatedOnSplit )\n\t\t\t\t\t) {\n\t\t\t\t\t\tevent.preventDefault();\n\t\t\t\t\t\t__unstableSplitSelection();\n\t\t\t\t\t} else if (\n\t\t\t\t\t\t// Handle Enter only on the block wrapper itself or\n\t\t\t\t\t\t// an editable element within the block, which may be\n\t\t\t\t\t\t// nested within the wrapper (e.g. Site Title). Other\n\t\t\t\t\t\t// focusable elements (an embed's URL field, an\n\t\t\t\t\t\t// appender button) keep their native Enter behavior.\n\t\t\t\t\t\t( activeElement.getAttribute( 'data-block' ) ===\n\t\t\t\t\t\t\tclientId ||\n\t\t\t\t\t\t\tactiveElement.isContentEditable ) &&\n\t\t\t\t\t\tgetBlockClientId( activeElement ) === clientId\n\t\t\t\t\t) {\n\t\t\t\t\t\t// The default block depends on context: containers\n\t\t\t\t\t\t// such as the gallery define their own default\n\t\t\t\t\t\t// block, which is what insertAfterBlock inserts.\n\t\t\t\t\t\tconst { defaultBlock: directInsertBlock } =\n\t\t\t\t\t\t\t( rootClientId &&\n\t\t\t\t\t\t\t\tgetBlockListSettings( rootClientId ) ) ||\n\t\t\t\t\t\t\t{};\n\n\t\t\t\t\t\tif (\n\t\t\t\t\t\t\tcanInsertBlockType(\n\t\t\t\t\t\t\t\tdirectInsertBlock?.name ??\n\t\t\t\t\t\t\t\t\tgetDefaultBlockName(),\n\t\t\t\t\t\t\t\trootClientId\n\t\t\t\t\t\t\t)\n\t\t\t\t\t\t) {\n\t\t\t\t\t\t\tevent.preventDefault();\n\t\t\t\t\t\t\tinsertAfterBlock( clientId );\n\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\t// Descend into an empty container by inserting\n\t\t\t\t\t\t\t// its default block, the same block an appender\n\t\t\t\t\t\t\t// or ghost would insert.\n\t\t\t\t\t\t\tif ( ! getBlockOrder( clientId ).length ) {\n\t\t\t\t\t\t\t\tconst { defaultBlock } =\n\t\t\t\t\t\t\t\t\tgetBlockListSettings( clientId ) ?? {};\n\t\t\t\t\t\t\t\tconst name =\n\t\t\t\t\t\t\t\t\tdefaultBlock?.name ?? getDefaultBlockName();\n\n\t\t\t\t\t\t\t\tif ( canInsertBlockType( name, clientId ) ) {\n\t\t\t\t\t\t\t\t\tevent.preventDefault();\n\t\t\t\t\t\t\t\t\tinsertBlock(\n\t\t\t\t\t\t\t\t\t\tcreateBlock(\n\t\t\t\t\t\t\t\t\t\t\tname,\n\t\t\t\t\t\t\t\t\t\t\tdefaultBlock?.attributes\n\t\t\t\t\t\t\t\t\t\t),\n\t\t\t\t\t\t\t\t\t\t0,\n\t\t\t\t\t\t\t\t\t\tclientId\n\t\t\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\t\t\treturn;\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\tfunction getNextClientId( id ) {\n\t\t\t\t\t\t\t\tlet nextClientId = null;\n\n\t\t\t\t\t\t\t\twhile (\n\t\t\t\t\t\t\t\t\ttypeof id === 'string' &&\n\t\t\t\t\t\t\t\t\t! ( nextClientId =\n\t\t\t\t\t\t\t\t\t\tgetNextBlockClientId( id ) )\n\t\t\t\t\t\t\t\t) {\n\t\t\t\t\t\t\t\t\tid = getBlockRootClientId( id );\n\t\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\t\treturn nextClientId;\n\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\tlet nextClientId =\n\t\t\t\t\t\t\t\tgetBlockOrder( clientId )[ 0 ] ??\n\t\t\t\t\t\t\t\tgetNextClientId( clientId );\n\n\t\t\t\t\t\t\twhile (\n\t\t\t\t\t\t\t\tnextClientId &&\n\t\t\t\t\t\t\t\tgetBlockEditingMode( nextClientId ) ===\n\t\t\t\t\t\t\t\t\t'disabled'\n\t\t\t\t\t\t\t) {\n\t\t\t\t\t\t\t\tnextClientId = getNextClientId( nextClientId );\n\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\tif ( nextClientId ) {\n\t\t\t\t\t\t\t\tevent.preventDefault();\n\t\t\t\t\t\t\t\t// An initial position of `true` is an\n\t\t\t\t\t\t\t\t// internal sentinel: it focuses the block\n\t\t\t\t\t\t\t\t// wrapper instead of a text field within\n\t\t\t\t\t\t\t\t// it. See useFocusFirstElement.\n\t\t\t\t\t\t\t\tselectBlock( nextClientId, true );\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}\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tif ( event.keyCode === ENTER ) {\n\t\t\t\tsetContentEditableWrapper( node, false );\n\t\t\t\tevent.preventDefault();\n\t\t\t\tif ( __unstableIsFullySelected() ) {\n\t\t\t\t\treplaceBlocks(\n\t\t\t\t\t\tgetSelectedBlockClientIds(),\n\t\t\t\t\t\tcreateBlock( getDefaultBlockName() )\n\t\t\t\t\t);\n\t\t\t\t} else {\n\t\t\t\t\t__unstableSplitSelection();\n\t\t\t\t}\n\t\t\t} else if (\n\t\t\t\tevent.keyCode === BACKSPACE ||\n\t\t\t\tevent.keyCode === DELETE\n\t\t\t) {\n\t\t\t\tsetContentEditableWrapper( node, false );\n\t\t\t\tevent.preventDefault();\n\t\t\t\tif ( __unstableIsFullySelected() ) {\n\t\t\t\t\tremoveBlocks( getSelectedBlockClientIds() );\n\t\t\t\t} else if ( __unstableIsSelectionMergeable() ) {\n\t\t\t\t\t__unstableDeleteSelection( event.keyCode === DELETE );\n\t\t\t\t} else {\n\t\t\t\t\t__unstableExpandSelection();\n\t\t\t\t}\n\t\t\t} else if (\n\t\t\t\t// If key.length is longer than 1, it's a control key that doesn't\n\t\t\t\t// input anything.\n\t\t\t\tevent.key.length === 1 &&\n\t\t\t\t! ( event.metaKey || event.ctrlKey )\n\t\t\t) {\n\t\t\t\tsetContentEditableWrapper( node, false );\n\t\t\t\tif ( __unstableIsSelectionMergeable() ) {\n\t\t\t\t\t__unstableDeleteSelection( event.keyCode === DELETE );\n\t\t\t\t} else {\n\t\t\t\t\tevent.preventDefault();\n\t\t\t\t\t// Safari does not stop default behaviour with either\n\t\t\t\t\t// event.preventDefault() or node.contentEditable = false, so\n\t\t\t\t\t// remove the selection to stop browser manipulation.\n\t\t\t\t\tnode.ownerDocument.defaultView\n\t\t\t\t\t\t.getSelection()\n\t\t\t\t\t\t.removeAllRanges();\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\tfunction onCompositionStart( event ) {\n\t\t\tif ( ! hasMultiSelection() ) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tsetContentEditableWrapper( node, false );\n\n\t\t\tif ( __unstableIsSelectionMergeable() ) {\n\t\t\t\t__unstableDeleteSelection();\n\t\t\t} else {\n\t\t\t\tevent.preventDefault();\n\t\t\t\t// Safari does not stop default behaviour with either\n\t\t\t\t// event.preventDefault() or node.contentEditable = false, so\n\t\t\t\t// remove the selection to stop browser manipulation.\n\t\t\t\tnode.ownerDocument.defaultView.getSelection().removeAllRanges();\n\t\t\t}\n\t\t}\n\n\t\tnode.addEventListener( 'beforeinput', onBeforeInput );\n\t\tnode.addEventListener( 'keydown', onKeyDown );\n\t\tnode.addEventListener( 'compositionstart', onCompositionStart );\n\t\treturn () => {\n\t\t\tnode.removeEventListener( 'beforeinput', onBeforeInput );\n\t\t\tnode.removeEventListener( 'keydown', onKeyDown );\n\t\t\tnode.removeEventListener( 'compositionstart', onCompositionStart );\n\t\t};\n\t}, [] );\n}\n"],
5
+ "mappings": ";AAAA,SAA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O;AAAA,QACrD,OAAO;AACN,gBAAM,eAAe;AAIrB,eAAK,cAAc,YACjB,aAAa,EACb,gBAAgB;AAAA,QACnB;AAAA,MACD;AAAA,IACD;AAEA,aAAS,mBAAoB,OAAQ;AACpC,UAAK,CAAE,kBAAkB,GAAI;AAC5B;AAAA,MACD;AAEA,gCAA2B,MAAM,KAAM;AAEvC,UAAK,+BAA+B,GAAI;AACvC,kCAA0B;AAAA,MAC3B,OAAO;AACN,cAAM,eAAe;AAIrB,aAAK,cAAc,YAAY,aAAa,EAAE,gBAAgB;AAAA,MAC/D;AAAA,IACD;AAEA,SAAK,iBAAkB,eAAe,aAAc;AACpD,SAAK,iBAAkB,WAAW,SAAU;AAC5C,SAAK,iBAAkB,oBAAoB,kBAAmB;AAC9D,WAAO,MAAM;AACZ,WAAK,oBAAqB,eAAe,aAAc;AACvD,WAAK,oBAAqB,WAAW,SAAU;AAC/C,WAAK,oBAAqB,oBAAoB,kBAAmB;AAAA,IAClE;AAAA,EACD,GAAG,CAAC,CAAE;AACP;",
6
+ "names": ["getNextClientId", "nextClientId"]
7
7
  }
@@ -9,11 +9,7 @@ import { __ } from "@wordpress/i18n";
9
9
  import { getColorClassName } from "../components/colors/index.mjs";
10
10
  import InspectorControls from "../components/inspector-controls/index.mjs";
11
11
  import useMultipleOriginColorsAndGradients from "../components/colors-gradients/use-multiple-origin-colors-and-gradients.mjs";
12
- import {
13
- cleanEmptyObject,
14
- shouldSkipSerialization,
15
- useBlockSettings
16
- } from "./utils.mjs";
12
+ import { cleanEmptyObject, shouldSkipSerialization } from "./utils.mjs";
17
13
  import {
18
14
  useHasBorderPanel,
19
15
  useHasBorderPanelControls,
@@ -27,9 +23,11 @@ import {
27
23
  setStyleForState,
28
24
  useBlockStyleState
29
25
  } from "./block-style-state.mjs";
26
+ import { unlock } from "../lock-unlock.mjs";
30
27
  import { jsx } from "react/jsx-runtime";
31
28
  var BORDER_SUPPORT_KEY = "__experimentalBorder";
32
29
  var SHADOW_SUPPORT_KEY = "shadow";
30
+ var EMPTY_ARRAY = [];
33
31
  var getColorByProperty = (colors, property, value) => {
34
32
  let matchedColor;
35
33
  colors.some(
@@ -196,13 +194,33 @@ function hasShadowSupport(blockName) {
196
194
  return hasBlockSupport(blockName, SHADOW_SUPPORT_KEY);
197
195
  }
198
196
  function useBorderPanelLabel({
199
- blockName,
197
+ clientId,
200
198
  hasBorderControl,
201
199
  hasShadowControl
202
200
  } = {}) {
203
- const settings = useBlockSettings(blockName);
201
+ const [color, radius, style, width, shadow] = useSelect(
202
+ (select) => {
203
+ if (!clientId) {
204
+ return EMPTY_ARRAY;
205
+ }
206
+ const { getBlockSettings } = unlock(select(blockEditorStore));
207
+ return getBlockSettings(
208
+ clientId,
209
+ "border.color",
210
+ "border.radius",
211
+ "border.style",
212
+ "border.width",
213
+ "shadow"
214
+ );
215
+ },
216
+ [clientId]
217
+ );
218
+ const settings = useMemo(
219
+ () => ({ border: { color, radius, style, width }, shadow }),
220
+ [color, radius, style, width, shadow]
221
+ );
204
222
  const controls = useHasBorderPanelControls(settings);
205
- if (!hasBorderControl && !hasShadowControl && blockName) {
223
+ if (!hasBorderControl && !hasShadowControl && clientId) {
206
224
  hasBorderControl = controls?.hasBorderColor || controls?.hasBorderStyle || controls?.hasBorderWidth || controls?.hasBorderRadius;
207
225
  hasShadowControl = controls?.hasShadow;
208
226
  }
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../src/hooks/border.js"],
4
- "sourcesContent": ["import clsx from 'clsx';\nimport { hasBlockSupport, getBlockSupport } from '@wordpress/blocks';\nimport { __experimentalHasSplitBorders as hasSplitBorders } from '@wordpress/components';\nimport { useCallback, useMemo } from '@wordpress/element';\nimport { addFilter } from '@wordpress/hooks';\nimport { useSelect } from '@wordpress/data';\nimport { __ } from '@wordpress/i18n';\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\tuseHasBorderPanelControls,\n\tBorderPanel as StylesBorderPanel,\n} from '../components/global-styles';\nimport { useResolvedStyle } from '../components/global-styles/inherited-value-context';\nimport { store as blockEditorStore } from '../store';\nimport {\n\tgetStyleForState,\n\tisDefaultBlockStyleState,\n\tsetStyleForState,\n\tuseBlockStyleState,\n} from './block-style-state';\n\nexport const BORDER_SUPPORT_KEY = '__experimentalBorder';\nexport const SHADOW_SUPPORT_KEY = 'shadow';\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( { label, 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\tlabel={ label }\n\t\t>\n\t\t\t{ children }\n\t\t</InspectorControls>\n\t);\n}\n\nexport function BorderPanel( { clientId, name, setAttributes, settings } ) {\n\tconst selectedState = useBlockStyleState();\n\tconst isEnabled = useHasBorderPanel( settings );\n\tconst { style, borderColor, className } = useSelect(\n\t\t( select ) => {\n\t\t\t// Early return to avoid subscription when disabled\n\t\t\tif ( ! isEnabled ) {\n\t\t\t\treturn {};\n\t\t\t}\n\t\t\tconst {\n\t\t\t\tstyle: _style,\n\t\t\t\tborderColor: _borderColor,\n\t\t\t\tclassName: _className,\n\t\t\t} = select( blockEditorStore ).getBlockAttributes( clientId ) || {};\n\t\t\treturn {\n\t\t\t\tstyle: _style,\n\t\t\t\tborderColor: _borderColor,\n\t\t\t\tclassName: _className,\n\t\t\t};\n\t\t},\n\t\t[ clientId, isEnabled ]\n\t);\n\n\tconst { value: inheritedValue } = useResolvedStyle(\n\t\tname,\n\t\tclassName,\n\t\tselectedState\n\t);\n\n\tconst isStateSelected = ! isDefaultBlockStyleState( selectedState );\n\n\tconst value = useMemo( () => {\n\t\tif ( isStateSelected ) {\n\t\t\treturn getStyleForState( style, selectedState );\n\t\t}\n\t\treturn attributesToStyle( { style, borderColor } );\n\t}, [ isStateSelected, selectedState, style, borderColor ] );\n\n\tconst onChange = isStateSelected\n\t\t? ( newStyle ) => {\n\t\t\t\tsetAttributes( {\n\t\t\t\t\tstyle: setStyleForState( style, selectedState, newStyle ),\n\t\t\t\t} );\n\t\t }\n\t\t: ( newStyle ) => {\n\t\t\t\tsetAttributes( styleToAttributes( newStyle ) );\n\t\t };\n\n\tif ( ! isEnabled ) {\n\t\treturn null;\n\t}\n\n\tconst defaultControls = {\n\t\t...getBlockSupport( name, [\n\t\t\tBORDER_SUPPORT_KEY,\n\t\t\t'__experimentalDefaultControls',\n\t\t] ),\n\t\t...getBlockSupport( name, [\n\t\t\tSHADOW_SUPPORT_KEY,\n\t\t\t'__experimentalDefaultControls',\n\t\t] ),\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\tinheritedValue={ inheritedValue }\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\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 * Determine whether there is block support for shadow properties.\n *\n * @param {string} blockName Block name.\n *\n * @return {boolean} Whether there is support.\n */\nexport function hasShadowSupport( blockName ) {\n\treturn hasBlockSupport( blockName, SHADOW_SUPPORT_KEY );\n}\n\nexport function useBorderPanelLabel( {\n\tblockName,\n\thasBorderControl,\n\thasShadowControl,\n} = {} ) {\n\tconst settings = useBlockSettings( blockName );\n\tconst controls = useHasBorderPanelControls( settings );\n\n\tif ( ! hasBorderControl && ! hasShadowControl && blockName ) {\n\t\thasBorderControl =\n\t\t\tcontrols?.hasBorderColor ||\n\t\t\tcontrols?.hasBorderStyle ||\n\t\t\tcontrols?.hasBorderWidth ||\n\t\t\tcontrols?.hasBorderRadius;\n\t\thasShadowControl = controls?.hasShadow;\n\t}\n\n\tif ( hasBorderControl && hasShadowControl ) {\n\t\treturn __( 'Border & Shadow' );\n\t}\n\n\tif ( hasShadowControl ) {\n\t\treturn __( 'Shadow' );\n\t}\n\n\treturn __( 'Border' );\n}\n\n/**\n * Returns a new style object where the specified border attribute has been\n * removed.\n *\n * @param {Object} style Styles from block attributes.\n * @param {string} attribute The border style attribute to clear.\n *\n * @return {Object} Style object with the specified attribute removed.\n */\nexport function removeBorderAttribute( style, attribute ) {\n\treturn cleanEmptyObject( {\n\t\t...style,\n\t\tborder: {\n\t\t\t...style?.border,\n\t\t\t[ attribute ]: undefined,\n\t\t},\n\t} );\n}\n\n/**\n * Filters registered block settings, extending attributes to include\n * `borderColor` if needed.\n *\n * @param {Object} settings Original block settings.\n *\n * @return {Object} Updated block settings.\n */\nfunction addAttributes( settings ) {\n\tif ( ! hasBorderSupport( settings, 'color' ) ) {\n\t\treturn settings;\n\t}\n\n\t// Allow blocks to specify default value if needed.\n\tif ( settings.attributes.borderColor ) {\n\t\treturn settings;\n\t}\n\n\t// Add new borderColor attribute to block settings.\n\treturn {\n\t\t...settings,\n\t\tattributes: {\n\t\t\t...settings.attributes,\n\t\t\tborderColor: {\n\t\t\t\ttype: 'string',\n\t\t\t},\n\t\t},\n\t};\n}\n\n/**\n * Override props assigned to save component to inject border color.\n *\n * @param {Object} props Additional props applied to save element.\n * @param {Object|string} blockNameOrType Block type definition.\n * @param {Object} attributes Block's attributes.\n *\n * @return {Object} Filtered props to apply to save element.\n */\nfunction addSaveProps( props, blockNameOrType, attributes ) {\n\tif (\n\t\t! hasBorderSupport( blockNameOrType, 'color' ) ||\n\t\tshouldSkipSerialization( blockNameOrType, BORDER_SUPPORT_KEY, 'color' )\n\t) {\n\t\treturn props;\n\t}\n\n\tconst borderClasses = getBorderClasses( attributes );\n\tconst newClassName = clsx( 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 clsx( {\n\t\t'has-border-color': borderColor || style?.border?.color,\n\t\t[ borderColorClass ]: !! borderColorClass,\n\t} );\n}\n\nfunction useBlockProps( { name, borderColor, style } ) {\n\tconst { colors } = useMultipleOriginColorsAndGradients();\n\n\tif (\n\t\t! hasBorderSupport( name, 'color' ) ||\n\t\tshouldSkipSerialization( name, BORDER_SUPPORT_KEY, 'color' )\n\t) {\n\t\treturn {};\n\t}\n\n\tconst { color: borderColorValue } = getMultiOriginColor( {\n\t\tcolors,\n\t\tnamedColor: borderColor,\n\t} );\n\tconst { color: borderTopColor } = getMultiOriginColor( {\n\t\tcolors,\n\t\tnamedColor: getColorSlugFromVariable( style?.border?.top?.color ),\n\t} );\n\tconst { color: borderRightColor } = getMultiOriginColor( {\n\t\tcolors,\n\t\tnamedColor: getColorSlugFromVariable( style?.border?.right?.color ),\n\t} );\n\n\tconst { color: borderBottomColor } = getMultiOriginColor( {\n\t\tcolors,\n\t\tnamedColor: getColorSlugFromVariable( style?.border?.bottom?.color ),\n\t} );\n\tconst { color: borderLeftColor } = getMultiOriginColor( {\n\t\tcolors,\n\t\tnamedColor: getColorSlugFromVariable( style?.border?.left?.color ),\n\t} );\n\n\tconst extraStyles = {\n\t\tborderTopColor: borderTopColor || borderColorValue,\n\t\tborderRightColor: borderRightColor || borderColorValue,\n\t\tborderBottomColor: borderBottomColor || borderColorValue,\n\t\tborderLeftColor: borderLeftColor || borderColorValue,\n\t};\n\n\treturn addSaveProps(\n\t\t{ style: cleanEmptyObject( extraStyles ) || {} },\n\t\tname,\n\t\t{ borderColor, style }\n\t);\n}\n\nexport default {\n\tuseBlockProps,\n\taddSaveProps,\n\tattributeKeys: [ 'borderColor', 'style' ],\n\thasSupport( name ) {\n\t\treturn hasBorderSupport( name, 'color' );\n\t},\n};\n\naddFilter(\n\t'blocks.registerBlockType',\n\t'core/border/addAttributes',\n\taddAttributes\n);\n"],
5
- "mappings": ";AAAA,OAAO,UAAU;AACjB,SAAS,iBAAiB,uBAAuB;AACjD,SAAS,iCAAiC,uBAAuB;AACjE,SAAS,aAAa,eAAe;AACrC,SAAS,iBAAiB;AAC1B,SAAS,iBAAiB;AAC1B,SAAS,UAAU;AACnB,SAAS,yBAAyB;AAClC,OAAO,uBAAuB;AAC9B,OAAO,yCAAyC;AAChD;AAAA,EACC;AAAA,EACA;AAAA,EACA;AAAA,OACM;AACP;AAAA,EACC;AAAA,EACA;AAAA,EACA,eAAe;AAAA,OACT;AACP,SAAS,wBAAwB;AACjC,SAAS,SAAS,wBAAw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iBAAQ;AAAA,EACd;AAAA,EACA;AAAA,EACA,eAAe,CAAE,eAAe,OAAQ;AAAA,EACxC,WAAY,MAAO;AAClB,WAAO,iBAAkB,MAAM,OAAQ;AAAA,EACxC;AACD;AAEA;AAAA,EACC;AAAA,EACA;AAAA,EACA;AACD;",
4
+ "sourcesContent": ["import clsx from 'clsx';\nimport { hasBlockSupport, getBlockSupport } from '@wordpress/blocks';\nimport { __experimentalHasSplitBorders as hasSplitBorders } from '@wordpress/components';\nimport { useCallback, useMemo } from '@wordpress/element';\nimport { addFilter } from '@wordpress/hooks';\nimport { useSelect } from '@wordpress/data';\nimport { __ } from '@wordpress/i18n';\nimport { getColorClassName } from '../components/colors';\nimport InspectorControls from '../components/inspector-controls';\nimport useMultipleOriginColorsAndGradients from '../components/colors-gradients/use-multiple-origin-colors-and-gradients';\nimport { cleanEmptyObject, shouldSkipSerialization } from './utils';\nimport {\n\tuseHasBorderPanel,\n\tuseHasBorderPanelControls,\n\tBorderPanel as StylesBorderPanel,\n} from '../components/global-styles';\nimport { useResolvedStyle } from '../components/global-styles/inherited-value-context';\nimport { store as blockEditorStore } from '../store';\nimport {\n\tgetStyleForState,\n\tisDefaultBlockStyleState,\n\tsetStyleForState,\n\tuseBlockStyleState,\n} from './block-style-state';\nimport { unlock } from '../lock-unlock';\n\nexport const BORDER_SUPPORT_KEY = '__experimentalBorder';\nexport const SHADOW_SUPPORT_KEY = 'shadow';\n\nconst EMPTY_ARRAY = [];\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( { label, 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\tlabel={ label }\n\t\t>\n\t\t\t{ children }\n\t\t</InspectorControls>\n\t);\n}\n\nexport function BorderPanel( { clientId, name, setAttributes, settings } ) {\n\tconst selectedState = useBlockStyleState();\n\tconst isEnabled = useHasBorderPanel( settings );\n\tconst { style, borderColor, className } = useSelect(\n\t\t( select ) => {\n\t\t\t// Early return to avoid subscription when disabled\n\t\t\tif ( ! isEnabled ) {\n\t\t\t\treturn {};\n\t\t\t}\n\t\t\tconst {\n\t\t\t\tstyle: _style,\n\t\t\t\tborderColor: _borderColor,\n\t\t\t\tclassName: _className,\n\t\t\t} = select( blockEditorStore ).getBlockAttributes( clientId ) || {};\n\t\t\treturn {\n\t\t\t\tstyle: _style,\n\t\t\t\tborderColor: _borderColor,\n\t\t\t\tclassName: _className,\n\t\t\t};\n\t\t},\n\t\t[ clientId, isEnabled ]\n\t);\n\n\tconst { value: inheritedValue } = useResolvedStyle(\n\t\tname,\n\t\tclassName,\n\t\tselectedState\n\t);\n\n\tconst isStateSelected = ! isDefaultBlockStyleState( selectedState );\n\n\tconst value = useMemo( () => {\n\t\tif ( isStateSelected ) {\n\t\t\treturn getStyleForState( style, selectedState );\n\t\t}\n\t\treturn attributesToStyle( { style, borderColor } );\n\t}, [ isStateSelected, selectedState, style, borderColor ] );\n\n\tconst onChange = isStateSelected\n\t\t? ( newStyle ) => {\n\t\t\t\tsetAttributes( {\n\t\t\t\t\tstyle: setStyleForState( style, selectedState, newStyle ),\n\t\t\t\t} );\n\t\t }\n\t\t: ( newStyle ) => {\n\t\t\t\tsetAttributes( styleToAttributes( newStyle ) );\n\t\t };\n\n\tif ( ! isEnabled ) {\n\t\treturn null;\n\t}\n\n\tconst defaultControls = {\n\t\t...getBlockSupport( name, [\n\t\t\tBORDER_SUPPORT_KEY,\n\t\t\t'__experimentalDefaultControls',\n\t\t] ),\n\t\t...getBlockSupport( name, [\n\t\t\tSHADOW_SUPPORT_KEY,\n\t\t\t'__experimentalDefaultControls',\n\t\t] ),\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\tinheritedValue={ inheritedValue }\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\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 * Determine whether there is block support for shadow properties.\n *\n * @param {string} blockName Block name.\n *\n * @return {boolean} Whether there is support.\n */\nexport function hasShadowSupport( blockName ) {\n\treturn hasBlockSupport( blockName, SHADOW_SUPPORT_KEY );\n}\n\nexport function useBorderPanelLabel( {\n\tclientId,\n\thasBorderControl,\n\thasShadowControl,\n} = {} ) {\n\tconst [ color, radius, style, width, shadow ] = useSelect(\n\t\t( select ) => {\n\t\t\tif ( ! clientId ) {\n\t\t\t\treturn EMPTY_ARRAY;\n\t\t\t}\n\t\t\tconst { getBlockSettings } = unlock( select( blockEditorStore ) );\n\t\t\treturn getBlockSettings(\n\t\t\t\tclientId,\n\t\t\t\t'border.color',\n\t\t\t\t'border.radius',\n\t\t\t\t'border.style',\n\t\t\t\t'border.width',\n\t\t\t\t'shadow'\n\t\t\t);\n\t\t},\n\t\t[ clientId ]\n\t);\n\tconst settings = useMemo(\n\t\t() => ( { border: { color, radius, style, width }, shadow } ),\n\t\t[ color, radius, style, width, shadow ]\n\t);\n\tconst controls = useHasBorderPanelControls( settings );\n\n\tif ( ! hasBorderControl && ! hasShadowControl && clientId ) {\n\t\thasBorderControl =\n\t\t\tcontrols?.hasBorderColor ||\n\t\t\tcontrols?.hasBorderStyle ||\n\t\t\tcontrols?.hasBorderWidth ||\n\t\t\tcontrols?.hasBorderRadius;\n\t\thasShadowControl = controls?.hasShadow;\n\t}\n\n\tif ( hasBorderControl && hasShadowControl ) {\n\t\treturn __( 'Border & Shadow' );\n\t}\n\n\tif ( hasShadowControl ) {\n\t\treturn __( 'Shadow' );\n\t}\n\n\treturn __( 'Border' );\n}\n\n/**\n * Returns a new style object where the specified border attribute has been\n * removed.\n *\n * @param {Object} style Styles from block attributes.\n * @param {string} attribute The border style attribute to clear.\n *\n * @return {Object} Style object with the specified attribute removed.\n */\nexport function removeBorderAttribute( style, attribute ) {\n\treturn cleanEmptyObject( {\n\t\t...style,\n\t\tborder: {\n\t\t\t...style?.border,\n\t\t\t[ attribute ]: undefined,\n\t\t},\n\t} );\n}\n\n/**\n * Filters registered block settings, extending attributes to include\n * `borderColor` if needed.\n *\n * @param {Object} settings Original block settings.\n *\n * @return {Object} Updated block settings.\n */\nfunction addAttributes( settings ) {\n\tif ( ! hasBorderSupport( settings, 'color' ) ) {\n\t\treturn settings;\n\t}\n\n\t// Allow blocks to specify default value if needed.\n\tif ( settings.attributes.borderColor ) {\n\t\treturn settings;\n\t}\n\n\t// Add new borderColor attribute to block settings.\n\treturn {\n\t\t...settings,\n\t\tattributes: {\n\t\t\t...settings.attributes,\n\t\t\tborderColor: {\n\t\t\t\ttype: 'string',\n\t\t\t},\n\t\t},\n\t};\n}\n\n/**\n * Override props assigned to save component to inject border color.\n *\n * @param {Object} props Additional props applied to save element.\n * @param {Object|string} blockNameOrType Block type definition.\n * @param {Object} attributes Block's attributes.\n *\n * @return {Object} Filtered props to apply to save element.\n */\nfunction addSaveProps( props, blockNameOrType, attributes ) {\n\tif (\n\t\t! hasBorderSupport( blockNameOrType, 'color' ) ||\n\t\tshouldSkipSerialization( blockNameOrType, BORDER_SUPPORT_KEY, 'color' )\n\t) {\n\t\treturn props;\n\t}\n\n\tconst borderClasses = getBorderClasses( attributes );\n\tconst newClassName = clsx( 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 clsx( {\n\t\t'has-border-color': borderColor || style?.border?.color,\n\t\t[ borderColorClass ]: !! borderColorClass,\n\t} );\n}\n\nfunction useBlockProps( { name, borderColor, style } ) {\n\tconst { colors } = useMultipleOriginColorsAndGradients();\n\n\tif (\n\t\t! hasBorderSupport( name, 'color' ) ||\n\t\tshouldSkipSerialization( name, BORDER_SUPPORT_KEY, 'color' )\n\t) {\n\t\treturn {};\n\t}\n\n\tconst { color: borderColorValue } = getMultiOriginColor( {\n\t\tcolors,\n\t\tnamedColor: borderColor,\n\t} );\n\tconst { color: borderTopColor } = getMultiOriginColor( {\n\t\tcolors,\n\t\tnamedColor: getColorSlugFromVariable( style?.border?.top?.color ),\n\t} );\n\tconst { color: borderRightColor } = getMultiOriginColor( {\n\t\tcolors,\n\t\tnamedColor: getColorSlugFromVariable( style?.border?.right?.color ),\n\t} );\n\n\tconst { color: borderBottomColor } = getMultiOriginColor( {\n\t\tcolors,\n\t\tnamedColor: getColorSlugFromVariable( style?.border?.bottom?.color ),\n\t} );\n\tconst { color: borderLeftColor } = getMultiOriginColor( {\n\t\tcolors,\n\t\tnamedColor: getColorSlugFromVariable( style?.border?.left?.color ),\n\t} );\n\n\tconst extraStyles = {\n\t\tborderTopColor: borderTopColor || borderColorValue,\n\t\tborderRightColor: borderRightColor || borderColorValue,\n\t\tborderBottomColor: borderBottomColor || borderColorValue,\n\t\tborderLeftColor: borderLeftColor || borderColorValue,\n\t};\n\n\treturn addSaveProps(\n\t\t{ style: cleanEmptyObject( extraStyles ) || {} },\n\t\tname,\n\t\t{ borderColor, style }\n\t);\n}\n\nexport default {\n\tuseBlockProps,\n\taddSaveProps,\n\tattributeKeys: [ 'borderColor', 'style' ],\n\thasSupport( name ) {\n\t\treturn hasBorderSupport( name, 'color' );\n\t},\n};\n\naddFilter(\n\t'blocks.registerBlockType',\n\t'core/border/addAttributes',\n\taddAttributes\n);\n"],
5
+ "mappings": ";AAAA,OAAO,UAAU;AACjB,SAAS,iBAAiB,uBAAuB;AACjD,SAAS,iCAAiC,uBAAuB;AACjE,SAAS,aAAa,eAAe;AACrC,SAAS,iBAAiB;AAC1B,SAAS,iBAAiB;AAC1B,SAAS,UAAU;AACnB,SAAS,yBAAyB;AAClC,OAAO,uBAAuB;AAC9B,OAAO,yCAAyC;AAChD,SAAS,kBAAkB,+BAA+B;AAC1D;AAAA,EACC;AAAA,EACA;AAAA,EACA,eAAe;AAAA,OACT;AACP,SAAS,wBAAwB;AACjC,SAAS,SAAS,wBAAwB;AAC1C;AAAA,EACC;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACM;AACP,SAAS,cAAc;AAuGrB;AArGK,IAAM,qBAAqB;AAC3B,IAAM,qBAAqB;AAElC,IAAM,cAAc,CAAC;AAErB,IAAM,qBAAqB,CAAE,QAAQ,UAAU,UAAW;AACzD,MAAI;AAEJ,SAAO;AAAA,IAAM,CAAE,WACd,OAAO,OAAO,KAAM,CAAE,UAAW;AAChC,UAAK,MAAO,QAAS,MAAM,OAAQ;AAClC,uBAAe;AACf,eAAO;AAA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AEA,SAAO;AAAA,IACN,EAAE,OAAO,iBAAkB,WAAY,KAAK,CAAC,EAAE;AAAA,IAC/C;AAAA,IACA,EAAE,aAAa,MAAM;AAAA,EACtB;AACD;AAEA,IAAO,iBAAQ;AAAA,EACd;AAAA,EACA;AAAA,EACA,eAAe,CAAE,eAAe,OAAQ;AAAA,EACxC,WAAY,MAAO;AAClB,WAAO,iBAAkB,MAAM,OAAQ;AAAA,EACxC;AACD;AAEA;AAAA,EACC;AAAA,EACA;AAAA,EACA;AACD;",
6
6
  "names": ["colorObject"]
7
7
  }
@@ -20,6 +20,7 @@ import {
20
20
  setStyleForState,
21
21
  useBlockStyleState
22
22
  } from "./block-style-state.mjs";
23
+ import { isAxialBlockGapAllowed } from "./gap.mjs";
23
24
  import { Fragment, jsx, jsxs } from "react/jsx-runtime";
24
25
  var DIMENSIONS_SUPPORT_KEY = "dimensions";
25
26
  var SPACING_SUPPORT_KEY = "spacing";
@@ -64,7 +65,7 @@ function DimensionsPanel({ clientId, name, setAttributes, settings }) {
64
65
  const selectedState = useBlockStyleState();
65
66
  const isStateSelected = !isDefaultBlockStyleState(selectedState);
66
67
  const isEnabled = useHasDimensionsPanel(settings, selectedState);
67
- const { style, className } = useSelect(
68
+ const { style, className, layout } = useSelect(
68
69
  (select) => {
69
70
  if (!isEnabled) {
70
71
  return {};
@@ -72,7 +73,8 @@ function DimensionsPanel({ clientId, name, setAttributes, settings }) {
72
73
  const attributes = select(blockEditorStore).getBlockAttributes(clientId) || {};
73
74
  return {
74
75
  style: attributes.style,
75
- className: attributes.className
76
+ className: attributes.className,
77
+ layout: attributes.layout
76
78
  };
77
79
  },
78
80
  [clientId, isEnabled]
@@ -104,6 +106,7 @@ function DimensionsPanel({ clientId, name, setAttributes, settings }) {
104
106
  SPACING_SUPPORT_KEY,
105
107
  "__experimentalDefaultControls"
106
108
  ]);
109
+ const { default: defaultLayout } = getBlockSupport(name, "layout") || {};
107
110
  const defaultControls = {
108
111
  // In the block inspector, minHeight and minWidth should not
109
112
  // be shown by default unless the block explicitly opts in.
@@ -119,6 +122,10 @@ function DimensionsPanel({ clientId, name, setAttributes, settings }) {
119
122
  as: DimensionsInspectorControl,
120
123
  panelId: clientId,
121
124
  settings,
125
+ allowAxialBlockGap: isAxialBlockGapAllowed(
126
+ layout,
127
+ defaultLayout
128
+ ),
122
129
  value,
123
130
  onChange,
124
131
  defaultControls,
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../src/hooks/dimensions.js"],
4
- "sourcesContent": ["import clsx from 'clsx';\nimport { useState, useEffect, useCallback } from '@wordpress/element';\nimport { useDispatch, useSelect } from '@wordpress/data';\nimport { getBlockSupport } from '@wordpress/blocks';\nimport deprecated from '@wordpress/deprecated';\nimport InspectorControls from '../components/inspector-controls';\nimport {\n\tDimensionsPanel as StylesDimensionsPanel,\n\tuseHasDimensionsPanel,\n} from '../components/global-styles';\nimport { useResolvedStyle } from '../components/global-styles/inherited-value-context';\nimport { MarginVisualizer, PaddingVisualizer } from './spacing-visualizer';\nimport { store as blockEditorStore } from '../store';\nimport { unlock } from '../lock-unlock';\nimport { cleanEmptyObject, shouldSkipSerialization } from './utils';\nimport {\n\tgetStyleForState,\n\tisDefaultBlockStyleState,\n\tsetStyleForState,\n\tuseBlockStyleState,\n} from './block-style-state';\n\nexport const DIMENSIONS_SUPPORT_KEY = 'dimensions';\nexport const SPACING_SUPPORT_KEY = 'spacing';\nexport const ALL_SIDES = [ 'top', 'right', 'bottom', 'left' ];\nexport const AXIAL_SIDES = [ 'vertical', 'horizontal' ];\n\nfunction useVisualizer() {\n\tconst [ property, setProperty ] = useState( false );\n\tconst { hideBlockInterface, showBlockInterface } = unlock(\n\t\tuseDispatch( blockEditorStore )\n\t);\n\tuseEffect( () => {\n\t\tif ( ! property ) {\n\t\t\tshowBlockInterface();\n\t\t} else {\n\t\t\thideBlockInterface();\n\t\t}\n\t}, [ property, showBlockInterface, hideBlockInterface ] );\n\n\treturn [ property, setProperty ];\n}\n\nfunction DimensionsInspectorControl( { children, resetAllFilter } ) {\n\tconst attributesResetAllFilter = useCallback(\n\t\t( attributes ) => {\n\t\t\tconst existingStyle = attributes.style;\n\t\t\tconst updatedStyle = resetAllFilter( existingStyle );\n\t\t\treturn {\n\t\t\t\t...attributes,\n\t\t\t\tstyle: 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=\"dimensions\"\n\t\t\tresetAllFilter={ attributesResetAllFilter }\n\t\t>\n\t\t\t{ children }\n\t\t</InspectorControls>\n\t);\n}\n\nexport function DimensionsPanel( { clientId, name, setAttributes, settings } ) {\n\tconst selectedState = useBlockStyleState();\n\tconst isStateSelected = ! isDefaultBlockStyleState( selectedState );\n\tconst isEnabled = useHasDimensionsPanel( settings, selectedState );\n\tconst { style, className } = useSelect(\n\t\t( select ) => {\n\t\t\t// Early return to avoid subscription when disabled\n\t\t\tif ( ! isEnabled ) {\n\t\t\t\treturn {};\n\t\t\t}\n\t\t\tconst attributes =\n\t\t\t\tselect( blockEditorStore ).getBlockAttributes( clientId ) || {};\n\t\t\treturn {\n\t\t\t\tstyle: attributes.style,\n\t\t\t\tclassName: attributes.className,\n\t\t\t};\n\t\t},\n\t\t[ clientId, isEnabled ]\n\t);\n\n\tconst { value: inheritedValue } = useResolvedStyle(\n\t\tname,\n\t\tclassName,\n\t\tselectedState\n\t);\n\n\tconst [ visualizedProperty, setVisualizedProperty ] = useVisualizer();\n\tconst value = isStateSelected\n\t\t? getStyleForState( style, selectedState )\n\t\t: style;\n\tconst onChange = isStateSelected\n\t\t? ( newStyle ) => {\n\t\t\t\tsetAttributes( {\n\t\t\t\t\tstyle: setStyleForState( style, selectedState, newStyle ),\n\t\t\t\t} );\n\t\t }\n\t\t: ( newStyle ) => {\n\t\t\t\tsetAttributes( {\n\t\t\t\t\tstyle: cleanEmptyObject( newStyle ),\n\t\t\t\t} );\n\t\t };\n\n\tif ( ! isEnabled ) {\n\t\treturn null;\n\t}\n\n\tconst defaultDimensionsControls = getBlockSupport( name, [\n\t\tDIMENSIONS_SUPPORT_KEY,\n\t\t'__experimentalDefaultControls',\n\t] );\n\tconst defaultSpacingControls = getBlockSupport( name, [\n\t\tSPACING_SUPPORT_KEY,\n\t\t'__experimentalDefaultControls',\n\t] );\n\tconst defaultControls = {\n\t\t// In the block inspector, minHeight and minWidth should not\n\t\t// be shown by default unless the block explicitly opts in.\n\t\tminHeight: false,\n\t\tminWidth: false,\n\t\t...defaultDimensionsControls,\n\t\t...defaultSpacingControls,\n\t};\n\n\treturn (\n\t\t<>\n\t\t\t<StylesDimensionsPanel\n\t\t\t\tas={ DimensionsInspectorControl }\n\t\t\t\tpanelId={ clientId }\n\t\t\t\tsettings={ settings }\n\t\t\t\tvalue={ value }\n\t\t\t\tonChange={ onChange }\n\t\t\t\tdefaultControls={ defaultControls }\n\t\t\t\tstyleState={ selectedState }\n\t\t\t\tonVisualize={\n\t\t\t\t\tisStateSelected ? undefined : setVisualizedProperty\n\t\t\t\t}\n\t\t\t\tinheritedValue={ inheritedValue }\n\t\t\t/>\n\t\t\t{ ! isStateSelected &&\n\t\t\t\t!! settings?.spacing?.padding &&\n\t\t\t\tvisualizedProperty === 'padding' && (\n\t\t\t\t\t<PaddingVisualizer\n\t\t\t\t\t\tforceShow={ visualizedProperty === 'padding' }\n\t\t\t\t\t\tclientId={ clientId }\n\t\t\t\t\t\tvalue={ value }\n\t\t\t\t\t/>\n\t\t\t\t) }\n\t\t\t{ ! isStateSelected &&\n\t\t\t\t!! settings?.spacing?.margin &&\n\t\t\t\tvisualizedProperty === 'margin' && (\n\t\t\t\t\t<MarginVisualizer\n\t\t\t\t\t\tforceShow={ visualizedProperty === 'margin' }\n\t\t\t\t\t\tclientId={ clientId }\n\t\t\t\t\t\tvalue={ value }\n\t\t\t\t\t/>\n\t\t\t\t) }\n\t\t</>\n\t);\n}\n\n/**\n * Determine whether there is block support for dimensions.\n *\n * @param {string} blockName Block name.\n * @param {string} feature Background image feature to check for.\n *\n * @return {boolean} Whether there is support.\n */\nexport function hasDimensionsSupport( blockName, feature = 'any' ) {\n\tconst support = getBlockSupport( blockName, DIMENSIONS_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?.aspectRatio ||\n\t\t\t!! support?.height ||\n\t\t\t!! support?.minHeight ||\n\t\t\t!! support?.width ||\n\t\t\t!! support?.minWidth\n\t\t);\n\t}\n\n\treturn !! support?.[ feature ];\n}\n\nexport function isExplicitAspectRatio( aspectRatio ) {\n\tif ( ! aspectRatio ) {\n\t\treturn false;\n\t}\n\n\treturn `${ aspectRatio }`.trim().toLowerCase() !== 'auto';\n}\n\nexport default {\n\tuseBlockProps,\n\tattributeKeys: [ 'height', 'minHeight', 'width', 'style' ],\n\thasSupport( name ) {\n\t\treturn hasDimensionsSupport( name );\n\t},\n};\n\nfunction useBlockProps( { name, height, minHeight, style } ) {\n\tif (\n\t\t! hasDimensionsSupport( name, 'aspectRatio' ) ||\n\t\tshouldSkipSerialization( name, DIMENSIONS_SUPPORT_KEY, 'aspectRatio' )\n\t) {\n\t\treturn {};\n\t}\n\n\tconst hasExplicitAspectRatio = isExplicitAspectRatio(\n\t\tstyle?.dimensions?.aspectRatio\n\t);\n\tconst className = clsx( {\n\t\t'has-aspect-ratio': hasExplicitAspectRatio,\n\t} );\n\n\t// Allow dimensions-based inline style overrides to override any global styles rules that\n\t// might be set for the block, and therefore affect the display of the aspect ratio.\n\tconst inlineStyleOverrides = {};\n\n\t// Apply rules to unset incompatible styles.\n\t// Note that an explicit `aspectRatio` will win out if both an aspect ratio and height-related properties are set.\n\t// This is because the aspect ratio is a newer block support, so (in theory) any aspect ratio\n\t// that is set should be intentional and should override any existing height properties. The Cover block\n\t// and dimensions controls have logic that will manually clear the aspect ratio if height properties\n\t// are set.\n\tif ( hasExplicitAspectRatio ) {\n\t\t// To ensure the aspect ratio does not get overridden by `minHeight` or `height` unset any existing rule.\n\t\tinlineStyleOverrides.minHeight = 'unset';\n\t\tinlineStyleOverrides.height = 'unset';\n\t} else if (\n\t\tminHeight ||\n\t\tstyle?.dimensions?.minHeight ||\n\t\theight ||\n\t\tstyle?.dimensions?.height\n\t) {\n\t\t// To ensure height properties do not get overridden by `aspectRatio` unset any existing rule.\n\t\tinlineStyleOverrides.aspectRatio = 'unset';\n\t}\n\n\treturn { className, style: inlineStyleOverrides };\n}\n\n/**\n * @deprecated\n */\nexport function useCustomSides() {\n\tdeprecated( 'wp.blockEditor.__experimentalUseCustomSides', {\n\t\tsince: '6.3',\n\t\tversion: '6.4',\n\t} );\n}\n"],
5
- "mappings": ";AAAA,OAAO,UAAU;AACjB,SAAS,UAAU,WAAW,mBAAmB;AACjD,SAAS,aAAa,iBAAiB;AACvC,SAAS,uBAAuB;AAChC,OAAO,gBAAgB;AACvB,OAAO,uBAAuB;AAC9B;AAAA,EACC,mBAAmB;AAAA,EACnB;AAAA,OACM;AACP,SAAS,wBAAwB;AACjC,SAAS,kBAAkB,yBAAyB;AACpD,SAAS,SAAS,wBAAwB;AAC1C,SAAS,cAAc;AACvB,SAAS,kBAAkB,+BAA+B;AAC1D;AAAA,EACC;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACM;AAqCL,SAyEA,UAzEA,KAyEA,YAzEA;AAnCK,IAAM,yBAAyB;AAC/B,IAAM,sBAAsB;AAC5B,IAAM,YAAY,CAAE,OAAO,SAAS,UAAU,MAAO;AACrD,IAAM,cAAc,CAAE,YAAY,YAAa;AAEtD,SAAS,gBAAgB;AACxB,QAAM,CAAE,UAAU,WAAY,IAAI,SAAU,KAAM;AAClD,QAAM,EAAE,oBAAoB,mBAAmB,IAAI;AAAA,IAClD,YAAa,gBAAiB;AAAA,EAC/B;AACA,YAAW,MAAM;AAChB,QAAK,CAAE,UAAW;AACjB,yBAAmB;AAAA,IACpB,OAAO;AACN,yBAAmB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B;AAEO,SAAS,sBAAuB,aAAc;AACpD,MAAK,CAAE,aAAc;AACpB,WAAO;AAAA,EACR;AAEA,SAAO,GAAI,WAAY,GAAG,KAAK,EAAE,YAAY,MAAM;AACpD;AAEA,IAAO,qBAAQ;AAAA,EACd;AAAA,EACA,eAAe,CAAE,UAAU,aAAa,SAAS,OAAQ;AAAA,EACzD,WAAY,MAAO;AAClB,WAAO,qBAAsB,IAAK;AAAA,EACnC;AACD;AAEA,SAAS,cAAe,EAAE,MAAM,QAAQ,WAAW,MAAM,GAAI;AAC5D,MACC,CAAE,qBAAsB,MAAM,aAAc,KAC5C,wBAAyB,MAAM,wBAAwB,aAAc,GACpE;AACD,WAAO,CAAC;AAAA,EACT;AAEA,QAAM,yBAAyB;AAAA,IAC9B,OAAO,YAAY;AAAA,EACpB;AACA,QAAM,YAAY,KAAM;AAAA,IACvB,oBAAoB;AAAA,EACrB,CAAE;AAIF,QAAM,uBAAuB,CAAC;AAQ9B,MAAK,wBAAyB;AAE7B,yBAAqB,YAAY;AACjC,yBAAqB,SAAS;AAAA,EAC/B,WACC,aACA,OAAO,YAAY,aACnB,UACA,OAAO,YAAY,QAClB;AAED,yBAAqB,cAAc;AAAA,EACpC;AAEA,SAAO,EAAE,WAAW,OAAO,qBAAqB;AACjD;AAKO,SAAS,iBAAiB;AAChC,aAAY,+CAA+C;AAAA,IAC1D,OAAO;AAAA,IACP,SAAS;AAAA,EACV,CAAE;AACH;",
4
+ "sourcesContent": ["import clsx from 'clsx';\nimport { useState, useEffect, useCallback } from '@wordpress/element';\nimport { useDispatch, useSelect } from '@wordpress/data';\nimport { getBlockSupport } from '@wordpress/blocks';\nimport deprecated from '@wordpress/deprecated';\nimport InspectorControls from '../components/inspector-controls';\nimport {\n\tDimensionsPanel as StylesDimensionsPanel,\n\tuseHasDimensionsPanel,\n} from '../components/global-styles';\nimport { useResolvedStyle } from '../components/global-styles/inherited-value-context';\nimport { MarginVisualizer, PaddingVisualizer } from './spacing-visualizer';\nimport { store as blockEditorStore } from '../store';\nimport { unlock } from '../lock-unlock';\nimport { cleanEmptyObject, shouldSkipSerialization } from './utils';\nimport {\n\tgetStyleForState,\n\tisDefaultBlockStyleState,\n\tsetStyleForState,\n\tuseBlockStyleState,\n} from './block-style-state';\nimport { isAxialBlockGapAllowed } from './gap';\n\nexport const DIMENSIONS_SUPPORT_KEY = 'dimensions';\nexport const SPACING_SUPPORT_KEY = 'spacing';\nexport const ALL_SIDES = [ 'top', 'right', 'bottom', 'left' ];\nexport const AXIAL_SIDES = [ 'vertical', 'horizontal' ];\n\nfunction useVisualizer() {\n\tconst [ property, setProperty ] = useState( false );\n\tconst { hideBlockInterface, showBlockInterface } = unlock(\n\t\tuseDispatch( blockEditorStore )\n\t);\n\tuseEffect( () => {\n\t\tif ( ! property ) {\n\t\t\tshowBlockInterface();\n\t\t} else {\n\t\t\thideBlockInterface();\n\t\t}\n\t}, [ property, showBlockInterface, hideBlockInterface ] );\n\n\treturn [ property, setProperty ];\n}\n\nfunction DimensionsInspectorControl( { children, resetAllFilter } ) {\n\tconst attributesResetAllFilter = useCallback(\n\t\t( attributes ) => {\n\t\t\tconst existingStyle = attributes.style;\n\t\t\tconst updatedStyle = resetAllFilter( existingStyle );\n\t\t\treturn {\n\t\t\t\t...attributes,\n\t\t\t\tstyle: 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=\"dimensions\"\n\t\t\tresetAllFilter={ attributesResetAllFilter }\n\t\t>\n\t\t\t{ children }\n\t\t</InspectorControls>\n\t);\n}\n\nexport function DimensionsPanel( { clientId, name, setAttributes, settings } ) {\n\tconst selectedState = useBlockStyleState();\n\tconst isStateSelected = ! isDefaultBlockStyleState( selectedState );\n\tconst isEnabled = useHasDimensionsPanel( settings, selectedState );\n\tconst { style, className, layout } = useSelect(\n\t\t( select ) => {\n\t\t\t// Early return to avoid subscription when disabled\n\t\t\tif ( ! isEnabled ) {\n\t\t\t\treturn {};\n\t\t\t}\n\t\t\tconst attributes =\n\t\t\t\tselect( blockEditorStore ).getBlockAttributes( clientId ) || {};\n\t\t\treturn {\n\t\t\t\tstyle: attributes.style,\n\t\t\t\tclassName: attributes.className,\n\t\t\t\tlayout: attributes.layout,\n\t\t\t};\n\t\t},\n\t\t[ clientId, isEnabled ]\n\t);\n\n\tconst { value: inheritedValue } = useResolvedStyle(\n\t\tname,\n\t\tclassName,\n\t\tselectedState\n\t);\n\n\tconst [ visualizedProperty, setVisualizedProperty ] = useVisualizer();\n\tconst value = isStateSelected\n\t\t? getStyleForState( style, selectedState )\n\t\t: style;\n\tconst onChange = isStateSelected\n\t\t? ( newStyle ) => {\n\t\t\t\tsetAttributes( {\n\t\t\t\t\tstyle: setStyleForState( style, selectedState, newStyle ),\n\t\t\t\t} );\n\t\t }\n\t\t: ( newStyle ) => {\n\t\t\t\tsetAttributes( {\n\t\t\t\t\tstyle: cleanEmptyObject( newStyle ),\n\t\t\t\t} );\n\t\t };\n\n\tif ( ! isEnabled ) {\n\t\treturn null;\n\t}\n\n\tconst defaultDimensionsControls = getBlockSupport( name, [\n\t\tDIMENSIONS_SUPPORT_KEY,\n\t\t'__experimentalDefaultControls',\n\t] );\n\tconst defaultSpacingControls = getBlockSupport( name, [\n\t\tSPACING_SUPPORT_KEY,\n\t\t'__experimentalDefaultControls',\n\t] );\n\tconst { default: defaultLayout } = getBlockSupport( name, 'layout' ) || {};\n\tconst defaultControls = {\n\t\t// In the block inspector, minHeight and minWidth should not\n\t\t// be shown by default unless the block explicitly opts in.\n\t\tminHeight: false,\n\t\tminWidth: false,\n\t\t...defaultDimensionsControls,\n\t\t...defaultSpacingControls,\n\t};\n\n\treturn (\n\t\t<>\n\t\t\t<StylesDimensionsPanel\n\t\t\t\tas={ DimensionsInspectorControl }\n\t\t\t\tpanelId={ clientId }\n\t\t\t\tsettings={ settings }\n\t\t\t\tallowAxialBlockGap={ isAxialBlockGapAllowed(\n\t\t\t\t\tlayout,\n\t\t\t\t\tdefaultLayout\n\t\t\t\t) }\n\t\t\t\tvalue={ value }\n\t\t\t\tonChange={ onChange }\n\t\t\t\tdefaultControls={ defaultControls }\n\t\t\t\tstyleState={ selectedState }\n\t\t\t\tonVisualize={\n\t\t\t\t\tisStateSelected ? undefined : setVisualizedProperty\n\t\t\t\t}\n\t\t\t\tinheritedValue={ inheritedValue }\n\t\t\t/>\n\t\t\t{ ! isStateSelected &&\n\t\t\t\t!! settings?.spacing?.padding &&\n\t\t\t\tvisualizedProperty === 'padding' && (\n\t\t\t\t\t<PaddingVisualizer\n\t\t\t\t\t\tforceShow={ visualizedProperty === 'padding' }\n\t\t\t\t\t\tclientId={ clientId }\n\t\t\t\t\t\tvalue={ value }\n\t\t\t\t\t/>\n\t\t\t\t) }\n\t\t\t{ ! isStateSelected &&\n\t\t\t\t!! settings?.spacing?.margin &&\n\t\t\t\tvisualizedProperty === 'margin' && (\n\t\t\t\t\t<MarginVisualizer\n\t\t\t\t\t\tforceShow={ visualizedProperty === 'margin' }\n\t\t\t\t\t\tclientId={ clientId }\n\t\t\t\t\t\tvalue={ value }\n\t\t\t\t\t/>\n\t\t\t\t) }\n\t\t</>\n\t);\n}\n\n/**\n * Determine whether there is block support for dimensions.\n *\n * @param {string} blockName Block name.\n * @param {string} feature Background image feature to check for.\n *\n * @return {boolean} Whether there is support.\n */\nexport function hasDimensionsSupport( blockName, feature = 'any' ) {\n\tconst support = getBlockSupport( blockName, DIMENSIONS_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?.aspectRatio ||\n\t\t\t!! support?.height ||\n\t\t\t!! support?.minHeight ||\n\t\t\t!! support?.width ||\n\t\t\t!! support?.minWidth\n\t\t);\n\t}\n\n\treturn !! support?.[ feature ];\n}\n\nexport function isExplicitAspectRatio( aspectRatio ) {\n\tif ( ! aspectRatio ) {\n\t\treturn false;\n\t}\n\n\treturn `${ aspectRatio }`.trim().toLowerCase() !== 'auto';\n}\n\nexport default {\n\tuseBlockProps,\n\tattributeKeys: [ 'height', 'minHeight', 'width', 'style' ],\n\thasSupport( name ) {\n\t\treturn hasDimensionsSupport( name );\n\t},\n};\n\nfunction useBlockProps( { name, height, minHeight, style } ) {\n\tif (\n\t\t! hasDimensionsSupport( name, 'aspectRatio' ) ||\n\t\tshouldSkipSerialization( name, DIMENSIONS_SUPPORT_KEY, 'aspectRatio' )\n\t) {\n\t\treturn {};\n\t}\n\n\tconst hasExplicitAspectRatio = isExplicitAspectRatio(\n\t\tstyle?.dimensions?.aspectRatio\n\t);\n\tconst className = clsx( {\n\t\t'has-aspect-ratio': hasExplicitAspectRatio,\n\t} );\n\n\t// Allow dimensions-based inline style overrides to override any global styles rules that\n\t// might be set for the block, and therefore affect the display of the aspect ratio.\n\tconst inlineStyleOverrides = {};\n\n\t// Apply rules to unset incompatible styles.\n\t// Note that an explicit `aspectRatio` will win out if both an aspect ratio and height-related properties are set.\n\t// This is because the aspect ratio is a newer block support, so (in theory) any aspect ratio\n\t// that is set should be intentional and should override any existing height properties. The Cover block\n\t// and dimensions controls have logic that will manually clear the aspect ratio if height properties\n\t// are set.\n\tif ( hasExplicitAspectRatio ) {\n\t\t// To ensure the aspect ratio does not get overridden by `minHeight` or `height` unset any existing rule.\n\t\tinlineStyleOverrides.minHeight = 'unset';\n\t\tinlineStyleOverrides.height = 'unset';\n\t} else if (\n\t\tminHeight ||\n\t\tstyle?.dimensions?.minHeight ||\n\t\theight ||\n\t\tstyle?.dimensions?.height\n\t) {\n\t\t// To ensure height properties do not get overridden by `aspectRatio` unset any existing rule.\n\t\tinlineStyleOverrides.aspectRatio = 'unset';\n\t}\n\n\treturn { className, style: inlineStyleOverrides };\n}\n\n/**\n * @deprecated\n */\nexport function useCustomSides() {\n\tdeprecated( 'wp.blockEditor.__experimentalUseCustomSides', {\n\t\tsince: '6.3',\n\t\tversion: '6.4',\n\t} );\n}\n"],
5
+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ACD;AAEA,SAAS,cAAe,EAAE,MAAM,QAAQ,WAAW,MAAM,GAAI;AAC5D,MACC,CAAE,qBAAsB,MAAM,aAAc,KAC5C,wBAAyB,MAAM,wBAAwB,aAAc,GACpE;AACD,WAAO,CAAC;AAAA,EACT;AAEA,QAAM,yBAAyB;AAAA,IAC9B,OAAO,YAAY;AAAA,EACpB;AACA,QAAM,YAAY,KAAM;AAAA,IACvB,oBAAoB;AAAA,EACrB,CAAE;AAIF,QAAM,uBAAuB,CAAC;AAQ9B,MAAK,wBAAyB;AAE7B,yBAAqB,YAAY;AACjC,yBAAqB,SAAS;AAAA,EAC/B,WACC,aACA,OAAO,YAAY,aACnB,UACA,OAAO,YAAY,QAClB;AAED,yBAAqB,cAAc;AAAA,EACpC;AAEA,SAAO,EAAE,WAAW,OAAO,qBAAqB;AACjD;AAKO,SAAS,iBAAiB;AAChC,aAAY,+CAA+C;AAAA,IAC1D,OAAO;AAAA,IACP,SAAS;AAAA,EACV,CAAE;AACH;",
6
6
  "names": []
7
7
  }
@@ -20,7 +20,10 @@ import {
20
20
  __experimentalDuotoneControl as DuotoneControl,
21
21
  useSettings
22
22
  } from "../components/index.mjs";
23
- import { scopeSelector } from "../components/global-styles/utils.mjs";
23
+ import {
24
+ scopeSelector,
25
+ getDuotoneSlugFromPreset
26
+ } from "../components/global-styles/utils.mjs";
24
27
  import {
25
28
  cleanEmptyObject,
26
29
  useBlockSettings,
@@ -108,7 +111,7 @@ function DuotonePanelPure({ style, setAttributes, name, clientId }) {
108
111
  StylesFiltersPanel,
109
112
  {
110
113
  value: {
111
- filter: { duotone: duotonePresetOrColors }
114
+ filter: { duotone: duotoneStyle }
112
115
  },
113
116
  onChange: (newDuotone) => {
114
117
  const newStyle = {
@@ -133,8 +136,9 @@ function DuotonePanelPure({ style, setAttributes, name, clientId }) {
133
136
  disableCustomDuotone,
134
137
  disableCustomColors,
135
138
  value: duotonePresetOrColors,
136
- onChange: (newDuotone) => {
137
- const maybePreset = getDuotonePresetFromColors(
139
+ selectedSlug: getDuotoneSlugFromPreset(duotoneStyle),
140
+ onChange: (newDuotone, index, slug) => {
141
+ const maybePreset = slug ? `var:preset|duotone|${slug}` : getDuotonePresetFromColors(
138
142
  newDuotone,
139
143
  duotonePalette
140
144
  );
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../src/hooks/duotone.js"],
4
- "sourcesContent": ["import { extend } from 'colord';\nimport namesPlugin from 'colord/plugins/names';\nimport {\n\tgetBlockSupport,\n\tgetBlockType,\n\thasBlockSupport,\n} from '@wordpress/blocks';\nimport { useInstanceId } from '@wordpress/compose';\nimport { addFilter } from '@wordpress/hooks';\nimport { useMemo, useEffect } from '@wordpress/element';\nimport { useSelect } from '@wordpress/data';\nimport {\n\tgetBlockSelector,\n\tprivateApis as globalStylesEnginePrivateApis,\n} from '@wordpress/global-styles-engine';\nimport {\n\tBlockControls,\n\tInspectorControls,\n\t__experimentalDuotoneControl as DuotoneControl,\n\tuseSettings,\n} from '../components';\nimport { scopeSelector } from '../components/global-styles/utils';\nimport {\n\tcleanEmptyObject,\n\tuseBlockSettings,\n\tusePrivateStyleOverride,\n} from './utils';\nimport { unlock } from '../lock-unlock';\nimport { default as StylesFiltersPanel } from '../components/global-styles/filters-panel';\nimport { useResolvedStyle } from '../components/global-styles/inherited-value-context';\nimport { useBlockEditingMode } from '../components/block-editing-mode';\nimport { useBlockElement } from '../components/block-list/use-block-props/use-block-refs';\nimport { store as blockEditorStore } from '../store';\n\nconst { getDuotoneFilter, getDuotoneStylesheet, getDuotoneUnsetStylesheet } =\n\tunlock( globalStylesEnginePrivateApis );\n\nconst EMPTY_ARRAY = [];\n\n// Safari does not always update the duotone filter when the duotone colors\n// are changed. This browser check is later used to force a re-render of the block\n// element to ensure the duotone filter is updated. The check is included at the\n// root of this file as it only needs to be run once per page load.\nconst isSafari =\n\twindow?.navigator.userAgent &&\n\twindow.navigator.userAgent.includes( 'Safari' ) &&\n\t! window.navigator.userAgent.includes( 'Chrome' ) &&\n\t! window.navigator.userAgent.includes( 'Chromium' );\n\nextend( [ namesPlugin ] );\n\nfunction useMultiOriginPresets( { presetSetting, defaultSetting } ) {\n\tconst [ enableDefault, userPresets, themePresets, defaultPresets ] =\n\t\tuseSettings(\n\t\t\tdefaultSetting,\n\t\t\t`${ presetSetting }.custom`,\n\t\t\t`${ presetSetting }.theme`,\n\t\t\t`${ presetSetting }.default`\n\t\t);\n\treturn useMemo(\n\t\t() => [\n\t\t\t...( userPresets || EMPTY_ARRAY ),\n\t\t\t...( themePresets || EMPTY_ARRAY ),\n\t\t\t...( ( enableDefault && defaultPresets ) || EMPTY_ARRAY ),\n\t\t],\n\t\t[ enableDefault, userPresets, themePresets, defaultPresets ]\n\t);\n}\n\nexport function getColorsFromDuotonePreset( duotone, duotonePalette ) {\n\tif ( ! duotone ) {\n\t\treturn;\n\t}\n\tconst preset = duotonePalette?.find( ( { slug } ) => {\n\t\treturn duotone === `var:preset|duotone|${ slug }`;\n\t} );\n\n\treturn preset ? preset.colors : undefined;\n}\n\nexport function getDuotonePresetFromColors( colors, duotonePalette ) {\n\tif ( ! colors || ! Array.isArray( colors ) ) {\n\t\treturn;\n\t}\n\n\tconst preset = duotonePalette?.find( ( duotonePreset ) => {\n\t\treturn duotonePreset?.colors?.every(\n\t\t\t( val, index ) => val === colors[ index ]\n\t\t);\n\t} );\n\n\treturn preset ? `var:preset|duotone|${ preset.slug }` : undefined;\n}\n\nfunction DuotonePanelPure( { style, setAttributes, name, clientId } ) {\n\tconst duotoneStyle = style?.color?.duotone;\n\tconst settings = useBlockSettings( name );\n\tconst blockEditingMode = useBlockEditingMode();\n\n\tconst className = useSelect(\n\t\t( select ) =>\n\t\t\tclientId\n\t\t\t\t? select( blockEditorStore ).getBlockAttributes( clientId )\n\t\t\t\t\t\t?.className\n\t\t\t\t: undefined,\n\t\t[ clientId ]\n\t);\n\tconst { value: inheritedValue } = useResolvedStyle( name, className );\n\n\tconst duotonePalette = useMultiOriginPresets( {\n\t\tpresetSetting: 'color.duotone',\n\t\tdefaultSetting: 'color.defaultDuotone',\n\t} );\n\tconst colorPalette = useMultiOriginPresets( {\n\t\tpresetSetting: 'color.palette',\n\t\tdefaultSetting: 'color.defaultPalette',\n\t} );\n\tconst [ enableCustomColors, enableCustomDuotone ] = useSettings(\n\t\t'color.custom',\n\t\t'color.customDuotone'\n\t);\n\tconst disableCustomColors = ! enableCustomColors;\n\tconst disableCustomDuotone =\n\t\t! enableCustomDuotone ||\n\t\t( colorPalette?.length === 0 && disableCustomColors );\n\n\tif ( duotonePalette?.length === 0 && disableCustomDuotone ) {\n\t\treturn null;\n\t}\n\n\tif ( blockEditingMode !== 'default' ) {\n\t\treturn null;\n\t}\n\n\tconst duotonePresetOrColors =\n\t\tduotoneStyle === 'unset' || Array.isArray( duotoneStyle )\n\t\t\t? duotoneStyle\n\t\t\t: getColorsFromDuotonePreset( duotoneStyle, duotonePalette );\n\n\treturn (\n\t\t<>\n\t\t\t<InspectorControls group=\"filter\">\n\t\t\t\t<StylesFiltersPanel\n\t\t\t\t\tvalue={ {\n\t\t\t\t\t\tfilter: { duotone: duotonePresetOrColors },\n\t\t\t\t\t} }\n\t\t\t\t\tonChange={ ( newDuotone ) => {\n\t\t\t\t\t\tconst newStyle = {\n\t\t\t\t\t\t\t...style,\n\t\t\t\t\t\t\tcolor: {\n\t\t\t\t\t\t\t\t...newDuotone?.filter,\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t};\n\t\t\t\t\t\tsetAttributes( {\n\t\t\t\t\t\t\tstyle: cleanEmptyObject( newStyle ),\n\t\t\t\t\t\t} );\n\t\t\t\t\t} }\n\t\t\t\t\tsettings={ settings }\n\t\t\t\t\tinheritedValue={ inheritedValue }\n\t\t\t\t/>\n\t\t\t</InspectorControls>\n\t\t\t<BlockControls group=\"block\" __experimentalShareWithChildBlocks>\n\t\t\t\t<DuotoneControl\n\t\t\t\t\tduotonePalette={ duotonePalette }\n\t\t\t\t\tcolorPalette={ colorPalette }\n\t\t\t\t\tdisableCustomDuotone={ disableCustomDuotone }\n\t\t\t\t\tdisableCustomColors={ disableCustomColors }\n\t\t\t\t\tvalue={ duotonePresetOrColors }\n\t\t\t\t\tonChange={ ( newDuotone ) => {\n\t\t\t\t\t\tconst maybePreset = getDuotonePresetFromColors(\n\t\t\t\t\t\t\tnewDuotone,\n\t\t\t\t\t\t\tduotonePalette\n\t\t\t\t\t\t);\n\n\t\t\t\t\t\tconst newStyle = {\n\t\t\t\t\t\t\t...style,\n\t\t\t\t\t\t\tcolor: {\n\t\t\t\t\t\t\t\t...style?.color,\n\t\t\t\t\t\t\t\tduotone: maybePreset ?? newDuotone, // use preset or fallback to custom colors.\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t};\n\t\t\t\t\t\tsetAttributes( {\n\t\t\t\t\t\t\tstyle: cleanEmptyObject( newStyle ),\n\t\t\t\t\t\t} );\n\t\t\t\t\t} }\n\t\t\t\t\tsettings={ settings }\n\t\t\t\t/>\n\t\t\t</BlockControls>\n\t\t</>\n\t);\n}\n\nexport default {\n\tshareWithChildBlocks: true,\n\tedit: DuotonePanelPure,\n\tuseBlockProps,\n\tattributeKeys: [ 'style' ],\n\thasSupport( name ) {\n\t\treturn hasBlockSupport( name, 'filter.duotone' );\n\t},\n};\n\n/**\n * Filters registered block settings, extending attributes to include\n * the `duotone` attribute.\n *\n * @param {Object} settings Original block settings.\n *\n * @return {Object} Filtered block settings.\n */\nfunction addDuotoneAttributes( settings ) {\n\t// Previous `color.__experimentalDuotone` support flag is migrated via\n\t// block_type_metadata_settings filter in `lib/block-supports/duotone.php`.\n\tif ( ! hasBlockSupport( settings, 'filter.duotone' ) ) {\n\t\treturn settings;\n\t}\n\n\t// Allow blocks to specify their own attribute definition with default\n\t// values if needed.\n\tif ( ! settings.attributes.style ) {\n\t\tObject.assign( settings.attributes, {\n\t\t\tstyle: {\n\t\t\t\ttype: 'object',\n\t\t\t},\n\t\t} );\n\t}\n\n\treturn settings;\n}\n\nfunction useDuotoneStyles( {\n\tclientId,\n\tid: filterId,\n\tselector: duotoneSelector,\n\tattribute: duotoneAttr,\n} ) {\n\tconst duotonePalette = useMultiOriginPresets( {\n\t\tpresetSetting: 'color.duotone',\n\t\tdefaultSetting: 'color.defaultDuotone',\n\t} );\n\n\t// Possible values for duotone attribute:\n\t// 1. Array of colors - e.g. ['#000000', '#ffffff'].\n\t// 2. Variable for an existing Duotone preset - e.g. 'var:preset|duotone|green-blue' or 'var(--wp--preset--duotone--green-blue)''\n\t// 3. A CSS string - e.g. 'unset' to remove globally applied duotone.\n\tconst isCustom = Array.isArray( duotoneAttr );\n\tconst duotonePreset = isCustom\n\t\t? undefined\n\t\t: getColorsFromDuotonePreset( duotoneAttr, duotonePalette );\n\tconst isPreset = typeof duotoneAttr === 'string' && duotonePreset;\n\tconst isCSS = typeof duotoneAttr === 'string' && ! isPreset;\n\n\t// Match the structure of WP_Duotone_Gutenberg::render_duotone_support() in PHP.\n\tlet colors = null;\n\tif ( isPreset ) {\n\t\t// Array of colors.\n\t\tcolors = duotonePreset;\n\t} else if ( isCSS ) {\n\t\t// CSS filter property string (e.g. 'unset').\n\t\tcolors = duotoneAttr;\n\t} else if ( isCustom ) {\n\t\t// Array of colors.\n\t\tcolors = duotoneAttr;\n\t}\n\n\t// Build the CSS selectors to which the filter will be applied.\n\tconst selectors = duotoneSelector.split( ',' );\n\n\tconst selectorsScoped = selectors.map( ( selectorPart ) => {\n\t\t// Assuming the selector part is a subclass selector (not a tag name)\n\t\t// so we can prepend the filter id class. If we want to support elements\n\t\t// such as `img` or namespaces, we'll need to add a case for that here.\n\t\treturn `.${ filterId }${ selectorPart.trim() }`;\n\t} );\n\n\tconst selector = selectorsScoped.join( ', ' );\n\n\tconst isValidFilter = Array.isArray( colors ) || colors === 'unset';\n\n\tusePrivateStyleOverride(\n\t\tisValidFilter\n\t\t\t? {\n\t\t\t\t\tcss:\n\t\t\t\t\t\tcolors !== 'unset'\n\t\t\t\t\t\t\t? getDuotoneStylesheet( selector, filterId )\n\t\t\t\t\t\t\t: getDuotoneUnsetStylesheet( selector ),\n\t\t\t\t\t__unstableType: 'presets',\n\t\t\t }\n\t\t\t: undefined\n\t);\n\tusePrivateStyleOverride(\n\t\tisValidFilter\n\t\t\t? {\n\t\t\t\t\tassets:\n\t\t\t\t\t\tcolors !== 'unset'\n\t\t\t\t\t\t\t? getDuotoneFilter( filterId, colors )\n\t\t\t\t\t\t\t: '',\n\t\t\t\t\t__unstableType: 'svgs',\n\t\t\t }\n\t\t\t: undefined\n\t);\n\n\tconst blockElement = useBlockElement( clientId );\n\n\tuseEffect( () => {\n\t\tif ( ! isValidFilter ) {\n\t\t\treturn;\n\t\t}\n\n\t\t// Safari does not always update the duotone filter when the duotone\n\t\t// colors are changed. When using Safari, force the block element to be\n\t\t// repainted by the browser to ensure any changes are reflected\n\t\t// visually. This logic matches that used on the site frontend in\n\t\t// `block-supports/duotone.php`.\n\t\tif ( blockElement && isSafari ) {\n\t\t\tconst display = blockElement.style.display;\n\t\t\t// Switch to `inline-block` to force a repaint. In the editor,\n\t\t\t// `inline-block` is used instead of `none` to ensure that scroll\n\t\t\t// position is not affected, as `none` results in the editor\n\t\t\t// scrolling to the top of the block.\n\t\t\tblockElement.style.setProperty( 'display', 'inline-block' );\n\t\t\t// Simply accessing el.offsetHeight flushes layout and style changes\n\t\t\t// in WebKit without having to wait for setTimeout.\n\t\t\t// eslint-disable-next-line no-unused-expressions\n\t\t\tblockElement.offsetHeight;\n\t\t\tblockElement.style.setProperty( 'display', display );\n\t\t}\n\t\t// `colors` must be a dependency so this effect runs when the colors\n\t\t// change in Safari.\n\t}, [ isValidFilter, blockElement, colors ] );\n}\n\n// Used for generating the instance ID\nconst DUOTONE_BLOCK_PROPS_REFERENCE = {};\n\nfunction useBlockProps( { clientId, name, style } ) {\n\tconst id = useInstanceId( DUOTONE_BLOCK_PROPS_REFERENCE );\n\tconst selector = useMemo( () => {\n\t\tconst blockType = getBlockType( name );\n\n\t\tif ( blockType ) {\n\t\t\t// Backwards compatibility for `supports.color.__experimentalDuotone`\n\t\t\t// is provided via the `block_type_metadata_settings` filter. If\n\t\t\t// `supports.filter.duotone` has not been set and the\n\t\t\t// experimental property has been, the experimental property\n\t\t\t// value is copied into `supports.filter.duotone`.\n\t\t\tconst duotoneSupport = getBlockSupport(\n\t\t\t\tblockType,\n\t\t\t\t'filter.duotone',\n\t\t\t\tfalse\n\t\t\t);\n\t\t\tif ( ! duotoneSupport ) {\n\t\t\t\treturn null;\n\t\t\t}\n\n\t\t\t// If the experimental duotone support was set, that value is\n\t\t\t// to be treated as a selector and requires scoping.\n\t\t\tconst experimentalDuotone = getBlockSupport(\n\t\t\t\tblockType,\n\t\t\t\t'color.__experimentalDuotone',\n\t\t\t\tfalse\n\t\t\t);\n\t\t\tif ( experimentalDuotone ) {\n\t\t\t\tconst rootSelector = getBlockSelector( blockType );\n\t\t\t\treturn typeof experimentalDuotone === 'string'\n\t\t\t\t\t? scopeSelector( rootSelector, experimentalDuotone )\n\t\t\t\t\t: rootSelector;\n\t\t\t}\n\n\t\t\t// Regular filter.duotone support uses filter.duotone selectors with fallbacks.\n\t\t\treturn getBlockSelector( blockType, 'filter.duotone', {\n\t\t\t\tfallback: true,\n\t\t\t} );\n\t\t}\n\t}, [ name ] );\n\n\tconst attribute = style?.color?.duotone;\n\n\tconst filterClass = `wp-duotone-${ id }`;\n\n\tconst shouldRender = selector && attribute;\n\n\tuseDuotoneStyles( {\n\t\tclientId,\n\t\tid: filterClass,\n\t\tselector,\n\t\tattribute,\n\t} );\n\n\treturn {\n\t\tclassName: shouldRender ? filterClass : '',\n\t};\n}\n\naddFilter(\n\t'blocks.registerBlockType',\n\t'core/editor/duotone/add-attributes',\n\taddDuotoneAttributes\n);\n"],
5
- "mappings": ";AAAA,SAAS,cAAc;AACvB,OAAO,iBAAiB;AACxB;AAAA,EACC;AAAA,EACA;AAAA,EACA;AAAA,OACM;AACP,SAAS,qBAAqB;AAC9B,SAAS,i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,WAAW,OAAQ;AAAA,IACpD;AAAA,EAGD,GAAG,CAAE,eAAe,cAAc,MAAO,CAAE;AAC5C;AAGA,IAAM,gCAAgC,CAAC;AAEvC,SAAS,cAAe,EAAE,UAAU,MAAM,MAAM,GAAI;AACnD,QAAM,KAAK,cAAe,6BAA8B;AACxD,QAAM,WAAW,QAAS,MAAM;AAC/B,UAAM,YAAY,aAAc,IAAK;AAErC,QAAK,WAAY;AAMhB,YAAM,iBAAiB;AAAA,QACtB;AAAA,QACA;AAAA,QACA;AAAA,MACD;AACA,UAAK,CAAE,gBAAiB;AACvB,eAAO;AAAA,MACR;AAIA,YAAM,sBAAsB;AAAA,QAC3B;AAAA,QACA;AAAA,QACA;AAAA,MACD;AACA,UAAK,qBAAsB;AAC1B,cAAM,eAAe,iBAAkB,SAAU;AACjD,eAAO,OAAO,wBAAwB,WACnC,cAAe,cAAc,mBAAoB,IACjD;AAAA,MACJ;AAGA,aAAO,iBAAkB,WAAW,kBAAkB;AAAA,QACrD,UAAU;AAAA,MACX,CAAE;AAAA,IACH;AAAA,EACD,GAAG,CAAE,IAAK,CAAE;AAEZ,QAAM,YAAY,OAAO,OAAO;AAEhC,QAAM,cAAc,cAAe,EAAG;AAEtC,QAAM,eAAe,YAAY;AAEjC,mBAAkB;AAAA,IACjB;AAAA,IACA,IAAI;AAAA,IACJ;AAAA,IACA;AAAA,EACD,CAAE;AAEF,SAAO;AAAA,IACN,WAAW,eAAe,cAAc;AAAA,EACzC;AACD;AAEA;AAAA,EACC;AAAA,EACA;AAAA,EACA;AACD;",
4
+ "sourcesContent": ["import { extend } from 'colord';\nimport namesPlugin from 'colord/plugins/names';\nimport {\n\tgetBlockSupport,\n\tgetBlockType,\n\thasBlockSupport,\n} from '@wordpress/blocks';\nimport { useInstanceId } from '@wordpress/compose';\nimport { addFilter } from '@wordpress/hooks';\nimport { useMemo, useEffect } from '@wordpress/element';\nimport { useSelect } from '@wordpress/data';\nimport {\n\tgetBlockSelector,\n\tprivateApis as globalStylesEnginePrivateApis,\n} from '@wordpress/global-styles-engine';\nimport {\n\tBlockControls,\n\tInspectorControls,\n\t__experimentalDuotoneControl as DuotoneControl,\n\tuseSettings,\n} from '../components';\nimport {\n\tscopeSelector,\n\tgetDuotoneSlugFromPreset,\n} from '../components/global-styles/utils';\nimport {\n\tcleanEmptyObject,\n\tuseBlockSettings,\n\tusePrivateStyleOverride,\n} from './utils';\nimport { unlock } from '../lock-unlock';\nimport { default as StylesFiltersPanel } from '../components/global-styles/filters-panel';\nimport { useResolvedStyle } from '../components/global-styles/inherited-value-context';\nimport { useBlockEditingMode } from '../components/block-editing-mode';\nimport { useBlockElement } from '../components/block-list/use-block-props/use-block-refs';\nimport { store as blockEditorStore } from '../store';\n\nconst { getDuotoneFilter, getDuotoneStylesheet, getDuotoneUnsetStylesheet } =\n\tunlock( globalStylesEnginePrivateApis );\n\nconst EMPTY_ARRAY = [];\n\n// Safari does not always update the duotone filter when the duotone colors\n// are changed. This browser check is later used to force a re-render of the block\n// element to ensure the duotone filter is updated. The check is included at the\n// root of this file as it only needs to be run once per page load.\nconst isSafari =\n\twindow?.navigator.userAgent &&\n\twindow.navigator.userAgent.includes( 'Safari' ) &&\n\t! window.navigator.userAgent.includes( 'Chrome' ) &&\n\t! window.navigator.userAgent.includes( 'Chromium' );\n\nextend( [ namesPlugin ] );\n\nfunction useMultiOriginPresets( { presetSetting, defaultSetting } ) {\n\tconst [ enableDefault, userPresets, themePresets, defaultPresets ] =\n\t\tuseSettings(\n\t\t\tdefaultSetting,\n\t\t\t`${ presetSetting }.custom`,\n\t\t\t`${ presetSetting }.theme`,\n\t\t\t`${ presetSetting }.default`\n\t\t);\n\treturn useMemo(\n\t\t() => [\n\t\t\t...( userPresets || EMPTY_ARRAY ),\n\t\t\t...( themePresets || EMPTY_ARRAY ),\n\t\t\t...( ( enableDefault && defaultPresets ) || EMPTY_ARRAY ),\n\t\t],\n\t\t[ enableDefault, userPresets, themePresets, defaultPresets ]\n\t);\n}\n\nexport function getColorsFromDuotonePreset( duotone, duotonePalette ) {\n\tif ( ! duotone ) {\n\t\treturn;\n\t}\n\tconst preset = duotonePalette?.find( ( { slug } ) => {\n\t\treturn duotone === `var:preset|duotone|${ slug }`;\n\t} );\n\n\treturn preset ? preset.colors : undefined;\n}\n\nexport function getDuotonePresetFromColors( colors, duotonePalette ) {\n\tif ( ! colors || ! Array.isArray( colors ) ) {\n\t\treturn;\n\t}\n\n\tconst preset = duotonePalette?.find( ( duotonePreset ) => {\n\t\treturn duotonePreset?.colors?.every(\n\t\t\t( val, index ) => val === colors[ index ]\n\t\t);\n\t} );\n\n\treturn preset ? `var:preset|duotone|${ preset.slug }` : undefined;\n}\n\nfunction DuotonePanelPure( { style, setAttributes, name, clientId } ) {\n\tconst duotoneStyle = style?.color?.duotone;\n\tconst settings = useBlockSettings( name );\n\tconst blockEditingMode = useBlockEditingMode();\n\n\tconst className = useSelect(\n\t\t( select ) =>\n\t\t\tclientId\n\t\t\t\t? select( blockEditorStore ).getBlockAttributes( clientId )\n\t\t\t\t\t\t?.className\n\t\t\t\t: undefined,\n\t\t[ clientId ]\n\t);\n\tconst { value: inheritedValue } = useResolvedStyle( name, className );\n\n\tconst duotonePalette = useMultiOriginPresets( {\n\t\tpresetSetting: 'color.duotone',\n\t\tdefaultSetting: 'color.defaultDuotone',\n\t} );\n\tconst colorPalette = useMultiOriginPresets( {\n\t\tpresetSetting: 'color.palette',\n\t\tdefaultSetting: 'color.defaultPalette',\n\t} );\n\tconst [ enableCustomColors, enableCustomDuotone ] = useSettings(\n\t\t'color.custom',\n\t\t'color.customDuotone'\n\t);\n\tconst disableCustomColors = ! enableCustomColors;\n\tconst disableCustomDuotone =\n\t\t! enableCustomDuotone ||\n\t\t( colorPalette?.length === 0 && disableCustomColors );\n\n\tif ( duotonePalette?.length === 0 && disableCustomDuotone ) {\n\t\treturn null;\n\t}\n\n\tif ( blockEditingMode !== 'default' ) {\n\t\treturn null;\n\t}\n\n\tconst duotonePresetOrColors =\n\t\tduotoneStyle === 'unset' || Array.isArray( duotoneStyle )\n\t\t\t? duotoneStyle\n\t\t\t: getColorsFromDuotonePreset( duotoneStyle, duotonePalette );\n\n\treturn (\n\t\t<>\n\t\t\t<InspectorControls group=\"filter\">\n\t\t\t\t<StylesFiltersPanel\n\t\t\t\t\t// The raw value, not the resolved colors. The panel\n\t\t\t\t\t// decodes it for display, but needs the preset reference\n\t\t\t\t\t// to know which preset is applied: two presets can hold\n\t\t\t\t\t// the same pair of colors, and resolving first throws the\n\t\t\t\t\t// slug away.\n\t\t\t\t\tvalue={ {\n\t\t\t\t\t\tfilter: { duotone: duotoneStyle },\n\t\t\t\t\t} }\n\t\t\t\t\tonChange={ ( newDuotone ) => {\n\t\t\t\t\t\tconst newStyle = {\n\t\t\t\t\t\t\t...style,\n\t\t\t\t\t\t\tcolor: {\n\t\t\t\t\t\t\t\t...newDuotone?.filter,\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t};\n\t\t\t\t\t\tsetAttributes( {\n\t\t\t\t\t\t\tstyle: cleanEmptyObject( newStyle ),\n\t\t\t\t\t\t} );\n\t\t\t\t\t} }\n\t\t\t\t\tsettings={ settings }\n\t\t\t\t\tinheritedValue={ inheritedValue }\n\t\t\t\t/>\n\t\t\t</InspectorControls>\n\t\t\t<BlockControls group=\"block\" __experimentalShareWithChildBlocks>\n\t\t\t\t<DuotoneControl\n\t\t\t\t\tduotonePalette={ duotonePalette }\n\t\t\t\t\tcolorPalette={ colorPalette }\n\t\t\t\t\tdisableCustomDuotone={ disableCustomDuotone }\n\t\t\t\t\tdisableCustomColors={ disableCustomColors }\n\t\t\t\t\tvalue={ duotonePresetOrColors }\n\t\t\t\t\tselectedSlug={ getDuotoneSlugFromPreset( duotoneStyle ) }\n\t\t\t\t\tonChange={ ( newDuotone, index, slug ) => {\n\t\t\t\t\t\t// A slug means a preset was picked out of the palette,\n\t\t\t\t\t\t// so it identifies the choice exactly. Matching back by\n\t\t\t\t\t\t// color would resolve to whichever preset holding those\n\t\t\t\t\t\t// colors comes first, which is the wrong one whenever\n\t\t\t\t\t\t// two presets share a pair.\n\t\t\t\t\t\tconst maybePreset = slug\n\t\t\t\t\t\t\t? `var:preset|duotone|${ slug }`\n\t\t\t\t\t\t\t: getDuotonePresetFromColors(\n\t\t\t\t\t\t\t\t\tnewDuotone,\n\t\t\t\t\t\t\t\t\tduotonePalette\n\t\t\t\t\t\t\t );\n\n\t\t\t\t\t\tconst newStyle = {\n\t\t\t\t\t\t\t...style,\n\t\t\t\t\t\t\tcolor: {\n\t\t\t\t\t\t\t\t...style?.color,\n\t\t\t\t\t\t\t\tduotone: maybePreset ?? newDuotone, // use preset or fallback to custom colors.\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t};\n\t\t\t\t\t\tsetAttributes( {\n\t\t\t\t\t\t\tstyle: cleanEmptyObject( newStyle ),\n\t\t\t\t\t\t} );\n\t\t\t\t\t} }\n\t\t\t\t\tsettings={ settings }\n\t\t\t\t/>\n\t\t\t</BlockControls>\n\t\t</>\n\t);\n}\n\nexport default {\n\tshareWithChildBlocks: true,\n\tedit: DuotonePanelPure,\n\tuseBlockProps,\n\tattributeKeys: [ 'style' ],\n\thasSupport( name ) {\n\t\treturn hasBlockSupport( name, 'filter.duotone' );\n\t},\n};\n\n/**\n * Filters registered block settings, extending attributes to include\n * the `duotone` attribute.\n *\n * @param {Object} settings Original block settings.\n *\n * @return {Object} Filtered block settings.\n */\nfunction addDuotoneAttributes( settings ) {\n\t// Previous `color.__experimentalDuotone` support flag is migrated via\n\t// block_type_metadata_settings filter in `lib/block-supports/duotone.php`.\n\tif ( ! hasBlockSupport( settings, 'filter.duotone' ) ) {\n\t\treturn settings;\n\t}\n\n\t// Allow blocks to specify their own attribute definition with default\n\t// values if needed.\n\tif ( ! settings.attributes.style ) {\n\t\tObject.assign( settings.attributes, {\n\t\t\tstyle: {\n\t\t\t\ttype: 'object',\n\t\t\t},\n\t\t} );\n\t}\n\n\treturn settings;\n}\n\nfunction useDuotoneStyles( {\n\tclientId,\n\tid: filterId,\n\tselector: duotoneSelector,\n\tattribute: duotoneAttr,\n} ) {\n\tconst duotonePalette = useMultiOriginPresets( {\n\t\tpresetSetting: 'color.duotone',\n\t\tdefaultSetting: 'color.defaultDuotone',\n\t} );\n\n\t// Possible values for duotone attribute:\n\t// 1. Array of colors - e.g. ['#000000', '#ffffff'].\n\t// 2. Variable for an existing Duotone preset - e.g. 'var:preset|duotone|green-blue' or 'var(--wp--preset--duotone--green-blue)''\n\t// 3. A CSS string - e.g. 'unset' to remove globally applied duotone.\n\tconst isCustom = Array.isArray( duotoneAttr );\n\tconst duotonePreset = isCustom\n\t\t? undefined\n\t\t: getColorsFromDuotonePreset( duotoneAttr, duotonePalette );\n\tconst isPreset = typeof duotoneAttr === 'string' && duotonePreset;\n\tconst isCSS = typeof duotoneAttr === 'string' && ! isPreset;\n\n\t// Match the structure of WP_Duotone_Gutenberg::render_duotone_support() in PHP.\n\tlet colors = null;\n\tif ( isPreset ) {\n\t\t// Array of colors.\n\t\tcolors = duotonePreset;\n\t} else if ( isCSS ) {\n\t\t// CSS filter property string (e.g. 'unset').\n\t\tcolors = duotoneAttr;\n\t} else if ( isCustom ) {\n\t\t// Array of colors.\n\t\tcolors = duotoneAttr;\n\t}\n\n\t// Build the CSS selectors to which the filter will be applied.\n\tconst selectors = duotoneSelector.split( ',' );\n\n\tconst selectorsScoped = selectors.map( ( selectorPart ) => {\n\t\t// Assuming the selector part is a subclass selector (not a tag name)\n\t\t// so we can prepend the filter id class. If we want to support elements\n\t\t// such as `img` or namespaces, we'll need to add a case for that here.\n\t\treturn `.${ filterId }${ selectorPart.trim() }`;\n\t} );\n\n\tconst selector = selectorsScoped.join( ', ' );\n\n\tconst isValidFilter = Array.isArray( colors ) || colors === 'unset';\n\n\tusePrivateStyleOverride(\n\t\tisValidFilter\n\t\t\t? {\n\t\t\t\t\tcss:\n\t\t\t\t\t\tcolors !== 'unset'\n\t\t\t\t\t\t\t? getDuotoneStylesheet( selector, filterId )\n\t\t\t\t\t\t\t: getDuotoneUnsetStylesheet( selector ),\n\t\t\t\t\t__unstableType: 'presets',\n\t\t\t }\n\t\t\t: undefined\n\t);\n\tusePrivateStyleOverride(\n\t\tisValidFilter\n\t\t\t? {\n\t\t\t\t\tassets:\n\t\t\t\t\t\tcolors !== 'unset'\n\t\t\t\t\t\t\t? getDuotoneFilter( filterId, colors )\n\t\t\t\t\t\t\t: '',\n\t\t\t\t\t__unstableType: 'svgs',\n\t\t\t }\n\t\t\t: undefined\n\t);\n\n\tconst blockElement = useBlockElement( clientId );\n\n\tuseEffect( () => {\n\t\tif ( ! isValidFilter ) {\n\t\t\treturn;\n\t\t}\n\n\t\t// Safari does not always update the duotone filter when the duotone\n\t\t// colors are changed. When using Safari, force the block element to be\n\t\t// repainted by the browser to ensure any changes are reflected\n\t\t// visually. This logic matches that used on the site frontend in\n\t\t// `block-supports/duotone.php`.\n\t\tif ( blockElement && isSafari ) {\n\t\t\tconst display = blockElement.style.display;\n\t\t\t// Switch to `inline-block` to force a repaint. In the editor,\n\t\t\t// `inline-block` is used instead of `none` to ensure that scroll\n\t\t\t// position is not affected, as `none` results in the editor\n\t\t\t// scrolling to the top of the block.\n\t\t\tblockElement.style.setProperty( 'display', 'inline-block' );\n\t\t\t// Simply accessing el.offsetHeight flushes layout and style changes\n\t\t\t// in WebKit without having to wait for setTimeout.\n\t\t\t// eslint-disable-next-line no-unused-expressions\n\t\t\tblockElement.offsetHeight;\n\t\t\tblockElement.style.setProperty( 'display', display );\n\t\t}\n\t\t// `colors` must be a dependency so this effect runs when the colors\n\t\t// change in Safari.\n\t}, [ isValidFilter, blockElement, colors ] );\n}\n\n// Used for generating the instance ID\nconst DUOTONE_BLOCK_PROPS_REFERENCE = {};\n\nfunction useBlockProps( { clientId, name, style } ) {\n\tconst id = useInstanceId( DUOTONE_BLOCK_PROPS_REFERENCE );\n\tconst selector = useMemo( () => {\n\t\tconst blockType = getBlockType( name );\n\n\t\tif ( blockType ) {\n\t\t\t// Backwards compatibility for `supports.color.__experimentalDuotone`\n\t\t\t// is provided via the `block_type_metadata_settings` filter. If\n\t\t\t// `supports.filter.duotone` has not been set and the\n\t\t\t// experimental property has been, the experimental property\n\t\t\t// value is copied into `supports.filter.duotone`.\n\t\t\tconst duotoneSupport = getBlockSupport(\n\t\t\t\tblockType,\n\t\t\t\t'filter.duotone',\n\t\t\t\tfalse\n\t\t\t);\n\t\t\tif ( ! duotoneSupport ) {\n\t\t\t\treturn null;\n\t\t\t}\n\n\t\t\t// If the experimental duotone support was set, that value is\n\t\t\t// to be treated as a selector and requires scoping.\n\t\t\tconst experimentalDuotone = getBlockSupport(\n\t\t\t\tblockType,\n\t\t\t\t'color.__experimentalDuotone',\n\t\t\t\tfalse\n\t\t\t);\n\t\t\tif ( experimentalDuotone ) {\n\t\t\t\tconst rootSelector = getBlockSelector( blockType );\n\t\t\t\treturn typeof experimentalDuotone === 'string'\n\t\t\t\t\t? scopeSelector( rootSelector, experimentalDuotone )\n\t\t\t\t\t: rootSelector;\n\t\t\t}\n\n\t\t\t// Regular filter.duotone support uses filter.duotone selectors with fallbacks.\n\t\t\treturn getBlockSelector( blockType, 'filter.duotone', {\n\t\t\t\tfallback: true,\n\t\t\t} );\n\t\t}\n\t}, [ name ] );\n\n\tconst attribute = style?.color?.duotone;\n\n\tconst filterClass = `wp-duotone-${ id }`;\n\n\tconst shouldRender = selector && attribute;\n\n\tuseDuotoneStyles( {\n\t\tclientId,\n\t\tid: filterClass,\n\t\tselector,\n\t\tattribute,\n\t} );\n\n\treturn {\n\t\tclassName: shouldRender ? filterClass : '',\n\t};\n}\n\naddFilter(\n\t'blocks.registerBlockType',\n\t'core/editor/duotone/add-attributes',\n\taddDuotoneAttributes\n);\n"],
5
+ "mappings": ";AAAA,SAAS,cAAc;AACvB,OAAO,iBAAiB;AACxB;AAAA,EACC;AAAA,EACA;AAAA,EACA;AAAA,OACM;AACP,SAAS,qBAAqB;AAC9B,SAAS,iBAAiB;AAC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nC,mBAAa,MAAM,YAAa,WAAW,cAAe;AAI1D,mBAAa;AACb,mBAAa,MAAM,YAAa,WAAW,OAAQ;AAAA,IACpD;AAAA,EAGD,GAAG,CAAE,eAAe,cAAc,MAAO,CAAE;AAC5C;AAGA,IAAM,gCAAgC,CAAC;AAEvC,SAAS,cAAe,EAAE,UAAU,MAAM,MAAM,GAAI;AACnD,QAAM,KAAK,cAAe,6BAA8B;AACxD,QAAM,WAAW,QAAS,MAAM;AAC/B,UAAM,YAAY,aAAc,IAAK;AAErC,QAAK,WAAY;AAMhB,YAAM,iBAAiB;AAAA,QACtB;AAAA,QACA;AAAA,QACA;AAAA,MACD;AACA,UAAK,CAAE,gBAAiB;AACvB,eAAO;AAAA,MACR;AAIA,YAAM,sBAAsB;AAAA,QAC3B;AAAA,QACA;AAAA,QACA;AAAA,MACD;AACA,UAAK,qBAAsB;AAC1B,cAAM,eAAe,iBAAkB,SAAU;AACjD,eAAO,OAAO,wBAAwB,WACnC,cAAe,cAAc,mBAAoB,IACjD;AAAA,MACJ;AAGA,aAAO,iBAAkB,WAAW,kBAAkB;AAAA,QACrD,UAAU;AAAA,MACX,CAAE;AAAA,IACH;AAAA,EACD,GAAG,CAAE,IAAK,CAAE;AAEZ,QAAM,YAAY,OAAO,OAAO;AAEhC,QAAM,cAAc,cAAe,EAAG;AAEtC,QAAM,eAAe,YAAY;AAEjC,mBAAkB;AAAA,IACjB;AAAA,IACA,IAAI;AAAA,IACJ;AAAA,IACA;AAAA,EACD,CAAE;AAEF,SAAO;AAAA,IACN,WAAW,eAAe,cAAc;AAAA,EACzC;AACD;AAEA;AAAA,EACC;AAAA,EACA;AAAA,EACA;AACD;",
6
6
  "names": []
7
7
  }
@@ -1,5 +1,9 @@
1
1
  // packages/block-editor/src/hooks/gap.js
2
2
  import { getSpacingPresetCssVar } from "../components/spacing-sizes-control/utils.mjs";
3
+ function isAxialBlockGapAllowed(layout, defaultLayout) {
4
+ const usedLayout = layout?.inherit || layout?.contentSize || layout?.wideSize ? { ...layout, type: "constrained" } : layout || defaultLayout || {};
5
+ return ["flex", "grid"].includes(usedLayout?.type);
6
+ }
3
7
  function getGapBoxControlValueFromStyle(blockGapValue) {
4
8
  if (!blockGapValue) {
5
9
  return null;
@@ -21,6 +25,7 @@ function getGapCSSValue(blockGapValue, defaultValue = "0") {
21
25
  }
22
26
  export {
23
27
  getGapBoxControlValueFromStyle,
24
- getGapCSSValue
28
+ getGapCSSValue,
29
+ isAxialBlockGapAllowed
25
30
  };
26
31
  //# sourceMappingURL=gap.mjs.map