@wordpress/block-editor 15.8.1-next.16d95556a.0 → 15.9.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 (302) hide show
  1. package/CHANGELOG.md +2 -0
  2. package/build/components/block-inspector/edit-contents.js +19 -23
  3. package/build/components/block-inspector/edit-contents.js.map +3 -3
  4. package/build/components/block-inspector/index.js +7 -1
  5. package/build/components/block-inspector/index.js.map +2 -2
  6. package/build/components/block-list/block.js +4 -0
  7. package/build/components/block-list/block.js.map +2 -2
  8. package/build/components/block-list/index.js +2 -1
  9. package/build/components/block-list/index.js.map +2 -2
  10. package/build/components/block-list/use-block-props/index.js +3 -1
  11. package/build/components/block-list/use-block-props/index.js.map +2 -2
  12. package/build/components/block-list/use-block-props/use-is-hovered.js +16 -10
  13. package/build/components/block-list/use-block-props/use-is-hovered.js.map +2 -2
  14. package/build/components/block-list/use-block-props/use-selected-block-event-handlers.js +27 -5
  15. package/build/components/block-list/use-block-props/use-selected-block-event-handlers.js.map +2 -2
  16. package/build/components/block-lock/modal.js +5 -5
  17. package/build/components/block-lock/modal.js.map +2 -2
  18. package/build/components/block-lock/use-block-lock.js +10 -13
  19. package/build/components/block-lock/use-block-lock.js.map +2 -2
  20. package/build/components/block-settings-menu-controls/edit-section-menu-item.js +64 -0
  21. package/build/components/block-settings-menu-controls/edit-section-menu-item.js.map +7 -0
  22. package/build/components/block-settings-menu-controls/index.js +9 -1
  23. package/build/components/block-settings-menu-controls/index.js.map +2 -2
  24. package/build/components/block-toolbar/block-toolbar-icon.js +9 -9
  25. package/build/components/block-toolbar/block-toolbar-icon.js.map +2 -2
  26. package/build/components/block-tools/index.js +56 -45
  27. package/build/components/block-tools/index.js.map +3 -3
  28. package/build/components/block-variation-transforms/index.js +32 -5
  29. package/build/components/block-variation-transforms/index.js.map +2 -2
  30. package/build/components/block-visibility/toolbar.js +1 -1
  31. package/build/components/block-visibility/toolbar.js.map +1 -1
  32. package/build/components/border-radius-control/single-input-control.js +1 -0
  33. package/build/components/border-radius-control/single-input-control.js.map +2 -2
  34. package/build/components/content-only-controls/fields-dropdown-menu.js +66 -0
  35. package/build/components/content-only-controls/fields-dropdown-menu.js.map +7 -0
  36. package/build/components/content-only-controls/index.js +444 -0
  37. package/build/components/content-only-controls/index.js.map +7 -0
  38. package/build/components/content-only-controls/link/index.js +193 -0
  39. package/build/components/content-only-controls/link/index.js.map +7 -0
  40. package/build/components/content-only-controls/media/index.js +264 -0
  41. package/build/components/content-only-controls/media/index.js.map +7 -0
  42. package/build/components/content-only-controls/rich-text/index.js +188 -0
  43. package/build/components/content-only-controls/rich-text/index.js.map +7 -0
  44. package/build/components/content-only-controls/use-inspector-popover-placement.js +41 -0
  45. package/build/components/content-only-controls/use-inspector-popover-placement.js.map +7 -0
  46. package/build/components/font-family/index.js +1 -15
  47. package/build/components/font-family/index.js.map +2 -2
  48. package/build/components/global-styles/dimensions-panel.js +35 -2
  49. package/build/components/global-styles/dimensions-panel.js.map +2 -2
  50. package/build/components/global-styles/hooks.js +1 -1
  51. package/build/components/global-styles/hooks.js.map +2 -2
  52. package/build/components/global-styles/typography-panel.js +1 -2
  53. package/build/components/global-styles/typography-panel.js.map +2 -2
  54. package/build/components/inserter/media-tab/media-tab.js +1 -33
  55. package/build/components/inserter/media-tab/media-tab.js.map +3 -3
  56. package/build/components/inspector-controls-tabs/content-tab.js +6 -2
  57. package/build/components/inspector-controls-tabs/content-tab.js.map +3 -3
  58. package/build/components/inspector-controls-tabs/index.js +7 -1
  59. package/build/components/inspector-controls-tabs/index.js.map +2 -2
  60. package/build/components/inspector-controls-tabs/use-inspector-controls-tabs.js +1 -1
  61. package/build/components/inspector-controls-tabs/use-inspector-controls-tabs.js.map +2 -2
  62. package/build/components/link-control/index.js +15 -7
  63. package/build/components/link-control/index.js.map +2 -2
  64. package/build/components/list-view/block-select-button.js +7 -8
  65. package/build/components/list-view/block-select-button.js.map +2 -2
  66. package/build/components/list-view/block.js +9 -7
  67. package/build/components/list-view/block.js.map +2 -2
  68. package/build/components/media-placeholder/index.js +18 -35
  69. package/build/components/media-placeholder/index.js.map +3 -3
  70. package/build/components/media-placeholder/utils.js +60 -0
  71. package/build/components/media-placeholder/utils.js.map +7 -0
  72. package/build/components/media-replace-flow/index.js +24 -33
  73. package/build/components/media-replace-flow/index.js.map +3 -3
  74. package/build/components/use-block-commands/index.js +1 -1
  75. package/build/components/use-block-commands/index.js.map +2 -2
  76. package/build/components/use-block-display-information/index.js +21 -1
  77. package/build/components/use-block-display-information/index.js.map +3 -3
  78. package/build/components/use-block-drop-zone/index.js +1 -5
  79. package/build/components/use-block-drop-zone/index.js.map +2 -2
  80. package/build/hooks/block-bindings.js +52 -61
  81. package/build/hooks/block-bindings.js.map +3 -3
  82. package/build/hooks/dimensions.js +3 -3
  83. package/build/hooks/dimensions.js.map +2 -2
  84. package/build/hooks/metadata.js +1 -1
  85. package/build/hooks/metadata.js.map +2 -2
  86. package/build/hooks/use-content-only-section-edit.js +67 -0
  87. package/build/hooks/use-content-only-section-edit.js.map +7 -0
  88. package/build/hooks/utils.js +5 -1
  89. package/build/hooks/utils.js.map +2 -2
  90. package/build/layouts/constrained.js +2 -2
  91. package/build/layouts/constrained.js.map +2 -2
  92. package/build/private-apis.js +2 -3
  93. package/build/private-apis.js.map +3 -3
  94. package/build/store/private-keys.js +3 -0
  95. package/build/store/private-keys.js.map +2 -2
  96. package/build/store/private-selectors.js +41 -2
  97. package/build/store/private-selectors.js.map +2 -2
  98. package/build/store/selectors.js +6 -4
  99. package/build/store/selectors.js.map +2 -2
  100. package/build/utils/fit-text-utils.js +9 -1
  101. package/build/utils/fit-text-utils.js.map +2 -2
  102. package/build-module/components/block-inspector/edit-contents.js +9 -23
  103. package/build-module/components/block-inspector/edit-contents.js.map +2 -2
  104. package/build-module/components/block-inspector/index.js +7 -1
  105. package/build-module/components/block-inspector/index.js.map +2 -2
  106. package/build-module/components/block-list/block.js +4 -0
  107. package/build-module/components/block-list/block.js.map +2 -2
  108. package/build-module/components/block-list/index.js +2 -1
  109. package/build-module/components/block-list/index.js.map +2 -2
  110. package/build-module/components/block-list/use-block-props/index.js +3 -1
  111. package/build-module/components/block-list/use-block-props/index.js.map +2 -2
  112. package/build-module/components/block-list/use-block-props/use-is-hovered.js +16 -10
  113. package/build-module/components/block-list/use-block-props/use-is-hovered.js.map +2 -2
  114. package/build-module/components/block-list/use-block-props/use-selected-block-event-handlers.js +27 -5
  115. package/build-module/components/block-list/use-block-props/use-selected-block-event-handlers.js.map +2 -2
  116. package/build-module/components/block-lock/modal.js +5 -5
  117. package/build-module/components/block-lock/modal.js.map +2 -2
  118. package/build-module/components/block-lock/use-block-lock.js +10 -13
  119. package/build-module/components/block-lock/use-block-lock.js.map +2 -2
  120. package/build-module/components/block-settings-menu-controls/edit-section-menu-item.js +29 -0
  121. package/build-module/components/block-settings-menu-controls/edit-section-menu-item.js.map +7 -0
  122. package/build-module/components/block-settings-menu-controls/index.js +9 -1
  123. package/build-module/components/block-settings-menu-controls/index.js.map +2 -2
  124. package/build-module/components/block-toolbar/block-toolbar-icon.js +10 -10
  125. package/build-module/components/block-toolbar/block-toolbar-icon.js.map +2 -2
  126. package/build-module/components/block-tools/index.js +56 -45
  127. package/build-module/components/block-tools/index.js.map +2 -2
  128. package/build-module/components/block-variation-transforms/index.js +32 -5
  129. package/build-module/components/block-variation-transforms/index.js.map +2 -2
  130. package/build-module/components/block-visibility/toolbar.js +1 -1
  131. package/build-module/components/block-visibility/toolbar.js.map +1 -1
  132. package/build-module/components/border-radius-control/single-input-control.js +1 -0
  133. package/build-module/components/border-radius-control/single-input-control.js.map +2 -2
  134. package/build-module/components/content-only-controls/fields-dropdown-menu.js +45 -0
  135. package/build-module/components/content-only-controls/fields-dropdown-menu.js.map +7 -0
  136. package/build-module/components/content-only-controls/index.js +420 -0
  137. package/build-module/components/content-only-controls/index.js.map +7 -0
  138. package/build-module/components/content-only-controls/link/index.js +160 -0
  139. package/build-module/components/content-only-controls/link/index.js.map +7 -0
  140. package/build-module/components/content-only-controls/media/index.js +242 -0
  141. package/build-module/components/content-only-controls/media/index.js.map +7 -0
  142. package/build-module/components/content-only-controls/rich-text/index.js +160 -0
  143. package/build-module/components/content-only-controls/rich-text/index.js.map +7 -0
  144. package/build-module/components/content-only-controls/use-inspector-popover-placement.js +16 -0
  145. package/build-module/components/content-only-controls/use-inspector-popover-placement.js.map +7 -0
  146. package/build-module/components/font-family/index.js +1 -15
  147. package/build-module/components/font-family/index.js.map +2 -2
  148. package/build-module/components/global-styles/dimensions-panel.js +35 -2
  149. package/build-module/components/global-styles/dimensions-panel.js.map +2 -2
  150. package/build-module/components/global-styles/hooks.js +1 -1
  151. package/build-module/components/global-styles/hooks.js.map +2 -2
  152. package/build-module/components/global-styles/typography-panel.js +1 -2
  153. package/build-module/components/global-styles/typography-panel.js.map +2 -2
  154. package/build-module/components/inserter/media-tab/media-tab.js +2 -34
  155. package/build-module/components/inserter/media-tab/media-tab.js.map +2 -2
  156. package/build-module/components/inspector-controls-tabs/content-tab.js +7 -3
  157. package/build-module/components/inspector-controls-tabs/content-tab.js.map +2 -2
  158. package/build-module/components/inspector-controls-tabs/index.js +7 -1
  159. package/build-module/components/inspector-controls-tabs/index.js.map +2 -2
  160. package/build-module/components/inspector-controls-tabs/use-inspector-controls-tabs.js +1 -1
  161. package/build-module/components/inspector-controls-tabs/use-inspector-controls-tabs.js.map +2 -2
  162. package/build-module/components/link-control/index.js +16 -8
  163. package/build-module/components/link-control/index.js.map +2 -2
  164. package/build-module/components/list-view/block-select-button.js +14 -9
  165. package/build-module/components/list-view/block-select-button.js.map +2 -2
  166. package/build-module/components/list-view/block.js +9 -7
  167. package/build-module/components/list-view/block.js.map +2 -2
  168. package/build-module/components/media-placeholder/index.js +19 -36
  169. package/build-module/components/media-placeholder/index.js.map +2 -2
  170. package/build-module/components/media-placeholder/utils.js +35 -0
  171. package/build-module/components/media-placeholder/utils.js.map +7 -0
  172. package/build-module/components/media-replace-flow/index.js +24 -33
  173. package/build-module/components/media-replace-flow/index.js.map +2 -2
  174. package/build-module/components/use-block-commands/index.js +1 -1
  175. package/build-module/components/use-block-commands/index.js.map +2 -2
  176. package/build-module/components/use-block-display-information/index.js +21 -1
  177. package/build-module/components/use-block-display-information/index.js.map +3 -3
  178. package/build-module/components/use-block-drop-zone/index.js +1 -5
  179. package/build-module/components/use-block-drop-zone/index.js.map +2 -2
  180. package/build-module/hooks/block-bindings.js +57 -62
  181. package/build-module/hooks/block-bindings.js.map +2 -2
  182. package/build-module/hooks/dimensions.js +3 -3
  183. package/build-module/hooks/dimensions.js.map +2 -2
  184. package/build-module/hooks/metadata.js +1 -1
  185. package/build-module/hooks/metadata.js.map +2 -2
  186. package/build-module/hooks/use-content-only-section-edit.js +46 -0
  187. package/build-module/hooks/use-content-only-section-edit.js.map +7 -0
  188. package/build-module/hooks/utils.js +5 -1
  189. package/build-module/hooks/utils.js.map +2 -2
  190. package/build-module/layouts/constrained.js +2 -2
  191. package/build-module/layouts/constrained.js.map +2 -2
  192. package/build-module/private-apis.js +3 -3
  193. package/build-module/private-apis.js.map +2 -2
  194. package/build-module/store/private-keys.js +2 -0
  195. package/build-module/store/private-keys.js.map +2 -2
  196. package/build-module/store/private-selectors.js +37 -2
  197. package/build-module/store/private-selectors.js.map +2 -2
  198. package/build-module/store/selectors.js +6 -4
  199. package/build-module/store/selectors.js.map +2 -2
  200. package/build-module/utils/fit-text-utils.js +9 -1
  201. package/build-module/utils/fit-text-utils.js.map +2 -2
  202. package/build-style/content-rtl.css +3 -0
  203. package/build-style/content.css +3 -0
  204. package/build-style/style-rtl.css +145 -4
  205. package/build-style/style.css +145 -4
  206. package/package.json +38 -37
  207. package/src/components/block-inspector/edit-contents.js +10 -29
  208. package/src/components/block-inspector/index.js +4 -2
  209. package/src/components/block-list/block.js +6 -0
  210. package/src/components/block-list/content.scss +5 -0
  211. package/src/components/block-list/index.js +3 -1
  212. package/src/components/block-list/use-block-props/index.js +3 -1
  213. package/src/components/block-list/use-block-props/use-is-hovered.js +24 -12
  214. package/src/components/block-list/use-block-props/use-selected-block-event-handlers.js +34 -3
  215. package/src/components/block-lock/modal.js +6 -5
  216. package/src/components/block-lock/use-block-lock.js +10 -14
  217. package/src/components/block-patterns-list/stories/{index.story.js → index.story.jsx} +3 -1
  218. package/src/components/block-settings-menu-controls/edit-section-menu-item.js +39 -0
  219. package/src/components/block-settings-menu-controls/index.js +8 -1
  220. package/src/components/block-toolbar/block-toolbar-icon.js +14 -10
  221. package/src/components/block-tools/index.js +15 -2
  222. package/src/components/block-tools/style.scss +4 -0
  223. package/src/components/block-variation-transforms/index.js +96 -35
  224. package/src/components/block-visibility/toolbar.js +1 -1
  225. package/src/components/border-radius-control/single-input-control.js +1 -0
  226. package/src/components/content-only-controls/fields-dropdown-menu.js +53 -0
  227. package/src/components/content-only-controls/index.js +560 -0
  228. package/src/components/content-only-controls/link/index.js +200 -0
  229. package/src/components/content-only-controls/link/styles.scss +23 -0
  230. package/src/components/content-only-controls/media/index.js +306 -0
  231. package/src/components/content-only-controls/media/styles.scss +47 -0
  232. package/src/components/content-only-controls/rich-text/index.js +179 -0
  233. package/src/components/content-only-controls/rich-text/styles.scss +24 -0
  234. package/src/components/content-only-controls/styles.scss +44 -0
  235. package/src/components/content-only-controls/use-inspector-popover-placement.js +19 -0
  236. package/src/components/font-family/README.md +0 -9
  237. package/src/components/font-family/index.js +1 -16
  238. package/src/components/font-family/stories/{index.story.js → index.story.jsx} +0 -1
  239. package/src/components/global-styles/dimensions-panel.js +36 -0
  240. package/src/components/global-styles/hooks.js +1 -1
  241. package/src/components/global-styles/typography-panel.js +0 -1
  242. package/src/components/inserter/media-tab/media-tab.js +2 -44
  243. package/src/components/inspector-controls-tabs/content-tab.js +12 -4
  244. package/src/components/inspector-controls-tabs/index.js +4 -1
  245. package/src/components/inspector-controls-tabs/use-inspector-controls-tabs.js +1 -5
  246. package/src/components/link-control/index.js +36 -12
  247. package/src/components/list-view/block-select-button.js +15 -10
  248. package/src/components/list-view/block.js +9 -7
  249. package/src/components/media-placeholder/index.js +21 -46
  250. package/src/components/media-placeholder/test/get-computed-accept-attribute.js +164 -0
  251. package/src/components/media-placeholder/utils.js +65 -0
  252. package/src/components/media-replace-flow/index.js +25 -42
  253. package/src/components/use-block-commands/index.js +1 -1
  254. package/src/components/use-block-display-information/index.js +30 -2
  255. package/src/components/use-block-drop-zone/index.js +1 -5
  256. package/src/hooks/block-bindings.js +71 -82
  257. package/src/hooks/dimensions.js +8 -3
  258. package/src/hooks/metadata.js +1 -1
  259. package/src/hooks/test/metadata.js +1 -1
  260. package/src/hooks/use-content-only-section-edit.js +63 -0
  261. package/src/hooks/utils.js +4 -0
  262. package/src/layouts/constrained.js +8 -2
  263. package/src/private-apis.js +2 -2
  264. package/src/store/private-keys.js +1 -0
  265. package/src/store/private-selectors.js +121 -5
  266. package/src/store/selectors.js +6 -4
  267. package/src/store/test/private-selectors.js +242 -0
  268. package/src/style.scss +1 -1
  269. package/src/utils/fit-text-utils.js +19 -1
  270. package/tsconfig.json +1 -0
  271. package/build/components/media-upload-modal/index.js +0 -29
  272. package/build/components/media-upload-modal/index.js.map +0 -7
  273. package/build-module/components/media-upload-modal/index.js +0 -8
  274. package/build-module/components/media-upload-modal/index.js.map +0 -7
  275. package/src/components/font-family/style.scss +0 -7
  276. package/src/components/media-upload-modal/index.js +0 -18
  277. /package/src/components/alignment-control/stories/{aliginment-toolbar.story.js → aliginment-toolbar.story.jsx} +0 -0
  278. /package/src/components/alignment-control/stories/{index.story.js → index.story.jsx} +0 -0
  279. /package/src/components/block-alignment-matrix-control/stories/{index.story.js → index.story.jsx} +0 -0
  280. /package/src/components/block-draggable/stories/{index.story.js → index.story.jsx} +0 -0
  281. /package/src/components/block-heading-level-dropdown/stories/{index.story.js → index.story.jsx} +0 -0
  282. /package/src/components/block-mover/stories/{index.story.js → index.story.jsx} +0 -0
  283. /package/src/components/block-title/stories/{index.story.js → index.story.jsx} +0 -0
  284. /package/src/components/border-radius-control/stories/{index.story.js → index.story.jsx} +0 -0
  285. /package/src/components/date-format-picker/stories/{index.story.js → index.story.jsx} +0 -0
  286. /package/src/components/dimensions-tool/stories/{aspect-ratio-tool.story.js → aspect-ratio-tool.story.jsx} +0 -0
  287. /package/src/components/dimensions-tool/stories/{index.story.js → index.story.jsx} +0 -0
  288. /package/src/components/dimensions-tool/stories/{scale-tool.story.js → scale-tool.story.jsx} +0 -0
  289. /package/src/components/dimensions-tool/stories/{width-height-tool.story.js → width-height-tool.story.jsx} +0 -0
  290. /package/src/components/height-control/stories/{index.story.js → index.story.jsx} +0 -0
  291. /package/src/components/inserter/stories/{index.story.js → index.story.jsx} +0 -0
  292. /package/src/components/line-height-control/stories/{index.story.js → index.story.jsx} +0 -0
  293. /package/src/components/plain-text/stories/{index.story.js → index.story.jsx} +0 -0
  294. /package/src/components/resolution-tool/stories/{index.story.js → index.story.jsx} +0 -0
  295. /package/src/components/tabbed-sidebar/stories/{index.story.js → index.story.jsx} +0 -0
  296. /package/src/components/text-alignment-control/stories/{index.story.js → index.story.jsx} +0 -0
  297. /package/src/components/text-decoration-control/stories/{index.story.js → index.story.jsx} +0 -0
  298. /package/src/components/text-transform-control/stories/{index.story.js → index.story.jsx} +0 -0
  299. /package/src/components/unit-control/stories/{index.story.js → index.story.jsx} +0 -0
  300. /package/src/components/url-popover/stories/{index.story.js → index.story.jsx} +0 -0
  301. /package/src/components/warning/stories/{index.story.js → index.story.jsx} +0 -0
  302. /package/src/components/writing-mode-control/stories/{index.story.js → index.story.jsx} +0 -0
@@ -0,0 +1,179 @@
1
+ /**
2
+ * WordPress dependencies
3
+ */
4
+ import { BaseControl, useBaseControlProps } from '@wordpress/components';
5
+ import { useMergeRefs } from '@wordpress/compose';
6
+ import { useRegistry } from '@wordpress/data';
7
+ import { useRef, useState } from '@wordpress/element';
8
+ import {
9
+ __unstableUseRichText as useRichText,
10
+ removeFormat,
11
+ } from '@wordpress/rich-text';
12
+
13
+ /**
14
+ * Internal dependencies
15
+ */
16
+ import { useFormatTypes } from '../../rich-text/use-format-types';
17
+ import { getAllowedFormats } from '../../rich-text/utils';
18
+ import { useEventListeners } from '../../rich-text/event-listeners';
19
+ import FormatEdit from '../../rich-text/format-edit';
20
+ import { keyboardShortcutContext, inputEventContext } from '../../rich-text';
21
+
22
+ export default function RichTextControl( {
23
+ data,
24
+ field,
25
+ hideLabelFromVision,
26
+ config = {},
27
+ } ) {
28
+ const registry = useRegistry();
29
+ const attrValue = field.getValue( { item: data } );
30
+ const fieldConfig = field.config || {};
31
+ const { clientId, updateBlockAttributes } = config;
32
+ const updateAttributes = ( html ) => {
33
+ const mappedChanges = field.setValue( { item: data, value: html } );
34
+ updateBlockAttributes( clientId, mappedChanges );
35
+ };
36
+ const [ selection, setSelection ] = useState( {
37
+ start: undefined,
38
+ end: undefined,
39
+ } );
40
+ const [ isSelected, setIsSelected ] = useState( false );
41
+ const anchorRef = useRef();
42
+ const inputEvents = useRef( new Set() );
43
+ const keyboardShortcuts = useRef( new Set() );
44
+
45
+ const adjustedAllowedFormats = getAllowedFormats( {
46
+ allowedFormats: fieldConfig?.allowedFormats,
47
+ disableFormats: fieldConfig?.disableFormats,
48
+ } );
49
+
50
+ const {
51
+ formatTypes,
52
+ prepareHandlers,
53
+ valueHandlers,
54
+ changeHandlers,
55
+ dependencies,
56
+ } = useFormatTypes( {
57
+ clientId,
58
+ identifier: field.id,
59
+ allowedFormats: adjustedAllowedFormats,
60
+ withoutInteractiveFormatting: fieldConfig?.withoutInteractiveFormatting,
61
+ disableNoneEssentialFormatting: true,
62
+ } );
63
+
64
+ function addEditorOnlyFormats( value ) {
65
+ return valueHandlers.reduce(
66
+ ( accumulator, fn ) => fn( accumulator, value.text ),
67
+ value.formats
68
+ );
69
+ }
70
+
71
+ function removeEditorOnlyFormats( value ) {
72
+ formatTypes.forEach( ( formatType ) => {
73
+ // Remove formats created by prepareEditableTree, because they are editor only.
74
+ if ( formatType.__experimentalCreatePrepareEditableTree ) {
75
+ value = removeFormat(
76
+ value,
77
+ formatType.name,
78
+ 0,
79
+ value.text.length
80
+ );
81
+ }
82
+ } );
83
+
84
+ return value.formats;
85
+ }
86
+
87
+ function addInvisibleFormats( value ) {
88
+ return prepareHandlers.reduce(
89
+ ( accumulator, fn ) => fn( accumulator, value.text ),
90
+ value.formats
91
+ );
92
+ }
93
+
94
+ function onFocus() {
95
+ anchorRef.current?.focus();
96
+ }
97
+
98
+ const {
99
+ value,
100
+ getValue,
101
+ onChange: onRichTextChange,
102
+ ref: richTextRef,
103
+ } = useRichText( {
104
+ value: attrValue,
105
+ onChange( html, { __unstableFormats, __unstableText } ) {
106
+ updateAttributes( html );
107
+ Object.values( changeHandlers ).forEach( ( changeHandler ) => {
108
+ changeHandler( __unstableFormats, __unstableText );
109
+ } );
110
+ },
111
+ selectionStart: selection.start,
112
+ selectionEnd: selection.end,
113
+ onSelectionChange: ( start, end ) => setSelection( { start, end } ),
114
+ __unstableIsSelected: isSelected,
115
+ preserveWhiteSpace: !! fieldConfig?.preserveWhiteSpace,
116
+ placeholder: fieldConfig?.placeholder,
117
+ __unstableDisableFormats: fieldConfig?.disableFormats,
118
+ __unstableDependencies: dependencies,
119
+ __unstableAfterParse: addEditorOnlyFormats,
120
+ __unstableBeforeSerialize: removeEditorOnlyFormats,
121
+ __unstableAddInvisibleFormats: addInvisibleFormats,
122
+ } );
123
+
124
+ const { baseControlProps, controlProps } = useBaseControlProps( {
125
+ hideLabelFromVision: hideLabelFromVision ?? field.hideLabelFromVision,
126
+ label: field.label,
127
+ } );
128
+
129
+ return (
130
+ <>
131
+ { isSelected && (
132
+ <keyboardShortcutContext.Provider value={ keyboardShortcuts }>
133
+ <inputEventContext.Provider value={ inputEvents }>
134
+ <div>
135
+ <FormatEdit
136
+ value={ value }
137
+ onChange={ onRichTextChange }
138
+ onFocus={ onFocus }
139
+ formatTypes={ formatTypes }
140
+ forwardedRef={ anchorRef }
141
+ isVisible={ false }
142
+ />
143
+ </div>
144
+ </inputEventContext.Provider>
145
+ </keyboardShortcutContext.Provider>
146
+ ) }
147
+ <BaseControl __nextHasNoMarginBottom { ...baseControlProps }>
148
+ <div
149
+ className="block-editor-content-only-controls__rich-text"
150
+ role="textbox"
151
+ aria-multiline={ ! fieldConfig?.disableLineBreaks }
152
+ ref={ useMergeRefs( [
153
+ richTextRef,
154
+ useEventListeners( {
155
+ registry,
156
+ getValue,
157
+ onChange: onRichTextChange,
158
+ formatTypes,
159
+ selectionChange: setSelection,
160
+ isSelected,
161
+ disableFormats: fieldConfig?.disableFormats,
162
+ value,
163
+ tagName: 'div',
164
+ removeEditorOnlyFormats,
165
+ disableLineBreaks: fieldConfig?.disableLineBreaks,
166
+ keyboardShortcuts,
167
+ inputEvents,
168
+ } ),
169
+ anchorRef,
170
+ ] ) }
171
+ onFocus={ () => setIsSelected( true ) }
172
+ onBlur={ () => setIsSelected( false ) }
173
+ contentEditable
174
+ { ...controlProps }
175
+ />
176
+ </BaseControl>
177
+ </>
178
+ );
179
+ }
@@ -0,0 +1,24 @@
1
+ @use "@wordpress/base-styles/colors" as *;
2
+ @use "@wordpress/base-styles/mixins" as *;
3
+ @use "@wordpress/base-styles/variables" as *;
4
+
5
+ .block-editor-content-only-controls__rich-text {
6
+ width: 100%;
7
+ // Override input style margin in WP forms.css.
8
+ margin: 0;
9
+ background: $white;
10
+ color: $gray-900;
11
+ @include input-control( var(--wp-admin-theme-color, #3858e9) );
12
+ border-color: $gray-600;
13
+
14
+ &::placeholder {
15
+ color: color-mix(in srgb, $gray-900, transparent 38%);
16
+ }
17
+
18
+ min-height: $grid-unit-50;
19
+
20
+ // Subtract 1px to account for the border, which isn't included on the element
21
+ // on newer components like InputControl, SelectControl, etc.
22
+ // These values should be shared with the `controlPaddingX` in ./utils/config-values.js
23
+ padding: $grid-unit-15;
24
+ }
@@ -0,0 +1,44 @@
1
+ @use "@wordpress/base-styles/colors" as *;
2
+ @use "@wordpress/base-styles/variables" as *;
3
+ @use "./link/styles.scss" as *;
4
+ @use "./media/styles.scss" as *;
5
+ @use "./rich-text/styles.scss" as *;
6
+
7
+ .block-editor-content-only-controls__screen {
8
+ &.components-navigator-screen {
9
+ padding: $grid-unit-10 0 $grid-unit-20 0;
10
+ }
11
+
12
+ // Add border for the entire content controls and remove the similar border
13
+ // for tools panel.
14
+ border-top: $border-width solid $gray-200;
15
+
16
+
17
+ .components-tools-panel {
18
+ border-top: none;
19
+
20
+ // Condense the tools panels more than normal.
21
+ padding-top: $grid-unit-10;
22
+ }
23
+ }
24
+
25
+ .block-editor-content-only-controls__button-panel {
26
+ padding: 4px;
27
+
28
+ // Match heading font weights for the tools panels.
29
+ font-weight: 500 !important;
30
+ }
31
+
32
+ .block-editor-content-only-controls__back-button,
33
+ .block-editor-content-only-controls__drill-down-button {
34
+ width: 100%;
35
+ }
36
+
37
+ .block-editor-content-only-controls__fields-container {
38
+ padding: 0 $grid-unit-20;
39
+ }
40
+
41
+ .block-editor-content-only-controls__fields-header {
42
+ padding: $grid-unit-10 0;
43
+ margin-bottom: $grid-unit-05;
44
+ }
@@ -0,0 +1,19 @@
1
+ /**
2
+ * WordPress dependencies
3
+ */
4
+ import { useViewportMatch } from '@wordpress/compose';
5
+
6
+ export function useInspectorPopoverPlacement(
7
+ { isControl } = { isControl: false }
8
+ ) {
9
+ const isMobile = useViewportMatch( 'medium', '<' );
10
+ return ! isMobile
11
+ ? {
12
+ popoverProps: {
13
+ placement: 'left-start',
14
+ // For non-mobile, inner sidebar width (248px) - button width (24px) - border (1px) + padding (16px) + spacing (20px)
15
+ offset: isControl ? 35 : 259,
16
+ },
17
+ }
18
+ : {};
19
+ }
@@ -28,7 +28,6 @@ const MyFontFamilyControl = () => {
28
28
  onChange={ ( newFontFamily ) => {
29
29
  setFontFamily( newFontFamily );
30
30
  } }
31
- __nextHasNoMarginBottom
32
31
  __next40pxDefaultSize
33
32
  />
34
33
  );
@@ -83,11 +82,3 @@ The rest of the props are passed down to the underlying `<SelectControl />` inst
83
82
  - Default: `false`
84
83
 
85
84
  Start opting into the larger default height that will become the default size in a future version.
86
-
87
- #### `__nextHasNoMarginBottom`
88
-
89
- - Type: `boolean`
90
- - Required: No
91
- - Default: `false`
92
-
93
- Start opting into the new margin-free styles that will become the default in a future version.
@@ -18,8 +18,6 @@ import { useSettings } from '../use-settings';
18
18
  export default function FontFamilyControl( {
19
19
  /** Start opting into the larger default height that will become the default size in a future version. */
20
20
  __next40pxDefaultSize = false,
21
- /** Start opting into the new margin-free styles that will become the default in a future version. */
22
- __nextHasNoMarginBottom = false,
23
21
  value = '',
24
22
  onChange,
25
23
  fontFamilies,
@@ -47,17 +45,6 @@ export default function FontFamilyControl( {
47
45
  } ) ),
48
46
  ];
49
47
 
50
- if ( ! __nextHasNoMarginBottom ) {
51
- deprecated(
52
- 'Bottom margin styles for wp.blockEditor.FontFamilyControl',
53
- {
54
- since: '6.7',
55
- version: '7.0',
56
- hint: 'Set the `__nextHasNoMarginBottom` prop to true to start opting into the new styles, which will become the default in a future version',
57
- }
58
- );
59
- }
60
-
61
48
  if (
62
49
  ! __next40pxDefaultSize &&
63
50
  ( props.size === undefined || props.size === 'default' )
@@ -82,9 +69,7 @@ export default function FontFamilyControl( {
82
69
  value={ selectedValue }
83
70
  onChange={ ( { selectedItem } ) => onChange( selectedItem.key ) }
84
71
  options={ options }
85
- className={ clsx( 'block-editor-font-family-control', className, {
86
- 'is-next-has-no-margin-bottom': __nextHasNoMarginBottom,
87
- } ) }
72
+ className={ clsx( 'block-editor-font-family-control', className ) }
88
73
  { ...props }
89
74
  />
90
75
  );
@@ -49,7 +49,6 @@ export const Default = {
49
49
  slug: 'system-font',
50
50
  },
51
51
  ],
52
- __nextHasNoMarginBottom: true,
53
52
  __next40pxDefaultSize: true,
54
53
  },
55
54
  };
@@ -39,6 +39,7 @@ export function useHasDimensionsPanel( settings ) {
39
39
  const hasMargin = useHasMargin( settings );
40
40
  const hasGap = useHasGap( settings );
41
41
  const hasMinHeight = useHasMinHeight( settings );
42
+ const hasWidth = useHasWidth( settings );
42
43
  const hasAspectRatio = useHasAspectRatio( settings );
43
44
  const hasChildLayout = useHasChildLayout( settings );
44
45
 
@@ -50,6 +51,7 @@ export function useHasDimensionsPanel( settings ) {
50
51
  hasMargin ||
51
52
  hasGap ||
52
53
  hasMinHeight ||
54
+ hasWidth ||
53
55
  hasAspectRatio ||
54
56
  hasChildLayout )
55
57
  );
@@ -79,6 +81,10 @@ function useHasMinHeight( settings ) {
79
81
  return settings?.dimensions?.minHeight;
80
82
  }
81
83
 
84
+ function useHasWidth( settings ) {
85
+ return settings?.dimensions?.width;
86
+ }
87
+
82
88
  function useHasAspectRatio( settings ) {
83
89
  return settings?.dimensions?.aspectRatio;
84
90
  }
@@ -206,6 +212,7 @@ const DEFAULT_CONTROLS = {
206
212
  margin: true,
207
213
  blockGap: true,
208
214
  minHeight: true,
215
+ width: true,
209
216
  aspectRatio: true,
210
217
  childLayout: true,
211
218
  };
@@ -384,6 +391,17 @@ export default function DimensionsPanel( {
384
391
  };
385
392
  const hasMinHeightValue = () => !! value?.dimensions?.minHeight;
386
393
 
394
+ // Width
395
+ const showWidthControl = useHasWidth( settings );
396
+ const widthValue = decodeValue( inheritedValue?.dimensions?.width );
397
+ const setWidthValue = ( newValue ) => {
398
+ onChange( setImmutably( value, [ 'dimensions', 'width' ], newValue ) );
399
+ };
400
+ const resetWidthValue = () => {
401
+ setWidthValue( undefined );
402
+ };
403
+ const hasWidthValue = () => !! value?.dimensions?.width;
404
+
387
405
  // Aspect Ratio
388
406
  const showAspectRatioControl = useHasAspectRatio( settings );
389
407
  const aspectRatioValue = decodeValue(
@@ -439,6 +457,7 @@ export default function DimensionsPanel( {
439
457
  ...previousValue?.dimensions,
440
458
  minHeight: undefined,
441
459
  aspectRatio: undefined,
460
+ width: undefined,
442
461
  },
443
462
  };
444
463
  }, [] );
@@ -688,6 +707,23 @@ export default function DimensionsPanel( {
688
707
  />
689
708
  </ToolsPanelItem>
690
709
  ) }
710
+ { showWidthControl && (
711
+ <ToolsPanelItem
712
+ hasValue={ hasWidthValue }
713
+ label={ __( 'Width' ) }
714
+ onDeselect={ resetWidthValue }
715
+ isShownByDefault={
716
+ defaultControls.width ?? DEFAULT_CONTROLS.width
717
+ }
718
+ panelId={ panelId }
719
+ >
720
+ <HeightControl
721
+ label={ __( 'Width' ) }
722
+ value={ widthValue }
723
+ onChange={ setWidthValue }
724
+ />
725
+ </ToolsPanelItem>
726
+ ) }
691
727
  { showAspectRatioControl && (
692
728
  <AspectRatioTool
693
729
  hasValue={ hasAspectRatioValue }
@@ -152,7 +152,7 @@ export function useSettingsForBlockElement(
152
152
  }
153
153
  } );
154
154
 
155
- [ 'aspectRatio', 'minHeight' ].forEach( ( key ) => {
155
+ [ 'aspectRatio', 'minHeight', 'width' ].forEach( ( key ) => {
156
156
  if ( ! supportedStyles.includes( key ) ) {
157
157
  updatedSettings.dimensions = {
158
158
  ...updatedSettings.dimensions,
@@ -446,7 +446,6 @@ export default function TypographyPanel( {
446
446
  value={ fontFamily }
447
447
  onChange={ setFontFamily }
448
448
  size="__unstable-large"
449
- __nextHasNoMarginBottom
450
449
  />
451
450
  </ToolsPanelItem>
452
451
  ) }
@@ -4,8 +4,7 @@
4
4
  import { __ } from '@wordpress/i18n';
5
5
  import { useViewportMatch } from '@wordpress/compose';
6
6
  import { Button } from '@wordpress/components';
7
- import { useCallback, useMemo, useState } from '@wordpress/element';
8
- import { useSelect } from '@wordpress/data';
7
+ import { useCallback, useMemo } from '@wordpress/element';
9
8
 
10
9
  /**
11
10
  * Internal dependencies
@@ -13,55 +12,14 @@ import { useSelect } from '@wordpress/data';
13
12
  import { MediaCategoryPanel } from './media-panel';
14
13
  import MediaUploadCheck from '../../media-upload/check';
15
14
  import MediaUpload from '../../media-upload';
16
- import MediaUploadModal from '../../media-upload-modal';
17
15
  import { useMediaCategories } from './hooks';
18
16
  import { getBlockAndPreviewFromMedia } from './utils';
19
17
  import MobileTabNavigation from '../mobile-tab-navigation';
20
18
  import CategoryTabs from '../category-tabs';
21
19
  import InserterNoResults from '../no-results';
22
- import { store as blockEditorStore } from '../../../store';
23
20
 
24
21
  const ALLOWED_MEDIA_TYPES = [ 'image', 'video', 'audio' ];
25
22
 
26
- /**
27
- * Conditional Media component that uses MediaUploadModal when experiment is enabled,
28
- * otherwise falls back to MediaUpload.
29
- *
30
- * @param {Object} root0 Component props.
31
- * @param {Function} root0.render Render prop function that receives { open } object.
32
- * @return {JSX.Element} The component.
33
- */
34
- function ConditionalMediaUpload( { render, ...props } ) {
35
- const [ isModalOpen, setIsModalOpen ] = useState( false );
36
- const mediaUpload = useSelect( ( select ) => {
37
- const { getSettings } = select( blockEditorStore );
38
- return getSettings().mediaUpload;
39
- }, [] );
40
-
41
- if ( window.__experimentalDataViewsMediaModal ) {
42
- return (
43
- <>
44
- { render && render( { open: () => setIsModalOpen( true ) } ) }
45
- <MediaUploadModal
46
- { ...props }
47
- isOpen={ isModalOpen }
48
- onClose={ () => {
49
- setIsModalOpen( false );
50
- props.onClose?.();
51
- } }
52
- onSelect={ ( media ) => {
53
- setIsModalOpen( false );
54
- props.onSelect?.( media );
55
- } }
56
- onUpload={ mediaUpload }
57
- />
58
- </>
59
- );
60
- }
61
-
62
- return <MediaUpload { ...props } render={ render } />;
63
- }
64
-
65
23
  function MediaTab( {
66
24
  rootClientId,
67
25
  selectedCategory,
@@ -113,7 +71,7 @@ function MediaTab( {
113
71
  { children }
114
72
  </CategoryTabs>
115
73
  <MediaUploadCheck>
116
- <ConditionalMediaUpload
74
+ <MediaUpload
117
75
  multiple={ false }
118
76
  onSelect={ onSelectMedia }
119
77
  allowedTypes={ ALLOWED_MEDIA_TYPES }
@@ -8,16 +8,24 @@ import { __ } from '@wordpress/i18n';
8
8
  * Internal dependencies
9
9
  */
10
10
  import BlockQuickNavigation from '../block-quick-navigation';
11
+ import ContentOnlyControls from '../content-only-controls';
11
12
 
12
- const ContentTab = ( { contentClientIds } ) => {
13
+ const ContentTab = ( { rootClientId, contentClientIds } ) => {
13
14
  if ( ! contentClientIds || contentClientIds.length === 0 ) {
14
15
  return null;
15
16
  }
16
17
 
17
18
  return (
18
- <PanelBody title={ __( 'Content' ) }>
19
- <BlockQuickNavigation clientIds={ contentClientIds } />
20
- </PanelBody>
19
+ <>
20
+ { ! window?.__experimentalContentOnlyPatternInsertion && (
21
+ <PanelBody title={ __( 'Content' ) }>
22
+ <BlockQuickNavigation clientIds={ contentClientIds } />
23
+ </PanelBody>
24
+ ) }
25
+ { window?.__experimentalContentOnlyPatternInsertion && (
26
+ <ContentOnlyControls rootClientId={ rootClientId } />
27
+ ) }
28
+ </>
21
29
  );
22
30
  };
23
31
 
@@ -109,7 +109,10 @@ export default function InspectorControlsTabs( {
109
109
  />
110
110
  </Tabs.TabPanel>
111
111
  <Tabs.TabPanel tabId={ TAB_CONTENT.name } focusable={ false }>
112
- <ContentTab contentClientIds={ contentClientIds } />
112
+ <ContentTab
113
+ rootClientId={ clientId }
114
+ contentClientIds={ contentClientIds }
115
+ />
113
116
  </Tabs.TabPanel>
114
117
  <Tabs.TabPanel tabId={ TAB_LIST_VIEW.name } focusable={ false }>
115
118
  <InspectorControls.Slot group="list" />
@@ -99,11 +99,7 @@ export default function useInspectorControlsTabs(
99
99
  tabs.push( TAB_SETTINGS );
100
100
  }
101
101
 
102
- if (
103
- hasBlockStyles ||
104
- hasStyleFills ||
105
- window?.__experimentalContentOnlyPatternInsertion
106
- ) {
102
+ if ( hasBlockStyles || hasStyleFills ) {
107
103
  tabs.push( TAB_STYLES );
108
104
  }
109
105
 
@@ -15,7 +15,7 @@ import {
15
15
  __experimentalInputControlSuffixWrapper as InputControlSuffixWrapper,
16
16
  } from '@wordpress/components';
17
17
  import { __, sprintf } from '@wordpress/i18n';
18
- import { useRef, useState, useEffect } from '@wordpress/element';
18
+ import { useRef, useState, useEffect, useMemo } from '@wordpress/element';
19
19
  import { useInstanceId } from '@wordpress/compose';
20
20
  import { focus } from '@wordpress/dom';
21
21
  import { ENTER } from '@wordpress/keycodes';
@@ -187,7 +187,15 @@ function LinkControl( {
187
187
  const wrapperNode = useRef();
188
188
  const textInputRef = useRef();
189
189
  const searchInputRef = useRef();
190
- const isEndingEditWithFocusRef = useRef( false );
190
+ // TODO: Remove entityUrlFallbackRef and previewValue in favor of value prop after taxonomy entity binding
191
+ // is stable and returns the correct URL instead of null while resolving when creating the entity.
192
+ //
193
+ // Preserve the URL from entity suggestions before binding overrides it
194
+ // This is due to entity binding not being available immediately after the suggestion is selected.
195
+ // The URL can return null, especially for taxonomy entities, while entity binding is being resolved.
196
+ // To avoid unnecessary rerenders and focus loss, we preserve the URL from the suggestion and use it
197
+ // as a fallback until the entity binding is available.
198
+ const entityUrlFallbackRef = useRef();
191
199
 
192
200
  const settingsKeys = settings.map( ( { id } ) => id );
193
201
 
@@ -244,8 +252,6 @@ function LinkControl( {
244
252
  wrapperNode.current;
245
253
 
246
254
  nextFocusTarget.focus();
247
-
248
- isEndingEditWithFocusRef.current = false;
249
255
  }, [ isEditingLink, isCreatingPage ] );
250
256
 
251
257
  // The component mounting reference is maintained separately
@@ -261,18 +267,18 @@ function LinkControl( {
261
267
  const hasLinkValue = value?.url?.trim()?.length > 0;
262
268
 
263
269
  /**
264
- * Cancels editing state and marks that focus may need to be restored after
265
- * the next render, if focus was within the wrapper when editing finished.
270
+ * Cancels editing state.
266
271
  */
267
272
  const stopEditing = () => {
268
- isEndingEditWithFocusRef.current = !! wrapperNode.current?.contains(
269
- wrapperNode.current.ownerDocument.activeElement
270
- );
271
-
272
273
  setIsEditingLink( false );
273
274
  };
274
275
 
275
276
  const handleSelectSuggestion = ( updatedValue ) => {
277
+ // Preserve the URL for taxonomy entities before binding overrides it
278
+ if ( updatedValue?.kind === 'taxonomy' && updatedValue?.url ) {
279
+ entityUrlFallbackRef.current = updatedValue.url;
280
+ }
281
+
276
282
  // Suggestions may contains "settings" values (e.g. `opensInNewTab`)
277
283
  // which should not override any existing settings values set by the
278
284
  // user. This filters out any settings values from the suggestion.
@@ -396,6 +402,24 @@ function LinkControl( {
396
402
  const isDisabled = ! valueHasChanges || currentInputIsEmpty;
397
403
  const showSettings = !! settings?.length && isEditingLink && hasLinkValue;
398
404
 
405
+ const previewValue = useMemo( () => {
406
+ // There is a chance that the value is not yet set from the entity binding, so we use the preserved URL.
407
+ if (
408
+ value?.kind === 'taxonomy' &&
409
+ ! value?.url &&
410
+ entityUrlFallbackRef.current
411
+ ) {
412
+ // combine the value prop with the preserved URL from the suggestion
413
+ return {
414
+ ...value,
415
+ url: entityUrlFallbackRef.current,
416
+ };
417
+ }
418
+
419
+ // If we don't have a fallback URL, use the value prop.
420
+ return value;
421
+ }, [ value ] );
422
+
399
423
  return (
400
424
  <div
401
425
  tabIndex={ -1 }
@@ -487,8 +511,8 @@ function LinkControl( {
487
511
 
488
512
  { value && ! isEditingLink && ! isCreatingPage && (
489
513
  <LinkPreview
490
- key={ value?.url } // force remount when URL changes to avoid race conditions for rich previews
491
- value={ value }
514
+ key={ previewValue?.url } // force remount when URL changes to avoid race conditions for rich previews
515
+ value={ previewValue }
492
516
  onEditClick={ () => setIsEditingLink( true ) }
493
517
  hasRichPreviews={ hasRichPreviews }
494
518
  hasUnlinkControl={ shownUnlinkControl }