@wordpress/block-editor 15.8.1-next.dc3f6d3c1.0 → 15.9.1-next.6deb34194.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (325) hide show
  1. package/CHANGELOG.md +2 -0
  2. package/README.md +12 -0
  3. package/build/components/block-alignment-matrix-control/index.js +1 -8
  4. package/build/components/block-alignment-matrix-control/index.js.map +2 -2
  5. package/build/components/block-bindings/attribute-control.js +172 -0
  6. package/build/components/block-bindings/attribute-control.js.map +7 -0
  7. package/build/components/block-bindings/index.js +47 -0
  8. package/build/components/block-bindings/index.js.map +7 -0
  9. package/build/components/block-bindings/source-fields-list.js +135 -0
  10. package/build/components/block-bindings/source-fields-list.js.map +7 -0
  11. package/build/components/block-bindings/use-block-bindings-utils.js +66 -0
  12. package/build/components/block-bindings/use-block-bindings-utils.js.map +7 -0
  13. package/build/components/block-edit/edit.js +1 -3
  14. package/build/components/block-edit/edit.js.map +2 -2
  15. package/build/components/block-list/index.js +2 -1
  16. package/build/components/block-list/index.js.map +2 -2
  17. package/build/components/block-list/use-block-props/use-selected-block-event-handlers.js +27 -5
  18. package/build/components/block-list/use-block-props/use-selected-block-event-handlers.js.map +2 -2
  19. package/build/components/block-lock/modal.js +5 -5
  20. package/build/components/block-lock/modal.js.map +2 -2
  21. package/build/components/block-lock/use-block-lock.js +10 -13
  22. package/build/components/block-lock/use-block-lock.js.map +2 -2
  23. package/build/components/block-settings-menu-controls/index.js +1 -1
  24. package/build/components/block-settings-menu-controls/index.js.map +2 -2
  25. package/build/components/block-styles/preview-panel.js +3 -5
  26. package/build/components/block-styles/preview-panel.js.map +2 -2
  27. package/build/components/block-styles/use-styles-for-block.js +2 -2
  28. package/build/components/block-styles/use-styles-for-block.js.map +2 -2
  29. package/build/components/block-toolbar/index.js +1 -8
  30. package/build/components/block-toolbar/index.js.map +3 -3
  31. package/build/components/block-tools/index.js +56 -45
  32. package/build/components/block-tools/index.js.map +3 -3
  33. package/build/components/block-visibility/toolbar.js +1 -1
  34. package/build/components/block-visibility/toolbar.js.map +1 -1
  35. package/build/components/content-only-controls/fields-dropdown-menu.js +66 -0
  36. package/build/components/content-only-controls/fields-dropdown-menu.js.map +7 -0
  37. package/build/components/content-only-controls/index.js +202 -44
  38. package/build/components/content-only-controls/index.js.map +3 -3
  39. package/build/components/content-only-controls/link/index.js +92 -103
  40. package/build/components/content-only-controls/link/index.js.map +3 -3
  41. package/build/components/content-only-controls/media/index.js +134 -134
  42. package/build/components/content-only-controls/media/index.js.map +3 -3
  43. package/build/components/content-only-controls/rich-text/index.js +66 -74
  44. package/build/components/content-only-controls/rich-text/index.js.map +3 -3
  45. package/build/components/dimensions-tool/width-height-tool.js +4 -16
  46. package/build/components/dimensions-tool/width-height-tool.js.map +3 -3
  47. package/build/components/font-family/index.js +1 -15
  48. package/build/components/font-family/index.js.map +2 -2
  49. package/build/components/global-styles/dimensions-panel.js +35 -2
  50. package/build/components/global-styles/dimensions-panel.js.map +2 -2
  51. package/build/components/global-styles/hooks.js +1 -1
  52. package/build/components/global-styles/hooks.js.map +2 -2
  53. package/build/components/global-styles/typography-panel.js +1 -2
  54. package/build/components/global-styles/typography-panel.js.map +2 -2
  55. package/build/components/image-editor/cropper.js +3 -34
  56. package/build/components/image-editor/cropper.js.map +3 -3
  57. package/build/components/image-editor/index.js +9 -3
  58. package/build/components/image-editor/index.js.map +2 -2
  59. package/build/components/image-editor/use-transform-image.js +62 -32
  60. package/build/components/image-editor/use-transform-image.js.map +2 -2
  61. package/build/components/image-editor/zoom-dropdown.js +2 -2
  62. package/build/components/image-editor/zoom-dropdown.js.map +2 -2
  63. package/build/components/index.js +10 -3
  64. package/build/components/index.js.map +2 -2
  65. package/build/components/inserter-draggable-blocks/index.js +8 -4
  66. package/build/components/inserter-draggable-blocks/index.js.map +2 -2
  67. package/build/components/inspector-controls-tabs/content-tab.js +3 -2
  68. package/build/components/inspector-controls-tabs/content-tab.js.map +2 -2
  69. package/build/components/inspector-controls-tabs/use-inspector-controls-tabs.js +1 -1
  70. package/build/components/inspector-controls-tabs/use-inspector-controls-tabs.js.map +2 -2
  71. package/build/components/link-control/index.js +15 -7
  72. package/build/components/link-control/index.js.map +2 -2
  73. package/build/components/list-view/block-select-button.js +3 -11
  74. package/build/components/list-view/block-select-button.js.map +2 -2
  75. package/build/components/list-view/block.js +9 -7
  76. package/build/components/list-view/block.js.map +2 -2
  77. package/build/components/media-placeholder/index.js +17 -4
  78. package/build/components/media-placeholder/index.js.map +2 -2
  79. package/build/components/media-placeholder/utils.js +60 -0
  80. package/build/components/media-placeholder/utils.js.map +7 -0
  81. package/build/components/media-replace-flow/index.js +20 -3
  82. package/build/components/media-replace-flow/index.js.map +2 -2
  83. package/build/components/tool-selector/index.js +46 -0
  84. package/build/components/tool-selector/index.js.map +7 -0
  85. package/build/components/use-block-commands/index.js +1 -1
  86. package/build/components/use-block-commands/index.js.map +2 -2
  87. package/build/components/use-block-drop-zone/index.js +1 -5
  88. package/build/components/use-block-drop-zone/index.js.map +2 -2
  89. package/build/hooks/block-bindings.js +22 -260
  90. package/build/hooks/block-bindings.js.map +3 -3
  91. package/build/hooks/dimensions.js +3 -3
  92. package/build/hooks/dimensions.js.map +2 -2
  93. package/build/hooks/metadata.js +1 -1
  94. package/build/hooks/metadata.js.map +2 -2
  95. package/build/hooks/utils.js +5 -1
  96. package/build/hooks/utils.js.map +2 -2
  97. package/build/layouts/grid.js +23 -28
  98. package/build/layouts/grid.js.map +2 -2
  99. package/build/store/private-selectors.js +43 -3
  100. package/build/store/private-selectors.js.map +2 -2
  101. package/build/store/reducer.js +2 -1
  102. package/build/store/reducer.js.map +2 -2
  103. package/build/store/selectors.js +6 -4
  104. package/build/store/selectors.js.map +2 -2
  105. package/build/utils/block-bindings.js +2 -44
  106. package/build/utils/block-bindings.js.map +3 -3
  107. package/build/utils/index.js +2 -5
  108. package/build/utils/index.js.map +2 -2
  109. package/build-module/components/block-alignment-matrix-control/index.js +1 -8
  110. package/build-module/components/block-alignment-matrix-control/index.js.map +2 -2
  111. package/build-module/components/block-bindings/attribute-control.js +150 -0
  112. package/build-module/components/block-bindings/attribute-control.js.map +7 -0
  113. package/build-module/components/block-bindings/index.js +10 -0
  114. package/build-module/components/block-bindings/index.js.map +7 -0
  115. package/build-module/components/block-bindings/source-fields-list.js +104 -0
  116. package/build-module/components/block-bindings/source-fields-list.js.map +7 -0
  117. package/build-module/components/block-bindings/use-block-bindings-utils.js +45 -0
  118. package/build-module/components/block-bindings/use-block-bindings-utils.js.map +7 -0
  119. package/build-module/components/block-edit/edit.js +1 -3
  120. package/build-module/components/block-edit/edit.js.map +2 -2
  121. package/build-module/components/block-list/index.js +2 -1
  122. package/build-module/components/block-list/index.js.map +2 -2
  123. package/build-module/components/block-list/use-block-props/use-selected-block-event-handlers.js +27 -5
  124. package/build-module/components/block-list/use-block-props/use-selected-block-event-handlers.js.map +2 -2
  125. package/build-module/components/block-lock/modal.js +5 -5
  126. package/build-module/components/block-lock/modal.js.map +2 -2
  127. package/build-module/components/block-lock/use-block-lock.js +10 -13
  128. package/build-module/components/block-lock/use-block-lock.js.map +2 -2
  129. package/build-module/components/block-settings-menu-controls/index.js +1 -1
  130. package/build-module/components/block-settings-menu-controls/index.js.map +2 -2
  131. package/build-module/components/block-styles/preview-panel.js +3 -5
  132. package/build-module/components/block-styles/preview-panel.js.map +2 -2
  133. package/build-module/components/block-styles/use-styles-for-block.js +2 -2
  134. package/build-module/components/block-styles/use-styles-for-block.js.map +2 -2
  135. package/build-module/components/block-toolbar/index.js +1 -8
  136. package/build-module/components/block-toolbar/index.js.map +2 -2
  137. package/build-module/components/block-tools/index.js +56 -45
  138. package/build-module/components/block-tools/index.js.map +2 -2
  139. package/build-module/components/block-visibility/toolbar.js +1 -1
  140. package/build-module/components/block-visibility/toolbar.js.map +1 -1
  141. package/build-module/components/content-only-controls/fields-dropdown-menu.js +45 -0
  142. package/build-module/components/content-only-controls/fields-dropdown-menu.js.map +7 -0
  143. package/build-module/components/content-only-controls/index.js +206 -46
  144. package/build-module/components/content-only-controls/index.js.map +2 -2
  145. package/build-module/components/content-only-controls/link/index.js +92 -104
  146. package/build-module/components/content-only-controls/link/index.js.map +2 -2
  147. package/build-module/components/content-only-controls/media/index.js +134 -135
  148. package/build-module/components/content-only-controls/media/index.js.map +2 -2
  149. package/build-module/components/content-only-controls/rich-text/index.js +68 -81
  150. package/build-module/components/content-only-controls/rich-text/index.js.map +2 -2
  151. package/build-module/components/dimensions-tool/width-height-tool.js +4 -6
  152. package/build-module/components/dimensions-tool/width-height-tool.js.map +2 -2
  153. package/build-module/components/font-family/index.js +1 -15
  154. package/build-module/components/font-family/index.js.map +2 -2
  155. package/build-module/components/global-styles/dimensions-panel.js +35 -2
  156. package/build-module/components/global-styles/dimensions-panel.js.map +2 -2
  157. package/build-module/components/global-styles/hooks.js +1 -1
  158. package/build-module/components/global-styles/hooks.js.map +2 -2
  159. package/build-module/components/global-styles/typography-panel.js +1 -2
  160. package/build-module/components/global-styles/typography-panel.js.map +2 -2
  161. package/build-module/components/image-editor/cropper.js +3 -34
  162. package/build-module/components/image-editor/cropper.js.map +2 -2
  163. package/build-module/components/image-editor/index.js +9 -3
  164. package/build-module/components/image-editor/index.js.map +2 -2
  165. package/build-module/components/image-editor/use-transform-image.js +63 -33
  166. package/build-module/components/image-editor/use-transform-image.js.map +2 -2
  167. package/build-module/components/image-editor/zoom-dropdown.js +2 -2
  168. package/build-module/components/image-editor/zoom-dropdown.js.map +2 -2
  169. package/build-module/components/index.js +74 -66
  170. package/build-module/components/index.js.map +2 -2
  171. package/build-module/components/inserter-draggable-blocks/index.js +8 -4
  172. package/build-module/components/inserter-draggable-blocks/index.js.map +2 -2
  173. package/build-module/components/inspector-controls-tabs/content-tab.js +3 -2
  174. package/build-module/components/inspector-controls-tabs/content-tab.js.map +2 -2
  175. package/build-module/components/inspector-controls-tabs/use-inspector-controls-tabs.js +1 -1
  176. package/build-module/components/inspector-controls-tabs/use-inspector-controls-tabs.js.map +2 -2
  177. package/build-module/components/link-control/index.js +16 -8
  178. package/build-module/components/link-control/index.js.map +2 -2
  179. package/build-module/components/list-view/block-select-button.js +3 -11
  180. package/build-module/components/list-view/block-select-button.js.map +2 -2
  181. package/build-module/components/list-view/block.js +9 -7
  182. package/build-module/components/list-view/block.js.map +2 -2
  183. package/build-module/components/media-placeholder/index.js +18 -5
  184. package/build-module/components/media-placeholder/index.js.map +2 -2
  185. package/build-module/components/media-placeholder/utils.js +35 -0
  186. package/build-module/components/media-placeholder/utils.js.map +7 -0
  187. package/build-module/components/media-replace-flow/index.js +20 -3
  188. package/build-module/components/media-replace-flow/index.js.map +2 -2
  189. package/build-module/components/tool-selector/index.js +15 -0
  190. package/build-module/components/tool-selector/index.js.map +7 -0
  191. package/build-module/components/use-block-commands/index.js +1 -1
  192. package/build-module/components/use-block-commands/index.js.map +2 -2
  193. package/build-module/components/use-block-drop-zone/index.js +1 -5
  194. package/build-module/components/use-block-drop-zone/index.js.map +2 -2
  195. package/build-module/hooks/block-bindings.js +27 -270
  196. package/build-module/hooks/block-bindings.js.map +2 -2
  197. package/build-module/hooks/dimensions.js +3 -3
  198. package/build-module/hooks/dimensions.js.map +2 -2
  199. package/build-module/hooks/metadata.js +1 -1
  200. package/build-module/hooks/metadata.js.map +2 -2
  201. package/build-module/hooks/utils.js +5 -1
  202. package/build-module/hooks/utils.js.map +2 -2
  203. package/build-module/layouts/grid.js +23 -28
  204. package/build-module/layouts/grid.js.map +2 -2
  205. package/build-module/store/private-selectors.js +39 -3
  206. package/build-module/store/private-selectors.js.map +2 -2
  207. package/build-module/store/reducer.js +2 -1
  208. package/build-module/store/reducer.js.map +2 -2
  209. package/build-module/store/selectors.js +6 -4
  210. package/build-module/store/selectors.js.map +2 -2
  211. package/build-module/utils/block-bindings.js +1 -42
  212. package/build-module/utils/block-bindings.js.map +2 -2
  213. package/build-module/utils/index.js +1 -3
  214. package/build-module/utils/index.js.map +2 -2
  215. package/build-style/content-rtl.css +3 -0
  216. package/build-style/content.css +3 -0
  217. package/build-style/style-rtl.css +20 -11
  218. package/build-style/style.css +20 -11
  219. package/package.json +39 -39
  220. package/src/components/block-alignment-matrix-control/index.js +1 -5
  221. package/src/components/block-bindings/attribute-control.js +174 -0
  222. package/src/components/block-bindings/index.js +6 -0
  223. package/src/components/block-bindings/source-fields-list.js +130 -0
  224. package/src/components/block-bindings/use-block-bindings-utils.js +156 -0
  225. package/src/components/block-edit/edit.js +1 -3
  226. package/src/components/block-list/content.scss +5 -0
  227. package/src/components/block-list/index.js +3 -1
  228. package/src/components/block-list/use-block-props/use-selected-block-event-handlers.js +34 -3
  229. package/src/components/block-lock/modal.js +6 -5
  230. package/src/components/block-lock/use-block-lock.js +10 -14
  231. package/src/components/block-patterns-list/stories/{index.story.js → index.story.jsx} +3 -1
  232. package/src/components/block-settings-menu-controls/index.js +1 -1
  233. package/src/components/block-styles/preview-panel.js +3 -5
  234. package/src/components/block-styles/use-styles-for-block.js +2 -2
  235. package/src/components/block-toolbar/index.js +1 -6
  236. package/src/components/block-toolbar/style.scss +6 -6
  237. package/src/components/block-tools/index.js +15 -2
  238. package/src/components/block-tools/style.scss +4 -0
  239. package/src/components/block-visibility/toolbar.js +1 -1
  240. package/src/components/content-only-controls/fields-dropdown-menu.js +53 -0
  241. package/src/components/content-only-controls/index.js +289 -50
  242. package/src/components/content-only-controls/link/index.js +62 -57
  243. package/src/components/content-only-controls/media/index.js +177 -156
  244. package/src/components/content-only-controls/rich-text/index.js +31 -44
  245. package/src/components/content-only-controls/styles.scss +10 -1
  246. package/src/components/dimensions-tool/width-height-tool.js +6 -13
  247. package/src/components/font-family/README.md +0 -9
  248. package/src/components/font-family/index.js +1 -16
  249. package/src/components/font-family/stories/{index.story.js → index.story.jsx} +0 -1
  250. package/src/components/global-styles/dimensions-panel.js +36 -0
  251. package/src/components/global-styles/hooks.js +1 -1
  252. package/src/components/global-styles/typography-panel.js +0 -1
  253. package/src/components/image-editor/cropper.js +3 -32
  254. package/src/components/image-editor/index.js +34 -29
  255. package/src/components/image-editor/use-transform-image.js +80 -34
  256. package/src/components/image-editor/zoom-dropdown.js +2 -2
  257. package/src/components/index.js +9 -1
  258. package/src/components/inserter/style.scss +1 -1
  259. package/src/components/inserter-draggable-blocks/index.js +19 -8
  260. package/src/components/inspector-controls-tabs/content-tab.js +6 -2
  261. package/src/components/inspector-controls-tabs/use-inspector-controls-tabs.js +1 -5
  262. package/src/components/link-control/index.js +36 -12
  263. package/src/components/list-view/block-select-button.js +22 -30
  264. package/src/components/list-view/block.js +9 -7
  265. package/src/components/media-placeholder/index.js +20 -5
  266. package/src/components/media-placeholder/test/get-computed-accept-attribute.js +164 -0
  267. package/src/components/media-placeholder/utils.js +65 -0
  268. package/src/components/media-replace-flow/index.js +22 -3
  269. package/src/components/tool-selector/index.js +19 -0
  270. package/src/components/use-block-commands/index.js +1 -1
  271. package/src/components/use-block-drop-zone/index.js +1 -5
  272. package/src/hooks/block-bindings.js +27 -347
  273. package/src/hooks/dimensions.js +8 -3
  274. package/src/hooks/metadata.js +1 -1
  275. package/src/hooks/test/metadata.js +1 -1
  276. package/src/hooks/utils.js +4 -0
  277. package/src/layouts/grid.js +40 -72
  278. package/src/layouts/test/grid.js +14 -0
  279. package/src/store/private-selectors.js +123 -6
  280. package/src/store/reducer.js +3 -0
  281. package/src/store/selectors.js +6 -4
  282. package/src/store/test/private-selectors.js +242 -0
  283. package/src/store/test/reducer.js +17 -7
  284. package/src/style.scss +0 -1
  285. package/src/utils/block-bindings.js +0 -157
  286. package/src/utils/index.js +0 -1
  287. package/tsconfig.json +2 -0
  288. package/build/components/block-toolbar/block-name-context.js +0 -30
  289. package/build/components/block-toolbar/block-name-context.js.map +0 -7
  290. package/build/components/content-only-controls/plain-text/index.js +0 -68
  291. package/build/components/content-only-controls/plain-text/index.js.map +0 -7
  292. package/build-module/components/block-toolbar/block-name-context.js +0 -9
  293. package/build-module/components/block-toolbar/block-name-context.js.map +0 -7
  294. package/build-module/components/content-only-controls/plain-text/index.js +0 -50
  295. package/build-module/components/content-only-controls/plain-text/index.js.map +0 -7
  296. package/src/components/block-toolbar/block-name-context.js +0 -9
  297. package/src/components/content-only-controls/plain-text/index.js +0 -49
  298. package/src/components/font-family/style.scss +0 -7
  299. /package/src/components/alignment-control/stories/{aliginment-toolbar.story.js → aliginment-toolbar.story.jsx} +0 -0
  300. /package/src/components/alignment-control/stories/{index.story.js → index.story.jsx} +0 -0
  301. /package/src/components/block-alignment-matrix-control/stories/{index.story.js → index.story.jsx} +0 -0
  302. /package/src/{utils → components/block-bindings}/test/use-block-bindings-utils.js +0 -0
  303. /package/src/components/block-draggable/stories/{index.story.js → index.story.jsx} +0 -0
  304. /package/src/components/block-heading-level-dropdown/stories/{index.story.js → index.story.jsx} +0 -0
  305. /package/src/components/block-mover/stories/{index.story.js → index.story.jsx} +0 -0
  306. /package/src/components/block-title/stories/{index.story.js → index.story.jsx} +0 -0
  307. /package/src/components/border-radius-control/stories/{index.story.js → index.story.jsx} +0 -0
  308. /package/src/components/date-format-picker/stories/{index.story.js → index.story.jsx} +0 -0
  309. /package/src/components/dimensions-tool/stories/{aspect-ratio-tool.story.js → aspect-ratio-tool.story.jsx} +0 -0
  310. /package/src/components/dimensions-tool/stories/{index.story.js → index.story.jsx} +0 -0
  311. /package/src/components/dimensions-tool/stories/{scale-tool.story.js → scale-tool.story.jsx} +0 -0
  312. /package/src/components/dimensions-tool/stories/{width-height-tool.story.js → width-height-tool.story.jsx} +0 -0
  313. /package/src/components/height-control/stories/{index.story.js → index.story.jsx} +0 -0
  314. /package/src/components/inserter/stories/{index.story.js → index.story.jsx} +0 -0
  315. /package/src/components/line-height-control/stories/{index.story.js → index.story.jsx} +0 -0
  316. /package/src/components/plain-text/stories/{index.story.js → index.story.jsx} +0 -0
  317. /package/src/components/resolution-tool/stories/{index.story.js → index.story.jsx} +0 -0
  318. /package/src/components/tabbed-sidebar/stories/{index.story.js → index.story.jsx} +0 -0
  319. /package/src/components/text-alignment-control/stories/{index.story.js → index.story.jsx} +0 -0
  320. /package/src/components/text-decoration-control/stories/{index.story.js → index.story.jsx} +0 -0
  321. /package/src/components/text-transform-control/stories/{index.story.js → index.story.jsx} +0 -0
  322. /package/src/components/unit-control/stories/{index.story.js → index.story.jsx} +0 -0
  323. /package/src/components/url-popover/stories/{index.story.js → index.story.jsx} +0 -0
  324. /package/src/components/warning/stories/{index.story.js → index.story.jsx} +0 -0
  325. /package/src/components/writing-mode-control/stories/{index.story.js → index.story.jsx} +0 -0
@@ -1,12 +1,6 @@
1
1
  // packages/block-editor/src/utils/block-bindings.js
2
- import { useDispatch, useRegistry } from "@wordpress/data";
3
- import { store as blockEditorStore } from "../store";
4
- import { useBlockEditContext } from "../components/block-edit";
5
2
  var DEFAULT_ATTRIBUTE = "__default";
6
3
  var PATTERN_OVERRIDES_SOURCE = "core/pattern-overrides";
7
- function isObjectEmpty(object) {
8
- return !object || Object.keys(object).length === 0;
9
- }
10
4
  function hasPatternOverridesDefaultBinding(bindings) {
11
5
  return bindings?.[DEFAULT_ATTRIBUTE]?.source === PATTERN_OVERRIDES_SOURCE;
12
6
  }
@@ -21,43 +15,8 @@ function replacePatternOverridesDefaultBinding(bindings, supportedAttributes) {
21
15
  }
22
16
  return bindings;
23
17
  }
24
- function useBlockBindingsUtils(clientId) {
25
- const { clientId: contextClientId } = useBlockEditContext();
26
- const blockClientId = clientId || contextClientId;
27
- const { updateBlockAttributes } = useDispatch(blockEditorStore);
28
- const { getBlockAttributes } = useRegistry().select(blockEditorStore);
29
- const updateBlockBindings = (bindings) => {
30
- const { metadata: { bindings: currentBindings, ...metadata } = {} } = getBlockAttributes(blockClientId);
31
- const newBindings = { ...currentBindings };
32
- Object.entries(bindings).forEach(([attribute, binding]) => {
33
- if (!binding && newBindings[attribute]) {
34
- delete newBindings[attribute];
35
- return;
36
- }
37
- newBindings[attribute] = binding;
38
- });
39
- const newMetadata = {
40
- ...metadata,
41
- bindings: newBindings
42
- };
43
- if (isObjectEmpty(newMetadata.bindings)) {
44
- delete newMetadata.bindings;
45
- }
46
- updateBlockAttributes(blockClientId, {
47
- metadata: isObjectEmpty(newMetadata) ? void 0 : newMetadata
48
- });
49
- };
50
- const removeAllBlockBindings = () => {
51
- const { metadata: { bindings, ...metadata } = {} } = getBlockAttributes(blockClientId);
52
- updateBlockAttributes(blockClientId, {
53
- metadata: isObjectEmpty(metadata) ? void 0 : metadata
54
- });
55
- };
56
- return { updateBlockBindings, removeAllBlockBindings };
57
- }
58
18
  export {
59
19
  hasPatternOverridesDefaultBinding,
60
- replacePatternOverridesDefaultBinding,
61
- useBlockBindingsUtils
20
+ replacePatternOverridesDefaultBinding
62
21
  };
63
22
  //# sourceMappingURL=block-bindings.js.map
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../src/utils/block-bindings.js"],
4
- "sourcesContent": ["/**\n * WordPress dependencies\n */\nimport { useDispatch, useRegistry } from '@wordpress/data';\n\n/**\n * Internal dependencies\n */\nimport { store as blockEditorStore } from '../store';\nimport { useBlockEditContext } from '../components/block-edit';\n\nconst DEFAULT_ATTRIBUTE = '__default';\nconst PATTERN_OVERRIDES_SOURCE = 'core/pattern-overrides';\n\n/**\n * Checks if the given object is empty.\n *\n * @param {?Object} object The object to check.\n *\n * @return {boolean} Whether the object is empty.\n */\nfunction isObjectEmpty( object ) {\n\treturn ! object || Object.keys( object ).length === 0;\n}\n\n/**\n * Checks if the block has the `__default` binding for pattern overrides.\n *\n * @param {?Record<string, object>} bindings A block's bindings from the metadata attribute.\n *\n * @return {boolean} Whether the block has the `__default` binding for pattern overrides.\n */\nexport function hasPatternOverridesDefaultBinding( bindings ) {\n\treturn bindings?.[ DEFAULT_ATTRIBUTE ]?.source === PATTERN_OVERRIDES_SOURCE;\n}\n\n/**\n * Returns the bindings with the `__default` binding for pattern overrides\n * replaced with the full-set of supported attributes. e.g.:\n *\n * - bindings passed in: `{ __default: { source: 'core/pattern-overrides' } }`\n * - bindings returned: `{ content: { source: 'core/pattern-overrides' } }`\n *\n * @param {?Record<string, object>} bindings A block's bindings from the metadata attribute.\n * @param {string[]} supportedAttributes The block's attributes which are supported by block bindings.\n *\n * @return {Object} The bindings with default replaced for pattern overrides.\n */\nexport function replacePatternOverridesDefaultBinding(\n\tbindings,\n\tsupportedAttributes\n) {\n\t// The `__default` binding currently only works for pattern overrides.\n\tif ( hasPatternOverridesDefaultBinding( bindings ) ) {\n\t\tconst bindingsWithDefaults = {};\n\t\tfor ( const attributeName of supportedAttributes ) {\n\t\t\t// If the block has mixed binding sources, retain any non pattern override bindings.\n\t\t\tconst bindingSource = bindings[ attributeName ]\n\t\t\t\t? bindings[ attributeName ]\n\t\t\t\t: { source: PATTERN_OVERRIDES_SOURCE };\n\t\t\tbindingsWithDefaults[ attributeName ] = bindingSource;\n\t\t}\n\n\t\treturn bindingsWithDefaults;\n\t}\n\n\treturn bindings;\n}\n\n/**\n * Contains utils to update the block `bindings` metadata.\n *\n * @typedef {Object} WPBlockBindingsUtils\n *\n * @property {Function} updateBlockBindings Updates the value of the bindings connected to block attributes.\n * @property {Function} removeAllBlockBindings Removes the bindings property of the `metadata` attribute.\n */\n\n/**\n * Retrieves the existing utils needed to update the block `bindings` metadata.\n * They can be used to create, modify, or remove connections from the existing block attributes.\n *\n * It contains the following utils:\n * - `updateBlockBindings`: Updates the value of the bindings connected to block attributes. It can be used to remove a specific binding by setting the value to `undefined`.\n * - `removeAllBlockBindings`: Removes the bindings property of the `metadata` attribute.\n *\n * @since 6.7.0 Introduced in WordPress core.\n *\n * @param {?string} clientId Optional block client ID. If not set, it will use the current block client ID from the context.\n *\n * @return {?WPBlockBindingsUtils} Object containing the block bindings utils.\n *\n * @example\n * ```js\n * import { useBlockBindingsUtils } from '@wordpress/block-editor'\n * const { updateBlockBindings, removeAllBlockBindings } = useBlockBindingsUtils();\n *\n * // Update url and alt attributes.\n * updateBlockBindings( {\n * url: {\n * source: 'core/post-meta',\n * args: {\n * key: 'url_custom_field',\n * },\n * },\n * alt: {\n * source: 'core/post-meta',\n * args: {\n * key: 'text_custom_field',\n * },\n * },\n * } );\n *\n * // Remove binding from url attribute.\n * updateBlockBindings( { url: undefined } );\n *\n * // Remove bindings from all attributes.\n * removeAllBlockBindings();\n * ```\n */\nexport function useBlockBindingsUtils( clientId ) {\n\tconst { clientId: contextClientId } = useBlockEditContext();\n\tconst blockClientId = clientId || contextClientId;\n\tconst { updateBlockAttributes } = useDispatch( blockEditorStore );\n\tconst { getBlockAttributes } = useRegistry().select( blockEditorStore );\n\n\t/**\n\t * Updates the value of the bindings connected to block attributes.\n\t * It removes the binding when the new value is `undefined`.\n\t *\n\t * @param {Object} bindings Bindings including the attributes to update and the new object.\n\t * @param {string} bindings.source The source name to connect to.\n\t * @param {Object} [bindings.args] Object containing the arguments needed by the source.\n\t *\n\t * @example\n\t * ```js\n\t * import { useBlockBindingsUtils } from '@wordpress/block-editor'\n\t *\n\t * const { updateBlockBindings } = useBlockBindingsUtils();\n\t * updateBlockBindings( {\n\t * url: {\n\t * source: 'core/post-meta',\n\t * args: {\n\t * key: 'url_custom_field',\n\t * },\n\t * \t },\n\t * alt: {\n\t * source: 'core/post-meta',\n\t * args: {\n\t * key: 'text_custom_field',\n\t * },\n\t * \t }\n\t * } );\n\t * ```\n\t */\n\tconst updateBlockBindings = ( bindings ) => {\n\t\tconst { metadata: { bindings: currentBindings, ...metadata } = {} } =\n\t\t\tgetBlockAttributes( blockClientId );\n\t\tconst newBindings = { ...currentBindings };\n\n\t\tObject.entries( bindings ).forEach( ( [ attribute, binding ] ) => {\n\t\t\tif ( ! binding && newBindings[ attribute ] ) {\n\t\t\t\tdelete newBindings[ attribute ];\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tnewBindings[ attribute ] = binding;\n\t\t} );\n\n\t\tconst newMetadata = {\n\t\t\t...metadata,\n\t\t\tbindings: newBindings,\n\t\t};\n\n\t\tif ( isObjectEmpty( newMetadata.bindings ) ) {\n\t\t\tdelete newMetadata.bindings;\n\t\t}\n\n\t\tupdateBlockAttributes( blockClientId, {\n\t\t\tmetadata: isObjectEmpty( newMetadata ) ? undefined : newMetadata,\n\t\t} );\n\t};\n\n\t/**\n\t * Removes the bindings property of the `metadata` attribute.\n\t *\n\t * @example\n\t * ```js\n\t * import { useBlockBindingsUtils } from '@wordpress/block-editor'\n\t *\n\t * const { removeAllBlockBindings } = useBlockBindingsUtils();\n\t * removeAllBlockBindings();\n\t * ```\n\t */\n\tconst removeAllBlockBindings = () => {\n\t\tconst { metadata: { bindings, ...metadata } = {} } =\n\t\t\tgetBlockAttributes( blockClientId );\n\t\tupdateBlockAttributes( blockClientId, {\n\t\t\tmetadata: isObjectEmpty( metadata ) ? undefined : metadata,\n\t\t} );\n\t};\n\n\treturn { updateBlockBindings, removeAllBlockBindings };\n}\n"],
5
- "mappings": ";AAGA,SAAS,aAAa,mBAAmB;AAKzC,SAAS,SAAS,wBAAwB;AAC1C,SAAS,2BAA2B;AAEpC,IAAM,oBAAoB;AAC1B,IAAM,2BAA2B;AASjC,SAAS,cAAe,QAAS;AAChC,SAAO,CAAE,UAAU,OAAO,KAAM,MAAO,EAAE,WAAW;AACrD;AASO,SAAS,kCAAmC,UAAW;AAC7D,SAAO,WAAY,iBAAkB,GAAG,WAAW;AACpD;AAcO,SAAS,sCACf,UACA,qBACC;AAED,MAAK,kCAAmC,QAAS,GAAI;AACpD,UAAM,uBAAuB,CAAC;AAC9B,eAAY,iBAAiB,qBAAsB;AAElD,YAAM,gBAAgB,SAAU,aAAc,IAC3C,SAAU,aAAc,IACxB,EAAE,QAAQ,yBAAyB;AACtC,2BAAsB,aAAc,IAAI;AAAA,IACzC;AAEA,WAAO;AAAA,EACR;AAEA,SAAO;AACR;AAqDO,SAAS,sBAAuB,UAAW;AACjD,QAAM,EAAE,UAAU,gBAAgB,IAAI,oBAAoB;AAC1D,QAAM,gBAAgB,YAAY;AAClC,QAAM,EAAE,sBAAsB,IAAI,YAAa,gBAAiB;AAChE,QAAM,EAAE,mBAAmB,IAAI,YAAY,EAAE,OAAQ,gBAAiB;AA+BtE,QAAM,sBAAsB,CAAE,aAAc;AAC3C,UAAM,EAAE,UAAU,EAAE,UAAU,iBAAiB,GAAG,SAAS,IAAI,CAAC,EAAE,IACjE,mBAAoB,aAAc;AACnC,UAAM,cAAc,EAAE,GAAG,gBAAgB;AAEzC,WAAO,QAAS,QAAS,EAAE,QAAS,CAAE,CAAE,WAAW,OAAQ,MAAO;AACjE,UAAK,CAAE,WAAW,YAAa,SAAU,GAAI;AAC5C,eAAO,YAAa,SAAU;AAC9B;AAAA,MACD;AACA,kBAAa,SAAU,IAAI;AAAA,IAC5B,CAAE;AAEF,UAAM,cAAc;AAAA,MACnB,GAAG;AAAA,MACH,UAAU;AAAA,IACX;AAEA,QAAK,cAAe,YAAY,QAAS,GAAI;AAC5C,aAAO,YAAY;AAAA,IACpB;AAEA,0BAAuB,eAAe;AAAA,MACrC,UAAU,cAAe,WAAY,IAAI,SAAY;AAAA,IACtD,CAAE;AAAA,EACH;AAaA,QAAM,yBAAyB,MAAM;AACpC,UAAM,EAAE,UAAU,EAAE,UAAU,GAAG,SAAS,IAAI,CAAC,EAAE,IAChD,mBAAoB,aAAc;AACnC,0BAAuB,eAAe;AAAA,MACrC,UAAU,cAAe,QAAS,IAAI,SAAY;AAAA,IACnD,CAAE;AAAA,EACH;AAEA,SAAO,EAAE,qBAAqB,uBAAuB;AACtD;",
4
+ "sourcesContent": ["const DEFAULT_ATTRIBUTE = '__default';\nconst PATTERN_OVERRIDES_SOURCE = 'core/pattern-overrides';\n\n/**\n * Checks if the block has the `__default` binding for pattern overrides.\n *\n * @param {?Record<string, object>} bindings A block's bindings from the metadata attribute.\n *\n * @return {boolean} Whether the block has the `__default` binding for pattern overrides.\n */\nexport function hasPatternOverridesDefaultBinding( bindings ) {\n\treturn bindings?.[ DEFAULT_ATTRIBUTE ]?.source === PATTERN_OVERRIDES_SOURCE;\n}\n\n/**\n * Returns the bindings with the `__default` binding for pattern overrides\n * replaced with the full-set of supported attributes. e.g.:\n *\n * - bindings passed in: `{ __default: { source: 'core/pattern-overrides' } }`\n * - bindings returned: `{ content: { source: 'core/pattern-overrides' } }`\n *\n * @param {?Record<string, object>} bindings A block's bindings from the metadata attribute.\n * @param {string[]} supportedAttributes The block's attributes which are supported by block bindings.\n *\n * @return {Object} The bindings with default replaced for pattern overrides.\n */\nexport function replacePatternOverridesDefaultBinding(\n\tbindings,\n\tsupportedAttributes\n) {\n\t// The `__default` binding currently only works for pattern overrides.\n\tif ( hasPatternOverridesDefaultBinding( bindings ) ) {\n\t\tconst bindingsWithDefaults = {};\n\t\tfor ( const attributeName of supportedAttributes ) {\n\t\t\t// If the block has mixed binding sources, retain any non pattern override bindings.\n\t\t\tconst bindingSource = bindings[ attributeName ]\n\t\t\t\t? bindings[ attributeName ]\n\t\t\t\t: { source: PATTERN_OVERRIDES_SOURCE };\n\t\t\tbindingsWithDefaults[ attributeName ] = bindingSource;\n\t\t}\n\n\t\treturn bindingsWithDefaults;\n\t}\n\n\treturn bindings;\n}\n"],
5
+ "mappings": ";AAAA,IAAM,oBAAoB;AAC1B,IAAM,2BAA2B;AAS1B,SAAS,kCAAmC,UAAW;AAC7D,SAAO,WAAY,iBAAkB,GAAG,WAAW;AACpD;AAcO,SAAS,sCACf,UACA,qBACC;AAED,MAAK,kCAAmC,QAAS,GAAI;AACpD,UAAM,uBAAuB,CAAC;AAC9B,eAAY,iBAAiB,qBAAsB;AAElD,YAAM,gBAAgB,SAAU,aAAc,IAC3C,SAAU,aAAc,IACxB,EAAE,QAAQ,yBAAyB;AACtC,2BAAsB,aAAc,IAAI;AAAA,IACzC;AAEA,WAAO;AAAA,EACR;AAEA,SAAO;AACR;",
6
6
  "names": []
7
7
  }
@@ -1,10 +1,8 @@
1
1
  // packages/block-editor/src/utils/index.js
2
2
  import { default as default2 } from "./transform-styles";
3
3
  import { default as default3 } from "./get-px-from-css-unit";
4
- import { useBlockBindingsUtils } from "./block-bindings";
5
4
  export {
6
5
  default3 as getPxFromCssUnit,
7
- default2 as transformStyles,
8
- useBlockBindingsUtils
6
+ default2 as transformStyles
9
7
  };
10
8
  //# sourceMappingURL=index.js.map
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../src/utils/index.js"],
4
- "sourcesContent": ["export { default as transformStyles } from './transform-styles';\nexport { default as getPxFromCssUnit } from './get-px-from-css-unit';\nexport { useBlockBindingsUtils } from './block-bindings';\n"],
5
- "mappings": ";AAAA,SAAoB,WAAXA,gBAAkC;AAC3C,SAAoB,WAAXA,gBAAmC;AAC5C,SAAS,6BAA6B;",
4
+ "sourcesContent": ["export { default as transformStyles } from './transform-styles';\nexport { default as getPxFromCssUnit } from './get-px-from-css-unit';\n"],
5
+ "mappings": ";AAAA,SAAoB,WAAXA,gBAAkC;AAC3C,SAAoB,WAAXA,gBAAmC;",
6
6
  "names": ["default"]
7
7
  }
@@ -279,6 +279,9 @@ _::-webkit-full-page-media, _:future, :root [data-has-multi-selection=true] .blo
279
279
  .block-editor-block-list__layout .block-editor-block-list__block[draggable=true], .block-editor-block-list__layout .block-editor-block-list__block[data-draggable=true] {
280
280
  cursor: grab;
281
281
  }
282
+ .block-editor-block-list__layout .block-editor-block-list__block.is-multi-selected {
283
+ cursor: default;
284
+ }
282
285
  .block-editor-block-list__layout .block-editor-block-list__block[contenteditable],
283
286
  .block-editor-block-list__layout .block-editor-block-list__block [contenteditable] {
284
287
  cursor: text;
@@ -279,6 +279,9 @@ _::-webkit-full-page-media, _:future, :root [data-has-multi-selection=true] .blo
279
279
  .block-editor-block-list__layout .block-editor-block-list__block[draggable=true], .block-editor-block-list__layout .block-editor-block-list__block[data-draggable=true] {
280
280
  cursor: grab;
281
281
  }
282
+ .block-editor-block-list__layout .block-editor-block-list__block.is-multi-selected {
283
+ cursor: default;
284
+ }
282
285
  .block-editor-block-list__layout .block-editor-block-list__block[contenteditable],
283
286
  .block-editor-block-list__layout .block-editor-block-list__block [contenteditable] {
284
287
  cursor: text;
@@ -531,6 +531,10 @@ iframe[name=editor-canvas] {
531
531
  right: 50%;
532
532
  }
533
533
 
534
+ .block-editor-block-tools--is-dragging > .popover-slot {
535
+ display: none;
536
+ }
537
+
534
538
  .block-editor-block-lock-modal {
535
539
  z-index: 1000001;
536
540
  }
@@ -1735,7 +1739,7 @@ block-editor-content-only-controls__media-thumbnail {
1735
1739
  }
1736
1740
 
1737
1741
  .block-editor-content-only-controls__screen.components-navigator-screen {
1738
- padding: 8px 0 0 0;
1742
+ padding: 8px 0 16px 0;
1739
1743
  }
1740
1744
  .block-editor-content-only-controls__screen {
1741
1745
  border-top: 1px solid #e0e0e0;
@@ -1755,6 +1759,15 @@ block-editor-content-only-controls__media-thumbnail {
1755
1759
  width: 100%;
1756
1760
  }
1757
1761
 
1762
+ .block-editor-content-only-controls__fields-container {
1763
+ padding: 0 16px;
1764
+ }
1765
+
1766
+ .block-editor-content-only-controls__fields-header {
1767
+ padding: 8px 0;
1768
+ margin-bottom: 4px;
1769
+ }
1770
+
1758
1771
  .block-editor-date-format-picker {
1759
1772
  margin: 0 0 16px;
1760
1773
  padding: 0;
@@ -1788,10 +1801,6 @@ block-editor-content-only-controls__media-thumbnail {
1788
1801
  text-transform: capitalize;
1789
1802
  }
1790
1803
 
1791
- .block-editor-font-family-control:not(.is-next-has-no-margin-bottom) {
1792
- margin-bottom: 8px;
1793
- }
1794
-
1795
1804
  .block-editor-global-styles__toggle-icon {
1796
1805
  fill: currentColor;
1797
1806
  }
@@ -3773,15 +3782,15 @@ div.block-editor-bindings__panel button:hover .block-editor-bindings__item span
3773
3782
  content: attr(aria-label);
3774
3783
  font-size: 12px;
3775
3784
  }
3776
- .show-icon-labels .components-accessible-toolbar .components-toolbar-group > div:first-child:last-child > .components-button.has-icon {
3777
- padding-right: 6px;
3778
- padding-left: 6px;
3779
- }
3780
- .show-icon-labels .block-editor-block-icon {
3785
+ .show-icon-labels .block-editor-block-toolbar .block-editor-block-icon {
3781
3786
  width: 0 !important;
3782
3787
  height: 0 !important;
3783
3788
  min-width: 0 !important;
3784
3789
  }
3790
+ .show-icon-labels .components-accessible-toolbar .components-toolbar-group > div:first-child:last-child > .components-button.has-icon {
3791
+ padding-right: 6px;
3792
+ padding-left: 6px;
3793
+ }
3785
3794
  .show-icon-labels .block-editor-block-parent-selector .block-editor-block-parent-selector__button {
3786
3795
  border-top-left-radius: 0;
3787
3796
  border-bottom-left-radius: 0;
@@ -4210,7 +4219,7 @@ div.block-editor-bindings__panel button:hover .block-editor-bindings__item span
4210
4219
  right: 0;
4211
4220
  bottom: 0;
4212
4221
  width: 280px;
4213
- padding: 24px 32px 32px;
4222
+ padding: 24px 24px 24px;
4214
4223
  overflow-x: visible;
4215
4224
  overflow-y: auto;
4216
4225
  }
@@ -531,6 +531,10 @@ iframe[name=editor-canvas] {
531
531
  left: 50%;
532
532
  }
533
533
 
534
+ .block-editor-block-tools--is-dragging > .popover-slot {
535
+ display: none;
536
+ }
537
+
534
538
  .block-editor-block-lock-modal {
535
539
  z-index: 1000001;
536
540
  }
@@ -1735,7 +1739,7 @@ block-editor-content-only-controls__media-thumbnail {
1735
1739
  }
1736
1740
 
1737
1741
  .block-editor-content-only-controls__screen.components-navigator-screen {
1738
- padding: 8px 0 0 0;
1742
+ padding: 8px 0 16px 0;
1739
1743
  }
1740
1744
  .block-editor-content-only-controls__screen {
1741
1745
  border-top: 1px solid #e0e0e0;
@@ -1755,6 +1759,15 @@ block-editor-content-only-controls__media-thumbnail {
1755
1759
  width: 100%;
1756
1760
  }
1757
1761
 
1762
+ .block-editor-content-only-controls__fields-container {
1763
+ padding: 0 16px;
1764
+ }
1765
+
1766
+ .block-editor-content-only-controls__fields-header {
1767
+ padding: 8px 0;
1768
+ margin-bottom: 4px;
1769
+ }
1770
+
1758
1771
  .block-editor-date-format-picker {
1759
1772
  margin: 0 0 16px;
1760
1773
  padding: 0;
@@ -1788,10 +1801,6 @@ block-editor-content-only-controls__media-thumbnail {
1788
1801
  text-transform: capitalize;
1789
1802
  }
1790
1803
 
1791
- .block-editor-font-family-control:not(.is-next-has-no-margin-bottom) {
1792
- margin-bottom: 8px;
1793
- }
1794
-
1795
1804
  .block-editor-global-styles__toggle-icon {
1796
1805
  fill: currentColor;
1797
1806
  }
@@ -3775,15 +3784,15 @@ div.block-editor-bindings__panel button:hover .block-editor-bindings__item span
3775
3784
  content: attr(aria-label);
3776
3785
  font-size: 12px;
3777
3786
  }
3778
- .show-icon-labels .components-accessible-toolbar .components-toolbar-group > div:first-child:last-child > .components-button.has-icon {
3779
- padding-left: 6px;
3780
- padding-right: 6px;
3781
- }
3782
- .show-icon-labels .block-editor-block-icon {
3787
+ .show-icon-labels .block-editor-block-toolbar .block-editor-block-icon {
3783
3788
  width: 0 !important;
3784
3789
  height: 0 !important;
3785
3790
  min-width: 0 !important;
3786
3791
  }
3792
+ .show-icon-labels .components-accessible-toolbar .components-toolbar-group > div:first-child:last-child > .components-button.has-icon {
3793
+ padding-left: 6px;
3794
+ padding-right: 6px;
3795
+ }
3787
3796
  .show-icon-labels .block-editor-block-parent-selector .block-editor-block-parent-selector__button {
3788
3797
  border-top-right-radius: 0;
3789
3798
  border-bottom-right-radius: 0;
@@ -4212,7 +4221,7 @@ div.block-editor-bindings__panel button:hover .block-editor-bindings__item span
4212
4221
  left: 0;
4213
4222
  bottom: 0;
4214
4223
  width: 280px;
4215
- padding: 24px 32px 32px;
4224
+ padding: 24px 24px 24px;
4216
4225
  overflow-x: visible;
4217
4226
  overflow-y: auto;
4218
4227
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@wordpress/block-editor",
3
- "version": "15.8.1-next.dc3f6d3c1.0",
3
+ "version": "15.9.1-next.6deb34194.0",
4
4
  "description": "Generic block editor.",
5
5
  "author": "The WordPress Contributors",
6
6
  "license": "GPL-2.0-or-later",
@@ -52,44 +52,44 @@
52
52
  "build-module/hooks/**"
53
53
  ],
54
54
  "dependencies": {
55
- "@emotion/react": "^11.7.1",
56
- "@emotion/styled": "^11.6.0",
57
55
  "@react-spring/web": "^9.4.5",
58
- "@wordpress/a11y": "^4.35.1-next.dc3f6d3c1.0",
59
- "@wordpress/api-fetch": "^7.35.1-next.dc3f6d3c1.0",
60
- "@wordpress/base-styles": "^6.11.1-next.dc3f6d3c1.0",
61
- "@wordpress/blob": "^4.35.1-next.dc3f6d3c1.0",
62
- "@wordpress/block-serialization-default-parser": "^5.35.1-next.dc3f6d3c1.0",
63
- "@wordpress/blocks": "^15.8.1-next.dc3f6d3c1.0",
64
- "@wordpress/commands": "^1.35.1-next.dc3f6d3c1.0",
65
- "@wordpress/components": "^30.8.2-next.dc3f6d3c1.0",
66
- "@wordpress/compose": "^7.35.1-next.dc3f6d3c1.0",
67
- "@wordpress/data": "^10.35.1-next.dc3f6d3c1.0",
68
- "@wordpress/date": "^5.35.1-next.dc3f6d3c1.0",
69
- "@wordpress/deprecated": "^4.35.1-next.dc3f6d3c1.0",
70
- "@wordpress/dom": "^4.35.1-next.dc3f6d3c1.0",
71
- "@wordpress/element": "^6.35.1-next.dc3f6d3c1.0",
72
- "@wordpress/escape-html": "^3.35.1-next.dc3f6d3c1.0",
73
- "@wordpress/global-styles-engine": "^1.2.1-next.dc3f6d3c1.0",
74
- "@wordpress/hooks": "^4.35.1-next.dc3f6d3c1.0",
75
- "@wordpress/html-entities": "^4.35.1-next.dc3f6d3c1.0",
76
- "@wordpress/i18n": "^6.8.1-next.dc3f6d3c1.0",
77
- "@wordpress/icons": "^11.2.1-next.dc3f6d3c1.0",
78
- "@wordpress/interactivity": "^6.35.1-next.dc3f6d3c1.0",
79
- "@wordpress/is-shallow-equal": "^5.35.1-next.dc3f6d3c1.0",
80
- "@wordpress/keyboard-shortcuts": "^5.35.1-next.dc3f6d3c1.0",
81
- "@wordpress/keycodes": "^4.35.1-next.dc3f6d3c1.0",
82
- "@wordpress/notices": "^5.35.1-next.dc3f6d3c1.0",
83
- "@wordpress/preferences": "^4.35.1-next.dc3f6d3c1.0",
84
- "@wordpress/priority-queue": "^3.35.1-next.dc3f6d3c1.0",
85
- "@wordpress/private-apis": "^1.35.1-next.dc3f6d3c1.0",
86
- "@wordpress/rich-text": "^7.35.1-next.dc3f6d3c1.0",
87
- "@wordpress/style-engine": "^2.35.1-next.dc3f6d3c1.0",
88
- "@wordpress/token-list": "^3.35.1-next.dc3f6d3c1.0",
89
- "@wordpress/upload-media": "^0.20.1-next.dc3f6d3c1.0",
90
- "@wordpress/url": "^4.35.1-next.dc3f6d3c1.0",
91
- "@wordpress/warning": "^3.35.1-next.dc3f6d3c1.0",
92
- "@wordpress/wordcount": "^4.35.1-next.dc3f6d3c1.0",
56
+ "@wordpress/a11y": "^4.36.1-next.6deb34194.0",
57
+ "@wordpress/api-fetch": "^7.36.1-next.6deb34194.0",
58
+ "@wordpress/base-styles": "^6.12.1-next.6deb34194.0",
59
+ "@wordpress/blob": "^4.36.1-next.6deb34194.0",
60
+ "@wordpress/block-serialization-default-parser": "^5.36.1-next.6deb34194.0",
61
+ "@wordpress/blocks": "^15.9.1-next.6deb34194.0",
62
+ "@wordpress/commands": "^1.36.1-next.6deb34194.0",
63
+ "@wordpress/components": "^31.0.1-next.6deb34194.0",
64
+ "@wordpress/compose": "^7.36.1-next.6deb34194.0",
65
+ "@wordpress/data": "^10.36.1-next.6deb34194.0",
66
+ "@wordpress/dataviews": "^11.1.1-next.6deb34194.0",
67
+ "@wordpress/date": "^5.36.1-next.6deb34194.0",
68
+ "@wordpress/deprecated": "^4.36.1-next.6deb34194.0",
69
+ "@wordpress/dom": "^4.36.1-next.6deb34194.0",
70
+ "@wordpress/element": "^6.36.1-next.6deb34194.0",
71
+ "@wordpress/escape-html": "^3.36.1-next.6deb34194.0",
72
+ "@wordpress/global-styles-engine": "^1.3.1-next.6deb34194.0",
73
+ "@wordpress/hooks": "^4.36.1-next.6deb34194.0",
74
+ "@wordpress/html-entities": "^4.36.1-next.6deb34194.0",
75
+ "@wordpress/i18n": "^6.9.1-next.6deb34194.0",
76
+ "@wordpress/icons": "^11.3.1-next.6deb34194.0",
77
+ "@wordpress/image-cropper": "^1.0.1-next.6deb34194.0",
78
+ "@wordpress/interactivity": "^6.36.1-next.6deb34194.0",
79
+ "@wordpress/is-shallow-equal": "^5.36.1-next.6deb34194.0",
80
+ "@wordpress/keyboard-shortcuts": "^5.36.1-next.6deb34194.0",
81
+ "@wordpress/keycodes": "^4.36.1-next.6deb34194.0",
82
+ "@wordpress/notices": "^5.36.1-next.6deb34194.0",
83
+ "@wordpress/preferences": "^4.36.1-next.6deb34194.0",
84
+ "@wordpress/priority-queue": "^3.36.1-next.6deb34194.0",
85
+ "@wordpress/private-apis": "^1.36.1-next.6deb34194.0",
86
+ "@wordpress/rich-text": "^7.36.1-next.6deb34194.0",
87
+ "@wordpress/style-engine": "^2.36.1-next.6deb34194.0",
88
+ "@wordpress/token-list": "^3.36.1-next.6deb34194.0",
89
+ "@wordpress/upload-media": "^0.21.1-next.6deb34194.0",
90
+ "@wordpress/url": "^4.36.1-next.6deb34194.0",
91
+ "@wordpress/warning": "^3.36.1-next.6deb34194.0",
92
+ "@wordpress/wordcount": "^4.36.1-next.6deb34194.0",
93
93
  "change-case": "^4.1.2",
94
94
  "clsx": "^2.1.1",
95
95
  "colord": "^2.7.0",
@@ -112,5 +112,5 @@
112
112
  "publishConfig": {
113
113
  "access": "public"
114
114
  },
115
- "gitHead": "f73b5e69b34fbaccfb8c47783f4f993059ff1a41"
115
+ "gitHead": "457096e9e9b3896d2d4fe54fc19d7fb571ee9a44"
116
116
  }
@@ -77,11 +77,7 @@ function BlockAlignmentMatrixControl( props ) {
77
77
  );
78
78
  } }
79
79
  renderContent={ () => (
80
- <AlignmentMatrixControl
81
- hasFocusBorder={ false }
82
- onChange={ onChange }
83
- value={ value }
84
- />
80
+ <AlignmentMatrixControl onChange={ onChange } value={ value } />
85
81
  ) }
86
82
  />
87
83
  );
@@ -0,0 +1,174 @@
1
+ /**
2
+ * External dependencies
3
+ */
4
+ import fastDeepEqual from 'fast-deep-equal/es6';
5
+
6
+ /**
7
+ * WordPress dependencies
8
+ */
9
+ import { __ } from '@wordpress/i18n';
10
+ import {
11
+ getBlockBindingsSource,
12
+ store as blocksStore,
13
+ } from '@wordpress/blocks';
14
+ import {
15
+ __experimentalItem as Item,
16
+ __experimentalText as Text,
17
+ __experimentalToolsPanelItem as ToolsPanelItem,
18
+ __experimentalVStack as VStack,
19
+ privateApis as componentsPrivateApis,
20
+ } from '@wordpress/components';
21
+ import { useSelect } from '@wordpress/data';
22
+ import { useContext } from '@wordpress/element';
23
+ import { useViewportMatch } from '@wordpress/compose';
24
+
25
+ /**
26
+ * Internal dependencies
27
+ */
28
+ import BlockContext from '../block-context';
29
+ import BlockBindingsSourceFieldsList from './source-fields-list';
30
+ import useBlockBindingsUtils from './use-block-bindings-utils';
31
+ import { unlock } from '../../lock-unlock';
32
+ import { store as blockEditorStore } from '../../store';
33
+
34
+ const { Menu } = unlock( componentsPrivateApis );
35
+
36
+ export default function BlockBindingsAttributeControl( {
37
+ attribute,
38
+ binding,
39
+ blockName,
40
+ } ) {
41
+ const { updateBlockBindings } = useBlockBindingsUtils();
42
+ const isMobile = useViewportMatch( 'medium', '<' );
43
+
44
+ const blockContext = useContext( BlockContext );
45
+ const compatibleFields = useSelect(
46
+ ( select ) => {
47
+ const {
48
+ getAllBlockBindingsSources,
49
+ getBlockBindingsSourceFieldsList,
50
+ getBlockType,
51
+ } = unlock( select( blocksStore ) );
52
+
53
+ const _attributeType =
54
+ getBlockType( blockName ).attributes?.[ attribute ]?.type;
55
+ const attributeType =
56
+ _attributeType === 'rich-text' ? 'string' : _attributeType;
57
+
58
+ const sourceFields = {};
59
+ Object.entries( getAllBlockBindingsSources() ).forEach(
60
+ ( [ sourceName, source ] ) => {
61
+ const fieldsList = getBlockBindingsSourceFieldsList(
62
+ source,
63
+ blockContext
64
+ );
65
+ if ( ! fieldsList?.length ) {
66
+ return;
67
+ }
68
+ const compatibleFieldsList = fieldsList.filter(
69
+ ( field ) => field.type === attributeType
70
+ );
71
+ if ( compatibleFieldsList.length ) {
72
+ sourceFields[ sourceName ] = compatibleFieldsList;
73
+ }
74
+ }
75
+ );
76
+ return sourceFields;
77
+ },
78
+ [ attribute, blockName, blockContext ]
79
+ );
80
+
81
+ const { canUpdateBlockBindings } = useSelect( ( select ) => ( {
82
+ canUpdateBlockBindings:
83
+ select( blockEditorStore ).getSettings().canUpdateBlockBindings,
84
+ } ) );
85
+
86
+ const hasCompatibleFields = Object.keys( compatibleFields ).length > 0;
87
+
88
+ // Lock the UI when the user can't update bindings or there are no fields to connect to.
89
+ const isAttributeReadOnly =
90
+ ! canUpdateBlockBindings || ! hasCompatibleFields;
91
+
92
+ const { source: boundSourceName, args } = binding || {};
93
+ const source = getBlockBindingsSource( boundSourceName );
94
+
95
+ let displayText;
96
+ let isValid = true;
97
+
98
+ if ( binding === undefined ) {
99
+ if ( ! hasCompatibleFields ) {
100
+ displayText = __( 'No sources available' );
101
+ } else {
102
+ displayText = __( 'Not connected' );
103
+ }
104
+ isValid = true;
105
+ } else if ( ! source ) {
106
+ // If there's a binding but the source is not found, it's invalid.
107
+ isValid = false;
108
+ displayText = __( 'Source not registered' );
109
+ } else {
110
+ displayText =
111
+ compatibleFields?.[ boundSourceName ]?.find( ( field ) =>
112
+ fastDeepEqual( field.args, args )
113
+ )?.label ||
114
+ source?.label ||
115
+ boundSourceName;
116
+ }
117
+
118
+ return (
119
+ <ToolsPanelItem
120
+ hasValue={ () => !! binding }
121
+ label={ attribute }
122
+ onDeselect={
123
+ !! hasCompatibleFields &&
124
+ ( () => {
125
+ updateBlockBindings( {
126
+ [ attribute ]: undefined,
127
+ } );
128
+ } )
129
+ }
130
+ >
131
+ <Menu placement={ isMobile ? 'bottom-start' : 'left-start' }>
132
+ <Menu.TriggerButton
133
+ render={ <Item /> }
134
+ disabled={ ! hasCompatibleFields }
135
+ >
136
+ <VStack
137
+ className="block-editor-bindings__item"
138
+ spacing={ 0 }
139
+ >
140
+ <Text truncate>{ attribute }</Text>
141
+ <Text
142
+ truncate
143
+ variant={ isValid ? 'muted' : undefined }
144
+ isDestructive={ ! isValid }
145
+ >
146
+ { displayText }
147
+ </Text>
148
+ </VStack>
149
+ </Menu.TriggerButton>
150
+ { ! isAttributeReadOnly && (
151
+ <Menu.Popover gutter={ isMobile ? 8 : 36 }>
152
+ <Menu
153
+ placement={
154
+ isMobile ? 'bottom-start' : 'left-start'
155
+ }
156
+ >
157
+ { Object.entries( compatibleFields ).map(
158
+ ( [ sourceKey, fields ] ) => (
159
+ <BlockBindingsSourceFieldsList
160
+ key={ sourceKey }
161
+ args={ binding?.args }
162
+ attribute={ attribute }
163
+ sourceKey={ sourceKey }
164
+ fields={ fields }
165
+ />
166
+ )
167
+ ) }
168
+ </Menu>
169
+ </Menu.Popover>
170
+ ) }
171
+ </Menu>
172
+ </ToolsPanelItem>
173
+ );
174
+ }
@@ -0,0 +1,6 @@
1
+ /**
2
+ * Internal dependencies
3
+ */
4
+ export { default as BlockBindingsAttributeControl } from './attribute-control';
5
+ export { default as BlockBindingsSourceFieldsList } from './source-fields-list';
6
+ export { default as useBlockBindingsUtils } from './use-block-bindings-utils';