@wordpress/block-editor 8.3.1 → 8.5.1

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 (475) hide show
  1. package/CHANGELOG.md +4 -0
  2. package/README.md +56 -18
  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-content-overlay/index.js +13 -4
  8. package/build/components/block-content-overlay/index.js.map +1 -1
  9. package/build/components/block-draggable/index.js +2 -3
  10. package/build/components/block-draggable/index.js.map +1 -1
  11. package/build/components/block-icon/index.js +4 -0
  12. package/build/components/block-icon/index.js.map +1 -1
  13. package/build/components/block-inspector/index.js +6 -1
  14. package/build/components/block-inspector/index.js.map +1 -1
  15. package/build/components/block-list/block-html.js +4 -1
  16. package/build/components/block-list/block-html.js.map +1 -1
  17. package/build/components/block-list/block.js +4 -1
  18. package/build/components/block-list/block.js.map +1 -1
  19. package/build/components/block-list/use-block-props/index.js +1 -6
  20. package/build/components/block-list/use-block-props/index.js.map +1 -1
  21. package/build/components/block-list/use-block-props/use-focus-first-element.js +22 -6
  22. package/build/components/block-list/use-block-props/use-focus-first-element.js.map +1 -1
  23. package/build/components/block-list/use-block-props/use-focus-handler.js +7 -1
  24. package/build/components/block-list/use-block-props/use-focus-handler.js.map +1 -1
  25. package/build/components/block-list-appender/index.js +6 -1
  26. package/build/components/block-list-appender/index.js.map +1 -1
  27. package/build/components/block-lock/index.js +40 -0
  28. package/build/components/block-lock/index.js.map +1 -0
  29. package/build/components/block-lock/menu-item.js +52 -0
  30. package/build/components/block-lock/menu-item.js.map +1 -0
  31. package/build/components/block-lock/modal.js +155 -0
  32. package/build/components/block-lock/modal.js.map +1 -0
  33. package/build/components/block-lock/toolbar.js +65 -0
  34. package/build/components/block-lock/toolbar.js.map +1 -0
  35. package/build/components/block-lock/use-block-lock.js +53 -0
  36. package/build/components/block-lock/use-block-lock.js.map +1 -0
  37. package/build/components/block-mover/index.js +4 -0
  38. package/build/components/block-mover/index.js.map +1 -1
  39. package/build/components/block-pattern-setup/index.js +37 -22
  40. package/build/components/block-pattern-setup/index.js.map +1 -1
  41. package/build/components/block-pattern-setup/setup-toolbar.js +1 -1
  42. package/build/components/block-pattern-setup/setup-toolbar.js.map +1 -1
  43. package/build/components/block-preview/auto.js +6 -3
  44. package/build/components/block-preview/auto.js.map +1 -1
  45. package/build/components/block-preview/index.js +4 -2
  46. package/build/components/block-preview/index.js.map +1 -1
  47. package/build/components/block-settings-menu/block-settings-dropdown.js +75 -10
  48. package/build/components/block-settings-menu/block-settings-dropdown.js.map +1 -1
  49. package/build/components/block-settings-menu-controls/index.js +19 -9
  50. package/build/components/block-settings-menu-controls/index.js.map +1 -1
  51. package/build/components/block-switcher/index.js +8 -3
  52. package/build/components/block-switcher/index.js.map +1 -1
  53. package/build/components/block-title/index.js +2 -2
  54. package/build/components/block-title/index.js.map +1 -1
  55. package/build/components/block-title/use-block-display-title.js +8 -6
  56. package/build/components/block-title/use-block-display-title.js.map +1 -1
  57. package/build/components/block-toolbar/block-name-context.js +17 -0
  58. package/build/components/block-toolbar/block-name-context.js.map +1 -0
  59. package/build/components/block-toolbar/block-toolbar-last-item.js +20 -0
  60. package/build/components/block-toolbar/block-toolbar-last-item.js.map +1 -0
  61. package/build/components/block-toolbar/index.js +24 -5
  62. package/build/components/block-toolbar/index.js.map +1 -1
  63. package/build/components/block-tools/index.js +0 -16
  64. package/build/components/block-tools/index.js.map +1 -1
  65. package/build/components/block-variation-transforms/index.js +92 -47
  66. package/build/components/block-variation-transforms/index.js.map +1 -1
  67. package/build/components/block-vertical-alignment-control/index.js +13 -6
  68. package/build/components/block-vertical-alignment-control/index.js.map +1 -1
  69. package/build/components/border-radius-control/index.js +0 -1
  70. package/build/components/border-radius-control/index.js.map +1 -1
  71. package/build/components/border-radius-control/utils.js +1 -1
  72. package/build/components/border-radius-control/utils.js.map +1 -1
  73. package/build/components/colors-gradients/control.js +3 -1
  74. package/build/components/colors-gradients/control.js.map +1 -1
  75. package/build/components/contrast-checker/index.js +4 -0
  76. package/build/components/contrast-checker/index.js.map +1 -1
  77. package/build/components/convert-to-group-buttons/index.js +8 -0
  78. package/build/components/convert-to-group-buttons/index.js.map +1 -1
  79. package/build/components/convert-to-group-buttons/toolbar.js +105 -0
  80. package/build/components/convert-to-group-buttons/toolbar.js.map +1 -0
  81. package/build/components/copy-handler/index.js +4 -0
  82. package/build/components/copy-handler/index.js.map +1 -1
  83. package/build/components/date-format-picker/index.js +132 -0
  84. package/build/components/date-format-picker/index.js.map +1 -0
  85. package/build/components/font-sizes/font-size-picker.js +4 -0
  86. package/build/components/font-sizes/font-size-picker.js.map +1 -1
  87. package/build/components/iframe/index.js +6 -9
  88. package/build/components/iframe/index.js.map +1 -1
  89. package/build/components/index.js +27 -0
  90. package/build/components/index.js.map +1 -1
  91. package/build/components/justify-content-control/index.js +13 -6
  92. package/build/components/justify-content-control/index.js.map +1 -1
  93. package/build/components/keyboard-shortcuts/index.js +1 -1
  94. package/build/components/keyboard-shortcuts/index.js.map +1 -1
  95. package/build/components/line-height-control/index.js +15 -6
  96. package/build/components/line-height-control/index.js.map +1 -1
  97. package/build/components/list-view/block-select-button.js +18 -23
  98. package/build/components/list-view/block-select-button.js.map +1 -1
  99. package/build/components/list-view/block.js +38 -13
  100. package/build/components/list-view/block.js.map +1 -1
  101. package/build/components/list-view/branch.js +16 -13
  102. package/build/components/list-view/branch.js.map +1 -1
  103. package/build/components/list-view/index.js +7 -1
  104. package/build/components/list-view/index.js.map +1 -1
  105. package/build/components/list-view/use-block-selection.js +9 -2
  106. package/build/components/list-view/use-block-selection.js.map +1 -1
  107. package/build/components/media-replace-flow/index.js +4 -0
  108. package/build/components/media-replace-flow/index.js.map +1 -1
  109. package/build/components/multi-selection-inspector/index.js +1 -1
  110. package/build/components/multi-selection-inspector/index.js.map +1 -1
  111. package/build/components/rich-text/index.js +27 -5
  112. package/build/components/rich-text/index.js.map +1 -1
  113. package/build/components/rich-text/index.native.js +13 -9
  114. package/build/components/rich-text/index.native.js.map +1 -1
  115. package/build/components/rich-text/split-value.js +12 -2
  116. package/build/components/rich-text/split-value.js.map +1 -1
  117. package/build/components/rich-text/use-firefox-compat.js +49 -0
  118. package/build/components/rich-text/use-firefox-compat.js.map +1 -0
  119. package/build/components/rich-text/use-input-rules.js +34 -2
  120. package/build/components/rich-text/use-input-rules.js.map +1 -1
  121. package/build/components/skip-to-selected-block/index.js +4 -0
  122. package/build/components/skip-to-selected-block/index.js.map +1 -1
  123. package/build/components/url-popover/image-url-input-ui.js +11 -27
  124. package/build/components/url-popover/image-url-input-ui.js.map +1 -1
  125. package/build/components/writing-flow/index.js +9 -1
  126. package/build/components/writing-flow/index.js.map +1 -1
  127. package/build/components/writing-flow/use-arrow-nav.js +3 -44
  128. package/build/components/writing-flow/use-arrow-nav.js.map +1 -1
  129. package/build/components/writing-flow/use-click-selection.js +68 -0
  130. package/build/components/writing-flow/use-click-selection.js.map +1 -0
  131. package/build/components/writing-flow/use-drag-selection.js +134 -0
  132. package/build/components/writing-flow/use-drag-selection.js.map +1 -0
  133. package/build/components/writing-flow/use-input.js +116 -0
  134. package/build/components/writing-flow/use-input.js.map +1 -0
  135. package/build/components/writing-flow/use-multi-selection.js +18 -38
  136. package/build/components/writing-flow/use-multi-selection.js.map +1 -1
  137. package/build/components/writing-flow/use-selection-observer.js +161 -0
  138. package/build/components/writing-flow/use-selection-observer.js.map +1 -0
  139. package/build/components/writing-flow/use-tab-nav.js +1 -8
  140. package/build/components/writing-flow/use-tab-nav.js.map +1 -1
  141. package/build/hooks/anchor.js +7 -6
  142. package/build/hooks/anchor.js.map +1 -1
  143. package/build/hooks/border-color.js +3 -3
  144. package/build/hooks/border-color.js.map +1 -1
  145. package/build/hooks/border.js +0 -14
  146. package/build/hooks/border.js.map +1 -1
  147. package/build/hooks/color.js +20 -17
  148. package/build/hooks/color.js.map +1 -1
  149. package/build/hooks/font-family.js +5 -1
  150. package/build/hooks/font-family.js.map +1 -1
  151. package/build/hooks/font-size.js +4 -2
  152. package/build/hooks/font-size.js.map +1 -1
  153. package/build/hooks/gap.js +77 -5
  154. package/build/hooks/gap.js.map +1 -1
  155. package/build/hooks/layout.js +7 -2
  156. package/build/hooks/layout.js.map +1 -1
  157. package/build/hooks/style.js +34 -3
  158. package/build/hooks/style.js.map +1 -1
  159. package/build/hooks/utils.js +29 -0
  160. package/build/hooks/utils.js.map +1 -1
  161. package/build/layouts/flex.js +82 -15
  162. package/build/layouts/flex.js.map +1 -1
  163. package/build/layouts/flow.js +22 -13
  164. package/build/layouts/flow.js.map +1 -1
  165. package/build/store/actions.js +297 -51
  166. package/build/store/actions.js.map +1 -1
  167. package/build/store/defaults.js +5 -1
  168. package/build/store/defaults.js.map +1 -1
  169. package/build/store/reducer.js +25 -13
  170. package/build/store/reducer.js.map +1 -1
  171. package/build/store/selectors.js +197 -23
  172. package/build/store/selectors.js.map +1 -1
  173. package/build/utils/dom.js +2 -1
  174. package/build/utils/dom.js.map +1 -1
  175. package/build-module/components/alignment-control/index.js +12 -4
  176. package/build-module/components/alignment-control/index.js.map +1 -1
  177. package/build-module/components/block-alignment-control/index.js +12 -4
  178. package/build-module/components/block-alignment-control/index.js.map +1 -1
  179. package/build-module/components/block-content-overlay/index.js +13 -4
  180. package/build-module/components/block-content-overlay/index.js.map +1 -1
  181. package/build-module/components/block-draggable/index.js +2 -3
  182. package/build-module/components/block-draggable/index.js.map +1 -1
  183. package/build-module/components/block-icon/index.js +4 -0
  184. package/build-module/components/block-icon/index.js.map +1 -1
  185. package/build-module/components/block-inspector/index.js +6 -1
  186. package/build-module/components/block-inspector/index.js.map +1 -1
  187. package/build-module/components/block-list/block-html.js +5 -2
  188. package/build-module/components/block-list/block-html.js.map +1 -1
  189. package/build-module/components/block-list/block.js +5 -2
  190. package/build-module/components/block-list/block.js.map +1 -1
  191. package/build-module/components/block-list/use-block-props/index.js +1 -4
  192. package/build-module/components/block-list/use-block-props/index.js.map +1 -1
  193. package/build-module/components/block-list/use-block-props/use-focus-first-element.js +22 -6
  194. package/build-module/components/block-list/use-block-props/use-focus-first-element.js.map +1 -1
  195. package/build-module/components/block-list/use-block-props/use-focus-handler.js +7 -1
  196. package/build-module/components/block-list/use-block-props/use-focus-handler.js.map +1 -1
  197. package/build-module/components/block-list-appender/index.js +6 -1
  198. package/build-module/components/block-list-appender/index.js.map +1 -1
  199. package/build-module/components/block-lock/index.js +5 -0
  200. package/build-module/components/block-lock/index.js.map +1 -0
  201. package/build-module/components/block-lock/menu-item.js +39 -0
  202. package/build-module/components/block-lock/menu-item.js.map +1 -0
  203. package/build-module/components/block-lock/modal.js +138 -0
  204. package/build-module/components/block-lock/modal.js.map +1 -0
  205. package/build-module/components/block-lock/toolbar.js +51 -0
  206. package/build-module/components/block-lock/toolbar.js.map +1 -0
  207. package/build-module/components/block-lock/use-block-lock.js +44 -0
  208. package/build-module/components/block-lock/use-block-lock.js.map +1 -0
  209. package/build-module/components/block-mover/index.js +4 -0
  210. package/build-module/components/block-mover/index.js.map +1 -1
  211. package/build-module/components/block-pattern-setup/index.js +39 -24
  212. package/build-module/components/block-pattern-setup/index.js.map +1 -1
  213. package/build-module/components/block-pattern-setup/setup-toolbar.js +1 -1
  214. package/build-module/components/block-pattern-setup/setup-toolbar.js.map +1 -1
  215. package/build-module/components/block-preview/auto.js +6 -3
  216. package/build-module/components/block-preview/auto.js.map +1 -1
  217. package/build-module/components/block-preview/index.js +4 -2
  218. package/build-module/components/block-preview/index.js.map +1 -1
  219. package/build-module/components/block-settings-menu/block-settings-dropdown.js +75 -12
  220. package/build-module/components/block-settings-menu/block-settings-dropdown.js.map +1 -1
  221. package/build-module/components/block-settings-menu-controls/index.js +18 -9
  222. package/build-module/components/block-settings-menu-controls/index.js.map +1 -1
  223. package/build-module/components/block-switcher/index.js +9 -4
  224. package/build-module/components/block-switcher/index.js.map +1 -1
  225. package/build-module/components/block-title/index.js +2 -2
  226. package/build-module/components/block-title/index.js.map +1 -1
  227. package/build-module/components/block-title/use-block-display-title.js +8 -6
  228. package/build-module/components/block-title/use-block-display-title.js.map +1 -1
  229. package/build-module/components/block-toolbar/block-name-context.js +9 -0
  230. package/build-module/components/block-toolbar/block-name-context.js.map +1 -0
  231. package/build-module/components/block-toolbar/block-toolbar-last-item.js +11 -0
  232. package/build-module/components/block-toolbar/block-toolbar-last-item.js.map +1 -0
  233. package/build-module/components/block-toolbar/index.js +19 -4
  234. package/build-module/components/block-toolbar/index.js.map +1 -1
  235. package/build-module/components/block-tools/index.js +0 -16
  236. package/build-module/components/block-tools/index.js.map +1 -1
  237. package/build-module/components/block-variation-transforms/index.js +95 -49
  238. package/build-module/components/block-variation-transforms/index.js.map +1 -1
  239. package/build-module/components/block-vertical-alignment-control/index.js +12 -4
  240. package/build-module/components/block-vertical-alignment-control/index.js.map +1 -1
  241. package/build-module/components/border-radius-control/index.js +0 -1
  242. package/build-module/components/border-radius-control/index.js.map +1 -1
  243. package/build-module/components/border-radius-control/utils.js +1 -1
  244. package/build-module/components/border-radius-control/utils.js.map +1 -1
  245. package/build-module/components/colors-gradients/control.js +3 -1
  246. package/build-module/components/colors-gradients/control.js.map +1 -1
  247. package/build-module/components/contrast-checker/index.js +4 -0
  248. package/build-module/components/contrast-checker/index.js.map +1 -1
  249. package/build-module/components/convert-to-group-buttons/index.js +2 -1
  250. package/build-module/components/convert-to-group-buttons/index.js.map +1 -1
  251. package/build-module/components/convert-to-group-buttons/toolbar.js +90 -0
  252. package/build-module/components/convert-to-group-buttons/toolbar.js.map +1 -0
  253. package/build-module/components/copy-handler/index.js +4 -0
  254. package/build-module/components/copy-handler/index.js.map +1 -1
  255. package/build-module/components/date-format-picker/index.js +122 -0
  256. package/build-module/components/date-format-picker/index.js.map +1 -0
  257. package/build-module/components/font-sizes/font-size-picker.js +4 -0
  258. package/build-module/components/font-sizes/font-size-picker.js.map +1 -1
  259. package/build-module/components/iframe/index.js +6 -9
  260. package/build-module/components/iframe/index.js.map +1 -1
  261. package/build-module/components/index.js +3 -0
  262. package/build-module/components/index.js.map +1 -1
  263. package/build-module/components/justify-content-control/index.js +12 -4
  264. package/build-module/components/justify-content-control/index.js.map +1 -1
  265. package/build-module/components/keyboard-shortcuts/index.js +1 -1
  266. package/build-module/components/keyboard-shortcuts/index.js.map +1 -1
  267. package/build-module/components/line-height-control/index.js +14 -5
  268. package/build-module/components/line-height-control/index.js.map +1 -1
  269. package/build-module/components/list-view/block-select-button.js +19 -23
  270. package/build-module/components/list-view/block-select-button.js.map +1 -1
  271. package/build-module/components/list-view/block.js +36 -13
  272. package/build-module/components/list-view/block.js.map +1 -1
  273. package/build-module/components/list-view/branch.js +16 -13
  274. package/build-module/components/list-view/branch.js.map +1 -1
  275. package/build-module/components/list-view/index.js +7 -1
  276. package/build-module/components/list-view/index.js.map +1 -1
  277. package/build-module/components/list-view/use-block-selection.js +10 -3
  278. package/build-module/components/list-view/use-block-selection.js.map +1 -1
  279. package/build-module/components/media-replace-flow/index.js +4 -0
  280. package/build-module/components/media-replace-flow/index.js.map +1 -1
  281. package/build-module/components/multi-selection-inspector/index.js +2 -2
  282. package/build-module/components/multi-selection-inspector/index.js.map +1 -1
  283. package/build-module/components/rich-text/index.js +26 -5
  284. package/build-module/components/rich-text/index.js.map +1 -1
  285. package/build-module/components/rich-text/index.native.js +13 -9
  286. package/build-module/components/rich-text/index.native.js.map +1 -1
  287. package/build-module/components/rich-text/split-value.js +12 -2
  288. package/build-module/components/rich-text/split-value.js.map +1 -1
  289. package/build-module/components/rich-text/use-firefox-compat.js +39 -0
  290. package/build-module/components/rich-text/use-firefox-compat.js.map +1 -0
  291. package/build-module/components/rich-text/use-input-rules.js +35 -4
  292. package/build-module/components/rich-text/use-input-rules.js.map +1 -1
  293. package/build-module/components/skip-to-selected-block/index.js +4 -0
  294. package/build-module/components/skip-to-selected-block/index.js.map +1 -1
  295. package/build-module/components/url-popover/image-url-input-ui.js +12 -28
  296. package/build-module/components/url-popover/image-url-input-ui.js.map +1 -1
  297. package/build-module/components/writing-flow/index.js +5 -1
  298. package/build-module/components/writing-flow/index.js.map +1 -1
  299. package/build-module/components/writing-flow/use-arrow-nav.js +4 -45
  300. package/build-module/components/writing-flow/use-arrow-nav.js.map +1 -1
  301. package/build-module/components/writing-flow/use-click-selection.js +57 -0
  302. package/build-module/components/writing-flow/use-click-selection.js.map +1 -0
  303. package/build-module/components/writing-flow/use-drag-selection.js +124 -0
  304. package/build-module/components/writing-flow/use-drag-selection.js.map +1 -0
  305. package/build-module/components/writing-flow/use-input.js +104 -0
  306. package/build-module/components/writing-flow/use-input.js.map +1 -0
  307. package/build-module/components/writing-flow/use-multi-selection.js +18 -37
  308. package/build-module/components/writing-flow/use-multi-selection.js.map +1 -1
  309. package/build-module/components/writing-flow/use-selection-observer.js +150 -0
  310. package/build-module/components/writing-flow/use-selection-observer.js.map +1 -0
  311. package/build-module/components/writing-flow/use-tab-nav.js +1 -9
  312. package/build-module/components/writing-flow/use-tab-nav.js.map +1 -1
  313. package/build-module/hooks/anchor.js +7 -6
  314. package/build-module/hooks/anchor.js.map +1 -1
  315. package/build-module/hooks/border-color.js +5 -5
  316. package/build-module/hooks/border-color.js.map +1 -1
  317. package/build-module/hooks/border.js +0 -12
  318. package/build-module/hooks/border.js.map +1 -1
  319. package/build-module/hooks/color.js +19 -18
  320. package/build-module/hooks/color.js.map +1 -1
  321. package/build-module/hooks/font-family.js +3 -1
  322. package/build-module/hooks/font-family.js.map +1 -1
  323. package/build-module/hooks/font-size.js +4 -3
  324. package/build-module/hooks/font-size.js.map +1 -1
  325. package/build-module/hooks/gap.js +75 -7
  326. package/build-module/hooks/gap.js.map +1 -1
  327. package/build-module/hooks/layout.js +7 -2
  328. package/build-module/hooks/layout.js.map +1 -1
  329. package/build-module/hooks/style.js +33 -3
  330. package/build-module/hooks/style.js.map +1 -1
  331. package/build-module/hooks/utils.js +26 -0
  332. package/build-module/hooks/utils.js.map +1 -1
  333. package/build-module/layouts/flex.js +81 -16
  334. package/build-module/layouts/flex.js.map +1 -1
  335. package/build-module/layouts/flow.js +20 -13
  336. package/build-module/layouts/flow.js.map +1 -1
  337. package/build-module/store/actions.js +286 -49
  338. package/build-module/store/actions.js.map +1 -1
  339. package/build-module/store/defaults.js +5 -1
  340. package/build-module/store/defaults.js.map +1 -1
  341. package/build-module/store/reducer.js +25 -13
  342. package/build-module/store/reducer.js.map +1 -1
  343. package/build-module/store/selectors.js +186 -22
  344. package/build-module/store/selectors.js.map +1 -1
  345. package/build-module/utils/dom.js +2 -1
  346. package/build-module/utils/dom.js.map +1 -1
  347. package/build-style/style-rtl.css +248 -49
  348. package/build-style/style.css +248 -49
  349. package/build-types/utils/dom.d.ts.map +1 -1
  350. package/package.json +28 -27
  351. package/src/components/alignment-control/index.js +9 -4
  352. package/src/components/block-alignment-control/index.js +9 -4
  353. package/src/components/block-content-overlay/index.js +19 -2
  354. package/src/components/block-draggable/index.js +2 -5
  355. package/src/components/block-icon/index.js +3 -0
  356. package/src/components/block-inspector/index.js +4 -0
  357. package/src/components/block-list/block-html.js +8 -4
  358. package/src/components/block-list/block.js +5 -1
  359. package/src/components/block-list/style.scss +4 -5
  360. package/src/components/block-list/use-block-props/index.js +0 -5
  361. package/src/components/block-list/use-block-props/use-focus-first-element.js +27 -6
  362. package/src/components/block-list/use-block-props/use-focus-handler.js +8 -0
  363. package/src/components/block-list-appender/index.js +5 -0
  364. package/src/components/block-lock/index.js +4 -0
  365. package/src/components/block-lock/menu-item.js +39 -0
  366. package/src/components/block-lock/modal.js +194 -0
  367. package/src/components/block-lock/style.scss +70 -0
  368. package/src/components/block-lock/toolbar.js +51 -0
  369. package/src/components/block-lock/use-block-lock.js +49 -0
  370. package/src/components/block-mover/index.js +3 -0
  371. package/src/components/block-mover/style.scss +4 -0
  372. package/src/components/block-pattern-setup/index.js +84 -59
  373. package/src/components/block-pattern-setup/setup-toolbar.js +3 -1
  374. package/src/components/block-pattern-setup/style.scss +32 -26
  375. package/src/components/block-preview/auto.js +10 -1
  376. package/src/components/block-preview/index.js +2 -0
  377. package/src/components/block-settings-menu/block-settings-dropdown.js +109 -9
  378. package/src/components/block-settings-menu-controls/index.js +33 -12
  379. package/src/components/block-switcher/index.js +15 -3
  380. package/src/components/block-switcher/style.scss +15 -4
  381. package/src/components/block-switcher/test/__snapshots__/index.js.snap +15 -13
  382. package/src/components/block-switcher/test/index.js +2 -2
  383. package/src/components/block-title/README.md +6 -1
  384. package/src/components/block-title/index.js +2 -2
  385. package/src/components/block-title/test/index.js +43 -1
  386. package/src/components/block-title/use-block-display-title.js +10 -7
  387. package/src/components/block-toolbar/block-name-context.js +8 -0
  388. package/src/components/block-toolbar/block-toolbar-last-item.js +12 -0
  389. package/src/components/block-toolbar/index.js +24 -2
  390. package/src/components/block-toolbar/style.scss +10 -0
  391. package/src/components/block-tools/index.js +0 -19
  392. package/src/components/block-tools/style.scss +27 -0
  393. package/src/components/block-variation-transforms/index.js +105 -36
  394. package/src/components/block-variation-transforms/style.scss +1 -1
  395. package/src/components/block-vertical-alignment-control/index.js +9 -4
  396. package/src/components/border-radius-control/index.js +0 -1
  397. package/src/components/border-radius-control/test/utils.js +4 -0
  398. package/src/components/border-radius-control/utils.js +2 -1
  399. package/src/components/button-block-appender/style.scss +5 -1
  400. package/src/components/color-palette/test/__snapshots__/control.js.snap +70 -4
  401. package/src/components/colors-gradients/control.js +1 -1
  402. package/src/components/colors-gradients/style.scss +6 -0
  403. package/src/components/contrast-checker/index.js +3 -0
  404. package/src/components/convert-to-group-buttons/index.js +6 -1
  405. package/src/components/convert-to-group-buttons/toolbar.js +87 -0
  406. package/src/components/copy-handler/index.js +3 -0
  407. package/src/components/date-format-picker/README.md +58 -0
  408. package/src/components/date-format-picker/index.js +161 -0
  409. package/src/components/date-format-picker/style.scss +31 -0
  410. package/src/components/font-sizes/font-size-picker.js +3 -0
  411. package/src/components/iframe/index.js +5 -7
  412. package/src/components/index.js +3 -0
  413. package/src/components/justify-content-control/index.js +9 -4
  414. package/src/components/keyboard-shortcuts/index.js +1 -1
  415. package/src/components/line-height-control/index.js +11 -6
  416. package/src/components/link-control/README.md +1 -1
  417. package/src/components/list-view/block-select-button.js +14 -31
  418. package/src/components/list-view/block.js +55 -13
  419. package/src/components/list-view/branch.js +37 -15
  420. package/src/components/list-view/index.js +6 -0
  421. package/src/components/list-view/style.scss +56 -14
  422. package/src/components/list-view/use-block-selection.js +15 -2
  423. package/src/components/media-placeholder/README.md +8 -0
  424. package/src/components/media-replace-flow/index.js +3 -0
  425. package/src/components/multi-selection-inspector/index.js +2 -2
  426. package/src/components/rich-text/index.js +25 -2
  427. package/src/components/rich-text/index.native.js +24 -8
  428. package/src/components/rich-text/split-value.js +5 -1
  429. package/src/components/rich-text/use-firefox-compat.js +39 -0
  430. package/src/components/rich-text/use-input-rules.js +40 -3
  431. package/src/components/skip-to-selected-block/index.js +3 -0
  432. package/src/components/url-input/style.scss +3 -2
  433. package/src/components/url-popover/image-url-input-ui.js +16 -29
  434. package/src/components/writing-flow/index.js +8 -0
  435. package/src/components/writing-flow/readme.md +28 -0
  436. package/src/components/writing-flow/use-arrow-nav.js +4 -53
  437. package/src/components/writing-flow/use-click-selection.js +65 -0
  438. package/src/components/writing-flow/use-drag-selection.js +126 -0
  439. package/src/components/writing-flow/use-input.js +112 -0
  440. package/src/components/writing-flow/use-multi-selection.js +13 -36
  441. package/src/components/writing-flow/use-selection-observer.js +153 -0
  442. package/src/components/writing-flow/use-tab-nav.js +1 -11
  443. package/src/hooks/anchor.js +8 -6
  444. package/src/hooks/border-color.js +5 -5
  445. package/src/hooks/border.js +0 -13
  446. package/src/hooks/color.js +51 -24
  447. package/src/hooks/font-family.js +5 -2
  448. package/src/hooks/font-size.js +10 -7
  449. package/src/hooks/gap.js +91 -12
  450. package/src/hooks/layout.js +11 -1
  451. package/src/hooks/style.js +40 -4
  452. package/src/hooks/test/gap.js +66 -0
  453. package/src/hooks/test/style.js +94 -0
  454. package/src/hooks/test/utils.js +1 -1
  455. package/src/hooks/utils.js +26 -0
  456. package/src/layouts/flex.js +93 -6
  457. package/src/layouts/flow.js +28 -12
  458. package/src/store/actions.js +349 -32
  459. package/src/store/defaults.js +7 -1
  460. package/src/store/reducer.js +25 -10
  461. package/src/store/selectors.js +229 -27
  462. package/src/store/test/selectors.js +305 -5
  463. package/src/style.scss +2 -0
  464. package/src/utils/dom.js +2 -1
  465. package/tsconfig.tsbuildinfo +1 -1
  466. package/build/components/block-list/use-block-props/use-multi-selection.js +0 -205
  467. package/build/components/block-list/use-block-props/use-multi-selection.js.map +0 -1
  468. package/build/components/block-list/use-block-props/use-scroll-into-view.js +0 -77
  469. package/build/components/block-list/use-block-props/use-scroll-into-view.js.map +0 -1
  470. package/build-module/components/block-list/use-block-props/use-multi-selection.js +0 -192
  471. package/build-module/components/block-list/use-block-props/use-multi-selection.js.map +0 -1
  472. package/build-module/components/block-list/use-block-props/use-scroll-into-view.js +0 -63
  473. package/build-module/components/block-list/use-block-props/use-scroll-into-view.js.map +0 -1
  474. package/src/components/block-list/use-block-props/use-multi-selection.js +0 -227
  475. package/src/components/block-list/use-block-props/use-scroll-into-view.js +0 -73
@@ -6,20 +6,20 @@ import { createElement, Fragment } from "@wordpress/element";
6
6
  import { __ } from '@wordpress/i18n';
7
7
  import { Platform } from '@wordpress/element';
8
8
  import { getBlockSupport } from '@wordpress/blocks';
9
- import { __experimentalUseCustomUnits as useCustomUnits, __experimentalUnitControl as UnitControl } from '@wordpress/components';
9
+ import { __experimentalUseCustomUnits as useCustomUnits, __experimentalBoxControl as BoxControl, __experimentalUnitControl as UnitControl } from '@wordpress/components';
10
10
  /**
11
11
  * Internal dependencies
12
12
  */
13
13
 
14
14
  import { __unstableUseBlockRef as useBlockRef } from '../components/block-list/use-block-props/use-block-refs';
15
15
  import useSetting from '../components/use-setting';
16
- import { SPACING_SUPPORT_KEY } from './dimensions';
16
+ import { AXIAL_SIDES, SPACING_SUPPORT_KEY, useCustomSides } from './dimensions';
17
17
  import { cleanEmptyObject } from './utils';
18
18
  /**
19
19
  * Determines if there is gap support.
20
20
  *
21
21
  * @param {string|Object} blockType Block name or Block Type object.
22
- * @return {boolean} Whether there is support.
22
+ * @return {boolean} Whether there is support.
23
23
  */
24
24
 
25
25
  export function hasGapSupport(blockType) {
@@ -38,6 +38,46 @@ export function hasGapValue(props) {
38
38
 
39
39
  return ((_props$attributes$sty = props.attributes.style) === null || _props$attributes$sty === void 0 ? void 0 : (_props$attributes$sty2 = _props$attributes$sty.spacing) === null || _props$attributes$sty2 === void 0 ? void 0 : _props$attributes$sty2.blockGap) !== undefined;
40
40
  }
41
+ /**
42
+ * Returns a BoxControl object value from a given blockGap style value.
43
+ * The string check is for backwards compatibility before Gutenberg supported
44
+ * split gap values (row and column) and the value was a string n + unit.
45
+ *
46
+ * @param {string? | Object?} blockGapValue A block gap string or axial object value, e.g., '10px' or { top: '10px', left: '10px'}.
47
+ * @return {Object|null} A value to pass to the BoxControl component.
48
+ */
49
+
50
+ export function getGapBoxControlValueFromStyle(blockGapValue) {
51
+ if (!blockGapValue) {
52
+ return null;
53
+ }
54
+
55
+ const isValueString = typeof blockGapValue === 'string';
56
+ return {
57
+ top: isValueString ? blockGapValue : blockGapValue === null || blockGapValue === void 0 ? void 0 : blockGapValue.top,
58
+ left: isValueString ? blockGapValue : blockGapValue === null || blockGapValue === void 0 ? void 0 : blockGapValue.left
59
+ };
60
+ }
61
+ /**
62
+ * Returns a CSS value for the `gap` property from a given blockGap style.
63
+ *
64
+ * @param {string? | Object?} blockGapValue A block gap string or axial object value, e.g., '10px' or { top: '10px', left: '10px'}.
65
+ * @param {string?} defaultValue A default gap value.
66
+ * @return {string|null} The concatenated gap value (row and column).
67
+ */
68
+
69
+ export function getGapCSSValue(blockGapValue) {
70
+ let defaultValue = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : '0';
71
+ const blockGapBoxControlValue = getGapBoxControlValueFromStyle(blockGapValue);
72
+
73
+ if (!blockGapBoxControlValue) {
74
+ return null;
75
+ }
76
+
77
+ const row = (blockGapBoxControlValue === null || blockGapBoxControlValue === void 0 ? void 0 : blockGapBoxControlValue.top) || defaultValue;
78
+ const column = (blockGapBoxControlValue === null || blockGapBoxControlValue === void 0 ? void 0 : blockGapBoxControlValue.left) || defaultValue;
79
+ return row === column ? row : `${row} ${column}`;
80
+ }
41
81
  /**
42
82
  * Resets the gap block support attribute. This can be used when disabling
43
83
  * the gap support controls for a block via a progressive discovery panel.
@@ -93,23 +133,34 @@ export function GapEdit(props) {
93
133
  attributes: {
94
134
  style
95
135
  },
136
+ name: blockName,
96
137
  setAttributes
97
138
  } = props;
98
139
  const units = useCustomUnits({
99
140
  availableUnits: useSetting('spacing.units') || ['%', 'px', 'em', 'rem', 'vw']
100
141
  });
142
+ const sides = useCustomSides(blockName, 'blockGap');
101
143
  const ref = useBlockRef(clientId);
102
144
 
103
145
  if (useIsGapDisabled(props)) {
104
146
  return null;
105
147
  }
106
148
 
149
+ const splitOnAxis = sides && sides.some(side => AXIAL_SIDES.includes(side));
150
+
107
151
  const onChange = next => {
108
152
  var _window;
109
153
 
154
+ let blockGap = next; // If splitOnAxis activated we need to return a BoxControl object to the BoxControl component.
155
+
156
+ if (!!next && splitOnAxis) {
157
+ blockGap = { ...getGapBoxControlValueFromStyle(next)
158
+ };
159
+ }
160
+
110
161
  const newStyle = { ...style,
111
162
  spacing: { ...(style === null || style === void 0 ? void 0 : style.spacing),
112
- blockGap: next
163
+ blockGap
113
164
  }
114
165
  };
115
166
  setAttributes({
@@ -127,14 +178,31 @@ export function GapEdit(props) {
127
178
  }
128
179
  };
129
180
 
181
+ const gapValue = getGapBoxControlValueFromStyle(style === null || style === void 0 ? void 0 : (_style$spacing = style.spacing) === null || _style$spacing === void 0 ? void 0 : _style$spacing.blockGap); // The BoxControl component expects a full complement of side values.
182
+ // Gap row and column values translate to top/bottom and left/right respectively.
183
+
184
+ const boxControlGapValue = splitOnAxis ? { ...gapValue,
185
+ right: gapValue === null || gapValue === void 0 ? void 0 : gapValue.left,
186
+ bottom: gapValue === null || gapValue === void 0 ? void 0 : gapValue.top
187
+ } : gapValue === null || gapValue === void 0 ? void 0 : gapValue.top;
130
188
  return Platform.select({
131
- web: createElement(Fragment, null, createElement(UnitControl, {
189
+ web: createElement(Fragment, null, splitOnAxis ? createElement(BoxControl, {
132
190
  label: __('Block spacing'),
133
- __unstableInputWidth: "80px",
134
191
  min: 0,
135
192
  onChange: onChange,
136
193
  units: units,
137
- value: style === null || style === void 0 ? void 0 : (_style$spacing = style.spacing) === null || _style$spacing === void 0 ? void 0 : _style$spacing.blockGap
194
+ sides: sides,
195
+ values: boxControlGapValue,
196
+ allowReset: false,
197
+ splitOnAxis: splitOnAxis
198
+ }) : createElement(UnitControl, {
199
+ label: __('Block spacing'),
200
+ __unstableInputWidth: "80px",
201
+ min: 0,
202
+ onChange: onChange,
203
+ units: units // Default to `row` for combined values.
204
+ ,
205
+ value: boxControlGapValue
138
206
  })),
139
207
  native: null
140
208
  });
@@ -1 +1 @@
1
- {"version":3,"sources":["@wordpress/block-editor/src/hooks/gap.js"],"names":["__","Platform","getBlockSupport","__experimentalUseCustomUnits","useCustomUnits","__experimentalUnitControl","UnitControl","__unstableUseBlockRef","useBlockRef","useSetting","SPACING_SUPPORT_KEY","cleanEmptyObject","hasGapSupport","blockType","support","blockGap","hasGapValue","props","attributes","style","spacing","undefined","resetGap","setAttributes","useIsGapDisabled","name","blockName","isDisabled","GapEdit","clientId","units","availableUnits","ref","onChange","next","newStyle","isSafari","window","navigator","userAgent","includes","current","parentNode","replaceChild","select","web","native"],"mappings":";;AAAA;AACA;AACA;AACA,SAASA,EAAT,QAAmB,iBAAnB;AACA,SAASC,QAAT,QAAyB,oBAAzB;AACA,SAASC,eAAT,QAAgC,mBAAhC;AACA,SACCC,4BAA4B,IAAIC,cADjC,EAECC,yBAAyB,IAAIC,WAF9B,QAGO,uBAHP;AAKA;AACA;AACA;;AACA,SAASC,qBAAqB,IAAI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,EAA+B;AAAA;;AAC9B,+BAAAJ,GAAG,CAACS,OAAJ,CAAYC,UAAZ,gFAAwBC,YAAxB,CAAsCX,GAAG,CAACS,OAA1C,EAAmDT,GAAG,CAACS,OAAvD;AACA;AACD,GAzBD;;AA2BA,SAAOxC,QAAQ,CAAC2C,MAAT,CAAiB;AACvBC,IAAAA,GAAG,EACF,8BACC,cAAC,WAAD;AACC,MAAA,KAAK,EAAG7C,EAAE,CAAE,eAAF,CADX;AAEC,MAAA,oBAAoB,EAAC,MAFtB;AAGC,MAAA,GAAG,EAAG,CAHP;AAIC,MAAA,QAAQ,EAAGiC,QAJZ;AAKC,MAAA,KAAK,EAAGH,KALT;AAMC,MAAA,KAAK,EAAGX,KAAH,aAAGA,KAAH,yCAAGA,KAAK,CAAEC,OAAV,mDAAG,eAAgBL;AANzB,MADD,CAFsB;AAavB+B,IAAAA,MAAM,EAAE;AAbe,GAAjB,CAAP;AAeA","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { __ } from '@wordpress/i18n';\nimport { Platform } from '@wordpress/element';\nimport { getBlockSupport } from '@wordpress/blocks';\nimport {\n\t__experimentalUseCustomUnits as useCustomUnits,\n\t__experimentalUnitControl as UnitControl,\n} from '@wordpress/components';\n\n/**\n * Internal dependencies\n */\nimport { __unstableUseBlockRef as useBlockRef } from '../components/block-list/use-block-props/use-block-refs';\nimport useSetting from '../components/use-setting';\nimport { SPACING_SUPPORT_KEY } from './dimensions';\nimport { cleanEmptyObject } from './utils';\n\n/**\n * Determines if there is gap support.\n *\n * @param {string|Object} blockType Block name or Block Type object.\n * @return {boolean} Whether there is support.\n */\nexport function hasGapSupport( blockType ) {\n\tconst support = getBlockSupport( blockType, SPACING_SUPPORT_KEY );\n\treturn !! ( true === support || support?.blockGap );\n}\n\n/**\n * Checks if there is a current value in the gap block support attributes.\n *\n * @param {Object} props Block props.\n * @return {boolean} Whether or not the block has a gap value set.\n */\nexport function hasGapValue( props ) {\n\treturn props.attributes.style?.spacing?.blockGap !== undefined;\n}\n\n/**\n * Resets the gap block support attribute. This can be used when disabling\n * the gap support controls for a block via a progressive discovery panel.\n *\n * @param {Object} props Block props.\n * @param {Object} props.attributes Block's attributes.\n * @param {Object} props.setAttributes Function to set block's attributes.\n */\nexport function resetGap( { attributes = {}, setAttributes } ) {\n\tconst { style } = attributes;\n\n\tsetAttributes( {\n\t\tstyle: {\n\t\t\t...style,\n\t\t\tspacing: {\n\t\t\t\t...style?.spacing,\n\t\t\t\tblockGap: undefined,\n\t\t\t},\n\t\t},\n\t} );\n}\n\n/**\n * Custom hook that checks if gap settings have been disabled.\n *\n * @param {string} name The name of the block.\n * @return {boolean} Whether the gap setting is disabled.\n */\nexport function useIsGapDisabled( { name: blockName } = {} ) {\n\tconst isDisabled = ! useSetting( 'spacing.blockGap' );\n\treturn ! hasGapSupport( blockName ) || isDisabled;\n}\n\n/**\n * Inspector control panel containing the gap related configuration\n *\n * @param {Object} props\n *\n * @return {WPElement} Gap edit element.\n */\nexport function GapEdit( props ) {\n\tconst {\n\t\tclientId,\n\t\tattributes: { style },\n\t\tsetAttributes,\n\t} = props;\n\n\tconst units = useCustomUnits( {\n\t\tavailableUnits: useSetting( 'spacing.units' ) || [\n\t\t\t'%',\n\t\t\t'px',\n\t\t\t'em',\n\t\t\t'rem',\n\t\t\t'vw',\n\t\t],\n\t} );\n\n\tconst ref = useBlockRef( clientId );\n\n\tif ( useIsGapDisabled( props ) ) {\n\t\treturn null;\n\t}\n\n\tconst onChange = ( next ) => {\n\t\tconst newStyle = {\n\t\t\t...style,\n\t\t\tspacing: {\n\t\t\t\t...style?.spacing,\n\t\t\t\tblockGap: next,\n\t\t\t},\n\t\t};\n\n\t\tsetAttributes( {\n\t\t\tstyle: cleanEmptyObject( newStyle ),\n\t\t} );\n\n\t\t// In Safari, changing the `gap` CSS value on its own will not trigger the layout\n\t\t// to be recalculated / re-rendered. To force the updated gap to re-render, here\n\t\t// we replace the block's node with itself.\n\t\tconst isSafari =\n\t\t\twindow?.navigator.userAgent &&\n\t\t\twindow.navigator.userAgent.includes( 'Safari' ) &&\n\t\t\t! window.navigator.userAgent.includes( 'Chrome ' ) &&\n\t\t\t! window.navigator.userAgent.includes( 'Chromium ' );\n\n\t\tif ( ref.current && isSafari ) {\n\t\t\tref.current.parentNode?.replaceChild( ref.current, ref.current );\n\t\t}\n\t};\n\n\treturn Platform.select( {\n\t\tweb: (\n\t\t\t<>\n\t\t\t\t<UnitControl\n\t\t\t\t\tlabel={ __( 'Block spacing' ) }\n\t\t\t\t\t__unstableInputWidth=\"80px\"\n\t\t\t\t\tmin={ 0 }\n\t\t\t\t\tonChange={ onChange }\n\t\t\t\t\tunits={ units }\n\t\t\t\t\tvalue={ style?.spacing?.blockGap }\n\t\t\t\t/>\n\t\t\t</>\n\t\t),\n\t\tnative: null,\n\t} );\n}\n"]}
1
+ {"version":3,"sources":["@wordpress/block-editor/src/hooks/gap.js"],"names":["__","Platform","getBlockSupport","__experimentalUseCustomUnits","useCustomUnits","__experimentalBoxControl","BoxControl","__experimentalUnitControl","UnitControl","__unstableUseBlockRef","useBlockRef","useSetting","AXIAL_SIDES","SPACING_SUPPORT_KEY","useCustomSides","cleanEmptyObject","hasGapSupport","blockType","support","blockGap","hasGapValue","props","attributes","style","spacing","undefined","getGapBoxControlValueFromStyle","blockGapValue","isValueString","top","left","getGapCSSValue","defaultValue","blockGapBoxControlValue","row","column","resetGap","setAttributes","useIsGapDisabled","name","blockName","isDisabled","GapEdit","clientId","units","availableUnits","sides","ref","splitOnAxis","some","side","includes","onChange","next","newStyle","isSafari","window","navigator","userAgent","current","parentNode","replaceChild","gapValue","boxControlGapValue","right","bottom","select","web","native"],"mappings":";;AAAA;AACA;AACA;AACA,SAASA,EAAT,QAAmB,iBAAnB;AACA,SAASC,QAAT,QAAyB,oBAAzB;AACA,SAASC,eAAT,QAAgC,mBAAhC;AACA,SACCC,4BAA4B,IAAIC,cADjC,EAECC,wBAAwB,IAAIC,UAF7B,EAGCC,yBAAyB,IAAI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AC,WAAD;AACC,MAAA,KAAK,EAAGhD,EAAE,CAAE,eAAF,CADX;AAEC,MAAA,oBAAoB,EAAC,MAFtB;AAGC,MAAA,GAAG,EAAG,CAHP;AAIC,MAAA,QAAQ,EAAGoD,QAJZ;AAKC,MAAA,KAAK,EAAGR,KALT,CAMC;AAND;AAOC,MAAA,KAAK,EAAGmB;AAPT,MAbF,CAFsB;AA2BvBK,IAAAA,MAAM,EAAE;AA3Be,GAAjB,CAAP;AA6BA","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { __ } from '@wordpress/i18n';\nimport { Platform } from '@wordpress/element';\nimport { getBlockSupport } from '@wordpress/blocks';\nimport {\n\t__experimentalUseCustomUnits as useCustomUnits,\n\t__experimentalBoxControl as BoxControl,\n\t__experimentalUnitControl as UnitControl,\n} from '@wordpress/components';\n\n/**\n * Internal dependencies\n */\nimport { __unstableUseBlockRef as useBlockRef } from '../components/block-list/use-block-props/use-block-refs';\nimport useSetting from '../components/use-setting';\nimport { AXIAL_SIDES, SPACING_SUPPORT_KEY, useCustomSides } from './dimensions';\nimport { cleanEmptyObject } from './utils';\n\n/**\n * Determines if there is gap support.\n *\n * @param {string|Object} blockType Block name or Block Type object.\n * @return {boolean} Whether there is support.\n */\nexport function hasGapSupport( blockType ) {\n\tconst support = getBlockSupport( blockType, SPACING_SUPPORT_KEY );\n\treturn !! ( true === support || support?.blockGap );\n}\n\n/**\n * Checks if there is a current value in the gap block support attributes.\n *\n * @param {Object} props Block props.\n * @return {boolean} Whether or not the block has a gap value set.\n */\nexport function hasGapValue( props ) {\n\treturn props.attributes.style?.spacing?.blockGap !== undefined;\n}\n\n/**\n * Returns a BoxControl object value from a given blockGap style value.\n * The string check is for backwards compatibility before Gutenberg supported\n * split gap values (row and column) and the value was a string n + unit.\n *\n * @param {string? | Object?} blockGapValue A block gap string or axial object value, e.g., '10px' or { top: '10px', left: '10px'}.\n * @return {Object|null} A value to pass to the BoxControl component.\n */\nexport function getGapBoxControlValueFromStyle( blockGapValue ) {\n\tif ( ! blockGapValue ) {\n\t\treturn null;\n\t}\n\n\tconst isValueString = typeof blockGapValue === 'string';\n\treturn {\n\t\ttop: isValueString ? blockGapValue : blockGapValue?.top,\n\t\tleft: isValueString ? blockGapValue : blockGapValue?.left,\n\t};\n}\n\n/**\n * Returns a CSS value for the `gap` property from a given blockGap style.\n *\n * @param {string? | Object?} blockGapValue A block gap string or axial object value, e.g., '10px' or { top: '10px', left: '10px'}.\n * @param {string?} defaultValue A default gap value.\n * @return {string|null} The concatenated gap value (row and column).\n */\nexport function getGapCSSValue( blockGapValue, defaultValue = '0' ) {\n\tconst blockGapBoxControlValue = getGapBoxControlValueFromStyle(\n\t\tblockGapValue\n\t);\n\tif ( ! blockGapBoxControlValue ) {\n\t\treturn null;\n\t}\n\n\tconst row = blockGapBoxControlValue?.top || defaultValue;\n\tconst column = blockGapBoxControlValue?.left || defaultValue;\n\n\treturn row === column ? row : `${ row } ${ column }`;\n}\n\n/**\n * Resets the gap block support attribute. This can be used when disabling\n * the gap support controls for a block via a progressive discovery panel.\n *\n * @param {Object} props Block props.\n * @param {Object} props.attributes Block's attributes.\n * @param {Object} props.setAttributes Function to set block's attributes.\n */\nexport function resetGap( { attributes = {}, setAttributes } ) {\n\tconst { style } = attributes;\n\n\tsetAttributes( {\n\t\tstyle: {\n\t\t\t...style,\n\t\t\tspacing: {\n\t\t\t\t...style?.spacing,\n\t\t\t\tblockGap: undefined,\n\t\t\t},\n\t\t},\n\t} );\n}\n\n/**\n * Custom hook that checks if gap settings have been disabled.\n *\n * @param {string} name The name of the block.\n * @return {boolean} Whether the gap setting is disabled.\n */\nexport function useIsGapDisabled( { name: blockName } = {} ) {\n\tconst isDisabled = ! useSetting( 'spacing.blockGap' );\n\treturn ! hasGapSupport( blockName ) || isDisabled;\n}\n\n/**\n * Inspector control panel containing the gap related configuration\n *\n * @param {Object} props\n *\n * @return {WPElement} Gap edit element.\n */\nexport function GapEdit( props ) {\n\tconst {\n\t\tclientId,\n\t\tattributes: { style },\n\t\tname: blockName,\n\t\tsetAttributes,\n\t} = props;\n\n\tconst units = useCustomUnits( {\n\t\tavailableUnits: useSetting( 'spacing.units' ) || [\n\t\t\t'%',\n\t\t\t'px',\n\t\t\t'em',\n\t\t\t'rem',\n\t\t\t'vw',\n\t\t],\n\t} );\n\tconst sides = useCustomSides( blockName, 'blockGap' );\n\tconst ref = useBlockRef( clientId );\n\n\tif ( useIsGapDisabled( props ) ) {\n\t\treturn null;\n\t}\n\n\tconst splitOnAxis =\n\t\tsides && sides.some( ( side ) => AXIAL_SIDES.includes( side ) );\n\n\tconst onChange = ( next ) => {\n\t\tlet blockGap = next;\n\n\t\t// If splitOnAxis activated we need to return a BoxControl object to the BoxControl component.\n\t\tif ( !! next && splitOnAxis ) {\n\t\t\tblockGap = { ...getGapBoxControlValueFromStyle( next ) };\n\t\t}\n\n\t\tconst newStyle = {\n\t\t\t...style,\n\t\t\tspacing: {\n\t\t\t\t...style?.spacing,\n\t\t\t\tblockGap,\n\t\t\t},\n\t\t};\n\n\t\tsetAttributes( {\n\t\t\tstyle: cleanEmptyObject( newStyle ),\n\t\t} );\n\n\t\t// In Safari, changing the `gap` CSS value on its own will not trigger the layout\n\t\t// to be recalculated / re-rendered. To force the updated gap to re-render, here\n\t\t// we replace the block's node with itself.\n\t\tconst isSafari =\n\t\t\twindow?.navigator.userAgent &&\n\t\t\twindow.navigator.userAgent.includes( 'Safari' ) &&\n\t\t\t! window.navigator.userAgent.includes( 'Chrome ' ) &&\n\t\t\t! window.navigator.userAgent.includes( 'Chromium ' );\n\n\t\tif ( ref.current && isSafari ) {\n\t\t\tref.current.parentNode?.replaceChild( ref.current, ref.current );\n\t\t}\n\t};\n\n\tconst gapValue = getGapBoxControlValueFromStyle( style?.spacing?.blockGap );\n\n\t// The BoxControl component expects a full complement of side values.\n\t// Gap row and column values translate to top/bottom and left/right respectively.\n\tconst boxControlGapValue = splitOnAxis\n\t\t? {\n\t\t\t\t...gapValue,\n\t\t\t\tright: gapValue?.left,\n\t\t\t\tbottom: gapValue?.top,\n\t\t }\n\t\t: gapValue?.top;\n\n\treturn Platform.select( {\n\t\tweb: (\n\t\t\t<>\n\t\t\t\t{ splitOnAxis ? (\n\t\t\t\t\t<BoxControl\n\t\t\t\t\t\tlabel={ __( 'Block spacing' ) }\n\t\t\t\t\t\tmin={ 0 }\n\t\t\t\t\t\tonChange={ onChange }\n\t\t\t\t\t\tunits={ units }\n\t\t\t\t\t\tsides={ sides }\n\t\t\t\t\t\tvalues={ boxControlGapValue }\n\t\t\t\t\t\tallowReset={ false }\n\t\t\t\t\t\tsplitOnAxis={ splitOnAxis }\n\t\t\t\t\t/>\n\t\t\t\t) : (\n\t\t\t\t\t<UnitControl\n\t\t\t\t\t\tlabel={ __( 'Block spacing' ) }\n\t\t\t\t\t\t__unstableInputWidth=\"80px\"\n\t\t\t\t\t\tmin={ 0 }\n\t\t\t\t\t\tonChange={ onChange }\n\t\t\t\t\t\tunits={ units }\n\t\t\t\t\t\t// Default to `row` for combined values.\n\t\t\t\t\t\tvalue={ boxControlGapValue }\n\t\t\t\t\t/>\n\t\t\t\t) }\n\t\t\t</>\n\t\t),\n\t\tnative: null,\n\t} );\n}\n"]}
@@ -55,8 +55,12 @@ function LayoutPanel(_ref) {
55
55
 
56
56
  if (!allowEditing) {
57
57
  return null;
58
- }
58
+ } // Only show the inherit toggle if it's supported,
59
+ // a default theme layout is set (e.g. one that provides `contentSize` and/or `wideSize` values),
60
+ // and that the default / flow layout type is in use, as this is the only one that supports inheritance.
61
+
59
62
 
63
+ 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));
60
64
  const usedLayout = layout || defaultBlockLayout || {};
61
65
  const {
62
66
  inherit = false,
@@ -86,7 +90,7 @@ function LayoutPanel(_ref) {
86
90
 
87
91
  return createElement(Fragment, null, createElement(InspectorControls, null, createElement(PanelBody, {
88
92
  title: __('Layout')
89
- }, allowInheriting && !!defaultThemeLayout && createElement(ToggleControl, {
93
+ }, showInheritToggle && createElement(ToggleControl, {
90
94
  label: __('Inherit default layout'),
91
95
  checked: !!inherit,
92
96
  onChange: () => setAttributes({
@@ -196,6 +200,7 @@ export const withLayoutStyles = createHigherOrderComponent(BlockListBlock => pro
196
200
  [`wp-container-${id}`]: shouldRenderLayoutStyles
197
201
  });
198
202
  return createElement(Fragment, null, shouldRenderLayoutStyles && element && createPortal(createElement(LayoutStyle, {
203
+ blockName: name,
199
204
  selector: `.wp-container-${id}`,
200
205
  layout: usedLayout,
201
206
  style: attributes === null || attributes === void 0 ? void 0 : attributes.style
@@ -1 +1 @@
1
- {"version":3,"sources":["@wordpress/block-editor/src/hooks/layout.js"],"names":["classnames","has","createHigherOrderComponent","useInstanceId","addFilter","getBlockSupport","hasBlockSupport","useSelect","Button","ButtonGroup","ToggleControl","PanelBody","__","useContext","createPortal","store","blockEditorStore","InspectorControls","useSetting","LayoutStyle","BlockList","getLayoutType","getLayoutTypes","layoutBlockSupportKey","LayoutPanel","setAttributes","attributes","name","blockName","layout","defaultThemeLayout","themeSupportsLayout","select","getSettings","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","__unstableElementContext","className","style"],"mappings":";;;AAAA;AACA;AACA;AACA,OAAOA,UAAP,MAAuB,YAAvB;AACA,SAASC,GAAT,QAAoB,QAApB;AAEA;AACA;AACA;;AACA,SAASC,0BAAT,EAAqCC,aAArC,QAA0D,oBAA1D;AACA,SAASC,SAAT,QAA0B,kBAA1B;AACA,SAASC,eAAT,EAA0BC,eAA1B,QAAiD,mBAAjD;AACA,SAASC,SAAT,QAA0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,IAAA,MAAM,EAAGrB,UAFV;AAGC,IAAA,KAAK,EAAGf,UAAH,aAAGA,UAAH,uBAAGA,UAAU,CAAEwC;AAHrB,IADW,EAMXH,OANW,CAHd,EAWC,cAAC,cAAD,eAAqBN,KAArB;AAA6B,IAAA,SAAS,EAAGQ;AAAzC,KAXD,CADD;AAeA,CAnCwD,CAAnD;AAsCP7D,SAAS,CACR,0BADQ,EAER,0BAFQ,EAGRiD,YAHQ,CAAT;AAKAjD,SAAS,CACR,uBADQ,EAER,uCAFQ,EAGRuD,gBAHQ,CAAT;AAKAvD,SAAS,CACR,kBADQ,EAER,4CAFQ,EAGRmD,qBAHQ,CAAT","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":["classnames","has","createHigherOrderComponent","useInstanceId","addFilter","getBlockSupport","hasBlockSupport","useSelect","Button","ButtonGroup","ToggleControl","PanelBody","__","useContext","createPortal","store","blockEditorStore","InspectorControls","useSetting","LayoutStyle","BlockList","getLayoutType","getLayoutTypes","layoutBlockSupportKey","LayoutPanel","setAttributes","attributes","name","blockName","layout","defaultThemeLayout","themeSupportsLayout","select","getSettings","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","__unstableElementContext","className","style"],"mappings":";;;AAAA;AACA;AACA;AACA,OAAOA,UAAP,MAAuB,YAAvB;AACA,SAASC,GAAT,QAAoB,QAApB;AAEA;AACA;AACA;;AACA,SAASC,0BAAT,EAAqCC,aAArC,QAA0D,oBAA1D;AACA,SAASC,SAAT,QAA0B,kBAA1B;AACA,SAASC,eAAT,EAA0BC,eAA1B,QAAiD,mBAAjD;AACA,SAASC,SAAT,QAA0B,iBAA1B;AACA,SACCC,MADD,EAECC,WAFD,EAGCC,aAHD,EAICC,SAJD,QAKO,uBALP;AAMA,SAASC,EAAT,QAAmB,iBAAnB;AACA,SAASC,UAAT,EAAqBC,YAArB,QAAyC,oBAAzC;AAEA;AACA;AACA;;AACA,SAASC,KAAK,IAAIC,gBAAlB,QAA0C,UAA1C;AACA,SAASC,iBAAT,QAAkC,eAAlC;AACA,OAAOC,UAAP,MAAuB,2BAAvB;AACA,SAASC,WAAT,QAA4B,iCAA5B;AACA,OAAOC,SAAP,MAAsB,0BAAtB;AACA,SAASC,aAAT,EAAwBC,cAAxB,QAA8C,YAA9C;AAEA,MAAMC,qBAAqB,GAAG,sBAA9B;;AAEA,SAASC,WAAT,OAAuE;AAAA,MA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N,KAArB;AAA6B,IAAA,SAAS,EAAGQ;AAAzC,KAZD,CADD;AAgBA,CApCwD,CAAnD;AAuCP9D,SAAS,CACR,0BADQ,EAER,0BAFQ,EAGRkD,YAHQ,CAAT;AAKAlD,SAAS,CACR,uBADQ,EAER,uCAFQ,EAGRwD,gBAHQ,CAAT;AAKAxD,SAAS,CACR,kBADQ,EAER,4CAFQ,EAGRoD,qBAHQ,CAAT","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"]}
@@ -25,6 +25,7 @@ import { COLOR_SUPPORT_KEY, ColorEdit } from './color';
25
25
  import { TypographyPanel, TYPOGRAPHY_SUPPORT_KEY, TYPOGRAPHY_SUPPORT_KEYS } from './typography';
26
26
  import { SPACING_SUPPORT_KEY, DimensionsPanel } from './dimensions';
27
27
  import useDisplayBlockControls from '../components/use-display-block-controls';
28
+ import { shouldSkipSerialization } from './utils';
28
29
  const styleSupportKeys = [...TYPOGRAPHY_SUPPORT_KEYS, BORDER_SUPPORT_KEY, COLOR_SUPPORT_KEY, SPACING_SUPPORT_KEY];
29
30
 
30
31
  const hasStyleSupport = blockType => styleSupportKeys.some(key => hasBlockSupport(blockType, key));
@@ -165,6 +166,21 @@ const skipSerializationPathsEdit = {
165
166
  const skipSerializationPathsSave = { ...skipSerializationPathsEdit,
166
167
  [`${SPACING_SUPPORT_KEY}`]: ['spacing.blockGap']
167
168
  };
169
+ /**
170
+ * A dictionary used to normalize feature names between support flags, style
171
+ * object properties and __experimentSkipSerialization configuration arrays.
172
+ *
173
+ * This allows not having to provide a migration for a support flag and possible
174
+ * backwards compatibility bridges, while still achieving consistency between
175
+ * the support flag and the skip serialization array.
176
+ *
177
+ * @constant
178
+ * @type {Record<string, string>}
179
+ */
180
+
181
+ const renamedFeatures = {
182
+ gradients: 'gradient'
183
+ };
168
184
  /**
169
185
  * Override props assigned to save component to inject the CSS variables definition.
170
186
  *
@@ -187,9 +203,18 @@ export function addSaveProps(props, blockType, attributes) {
187
203
  style
188
204
  } = attributes;
189
205
  forEach(skipPaths, (path, indicator) => {
190
- if (getBlockSupport(blockType, indicator)) {
206
+ const skipSerialization = getBlockSupport(blockType, indicator);
207
+
208
+ if (skipSerialization === true) {
191
209
  style = omit(style, path);
192
210
  }
211
+
212
+ if (Array.isArray(skipSerialization)) {
213
+ skipSerialization.forEach(featureName => {
214
+ const feature = renamedFeatures[featureName] || featureName;
215
+ style = omit(style, [[...path, feature]]);
216
+ });
217
+ }
193
218
  });
194
219
  props.style = { ...getInlineStyles(style),
195
220
  ...props.style
@@ -247,9 +272,14 @@ export const withBlockControls = createHigherOrderComponent(BlockEdit => props =
247
272
  const withElementsStyles = createHigherOrderComponent(BlockListBlock => props => {
248
273
  var _props$attributes$sty, _props$attributes$sty2;
249
274
 
250
- const elements = (_props$attributes$sty = props.attributes.style) === null || _props$attributes$sty === void 0 ? void 0 : _props$attributes$sty.elements;
251
275
  const blockElementsContainerIdentifier = `wp-elements-${useInstanceId(BlockListBlock)}`;
252
- const styles = compileElementsStyles(blockElementsContainerIdentifier, (_props$attributes$sty2 = props.attributes.style) === null || _props$attributes$sty2 === void 0 ? void 0 : _props$attributes$sty2.elements);
276
+ const skipLinkColorSerialization = shouldSkipSerialization(props.name, COLOR_SUPPORT_KEY, 'link'); // The Elements API only supports link colors for now,
277
+ // hence the specific omission of `link` in the elements styles.
278
+ // This might need to be refactored or removed if the Elements API
279
+ // changes or `link` supports styles beyond `color`.
280
+
281
+ const elements = skipLinkColorSerialization ? 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;
282
+ const styles = compileElementsStyles(blockElementsContainerIdentifier, elements);
253
283
  const element = useContext(BlockList.__unstableElementContext);
254
284
  return createElement(Fragment, null, elements && element && createPortal(createElement("style", {
255
285
  dangerouslySetInnerHTML: {
@@ -1 +1 @@
1
- {"version":3,"sources":["@wordpress/block-editor/src/hooks/style.js"],"names":["first","forEach","get","has","isEmpty","isString","kebabCase","map","omit","startsWith","classnames","useContext","createPortal","addFilter","getBlockSupport","hasBlockSupport","__EXPERIMENTAL_STYLE_PROPERTY","STYLE_PROPERTY","__EXPERIMENTAL_ELEMENTS","ELEMENTS","createHigherOrderComponent","useInstanceId","getCSSRules","BlockList","BORDER_SUPPORT_KEY","BorderPanel","COLOR_SUPPORT_KEY","ColorEdit","TypographyPanel","TYPOGRAPHY_SUPPORT_KEY","TYPOGRAPHY_SUPPORT_KEYS","SPACING_SUPPORT_KEY","DimensionsPanel","useDisplayBlockControls","styleSupportKeys","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","propKey","path","value","subPaths","properties","styleValue","useEngine","entries","entry","name","subPath","includes","extraRules","selector","rule","compileElementsStyles","elements","element","elementStyles","property","addAttribute","settings","attributes","style","assign","type","skipSerializationPathsEdit","skipSerializationPathsSave","addSaveProps","props","skipPaths","indicator","addEditProps","existingGetEditWrapperProps","getEditWrapperProps","withBlockControls","BlockEdit","shouldDisplayControls","withElementsStyles","BlockListBlock","blockElementsContainerIdentifier","__unstableElementContext","__html","className"],"mappings":";;;AAAA;AACA;AACA;AACA,SACCA,KADD,EAECC,OAFD,EAGCC,GAHD,EAICC,GAJD,EAKCC,OALD,EAMCC,QAND,EAOCC,SAPD,EAQCC,GARD,EASCC,IATD,EAUCC,UAVD,QAWO,QAXP;AAYA,OAAOC,UAAP,MAAuB,YAAvB;AAEA;AACA;AACA;;AACA,SAASC,UAAT,EAAqBC,YAArB,QAAyC,oBAAzC;AACA,SAASC,SAAT,QAA0B,kBAA1B;AACA,SACCC,eADD,EAECC,eAFD,EAGCC,6BAA6B,IAAIC,cAHlC,EAICC,uBAAuB,IAAIC,QAJ5B,QAKO,mBALP;AAMA,SAASC,0BAAT,EAAqCC,aAArC,QAA0D,oBAA1D;AACA,SAASC,WAAT,QAA4B,yBAA5B;AAEA;AACA;AACA;;AACA,OAAOC,SAAP,MAAsB,0BAAtB;AACA,SAASC,kBAAT,EAA6BC,WAA7B,QAAgD,UAAhD;AACA,SAASC,iBAAT,EAA4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,IACTC,OADC,IAED5D,YAAY,CACX;AACC,IAAA,uBAAuB,EAAG;AACzBqF,MAAAA,MAAM,EAAE/C;AADiB;AAD3B,IADW,EAMXsB,OANW,CAHd,EAYC,cAAC,cAAD,eACMY,KADN;AAEC,IAAA,SAAS,EACRb,QAAQ,GACL7D,UAAU,CACV0E,KAAK,CAACc,SADI,EAEVH,gCAFU,CADL,GAKLX,KAAK,CAACc;AARX,KAZD,CADD;AA0BA,CAvCmD,CAArD;AA0CArF,SAAS,CACR,0BADQ,EAER,yBAFQ,EAGR8D,YAHQ,CAAT;AAMA9D,SAAS,CACR,kCADQ,EAER,yBAFQ,EAGRsE,YAHQ,CAAT;AAMAtE,SAAS,CACR,0BADQ,EAER,yBAFQ,EAGR0E,YAHQ,CAAT;AAMA1E,SAAS,CACR,kBADQ,EAER,gCAFQ,EAGR6E,iBAHQ,CAAT;AAMA7E,SAAS,CACR,uBADQ,EAER,kCAFQ,EAGRgF,kBAHQ,CAAT","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":["first","forEach","get","has","isEmpty","isString","kebabCase","map","omit","startsWith","classnames","useContext","createPortal","addFilter","getBlockSupport","hasBlockSupport","__EXPERIMENTAL_STYLE_PROPERTY","STYLE_PROPERTY","__EXPERIMENTAL_ELEMENTS","ELEMENTS","createHigherOrderComponent","useInstanceId","getCSSRules","BlockList","BORDER_SUPPORT_KEY","BorderPanel","COLOR_SUPPORT_KEY","ColorEdit","TypographyPanel","TYPOGRAPHY_SUPPORT_KEY","TYPOGRAPHY_SUPPORT_KEYS","SPACING_SUPPORT_KEY","DimensionsPanel","useDisplayBlockControls","shouldSkipSerialization","styleSupportKeys","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","propKey","path","value","subPaths","properties","styleValue","useEngine","entries","entry","name","subPath","includes","extraRules","selector","rule","compileElementsStyles","elements","element","elementStyles","property","addAttribute","settings","attributes","style","assign","type","skipSerializationPathsEdit","skipSerializationPathsSave","renamedFeatures","gradients","addSaveProps","props","skipPaths","indicator","skipSerialization","Array","isArray","featureName","feature","addEditProps","existingGetEditWrapperProps","getEditWrapperProps","withBlockControls","BlockEdit","shouldDisplayControls","withElementsStyles","BlockListBlock","blockElementsContainerIdentifier","skipLinkColorSerialization","__unstableElementContext","__html","className"],"mappings":";;;AAAA;AACA;AACA;AACA,SACCA,KADD,EAECC,OAFD,EAGCC,GAHD,EAICC,GAJD,EAKCC,OALD,EAMCC,QAND,EAOCC,SAPD,EAQCC,GARD,EASCC,IATD,EAUCC,UAVD,QAWO,QAXP;AAYA,OAAOC,UAAP,MAAuB,YAAvB;AAEA;AACA;AACA;;AACA,SAASC,UAAT,EAAqBC,YAArB,QAAyC,oBAAzC;AACA,SAASC,SAAT,QAA0B,kBAA1B;AACA,SACCC,eADD,EAECC,e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oB,SADI,EAEVJ,gCAFU,CADL,GAKLhB,KAAK,CAACoB;AARX,KAZD,CADD;AA0BA,CApDmD,CAArD;AAuDA9F,SAAS,CACR,0BADQ,EAER,yBAFQ,EAGR+D,YAHQ,CAAT;AAMA/D,SAAS,CACR,kCADQ,EAER,yBAFQ,EAGRyE,YAHQ,CAAT;AAMAzE,SAAS,CACR,0BADQ,EAER,yBAFQ,EAGRkF,YAHQ,CAAT;AAMAlF,SAAS,CACR,kBADQ,EAER,gCAFQ,EAGRqF,iBAHQ,CAAT;AAMArF,SAAS,CACR,uBADQ,EAER,kCAFQ,EAGRwF,kBAHQ,CAAT","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"]}
@@ -2,6 +2,11 @@
2
2
  * External dependencies
3
3
  */
4
4
  import { pickBy, isEmpty, isObject, identity, mapValues, forEach, get, setWith, clone, every } from 'lodash';
5
+ /**
6
+ * WordPress dependencies
7
+ */
8
+
9
+ import { getBlockSupport } from '@wordpress/blocks';
5
10
  /**
6
11
  * Removed falsy values from nested object.
7
12
  *
@@ -68,4 +73,25 @@ export function transformStyles(activeSupports, migrationPaths, result, source,
68
73
  });
69
74
  return returnBlock;
70
75
  }
76
+ /**
77
+ * Check whether serialization of specific block support feature or set should
78
+ * be skipped.
79
+ *
80
+ * @param {string|Object} blockType Block name or block type object.
81
+ * @param {string} featureSet Name of block support feature set.
82
+ * @param {string} feature Name of the individual feature to check.
83
+ *
84
+ * @return {boolean} Whether serialization should occur.
85
+ */
86
+
87
+ export function shouldSkipSerialization(blockType, featureSet, feature) {
88
+ const support = getBlockSupport(blockType, featureSet);
89
+ const skipSerialization = support === null || support === void 0 ? void 0 : support.__experimentalSkipSerialization;
90
+
91
+ if (Array.isArray(skipSerialization)) {
92
+ return skipSerialization.includes(feature);
93
+ }
94
+
95
+ return skipSerialization;
96
+ }
71
97
  //# sourceMappingURL=utils.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["@wordpress/block-editor/src/hooks/utils.js"],"names":["pickBy","isEmpty","isObject","identity","mapValues","forEach","get","setWith","clone","every","cleanEmptyObject","object","Array","isArray","cleanedNestedObjects","undefined","immutableSet","path","value","transformStyles","activeSupports","migrationPaths","result","source","index","results","isActive","length","innerBlocks","referenceBlockAttributes","attributes","returnBlock","support","styleValue"],"mappings":"AAAA;AACA;AACA;AACA,SACCA,MADD,EAECC,OAFD,EAGCC,QAHD,EAICC,QAJD,EAKCC,SALD,EAMCC,OAND,EAOCC,GAPD,EAQCC,OARD,EASCC,KATD,EAUCC,KAVD,QAWO,QAXP;AAaA;AACA;AACA;AACA;AACA;AACA;;AACA,OAAO,MAAMC,gBAAgB,GAAKC,MAAF,IAAc;AAC7C,MAAK,CAAET,QAAQ,CAAES,MAAF,CAAV,IAAwBC,KAAK,CAACC,OAAN,CAAeF,MAAf,CAA7B,EAAuD;AACtD,WAAOA,MAAP;AACA;;AACD,QAAMG,oBAAoB,GAAGd,MAAM,CAClCI,SAAS,CAAEO,MAAF,EAAUD,gBAAV,CADyB,EAElCP,QAFkC,CAAnC;AAIA,SAAOF,OAAO,CAAEa,oBAAF,CAAP,GAAkCC,SAAlC,GAA8CD,oBAArD;AACA,CATM;AAWP,OAAO,SAASE,YAAT,CAAuBL,MAAvB,EAA+BM,IAA/B,EAAqCC,KAArC,EAA6C;AACnD,SAAOX,OAAO,CAAEI,MAAM,GAAGH,KAAK,CAAEG,MAAF,CAAR,GAAqB,EAA7B,EAAiCM,IAAjC,EAAuCC,KAAvC,EAA8CV,KAA9C,CAAd;AACA;AAED,OAAO,SAASW,eAAT,CACNC,cADM,EAENC,cAFM,EAGNC,MAHM,EAINC,MAJM,EAKNC,KALM,EAMNC,OANM,EAOL;AAAA;;AACD;AACA,MAAKhB,KAAK,CAAEW,cAAF,EAAoBM,QAAF,IAAgB,CAAEA,QAApC,CAAV,EAA2D;AAC1D,WAAOJ,MAAP;AACA,GAJA,CAKD;AACA;;;AACA,MAAKG,OAAO,CAACE,MAAR,KAAmB,CAAnB,IAAwBL,MAAM,CAACM,WAAP,CAAmBD,MAAnB,KAA8BJ,MAAM,CAACI,MAAlE,EAA2E;AAC1E,WAAOL,MAAP;AACA,GATA,CAUD;AACA;AACA;;;AACA,MAAIO,wBAAwB,eAAGN,MAAM,CAAE,CAAF,CAAT,6CAAG,SAAaO,UAA5C,CAbC,CAcD;AACA;AACA;AACA;;AACA,MAAKL,OAAO,CAACE,MAAR,GAAiB,CAAjB,IAAsBJ,MAAM,CAACI,MAAP,GAAgB,CAA3C,EAA+C;AAC9C,QAAKJ,MAAM,CAAEC,KAAF,CAAX,EAAuB;AAAA;;AACtBK,MAAAA,wBAAwB,oBAAGN,MAAM,CAAEC,KAAF,CAAT,kDAAG,cAAiBM,UAA5C;AACA,KAFD,MAEO;AACN,aAAOR,MAAP;AACA;AACD;;AACD,MAAIS,WAAW,GAAGT,MAAlB;AACAjB,EAAAA,OAAO,CAAEe,cAAF,EAAkB,CAAEM,QAAF,EAAYM,OAAZ,KAAyB;AACjD,QAAKN,QAAL,EAAgB;AACfL,MAAAA,cAAc,CAAEW,OAAF,CAAd,CAA0B3B,OAA1B,CAAqCY,IAAF,IAAY;AAC9C,cAAMgB,UAAU,GAAG3B,GAAG,CAAEuB,wBAAF,EAA4BZ,IAA5B,CAAtB;;AACA,YAAKgB,UAAL,EAAkB;AACjBF,UAAAA,WAAW,GAAG,EACb,GAAGA,WADU;AAEbD,YAAAA,UAAU,EAAEd,YAAY,CACvBe,WAAW,CAACD,UADW,EAEvBb,IAFuB,EAGvBgB,UAHuB;AAFX,WAAd;AAQA;AACD,OAZD;AAaA;AACD,GAhBM,CAAP;AAiBA,SAAOF,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":["pickBy","isEmpty","isObject","identity","mapValues","forEach","get","setWith","clone","every","getBlockSupport","cleanEmptyObject","object","Array","isArray","cleanedNestedObjects","undefined","immutableSet","path","value","transformStyles","activeSupports","migrationPaths","result","source","index","results","isActive","length","innerBlocks","referenceBlockAttributes","attributes","returnBlock","support","styleValue","shouldSkipSerialization","blockType","featureSet","feature","skipSerialization","__experimentalSkipSerialization","includes"],"mappings":"AAAA;AACA;AACA;AACA,SACCA,MADD,EAECC,OAFD,EAGCC,QAHD,EAICC,QAJD,EAKCC,SALD,EAMCC,OAND,EAOCC,GAPD,EAQCC,OARD,EASCC,KATD,EAUCC,KAVD,QAWO,QAXP;AAaA;AACA;AACA;;AACA,SAASC,eAAT,QAAgC,mBAAhC;AAEA;AACA;AACA;AACA;AACA;AACA;;AACA,OAAO,MAAMC,gBAAgB,GAAKC,MAAF,IAAc;AAC7C,MAAK,CAAEV,QAAQ,CAAEU,MAAF,CAAV,IAAwBC,KAAK,CAACC,OAAN,CAAeF,MAAf,CAA7B,EAAuD;AACtD,WAAOA,MAAP;AACA;;AACD,QAAMG,oBAAoB,GAAGf,MAAM,CAClCI,SAAS,CAAEQ,MAAF,EAAUD,gBAAV,CADyB,EAElCR,QAFkC,CAAnC;AAIA,SAAOF,OAAO,CAAEc,oBAAF,CAAP,GAAkCC,SAAlC,GAA8CD,oBAArD;AACA,CATM;AAWP,OAAO,SAASE,YAAT,CAAuBL,MAAvB,EAA+BM,IAA/B,EAAqCC,KAArC,EAA6C;AACnD,SAAOZ,OAAO,CAAEK,MAAM,GAAGJ,KAAK,CAAEI,MAAF,CAAR,GAAqB,EAA7B,EAAiCM,IAAjC,EAAuCC,KAAvC,EAA8CX,KAA9C,CAAd;AACA;AAED,OAAO,SAASY,eAAT,CACNC,cADM,EAENC,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D,GAhBM,CAAP;AAiBA,SAAOF,WAAP;AACA;AAED;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AACA,OAAO,SAASG,uBAAT,CAAkCC,SAAlC,EAA6CC,UAA7C,EAAyDC,OAAzD,EAAmE;AACzE,QAAML,OAAO,GAAGvB,eAAe,CAAE0B,SAAF,EAAaC,UAAb,CAA/B;AACA,QAAME,iBAAiB,GAAGN,OAAH,aAAGA,OAAH,uBAAGA,OAAO,CAAEO,+BAAnC;;AAEA,MAAK3B,KAAK,CAACC,OAAN,CAAeyB,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"]}