@wordpress/block-editor 10.3.0 → 10.5.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (460) hide show
  1. package/CHANGELOG.md +13 -0
  2. package/README.md +0 -1
  3. package/build/components/alignment-control/ui.js +1 -1
  4. package/build/components/alignment-control/ui.js.map +1 -1
  5. package/build/components/block-alignment-control/constants.js +1 -1
  6. package/build/components/block-alignment-control/constants.js.map +1 -1
  7. package/build/components/block-alignment-matrix-control/index.js +1 -1
  8. package/build/components/block-alignment-matrix-control/index.js.map +1 -1
  9. package/build/components/block-compare/index.js +1 -3
  10. package/build/components/block-compare/index.js.map +1 -1
  11. package/build/components/block-edit/index.js +4 -2
  12. package/build/components/block-edit/index.js.map +1 -1
  13. package/build/components/block-list/block.js +3 -1
  14. package/build/components/block-list/block.js.map +1 -1
  15. package/build/components/block-lock/menu-item.js +1 -1
  16. package/build/components/block-lock/menu-item.js.map +1 -1
  17. package/build/components/block-lock/modal.js +16 -9
  18. package/build/components/block-lock/modal.js.map +1 -1
  19. package/build/components/block-popover/inbetween.js +2 -1
  20. package/build/components/block-popover/inbetween.js.map +1 -1
  21. package/build/components/block-popover/index.js +2 -1
  22. package/build/components/block-popover/index.js.map +1 -1
  23. package/build/components/block-preview/index.js +2 -4
  24. package/build/components/block-preview/index.js.map +1 -1
  25. package/build/components/block-settings-menu/block-settings-dropdown.js +2 -8
  26. package/build/components/block-settings-menu/block-settings-dropdown.js.map +1 -1
  27. package/build/components/block-styles/utils.js +3 -3
  28. package/build/components/block-styles/utils.js.map +1 -1
  29. package/build/components/block-switcher/index.js +21 -12
  30. package/build/components/block-switcher/index.js.map +1 -1
  31. package/build/components/block-switcher/preview-block-popover.js +1 -1
  32. package/build/components/block-switcher/preview-block-popover.js.map +1 -1
  33. package/build/components/block-tools/insertion-point.js +12 -2
  34. package/build/components/block-tools/insertion-point.js.map +1 -1
  35. package/build/components/block-tools/selected-block-popover.js +27 -4
  36. package/build/components/block-tools/selected-block-popover.js.map +1 -1
  37. package/build/components/block-vertical-alignment-control/ui.js +1 -1
  38. package/build/components/block-vertical-alignment-control/ui.js.map +1 -1
  39. package/build/components/border-radius-control/all-input-control.js +2 -1
  40. package/build/components/border-radius-control/all-input-control.js.map +1 -1
  41. package/build/components/border-radius-control/index.js +2 -1
  42. package/build/components/border-radius-control/index.js.map +1 -1
  43. package/build/components/border-radius-control/input-controls.js +2 -1
  44. package/build/components/border-radius-control/input-controls.js.map +1 -1
  45. package/build/components/colors/with-colors.js +4 -3
  46. package/build/components/colors/with-colors.js.map +1 -1
  47. package/build/components/duotone-control/index.js +1 -1
  48. package/build/components/duotone-control/index.js.map +1 -1
  49. package/build/components/font-sizes/fluid-utils.js +24 -40
  50. package/build/components/font-sizes/fluid-utils.js.map +1 -1
  51. package/build/components/font-sizes/with-font-sizes.js +8 -6
  52. package/build/components/font-sizes/with-font-sizes.js.map +1 -1
  53. package/build/components/iframe/index.js +1 -1
  54. package/build/components/iframe/index.js.map +1 -1
  55. package/build/components/image-editor/constants.js +1 -1
  56. package/build/components/image-editor/constants.js.map +1 -1
  57. package/build/components/index.js +9 -0
  58. package/build/components/index.js.map +1 -1
  59. package/build/components/inner-blocks/index.js +10 -4
  60. package/build/components/inner-blocks/index.js.map +1 -1
  61. package/build/components/inserter/hooks/use-insertion-point.js +2 -7
  62. package/build/components/inserter/hooks/use-insertion-point.js.map +1 -1
  63. package/build/components/inserter/reusable-blocks-tab.js +4 -1
  64. package/build/components/inserter/reusable-blocks-tab.js.map +1 -1
  65. package/build/components/inserter/search-items.js +23 -2
  66. package/build/components/inserter/search-items.js.map +1 -1
  67. package/build/components/line-height-control/index.js +2 -1
  68. package/build/components/line-height-control/index.js.map +1 -1
  69. package/build/components/link-control/index.js +18 -34
  70. package/build/components/link-control/index.js.map +1 -1
  71. package/build/components/link-control/search-input.js +1 -1
  72. package/build/components/link-control/search-input.js.map +1 -1
  73. package/build/components/link-control/use-internal-input-value.js +26 -0
  74. package/build/components/link-control/use-internal-input-value.js.map +1 -0
  75. package/build/components/list-view/block.js +5 -3
  76. package/build/components/list-view/block.js.map +1 -1
  77. package/build/components/list-view/branch.js +9 -3
  78. package/build/components/list-view/branch.js.map +1 -1
  79. package/build/components/list-view/drop-indicator.js +2 -1
  80. package/build/components/list-view/drop-indicator.js.map +1 -1
  81. package/build/components/media-replace-flow/index.js +1 -1
  82. package/build/components/media-replace-flow/index.js.map +1 -1
  83. package/build/components/off-canvas-editor/block-contents.js +100 -0
  84. package/build/components/off-canvas-editor/block-contents.js.map +1 -0
  85. package/build/components/off-canvas-editor/block-select-button.js +119 -0
  86. package/build/components/off-canvas-editor/block-select-button.js.map +1 -0
  87. package/build/components/off-canvas-editor/block.js +292 -0
  88. package/build/components/off-canvas-editor/block.js.map +1 -0
  89. package/build/components/off-canvas-editor/branch.js +181 -0
  90. package/build/components/off-canvas-editor/branch.js.map +1 -0
  91. package/build/components/off-canvas-editor/context.js +19 -0
  92. package/build/components/off-canvas-editor/context.js.map +1 -0
  93. package/build/components/off-canvas-editor/drop-indicator.js +118 -0
  94. package/build/components/off-canvas-editor/drop-indicator.js.map +1 -0
  95. package/build/components/off-canvas-editor/expander.js +41 -0
  96. package/build/components/off-canvas-editor/expander.js.map +1 -0
  97. package/build/components/off-canvas-editor/index.js +204 -0
  98. package/build/components/off-canvas-editor/index.js.map +1 -0
  99. package/build/components/off-canvas-editor/leaf.js +60 -0
  100. package/build/components/off-canvas-editor/leaf.js.map +1 -0
  101. package/build/components/off-canvas-editor/use-block-selection.js +139 -0
  102. package/build/components/off-canvas-editor/use-block-selection.js.map +1 -0
  103. package/build/components/off-canvas-editor/use-list-view-client-ids.js +33 -0
  104. package/build/components/off-canvas-editor/use-list-view-client-ids.js.map +1 -0
  105. package/build/components/off-canvas-editor/use-list-view-drop-zone.js +235 -0
  106. package/build/components/off-canvas-editor/use-list-view-drop-zone.js.map +1 -0
  107. package/build/components/off-canvas-editor/use-list-view-expand-selected-item.js +60 -0
  108. package/build/components/off-canvas-editor/use-list-view-expand-selected-item.js.map +1 -0
  109. package/build/components/off-canvas-editor/utils.js +60 -0
  110. package/build/components/off-canvas-editor/utils.js.map +1 -0
  111. package/build/components/rich-text/format-toolbar/index.js +1 -1
  112. package/build/components/rich-text/format-toolbar/index.js.map +1 -1
  113. package/build/components/rich-text/format-toolbar-container.js +1 -1
  114. package/build/components/rich-text/format-toolbar-container.js.map +1 -1
  115. package/build/components/rich-text/use-paste-handler.js +1 -1
  116. package/build/components/rich-text/use-paste-handler.js.map +1 -1
  117. package/build/components/spacing-sizes-control/all-input-control.js +6 -2
  118. package/build/components/spacing-sizes-control/all-input-control.js.map +1 -1
  119. package/build/components/spacing-sizes-control/axial-input-controls.js +6 -2
  120. package/build/components/spacing-sizes-control/axial-input-controls.js.map +1 -1
  121. package/build/components/spacing-sizes-control/index.js +6 -2
  122. package/build/components/spacing-sizes-control/index.js.map +1 -1
  123. package/build/components/spacing-sizes-control/input-controls.js +6 -2
  124. package/build/components/spacing-sizes-control/input-controls.js.map +1 -1
  125. package/build/components/spacing-sizes-control/spacing-input-control.js +12 -5
  126. package/build/components/spacing-sizes-control/spacing-input-control.js.map +1 -1
  127. package/build/components/url-input/index.js +1 -1
  128. package/build/components/url-input/index.js.map +1 -1
  129. package/build/components/url-popover/index.js +31 -2
  130. package/build/components/url-popover/index.js.map +1 -1
  131. package/build/components/use-setting/index.js +1 -1
  132. package/build/components/use-setting/index.js.map +1 -1
  133. package/build/hooks/border.js +1 -0
  134. package/build/hooks/border.js.map +1 -1
  135. package/build/hooks/color-panel.js +17 -1
  136. package/build/hooks/color-panel.js.map +1 -1
  137. package/build/hooks/color.js +1 -1
  138. package/build/hooks/color.js.map +1 -1
  139. package/build/hooks/content-lock-ui.js +13 -6
  140. package/build/hooks/content-lock-ui.js.map +1 -1
  141. package/build/hooks/dimensions.js +72 -13
  142. package/build/hooks/dimensions.js.map +1 -1
  143. package/build/hooks/font-size.js +1 -0
  144. package/build/hooks/font-size.js.map +1 -1
  145. package/build/hooks/layout.js +5 -4
  146. package/build/hooks/layout.js.map +1 -1
  147. package/build/hooks/margin.js +26 -18
  148. package/build/hooks/margin.js.map +1 -1
  149. package/build/hooks/min-height.js +145 -0
  150. package/build/hooks/min-height.js.map +1 -0
  151. package/build/hooks/padding.js +22 -13
  152. package/build/hooks/padding.js.map +1 -1
  153. package/build/hooks/style.js +3 -2
  154. package/build/hooks/style.js.map +1 -1
  155. package/build/hooks/utils.js +7 -6
  156. package/build/hooks/utils.js.map +1 -1
  157. package/build/layouts/constrained.js +0 -1
  158. package/build/layouts/constrained.js.map +1 -1
  159. package/build/layouts/flex.js +23 -22
  160. package/build/layouts/flex.js.map +1 -1
  161. package/build/store/actions.js +30 -0
  162. package/build/store/actions.js.map +1 -1
  163. package/build/store/array.js +1 -7
  164. package/build/store/array.js.map +1 -1
  165. package/build/store/reducer.js +46 -14
  166. package/build/store/reducer.js.map +1 -1
  167. package/build/store/selectors.js +62 -31
  168. package/build/store/selectors.js.map +1 -1
  169. package/build-module/components/alignment-control/ui.js +1 -1
  170. package/build-module/components/alignment-control/ui.js.map +1 -1
  171. package/build-module/components/block-alignment-control/constants.js +1 -1
  172. package/build-module/components/block-alignment-control/constants.js.map +1 -1
  173. package/build-module/components/block-alignment-matrix-control/index.js +1 -1
  174. package/build-module/components/block-alignment-matrix-control/index.js.map +1 -1
  175. package/build-module/components/block-compare/index.js +2 -3
  176. package/build-module/components/block-compare/index.js.map +1 -1
  177. package/build-module/components/block-edit/index.js +4 -2
  178. package/build-module/components/block-edit/index.js.map +1 -1
  179. package/build-module/components/block-list/block.js +3 -1
  180. package/build-module/components/block-list/block.js.map +1 -1
  181. package/build-module/components/block-lock/menu-item.js +2 -2
  182. package/build-module/components/block-lock/menu-item.js.map +1 -1
  183. package/build-module/components/block-lock/modal.js +17 -10
  184. package/build-module/components/block-lock/modal.js.map +1 -1
  185. package/build-module/components/block-popover/inbetween.js +2 -1
  186. package/build-module/components/block-popover/inbetween.js.map +1 -1
  187. package/build-module/components/block-popover/index.js +2 -1
  188. package/build-module/components/block-popover/index.js.map +1 -1
  189. package/build-module/components/block-preview/index.js +2 -3
  190. package/build-module/components/block-preview/index.js.map +1 -1
  191. package/build-module/components/block-settings-menu/block-settings-dropdown.js +2 -7
  192. package/build-module/components/block-settings-menu/block-settings-dropdown.js.map +1 -1
  193. package/build-module/components/block-styles/utils.js +3 -3
  194. package/build-module/components/block-styles/utils.js.map +1 -1
  195. package/build-module/components/block-switcher/index.js +21 -11
  196. package/build-module/components/block-switcher/index.js.map +1 -1
  197. package/build-module/components/block-switcher/preview-block-popover.js +1 -1
  198. package/build-module/components/block-switcher/preview-block-popover.js.map +1 -1
  199. package/build-module/components/block-tools/insertion-point.js +12 -2
  200. package/build-module/components/block-tools/insertion-point.js.map +1 -1
  201. package/build-module/components/block-tools/selected-block-popover.js +27 -5
  202. package/build-module/components/block-tools/selected-block-popover.js.map +1 -1
  203. package/build-module/components/block-vertical-alignment-control/ui.js +1 -1
  204. package/build-module/components/block-vertical-alignment-control/ui.js.map +1 -1
  205. package/build-module/components/border-radius-control/all-input-control.js +2 -1
  206. package/build-module/components/border-radius-control/all-input-control.js.map +1 -1
  207. package/build-module/components/border-radius-control/index.js +2 -1
  208. package/build-module/components/border-radius-control/index.js.map +1 -1
  209. package/build-module/components/border-radius-control/input-controls.js +2 -1
  210. package/build-module/components/border-radius-control/input-controls.js.map +1 -1
  211. package/build-module/components/colors/with-colors.js +5 -4
  212. package/build-module/components/colors/with-colors.js.map +1 -1
  213. package/build-module/components/duotone-control/index.js +1 -1
  214. package/build-module/components/duotone-control/index.js.map +1 -1
  215. package/build-module/components/font-sizes/fluid-utils.js +24 -40
  216. package/build-module/components/font-sizes/fluid-utils.js.map +1 -1
  217. package/build-module/components/font-sizes/with-font-sizes.js +9 -7
  218. package/build-module/components/font-sizes/with-font-sizes.js.map +1 -1
  219. package/build-module/components/iframe/index.js +1 -1
  220. package/build-module/components/iframe/index.js.map +1 -1
  221. package/build-module/components/image-editor/constants.js +1 -1
  222. package/build-module/components/image-editor/constants.js.map +1 -1
  223. package/build-module/components/index.js +1 -0
  224. package/build-module/components/index.js.map +1 -1
  225. package/build-module/components/inner-blocks/index.js +10 -4
  226. package/build-module/components/inner-blocks/index.js.map +1 -1
  227. package/build-module/components/inserter/hooks/use-insertion-point.js +2 -6
  228. package/build-module/components/inserter/hooks/use-insertion-point.js.map +1 -1
  229. package/build-module/components/inserter/reusable-blocks-tab.js +3 -1
  230. package/build-module/components/inserter/reusable-blocks-tab.js.map +1 -1
  231. package/build-module/components/inserter/search-items.js +23 -3
  232. package/build-module/components/inserter/search-items.js.map +1 -1
  233. package/build-module/components/line-height-control/index.js +2 -1
  234. package/build-module/components/line-height-control/index.js.map +1 -1
  235. package/build-module/components/link-control/index.js +17 -34
  236. package/build-module/components/link-control/index.js.map +1 -1
  237. package/build-module/components/link-control/search-input.js +1 -1
  238. package/build-module/components/link-control/search-input.js.map +1 -1
  239. package/build-module/components/link-control/use-internal-input-value.js +18 -0
  240. package/build-module/components/link-control/use-internal-input-value.js.map +1 -0
  241. package/build-module/components/list-view/block.js +5 -3
  242. package/build-module/components/list-view/block.js.map +1 -1
  243. package/build-module/components/list-view/branch.js +9 -3
  244. package/build-module/components/list-view/branch.js.map +1 -1
  245. package/build-module/components/list-view/drop-indicator.js +2 -1
  246. package/build-module/components/list-view/drop-indicator.js.map +1 -1
  247. package/build-module/components/media-replace-flow/index.js +1 -1
  248. package/build-module/components/media-replace-flow/index.js.map +1 -1
  249. package/build-module/components/off-canvas-editor/block-contents.js +85 -0
  250. package/build-module/components/off-canvas-editor/block-contents.js.map +1 -0
  251. package/build-module/components/off-canvas-editor/block-select-button.js +101 -0
  252. package/build-module/components/off-canvas-editor/block-select-button.js.map +1 -0
  253. package/build-module/components/off-canvas-editor/block.js +268 -0
  254. package/build-module/components/off-canvas-editor/block.js.map +1 -0
  255. package/build-module/components/off-canvas-editor/branch.js +165 -0
  256. package/build-module/components/off-canvas-editor/branch.js.map +1 -0
  257. package/build-module/components/off-canvas-editor/context.js +7 -0
  258. package/build-module/components/off-canvas-editor/context.js.map +1 -0
  259. package/build-module/components/off-canvas-editor/drop-indicator.js +111 -0
  260. package/build-module/components/off-canvas-editor/drop-indicator.js.map +1 -0
  261. package/build-module/components/off-canvas-editor/expander.js +32 -0
  262. package/build-module/components/off-canvas-editor/expander.js.map +1 -0
  263. package/build-module/components/off-canvas-editor/index.js +181 -0
  264. package/build-module/components/off-canvas-editor/index.js.map +1 -0
  265. package/build-module/components/off-canvas-editor/leaf.js +45 -0
  266. package/build-module/components/off-canvas-editor/leaf.js.map +1 -0
  267. package/build-module/components/off-canvas-editor/use-block-selection.js +124 -0
  268. package/build-module/components/off-canvas-editor/use-block-selection.js.map +1 -0
  269. package/build-module/components/off-canvas-editor/use-list-view-client-ids.js +24 -0
  270. package/build-module/components/off-canvas-editor/use-list-view-client-ids.js.map +1 -0
  271. package/build-module/components/off-canvas-editor/use-list-view-drop-zone.js +220 -0
  272. package/build-module/components/off-canvas-editor/use-list-view-drop-zone.js.map +1 -0
  273. package/build-module/components/off-canvas-editor/use-list-view-expand-selected-item.js +50 -0
  274. package/build-module/components/off-canvas-editor/use-list-view-expand-selected-item.js.map +1 -0
  275. package/build-module/components/off-canvas-editor/utils.js +44 -0
  276. package/build-module/components/off-canvas-editor/utils.js.map +1 -0
  277. package/build-module/components/rich-text/format-toolbar/index.js +1 -1
  278. package/build-module/components/rich-text/format-toolbar/index.js.map +1 -1
  279. package/build-module/components/rich-text/format-toolbar-container.js +1 -1
  280. package/build-module/components/rich-text/format-toolbar-container.js.map +1 -1
  281. package/build-module/components/rich-text/use-paste-handler.js +1 -1
  282. package/build-module/components/rich-text/use-paste-handler.js.map +1 -1
  283. package/build-module/components/spacing-sizes-control/all-input-control.js +6 -2
  284. package/build-module/components/spacing-sizes-control/all-input-control.js.map +1 -1
  285. package/build-module/components/spacing-sizes-control/axial-input-controls.js +6 -2
  286. package/build-module/components/spacing-sizes-control/axial-input-controls.js.map +1 -1
  287. package/build-module/components/spacing-sizes-control/index.js +6 -2
  288. package/build-module/components/spacing-sizes-control/index.js.map +1 -1
  289. package/build-module/components/spacing-sizes-control/input-controls.js +6 -2
  290. package/build-module/components/spacing-sizes-control/input-controls.js.map +1 -1
  291. package/build-module/components/spacing-sizes-control/spacing-input-control.js +12 -5
  292. package/build-module/components/spacing-sizes-control/spacing-input-control.js.map +1 -1
  293. package/build-module/components/url-input/index.js +1 -1
  294. package/build-module/components/url-input/index.js.map +1 -1
  295. package/build-module/components/url-popover/index.js +30 -3
  296. package/build-module/components/url-popover/index.js.map +1 -1
  297. package/build-module/components/use-setting/index.js +1 -1
  298. package/build-module/components/use-setting/index.js.map +1 -1
  299. package/build-module/hooks/border.js +1 -0
  300. package/build-module/hooks/border.js.map +1 -1
  301. package/build-module/hooks/color-panel.js +17 -1
  302. package/build-module/hooks/color-panel.js.map +1 -1
  303. package/build-module/hooks/color.js +1 -1
  304. package/build-module/hooks/color.js.map +1 -1
  305. package/build-module/hooks/content-lock-ui.js +15 -8
  306. package/build-module/hooks/content-lock-ui.js.map +1 -1
  307. package/build-module/hooks/dimensions.js +67 -12
  308. package/build-module/hooks/dimensions.js.map +1 -1
  309. package/build-module/hooks/font-size.js +1 -0
  310. package/build-module/hooks/font-size.js.map +1 -1
  311. package/build-module/hooks/layout.js +6 -5
  312. package/build-module/hooks/layout.js.map +1 -1
  313. package/build-module/hooks/margin.js +27 -19
  314. package/build-module/hooks/margin.js.map +1 -1
  315. package/build-module/hooks/min-height.js +122 -0
  316. package/build-module/hooks/min-height.js.map +1 -0
  317. package/build-module/hooks/padding.js +23 -14
  318. package/build-module/hooks/padding.js.map +1 -1
  319. package/build-module/hooks/style.js +4 -3
  320. package/build-module/hooks/style.js.map +1 -1
  321. package/build-module/hooks/utils.js +7 -7
  322. package/build-module/hooks/utils.js.map +1 -1
  323. package/build-module/layouts/constrained.js +0 -1
  324. package/build-module/layouts/constrained.js.map +1 -1
  325. package/build-module/layouts/flex.js +24 -23
  326. package/build-module/layouts/flex.js.map +1 -1
  327. package/build-module/store/actions.js +26 -0
  328. package/build-module/store/actions.js.map +1 -1
  329. package/build-module/store/array.js +1 -6
  330. package/build-module/store/array.js.map +1 -1
  331. package/build-module/store/reducer.js +44 -14
  332. package/build-module/store/reducer.js.map +1 -1
  333. package/build-module/store/selectors.js +59 -31
  334. package/build-module/store/selectors.js.map +1 -1
  335. package/build-style/style-rtl.css +88 -88
  336. package/build-style/style.css +84 -84
  337. package/package.json +29 -28
  338. package/src/components/alignment-control/README.md +1 -1
  339. package/src/components/alignment-control/ui.js +1 -1
  340. package/src/components/block-alignment-control/constants.js +1 -1
  341. package/src/components/block-alignment-control/test/index.native.js +4 -4
  342. package/src/components/block-alignment-matrix-control/index.js +1 -1
  343. package/src/components/block-breadcrumb/test/__snapshots__/index.js.snap +13 -11
  344. package/src/components/block-breadcrumb/test/index.js +1 -1
  345. package/src/components/block-compare/index.js +3 -2
  346. package/src/components/block-draggable/test/helpers.native.js +3 -3
  347. package/src/components/block-draggable/test/index.native.js +27 -27
  348. package/src/components/block-edit/index.js +2 -1
  349. package/src/components/block-list/block.js +2 -0
  350. package/src/components/block-list/style.scss +11 -6
  351. package/src/components/block-lock/menu-item.js +5 -2
  352. package/src/components/block-lock/modal.js +19 -36
  353. package/src/components/block-lock/style.scss +8 -17
  354. package/src/components/block-mover/stories/index.js +1 -1
  355. package/src/components/block-mover/style.scss +35 -1
  356. package/src/components/block-popover/inbetween.js +1 -0
  357. package/src/components/block-popover/index.js +1 -0
  358. package/src/components/block-popover/style.scss +1 -5
  359. package/src/components/block-preview/index.js +8 -3
  360. package/src/components/block-settings-menu/block-settings-dropdown.js +4 -7
  361. package/src/components/block-styles/utils.js +3 -3
  362. package/src/components/block-switcher/index.js +21 -11
  363. package/src/components/block-switcher/preview-block-popover.js +1 -1
  364. package/src/components/block-tools/insertion-point.js +10 -1
  365. package/src/components/block-tools/selected-block-popover.js +80 -34
  366. package/src/components/block-tools/style.scss +15 -0
  367. package/src/components/block-variation-picker/README.md +1 -1
  368. package/src/components/block-vertical-alignment-control/ui.js +1 -1
  369. package/src/components/border-radius-control/all-input-control.js +1 -0
  370. package/src/components/border-radius-control/index.js +1 -0
  371. package/src/components/border-radius-control/input-controls.js +1 -0
  372. package/src/components/border-radius-control/style.scss +15 -24
  373. package/src/components/color-palette/test/__snapshots__/control.js.snap +85 -83
  374. package/src/components/color-palette/test/control.js +1 -1
  375. package/src/components/colors/with-colors.js +13 -23
  376. package/src/components/default-block-appender/style.scss +1 -0
  377. package/src/components/duotone-control/index.js +1 -1
  378. package/src/components/font-sizes/fluid-utils.js +37 -64
  379. package/src/components/font-sizes/test/fluid-utils.js +5 -5
  380. package/src/components/font-sizes/with-font-sizes.js +15 -13
  381. package/src/components/iframe/index.js +1 -1
  382. package/src/components/image-editor/constants.js +1 -1
  383. package/src/components/index.js +1 -0
  384. package/src/components/inner-blocks/index.js +11 -4
  385. package/src/components/inner-blocks/test/index.js +4 -0
  386. package/src/components/inserter/hooks/use-insertion-point.js +3 -11
  387. package/src/components/inserter/reusable-blocks-tab.js +4 -2
  388. package/src/components/inserter/search-items.js +23 -3
  389. package/src/components/inserter/style.scss +8 -7
  390. package/src/components/inserter/test/reusable-blocks-tab.js +14 -57
  391. package/src/components/inserter/test/search-items.js +6 -0
  392. package/src/components/inserter-list-item/style.scss +2 -0
  393. package/src/components/letter-spacing-control/README.md +55 -0
  394. package/src/components/line-height-control/index.js +1 -0
  395. package/src/components/link-control/README.md +3 -3
  396. package/src/components/link-control/index.js +23 -39
  397. package/src/components/link-control/search-input.js +1 -1
  398. package/src/components/link-control/test/index.js +272 -241
  399. package/src/components/link-control/use-internal-input-value.js +22 -0
  400. package/src/components/list-view/block.js +4 -3
  401. package/src/components/list-view/branch.js +11 -6
  402. package/src/components/list-view/drop-indicator.js +1 -0
  403. package/src/components/list-view/style.scss +1 -36
  404. package/src/components/media-replace-flow/index.js +1 -1
  405. package/src/components/media-replace-flow/test/index.js +69 -51
  406. package/src/components/off-canvas-editor/README.md +5 -0
  407. package/src/components/off-canvas-editor/block-contents.js +89 -0
  408. package/src/components/off-canvas-editor/block-select-button.js +113 -0
  409. package/src/components/off-canvas-editor/block.js +335 -0
  410. package/src/components/off-canvas-editor/branch.js +210 -0
  411. package/src/components/off-canvas-editor/context.js +8 -0
  412. package/src/components/off-canvas-editor/drop-indicator.js +126 -0
  413. package/src/components/off-canvas-editor/expander.js +26 -0
  414. package/src/components/off-canvas-editor/index.js +216 -0
  415. package/src/components/off-canvas-editor/leaf.js +48 -0
  416. package/src/components/off-canvas-editor/style.scss +397 -0
  417. package/src/components/off-canvas-editor/test/utils.js +50 -0
  418. package/src/components/off-canvas-editor/use-block-selection.js +169 -0
  419. package/src/components/off-canvas-editor/use-list-view-client-ids.js +29 -0
  420. package/src/components/off-canvas-editor/use-list-view-drop-zone.js +260 -0
  421. package/src/components/off-canvas-editor/use-list-view-expand-selected-item.js +58 -0
  422. package/src/components/off-canvas-editor/utils.js +58 -0
  423. package/src/components/responsive-block-control/test/index.js +69 -92
  424. package/src/components/rich-text/format-toolbar/index.js +1 -1
  425. package/src/components/rich-text/format-toolbar-container.js +1 -1
  426. package/src/components/rich-text/use-paste-handler.js +1 -1
  427. package/src/components/spacing-sizes-control/all-input-control.js +4 -0
  428. package/src/components/spacing-sizes-control/axial-input-controls.js +4 -0
  429. package/src/components/spacing-sizes-control/index.js +4 -0
  430. package/src/components/spacing-sizes-control/input-controls.js +4 -0
  431. package/src/components/spacing-sizes-control/spacing-input-control.js +10 -1
  432. package/src/components/spacing-sizes-control/style.scss +1 -0
  433. package/src/components/url-input/index.js +1 -1
  434. package/src/components/url-popover/README.md +12 -3
  435. package/src/components/url-popover/index.js +33 -3
  436. package/src/components/use-setting/index.js +7 -1
  437. package/src/hooks/border.js +1 -0
  438. package/src/hooks/color-panel.js +13 -1
  439. package/src/hooks/color.js +2 -0
  440. package/src/hooks/content-lock-ui.js +46 -34
  441. package/src/hooks/dimensions.js +106 -19
  442. package/src/hooks/font-size.js +1 -0
  443. package/src/hooks/layout.js +8 -11
  444. package/src/hooks/margin.js +23 -17
  445. package/src/hooks/min-height.js +121 -0
  446. package/src/hooks/padding.js +23 -19
  447. package/src/hooks/style.js +10 -2
  448. package/src/hooks/test/align.js +96 -72
  449. package/src/hooks/test/style.js +4 -0
  450. package/src/hooks/test/use-typography-props.js +1 -1
  451. package/src/hooks/utils.js +5 -6
  452. package/src/layouts/constrained.js +0 -1
  453. package/src/layouts/flex.js +44 -39
  454. package/src/store/actions.js +26 -0
  455. package/src/store/array.js +1 -6
  456. package/src/store/reducer.js +50 -40
  457. package/src/store/selectors.js +43 -29
  458. package/src/store/test/actions.js +18 -0
  459. package/src/store/test/reducer.js +40 -0
  460. package/src/store/test/selectors.js +20 -1
@@ -1 +1 @@
1
- {"version":3,"sources":["@wordpress/block-editor/src/hooks/margin.js"],"names":["hasMarginSupport","blockType","support","SPACING_SUPPORT_KEY","margin","hasMarginValue","props","attributes","style","spacing","undefined","resetMargin","setAttributes","useIsMarginDisabled","name","blockName","isDisabled","isInvalid","MarginEdit","spacingSizes","units","availableUnits","sides","splitOnAxis","some","side","AXIAL_SIDES","includes","onChange","next","newStyle","Platform","select","web","length","native","MarginVisualizer","clientId","marginTop","top","marginRight","right","marginBottom","bottom","marginLeft","left","borderTopWidth","borderRightWidth","borderBottomWidth","borderLeftWidth","isActive","setIsActive","valueRef","timeoutRef","clearTimer","current","window","clearTimeout","setTimeout"],"mappings":";;;;;;;;;;;;;;AAIA;;AADA;;AAQA;;AACA;;AAIA;;AAKA;;AACA;;AAMA;;AACA;;AACA;;AACA;;AA/BA;AACA;AACA;;AAgBA;AACA;AACA;;AAaA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,SAASA,gBAAT,CAA2BC,SAA3B,EAAuC;AAC7C,QAAMC,OAAO,GAAG,6BAAiBD,SAAjB,EAA4BE,+BAA5B,CAAhB;AACA,SAAO,CAAC,EAAI,SA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ACA;AACD,GAJD;;AAMA,0BAAW,MAAM;AAChB,QAAK,CAAE,6BAAgBnD,MAAhB,EAAwBgD,QAAQ,CAACG,OAAjC,CAAP,EAAoD;AACnDJ,MAAAA,WAAW,CAAE,IAAF,CAAX;AACAC,MAAAA,QAAQ,CAACG,OAAT,GAAmBnD,MAAnB;AAEAkD,MAAAA,UAAU;AAEVD,MAAAA,UAAU,CAACE,OAAX,GAAqBG,UAAU,CAAE,MAAM;AACtCP,QAAAA,WAAW,CAAE,KAAF,CAAX;AACA,OAF8B,EAE5B,GAF4B,CAA/B;AAGA;;AAED,WAAO,MAAMG,UAAU,EAAvB;AACA,GAbD,EAaG,CAAElD,MAAF,CAbH;;AAeA,MAAK,CAAE8C,QAAP,EAAkB;AACjB,WAAO,IAAP;AACA;;AAED,SACC,4BAAC,qBAAD;AACC,IAAA,QAAQ,EAAGb,QADZ;AAEC,IAAA,qBAAqB,MAFtB;AAGC,IAAA,qBAAqB,EAAGjC,MAHzB;AAIC,IAAA,KAAK,EAAG;AAJT,KAMC;AAAK,IAAA,SAAS,EAAC,kCAAf;AAAkD,IAAA,KAAK,EAAGI;AAA1D,IAND,CADD;AAUA","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { __ } from '@wordpress/i18n';\nimport {\n\tPlatform,\n\tuseMemo,\n\tuseRef,\n\tuseState,\n\tuseEffect,\n} from '@wordpress/element';\nimport { getBlockSupport } from '@wordpress/blocks';\nimport {\n\t__experimentalUseCustomUnits as useCustomUnits,\n\t__experimentalBoxControl as BoxControl,\n} from '@wordpress/components';\nimport isShallowEqual from '@wordpress/is-shallow-equal';\n\n/**\n * Internal dependencies\n */\nimport useSetting from '../components/use-setting';\nimport {\n\tAXIAL_SIDES,\n\tSPACING_SUPPORT_KEY,\n\tuseCustomSides,\n\tuseIsDimensionsSupportValid,\n} from './dimensions';\nimport { cleanEmptyObject } from './utils';\nimport BlockPopover from '../components/block-popover';\nimport SpacingSizesControl from '../components/spacing-sizes-control';\nimport { getCustomValueFromPreset } from '../components/spacing-sizes-control/utils';\n\n/**\n * Determines if there is margin support.\n *\n * @param {string|Object} blockType Block name or Block Type object.\n *\n * @return {boolean} Whether there is support.\n */\nexport function hasMarginSupport( blockType ) {\n\tconst support = getBlockSupport( blockType, SPACING_SUPPORT_KEY );\n\treturn !! ( true === support || support?.margin );\n}\n\n/**\n * Checks if there is a current value in the margin block support attributes.\n *\n * @param {Object} props Block props.\n * @return {boolean} Whether or not the block has a margin value set.\n */\nexport function hasMarginValue( props ) {\n\treturn props.attributes.style?.spacing?.margin !== undefined;\n}\n\n/**\n * Resets the margin block support attributes. This can be used when disabling\n * the margin support controls for a block via a `ToolsPanel`.\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 resetMargin( { attributes = {}, setAttributes } ) {\n\tconst { style } = attributes;\n\n\tsetAttributes( {\n\t\tstyle: cleanEmptyObject( {\n\t\t\t...style,\n\t\t\tspacing: {\n\t\t\t\t...style?.spacing,\n\t\t\t\tmargin: undefined,\n\t\t\t},\n\t\t} ),\n\t} );\n}\n\n/**\n * Custom hook that checks if margin settings have been disabled.\n *\n * @param {string} name The name of the block.\n *\n * @return {boolean} Whether margin setting is disabled.\n */\nexport function useIsMarginDisabled( { name: blockName } = {} ) {\n\tconst isDisabled = ! useSetting( 'spacing.margin' );\n\tconst isInvalid = ! useIsDimensionsSupportValid( blockName, 'margin' );\n\n\treturn ! hasMarginSupport( blockName ) || isDisabled || isInvalid;\n}\n\n/**\n * Inspector control panel containing the margin related configuration\n *\n * @param {Object} props Block props.\n *\n * @return {WPElement} Margin edit element.\n */\nexport function MarginEdit( props ) {\n\tconst {\n\t\tname: blockName,\n\t\tattributes: { style },\n\t\tsetAttributes,\n\t} = props;\n\n\tconst spacingSizes = useSetting( 'spacing.spacingSizes' );\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, 'margin' );\n\tconst splitOnAxis =\n\t\tsides && sides.some( ( side ) => AXIAL_SIDES.includes( side ) );\n\n\tif ( useIsMarginDisabled( 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\tmargin: next,\n\t\t\t},\n\t\t};\n\n\t\tsetAttributes( {\n\t\t\tstyle: cleanEmptyObject( newStyle ),\n\t\t} );\n\t};\n\n\treturn Platform.select( {\n\t\tweb: (\n\t\t\t<>\n\t\t\t\t{ ( ! spacingSizes || spacingSizes?.length === 0 ) && (\n\t\t\t\t\t<BoxControl\n\t\t\t\t\t\tvalues={ style?.spacing?.margin }\n\t\t\t\t\t\tonChange={ onChange }\n\t\t\t\t\t\tlabel={ __( 'Margin' ) }\n\t\t\t\t\t\tsides={ sides }\n\t\t\t\t\t\tunits={ units }\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{ spacingSizes?.length > 0 && (\n\t\t\t\t\t<SpacingSizesControl\n\t\t\t\t\t\tvalues={ style?.spacing?.margin }\n\t\t\t\t\t\tonChange={ onChange }\n\t\t\t\t\t\tlabel={ __( 'Margin' ) }\n\t\t\t\t\t\tsides={ sides }\n\t\t\t\t\t\tunits={ units }\n\t\t\t\t\t\tallowReset={ false }\n\t\t\t\t\t\tsplitOnAxis={ false }\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\nexport function MarginVisualizer( { clientId, attributes } ) {\n\tconst margin = attributes?.style?.spacing?.margin;\n\tconst spacingSizes = useSetting( 'spacing.spacingSizes' );\n\n\tconst style = useMemo( () => {\n\t\tconst marginTop = margin?.top\n\t\t\t? getCustomValueFromPreset( margin?.top, spacingSizes )\n\t\t\t: 0;\n\t\tconst marginRight = margin?.right\n\t\t\t? getCustomValueFromPreset( margin?.right, spacingSizes )\n\t\t\t: 0;\n\t\tconst marginBottom = margin?.bottom\n\t\t\t? getCustomValueFromPreset( margin?.bottom, spacingSizes )\n\t\t\t: 0;\n\t\tconst marginLeft = margin?.left\n\t\t\t? getCustomValueFromPreset( margin?.left, spacingSizes )\n\t\t\t: 0;\n\n\t\treturn {\n\t\t\tborderTopWidth: marginTop,\n\t\t\tborderRightWidth: marginRight,\n\t\t\tborderBottomWidth: marginBottom,\n\t\t\tborderLeftWidth: marginLeft,\n\t\t\ttop: marginTop !== 0 ? `calc(${ marginTop } * -1)` : 0,\n\t\t\tright: marginRight !== 0 ? `calc(${ marginRight } * -1)` : 0,\n\t\t\tbottom: marginBottom !== 0 ? `calc(${ marginBottom } * -1)` : 0,\n\t\t\tleft: marginLeft !== 0 ? `calc(${ marginLeft } * -1)` : 0,\n\t\t};\n\t}, [ margin ] );\n\n\tconst [ isActive, setIsActive ] = useState( false );\n\tconst valueRef = useRef( margin );\n\tconst timeoutRef = useRef();\n\n\tconst clearTimer = () => {\n\t\tif ( timeoutRef.current ) {\n\t\t\twindow.clearTimeout( timeoutRef.current );\n\t\t}\n\t};\n\n\tuseEffect( () => {\n\t\tif ( ! isShallowEqual( margin, valueRef.current ) ) {\n\t\t\tsetIsActive( true );\n\t\t\tvalueRef.current = margin;\n\n\t\t\tclearTimer();\n\n\t\t\ttimeoutRef.current = setTimeout( () => {\n\t\t\t\tsetIsActive( false );\n\t\t\t}, 400 );\n\t\t}\n\n\t\treturn () => clearTimer();\n\t}, [ margin ] );\n\n\tif ( ! isActive ) {\n\t\treturn null;\n\t}\n\n\treturn (\n\t\t<BlockPopover\n\t\t\tclientId={ clientId }\n\t\t\t__unstableCoverTarget\n\t\t\t__unstableRefreshSize={ margin }\n\t\t\tshift={ false }\n\t\t>\n\t\t\t<div className=\"block-editor__padding-visualizer\" style={ style } />\n\t\t</BlockPopover>\n\t);\n}\n"]}
1
+ {"version":3,"sources":["@wordpress/block-editor/src/hooks/margin.js"],"names":["hasMarginSupport","blockType","support","SPACING_SUPPORT_KEY","margin","hasMarginValue","props","attributes","style","spacing","undefined","resetMargin","setAttributes","useIsMarginDisabled","name","blockName","isDisabled","isInvalid","MarginEdit","onMouseOver","onMouseOut","spacingSizes","units","availableUnits","sides","splitOnAxis","some","side","AXIAL_SIDES","includes","onChange","next","newStyle","Platform","select","web","length","native","MarginVisualizer","clientId","forceShow","marginTop","top","marginRight","right","marginBottom","bottom","marginLeft","left","borderTopWidth","borderRightWidth","borderBottomWidth","borderLeftWidth","isActive","setIsActive","valueRef","timeoutRef","clearTimer","current","window","clearTimeout","setTimeout"],"mappings":";;;;;;;;;;;;;;AAIA;;AADA;;AAQA;;AACA;;AAIA;;AAKA;;AACA;;AAMA;;AACA;;AACA;;AACA;;AA/BA;AACA;AACA;;AAgBA;AACA;AACA;;AAaA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,SAASA,gBAAT,CAA2BC,SAA3B,EAAuC;AAC7C,QAAMC,OAAO,GAAG,6BAAiBD,SAAjB,EAA4BE,+BAA5B,CAAhB;AACA,SAAO,CAAC,EAAI,SAASD,OAAT,IAAoBA,OAApB,aAAoBA,OAApB,eAAoBA,OAAO,CAAEE,MAAjC,CAAR;AACA;AAED;AACA;AACA;AACA;AACA;AACA;;;AACO,SAASC,cAAT,CAAyBC,KAAzB,EAAiC;AAAA;;AACvC,SAAO,0BAAAA,KAAK,CAACC,UAAN,CAAiBC,KAAjB,0GAAwBC,OAAxB,kFAAiCL,MAAjC,MAA4CM,SAAnD;AACA;AAED;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;AACO,SAASC,WAAT,OAA2D;AAAA,MAArC;AAAEJ,IAAAA,UAAU,GAAG,EAAf;AAAmBK,IAAAA;AAAnB,GAAqC;AACjE,QAAM;AAAEJ,IAAAA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AAA,UAAU;AACV,KAHD;AAIA,GAdD,EAcG,CAAErD,MAAF,EAAUoC,SAAV,CAdH;;AAgBA,MAAK,CAAEa,QAAF,IAAc,CAAEb,SAArB,EAAiC;AAChC,WAAO,IAAP;AACA;;AAED,SACC,4BAAC,qBAAD;AACC,IAAA,QAAQ,EAAGD,QADZ;AAEC,IAAA,qBAAqB,MAFtB;AAGC,IAAA,qBAAqB,EAAGnC,MAHzB;AAIC,IAAA,KAAK,EAAG;AAJT,KAMC;AAAK,IAAA,SAAS,EAAC,kCAAf;AAAkD,IAAA,KAAK,EAAGI;AAA1D,IAND,CADD;AAUA","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { __ } from '@wordpress/i18n';\nimport {\n\tPlatform,\n\tuseMemo,\n\tuseRef,\n\tuseState,\n\tuseEffect,\n} from '@wordpress/element';\nimport { getBlockSupport } from '@wordpress/blocks';\nimport {\n\t__experimentalUseCustomUnits as useCustomUnits,\n\t__experimentalBoxControl as BoxControl,\n} from '@wordpress/components';\nimport isShallowEqual from '@wordpress/is-shallow-equal';\n\n/**\n * Internal dependencies\n */\nimport useSetting from '../components/use-setting';\nimport {\n\tAXIAL_SIDES,\n\tSPACING_SUPPORT_KEY,\n\tuseCustomSides,\n\tuseIsDimensionsSupportValid,\n} from './dimensions';\nimport { cleanEmptyObject } from './utils';\nimport BlockPopover from '../components/block-popover';\nimport SpacingSizesControl from '../components/spacing-sizes-control';\nimport { getSpacingPresetCssVar } from '../components/spacing-sizes-control/utils';\n\n/**\n * Determines if there is margin support.\n *\n * @param {string|Object} blockType Block name or Block Type object.\n *\n * @return {boolean} Whether there is support.\n */\nexport function hasMarginSupport( blockType ) {\n\tconst support = getBlockSupport( blockType, SPACING_SUPPORT_KEY );\n\treturn !! ( true === support || support?.margin );\n}\n\n/**\n * Checks if there is a current value in the margin block support attributes.\n *\n * @param {Object} props Block props.\n * @return {boolean} Whether or not the block has a margin value set.\n */\nexport function hasMarginValue( props ) {\n\treturn props.attributes.style?.spacing?.margin !== undefined;\n}\n\n/**\n * Resets the margin block support attributes. This can be used when disabling\n * the margin support controls for a block via a `ToolsPanel`.\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 resetMargin( { attributes = {}, setAttributes } ) {\n\tconst { style } = attributes;\n\n\tsetAttributes( {\n\t\tstyle: cleanEmptyObject( {\n\t\t\t...style,\n\t\t\tspacing: {\n\t\t\t\t...style?.spacing,\n\t\t\t\tmargin: undefined,\n\t\t\t},\n\t\t} ),\n\t} );\n}\n\n/**\n * Custom hook that checks if margin settings have been disabled.\n *\n * @param {string} name The name of the block.\n *\n * @return {boolean} Whether margin setting is disabled.\n */\nexport function useIsMarginDisabled( { name: blockName } = {} ) {\n\tconst isDisabled = ! useSetting( 'spacing.margin' );\n\tconst isInvalid = ! useIsDimensionsSupportValid( blockName, 'margin' );\n\n\treturn ! hasMarginSupport( blockName ) || isDisabled || isInvalid;\n}\n\n/**\n * Inspector control panel containing the margin related configuration\n *\n * @param {Object} props Block props.\n *\n * @return {WPElement} Margin edit element.\n */\nexport function MarginEdit( props ) {\n\tconst {\n\t\tname: blockName,\n\t\tattributes: { style },\n\t\tsetAttributes,\n\t\tonMouseOver,\n\t\tonMouseOut,\n\t} = props;\n\n\tconst spacingSizes = useSetting( 'spacing.spacingSizes' );\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, 'margin' );\n\tconst splitOnAxis =\n\t\tsides && sides.some( ( side ) => AXIAL_SIDES.includes( side ) );\n\n\tif ( useIsMarginDisabled( 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\tmargin: next,\n\t\t\t},\n\t\t};\n\n\t\tsetAttributes( {\n\t\t\tstyle: cleanEmptyObject( newStyle ),\n\t\t} );\n\t};\n\n\treturn Platform.select( {\n\t\tweb: (\n\t\t\t<>\n\t\t\t\t{ ( ! spacingSizes || spacingSizes?.length === 0 ) && (\n\t\t\t\t\t<BoxControl\n\t\t\t\t\t\tvalues={ style?.spacing?.margin }\n\t\t\t\t\t\tonChange={ onChange }\n\t\t\t\t\t\tlabel={ __( 'Margin' ) }\n\t\t\t\t\t\tsides={ sides }\n\t\t\t\t\t\tunits={ units }\n\t\t\t\t\t\tallowReset={ false }\n\t\t\t\t\t\tsplitOnAxis={ splitOnAxis }\n\t\t\t\t\t\tonMouseOver={ onMouseOver }\n\t\t\t\t\t\tonMouseOut={ onMouseOut }\n\t\t\t\t\t/>\n\t\t\t\t) }\n\t\t\t\t{ spacingSizes?.length > 0 && (\n\t\t\t\t\t<SpacingSizesControl\n\t\t\t\t\t\tvalues={ style?.spacing?.margin }\n\t\t\t\t\t\tonChange={ onChange }\n\t\t\t\t\t\tlabel={ __( 'Margin' ) }\n\t\t\t\t\t\tsides={ sides }\n\t\t\t\t\t\tunits={ units }\n\t\t\t\t\t\tallowReset={ false }\n\t\t\t\t\t\tsplitOnAxis={ false }\n\t\t\t\t\t\tonMouseOver={ onMouseOver }\n\t\t\t\t\t\tonMouseOut={ onMouseOut }\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\nexport function MarginVisualizer( { clientId, attributes, forceShow } ) {\n\tconst margin = attributes?.style?.spacing?.margin;\n\n\tconst style = useMemo( () => {\n\t\tconst marginTop = margin?.top\n\t\t\t? getSpacingPresetCssVar( margin?.top )\n\t\t\t: 0;\n\t\tconst marginRight = margin?.right\n\t\t\t? getSpacingPresetCssVar( margin?.right )\n\t\t\t: 0;\n\t\tconst marginBottom = margin?.bottom\n\t\t\t? getSpacingPresetCssVar( margin?.bottom )\n\t\t\t: 0;\n\t\tconst marginLeft = margin?.left\n\t\t\t? getSpacingPresetCssVar( margin?.left )\n\t\t\t: 0;\n\n\t\treturn {\n\t\t\tborderTopWidth: marginTop,\n\t\t\tborderRightWidth: marginRight,\n\t\t\tborderBottomWidth: marginBottom,\n\t\t\tborderLeftWidth: marginLeft,\n\t\t\ttop: marginTop ? `calc(${ marginTop } * -1)` : 0,\n\t\t\tright: marginRight ? `calc(${ marginRight } * -1)` : 0,\n\t\t\tbottom: marginBottom ? `calc(${ marginBottom } * -1)` : 0,\n\t\t\tleft: marginLeft ? `calc(${ marginLeft } * -1)` : 0,\n\t\t};\n\t}, [ margin ] );\n\n\tconst [ isActive, setIsActive ] = useState( false );\n\tconst valueRef = useRef( margin );\n\tconst timeoutRef = useRef();\n\n\tconst clearTimer = () => {\n\t\tif ( timeoutRef.current ) {\n\t\t\twindow.clearTimeout( timeoutRef.current );\n\t\t}\n\t};\n\n\tuseEffect( () => {\n\t\tif ( ! isShallowEqual( margin, valueRef.current ) && ! forceShow ) {\n\t\t\tsetIsActive( true );\n\t\t\tvalueRef.current = margin;\n\n\t\t\ttimeoutRef.current = setTimeout( () => {\n\t\t\t\tsetIsActive( false );\n\t\t\t}, 400 );\n\t\t}\n\n\t\treturn () => {\n\t\t\tsetIsActive( false );\n\t\t\tclearTimer();\n\t\t};\n\t}, [ margin, forceShow ] );\n\n\tif ( ! isActive && ! forceShow ) {\n\t\treturn null;\n\t}\n\n\treturn (\n\t\t<BlockPopover\n\t\t\tclientId={ clientId }\n\t\t\t__unstableCoverTarget\n\t\t\t__unstableRefreshSize={ margin }\n\t\t\tshift={ false }\n\t\t>\n\t\t\t<div className=\"block-editor__padding-visualizer\" style={ style } />\n\t\t</BlockPopover>\n\t);\n}\n"]}
@@ -0,0 +1,145 @@
1
+ "use strict";
2
+
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
+
5
+ Object.defineProperty(exports, "__esModule", {
6
+ value: true
7
+ });
8
+ exports.MinHeightEdit = MinHeightEdit;
9
+ exports.hasMinHeightSupport = hasMinHeightSupport;
10
+ exports.hasMinHeightValue = hasMinHeightValue;
11
+ exports.resetMinHeight = resetMinHeight;
12
+ exports.useIsMinHeightDisabled = useIsMinHeightDisabled;
13
+
14
+ var _element = require("@wordpress/element");
15
+
16
+ var _blocks = require("@wordpress/blocks");
17
+
18
+ var _components = require("@wordpress/components");
19
+
20
+ var _i18n = require("@wordpress/i18n");
21
+
22
+ var _useSetting = _interopRequireDefault(require("../components/use-setting"));
23
+
24
+ var _dimensions = require("./dimensions");
25
+
26
+ var _utils = require("./utils");
27
+
28
+ /**
29
+ * WordPress dependencies
30
+ */
31
+
32
+ /**
33
+ * Internal dependencies
34
+ */
35
+
36
+ /**
37
+ * Determines if there is minHeight support.
38
+ *
39
+ * @param {string|Object} blockType Block name or Block Type object.
40
+ * @return {boolean} Whether there is support.
41
+ */
42
+ function hasMinHeightSupport(blockType) {
43
+ const support = (0, _blocks.getBlockSupport)(blockType, _dimensions.DIMENSIONS_SUPPORT_KEY);
44
+ return !!(true === support || support !== null && support !== void 0 && support.minHeight);
45
+ }
46
+ /**
47
+ * Checks if there is a current value in the minHeight block support attributes.
48
+ *
49
+ * @param {Object} props Block props.
50
+ * @return {boolean} Whether or not the block has a minHeight value set.
51
+ */
52
+
53
+
54
+ function hasMinHeightValue(props) {
55
+ var _props$attributes$sty, _props$attributes$sty2;
56
+
57
+ return ((_props$attributes$sty = props.attributes.style) === null || _props$attributes$sty === void 0 ? void 0 : (_props$attributes$sty2 = _props$attributes$sty.dimensions) === null || _props$attributes$sty2 === void 0 ? void 0 : _props$attributes$sty2.minHeight) !== undefined;
58
+ }
59
+ /**
60
+ * Resets the minHeight block support attributes. This can be used when disabling
61
+ * the padding support controls for a block via a `ToolsPanel`.
62
+ *
63
+ * @param {Object} props Block props.
64
+ * @param {Object} props.attributes Block's attributes.
65
+ * @param {Object} props.setAttributes Function to set block's attributes.
66
+ */
67
+
68
+
69
+ function resetMinHeight(_ref) {
70
+ let {
71
+ attributes = {},
72
+ setAttributes
73
+ } = _ref;
74
+ const {
75
+ style
76
+ } = attributes;
77
+ setAttributes({
78
+ style: (0, _utils.cleanEmptyObject)({ ...style,
79
+ dimensions: { ...(style === null || style === void 0 ? void 0 : style.dimensions),
80
+ minHeight: undefined
81
+ }
82
+ })
83
+ });
84
+ }
85
+ /**
86
+ * Custom hook that checks if minHeight controls have been disabled.
87
+ *
88
+ * @param {string} name The name of the block.
89
+ * @return {boolean} Whether minHeight control is disabled.
90
+ */
91
+
92
+
93
+ function useIsMinHeightDisabled() {
94
+ let {
95
+ name: blockName
96
+ } = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
97
+ const isDisabled = !(0, _useSetting.default)('dimensions.minHeight');
98
+ return !hasMinHeightSupport(blockName) || isDisabled;
99
+ }
100
+ /**
101
+ * Inspector control panel containing the minHeight related configuration.
102
+ *
103
+ * @param {Object} props Block props.
104
+ * @return {WPElement} Edit component for height.
105
+ */
106
+
107
+
108
+ function MinHeightEdit(props) {
109
+ var _style$dimensions;
110
+
111
+ const {
112
+ attributes: {
113
+ style
114
+ },
115
+ setAttributes
116
+ } = props;
117
+ const units = (0, _components.__experimentalUseCustomUnits)({
118
+ availableUnits: (0, _useSetting.default)('dimensions.units') || ['%', 'px', 'em', 'rem', 'vh', 'vw']
119
+ });
120
+
121
+ if (useIsMinHeightDisabled(props)) {
122
+ return null;
123
+ }
124
+
125
+ const onChange = next => {
126
+ const newStyle = { ...style,
127
+ dimensions: { ...(style === null || style === void 0 ? void 0 : style.dimensions),
128
+ minHeight: next
129
+ }
130
+ };
131
+ setAttributes({
132
+ style: (0, _utils.cleanEmptyObject)(newStyle)
133
+ });
134
+ };
135
+
136
+ return (0, _element.createElement)(_components.__experimentalUnitControl, {
137
+ label: (0, _i18n.__)('Min. height'),
138
+ value: style === null || style === void 0 ? void 0 : (_style$dimensions = style.dimensions) === null || _style$dimensions === void 0 ? void 0 : _style$dimensions.minHeight,
139
+ units: units,
140
+ onChange: onChange,
141
+ min: 0,
142
+ size: '__unstable-large'
143
+ });
144
+ }
145
+ //# sourceMappingURL=min-height.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["@wordpress/block-editor/src/hooks/min-height.js"],"names":["hasMinHeightSupport","blockType","support","DIMENSIONS_SUPPORT_KEY","minHeight","hasMinHeightValue","props","attributes","style","dimensions","undefined","resetMinHeight","setAttributes","useIsMinHeightDisabled","name","blockName","isDisabled","MinHeightEdit","units","availableUnits","onChange","next","newStyle"],"mappings":";;;;;;;;;;;;;;;AAGA;;AACA;;AAIA;;AAKA;;AACA;;AACA;;AAfA;AACA;AACA;;AAQA;AACA;AACA;;AAKA;AACA;AACA;AACA;AACA;AACA;AACO,SAASA,mBAAT,CAA8BC,SAA9B,EAA0C;AAChD,QAAMC,OAAO,GAAG,6BAAiBD,SAAjB,EAA4BE,kCAA5B,CAAhB;AACA,SAAO,CAAC,EAAI,SAASD,OAAT,IAAoBA,OAApB,aAAoBA,OAApB,eAAoBA,OAAO,CAAEE,SAAjC,CAAR;AACA;AAED;AACA;AACA;AACA;AACA;AACA;;;AACO,SAASC,iBAAT,CAA4BC,KAA5B,EAAoC;AAAA;;AAC1C,SAAO,0BAAAA,KAAK,CAACC,UAAN,CAAiBC,KAAjB,0GAAwBC,UAAxB,kFAAoCL,SAApC,MAAkDM,SAAzD;AACA;AAED;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;AACO,SAASC,cAAT,OAA8D;AAAA,MAArC;AAAEJ,IAAAA,UAAU,GAAG,EAAf;AAAmBK,IAAAA;AAAnB,GAAqC;AACpE,QAAM;AAAEJ,IAAAA;AAAF,MAAYD,UAAlB;AAEAK,EAAAA,aAAa,CAAE;AACdJ,IAAAA,KAAK,EAAE,6BAAkB,EACxB,GAAGA,KADqB;AAExBC,MAAAA,UAAU,EAAE,EACX,IAAGD,KAAH,aAAGA,KAAH,uBAAGA,KAAK,CAAEC,UAAV,CADW;AAEXL,QAAA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,KAAK,EAAGc,KAHT;AAIC,IAAA,QAAQ,EAAGE,QAJZ;AAKC,IAAA,GAAG,EAAG,CALP;AAMC,IAAA,IAAI,EAAG;AANR,IADD;AAUA","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { getBlockSupport } from '@wordpress/blocks';\nimport {\n\t__experimentalUseCustomUnits as useCustomUnits,\n\t__experimentalUnitControl as UnitControl,\n} from '@wordpress/components';\nimport { __ } from '@wordpress/i18n';\n\n/**\n * Internal dependencies\n */\nimport useSetting from '../components/use-setting';\nimport { DIMENSIONS_SUPPORT_KEY } from './dimensions';\nimport { cleanEmptyObject } from './utils';\n\n/**\n * Determines if there is minHeight support.\n *\n * @param {string|Object} blockType Block name or Block Type object.\n * @return {boolean} Whether there is support.\n */\nexport function hasMinHeightSupport( blockType ) {\n\tconst support = getBlockSupport( blockType, DIMENSIONS_SUPPORT_KEY );\n\treturn !! ( true === support || support?.minHeight );\n}\n\n/**\n * Checks if there is a current value in the minHeight block support attributes.\n *\n * @param {Object} props Block props.\n * @return {boolean} Whether or not the block has a minHeight value set.\n */\nexport function hasMinHeightValue( props ) {\n\treturn props.attributes.style?.dimensions?.minHeight !== undefined;\n}\n\n/**\n * Resets the minHeight block support attributes. This can be used when disabling\n * the padding support controls for a block via a `ToolsPanel`.\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 resetMinHeight( { attributes = {}, setAttributes } ) {\n\tconst { style } = attributes;\n\n\tsetAttributes( {\n\t\tstyle: cleanEmptyObject( {\n\t\t\t...style,\n\t\t\tdimensions: {\n\t\t\t\t...style?.dimensions,\n\t\t\t\tminHeight: undefined,\n\t\t\t},\n\t\t} ),\n\t} );\n}\n\n/**\n * Custom hook that checks if minHeight controls have been disabled.\n *\n * @param {string} name The name of the block.\n * @return {boolean} Whether minHeight control is disabled.\n */\nexport function useIsMinHeightDisabled( { name: blockName } = {} ) {\n\tconst isDisabled = ! useSetting( 'dimensions.minHeight' );\n\treturn ! hasMinHeightSupport( blockName ) || isDisabled;\n}\n\n/**\n * Inspector control panel containing the minHeight related configuration.\n *\n * @param {Object} props Block props.\n * @return {WPElement} Edit component for height.\n */\nexport function MinHeightEdit( props ) {\n\tconst {\n\t\tattributes: { style },\n\t\tsetAttributes,\n\t} = props;\n\n\tconst units = useCustomUnits( {\n\t\tavailableUnits: useSetting( 'dimensions.units' ) || [\n\t\t\t'%',\n\t\t\t'px',\n\t\t\t'em',\n\t\t\t'rem',\n\t\t\t'vh',\n\t\t\t'vw',\n\t\t],\n\t} );\n\n\tif ( useIsMinHeightDisabled( props ) ) {\n\t\treturn null;\n\t}\n\n\tconst onChange = ( next ) => {\n\t\tconst newStyle = {\n\t\t\t...style,\n\t\t\tdimensions: {\n\t\t\t\t...style?.dimensions,\n\t\t\t\tminHeight: next,\n\t\t\t},\n\t\t};\n\n\t\tsetAttributes( { style: cleanEmptyObject( newStyle ) } );\n\t};\n\n\treturn (\n\t\t<UnitControl\n\t\t\tlabel={ __( 'Min. height' ) }\n\t\t\tvalue={ style?.dimensions?.minHeight }\n\t\t\tunits={ units }\n\t\t\tonChange={ onChange }\n\t\t\tmin={ 0 }\n\t\t\tsize={ '__unstable-large' }\n\t\t/>\n\t);\n}\n"]}
@@ -126,7 +126,9 @@ function PaddingEdit(props) {
126
126
  attributes: {
127
127
  style
128
128
  },
129
- setAttributes
129
+ setAttributes,
130
+ onMouseOver,
131
+ onMouseOut
130
132
  } = props;
131
133
  const spacingSizes = (0, _useSetting.default)('spacing.spacingSizes');
132
134
  const units = (0, _components.__experimentalUseCustomUnits)({
@@ -158,7 +160,9 @@ function PaddingEdit(props) {
158
160
  sides: sides,
159
161
  units: units,
160
162
  allowReset: false,
161
- splitOnAxis: splitOnAxis
163
+ splitOnAxis: splitOnAxis,
164
+ onMouseOver: onMouseOver,
165
+ onMouseOut: onMouseOut
162
166
  }), (spacingSizes === null || spacingSizes === void 0 ? void 0 : spacingSizes.length) > 0 && (0, _element.createElement)(_spacingSizesControl.default, {
163
167
  values: style === null || style === void 0 ? void 0 : (_style$spacing2 = style.spacing) === null || _style$spacing2 === void 0 ? void 0 : _style$spacing2.padding,
164
168
  onChange: onChange,
@@ -166,7 +170,9 @@ function PaddingEdit(props) {
166
170
  sides: sides,
167
171
  units: units,
168
172
  allowReset: false,
169
- splitOnAxis: splitOnAxis
173
+ splitOnAxis: splitOnAxis,
174
+ onMouseOver: onMouseOver,
175
+ onMouseOut: onMouseOut
170
176
  })),
171
177
  native: null
172
178
  });
@@ -177,15 +183,16 @@ function PaddingVisualizer(_ref2) {
177
183
 
178
184
  let {
179
185
  clientId,
180
- attributes
186
+ attributes,
187
+ forceShow
181
188
  } = _ref2;
182
189
  const padding = attributes === null || attributes === void 0 ? void 0 : (_attributes$style = attributes.style) === null || _attributes$style === void 0 ? void 0 : (_attributes$style$spa = _attributes$style.spacing) === null || _attributes$style$spa === void 0 ? void 0 : _attributes$style$spa.padding;
183
190
  const style = (0, _element.useMemo)(() => {
184
191
  return {
185
- borderTopWidth: (0, _utils2.isValueSpacingPreset)(padding === null || padding === void 0 ? void 0 : padding.top) ? (0, _utils2.getSpacingPresetCssVar)(padding === null || padding === void 0 ? void 0 : padding.top) : padding === null || padding === void 0 ? void 0 : padding.top,
186
- borderRightWidth: (0, _utils2.isValueSpacingPreset)(padding === null || padding === void 0 ? void 0 : padding.right) ? (0, _utils2.getSpacingPresetCssVar)(padding === null || padding === void 0 ? void 0 : padding.right) : padding === null || padding === void 0 ? void 0 : padding.right,
187
- borderBottomWidth: (0, _utils2.isValueSpacingPreset)(padding === null || padding === void 0 ? void 0 : padding.bottom) ? (0, _utils2.getSpacingPresetCssVar)(padding === null || padding === void 0 ? void 0 : padding.bottom) : padding === null || padding === void 0 ? void 0 : padding.bottom,
188
- borderLeftWidth: (0, _utils2.isValueSpacingPreset)(padding === null || padding === void 0 ? void 0 : padding.left) ? (0, _utils2.getSpacingPresetCssVar)(padding === null || padding === void 0 ? void 0 : padding.left) : padding === null || padding === void 0 ? void 0 : padding.left
192
+ borderTopWidth: padding !== null && padding !== void 0 && padding.top ? (0, _utils2.getSpacingPresetCssVar)(padding === null || padding === void 0 ? void 0 : padding.top) : 0,
193
+ borderRightWidth: padding !== null && padding !== void 0 && padding.right ? (0, _utils2.getSpacingPresetCssVar)(padding === null || padding === void 0 ? void 0 : padding.right) : 0,
194
+ borderBottomWidth: padding !== null && padding !== void 0 && padding.bottom ? (0, _utils2.getSpacingPresetCssVar)(padding === null || padding === void 0 ? void 0 : padding.bottom) : 0,
195
+ borderLeftWidth: padding !== null && padding !== void 0 && padding.left ? (0, _utils2.getSpacingPresetCssVar)(padding === null || padding === void 0 ? void 0 : padding.left) : 0
189
196
  };
190
197
  }, [padding]);
191
198
  const [isActive, setIsActive] = (0, _element.useState)(false);
@@ -199,19 +206,21 @@ function PaddingVisualizer(_ref2) {
199
206
  };
200
207
 
201
208
  (0, _element.useEffect)(() => {
202
- if (!(0, _isShallowEqual.default)(padding, valueRef.current)) {
209
+ if (!(0, _isShallowEqual.default)(padding, valueRef.current) && !forceShow) {
203
210
  setIsActive(true);
204
211
  valueRef.current = padding;
205
- clearTimer();
206
212
  timeoutRef.current = setTimeout(() => {
207
213
  setIsActive(false);
208
214
  }, 400);
209
215
  }
210
216
 
211
- return () => clearTimer();
212
- }, [padding]);
217
+ return () => {
218
+ setIsActive(false);
219
+ clearTimer();
220
+ };
221
+ }, [padding, forceShow]);
213
222
 
214
- if (!isActive) {
223
+ if (!isActive && !forceShow) {
215
224
  return null;
216
225
  }
217
226
 
@@ -1 +1 @@
1
- {"version":3,"sources":["@wordpress/block-editor/src/hooks/padding.js"],"names":["hasPaddingSupport","blockType","support","SPACING_SUPPORT_KEY","padding","hasPaddingValue","props","attributes","style","spacing","undefined","resetPadding","setAttributes","useIsPaddingDisabled","name","blockName","isDisabled","isInvalid","PaddingEdit","spacingSizes","units","availableUnits","sides","splitOnAxis","some","side","AXIAL_SIDES","includes","onChange","next","newStyle","Platform","select","web","length","native","PaddingVisualizer","clientId","borderTopWidth","top","borderRightWidth","right","borderBottomWidth","bottom","borderLeftWidth","left","isActive","setIsActive","valueRef","timeoutRef","clearTimer","current","window","clearTimeout","setTimeout"],"mappings":";;;;;;;;;;;;;;AAIA;;AADA;;AAQA;;AACA;;AAIA;;AAKA;;AACA;;AAMA;;AACA;;AACA;;AACA;;AA/BA;AACA;AACA;;AAgBA;AACA;AACA;;AAeA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,SAASA,iBAAT,CAA4BC,SAA5B,EAAwC;AAC9C,QAAMC,OAAO,GAAG,6BAAiBD,SAAjB,EAA4BE,+BAA5B,CAAhB;AACA,SAAO,CAAC,EAAI,SAASD,OAAT,IAAoBA,OAApB,aAAoBA,OAApB,eAAoBA,OAAO,CAAEE,OAAjC,CAAR;AACA;AAED;AACA;AACA;AACA;AACA;AACA;;;AACO,SAASC,eAAT,CAA0BC,KAA1B,EAAkC;AAAA;;AACxC,SAAO,0BAAAA,KAAK,CAACC,UAAN,CAAiBC,KAAjB,0GAAwBC,OAAxB,kFAAiCL,OAAjC,MAA6CM,SAApD;AACA;AAED;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;AACO,SAASC,YAAT,OAA4D;AAAA,MAArC;AAAEJ,IAAAA,UAAU,GAAG,EAAf;AAAmBK,IAAAA;AAAnB,GAAqC;AAClE,QAAM;AAAEJ,IAAAA;AAAF,MAAYD,UAAlB;AAEAK,EAAAA,aAAa,CAAE;AACdJ,IAAAA,KAAK,EAAE,6BAAkB,EACxB,GAAGA,KADqB;AAExBC,MAAAA,OAAO,EAAE,EACR,IAAGD,KAAH,aAAGA,KAAH,uBAAGA,KAAK,CAAEC,OAAV,CADQ;AAERL,QAAAA,OAAO,EAAEM;AAFD;AAFe,KAAlB;AADO,GAAF,CAAb;AASA;AAED;AACA;AACA;AACA;AACA;AACA;AACA;;;AACO,SAASG,oBAAT,GAA0D;AAAA,MAA3B;AAAEC,IAAAA,IAAI,EAA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AP,CAAqBJ,UAAU,CAACE,OAAhC;AACA;AACD,GAJD;;AAMA,0BAAW,MAAM;AAChB,QAAK,CAAE,6BAAgB/C,OAAhB,EAAyB4C,QAAQ,CAACG,OAAlC,CAAP,EAAqD;AACpDJ,MAAAA,WAAW,CAAE,IAAF,CAAX;AACAC,MAAAA,QAAQ,CAACG,OAAT,GAAmB/C,OAAnB;AAEA8C,MAAAA,UAAU;AAEVD,MAAAA,UAAU,CAACE,OAAX,GAAqBG,UAAU,CAAE,MAAM;AACtCP,QAAAA,WAAW,CAAE,KAAF,CAAX;AACA,OAF8B,EAE5B,GAF4B,CAA/B;AAGA;;AAED,WAAO,MAAMG,UAAU,EAAvB;AACA,GAbD,EAaG,CAAE9C,OAAF,CAbH;;AAeA,MAAK,CAAE0C,QAAP,EAAkB;AACjB,WAAO,IAAP;AACA;;AAED,SACC,4BAAC,qBAAD;AACC,IAAA,QAAQ,EAAGT,QADZ;AAEC,IAAA,qBAAqB,MAFtB;AAGC,IAAA,qBAAqB,EAAGjC,OAHzB;AAIC,IAAA,KAAK,EAAG;AAJT,KAMC;AAAK,IAAA,SAAS,EAAC,kCAAf;AAAkD,IAAA,KAAK,EAAGI;AAA1D,IAND,CADD;AAUA","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { __ } from '@wordpress/i18n';\nimport {\n\tPlatform,\n\tuseState,\n\tuseRef,\n\tuseEffect,\n\tuseMemo,\n} from '@wordpress/element';\nimport { getBlockSupport } from '@wordpress/blocks';\nimport {\n\t__experimentalUseCustomUnits as useCustomUnits,\n\t__experimentalBoxControl as BoxControl,\n} from '@wordpress/components';\nimport isShallowEqual from '@wordpress/is-shallow-equal';\n\n/**\n * Internal dependencies\n */\nimport useSetting from '../components/use-setting';\nimport {\n\tAXIAL_SIDES,\n\tSPACING_SUPPORT_KEY,\n\tuseCustomSides,\n\tuseIsDimensionsSupportValid,\n} from './dimensions';\nimport { cleanEmptyObject } from './utils';\nimport BlockPopover from '../components/block-popover';\nimport SpacingSizesControl from '../components/spacing-sizes-control';\nimport {\n\tgetSpacingPresetCssVar,\n\tisValueSpacingPreset,\n} from '../components/spacing-sizes-control/utils';\n/**\n * Determines if there is padding support.\n *\n * @param {string|Object} blockType Block name or Block Type object.\n *\n * @return {boolean} Whether there is support.\n */\nexport function hasPaddingSupport( blockType ) {\n\tconst support = getBlockSupport( blockType, SPACING_SUPPORT_KEY );\n\treturn !! ( true === support || support?.padding );\n}\n\n/**\n * Checks if there is a current value in the padding block support attributes.\n *\n * @param {Object} props Block props.\n * @return {boolean} Whether or not the block has a padding value set.\n */\nexport function hasPaddingValue( props ) {\n\treturn props.attributes.style?.spacing?.padding !== undefined;\n}\n\n/**\n * Resets the padding block support attributes. This can be used when disabling\n * the padding support controls for a block via a `ToolsPanel`.\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 resetPadding( { attributes = {}, setAttributes } ) {\n\tconst { style } = attributes;\n\n\tsetAttributes( {\n\t\tstyle: cleanEmptyObject( {\n\t\t\t...style,\n\t\t\tspacing: {\n\t\t\t\t...style?.spacing,\n\t\t\t\tpadding: undefined,\n\t\t\t},\n\t\t} ),\n\t} );\n}\n\n/**\n * Custom hook that checks if padding settings have been disabled.\n *\n * @param {string} name The name of the block.\n *\n * @return {boolean} Whether padding setting is disabled.\n */\nexport function useIsPaddingDisabled( { name: blockName } = {} ) {\n\tconst isDisabled = ! useSetting( 'spacing.padding' );\n\tconst isInvalid = ! useIsDimensionsSupportValid( blockName, 'padding' );\n\n\treturn ! hasPaddingSupport( blockName ) || isDisabled || isInvalid;\n}\n\n/**\n * Inspector control panel containing the padding related configuration\n *\n * @param {Object} props\n *\n * @return {WPElement} Padding edit element.\n */\nexport function PaddingEdit( props ) {\n\tconst {\n\t\tname: blockName,\n\t\tattributes: { style },\n\t\tsetAttributes,\n\t} = props;\n\n\tconst spacingSizes = useSetting( 'spacing.spacingSizes' );\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, 'padding' );\n\tconst splitOnAxis =\n\t\tsides && sides.some( ( side ) => AXIAL_SIDES.includes( side ) );\n\n\tif ( useIsPaddingDisabled( 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\tpadding: next,\n\t\t\t},\n\t\t};\n\n\t\tsetAttributes( {\n\t\t\tstyle: cleanEmptyObject( newStyle ),\n\t\t} );\n\t};\n\n\treturn Platform.select( {\n\t\tweb: (\n\t\t\t<>\n\t\t\t\t{ ( ! spacingSizes || spacingSizes?.length === 0 ) && (\n\t\t\t\t\t<BoxControl\n\t\t\t\t\t\tvalues={ style?.spacing?.padding }\n\t\t\t\t\t\tonChange={ onChange }\n\t\t\t\t\t\tlabel={ __( 'Padding' ) }\n\t\t\t\t\t\tsides={ sides }\n\t\t\t\t\t\tunits={ units }\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{ spacingSizes?.length > 0 && (\n\t\t\t\t\t<SpacingSizesControl\n\t\t\t\t\t\tvalues={ style?.spacing?.padding }\n\t\t\t\t\t\tonChange={ onChange }\n\t\t\t\t\t\tlabel={ __( 'Padding' ) }\n\t\t\t\t\t\tsides={ sides }\n\t\t\t\t\t\tunits={ units }\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</>\n\t\t),\n\t\tnative: null,\n\t} );\n}\n\nexport function PaddingVisualizer( { clientId, attributes } ) {\n\tconst padding = attributes?.style?.spacing?.padding;\n\tconst style = useMemo( () => {\n\t\treturn {\n\t\t\tborderTopWidth: isValueSpacingPreset( padding?.top )\n\t\t\t\t? getSpacingPresetCssVar( padding?.top )\n\t\t\t\t: padding?.top,\n\t\t\tborderRightWidth: isValueSpacingPreset( padding?.right )\n\t\t\t\t? getSpacingPresetCssVar( padding?.right )\n\t\t\t\t: padding?.right,\n\t\t\tborderBottomWidth: isValueSpacingPreset( padding?.bottom )\n\t\t\t\t? getSpacingPresetCssVar( padding?.bottom )\n\t\t\t\t: padding?.bottom,\n\t\t\tborderLeftWidth: isValueSpacingPreset( padding?.left )\n\t\t\t\t? getSpacingPresetCssVar( padding?.left )\n\t\t\t\t: padding?.left,\n\t\t};\n\t}, [ padding ] );\n\n\tconst [ isActive, setIsActive ] = useState( false );\n\tconst valueRef = useRef( padding );\n\tconst timeoutRef = useRef();\n\n\tconst clearTimer = () => {\n\t\tif ( timeoutRef.current ) {\n\t\t\twindow.clearTimeout( timeoutRef.current );\n\t\t}\n\t};\n\n\tuseEffect( () => {\n\t\tif ( ! isShallowEqual( padding, valueRef.current ) ) {\n\t\t\tsetIsActive( true );\n\t\t\tvalueRef.current = padding;\n\n\t\t\tclearTimer();\n\n\t\t\ttimeoutRef.current = setTimeout( () => {\n\t\t\t\tsetIsActive( false );\n\t\t\t}, 400 );\n\t\t}\n\n\t\treturn () => clearTimer();\n\t}, [ padding ] );\n\n\tif ( ! isActive ) {\n\t\treturn null;\n\t}\n\n\treturn (\n\t\t<BlockPopover\n\t\t\tclientId={ clientId }\n\t\t\t__unstableCoverTarget\n\t\t\t__unstableRefreshSize={ padding }\n\t\t\tshift={ false }\n\t\t>\n\t\t\t<div className=\"block-editor__padding-visualizer\" style={ style } />\n\t\t</BlockPopover>\n\t);\n}\n"]}
1
+ {"version":3,"sources":["@wordpress/block-editor/src/hooks/padding.js"],"names":["hasPaddingSupport","blockType","support","SPACING_SUPPORT_KEY","padding","hasPaddingValue","props","attributes","style","spacing","undefined","resetPadding","setAttributes","useIsPaddingDisabled","name","blockName","isDisabled","isInvalid","PaddingEdit","onMouseOver","onMouseOut","spacingSizes","units","availableUnits","sides","splitOnAxis","some","side","AXIAL_SIDES","includes","onChange","next","newStyle","Platform","select","web","length","native","PaddingVisualizer","clientId","forceShow","borderTopWidth","top","borderRightWidth","right","borderBottomWidth","bottom","borderLeftWidth","left","isActive","setIsActive","valueRef","timeoutRef","clearTimer","current","window","clearTimeout","setTimeout"],"mappings":";;;;;;;;;;;;;;AAIA;;AADA;;AAQA;;AACA;;AAIA;;AAKA;;AACA;;AAMA;;AACA;;AACA;;AACA;;AA/BA;AACA;AACA;;AAgBA;AACA;AACA;;AAYA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,SAASA,iBAAT,CAA4BC,SAA5B,EAAwC;AAC9C,QAAMC,OAAO,GAAG,6BAAiBD,SAAjB,EAA4BE,+BAA5B,CAAhB;AACA,SAAO,CAAC,EAAI,SAASD,OAAT,IAAoBA,OAApB,aAAoBA,OAApB,eAAoBA,OAAO,CAAEE,OAAjC,CAAR;AACA;AAED;AACA;AACA;AACA;AACA;AACA;;;AACO,SAASC,eAAT,CAA0BC,KAA1B,EAAkC;AAAA;;AACxC,SAAO,0BAAAA,KAAK,CAACC,UAAN,CAAiBC,KAAjB,0GAAwBC,OAAxB,kFAAiCL,OAAjC,MAA6CM,SAApD;AACA;AAED;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;AACO,SAASC,YAAT,OAA4D;AAAA,MAArC;AAAEJ,IAAAA,UAAU,GAAG,EAAf;AAAmBK,IAAAA;AAAnB,GAAqC;AAClE,QAAM;AAAEJ,IAAAA;AAAF,MAAYD,UAAlB;AAEAK,EAAAA,aAAa,CAAE;AACdJ,IAAAA,KAAK,EAAE,6BAAkB,EACxB,GAAGA,KADqB;AAExBC,MAAAA,OAAO,EAAE,EACR,IAAGD,KAAH,aAAGA,KAAH,uBAAGA,KAAK,CAAEC,OAAV,CADQ;AAERL,QAAAA,OAAO,EAAEM;AAFD;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G,sBAAnB;;AAEA,QAAMC,UAAU,GAAG,MAAM;AACxB,QAAKD,UAAU,CAACE,OAAhB,EAA0B;AACzBC,MAAAA,MAAM,CAACC,YAAP,CAAqBJ,UAAU,CAACE,OAAhC;AACA;AACD,GAJD;;AAMA,0BAAW,MAAM;AAChB,QAAK,CAAE,6BAAgBlD,OAAhB,EAAyB+C,QAAQ,CAACG,OAAlC,CAAF,IAAiD,CAAEd,SAAxD,EAAoE;AACnEU,MAAAA,WAAW,CAAE,IAAF,CAAX;AACAC,MAAAA,QAAQ,CAACG,OAAT,GAAmBlD,OAAnB;AAEAgD,MAAAA,UAAU,CAACE,OAAX,GAAqBG,UAAU,CAAE,MAAM;AACtCP,QAAAA,WAAW,CAAE,KAAF,CAAX;AACA,OAF8B,EAE5B,GAF4B,CAA/B;AAGA;;AAED,WAAO,MAAM;AACZA,MAAAA,WAAW,CAAE,KAAF,CAAX;AACAG,MAAAA,UAAU;AACV,KAHD;AAIA,GAdD,EAcG,CAAEjD,OAAF,EAAWoC,SAAX,CAdH;;AAgBA,MAAK,CAAES,QAAF,IAAc,CAAET,SAArB,EAAiC;AAChC,WAAO,IAAP;AACA;;AAED,SACC,4BAAC,qBAAD;AACC,IAAA,QAAQ,EAAGD,QADZ;AAEC,IAAA,qBAAqB,MAFtB;AAGC,IAAA,qBAAqB,EAAGnC,OAHzB;AAIC,IAAA,KAAK,EAAG;AAJT,KAMC;AAAK,IAAA,SAAS,EAAC,kCAAf;AAAkD,IAAA,KAAK,EAAGI;AAA1D,IAND,CADD;AAUA","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { __ } from '@wordpress/i18n';\nimport {\n\tPlatform,\n\tuseState,\n\tuseRef,\n\tuseEffect,\n\tuseMemo,\n} from '@wordpress/element';\nimport { getBlockSupport } from '@wordpress/blocks';\nimport {\n\t__experimentalUseCustomUnits as useCustomUnits,\n\t__experimentalBoxControl as BoxControl,\n} from '@wordpress/components';\nimport isShallowEqual from '@wordpress/is-shallow-equal';\n\n/**\n * Internal dependencies\n */\nimport useSetting from '../components/use-setting';\nimport {\n\tAXIAL_SIDES,\n\tSPACING_SUPPORT_KEY,\n\tuseCustomSides,\n\tuseIsDimensionsSupportValid,\n} from './dimensions';\nimport { cleanEmptyObject } from './utils';\nimport BlockPopover from '../components/block-popover';\nimport SpacingSizesControl from '../components/spacing-sizes-control';\nimport { getSpacingPresetCssVar } from '../components/spacing-sizes-control/utils';\n/**\n * Determines if there is padding support.\n *\n * @param {string|Object} blockType Block name or Block Type object.\n *\n * @return {boolean} Whether there is support.\n */\nexport function hasPaddingSupport( blockType ) {\n\tconst support = getBlockSupport( blockType, SPACING_SUPPORT_KEY );\n\treturn !! ( true === support || support?.padding );\n}\n\n/**\n * Checks if there is a current value in the padding block support attributes.\n *\n * @param {Object} props Block props.\n * @return {boolean} Whether or not the block has a padding value set.\n */\nexport function hasPaddingValue( props ) {\n\treturn props.attributes.style?.spacing?.padding !== undefined;\n}\n\n/**\n * Resets the padding block support attributes. This can be used when disabling\n * the padding support controls for a block via a `ToolsPanel`.\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 resetPadding( { attributes = {}, setAttributes } ) {\n\tconst { style } = attributes;\n\n\tsetAttributes( {\n\t\tstyle: cleanEmptyObject( {\n\t\t\t...style,\n\t\t\tspacing: {\n\t\t\t\t...style?.spacing,\n\t\t\t\tpadding: undefined,\n\t\t\t},\n\t\t} ),\n\t} );\n}\n\n/**\n * Custom hook that checks if padding settings have been disabled.\n *\n * @param {string} name The name of the block.\n *\n * @return {boolean} Whether padding setting is disabled.\n */\nexport function useIsPaddingDisabled( { name: blockName } = {} ) {\n\tconst isDisabled = ! useSetting( 'spacing.padding' );\n\tconst isInvalid = ! useIsDimensionsSupportValid( blockName, 'padding' );\n\n\treturn ! hasPaddingSupport( blockName ) || isDisabled || isInvalid;\n}\n\n/**\n * Inspector control panel containing the padding related configuration\n *\n * @param {Object} props\n *\n * @return {WPElement} Padding edit element.\n */\nexport function PaddingEdit( props ) {\n\tconst {\n\t\tname: blockName,\n\t\tattributes: { style },\n\t\tsetAttributes,\n\t\tonMouseOver,\n\t\tonMouseOut,\n\t} = props;\n\n\tconst spacingSizes = useSetting( 'spacing.spacingSizes' );\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, 'padding' );\n\tconst splitOnAxis =\n\t\tsides && sides.some( ( side ) => AXIAL_SIDES.includes( side ) );\n\n\tif ( useIsPaddingDisabled( 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\tpadding: next,\n\t\t\t},\n\t\t};\n\n\t\tsetAttributes( {\n\t\t\tstyle: cleanEmptyObject( newStyle ),\n\t\t} );\n\t};\n\n\treturn Platform.select( {\n\t\tweb: (\n\t\t\t<>\n\t\t\t\t{ ( ! spacingSizes || spacingSizes?.length === 0 ) && (\n\t\t\t\t\t<BoxControl\n\t\t\t\t\t\tvalues={ style?.spacing?.padding }\n\t\t\t\t\t\tonChange={ onChange }\n\t\t\t\t\t\tlabel={ __( 'Padding' ) }\n\t\t\t\t\t\tsides={ sides }\n\t\t\t\t\t\tunits={ units }\n\t\t\t\t\t\tallowReset={ false }\n\t\t\t\t\t\tsplitOnAxis={ splitOnAxis }\n\t\t\t\t\t\tonMouseOver={ onMouseOver }\n\t\t\t\t\t\tonMouseOut={ onMouseOut }\n\t\t\t\t\t/>\n\t\t\t\t) }\n\t\t\t\t{ spacingSizes?.length > 0 && (\n\t\t\t\t\t<SpacingSizesControl\n\t\t\t\t\t\tvalues={ style?.spacing?.padding }\n\t\t\t\t\t\tonChange={ onChange }\n\t\t\t\t\t\tlabel={ __( 'Padding' ) }\n\t\t\t\t\t\tsides={ sides }\n\t\t\t\t\t\tunits={ units }\n\t\t\t\t\t\tallowReset={ false }\n\t\t\t\t\t\tsplitOnAxis={ splitOnAxis }\n\t\t\t\t\t\tonMouseOver={ onMouseOver }\n\t\t\t\t\t\tonMouseOut={ onMouseOut }\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\nexport function PaddingVisualizer( { clientId, attributes, forceShow } ) {\n\tconst padding = attributes?.style?.spacing?.padding;\n\tconst style = useMemo( () => {\n\t\treturn {\n\t\t\tborderTopWidth: padding?.top\n\t\t\t\t? getSpacingPresetCssVar( padding?.top )\n\t\t\t\t: 0,\n\t\t\tborderRightWidth: padding?.right\n\t\t\t\t? getSpacingPresetCssVar( padding?.right )\n\t\t\t\t: 0,\n\t\t\tborderBottomWidth: padding?.bottom\n\t\t\t\t? getSpacingPresetCssVar( padding?.bottom )\n\t\t\t\t: 0,\n\t\t\tborderLeftWidth: padding?.left\n\t\t\t\t? getSpacingPresetCssVar( padding?.left )\n\t\t\t\t: 0,\n\t\t};\n\t}, [ padding ] );\n\n\tconst [ isActive, setIsActive ] = useState( false );\n\tconst valueRef = useRef( padding );\n\tconst timeoutRef = useRef();\n\n\tconst clearTimer = () => {\n\t\tif ( timeoutRef.current ) {\n\t\t\twindow.clearTimeout( timeoutRef.current );\n\t\t}\n\t};\n\n\tuseEffect( () => {\n\t\tif ( ! isShallowEqual( padding, valueRef.current ) && ! forceShow ) {\n\t\t\tsetIsActive( true );\n\t\t\tvalueRef.current = padding;\n\n\t\t\ttimeoutRef.current = setTimeout( () => {\n\t\t\t\tsetIsActive( false );\n\t\t\t}, 400 );\n\t\t}\n\n\t\treturn () => {\n\t\t\tsetIsActive( false );\n\t\t\tclearTimer();\n\t\t};\n\t}, [ padding, forceShow ] );\n\n\tif ( ! isActive && ! forceShow ) {\n\t\treturn null;\n\t}\n\n\treturn (\n\t\t<BlockPopover\n\t\t\tclientId={ clientId }\n\t\t\t__unstableCoverTarget\n\t\t\t__unstableRefreshSize={ padding }\n\t\t\tshift={ false }\n\t\t>\n\t\t\t<div className=\"block-editor__padding-visualizer\" style={ style } />\n\t\t</BlockPopover>\n\t);\n}\n"]}
@@ -50,7 +50,7 @@ var _utils = require("./utils");
50
50
  /**
51
51
  * Internal dependencies
52
52
  */
53
- const styleSupportKeys = [..._typography.TYPOGRAPHY_SUPPORT_KEYS, _border.BORDER_SUPPORT_KEY, _color.COLOR_SUPPORT_KEY, _dimensions.SPACING_SUPPORT_KEY];
53
+ const styleSupportKeys = [..._typography.TYPOGRAPHY_SUPPORT_KEYS, _border.BORDER_SUPPORT_KEY, _color.COLOR_SUPPORT_KEY, _dimensions.DIMENSIONS_SUPPORT_KEY, _dimensions.SPACING_SUPPORT_KEY];
54
54
 
55
55
  const hasStyleSupport = blockType => styleSupportKeys.some(key => (0, _blocks.hasBlockSupport)(blockType, key));
56
56
  /**
@@ -110,7 +110,8 @@ const skipSerializationPathsEdit = {
110
110
  [`${_border.BORDER_SUPPORT_KEY}.__experimentalSkipSerialization`]: ['border'],
111
111
  [`${_color.COLOR_SUPPORT_KEY}.__experimentalSkipSerialization`]: [_color.COLOR_SUPPORT_KEY],
112
112
  [`${_typography.TYPOGRAPHY_SUPPORT_KEY}.__experimentalSkipSerialization`]: [_typography.TYPOGRAPHY_SUPPORT_KEY],
113
- [`${_dimensions.SPACING_SUPPORT_KEY}.__experimentalSkipSerialization`]: ['spacing']
113
+ [`${_dimensions.DIMENSIONS_SUPPORT_KEY}.__experimentalSkipSerialization`]: [_dimensions.DIMENSIONS_SUPPORT_KEY],
114
+ [`${_dimensions.SPACING_SUPPORT_KEY}.__experimentalSkipSerialization`]: [_dimensions.SPACING_SUPPORT_KEY]
114
115
  };
115
116
  /**
116
117
  * A dictionary of paths to flag skipping block support serialization as the key,
@@ -1 +1 @@
1
- {"version":3,"sources":["@wordpress/block-editor/src/hooks/style.js"],"names":["styleSupportKeys","TYPOGRAPHY_SUPPORT_KEYS","BORDER_SUPPORT_KEY","COLOR_SUPPORT_KEY","SPACING_SUPPORT_KEY","hasStyleSupport","blockType","some","key","getInlineStyles","styles","output","forEach","rule","value","addAttribute","settings","attributes","style","Object","assign","type","skipSerializationPathsEdit","TYPOGRAPHY_SUPPORT_KEY","skipSerializationPathsSave","renamedFeatures","gradients","omitStyle","paths","preserveReference","newStyle","JSON","parse","stringify","Array","isArray","path","split","length","firstSubpath","restPath","addSaveProps","props","skipPaths","entries","indicator","skipSerialization","featureName","feature","addEditProps","existingGetEditWrapperProps","getEditWrapperProps","withBlockControls","BlockEdit","shouldDisplayControls","withElementsStyles","BlockListBlock","blockElementsContainerIdentifier","skipLinkColorSerialization","name","rawElementsStyles","elements","elementCssRules","keys","filteredElementsStyles","link","color","undefined","elementName","elementStyles","cssRule","selector","ELEMENTS","push","element","BlockList","__unstableElementContext","__html","className"],"mappings":";;;;;;;;;;;;;AAQA;;;;AALA;;AAMA;;AACA;;AAKA;;AACA;;AAKA;;AACA;;AACA;;AACA;;AAKA;;AACA;;AACA;;AA/BA;AACA;AACA;;AAGA;AACA;AACA;;AAWA;AACA;AACA;AAaA,MAAMA,gBAAgB,GAAG,CACxB,GAAGC,mCADqB,EAExBC,0BAFwB,EAGxBC,wBAHwB,EAIxBC,+BAJwB,CAAzB;;AAOA,MAAMC,eAAe,GAAKC,SAAF,IACvBN,gBAAgB,CAACO,IAAjB,CAAyBC,GAAF,IAAW,6BAAiBF,SAAjB,EAA4BE,GAA5B,CAAlC,CADD;AAGA;AACA;AACA;AACA;AACA;AACA;AACA;;;AACO,SAASC,eAAT,GAAwC;AAAA,MAAdC,MAAc,uEAAL,EAAK;AAC9C,QAAMC,MAAM,GAAG,EAAf,CAD8C,CAE9C;AACA;;AACA,gCAAaD,MAAb,EAAsBE,OAAtB,CAAiCC,IAAF,IAAY;AAC1CF,IAAAA,MAAM,CAAEE,IAAI,CAACL,GAAP,CAAN,GAAqB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KAAjB,0EAAwB2C,QAAxB,GACG,yBACAnB,KAAK,CAACoC,SADN,EAEArB,gCAFA,CADH,GAKGf,KAAK,CAACoC;AARX,KAZD,CADD;AA0BA,CA3EyB,CAA3B;AA8EA,sBACC,0BADD,EAEC,yBAFD,EAGC/D,YAHD;AAMA,sBACC,kCADD,EAEC,yBAFD,EAGC0B,YAHD;AAMA,sBACC,0BADD,EAEC,yBAFD,EAGCQ,YAHD;AAMA,sBACC,kBADD,EAEC,gCAFD,EAGCG,iBAHD;AAMA,sBACC,uBADD,EAEC,kCAFD,EAGCG,kBAHD","sourcesContent":["/**\n * External dependencies\n */\nimport classnames from 'classnames';\n\n/**\n * WordPress dependencies\n */\nimport { useContext, useMemo, createPortal } from '@wordpress/element';\nimport { addFilter } from '@wordpress/hooks';\nimport {\n\tgetBlockSupport,\n\thasBlockSupport,\n\t__EXPERIMENTAL_ELEMENTS as ELEMENTS,\n} from '@wordpress/blocks';\nimport { createHigherOrderComponent, useInstanceId } from '@wordpress/compose';\nimport { getCSSRules, compileCSS } 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\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 output = {};\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\tgetCSSRules( styles ).forEach( ( rule ) => {\n\t\toutput[ rule.key ] = rule.value;\n\t} );\n\n\treturn output;\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 * A utility function used to remove one or more paths from a style object.\n * Works in a way similar to Lodash's `omit()`. See unit tests and examples below.\n *\n * It supports a single string path:\n *\n * ```\n * omitStyle( { color: 'red' }, 'color' ); // {}\n * ```\n *\n * or an array of paths:\n *\n * ```\n * omitStyle( { color: 'red', background: '#fff' }, [ 'color', 'background' ] ); // {}\n * ```\n *\n * It also allows you to specify paths at multiple levels in a string.\n *\n * ```\n * omitStyle( { typography: { textDecoration: 'underline' } }, 'typography.textDecoration' ); // {}\n * ```\n *\n * You can remove multiple paths at the same time:\n *\n * ```\n * omitStyle(\n * \t\t{\n * \t\t\ttypography: {\n * \t\t\t\ttextDecoration: 'underline',\n * \t\t\t\ttextTransform: 'uppercase',\n * \t\t\t}\n *\t\t},\n *\t\t[\n * \t\t\t'typography.textDecoration',\n * \t\t\t'typography.textTransform',\n *\t\t]\n * );\n * // {}\n * ```\n *\n * You can also specify nested paths as arrays:\n *\n * ```\n * omitStyle(\n * \t\t{\n * \t\t\ttypography: {\n * \t\t\t\ttextDecoration: 'underline',\n * \t\t\t\ttextTransform: 'uppercase',\n * \t\t\t}\n *\t\t},\n *\t\t[\n * \t\t\t[ 'typography', 'textDecoration' ],\n * \t\t\t[ 'typography', 'textTransform' ],\n *\t\t]\n * );\n * // {}\n * ```\n *\n * With regards to nesting of styles, infinite depth is supported:\n *\n * ```\n * omitStyle(\n * \t\t{\n * \t\t\tborder: {\n * \t\t\t\tradius: {\n * \t\t\t\t\ttopLeft: '10px',\n * \t\t\t\t\ttopRight: '0.5rem',\n * \t\t\t\t}\n * \t\t\t}\n *\t\t},\n *\t\t[\n * \t\t\t[ 'border', 'radius', 'topRight' ],\n *\t\t]\n * );\n * // { border: { radius: { topLeft: '10px' } } }\n * ```\n *\n * The third argument, `preserveReference`, defines how to treat the input style object.\n * It is mostly necessary to properly handle mutation when recursively handling the style object.\n * Defaulting to `false`, this will always create a new object, avoiding to mutate `style`.\n * However, when recursing, we change that value to `true` in order to work with a single copy\n * of the original style object.\n *\n * @see https://lodash.com/docs/4.17.15#omit\n *\n * @param {Object} style Styles object.\n * @param {Array|string} paths Paths to remove.\n * @param {boolean} preserveReference True to mutate the `style` object, false otherwise.\n * @return {Object} Styles object with the specified paths removed.\n */\nexport function omitStyle( style, paths, preserveReference = false ) {\n\tif ( ! style ) {\n\t\treturn style;\n\t}\n\n\tlet newStyle = style;\n\tif ( ! preserveReference ) {\n\t\tnewStyle = JSON.parse( JSON.stringify( style ) );\n\t}\n\n\tif ( ! Array.isArray( paths ) ) {\n\t\tpaths = [ paths ];\n\t}\n\n\tpaths.forEach( ( path ) => {\n\t\tif ( ! Array.isArray( path ) ) {\n\t\t\tpath = path.split( '.' );\n\t\t}\n\n\t\tif ( path.length > 1 ) {\n\t\t\tconst [ firstSubpath, ...restPath ] = path;\n\t\t\tomitStyle( newStyle[ firstSubpath ], [ restPath ], true );\n\t\t} else if ( path.length === 1 ) {\n\t\t\tdelete newStyle[ path[ 0 ] ];\n\t\t}\n\t} );\n\n\treturn newStyle;\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\tObject.entries( skipPaths ).forEach( ( [ indicator, path ] ) => {\n\t\tconst skipSerialization = getBlockSupport( blockType, indicator );\n\n\t\tif ( skipSerialization === true ) {\n\t\t\tstyle = omitStyle( 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 = omitStyle( 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 elements 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\tconst styles = useMemo( () => {\n\t\t\tconst rawElementsStyles = props.attributes.style?.elements;\n\t\t\tconst elementCssRules = [];\n\t\t\tif (\n\t\t\t\trawElementsStyles &&\n\t\t\t\tObject.keys( rawElementsStyles ).length > 0\n\t\t\t) {\n\t\t\t\t// Remove values based on whether serialization has been skipped for a specific style.\n\t\t\t\tconst filteredElementsStyles = {\n\t\t\t\t\t...rawElementsStyles,\n\t\t\t\t\tlink: {\n\t\t\t\t\t\t...rawElementsStyles.link,\n\t\t\t\t\t\tcolor: ! skipLinkColorSerialization\n\t\t\t\t\t\t\t? rawElementsStyles.link?.color\n\t\t\t\t\t\t\t: undefined,\n\t\t\t\t\t},\n\t\t\t\t};\n\n\t\t\t\tfor ( const [ elementName, elementStyles ] of Object.entries(\n\t\t\t\t\tfilteredElementsStyles\n\t\t\t\t) ) {\n\t\t\t\t\tconst cssRule = compileCSS( elementStyles, {\n\t\t\t\t\t\t// The .editor-styles-wrapper selector is required on elements styles. As it is\n\t\t\t\t\t\t// added to all other editor styles, not providing it causes reset and global\n\t\t\t\t\t\t// styles to override element styles because of higher specificity.\n\t\t\t\t\t\tselector: `.editor-styles-wrapper .${ blockElementsContainerIdentifier } ${ ELEMENTS[ elementName ] }`,\n\t\t\t\t\t} );\n\t\t\t\t\tif ( !! cssRule ) {\n\t\t\t\t\t\telementCssRules.push( cssRule );\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t\treturn elementCssRules.length > 0 ? elementCssRules : undefined;\n\t\t}, [ props.attributes.style?.elements ] );\n\n\t\tconst element = useContext( BlockList.__unstableElementContext );\n\n\t\treturn (\n\t\t\t<>\n\t\t\t\t{ styles &&\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\tprops.attributes.style?.elements\n\t\t\t\t\t\t\t? classnames(\n\t\t\t\t\t\t\t\t\tprops.className,\n\t\t\t\t\t\t\t\t\tblockElementsContainerIdentifier\n\t\t\t\t\t\t\t )\n\t\t\t\t\t\t\t: props.className\n\t\t\t\t\t}\n\t\t\t\t/>\n\t\t\t</>\n\t\t);\n\t}\n);\n\naddFilter(\n\t'blocks.registerBlockType',\n\t'core/style/addAttribute',\n\taddAttribute\n);\n\naddFilter(\n\t'blocks.getSaveContent.extraProps',\n\t'core/style/addSaveProps',\n\taddSaveProps\n);\n\naddFilter(\n\t'blocks.registerBlockType',\n\t'core/style/addEditProps',\n\taddEditProps\n);\n\naddFilter(\n\t'editor.BlockEdit',\n\t'core/style/with-block-controls',\n\twithBlockControls\n);\n\naddFilter(\n\t'editor.BlockListBlock',\n\t'core/editor/with-elements-styles',\n\twithElementsStyles\n);\n"]}
1
+ {"version":3,"sources":["@wordpress/block-editor/src/hooks/style.js"],"names":["styleSupportKeys","TYPOGRAPHY_SUPPORT_KEYS","BORDER_SUPPORT_KEY","COLOR_SUPPORT_KEY","DIMENSIONS_SUPPORT_KEY","SPACING_SUPPORT_KEY","hasStyleSupport","blockType","some","key","getInlineStyles","styles","output","forEach","rule","value","addAttribute","settings","attributes","style","Object","assign","type","skipSerializationPathsEdit","TYPOGRAPHY_SUPPORT_KEY","skipSerializationPathsSave","renamedFeatures","gradients","omitStyle","paths","preserveReference","newStyle","JSON","parse","stringify","Array","isArray","path","split","length","firstSubpath","restPath","addSaveProps","props","skipPaths","entries","indicator","skipSerialization","featureName","feature","addEditProps","existingGetEditWrapperProps","getEditWrapperProps","withBlockControls","BlockEdit","shouldDisplayControls","withElementsStyles","BlockListBlock","blockElementsContainerIdentifier","skipLinkColorSerialization","name","rawElementsStyles","elements","elementCssRules","keys","filteredElementsStyles","link","color","undefined","elementName","elementStyles","cssRule","selector","ELEMENTS","push","element","BlockList","__unstableElementContext","__html","className"],"mappings":";;;;;;;;;;;;;AAQA;;;;AALA;;AAMA;;AACA;;AAKA;;AACA;;AAKA;;AACA;;AACA;;AACA;;AAKA;;AAKA;;AACA;;AAnCA;AACA;AACA;;AAGA;AACA;AACA;;AAWA;AACA;AACA;AAiBA,MAAMA,gBAAgB,GAAG,CACxB,GAAGC,mCADqB,EAExBC,0BAFwB,EAGxBC,wBAHwB,EAIxBC,kCAJwB,EAKxBC,+BALwB,CAAzB;;AAQA,MAAMC,eAAe,GAAKC,SAAF,IACvBP,gBAAgB,CAACQ,IAAjB,CAAyBC,GAAF,IAAW,6BAAiBF,SAAjB,EAA4BE,GAA5B,CAAlC,CADD;AAGA;AACA;AACA;AACA;AACA;AACA;AACA;;;AACO,SAASC,eAAT,GAAwC;AAAA,MAAdC,MAAc,uEAAL,EAAK;AAC9C,QAAMC,MAAM,GAAG,EAAf,CAD8C,CAE9C;AACA;;AACA,gCAAaD,MAAb,EAAsBE,OAAtB,CAAiCC,IAAF,IAAY;AAC1CF,IAAAA,MAAM,CAAEE,IAAI,CAACL,GAAP,CAAN,GAAqBK,IAAI,CAACC,KAA1B;AACA,GAFD;AAIA,SAAOH,MAAP;AACA;AAED;AACA;AACA;AACA;AACA;AACA;AACA;;;AACA,SAASI,YAAT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KAAK,CAACoC,SADN,EAEArB,gCAFA,CADH,GAKGf,KAAK,CAACoC;AARX,KAZD,CADD;AA0BA,CA3EyB,CAA3B;AA8EA,sBACC,0BADD,EAEC,yBAFD,EAGC/D,YAHD;AAMA,sBACC,kCADD,EAEC,yBAFD,EAGC0B,YAHD;AAMA,sBACC,0BADD,EAEC,yBAFD,EAGCQ,YAHD;AAMA,sBACC,kBADD,EAEC,gCAFD,EAGCG,iBAHD;AAMA,sBACC,uBADD,EAEC,kCAFD,EAGCG,kBAHD","sourcesContent":["/**\n * External dependencies\n */\nimport classnames from 'classnames';\n\n/**\n * WordPress dependencies\n */\nimport { useContext, useMemo, createPortal } from '@wordpress/element';\nimport { addFilter } from '@wordpress/hooks';\nimport {\n\tgetBlockSupport,\n\thasBlockSupport,\n\t__EXPERIMENTAL_ELEMENTS as ELEMENTS,\n} from '@wordpress/blocks';\nimport { createHigherOrderComponent, useInstanceId } from '@wordpress/compose';\nimport { getCSSRules, compileCSS } 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 {\n\tDIMENSIONS_SUPPORT_KEY,\n\tSPACING_SUPPORT_KEY,\n\tDimensionsPanel,\n} 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\tDIMENSIONS_SUPPORT_KEY,\n\tSPACING_SUPPORT_KEY,\n];\n\nconst hasStyleSupport = ( blockType ) =>\n\tstyleSupportKeys.some( ( key ) => hasBlockSupport( blockType, key ) );\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 output = {};\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\tgetCSSRules( styles ).forEach( ( rule ) => {\n\t\toutput[ rule.key ] = rule.value;\n\t} );\n\n\treturn output;\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[ `${ DIMENSIONS_SUPPORT_KEY }.__experimentalSkipSerialization` ]: [\n\t\tDIMENSIONS_SUPPORT_KEY,\n\t],\n\t[ `${ SPACING_SUPPORT_KEY }.__experimentalSkipSerialization` ]: [\n\t\tSPACING_SUPPORT_KEY,\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 * A utility function used to remove one or more paths from a style object.\n * Works in a way similar to Lodash's `omit()`. See unit tests and examples below.\n *\n * It supports a single string path:\n *\n * ```\n * omitStyle( { color: 'red' }, 'color' ); // {}\n * ```\n *\n * or an array of paths:\n *\n * ```\n * omitStyle( { color: 'red', background: '#fff' }, [ 'color', 'background' ] ); // {}\n * ```\n *\n * It also allows you to specify paths at multiple levels in a string.\n *\n * ```\n * omitStyle( { typography: { textDecoration: 'underline' } }, 'typography.textDecoration' ); // {}\n * ```\n *\n * You can remove multiple paths at the same time:\n *\n * ```\n * omitStyle(\n * \t\t{\n * \t\t\ttypography: {\n * \t\t\t\ttextDecoration: 'underline',\n * \t\t\t\ttextTransform: 'uppercase',\n * \t\t\t}\n *\t\t},\n *\t\t[\n * \t\t\t'typography.textDecoration',\n * \t\t\t'typography.textTransform',\n *\t\t]\n * );\n * // {}\n * ```\n *\n * You can also specify nested paths as arrays:\n *\n * ```\n * omitStyle(\n * \t\t{\n * \t\t\ttypography: {\n * \t\t\t\ttextDecoration: 'underline',\n * \t\t\t\ttextTransform: 'uppercase',\n * \t\t\t}\n *\t\t},\n *\t\t[\n * \t\t\t[ 'typography', 'textDecoration' ],\n * \t\t\t[ 'typography', 'textTransform' ],\n *\t\t]\n * );\n * // {}\n * ```\n *\n * With regards to nesting of styles, infinite depth is supported:\n *\n * ```\n * omitStyle(\n * \t\t{\n * \t\t\tborder: {\n * \t\t\t\tradius: {\n * \t\t\t\t\ttopLeft: '10px',\n * \t\t\t\t\ttopRight: '0.5rem',\n * \t\t\t\t}\n * \t\t\t}\n *\t\t},\n *\t\t[\n * \t\t\t[ 'border', 'radius', 'topRight' ],\n *\t\t]\n * );\n * // { border: { radius: { topLeft: '10px' } } }\n * ```\n *\n * The third argument, `preserveReference`, defines how to treat the input style object.\n * It is mostly necessary to properly handle mutation when recursively handling the style object.\n * Defaulting to `false`, this will always create a new object, avoiding to mutate `style`.\n * However, when recursing, we change that value to `true` in order to work with a single copy\n * of the original style object.\n *\n * @see https://lodash.com/docs/4.17.15#omit\n *\n * @param {Object} style Styles object.\n * @param {Array|string} paths Paths to remove.\n * @param {boolean} preserveReference True to mutate the `style` object, false otherwise.\n * @return {Object} Styles object with the specified paths removed.\n */\nexport function omitStyle( style, paths, preserveReference = false ) {\n\tif ( ! style ) {\n\t\treturn style;\n\t}\n\n\tlet newStyle = style;\n\tif ( ! preserveReference ) {\n\t\tnewStyle = JSON.parse( JSON.stringify( style ) );\n\t}\n\n\tif ( ! Array.isArray( paths ) ) {\n\t\tpaths = [ paths ];\n\t}\n\n\tpaths.forEach( ( path ) => {\n\t\tif ( ! Array.isArray( path ) ) {\n\t\t\tpath = path.split( '.' );\n\t\t}\n\n\t\tif ( path.length > 1 ) {\n\t\t\tconst [ firstSubpath, ...restPath ] = path;\n\t\t\tomitStyle( newStyle[ firstSubpath ], [ restPath ], true );\n\t\t} else if ( path.length === 1 ) {\n\t\t\tdelete newStyle[ path[ 0 ] ];\n\t\t}\n\t} );\n\n\treturn newStyle;\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\tObject.entries( skipPaths ).forEach( ( [ indicator, path ] ) => {\n\t\tconst skipSerialization = getBlockSupport( blockType, indicator );\n\n\t\tif ( skipSerialization === true ) {\n\t\t\tstyle = omitStyle( 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 = omitStyle( 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 elements 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\tconst styles = useMemo( () => {\n\t\t\tconst rawElementsStyles = props.attributes.style?.elements;\n\t\t\tconst elementCssRules = [];\n\t\t\tif (\n\t\t\t\trawElementsStyles &&\n\t\t\t\tObject.keys( rawElementsStyles ).length > 0\n\t\t\t) {\n\t\t\t\t// Remove values based on whether serialization has been skipped for a specific style.\n\t\t\t\tconst filteredElementsStyles = {\n\t\t\t\t\t...rawElementsStyles,\n\t\t\t\t\tlink: {\n\t\t\t\t\t\t...rawElementsStyles.link,\n\t\t\t\t\t\tcolor: ! skipLinkColorSerialization\n\t\t\t\t\t\t\t? rawElementsStyles.link?.color\n\t\t\t\t\t\t\t: undefined,\n\t\t\t\t\t},\n\t\t\t\t};\n\n\t\t\t\tfor ( const [ elementName, elementStyles ] of Object.entries(\n\t\t\t\t\tfilteredElementsStyles\n\t\t\t\t) ) {\n\t\t\t\t\tconst cssRule = compileCSS( elementStyles, {\n\t\t\t\t\t\t// The .editor-styles-wrapper selector is required on elements styles. As it is\n\t\t\t\t\t\t// added to all other editor styles, not providing it causes reset and global\n\t\t\t\t\t\t// styles to override element styles because of higher specificity.\n\t\t\t\t\t\tselector: `.editor-styles-wrapper .${ blockElementsContainerIdentifier } ${ ELEMENTS[ elementName ] }`,\n\t\t\t\t\t} );\n\t\t\t\t\tif ( !! cssRule ) {\n\t\t\t\t\t\telementCssRules.push( cssRule );\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t\treturn elementCssRules.length > 0 ? elementCssRules : undefined;\n\t\t}, [ props.attributes.style?.elements ] );\n\n\t\tconst element = useContext( BlockList.__unstableElementContext );\n\n\t\treturn (\n\t\t\t<>\n\t\t\t\t{ styles &&\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\tprops.attributes.style?.elements\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"]}
@@ -19,21 +19,22 @@ var _blocks = require("@wordpress/blocks");
19
19
  /**
20
20
  * WordPress dependencies
21
21
  */
22
- const identity = x => x;
22
+
23
23
  /**
24
24
  * Removed falsy values from nested object.
25
25
  *
26
26
  * @param {*} object
27
27
  * @return {*} Object cleaned from falsy values
28
28
  */
29
-
30
-
31
29
  const cleanEmptyObject = object => {
32
30
  if (object === null || typeof object !== 'object' || Array.isArray(object)) {
33
31
  return object;
34
32
  }
35
33
 
36
- const cleanedNestedObjects = (0, _lodash.pickBy)((0, _lodash.mapValues)(object, cleanEmptyObject), identity);
34
+ const cleanedNestedObjects = Object.fromEntries(Object.entries((0, _lodash.mapValues)(object, cleanEmptyObject)).filter(_ref => {
35
+ let [, value] = _ref;
36
+ return Boolean(value);
37
+ }));
37
38
  return (0, _lodash.isEmpty)(cleanedNestedObjects) ? undefined : cleanedNestedObjects;
38
39
  };
39
40
 
@@ -76,8 +77,8 @@ function transformStyles(activeSupports, migrationPaths, result, source, index,
76
77
  }
77
78
 
78
79
  let returnBlock = result;
79
- Object.entries(activeSupports).forEach(_ref => {
80
- let [support, isActive] = _ref;
80
+ Object.entries(activeSupports).forEach(_ref2 => {
81
+ let [support, isActive] = _ref2;
81
82
 
82
83
  if (isActive) {
83
84
  migrationPaths[support].forEach(path => {
@@ -1 +1 @@
1
- {"version":3,"sources":["@wordpress/block-editor/src/hooks/utils.js"],"names":["identity","x","cleanEmptyObject","object","Array","isArray","cleanedNestedObjects","undefined","immutableSet","path","value","clone","transformStyles","activeSupports","migrationPaths","result","source","index","results","Object","values","every","isActive","length","innerBlocks","referenceBlockAttributes","attributes","returnBlock","entries","forEach","support","styleValue","shouldSkipSerialization","blockType","featureSet","feature","skipSerialization","__experimentalSkipSerialization","includes"],"mappings":";;;;;;;;;;AAGA;;AAKA;;AARA;AACA;AACA;;AAGA;AACA;AACA;AAGA,MAAMA,QAAQ,GAAKC,CAAF,IAASA,CAA1B;AAEA;AACA;AACA;AACA;AACA;AACA;;;AACO,MAAMC,gBAAgB,GAAKC,MAAF,IAAc;AAC7C,MACCA,MAAM,KAAK,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KAAF,CAAT,kDAAG,cAAiBS,UAA5C;AACA,KAFD,MAEO;AACN,aAAOX,MAAP;AACA;AACD;;AACD,MAAIY,WAAW,GAAGZ,MAAlB;AACAI,EAAAA,MAAM,CAACS,OAAP,CAAgBf,cAAhB,EAAiCgB,OAAjC,CAA0C,QAA6B;AAAA,QAA3B,CAAEC,OAAF,EAAWR,QAAX,CAA2B;;AACtE,QAAKA,QAAL,EAAgB;AACfR,MAAAA,cAAc,CAAEgB,OAAF,CAAd,CAA0BD,OAA1B,CAAqCpB,IAAF,IAAY;AAC9C,cAAMsB,UAAU,GAAG,iBAAKN,wBAAL,EAA+BhB,IAA/B,CAAnB;;AACA,YAAKsB,UAAL,EAAkB;AACjBJ,UAAAA,WAAW,GAAG,EACb,GAAGA,WADU;AAEbD,YAAAA,UAAU,EAAElB,YAAY,CACvBmB,WAAW,CAACD,UADW,EAEvBjB,IAFuB,EAGvBsB,UAHuB;AAFX,WAAd;AAQA;AACD,OAZD;AAaA;AACD,GAhBD;AAiBA,SAAOJ,WAAP;AACA;AAED;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;AACO,SAASK,uBAAT,CAAkCC,SAAlC,EAA6CC,UAA7C,EAAyDC,OAAzD,EAAmE;AACzE,QAAML,OAAO,GAAG,6BAAiBG,SAAjB,EAA4BC,UAA5B,CAAhB;AACA,QAAME,iBAAiB,GAAGN,OAAH,aAAGA,OAAH,uBAAGA,OAAO,CAAEO,+BAAnC;;AAEA,MAAKjC,KAAK,CAACC,OAAN,CAAe+B,iBAAf,CAAL,EAA0C;AACzC,WAAOA,iBAAiB,CAACE,QAAlB,CAA4BH,OAA5B,CAAP;AACA;;AAED,SAAOC,iBAAP;AACA","sourcesContent":["/**\n * External dependencies\n */\nimport { pickBy, isEmpty, mapValues, get, setWith, clone } from 'lodash';\n\n/**\n * WordPress dependencies\n */\nimport { getBlockSupport } from '@wordpress/blocks';\n\nconst identity = ( x ) => x;\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 (\n\t\tobject === null ||\n\t\ttypeof object !== 'object' ||\n\t\tArray.isArray( object )\n\t) {\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 (\n\t\tObject.values( activeSupports ?? {} ).every(\n\t\t\t( isActive ) => ! isActive\n\t\t)\n\t) {\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\tObject.entries( activeSupports ).forEach( ( [ support, isActive ] ) => {\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"]}
1
+ {"version":3,"sources":["@wordpress/block-editor/src/hooks/utils.js"],"names":["cleanEmptyObject","object","Array","isArray","cleanedNestedObjects","Object","fromEntries","entries","filter","value","Boolean","undefined","immutableSet","path","clone","transformStyles","activeSupports","migrationPaths","result","source","index","results","values","every","isActive","length","innerBlocks","referenceBlockAttributes","attributes","returnBlock","forEach","support","styleValue","shouldSkipSerialization","blockType","featureSet","feature","skipSerialization","__experimentalSkipSerialization","includes"],"mappings":";;;;;;;;;;AAGA;;AAKA;;AARA;AACA;AACA;;AAGA;AACA;AACA;;AAGA;AACA;AACA;AACA;AACA;AACA;AACO,MAAMA,gBAAgB,GAAKC,MAAF,IAAc;AAC7C,MACCA,MAAM,KAAK,IAAX,IACA,OAAOA,MAAP,KAAkB,QADlB,IAEAC,KAAK,CAACC,OAAN,CAAeF,MAAf,CAHD,EAIE;AACD,WAAOA,MAAP;AACA;;AACD,QAAMG,oBAAoB,GAAGC,MAAM,CAACC,WAAP,CAC5BD,MAAM,CAACE,OAAP,CAAgB,uBAAWN,MAAX,EAAmBD,gBAAnB,CAAhB,EAAwDQ,MAAxD,CACC;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MAAlB;AACAb,EAAAA,MAAM,CAACE,OAAP,CAAgBS,cAAhB,EAAiCc,OAAjC,CAA0C,SAA6B;AAAA,QAA3B,CAAEC,OAAF,EAAWP,QAAX,CAA2B;;AACtE,QAAKA,QAAL,EAAgB;AACfP,MAAAA,cAAc,CAAEc,OAAF,CAAd,CAA0BD,OAA1B,CAAqCjB,IAAF,IAAY;AAC9C,cAAMmB,UAAU,GAAG,iBAAKL,wBAAL,EAA+Bd,IAA/B,CAAnB;;AACA,YAAKmB,UAAL,EAAkB;AACjBH,UAAAA,WAAW,GAAG,EACb,GAAGA,WADU;AAEbD,YAAAA,UAAU,EAAEhB,YAAY,CACvBiB,WAAW,CAACD,UADW,EAEvBf,IAFuB,EAGvBmB,UAHuB;AAFX,WAAd;AAQA;AACD,OAZD;AAaA;AACD,GAhBD;AAiBA,SAAOH,WAAP;AACA;AAED;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;AACO,SAASI,uBAAT,CAAkCC,SAAlC,EAA6CC,UAA7C,EAAyDC,OAAzD,EAAmE;AACzE,QAAML,OAAO,GAAG,6BAAiBG,SAAjB,EAA4BC,UAA5B,CAAhB;AACA,QAAME,iBAAiB,GAAGN,OAAH,aAAGA,OAAH,uBAAGA,OAAO,CAAEO,+BAAnC;;AAEA,MAAKpC,KAAK,CAACC,OAAN,CAAekC,iBAAf,CAAL,EAA0C;AACzC,WAAOA,iBAAiB,CAACE,QAAlB,CAA4BH,OAA5B,CAAP;AACA;;AAED,SAAOC,iBAAP;AACA","sourcesContent":["/**\n * External dependencies\n */\nimport { isEmpty, mapValues, get, setWith, clone } 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 (\n\t\tobject === null ||\n\t\ttypeof object !== 'object' ||\n\t\tArray.isArray( object )\n\t) {\n\t\treturn object;\n\t}\n\tconst cleanedNestedObjects = Object.fromEntries(\n\t\tObject.entries( mapValues( object, cleanEmptyObject ) ).filter(\n\t\t\t( [ , value ] ) => Boolean( value )\n\t\t)\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 (\n\t\tObject.values( activeSupports ?? {} ).every(\n\t\t\t( isActive ) => ! isActive\n\t\t)\n\t) {\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\tObject.entries( activeSupports ).forEach( ( [ support, isActive ] ) => {\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"]}
@@ -105,7 +105,6 @@ var _default = {
105
105
  }))), (0, _element.createElement)("p", {
106
106
  className: "block-editor-hooks__layout-controls-helptext"
107
107
  }, (0, _i18n.__)('Customize the width for all elements that are assigned to the center or wide columns.')), (0, _element.createElement)(_components.__experimentalToggleGroupControl, {
108
- __experimentalIsBorderless: true,
109
108
  label: (0, _i18n.__)('Justification'),
110
109
  value: justifyContent,
111
110
  onChange: onJustificationChange