@wordpress/block-editor 15.8.1-next.dc3f6d3c1.0 → 15.9.1-next.6deb34194.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 (325) hide show
  1. package/CHANGELOG.md +2 -0
  2. package/README.md +12 -0
  3. package/build/components/block-alignment-matrix-control/index.js +1 -8
  4. package/build/components/block-alignment-matrix-control/index.js.map +2 -2
  5. package/build/components/block-bindings/attribute-control.js +172 -0
  6. package/build/components/block-bindings/attribute-control.js.map +7 -0
  7. package/build/components/block-bindings/index.js +47 -0
  8. package/build/components/block-bindings/index.js.map +7 -0
  9. package/build/components/block-bindings/source-fields-list.js +135 -0
  10. package/build/components/block-bindings/source-fields-list.js.map +7 -0
  11. package/build/components/block-bindings/use-block-bindings-utils.js +66 -0
  12. package/build/components/block-bindings/use-block-bindings-utils.js.map +7 -0
  13. package/build/components/block-edit/edit.js +1 -3
  14. package/build/components/block-edit/edit.js.map +2 -2
  15. package/build/components/block-list/index.js +2 -1
  16. package/build/components/block-list/index.js.map +2 -2
  17. package/build/components/block-list/use-block-props/use-selected-block-event-handlers.js +27 -5
  18. package/build/components/block-list/use-block-props/use-selected-block-event-handlers.js.map +2 -2
  19. package/build/components/block-lock/modal.js +5 -5
  20. package/build/components/block-lock/modal.js.map +2 -2
  21. package/build/components/block-lock/use-block-lock.js +10 -13
  22. package/build/components/block-lock/use-block-lock.js.map +2 -2
  23. package/build/components/block-settings-menu-controls/index.js +1 -1
  24. package/build/components/block-settings-menu-controls/index.js.map +2 -2
  25. package/build/components/block-styles/preview-panel.js +3 -5
  26. package/build/components/block-styles/preview-panel.js.map +2 -2
  27. package/build/components/block-styles/use-styles-for-block.js +2 -2
  28. package/build/components/block-styles/use-styles-for-block.js.map +2 -2
  29. package/build/components/block-toolbar/index.js +1 -8
  30. package/build/components/block-toolbar/index.js.map +3 -3
  31. package/build/components/block-tools/index.js +56 -45
  32. package/build/components/block-tools/index.js.map +3 -3
  33. package/build/components/block-visibility/toolbar.js +1 -1
  34. package/build/components/block-visibility/toolbar.js.map +1 -1
  35. package/build/components/content-only-controls/fields-dropdown-menu.js +66 -0
  36. package/build/components/content-only-controls/fields-dropdown-menu.js.map +7 -0
  37. package/build/components/content-only-controls/index.js +202 -44
  38. package/build/components/content-only-controls/index.js.map +3 -3
  39. package/build/components/content-only-controls/link/index.js +92 -103
  40. package/build/components/content-only-controls/link/index.js.map +3 -3
  41. package/build/components/content-only-controls/media/index.js +134 -134
  42. package/build/components/content-only-controls/media/index.js.map +3 -3
  43. package/build/components/content-only-controls/rich-text/index.js +66 -74
  44. package/build/components/content-only-controls/rich-text/index.js.map +3 -3
  45. package/build/components/dimensions-tool/width-height-tool.js +4 -16
  46. package/build/components/dimensions-tool/width-height-tool.js.map +3 -3
  47. package/build/components/font-family/index.js +1 -15
  48. package/build/components/font-family/index.js.map +2 -2
  49. package/build/components/global-styles/dimensions-panel.js +35 -2
  50. package/build/components/global-styles/dimensions-panel.js.map +2 -2
  51. package/build/components/global-styles/hooks.js +1 -1
  52. package/build/components/global-styles/hooks.js.map +2 -2
  53. package/build/components/global-styles/typography-panel.js +1 -2
  54. package/build/components/global-styles/typography-panel.js.map +2 -2
  55. package/build/components/image-editor/cropper.js +3 -34
  56. package/build/components/image-editor/cropper.js.map +3 -3
  57. package/build/components/image-editor/index.js +9 -3
  58. package/build/components/image-editor/index.js.map +2 -2
  59. package/build/components/image-editor/use-transform-image.js +62 -32
  60. package/build/components/image-editor/use-transform-image.js.map +2 -2
  61. package/build/components/image-editor/zoom-dropdown.js +2 -2
  62. package/build/components/image-editor/zoom-dropdown.js.map +2 -2
  63. package/build/components/index.js +10 -3
  64. package/build/components/index.js.map +2 -2
  65. package/build/components/inserter-draggable-blocks/index.js +8 -4
  66. package/build/components/inserter-draggable-blocks/index.js.map +2 -2
  67. package/build/components/inspector-controls-tabs/content-tab.js +3 -2
  68. package/build/components/inspector-controls-tabs/content-tab.js.map +2 -2
  69. package/build/components/inspector-controls-tabs/use-inspector-controls-tabs.js +1 -1
  70. package/build/components/inspector-controls-tabs/use-inspector-controls-tabs.js.map +2 -2
  71. package/build/components/link-control/index.js +15 -7
  72. package/build/components/link-control/index.js.map +2 -2
  73. package/build/components/list-view/block-select-button.js +3 -11
  74. package/build/components/list-view/block-select-button.js.map +2 -2
  75. package/build/components/list-view/block.js +9 -7
  76. package/build/components/list-view/block.js.map +2 -2
  77. package/build/components/media-placeholder/index.js +17 -4
  78. package/build/components/media-placeholder/index.js.map +2 -2
  79. package/build/components/media-placeholder/utils.js +60 -0
  80. package/build/components/media-placeholder/utils.js.map +7 -0
  81. package/build/components/media-replace-flow/index.js +20 -3
  82. package/build/components/media-replace-flow/index.js.map +2 -2
  83. package/build/components/tool-selector/index.js +46 -0
  84. package/build/components/tool-selector/index.js.map +7 -0
  85. package/build/components/use-block-commands/index.js +1 -1
  86. package/build/components/use-block-commands/index.js.map +2 -2
  87. package/build/components/use-block-drop-zone/index.js +1 -5
  88. package/build/components/use-block-drop-zone/index.js.map +2 -2
  89. package/build/hooks/block-bindings.js +22 -260
  90. package/build/hooks/block-bindings.js.map +3 -3
  91. package/build/hooks/dimensions.js +3 -3
  92. package/build/hooks/dimensions.js.map +2 -2
  93. package/build/hooks/metadata.js +1 -1
  94. package/build/hooks/metadata.js.map +2 -2
  95. package/build/hooks/utils.js +5 -1
  96. package/build/hooks/utils.js.map +2 -2
  97. package/build/layouts/grid.js +23 -28
  98. package/build/layouts/grid.js.map +2 -2
  99. package/build/store/private-selectors.js +43 -3
  100. package/build/store/private-selectors.js.map +2 -2
  101. package/build/store/reducer.js +2 -1
  102. package/build/store/reducer.js.map +2 -2
  103. package/build/store/selectors.js +6 -4
  104. package/build/store/selectors.js.map +2 -2
  105. package/build/utils/block-bindings.js +2 -44
  106. package/build/utils/block-bindings.js.map +3 -3
  107. package/build/utils/index.js +2 -5
  108. package/build/utils/index.js.map +2 -2
  109. package/build-module/components/block-alignment-matrix-control/index.js +1 -8
  110. package/build-module/components/block-alignment-matrix-control/index.js.map +2 -2
  111. package/build-module/components/block-bindings/attribute-control.js +150 -0
  112. package/build-module/components/block-bindings/attribute-control.js.map +7 -0
  113. package/build-module/components/block-bindings/index.js +10 -0
  114. package/build-module/components/block-bindings/index.js.map +7 -0
  115. package/build-module/components/block-bindings/source-fields-list.js +104 -0
  116. package/build-module/components/block-bindings/source-fields-list.js.map +7 -0
  117. package/build-module/components/block-bindings/use-block-bindings-utils.js +45 -0
  118. package/build-module/components/block-bindings/use-block-bindings-utils.js.map +7 -0
  119. package/build-module/components/block-edit/edit.js +1 -3
  120. package/build-module/components/block-edit/edit.js.map +2 -2
  121. package/build-module/components/block-list/index.js +2 -1
  122. package/build-module/components/block-list/index.js.map +2 -2
  123. package/build-module/components/block-list/use-block-props/use-selected-block-event-handlers.js +27 -5
  124. package/build-module/components/block-list/use-block-props/use-selected-block-event-handlers.js.map +2 -2
  125. package/build-module/components/block-lock/modal.js +5 -5
  126. package/build-module/components/block-lock/modal.js.map +2 -2
  127. package/build-module/components/block-lock/use-block-lock.js +10 -13
  128. package/build-module/components/block-lock/use-block-lock.js.map +2 -2
  129. package/build-module/components/block-settings-menu-controls/index.js +1 -1
  130. package/build-module/components/block-settings-menu-controls/index.js.map +2 -2
  131. package/build-module/components/block-styles/preview-panel.js +3 -5
  132. package/build-module/components/block-styles/preview-panel.js.map +2 -2
  133. package/build-module/components/block-styles/use-styles-for-block.js +2 -2
  134. package/build-module/components/block-styles/use-styles-for-block.js.map +2 -2
  135. package/build-module/components/block-toolbar/index.js +1 -8
  136. package/build-module/components/block-toolbar/index.js.map +2 -2
  137. package/build-module/components/block-tools/index.js +56 -45
  138. package/build-module/components/block-tools/index.js.map +2 -2
  139. package/build-module/components/block-visibility/toolbar.js +1 -1
  140. package/build-module/components/block-visibility/toolbar.js.map +1 -1
  141. package/build-module/components/content-only-controls/fields-dropdown-menu.js +45 -0
  142. package/build-module/components/content-only-controls/fields-dropdown-menu.js.map +7 -0
  143. package/build-module/components/content-only-controls/index.js +206 -46
  144. package/build-module/components/content-only-controls/index.js.map +2 -2
  145. package/build-module/components/content-only-controls/link/index.js +92 -104
  146. package/build-module/components/content-only-controls/link/index.js.map +2 -2
  147. package/build-module/components/content-only-controls/media/index.js +134 -135
  148. package/build-module/components/content-only-controls/media/index.js.map +2 -2
  149. package/build-module/components/content-only-controls/rich-text/index.js +68 -81
  150. package/build-module/components/content-only-controls/rich-text/index.js.map +2 -2
  151. package/build-module/components/dimensions-tool/width-height-tool.js +4 -6
  152. package/build-module/components/dimensions-tool/width-height-tool.js.map +2 -2
  153. package/build-module/components/font-family/index.js +1 -15
  154. package/build-module/components/font-family/index.js.map +2 -2
  155. package/build-module/components/global-styles/dimensions-panel.js +35 -2
  156. package/build-module/components/global-styles/dimensions-panel.js.map +2 -2
  157. package/build-module/components/global-styles/hooks.js +1 -1
  158. package/build-module/components/global-styles/hooks.js.map +2 -2
  159. package/build-module/components/global-styles/typography-panel.js +1 -2
  160. package/build-module/components/global-styles/typography-panel.js.map +2 -2
  161. package/build-module/components/image-editor/cropper.js +3 -34
  162. package/build-module/components/image-editor/cropper.js.map +2 -2
  163. package/build-module/components/image-editor/index.js +9 -3
  164. package/build-module/components/image-editor/index.js.map +2 -2
  165. package/build-module/components/image-editor/use-transform-image.js +63 -33
  166. package/build-module/components/image-editor/use-transform-image.js.map +2 -2
  167. package/build-module/components/image-editor/zoom-dropdown.js +2 -2
  168. package/build-module/components/image-editor/zoom-dropdown.js.map +2 -2
  169. package/build-module/components/index.js +74 -66
  170. package/build-module/components/index.js.map +2 -2
  171. package/build-module/components/inserter-draggable-blocks/index.js +8 -4
  172. package/build-module/components/inserter-draggable-blocks/index.js.map +2 -2
  173. package/build-module/components/inspector-controls-tabs/content-tab.js +3 -2
  174. package/build-module/components/inspector-controls-tabs/content-tab.js.map +2 -2
  175. package/build-module/components/inspector-controls-tabs/use-inspector-controls-tabs.js +1 -1
  176. package/build-module/components/inspector-controls-tabs/use-inspector-controls-tabs.js.map +2 -2
  177. package/build-module/components/link-control/index.js +16 -8
  178. package/build-module/components/link-control/index.js.map +2 -2
  179. package/build-module/components/list-view/block-select-button.js +3 -11
  180. package/build-module/components/list-view/block-select-button.js.map +2 -2
  181. package/build-module/components/list-view/block.js +9 -7
  182. package/build-module/components/list-view/block.js.map +2 -2
  183. package/build-module/components/media-placeholder/index.js +18 -5
  184. package/build-module/components/media-placeholder/index.js.map +2 -2
  185. package/build-module/components/media-placeholder/utils.js +35 -0
  186. package/build-module/components/media-placeholder/utils.js.map +7 -0
  187. package/build-module/components/media-replace-flow/index.js +20 -3
  188. package/build-module/components/media-replace-flow/index.js.map +2 -2
  189. package/build-module/components/tool-selector/index.js +15 -0
  190. package/build-module/components/tool-selector/index.js.map +7 -0
  191. package/build-module/components/use-block-commands/index.js +1 -1
  192. package/build-module/components/use-block-commands/index.js.map +2 -2
  193. package/build-module/components/use-block-drop-zone/index.js +1 -5
  194. package/build-module/components/use-block-drop-zone/index.js.map +2 -2
  195. package/build-module/hooks/block-bindings.js +27 -270
  196. package/build-module/hooks/block-bindings.js.map +2 -2
  197. package/build-module/hooks/dimensions.js +3 -3
  198. package/build-module/hooks/dimensions.js.map +2 -2
  199. package/build-module/hooks/metadata.js +1 -1
  200. package/build-module/hooks/metadata.js.map +2 -2
  201. package/build-module/hooks/utils.js +5 -1
  202. package/build-module/hooks/utils.js.map +2 -2
  203. package/build-module/layouts/grid.js +23 -28
  204. package/build-module/layouts/grid.js.map +2 -2
  205. package/build-module/store/private-selectors.js +39 -3
  206. package/build-module/store/private-selectors.js.map +2 -2
  207. package/build-module/store/reducer.js +2 -1
  208. package/build-module/store/reducer.js.map +2 -2
  209. package/build-module/store/selectors.js +6 -4
  210. package/build-module/store/selectors.js.map +2 -2
  211. package/build-module/utils/block-bindings.js +1 -42
  212. package/build-module/utils/block-bindings.js.map +2 -2
  213. package/build-module/utils/index.js +1 -3
  214. package/build-module/utils/index.js.map +2 -2
  215. package/build-style/content-rtl.css +3 -0
  216. package/build-style/content.css +3 -0
  217. package/build-style/style-rtl.css +20 -11
  218. package/build-style/style.css +20 -11
  219. package/package.json +39 -39
  220. package/src/components/block-alignment-matrix-control/index.js +1 -5
  221. package/src/components/block-bindings/attribute-control.js +174 -0
  222. package/src/components/block-bindings/index.js +6 -0
  223. package/src/components/block-bindings/source-fields-list.js +130 -0
  224. package/src/components/block-bindings/use-block-bindings-utils.js +156 -0
  225. package/src/components/block-edit/edit.js +1 -3
  226. package/src/components/block-list/content.scss +5 -0
  227. package/src/components/block-list/index.js +3 -1
  228. package/src/components/block-list/use-block-props/use-selected-block-event-handlers.js +34 -3
  229. package/src/components/block-lock/modal.js +6 -5
  230. package/src/components/block-lock/use-block-lock.js +10 -14
  231. package/src/components/block-patterns-list/stories/{index.story.js → index.story.jsx} +3 -1
  232. package/src/components/block-settings-menu-controls/index.js +1 -1
  233. package/src/components/block-styles/preview-panel.js +3 -5
  234. package/src/components/block-styles/use-styles-for-block.js +2 -2
  235. package/src/components/block-toolbar/index.js +1 -6
  236. package/src/components/block-toolbar/style.scss +6 -6
  237. package/src/components/block-tools/index.js +15 -2
  238. package/src/components/block-tools/style.scss +4 -0
  239. package/src/components/block-visibility/toolbar.js +1 -1
  240. package/src/components/content-only-controls/fields-dropdown-menu.js +53 -0
  241. package/src/components/content-only-controls/index.js +289 -50
  242. package/src/components/content-only-controls/link/index.js +62 -57
  243. package/src/components/content-only-controls/media/index.js +177 -156
  244. package/src/components/content-only-controls/rich-text/index.js +31 -44
  245. package/src/components/content-only-controls/styles.scss +10 -1
  246. package/src/components/dimensions-tool/width-height-tool.js +6 -13
  247. package/src/components/font-family/README.md +0 -9
  248. package/src/components/font-family/index.js +1 -16
  249. package/src/components/font-family/stories/{index.story.js → index.story.jsx} +0 -1
  250. package/src/components/global-styles/dimensions-panel.js +36 -0
  251. package/src/components/global-styles/hooks.js +1 -1
  252. package/src/components/global-styles/typography-panel.js +0 -1
  253. package/src/components/image-editor/cropper.js +3 -32
  254. package/src/components/image-editor/index.js +34 -29
  255. package/src/components/image-editor/use-transform-image.js +80 -34
  256. package/src/components/image-editor/zoom-dropdown.js +2 -2
  257. package/src/components/index.js +9 -1
  258. package/src/components/inserter/style.scss +1 -1
  259. package/src/components/inserter-draggable-blocks/index.js +19 -8
  260. package/src/components/inspector-controls-tabs/content-tab.js +6 -2
  261. package/src/components/inspector-controls-tabs/use-inspector-controls-tabs.js +1 -5
  262. package/src/components/link-control/index.js +36 -12
  263. package/src/components/list-view/block-select-button.js +22 -30
  264. package/src/components/list-view/block.js +9 -7
  265. package/src/components/media-placeholder/index.js +20 -5
  266. package/src/components/media-placeholder/test/get-computed-accept-attribute.js +164 -0
  267. package/src/components/media-placeholder/utils.js +65 -0
  268. package/src/components/media-replace-flow/index.js +22 -3
  269. package/src/components/tool-selector/index.js +19 -0
  270. package/src/components/use-block-commands/index.js +1 -1
  271. package/src/components/use-block-drop-zone/index.js +1 -5
  272. package/src/hooks/block-bindings.js +27 -347
  273. package/src/hooks/dimensions.js +8 -3
  274. package/src/hooks/metadata.js +1 -1
  275. package/src/hooks/test/metadata.js +1 -1
  276. package/src/hooks/utils.js +4 -0
  277. package/src/layouts/grid.js +40 -72
  278. package/src/layouts/test/grid.js +14 -0
  279. package/src/store/private-selectors.js +123 -6
  280. package/src/store/reducer.js +3 -0
  281. package/src/store/selectors.js +6 -4
  282. package/src/store/test/private-selectors.js +242 -0
  283. package/src/store/test/reducer.js +17 -7
  284. package/src/style.scss +0 -1
  285. package/src/utils/block-bindings.js +0 -157
  286. package/src/utils/index.js +0 -1
  287. package/tsconfig.json +2 -0
  288. package/build/components/block-toolbar/block-name-context.js +0 -30
  289. package/build/components/block-toolbar/block-name-context.js.map +0 -7
  290. package/build/components/content-only-controls/plain-text/index.js +0 -68
  291. package/build/components/content-only-controls/plain-text/index.js.map +0 -7
  292. package/build-module/components/block-toolbar/block-name-context.js +0 -9
  293. package/build-module/components/block-toolbar/block-name-context.js.map +0 -7
  294. package/build-module/components/content-only-controls/plain-text/index.js +0 -50
  295. package/build-module/components/content-only-controls/plain-text/index.js.map +0 -7
  296. package/src/components/block-toolbar/block-name-context.js +0 -9
  297. package/src/components/content-only-controls/plain-text/index.js +0 -49
  298. package/src/components/font-family/style.scss +0 -7
  299. /package/src/components/alignment-control/stories/{aliginment-toolbar.story.js → aliginment-toolbar.story.jsx} +0 -0
  300. /package/src/components/alignment-control/stories/{index.story.js → index.story.jsx} +0 -0
  301. /package/src/components/block-alignment-matrix-control/stories/{index.story.js → index.story.jsx} +0 -0
  302. /package/src/{utils → components/block-bindings}/test/use-block-bindings-utils.js +0 -0
  303. /package/src/components/block-draggable/stories/{index.story.js → index.story.jsx} +0 -0
  304. /package/src/components/block-heading-level-dropdown/stories/{index.story.js → index.story.jsx} +0 -0
  305. /package/src/components/block-mover/stories/{index.story.js → index.story.jsx} +0 -0
  306. /package/src/components/block-title/stories/{index.story.js → index.story.jsx} +0 -0
  307. /package/src/components/border-radius-control/stories/{index.story.js → index.story.jsx} +0 -0
  308. /package/src/components/date-format-picker/stories/{index.story.js → index.story.jsx} +0 -0
  309. /package/src/components/dimensions-tool/stories/{aspect-ratio-tool.story.js → aspect-ratio-tool.story.jsx} +0 -0
  310. /package/src/components/dimensions-tool/stories/{index.story.js → index.story.jsx} +0 -0
  311. /package/src/components/dimensions-tool/stories/{scale-tool.story.js → scale-tool.story.jsx} +0 -0
  312. /package/src/components/dimensions-tool/stories/{width-height-tool.story.js → width-height-tool.story.jsx} +0 -0
  313. /package/src/components/height-control/stories/{index.story.js → index.story.jsx} +0 -0
  314. /package/src/components/inserter/stories/{index.story.js → index.story.jsx} +0 -0
  315. /package/src/components/line-height-control/stories/{index.story.js → index.story.jsx} +0 -0
  316. /package/src/components/plain-text/stories/{index.story.js → index.story.jsx} +0 -0
  317. /package/src/components/resolution-tool/stories/{index.story.js → index.story.jsx} +0 -0
  318. /package/src/components/tabbed-sidebar/stories/{index.story.js → index.story.jsx} +0 -0
  319. /package/src/components/text-alignment-control/stories/{index.story.js → index.story.jsx} +0 -0
  320. /package/src/components/text-decoration-control/stories/{index.story.js → index.story.jsx} +0 -0
  321. /package/src/components/text-transform-control/stories/{index.story.js → index.story.jsx} +0 -0
  322. /package/src/components/unit-control/stories/{index.story.js → index.story.jsx} +0 -0
  323. /package/src/components/url-popover/stories/{index.story.js → index.story.jsx} +0 -0
  324. /package/src/components/warning/stories/{index.story.js → index.story.jsx} +0 -0
  325. /package/src/components/writing-mode-control/stories/{index.story.js → index.story.jsx} +0 -0
@@ -1,15 +1,10 @@
1
1
  // packages/block-editor/src/components/content-only-controls/rich-text/index.js
2
- import {
3
- BaseControl,
4
- useBaseControlProps,
5
- __experimentalToolsPanelItem as ToolsPanelItem
6
- } from "@wordpress/components";
2
+ import { BaseControl, useBaseControlProps } from "@wordpress/components";
7
3
  import { useMergeRefs } from "@wordpress/compose";
8
4
  import { useRegistry } from "@wordpress/data";
9
5
  import { useRef, useState } from "@wordpress/element";
10
6
  import {
11
7
  __unstableUseRichText as useRichText,
12
- isEmpty,
13
8
  removeFormat
14
9
  } from "@wordpress/rich-text";
15
10
  import { useFormatTypes } from "../../rich-text/use-format-types";
@@ -17,18 +12,22 @@ import { getAllowedFormats } from "../../rich-text/utils";
17
12
  import { useEventListeners } from "../../rich-text/event-listeners";
18
13
  import FormatEdit from "../../rich-text/format-edit";
19
14
  import { keyboardShortcutContext, inputEventContext } from "../../rich-text";
20
- import { jsx, jsxs } from "react/jsx-runtime";
15
+ import { Fragment, jsx, jsxs } from "react/jsx-runtime";
21
16
  function RichTextControl({
22
- clientId,
23
- control,
24
- blockType,
25
- attributeValues,
26
- updateAttributes
17
+ data,
18
+ field,
19
+ hideLabelFromVision,
20
+ onChange,
21
+ config = {}
27
22
  }) {
28
23
  const registry = useRegistry();
29
- const valueKey = control.mapping.value;
30
- const attrValue = attributeValues[valueKey];
31
- const defaultValue = blockType.attributes[valueKey]?.defaultValue ?? void 0;
24
+ const attrValue = field.getValue({ item: data });
25
+ const fieldConfig = field.config || {};
26
+ const { clientId } = config;
27
+ const updateAttributes = (html) => {
28
+ const mappedChanges = field.setValue({ item: data, value: html });
29
+ onChange(mappedChanges);
30
+ };
32
31
  const [selection, setSelection] = useState({
33
32
  start: void 0,
34
33
  end: void 0
@@ -38,8 +37,8 @@ function RichTextControl({
38
37
  const inputEvents = useRef(/* @__PURE__ */ new Set());
39
38
  const keyboardShortcuts = useRef(/* @__PURE__ */ new Set());
40
39
  const adjustedAllowedFormats = getAllowedFormats({
41
- allowedFormats: control.args?.allowedFormats,
42
- disableFormats: control.args?.disableFormats
40
+ allowedFormats: fieldConfig?.allowedFormats,
41
+ disableFormats: fieldConfig?.disableFormats
43
42
  });
44
43
  const {
45
44
  formatTypes,
@@ -49,9 +48,9 @@ function RichTextControl({
49
48
  dependencies
50
49
  } = useFormatTypes({
51
50
  clientId,
52
- identifier: valueKey,
51
+ identifier: field.id,
53
52
  allowedFormats: adjustedAllowedFormats,
54
- withoutInteractiveFormatting: control.args?.withoutInteractiveFormatting,
53
+ withoutInteractiveFormatting: fieldConfig?.withoutInteractiveFormatting,
55
54
  disableNoneEssentialFormatting: true
56
55
  });
57
56
  function addEditorOnlyFormats(value2) {
@@ -85,12 +84,12 @@ function RichTextControl({
85
84
  const {
86
85
  value,
87
86
  getValue,
88
- onChange,
87
+ onChange: onRichTextChange,
89
88
  ref: richTextRef
90
89
  } = useRichText({
91
90
  value: attrValue,
92
91
  onChange(html, { __unstableFormats, __unstableText }) {
93
- updateAttributes({ [valueKey]: html });
92
+ updateAttributes(html);
94
93
  Object.values(changeHandlers).forEach((changeHandler) => {
95
94
  changeHandler(__unstableFormats, __unstableText);
96
95
  });
@@ -99,74 +98,62 @@ function RichTextControl({
99
98
  selectionEnd: selection.end,
100
99
  onSelectionChange: (start, end) => setSelection({ start, end }),
101
100
  __unstableIsSelected: isSelected,
102
- preserveWhiteSpace: !!control.args?.preserveWhiteSpace,
103
- placeholder: control.args?.placeholder,
104
- __unstableDisableFormats: control.args?.disableFormats,
101
+ preserveWhiteSpace: !!fieldConfig?.preserveWhiteSpace,
102
+ placeholder: fieldConfig?.placeholder,
103
+ __unstableDisableFormats: fieldConfig?.disableFormats,
105
104
  __unstableDependencies: dependencies,
106
105
  __unstableAfterParse: addEditorOnlyFormats,
107
106
  __unstableBeforeSerialize: removeEditorOnlyFormats,
108
107
  __unstableAddInvisibleFormats: addInvisibleFormats
109
108
  });
110
109
  const { baseControlProps, controlProps } = useBaseControlProps({
111
- hideLabelFromVision: control.shownByDefault,
112
- label: control.label
110
+ hideLabelFromVision: hideLabelFromVision ?? field.hideLabelFromVision,
111
+ label: field.label
113
112
  });
114
- return /* @__PURE__ */ jsxs(
115
- ToolsPanelItem,
116
- {
117
- panelId: clientId,
118
- label: control.label,
119
- hasValue: () => {
120
- return value?.text && !isEmpty(value);
121
- },
122
- onDeselect: () => updateAttributes({ [valueKey]: defaultValue }),
123
- isShownByDefault: control.shownByDefault,
124
- children: [
125
- isSelected && /* @__PURE__ */ jsx(keyboardShortcutContext.Provider, { value: keyboardShortcuts, children: /* @__PURE__ */ jsx(inputEventContext.Provider, { value: inputEvents, children: /* @__PURE__ */ jsx("div", { children: /* @__PURE__ */ jsx(
126
- FormatEdit,
127
- {
128
- value,
129
- onChange,
130
- onFocus,
113
+ return /* @__PURE__ */ jsxs(Fragment, { children: [
114
+ isSelected && /* @__PURE__ */ jsx(keyboardShortcutContext.Provider, { value: keyboardShortcuts, children: /* @__PURE__ */ jsx(inputEventContext.Provider, { value: inputEvents, children: /* @__PURE__ */ jsx("div", { children: /* @__PURE__ */ jsx(
115
+ FormatEdit,
116
+ {
117
+ value,
118
+ onChange: onRichTextChange,
119
+ onFocus,
120
+ formatTypes,
121
+ forwardedRef: anchorRef,
122
+ isVisible: false
123
+ }
124
+ ) }) }) }),
125
+ /* @__PURE__ */ jsx(BaseControl, { __nextHasNoMarginBottom: true, ...baseControlProps, children: /* @__PURE__ */ jsx(
126
+ "div",
127
+ {
128
+ className: "block-editor-content-only-controls__rich-text",
129
+ role: "textbox",
130
+ "aria-multiline": !fieldConfig?.disableLineBreaks,
131
+ ref: useMergeRefs([
132
+ richTextRef,
133
+ useEventListeners({
134
+ registry,
135
+ getValue,
136
+ onChange: onRichTextChange,
131
137
  formatTypes,
132
- forwardedRef: anchorRef,
133
- isVisible: false
134
- }
135
- ) }) }) }),
136
- /* @__PURE__ */ jsx(BaseControl, { __nextHasNoMarginBottom: true, ...baseControlProps, children: /* @__PURE__ */ jsx(
137
- "div",
138
- {
139
- className: "block-editor-content-only-controls__rich-text",
140
- role: "textbox",
141
- "aria-multiline": !control.args?.disableLineBreaks,
142
- ref: useMergeRefs([
143
- richTextRef,
144
- useEventListeners({
145
- registry,
146
- getValue,
147
- onChange,
148
- formatTypes,
149
- selectionChange: setSelection,
150
- isSelected,
151
- disableFormats: control.args?.disableFormats,
152
- value,
153
- tagName: "div",
154
- removeEditorOnlyFormats,
155
- disableLineBreaks: control.args?.disableLineBreaks,
156
- keyboardShortcuts,
157
- inputEvents
158
- }),
159
- anchorRef
160
- ]),
161
- onFocus: () => setIsSelected(true),
162
- onBlur: () => setIsSelected(false),
163
- contentEditable: true,
164
- ...controlProps
165
- }
166
- ) })
167
- ]
168
- }
169
- );
138
+ selectionChange: setSelection,
139
+ isSelected,
140
+ disableFormats: fieldConfig?.disableFormats,
141
+ value,
142
+ tagName: "div",
143
+ removeEditorOnlyFormats,
144
+ disableLineBreaks: fieldConfig?.disableLineBreaks,
145
+ keyboardShortcuts,
146
+ inputEvents
147
+ }),
148
+ anchorRef
149
+ ]),
150
+ onFocus: () => setIsSelected(true),
151
+ onBlur: () => setIsSelected(false),
152
+ contentEditable: true,
153
+ ...controlProps
154
+ }
155
+ ) })
156
+ ] });
170
157
  }
171
158
  export {
172
159
  RichTextControl as default
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../../src/components/content-only-controls/rich-text/index.js"],
4
- "sourcesContent": ["/**\n * WordPress dependencies\n */\nimport {\n\tBaseControl,\n\tuseBaseControlProps,\n\t__experimentalToolsPanelItem as ToolsPanelItem,\n} from '@wordpress/components';\nimport { useMergeRefs } from '@wordpress/compose';\nimport { useRegistry } from '@wordpress/data';\nimport { useRef, useState } from '@wordpress/element';\nimport {\n\t__unstableUseRichText as useRichText,\n\tisEmpty,\n\tremoveFormat,\n} from '@wordpress/rich-text';\n\n/**\n * Internal dependencies\n */\nimport { useFormatTypes } from '../../rich-text/use-format-types';\nimport { getAllowedFormats } from '../../rich-text/utils';\nimport { useEventListeners } from '../../rich-text/event-listeners';\nimport FormatEdit from '../../rich-text/format-edit';\nimport { keyboardShortcutContext, inputEventContext } from '../../rich-text';\n\nexport default function RichTextControl( {\n\tclientId,\n\tcontrol,\n\tblockType,\n\tattributeValues,\n\tupdateAttributes,\n} ) {\n\tconst registry = useRegistry();\n\tconst valueKey = control.mapping.value;\n\tconst attrValue = attributeValues[ valueKey ];\n\tconst defaultValue =\n\t\tblockType.attributes[ valueKey ]?.defaultValue ?? undefined;\n\tconst [ selection, setSelection ] = useState( {\n\t\tstart: undefined,\n\t\tend: undefined,\n\t} );\n\tconst [ isSelected, setIsSelected ] = useState( false );\n\tconst anchorRef = useRef();\n\tconst inputEvents = useRef( new Set() );\n\tconst keyboardShortcuts = useRef( new Set() );\n\n\tconst adjustedAllowedFormats = getAllowedFormats( {\n\t\tallowedFormats: control.args?.allowedFormats,\n\t\tdisableFormats: control.args?.disableFormats,\n\t} );\n\n\tconst {\n\t\tformatTypes,\n\t\tprepareHandlers,\n\t\tvalueHandlers,\n\t\tchangeHandlers,\n\t\tdependencies,\n\t} = useFormatTypes( {\n\t\tclientId,\n\t\tidentifier: valueKey,\n\t\tallowedFormats: adjustedAllowedFormats,\n\t\twithoutInteractiveFormatting:\n\t\t\tcontrol.args?.withoutInteractiveFormatting,\n\t\tdisableNoneEssentialFormatting: true,\n\t} );\n\n\tfunction addEditorOnlyFormats( value ) {\n\t\treturn valueHandlers.reduce(\n\t\t\t( accumulator, fn ) => fn( accumulator, value.text ),\n\t\t\tvalue.formats\n\t\t);\n\t}\n\n\tfunction removeEditorOnlyFormats( value ) {\n\t\tformatTypes.forEach( ( formatType ) => {\n\t\t\t// Remove formats created by prepareEditableTree, because they are editor only.\n\t\t\tif ( formatType.__experimentalCreatePrepareEditableTree ) {\n\t\t\t\tvalue = removeFormat(\n\t\t\t\t\tvalue,\n\t\t\t\t\tformatType.name,\n\t\t\t\t\t0,\n\t\t\t\t\tvalue.text.length\n\t\t\t\t);\n\t\t\t}\n\t\t} );\n\n\t\treturn value.formats;\n\t}\n\n\tfunction addInvisibleFormats( value ) {\n\t\treturn prepareHandlers.reduce(\n\t\t\t( accumulator, fn ) => fn( accumulator, value.text ),\n\t\t\tvalue.formats\n\t\t);\n\t}\n\n\tfunction onFocus() {\n\t\tanchorRef.current?.focus();\n\t}\n\n\tconst {\n\t\tvalue,\n\t\tgetValue,\n\t\tonChange,\n\t\tref: richTextRef,\n\t} = useRichText( {\n\t\tvalue: attrValue,\n\t\tonChange( html, { __unstableFormats, __unstableText } ) {\n\t\t\tupdateAttributes( { [ valueKey ]: html } );\n\t\t\tObject.values( changeHandlers ).forEach( ( changeHandler ) => {\n\t\t\t\tchangeHandler( __unstableFormats, __unstableText );\n\t\t\t} );\n\t\t},\n\t\tselectionStart: selection.start,\n\t\tselectionEnd: selection.end,\n\t\tonSelectionChange: ( start, end ) => setSelection( { start, end } ),\n\t\t__unstableIsSelected: isSelected,\n\t\tpreserveWhiteSpace: !! control.args?.preserveWhiteSpace,\n\t\tplaceholder: control.args?.placeholder,\n\t\t__unstableDisableFormats: control.args?.disableFormats,\n\t\t__unstableDependencies: dependencies,\n\t\t__unstableAfterParse: addEditorOnlyFormats,\n\t\t__unstableBeforeSerialize: removeEditorOnlyFormats,\n\t\t__unstableAddInvisibleFormats: addInvisibleFormats,\n\t} );\n\n\tconst { baseControlProps, controlProps } = useBaseControlProps( {\n\t\thideLabelFromVision: control.shownByDefault,\n\t\tlabel: control.label,\n\t} );\n\n\treturn (\n\t\t<ToolsPanelItem\n\t\t\tpanelId={ clientId }\n\t\t\tlabel={ control.label }\n\t\t\thasValue={ () => {\n\t\t\t\treturn value?.text && ! isEmpty( value );\n\t\t\t} }\n\t\t\tonDeselect={ () =>\n\t\t\t\tupdateAttributes( { [ valueKey ]: defaultValue } )\n\t\t\t}\n\t\t\tisShownByDefault={ control.shownByDefault }\n\t\t>\n\t\t\t{ isSelected && (\n\t\t\t\t<keyboardShortcutContext.Provider value={ keyboardShortcuts }>\n\t\t\t\t\t<inputEventContext.Provider value={ inputEvents }>\n\t\t\t\t\t\t<div>\n\t\t\t\t\t\t\t<FormatEdit\n\t\t\t\t\t\t\t\tvalue={ value }\n\t\t\t\t\t\t\t\tonChange={ onChange }\n\t\t\t\t\t\t\t\tonFocus={ onFocus }\n\t\t\t\t\t\t\t\tformatTypes={ formatTypes }\n\t\t\t\t\t\t\t\tforwardedRef={ anchorRef }\n\t\t\t\t\t\t\t\tisVisible={ false }\n\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t</div>\n\t\t\t\t\t</inputEventContext.Provider>\n\t\t\t\t</keyboardShortcutContext.Provider>\n\t\t\t) }\n\t\t\t<BaseControl __nextHasNoMarginBottom { ...baseControlProps }>\n\t\t\t\t<div\n\t\t\t\t\tclassName=\"block-editor-content-only-controls__rich-text\"\n\t\t\t\t\trole=\"textbox\"\n\t\t\t\t\taria-multiline={ ! control.args?.disableLineBreaks }\n\t\t\t\t\tref={ useMergeRefs( [\n\t\t\t\t\t\trichTextRef,\n\t\t\t\t\t\tuseEventListeners( {\n\t\t\t\t\t\t\tregistry,\n\t\t\t\t\t\t\tgetValue,\n\t\t\t\t\t\t\tonChange,\n\t\t\t\t\t\t\tformatTypes,\n\t\t\t\t\t\t\tselectionChange: setSelection,\n\t\t\t\t\t\t\tisSelected,\n\t\t\t\t\t\t\tdisableFormats: control.args?.disableFormats,\n\t\t\t\t\t\t\tvalue,\n\t\t\t\t\t\t\ttagName: 'div',\n\t\t\t\t\t\t\tremoveEditorOnlyFormats,\n\t\t\t\t\t\t\tdisableLineBreaks: control.args?.disableLineBreaks,\n\t\t\t\t\t\t\tkeyboardShortcuts,\n\t\t\t\t\t\t\tinputEvents,\n\t\t\t\t\t\t} ),\n\t\t\t\t\t\tanchorRef,\n\t\t\t\t\t] ) }\n\t\t\t\t\tonFocus={ () => setIsSelected( true ) }\n\t\t\t\t\tonBlur={ () => setIsSelected( false ) }\n\t\t\t\t\tcontentEditable\n\t\t\t\t\t{ ...controlProps }\n\t\t\t\t/>\n\t\t\t</BaseControl>\n\t\t</ToolsPanelItem>\n\t);\n}\n"],
5
- "mappings": ";AAGA;AAAA,EACC;AAAA,EACA;AAAA,EACA,gCAAgC;AAAA,OAC1B;AACP,SAAS,oBAAoB;AAC7B,SAAS,mBAAmB;AAC5B,SAAS,QAAQ,gBAAgB;AACjC;AAAA,EACC,yBAAyB;AAAA,EACzB;AAAA,EACA;AAAA,OACM;AAKP,SAAS,sBAAsB;AAC/B,SAAS,yBAAyB;AAClC,SAAS,yBAAyB;AAClC,OAAO,gBAAgB;AACvB,SAAS,yBAAyB,yBAAyB;AA6GzD,SAeK,KAfL;AA3Ga,SAAR,gBAAkC;AAAA,EACxC;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACD,GAAI;AACH,QAAM,WAAW,YAAY;AAC7B,QAAM,WAAW,QAAQ,QAAQ;AACjC,QAAM,YAAY,gBAAiB,QAAS;AAC5C,QAAM,eACL,UAAU,WAAY,QAAS,GAAG,gBAAgB;AACnD,QAAM,CAAE,WAAW,YAAa,IAAI,SAAU;AAAA,IAC7C,OAAO;AAAA,IACP,KAAK;AAAA,EACN,CAAE;AACF,QAAM,CAAE,YAAY,aAAc,IAAI,SAAU,KAAM;AACtD,QAAM,YAAY,OAAO;AACzB,QAAM,cAAc,OAAQ,oBAAI,IAAI,CAAE;AACtC,QAAM,oBAAoB,OAAQ,oBAAI,IAAI,CAAE;AAE5C,QAAM,yBAAy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gBACA,gBAAgB,QAAQ,MAAM;AAAA,gBAC9B;AAAA,gBACA,SAAS;AAAA,gBACT;AAAA,gBACA,mBAAmB,QAAQ,MAAM;AAAA,gBACjC;AAAA,gBACA;AAAA,cACD,CAAE;AAAA,cACF;AAAA,YACD,CAAE;AAAA,YACF,SAAU,MAAM,cAAe,IAAK;AAAA,YACpC,QAAS,MAAM,cAAe,KAAM;AAAA,YACpC,iBAAe;AAAA,YACb,GAAG;AAAA;AAAA,QACN,GACD;AAAA;AAAA;AAAA,EACD;AAEF;",
4
+ "sourcesContent": ["/**\n * WordPress dependencies\n */\nimport { BaseControl, useBaseControlProps } from '@wordpress/components';\nimport { useMergeRefs } from '@wordpress/compose';\nimport { useRegistry } from '@wordpress/data';\nimport { useRef, useState } from '@wordpress/element';\nimport {\n\t__unstableUseRichText as useRichText,\n\tremoveFormat,\n} from '@wordpress/rich-text';\n\n/**\n * Internal dependencies\n */\nimport { useFormatTypes } from '../../rich-text/use-format-types';\nimport { getAllowedFormats } from '../../rich-text/utils';\nimport { useEventListeners } from '../../rich-text/event-listeners';\nimport FormatEdit from '../../rich-text/format-edit';\nimport { keyboardShortcutContext, inputEventContext } from '../../rich-text';\n\nexport default function RichTextControl( {\n\tdata,\n\tfield,\n\thideLabelFromVision,\n\tonChange,\n\tconfig = {},\n} ) {\n\tconst registry = useRegistry();\n\tconst attrValue = field.getValue( { item: data } );\n\tconst fieldConfig = field.config || {};\n\tconst { clientId } = config;\n\tconst updateAttributes = ( html ) => {\n\t\tconst mappedChanges = field.setValue( { item: data, value: html } );\n\t\tonChange( mappedChanges );\n\t};\n\tconst [ selection, setSelection ] = useState( {\n\t\tstart: undefined,\n\t\tend: undefined,\n\t} );\n\tconst [ isSelected, setIsSelected ] = useState( false );\n\tconst anchorRef = useRef();\n\tconst inputEvents = useRef( new Set() );\n\tconst keyboardShortcuts = useRef( new Set() );\n\n\tconst adjustedAllowedFormats = getAllowedFormats( {\n\t\tallowedFormats: fieldConfig?.allowedFormats,\n\t\tdisableFormats: fieldConfig?.disableFormats,\n\t} );\n\n\tconst {\n\t\tformatTypes,\n\t\tprepareHandlers,\n\t\tvalueHandlers,\n\t\tchangeHandlers,\n\t\tdependencies,\n\t} = useFormatTypes( {\n\t\tclientId,\n\t\tidentifier: field.id,\n\t\tallowedFormats: adjustedAllowedFormats,\n\t\twithoutInteractiveFormatting: fieldConfig?.withoutInteractiveFormatting,\n\t\tdisableNoneEssentialFormatting: true,\n\t} );\n\n\tfunction addEditorOnlyFormats( value ) {\n\t\treturn valueHandlers.reduce(\n\t\t\t( accumulator, fn ) => fn( accumulator, value.text ),\n\t\t\tvalue.formats\n\t\t);\n\t}\n\n\tfunction removeEditorOnlyFormats( value ) {\n\t\tformatTypes.forEach( ( formatType ) => {\n\t\t\t// Remove formats created by prepareEditableTree, because they are editor only.\n\t\t\tif ( formatType.__experimentalCreatePrepareEditableTree ) {\n\t\t\t\tvalue = removeFormat(\n\t\t\t\t\tvalue,\n\t\t\t\t\tformatType.name,\n\t\t\t\t\t0,\n\t\t\t\t\tvalue.text.length\n\t\t\t\t);\n\t\t\t}\n\t\t} );\n\n\t\treturn value.formats;\n\t}\n\n\tfunction addInvisibleFormats( value ) {\n\t\treturn prepareHandlers.reduce(\n\t\t\t( accumulator, fn ) => fn( accumulator, value.text ),\n\t\t\tvalue.formats\n\t\t);\n\t}\n\n\tfunction onFocus() {\n\t\tanchorRef.current?.focus();\n\t}\n\n\tconst {\n\t\tvalue,\n\t\tgetValue,\n\t\tonChange: onRichTextChange,\n\t\tref: richTextRef,\n\t} = useRichText( {\n\t\tvalue: attrValue,\n\t\tonChange( html, { __unstableFormats, __unstableText } ) {\n\t\t\tupdateAttributes( html );\n\t\t\tObject.values( changeHandlers ).forEach( ( changeHandler ) => {\n\t\t\t\tchangeHandler( __unstableFormats, __unstableText );\n\t\t\t} );\n\t\t},\n\t\tselectionStart: selection.start,\n\t\tselectionEnd: selection.end,\n\t\tonSelectionChange: ( start, end ) => setSelection( { start, end } ),\n\t\t__unstableIsSelected: isSelected,\n\t\tpreserveWhiteSpace: !! fieldConfig?.preserveWhiteSpace,\n\t\tplaceholder: fieldConfig?.placeholder,\n\t\t__unstableDisableFormats: fieldConfig?.disableFormats,\n\t\t__unstableDependencies: dependencies,\n\t\t__unstableAfterParse: addEditorOnlyFormats,\n\t\t__unstableBeforeSerialize: removeEditorOnlyFormats,\n\t\t__unstableAddInvisibleFormats: addInvisibleFormats,\n\t} );\n\n\tconst { baseControlProps, controlProps } = useBaseControlProps( {\n\t\thideLabelFromVision: hideLabelFromVision ?? field.hideLabelFromVision,\n\t\tlabel: field.label,\n\t} );\n\n\treturn (\n\t\t<>\n\t\t\t{ isSelected && (\n\t\t\t\t<keyboardShortcutContext.Provider value={ keyboardShortcuts }>\n\t\t\t\t\t<inputEventContext.Provider value={ inputEvents }>\n\t\t\t\t\t\t<div>\n\t\t\t\t\t\t\t<FormatEdit\n\t\t\t\t\t\t\t\tvalue={ value }\n\t\t\t\t\t\t\t\tonChange={ onRichTextChange }\n\t\t\t\t\t\t\t\tonFocus={ onFocus }\n\t\t\t\t\t\t\t\tformatTypes={ formatTypes }\n\t\t\t\t\t\t\t\tforwardedRef={ anchorRef }\n\t\t\t\t\t\t\t\tisVisible={ false }\n\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t</div>\n\t\t\t\t\t</inputEventContext.Provider>\n\t\t\t\t</keyboardShortcutContext.Provider>\n\t\t\t) }\n\t\t\t<BaseControl __nextHasNoMarginBottom { ...baseControlProps }>\n\t\t\t\t<div\n\t\t\t\t\tclassName=\"block-editor-content-only-controls__rich-text\"\n\t\t\t\t\trole=\"textbox\"\n\t\t\t\t\taria-multiline={ ! fieldConfig?.disableLineBreaks }\n\t\t\t\t\tref={ useMergeRefs( [\n\t\t\t\t\t\trichTextRef,\n\t\t\t\t\t\tuseEventListeners( {\n\t\t\t\t\t\t\tregistry,\n\t\t\t\t\t\t\tgetValue,\n\t\t\t\t\t\t\tonChange: onRichTextChange,\n\t\t\t\t\t\t\tformatTypes,\n\t\t\t\t\t\t\tselectionChange: setSelection,\n\t\t\t\t\t\t\tisSelected,\n\t\t\t\t\t\t\tdisableFormats: fieldConfig?.disableFormats,\n\t\t\t\t\t\t\tvalue,\n\t\t\t\t\t\t\ttagName: 'div',\n\t\t\t\t\t\t\tremoveEditorOnlyFormats,\n\t\t\t\t\t\t\tdisableLineBreaks: fieldConfig?.disableLineBreaks,\n\t\t\t\t\t\t\tkeyboardShortcuts,\n\t\t\t\t\t\t\tinputEvents,\n\t\t\t\t\t\t} ),\n\t\t\t\t\t\tanchorRef,\n\t\t\t\t\t] ) }\n\t\t\t\t\tonFocus={ () => setIsSelected( true ) }\n\t\t\t\t\tonBlur={ () => setIsSelected( false ) }\n\t\t\t\t\tcontentEditable\n\t\t\t\t\t{ ...controlProps }\n\t\t\t\t/>\n\t\t\t</BaseControl>\n\t\t</>\n\t);\n}\n"],
5
+ "mappings": ";AAGA,SAAS,aAAa,2BAA2B;AACjD,SAAS,oBAAoB;AAC7B,SAAS,mBAAmB;AAC5B,SAAS,QAAQ,gBAAgB;AACjC;AAAA,EACC,yBAAyB;AAAA,EACzB;AAAA,OACM;AAKP,SAAS,sBAAsB;AAC/B,SAAS,yBAAyB;AAClC,SAAS,yBAAyB;AAClC,OAAO,gBAAgB;AACvB,SAAS,yBAAyB,yBAAyB;AA+GzD,mBAKK,KALL;AA7Ga,SAAR,gBAAkC;AAAA,EACxC;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA,SAAS,CAAC;AACX,GAAI;AACH,QAAM,WAAW,YAAY;AAC7B,QAAM,YAAY,MAAM,SAAU,EAAE,MAAM,KAAK,CAAE;AACjD,QAAM,cAAc,MAAM,UAAU,CAAC;AACrC,QAAM,EAAE,SAAS,IAAI;AACrB,QAAM,mBAAmB,CAAE,SAAU;AACpC,UAAM,gBAAgB,MAAM,SAAU,EAAE,MAAM,MAAM,OAAO,KAAK,CAAE;AAClE,aAAU,aAAc;AAAA,EACz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AAAA,YAC7B;AAAA,YACA,SAAS;AAAA,YACT;AAAA,YACA,mBAAmB,aAAa;AAAA,YAChC;AAAA,YACA;AAAA,UACD,CAAE;AAAA,UACF;AAAA,QACD,CAAE;AAAA,QACF,SAAU,MAAM,cAAe,IAAK;AAAA,QACpC,QAAS,MAAM,cAAe,KAAM;AAAA,QACpC,iBAAe;AAAA,QACb,GAAG;AAAA;AAAA,IACN,GACD;AAAA,KACD;AAEF;",
6
6
  "names": ["value"]
7
7
  }
@@ -1,14 +1,10 @@
1
1
  // packages/block-editor/src/components/dimensions-tool/width-height-tool.js
2
- import styled from "@emotion/styled";
3
2
  import {
4
3
  __experimentalToolsPanelItem as ToolsPanelItem,
5
4
  __experimentalUnitControl as UnitControl
6
5
  } from "@wordpress/components";
7
6
  import { __ } from "@wordpress/i18n";
8
7
  import { Fragment, jsx, jsxs } from "react/jsx-runtime";
9
- var SingleColumnToolsPanelItem = styled(ToolsPanelItem)`
10
- grid-column: span 1;
11
- `;
12
8
  function WidthHeightTool({
13
9
  panelId,
14
10
  value = {},
@@ -30,8 +26,9 @@ function WidthHeightTool({
30
26
  };
31
27
  return /* @__PURE__ */ jsxs(Fragment, { children: [
32
28
  /* @__PURE__ */ jsx(
33
- SingleColumnToolsPanelItem,
29
+ ToolsPanelItem,
34
30
  {
31
+ style: { gridColumn: "span 1" },
35
32
  label: __("Width"),
36
33
  isShownByDefault,
37
34
  hasValue: () => width !== "",
@@ -53,8 +50,9 @@ function WidthHeightTool({
53
50
  }
54
51
  ),
55
52
  /* @__PURE__ */ jsx(
56
- SingleColumnToolsPanelItem,
53
+ ToolsPanelItem,
57
54
  {
55
+ style: { gridColumn: "span 1" },
58
56
  label: __("Height"),
59
57
  isShownByDefault,
60
58
  hasValue: () => height !== "",
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../src/components/dimensions-tool/width-height-tool.js"],
4
- "sourcesContent": ["/**\n * External dependencies\n */\nimport styled from '@emotion/styled';\n\n/**\n * WordPress dependencies\n */\nimport {\n\t__experimentalToolsPanelItem as ToolsPanelItem,\n\t__experimentalUnitControl as UnitControl,\n} from '@wordpress/components';\nimport { __ } from '@wordpress/i18n';\n\nconst SingleColumnToolsPanelItem = styled( ToolsPanelItem )`\n\tgrid-column: span 1;\n`;\n\n/**\n * @typedef {import('@wordpress/components/build-types/unit-control/types').WPUnitControlUnit} WPUnitControlUnit\n */\n\n/**\n * @typedef {Object} WidthHeightToolValue\n * @property {string} [width] Width CSS value.\n * @property {string} [height] Height CSS value.\n */\n\n/**\n * @callback WidthHeightToolOnChange\n * @param {WidthHeightToolValue} nextValue Next dimensions value.\n * @return {void}\n */\n\n/**\n * @typedef {Object} WidthHeightToolProps\n * @property {string} [panelId] ID of the panel that contains the controls.\n * @property {WidthHeightToolValue} [value] Current dimensions values.\n * @property {WidthHeightToolOnChange} [onChange] Callback to update the dimensions values.\n * @property {WPUnitControlUnit[]} [units] Units options.\n * @property {boolean} [isShownByDefault] Whether the panel is shown by default.\n */\n\n/**\n * Component that renders controls to edit the dimensions of an image or container.\n *\n * @param {WidthHeightToolProps} props The component props.\n *\n * @return {import('react').ReactElement} The width and height tool.\n */\nexport default function WidthHeightTool( {\n\tpanelId,\n\tvalue = {},\n\tonChange = () => {},\n\tunits,\n\tisShownByDefault = true,\n} ) {\n\t// null, undefined, and 'auto' all represent the default value.\n\tconst width = value.width === 'auto' ? '' : value.width ?? '';\n\tconst height = value.height === 'auto' ? '' : value.height ?? '';\n\n\tconst onDimensionChange = ( dimension ) => ( nextDimension ) => {\n\t\tconst nextValue = { ...value };\n\t\t// Empty strings or undefined may be passed and both represent removing the value.\n\t\tif ( ! nextDimension ) {\n\t\t\tdelete nextValue[ dimension ];\n\t\t} else {\n\t\t\tnextValue[ dimension ] = nextDimension;\n\t\t}\n\t\tonChange( nextValue );\n\t};\n\n\treturn (\n\t\t<>\n\t\t\t<SingleColumnToolsPanelItem\n\t\t\t\tlabel={ __( 'Width' ) }\n\t\t\t\tisShownByDefault={ isShownByDefault }\n\t\t\t\thasValue={ () => width !== '' }\n\t\t\t\tonDeselect={ onDimensionChange( 'width' ) }\n\t\t\t\tpanelId={ panelId }\n\t\t\t>\n\t\t\t\t<UnitControl\n\t\t\t\t\tlabel={ __( 'Width' ) }\n\t\t\t\t\tplaceholder={ __( 'Auto' ) }\n\t\t\t\t\tlabelPosition=\"top\"\n\t\t\t\t\tunits={ units }\n\t\t\t\t\tmin={ 0 }\n\t\t\t\t\tvalue={ width }\n\t\t\t\t\tonChange={ onDimensionChange( 'width' ) }\n\t\t\t\t\tsize=\"__unstable-large\"\n\t\t\t\t/>\n\t\t\t</SingleColumnToolsPanelItem>\n\t\t\t<SingleColumnToolsPanelItem\n\t\t\t\tlabel={ __( 'Height' ) }\n\t\t\t\tisShownByDefault={ isShownByDefault }\n\t\t\t\thasValue={ () => height !== '' }\n\t\t\t\tonDeselect={ onDimensionChange( 'height' ) }\n\t\t\t\tpanelId={ panelId }\n\t\t\t>\n\t\t\t\t<UnitControl\n\t\t\t\t\tlabel={ __( 'Height' ) }\n\t\t\t\t\tplaceholder={ __( 'Auto' ) }\n\t\t\t\t\tlabelPosition=\"top\"\n\t\t\t\t\tunits={ units }\n\t\t\t\t\tmin={ 0 }\n\t\t\t\t\tvalue={ height }\n\t\t\t\t\tonChange={ onDimensionChange( 'height' ) }\n\t\t\t\t\tsize=\"__unstable-large\"\n\t\t\t\t/>\n\t\t\t</SingleColumnToolsPanelItem>\n\t\t</>\n\t);\n}\n"],
5
- "mappings": ";AAGA,OAAO,YAAY;AAKnB;AAAA,EACC,gCAAgC;AAAA,EAChC,6BAA6B;AAAA,OACvB;AACP,SAAS,UAAU;AA6DjB,mBAQE,KARF;AA3DF,IAAM,6BAA6B,OAAQ,cAAe;AAAA;AAAA;AAoC3C,SAAR,gBAAkC;AAAA,EACxC;AAAA,EACA,QAAQ,CAAC;AAAA,EACT,WAAW,MAAM;AAAA,EAAC;AAAA,EAClB;AAAA,EACA,mBAA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imentalUnitControl as UnitControl,\n} from '@wordpress/components';\nimport { __ } from '@wordpress/i18n';\n\n/**\n * @typedef {import('@wordpress/components/build-types/unit-control/types').WPUnitControlUnit} WPUnitControlUnit\n */\n\n/**\n * @typedef {Object} WidthHeightToolValue\n * @property {string} [width] Width CSS value.\n * @property {string} [height] Height CSS value.\n */\n\n/**\n * @callback WidthHeightToolOnChange\n * @param {WidthHeightToolValue} nextValue Next dimensions value.\n * @return {void}\n */\n\n/**\n * @typedef {Object} WidthHeightToolProps\n * @property {string} [panelId] ID of the panel that contains the controls.\n * @property {WidthHeightToolValue} [value] Current dimensions values.\n * @property {WidthHeightToolOnChange} [onChange] Callback to update the dimensions values.\n * @property {WPUnitControlUnit[]} [units] Units options.\n * @property {boolean} [isShownByDefault] Whether the panel is shown by default.\n */\n\n/**\n * Component that renders controls to edit the dimensions of an image or container.\n *\n * @param {WidthHeightToolProps} props The component props.\n *\n * @return {import('react').ReactElement} The width and height tool.\n */\nexport default function WidthHeightTool( {\n\tpanelId,\n\tvalue = {},\n\tonChange = () => {},\n\tunits,\n\tisShownByDefault = true,\n} ) {\n\t// null, undefined, and 'auto' all represent the default value.\n\tconst width = value.width === 'auto' ? '' : value.width ?? '';\n\tconst height = value.height === 'auto' ? '' : value.height ?? '';\n\n\tconst onDimensionChange = ( dimension ) => ( nextDimension ) => {\n\t\tconst nextValue = { ...value };\n\t\t// Empty strings or undefined may be passed and both represent removing the value.\n\t\tif ( ! nextDimension ) {\n\t\t\tdelete nextValue[ dimension ];\n\t\t} else {\n\t\t\tnextValue[ dimension ] = nextDimension;\n\t\t}\n\t\tonChange( nextValue );\n\t};\n\n\treturn (\n\t\t<>\n\t\t\t<ToolsPanelItem\n\t\t\t\tstyle={ { gridColumn: 'span 1' } }\n\t\t\t\tlabel={ __( 'Width' ) }\n\t\t\t\tisShownByDefault={ isShownByDefault }\n\t\t\t\thasValue={ () => width !== '' }\n\t\t\t\tonDeselect={ onDimensionChange( 'width' ) }\n\t\t\t\tpanelId={ panelId }\n\t\t\t>\n\t\t\t\t<UnitControl\n\t\t\t\t\tlabel={ __( 'Width' ) }\n\t\t\t\t\tplaceholder={ __( 'Auto' ) }\n\t\t\t\t\tlabelPosition=\"top\"\n\t\t\t\t\tunits={ units }\n\t\t\t\t\tmin={ 0 }\n\t\t\t\t\tvalue={ width }\n\t\t\t\t\tonChange={ onDimensionChange( 'width' ) }\n\t\t\t\t\tsize=\"__unstable-large\"\n\t\t\t\t/>\n\t\t\t</ToolsPanelItem>\n\t\t\t<ToolsPanelItem\n\t\t\t\tstyle={ { gridColumn: 'span 1' } }\n\t\t\t\tlabel={ __( 'Height' ) }\n\t\t\t\tisShownByDefault={ isShownByDefault }\n\t\t\t\thasValue={ () => height !== '' }\n\t\t\t\tonDeselect={ onDimensionChange( 'height' ) }\n\t\t\t\tpanelId={ panelId }\n\t\t\t>\n\t\t\t\t<UnitControl\n\t\t\t\t\tlabel={ __( 'Height' ) }\n\t\t\t\t\tplaceholder={ __( 'Auto' ) }\n\t\t\t\t\tlabelPosition=\"top\"\n\t\t\t\t\tunits={ units }\n\t\t\t\t\tmin={ 0 }\n\t\t\t\t\tvalue={ height }\n\t\t\t\t\tonChange={ onDimensionChange( 'height' ) }\n\t\t\t\t\tsize=\"__unstable-large\"\n\t\t\t\t/>\n\t\t\t</ToolsPanelItem>\n\t\t</>\n\t);\n}\n"],
5
+ "mappings": ";AAGA;AAAA,EACC,gCAAgC;AAAA,EAChC,6BAA6B;AAAA,OACvB;AACP,SAAS,UAAU;AAyDjB,mBASE,KATF;AAvBa,SAAR,gBAAkC;AAAA,EACxC;AAAA,EACA,QAAQ,CAAC;AAAA,EACT,WAAW,MAAM;AAAA,EAAC;AAAA,EAClB;AAAA,EACA,mBAAmB;AACpB,GAAI;AAEH,QAAM,QAAQ,MAAM,UAAU,SAAS,KAAK,MAAM,SAAS;AAC3D,QAAM,SAAS,MAAM,WAAW,SAAS,KAAK,MAAM,UAAU;AAE9D,QAAM,oBAAoB,CAAE,cAAe,CAAE,kBAAmB;AAC/D,UAAM,YAAY,EAAE,GAAG,MAAM;AAE7B,QAAK,CAAE,eAAgB;AACtB,aAAO,UAAW,SAAU;AAAA,IAC7B,OAAO;AACN,gBAAW,SAAU,IAAI;AAAA,IAC1B;AACA,aAAU,SAAU;AAAA,EACrB;AAEA,SACC,iCACC;AAAA;AAAA,MAAC;AAAA;AAAA,QACA,OAAQ,EAAE,YAAY,SAAS;AAAA,QAC/B,OAAQ,GAAI,OAAQ;AAAA,QACpB;AAAA,QACA,UAAW,MAAM,UAAU;AAAA,QAC3B,YAAa,kBAAmB,OAAQ;AAAA,QACxC;AAAA,QAEA;AAAA,UAAC;AAAA;AAAA,YACA,OAAQ,GAAI,OAAQ;AAAA,YACpB,aAAc,GAAI,MAAO;AAAA,YACzB,eAAc;AAAA,YACd;AAAA,YACA,KAAM;AAAA,YACN,OAAQ;AAAA,YACR,UAAW,kBAAmB,OAAQ;AAAA,YACtC,MAAK;AAAA;AAAA,QACN;AAAA;AAAA,IACD;AAAA,IACA;AAAA,MAAC;AAAA;AAAA,QACA,OAAQ,EAAE,YAAY,SAAS;AAAA,QAC/B,OAAQ,GAAI,QAAS;AAAA,QACrB;AAAA,QACA,UAAW,MAAM,WAAW;AAAA,QAC5B,YAAa,kBAAmB,QAAS;AAAA,QACzC;AAAA,QAEA;AAAA,UAAC;AAAA;AAAA,YACA,OAAQ,GAAI,QAAS;AAAA,YACrB,aAAc,GAAI,MAAO;AAAA,YACzB,eAAc;AAAA,YACd;AAAA,YACA,KAAM;AAAA,YACN,OAAQ;AAAA,YACR,UAAW,kBAAmB,QAAS;AAAA,YACvC,MAAK;AAAA;AAAA,QACN;AAAA;AAAA,IACD;AAAA,KACD;AAEF;",
6
6
  "names": []
7
7
  }
@@ -8,8 +8,6 @@ import { jsx } from "react/jsx-runtime";
8
8
  function FontFamilyControl({
9
9
  /** Start opting into the larger default height that will become the default size in a future version. */
10
10
  __next40pxDefaultSize = false,
11
- /** Start opting into the new margin-free styles that will become the default in a future version. */
12
- __nextHasNoMarginBottom = false,
13
11
  value = "",
14
12
  onChange,
15
13
  fontFamilies,
@@ -34,16 +32,6 @@ function FontFamilyControl({
34
32
  style: { fontFamily }
35
33
  }))
36
34
  ];
37
- if (!__nextHasNoMarginBottom) {
38
- deprecated(
39
- "Bottom margin styles for wp.blockEditor.FontFamilyControl",
40
- {
41
- since: "6.7",
42
- version: "7.0",
43
- hint: "Set the `__nextHasNoMarginBottom` prop to true to start opting into the new styles, which will become the default in a future version"
44
- }
45
- );
46
- }
47
35
  if (!__next40pxDefaultSize && (props.size === void 0 || props.size === "default")) {
48
36
  deprecated(
49
37
  `36px default size for wp.blockEditor.__experimentalFontFamilyControl`,
@@ -64,9 +52,7 @@ function FontFamilyControl({
64
52
  value: selectedValue,
65
53
  onChange: ({ selectedItem }) => onChange(selectedItem.key),
66
54
  options,
67
- className: clsx("block-editor-font-family-control", className, {
68
- "is-next-has-no-margin-bottom": __nextHasNoMarginBottom
69
- }),
55
+ className: clsx("block-editor-font-family-control", className),
70
56
  ...props
71
57
  }
72
58
  );
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../src/components/font-family/index.js"],
4
- "sourcesContent": ["/**\n * External dependencies\n */\nimport clsx from 'clsx';\n\n/**\n * WordPress dependencies\n */\nimport { CustomSelectControl } from '@wordpress/components';\nimport deprecated from '@wordpress/deprecated';\nimport { __ } from '@wordpress/i18n';\n\n/**\n * Internal dependencies\n */\nimport { useSettings } from '../use-settings';\n\nexport default function FontFamilyControl( {\n\t/** Start opting into the larger default height that will become the default size in a future version. */\n\t__next40pxDefaultSize = false,\n\t/** Start opting into the new margin-free styles that will become the default in a future version. */\n\t__nextHasNoMarginBottom = false,\n\tvalue = '',\n\tonChange,\n\tfontFamilies,\n\tclassName,\n\t...props\n} ) {\n\tconst [ blockLevelFontFamilies ] = useSettings( 'typography.fontFamilies' );\n\tif ( ! fontFamilies ) {\n\t\tfontFamilies = blockLevelFontFamilies;\n\t}\n\n\tif ( ! fontFamilies || fontFamilies.length === 0 ) {\n\t\treturn null;\n\t}\n\n\tconst options = [\n\t\t{\n\t\t\tkey: '',\n\t\t\tname: __( 'Default' ),\n\t\t},\n\t\t...fontFamilies.map( ( { fontFamily, name } ) => ( {\n\t\t\tkey: fontFamily,\n\t\t\tname: name || fontFamily,\n\t\t\tstyle: { fontFamily },\n\t\t} ) ),\n\t];\n\n\tif ( ! __nextHasNoMarginBottom ) {\n\t\tdeprecated(\n\t\t\t'Bottom margin styles for wp.blockEditor.FontFamilyControl',\n\t\t\t{\n\t\t\t\tsince: '6.7',\n\t\t\t\tversion: '7.0',\n\t\t\t\thint: 'Set the `__nextHasNoMarginBottom` prop to true to start opting into the new styles, which will become the default in a future version',\n\t\t\t}\n\t\t);\n\t}\n\n\tif (\n\t\t! __next40pxDefaultSize &&\n\t\t( props.size === undefined || props.size === 'default' )\n\t) {\n\t\tdeprecated(\n\t\t\t`36px default size for wp.blockEditor.__experimentalFontFamilyControl`,\n\t\t\t{\n\t\t\t\tsince: '6.8',\n\t\t\t\tversion: '7.1',\n\t\t\t\thint: 'Set the `__next40pxDefaultSize` prop to true to start opting into the new default size, which will become the default in a future version.',\n\t\t\t}\n\t\t);\n\t}\n\n\tconst selectedValue =\n\t\toptions.find( ( option ) => option.key === value ) ?? '';\n\treturn (\n\t\t<CustomSelectControl\n\t\t\t__next40pxDefaultSize={ __next40pxDefaultSize }\n\t\t\t__shouldNotWarnDeprecated36pxSize\n\t\t\tlabel={ __( 'Font' ) }\n\t\t\tvalue={ selectedValue }\n\t\t\tonChange={ ( { selectedItem } ) => onChange( selectedItem.key ) }\n\t\t\toptions={ options }\n\t\t\tclassName={ clsx( 'block-editor-font-family-control', className, {\n\t\t\t\t'is-next-has-no-margin-bottom': __nextHasNoMarginBottom,\n\t\t\t} ) }\n\t\t\t{ ...props }\n\t\t/>\n\t);\n}\n"],
5
- "mappings": ";AAGA,OAAO,UAAU;AAKjB,SAAS,2B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AW;AAAA,QAChE,gCAAgC;AAAA,MACjC,CAAE;AAAA,MACA,GAAG;AAAA;AAAA,EACN;AAEF;",
4
+ "sourcesContent": ["/**\n * External dependencies\n */\nimport clsx from 'clsx';\n\n/**\n * WordPress dependencies\n */\nimport { CustomSelectControl } from '@wordpress/components';\nimport deprecated from '@wordpress/deprecated';\nimport { __ } from '@wordpress/i18n';\n\n/**\n * Internal dependencies\n */\nimport { useSettings } from '../use-settings';\n\nexport default function FontFamilyControl( {\n\t/** Start opting into the larger default height that will become the default size in a future version. */\n\t__next40pxDefaultSize = false,\n\tvalue = '',\n\tonChange,\n\tfontFamilies,\n\tclassName,\n\t...props\n} ) {\n\tconst [ blockLevelFontFamilies ] = useSettings( 'typography.fontFamilies' );\n\tif ( ! fontFamilies ) {\n\t\tfontFamilies = blockLevelFontFamilies;\n\t}\n\n\tif ( ! fontFamilies || fontFamilies.length === 0 ) {\n\t\treturn null;\n\t}\n\n\tconst options = [\n\t\t{\n\t\t\tkey: '',\n\t\t\tname: __( 'Default' ),\n\t\t},\n\t\t...fontFamilies.map( ( { fontFamily, name } ) => ( {\n\t\t\tkey: fontFamily,\n\t\t\tname: name || fontFamily,\n\t\t\tstyle: { fontFamily },\n\t\t} ) ),\n\t];\n\n\tif (\n\t\t! __next40pxDefaultSize &&\n\t\t( props.size === undefined || props.size === 'default' )\n\t) {\n\t\tdeprecated(\n\t\t\t`36px default size for wp.blockEditor.__experimentalFontFamilyControl`,\n\t\t\t{\n\t\t\t\tsince: '6.8',\n\t\t\t\tversion: '7.1',\n\t\t\t\thint: 'Set the `__next40pxDefaultSize` prop to true to start opting into the new default size, which will become the default in a future version.',\n\t\t\t}\n\t\t);\n\t}\n\n\tconst selectedValue =\n\t\toptions.find( ( option ) => option.key === value ) ?? '';\n\treturn (\n\t\t<CustomSelectControl\n\t\t\t__next40pxDefaultSize={ __next40pxDefaultSize }\n\t\t\t__shouldNotWarnDeprecated36pxSize\n\t\t\tlabel={ __( 'Font' ) }\n\t\t\tvalue={ selectedValue }\n\t\t\tonChange={ ( { selectedItem } ) => onChange( selectedItem.key ) }\n\t\t\toptions={ options }\n\t\t\tclassName={ clsx( 'block-editor-font-family-control', className ) }\n\t\t\t{ ...props }\n\t\t/>\n\t);\n}\n"],
5
+ "mappings": ";AAGA,OAAO,UAAU;AAKjB,SAAS,2BAA2B;AACpC,OAAO,gBAAgB;AACvB,SAAS,UAAU;AAKnB,SAAS,mBAAmB;AAiD1B;AA/Ca,SAAR,kBAAoC;AAAA;AAAA,EAE1C,wBAAwB;AAAA,EACxB,QAAQ;AAAA,EACR;AAAA,EACA;AAAA,EACA;AAAA,EACA,GAAG;AACJ,GAAI;AACH,QAAM,CAAE,sBAAuB,IAAI,YAAa,yBAA0B;AAC1E,MAAK,CAAE,cAAe;AACrB,mBAAe;AAAA,EAChB;AAEA,MAAK,CAAE,gBAAgB,aAAa,WAAW,GAAI;AAClD,WAAO;AAAA,EACR;AAEA,QAAM,UAAU;AAAA,IACf;AAAA,MACC,KAAK;AAAA,MACL,MAAM,GAAI,SAAU;AAAA,IACrB;AAAA,IACA,GAAG,aAAa,IAAK,CAAE,EAAE,YAAY,KAAK,OAAS;AAAA,MAClD,KAAK;AAAA,MACL,MAAM,QAAQ;AAAA,MACd,OAAO,EAAE,WAAW;AAAA,IACrB,EAAI;AAAA,EACL;AAEA,MACC,CAAE,0BACA,MAAM,SAAS,UAAa,MAAM,SAAS,YAC5C;AACD;AAAA,MACC;AAAA,MACA;AAAA,QACC,OAAO;AAAA,QACP,SAAS;AAAA,QACT,MAAM;AAAA,MACP;AAAA,IACD;AAAA,EACD;AAEA,QAAM,gBACL,QAAQ,KAAM,CAAE,WAAY,OAAO,QAAQ,KAAM,KAAK;AACvD,SACC;AAAA,IAAC;AAAA;AAAA,MACA;AAAA,MACA,mCAAiC;AAAA,MACjC,OAAQ,GAAI,MAAO;AAAA,MACnB,OAAQ;AAAA,MACR,UAAW,CAAE,EAAE,aAAa,MAAO,SAAU,aAAa,GAAI;AAAA,MAC9D;AAAA,MACA,WAAY,KAAM,oCAAoC,SAAU;AAAA,MAC9D,GAAG;AAAA;AAAA,EACN;AAEF;",
6
6
  "names": []
7
7
  }
@@ -28,9 +28,10 @@ function useHasDimensionsPanel(settings) {
28
28
  const hasMargin = useHasMargin(settings);
29
29
  const hasGap = useHasGap(settings);
30
30
  const hasMinHeight = useHasMinHeight(settings);
31
+ const hasWidth = useHasWidth(settings);
31
32
  const hasAspectRatio = useHasAspectRatio(settings);
32
33
  const hasChildLayout = useHasChildLayout(settings);
33
- return Platform.OS === "web" && (hasContentSize || hasWideSize || hasPadding || hasMargin || hasGap || hasMinHeight || hasAspectRatio || hasChildLayout);
34
+ return Platform.OS === "web" && (hasContentSize || hasWideSize || hasPadding || hasMargin || hasGap || hasMinHeight || hasWidth || hasAspectRatio || hasChildLayout);
34
35
  }
35
36
  function useHasContentSize(settings) {
36
37
  return settings?.layout?.contentSize;
@@ -50,6 +51,9 @@ function useHasGap(settings) {
50
51
  function useHasMinHeight(settings) {
51
52
  return settings?.dimensions?.minHeight;
52
53
  }
54
+ function useHasWidth(settings) {
55
+ return settings?.dimensions?.width;
56
+ }
53
57
  function useHasAspectRatio(settings) {
54
58
  return settings?.dimensions?.aspectRatio;
55
59
  }
@@ -138,6 +142,7 @@ var DEFAULT_CONTROLS = {
138
142
  margin: true,
139
143
  blockGap: true,
140
144
  minHeight: true,
145
+ width: true,
141
146
  aspectRatio: true,
142
147
  childLayout: true
143
148
  };
@@ -280,6 +285,15 @@ function DimensionsPanel({
280
285
  setMinHeightValue(void 0);
281
286
  };
282
287
  const hasMinHeightValue = () => !!value?.dimensions?.minHeight;
288
+ const showWidthControl = useHasWidth(settings);
289
+ const widthValue = decodeValue(inheritedValue?.dimensions?.width);
290
+ const setWidthValue = (newValue) => {
291
+ onChange(setImmutably(value, ["dimensions", "width"], newValue));
292
+ };
293
+ const resetWidthValue = () => {
294
+ setWidthValue(void 0);
295
+ };
296
+ const hasWidthValue = () => !!value?.dimensions?.width;
283
297
  const showAspectRatioControl = useHasAspectRatio(settings);
284
298
  const aspectRatioValue = decodeValue(
285
299
  inheritedValue?.dimensions?.aspectRatio
@@ -328,7 +342,8 @@ function DimensionsPanel({
328
342
  dimensions: {
329
343
  ...previousValue?.dimensions,
330
344
  minHeight: void 0,
331
- aspectRatio: void 0
345
+ aspectRatio: void 0,
346
+ width: void 0
332
347
  }
333
348
  };
334
349
  }, []);
@@ -571,6 +586,24 @@ function DimensionsPanel({
571
586
  )
572
587
  }
573
588
  ),
589
+ showWidthControl && /* @__PURE__ */ jsx(
590
+ ToolsPanelItem,
591
+ {
592
+ hasValue: hasWidthValue,
593
+ label: __("Width"),
594
+ onDeselect: resetWidthValue,
595
+ isShownByDefault: defaultControls.width ?? DEFAULT_CONTROLS.width,
596
+ panelId,
597
+ children: /* @__PURE__ */ jsx(
598
+ HeightControl,
599
+ {
600
+ label: __("Width"),
601
+ value: widthValue,
602
+ onChange: setWidthValue
603
+ }
604
+ )
605
+ }
606
+ ),
574
607
  showAspectRatioControl && /* @__PURE__ */ jsx(
575
608
  AspectRatioTool,
576
609
  {