@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
@@ -7,7 +7,11 @@ import fastDeepEqual from 'fast-deep-equal/es6';
7
7
  * WordPress dependencies
8
8
  */
9
9
  import { __ } from '@wordpress/i18n';
10
- import { getBlockBindingsSources, getBlockType } from '@wordpress/blocks';
10
+ import {
11
+ getBlockBindingsSource,
12
+ getBlockType,
13
+ store as blockStore,
14
+ } from '@wordpress/blocks';
11
15
  import {
12
16
  __experimentalItemGroup as ItemGroup,
13
17
  __experimentalItem as Item,
@@ -33,8 +37,6 @@ import { store as blockEditorStore } from '../store';
33
37
 
34
38
  const { Menu } = unlock( componentsPrivateApis );
35
39
 
36
- const EMPTY_OBJECT = {};
37
-
38
40
  /**
39
41
  * Get the normalized attribute type for block bindings.
40
42
  * Converts 'rich-text' to 'string' since rich-text is stored as string.
@@ -80,10 +82,10 @@ function BlockBindingsPanelMenuContent( { attribute, binding, sources } ) {
80
82
  );
81
83
  return (
82
84
  <Menu placement={ isMobile ? 'bottom-start' : 'left-start' }>
83
- { Object.entries( sources ).map( ( [ sourceKey, source ] ) => {
85
+ { Object.entries( sources ).map( ( [ sourceKey, data ] ) => {
84
86
  // Only show sources that have compatible data for this specific attribute.
85
- const sourceDataItems = source.data?.filter(
86
- ( item ) => item?.type === attributeType
87
+ const sourceDataItems = data.filter(
88
+ ( item ) => item.type === attributeType
87
89
  );
88
90
 
89
91
  const noItemsAvailable =
@@ -93,6 +95,8 @@ function BlockBindingsPanelMenuContent( { attribute, binding, sources } ) {
93
95
  return null;
94
96
  }
95
97
 
98
+ const source = getBlockBindingsSource( sourceKey );
99
+
96
100
  return (
97
101
  <Menu
98
102
  key={ sourceKey }
@@ -106,17 +110,21 @@ function BlockBindingsPanelMenuContent( { attribute, binding, sources } ) {
106
110
  { sourceDataItems.map( ( item ) => {
107
111
  const itemBindings = {
108
112
  source: sourceKey,
109
- args: item?.args || {
113
+ args: item.args || {
110
114
  key: item.key,
111
115
  },
112
116
  };
113
- const values = source.getValues( {
114
- select,
115
- context: blockContext,
116
- bindings: {
117
- [ attribute ]: itemBindings,
118
- },
119
- } );
117
+ let values = {};
118
+ try {
119
+ values = source.getValues( {
120
+ select,
121
+ context: blockContext,
122
+ bindings: {
123
+ [ attribute ]: itemBindings,
124
+ },
125
+ } );
126
+ } catch ( e ) {}
127
+
120
128
  return (
121
129
  <Menu.CheckboxItem
122
130
  key={
@@ -160,7 +168,7 @@ function BlockBindingsPanelMenuContent( { attribute, binding, sources } ) {
160
168
  }
161
169
  >
162
170
  <Menu.ItemLabel>
163
- { item?.label }
171
+ { item.label }
164
172
  </Menu.ItemLabel>
165
173
  <Menu.ItemHelpText>
166
174
  { values[ attribute ] }
@@ -179,7 +187,8 @@ function BlockBindingsPanelMenuContent( { attribute, binding, sources } ) {
179
187
 
180
188
  function BlockBindingsAttribute( { attribute, binding, sources, blockName } ) {
181
189
  const { source: sourceName, args } = binding || {};
182
- const source = sources?.[ sourceName ];
190
+ const data = sources?.[ sourceName ];
191
+ const source = getBlockBindingsSource( sourceName );
183
192
 
184
193
  let displayText;
185
194
  let isValid = true;
@@ -189,8 +198,8 @@ function BlockBindingsAttribute( { attribute, binding, sources, blockName } ) {
189
198
  // Check if there are any compatible sources for this attribute type.
190
199
  const attributeType = getAttributeType( blockName, attribute );
191
200
 
192
- const hasCompatibleSources = Object.values( sources ).some( ( src ) =>
193
- src.data?.some( ( item ) => item?.type === attributeType )
201
+ const hasCompatibleSources = Object.values( sources ).some( ( items ) =>
202
+ items.some( ( item ) => item.type === attributeType )
194
203
  );
195
204
 
196
205
  if ( ! hasCompatibleSources ) {
@@ -203,14 +212,10 @@ function BlockBindingsAttribute( { attribute, binding, sources, blockName } ) {
203
212
  // If there's a binding but the source is not found, it's invalid.
204
213
  isValid = false;
205
214
  displayText = __( 'Source not registered' );
206
- if ( Object.keys( sources ).length === 0 ) {
207
- displayText = __( 'No sources available' );
208
- }
209
215
  } else {
210
216
  displayText =
211
- source.data?.find( ( item ) => fastDeepEqual( item.args, args ) )
212
- ?.label ||
213
- source.label ||
217
+ data?.find( ( item ) => fastDeepEqual( item.args, args ) )?.label ||
218
+ source?.label ||
214
219
  sourceName;
215
220
  }
216
221
 
@@ -299,68 +304,57 @@ export const BlockBindingsPanel = ( { name: blockName, metadata } ) => {
299
304
 
300
305
  // Use useSelect to ensure sources are updated whenever there are updates in block context
301
306
  // or when underlying data changes.
302
- // Still needs a fix regarding _sources scope.
303
- const _sources = {};
304
- const { sources, canUpdateBlockBindings, bindableAttributes } = useSelect(
307
+ const { canUpdateBlockBindings, bindableAttributes } = useSelect(
305
308
  ( select ) => {
306
309
  const { __experimentalBlockBindingsSupportedAttributes } =
307
310
  select( blockEditorStore ).getSettings();
308
- const _bindableAttributes =
309
- __experimentalBlockBindingsSupportedAttributes?.[ blockName ];
310
- if ( ! _bindableAttributes || _bindableAttributes.length === 0 ) {
311
- return EMPTY_OBJECT;
312
- }
313
-
314
- const registeredSources = getBlockBindingsSources();
315
- Object.entries( registeredSources ).forEach(
316
- ( [
317
- sourceName,
318
- { getFieldsList, usesContext, label, getValues },
319
- ] ) => {
320
- // Populate context.
311
+
312
+ return {
313
+ canUpdateBlockBindings:
314
+ select( blockEditorStore ).getSettings()
315
+ .canUpdateBlockBindings,
316
+ bindableAttributes:
317
+ __experimentalBlockBindingsSupportedAttributes?.[
318
+ blockName
319
+ ],
320
+ };
321
+ },
322
+ [ blockName ]
323
+ );
324
+
325
+ const sources = useSelect(
326
+ ( select ) => {
327
+ const { getAllBlockBindingsSources } = unlock(
328
+ select( blockStore )
329
+ );
330
+ const data = {};
331
+ Object.entries( getAllBlockBindingsSources() ).forEach(
332
+ ( [ sourceName, source ] ) => {
333
+ if ( ! source.getFieldsList ) {
334
+ return;
335
+ }
336
+
321
337
  const context = {};
322
- if ( usesContext?.length ) {
323
- for ( const key of usesContext ) {
338
+ if ( source.usesContext?.length ) {
339
+ for ( const key of source.usesContext ) {
324
340
  context[ key ] = blockContext[ key ];
325
341
  }
326
342
  }
327
- if ( getFieldsList ) {
328
- const fieldsListResult = getFieldsList( {
329
- select,
330
- context,
331
- } );
332
- _sources[ sourceName ] = {
333
- data: fieldsListResult || [],
334
- label,
335
- getValues,
336
- };
337
- } else {
338
- /*
339
- * Include sources without getFieldsList if they are already used in a binding.
340
- * This allows them to be displayed in read-only mode.
341
- */
342
- _sources[ sourceName ] = {
343
- data: [],
344
- label,
345
- getValues,
346
- };
343
+
344
+ const items = source.getFieldsList( {
345
+ select,
346
+ context,
347
+ } );
348
+ if ( items?.length ) {
349
+ data[ sourceName ] = items;
347
350
  }
348
351
  }
349
352
  );
350
-
351
- return {
352
- sources:
353
- Object.values( _sources ).length > 0
354
- ? _sources
355
- : EMPTY_OBJECT,
356
- canUpdateBlockBindings:
357
- select( blockEditorStore ).getSettings()
358
- .canUpdateBlockBindings,
359
- bindableAttributes: _bindableAttributes,
360
- };
353
+ return data;
361
354
  },
362
- [ blockContext, blockName ]
355
+ [ blockContext ]
363
356
  );
357
+
364
358
  // Return early if there are no bindable attributes.
365
359
  if ( ! bindableAttributes || bindableAttributes.length === 0 ) {
366
360
  return null;
@@ -368,10 +362,7 @@ export const BlockBindingsPanel = ( { name: blockName, metadata } ) => {
368
362
 
369
363
  const { bindings } = metadata || {};
370
364
 
371
- // Check if all sources have empty data arrays.
372
- const hasCompatibleData = Object.values( sources ).some(
373
- ( source ) => source.data && source.data.length > 0
374
- );
365
+ const hasCompatibleData = Object.keys( sources ).length > 0;
375
366
 
376
367
  // Lock the UI when the user can't update bindings or there are no fields to connect to.
377
368
  const readOnly = ! canUpdateBlockBindings || ! hasCompatibleData;
@@ -402,10 +393,8 @@ export const BlockBindingsPanel = ( { name: blockName, metadata } ) => {
402
393
 
403
394
  const hasCompatibleDataForAttribute = Object.values(
404
395
  sources
405
- ).some( ( source ) =>
406
- source.data?.some(
407
- ( item ) => item?.type === attributeType
408
- )
396
+ ).some( ( data ) =>
397
+ data.some( ( item ) => item.type === attributeType )
409
398
  );
410
399
 
411
400
  const isAttributeReadOnly =
@@ -81,6 +81,7 @@ export function DimensionsPanel( { clientId, name, setAttributes, settings } ) {
81
81
  },
82
82
  [ clientId, isEnabled ]
83
83
  );
84
+
84
85
  const [ visualizedProperty, setVisualizedProperty ] = useVisualizer();
85
86
  const onChange = ( newStyle ) => {
86
87
  setAttributes( {
@@ -156,7 +157,11 @@ export function hasDimensionsSupport( blockName, feature = 'any' ) {
156
157
  }
157
158
 
158
159
  if ( feature === 'any' ) {
159
- return !! ( support?.aspectRatio || !! support?.minHeight );
160
+ return !! (
161
+ support?.aspectRatio ||
162
+ !! support?.minHeight ||
163
+ !! support?.width
164
+ );
160
165
  }
161
166
 
162
167
  return !! support?.[ feature ];
@@ -164,9 +169,9 @@ export function hasDimensionsSupport( blockName, feature = 'any' ) {
164
169
 
165
170
  export default {
166
171
  useBlockProps,
167
- attributeKeys: [ 'minHeight', 'style' ],
172
+ attributeKeys: [ 'minHeight', 'width', 'style' ],
168
173
  hasSupport( name ) {
169
- return hasDimensionsSupport( name, 'aspectRatio' );
174
+ return hasDimensionsSupport( name );
170
175
  },
171
176
  };
172
177
 
@@ -91,7 +91,7 @@ export function addTransforms( result, source, index, results ) {
91
91
  if (
92
92
  sourceMetadata.blockVisibility !== undefined &&
93
93
  ! result.attributes?.metadata?.blockVisibility &&
94
- hasBlockSupport( result.name, 'blockVisibility', true )
94
+ hasBlockSupport( result.name, 'visibility', true )
95
95
  ) {
96
96
  preservedMetadata.blockVisibility = sourceMetadata.blockVisibility;
97
97
  }
@@ -254,7 +254,7 @@ describe( 'metadata', () => {
254
254
  registerBlockType( 'core/bar', {
255
255
  title: 'Bar',
256
256
  supports: {
257
- blockVisibility: false,
257
+ visibility: false,
258
258
  },
259
259
  } );
260
260
 
@@ -0,0 +1,63 @@
1
+ /**
2
+ * WordPress dependencies
3
+ */
4
+ import { useDispatch, useSelect } from '@wordpress/data';
5
+
6
+ /**
7
+ * Internal dependencies
8
+ */
9
+ import { store as blockEditorStore } from '../store';
10
+ import { unlock } from '../lock-unlock';
11
+
12
+ /**
13
+ * Hook that provides section block editing state and actions.
14
+ *
15
+ * @param {string} clientId Block client ID.
16
+ * @return {Object} Object containing section block state and actions.
17
+ */
18
+ export default function useContentOnlySectionEdit( clientId ) {
19
+ const {
20
+ isSectionBlock,
21
+ isWithinSection,
22
+ isWithinEditedSection,
23
+ isEditingContentOnlySection,
24
+ editedContentOnlySection,
25
+ } = useSelect(
26
+ ( select ) => {
27
+ const {
28
+ isSectionBlock: _isSectionBlock,
29
+ getParentSectionBlock,
30
+ getEditedContentOnlySection,
31
+ isWithinEditedContentOnlySection,
32
+ } = unlock( select( blockEditorStore ) );
33
+
34
+ const editedSection = getEditedContentOnlySection();
35
+
36
+ return {
37
+ isSectionBlock: _isSectionBlock( clientId ),
38
+ isWithinSection:
39
+ _isSectionBlock( clientId ) ||
40
+ !! getParentSectionBlock( clientId ),
41
+ isWithinEditedSection:
42
+ isWithinEditedContentOnlySection( clientId ),
43
+ isEditingContentOnlySection: editedSection === clientId,
44
+ editedContentOnlySection: editedSection,
45
+ };
46
+ },
47
+ [ clientId ]
48
+ );
49
+
50
+ const blockEditorActions = useDispatch( blockEditorStore );
51
+ const { editContentOnlySection, stopEditingContentOnlySection } =
52
+ unlock( blockEditorActions );
53
+
54
+ return {
55
+ isSectionBlock,
56
+ isWithinSection,
57
+ isWithinEditedSection,
58
+ isEditingContentOnlySection,
59
+ editedContentOnlySection,
60
+ editContentOnlySection,
61
+ stopEditingContentOnlySection,
62
+ };
63
+ }
@@ -263,6 +263,7 @@ export function useBlockSettings( name, parentLayout ) {
263
263
  units,
264
264
  aspectRatio,
265
265
  minHeight,
266
+ width,
266
267
  layout,
267
268
  borderColor,
268
269
  borderRadius,
@@ -321,6 +322,7 @@ export function useBlockSettings( name, parentLayout ) {
321
322
  'spacing.units',
322
323
  'dimensions.aspectRatio',
323
324
  'dimensions.minHeight',
325
+ 'dimensions.width',
324
326
  'layout',
325
327
  'border.color',
326
328
  'border.radius',
@@ -430,6 +432,7 @@ export function useBlockSettings( name, parentLayout ) {
430
432
  dimensions: {
431
433
  aspectRatio,
432
434
  minHeight,
435
+ width,
433
436
  },
434
437
  layout,
435
438
  parentLayout,
@@ -466,6 +469,7 @@ export function useBlockSettings( name, parentLayout ) {
466
469
  units,
467
470
  aspectRatio,
468
471
  minHeight,
472
+ width,
469
473
  layout,
470
474
  parentLayout,
471
475
  borderColor,
@@ -89,7 +89,10 @@ export default {
89
89
  : nextWidth;
90
90
  onChange( {
91
91
  ...layout,
92
- contentSize: nextWidth,
92
+ contentSize:
93
+ nextWidth !== ''
94
+ ? nextWidth
95
+ : undefined,
93
96
  } );
94
97
  } }
95
98
  units={ units }
@@ -111,7 +114,10 @@ export default {
111
114
  : nextWidth;
112
115
  onChange( {
113
116
  ...layout,
114
- wideSize: nextWidth,
117
+ wideSize:
118
+ nextWidth !== ''
119
+ ? nextWidth
120
+ : undefined,
115
121
  } );
116
122
  } }
117
123
  units={ units }
@@ -40,6 +40,7 @@ import {
40
40
  globalStylesLinksDataKey,
41
41
  sectionRootClientIdKey,
42
42
  mediaEditKey,
43
+ getMediaSelectKey,
43
44
  essentialFormatKey,
44
45
  } from './store/private-keys';
45
46
  import { requiresWrapperOnCopy } from './components/writing-flow/utils';
@@ -57,7 +58,6 @@ import {
57
58
  useBlockElementRef,
58
59
  useBlockElement,
59
60
  } from './components/block-list/use-block-props/use-block-refs';
60
- import { default as MediaUploadModal } from './components/media-upload-modal';
61
61
 
62
62
  /**
63
63
  * Private @wordpress/block-editor APIs.
@@ -108,8 +108,8 @@ lock( privateApis, {
108
108
  CommentIconSlotFill,
109
109
  CommentIconToolbarSlotFill,
110
110
  mediaEditKey,
111
+ getMediaSelectKey,
111
112
  essentialFormatKey,
112
113
  useBlockElement,
113
114
  useBlockElementRef,
114
- MediaUploadModal,
115
115
  } );
@@ -4,4 +4,5 @@ export const selectBlockPatternsKey = Symbol( 'selectBlockPatternsKey' );
4
4
  export const reusableBlocksSelectKey = Symbol( 'reusableBlocksSelect' );
5
5
  export const sectionRootClientIdKey = Symbol( 'sectionRootClientIdKey' );
6
6
  export const mediaEditKey = Symbol( 'mediaEditKey' );
7
+ export const getMediaSelectKey = Symbol( 'getMediaSelect' );
7
8
  export const essentialFormatKey = Symbol( 'essentialFormat' );
@@ -518,10 +518,7 @@ export function isSectionBlock( state, clientId ) {
518
518
  }
519
519
 
520
520
  const blockName = getBlockName( state, clientId );
521
- if (
522
- blockName === 'core/block' ||
523
- getTemplateLock( state, clientId ) === 'contentOnly'
524
- ) {
521
+ if ( blockName === 'core/block' ) {
525
522
  return true;
526
523
  }
527
524
 
@@ -533,6 +530,19 @@ export function isSectionBlock( state, clientId ) {
533
530
  ) {
534
531
  return true;
535
532
  }
533
+
534
+ // TemplateLock cascades to all inner parent blocks. Only the top-level
535
+ // block that's contentOnly templateLocked is the true contentLocker,
536
+ // all the others are mere imitators.
537
+ const hasContentOnlyTempateLock =
538
+ getTemplateLock( state, clientId ) === 'contentOnly';
539
+ const rootClientId = getBlockRootClientId( state, clientId );
540
+ const hasRootContentOnlyTemplateLock =
541
+ getTemplateLock( state, rootClientId ) === 'contentOnly';
542
+ if ( hasContentOnlyTempateLock && ! hasRootContentOnlyTemplateLock ) {
543
+ return true;
544
+ }
545
+
536
546
  return false;
537
547
  }
538
548
 
@@ -700,7 +710,7 @@ export function getInsertionPoint( state ) {
700
710
  */
701
711
  export const isBlockHidden = ( state, clientId ) => {
702
712
  const blockName = getBlockName( state, clientId );
703
- if ( ! hasBlockSupport( state, blockName, 'blockVisibility', true ) ) {
713
+ if ( ! hasBlockSupport( state, blockName, 'visibility', true ) ) {
704
714
  return false;
705
715
  }
706
716
  const attributes = state.blocks.attributes.get( clientId );
@@ -720,3 +730,109 @@ export const isBlockHidden = ( state, clientId ) => {
720
730
  export function hasBlockSpotlight( state ) {
721
731
  return !! state.hasBlockSpotlight || !! state.editedContentOnlySection;
722
732
  }
733
+
734
+ /**
735
+ * Returns whether a block is locked to prevent editing.
736
+ *
737
+ * This selector only reasons about block lock, not associated features
738
+ * like `blockEditingMode` that might prevent user modifications to a block.
739
+ * Currently there's also no way to prevent editing via `templateLock`.
740
+ *
741
+ * This distinction is important as this selector specifically drives the block lock UI
742
+ * that a user interacts with. `blockEditingModes` aren't included as a user can't change
743
+ * them.
744
+ *
745
+ * @param {Object} state Global application state.
746
+ * @param {string} clientId ClientId of the block.
747
+ *
748
+ * @return {boolean} Whether the block is currently locked.
749
+ */
750
+ export function isEditLockedBlock( state, clientId ) {
751
+ const attributes = getBlockAttributes( state, clientId );
752
+ return !! attributes?.lock?.edit;
753
+ }
754
+
755
+ /**
756
+ * Returns whether a block is locked to prevent moving.
757
+ *
758
+ * This selector only reasons about templateLock and block lock, not associated features
759
+ * like `blockEditingMode` that might prevent user modifications to a block.
760
+ *
761
+ * This distinction is important as this selector specifically drives the block lock UI
762
+ * that a user interacts with. `blockEditingModes` are excluded as a user can't change
763
+ * them.
764
+ *
765
+ * @param {Object} state Global application state.
766
+ * @param {string} clientId ClientId of the block.
767
+ *
768
+ * @return {boolean} Whether the block is currently locked.
769
+ */
770
+ export function isMoveLockedBlock( state, clientId ) {
771
+ const attributes = getBlockAttributes( state, clientId );
772
+ // If a block explicitly has `move` set to `false`, it turns off
773
+ // any locking that might be inherited from a parent.
774
+ if ( attributes?.lock?.move !== undefined ) {
775
+ return !! attributes?.lock?.move;
776
+ }
777
+
778
+ const rootClientId = getBlockRootClientId( state, clientId );
779
+ const templateLock = getTemplateLock( state, rootClientId );
780
+
781
+ // While `contentOnly` templateLock does sometimes prevent moving, a user can't modify
782
+ // this, so don't include it in this function. See the `canMoveBlock` selector
783
+ // as an alternative.
784
+ return templateLock === 'all';
785
+ }
786
+
787
+ /**
788
+ * Returns whether a block is locked to prevent removal.
789
+ *
790
+ * This selector only reasons about templateLock and block lock, not associated features
791
+ * like `blockEditingMode` that might prevent user modifications to a block.
792
+ *
793
+ * This distinction is important as this selector specifically drives the block lock UI
794
+ * that a user interacts with. `blockEditingModes` are excluded as a user can't change
795
+ * them.
796
+ *
797
+ * @param {Object} state Global application state.
798
+ * @param {string} clientId ClientId of the block.
799
+ *
800
+ * @return {boolean} Whether the block is currently locked.
801
+ */
802
+ export function isRemoveLockedBlock( state, clientId ) {
803
+ const attributes = getBlockAttributes( state, clientId );
804
+ if ( attributes?.lock?.remove !== undefined ) {
805
+ return !! attributes?.lock?.remove;
806
+ }
807
+
808
+ const rootClientId = getBlockRootClientId( state, clientId );
809
+ const templateLock = getTemplateLock( state, rootClientId );
810
+
811
+ // While `contentOnly` templateLock does sometimes prevent removal, a user can't modify
812
+ // this, so don't include it in this function. See the `canRemoveBlock` selector
813
+ // as an alternative.
814
+ return templateLock === 'all' || templateLock === 'insert';
815
+ }
816
+
817
+ /**
818
+ * Returns whether a block is locked.
819
+ *
820
+ * This selector only reasons about templateLock and block lock, not associated features
821
+ * like `blockEditingMode` that might prevent user modifications to a block.
822
+ *
823
+ * This distinction is important as this selector specifically drives the block lock UI
824
+ * that a user interacts with. `blockEditingModes` are excluded as a user can't change
825
+ * them.
826
+ *
827
+ * @param {Object} state Global application state.
828
+ * @param {string} clientId ClientId of the block.
829
+ *
830
+ * @return {boolean} Whether the block is currently locked.
831
+ */
832
+ export function isLockedBlock( state, clientId ) {
833
+ return (
834
+ isEditLockedBlock( state, clientId ) ||
835
+ isMoveLockedBlock( state, clientId ) ||
836
+ isRemoveLockedBlock( state, clientId )
837
+ );
838
+ }
@@ -1693,7 +1693,8 @@ const canInsertBlockTypeUnmemoized = (
1693
1693
  blockType = getBlockType( blockName );
1694
1694
  }
1695
1695
 
1696
- if ( getTemplateLock( state, rootClientId ) ) {
1696
+ const rootTemplateLock = getTemplateLock( state, rootClientId );
1697
+ if ( rootTemplateLock && rootTemplateLock !== 'contentOnly' ) {
1697
1698
  return false;
1698
1699
  }
1699
1700
 
@@ -1876,7 +1877,8 @@ export function canRemoveBlock( state, clientId ) {
1876
1877
  }
1877
1878
 
1878
1879
  const rootClientId = getBlockRootClientId( state, clientId );
1879
- if ( getTemplateLock( state, rootClientId ) ) {
1880
+ const rootTemplateLock = getTemplateLock( state, rootClientId );
1881
+ if ( rootTemplateLock && rootTemplateLock !== 'contentOnly' ) {
1880
1882
  return false;
1881
1883
  }
1882
1884
 
@@ -1937,8 +1939,8 @@ export function canMoveBlock( state, clientId ) {
1937
1939
  }
1938
1940
 
1939
1941
  const rootClientId = getBlockRootClientId( state, clientId );
1940
- const templateLock = getTemplateLock( state, rootClientId );
1941
- if ( templateLock === 'all' || templateLock === 'contentOnly' ) {
1942
+ const rootTemplateLock = getTemplateLock( state, rootClientId );
1943
+ if ( rootTemplateLock === 'all' ) {
1942
1944
  return false;
1943
1945
  }
1944
1946