@wordpress/block-editor 7.0.4 → 8.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (347) hide show
  1. package/CHANGELOG.md +11 -0
  2. package/README.md +31 -0
  3. package/build/components/alignment-control/ui.js +1 -2
  4. package/build/components/alignment-control/ui.js.map +1 -1
  5. package/build/components/block-icon/index.js +5 -1
  6. package/build/components/block-icon/index.js.map +1 -1
  7. package/build/components/block-inspector/index.js +4 -0
  8. package/build/components/block-inspector/index.js.map +1 -1
  9. package/build/components/block-list/index.native.js +1 -1
  10. package/build/components/block-list/index.native.js.map +1 -1
  11. package/build/components/block-list/use-block-props/use-multi-selection.js +21 -8
  12. package/build/components/block-list/use-block-props/use-multi-selection.js.map +1 -1
  13. package/build/components/block-navigation/dropdown.js +0 -1
  14. package/build/components/block-navigation/dropdown.js.map +1 -1
  15. package/build/components/block-patterns-list/index.js +1 -8
  16. package/build/components/block-patterns-list/index.js.map +1 -1
  17. package/build/components/block-settings/container.native.js +5 -2
  18. package/build/components/block-settings/container.native.js.map +1 -1
  19. package/build/components/block-settings-menu/block-settings-dropdown.js +22 -2
  20. package/build/components/block-settings-menu/block-settings-dropdown.js.map +1 -1
  21. package/build/components/block-styles/preview.native.js +2 -2
  22. package/build/components/block-styles/preview.native.js.map +1 -1
  23. package/build/components/colors-gradients/control.js +8 -47
  24. package/build/components/colors-gradients/control.js.map +1 -1
  25. package/build/components/colors-gradients/panel-color-gradient-settings.js +81 -6
  26. package/build/components/colors-gradients/panel-color-gradient-settings.js.map +1 -1
  27. package/build/components/duotone-control/index.js +5 -2
  28. package/build/components/duotone-control/index.js.map +1 -1
  29. package/build/components/font-appearance-control/index.js +27 -15
  30. package/build/components/font-appearance-control/index.js.map +1 -1
  31. package/build/components/iframe/index.js +1 -1
  32. package/build/components/iframe/index.js.map +1 -1
  33. package/build/components/index.js +20 -2
  34. package/build/components/index.js.map +1 -1
  35. package/build/components/index.native.js +2 -2
  36. package/build/components/index.native.js.map +1 -1
  37. package/build/components/inner-blocks/index.js +5 -4
  38. package/build/components/inner-blocks/index.js.map +1 -1
  39. package/build/components/inner-blocks/index.native.js +4 -3
  40. package/build/components/inner-blocks/index.native.js.map +1 -1
  41. package/build/components/inserter/block-patterns-explorer/explorer.js +62 -0
  42. package/build/components/inserter/block-patterns-explorer/explorer.js.map +1 -0
  43. package/build/components/inserter/block-patterns-explorer/patterns-list.js +111 -0
  44. package/build/components/inserter/block-patterns-explorer/patterns-list.js.map +1 -0
  45. package/build/components/inserter/block-patterns-explorer/sidebar.js +78 -0
  46. package/build/components/inserter/block-patterns-explorer/sidebar.js.map +1 -0
  47. package/build/components/inserter/block-patterns-tab.js +74 -45
  48. package/build/components/inserter/block-patterns-tab.js.map +1 -1
  49. package/build/components/inserter/hooks/use-block-type-impressions.native.js +4 -7
  50. package/build/components/inserter/hooks/use-block-type-impressions.native.js.map +1 -1
  51. package/build/components/inserter/pattern-panel.js +19 -10
  52. package/build/components/inserter/pattern-panel.js.map +1 -1
  53. package/build/components/inspector-controls/groups.js +3 -1
  54. package/build/components/inspector-controls/groups.js.map +1 -1
  55. package/build/components/letter-spacing-control/index.js +9 -6
  56. package/build/components/letter-spacing-control/index.js.map +1 -1
  57. package/build/components/link-control/index.js +88 -35
  58. package/build/components/link-control/index.js.map +1 -1
  59. package/build/components/link-control/link-preview.js +19 -6
  60. package/build/components/link-control/link-preview.js.map +1 -1
  61. package/build/components/link-control/search-input.js +12 -3
  62. package/build/components/link-control/search-input.js.map +1 -1
  63. package/build/components/list-view/block.js +49 -23
  64. package/build/components/list-view/block.js.map +1 -1
  65. package/build/components/list-view/branch.js +92 -73
  66. package/build/components/list-view/branch.js.map +1 -1
  67. package/build/components/list-view/index.js +39 -16
  68. package/build/components/list-view/index.js.map +1 -1
  69. package/build/components/list-view/leaf.js +1 -1
  70. package/build/components/list-view/leaf.js.map +1 -1
  71. package/build/components/list-view/use-list-view-client-ids.js +8 -58
  72. package/build/components/list-view/use-list-view-client-ids.js.map +1 -1
  73. package/build/components/rich-text/embed-handler-picker.native.js +1 -0
  74. package/build/components/rich-text/embed-handler-picker.native.js.map +1 -1
  75. package/build/components/rich-text/format-edit.js +28 -2
  76. package/build/components/rich-text/format-edit.js.map +1 -1
  77. package/build/components/rich-text/format-toolbar/index.js +2 -1
  78. package/build/components/rich-text/format-toolbar/index.js.map +1 -1
  79. package/build/components/url-input/index.js +11 -4
  80. package/build/components/url-input/index.js.map +1 -1
  81. package/build/components/use-setting/index.js +48 -9
  82. package/build/components/use-setting/index.js.map +1 -1
  83. package/build/hooks/border.js +5 -5
  84. package/build/hooks/border.js.map +1 -1
  85. package/build/hooks/color-panel.js +2 -1
  86. package/build/hooks/color-panel.js.map +1 -1
  87. package/build/hooks/duotone.js +16 -5
  88. package/build/hooks/duotone.js.map +1 -1
  89. package/build/hooks/font-appearance.js +49 -6
  90. package/build/hooks/font-appearance.js.map +1 -1
  91. package/build/hooks/font-family.js +37 -16
  92. package/build/hooks/font-family.js.map +1 -1
  93. package/build/hooks/font-size.js +51 -9
  94. package/build/hooks/font-size.js.map +1 -1
  95. package/build/hooks/index.js +8 -0
  96. package/build/hooks/index.js.map +1 -1
  97. package/build/hooks/index.native.js +8 -0
  98. package/build/hooks/index.native.js.map +1 -1
  99. package/build/hooks/letter-spacing.js +44 -7
  100. package/build/hooks/letter-spacing.js.map +1 -1
  101. package/build/hooks/line-height.js +45 -8
  102. package/build/hooks/line-height.js.map +1 -1
  103. package/build/hooks/margin.js +1 -1
  104. package/build/hooks/margin.js.map +1 -1
  105. package/build/hooks/padding.js +1 -1
  106. package/build/hooks/padding.js.map +1 -1
  107. package/build/hooks/text-decoration.js +42 -6
  108. package/build/hooks/text-decoration.js.map +1 -1
  109. package/build/hooks/text-transform.js +42 -6
  110. package/build/hooks/text-transform.js.map +1 -1
  111. package/build/hooks/typography.js +108 -8
  112. package/build/hooks/typography.js.map +1 -1
  113. package/build/hooks/use-cached-truthy.js +29 -0
  114. package/build/hooks/use-cached-truthy.js.map +1 -0
  115. package/build/index.js +7 -0
  116. package/build/index.js.map +1 -1
  117. package/build/layouts/flex.js +120 -28
  118. package/build/layouts/flex.js.map +1 -1
  119. package/build/store/actions.js +303 -265
  120. package/build/store/actions.js.map +1 -1
  121. package/build/store/index.js +1 -3
  122. package/build/store/index.js.map +1 -1
  123. package/build/store/reducer.js +23 -22
  124. package/build/store/reducer.js.map +1 -1
  125. package/build/store/selectors.js +44 -35
  126. package/build/store/selectors.js.map +1 -1
  127. package/build-module/components/alignment-control/ui.js +1 -2
  128. package/build-module/components/alignment-control/ui.js.map +1 -1
  129. package/build-module/components/block-icon/index.js +5 -1
  130. package/build-module/components/block-icon/index.js.map +1 -1
  131. package/build-module/components/block-inspector/index.js +4 -0
  132. package/build-module/components/block-inspector/index.js.map +1 -1
  133. package/build-module/components/block-list/index.native.js +1 -1
  134. package/build-module/components/block-list/index.native.js.map +1 -1
  135. package/build-module/components/block-list/use-block-props/use-multi-selection.js +21 -8
  136. package/build-module/components/block-list/use-block-props/use-multi-selection.js.map +1 -1
  137. package/build-module/components/block-navigation/dropdown.js +0 -1
  138. package/build-module/components/block-navigation/dropdown.js.map +1 -1
  139. package/build-module/components/block-patterns-list/index.js +1 -6
  140. package/build-module/components/block-patterns-list/index.js.map +1 -1
  141. package/build-module/components/block-settings/container.native.js +6 -3
  142. package/build-module/components/block-settings/container.native.js.map +1 -1
  143. package/build-module/components/block-settings-menu/block-settings-dropdown.js +24 -4
  144. package/build-module/components/block-settings-menu/block-settings-dropdown.js.map +1 -1
  145. package/build-module/components/block-styles/preview.native.js +2 -2
  146. package/build-module/components/block-styles/preview.native.js.map +1 -1
  147. package/build-module/components/colors-gradients/control.js +12 -53
  148. package/build-module/components/colors-gradients/control.js.map +1 -1
  149. package/build-module/components/colors-gradients/panel-color-gradient-settings.js +82 -6
  150. package/build-module/components/colors-gradients/panel-color-gradient-settings.js.map +1 -1
  151. package/build-module/components/duotone-control/index.js +5 -2
  152. package/build-module/components/duotone-control/index.js.map +1 -1
  153. package/build-module/components/font-appearance-control/index.js +23 -15
  154. package/build-module/components/font-appearance-control/index.js.map +1 -1
  155. package/build-module/components/iframe/index.js +1 -1
  156. package/build-module/components/iframe/index.js.map +1 -1
  157. package/build-module/components/index.js +3 -1
  158. package/build-module/components/index.js.map +1 -1
  159. package/build-module/components/index.native.js +1 -1
  160. package/build-module/components/index.native.js.map +1 -1
  161. package/build-module/components/inner-blocks/index.js +6 -5
  162. package/build-module/components/inner-blocks/index.js.map +1 -1
  163. package/build-module/components/inner-blocks/index.native.js +5 -4
  164. package/build-module/components/inner-blocks/index.native.js.map +1 -1
  165. package/build-module/components/inserter/block-patterns-explorer/explorer.js +50 -0
  166. package/build-module/components/inserter/block-patterns-explorer/explorer.js.map +1 -0
  167. package/build-module/components/inserter/block-patterns-explorer/patterns-list.js +92 -0
  168. package/build-module/components/inserter/block-patterns-explorer/patterns-list.js.map +1 -0
  169. package/build-module/components/inserter/block-patterns-explorer/sidebar.js +69 -0
  170. package/build-module/components/inserter/block-patterns-explorer/sidebar.js.map +1 -0
  171. package/build-module/components/inserter/block-patterns-tab.js +75 -46
  172. package/build-module/components/inserter/block-patterns-tab.js.map +1 -1
  173. package/build-module/components/inserter/hooks/use-block-type-impressions.native.js +4 -7
  174. package/build-module/components/inserter/hooks/use-block-type-impressions.native.js.map +1 -1
  175. package/build-module/components/inserter/pattern-panel.js +21 -13
  176. package/build-module/components/inserter/pattern-panel.js.map +1 -1
  177. package/build-module/components/inspector-controls/groups.js +3 -1
  178. package/build-module/components/inspector-controls/groups.js.map +1 -1
  179. package/build-module/components/letter-spacing-control/index.js +9 -6
  180. package/build-module/components/letter-spacing-control/index.js.map +1 -1
  181. package/build-module/components/link-control/index.js +88 -36
  182. package/build-module/components/link-control/index.js.map +1 -1
  183. package/build-module/components/link-control/link-preview.js +19 -7
  184. package/build-module/components/link-control/link-preview.js.map +1 -1
  185. package/build-module/components/link-control/search-input.js +11 -3
  186. package/build-module/components/link-control/search-input.js.map +1 -1
  187. package/build-module/components/list-view/block.js +49 -24
  188. package/build-module/components/list-view/block.js.map +1 -1
  189. package/build-module/components/list-view/branch.js +92 -73
  190. package/build-module/components/list-view/branch.js.map +1 -1
  191. package/build-module/components/list-view/index.js +41 -18
  192. package/build-module/components/list-view/index.js.map +1 -1
  193. package/build-module/components/list-view/leaf.js +1 -1
  194. package/build-module/components/list-view/leaf.js.map +1 -1
  195. package/build-module/components/list-view/use-list-view-client-ids.js +8 -58
  196. package/build-module/components/list-view/use-list-view-client-ids.js.map +1 -1
  197. package/build-module/components/rich-text/embed-handler-picker.native.js +1 -0
  198. package/build-module/components/rich-text/embed-handler-picker.native.js.map +1 -1
  199. package/build-module/components/rich-text/format-edit.js +28 -3
  200. package/build-module/components/rich-text/format-edit.js.map +1 -1
  201. package/build-module/components/rich-text/format-toolbar/index.js +2 -1
  202. package/build-module/components/rich-text/format-toolbar/index.js.map +1 -1
  203. package/build-module/components/url-input/index.js +11 -4
  204. package/build-module/components/url-input/index.js.map +1 -1
  205. package/build-module/components/use-setting/index.js +48 -9
  206. package/build-module/components/use-setting/index.js.map +1 -1
  207. package/build-module/hooks/border.js +5 -5
  208. package/build-module/hooks/border.js.map +1 -1
  209. package/build-module/hooks/color-panel.js +2 -1
  210. package/build-module/hooks/color-panel.js.map +1 -1
  211. package/build-module/hooks/duotone.js +16 -5
  212. package/build-module/hooks/duotone.js.map +1 -1
  213. package/build-module/hooks/font-appearance.js +45 -6
  214. package/build-module/hooks/font-appearance.js.map +1 -1
  215. package/build-module/hooks/font-family.js +33 -16
  216. package/build-module/hooks/font-family.js.map +1 -1
  217. package/build-module/hooks/font-size.js +47 -9
  218. package/build-module/hooks/font-size.js.map +1 -1
  219. package/build-module/hooks/index.js +1 -0
  220. package/build-module/hooks/index.js.map +1 -1
  221. package/build-module/hooks/index.native.js +1 -0
  222. package/build-module/hooks/index.native.js.map +1 -1
  223. package/build-module/hooks/letter-spacing.js +40 -7
  224. package/build-module/hooks/letter-spacing.js.map +1 -1
  225. package/build-module/hooks/line-height.js +41 -8
  226. package/build-module/hooks/line-height.js.map +1 -1
  227. package/build-module/hooks/margin.js +1 -1
  228. package/build-module/hooks/margin.js.map +1 -1
  229. package/build-module/hooks/padding.js +1 -1
  230. package/build-module/hooks/padding.js.map +1 -1
  231. package/build-module/hooks/text-decoration.js +38 -6
  232. package/build-module/hooks/text-decoration.js.map +1 -1
  233. package/build-module/hooks/text-transform.js +38 -6
  234. package/build-module/hooks/text-transform.js.map +1 -1
  235. package/build-module/hooks/typography.js +117 -17
  236. package/build-module/hooks/typography.js.map +1 -1
  237. package/build-module/hooks/use-cached-truthy.js +21 -0
  238. package/build-module/hooks/use-cached-truthy.js.map +1 -0
  239. package/build-module/index.js +1 -1
  240. package/build-module/index.js.map +1 -1
  241. package/build-module/layouts/flex.js +124 -32
  242. package/build-module/layouts/flex.js.map +1 -1
  243. package/build-module/store/actions.js +266 -241
  244. package/build-module/store/actions.js.map +1 -1
  245. package/build-module/store/index.js +1 -2
  246. package/build-module/store/index.js.map +1 -1
  247. package/build-module/store/reducer.js +23 -22
  248. package/build-module/store/reducer.js.map +1 -1
  249. package/build-module/store/selectors.js +42 -30
  250. package/build-module/store/selectors.js.map +1 -1
  251. package/build-style/style-rtl.css +160 -57
  252. package/build-style/style.css +160 -57
  253. package/package.json +13 -14
  254. package/src/components/alignment-control/test/__snapshots__/index.js.snap +0 -2
  255. package/src/components/alignment-control/ui.js +1 -4
  256. package/src/components/block-draggable/style.scss +19 -4
  257. package/src/components/block-icon/index.js +4 -1
  258. package/src/components/block-inspector/index.js +5 -0
  259. package/src/components/block-list/index.native.js +1 -1
  260. package/src/components/block-list/use-block-props/use-multi-selection.js +27 -7
  261. package/src/components/block-navigation/dropdown.js +0 -1
  262. package/src/components/block-patterns-list/index.js +1 -8
  263. package/src/components/block-patterns-list/style.scss +22 -12
  264. package/src/components/block-settings/container.native.js +7 -0
  265. package/src/components/block-settings-menu/block-settings-dropdown.js +19 -7
  266. package/src/components/block-styles/preview.native.js +2 -2
  267. package/src/components/block-switcher/test/__snapshots__/index.js.snap +1 -1
  268. package/src/components/color-palette/test/__snapshots__/control.js.snap +88 -63
  269. package/src/components/colors-gradients/control.js +19 -62
  270. package/src/components/colors-gradients/panel-color-gradient-settings.js +76 -6
  271. package/src/components/colors-gradients/style.scss +3 -14
  272. package/src/components/colors-gradients/test/control.js +0 -16
  273. package/src/components/duotone-control/index.js +6 -0
  274. package/src/components/duotone-control/style.scss +27 -12
  275. package/src/components/font-appearance-control/index.js +22 -14
  276. package/src/components/iframe/index.js +1 -1
  277. package/src/components/index.js +3 -4
  278. package/src/components/index.native.js +1 -4
  279. package/src/components/inner-blocks/index.js +4 -4
  280. package/src/components/inner-blocks/index.native.js +7 -4
  281. package/src/components/inserter/block-patterns-explorer/explorer.js +50 -0
  282. package/src/components/inserter/block-patterns-explorer/patterns-list.js +122 -0
  283. package/src/components/inserter/block-patterns-explorer/sidebar.js +73 -0
  284. package/src/components/inserter/block-patterns-tab.js +107 -80
  285. package/src/components/inserter/hooks/use-block-type-impressions.native.js +14 -21
  286. package/src/components/inserter/pattern-panel.js +33 -16
  287. package/src/components/inserter/style.scss +64 -1
  288. package/src/components/inserter/test/block-types-tab.native.js +1 -1
  289. package/src/components/inserter/test/fixtures/index.native.js +12 -0
  290. package/src/components/inspector-controls/groups.js +4 -0
  291. package/src/components/letter-spacing-control/index.js +12 -6
  292. package/src/components/link-control/README.md +7 -0
  293. package/src/components/link-control/index.js +99 -34
  294. package/src/components/link-control/link-preview.js +21 -9
  295. package/src/components/link-control/search-input.js +9 -3
  296. package/src/components/link-control/style.scss +32 -16
  297. package/src/components/link-control/test/index.js +179 -4
  298. package/src/components/list-view/block.js +67 -23
  299. package/src/components/list-view/branch.js +113 -91
  300. package/src/components/list-view/index.js +58 -19
  301. package/src/components/list-view/leaf.js +1 -1
  302. package/src/components/list-view/style.scss +14 -3
  303. package/src/components/list-view/use-list-view-client-ids.js +7 -66
  304. package/src/components/rich-text/embed-handler-picker.native.js +1 -0
  305. package/src/components/rich-text/format-edit.js +36 -2
  306. package/src/components/rich-text/format-toolbar/index.js +3 -0
  307. package/src/components/url-input/index.js +14 -4
  308. package/src/components/use-setting/index.js +49 -11
  309. package/src/hooks/border.js +8 -11
  310. package/src/hooks/color-panel.js +1 -0
  311. package/src/hooks/duotone.js +21 -7
  312. package/src/hooks/font-appearance.js +38 -7
  313. package/src/hooks/font-family.js +29 -13
  314. package/src/hooks/font-size.js +42 -6
  315. package/src/hooks/index.js +1 -0
  316. package/src/hooks/index.native.js +1 -0
  317. package/src/hooks/layout.scss +3 -1
  318. package/src/hooks/letter-spacing.js +35 -7
  319. package/src/hooks/line-height.js +37 -9
  320. package/src/hooks/margin.js +1 -1
  321. package/src/hooks/padding.js +1 -1
  322. package/src/hooks/text-decoration.js +34 -6
  323. package/src/hooks/text-transform.js +34 -6
  324. package/src/hooks/typography.js +165 -15
  325. package/src/hooks/typography.scss +16 -0
  326. package/src/hooks/use-cached-truthy.js +20 -0
  327. package/src/index.js +1 -0
  328. package/src/layouts/flex.js +137 -41
  329. package/src/store/actions.js +223 -391
  330. package/src/store/index.js +1 -2
  331. package/src/store/reducer.js +36 -18
  332. package/src/store/selectors.js +52 -47
  333. package/src/store/test/actions.js +395 -694
  334. package/src/store/test/selectors.js +79 -21
  335. package/src/style.scss +1 -1
  336. package/src/utils/test/parse-css-unit-to-px.js +127 -167
  337. package/build/components/text-decoration-and-transform/index.js +0 -39
  338. package/build/components/text-decoration-and-transform/index.js.map +0 -1
  339. package/build/store/controls.js +0 -44
  340. package/build/store/controls.js.map +0 -1
  341. package/build-module/components/text-decoration-and-transform/index.js +0 -30
  342. package/build-module/components/text-decoration-and-transform/index.js.map +0 -1
  343. package/build-module/store/controls.js +0 -32
  344. package/build-module/store/controls.js.map +0 -1
  345. package/src/components/text-decoration-and-transform/index.js +0 -36
  346. package/src/components/text-decoration-and-transform/style.scss +0 -3
  347. package/src/store/controls.js +0 -39
@@ -6,6 +6,8 @@ Object.defineProperty(exports, "__esModule", {
6
6
  value: true
7
7
  });
8
8
  exports.FontSizeEdit = FontSizeEdit;
9
+ exports.hasFontSizeValue = hasFontSizeValue;
10
+ exports.resetFontSize = resetFontSize;
9
11
  exports.useIsFontSizeDisabled = useIsFontSizeDisabled;
10
12
  exports.FONT_SIZE_SUPPORT_KEY = void 0;
11
13
 
@@ -135,7 +137,6 @@ function FontSizeEdit(props) {
135
137
  },
136
138
  setAttributes
137
139
  } = props;
138
- const isDisabled = useIsFontSizeDisabled(props);
139
140
  const fontSizes = (0, _useSetting.default)('typography.fontSizes');
140
141
 
141
142
  const onChange = value => {
@@ -150,15 +151,56 @@ function FontSizeEdit(props) {
150
151
  });
151
152
  };
152
153
 
153
- if (isDisabled) {
154
- return null;
155
- }
156
-
157
154
  const fontSizeObject = (0, _fontSizes.getFontSize)(fontSizes, fontSize, style === null || style === void 0 ? void 0 : (_style$typography = style.typography) === null || _style$typography === void 0 ? void 0 : _style$typography.fontSize);
158
155
  const fontSizeValue = (fontSizeObject === null || fontSizeObject === void 0 ? void 0 : fontSizeObject.size) || (style === null || style === void 0 ? void 0 : (_style$typography2 = style.typography) === null || _style$typography2 === void 0 ? void 0 : _style$typography2.fontSize) || fontSize;
159
156
  return (0, _element.createElement)(_fontSizes.FontSizePicker, {
160
157
  onChange: onChange,
161
- value: fontSizeValue
158
+ value: fontSizeValue,
159
+ withReset: false
160
+ });
161
+ }
162
+ /**
163
+ * Checks if there is a current value set for the font size block support.
164
+ *
165
+ * @param {Object} props Block props.
166
+ * @return {boolean} Whether or not the block has a font size value set.
167
+ */
168
+
169
+
170
+ function hasFontSizeValue(props) {
171
+ var _style$typography3;
172
+
173
+ const {
174
+ fontSize,
175
+ style
176
+ } = props.attributes;
177
+ return !!fontSize || !!(style !== null && style !== void 0 && (_style$typography3 = style.typography) !== null && _style$typography3 !== void 0 && _style$typography3.fontSize);
178
+ }
179
+ /**
180
+ * Resets the font size block support attribute. This can be used when
181
+ * disabling the font size support controls for a block via a progressive
182
+ * discovery panel.
183
+ *
184
+ * @param {Object} props Block props.
185
+ * @param {Object} props.attributes Block's attributes.
186
+ * @param {Object} props.setAttributes Function to set block's attributes.
187
+ */
188
+
189
+
190
+ function resetFontSize({
191
+ attributes = {},
192
+ setAttributes
193
+ }) {
194
+ const {
195
+ style
196
+ } = attributes;
197
+ setAttributes({
198
+ fontSize: undefined,
199
+ style: (0, _utils.cleanEmptyObject)({ ...style,
200
+ typography: { ...(style === null || style === void 0 ? void 0 : style.typography),
201
+ fontSize: undefined
202
+ }
203
+ })
162
204
  });
163
205
  }
164
206
  /**
@@ -188,7 +230,7 @@ function useIsFontSizeDisabled({
188
230
 
189
231
 
190
232
  const withFontSizeInlineStyles = (0, _compose.createHigherOrderComponent)(BlockListBlock => props => {
191
- var _style$typography3, _style$typography4;
233
+ var _style$typography4, _style$typography5;
192
234
 
193
235
  const fontSizes = (0, _useSetting.default)('typography.fontSizes');
194
236
  const {
@@ -203,11 +245,11 @@ const withFontSizeInlineStyles = (0, _compose.createHigherOrderComponent)(BlockL
203
245
  // doesn't already have an inline font size,
204
246
  // and does have a class to extract the font size from.
205
247
 
206
- if (!(0, _blocks.hasBlockSupport)(blockName, FONT_SIZE_SUPPORT_KEY) || (0, _blocks.hasBlockSupport)(blockName, 'typography.__experimentalSkipSerialization') || !fontSize || style !== null && style !== void 0 && (_style$typography3 = style.typography) !== null && _style$typography3 !== void 0 && _style$typography3.fontSize) {
248
+ if (!(0, _blocks.hasBlockSupport)(blockName, FONT_SIZE_SUPPORT_KEY) || (0, _blocks.hasBlockSupport)(blockName, 'typography.__experimentalSkipSerialization') || !fontSize || style !== null && style !== void 0 && (_style$typography4 = style.typography) !== null && _style$typography4 !== void 0 && _style$typography4.fontSize) {
207
249
  return (0, _element.createElement)(BlockListBlock, props);
208
250
  }
209
251
 
210
- const fontSizeValue = (0, _fontSizes.getFontSize)(fontSizes, fontSize, style === null || style === void 0 ? void 0 : (_style$typography4 = style.typography) === null || _style$typography4 === void 0 ? void 0 : _style$typography4.fontSize).size;
252
+ const fontSizeValue = (0, _fontSizes.getFontSize)(fontSizes, fontSize, style === null || style === void 0 ? void 0 : (_style$typography5 = style.typography) === null || _style$typography5 === void 0 ? void 0 : _style$typography5.fontSize).size;
211
253
  const newProps = { ...props,
212
254
  wrapperProps: { ...wrapperProps,
213
255
  style: {
@@ -1 +1 @@
1
- {"version":3,"sources":["@wordpress/block-editor/src/hooks/font-size.js"],"names":["FONT_SIZE_SUPPORT_KEY","addAttributes","settings","attributes","fontSize","Object","assign","type","addSaveProps","props","blockType","classes","TokenList","className","add","newClassName","value","undefined","addEditProps","existingGetEditWrapperProps","getEditWrapperProps","FontSizeEdit","style","setAttributes","isDisabled","useIsFontSizeDisabled","fontSizes","onChange","fontSizeSlug","slug","typography","fontSizeObject","fontSizeValue","size","name","blockName","hasFontSizes","length","withFontSizeInlineStyles","BlockListBlock","wrapperProps","newProps"],"mappings":";;;;;;;;;;;;;AAGA;;AACA;;AACA;;AACA;;AAKA;;AAMA;;AACA;;AAlBA;AACA;AACA;;AAMA;AACA;AACA;AAUO,MAAMA,qBAAqB,GAAG,qBAA9B;AAEP;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;;AACA,SAASC,aAAT,CAAwBC,QAAxB,EAAmC;AAClC,MAAK,CAAE,6BAAiBA,QAAjB,EAA2BF,qBAA3B,CAAP,EAA4D;AAC3D,WAAOE,QAAP;AACA,GAHiC,CAKlC;;;AACA,MAAK,CAAEA,QAAQ,CAACC,UAAT,CAAoBC,QAA3B,EAAsC;AACrCC,IAAAA,MAAM,CAACC,MAAP,CAAeJ,QAAQ,CAACC,UAAxB,EAAoC;AACnCC,MAAAA,QAAQ,EAAE;AACTG,QAAAA,IAAI,EAAE;AADG;AADyB,KAApC;AAKA;;AAED,SAAOL,QAAP;AACA;AAED;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;AACA,SAASM,YAAT,CAAuBC,KAAvB,EA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ADD,EAEC,wBAFD,EAGCxC,aAHD;AAMA,sBACC,kCADD,EAEC,wBAFD,EAGCO,YAHD;AAMA,sBAAW,0BAAX,EAAuC,wBAAvC,EAAiEU,YAAjE;AAEA,sBACC,uBADD,EAEC,6CAFD,EAGCoB,wBAHD","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { addFilter } from '@wordpress/hooks';\nimport { hasBlockSupport } from '@wordpress/blocks';\nimport TokenList from '@wordpress/token-list';\nimport { createHigherOrderComponent } from '@wordpress/compose';\n\n/**\n * Internal dependencies\n */\nimport {\n\tgetFontSize,\n\tgetFontSizeClass,\n\tgetFontSizeObjectByValue,\n\tFontSizePicker,\n} from '../components/font-sizes';\nimport { cleanEmptyObject } from './utils';\nimport useSetting from '../components/use-setting';\n\nexport const FONT_SIZE_SUPPORT_KEY = 'typography.fontSize';\n\n/**\n * Filters registered block settings, extending attributes to include\n * `fontSize` and `fontWeight` attributes.\n *\n * @param {Object} settings Original block settings.\n *\n * @return {Object} Filtered block settings.\n */\nfunction addAttributes( settings ) {\n\tif ( ! hasBlockSupport( settings, FONT_SIZE_SUPPORT_KEY ) ) {\n\t\treturn settings;\n\t}\n\n\t// Allow blocks to specify a default value if needed.\n\tif ( ! settings.attributes.fontSize ) {\n\t\tObject.assign( settings.attributes, {\n\t\t\tfontSize: {\n\t\t\t\ttype: 'string',\n\t\t\t},\n\t\t} );\n\t}\n\n\treturn settings;\n}\n\n/**\n * Override props assigned to save component to inject font size.\n *\n * @param {Object} props Additional props applied to save element.\n * @param {Object} blockType Block type.\n * @param {Object} attributes Block attributes.\n *\n * @return {Object} Filtered props applied to save element.\n */\nfunction addSaveProps( props, blockType, attributes ) {\n\tif ( ! hasBlockSupport( blockType, FONT_SIZE_SUPPORT_KEY ) ) {\n\t\treturn props;\n\t}\n\n\tif (\n\t\thasBlockSupport(\n\t\t\tblockType,\n\t\t\t'typography.__experimentalSkipSerialization'\n\t\t)\n\t) {\n\t\treturn props;\n\t}\n\n\t// Use TokenList to dedupe classes.\n\tconst classes = new TokenList( props.className );\n\tclasses.add( getFontSizeClass( attributes.fontSize ) );\n\tconst newClassName = classes.value;\n\tprops.className = newClassName ? newClassName : undefined;\n\n\treturn props;\n}\n\n/**\n * Filters registered block settings to expand the block edit wrapper\n * by applying the desired styles and classnames.\n *\n * @param {Object} settings Original block settings.\n *\n * @return {Object} Filtered block settings.\n */\nfunction addEditProps( settings ) {\n\tif ( ! hasBlockSupport( settings, FONT_SIZE_SUPPORT_KEY ) ) {\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\t\treturn addSaveProps( props, settings, attributes );\n\t};\n\n\treturn settings;\n}\n\n/**\n * Inspector control panel containing the font size related configuration\n *\n * @param {Object} props\n *\n * @return {WPElement} Font size edit element.\n */\nexport function FontSizeEdit( props ) {\n\tconst {\n\t\tattributes: { fontSize, style },\n\t\tsetAttributes,\n\t} = props;\n\tconst isDisabled = useIsFontSizeDisabled( props );\n\tconst fontSizes = useSetting( 'typography.fontSizes' );\n\n\tconst onChange = ( value ) => {\n\t\tconst fontSizeSlug = getFontSizeObjectByValue( fontSizes, value ).slug;\n\n\t\tsetAttributes( {\n\t\t\tstyle: cleanEmptyObject( {\n\t\t\t\t...style,\n\t\t\t\ttypography: {\n\t\t\t\t\t...style?.typography,\n\t\t\t\t\tfontSize: fontSizeSlug ? undefined : value,\n\t\t\t\t},\n\t\t\t} ),\n\t\t\tfontSize: fontSizeSlug,\n\t\t} );\n\t};\n\n\tif ( isDisabled ) {\n\t\treturn null;\n\t}\n\n\tconst fontSizeObject = getFontSize(\n\t\tfontSizes,\n\t\tfontSize,\n\t\tstyle?.typography?.fontSize\n\t);\n\n\tconst fontSizeValue =\n\t\tfontSizeObject?.size || style?.typography?.fontSize || fontSize;\n\n\treturn <FontSizePicker onChange={ onChange } value={ fontSizeValue } />;\n}\n\n/**\n * Custom hook that checks if font-size settings have been disabled.\n *\n * @param {string} name The name of the block.\n * @return {boolean} Whether setting is disabled.\n */\nexport function useIsFontSizeDisabled( { name: blockName } = {} ) {\n\tconst fontSizes = useSetting( 'typography.fontSizes' );\n\tconst hasFontSizes = !! fontSizes?.length;\n\n\treturn (\n\t\t! hasBlockSupport( blockName, FONT_SIZE_SUPPORT_KEY ) || ! hasFontSizes\n\t);\n}\n\n/**\n * Add inline styles for font sizes.\n * Ideally, this is not needed and themes load the font-size classes on the\n * editor.\n *\n * @param {Function} BlockListBlock Original component.\n *\n * @return {Function} Wrapped component.\n */\nconst withFontSizeInlineStyles = createHigherOrderComponent(\n\t( BlockListBlock ) => ( props ) => {\n\t\tconst fontSizes = useSetting( 'typography.fontSizes' );\n\t\tconst {\n\t\t\tname: blockName,\n\t\t\tattributes: { fontSize, style },\n\t\t\twrapperProps,\n\t\t} = props;\n\n\t\t// Only add inline styles if the block supports font sizes,\n\t\t// doesn't skip serialization of font sizes,\n\t\t// doesn't already have an inline font size,\n\t\t// and does have a class to extract the font size from.\n\t\tif (\n\t\t\t! hasBlockSupport( blockName, FONT_SIZE_SUPPORT_KEY ) ||\n\t\t\thasBlockSupport(\n\t\t\t\tblockName,\n\t\t\t\t'typography.__experimentalSkipSerialization'\n\t\t\t) ||\n\t\t\t! fontSize ||\n\t\t\tstyle?.typography?.fontSize\n\t\t) {\n\t\t\treturn <BlockListBlock { ...props } />;\n\t\t}\n\n\t\tconst fontSizeValue = getFontSize(\n\t\t\tfontSizes,\n\t\t\tfontSize,\n\t\t\tstyle?.typography?.fontSize\n\t\t).size;\n\n\t\tconst newProps = {\n\t\t\t...props,\n\t\t\twrapperProps: {\n\t\t\t\t...wrapperProps,\n\t\t\t\tstyle: {\n\t\t\t\t\tfontSize: fontSizeValue,\n\t\t\t\t\t...wrapperProps?.style,\n\t\t\t\t},\n\t\t\t},\n\t\t};\n\n\t\treturn <BlockListBlock { ...newProps } />;\n\t},\n\t'withFontSizeInlineStyles'\n);\n\naddFilter(\n\t'blocks.registerBlockType',\n\t'core/font/addAttribute',\n\taddAttributes\n);\n\naddFilter(\n\t'blocks.getSaveContent.extraProps',\n\t'core/font/addSaveProps',\n\taddSaveProps\n);\n\naddFilter( 'blocks.registerBlockType', 'core/font/addEditProps', addEditProps );\n\naddFilter(\n\t'editor.BlockListBlock',\n\t'core/font-size/with-font-size-inline-styles',\n\twithFontSizeInlineStyles\n);\n"]}
1
+ {"version":3,"sources":["@wordpress/block-editor/src/hooks/font-size.js"],"names":["FONT_SIZE_SUPPORT_KEY","addAttributes","settings","attributes","fontSize","Object","assign","type","addSaveProps","props","blockType","classes","TokenList","className","add","newClassName","value","undefined","addEditProps","existingGetEditWrapperProps","getEditWrapperProps","FontSizeEdit","style","setAttributes","fontSizes","onChange","fontSizeSlug","slug","typography","fontSizeObject","fontSizeValue","size","hasFontSizeValue","resetFontSize","useIsFontSizeDisabled","name","blockName","hasFontSizes","length","withFontSizeInlineStyles","BlockListBlock","wrapperProps","newProps"],"mappings":";;;;;;;;;;;;;;;AAGA;;AACA;;AACA;;AACA;;AAKA;;AAMA;;AACA;;AAlBA;AACA;AACA;;AAMA;AACA;AACA;AAUO,MAAMA,qBAAqB,GAAG,qBAA9B;AAEP;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;;AACA,SAASC,aAAT,CAAwBC,QAAxB,EAAmC;AAClC,MAAK,CAAE,6BAAiBA,QAAjB,EAA2BF,qBAA3B,CAAP,EAA4D;AAC3D,WAAOE,QAAP;AACA,GAHiC,CAKlC;;;AACA,MAAK,CAAEA,QAAQ,CAACC,UAAT,CAAoBC,QAA3B,EAAsC;AACrCC,IAAAA,MAAM,CAACC,MAAP,CAAeJ,QAAQ,CAACC,UAAxB,EAAoC;AACnCC,MAAAA,QAAQ,EAAE;AACTG,QAAAA,IAAI,EAAE;AADG;AADyB,KAApC;AAKA;;AAED,SAAOL,QAAP;A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A;AACA;AACA;;AACA,MACC,CAAE,6BAAiB2B,SAAjB,EAA4BpC,qBAA5B,CAAF,IACA,6BACCoC,SADD,EAEC,4CAFD,CADA,IAKA,CAAEhC,QALF,IAMAkB,KANA,aAMAA,KANA,qCAMAA,KAAK,CAAEM,UANP,+CAMA,mBAAmBxB,QAPpB,EAQE;AACD,WAAO,4BAAC,cAAD,EAAqBK,KAArB,CAAP;AACA;;AAED,QAAMqB,aAAa,GAAG,4BACrBN,SADqB,EAErBpB,QAFqB,EAGrBkB,KAHqB,aAGrBA,KAHqB,6CAGrBA,KAAK,CAAEM,UAHc,uDAGrB,mBAAmBxB,QAHE,EAIpB2B,IAJF;AAMA,QAAMW,QAAQ,GAAG,EAChB,GAAGjC,KADa;AAEhBgC,IAAAA,YAAY,EAAE,EACb,GAAGA,YADU;AAEbnB,MAAAA,KAAK,EAAE;AACNlB,QAAAA,QAAQ,EAAE0B,aADJ;AAEN,YAAGW,YAAH,aAAGA,YAAH,uBAAGA,YAAY,CAAEnB,KAAjB;AAFM;AAFM;AAFE,GAAjB;AAWA,SAAO,4BAAC,cAAD,EAAqBoB,QAArB,CAAP;AACA,CA3C+B,EA4ChC,0BA5CgC,CAAjC;AA+CA,sBACC,0BADD,EAEC,wBAFD,EAGCzC,aAHD;AAMA,sBACC,kCADD,EAEC,wBAFD,EAGCO,YAHD;AAMA,sBAAW,0BAAX,EAAuC,wBAAvC,EAAiEU,YAAjE;AAEA,sBACC,uBADD,EAEC,6CAFD,EAGCqB,wBAHD","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { addFilter } from '@wordpress/hooks';\nimport { hasBlockSupport } from '@wordpress/blocks';\nimport TokenList from '@wordpress/token-list';\nimport { createHigherOrderComponent } from '@wordpress/compose';\n\n/**\n * Internal dependencies\n */\nimport {\n\tgetFontSize,\n\tgetFontSizeClass,\n\tgetFontSizeObjectByValue,\n\tFontSizePicker,\n} from '../components/font-sizes';\nimport { cleanEmptyObject } from './utils';\nimport useSetting from '../components/use-setting';\n\nexport const FONT_SIZE_SUPPORT_KEY = 'typography.fontSize';\n\n/**\n * Filters registered block settings, extending attributes to include\n * `fontSize` and `fontWeight` attributes.\n *\n * @param {Object} settings Original block settings.\n *\n * @return {Object} Filtered block settings.\n */\nfunction addAttributes( settings ) {\n\tif ( ! hasBlockSupport( settings, FONT_SIZE_SUPPORT_KEY ) ) {\n\t\treturn settings;\n\t}\n\n\t// Allow blocks to specify a default value if needed.\n\tif ( ! settings.attributes.fontSize ) {\n\t\tObject.assign( settings.attributes, {\n\t\t\tfontSize: {\n\t\t\t\ttype: 'string',\n\t\t\t},\n\t\t} );\n\t}\n\n\treturn settings;\n}\n\n/**\n * Override props assigned to save component to inject font size.\n *\n * @param {Object} props Additional props applied to save element.\n * @param {Object} blockType Block type.\n * @param {Object} attributes Block attributes.\n *\n * @return {Object} Filtered props applied to save element.\n */\nfunction addSaveProps( props, blockType, attributes ) {\n\tif ( ! hasBlockSupport( blockType, FONT_SIZE_SUPPORT_KEY ) ) {\n\t\treturn props;\n\t}\n\n\tif (\n\t\thasBlockSupport(\n\t\t\tblockType,\n\t\t\t'typography.__experimentalSkipSerialization'\n\t\t)\n\t) {\n\t\treturn props;\n\t}\n\n\t// Use TokenList to dedupe classes.\n\tconst classes = new TokenList( props.className );\n\tclasses.add( getFontSizeClass( attributes.fontSize ) );\n\tconst newClassName = classes.value;\n\tprops.className = newClassName ? newClassName : undefined;\n\n\treturn props;\n}\n\n/**\n * Filters registered block settings to expand the block edit wrapper\n * by applying the desired styles and classnames.\n *\n * @param {Object} settings Original block settings.\n *\n * @return {Object} Filtered block settings.\n */\nfunction addEditProps( settings ) {\n\tif ( ! hasBlockSupport( settings, FONT_SIZE_SUPPORT_KEY ) ) {\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\t\treturn addSaveProps( props, settings, attributes );\n\t};\n\n\treturn settings;\n}\n\n/**\n * Inspector control panel containing the font size related configuration\n *\n * @param {Object} props\n *\n * @return {WPElement} Font size edit element.\n */\nexport function FontSizeEdit( props ) {\n\tconst {\n\t\tattributes: { fontSize, style },\n\t\tsetAttributes,\n\t} = props;\n\tconst fontSizes = useSetting( 'typography.fontSizes' );\n\n\tconst onChange = ( value ) => {\n\t\tconst fontSizeSlug = getFontSizeObjectByValue( fontSizes, value ).slug;\n\n\t\tsetAttributes( {\n\t\t\tstyle: cleanEmptyObject( {\n\t\t\t\t...style,\n\t\t\t\ttypography: {\n\t\t\t\t\t...style?.typography,\n\t\t\t\t\tfontSize: fontSizeSlug ? undefined : value,\n\t\t\t\t},\n\t\t\t} ),\n\t\t\tfontSize: fontSizeSlug,\n\t\t} );\n\t};\n\n\tconst fontSizeObject = getFontSize(\n\t\tfontSizes,\n\t\tfontSize,\n\t\tstyle?.typography?.fontSize\n\t);\n\n\tconst fontSizeValue =\n\t\tfontSizeObject?.size || style?.typography?.fontSize || fontSize;\n\n\treturn (\n\t\t<FontSizePicker\n\t\t\tonChange={ onChange }\n\t\t\tvalue={ fontSizeValue }\n\t\t\twithReset={ false }\n\t\t/>\n\t);\n}\n\n/**\n * Checks if there is a current value set for the font size block support.\n *\n * @param {Object} props Block props.\n * @return {boolean} Whether or not the block has a font size value set.\n */\nexport function hasFontSizeValue( props ) {\n\tconst { fontSize, style } = props.attributes;\n\treturn !! fontSize || !! style?.typography?.fontSize;\n}\n\n/**\n * Resets the font size block support attribute. This can be used when\n * disabling the font size support controls for a block via a progressive\n * discovery panel.\n *\n * @param {Object} props Block props.\n * @param {Object} props.attributes Block's attributes.\n * @param {Object} props.setAttributes Function to set block's attributes.\n */\nexport function resetFontSize( { attributes = {}, setAttributes } ) {\n\tconst { style } = attributes;\n\n\tsetAttributes( {\n\t\tfontSize: undefined,\n\t\tstyle: cleanEmptyObject( {\n\t\t\t...style,\n\t\t\ttypography: {\n\t\t\t\t...style?.typography,\n\t\t\t\tfontSize: undefined,\n\t\t\t},\n\t\t} ),\n\t} );\n}\n\n/**\n * Custom hook that checks if font-size settings have been disabled.\n *\n * @param {string} name The name of the block.\n * @return {boolean} Whether setting is disabled.\n */\nexport function useIsFontSizeDisabled( { name: blockName } = {} ) {\n\tconst fontSizes = useSetting( 'typography.fontSizes' );\n\tconst hasFontSizes = !! fontSizes?.length;\n\n\treturn (\n\t\t! hasBlockSupport( blockName, FONT_SIZE_SUPPORT_KEY ) || ! hasFontSizes\n\t);\n}\n\n/**\n * Add inline styles for font sizes.\n * Ideally, this is not needed and themes load the font-size classes on the\n * editor.\n *\n * @param {Function} BlockListBlock Original component.\n *\n * @return {Function} Wrapped component.\n */\nconst withFontSizeInlineStyles = createHigherOrderComponent(\n\t( BlockListBlock ) => ( props ) => {\n\t\tconst fontSizes = useSetting( 'typography.fontSizes' );\n\t\tconst {\n\t\t\tname: blockName,\n\t\t\tattributes: { fontSize, style },\n\t\t\twrapperProps,\n\t\t} = props;\n\n\t\t// Only add inline styles if the block supports font sizes,\n\t\t// doesn't skip serialization of font sizes,\n\t\t// doesn't already have an inline font size,\n\t\t// and does have a class to extract the font size from.\n\t\tif (\n\t\t\t! hasBlockSupport( blockName, FONT_SIZE_SUPPORT_KEY ) ||\n\t\t\thasBlockSupport(\n\t\t\t\tblockName,\n\t\t\t\t'typography.__experimentalSkipSerialization'\n\t\t\t) ||\n\t\t\t! fontSize ||\n\t\t\tstyle?.typography?.fontSize\n\t\t) {\n\t\t\treturn <BlockListBlock { ...props } />;\n\t\t}\n\n\t\tconst fontSizeValue = getFontSize(\n\t\t\tfontSizes,\n\t\t\tfontSize,\n\t\t\tstyle?.typography?.fontSize\n\t\t).size;\n\n\t\tconst newProps = {\n\t\t\t...props,\n\t\t\twrapperProps: {\n\t\t\t\t...wrapperProps,\n\t\t\t\tstyle: {\n\t\t\t\t\tfontSize: fontSizeValue,\n\t\t\t\t\t...wrapperProps?.style,\n\t\t\t\t},\n\t\t\t},\n\t\t};\n\n\t\treturn <BlockListBlock { ...newProps } />;\n\t},\n\t'withFontSizeInlineStyles'\n);\n\naddFilter(\n\t'blocks.registerBlockType',\n\t'core/font/addAttribute',\n\taddAttributes\n);\n\naddFilter(\n\t'blocks.getSaveContent.extraProps',\n\t'core/font/addSaveProps',\n\taddSaveProps\n);\n\naddFilter( 'blocks.registerBlockType', 'core/font/addEditProps', addEditProps );\n\naddFilter(\n\t'editor.BlockListBlock',\n\t'core/font-size/with-font-size-inline-styles',\n\twithFontSizeInlineStyles\n);\n"]}
@@ -39,6 +39,12 @@ Object.defineProperty(exports, "getSpacingClassesAndStyles", {
39
39
  return _useSpacingProps.getSpacingClassesAndStyles;
40
40
  }
41
41
  });
42
+ Object.defineProperty(exports, "useCachedTruthy", {
43
+ enumerable: true,
44
+ get: function () {
45
+ return _useCachedTruthy.useCachedTruthy;
46
+ }
47
+ });
42
48
 
43
49
  require("./compat");
44
50
 
@@ -71,4 +77,6 @@ var _useBorderProps = require("./use-border-props");
71
77
  var _useColorProps = require("./use-color-props");
72
78
 
73
79
  var _useSpacingProps = require("./use-spacing-props");
80
+
81
+ var _useCachedTruthy = require("./use-cached-truthy");
74
82
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["@wordpress/block-editor/src/hooks/index.js"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAGA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AAEA;;AACA;;AACA;;AACA","sourcesContent":["/**\n * Internal dependencies\n */\nimport './compat';\nimport './align';\nimport './lock';\nimport './anchor';\nimport './custom-class-name';\nimport './generated-class-name';\nimport './style';\nimport './color';\nimport './duotone';\nimport './font-size';\nimport './border-color';\nimport './layout';\n\nexport { useCustomSides } from './dimensions';\nexport { getBorderClassesAndStyles, useBorderProps } from './use-border-props';\nexport { getColorClassesAndStyles, useColorProps } from './use-color-props';\nexport { getSpacingClassesAndStyles } from './use-spacing-props';\n"]}
1
+ {"version":3,"sources":["@wordpress/block-editor/src/hooks/index.js"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAGA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AAEA;;AACA;;AACA;;AACA;;AACA","sourcesContent":["/**\n * Internal dependencies\n */\nimport './compat';\nimport './align';\nimport './lock';\nimport './anchor';\nimport './custom-class-name';\nimport './generated-class-name';\nimport './style';\nimport './color';\nimport './duotone';\nimport './font-size';\nimport './border-color';\nimport './layout';\n\nexport { useCustomSides } from './dimensions';\nexport { getBorderClassesAndStyles, useBorderProps } from './use-border-props';\nexport { getColorClassesAndStyles, useColorProps } from './use-color-props';\nexport { getSpacingClassesAndStyles } from './use-spacing-props';\nexport { useCachedTruthy } from './use-cached-truthy';\n"]}
@@ -33,6 +33,12 @@ Object.defineProperty(exports, "getSpacingClassesAndStyles", {
33
33
  return _useSpacingProps.getSpacingClassesAndStyles;
34
34
  }
35
35
  });
36
+ Object.defineProperty(exports, "useCachedTruthy", {
37
+ enumerable: true,
38
+ get: function () {
39
+ return _useCachedTruthy.useCachedTruthy;
40
+ }
41
+ });
36
42
 
37
43
  require("./compat");
38
44
 
@@ -55,4 +61,6 @@ var _useBorderProps = require("./use-border-props");
55
61
  var _useColorProps = require("./use-color-props");
56
62
 
57
63
  var _useSpacingProps = require("./use-spacing-props");
64
+
65
+ var _useCachedTruthy = require("./use-cached-truthy");
58
66
  //# sourceMappingURL=index.native.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["@wordpress/block-editor/src/hooks/index.native.js"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAGA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AAEA;;AACA;;AACA","sourcesContent":["/**\n * Internal dependencies\n */\nimport './compat';\nimport './align';\nimport './anchor';\nimport './custom-class-name';\nimport './generated-class-name';\nimport './style';\nimport './color';\nimport './font-size';\n\nexport { getBorderClassesAndStyles, useBorderProps } from './use-border-props';\nexport { getColorClassesAndStyles, useColorProps } from './use-color-props';\nexport { getSpacingClassesAndStyles } from './use-spacing-props';\n"]}
1
+ {"version":3,"sources":["@wordpress/block-editor/src/hooks/index.native.js"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAGA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AAEA;;AACA;;AACA;;AACA","sourcesContent":["/**\n * Internal dependencies\n */\nimport './compat';\nimport './align';\nimport './anchor';\nimport './custom-class-name';\nimport './generated-class-name';\nimport './style';\nimport './color';\nimport './font-size';\n\nexport { getBorderClassesAndStyles, useBorderProps } from './use-border-props';\nexport { getColorClassesAndStyles, useColorProps } from './use-color-props';\nexport { getSpacingClassesAndStyles } from './use-spacing-props';\nexport { useCachedTruthy } from './use-cached-truthy';\n"]}
@@ -7,6 +7,8 @@ Object.defineProperty(exports, "__esModule", {
7
7
  });
8
8
  exports.LetterSpacingEdit = LetterSpacingEdit;
9
9
  exports.useIsLetterSpacingDisabled = useIsLetterSpacingDisabled;
10
+ exports.hasLetterSpacingValue = hasLetterSpacingValue;
11
+ exports.resetLetterSpacing = resetLetterSpacing;
10
12
  exports.LETTER_SPACING_SUPPORT_KEY = void 0;
11
13
 
12
14
  var _element = require("@wordpress/element");
@@ -50,11 +52,6 @@ function LetterSpacingEdit(props) {
50
52
  },
51
53
  setAttributes
52
54
  } = props;
53
- const isDisabled = useIsLetterSpacingDisabled(props);
54
-
55
- if (isDisabled) {
56
- return null;
57
- }
58
55
 
59
56
  function onChange(newSpacing) {
60
57
  setAttributes({
@@ -68,7 +65,8 @@ function LetterSpacingEdit(props) {
68
65
 
69
66
  return (0, _element.createElement)(_letterSpacingControl.default, {
70
67
  value: style === null || style === void 0 ? void 0 : (_style$typography = style.typography) === null || _style$typography === void 0 ? void 0 : _style$typography.letterSpacing,
71
- onChange: onChange
68
+ onChange: onChange,
69
+ __unstableInputWidth: false
72
70
  });
73
71
  }
74
72
  /**
@@ -83,7 +81,46 @@ function useIsLetterSpacingDisabled({
83
81
  name: blockName
84
82
  } = {}) {
85
83
  const notSupported = !(0, _blocks.hasBlockSupport)(blockName, LETTER_SPACING_SUPPORT_KEY);
86
- const hasLetterSpacing = (0, _useSetting.default)('typography.customLetterSpacing');
84
+ const hasLetterSpacing = (0, _useSetting.default)('typography.letterSpacing');
87
85
  return notSupported || !hasLetterSpacing;
88
86
  }
87
+ /**
88
+ * Checks if there is a current value set for the letter spacing block support.
89
+ *
90
+ * @param {Object} props Block props.
91
+ * @return {boolean} Whether or not the block has a letter spacing set.
92
+ */
93
+
94
+
95
+ function hasLetterSpacingValue(props) {
96
+ var _props$attributes$sty, _props$attributes$sty2;
97
+
98
+ return !!((_props$attributes$sty = props.attributes.style) !== null && _props$attributes$sty !== void 0 && (_props$attributes$sty2 = _props$attributes$sty.typography) !== null && _props$attributes$sty2 !== void 0 && _props$attributes$sty2.letterSpacing);
99
+ }
100
+ /**
101
+ * Resets the letter spacing block support attribute. This can be used when
102
+ * disabling the letter spacing support controls for a block via a progressive
103
+ * discovery panel.
104
+ *
105
+ * @param {Object} props Block props.
106
+ * @param {Object} props.attributes Block's attributes.
107
+ * @param {Object} props.setAttributes Function to set block's attributes.
108
+ */
109
+
110
+
111
+ function resetLetterSpacing({
112
+ attributes = {},
113
+ setAttributes
114
+ }) {
115
+ const {
116
+ style
117
+ } = attributes;
118
+ setAttributes({
119
+ style: (0, _utils.cleanEmptyObject)({ ...style,
120
+ typography: { ...(style === null || style === void 0 ? void 0 : style.typography),
121
+ letterSpacing: undefined
122
+ }
123
+ })
124
+ });
125
+ }
89
126
  //# sourceMappingURL=letter-spacing.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["@wordpress/block-editor/src/hooks/letter-spacing.js"],"names":["LETTER_SPACING_SUPPORT_KEY","LetterSpacingEdit","props","attributes","style","setAttributes","isDisabled","useIsLetterSpacingDisabled","onChange","newSpacing","typography","letterSpacing","name","blockName","notSupported","hasLetterSpacing"],"mappings":";;;;;;;;;;;;;AAGA;;AAKA;;AACA;;AACA;;AAVA;AACA;AACA;;AAGA;AACA;AACA;;AAKA;AACA;AACA;AACA;AACO,MAAMA,0BAA0B,GACtC,wCADM;AAGP;AACA;AACA;AACA;AACA;AACA;;;;AACO,SAASC,iBAAT,CAA4BC,KAA5B,EAAoC;AAAA;;AAC1C,QAAM;AACLC,IAAAA,UAAU,EAAE;AAAEC,MAAAA;AAAF,KADP;AAELC,IAAAA;AAFK,MAGFH,KAHJ;AAKA,QAAMI,UAAU,GAAGC,0BAA0B,CAAEL,KAAF,CAA7C;;AAEA,MAAKI,UAAL,EAAkB;AACjB,WAAO,IAAP;AACA;;AAED,WAASE,QAAT,CAAmBC,UAAnB,EAAgC;AAC/BJ,IAAAA,aAAa,CAAE;AACdD,MAAAA,KAAK,EAAE,6BAAkB,EACxB,GAAGA,KADqB;AAExBM,QAAAA,UAAU,EAAE,EACX,IAAGN,KAAH,aAAGA,KAAH,uBAAGA,KAAK,CAAEM,UAAV,CADW;AAEXC,UAAAA,aAAa,EAAEF;AAFJ;AAFY,OAAlB;AADO,KAAF,CAAb;AASA;;AAED,SACC,4BAAC,6BAAD;AACC,IAAA,KAAK,EAAGL,KAAH,aAAGA,KAAH,4CAAGA,KAAK,CAAEM,UAAV,sDAAG,kBAAmBC,aAD5B;AAEC,IAAA,QAAQ,EAAGH;AAFZ,IADD;AAMA;AAED;AACA;AACA;AACA;AACA;AACA;;;AACO,SAASD,0BAAT,CAAqC;AAAEK,EAAAA,IAAI,EAAEC;AAAR,IAAsB,EAA3D,EAAgE;AACtE,QAAMC,YAAY,GAAG,CAAE,6BACtBD,SADsB,EAEtBb,0BAFsB,CAAvB;AAIA,QAAMe,gBAAgB,GAAG,yBAAY,gCAAZ,CAAzB;AAEA,SAAOD,YAAY,IAAI,CAAEC,gBAAzB;AACA","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { hasBlockSupport } from '@wordpress/blocks';\n\n/**\n * Internal dependencies\n */\nimport LetterSpacingControl from '../components/letter-spacing-control';\nimport useSetting from '../components/use-setting';\nimport { cleanEmptyObject } from './utils';\n\n/**\n * Key within block settings' supports array indicating support for letter-spacing\n * e.g. settings found in `block.json`.\n */\nexport const LETTER_SPACING_SUPPORT_KEY =\n\t'typography.__experimentalLetterSpacing';\n\n/**\n * Inspector control panel containing the letter-spacing options.\n *\n * @param {Object} props Block properties.\n * @return {WPElement} Letter-spacing edit element.\n */\nexport function LetterSpacingEdit( props ) {\n\tconst {\n\t\tattributes: { style },\n\t\tsetAttributes,\n\t} = props;\n\n\tconst isDisabled = useIsLetterSpacingDisabled( props );\n\n\tif ( isDisabled ) {\n\t\treturn null;\n\t}\n\n\tfunction onChange( newSpacing ) {\n\t\tsetAttributes( {\n\t\t\tstyle: cleanEmptyObject( {\n\t\t\t\t...style,\n\t\t\t\ttypography: {\n\t\t\t\t\t...style?.typography,\n\t\t\t\t\tletterSpacing: newSpacing,\n\t\t\t\t},\n\t\t\t} ),\n\t\t} );\n\t}\n\n\treturn (\n\t\t<LetterSpacingControl\n\t\t\tvalue={ style?.typography?.letterSpacing }\n\t\t\tonChange={ onChange }\n\t\t/>\n\t);\n}\n\n/**\n * Checks if letter-spacing settings have been disabled.\n *\n * @param {string} name Name of the block.\n * @return {boolean} Whether or not the setting is disabled.\n */\nexport function useIsLetterSpacingDisabled( { name: blockName } = {} ) {\n\tconst notSupported = ! hasBlockSupport(\n\t\tblockName,\n\t\tLETTER_SPACING_SUPPORT_KEY\n\t);\n\tconst hasLetterSpacing = useSetting( 'typography.customLetterSpacing' );\n\n\treturn notSupported || ! hasLetterSpacing;\n}\n"]}
1
+ {"version":3,"sources":["@wordpress/block-editor/src/hooks/letter-spacing.js"],"names":["LETTER_SPACING_SUPPORT_KEY","LetterSpacingEdit","props","attributes","style","setAttributes","onChange","newSpacing","typography","letterSpacing","useIsLetterSpacingDisabled","name","blockName","notSupported","hasLetterSpacing","hasLetterSpacingValue","resetLetterSpacing","undefined"],"mappings":";;;;;;;;;;;;;;;AAGA;;AAKA;;AACA;;AACA;;AAVA;AACA;AACA;;AAGA;AACA;AACA;;AAKA;AACA;AACA;AACA;AACO,MAAMA,0BAA0B,GACtC,wCADM;AAGP;AACA;AACA;AACA;AACA;AACA;;;;AACO,SAASC,iBAAT,CAA4BC,KAA5B,EAAoC;AAAA;;AAC1C,QAAM;AACLC,IAAAA,UAAU,EAAE;AAAEC,MAAAA;AAAF,KADP;AAELC,IAAAA;AAFK,MAGFH,KAHJ;;AAKA,WAASI,QAAT,CAAmBC,UAAnB,EAAgC;AAC/BF,IAAAA,aAAa,CAAE;AACdD,MAAAA,KAAK,EAAE,6BAAkB,EACxB,GAAGA,KADqB;AAExBI,QAAAA,UAAU,EAAE,EACX,IAAGJ,KAAH,aAAGA,KAAH,uBAAGA,KAAK,CAAEI,UAAV,CADW;AAEXC,UAAAA,aAAa,EAAEF;AAFJ;AAFY,OAAlB;AADO,KAAF,CAAb;AASA;;AAED,SACC,4BAAC,6BAAD;AACC,IAAA,KAAK,EAAGH,KAAH,aAAGA,KAAH,4CAAGA,KAAK,CAAEI,UAAV,sDAAG,kBAAmBC,aAD5B;AAEC,IAAA,QAAQ,EAAGH,QAFZ;AAGC,IAAA,oBAAoB,EAAG;AAHxB,IADD;AAOA;AAED;AACA;AACA;AACA;AACA;AACA;;;AACO,SAASI,0BAAT,CAAqC;AAAEC,EAAAA,IAAI,EAAEC;AAAR,IAAsB,EAA3D,EAAgE;AACtE,QAAMC,YAAY,GAAG,CAAE,6BACtBD,SADsB,EAEtBZ,0BAFsB,CAAvB;AAIA,QAAMc,gBAAgB,GAAG,yBAAY,0BAAZ,CAAzB;AAEA,SAAOD,YAAY,IAAI,CAAEC,gBAAzB;AACA;AAED;AACA;AACA;AACA;AACA;AACA;;;AACO,SAASC,qBAAT,CAAgCb,KAAhC,EAAwC;AAAA;;AAC9C,SAAO,CAAC,2BAAEA,KAAK,CAACC,UAAN,CAAiBC,KAAnB,4EAAE,sBAAwBI,UAA1B,mDAAE,uBAAoCC,aAAtC,CAAR;AACA;AAED;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;AACO,SAASO,kBAAT,CAA6B;AAAEb,EAAAA,UAAU,GAAG,EAAf;AAAmBE,EAAAA;AAAnB,CAA7B,EAAkE;AACxE,QAAM;AAAED,IAAAA;AAAF,MAAYD,UAAlB;AAEAE,EAAAA,aAAa,CAAE;AACdD,IAAAA,KAAK,EAAE,6BAAkB,EACxB,GAAGA,KADqB;AAExBI,MAAAA,UAAU,EAAE,EACX,IAAGJ,KAAH,aAAGA,KAAH,uBAAGA,KAAK,CAAEI,UAAV,CADW;AAEXC,QAAAA,aAAa,EAAEQ;AAFJ;AAFY,KAAlB;AADO,GAAF,CAAb;AASA","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { hasBlockSupport } from '@wordpress/blocks';\n\n/**\n * Internal dependencies\n */\nimport LetterSpacingControl from '../components/letter-spacing-control';\nimport useSetting from '../components/use-setting';\nimport { cleanEmptyObject } from './utils';\n\n/**\n * Key within block settings' supports array indicating support for letter-spacing\n * e.g. settings found in `block.json`.\n */\nexport const LETTER_SPACING_SUPPORT_KEY =\n\t'typography.__experimentalLetterSpacing';\n\n/**\n * Inspector control panel containing the letter-spacing options.\n *\n * @param {Object} props Block properties.\n * @return {WPElement} Letter-spacing edit element.\n */\nexport function LetterSpacingEdit( props ) {\n\tconst {\n\t\tattributes: { style },\n\t\tsetAttributes,\n\t} = props;\n\n\tfunction onChange( newSpacing ) {\n\t\tsetAttributes( {\n\t\t\tstyle: cleanEmptyObject( {\n\t\t\t\t...style,\n\t\t\t\ttypography: {\n\t\t\t\t\t...style?.typography,\n\t\t\t\t\tletterSpacing: newSpacing,\n\t\t\t\t},\n\t\t\t} ),\n\t\t} );\n\t}\n\n\treturn (\n\t\t<LetterSpacingControl\n\t\t\tvalue={ style?.typography?.letterSpacing }\n\t\t\tonChange={ onChange }\n\t\t\t__unstableInputWidth={ false }\n\t\t/>\n\t);\n}\n\n/**\n * Checks if letter-spacing settings have been disabled.\n *\n * @param {string} name Name of the block.\n * @return {boolean} Whether or not the setting is disabled.\n */\nexport function useIsLetterSpacingDisabled( { name: blockName } = {} ) {\n\tconst notSupported = ! hasBlockSupport(\n\t\tblockName,\n\t\tLETTER_SPACING_SUPPORT_KEY\n\t);\n\tconst hasLetterSpacing = useSetting( 'typography.letterSpacing' );\n\n\treturn notSupported || ! hasLetterSpacing;\n}\n\n/**\n * Checks if there is a current value set for the letter spacing block support.\n *\n * @param {Object} props Block props.\n * @return {boolean} Whether or not the block has a letter spacing set.\n */\nexport function hasLetterSpacingValue( props ) {\n\treturn !! props.attributes.style?.typography?.letterSpacing;\n}\n\n/**\n * Resets the letter spacing block support attribute. This can be used when\n * disabling the letter spacing support controls for a block via a progressive\n * discovery panel.\n *\n * @param {Object} props Block props.\n * @param {Object} props.attributes Block's attributes.\n * @param {Object} props.setAttributes Function to set block's attributes.\n */\nexport function resetLetterSpacing( { attributes = {}, setAttributes } ) {\n\tconst { style } = attributes;\n\n\tsetAttributes( {\n\t\tstyle: cleanEmptyObject( {\n\t\t\t...style,\n\t\t\ttypography: {\n\t\t\t\t...style?.typography,\n\t\t\t\tletterSpacing: undefined,\n\t\t\t},\n\t\t} ),\n\t} );\n}\n"]}
@@ -7,6 +7,8 @@ Object.defineProperty(exports, "__esModule", {
7
7
  });
8
8
  exports.LineHeightEdit = LineHeightEdit;
9
9
  exports.useIsLineHeightDisabled = useIsLineHeightDisabled;
10
+ exports.hasLineHeightValue = hasLineHeightValue;
11
+ exports.resetLineHeight = resetLineHeight;
10
12
  exports.LINE_HEIGHT_SUPPORT_KEY = void 0;
11
13
 
12
14
  var _element = require("@wordpress/element");
@@ -43,13 +45,9 @@ function LineHeightEdit(props) {
43
45
  const {
44
46
  attributes: {
45
47
  style
46
- }
48
+ },
49
+ setAttributes
47
50
  } = props;
48
- const isDisabled = useIsLineHeightDisabled(props);
49
-
50
- if (isDisabled) {
51
- return null;
52
- }
53
51
 
54
52
  const onChange = newLineHeightValue => {
55
53
  const newStyle = { ...style,
@@ -57,7 +55,7 @@ function LineHeightEdit(props) {
57
55
  lineHeight: newLineHeightValue
58
56
  }
59
57
  };
60
- props.setAttributes({
58
+ setAttributes({
61
59
  style: (0, _utils.cleanEmptyObject)(newStyle)
62
60
  });
63
61
  };
@@ -78,7 +76,46 @@ function LineHeightEdit(props) {
78
76
  function useIsLineHeightDisabled({
79
77
  name: blockName
80
78
  } = {}) {
81
- const isDisabled = !(0, _useSetting.default)('typography.customLineHeight');
79
+ const isDisabled = !(0, _useSetting.default)('typography.lineHeight');
82
80
  return !(0, _blocks.hasBlockSupport)(blockName, LINE_HEIGHT_SUPPORT_KEY) || isDisabled;
83
81
  }
82
+ /**
83
+ * Checks if there is a current value set for the line height block support.
84
+ *
85
+ * @param {Object} props Block props.
86
+ * @return {boolean} Whether or not the block has a line height value set.
87
+ */
88
+
89
+
90
+ function hasLineHeightValue(props) {
91
+ var _props$attributes$sty, _props$attributes$sty2;
92
+
93
+ return !!((_props$attributes$sty = props.attributes.style) !== null && _props$attributes$sty !== void 0 && (_props$attributes$sty2 = _props$attributes$sty.typography) !== null && _props$attributes$sty2 !== void 0 && _props$attributes$sty2.lineHeight);
94
+ }
95
+ /**
96
+ * Resets the line height block support attribute. This can be used when
97
+ * disabling the line height support controls for a block via a progressive
98
+ * discovery panel.
99
+ *
100
+ * @param {Object} props Block props.
101
+ * @param {Object} props.attributes Block's attributes.
102
+ * @param {Object} props.setAttributes Function to set block's attributes.
103
+ */
104
+
105
+
106
+ function resetLineHeight({
107
+ attributes = {},
108
+ setAttributes
109
+ }) {
110
+ const {
111
+ style
112
+ } = attributes;
113
+ setAttributes({
114
+ style: (0, _utils.cleanEmptyObject)({ ...style,
115
+ typography: { ...(style === null || style === void 0 ? void 0 : style.typography),
116
+ lineHeight: undefined
117
+ }
118
+ })
119
+ });
120
+ }
84
121
  //# sourceMappingURL=line-height.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["@wordpress/block-editor/src/hooks/line-height.js"],"names":["LINE_HEIGHT_SUPPORT_KEY","LineHeightEdit","props","attributes","style","isDisabled","useIsLineHeightDisabled","onChange","newLineHeightValue","newStyle","typography","lineHeight","setAttributes","name","blockName"],"mappings":";;;;;;;;;;;;;AAGA;;AAKA;;AACA;;AACA;;AAVA;AACA;AACA;;AAGA;AACA;AACA;AAKO,MAAMA,uBAAuB,GAAG,uBAAhC;AAEP;AACA;AACA;AACA;AACA;AACA;AACA;;;;AACO,SAASC,cAAT,CAAyBC,KAAzB,EAAiC;AAAA;;AACvC,QAAM;AACLC,IAAAA,UAAU,EAAE;AAAEC,MAAAA;AAAF;AADP,MAEFF,KAFJ;AAGA,QAAMG,UAAU,GAAGC,uBAAuB,CAAEJ,KAAF,CAA1C;;AAEA,MAAKG,UAAL,EAAkB;AACjB,WAAO,IAAP;AACA;;AAED,QAAME,QAAQ,GAAKC,kBAAF,IAA0B;AAC1C,UAAMC,QAAQ,GAAG,EAChB,GAAGL,KADa;AAEhBM,MAAAA,UAAU,EAAE,EACX,IAAGN,KAAH,aAAGA,KAAH,uBAAGA,KAAK,CAAEM,UAAV,CADW;AAEXC,QAAAA,UAAU,EAAEH;AAFD;AAFI,KAAjB;AAOAN,IAAAA,KAAK,CAACU,aAAN,CAAqB;AACpBR,MAAAA,KAAK,EAAE,6BAAkBK,QAAlB;AADa,KAArB;AAGA,GAXD;;AAYA,SACC,4BAAC,0BAAD;AACC,IAAA,KAAK,EAAGL,KAAH,aAAGA,KAAH,4CAAGA,KAAK,CAAEM,UAAV,sDAAG,kBAAmBC,UAD5B;AAEC,IAAA,QAAQ,EAAGJ;AAFZ,IADD;AAMA;AAED;AACA;AACA;AACA;AACA;AACA;;;AACO,SAASD,uBAAT,CAAkC;AAAEO,EAAAA,IAAI,EAAEC;AAAR,IAAsB,EAAxD,EAA6D;AACnE,QAAMT,UAAU,GAAG,CAAE,yBAAY,6BAAZ,CAArB;AAEA,SACC,CAAE,6BAAiBS,SAAjB,EAA4Bd,uBAA5B,CAAF,IAA2DK,UAD5D;AAGA","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { hasBlockSupport } from '@wordpress/blocks';\n\n/**\n * Internal dependencies\n */\nimport LineHeightControl from '../components/line-height-control';\nimport { cleanEmptyObject } from './utils';\nimport useSetting from '../components/use-setting';\n\nexport const LINE_HEIGHT_SUPPORT_KEY = 'typography.lineHeight';\n\n/**\n * Inspector control panel containing the line height related configuration\n *\n * @param {Object} props\n *\n * @return {WPElement} Line height edit element.\n */\nexport function LineHeightEdit( props ) {\n\tconst {\n\t\tattributes: { style },\n\t} = props;\n\tconst isDisabled = useIsLineHeightDisabled( props );\n\n\tif ( isDisabled ) {\n\t\treturn null;\n\t}\n\n\tconst onChange = ( newLineHeightValue ) => {\n\t\tconst newStyle = {\n\t\t\t...style,\n\t\t\ttypography: {\n\t\t\t\t...style?.typography,\n\t\t\t\tlineHeight: newLineHeightValue,\n\t\t\t},\n\t\t};\n\t\tprops.setAttributes( {\n\t\t\tstyle: cleanEmptyObject( newStyle ),\n\t\t} );\n\t};\n\treturn (\n\t\t<LineHeightControl\n\t\t\tvalue={ style?.typography?.lineHeight }\n\t\t\tonChange={ onChange }\n\t\t/>\n\t);\n}\n\n/**\n * Custom hook that checks if line-height settings have been disabled.\n *\n * @param {string} name The name of the block.\n * @return {boolean} Whether setting is disabled.\n */\nexport function useIsLineHeightDisabled( { name: blockName } = {} ) {\n\tconst isDisabled = ! useSetting( 'typography.customLineHeight' );\n\n\treturn (\n\t\t! hasBlockSupport( blockName, LINE_HEIGHT_SUPPORT_KEY ) || isDisabled\n\t);\n}\n"]}
1
+ {"version":3,"sources":["@wordpress/block-editor/src/hooks/line-height.js"],"names":["LINE_HEIGHT_SUPPORT_KEY","LineHeightEdit","props","attributes","style","setAttributes","onChange","newLineHeightValue","newStyle","typography","lineHeight","useIsLineHeightDisabled","name","blockName","isDisabled","hasLineHeightValue","resetLineHeight","undefined"],"mappings":";;;;;;;;;;;;;;;AAGA;;AAKA;;AACA;;AACA;;AAVA;AACA;AACA;;AAGA;AACA;AACA;AAKO,MAAMA,uBAAuB,GAAG,uBAAhC;AAEP;AACA;AACA;AACA;AACA;AACA;AACA;;;;AACO,SAASC,cAAT,CAAyBC,KAAzB,EAAiC;AAAA;;AACvC,QAAM;AACLC,IAAAA,UAAU,EAAE;AAAEC,MAAAA;AAAF,KADP;AAELC,IAAAA;AAFK,MAGFH,KAHJ;;AAKA,QAAMI,QAAQ,GAAKC,kBAAF,IAA0B;AAC1C,UAAMC,QAAQ,GAAG,EAChB,GAAGJ,KADa;AAEhBK,MAAAA,UAAU,EAAE,EACX,IAAGL,KAAH,aAAGA,KAAH,uBAAGA,KAAK,CAAEK,UAAV,CADW;AAEXC,QAAAA,UAAU,EAAEH;AAFD;AAFI,KAAjB;AAQAF,IAAAA,aAAa,CAAE;AAAED,MAAAA,KAAK,EAAE,6BAAkBI,QAAlB;AAAT,KAAF,CAAb;AACA,GAVD;;AAWA,SACC,4BAAC,0BAAD;AACC,IAAA,KAAK,EAAGJ,KAAH,aAAGA,KAAH,4CAAGA,KAAK,CAAEK,UAAV,sDAAG,kBAAmBC,UAD5B;AAEC,IAAA,QAAQ,EAAGJ;AAFZ,IADD;AAMA;AAED;AACA;AACA;AACA;AACA;AACA;;;AACO,SAASK,uBAAT,CAAkC;AAAEC,EAAAA,IAAI,EAAEC;AAAR,IAAsB,EAAxD,EAA6D;AACnE,QAAMC,UAAU,GAAG,CAAE,yBAAY,uBAAZ,CAArB;AAEA,SACC,CAAE,6BAAiBD,SAAjB,EAA4Bb,uBAA5B,CAAF,IAA2Dc,UAD5D;AAGA;AAED;AACA;AACA;AACA;AACA;AACA;;;AACO,SAASC,kBAAT,CAA6Bb,KAA7B,EAAqC;AAAA;;AAC3C,SAAO,CAAC,2BAAEA,KAAK,CAACC,UAAN,CAAiBC,KAAnB,4EAAE,sBAAwBK,UAA1B,mDAAE,uBAAoCC,UAAtC,CAAR;AACA;AAED;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;AACO,SAASM,eAAT,CAA0B;AAAEb,EAAAA,UAAU,GAAG,EAAf;AAAmBE,EAAAA;AAAnB,CAA1B,EAA+D;AACrE,QAAM;AAAED,IAAAA;AAAF,MAAYD,UAAlB;AAEAE,EAAAA,aAAa,CAAE;AACdD,IAAAA,KAAK,EAAE,6BAAkB,EACxB,GAAGA,KADqB;AAExBK,MAAAA,UAAU,EAAE,EACX,IAAGL,KAAH,aAAGA,KAAH,uBAAGA,KAAK,CAAEK,UAAV,CADW;AAEXC,QAAAA,UAAU,EAAEO;AAFD;AAFY,KAAlB;AADO,GAAF,CAAb;AASA","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { hasBlockSupport } from '@wordpress/blocks';\n\n/**\n * Internal dependencies\n */\nimport LineHeightControl from '../components/line-height-control';\nimport { cleanEmptyObject } from './utils';\nimport useSetting from '../components/use-setting';\n\nexport const LINE_HEIGHT_SUPPORT_KEY = 'typography.lineHeight';\n\n/**\n * Inspector control panel containing the line height related configuration\n *\n * @param {Object} props\n *\n * @return {WPElement} Line height edit element.\n */\nexport function LineHeightEdit( props ) {\n\tconst {\n\t\tattributes: { style },\n\t\tsetAttributes,\n\t} = props;\n\n\tconst onChange = ( newLineHeightValue ) => {\n\t\tconst newStyle = {\n\t\t\t...style,\n\t\t\ttypography: {\n\t\t\t\t...style?.typography,\n\t\t\t\tlineHeight: newLineHeightValue,\n\t\t\t},\n\t\t};\n\n\t\tsetAttributes( { style: cleanEmptyObject( newStyle ) } );\n\t};\n\treturn (\n\t\t<LineHeightControl\n\t\t\tvalue={ style?.typography?.lineHeight }\n\t\t\tonChange={ onChange }\n\t\t/>\n\t);\n}\n\n/**\n * Custom hook that checks if line-height settings have been disabled.\n *\n * @param {string} name The name of the block.\n * @return {boolean} Whether setting is disabled.\n */\nexport function useIsLineHeightDisabled( { name: blockName } = {} ) {\n\tconst isDisabled = ! useSetting( 'typography.lineHeight' );\n\n\treturn (\n\t\t! hasBlockSupport( blockName, LINE_HEIGHT_SUPPORT_KEY ) || isDisabled\n\t);\n}\n\n/**\n * Checks if there is a current value set for the line height block support.\n *\n * @param {Object} props Block props.\n * @return {boolean} Whether or not the block has a line height value set.\n */\nexport function hasLineHeightValue( props ) {\n\treturn !! props.attributes.style?.typography?.lineHeight;\n}\n\n/**\n * Resets the line height block support attribute. This can be used when\n * disabling the line height support controls for a block via a progressive\n * discovery panel.\n *\n * @param {Object} props Block props.\n * @param {Object} props.attributes Block's attributes.\n * @param {Object} props.setAttributes Function to set block's attributes.\n */\nexport function resetLineHeight( { attributes = {}, setAttributes } ) {\n\tconst { style } = attributes;\n\n\tsetAttributes( {\n\t\tstyle: cleanEmptyObject( {\n\t\t\t...style,\n\t\t\ttypography: {\n\t\t\t\t...style?.typography,\n\t\t\t\tlineHeight: undefined,\n\t\t\t},\n\t\t} ),\n\t} );\n}\n"]}
@@ -94,7 +94,7 @@ function resetMargin({
94
94
  function useIsMarginDisabled({
95
95
  name: blockName
96
96
  } = {}) {
97
- const isDisabled = !(0, _useSetting.default)('spacing.customMargin');
97
+ const isDisabled = !(0, _useSetting.default)('spacing.margin');
98
98
  const isInvalid = !(0, _dimensions.useIsDimensionsSupportValid)(blockName, 'margin');
99
99
  return !hasMarginSupport(blockName) || isDisabled || isInvalid;
100
100
  }
@@ -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","units","availableUnits","sides","splitOnAxis","some","side","AXIAL_SIDES","includes","onChange","next","newStyle","onChangeShowVisualizer","visualizers","Plat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A,KAAK,EAAE,6BAAkBqB,QAAlB;AADO,KAAF,CAAb;AAGA,GAXD;;AAaA,SAAOG,kBAASC,MAAT,CAAiB;AACvBC,IAAAA,GAAG,EACF,qDACC,4BAAC,oCAAD;AACC,MAAA,MAAM,EAAG1B,KAAH,aAAGA,KAAH,yCAAGA,KAAK,CAAEC,OAAV,mDAAG,eAAgBL,MAD1B;AAEC,MAAA,QAAQ,EAAGuB,QAFZ;AAGC,MAAA,sBAAsB,EAAGG,sBAH1B;AAIC,MAAA,KAAK,EAAG,cAAI,QAAJ,CAJT;AAKC,MAAA,KAAK,EAAGT,KALT;AAMC,MAAA,KAAK,EAAGF,KANT;AAOC,MAAA,UAAU,EAAG,KAPd;AAQC,MAAA,WAAW,EAAGG;AARf,MADD,CAFsB;AAevBa,IAAAA,MAAM,EAAE;AAfe,GAAjB,CAAP;AAiBA","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { __ } from '@wordpress/i18n';\nimport { Platform } from '@wordpress/element';\nimport { getBlockSupport } from '@wordpress/blocks';\nimport {\n\t__experimentalUseCustomUnits as useCustomUnits,\n\t__experimentalBoxControl as BoxControl,\n} from '@wordpress/components';\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';\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.customMargin' );\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 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\tconst onChangeShowVisualizer = ( next ) => {\n\t\tconst newStyle = {\n\t\t\t...style,\n\t\t\tvisualizers: {\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<BoxControl\n\t\t\t\t\tvalues={ style?.spacing?.margin }\n\t\t\t\t\tonChange={ onChange }\n\t\t\t\t\tonChangeShowVisualizer={ onChangeShowVisualizer }\n\t\t\t\t\tlabel={ __( 'Margin' ) }\n\t\t\t\t\tsides={ sides }\n\t\t\t\t\tunits={ units }\n\t\t\t\t\tallowReset={ false }\n\t\t\t\t\tsplitOnAxis={ splitOnAxis }\n\t\t\t\t/>\n\t\t\t</>\n\t\t),\n\t\tnative: null,\n\t} );\n}\n"]}
1
+ {"version":3,"sources":["@wordpress/block-editor/src/hooks/margin.js"],"names":["hasMarginSupport","blockType","support","SPACING_SUPPORT_KEY","margin","hasMarginValue","props","attributes","style","spacing","undefined","resetMargin","setAttributes","useIsMarginDisabled","name","blockName","isDisabled","isInvalid","MarginEdit","units","availableUnits","sides","splitOnAxis","some","side","AXIAL_SIDES","includes","onChange","next","newStyle","onChangeShowVisualizer","visualizers","Platform","select","web","native"],"mappings":";;;;;;;;;;;;;AAIA;;AADA;;AAEA;;AACA;;AAQA;;AACA;;AAMA;;AArBA;AACA;AACA;;AASA;AACA;AACA;;AAUA;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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,EAAG,KAPd;AAQC,MAAA,WAAW,EAAGG;AARf,MADD,CAFsB;AAevBa,IAAAA,MAAM,EAAE;AAfe,GAAjB,CAAP;AAiBA","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { __ } from '@wordpress/i18n';\nimport { Platform } from '@wordpress/element';\nimport { getBlockSupport } from '@wordpress/blocks';\nimport {\n\t__experimentalUseCustomUnits as useCustomUnits,\n\t__experimentalBoxControl as BoxControl,\n} from '@wordpress/components';\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';\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 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\tconst onChangeShowVisualizer = ( next ) => {\n\t\tconst newStyle = {\n\t\t\t...style,\n\t\t\tvisualizers: {\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<BoxControl\n\t\t\t\t\tvalues={ style?.spacing?.margin }\n\t\t\t\t\tonChange={ onChange }\n\t\t\t\t\tonChangeShowVisualizer={ onChangeShowVisualizer }\n\t\t\t\t\tlabel={ __( 'Margin' ) }\n\t\t\t\t\tsides={ sides }\n\t\t\t\t\tunits={ units }\n\t\t\t\t\tallowReset={ false }\n\t\t\t\t\tsplitOnAxis={ splitOnAxis }\n\t\t\t\t/>\n\t\t\t</>\n\t\t),\n\t\tnative: null,\n\t} );\n}\n"]}
@@ -94,7 +94,7 @@ function resetPadding({
94
94
  function useIsPaddingDisabled({
95
95
  name: blockName
96
96
  } = {}) {
97
- const isDisabled = !(0, _useSetting.default)('spacing.customPadding');
97
+ const isDisabled = !(0, _useSetting.default)('spacing.padding');
98
98
  const isInvalid = !(0, _dimensions.useIsDimensionsSupportValid)(blockName, 'padding');
99
99
  return !hasPaddingSupport(blockName) || isDisabled || isInvalid;
100
100
  }
@@ -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","units","availableUnits","sides","splitOnAxis","some","side","AXIAL_SIDES","includes","onChange","next","newStyle","onChangeShowVisualizer","visualizers","Platform","select","web","native"],"mappings":";;;;;;;;;;;;;AAIA;;AADA;;AAEA;;AACA;;AAQA;;AACA;;AAMA;;AArBA;AACA;AACA;;AASA;AACA;AACA;;AAUA;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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wordpress/i18n';\nimport { Platform } from '@wordpress/element';\nimport { getBlockSupport } from '@wordpress/blocks';\nimport {\n\t__experimentalUseCustomUnits as useCustomUnits,\n\t__experimentalBoxControl as BoxControl,\n} from '@wordpress/components';\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';\n\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.customPadding' );\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 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\tconst onChangeShowVisualizer = ( next ) => {\n\t\tconst newStyle = {\n\t\t\t...style,\n\t\t\tvisualizers: {\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<BoxControl\n\t\t\t\t\tvalues={ style?.spacing?.padding }\n\t\t\t\t\tonChange={ onChange }\n\t\t\t\t\tonChangeShowVisualizer={ onChangeShowVisualizer }\n\t\t\t\t\tlabel={ __( 'Padding' ) }\n\t\t\t\t\tsides={ sides }\n\t\t\t\t\tunits={ units }\n\t\t\t\t\tallowReset={ false }\n\t\t\t\t\tsplitOnAxis={ splitOnAxis }\n\t\t\t\t/>\n\t\t\t</>\n\t\t),\n\t\tnative: null,\n\t} );\n}\n"]}
1
+ {"version":3,"sources":["@wordpress/block-editor/src/hooks/padding.js"],"names":["hasPaddingSupport","blockType","support","SPACING_SUPPORT_KEY","padding","hasPaddingValue","props","attributes","style","spacing","undefined","resetPadding","setAttributes","useIsPaddingDisabled","name","blockName","isDisabled","isInvalid","PaddingEdit","units","availableUnits","sides","splitOnAxis","some","side","AXIAL_SIDES","includes","onChange","next","newStyle","onChangeShowVisualizer","visualizers","Platform","select","web","native"],"mappings":";;;;;;;;;;;;;AAIA;;AADA;;AAEA;;AACA;;AAQA;;AACA;;AAMA;;AArBA;AACA;AACA;;AASA;AACA;AACA;;AAUA;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,CAAuB;AAAEJ,EAAAA,UAAU,GAAG,EAAf;AAAmBK,EAAAA;AAAnB,CAAvB,EAA4D;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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KAAF,CAAb;AAGA,GAZD;;AAcA,QAAMC,sBAAsB,GAAKF,IAAF,IAAY;AAC1C,UAAMC,QAAQ,GAAG,EAChB,GAAGrB,KADa;AAEhBuB,MAAAA,WAAW,EAAE;AACZ3B,QAAAA,OAAO,EAAEwB;AADG;AAFG,KAAjB;AAOAhB,IAAAA,aAAa,CAAE;AACdJ,MAAAA,KAAK,EAAE,6BAAkBqB,QAAlB;AADO,KAAF,CAAb;AAGA,GAXD;;AAaA,SAAOG,kBAASC,MAAT,CAAiB;AACvBC,IAAAA,GAAG,EACF,qDACC,4BAAC,oCAAD;AACC,MAAA,MAAM,EAAG1B,KAAH,aAAGA,KAAH,yCAAGA,KAAK,CAAEC,OAAV,mDAAG,eAAgBL,OAD1B;AAEC,MAAA,QAAQ,EAAGuB,QAFZ;AAGC,MAAA,sBAAsB,EAAGG,sBAH1B;AAIC,MAAA,KAAK,EAAG,cAAI,SAAJ,CAJT;AAKC,MAAA,KAAK,EAAGT,KALT;AAMC,MAAA,KAAK,EAAGF,KANT;AAOC,MAAA,UAAU,EAAG,KAPd;AAQC,MAAA,WAAW,EAAGG;AARf,MADD,CAFsB;AAevBa,IAAAA,MAAM,EAAE;AAfe,GAAjB,CAAP;AAiBA","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { __ } from '@wordpress/i18n';\nimport { Platform } from '@wordpress/element';\nimport { getBlockSupport } from '@wordpress/blocks';\nimport {\n\t__experimentalUseCustomUnits as useCustomUnits,\n\t__experimentalBoxControl as BoxControl,\n} from '@wordpress/components';\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';\n\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 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\tconst onChangeShowVisualizer = ( next ) => {\n\t\tconst newStyle = {\n\t\t\t...style,\n\t\t\tvisualizers: {\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<BoxControl\n\t\t\t\t\tvalues={ style?.spacing?.padding }\n\t\t\t\t\tonChange={ onChange }\n\t\t\t\t\tonChangeShowVisualizer={ onChangeShowVisualizer }\n\t\t\t\t\tlabel={ __( 'Padding' ) }\n\t\t\t\t\tsides={ sides }\n\t\t\t\t\tunits={ units }\n\t\t\t\t\tallowReset={ false }\n\t\t\t\t\tsplitOnAxis={ splitOnAxis }\n\t\t\t\t/>\n\t\t\t</>\n\t\t),\n\t\tnative: null,\n\t} );\n}\n"]}
@@ -7,6 +7,8 @@ Object.defineProperty(exports, "__esModule", {
7
7
  });
8
8
  exports.TextDecorationEdit = TextDecorationEdit;
9
9
  exports.useIsTextDecorationDisabled = useIsTextDecorationDisabled;
10
+ exports.hasTextDecorationValue = hasTextDecorationValue;
11
+ exports.resetTextDecoration = resetTextDecoration;
10
12
  exports.TEXT_DECORATION_SUPPORT_KEY = void 0;
11
13
 
12
14
  var _element = require("@wordpress/element");
@@ -51,11 +53,6 @@ function TextDecorationEdit(props) {
51
53
  },
52
54
  setAttributes
53
55
  } = props;
54
- const isDisabled = useIsTextDecorationDisabled(props);
55
-
56
- if (isDisabled) {
57
- return null;
58
- }
59
56
 
60
57
  function onChange(newDecoration) {
61
58
  setAttributes({
@@ -85,7 +82,46 @@ function useIsTextDecorationDisabled({
85
82
  name: blockName
86
83
  } = {}) {
87
84
  const notSupported = !(0, _blocks.hasBlockSupport)(blockName, TEXT_DECORATION_SUPPORT_KEY);
88
- const hasTextDecoration = (0, _useSetting.default)('typography.customTextDecorations');
85
+ const hasTextDecoration = (0, _useSetting.default)('typography.textDecoration');
89
86
  return notSupported || !hasTextDecoration;
90
87
  }
88
+ /**
89
+ * Checks if there is a current value set for the text decoration block support.
90
+ *
91
+ * @param {Object} props Block props.
92
+ * @return {boolean} Whether or not the block has a text decoration set.
93
+ */
94
+
95
+
96
+ function hasTextDecorationValue(props) {
97
+ var _props$attributes$sty, _props$attributes$sty2;
98
+
99
+ return !!((_props$attributes$sty = props.attributes.style) !== null && _props$attributes$sty !== void 0 && (_props$attributes$sty2 = _props$attributes$sty.typography) !== null && _props$attributes$sty2 !== void 0 && _props$attributes$sty2.textDecoration);
100
+ }
101
+ /**
102
+ * Resets the text decoration block support attribute. This can be used when
103
+ * disabling the text decoration support controls for a block via a progressive
104
+ * discovery panel.
105
+ *
106
+ * @param {Object} props Block props.
107
+ * @param {Object} props.attributes Block's attributes.
108
+ * @param {Object} props.setAttributes Function to set block's attributes.
109
+ */
110
+
111
+
112
+ function resetTextDecoration({
113
+ attributes = {},
114
+ setAttributes
115
+ }) {
116
+ const {
117
+ style
118
+ } = attributes;
119
+ setAttributes({
120
+ style: (0, _utils.cleanEmptyObject)({ ...style,
121
+ typography: { ...(style === null || style === void 0 ? void 0 : style.typography),
122
+ textDecoration: undefined
123
+ }
124
+ })
125
+ });
126
+ }
91
127
  //# sourceMappingURL=text-decoration.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["@wordpress/block-editor/src/hooks/text-decoration.js"],"names":["TEXT_DECORATION_SUPPORT_KEY","TextDecorationEdit","props","attributes","style","setAttributes","isDisabled","useIsTextDecorationDisabled","onChange","newDecoration","typography","textDecoration","name","blockName","notSupported","hasTextDecoration"],"mappings":";;;;;;;;;;;;;AAGA;;AAKA;;AACA;;AACA;;AAVA;AACA;AACA;;AAGA;AACA;AACA;;AAKA;AACA;AACA;AACA;AACO,MAAMA,2BAA2B,GACvC,yCADM;AAGP;AACA;AACA;AACA;AACA;AACA;AACA;;;;AACO,SAASC,kBAAT,CAA6BC,KAA7B,EAAqC;AAAA;;AAC3C,QAAM;AACLC,IAAAA,UAAU,EAAE;AAAEC,MAAAA;AAAF,KADP;AAELC,IAAAA;AAFK,MAGFH,KAHJ;AAIA,QAAMI,UAAU,GAAGC,2BAA2B,CAAEL,KAAF,CAA9C;;AAEA,MAAKI,UAAL,EAAkB;AACjB,WAAO,IAAP;AACA;;AAED,WAASE,QAAT,CAAmBC,aAAnB,EAAmC;AAClCJ,IAAAA,aAAa,CAAE;AACdD,MAAAA,KAAK,EAAE,6BAAkB,EACxB,GAAGA,KADqB;AAExBM,QAAAA,UAAU,EAAE,EACX,IAAGN,KAAH,aAAGA,KAAH,uBAAGA,KAAK,CAAEM,UAAV,CADW;AAEXC,UAAAA,cAAc,EAAEF;AAFL;AAFY,OAAlB;AADO,KAAF,CAAb;AASA;;AAED,SACC,4BAAC,8BAAD;AACC,IAAA,KAAK,EAAGL,KAAH,aAAGA,KAAH,4CAAGA,KAAK,CAAEM,UAAV,sDAAG,kBAAmBC,cAD5B;AAEC,IAAA,QAAQ,EAAGH;AAFZ,IADD;AAMA;AAED;AACA;AACA;AACA;AACA;AACA;AACA;;;AACO,SAASD,2BAAT,CAAsC;AAAEK,EAAAA,IAAI,EAAEC;AAAR,IAAsB,EAA5D,EAAiE;AACvE,QAAMC,YAAY,GAAG,CAAE,6BACtBD,SADsB,EAEtBb,2BAFsB,CAAvB;AAIA,QAAMe,iBAAiB,GAAG,yBAAY,kCAAZ,CAA1B;AAEA,SAAOD,YAAY,IAAI,CAAEC,iBAAzB;AACA","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { hasBlockSupport } from '@wordpress/blocks';\n\n/**\n * Internal dependencies\n */\nimport TextDecorationControl from '../components/text-decoration-control';\nimport useSetting from '../components/use-setting';\nimport { cleanEmptyObject } from './utils';\n\n/**\n * Key within block settings' supports array indicating support for text\n * decorations e.g. settings found in `block.json`.\n */\nexport const TEXT_DECORATION_SUPPORT_KEY =\n\t'typography.__experimentalTextDecoration';\n\n/**\n * Inspector control panel containing the text decoration options.\n *\n * @param {Object} props Block properties.\n *\n * @return {WPElement} Text decoration edit element.\n */\nexport function TextDecorationEdit( props ) {\n\tconst {\n\t\tattributes: { style },\n\t\tsetAttributes,\n\t} = props;\n\tconst isDisabled = useIsTextDecorationDisabled( props );\n\n\tif ( isDisabled ) {\n\t\treturn null;\n\t}\n\n\tfunction onChange( newDecoration ) {\n\t\tsetAttributes( {\n\t\t\tstyle: cleanEmptyObject( {\n\t\t\t\t...style,\n\t\t\t\ttypography: {\n\t\t\t\t\t...style?.typography,\n\t\t\t\t\ttextDecoration: newDecoration,\n\t\t\t\t},\n\t\t\t} ),\n\t\t} );\n\t}\n\n\treturn (\n\t\t<TextDecorationControl\n\t\t\tvalue={ style?.typography?.textDecoration }\n\t\t\tonChange={ onChange }\n\t\t/>\n\t);\n}\n\n/**\n * Checks if text-decoration settings have been disabled.\n *\n * @param {string} name Name of the block.\n *\n * @return {boolean} Whether or not the setting is disabled.\n */\nexport function useIsTextDecorationDisabled( { name: blockName } = {} ) {\n\tconst notSupported = ! hasBlockSupport(\n\t\tblockName,\n\t\tTEXT_DECORATION_SUPPORT_KEY\n\t);\n\tconst hasTextDecoration = useSetting( 'typography.customTextDecorations' );\n\n\treturn notSupported || ! hasTextDecoration;\n}\n"]}
1
+ {"version":3,"sources":["@wordpress/block-editor/src/hooks/text-decoration.js"],"names":["TEXT_DECORATION_SUPPORT_KEY","TextDecorationEdit","props","attributes","style","setAttributes","onChange","newDecoration","typography","textDecoration","useIsTextDecorationDisabled","name","blockName","notSupported","hasTextDecoration","hasTextDecorationValue","resetTextDecoration","undefined"],"mappings":";;;;;;;;;;;;;;;AAGA;;AAKA;;AACA;;AACA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AACA;AACA;AACA;;;AACO,SAASO,mBAAT,CAA8B;AAAEb,EAAAA,UAAU,GAAG,EAAf;AAAmBE,EAAAA;AAAnB,CAA9B,EAAmE;AACzE,QAAM;AAAED,IAAAA;AAAF,MAAYD,UAAlB;AAEAE,EAAAA,aAAa,CAAE;AACdD,IAAAA,KAAK,EAAE,6BAAkB,EACxB,GAAGA,KADqB;AAExBI,MAAAA,UAAU,EAAE,EACX,IAAGJ,KAAH,aAAGA,KAAH,uBAAGA,KAAK,CAAEI,UAAV,CADW;AAEXC,QAAAA,cAAc,EAAEQ;AAFL;AAFY,KAAlB;AADO,GAAF,CAAb;AASA","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { hasBlockSupport } from '@wordpress/blocks';\n\n/**\n * Internal dependencies\n */\nimport TextDecorationControl from '../components/text-decoration-control';\nimport useSetting from '../components/use-setting';\nimport { cleanEmptyObject } from './utils';\n\n/**\n * Key within block settings' supports array indicating support for text\n * decorations e.g. settings found in `block.json`.\n */\nexport const TEXT_DECORATION_SUPPORT_KEY =\n\t'typography.__experimentalTextDecoration';\n\n/**\n * Inspector control panel containing the text decoration options.\n *\n * @param {Object} props Block properties.\n *\n * @return {WPElement} Text decoration edit element.\n */\nexport function TextDecorationEdit( props ) {\n\tconst {\n\t\tattributes: { style },\n\t\tsetAttributes,\n\t} = props;\n\n\tfunction onChange( newDecoration ) {\n\t\tsetAttributes( {\n\t\t\tstyle: cleanEmptyObject( {\n\t\t\t\t...style,\n\t\t\t\ttypography: {\n\t\t\t\t\t...style?.typography,\n\t\t\t\t\ttextDecoration: newDecoration,\n\t\t\t\t},\n\t\t\t} ),\n\t\t} );\n\t}\n\n\treturn (\n\t\t<TextDecorationControl\n\t\t\tvalue={ style?.typography?.textDecoration }\n\t\t\tonChange={ onChange }\n\t\t/>\n\t);\n}\n\n/**\n * Checks if text-decoration settings have been disabled.\n *\n * @param {string} name Name of the block.\n *\n * @return {boolean} Whether or not the setting is disabled.\n */\nexport function useIsTextDecorationDisabled( { name: blockName } = {} ) {\n\tconst notSupported = ! hasBlockSupport(\n\t\tblockName,\n\t\tTEXT_DECORATION_SUPPORT_KEY\n\t);\n\tconst hasTextDecoration = useSetting( 'typography.textDecoration' );\n\n\treturn notSupported || ! hasTextDecoration;\n}\n\n/**\n * Checks if there is a current value set for the text decoration block support.\n *\n * @param {Object} props Block props.\n * @return {boolean} Whether or not the block has a text decoration set.\n */\nexport function hasTextDecorationValue( props ) {\n\treturn !! props.attributes.style?.typography?.textDecoration;\n}\n\n/**\n * Resets the text decoration block support attribute. This can be used when\n * disabling the text decoration support controls for a block via a progressive\n * discovery panel.\n *\n * @param {Object} props Block props.\n * @param {Object} props.attributes Block's attributes.\n * @param {Object} props.setAttributes Function to set block's attributes.\n */\nexport function resetTextDecoration( { attributes = {}, setAttributes } ) {\n\tconst { style } = attributes;\n\n\tsetAttributes( {\n\t\tstyle: cleanEmptyObject( {\n\t\t\t...style,\n\t\t\ttypography: {\n\t\t\t\t...style?.typography,\n\t\t\t\ttextDecoration: undefined,\n\t\t\t},\n\t\t} ),\n\t} );\n}\n"]}