@wordpress/block-editor 8.4.0 → 8.5.2

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 (421) hide show
  1. package/CHANGELOG.md +2 -0
  2. package/README.md +56 -19
  3. package/build/components/alignment-control/index.js +13 -6
  4. package/build/components/alignment-control/index.js.map +1 -1
  5. package/build/components/block-alignment-control/index.js +13 -6
  6. package/build/components/block-alignment-control/index.js.map +1 -1
  7. package/build/components/block-alignment-control/ui.js +1 -1
  8. package/build/components/block-alignment-control/ui.js.map +1 -1
  9. package/build/components/block-content-overlay/index.js +13 -4
  10. package/build/components/block-content-overlay/index.js.map +1 -1
  11. package/build/components/block-draggable/index.js +2 -3
  12. package/build/components/block-draggable/index.js.map +1 -1
  13. package/build/components/block-icon/index.js +4 -0
  14. package/build/components/block-icon/index.js.map +1 -1
  15. package/build/components/block-inspector/index.js +6 -1
  16. package/build/components/block-inspector/index.js.map +1 -1
  17. package/build/components/block-list/use-block-props/index.js +1 -6
  18. package/build/components/block-list/use-block-props/index.js.map +1 -1
  19. package/build/components/block-list/use-block-props/use-focus-first-element.js +14 -17
  20. package/build/components/block-list/use-block-props/use-focus-first-element.js.map +1 -1
  21. package/build/components/block-list/use-block-props/use-focus-handler.js +7 -1
  22. package/build/components/block-list/use-block-props/use-focus-handler.js.map +1 -1
  23. package/build/components/block-list-appender/index.js +6 -1
  24. package/build/components/block-list-appender/index.js.map +1 -1
  25. package/build/components/block-lock/index.js +8 -0
  26. package/build/components/block-lock/index.js.map +1 -1
  27. package/build/components/block-lock/menu-item.js +9 -15
  28. package/build/components/block-lock/menu-item.js.map +1 -1
  29. package/build/components/block-lock/modal.js +35 -23
  30. package/build/components/block-lock/modal.js.map +1 -1
  31. package/build/components/block-lock/toolbar.js +11 -16
  32. package/build/components/block-lock/toolbar.js.map +1 -1
  33. package/build/components/block-lock/use-block-lock.js +50 -0
  34. package/build/components/block-lock/use-block-lock.js.map +1 -0
  35. package/build/components/block-mover/index.js +4 -0
  36. package/build/components/block-mover/index.js.map +1 -1
  37. package/build/components/block-pattern-setup/index.js +37 -22
  38. package/build/components/block-pattern-setup/index.js.map +1 -1
  39. package/build/components/block-pattern-setup/setup-toolbar.js +1 -1
  40. package/build/components/block-pattern-setup/setup-toolbar.js.map +1 -1
  41. package/build/components/block-preview/auto.js +6 -3
  42. package/build/components/block-preview/auto.js.map +1 -1
  43. package/build/components/block-preview/index.js +4 -2
  44. package/build/components/block-preview/index.js.map +1 -1
  45. package/build/components/block-settings-menu/block-settings-dropdown.js +50 -5
  46. package/build/components/block-settings-menu/block-settings-dropdown.js.map +1 -1
  47. package/build/components/block-switcher/index.js +8 -3
  48. package/build/components/block-switcher/index.js.map +1 -1
  49. package/build/components/block-title/index.js +2 -2
  50. package/build/components/block-title/index.js.map +1 -1
  51. package/build/components/block-title/use-block-display-title.js +1 -1
  52. package/build/components/block-title/use-block-display-title.js.map +1 -1
  53. package/build/components/block-toolbar/block-name-context.js +17 -0
  54. package/build/components/block-toolbar/block-name-context.js.map +1 -0
  55. package/build/components/block-toolbar/block-toolbar-last-item.js +20 -0
  56. package/build/components/block-toolbar/block-toolbar-last-item.js.map +1 -0
  57. package/build/components/block-toolbar/index.js +20 -5
  58. package/build/components/block-toolbar/index.js.map +1 -1
  59. package/build/components/block-tools/index.js +0 -16
  60. package/build/components/block-tools/index.js.map +1 -1
  61. package/build/components/block-variation-transforms/index.js +92 -47
  62. package/build/components/block-variation-transforms/index.js.map +1 -1
  63. package/build/components/block-vertical-alignment-control/index.js +13 -6
  64. package/build/components/block-vertical-alignment-control/index.js.map +1 -1
  65. package/build/components/contrast-checker/index.js +4 -0
  66. package/build/components/contrast-checker/index.js.map +1 -1
  67. package/build/components/convert-to-group-buttons/index.js +8 -0
  68. package/build/components/convert-to-group-buttons/index.js.map +1 -1
  69. package/build/components/convert-to-group-buttons/toolbar.js +105 -0
  70. package/build/components/convert-to-group-buttons/toolbar.js.map +1 -0
  71. package/build/components/copy-handler/index.js +48 -9
  72. package/build/components/copy-handler/index.js.map +1 -1
  73. package/build/components/font-sizes/font-size-picker.js +4 -0
  74. package/build/components/font-sizes/font-size-picker.js.map +1 -1
  75. package/build/components/iframe/index.js +6 -9
  76. package/build/components/iframe/index.js.map +1 -1
  77. package/build/components/index.js +18 -0
  78. package/build/components/index.js.map +1 -1
  79. package/build/components/justify-content-control/index.js +13 -6
  80. package/build/components/justify-content-control/index.js.map +1 -1
  81. package/build/components/keyboard-shortcuts/index.js +1 -1
  82. package/build/components/keyboard-shortcuts/index.js.map +1 -1
  83. package/build/components/line-height-control/index.js +10 -3
  84. package/build/components/line-height-control/index.js.map +1 -1
  85. package/build/components/link-control/index.js +6 -7
  86. package/build/components/link-control/index.js.map +1 -1
  87. package/build/components/list-view/block-select-button.js +19 -6
  88. package/build/components/list-view/block-select-button.js.map +1 -1
  89. package/build/components/list-view/block.js +18 -3
  90. package/build/components/list-view/block.js.map +1 -1
  91. package/build/components/list-view/branch.js +1 -1
  92. package/build/components/list-view/branch.js.map +1 -1
  93. package/build/components/media-replace-flow/index.js +4 -0
  94. package/build/components/media-replace-flow/index.js.map +1 -1
  95. package/build/components/multi-selection-inspector/index.js +1 -1
  96. package/build/components/multi-selection-inspector/index.js.map +1 -1
  97. package/build/components/rich-text/index.js +26 -4
  98. package/build/components/rich-text/index.js.map +1 -1
  99. package/build/components/rich-text/split-value.js +12 -2
  100. package/build/components/rich-text/split-value.js.map +1 -1
  101. package/build/components/rich-text/use-firefox-compat.js +49 -0
  102. package/build/components/rich-text/use-firefox-compat.js.map +1 -0
  103. package/build/components/rich-text/use-input-rules.js +34 -2
  104. package/build/components/rich-text/use-input-rules.js.map +1 -1
  105. package/build/components/skip-to-selected-block/index.js +4 -0
  106. package/build/components/skip-to-selected-block/index.js.map +1 -1
  107. package/build/components/writing-flow/index.js +9 -1
  108. package/build/components/writing-flow/index.js.map +1 -1
  109. package/build/components/writing-flow/use-arrow-nav.js +3 -44
  110. package/build/components/writing-flow/use-arrow-nav.js.map +1 -1
  111. package/build/components/writing-flow/use-click-selection.js +68 -0
  112. package/build/components/writing-flow/use-click-selection.js.map +1 -0
  113. package/build/components/writing-flow/use-drag-selection.js +134 -0
  114. package/build/components/writing-flow/use-drag-selection.js.map +1 -0
  115. package/build/components/writing-flow/use-input.js +116 -0
  116. package/build/components/writing-flow/use-input.js.map +1 -0
  117. package/build/components/writing-flow/use-multi-selection.js +18 -38
  118. package/build/components/writing-flow/use-multi-selection.js.map +1 -1
  119. package/build/components/writing-flow/use-selection-observer.js +161 -0
  120. package/build/components/writing-flow/use-selection-observer.js.map +1 -0
  121. package/build/components/writing-flow/use-tab-nav.js +1 -8
  122. package/build/components/writing-flow/use-tab-nav.js.map +1 -1
  123. package/build/hooks/border-color.js +3 -3
  124. package/build/hooks/border-color.js.map +1 -1
  125. package/build/hooks/border.js +0 -14
  126. package/build/hooks/border.js.map +1 -1
  127. package/build/hooks/color.js +20 -17
  128. package/build/hooks/color.js.map +1 -1
  129. package/build/hooks/font-family.js +5 -1
  130. package/build/hooks/font-family.js.map +1 -1
  131. package/build/hooks/font-size.js +4 -2
  132. package/build/hooks/font-size.js.map +1 -1
  133. package/build/hooks/gap.js +23 -16
  134. package/build/hooks/gap.js.map +1 -1
  135. package/build/hooks/layout.js +7 -2
  136. package/build/hooks/layout.js.map +1 -1
  137. package/build/hooks/style.js +34 -3
  138. package/build/hooks/style.js.map +1 -1
  139. package/build/hooks/utils.js +29 -0
  140. package/build/hooks/utils.js.map +1 -1
  141. package/build/layouts/flex.js +76 -12
  142. package/build/layouts/flex.js.map +1 -1
  143. package/build/layouts/flow.js +9 -4
  144. package/build/layouts/flow.js.map +1 -1
  145. package/build/store/actions.js +290 -51
  146. package/build/store/actions.js.map +1 -1
  147. package/build/store/defaults.js +5 -2
  148. package/build/store/defaults.js.map +1 -1
  149. package/build/store/reducer.js +25 -13
  150. package/build/store/reducer.js.map +1 -1
  151. package/build/store/selectors.js +264 -21
  152. package/build/store/selectors.js.map +1 -1
  153. package/build/store/utils.js +27 -0
  154. package/build/store/utils.js.map +1 -0
  155. package/build/utils/dom.js +2 -1
  156. package/build/utils/dom.js.map +1 -1
  157. package/build-module/components/alignment-control/index.js +12 -4
  158. package/build-module/components/alignment-control/index.js.map +1 -1
  159. package/build-module/components/block-alignment-control/index.js +12 -4
  160. package/build-module/components/block-alignment-control/index.js.map +1 -1
  161. package/build-module/components/block-alignment-control/ui.js +2 -2
  162. package/build-module/components/block-alignment-control/ui.js.map +1 -1
  163. package/build-module/components/block-content-overlay/index.js +13 -4
  164. package/build-module/components/block-content-overlay/index.js.map +1 -1
  165. package/build-module/components/block-draggable/index.js +2 -3
  166. package/build-module/components/block-draggable/index.js.map +1 -1
  167. package/build-module/components/block-icon/index.js +4 -0
  168. package/build-module/components/block-icon/index.js.map +1 -1
  169. package/build-module/components/block-inspector/index.js +6 -1
  170. package/build-module/components/block-inspector/index.js.map +1 -1
  171. package/build-module/components/block-list/use-block-props/index.js +1 -4
  172. package/build-module/components/block-list/use-block-props/index.js.map +1 -1
  173. package/build-module/components/block-list/use-block-props/use-focus-first-element.js +15 -17
  174. package/build-module/components/block-list/use-block-props/use-focus-first-element.js.map +1 -1
  175. package/build-module/components/block-list/use-block-props/use-focus-handler.js +7 -1
  176. package/build-module/components/block-list/use-block-props/use-focus-handler.js.map +1 -1
  177. package/build-module/components/block-list-appender/index.js +6 -1
  178. package/build-module/components/block-list-appender/index.js.map +1 -1
  179. package/build-module/components/block-lock/index.js +1 -0
  180. package/build-module/components/block-lock/index.js.map +1 -1
  181. package/build-module/components/block-lock/menu-item.js +8 -13
  182. package/build-module/components/block-lock/menu-item.js.map +1 -1
  183. package/build-module/components/block-lock/modal.js +34 -24
  184. package/build-module/components/block-lock/modal.js.map +1 -1
  185. package/build-module/components/block-lock/toolbar.js +10 -14
  186. package/build-module/components/block-lock/toolbar.js.map +1 -1
  187. package/build-module/components/block-lock/use-block-lock.js +41 -0
  188. package/build-module/components/block-lock/use-block-lock.js.map +1 -0
  189. package/build-module/components/block-mover/index.js +4 -0
  190. package/build-module/components/block-mover/index.js.map +1 -1
  191. package/build-module/components/block-pattern-setup/index.js +39 -24
  192. package/build-module/components/block-pattern-setup/index.js.map +1 -1
  193. package/build-module/components/block-pattern-setup/setup-toolbar.js +1 -1
  194. package/build-module/components/block-pattern-setup/setup-toolbar.js.map +1 -1
  195. package/build-module/components/block-preview/auto.js +6 -3
  196. package/build-module/components/block-preview/auto.js.map +1 -1
  197. package/build-module/components/block-preview/index.js +4 -2
  198. package/build-module/components/block-preview/index.js.map +1 -1
  199. package/build-module/components/block-settings-menu/block-settings-dropdown.js +50 -7
  200. package/build-module/components/block-settings-menu/block-settings-dropdown.js.map +1 -1
  201. package/build-module/components/block-switcher/index.js +9 -4
  202. package/build-module/components/block-switcher/index.js.map +1 -1
  203. package/build-module/components/block-title/index.js +2 -2
  204. package/build-module/components/block-title/index.js.map +1 -1
  205. package/build-module/components/block-title/use-block-display-title.js +1 -1
  206. package/build-module/components/block-title/use-block-display-title.js.map +1 -1
  207. package/build-module/components/block-toolbar/block-name-context.js +9 -0
  208. package/build-module/components/block-toolbar/block-name-context.js.map +1 -0
  209. package/build-module/components/block-toolbar/block-toolbar-last-item.js +11 -0
  210. package/build-module/components/block-toolbar/block-toolbar-last-item.js.map +1 -0
  211. package/build-module/components/block-toolbar/index.js +16 -4
  212. package/build-module/components/block-toolbar/index.js.map +1 -1
  213. package/build-module/components/block-tools/index.js +0 -16
  214. package/build-module/components/block-tools/index.js.map +1 -1
  215. package/build-module/components/block-variation-transforms/index.js +95 -49
  216. package/build-module/components/block-variation-transforms/index.js.map +1 -1
  217. package/build-module/components/block-vertical-alignment-control/index.js +12 -4
  218. package/build-module/components/block-vertical-alignment-control/index.js.map +1 -1
  219. package/build-module/components/contrast-checker/index.js +4 -0
  220. package/build-module/components/contrast-checker/index.js.map +1 -1
  221. package/build-module/components/convert-to-group-buttons/index.js +2 -1
  222. package/build-module/components/convert-to-group-buttons/index.js.map +1 -1
  223. package/build-module/components/convert-to-group-buttons/toolbar.js +90 -0
  224. package/build-module/components/convert-to-group-buttons/toolbar.js.map +1 -0
  225. package/build-module/components/copy-handler/index.js +48 -9
  226. package/build-module/components/copy-handler/index.js.map +1 -1
  227. package/build-module/components/font-sizes/font-size-picker.js +4 -0
  228. package/build-module/components/font-sizes/font-size-picker.js.map +1 -1
  229. package/build-module/components/iframe/index.js +6 -9
  230. package/build-module/components/iframe/index.js.map +1 -1
  231. package/build-module/components/index.js +2 -0
  232. package/build-module/components/index.js.map +1 -1
  233. package/build-module/components/justify-content-control/index.js +12 -4
  234. package/build-module/components/justify-content-control/index.js.map +1 -1
  235. package/build-module/components/keyboard-shortcuts/index.js +1 -1
  236. package/build-module/components/keyboard-shortcuts/index.js.map +1 -1
  237. package/build-module/components/line-height-control/index.js +9 -2
  238. package/build-module/components/line-height-control/index.js.map +1 -1
  239. package/build-module/components/link-control/index.js +6 -7
  240. package/build-module/components/link-control/index.js.map +1 -1
  241. package/build-module/components/list-view/block-select-button.js +17 -6
  242. package/build-module/components/list-view/block-select-button.js.map +1 -1
  243. package/build-module/components/list-view/block.js +18 -3
  244. package/build-module/components/list-view/block.js.map +1 -1
  245. package/build-module/components/list-view/branch.js +1 -1
  246. package/build-module/components/list-view/branch.js.map +1 -1
  247. package/build-module/components/media-replace-flow/index.js +4 -0
  248. package/build-module/components/media-replace-flow/index.js.map +1 -1
  249. package/build-module/components/multi-selection-inspector/index.js +2 -2
  250. package/build-module/components/multi-selection-inspector/index.js.map +1 -1
  251. package/build-module/components/rich-text/index.js +25 -4
  252. package/build-module/components/rich-text/index.js.map +1 -1
  253. package/build-module/components/rich-text/split-value.js +12 -2
  254. package/build-module/components/rich-text/split-value.js.map +1 -1
  255. package/build-module/components/rich-text/use-firefox-compat.js +39 -0
  256. package/build-module/components/rich-text/use-firefox-compat.js.map +1 -0
  257. package/build-module/components/rich-text/use-input-rules.js +35 -4
  258. package/build-module/components/rich-text/use-input-rules.js.map +1 -1
  259. package/build-module/components/skip-to-selected-block/index.js +4 -0
  260. package/build-module/components/skip-to-selected-block/index.js.map +1 -1
  261. package/build-module/components/writing-flow/index.js +5 -1
  262. package/build-module/components/writing-flow/index.js.map +1 -1
  263. package/build-module/components/writing-flow/use-arrow-nav.js +4 -45
  264. package/build-module/components/writing-flow/use-arrow-nav.js.map +1 -1
  265. package/build-module/components/writing-flow/use-click-selection.js +57 -0
  266. package/build-module/components/writing-flow/use-click-selection.js.map +1 -0
  267. package/build-module/components/writing-flow/use-drag-selection.js +124 -0
  268. package/build-module/components/writing-flow/use-drag-selection.js.map +1 -0
  269. package/build-module/components/writing-flow/use-input.js +104 -0
  270. package/build-module/components/writing-flow/use-input.js.map +1 -0
  271. package/build-module/components/writing-flow/use-multi-selection.js +18 -37
  272. package/build-module/components/writing-flow/use-multi-selection.js.map +1 -1
  273. package/build-module/components/writing-flow/use-selection-observer.js +150 -0
  274. package/build-module/components/writing-flow/use-selection-observer.js.map +1 -0
  275. package/build-module/components/writing-flow/use-tab-nav.js +1 -9
  276. package/build-module/components/writing-flow/use-tab-nav.js.map +1 -1
  277. package/build-module/hooks/border-color.js +5 -5
  278. package/build-module/hooks/border-color.js.map +1 -1
  279. package/build-module/hooks/border.js +0 -12
  280. package/build-module/hooks/border.js.map +1 -1
  281. package/build-module/hooks/color.js +19 -18
  282. package/build-module/hooks/color.js.map +1 -1
  283. package/build-module/hooks/font-family.js +3 -1
  284. package/build-module/hooks/font-family.js.map +1 -1
  285. package/build-module/hooks/font-size.js +4 -3
  286. package/build-module/hooks/font-size.js.map +1 -1
  287. package/build-module/hooks/gap.js +22 -15
  288. package/build-module/hooks/gap.js.map +1 -1
  289. package/build-module/hooks/layout.js +7 -2
  290. package/build-module/hooks/layout.js.map +1 -1
  291. package/build-module/hooks/style.js +33 -3
  292. package/build-module/hooks/style.js.map +1 -1
  293. package/build-module/hooks/utils.js +26 -0
  294. package/build-module/hooks/utils.js.map +1 -1
  295. package/build-module/layouts/flex.js +76 -13
  296. package/build-module/layouts/flex.js.map +1 -1
  297. package/build-module/layouts/flow.js +9 -5
  298. package/build-module/layouts/flow.js.map +1 -1
  299. package/build-module/store/actions.js +277 -49
  300. package/build-module/store/actions.js.map +1 -1
  301. package/build-module/store/defaults.js +5 -2
  302. package/build-module/store/defaults.js.map +1 -1
  303. package/build-module/store/reducer.js +25 -13
  304. package/build-module/store/reducer.js.map +1 -1
  305. package/build-module/store/selectors.js +250 -21
  306. package/build-module/store/selectors.js.map +1 -1
  307. package/build-module/store/utils.js +20 -0
  308. package/build-module/store/utils.js.map +1 -0
  309. package/build-module/utils/dom.js +2 -1
  310. package/build-module/utils/dom.js.map +1 -1
  311. package/build-style/style-rtl.css +142 -101
  312. package/build-style/style.css +142 -101
  313. package/build-types/utils/dom.d.ts.map +1 -1
  314. package/package.json +28 -28
  315. package/src/components/alignment-control/index.js +9 -4
  316. package/src/components/block-alignment-control/index.js +9 -4
  317. package/src/components/block-alignment-control/ui.js +2 -2
  318. package/src/components/block-content-overlay/index.js +19 -2
  319. package/src/components/block-draggable/index.js +2 -5
  320. package/src/components/block-icon/index.js +3 -0
  321. package/src/components/block-inspector/index.js +4 -0
  322. package/src/components/block-list/style.scss +4 -5
  323. package/src/components/block-list/use-block-props/index.js +0 -5
  324. package/src/components/block-list/use-block-props/use-focus-first-element.js +19 -26
  325. package/src/components/block-list/use-block-props/use-focus-handler.js +8 -0
  326. package/src/components/block-list-appender/index.js +5 -0
  327. package/src/components/block-lock/index.js +1 -0
  328. package/src/components/block-lock/menu-item.js +6 -19
  329. package/src/components/block-lock/modal.js +52 -23
  330. package/src/components/block-lock/style.scss +7 -5
  331. package/src/components/block-lock/toolbar.js +7 -14
  332. package/src/components/block-lock/use-block-lock.js +45 -0
  333. package/src/components/block-mover/index.js +3 -0
  334. package/src/components/block-mover/style.scss +4 -0
  335. package/src/components/block-pattern-setup/index.js +84 -59
  336. package/src/components/block-pattern-setup/setup-toolbar.js +3 -1
  337. package/src/components/block-pattern-setup/style.scss +32 -26
  338. package/src/components/block-preview/auto.js +10 -1
  339. package/src/components/block-preview/index.js +2 -0
  340. package/src/components/block-settings-menu/block-settings-dropdown.js +62 -4
  341. package/src/components/block-switcher/index.js +15 -3
  342. package/src/components/block-switcher/style.scss +15 -4
  343. package/src/components/block-switcher/test/__snapshots__/index.js.snap +15 -13
  344. package/src/components/block-switcher/test/index.js +2 -2
  345. package/src/components/block-title/index.js +2 -2
  346. package/src/components/block-title/use-block-display-title.js +1 -1
  347. package/src/components/block-toolbar/block-name-context.js +8 -0
  348. package/src/components/block-toolbar/block-toolbar-last-item.js +12 -0
  349. package/src/components/block-toolbar/index.js +18 -2
  350. package/src/components/block-toolbar/style.scss +6 -0
  351. package/src/components/block-tools/index.js +0 -19
  352. package/src/components/block-tools/style.scss +3 -5
  353. package/src/components/block-variation-transforms/index.js +105 -36
  354. package/src/components/block-variation-transforms/style.scss +1 -1
  355. package/src/components/block-vertical-alignment-control/index.js +9 -4
  356. package/src/components/button-block-appender/style.scss +5 -1
  357. package/src/components/contrast-checker/index.js +3 -0
  358. package/src/components/convert-to-group-buttons/index.js +6 -1
  359. package/src/components/convert-to-group-buttons/toolbar.js +87 -0
  360. package/src/components/copy-handler/index.js +55 -10
  361. package/src/components/font-sizes/font-size-picker.js +3 -0
  362. package/src/components/iframe/index.js +5 -7
  363. package/src/components/index.js +2 -0
  364. package/src/components/justify-content-control/index.js +9 -4
  365. package/src/components/keyboard-shortcuts/index.js +1 -1
  366. package/src/components/line-height-control/index.js +8 -3
  367. package/src/components/link-control/index.js +5 -5
  368. package/src/components/list-view/block-select-button.js +13 -3
  369. package/src/components/list-view/block.js +24 -8
  370. package/src/components/list-view/branch.js +1 -1
  371. package/src/components/list-view/style.scss +56 -14
  372. package/src/components/media-placeholder/README.md +8 -0
  373. package/src/components/media-replace-flow/index.js +3 -0
  374. package/src/components/multi-selection-inspector/index.js +2 -2
  375. package/src/components/rich-text/index.js +24 -1
  376. package/src/components/rich-text/split-value.js +5 -1
  377. package/src/components/rich-text/use-firefox-compat.js +39 -0
  378. package/src/components/rich-text/use-input-rules.js +40 -3
  379. package/src/components/skip-to-selected-block/index.js +3 -0
  380. package/src/components/url-input/style.scss +3 -2
  381. package/src/components/writing-flow/index.js +8 -0
  382. package/src/components/writing-flow/readme.md +28 -0
  383. package/src/components/writing-flow/use-arrow-nav.js +4 -53
  384. package/src/components/writing-flow/use-click-selection.js +65 -0
  385. package/src/components/writing-flow/use-drag-selection.js +126 -0
  386. package/src/components/writing-flow/use-input.js +112 -0
  387. package/src/components/writing-flow/use-multi-selection.js +13 -36
  388. package/src/components/writing-flow/use-selection-observer.js +153 -0
  389. package/src/components/writing-flow/use-tab-nav.js +1 -11
  390. package/src/hooks/border-color.js +5 -5
  391. package/src/hooks/border.js +0 -13
  392. package/src/hooks/color.js +51 -24
  393. package/src/hooks/font-family.js +5 -2
  394. package/src/hooks/font-size.js +10 -7
  395. package/src/hooks/gap.js +25 -17
  396. package/src/hooks/layout.js +11 -1
  397. package/src/hooks/style.js +40 -4
  398. package/src/hooks/test/gap.js +25 -1
  399. package/src/hooks/test/style.js +94 -0
  400. package/src/hooks/test/utils.js +1 -1
  401. package/src/hooks/utils.js +26 -0
  402. package/src/layouts/flex.js +89 -5
  403. package/src/layouts/flow.js +15 -4
  404. package/src/store/actions.js +341 -32
  405. package/src/store/defaults.js +7 -2
  406. package/src/store/reducer.js +25 -10
  407. package/src/store/selectors.js +329 -26
  408. package/src/store/test/selectors.js +242 -5
  409. package/src/store/utils.js +19 -0
  410. package/src/utils/dom.js +2 -1
  411. package/tsconfig.tsbuildinfo +1 -1
  412. package/build/components/block-list/use-block-props/use-multi-selection.js +0 -205
  413. package/build/components/block-list/use-block-props/use-multi-selection.js.map +0 -1
  414. package/build/components/block-list/use-block-props/use-scroll-into-view.js +0 -77
  415. package/build/components/block-list/use-block-props/use-scroll-into-view.js.map +0 -1
  416. package/build-module/components/block-list/use-block-props/use-multi-selection.js +0 -192
  417. package/build-module/components/block-list/use-block-props/use-multi-selection.js.map +0 -1
  418. package/build-module/components/block-list/use-block-props/use-scroll-into-view.js +0 -63
  419. package/build-module/components/block-list/use-block-props/use-scroll-into-view.js.map +0 -1
  420. package/src/components/block-list/use-block-props/use-multi-selection.js +0 -227
  421. package/src/components/block-list/use-block-props/use-scroll-into-view.js +0 -73
@@ -79,8 +79,12 @@ function LayoutPanel(_ref) {
79
79
 
80
80
  if (!allowEditing) {
81
81
  return null;
82
- }
82
+ } // Only show the inherit toggle if it's supported,
83
+ // a default theme layout is set (e.g. one that provides `contentSize` and/or `wideSize` values),
84
+ // and that the default / flow layout type is in use, as this is the only one that supports inheritance.
85
+
83
86
 
87
+ const showInheritToggle = !!(allowInheriting && !!defaultThemeLayout && (!(layout !== null && layout !== void 0 && layout.type) || (layout === null || layout === void 0 ? void 0 : layout.type) === 'default' || layout !== null && layout !== void 0 && layout.inherit));
84
88
  const usedLayout = layout || defaultBlockLayout || {};
85
89
  const {
86
90
  inherit = false,
@@ -110,7 +114,7 @@ function LayoutPanel(_ref) {
110
114
 
111
115
  return (0, _element.createElement)(_element.Fragment, null, (0, _element.createElement)(_components2.InspectorControls, null, (0, _element.createElement)(_components.PanelBody, {
112
116
  title: (0, _i18n.__)('Layout')
113
- }, allowInheriting && !!defaultThemeLayout && (0, _element.createElement)(_components.ToggleControl, {
117
+ }, showInheritToggle && (0, _element.createElement)(_components.ToggleControl, {
114
118
  label: (0, _i18n.__)('Inherit default layout'),
115
119
  checked: !!inherit,
116
120
  onChange: () => setAttributes({
@@ -222,6 +226,7 @@ const withLayoutStyles = (0, _compose.createHigherOrderComponent)(BlockListBlock
222
226
  [`wp-container-${id}`]: shouldRenderLayoutStyles
223
227
  });
224
228
  return (0, _element.createElement)(_element.Fragment, null, shouldRenderLayoutStyles && element && (0, _element.createPortal)((0, _element.createElement)(_layout.LayoutStyle, {
229
+ blockName: name,
225
230
  selector: `.wp-container-${id}`,
226
231
  layout: usedLayout,
227
232
  style: attributes === null || attributes === void 0 ? void 0 : attributes.style
@@ -1 +1 @@
1
- {"version":3,"sources":["@wordpress/block-editor/src/hooks/layout.js"],"names":["layoutBlockSupportKey","LayoutPanel","setAttributes","attributes","name","blockName","layout","defaultThemeLayout","themeSupportsLayout","select","getSettings","blockEditorStore","supportsLayout","layoutBlockSupport","allowSwitching","allowEditing","allowInheriting","default","defaultBlockLayout","usedLayout","inherit","type","layoutType","onChangeType","newType","onChangeLayout","newLayout","LayoutTypeSwitcher","onChange","map","label","addAttribute","settings","withInspectorControls","BlockEdit","props","supportLayout","withLayoutStyles","BlockListBlock","shouldRenderLayoutStyles","id","element","BlockList","__unstableElementContext","className","style"],"mappings":";;;;;;;;;;AAoBA;;;;AAjBA;;AACA;;AAKA;;AACA;;AACA;;AACA;;AACA;;AAMA;;AAMA;;AACA;;AACA;;AACA;;AACA;;AACA;;AA9BA;AACA;AACA;;AAIA;AACA;AACA;;AAcA;AACA;AACA;AAQA,MAAMA,qBAAqB,GAAG,sBAA9B;;AAEA,SAASC,WAAT,OAAuE;AAAA,MAAjD;AAAEC,IAAAA,aAAF;AAAiBC,IAAAA,UAAjB;AAA6BC,IAAAA,IAAI,EAAEC;AAAnC,GAAiD;AACtE,QAAM;AAAEC,IAAAA;AAAF,MAAaH,UAAnB;AACA,QAAMI,kBAAkB,GAAG,yBAAY,QAAZ,CAA3B;AACA,QAAMC,mBAAmB,GAAG,qBAAaC,MAAF,IAAc;AACpD,UAAM;AAAEC,MAAAA;AAAF,QAAkBD,MAAM,CAAEE,YAAF,CAA9B;AACA,WAAOD,WAAW,GAAGE,cAArB;AACA,GAH2B,EAGzB,EAHyB,CAA5B;AAKA,QAAMC,kBAAkB,GAAG,6BAC1BR,SAD0B,EAE1BL,qBAF0B,EAG1B,EAH0B,CAA3B;AAKA,QAAM;AACLc,IAAAA,cADK;AAELC,IAAAA,YAAY,GAAG,IAFV;AAGLC,IAAAA,eAAe,GAAG,IAHb;AAILC,IAAAA,OAAO,EAAEC;AAJJ,MAKFL,kBALJ;;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C,IAAA,MAAM,EAAGrB,UAFV;AAGC,IAAA,KAAK,EAAGhB,UAAH,aAAGA,UAAH,uBAAGA,UAAU,CAAE0C;AAHrB,IADD,EAMCJ,OAND,CAHF,EAWC,4BAAC,cAAD,6BAAqBN,KAArB;AAA6B,IAAA,SAAS,EAAGS;AAAzC,KAXD,CADD;AAeA,CAnC8B,CAAzB;;AAsCP,sBACC,0BADD,EAEC,0BAFD,EAGCb,YAHD;AAKA,sBACC,uBADD,EAEC,uCAFD,EAGCM,gBAHD;AAKA,sBACC,kBADD,EAEC,4CAFD,EAGCJ,qBAHD","sourcesContent":["/**\n * External dependencies\n */\nimport classnames from 'classnames';\nimport { has } from 'lodash';\n\n/**\n * WordPress dependencies\n */\nimport { createHigherOrderComponent, useInstanceId } from '@wordpress/compose';\nimport { addFilter } from '@wordpress/hooks';\nimport { getBlockSupport, hasBlockSupport } from '@wordpress/blocks';\nimport { useSelect } from '@wordpress/data';\nimport {\n\tButton,\n\tButtonGroup,\n\tToggleControl,\n\tPanelBody,\n} from '@wordpress/components';\nimport { __ } from '@wordpress/i18n';\nimport { useContext, createPortal } from '@wordpress/element';\n\n/**\n * Internal dependencies\n */\nimport { store as blockEditorStore } from '../store';\nimport { InspectorControls } from '../components';\nimport useSetting from '../components/use-setting';\nimport { LayoutStyle } from '../components/block-list/layout';\nimport BlockList from '../components/block-list';\nimport { getLayoutType, getLayoutTypes } from '../layouts';\n\nconst layoutBlockSupportKey = '__experimentalLayout';\n\nfunction LayoutPanel( { setAttributes, attributes, name: blockName } ) {\n\tconst { layout } = attributes;\n\tconst defaultThemeLayout = useSetting( 'layout' );\n\tconst themeSupportsLayout = useSelect( ( select ) => {\n\t\tconst { getSettings } = select( blockEditorStore );\n\t\treturn getSettings().supportsLayout;\n\t}, [] );\n\n\tconst layoutBlockSupport = getBlockSupport(\n\t\tblockName,\n\t\tlayoutBlockSupportKey,\n\t\t{}\n\t);\n\tconst {\n\t\tallowSwitching,\n\t\tallowEditing = true,\n\t\tallowInheriting = true,\n\t\tdefault: defaultBlockLayout,\n\t} = layoutBlockSupport;\n\n\tif ( ! allowEditing ) {\n\t\treturn null;\n\t}\n\n\tconst usedLayout = layout || defaultBlockLayout || {};\n\tconst { inherit = false, type = 'default' } = usedLayout;\n\t/**\n\t * `themeSupportsLayout` is only relevant to the `default/flow`\n\t * layout and it should not be taken into account when other\n\t * `layout` types are used.\n\t */\n\tif ( type === 'default' && ! themeSupportsLayout ) {\n\t\treturn null;\n\t}\n\tconst layoutType = getLayoutType( type );\n\n\tconst onChangeType = ( newType ) =>\n\t\tsetAttributes( { layout: { type: newType } } );\n\tconst onChangeLayout = ( newLayout ) =>\n\t\tsetAttributes( { layout: newLayout } );\n\n\treturn (\n\t\t<>\n\t\t\t<InspectorControls>\n\t\t\t\t<PanelBody title={ __( 'Layout' ) }>\n\t\t\t\t\t{ allowInheriting && !! defaultThemeLayout && (\n\t\t\t\t\t\t<ToggleControl\n\t\t\t\t\t\t\tlabel={ __( 'Inherit default layout' ) }\n\t\t\t\t\t\t\tchecked={ !! inherit }\n\t\t\t\t\t\t\tonChange={ () =>\n\t\t\t\t\t\t\t\tsetAttributes( {\n\t\t\t\t\t\t\t\t\tlayout: { inherit: ! inherit },\n\t\t\t\t\t\t\t\t} )\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t/>\n\t\t\t\t\t) }\n\n\t\t\t\t\t{ ! inherit && allowSwitching && (\n\t\t\t\t\t\t<LayoutTypeSwitcher\n\t\t\t\t\t\t\ttype={ type }\n\t\t\t\t\t\t\tonChange={ onChangeType }\n\t\t\t\t\t\t/>\n\t\t\t\t\t) }\n\n\t\t\t\t\t{ ! inherit && layoutType && (\n\t\t\t\t\t\t<layoutType.inspectorControls\n\t\t\t\t\t\t\tlayout={ usedLayout }\n\t\t\t\t\t\t\tonChange={ onChangeLayout }\n\t\t\t\t\t\t\tlayoutBlockSupport={ layoutBlockSupport }\n\t\t\t\t\t\t/>\n\t\t\t\t\t) }\n\t\t\t\t</PanelBody>\n\t\t\t</InspectorControls>\n\t\t\t{ ! inherit && layoutType && (\n\t\t\t\t<layoutType.toolBarControls\n\t\t\t\t\tlayout={ usedLayout }\n\t\t\t\t\tonChange={ onChangeLayout }\n\t\t\t\t\tlayoutBlockSupport={ layoutBlockSupport }\n\t\t\t\t/>\n\t\t\t) }\n\t\t</>\n\t);\n}\n\nfunction LayoutTypeSwitcher( { type, onChange } ) {\n\treturn (\n\t\t<ButtonGroup>\n\t\t\t{ getLayoutTypes().map( ( { name, label } ) => {\n\t\t\t\treturn (\n\t\t\t\t\t<Button\n\t\t\t\t\t\tkey={ name }\n\t\t\t\t\t\tisPressed={ type === name }\n\t\t\t\t\t\tonClick={ () => onChange( name ) }\n\t\t\t\t\t>\n\t\t\t\t\t\t{ label }\n\t\t\t\t\t</Button>\n\t\t\t\t);\n\t\t\t} ) }\n\t\t</ButtonGroup>\n\t);\n}\n\n/**\n * Filters registered block settings, extending attributes to include `layout`.\n *\n * @param {Object} settings Original block settings.\n *\n * @return {Object} Filtered block settings.\n */\nexport function addAttribute( settings ) {\n\tif ( has( settings.attributes, [ 'layout', 'type' ] ) ) {\n\t\treturn settings;\n\t}\n\tif ( hasBlockSupport( settings, layoutBlockSupportKey ) ) {\n\t\tsettings.attributes = {\n\t\t\t...settings.attributes,\n\t\t\tlayout: {\n\t\t\t\ttype: 'object',\n\t\t\t},\n\t\t};\n\t}\n\n\treturn settings;\n}\n\n/**\n * Override the default edit UI to include layout controls\n *\n * @param {Function} BlockEdit Original component.\n *\n * @return {Function} Wrapped component.\n */\nexport const withInspectorControls = createHigherOrderComponent(\n\t( BlockEdit ) => ( props ) => {\n\t\tconst { name: blockName } = props;\n\t\tconst supportLayout = hasBlockSupport(\n\t\t\tblockName,\n\t\t\tlayoutBlockSupportKey\n\t\t);\n\n\t\treturn [\n\t\t\tsupportLayout && <LayoutPanel key=\"layout\" { ...props } />,\n\t\t\t<BlockEdit key=\"edit\" { ...props } />,\n\t\t];\n\t},\n\t'withInspectorControls'\n);\n\n/**\n * Override the default block element to add the layout styles.\n *\n * @param {Function} BlockListBlock Original component.\n *\n * @return {Function} Wrapped component.\n */\nexport const withLayoutStyles = createHigherOrderComponent(\n\t( BlockListBlock ) => ( props ) => {\n\t\tconst { name, attributes } = props;\n\t\tconst shouldRenderLayoutStyles = hasBlockSupport(\n\t\t\tname,\n\t\t\tlayoutBlockSupportKey\n\t\t);\n\t\tconst id = useInstanceId( BlockListBlock );\n\t\tconst defaultThemeLayout = useSetting( 'layout' ) || {};\n\t\tconst element = useContext( BlockList.__unstableElementContext );\n\t\tconst { layout } = attributes;\n\t\tconst { default: defaultBlockLayout } =\n\t\t\tgetBlockSupport( name, layoutBlockSupportKey ) || {};\n\t\tconst usedLayout = layout?.inherit\n\t\t\t? defaultThemeLayout\n\t\t\t: layout || defaultBlockLayout || {};\n\t\tconst className = classnames( props?.className, {\n\t\t\t[ `wp-container-${ id }` ]: shouldRenderLayoutStyles,\n\t\t} );\n\n\t\treturn (\n\t\t\t<>\n\t\t\t\t{ shouldRenderLayoutStyles &&\n\t\t\t\t\telement &&\n\t\t\t\t\tcreatePortal(\n\t\t\t\t\t\t<LayoutStyle\n\t\t\t\t\t\t\tselector={ `.wp-container-${ id }` }\n\t\t\t\t\t\t\tlayout={ usedLayout }\n\t\t\t\t\t\t\tstyle={ attributes?.style }\n\t\t\t\t\t\t/>,\n\t\t\t\t\t\telement\n\t\t\t\t\t) }\n\t\t\t\t<BlockListBlock { ...props } className={ className } />\n\t\t\t</>\n\t\t);\n\t}\n);\n\naddFilter(\n\t'blocks.registerBlockType',\n\t'core/layout/addAttribute',\n\taddAttribute\n);\naddFilter(\n\t'editor.BlockListBlock',\n\t'core/editor/layout/with-layout-styles',\n\twithLayoutStyles\n);\naddFilter(\n\t'editor.BlockEdit',\n\t'core/editor/layout/with-inspector-controls',\n\twithInspectorControls\n);\n"]}
1
+ {"version":3,"sources":["@wordpress/block-editor/src/hooks/layout.js"],"names":["layoutBlockSupportKey","LayoutPanel","setAttributes","attributes","name","blockName","layout","defaultThemeLayout","themeSupportsLayout","select","getSettings","blockEditorStore","supportsLayout","layoutBlockSupport","allowSwitching","allowEditing","allowInheriting","default","defaultBlockLayout","showInheritToggle","type","inherit","usedLayout","layoutType","onChangeType","newType","onChangeLayout","newLayout","LayoutTypeSwitcher","onChange","map","label","addAttribute","settings","withInspectorControls","BlockEdit","props","supportLayout","withLayoutStyles","BlockListBlock","shouldRenderLayoutStyles","id","element","BlockList","__unstableElementContext","className","style"],"mappings":";;;;;;;;;;AAoBA;;;;AAjBA;;AACA;;AAKA;;AACA;;AACA;;AACA;;AACA;;AAMA;;AAMA;;AACA;;AACA;;AACA;;AACA;;AACA;;AA9BA;AACA;AACA;;AAIA;AACA;AACA;;AAcA;AACA;AACA;AAQA,MAAMA,qBAAqB,GAAG,sBAA9B;;AAEA,SAASC,WAAT,OAAuE;AAAA,MAAjD;AAAEC,IAAAA,aAAF;AAAiBC,IAAAA,UAAjB;AAA6BC,IAAAA,IAAI,EAAEC;AAAnC,GAAiD;AACtE,QAAM;AAAEC,IAAAA;AAAF,MAAaH,UAAnB;AACA,QAAMI,kBAAkB,GAAG,yBAAY,QAAZ,CAA3B;AACA,QAAMC,mBAAmB,GAAG,qBAAaC,MAAF,IAAc;AACpD,UAAM;AAAEC,MAAAA;AAAF,QAAkBD,MAAM,CAAEE,YAAF,CAA9B;AACA,WAAOD,WAAW,GAAGE,cAArB;AACA,GAH2B,EAGzB,EAHyB,CAA5B;AAKA,QAAMC,kBAAkB,GAAG,6BAC1BR,SAD0B,EAE1BL,qBAF0B,EAG1B,EAH0B,CAA3B;AAKA,QAAM;AACLc,IAAAA,cADK;AAELC,IAAAA,YAAY,GAAG,IAFV;AAGLC,IAAAA,eAAe,GAAG,IAHb;AAILC,IAAAA,OAAO,EAAEC;AAJJ,MAKFL,kBALJ;;AAOA,MAAK,CAAEE,YAAP,EAAsB;AACrB,WAAO,IAAP;AACA,GAtBqE,CAwBtE;AACA;AACA;;;A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uBAAYA,KAAK,CAAES,SAAnB,EAA8B;AAC/C,KAAG,gBAAgBJ,EAAI,EAAvB,GAA4BD;AADmB,GAA9B,CAAlB;AAIA,SACC,qDACGA,wBAAwB,IACzBE,OADC,IAED,2BACC,4BAAC,mBAAD;AACC,IAAA,SAAS,EAAGtC,IADb;AAEC,IAAA,QAAQ,EAAI,iBAAiBqC,EAAI,EAFlC;AAGC,IAAA,MAAM,EAAGnB,UAHV;AAIC,IAAA,KAAK,EAAGnB,UAAH,aAAGA,UAAH,uBAAGA,UAAU,CAAE2C;AAJrB,IADD,EAOCJ,OAPD,CAHF,EAYC,4BAAC,cAAD,6BAAqBN,KAArB;AAA6B,IAAA,SAAS,EAAGS;AAAzC,KAZD,CADD;AAgBA,CApC8B,CAAzB;;AAuCP,sBACC,0BADD,EAEC,0BAFD,EAGCb,YAHD;AAKA,sBACC,uBADD,EAEC,uCAFD,EAGCM,gBAHD;AAKA,sBACC,kBADD,EAEC,4CAFD,EAGCJ,qBAHD","sourcesContent":["/**\n * External dependencies\n */\nimport classnames from 'classnames';\nimport { has } from 'lodash';\n\n/**\n * WordPress dependencies\n */\nimport { createHigherOrderComponent, useInstanceId } from '@wordpress/compose';\nimport { addFilter } from '@wordpress/hooks';\nimport { getBlockSupport, hasBlockSupport } from '@wordpress/blocks';\nimport { useSelect } from '@wordpress/data';\nimport {\n\tButton,\n\tButtonGroup,\n\tToggleControl,\n\tPanelBody,\n} from '@wordpress/components';\nimport { __ } from '@wordpress/i18n';\nimport { useContext, createPortal } from '@wordpress/element';\n\n/**\n * Internal dependencies\n */\nimport { store as blockEditorStore } from '../store';\nimport { InspectorControls } from '../components';\nimport useSetting from '../components/use-setting';\nimport { LayoutStyle } from '../components/block-list/layout';\nimport BlockList from '../components/block-list';\nimport { getLayoutType, getLayoutTypes } from '../layouts';\n\nconst layoutBlockSupportKey = '__experimentalLayout';\n\nfunction LayoutPanel( { setAttributes, attributes, name: blockName } ) {\n\tconst { layout } = attributes;\n\tconst defaultThemeLayout = useSetting( 'layout' );\n\tconst themeSupportsLayout = useSelect( ( select ) => {\n\t\tconst { getSettings } = select( blockEditorStore );\n\t\treturn getSettings().supportsLayout;\n\t}, [] );\n\n\tconst layoutBlockSupport = getBlockSupport(\n\t\tblockName,\n\t\tlayoutBlockSupportKey,\n\t\t{}\n\t);\n\tconst {\n\t\tallowSwitching,\n\t\tallowEditing = true,\n\t\tallowInheriting = true,\n\t\tdefault: defaultBlockLayout,\n\t} = layoutBlockSupport;\n\n\tif ( ! allowEditing ) {\n\t\treturn null;\n\t}\n\n\t// Only show the inherit toggle if it's supported,\n\t// a default theme layout is set (e.g. one that provides `contentSize` and/or `wideSize` values),\n\t// and that the default / flow layout type is in use, as this is the only one that supports inheritance.\n\tconst showInheritToggle = !! (\n\t\tallowInheriting &&\n\t\t!! defaultThemeLayout &&\n\t\t( ! layout?.type || layout?.type === 'default' || layout?.inherit )\n\t);\n\n\tconst usedLayout = layout || defaultBlockLayout || {};\n\tconst { inherit = false, type = 'default' } = usedLayout;\n\t/**\n\t * `themeSupportsLayout` is only relevant to the `default/flow`\n\t * layout and it should not be taken into account when other\n\t * `layout` types are used.\n\t */\n\tif ( type === 'default' && ! themeSupportsLayout ) {\n\t\treturn null;\n\t}\n\tconst layoutType = getLayoutType( type );\n\n\tconst onChangeType = ( newType ) =>\n\t\tsetAttributes( { layout: { type: newType } } );\n\tconst onChangeLayout = ( newLayout ) =>\n\t\tsetAttributes( { layout: newLayout } );\n\n\treturn (\n\t\t<>\n\t\t\t<InspectorControls>\n\t\t\t\t<PanelBody title={ __( 'Layout' ) }>\n\t\t\t\t\t{ showInheritToggle && (\n\t\t\t\t\t\t<ToggleControl\n\t\t\t\t\t\t\tlabel={ __( 'Inherit default layout' ) }\n\t\t\t\t\t\t\tchecked={ !! inherit }\n\t\t\t\t\t\t\tonChange={ () =>\n\t\t\t\t\t\t\t\tsetAttributes( {\n\t\t\t\t\t\t\t\t\tlayout: { inherit: ! inherit },\n\t\t\t\t\t\t\t\t} )\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t/>\n\t\t\t\t\t) }\n\n\t\t\t\t\t{ ! inherit && allowSwitching && (\n\t\t\t\t\t\t<LayoutTypeSwitcher\n\t\t\t\t\t\t\ttype={ type }\n\t\t\t\t\t\t\tonChange={ onChangeType }\n\t\t\t\t\t\t/>\n\t\t\t\t\t) }\n\n\t\t\t\t\t{ ! inherit && layoutType && (\n\t\t\t\t\t\t<layoutType.inspectorControls\n\t\t\t\t\t\t\tlayout={ usedLayout }\n\t\t\t\t\t\t\tonChange={ onChangeLayout }\n\t\t\t\t\t\t\tlayoutBlockSupport={ layoutBlockSupport }\n\t\t\t\t\t\t/>\n\t\t\t\t\t) }\n\t\t\t\t</PanelBody>\n\t\t\t</InspectorControls>\n\t\t\t{ ! inherit && layoutType && (\n\t\t\t\t<layoutType.toolBarControls\n\t\t\t\t\tlayout={ usedLayout }\n\t\t\t\t\tonChange={ onChangeLayout }\n\t\t\t\t\tlayoutBlockSupport={ layoutBlockSupport }\n\t\t\t\t/>\n\t\t\t) }\n\t\t</>\n\t);\n}\n\nfunction LayoutTypeSwitcher( { type, onChange } ) {\n\treturn (\n\t\t<ButtonGroup>\n\t\t\t{ getLayoutTypes().map( ( { name, label } ) => {\n\t\t\t\treturn (\n\t\t\t\t\t<Button\n\t\t\t\t\t\tkey={ name }\n\t\t\t\t\t\tisPressed={ type === name }\n\t\t\t\t\t\tonClick={ () => onChange( name ) }\n\t\t\t\t\t>\n\t\t\t\t\t\t{ label }\n\t\t\t\t\t</Button>\n\t\t\t\t);\n\t\t\t} ) }\n\t\t</ButtonGroup>\n\t);\n}\n\n/**\n * Filters registered block settings, extending attributes to include `layout`.\n *\n * @param {Object} settings Original block settings.\n *\n * @return {Object} Filtered block settings.\n */\nexport function addAttribute( settings ) {\n\tif ( has( settings.attributes, [ 'layout', 'type' ] ) ) {\n\t\treturn settings;\n\t}\n\tif ( hasBlockSupport( settings, layoutBlockSupportKey ) ) {\n\t\tsettings.attributes = {\n\t\t\t...settings.attributes,\n\t\t\tlayout: {\n\t\t\t\ttype: 'object',\n\t\t\t},\n\t\t};\n\t}\n\n\treturn settings;\n}\n\n/**\n * Override the default edit UI to include layout controls\n *\n * @param {Function} BlockEdit Original component.\n *\n * @return {Function} Wrapped component.\n */\nexport const withInspectorControls = createHigherOrderComponent(\n\t( BlockEdit ) => ( props ) => {\n\t\tconst { name: blockName } = props;\n\t\tconst supportLayout = hasBlockSupport(\n\t\t\tblockName,\n\t\t\tlayoutBlockSupportKey\n\t\t);\n\n\t\treturn [\n\t\t\tsupportLayout && <LayoutPanel key=\"layout\" { ...props } />,\n\t\t\t<BlockEdit key=\"edit\" { ...props } />,\n\t\t];\n\t},\n\t'withInspectorControls'\n);\n\n/**\n * Override the default block element to add the layout styles.\n *\n * @param {Function} BlockListBlock Original component.\n *\n * @return {Function} Wrapped component.\n */\nexport const withLayoutStyles = createHigherOrderComponent(\n\t( BlockListBlock ) => ( props ) => {\n\t\tconst { name, attributes } = props;\n\t\tconst shouldRenderLayoutStyles = hasBlockSupport(\n\t\t\tname,\n\t\t\tlayoutBlockSupportKey\n\t\t);\n\t\tconst id = useInstanceId( BlockListBlock );\n\t\tconst defaultThemeLayout = useSetting( 'layout' ) || {};\n\t\tconst element = useContext( BlockList.__unstableElementContext );\n\t\tconst { layout } = attributes;\n\t\tconst { default: defaultBlockLayout } =\n\t\t\tgetBlockSupport( name, layoutBlockSupportKey ) || {};\n\t\tconst usedLayout = layout?.inherit\n\t\t\t? defaultThemeLayout\n\t\t\t: layout || defaultBlockLayout || {};\n\t\tconst className = classnames( props?.className, {\n\t\t\t[ `wp-container-${ id }` ]: shouldRenderLayoutStyles,\n\t\t} );\n\n\t\treturn (\n\t\t\t<>\n\t\t\t\t{ shouldRenderLayoutStyles &&\n\t\t\t\t\telement &&\n\t\t\t\t\tcreatePortal(\n\t\t\t\t\t\t<LayoutStyle\n\t\t\t\t\t\t\tblockName={ name }\n\t\t\t\t\t\t\tselector={ `.wp-container-${ id }` }\n\t\t\t\t\t\t\tlayout={ usedLayout }\n\t\t\t\t\t\t\tstyle={ attributes?.style }\n\t\t\t\t\t\t/>,\n\t\t\t\t\t\telement\n\t\t\t\t\t) }\n\t\t\t\t<BlockListBlock { ...props } className={ className } />\n\t\t\t</>\n\t\t);\n\t}\n);\n\naddFilter(\n\t'blocks.registerBlockType',\n\t'core/layout/addAttribute',\n\taddAttribute\n);\naddFilter(\n\t'editor.BlockListBlock',\n\t'core/editor/layout/with-layout-styles',\n\twithLayoutStyles\n);\naddFilter(\n\t'editor.BlockEdit',\n\t'core/editor/layout/with-inspector-controls',\n\twithInspectorControls\n);\n"]}
@@ -38,6 +38,8 @@ var _dimensions = require("./dimensions");
38
38
 
39
39
  var _useDisplayBlockControls = _interopRequireDefault(require("../components/use-display-block-controls"));
40
40
 
41
+ var _utils = require("./utils");
42
+
41
43
  /**
42
44
  * External dependencies
43
45
  */
@@ -189,6 +191,21 @@ const skipSerializationPathsEdit = {
189
191
  const skipSerializationPathsSave = { ...skipSerializationPathsEdit,
190
192
  [`${_dimensions.SPACING_SUPPORT_KEY}`]: ['spacing.blockGap']
191
193
  };
194
+ /**
195
+ * A dictionary used to normalize feature names between support flags, style
196
+ * object properties and __experimentSkipSerialization configuration arrays.
197
+ *
198
+ * This allows not having to provide a migration for a support flag and possible
199
+ * backwards compatibility bridges, while still achieving consistency between
200
+ * the support flag and the skip serialization array.
201
+ *
202
+ * @constant
203
+ * @type {Record<string, string>}
204
+ */
205
+
206
+ const renamedFeatures = {
207
+ gradients: 'gradient'
208
+ };
192
209
  /**
193
210
  * Override props assigned to save component to inject the CSS variables definition.
194
211
  *
@@ -211,9 +228,18 @@ function addSaveProps(props, blockType, attributes) {
211
228
  style
212
229
  } = attributes;
213
230
  (0, _lodash.forEach)(skipPaths, (path, indicator) => {
214
- if ((0, _blocks.getBlockSupport)(blockType, indicator)) {
231
+ const skipSerialization = (0, _blocks.getBlockSupport)(blockType, indicator);
232
+
233
+ if (skipSerialization === true) {
215
234
  style = (0, _lodash.omit)(style, path);
216
235
  }
236
+
237
+ if (Array.isArray(skipSerialization)) {
238
+ skipSerialization.forEach(featureName => {
239
+ const feature = renamedFeatures[featureName] || featureName;
240
+ style = (0, _lodash.omit)(style, [[...path, feature]]);
241
+ });
242
+ }
217
243
  });
218
244
  props.style = { ...getInlineStyles(style),
219
245
  ...props.style
@@ -274,9 +300,14 @@ exports.withBlockControls = withBlockControls;
274
300
  const withElementsStyles = (0, _compose.createHigherOrderComponent)(BlockListBlock => props => {
275
301
  var _props$attributes$sty, _props$attributes$sty2;
276
302
 
277
- const elements = (_props$attributes$sty = props.attributes.style) === null || _props$attributes$sty === void 0 ? void 0 : _props$attributes$sty.elements;
278
303
  const blockElementsContainerIdentifier = `wp-elements-${(0, _compose.useInstanceId)(BlockListBlock)}`;
279
- const styles = compileElementsStyles(blockElementsContainerIdentifier, (_props$attributes$sty2 = props.attributes.style) === null || _props$attributes$sty2 === void 0 ? void 0 : _props$attributes$sty2.elements);
304
+ const skipLinkColorSerialization = (0, _utils.shouldSkipSerialization)(props.name, _color.COLOR_SUPPORT_KEY, 'link'); // The Elements API only supports link colors for now,
305
+ // hence the specific omission of `link` in the elements styles.
306
+ // This might need to be refactored or removed if the Elements API
307
+ // changes or `link` supports styles beyond `color`.
308
+
309
+ const elements = skipLinkColorSerialization ? (0, _lodash.omit)((_props$attributes$sty = props.attributes.style) === null || _props$attributes$sty === void 0 ? void 0 : _props$attributes$sty.elements, ['link']) : (_props$attributes$sty2 = props.attributes.style) === null || _props$attributes$sty2 === void 0 ? void 0 : _props$attributes$sty2.elements;
310
+ const styles = compileElementsStyles(blockElementsContainerIdentifier, elements);
280
311
  const element = (0, _element.useContext)(_blockList.default.__unstableElementContext);
281
312
  return (0, _element.createElement)(_element.Fragment, null, elements && element && (0, _element.createPortal)((0, _element.createElement)("style", {
282
313
  dangerouslySetInnerHTML: {
@@ -1 +1 @@
1
- {"version":3,"sources":["@wordpress/block-editor/src/hooks/style.js"],"names":["styleSupportKeys","TYPOGRAPHY_SUPPORT_KEYS","BORDER_SUPPORT_KEY","COLOR_SUPPORT_KEY","SPACING_SUPPORT_KEY","hasStyleSupport","blockType","some","key","VARIABLE_REFERENCE_PREFIX","VARIABLE_PATH_SEPARATOR_TOKEN_ATTRIBUTE","VARIABLE_PATH_SEPARATOR_TOKEN_STYLE","compileStyleValue","uncompiledValue","variable","slice","length","split","join","getInlineStyles","styles","ignoredStyles","output","Object","keys","STYLE_PROPERTY","forEach","propKey","path","value","subPaths","properties","styleValue","useEngine","entries","entry","name","subPath","includes","extraRules","selector","rule","compileElementsStyles","elements","element","elementStyles","ELEMENTS","property","addAttribute","settings","attributes","style","assign","type","skipSerializationPathsEdit","TYPOGRAPHY_SUPPORT_KEY","skipSerializationPathsSave","addSaveProps","props","skipPaths","indicator","addEditProps","existingGetEditWrapperProps","getEditWrapperProps","withBlockControls","BlockEdit","shouldDisplayControls","withElementsStyles","BlockListBlock","blockElementsContainerIdentifier","BlockList","__unstableElementContext","__html","className"],"mappings":";;;;;;;;;;;;AAoBA;;;;AAjBA;;AAYA;;AAMA;;AACA;;AAMA;;AACA;;AAKA;;AACA;;AACA;;AACA;;AAKA;;AACA;;AA3CA;AACA;AACA;;AAeA;AACA;AACA;;AAYA;AACA;AACA;AAYA,MAAMA,gBAAgB,GAAG,CACxB,GAAGC,mCADqB,EAExBC,0BAFwB,EAGxBC,wBAHwB,EAIxBC,+BAJwB,CAAzB;;AAOA,MAAMC,eAAe,GAAKC,SAAF,IACvBN,gBAAgB,CAACO,IAAjB,CAAyBC,GAAF,IAAW,6BAAiBF,SAAjB,EAA4BE,GAA5B,CAAlC,CADD;;AAGA,MAAMC,yBAAyB,GAAG,MAAlC;AACA,MAAMC,uCAAuC,GAAG,GAAhD;AACA,MAAMC,mCAAmC,GAAG,IAA5C;;AACA,SAASC,iBAAT,CAA4BC,eAA5B,EAA8C;AAC7C,MAAK,wBAAYA,eAAZ,EAA6BJ,yBAA7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kB,GAAG,yCACxBC,cAAF,IAAwBV,KAAF,IAAa;AAAA;;AAClC,QAAMf,QAAQ,4BAAGe,KAAK,CAACR,UAAN,CAAiBC,KAApB,0DAAG,sBAAwBR,QAAzC;AAEA,QAAM0B,gCAAgC,GAAI,eAAe,4BACxDD,cADwD,CAEtD,EAFH;AAGA,QAAMhD,MAAM,GAAGsB,qBAAqB,CACnC2B,gCADmC,4BAEnCX,KAAK,CAACR,UAAN,CAAiBC,KAFkB,2DAEnC,uBAAwBR,QAFW,CAApC;AAIA,QAAMC,OAAO,GAAG,yBAAY0B,mBAAUC,wBAAtB,CAAhB;AAEA,SACC,qDACG5B,QAAQ,IACTC,OADC,IAED,2BACC;AACC,IAAA,uBAAuB,EAAG;AACzB4B,MAAAA,MAAM,EAAEpD;AADiB;AAD3B,IADD,EAMCwB,OAND,CAHF,EAYC,4BAAC,cAAD,6BACMc,KADN;AAEC,IAAA,SAAS,EACRf,QAAQ,GACL,yBACAe,KAAK,CAACe,SADN,EAEAJ,gCAFA,CADK,GAKLX,KAAK,CAACe;AARX,KAZD,CADD;AA0BA,CAvCyB,CAA3B;AA0CA,sBACC,0BADD,EAEC,yBAFD,EAGCzB,YAHD;AAMA,sBACC,kCADD,EAEC,yBAFD,EAGCS,YAHD;AAMA,sBACC,0BADD,EAEC,yBAFD,EAGCI,YAHD;AAMA,sBACC,kBADD,EAEC,gCAFD,EAGCG,iBAHD;AAMA,sBACC,uBADD,EAEC,kCAFD,EAGCG,kBAHD","sourcesContent":["/**\n * External dependencies\n */\nimport {\n\tfirst,\n\tforEach,\n\tget,\n\thas,\n\tisEmpty,\n\tisString,\n\tkebabCase,\n\tmap,\n\tomit,\n\tstartsWith,\n} from 'lodash';\nimport classnames from 'classnames';\n\n/**\n * WordPress dependencies\n */\nimport { useContext, createPortal } from '@wordpress/element';\nimport { addFilter } from '@wordpress/hooks';\nimport {\n\tgetBlockSupport,\n\thasBlockSupport,\n\t__EXPERIMENTAL_STYLE_PROPERTY as STYLE_PROPERTY,\n\t__EXPERIMENTAL_ELEMENTS as ELEMENTS,\n} from '@wordpress/blocks';\nimport { createHigherOrderComponent, useInstanceId } from '@wordpress/compose';\nimport { getCSSRules } from '@wordpress/style-engine';\n\n/**\n * Internal dependencies\n */\nimport BlockList from '../components/block-list';\nimport { BORDER_SUPPORT_KEY, BorderPanel } from './border';\nimport { COLOR_SUPPORT_KEY, ColorEdit } from './color';\nimport {\n\tTypographyPanel,\n\tTYPOGRAPHY_SUPPORT_KEY,\n\tTYPOGRAPHY_SUPPORT_KEYS,\n} from './typography';\nimport { SPACING_SUPPORT_KEY, DimensionsPanel } from './dimensions';\nimport useDisplayBlockControls from '../components/use-display-block-controls';\n\nconst styleSupportKeys = [\n\t...TYPOGRAPHY_SUPPORT_KEYS,\n\tBORDER_SUPPORT_KEY,\n\tCOLOR_SUPPORT_KEY,\n\tSPACING_SUPPORT_KEY,\n];\n\nconst hasStyleSupport = ( blockType ) =>\n\tstyleSupportKeys.some( ( key ) => hasBlockSupport( blockType, key ) );\n\nconst VARIABLE_REFERENCE_PREFIX = 'var:';\nconst VARIABLE_PATH_SEPARATOR_TOKEN_ATTRIBUTE = '|';\nconst VARIABLE_PATH_SEPARATOR_TOKEN_STYLE = '--';\nfunction compileStyleValue( uncompiledValue ) {\n\tif ( startsWith( uncompiledValue, VARIABLE_REFERENCE_PREFIX ) ) {\n\t\tconst variable = uncompiledValue\n\t\t\t.slice( VARIABLE_REFERENCE_PREFIX.length )\n\t\t\t.split( VARIABLE_PATH_SEPARATOR_TOKEN_ATTRIBUTE )\n\t\t\t.join( VARIABLE_PATH_SEPARATOR_TOKEN_STYLE );\n\t\treturn `var(--wp--${ variable })`;\n\t}\n\treturn uncompiledValue;\n}\n\n/**\n * Returns the inline styles to add depending on the style object\n *\n * @param {Object} styles Styles configuration.\n *\n * @return {Object} Flattened CSS variables declaration.\n */\nexport function getInlineStyles( styles = {} ) {\n\tconst ignoredStyles = [ 'spacing.blockGap' ];\n\tconst output = {};\n\tObject.keys( STYLE_PROPERTY ).forEach( ( propKey ) => {\n\t\tconst path = STYLE_PROPERTY[ propKey ].value;\n\t\tconst subPaths = STYLE_PROPERTY[ propKey ].properties;\n\t\t// Ignore styles on elements because they are handled on the server.\n\t\tif ( has( styles, path ) && 'elements' !== first( path ) ) {\n\t\t\t// Checking if style value is a string allows for shorthand css\n\t\t\t// option and backwards compatibility for border radius support.\n\t\t\tconst styleValue = get( styles, path );\n\n\t\t\tif ( ! STYLE_PROPERTY[ propKey ].useEngine ) {\n\t\t\t\tif ( !! subPaths && ! isString( styleValue ) ) {\n\t\t\t\t\tObject.entries( subPaths ).forEach( ( entry ) => {\n\t\t\t\t\t\tconst [ name, subPath ] = entry;\n\t\t\t\t\t\tconst value = get( styleValue, [ subPath ] );\n\n\t\t\t\t\t\tif ( value ) {\n\t\t\t\t\t\t\toutput[ name ] = compileStyleValue( value );\n\t\t\t\t\t\t}\n\t\t\t\t\t} );\n\t\t\t\t} else if ( ! ignoredStyles.includes( path.join( '.' ) ) ) {\n\t\t\t\t\toutput[ propKey ] = compileStyleValue(\n\t\t\t\t\t\tget( styles, path )\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t} );\n\n\t// The goal is to move everything to server side generated engine styles\n\t// This is temporary as we absorb more and more styles into the engine.\n\tconst extraRules = getCSSRules( styles, { selector: 'self' } );\n\textraRules.forEach( ( rule ) => {\n\t\tif ( rule.selector !== 'self' ) {\n\t\t\tthrow \"This style can't be added as inline style\";\n\t\t}\n\t\toutput[ rule.key ] = rule.value;\n\t} );\n\n\treturn output;\n}\n\nfunction compileElementsStyles( selector, elements = {} ) {\n\treturn map( elements, ( styles, element ) => {\n\t\tconst elementStyles = getInlineStyles( styles );\n\t\tif ( ! isEmpty( elementStyles ) ) {\n\t\t\t// The .editor-styles-wrapper selector is required on elements styles. As it is\n\t\t\t// added to all other editor styles, not providing it causes reset and global\n\t\t\t// styles to override element styles because of higher specificity.\n\t\t\treturn [\n\t\t\t\t`.editor-styles-wrapper .${ selector } ${ ELEMENTS[ element ] }{`,\n\t\t\t\t...map(\n\t\t\t\t\telementStyles,\n\t\t\t\t\t( value, property ) =>\n\t\t\t\t\t\t`\\t${ kebabCase( property ) }: ${ value };`\n\t\t\t\t),\n\t\t\t\t'}',\n\t\t\t].join( '\\n' );\n\t\t}\n\t\treturn '';\n\t} ).join( '\\n' );\n}\n\n/**\n * Filters registered block settings, extending attributes to include `style` attribute.\n *\n * @param {Object} settings Original block settings.\n *\n * @return {Object} Filtered block settings.\n */\nfunction addAttribute( settings ) {\n\tif ( ! hasStyleSupport( settings ) ) {\n\t\treturn settings;\n\t}\n\n\t// Allow blocks to specify their own attribute definition with default 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\n/**\n * A dictionary of paths to flag skipping block support serialization as the key,\n * with values providing the style paths to be omitted from serialization.\n *\n * @constant\n * @type {Record<string, string[]>}\n */\nconst skipSerializationPathsEdit = {\n\t[ `${ BORDER_SUPPORT_KEY }.__experimentalSkipSerialization` ]: [ 'border' ],\n\t[ `${ COLOR_SUPPORT_KEY }.__experimentalSkipSerialization` ]: [\n\t\tCOLOR_SUPPORT_KEY,\n\t],\n\t[ `${ TYPOGRAPHY_SUPPORT_KEY }.__experimentalSkipSerialization` ]: [\n\t\tTYPOGRAPHY_SUPPORT_KEY,\n\t],\n\t[ `${ SPACING_SUPPORT_KEY }.__experimentalSkipSerialization` ]: [\n\t\t'spacing',\n\t],\n};\n\n/**\n * A dictionary of paths to flag skipping block support serialization as the key,\n * with values providing the style paths to be omitted from serialization.\n *\n * Extends the Edit skip paths to enable skipping additional paths in just\n * the Save component. This allows a block support to be serialized within the\n * editor, while using an alternate approach, such as server-side rendering, when\n * the support is saved.\n *\n * @constant\n * @type {Record<string, string[]>}\n */\nconst skipSerializationPathsSave = {\n\t...skipSerializationPathsEdit,\n\t[ `${ SPACING_SUPPORT_KEY }` ]: [ 'spacing.blockGap' ],\n};\n\n/**\n * Override props assigned to save component to inject the CSS variables definition.\n *\n * @param {Object} props Additional props applied to save element.\n * @param {Object} blockType Block type.\n * @param {Object} attributes Block attributes.\n * @param {?Record<string, string[]>} skipPaths An object of keys and paths to skip serialization.\n *\n * @return {Object} Filtered props applied to save element.\n */\nexport function addSaveProps(\n\tprops,\n\tblockType,\n\tattributes,\n\tskipPaths = skipSerializationPathsSave\n) {\n\tif ( ! hasStyleSupport( blockType ) ) {\n\t\treturn props;\n\t}\n\n\tlet { style } = attributes;\n\n\tforEach( skipPaths, ( path, indicator ) => {\n\t\tif ( getBlockSupport( blockType, indicator ) ) {\n\t\t\tstyle = omit( style, path );\n\t\t}\n\t} );\n\n\tprops.style = {\n\t\t...getInlineStyles( style ),\n\t\t...props.style,\n\t};\n\n\treturn props;\n}\n\n/**\n * Filters registered block settings to extend the block edit wrapper\n * to apply the desired styles and classnames properly.\n *\n * @param {Object} settings Original block settings.\n *\n * @return {Object}.Filtered block settings.\n */\nexport function addEditProps( settings ) {\n\tif ( ! hasStyleSupport( settings ) ) {\n\t\treturn settings;\n\t}\n\n\tconst existingGetEditWrapperProps = settings.getEditWrapperProps;\n\tsettings.getEditWrapperProps = ( attributes ) => {\n\t\tlet props = {};\n\t\tif ( existingGetEditWrapperProps ) {\n\t\t\tprops = existingGetEditWrapperProps( attributes );\n\t\t}\n\n\t\treturn addSaveProps(\n\t\t\tprops,\n\t\t\tsettings,\n\t\t\tattributes,\n\t\t\tskipSerializationPathsEdit\n\t\t);\n\t};\n\n\treturn settings;\n}\n\n/**\n * Override the default edit UI to include new inspector controls for\n * all the custom styles configs.\n *\n * @param {Function} BlockEdit Original component.\n *\n * @return {Function} Wrapped component.\n */\nexport const withBlockControls = createHigherOrderComponent(\n\t( BlockEdit ) => ( props ) => {\n\t\tconst shouldDisplayControls = useDisplayBlockControls();\n\n\t\treturn (\n\t\t\t<>\n\t\t\t\t{ shouldDisplayControls && (\n\t\t\t\t\t<>\n\t\t\t\t\t\t<ColorEdit { ...props } />\n\t\t\t\t\t\t<TypographyPanel { ...props } />\n\t\t\t\t\t\t<BorderPanel { ...props } />\n\t\t\t\t\t\t<DimensionsPanel { ...props } />\n\t\t\t\t\t</>\n\t\t\t\t) }\n\t\t\t\t<BlockEdit { ...props } />\n\t\t\t</>\n\t\t);\n\t},\n\t'withToolbarControls'\n);\n\n/**\n * Override the default block element to include duotone styles.\n *\n * @param {Function} BlockListBlock Original component\n * @return {Function} Wrapped component\n */\nconst withElementsStyles = createHigherOrderComponent(\n\t( BlockListBlock ) => ( props ) => {\n\t\tconst elements = props.attributes.style?.elements;\n\n\t\tconst blockElementsContainerIdentifier = `wp-elements-${ useInstanceId(\n\t\t\tBlockListBlock\n\t\t) }`;\n\t\tconst styles = compileElementsStyles(\n\t\t\tblockElementsContainerIdentifier,\n\t\t\tprops.attributes.style?.elements\n\t\t);\n\t\tconst element = useContext( BlockList.__unstableElementContext );\n\n\t\treturn (\n\t\t\t<>\n\t\t\t\t{ elements &&\n\t\t\t\t\telement &&\n\t\t\t\t\tcreatePortal(\n\t\t\t\t\t\t<style\n\t\t\t\t\t\t\tdangerouslySetInnerHTML={ {\n\t\t\t\t\t\t\t\t__html: styles,\n\t\t\t\t\t\t\t} }\n\t\t\t\t\t\t/>,\n\t\t\t\t\t\telement\n\t\t\t\t\t) }\n\n\t\t\t\t<BlockListBlock\n\t\t\t\t\t{ ...props }\n\t\t\t\t\tclassName={\n\t\t\t\t\t\telements\n\t\t\t\t\t\t\t? classnames(\n\t\t\t\t\t\t\t\t\tprops.className,\n\t\t\t\t\t\t\t\t\tblockElementsContainerIdentifier\n\t\t\t\t\t\t\t )\n\t\t\t\t\t\t\t: props.className\n\t\t\t\t\t}\n\t\t\t\t/>\n\t\t\t</>\n\t\t);\n\t}\n);\n\naddFilter(\n\t'blocks.registerBlockType',\n\t'core/style/addAttribute',\n\taddAttribute\n);\n\naddFilter(\n\t'blocks.getSaveContent.extraProps',\n\t'core/style/addSaveProps',\n\taddSaveProps\n);\n\naddFilter(\n\t'blocks.registerBlockType',\n\t'core/style/addEditProps',\n\taddEditProps\n);\n\naddFilter(\n\t'editor.BlockEdit',\n\t'core/style/with-block-controls',\n\twithBlockControls\n);\n\naddFilter(\n\t'editor.BlockListBlock',\n\t'core/editor/with-elements-styles',\n\twithElementsStyles\n);\n"]}
1
+ {"version":3,"sources":["@wordpress/block-editor/src/hooks/style.js"],"names":["styleSupportKeys","TYPOGRAPHY_SUPPORT_KEYS","BORDER_SUPPORT_KEY","COLOR_SUPPORT_KEY","SPACING_SUPPORT_KEY","hasStyleSupport","blockType","some","key","VARIABLE_REFERENCE_PREFIX","VARIABLE_PATH_SEPARATOR_TOKEN_ATTRIBUTE","VARIABLE_PATH_SEPARATOR_TOKEN_STYLE","compileStyleValue","uncompiledValue","variable","slice","length","split","join","getInlineStyles","styles","ignoredStyles","output","Object","keys","STYLE_PROPERTY","forEach","propKey","path","value","subPaths","properties","styleValue","useEngine","entries","entry","name","subPath","includes","extraRules","selector","rule","compileElementsStyles","elements","element","elementStyles","ELEMENTS","property","addAttribute","settings","attributes","style","assign","type","skipSerializationPathsEdit","TYPOGRAPHY_SUPPORT_KEY","skipSerializationPathsSave","renamedFeatures","gradients","addSaveProps","props","skipPaths","indicator","skipSerialization","Array","isArray","featureName","feature","addEditProps","existingGetEditWrapperProps","getEditWrapperProps","withBlockControls","BlockEdit","shouldDisplayControls","withElementsStyles","BlockListBlock","blockElementsContainerIdentifier","skipLinkColorSerialization","BlockList","__unstableElementContext","__html","className"],"mappings":";;;;;;;;;;;;AAoBA;;;;AAjBA;;AAYA;;AAMA;;AACA;;AAMA;;AACA;;AAKA;;AACA;;AACA;;AACA;;AAKA;;AACA;;AACA;;AA5CA;AACA;AACA;;AAeA;AACA;AACA;;AAYA;AACA;AACA;AAaA,MAAMA,gBAAgB,GAAG,CACxB,GAAGC,mCADqB,EAExBC,0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6BAExCiB,KAAK,CAACV,UAAN,CAAiBC,KAFuB,2DAExC,uBAAwBR,QAF3B;AAIA,QAAMvB,MAAM,GAAGsB,qBAAqB,CACnCkC,gCADmC,EAEnCjC,QAFmC,CAApC;AAIA,QAAMC,OAAO,GAAG,yBAAYkC,mBAAUC,wBAAtB,CAAhB;AAEA,SACC,qDACGpC,QAAQ,IACTC,OADC,IAED,2BACC;AACC,IAAA,uBAAuB,EAAG;AACzBoC,MAAAA,MAAM,EAAE5D;AADiB;AAD3B,IADD,EAMCwB,OAND,CAHF,EAYC,4BAAC,cAAD,6BACMgB,KADN;AAEC,IAAA,SAAS,EACRjB,QAAQ,GACL,yBACAiB,KAAK,CAACqB,SADN,EAEAL,gCAFA,CADK,GAKLhB,KAAK,CAACqB;AARX,KAZD,CADD;AA0BA,CApDyB,CAA3B;AAuDA,sBACC,0BADD,EAEC,yBAFD,EAGCjC,YAHD;AAMA,sBACC,kCADD,EAEC,yBAFD,EAGCW,YAHD;AAMA,sBACC,0BADD,EAEC,yBAFD,EAGCS,YAHD;AAMA,sBACC,kBADD,EAEC,gCAFD,EAGCG,iBAHD;AAMA,sBACC,uBADD,EAEC,kCAFD,EAGCG,kBAHD","sourcesContent":["/**\n * External dependencies\n */\nimport {\n\tfirst,\n\tforEach,\n\tget,\n\thas,\n\tisEmpty,\n\tisString,\n\tkebabCase,\n\tmap,\n\tomit,\n\tstartsWith,\n} from 'lodash';\nimport classnames from 'classnames';\n\n/**\n * WordPress dependencies\n */\nimport { useContext, createPortal } from '@wordpress/element';\nimport { addFilter } from '@wordpress/hooks';\nimport {\n\tgetBlockSupport,\n\thasBlockSupport,\n\t__EXPERIMENTAL_STYLE_PROPERTY as STYLE_PROPERTY,\n\t__EXPERIMENTAL_ELEMENTS as ELEMENTS,\n} from '@wordpress/blocks';\nimport { createHigherOrderComponent, useInstanceId } from '@wordpress/compose';\nimport { getCSSRules } from '@wordpress/style-engine';\n\n/**\n * Internal dependencies\n */\nimport BlockList from '../components/block-list';\nimport { BORDER_SUPPORT_KEY, BorderPanel } from './border';\nimport { COLOR_SUPPORT_KEY, ColorEdit } from './color';\nimport {\n\tTypographyPanel,\n\tTYPOGRAPHY_SUPPORT_KEY,\n\tTYPOGRAPHY_SUPPORT_KEYS,\n} from './typography';\nimport { SPACING_SUPPORT_KEY, DimensionsPanel } from './dimensions';\nimport useDisplayBlockControls from '../components/use-display-block-controls';\nimport { shouldSkipSerialization } from './utils';\n\nconst styleSupportKeys = [\n\t...TYPOGRAPHY_SUPPORT_KEYS,\n\tBORDER_SUPPORT_KEY,\n\tCOLOR_SUPPORT_KEY,\n\tSPACING_SUPPORT_KEY,\n];\n\nconst hasStyleSupport = ( blockType ) =>\n\tstyleSupportKeys.some( ( key ) => hasBlockSupport( blockType, key ) );\n\nconst VARIABLE_REFERENCE_PREFIX = 'var:';\nconst VARIABLE_PATH_SEPARATOR_TOKEN_ATTRIBUTE = '|';\nconst VARIABLE_PATH_SEPARATOR_TOKEN_STYLE = '--';\nfunction compileStyleValue( uncompiledValue ) {\n\tif ( startsWith( uncompiledValue, VARIABLE_REFERENCE_PREFIX ) ) {\n\t\tconst variable = uncompiledValue\n\t\t\t.slice( VARIABLE_REFERENCE_PREFIX.length )\n\t\t\t.split( VARIABLE_PATH_SEPARATOR_TOKEN_ATTRIBUTE )\n\t\t\t.join( VARIABLE_PATH_SEPARATOR_TOKEN_STYLE );\n\t\treturn `var(--wp--${ variable })`;\n\t}\n\treturn uncompiledValue;\n}\n\n/**\n * Returns the inline styles to add depending on the style object\n *\n * @param {Object} styles Styles configuration.\n *\n * @return {Object} Flattened CSS variables declaration.\n */\nexport function getInlineStyles( styles = {} ) {\n\tconst ignoredStyles = [ 'spacing.blockGap' ];\n\tconst output = {};\n\tObject.keys( STYLE_PROPERTY ).forEach( ( propKey ) => {\n\t\tconst path = STYLE_PROPERTY[ propKey ].value;\n\t\tconst subPaths = STYLE_PROPERTY[ propKey ].properties;\n\t\t// Ignore styles on elements because they are handled on the server.\n\t\tif ( has( styles, path ) && 'elements' !== first( path ) ) {\n\t\t\t// Checking if style value is a string allows for shorthand css\n\t\t\t// option and backwards compatibility for border radius support.\n\t\t\tconst styleValue = get( styles, path );\n\n\t\t\tif ( ! STYLE_PROPERTY[ propKey ].useEngine ) {\n\t\t\t\tif ( !! subPaths && ! isString( styleValue ) ) {\n\t\t\t\t\tObject.entries( subPaths ).forEach( ( entry ) => {\n\t\t\t\t\t\tconst [ name, subPath ] = entry;\n\t\t\t\t\t\tconst value = get( styleValue, [ subPath ] );\n\n\t\t\t\t\t\tif ( value ) {\n\t\t\t\t\t\t\toutput[ name ] = compileStyleValue( value );\n\t\t\t\t\t\t}\n\t\t\t\t\t} );\n\t\t\t\t} else if ( ! ignoredStyles.includes( path.join( '.' ) ) ) {\n\t\t\t\t\toutput[ propKey ] = compileStyleValue(\n\t\t\t\t\t\tget( styles, path )\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t} );\n\n\t// The goal is to move everything to server side generated engine styles\n\t// This is temporary as we absorb more and more styles into the engine.\n\tconst extraRules = getCSSRules( styles, { selector: 'self' } );\n\textraRules.forEach( ( rule ) => {\n\t\tif ( rule.selector !== 'self' ) {\n\t\t\tthrow \"This style can't be added as inline style\";\n\t\t}\n\t\toutput[ rule.key ] = rule.value;\n\t} );\n\n\treturn output;\n}\n\nfunction compileElementsStyles( selector, elements = {} ) {\n\treturn map( elements, ( styles, element ) => {\n\t\tconst elementStyles = getInlineStyles( styles );\n\t\tif ( ! isEmpty( elementStyles ) ) {\n\t\t\t// The .editor-styles-wrapper selector is required on elements styles. As it is\n\t\t\t// added to all other editor styles, not providing it causes reset and global\n\t\t\t// styles to override element styles because of higher specificity.\n\t\t\treturn [\n\t\t\t\t`.editor-styles-wrapper .${ selector } ${ ELEMENTS[ element ] }{`,\n\t\t\t\t...map(\n\t\t\t\t\telementStyles,\n\t\t\t\t\t( value, property ) =>\n\t\t\t\t\t\t`\\t${ kebabCase( property ) }: ${ value };`\n\t\t\t\t),\n\t\t\t\t'}',\n\t\t\t].join( '\\n' );\n\t\t}\n\t\treturn '';\n\t} ).join( '\\n' );\n}\n\n/**\n * Filters registered block settings, extending attributes to include `style` attribute.\n *\n * @param {Object} settings Original block settings.\n *\n * @return {Object} Filtered block settings.\n */\nfunction addAttribute( settings ) {\n\tif ( ! hasStyleSupport( settings ) ) {\n\t\treturn settings;\n\t}\n\n\t// Allow blocks to specify their own attribute definition with default 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\n/**\n * A dictionary of paths to flag skipping block support serialization as the key,\n * with values providing the style paths to be omitted from serialization.\n *\n * @constant\n * @type {Record<string, string[]>}\n */\nconst skipSerializationPathsEdit = {\n\t[ `${ BORDER_SUPPORT_KEY }.__experimentalSkipSerialization` ]: [ 'border' ],\n\t[ `${ COLOR_SUPPORT_KEY }.__experimentalSkipSerialization` ]: [\n\t\tCOLOR_SUPPORT_KEY,\n\t],\n\t[ `${ TYPOGRAPHY_SUPPORT_KEY }.__experimentalSkipSerialization` ]: [\n\t\tTYPOGRAPHY_SUPPORT_KEY,\n\t],\n\t[ `${ SPACING_SUPPORT_KEY }.__experimentalSkipSerialization` ]: [\n\t\t'spacing',\n\t],\n};\n\n/**\n * A dictionary of paths to flag skipping block support serialization as the key,\n * with values providing the style paths to be omitted from serialization.\n *\n * Extends the Edit skip paths to enable skipping additional paths in just\n * the Save component. This allows a block support to be serialized within the\n * editor, while using an alternate approach, such as server-side rendering, when\n * the support is saved.\n *\n * @constant\n * @type {Record<string, string[]>}\n */\nconst skipSerializationPathsSave = {\n\t...skipSerializationPathsEdit,\n\t[ `${ SPACING_SUPPORT_KEY }` ]: [ 'spacing.blockGap' ],\n};\n\n/**\n * A dictionary used to normalize feature names between support flags, style\n * object properties and __experimentSkipSerialization configuration arrays.\n *\n * This allows not having to provide a migration for a support flag and possible\n * backwards compatibility bridges, while still achieving consistency between\n * the support flag and the skip serialization array.\n *\n * @constant\n * @type {Record<string, string>}\n */\nconst renamedFeatures = { gradients: 'gradient' };\n\n/**\n * Override props assigned to save component to inject the CSS variables definition.\n *\n * @param {Object} props Additional props applied to save element.\n * @param {Object} blockType Block type.\n * @param {Object} attributes Block attributes.\n * @param {?Record<string, string[]>} skipPaths An object of keys and paths to skip serialization.\n *\n * @return {Object} Filtered props applied to save element.\n */\nexport function addSaveProps(\n\tprops,\n\tblockType,\n\tattributes,\n\tskipPaths = skipSerializationPathsSave\n) {\n\tif ( ! hasStyleSupport( blockType ) ) {\n\t\treturn props;\n\t}\n\n\tlet { style } = attributes;\n\n\tforEach( skipPaths, ( path, indicator ) => {\n\t\tconst skipSerialization = getBlockSupport( blockType, indicator );\n\n\t\tif ( skipSerialization === true ) {\n\t\t\tstyle = omit( style, path );\n\t\t}\n\n\t\tif ( Array.isArray( skipSerialization ) ) {\n\t\t\tskipSerialization.forEach( ( featureName ) => {\n\t\t\t\tconst feature = renamedFeatures[ featureName ] || featureName;\n\t\t\t\tstyle = omit( style, [ [ ...path, feature ] ] );\n\t\t\t} );\n\t\t}\n\t} );\n\n\tprops.style = {\n\t\t...getInlineStyles( style ),\n\t\t...props.style,\n\t};\n\n\treturn props;\n}\n\n/**\n * Filters registered block settings to extend the block edit wrapper\n * to apply the desired styles and classnames properly.\n *\n * @param {Object} settings Original block settings.\n *\n * @return {Object}.Filtered block settings.\n */\nexport function addEditProps( settings ) {\n\tif ( ! hasStyleSupport( settings ) ) {\n\t\treturn settings;\n\t}\n\n\tconst existingGetEditWrapperProps = settings.getEditWrapperProps;\n\tsettings.getEditWrapperProps = ( attributes ) => {\n\t\tlet props = {};\n\t\tif ( existingGetEditWrapperProps ) {\n\t\t\tprops = existingGetEditWrapperProps( attributes );\n\t\t}\n\n\t\treturn addSaveProps(\n\t\t\tprops,\n\t\t\tsettings,\n\t\t\tattributes,\n\t\t\tskipSerializationPathsEdit\n\t\t);\n\t};\n\n\treturn settings;\n}\n\n/**\n * Override the default edit UI to include new inspector controls for\n * all the custom styles configs.\n *\n * @param {Function} BlockEdit Original component.\n *\n * @return {Function} Wrapped component.\n */\nexport const withBlockControls = createHigherOrderComponent(\n\t( BlockEdit ) => ( props ) => {\n\t\tconst shouldDisplayControls = useDisplayBlockControls();\n\n\t\treturn (\n\t\t\t<>\n\t\t\t\t{ shouldDisplayControls && (\n\t\t\t\t\t<>\n\t\t\t\t\t\t<ColorEdit { ...props } />\n\t\t\t\t\t\t<TypographyPanel { ...props } />\n\t\t\t\t\t\t<BorderPanel { ...props } />\n\t\t\t\t\t\t<DimensionsPanel { ...props } />\n\t\t\t\t\t</>\n\t\t\t\t) }\n\t\t\t\t<BlockEdit { ...props } />\n\t\t\t</>\n\t\t);\n\t},\n\t'withToolbarControls'\n);\n\n/**\n * Override the default block element to include duotone styles.\n *\n * @param {Function} BlockListBlock Original component\n * @return {Function} Wrapped component\n */\nconst withElementsStyles = createHigherOrderComponent(\n\t( BlockListBlock ) => ( props ) => {\n\t\tconst blockElementsContainerIdentifier = `wp-elements-${ useInstanceId(\n\t\t\tBlockListBlock\n\t\t) }`;\n\n\t\tconst skipLinkColorSerialization = shouldSkipSerialization(\n\t\t\tprops.name,\n\t\t\tCOLOR_SUPPORT_KEY,\n\t\t\t'link'\n\t\t);\n\n\t\t// The Elements API only supports link colors for now,\n\t\t// hence the specific omission of `link` in the elements styles.\n\t\t// This might need to be refactored or removed if the Elements API\n\t\t// changes or `link` supports styles beyond `color`.\n\t\tconst elements = skipLinkColorSerialization\n\t\t\t? omit( props.attributes.style?.elements, [ 'link' ] )\n\t\t\t: props.attributes.style?.elements;\n\n\t\tconst styles = compileElementsStyles(\n\t\t\tblockElementsContainerIdentifier,\n\t\t\telements\n\t\t);\n\t\tconst element = useContext( BlockList.__unstableElementContext );\n\n\t\treturn (\n\t\t\t<>\n\t\t\t\t{ elements &&\n\t\t\t\t\telement &&\n\t\t\t\t\tcreatePortal(\n\t\t\t\t\t\t<style\n\t\t\t\t\t\t\tdangerouslySetInnerHTML={ {\n\t\t\t\t\t\t\t\t__html: styles,\n\t\t\t\t\t\t\t} }\n\t\t\t\t\t\t/>,\n\t\t\t\t\t\telement\n\t\t\t\t\t) }\n\n\t\t\t\t<BlockListBlock\n\t\t\t\t\t{ ...props }\n\t\t\t\t\tclassName={\n\t\t\t\t\t\telements\n\t\t\t\t\t\t\t? classnames(\n\t\t\t\t\t\t\t\t\tprops.className,\n\t\t\t\t\t\t\t\t\tblockElementsContainerIdentifier\n\t\t\t\t\t\t\t )\n\t\t\t\t\t\t\t: props.className\n\t\t\t\t\t}\n\t\t\t\t/>\n\t\t\t</>\n\t\t);\n\t}\n);\n\naddFilter(\n\t'blocks.registerBlockType',\n\t'core/style/addAttribute',\n\taddAttribute\n);\n\naddFilter(\n\t'blocks.getSaveContent.extraProps',\n\t'core/style/addSaveProps',\n\taddSaveProps\n);\n\naddFilter(\n\t'blocks.registerBlockType',\n\t'core/style/addEditProps',\n\taddEditProps\n);\n\naddFilter(\n\t'editor.BlockEdit',\n\t'core/style/with-block-controls',\n\twithBlockControls\n);\n\naddFilter(\n\t'editor.BlockListBlock',\n\t'core/editor/with-elements-styles',\n\twithElementsStyles\n);\n"]}
@@ -5,14 +5,21 @@ Object.defineProperty(exports, "__esModule", {
5
5
  });
6
6
  exports.cleanEmptyObject = void 0;
7
7
  exports.immutableSet = immutableSet;
8
+ exports.shouldSkipSerialization = shouldSkipSerialization;
8
9
  exports.transformStyles = transformStyles;
9
10
 
10
11
  var _lodash = require("lodash");
11
12
 
13
+ var _blocks = require("@wordpress/blocks");
14
+
12
15
  /**
13
16
  * External dependencies
14
17
  */
15
18
 
19
+ /**
20
+ * WordPress dependencies
21
+ */
22
+
16
23
  /**
17
24
  * Removed falsy values from nested object.
18
25
  *
@@ -82,4 +89,26 @@ function transformStyles(activeSupports, migrationPaths, result, source, index,
82
89
  });
83
90
  return returnBlock;
84
91
  }
92
+ /**
93
+ * Check whether serialization of specific block support feature or set should
94
+ * be skipped.
95
+ *
96
+ * @param {string|Object} blockType Block name or block type object.
97
+ * @param {string} featureSet Name of block support feature set.
98
+ * @param {string} feature Name of the individual feature to check.
99
+ *
100
+ * @return {boolean} Whether serialization should occur.
101
+ */
102
+
103
+
104
+ function shouldSkipSerialization(blockType, featureSet, feature) {
105
+ const support = (0, _blocks.getBlockSupport)(blockType, featureSet);
106
+ const skipSerialization = support === null || support === void 0 ? void 0 : support.__experimentalSkipSerialization;
107
+
108
+ if (Array.isArray(skipSerialization)) {
109
+ return skipSerialization.includes(feature);
110
+ }
111
+
112
+ return skipSerialization;
113
+ }
85
114
  //# sourceMappingURL=utils.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["@wordpress/block-editor/src/hooks/utils.js"],"names":["cleanEmptyObject","object","Array","isArray","cleanedNestedObjects","identity","undefined","immutableSet","path","value","clone","transformStyles","activeSupports","migrationPaths","result","source","index","results","isActive","length","innerBlocks","referenceBlockAttributes","attributes","returnBlock","support","forEach","styleValue"],"mappings":";;;;;;;;;AAGA;;AAHA;AACA;AACA;;AAcA;AACA;AACA;AACA;AACA;AACA;AACO,MAAMA,gBAAgB,GAAKC,MAAF,IAAc;AAC7C,MAAK,CAAE,sBAAUA,MAAV,CAAF,IAAwBC,KAAK,CAACC,OAAN,CAAeF,MAAf,CAA7B,EAAuD;AACtD,WAAOA,MAAP;AACA;;AACD,QAAMG,oBAAoB,GAAG,oBAC5B,uBAAWH,MAAX,EAAmBD,gBAAnB,CAD4B,EAE5BK,gBAF4B,CAA7B;AAIA,SAAO,qBAASD,oBAAT,IAAkCE,SAAlC,GAA8CF,oBAArD;AACA,CATM;;;;AAWA,SAASG,YAAT,CAAuBN,MAAvB,EAA+BO,IAA/B,EAAqCC,KAArC,EAA6C;AACnD,SAAO,qBAASR,MAAM,GAAG,mBAAOA,MAAP,CAAH,GAAqB,EAApC,EAAwCO,IAAxC,EAA8CC,KAA9C,EAAqDC,aA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;AACD,OAZD;AAaA;AACD,GAhBD;AAiBA,SAAOH,WAAP;AACA","sourcesContent":["/**\n * External dependencies\n */\nimport {\n\tpickBy,\n\tisEmpty,\n\tisObject,\n\tidentity,\n\tmapValues,\n\tforEach,\n\tget,\n\tsetWith,\n\tclone,\n\tevery,\n} from 'lodash';\n\n/**\n * Removed falsy values from nested object.\n *\n * @param {*} object\n * @return {*} Object cleaned from falsy values\n */\nexport const cleanEmptyObject = ( object ) => {\n\tif ( ! isObject( object ) || Array.isArray( object ) ) {\n\t\treturn object;\n\t}\n\tconst cleanedNestedObjects = pickBy(\n\t\tmapValues( object, cleanEmptyObject ),\n\t\tidentity\n\t);\n\treturn isEmpty( cleanedNestedObjects ) ? undefined : cleanedNestedObjects;\n};\n\nexport function immutableSet( object, path, value ) {\n\treturn setWith( object ? clone( object ) : {}, path, value, clone );\n}\n\nexport function transformStyles(\n\tactiveSupports,\n\tmigrationPaths,\n\tresult,\n\tsource,\n\tindex,\n\tresults\n) {\n\t// If there are no active supports return early.\n\tif ( every( activeSupports, ( isActive ) => ! isActive ) ) {\n\t\treturn result;\n\t}\n\t// If the condition verifies we are probably in the presence of a wrapping transform\n\t// e.g: nesting paragraphs in a group or columns and in that case the styles should not be transformed.\n\tif ( results.length === 1 && result.innerBlocks.length === source.length ) {\n\t\treturn result;\n\t}\n\t// For cases where we have a transform from one block to multiple blocks\n\t// or multiple blocks to one block we apply the styles of the first source block\n\t// to the result(s).\n\tlet referenceBlockAttributes = source[ 0 ]?.attributes;\n\t// If we are in presence of transform between more than one block in the source\n\t// that has more than one block in the result\n\t// we apply the styles on source N to the result N,\n\t// if source N does not exists we do nothing.\n\tif ( results.length > 1 && source.length > 1 ) {\n\t\tif ( source[ index ] ) {\n\t\t\treferenceBlockAttributes = source[ index ]?.attributes;\n\t\t} else {\n\t\t\treturn result;\n\t\t}\n\t}\n\tlet returnBlock = result;\n\tforEach( activeSupports, ( isActive, support ) => {\n\t\tif ( isActive ) {\n\t\t\tmigrationPaths[ support ].forEach( ( path ) => {\n\t\t\t\tconst styleValue = get( referenceBlockAttributes, path );\n\t\t\t\tif ( styleValue ) {\n\t\t\t\t\treturnBlock = {\n\t\t\t\t\t\t...returnBlock,\n\t\t\t\t\t\tattributes: immutableSet(\n\t\t\t\t\t\t\treturnBlock.attributes,\n\t\t\t\t\t\t\tpath,\n\t\t\t\t\t\t\tstyleValue\n\t\t\t\t\t\t),\n\t\t\t\t\t};\n\t\t\t\t}\n\t\t\t} );\n\t\t}\n\t} );\n\treturn returnBlock;\n}\n"]}
1
+ {"version":3,"sources":["@wordpress/block-editor/src/hooks/utils.js"],"names":["cleanEmptyObject","object","Array","isArray","cleanedNestedObjects","identity","undefined","immutableSet","path","value","clone","transformStyles","activeSupports","migrationPaths","result","source","index","results","isActive","length","innerBlocks","referenceBlockAttributes","attributes","returnBlock","support","forEach","styleValue","shouldSkipSerialization","blockType","featureSet","feature","skipSerialization","__experimentalSkipSerialization","includes"],"mappings":";;;;;;;;;;AAGA;;AAgBA;;AAnBA;AACA;AACA;;AAcA;AACA;AACA;;AAGA;AACA;AACA;AACA;AACA;AACA;AACO,MAAMA,gBAAgB,GAAKC,MAAF,IAAc;AAC7C,MAAK,CAAE,sBAAUA,MAAV,CAAF,IAAwBC,KAAK,CAACC,OAAN,CAAeF,MAAf,CAA7B,EAAuD;AACtD,WAAOA,MAAP;AACA;;AACD,QAAMG,oBAAoB,GAAG,oBAC5B,uBAAWH,MAAX,EAAmBD,gBAAnB,CAD4B,EAE5BK,gBAF4B,CAA7B;AAIA,SAAO,qBAASD,oBAAT,IAAkCE,SAAlC,GAA8CF,oBAArD;AACA,CATM;;;;AAWA,SAASG,YAAT,CAAuBN,MAAvB,EAA+BO,IAA/B,EAAqCC,KAArC,EAA6C;AACnD,SAAO,qBAASR,MAAM,GAAG,mBAAOA,MAAP,CAAH,GAAqB,EAApC,EAAwCO,IAAxC,EAA8CC,KAA9C,EAAqDC,aAArD,CAAP;AACA;;AAEM,SAASC,eAAT,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BA,SAAOH,WAAP;AACA;AAED;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;AACO,SAASI,uBAAT,CAAkCC,SAAlC,EAA6CC,UAA7C,EAAyDC,OAAzD,EAAmE;AACzE,QAAMN,OAAO,GAAG,6BAAiBI,SAAjB,EAA4BC,UAA5B,CAAhB;AACA,QAAME,iBAAiB,GAAGP,OAAH,aAAGA,OAAH,uBAAGA,OAAO,CAAEQ,+BAAnC;;AAEA,MAAK9B,KAAK,CAACC,OAAN,CAAe4B,iBAAf,CAAL,EAA0C;AACzC,WAAOA,iBAAiB,CAACE,QAAlB,CAA4BH,OAA5B,CAAP;AACA;;AAED,SAAOC,iBAAP;AACA","sourcesContent":["/**\n * External dependencies\n */\nimport {\n\tpickBy,\n\tisEmpty,\n\tisObject,\n\tidentity,\n\tmapValues,\n\tforEach,\n\tget,\n\tsetWith,\n\tclone,\n\tevery,\n} from 'lodash';\n\n/**\n * WordPress dependencies\n */\nimport { getBlockSupport } from '@wordpress/blocks';\n\n/**\n * Removed falsy values from nested object.\n *\n * @param {*} object\n * @return {*} Object cleaned from falsy values\n */\nexport const cleanEmptyObject = ( object ) => {\n\tif ( ! isObject( object ) || Array.isArray( object ) ) {\n\t\treturn object;\n\t}\n\tconst cleanedNestedObjects = pickBy(\n\t\tmapValues( object, cleanEmptyObject ),\n\t\tidentity\n\t);\n\treturn isEmpty( cleanedNestedObjects ) ? undefined : cleanedNestedObjects;\n};\n\nexport function immutableSet( object, path, value ) {\n\treturn setWith( object ? clone( object ) : {}, path, value, clone );\n}\n\nexport function transformStyles(\n\tactiveSupports,\n\tmigrationPaths,\n\tresult,\n\tsource,\n\tindex,\n\tresults\n) {\n\t// If there are no active supports return early.\n\tif ( every( activeSupports, ( isActive ) => ! isActive ) ) {\n\t\treturn result;\n\t}\n\t// If the condition verifies we are probably in the presence of a wrapping transform\n\t// e.g: nesting paragraphs in a group or columns and in that case the styles should not be transformed.\n\tif ( results.length === 1 && result.innerBlocks.length === source.length ) {\n\t\treturn result;\n\t}\n\t// For cases where we have a transform from one block to multiple blocks\n\t// or multiple blocks to one block we apply the styles of the first source block\n\t// to the result(s).\n\tlet referenceBlockAttributes = source[ 0 ]?.attributes;\n\t// If we are in presence of transform between more than one block in the source\n\t// that has more than one block in the result\n\t// we apply the styles on source N to the result N,\n\t// if source N does not exists we do nothing.\n\tif ( results.length > 1 && source.length > 1 ) {\n\t\tif ( source[ index ] ) {\n\t\t\treferenceBlockAttributes = source[ index ]?.attributes;\n\t\t} else {\n\t\t\treturn result;\n\t\t}\n\t}\n\tlet returnBlock = result;\n\tforEach( activeSupports, ( isActive, support ) => {\n\t\tif ( isActive ) {\n\t\t\tmigrationPaths[ support ].forEach( ( path ) => {\n\t\t\t\tconst styleValue = get( referenceBlockAttributes, path );\n\t\t\t\tif ( styleValue ) {\n\t\t\t\t\treturnBlock = {\n\t\t\t\t\t\t...returnBlock,\n\t\t\t\t\t\tattributes: immutableSet(\n\t\t\t\t\t\t\treturnBlock.attributes,\n\t\t\t\t\t\t\tpath,\n\t\t\t\t\t\t\tstyleValue\n\t\t\t\t\t\t),\n\t\t\t\t\t};\n\t\t\t\t}\n\t\t\t} );\n\t\t}\n\t} );\n\treturn returnBlock;\n}\n\n/**\n * Check whether serialization of specific block support feature or set should\n * be skipped.\n *\n * @param {string|Object} blockType Block name or block type object.\n * @param {string} featureSet Name of block support feature set.\n * @param {string} feature Name of the individual feature to check.\n *\n * @return {boolean} Whether serialization should occur.\n */\nexport function shouldSkipSerialization( blockType, featureSet, feature ) {\n\tconst support = getBlockSupport( blockType, featureSet );\n\tconst skipSerialization = support?.__experimentalSkipSerialization;\n\n\tif ( Array.isArray( skipSerialization ) ) {\n\t\treturn skipSerialization.includes( feature );\n\t}\n\n\treturn skipSerialization;\n}\n"]}
@@ -23,6 +23,8 @@ var _useSetting = _interopRequireDefault(require("../components/use-setting"));
23
23
 
24
24
  var _components2 = require("../components");
25
25
 
26
+ var _utils2 = require("../hooks/utils");
27
+
26
28
  /**
27
29
  * WordPress dependencies
28
30
  */
@@ -43,6 +45,11 @@ const alignItemsMap = {
43
45
  right: 'flex-end',
44
46
  center: 'center'
45
47
  };
48
+ const verticalAlignmentMap = {
49
+ top: 'flex-start',
50
+ center: 'center',
51
+ bottom: 'flex-end'
52
+ };
46
53
  const flexWrapOptions = ['wrap', 'nowrap'];
47
54
  var _default = {
48
55
  name: 'flex',
@@ -78,6 +85,9 @@ var _default = {
78
85
  return null;
79
86
  }
80
87
 
88
+ const {
89
+ allowVerticalAlignment = true
90
+ } = layoutBlockSupport;
81
91
  return (0, _element.createElement)(_components2.BlockControls, {
82
92
  group: "block",
83
93
  __experimentalShareWithChildBlocks: true
@@ -85,27 +95,35 @@ var _default = {
85
95
  layout: layout,
86
96
  onChange: onChange,
87
97
  isToolbar: true
98
+ }), allowVerticalAlignment && (layout === null || layout === void 0 ? void 0 : layout.orientation) !== 'vertical' && (0, _element.createElement)(FlexLayoutVerticalAlignmentControl, {
99
+ layout: layout,
100
+ onChange: onChange,
101
+ isToolbar: true
88
102
  }));
89
103
  },
90
104
  save: function FlexLayoutStyle(_ref3) {
91
- var _getGapCSSValue, _style$spacing;
105
+ var _style$spacing, _style$spacing2;
92
106
 
93
107
  let {
94
108
  selector,
95
109
  layout,
96
- style
110
+ style,
111
+ blockName
97
112
  } = _ref3;
98
113
  const {
99
114
  orientation = 'horizontal'
100
115
  } = layout;
101
116
  const blockGapSupport = (0, _useSetting.default)('spacing.blockGap');
102
- const hasBlockGapStylesSupport = blockGapSupport !== null;
103
- const blockGapValue = (_getGapCSSValue = (0, _gap.getGapCSSValue)(style === null || style === void 0 ? void 0 : (_style$spacing = style.spacing) === null || _style$spacing === void 0 ? void 0 : _style$spacing.blockGap, '0.5em')) !== null && _getGapCSSValue !== void 0 ? _getGapCSSValue : 'var( --wp--style--block-gap, 0.5em )';
117
+ const hasBlockGapStylesSupport = blockGapSupport !== null; // If a block's block.json skips serialization for spacing or spacing.blockGap,
118
+ // don't apply the user-defined value to the styles.
119
+
120
+ const blockGapValue = style !== null && style !== void 0 && (_style$spacing = style.spacing) !== null && _style$spacing !== void 0 && _style$spacing.blockGap && !(0, _utils2.shouldSkipSerialization)(blockName, 'spacing', 'blockGap') ? (0, _gap.getGapCSSValue)(style === null || style === void 0 ? void 0 : (_style$spacing2 = style.spacing) === null || _style$spacing2 === void 0 ? void 0 : _style$spacing2.blockGap, '0.5em') : 'var( --wp--style--block-gap, 0.5em )';
104
121
  const justifyContent = justifyContentMap[layout.justifyContent] || justifyContentMap.left;
105
122
  const flexWrap = flexWrapOptions.includes(layout.flexWrap) ? layout.flexWrap : 'wrap';
123
+ const verticalAlignment = verticalAlignmentMap[layout.verticalAlignment] || verticalAlignmentMap.center;
106
124
  const rowOrientation = `
107
125
  flex-direction: row;
108
- align-items: center;
126
+ align-items: ${verticalAlignment};
109
127
  justify-content: ${justifyContent};
110
128
  `;
111
129
  const alignItems = alignItemsMap[layout.justifyContent] || alignItemsMap.left;
@@ -141,12 +159,58 @@ var _default = {
141
159
  };
142
160
  exports.default = _default;
143
161
 
144
- function FlexLayoutJustifyContentControl(_ref4) {
162
+ function FlexLayoutVerticalAlignmentControl(_ref4) {
145
163
  let {
146
164
  layout,
147
165
  onChange,
148
166
  isToolbar = false
149
167
  } = _ref4;
168
+ const {
169
+ verticalAlignment = verticalAlignmentMap.center
170
+ } = layout;
171
+
172
+ const onVerticalAlignmentChange = value => {
173
+ onChange({ ...layout,
174
+ verticalAlignment: value
175
+ });
176
+ };
177
+
178
+ if (isToolbar) {
179
+ return (0, _element.createElement)(_components2.BlockVerticalAlignmentControl, {
180
+ onChange: onVerticalAlignmentChange,
181
+ value: verticalAlignment
182
+ });
183
+ }
184
+
185
+ const verticalAlignmentOptions = [{
186
+ value: 'flex-start',
187
+ label: (0, _i18n.__)('Align items top')
188
+ }, {
189
+ value: 'center',
190
+ label: (0, _i18n.__)('Align items center')
191
+ }, {
192
+ value: 'flex-end',
193
+ label: (0, _i18n.__)('Align items bottom')
194
+ }];
195
+ return (0, _element.createElement)("fieldset", {
196
+ className: "block-editor-hooks__flex-layout-vertical-alignment-control"
197
+ }, (0, _element.createElement)("legend", null, (0, _i18n.__)('Vertical alignment')), (0, _element.createElement)("div", null, verticalAlignmentOptions.map((value, icon, label) => {
198
+ return (0, _element.createElement)(_components.Button, {
199
+ key: value,
200
+ label: label,
201
+ icon: icon,
202
+ isPressed: verticalAlignment === value,
203
+ onClick: () => onVerticalAlignmentChange(value)
204
+ });
205
+ })));
206
+ }
207
+
208
+ function FlexLayoutJustifyContentControl(_ref5) {
209
+ let {
210
+ layout,
211
+ onChange,
212
+ isToolbar = false
213
+ } = _ref5;
150
214
  const {
151
215
  justifyContent = 'left',
152
216
  orientation = 'horizontal'
@@ -200,12 +264,12 @@ function FlexLayoutJustifyContentControl(_ref4) {
200
264
 
201
265
  return (0, _element.createElement)("fieldset", {
202
266
  className: "block-editor-hooks__flex-layout-justification-controls"
203
- }, (0, _element.createElement)("legend", null, (0, _i18n.__)('Justification')), (0, _element.createElement)("div", null, justificationOptions.map(_ref5 => {
267
+ }, (0, _element.createElement)("legend", null, (0, _i18n.__)('Justification')), (0, _element.createElement)("div", null, justificationOptions.map(_ref6 => {
204
268
  let {
205
269
  value,
206
270
  icon,
207
271
  label
208
- } = _ref5;
272
+ } = _ref6;
209
273
  return (0, _element.createElement)(_components.Button, {
210
274
  key: value,
211
275
  label: label,
@@ -216,11 +280,11 @@ function FlexLayoutJustifyContentControl(_ref4) {
216
280
  })));
217
281
  }
218
282
 
219
- function FlexWrapControl(_ref6) {
283
+ function FlexWrapControl(_ref7) {
220
284
  let {
221
285
  layout,
222
286
  onChange
223
- } = _ref6;
287
+ } = _ref7;
224
288
  const {
225
289
  flexWrap = 'wrap'
226
290
  } = layout;
@@ -235,11 +299,11 @@ function FlexWrapControl(_ref6) {
235
299
  });
236
300
  }
237
301
 
238
- function OrientationControl(_ref7) {
302
+ function OrientationControl(_ref8) {
239
303
  let {
240
304
  layout,
241
305
  onChange
242
- } = _ref7;
306
+ } = _ref8;
243
307
  const {
244
308
  orientation = 'horizontal'
245
309
  } = layout;
@@ -1 +1 @@
1
- {"version":3,"sources":["@wordpress/block-editor/src/layouts/flex.js"],"names":["justifyContentMap","left","right","center","alignItemsMap","flexWrapOptions","name","label","inspectorControls","FlexLayoutInspectorControls","layout","onChange","layoutBlockSupport","allowOrientation","toolBarControls","FlexLayoutToolbarControls","allowSwitching","save","FlexLayoutStyle","selector","style","orientation","blockGapSupport","hasBlockGapStylesSupport","blockGapValue","spacing","blockGap","justifyContent","flexWrap","includes","rowOrientation","alignItems","columnOrientation","getOrientation","getAlignments","FlexLayoutJustifyContentControl","isToolbar","onJustificationChange","value","allowedControls","push","position","isAlternate","justificationOptions","icon","justifyLeft","justifyCenter","justifyRight","justifySpaceBetween","map","FlexWrapControl","OrientationControl","arrowRight","arrowDown"],"mappings":";;;;;;;;;;;AAGA;;AACA;;AAQA;;AAKA;;AACA;;AACA;;AACA;;AApBA;AACA;AACA;;AAYA;AACA;AACA;AAMA;AACA,MAAMA,iBAAiB,GAAG;AACzBC,EAAAA,IAAI,EAAE,YADmB;AAEzBC,EAAAA,KAAK,EAAE,UAFkB;AAGzBC,EAAAA,MAAM,EAAE,QAHiB;AAIzB,mBAAiB;AAJQ,CAA1B,C,CAOA;;AACA,MAAMC,aAAa,GAAG;AACrBH,EAAAA,IAAI,EAAE,YADe;AAErBC,EAAAA,KAAK,EAAE,UAFc;AAGrBC,EAAAA,MAAM,EAAE;AAHa,CAAtB;AAMA,MAAME,eAAe,GAAG,CAAE,MAAF,EAAU,QAAV,CAAxB;eAEe;AACdC,EAAAA,IAAI,EAAE,MADQ;AAEdC,EAAAA,KAAK,EAAE,cAAI,MAAJ,CAFO;AAGdC,EAAAA,iBAAiB,EAAE,SAASC,2BAAT,OAIf;AAAA,QAJqD;AACxDC,MAAAA,MAAM,GAAG,EAD+C;AAExDC,MAAAA,QAFwD;AAGxDC,MAAAA,kBAAkB,GAAG;AA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IAAI,EAAG0C,iBAFR;AAGC,IAAA,SAAS,EAAG/B,WAAW,KAAK,YAH7B;AAIC,IAAA,OAAO,EAAG,MACTV,QAAQ,CAAE,EACT,GAAGD,MADM;AAETW,MAAAA,WAAW,EAAE;AAFJ,KAAF;AALV,IAFD,EAaC,4BAAC,kBAAD;AACC,IAAA,KAAK,EAAG,UADT;AAEC,IAAA,IAAI,EAAGgC,gBAFR;AAGC,IAAA,SAAS,EAAGhC,WAAW,KAAK,UAH7B;AAIC,IAAA,OAAO,EAAG,MACTV,QAAQ,CAAE,EACT,GAAGD,MADM;AAETW,MAAAA,WAAW,EAAE;AAFJ,KAAF;AALV,IAbD,CADD;AA2BA","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { __ } from '@wordpress/i18n';\nimport {\n\tjustifyLeft,\n\tjustifyCenter,\n\tjustifyRight,\n\tjustifySpaceBetween,\n\tarrowRight,\n\tarrowDown,\n} from '@wordpress/icons';\nimport { Button, ToggleControl, Flex, FlexItem } from '@wordpress/components';\n\n/**\n * Internal dependencies\n */\nimport { appendSelectors } from './utils';\nimport { getGapCSSValue } from '../hooks/gap';\nimport useSetting from '../components/use-setting';\nimport { BlockControls, JustifyContentControl } from '../components';\n\n// Used with the default, horizontal flex orientation.\nconst justifyContentMap = {\n\tleft: 'flex-start',\n\tright: 'flex-end',\n\tcenter: 'center',\n\t'space-between': 'space-between',\n};\n\n// Used with the vertical (column) flex orientation.\nconst alignItemsMap = {\n\tleft: 'flex-start',\n\tright: 'flex-end',\n\tcenter: 'center',\n};\n\nconst flexWrapOptions = [ 'wrap', 'nowrap' ];\n\nexport default {\n\tname: 'flex',\n\tlabel: __( 'Flex' ),\n\tinspectorControls: function FlexLayoutInspectorControls( {\n\t\tlayout = {},\n\t\tonChange,\n\t\tlayoutBlockSupport = {},\n\t} ) {\n\t\tconst { allowOrientation = true } = layoutBlockSupport;\n\t\treturn (\n\t\t\t<>\n\t\t\t\t<Flex>\n\t\t\t\t\t<FlexItem>\n\t\t\t\t\t\t<FlexLayoutJustifyContentControl\n\t\t\t\t\t\t\tlayout={ layout }\n\t\t\t\t\t\t\tonChange={ onChange }\n\t\t\t\t\t\t/>\n\t\t\t\t\t</FlexItem>\n\t\t\t\t\t<FlexItem>\n\t\t\t\t\t\t{ allowOrientation && (\n\t\t\t\t\t\t\t<OrientationControl\n\t\t\t\t\t\t\t\tlayout={ layout }\n\t\t\t\t\t\t\t\tonChange={ onChange }\n\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t) }\n\t\t\t\t\t</FlexItem>\n\t\t\t\t</Flex>\n\t\t\t\t<FlexWrapControl layout={ layout } onChange={ onChange } />\n\t\t\t</>\n\t\t);\n\t},\n\ttoolBarControls: function FlexLayoutToolbarControls( {\n\t\tlayout = {},\n\t\tonChange,\n\t\tlayoutBlockSupport,\n\t} ) {\n\t\tif ( layoutBlockSupport?.allowSwitching ) {\n\t\t\treturn null;\n\t\t}\n\t\treturn (\n\t\t\t<BlockControls group=\"block\" __experimentalShareWithChildBlocks>\n\t\t\t\t<FlexLayoutJustifyContentControl\n\t\t\t\t\tlayout={ layout }\n\t\t\t\t\tonChange={ onChange }\n\t\t\t\t\tisToolbar\n\t\t\t\t/>\n\t\t\t</BlockControls>\n\t\t);\n\t},\n\tsave: function FlexLayoutStyle( { selector, layout, style } ) {\n\t\tconst { orientation = 'horizontal' } = layout;\n\t\tconst blockGapSupport = useSetting( 'spacing.blockGap' );\n\t\tconst hasBlockGapStylesSupport = blockGapSupport !== null;\n\t\tconst blockGapValue =\n\t\t\tgetGapCSSValue( style?.spacing?.blockGap, '0.5em' ) ??\n\t\t\t'var( --wp--style--block-gap, 0.5em )';\n\t\tconst justifyContent =\n\t\t\tjustifyContentMap[ layout.justifyContent ] ||\n\t\t\tjustifyContentMap.left;\n\t\tconst flexWrap = flexWrapOptions.includes( layout.flexWrap )\n\t\t\t? layout.flexWrap\n\t\t\t: 'wrap';\n\t\tconst rowOrientation = `\n\t\tflex-direction: row;\n\t\talign-items: center;\n\t\tjustify-content: ${ justifyContent };\n\t\t`;\n\t\tconst alignItems =\n\t\t\talignItemsMap[ layout.justifyContent ] || alignItemsMap.left;\n\t\tconst columnOrientation = `\n\t\tflex-direction: column;\n\t\talign-items: ${ alignItems };\n\t\t`;\n\n\t\treturn (\n\t\t\t<style>{ `\n\t\t\t\t${ appendSelectors( selector ) } {\n\t\t\t\t\tdisplay: flex;\n\t\t\t\t\tflex-wrap: ${ flexWrap };\n\t\t\t\t\tgap: ${ hasBlockGapStylesSupport ? blockGapValue : '0.5em' };\n\t\t\t\t\t${ orientation === 'horizontal' ? rowOrientation : columnOrientation }\n\t\t\t\t}\n\n\t\t\t\t${ appendSelectors( selector, '> *' ) } {\n\t\t\t\t\tmargin: 0;\n\t\t\t\t}\n\t\t\t` }</style>\n\t\t);\n\t},\n\tgetOrientation( layout ) {\n\t\tconst { orientation = 'horizontal' } = layout;\n\t\treturn orientation;\n\t},\n\tgetAlignments() {\n\t\treturn [];\n\t},\n};\n\nfunction FlexLayoutJustifyContentControl( {\n\tlayout,\n\tonChange,\n\tisToolbar = false,\n} ) {\n\tconst { justifyContent = 'left', orientation = 'horizontal' } = layout;\n\tconst onJustificationChange = ( value ) => {\n\t\tonChange( {\n\t\t\t...layout,\n\t\t\tjustifyContent: value,\n\t\t} );\n\t};\n\tconst allowedControls = [ 'left', 'center', 'right' ];\n\tif ( orientation === 'horizontal' ) {\n\t\tallowedControls.push( 'space-between' );\n\t}\n\tif ( isToolbar ) {\n\t\treturn (\n\t\t\t<JustifyContentControl\n\t\t\t\tallowedControls={ allowedControls }\n\t\t\t\tvalue={ justifyContent }\n\t\t\t\tonChange={ onJustificationChange }\n\t\t\t\tpopoverProps={ {\n\t\t\t\t\tposition: 'bottom right',\n\t\t\t\t\tisAlternate: true,\n\t\t\t\t} }\n\t\t\t/>\n\t\t);\n\t}\n\n\tconst justificationOptions = [\n\t\t{\n\t\t\tvalue: 'left',\n\t\t\ticon: justifyLeft,\n\t\t\tlabel: __( 'Justify items left' ),\n\t\t},\n\t\t{\n\t\t\tvalue: 'center',\n\t\t\ticon: justifyCenter,\n\t\t\tlabel: __( 'Justify items center' ),\n\t\t},\n\t\t{\n\t\t\tvalue: 'right',\n\t\t\ticon: justifyRight,\n\t\t\tlabel: __( 'Justify items right' ),\n\t\t},\n\t];\n\tif ( orientation === 'horizontal' ) {\n\t\tjustificationOptions.push( {\n\t\t\tvalue: 'space-between',\n\t\t\ticon: justifySpaceBetween,\n\t\t\tlabel: __( 'Space between items' ),\n\t\t} );\n\t}\n\n\treturn (\n\t\t<fieldset className=\"block-editor-hooks__flex-layout-justification-controls\">\n\t\t\t<legend>{ __( 'Justification' ) }</legend>\n\t\t\t<div>\n\t\t\t\t{ justificationOptions.map( ( { value, icon, label } ) => {\n\t\t\t\t\treturn (\n\t\t\t\t\t\t<Button\n\t\t\t\t\t\t\tkey={ value }\n\t\t\t\t\t\t\tlabel={ label }\n\t\t\t\t\t\t\ticon={ icon }\n\t\t\t\t\t\t\tisPressed={ justifyContent === value }\n\t\t\t\t\t\t\tonClick={ () => onJustificationChange( value ) }\n\t\t\t\t\t\t/>\n\t\t\t\t\t);\n\t\t\t\t} ) }\n\t\t\t</div>\n\t\t</fieldset>\n\t);\n}\n\nfunction FlexWrapControl( { layout, onChange } ) {\n\tconst { flexWrap = 'wrap' } = layout;\n\treturn (\n\t\t<ToggleControl\n\t\t\tlabel={ __( 'Allow to wrap to multiple lines' ) }\n\t\t\tonChange={ ( value ) => {\n\t\t\t\tonChange( {\n\t\t\t\t\t...layout,\n\t\t\t\t\tflexWrap: value ? 'wrap' : 'nowrap',\n\t\t\t\t} );\n\t\t\t} }\n\t\t\tchecked={ flexWrap === 'wrap' }\n\t\t/>\n\t);\n}\n\nfunction OrientationControl( { layout, onChange } ) {\n\tconst { orientation = 'horizontal' } = layout;\n\treturn (\n\t\t<fieldset className=\"block-editor-hooks__flex-layout-orientation-controls\">\n\t\t\t<legend>{ __( 'Orientation' ) }</legend>\n\t\t\t<Button\n\t\t\t\tlabel={ 'horizontal' }\n\t\t\t\ticon={ arrowRight }\n\t\t\t\tisPressed={ orientation === 'horizontal' }\n\t\t\t\tonClick={ () =>\n\t\t\t\t\tonChange( {\n\t\t\t\t\t\t...layout,\n\t\t\t\t\t\torientation: 'horizontal',\n\t\t\t\t\t} )\n\t\t\t\t}\n\t\t\t/>\n\t\t\t<Button\n\t\t\t\tlabel={ 'vertical' }\n\t\t\t\ticon={ arrowDown }\n\t\t\t\tisPressed={ orientation === 'vertical' }\n\t\t\t\tonClick={ () =>\n\t\t\t\t\tonChange( {\n\t\t\t\t\t\t...layout,\n\t\t\t\t\t\torientation: 'vertical',\n\t\t\t\t\t} )\n\t\t\t\t}\n\t\t\t/>\n\t\t</fieldset>\n\t);\n}\n"]}
1
+ {"version":3,"sources":["@wordpress/block-editor/src/layouts/flex.js"],"names":["justifyContentMap","left","right","center","alignItemsMap","verticalAlignmentMap","top","bottom","flexWrapOptions","name","label","inspectorControls","FlexLayoutInspectorControls","layout","onChange","layoutBlockSupport","allowOrientation","toolBarControls","FlexLayoutToolbarControls","allowSwitching","allowVerticalAlignment","orientation","save","FlexLayoutStyle","selector","style","blockName","blockGapSupport","hasBlockGapStylesSupport","blockGapValue","spacing","blockGap","justifyContent","flexWrap","includes","verticalAlignment","rowOrientation","alignItems","columnOrientation","getOrientation","getAlignments","FlexLayoutVerticalAlignmentControl","isToolbar","onVerticalAlignmentChange","value","verticalAlignmentOptions","map","icon","FlexLayoutJustifyContentControl","onJustificationChange","allowedControls","push","position","isAlternate","justificationOptions","justifyLeft","justifyCenter","justifyRight","justifySpaceBetween","FlexWrapControl","OrientationControl","arrowRight","arrowDown"],"mappings":";;;;;;;;;;;AAGA;;AACA;;AAQA;;AAKA;;AACA;;AACA;;AACA;;AAKA;;AAzBA;AACA;AACA;;AAYA;AACA;AACA;AAWA;AACA,MAAMA,iBAAiB,GAAG;AACzBC,EAAAA,IAAI,EAAE,YADmB;AAEzBC,EAAAA,KAAK,EAAE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GgD,iBAFR;AAGC,IAAA,SAAS,EAAGxC,WAAW,KAAK,YAH7B;AAIC,IAAA,OAAO,EAAG,MACTP,QAAQ,CAAE,EACT,GAAGD,MADM;AAETQ,MAAAA,WAAW,EAAE;AAFJ,KAAF;AALV,IAFD,EAaC,4BAAC,kBAAD;AACC,IAAA,KAAK,EAAG,UADT;AAEC,IAAA,IAAI,EAAGyC,gBAFR;AAGC,IAAA,SAAS,EAAGzC,WAAW,KAAK,UAH7B;AAIC,IAAA,OAAO,EAAG,MACTP,QAAQ,CAAE,EACT,GAAGD,MADM;AAETQ,MAAAA,WAAW,EAAE;AAFJ,KAAF;AALV,IAbD,CADD;AA2BA","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { __ } from '@wordpress/i18n';\nimport {\n\tjustifyLeft,\n\tjustifyCenter,\n\tjustifyRight,\n\tjustifySpaceBetween,\n\tarrowRight,\n\tarrowDown,\n} from '@wordpress/icons';\nimport { Button, ToggleControl, Flex, FlexItem } from '@wordpress/components';\n\n/**\n * Internal dependencies\n */\nimport { appendSelectors } from './utils';\nimport { getGapCSSValue } from '../hooks/gap';\nimport useSetting from '../components/use-setting';\nimport {\n\tBlockControls,\n\tJustifyContentControl,\n\tBlockVerticalAlignmentControl,\n} from '../components';\nimport { shouldSkipSerialization } from '../hooks/utils';\n\n// Used with the default, horizontal flex orientation.\nconst justifyContentMap = {\n\tleft: 'flex-start',\n\tright: 'flex-end',\n\tcenter: 'center',\n\t'space-between': 'space-between',\n};\n\n// Used with the vertical (column) flex orientation.\nconst alignItemsMap = {\n\tleft: 'flex-start',\n\tright: 'flex-end',\n\tcenter: 'center',\n};\n\nconst verticalAlignmentMap = {\n\ttop: 'flex-start',\n\tcenter: 'center',\n\tbottom: 'flex-end',\n};\n\nconst flexWrapOptions = [ 'wrap', 'nowrap' ];\n\nexport default {\n\tname: 'flex',\n\tlabel: __( 'Flex' ),\n\tinspectorControls: function FlexLayoutInspectorControls( {\n\t\tlayout = {},\n\t\tonChange,\n\t\tlayoutBlockSupport = {},\n\t} ) {\n\t\tconst { allowOrientation = true } = layoutBlockSupport;\n\t\treturn (\n\t\t\t<>\n\t\t\t\t<Flex>\n\t\t\t\t\t<FlexItem>\n\t\t\t\t\t\t<FlexLayoutJustifyContentControl\n\t\t\t\t\t\t\tlayout={ layout }\n\t\t\t\t\t\t\tonChange={ onChange }\n\t\t\t\t\t\t/>\n\t\t\t\t\t</FlexItem>\n\t\t\t\t\t<FlexItem>\n\t\t\t\t\t\t{ allowOrientation && (\n\t\t\t\t\t\t\t<OrientationControl\n\t\t\t\t\t\t\t\tlayout={ layout }\n\t\t\t\t\t\t\t\tonChange={ onChange }\n\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t) }\n\t\t\t\t\t</FlexItem>\n\t\t\t\t</Flex>\n\t\t\t\t<FlexWrapControl layout={ layout } onChange={ onChange } />\n\t\t\t</>\n\t\t);\n\t},\n\ttoolBarControls: function FlexLayoutToolbarControls( {\n\t\tlayout = {},\n\t\tonChange,\n\t\tlayoutBlockSupport,\n\t} ) {\n\t\tif ( layoutBlockSupport?.allowSwitching ) {\n\t\t\treturn null;\n\t\t}\n\t\tconst { allowVerticalAlignment = true } = layoutBlockSupport;\n\t\treturn (\n\t\t\t<BlockControls group=\"block\" __experimentalShareWithChildBlocks>\n\t\t\t\t<FlexLayoutJustifyContentControl\n\t\t\t\t\tlayout={ layout }\n\t\t\t\t\tonChange={ onChange }\n\t\t\t\t\tisToolbar\n\t\t\t\t/>\n\t\t\t\t{ allowVerticalAlignment &&\n\t\t\t\t\tlayout?.orientation !== 'vertical' && (\n\t\t\t\t\t\t<FlexLayoutVerticalAlignmentControl\n\t\t\t\t\t\t\tlayout={ layout }\n\t\t\t\t\t\t\tonChange={ onChange }\n\t\t\t\t\t\t\tisToolbar\n\t\t\t\t\t\t/>\n\t\t\t\t\t) }\n\t\t\t</BlockControls>\n\t\t);\n\t},\n\tsave: function FlexLayoutStyle( { selector, layout, style, blockName } ) {\n\t\tconst { orientation = 'horizontal' } = layout;\n\t\tconst blockGapSupport = useSetting( 'spacing.blockGap' );\n\t\tconst hasBlockGapStylesSupport = blockGapSupport !== null;\n\t\t// If a block's block.json skips serialization for spacing or spacing.blockGap,\n\t\t// don't apply the user-defined value to the styles.\n\t\tconst blockGapValue =\n\t\t\tstyle?.spacing?.blockGap &&\n\t\t\t! shouldSkipSerialization( blockName, 'spacing', 'blockGap' )\n\t\t\t\t? getGapCSSValue( style?.spacing?.blockGap, '0.5em' )\n\t\t\t\t: 'var( --wp--style--block-gap, 0.5em )';\n\t\tconst justifyContent =\n\t\t\tjustifyContentMap[ layout.justifyContent ] ||\n\t\t\tjustifyContentMap.left;\n\t\tconst flexWrap = flexWrapOptions.includes( layout.flexWrap )\n\t\t\t? layout.flexWrap\n\t\t\t: 'wrap';\n\t\tconst verticalAlignment =\n\t\t\tverticalAlignmentMap[ layout.verticalAlignment ] ||\n\t\t\tverticalAlignmentMap.center;\n\t\tconst rowOrientation = `\n\t\tflex-direction: row;\n\t\talign-items: ${ verticalAlignment };\n\t\tjustify-content: ${ justifyContent };\n\t\t`;\n\t\tconst alignItems =\n\t\t\talignItemsMap[ layout.justifyContent ] || alignItemsMap.left;\n\t\tconst columnOrientation = `\n\t\tflex-direction: column;\n\t\talign-items: ${ alignItems };\n\t\t`;\n\n\t\treturn (\n\t\t\t<style>{ `\n\t\t\t\t${ appendSelectors( selector ) } {\n\t\t\t\t\tdisplay: flex;\n\t\t\t\t\tflex-wrap: ${ flexWrap };\n\t\t\t\t\tgap: ${ hasBlockGapStylesSupport ? blockGapValue : '0.5em' };\n\t\t\t\t\t${ orientation === 'horizontal' ? rowOrientation : columnOrientation }\n\t\t\t\t}\n\n\t\t\t\t${ appendSelectors( selector, '> *' ) } {\n\t\t\t\t\tmargin: 0;\n\t\t\t\t}\n\t\t\t` }</style>\n\t\t);\n\t},\n\tgetOrientation( layout ) {\n\t\tconst { orientation = 'horizontal' } = layout;\n\t\treturn orientation;\n\t},\n\tgetAlignments() {\n\t\treturn [];\n\t},\n};\n\nfunction FlexLayoutVerticalAlignmentControl( {\n\tlayout,\n\tonChange,\n\tisToolbar = false,\n} ) {\n\tconst { verticalAlignment = verticalAlignmentMap.center } = layout;\n\n\tconst onVerticalAlignmentChange = ( value ) => {\n\t\tonChange( {\n\t\t\t...layout,\n\t\t\tverticalAlignment: value,\n\t\t} );\n\t};\n\tif ( isToolbar ) {\n\t\treturn (\n\t\t\t<BlockVerticalAlignmentControl\n\t\t\t\tonChange={ onVerticalAlignmentChange }\n\t\t\t\tvalue={ verticalAlignment }\n\t\t\t/>\n\t\t);\n\t}\n\n\tconst verticalAlignmentOptions = [\n\t\t{\n\t\t\tvalue: 'flex-start',\n\t\t\tlabel: __( 'Align items top' ),\n\t\t},\n\t\t{\n\t\t\tvalue: 'center',\n\t\t\tlabel: __( 'Align items center' ),\n\t\t},\n\t\t{\n\t\t\tvalue: 'flex-end',\n\t\t\tlabel: __( 'Align items bottom' ),\n\t\t},\n\t];\n\n\treturn (\n\t\t<fieldset className=\"block-editor-hooks__flex-layout-vertical-alignment-control\">\n\t\t\t<legend>{ __( 'Vertical alignment' ) }</legend>\n\t\t\t<div>\n\t\t\t\t{ verticalAlignmentOptions.map( ( value, icon, label ) => {\n\t\t\t\t\treturn (\n\t\t\t\t\t\t<Button\n\t\t\t\t\t\t\tkey={ value }\n\t\t\t\t\t\t\tlabel={ label }\n\t\t\t\t\t\t\ticon={ icon }\n\t\t\t\t\t\t\tisPressed={ verticalAlignment === value }\n\t\t\t\t\t\t\tonClick={ () => onVerticalAlignmentChange( value ) }\n\t\t\t\t\t\t/>\n\t\t\t\t\t);\n\t\t\t\t} ) }\n\t\t\t</div>\n\t\t</fieldset>\n\t);\n}\n\nfunction FlexLayoutJustifyContentControl( {\n\tlayout,\n\tonChange,\n\tisToolbar = false,\n} ) {\n\tconst { justifyContent = 'left', orientation = 'horizontal' } = layout;\n\tconst onJustificationChange = ( value ) => {\n\t\tonChange( {\n\t\t\t...layout,\n\t\t\tjustifyContent: value,\n\t\t} );\n\t};\n\tconst allowedControls = [ 'left', 'center', 'right' ];\n\tif ( orientation === 'horizontal' ) {\n\t\tallowedControls.push( 'space-between' );\n\t}\n\tif ( isToolbar ) {\n\t\treturn (\n\t\t\t<JustifyContentControl\n\t\t\t\tallowedControls={ allowedControls }\n\t\t\t\tvalue={ justifyContent }\n\t\t\t\tonChange={ onJustificationChange }\n\t\t\t\tpopoverProps={ {\n\t\t\t\t\tposition: 'bottom right',\n\t\t\t\t\tisAlternate: true,\n\t\t\t\t} }\n\t\t\t/>\n\t\t);\n\t}\n\n\tconst justificationOptions = [\n\t\t{\n\t\t\tvalue: 'left',\n\t\t\ticon: justifyLeft,\n\t\t\tlabel: __( 'Justify items left' ),\n\t\t},\n\t\t{\n\t\t\tvalue: 'center',\n\t\t\ticon: justifyCenter,\n\t\t\tlabel: __( 'Justify items center' ),\n\t\t},\n\t\t{\n\t\t\tvalue: 'right',\n\t\t\ticon: justifyRight,\n\t\t\tlabel: __( 'Justify items right' ),\n\t\t},\n\t];\n\tif ( orientation === 'horizontal' ) {\n\t\tjustificationOptions.push( {\n\t\t\tvalue: 'space-between',\n\t\t\ticon: justifySpaceBetween,\n\t\t\tlabel: __( 'Space between items' ),\n\t\t} );\n\t}\n\n\treturn (\n\t\t<fieldset className=\"block-editor-hooks__flex-layout-justification-controls\">\n\t\t\t<legend>{ __( 'Justification' ) }</legend>\n\t\t\t<div>\n\t\t\t\t{ justificationOptions.map( ( { value, icon, label } ) => {\n\t\t\t\t\treturn (\n\t\t\t\t\t\t<Button\n\t\t\t\t\t\t\tkey={ value }\n\t\t\t\t\t\t\tlabel={ label }\n\t\t\t\t\t\t\ticon={ icon }\n\t\t\t\t\t\t\tisPressed={ justifyContent === value }\n\t\t\t\t\t\t\tonClick={ () => onJustificationChange( value ) }\n\t\t\t\t\t\t/>\n\t\t\t\t\t);\n\t\t\t\t} ) }\n\t\t\t</div>\n\t\t</fieldset>\n\t);\n}\n\nfunction FlexWrapControl( { layout, onChange } ) {\n\tconst { flexWrap = 'wrap' } = layout;\n\treturn (\n\t\t<ToggleControl\n\t\t\tlabel={ __( 'Allow to wrap to multiple lines' ) }\n\t\t\tonChange={ ( value ) => {\n\t\t\t\tonChange( {\n\t\t\t\t\t...layout,\n\t\t\t\t\tflexWrap: value ? 'wrap' : 'nowrap',\n\t\t\t\t} );\n\t\t\t} }\n\t\t\tchecked={ flexWrap === 'wrap' }\n\t\t/>\n\t);\n}\n\nfunction OrientationControl( { layout, onChange } ) {\n\tconst { orientation = 'horizontal' } = layout;\n\treturn (\n\t\t<fieldset className=\"block-editor-hooks__flex-layout-orientation-controls\">\n\t\t\t<legend>{ __( 'Orientation' ) }</legend>\n\t\t\t<Button\n\t\t\t\tlabel={ 'horizontal' }\n\t\t\t\ticon={ arrowRight }\n\t\t\t\tisPressed={ orientation === 'horizontal' }\n\t\t\t\tonClick={ () =>\n\t\t\t\t\tonChange( {\n\t\t\t\t\t\t...layout,\n\t\t\t\t\t\torientation: 'horizontal',\n\t\t\t\t\t} )\n\t\t\t\t}\n\t\t\t/>\n\t\t\t<Button\n\t\t\t\tlabel={ 'vertical' }\n\t\t\t\ticon={ arrowDown }\n\t\t\t\tisPressed={ orientation === 'vertical' }\n\t\t\t\tonClick={ () =>\n\t\t\t\t\tonChange( {\n\t\t\t\t\t\t...layout,\n\t\t\t\t\t\torientation: 'vertical',\n\t\t\t\t\t} )\n\t\t\t\t}\n\t\t\t/>\n\t\t</fieldset>\n\t);\n}\n"]}
@@ -21,6 +21,8 @@ var _utils = require("./utils");
21
21
 
22
22
  var _gap = require("../hooks/gap");
23
23
 
24
+ var _utils2 = require("../hooks/utils");
25
+
24
26
  /**
25
27
  * WordPress dependencies
26
28
  */
@@ -96,12 +98,13 @@ var _default = {
96
98
  return null;
97
99
  },
98
100
  save: function DefaultLayoutStyle(_ref2) {
99
- var _style$spacing, _blockGapStyleValue$t;
101
+ var _style$spacing;
100
102
 
101
103
  let {
102
104
  selector,
103
105
  layout = {},
104
- style
106
+ style,
107
+ blockName
105
108
  } = _ref2;
106
109
  const {
107
110
  contentSize,
@@ -109,8 +112,10 @@ var _default = {
109
112
  } = layout;
110
113
  const blockGapSupport = (0, _useSetting.default)('spacing.blockGap');
111
114
  const hasBlockGapStylesSupport = blockGapSupport !== null;
112
- const blockGapStyleValue = (0, _gap.getGapValueFromStyle)(style === null || style === void 0 ? void 0 : (_style$spacing = style.spacing) === null || _style$spacing === void 0 ? void 0 : _style$spacing.blockGap);
113
- const blockGapValue = (_blockGapStyleValue$t = blockGapStyleValue === null || blockGapStyleValue === void 0 ? void 0 : blockGapStyleValue.top) !== null && _blockGapStyleValue$t !== void 0 ? _blockGapStyleValue$t : 'var( --wp--style--block-gap )';
115
+ const blockGapStyleValue = (0, _gap.getGapBoxControlValueFromStyle)(style === null || style === void 0 ? void 0 : (_style$spacing = style.spacing) === null || _style$spacing === void 0 ? void 0 : _style$spacing.blockGap); // If a block's block.json skips serialization for spacing or
116
+ // spacing.blockGap, don't apply the user-defined value to the styles.
117
+
118
+ const blockGapValue = blockGapStyleValue !== null && blockGapStyleValue !== void 0 && blockGapStyleValue.top && !(0, _utils2.shouldSkipSerialization)(blockName, 'spacing', 'blockGap') ? blockGapStyleValue === null || blockGapStyleValue === void 0 ? void 0 : blockGapStyleValue.top : 'var( --wp--style--block-gap )';
114
119
  let output = !!contentSize || !!wideSize ? `
115
120
  ${(0, _utils.appendSelectors)(selector, '> :where(:not(.alignleft):not(.alignright))')} {
116
121
  max-width: ${contentSize !== null && contentSize !== void 0 ? contentSize : wideSize};