@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
@@ -4,11 +4,9 @@
4
4
  import {
5
5
  Button,
6
6
  Icon,
7
- __experimentalToolsPanelItem as ToolsPanelItem,
8
7
  __experimentalGrid as Grid,
9
8
  } from '@wordpress/components';
10
9
  import { useSelect } from '@wordpress/data';
11
- import { useMemo } from '@wordpress/element';
12
10
  import { __ } from '@wordpress/i18n';
13
11
  import {
14
12
  audio as audioIcon,
@@ -26,9 +24,10 @@ import { useInspectorPopoverPlacement } from '../use-inspector-popover-placement
26
24
  import { getMediaSelectKey } from '../../../store/private-keys';
27
25
  import { store as blockEditorStore } from '../../../store';
28
26
 
29
- function MediaThumbnail( { control, attributeValues, attachment } ) {
30
- const { allowedTypes, multiple } = control.args;
31
- const mapping = control.mapping;
27
+ function MediaThumbnail( { data, field, attachment } ) {
28
+ const config = field.config || {};
29
+ const { allowedTypes = [], multiple = false } = config;
30
+
32
31
  if ( multiple ) {
33
32
  return 'todo multiple';
34
33
  }
@@ -50,29 +49,17 @@ function MediaThumbnail( { control, attributeValues, attachment } ) {
50
49
  }
51
50
 
52
51
  if ( allowedTypes.length === 1 ) {
53
- let src;
54
- if (
55
- allowedTypes[ 0 ] === 'image' &&
56
- mapping.src &&
57
- attributeValues[ mapping.src ]
58
- ) {
59
- src = attributeValues[ mapping.src ];
60
- } else if (
61
- allowedTypes[ 0 ] === 'video' &&
62
- mapping.poster &&
63
- attributeValues[ mapping.poster ]
64
- ) {
65
- src = attributeValues[ mapping.poster ];
66
- }
52
+ const value = field.getValue( { item: data } );
53
+ const url = value?.url;
67
54
 
68
- if ( src ) {
55
+ if ( url ) {
69
56
  return (
70
57
  <img
71
58
  className="block-editor-content-only-controls__media-thumbnail"
72
59
  alt=""
73
60
  width={ 24 }
74
61
  height={ 24 }
75
- src={ src }
62
+ src={ url }
76
63
  />
77
64
  );
78
65
  }
@@ -96,29 +83,27 @@ function MediaThumbnail( { control, attributeValues, attachment } ) {
96
83
  return <Icon icon={ mediaIcon } size={ 24 } />;
97
84
  }
98
85
 
99
- export default function Media( {
100
- clientId,
101
- control,
102
- blockType,
103
- attributeValues,
104
- updateAttributes,
105
- } ) {
86
+ export default function Media( { data, field, onChange, config = {} } ) {
106
87
  const { popoverProps } = useInspectorPopoverPlacement( {
107
88
  isControl: true,
108
89
  } );
109
- const typeKey = control.mapping.type;
110
- const idKey = control.mapping.id;
111
- const srcKey = control.mapping.src;
112
- const captionKey = control.mapping.caption;
113
- const altKey = control.mapping.alt;
114
- const posterKey = control.mapping.poster;
115
- const featuredImageKey = control.mapping.featuredImage;
90
+ const value = field.getValue( { item: data } );
91
+ const { allowedTypes = [], multiple = false } = field.config || {};
92
+ const { fieldDef } = config;
93
+ const updateAttributes = ( newFieldValue ) => {
94
+ const mappedChanges = field.setValue( {
95
+ item: data,
96
+ value: newFieldValue,
97
+ } );
98
+ onChange( mappedChanges );
99
+ };
116
100
 
117
- const id = attributeValues[ idKey ];
118
- const src = attributeValues[ srcKey ];
119
- const caption = attributeValues[ captionKey ];
120
- const alt = attributeValues[ altKey ];
121
- const useFeaturedImage = attributeValues[ featuredImageKey ];
101
+ // Check if featured image is supported by checking if it's in the mapping
102
+ const hasFeaturedImageSupport =
103
+ fieldDef?.mapping && 'featuredImage' in fieldDef.mapping;
104
+
105
+ const id = value?.id;
106
+ const url = value?.url;
122
107
 
123
108
  const attachment = useSelect(
124
109
  ( select ) => {
@@ -140,8 +125,8 @@ export default function Media( {
140
125
 
141
126
  // TODO - pluralize when multiple.
142
127
  let chooseItemLabel;
143
- if ( control.args.allowedTypes.length === 1 ) {
144
- const allowedType = control.args.allowedTypes[ 0 ];
128
+ if ( allowedTypes.length === 1 ) {
129
+ const allowedType = allowedTypes[ 0 ];
145
130
  if ( allowedType === 'image' ) {
146
131
  chooseItemLabel = __( 'Choose an image…' );
147
132
  } else if ( allowedType === 'video' ) {
@@ -155,131 +140,167 @@ export default function Media( {
155
140
  chooseItemLabel = __( 'Choose a media item…' );
156
141
  }
157
142
 
158
- const defaultValues = useMemo( () => {
159
- return Object.fromEntries(
160
- Object.entries( control.mapping ).map( ( [ , attributeKey ] ) => {
161
- return [
162
- attributeKey,
163
- blockType.attributes[ attributeKey ]?.defaultValue ??
164
- undefined,
165
- ];
166
- } )
167
- );
168
- }, [ blockType.attributes, control.mapping ] );
169
-
170
143
  return (
171
144
  <MediaUploadCheck>
172
- <ToolsPanelItem
173
- panelId={ clientId }
174
- label={ control.label }
175
- hasValue={ () => !! src }
176
- onDeselect={ () => {
177
- updateAttributes( defaultValues );
178
- } }
179
- isShownByDefault={ control.shownByDefault }
180
- >
181
- <MediaReplaceFlow
182
- className="block-editor-content-only-controls__media-replace-flow"
183
- allowedTypes={ control.args.allowedTypes }
184
- mediaId={ id }
185
- mediaURL={ src }
186
- multiple={ control.args.multiple }
187
- popoverProps={ popoverProps }
188
- onReset={ () => {
189
- updateAttributes( defaultValues );
190
- } }
191
- useFeaturedImage={ !! useFeaturedImage }
192
- onToggleFeaturedImage={
193
- !! featuredImageKey &&
194
- ( () => {
195
- updateAttributes( {
196
- ...defaultValues,
197
- [ featuredImageKey ]: ! useFeaturedImage,
198
- } );
199
- } )
200
- }
201
- onSelect={ ( selectedMedia ) => {
202
- if ( selectedMedia.id && selectedMedia.url ) {
203
- const optionalAttributes = {};
145
+ <MediaReplaceFlow
146
+ className="block-editor-content-only-controls__media-replace-flow"
147
+ allowedTypes={ allowedTypes }
148
+ mediaId={ id }
149
+ mediaURL={ url }
150
+ multiple={ multiple }
151
+ popoverProps={ popoverProps }
152
+ onReset={ () => {
153
+ // Build reset value dynamically based on mapping
154
+ const resetValue = {};
204
155
 
205
- if ( typeKey && selectedMedia.type ) {
206
- optionalAttributes[ typeKey ] =
207
- selectedMedia.type;
156
+ if ( fieldDef?.mapping ) {
157
+ Object.keys( fieldDef.mapping ).forEach( ( key ) => {
158
+ if (
159
+ key === 'id' ||
160
+ key === 'src' ||
161
+ key === 'url'
162
+ ) {
163
+ resetValue[ key ] = undefined;
164
+ } else if ( key === 'caption' || key === 'alt' ) {
165
+ resetValue[ key ] = '';
208
166
  }
167
+ } );
168
+ }
169
+
170
+ // Turn off featured image when resetting (only if it's in the mapping)
171
+ if ( hasFeaturedImageSupport ) {
172
+ resetValue.featuredImage = false;
173
+ }
209
174
 
175
+ // Merge with existing value to preserve other field properties
176
+ updateAttributes( { ...value, ...resetValue } );
177
+ } }
178
+ { ...( hasFeaturedImageSupport && {
179
+ useFeaturedImage: !! value?.featuredImage,
180
+ onToggleFeaturedImage: () => {
181
+ updateAttributes( {
182
+ ...value,
183
+ featuredImage: ! value?.featuredImage,
184
+ } );
185
+ },
186
+ } ) }
187
+ onSelect={ ( selectedMedia ) => {
188
+ if ( selectedMedia.id && selectedMedia.url ) {
189
+ // Determine mediaType from MIME type, not from object type
190
+ let mediaType = 'image'; // default
191
+ if ( selectedMedia.mime_type ) {
210
192
  if (
211
- captionKey &&
212
- ! caption &&
213
- selectedMedia.caption
193
+ selectedMedia.mime_type.startsWith( 'video/' )
214
194
  ) {
215
- optionalAttributes[ captionKey ] =
216
- selectedMedia.caption;
217
- }
218
- if ( altKey && ! alt && selectedMedia.alt ) {
219
- optionalAttributes[ altKey ] =
220
- selectedMedia.alt;
221
- }
222
- if ( posterKey && selectedMedia.poster ) {
223
- optionalAttributes[ posterKey ] =
224
- selectedMedia.poster;
195
+ mediaType = 'video';
196
+ } else if (
197
+ selectedMedia.mime_type.startsWith( 'audio/' )
198
+ ) {
199
+ mediaType = 'audio';
225
200
  }
201
+ }
202
+
203
+ // Build new value dynamically based on what's in the mapping
204
+ const newValue = {};
226
205
 
227
- updateAttributes( {
228
- [ idKey ]: selectedMedia.id,
229
- [ srcKey ]: selectedMedia.url,
230
- ...optionalAttributes,
231
- } );
206
+ // Iterate over mapping keys and set values for supported properties
207
+ if ( fieldDef?.mapping ) {
208
+ Object.keys( fieldDef.mapping ).forEach(
209
+ ( key ) => {
210
+ if ( key === 'id' ) {
211
+ newValue[ key ] = selectedMedia.id;
212
+ } else if (
213
+ key === 'src' ||
214
+ key === 'url'
215
+ ) {
216
+ newValue[ key ] = selectedMedia.url;
217
+ } else if ( key === 'type' ) {
218
+ newValue[ key ] = mediaType;
219
+ } else if (
220
+ key === 'link' &&
221
+ selectedMedia.link
222
+ ) {
223
+ newValue[ key ] = selectedMedia.link;
224
+ } else if (
225
+ key === 'caption' &&
226
+ ! value?.caption &&
227
+ selectedMedia.caption
228
+ ) {
229
+ newValue[ key ] = selectedMedia.caption;
230
+ } else if (
231
+ key === 'alt' &&
232
+ ! value?.alt &&
233
+ selectedMedia.alt
234
+ ) {
235
+ newValue[ key ] = selectedMedia.alt;
236
+ } else if (
237
+ key === 'poster' &&
238
+ selectedMedia.poster
239
+ ) {
240
+ newValue[ key ] = selectedMedia.poster;
241
+ }
242
+ }
243
+ );
232
244
  }
233
- } }
234
- renderToggle={ ( buttonProps ) => (
235
- <Button
236
- __next40pxDefaultSize
237
- className="block-editor-content-only-controls__media"
238
- { ...buttonProps }
245
+
246
+ // Turn off featured image when manually selecting media
247
+ if ( hasFeaturedImageSupport ) {
248
+ newValue.featuredImage = false;
249
+ }
250
+
251
+ // Merge with existing value to preserve other field properties
252
+ const finalValue = { ...value, ...newValue };
253
+ updateAttributes( finalValue );
254
+ }
255
+ } }
256
+ renderToggle={ ( buttonProps ) => (
257
+ <Button
258
+ __next40pxDefaultSize
259
+ className="block-editor-content-only-controls__media"
260
+ { ...buttonProps }
261
+ >
262
+ <Grid
263
+ rowGap={ 0 }
264
+ columnGap={ 8 }
265
+ templateColumns="24px 1fr"
266
+ className="block-editor-content-only-controls__media-row"
239
267
  >
240
- <Grid
241
- rowGap={ 0 }
242
- columnGap={ 8 }
243
- templateColumns="24px 1fr"
244
- className="block-editor-content-only-controls__media-row"
245
- >
246
- { src && (
247
- <>
248
- <MediaThumbnail
249
- attachment={ attachment }
250
- control={ control }
251
- attributeValues={ attributeValues }
252
- />
253
- <span className="block-editor-content-only-controls__media-title">
254
- {
255
- // TODO - truncate long titles or url smartly (e.g. show filename).
256
- attachment?.title?.raw &&
257
- attachment?.title?.raw !== ''
258
- ? attachment?.title?.raw
259
- : src
260
- }
261
- </span>
262
- </>
263
- ) }
264
- { ! src && (
265
- <>
266
- <span
267
- className="block-editor-content-only-controls__media-placeholder"
268
- style={ {
269
- width: '24px',
270
- height: '24px',
271
- } }
272
- />
273
- <span className="block-editor-content-only-controls__media-title">
274
- { chooseItemLabel }
275
- </span>
276
- </>
277
- ) }
278
- </Grid>
279
- </Button>
280
- ) }
281
- />
282
- </ToolsPanelItem>
268
+ { url && (
269
+ <>
270
+ <MediaThumbnail
271
+ attachment={ attachment }
272
+ field={ field }
273
+ data={ data }
274
+ />
275
+ <span className="block-editor-content-only-controls__media-title">
276
+ {
277
+ // TODO - truncate long titles or url smartly (e.g. show filename).
278
+ attachment?.title?.raw &&
279
+ attachment?.title?.raw !== ''
280
+ ? attachment?.title?.raw
281
+ : url
282
+ }
283
+ </span>
284
+ </>
285
+ ) }
286
+ { ! url && (
287
+ <>
288
+ <span
289
+ className="block-editor-content-only-controls__media-placeholder"
290
+ style={ {
291
+ width: '24px',
292
+ height: '24px',
293
+ } }
294
+ />
295
+ <span className="block-editor-content-only-controls__media-title">
296
+ { chooseItemLabel }
297
+ </span>
298
+ </>
299
+ ) }
300
+ </Grid>
301
+ </Button>
302
+ ) }
303
+ />
283
304
  </MediaUploadCheck>
284
305
  );
285
306
  }
@@ -1,17 +1,12 @@
1
1
  /**
2
2
  * WordPress dependencies
3
3
  */
4
- import {
5
- BaseControl,
6
- useBaseControlProps,
7
- __experimentalToolsPanelItem as ToolsPanelItem,
8
- } from '@wordpress/components';
4
+ import { BaseControl, useBaseControlProps } from '@wordpress/components';
9
5
  import { useMergeRefs } from '@wordpress/compose';
10
6
  import { useRegistry } from '@wordpress/data';
11
7
  import { useRef, useState } from '@wordpress/element';
12
8
  import {
13
9
  __unstableUseRichText as useRichText,
14
- isEmpty,
15
10
  removeFormat,
16
11
  } from '@wordpress/rich-text';
17
12
 
@@ -25,17 +20,20 @@ import FormatEdit from '../../rich-text/format-edit';
25
20
  import { keyboardShortcutContext, inputEventContext } from '../../rich-text';
26
21
 
27
22
  export default function RichTextControl( {
28
- clientId,
29
- control,
30
- blockType,
31
- attributeValues,
32
- updateAttributes,
23
+ data,
24
+ field,
25
+ hideLabelFromVision,
26
+ onChange,
27
+ config = {},
33
28
  } ) {
34
29
  const registry = useRegistry();
35
- const valueKey = control.mapping.value;
36
- const attrValue = attributeValues[ valueKey ];
37
- const defaultValue =
38
- blockType.attributes[ valueKey ]?.defaultValue ?? undefined;
30
+ const attrValue = field.getValue( { item: data } );
31
+ const fieldConfig = field.config || {};
32
+ const { clientId } = config;
33
+ const updateAttributes = ( html ) => {
34
+ const mappedChanges = field.setValue( { item: data, value: html } );
35
+ onChange( mappedChanges );
36
+ };
39
37
  const [ selection, setSelection ] = useState( {
40
38
  start: undefined,
41
39
  end: undefined,
@@ -46,8 +44,8 @@ export default function RichTextControl( {
46
44
  const keyboardShortcuts = useRef( new Set() );
47
45
 
48
46
  const adjustedAllowedFormats = getAllowedFormats( {
49
- allowedFormats: control.args?.allowedFormats,
50
- disableFormats: control.args?.disableFormats,
47
+ allowedFormats: fieldConfig?.allowedFormats,
48
+ disableFormats: fieldConfig?.disableFormats,
51
49
  } );
52
50
 
53
51
  const {
@@ -58,10 +56,9 @@ export default function RichTextControl( {
58
56
  dependencies,
59
57
  } = useFormatTypes( {
60
58
  clientId,
61
- identifier: valueKey,
59
+ identifier: field.id,
62
60
  allowedFormats: adjustedAllowedFormats,
63
- withoutInteractiveFormatting:
64
- control.args?.withoutInteractiveFormatting,
61
+ withoutInteractiveFormatting: fieldConfig?.withoutInteractiveFormatting,
65
62
  disableNoneEssentialFormatting: true,
66
63
  } );
67
64
 
@@ -102,12 +99,12 @@ export default function RichTextControl( {
102
99
  const {
103
100
  value,
104
101
  getValue,
105
- onChange,
102
+ onChange: onRichTextChange,
106
103
  ref: richTextRef,
107
104
  } = useRichText( {
108
105
  value: attrValue,
109
106
  onChange( html, { __unstableFormats, __unstableText } ) {
110
- updateAttributes( { [ valueKey ]: html } );
107
+ updateAttributes( html );
111
108
  Object.values( changeHandlers ).forEach( ( changeHandler ) => {
112
109
  changeHandler( __unstableFormats, __unstableText );
113
110
  } );
@@ -116,9 +113,9 @@ export default function RichTextControl( {
116
113
  selectionEnd: selection.end,
117
114
  onSelectionChange: ( start, end ) => setSelection( { start, end } ),
118
115
  __unstableIsSelected: isSelected,
119
- preserveWhiteSpace: !! control.args?.preserveWhiteSpace,
120
- placeholder: control.args?.placeholder,
121
- __unstableDisableFormats: control.args?.disableFormats,
116
+ preserveWhiteSpace: !! fieldConfig?.preserveWhiteSpace,
117
+ placeholder: fieldConfig?.placeholder,
118
+ __unstableDisableFormats: fieldConfig?.disableFormats,
122
119
  __unstableDependencies: dependencies,
123
120
  __unstableAfterParse: addEditorOnlyFormats,
124
121
  __unstableBeforeSerialize: removeEditorOnlyFormats,
@@ -126,29 +123,19 @@ export default function RichTextControl( {
126
123
  } );
127
124
 
128
125
  const { baseControlProps, controlProps } = useBaseControlProps( {
129
- hideLabelFromVision: control.shownByDefault,
130
- label: control.label,
126
+ hideLabelFromVision: hideLabelFromVision ?? field.hideLabelFromVision,
127
+ label: field.label,
131
128
  } );
132
129
 
133
130
  return (
134
- <ToolsPanelItem
135
- panelId={ clientId }
136
- label={ control.label }
137
- hasValue={ () => {
138
- return value?.text && ! isEmpty( value );
139
- } }
140
- onDeselect={ () =>
141
- updateAttributes( { [ valueKey ]: defaultValue } )
142
- }
143
- isShownByDefault={ control.shownByDefault }
144
- >
131
+ <>
145
132
  { isSelected && (
146
133
  <keyboardShortcutContext.Provider value={ keyboardShortcuts }>
147
134
  <inputEventContext.Provider value={ inputEvents }>
148
135
  <div>
149
136
  <FormatEdit
150
137
  value={ value }
151
- onChange={ onChange }
138
+ onChange={ onRichTextChange }
152
139
  onFocus={ onFocus }
153
140
  formatTypes={ formatTypes }
154
141
  forwardedRef={ anchorRef }
@@ -162,21 +149,21 @@ export default function RichTextControl( {
162
149
  <div
163
150
  className="block-editor-content-only-controls__rich-text"
164
151
  role="textbox"
165
- aria-multiline={ ! control.args?.disableLineBreaks }
152
+ aria-multiline={ ! fieldConfig?.disableLineBreaks }
166
153
  ref={ useMergeRefs( [
167
154
  richTextRef,
168
155
  useEventListeners( {
169
156
  registry,
170
157
  getValue,
171
- onChange,
158
+ onChange: onRichTextChange,
172
159
  formatTypes,
173
160
  selectionChange: setSelection,
174
161
  isSelected,
175
- disableFormats: control.args?.disableFormats,
162
+ disableFormats: fieldConfig?.disableFormats,
176
163
  value,
177
164
  tagName: 'div',
178
165
  removeEditorOnlyFormats,
179
- disableLineBreaks: control.args?.disableLineBreaks,
166
+ disableLineBreaks: fieldConfig?.disableLineBreaks,
180
167
  keyboardShortcuts,
181
168
  inputEvents,
182
169
  } ),
@@ -188,6 +175,6 @@ export default function RichTextControl( {
188
175
  { ...controlProps }
189
176
  />
190
177
  </BaseControl>
191
- </ToolsPanelItem>
178
+ </>
192
179
  );
193
180
  }
@@ -6,7 +6,7 @@
6
6
 
7
7
  .block-editor-content-only-controls__screen {
8
8
  &.components-navigator-screen {
9
- padding: $grid-unit-10 0 0 0;
9
+ padding: $grid-unit-10 0 $grid-unit-20 0;
10
10
  }
11
11
 
12
12
  // Add border for the entire content controls and remove the similar border
@@ -33,3 +33,12 @@
33
33
  .block-editor-content-only-controls__drill-down-button {
34
34
  width: 100%;
35
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
+ }
@@ -1,8 +1,3 @@
1
- /**
2
- * External dependencies
3
- */
4
- import styled from '@emotion/styled';
5
-
6
1
  /**
7
2
  * WordPress dependencies
8
3
  */
@@ -12,10 +7,6 @@ import {
12
7
  } from '@wordpress/components';
13
8
  import { __ } from '@wordpress/i18n';
14
9
 
15
- const SingleColumnToolsPanelItem = styled( ToolsPanelItem )`
16
- grid-column: span 1;
17
- `;
18
-
19
10
  /**
20
11
  * @typedef {import('@wordpress/components/build-types/unit-control/types').WPUnitControlUnit} WPUnitControlUnit
21
12
  */
@@ -72,7 +63,8 @@ export default function WidthHeightTool( {
72
63
 
73
64
  return (
74
65
  <>
75
- <SingleColumnToolsPanelItem
66
+ <ToolsPanelItem
67
+ style={ { gridColumn: 'span 1' } }
76
68
  label={ __( 'Width' ) }
77
69
  isShownByDefault={ isShownByDefault }
78
70
  hasValue={ () => width !== '' }
@@ -89,8 +81,9 @@ export default function WidthHeightTool( {
89
81
  onChange={ onDimensionChange( 'width' ) }
90
82
  size="__unstable-large"
91
83
  />
92
- </SingleColumnToolsPanelItem>
93
- <SingleColumnToolsPanelItem
84
+ </ToolsPanelItem>
85
+ <ToolsPanelItem
86
+ style={ { gridColumn: 'span 1' } }
94
87
  label={ __( 'Height' ) }
95
88
  isShownByDefault={ isShownByDefault }
96
89
  hasValue={ () => height !== '' }
@@ -107,7 +100,7 @@ export default function WidthHeightTool( {
107
100
  onChange={ onDimensionChange( 'height' ) }
108
101
  size="__unstable-large"
109
102
  />
110
- </SingleColumnToolsPanelItem>
103
+ </ToolsPanelItem>
111
104
  </>
112
105
  );
113
106
  }
@@ -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.