@wordpress/block-editor 14.9.0 → 14.10.1

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 (370) hide show
  1. package/CHANGELOG.md +2 -0
  2. package/LICENSE.md +1 -1
  3. package/README.md +40 -0
  4. package/build/components/audio-player/index.native.js +1 -1
  5. package/build/components/audio-player/index.native.js.map +1 -1
  6. package/build/components/background-image-control/index.js +4 -0
  7. package/build/components/background-image-control/index.js.map +1 -1
  8. package/build/components/block-alignment-matrix-control/index.js +32 -0
  9. package/build/components/block-alignment-matrix-control/index.js.map +1 -1
  10. package/build/components/block-card/index.js +45 -8
  11. package/build/components/block-card/index.js.map +1 -1
  12. package/build/components/block-edit/edit.js +147 -10
  13. package/build/components/block-edit/edit.js.map +1 -1
  14. package/build/components/block-list/index.js +1 -2
  15. package/build/components/block-list/index.js.map +1 -1
  16. package/build/components/block-list/use-block-props/index.js +2 -2
  17. package/build/components/block-list/use-block-props/index.js.map +1 -1
  18. package/build/components/block-list/zoom-out-separator.js +20 -3
  19. package/build/components/block-list/zoom-out-separator.js.map +1 -1
  20. package/build/components/block-settings-menu/block-settings-dropdown.js +5 -8
  21. package/build/components/block-settings-menu/block-settings-dropdown.js.map +1 -1
  22. package/build/components/block-styles/utils.js +3 -3
  23. package/build/components/block-styles/utils.js.map +1 -1
  24. package/build/components/block-tools/zoom-out-mode-inserters.js +19 -6
  25. package/build/components/block-tools/zoom-out-mode-inserters.js.map +1 -1
  26. package/build/components/button-block-appender/index.js +1 -5
  27. package/build/components/button-block-appender/index.js.map +1 -1
  28. package/build/components/child-layout-control/index.js +6 -0
  29. package/build/components/child-layout-control/index.js.map +1 -1
  30. package/build/components/colors-gradients/dropdown.js +51 -11
  31. package/build/components/colors-gradients/dropdown.js.map +1 -1
  32. package/build/components/contrast-checker/index.native.js +1 -1
  33. package/build/components/contrast-checker/index.native.js.map +1 -1
  34. package/build/components/date-format-picker/index.js +7 -16
  35. package/build/components/date-format-picker/index.js.map +1 -1
  36. package/build/components/font-appearance-control/index.js +9 -0
  37. package/build/components/font-appearance-control/index.js.map +1 -1
  38. package/build/components/font-family/index.js +10 -1
  39. package/build/components/font-family/index.js.map +1 -1
  40. package/build/components/global-styles/color-panel.js +3 -0
  41. package/build/components/global-styles/color-panel.js.map +1 -1
  42. package/build/components/global-styles/typography-utils.js +1 -1
  43. package/build/components/global-styles/typography-utils.js.map +1 -1
  44. package/build/components/global-styles/use-global-styles-output.js +2 -2
  45. package/build/components/global-styles/use-global-styles-output.js.map +1 -1
  46. package/build/components/grid/grid-visualizer.js +9 -0
  47. package/build/components/grid/grid-visualizer.js.map +1 -1
  48. package/build/components/grid/utils.js +12 -1
  49. package/build/components/grid/utils.js.map +1 -1
  50. package/build/components/iframe/index.js +1 -1
  51. package/build/components/iframe/index.js.map +1 -1
  52. package/build/components/inner-blocks/use-inner-block-template-sync.js +11 -11
  53. package/build/components/inner-blocks/use-inner-block-template-sync.js.map +1 -1
  54. package/build/components/inserter/block-patterns-explorer/index.js +1 -1
  55. package/build/components/inserter/block-patterns-explorer/index.js.map +1 -1
  56. package/build/components/inserter/block-patterns-tab/index.js +1 -1
  57. package/build/components/inserter/block-patterns-tab/index.js.map +1 -1
  58. package/build/components/inserter/block-patterns-tab/pattern-category-previews.js +4 -4
  59. package/build/components/inserter/block-patterns-tab/pattern-category-previews.js.map +1 -1
  60. package/build/components/inserter/block-patterns-tab/patterns-filter.js +2 -2
  61. package/build/components/inserter/block-patterns-tab/patterns-filter.js.map +1 -1
  62. package/build/components/inserter/category-tabs/index.js +1 -2
  63. package/build/components/inserter/category-tabs/index.js.map +1 -1
  64. package/build/components/inserter/index.js +6 -15
  65. package/build/components/inserter/index.js.map +1 -1
  66. package/build/components/inserter/quick-inserter.js +2 -13
  67. package/build/components/inserter/quick-inserter.js.map +1 -1
  68. package/build/components/keyboard-shortcuts/index.js +2 -2
  69. package/build/components/keyboard-shortcuts/index.js.map +1 -1
  70. package/build/components/line-height-control/index.js +9 -0
  71. package/build/components/line-height-control/index.js.map +1 -1
  72. package/build/components/media-placeholder/index.js +2 -2
  73. package/build/components/media-placeholder/index.js.map +1 -1
  74. package/build/components/media-replace-flow/index.js +26 -26
  75. package/build/components/media-replace-flow/index.js.map +1 -1
  76. package/build/components/plain-text/index.js +34 -0
  77. package/build/components/plain-text/index.js.map +1 -1
  78. package/build/components/provider/index.js +61 -5
  79. package/build/components/provider/index.js.map +1 -1
  80. package/build/components/provider/use-media-upload-settings.js +28 -0
  81. package/build/components/provider/use-media-upload-settings.js.map +1 -0
  82. package/build/components/resolution-tool/index.js +3 -1
  83. package/build/components/resolution-tool/index.js.map +1 -1
  84. package/build/components/responsive-block-control/index.js +1 -1
  85. package/build/components/responsive-block-control/index.js.map +1 -1
  86. package/build/components/rich-text/event-listeners/delete.js +7 -1
  87. package/build/components/rich-text/event-listeners/delete.js.map +1 -1
  88. package/build/components/rich-text/index.js +2 -2
  89. package/build/components/rich-text/index.js.map +1 -1
  90. package/build/components/use-block-drop-zone/index.js +2 -1
  91. package/build/components/use-block-drop-zone/index.js.map +1 -1
  92. package/build/hooks/background.js +2 -0
  93. package/build/hooks/background.js.map +1 -1
  94. package/build/hooks/block-bindings.js +15 -14
  95. package/build/hooks/block-bindings.js.map +1 -1
  96. package/build/hooks/border.js +3 -3
  97. package/build/hooks/border.js.map +1 -1
  98. package/build/hooks/color.js +1 -1
  99. package/build/hooks/color.js.map +1 -1
  100. package/build/hooks/dimensions.js +2 -2
  101. package/build/hooks/dimensions.js.map +1 -1
  102. package/build/hooks/font-family.js +1 -1
  103. package/build/hooks/font-family.js.map +1 -1
  104. package/build/hooks/gap.js +2 -2
  105. package/build/hooks/gap.js.map +1 -1
  106. package/build/hooks/index.js +0 -1
  107. package/build/hooks/index.js.map +1 -1
  108. package/build/hooks/index.native.js +7 -0
  109. package/build/hooks/index.native.js.map +1 -1
  110. package/build/hooks/style.js +7 -7
  111. package/build/hooks/style.js.map +1 -1
  112. package/build/hooks/supports.js +7 -7
  113. package/build/hooks/supports.js.map +1 -1
  114. package/build/hooks/typography.js +6 -6
  115. package/build/hooks/typography.js.map +1 -1
  116. package/build/hooks/use-zoom-out.js +12 -1
  117. package/build/hooks/use-zoom-out.js.map +1 -1
  118. package/build/hooks/utils.js +1 -1
  119. package/build/hooks/utils.js.map +1 -1
  120. package/build/store/private-actions.js +1 -1
  121. package/build/store/private-actions.js.map +1 -1
  122. package/build/store/private-selectors.js +11 -1
  123. package/build/store/private-selectors.js.map +1 -1
  124. package/build/store/reducer.js +93 -12
  125. package/build/store/reducer.js.map +1 -1
  126. package/build/store/selectors.js +6 -8
  127. package/build/store/selectors.js.map +1 -1
  128. package/build/utils/block-bindings.js +95 -0
  129. package/build/utils/block-bindings.js.map +1 -1
  130. package/build-module/components/audio-player/index.native.js +2 -2
  131. package/build-module/components/audio-player/index.native.js.map +1 -1
  132. package/build-module/components/background-image-control/index.js +5 -1
  133. package/build-module/components/background-image-control/index.js.map +1 -1
  134. package/build-module/components/block-alignment-matrix-control/index.js +32 -0
  135. package/build-module/components/block-alignment-matrix-control/index.js.map +1 -1
  136. package/build-module/components/block-card/index.js +45 -8
  137. package/build-module/components/block-card/index.js.map +1 -1
  138. package/build-module/components/block-edit/edit.js +148 -11
  139. package/build-module/components/block-edit/edit.js.map +1 -1
  140. package/build-module/components/block-list/index.js +2 -3
  141. package/build-module/components/block-list/index.js.map +1 -1
  142. package/build-module/components/block-list/use-block-props/index.js +1 -1
  143. package/build-module/components/block-list/use-block-props/index.js.map +1 -1
  144. package/build-module/components/block-list/zoom-out-separator.js +20 -3
  145. package/build-module/components/block-list/zoom-out-separator.js.map +1 -1
  146. package/build-module/components/block-settings-menu/block-settings-dropdown.js +5 -8
  147. package/build-module/components/block-settings-menu/block-settings-dropdown.js.map +1 -1
  148. package/build-module/components/block-styles/utils.js +3 -3
  149. package/build-module/components/block-styles/utils.js.map +1 -1
  150. package/build-module/components/block-tools/zoom-out-mode-inserters.js +19 -6
  151. package/build-module/components/block-tools/zoom-out-mode-inserters.js.map +1 -1
  152. package/build-module/components/button-block-appender/index.js +2 -6
  153. package/build-module/components/button-block-appender/index.js.map +1 -1
  154. package/build-module/components/child-layout-control/index.js +7 -1
  155. package/build-module/components/child-layout-control/index.js.map +1 -1
  156. package/build-module/components/colors-gradients/dropdown.js +51 -11
  157. package/build-module/components/colors-gradients/dropdown.js.map +1 -1
  158. package/build-module/components/contrast-checker/index.native.js +2 -2
  159. package/build-module/components/contrast-checker/index.native.js.map +1 -1
  160. package/build-module/components/date-format-picker/index.js +7 -16
  161. package/build-module/components/date-format-picker/index.js.map +1 -1
  162. package/build-module/components/font-appearance-control/index.js +8 -0
  163. package/build-module/components/font-appearance-control/index.js.map +1 -1
  164. package/build-module/components/font-family/index.js +10 -1
  165. package/build-module/components/font-family/index.js.map +1 -1
  166. package/build-module/components/global-styles/color-panel.js +3 -0
  167. package/build-module/components/global-styles/color-panel.js.map +1 -1
  168. package/build-module/components/global-styles/typography-utils.js +1 -1
  169. package/build-module/components/global-styles/typography-utils.js.map +1 -1
  170. package/build-module/components/global-styles/use-global-styles-output.js +2 -2
  171. package/build-module/components/global-styles/use-global-styles-output.js.map +1 -1
  172. package/build-module/components/grid/grid-visualizer.js +9 -0
  173. package/build-module/components/grid/grid-visualizer.js.map +1 -1
  174. package/build-module/components/grid/utils.js +12 -1
  175. package/build-module/components/grid/utils.js.map +1 -1
  176. package/build-module/components/iframe/index.js +1 -1
  177. package/build-module/components/iframe/index.js.map +1 -1
  178. package/build-module/components/inner-blocks/use-inner-block-template-sync.js +12 -12
  179. package/build-module/components/inner-blocks/use-inner-block-template-sync.js.map +1 -1
  180. package/build-module/components/inserter/block-patterns-explorer/index.js +1 -1
  181. package/build-module/components/inserter/block-patterns-explorer/index.js.map +1 -1
  182. package/build-module/components/inserter/block-patterns-tab/index.js +1 -1
  183. package/build-module/components/inserter/block-patterns-tab/index.js.map +1 -1
  184. package/build-module/components/inserter/block-patterns-tab/pattern-category-previews.js +4 -4
  185. package/build-module/components/inserter/block-patterns-tab/pattern-category-previews.js.map +1 -1
  186. package/build-module/components/inserter/block-patterns-tab/patterns-filter.js +2 -2
  187. package/build-module/components/inserter/block-patterns-tab/patterns-filter.js.map +1 -1
  188. package/build-module/components/inserter/category-tabs/index.js +1 -2
  189. package/build-module/components/inserter/category-tabs/index.js.map +1 -1
  190. package/build-module/components/inserter/index.js +6 -15
  191. package/build-module/components/inserter/index.js.map +1 -1
  192. package/build-module/components/inserter/quick-inserter.js +2 -13
  193. package/build-module/components/inserter/quick-inserter.js.map +1 -1
  194. package/build-module/components/keyboard-shortcuts/index.js +2 -2
  195. package/build-module/components/keyboard-shortcuts/index.js.map +1 -1
  196. package/build-module/components/line-height-control/index.js +8 -0
  197. package/build-module/components/line-height-control/index.js.map +1 -1
  198. package/build-module/components/media-placeholder/index.js +3 -3
  199. package/build-module/components/media-placeholder/index.js.map +1 -1
  200. package/build-module/components/media-replace-flow/index.js +28 -28
  201. package/build-module/components/media-replace-flow/index.js.map +1 -1
  202. package/build-module/components/plain-text/index.js +34 -0
  203. package/build-module/components/plain-text/index.js.map +1 -1
  204. package/build-module/components/provider/index.js +62 -5
  205. package/build-module/components/provider/index.js.map +1 -1
  206. package/build-module/components/provider/use-media-upload-settings.js +22 -0
  207. package/build-module/components/provider/use-media-upload-settings.js.map +1 -0
  208. package/build-module/components/resolution-tool/index.js +3 -1
  209. package/build-module/components/resolution-tool/index.js.map +1 -1
  210. package/build-module/components/responsive-block-control/index.js +1 -1
  211. package/build-module/components/responsive-block-control/index.js.map +1 -1
  212. package/build-module/components/rich-text/event-listeners/delete.js +7 -1
  213. package/build-module/components/rich-text/event-listeners/delete.js.map +1 -1
  214. package/build-module/components/rich-text/index.js +1 -1
  215. package/build-module/components/rich-text/index.js.map +1 -1
  216. package/build-module/components/use-block-drop-zone/index.js +2 -1
  217. package/build-module/components/use-block-drop-zone/index.js.map +1 -1
  218. package/build-module/hooks/background.js +2 -0
  219. package/build-module/hooks/background.js.map +1 -1
  220. package/build-module/hooks/block-bindings.js +13 -12
  221. package/build-module/hooks/block-bindings.js.map +1 -1
  222. package/build-module/hooks/border.js +3 -3
  223. package/build-module/hooks/border.js.map +1 -1
  224. package/build-module/hooks/color.js +1 -1
  225. package/build-module/hooks/color.js.map +1 -1
  226. package/build-module/hooks/dimensions.js +2 -2
  227. package/build-module/hooks/dimensions.js.map +1 -1
  228. package/build-module/hooks/font-family.js +1 -1
  229. package/build-module/hooks/font-family.js.map +1 -1
  230. package/build-module/hooks/gap.js +2 -2
  231. package/build-module/hooks/gap.js.map +1 -1
  232. package/build-module/hooks/index.js +0 -1
  233. package/build-module/hooks/index.js.map +1 -1
  234. package/build-module/hooks/index.native.js +1 -0
  235. package/build-module/hooks/index.native.js.map +1 -1
  236. package/build-module/hooks/style.js +7 -7
  237. package/build-module/hooks/style.js.map +1 -1
  238. package/build-module/hooks/supports.js +7 -7
  239. package/build-module/hooks/supports.js.map +1 -1
  240. package/build-module/hooks/typography.js +6 -6
  241. package/build-module/hooks/typography.js.map +1 -1
  242. package/build-module/hooks/use-zoom-out.js +12 -2
  243. package/build-module/hooks/use-zoom-out.js.map +1 -1
  244. package/build-module/hooks/utils.js +1 -1
  245. package/build-module/hooks/utils.js.map +1 -1
  246. package/build-module/store/private-actions.js +1 -1
  247. package/build-module/store/private-actions.js.map +1 -1
  248. package/build-module/store/private-selectors.js +11 -1
  249. package/build-module/store/private-selectors.js.map +1 -1
  250. package/build-module/store/reducer.js +93 -12
  251. package/build-module/store/reducer.js.map +1 -1
  252. package/build-module/store/selectors.js +6 -8
  253. package/build-module/store/selectors.js.map +1 -1
  254. package/build-module/utils/block-bindings.js +90 -0
  255. package/build-module/utils/block-bindings.js.map +1 -1
  256. package/build-style/style-rtl.css +27 -9
  257. package/build-style/style.css +27 -9
  258. package/package.json +33 -33
  259. package/src/components/audio-player/index.native.js +2 -2
  260. package/src/components/background-image-control/index.js +4 -0
  261. package/src/components/background-image-control/style.scss +4 -2
  262. package/src/components/block-alignment-matrix-control/README.md +29 -6
  263. package/src/components/block-alignment-matrix-control/index.js +31 -0
  264. package/src/components/block-alignment-matrix-control/stories/index.story.js +78 -0
  265. package/src/components/block-card/README.md +7 -0
  266. package/src/components/block-card/index.js +41 -12
  267. package/src/components/block-card/stories/index.story.js +79 -0
  268. package/src/components/block-card/style.scss +9 -1
  269. package/src/components/block-edit/edit.js +218 -11
  270. package/src/components/block-list/index.js +2 -7
  271. package/src/components/block-list/use-block-props/index.js +1 -1
  272. package/src/components/block-list/zoom-out-separator.js +30 -0
  273. package/src/components/block-settings-menu/block-settings-dropdown.js +17 -20
  274. package/src/components/block-styles/utils.js +3 -3
  275. package/src/components/block-title/stories/index.story.js +76 -0
  276. package/src/components/block-tools/style.scss +1 -0
  277. package/src/components/block-tools/zoom-out-mode-inserters.js +21 -3
  278. package/src/components/border-radius-control/README.md +59 -0
  279. package/src/components/border-radius-control/stories/index.story.js +58 -0
  280. package/src/components/button-block-appender/index.js +2 -7
  281. package/src/components/child-layout-control/index.js +14 -0
  282. package/src/components/colors-gradients/dropdown.js +57 -8
  283. package/src/components/colors-gradients/style.scss +5 -0
  284. package/src/components/contrast-checker/index.native.js +2 -2
  285. package/src/components/contrast-checker/stories/index.story.js +117 -0
  286. package/src/components/date-format-picker/README.md +6 -13
  287. package/src/components/date-format-picker/index.js +10 -17
  288. package/src/components/date-format-picker/stories/index.story.js +69 -0
  289. package/src/components/date-format-picker/style.scss +3 -1
  290. package/src/components/default-block-appender/content.scss +1 -0
  291. package/src/components/dimensions-tool/stories/aspect-ratio-tool.story.js +2 -1
  292. package/src/components/dimensions-tool/stories/index.story.js +2 -1
  293. package/src/components/dimensions-tool/stories/scale-tool.story.js +2 -1
  294. package/src/components/dimensions-tool/stories/width-height-tool.story.js +2 -1
  295. package/src/components/font-appearance-control/index.js +15 -0
  296. package/src/components/font-family/README.md +1 -0
  297. package/src/components/font-family/index.js +17 -1
  298. package/src/components/font-family/stories/index.story.js +1 -0
  299. package/src/components/global-styles/color-panel.js +3 -0
  300. package/src/components/global-styles/test/use-global-styles-output.js +1 -1
  301. package/src/components/global-styles/typography-utils.js +1 -1
  302. package/src/components/global-styles/use-global-styles-output.js +2 -2
  303. package/src/components/grid/grid-visualizer.js +11 -0
  304. package/src/components/grid/utils.js +19 -1
  305. package/src/components/iframe/index.js +1 -1
  306. package/src/components/inner-blocks/use-inner-block-template-sync.js +17 -10
  307. package/src/components/inserter/block-patterns-explorer/index.js +2 -3
  308. package/src/components/inserter/block-patterns-tab/index.js +3 -1
  309. package/src/components/inserter/block-patterns-tab/pattern-category-previews.js +4 -4
  310. package/src/components/inserter/block-patterns-tab/patterns-filter.js +2 -2
  311. package/src/components/inserter/category-tabs/index.js +3 -2
  312. package/src/components/inserter/index.js +1 -13
  313. package/src/components/inserter/quick-inserter.js +2 -25
  314. package/src/components/keyboard-shortcuts/index.js +2 -2
  315. package/src/components/line-height-control/README.md +1 -0
  316. package/src/components/line-height-control/index.js +12 -0
  317. package/src/components/line-height-control/stories/index.story.js +1 -0
  318. package/src/components/line-height-control/test/index.js +7 -1
  319. package/src/components/list-view/style.scss +10 -5
  320. package/src/components/media-placeholder/index.js +3 -3
  321. package/src/components/media-replace-flow/README.md +7 -0
  322. package/src/components/media-replace-flow/index.js +28 -36
  323. package/src/components/media-replace-flow/style.scss +6 -6
  324. package/src/components/plain-text/README.md +2 -2
  325. package/src/components/plain-text/index.js +34 -0
  326. package/src/components/plain-text/stories/index.story.js +75 -0
  327. package/src/components/provider/index.js +81 -4
  328. package/src/components/provider/use-media-upload-settings.js +25 -0
  329. package/src/components/resolution-tool/index.js +2 -0
  330. package/src/components/resolution-tool/stories/index.story.js +36 -8
  331. package/src/components/responsive-block-control/index.js +1 -1
  332. package/src/components/rich-text/event-listeners/delete.js +6 -1
  333. package/src/components/rich-text/index.js +1 -1
  334. package/src/components/text-alignment-control/README.md +49 -0
  335. package/src/components/text-alignment-control/stories/index.story.js +56 -18
  336. package/src/components/text-decoration-control/README.md +0 -1
  337. package/src/components/text-decoration-control/stories/index.story.js +51 -16
  338. package/src/components/text-transform-control/README.md +3 -4
  339. package/src/components/text-transform-control/stories/index.story.js +53 -16
  340. package/src/components/use-block-drop-zone/index.js +8 -1
  341. package/src/components/warning/stories/index.story.js +86 -0
  342. package/src/hooks/background.js +6 -0
  343. package/src/hooks/block-bindings.js +17 -18
  344. package/src/hooks/border.js +9 -3
  345. package/src/hooks/color.js +1 -1
  346. package/src/hooks/dimensions.js +2 -2
  347. package/src/hooks/font-family.js +1 -1
  348. package/src/hooks/gap.js +2 -2
  349. package/src/hooks/index.js +0 -1
  350. package/src/hooks/index.native.js +1 -0
  351. package/src/hooks/style.js +13 -7
  352. package/src/hooks/supports.js +7 -7
  353. package/src/hooks/test/style.js +2 -1
  354. package/src/hooks/typography.js +6 -6
  355. package/src/hooks/use-zoom-out.js +10 -2
  356. package/src/hooks/utils.js +1 -1
  357. package/src/store/private-actions.js +1 -0
  358. package/src/store/private-selectors.js +15 -5
  359. package/src/store/reducer.js +112 -19
  360. package/src/store/selectors.js +6 -8
  361. package/src/store/test/private-selectors.js +53 -9
  362. package/src/store/test/reducer.js +172 -166
  363. package/src/store/test/selectors.js +23 -0
  364. package/src/utils/block-bindings.js +95 -0
  365. package/tsconfig.json +2 -5
  366. package/build/hooks/use-bindings-attributes.js +0 -262
  367. package/build/hooks/use-bindings-attributes.js.map +0 -1
  368. package/build-module/hooks/use-bindings-attributes.js +0 -253
  369. package/build-module/hooks/use-bindings-attributes.js.map +0 -1
  370. package/src/hooks/use-bindings-attributes.js +0 -322
@@ -6,22 +6,55 @@ import clsx from 'clsx';
6
6
  /**
7
7
  * WordPress dependencies
8
8
  */
9
- import deprecated from '@wordpress/deprecated';
10
9
  import {
11
10
  Button,
12
11
  __experimentalText as Text,
13
12
  __experimentalVStack as VStack,
13
+ privateApis as componentsPrivateApis,
14
14
  } from '@wordpress/components';
15
+ import { useDispatch, useSelect } from '@wordpress/data';
16
+ import deprecated from '@wordpress/deprecated';
17
+ import { __, isRTL } from '@wordpress/i18n';
15
18
  import { chevronLeft, chevronRight } from '@wordpress/icons';
16
- import { __, _x, isRTL, sprintf } from '@wordpress/i18n';
17
- import { useSelect, useDispatch } from '@wordpress/data';
18
19
 
19
20
  /**
20
21
  * Internal dependencies
21
22
  */
22
- import BlockIcon from '../block-icon';
23
+ import { unlock } from '../../lock-unlock';
23
24
  import { store as blockEditorStore } from '../../store';
25
+ import BlockIcon from '../block-icon';
24
26
 
27
+ const { Badge } = unlock( componentsPrivateApis );
28
+
29
+ /**
30
+ * A card component that displays block information including title, icon, and description.
31
+ * Can be used to show block metadata and navigation controls for parent blocks.
32
+ *
33
+ * @see https://github.com/WordPress/gutenberg/blob/HEAD/packages/block-editor/src/components/block-card/README.md
34
+ *
35
+ * @example
36
+ * ```jsx
37
+ * function Example() {
38
+ * return (
39
+ * <BlockCard
40
+ * title="My Block"
41
+ * icon="smiley"
42
+ * description="A simple block example"
43
+ * name="Custom Block"
44
+ * />
45
+ * );
46
+ * }
47
+ * ```
48
+ *
49
+ * @param {Object} props Component props.
50
+ * @param {string} props.title The title of the block.
51
+ * @param {string|Object} props.icon The icon of the block. This can be any of [WordPress' Dashicons](https://developer.wordpress.org/resource/dashicons/), or a custom `svg` element.
52
+ * @param {string} props.description The description of the block.
53
+ * @param {Object} [props.blockType] Deprecated: Object containing block type data.
54
+ * @param {string} [props.className] Additional classes to apply to the card.
55
+ * @param {string} [props.name] Custom block name to display before the title.
56
+ * @return {Element} Block card component.
57
+ */
25
58
  function BlockCard( { title, icon, description, blockType, className, name } ) {
26
59
  if ( blockType ) {
27
60
  deprecated( '`blockType` property in `BlockCard component`', {
@@ -66,14 +99,10 @@ function BlockCard( { title, icon, description, blockType, className, name } ) {
66
99
  <BlockIcon icon={ icon } showColors />
67
100
  <VStack spacing={ 1 }>
68
101
  <h2 className="block-editor-block-card__title">
69
- { name?.length
70
- ? sprintf(
71
- // translators: 1: Custom block name. 2: Block title.
72
- _x( '%1$s (%2$s)', 'block label' ),
73
- name,
74
- title
75
- )
76
- : title }
102
+ <span className="block-editor-block-card__name">
103
+ { !! name?.length ? name : title }
104
+ </span>
105
+ { !! name?.length && <Badge>{ title }</Badge> }
77
106
  </h2>
78
107
  { description && (
79
108
  <Text className="block-editor-block-card__description">
@@ -0,0 +1,79 @@
1
+ /**
2
+ * WordPress dependencies
3
+ */
4
+ import { box, button, cog, paragraph } from '@wordpress/icons';
5
+
6
+ /**
7
+ * Internal dependencies
8
+ */
9
+ import BlockCard from '../';
10
+
11
+ const meta = {
12
+ title: 'BlockEditor/BlockCard',
13
+ component: BlockCard,
14
+ parameters: {
15
+ docs: {
16
+ description: {
17
+ component:
18
+ 'The `BlockCard` component allows to display a "card" which contains the title of a block, its icon and its description.',
19
+ },
20
+ canvas: { sourceState: 'shown' },
21
+ },
22
+ },
23
+ argTypes: {
24
+ title: {
25
+ control: 'text',
26
+ description: 'The title of the block.',
27
+ table: {
28
+ type: { summary: 'string' },
29
+ },
30
+ },
31
+ description: {
32
+ control: 'text',
33
+ description: 'A description of the block functionality.',
34
+ table: {
35
+ type: { summary: 'string' },
36
+ },
37
+ },
38
+ icon: {
39
+ control: 'select',
40
+ options: [ 'paragraph', 'cog', 'box', 'button' ],
41
+ mapping: {
42
+ paragraph,
43
+ cog,
44
+ box,
45
+ button,
46
+ },
47
+ description:
48
+ 'The icon of the block. This can be any of [WordPress Dashicons](https://developer.wordpress.org/resource/dashicons/), or a custom `svg` element.',
49
+ table: {
50
+ type: { summary: 'string | object' },
51
+ },
52
+ },
53
+ name: {
54
+ control: 'text',
55
+ description: 'Optional custom name for the block.',
56
+ table: {
57
+ type: { summary: 'string' },
58
+ },
59
+ },
60
+ className: {
61
+ control: 'text',
62
+ description: 'Additional CSS class names.',
63
+ table: {
64
+ type: { summary: 'string' },
65
+ },
66
+ },
67
+ },
68
+ };
69
+
70
+ export default meta;
71
+
72
+ export const Default = {
73
+ args: {
74
+ title: 'Paragraph',
75
+ icon: paragraph,
76
+ description: 'This is a paragraph block description.',
77
+ name: 'Paragraph Block',
78
+ },
79
+ };
@@ -7,15 +7,22 @@
7
7
 
8
8
  .block-editor-block-card__title {
9
9
  font-weight: 500;
10
+ display: flex;
11
+ align-items: center;
12
+ flex-wrap: wrap;
13
+ gap: calc($grid-unit-10 / 2) $grid-unit-10;
10
14
 
11
15
  &.block-editor-block-card__title {
12
16
  font-size: $default-font-size;
13
17
  line-height: $default-line-height;
14
18
  margin: 0;
15
- padding: 3px 0; // This makes the title as high as the icon.
16
19
  }
17
20
  }
18
21
 
22
+ .block-editor-block-card__name {
23
+ padding: 3px 0; // This makes the title as high as the icon.
24
+ }
25
+
19
26
  .block-editor-block-card .block-editor-block-icon {
20
27
  flex: 0 0 $button-size-small;
21
28
  margin-left: 0;
@@ -27,3 +34,4 @@
27
34
  .block-editor-block-card.is-synced .block-editor-block-icon {
28
35
  color: var(--wp-block-synced-color);
29
36
  }
37
+
@@ -6,18 +6,27 @@ import clsx from 'clsx';
6
6
  /**
7
7
  * WordPress dependencies
8
8
  */
9
- import { withFilters } from '@wordpress/components';
10
9
  import {
11
10
  getBlockDefaultClassName,
12
- hasBlockSupport,
13
11
  getBlockType,
12
+ hasBlockSupport,
13
+ store as blocksStore,
14
14
  } from '@wordpress/blocks';
15
- import { useContext, useMemo } from '@wordpress/element';
15
+ import { withFilters } from '@wordpress/components';
16
+ import { useRegistry, useSelect } from '@wordpress/data';
17
+ import { useCallback, useContext, useMemo } from '@wordpress/element';
16
18
 
17
19
  /**
18
20
  * Internal dependencies
19
21
  */
20
22
  import BlockContext from '../block-context';
23
+ import isURLLike from '../link-control/is-url-like';
24
+ import {
25
+ canBindAttribute,
26
+ hasPatternOverridesDefaultBinding,
27
+ replacePatternOverridesDefaultBinding,
28
+ } from '../../utils/block-bindings';
29
+ import { unlock } from '../../lock-unlock';
21
30
 
22
31
  /**
23
32
  * Default value used for blocks which do not define their own context needs,
@@ -48,27 +57,223 @@ const Edit = ( props ) => {
48
57
  const EditWithFilters = withFilters( 'editor.BlockEdit' )( Edit );
49
58
 
50
59
  const EditWithGeneratedProps = ( props ) => {
51
- const { attributes = {}, name } = props;
60
+ const { name, clientId, attributes, setAttributes } = props;
61
+ const registry = useRegistry();
52
62
  const blockType = getBlockType( name );
53
63
  const blockContext = useContext( BlockContext );
64
+ const registeredSources = useSelect(
65
+ ( select ) =>
66
+ unlock( select( blocksStore ) ).getAllBlockBindingsSources(),
67
+ []
68
+ );
54
69
 
55
- // Assign context values using the block type's declared context needs.
56
- const context = useMemo( () => {
57
- return blockType && blockType.usesContext
70
+ const { blockBindings, context, hasPatternOverrides } = useMemo( () => {
71
+ // Assign context values using the block type's declared context needs.
72
+ const computedContext = blockType?.usesContext
58
73
  ? Object.fromEntries(
59
74
  Object.entries( blockContext ).filter( ( [ key ] ) =>
60
75
  blockType.usesContext.includes( key )
61
76
  )
62
77
  )
63
78
  : DEFAULT_BLOCK_CONTEXT;
64
- }, [ blockType, blockContext ] );
79
+ // Add context requested by Block Bindings sources.
80
+ if ( attributes?.metadata?.bindings ) {
81
+ Object.values( attributes?.metadata?.bindings || {} ).forEach(
82
+ ( binding ) => {
83
+ registeredSources[ binding?.source ]?.usesContext?.forEach(
84
+ ( key ) => {
85
+ computedContext[ key ] = blockContext[ key ];
86
+ }
87
+ );
88
+ }
89
+ );
90
+ }
91
+ return {
92
+ blockBindings: replacePatternOverridesDefaultBinding(
93
+ name,
94
+ attributes?.metadata?.bindings
95
+ ),
96
+ context: computedContext,
97
+ hasPatternOverrides: hasPatternOverridesDefaultBinding(
98
+ attributes?.metadata?.bindings
99
+ ),
100
+ };
101
+ }, [
102
+ name,
103
+ blockType?.usesContext,
104
+ blockContext,
105
+ attributes?.metadata?.bindings,
106
+ registeredSources,
107
+ ] );
108
+
109
+ const computedAttributes = useSelect(
110
+ ( select ) => {
111
+ if ( ! blockBindings ) {
112
+ return attributes;
113
+ }
114
+
115
+ const attributesFromSources = {};
116
+ const blockBindingsBySource = new Map();
117
+
118
+ for ( const [ attributeName, binding ] of Object.entries(
119
+ blockBindings
120
+ ) ) {
121
+ const { source: sourceName, args: sourceArgs } = binding;
122
+ const source = registeredSources[ sourceName ];
123
+ if ( ! source || ! canBindAttribute( name, attributeName ) ) {
124
+ continue;
125
+ }
126
+
127
+ blockBindingsBySource.set( source, {
128
+ ...blockBindingsBySource.get( source ),
129
+ [ attributeName ]: {
130
+ args: sourceArgs,
131
+ },
132
+ } );
133
+ }
134
+
135
+ if ( blockBindingsBySource.size ) {
136
+ for ( const [ source, bindings ] of blockBindingsBySource ) {
137
+ // Get values in batch if the source supports it.
138
+ let values = {};
139
+ if ( ! source.getValues ) {
140
+ Object.keys( bindings ).forEach( ( attr ) => {
141
+ // Default to the the source label when `getValues` doesn't exist.
142
+ values[ attr ] = source.label;
143
+ } );
144
+ } else {
145
+ values = source.getValues( {
146
+ select,
147
+ context,
148
+ clientId,
149
+ bindings,
150
+ } );
151
+ }
152
+ for ( const [ attributeName, value ] of Object.entries(
153
+ values
154
+ ) ) {
155
+ if (
156
+ attributeName === 'url' &&
157
+ ( ! value || ! isURLLike( value ) )
158
+ ) {
159
+ // Return null if value is not a valid URL.
160
+ attributesFromSources[ attributeName ] = null;
161
+ } else {
162
+ attributesFromSources[ attributeName ] = value;
163
+ }
164
+ }
165
+ }
166
+ }
167
+
168
+ return {
169
+ ...attributes,
170
+ ...attributesFromSources,
171
+ };
172
+ },
173
+ [
174
+ attributes,
175
+ blockBindings,
176
+ clientId,
177
+ context,
178
+ name,
179
+ registeredSources,
180
+ ]
181
+ );
182
+
183
+ const setBoundAttributes = useCallback(
184
+ ( nextAttributes ) => {
185
+ if ( ! blockBindings ) {
186
+ setAttributes( nextAttributes );
187
+ return;
188
+ }
189
+
190
+ registry.batch( () => {
191
+ const keptAttributes = { ...nextAttributes };
192
+ const blockBindingsBySource = new Map();
193
+
194
+ // Loop only over the updated attributes to avoid modifying the bound ones that haven't changed.
195
+ for ( const [ attributeName, newValue ] of Object.entries(
196
+ keptAttributes
197
+ ) ) {
198
+ if (
199
+ ! blockBindings[ attributeName ] ||
200
+ ! canBindAttribute( name, attributeName )
201
+ ) {
202
+ continue;
203
+ }
204
+
205
+ const binding = blockBindings[ attributeName ];
206
+ const source = registeredSources[ binding?.source ];
207
+ if ( ! source?.setValues ) {
208
+ continue;
209
+ }
210
+ blockBindingsBySource.set( source, {
211
+ ...blockBindingsBySource.get( source ),
212
+ [ attributeName ]: {
213
+ args: binding.args,
214
+ newValue,
215
+ },
216
+ } );
217
+ delete keptAttributes[ attributeName ];
218
+ }
219
+
220
+ if ( blockBindingsBySource.size ) {
221
+ for ( const [
222
+ source,
223
+ bindings,
224
+ ] of blockBindingsBySource ) {
225
+ source.setValues( {
226
+ select: registry.select,
227
+ dispatch: registry.dispatch,
228
+ context,
229
+ clientId,
230
+ bindings,
231
+ } );
232
+ }
233
+ }
234
+
235
+ const hasParentPattern = !! context[ 'pattern/overrides' ];
236
+
237
+ if (
238
+ // Don't update non-connected attributes if the block is using pattern overrides
239
+ // and the editing is happening while overriding the pattern (not editing the original).
240
+ ! ( hasPatternOverrides && hasParentPattern ) &&
241
+ Object.keys( keptAttributes ).length
242
+ ) {
243
+ // Don't update caption and href until they are supported.
244
+ if ( hasPatternOverrides ) {
245
+ delete keptAttributes.caption;
246
+ delete keptAttributes.href;
247
+ }
248
+ setAttributes( keptAttributes );
249
+ }
250
+ } );
251
+ },
252
+ [
253
+ blockBindings,
254
+ clientId,
255
+ context,
256
+ hasPatternOverrides,
257
+ setAttributes,
258
+ registeredSources,
259
+ name,
260
+ registry,
261
+ ]
262
+ );
65
263
 
66
264
  if ( ! blockType ) {
67
265
  return null;
68
266
  }
69
267
 
70
268
  if ( blockType.apiVersion > 1 ) {
71
- return <EditWithFilters { ...props } context={ context } />;
269
+ return (
270
+ <EditWithFilters
271
+ { ...props }
272
+ attributes={ computedAttributes }
273
+ context={ context }
274
+ setAttributes={ setBoundAttributes }
275
+ />
276
+ );
72
277
  }
73
278
 
74
279
  // Generate a class name for the block's editable form.
@@ -77,15 +282,17 @@ const EditWithGeneratedProps = ( props ) => {
77
282
  : null;
78
283
  const className = clsx(
79
284
  generatedClassName,
80
- attributes.className,
285
+ attributes?.className,
81
286
  props.className
82
287
  );
83
288
 
84
289
  return (
85
290
  <EditWithFilters
86
291
  { ...props }
87
- context={ context }
292
+ attributes={ computedAttributes }
88
293
  className={ className }
294
+ context={ context }
295
+ setAttributes={ setBoundAttributes }
89
296
  />
90
297
  );
91
298
  };
@@ -12,11 +12,7 @@ import {
12
12
  useDispatch,
13
13
  useRegistry,
14
14
  } from '@wordpress/data';
15
- import {
16
- useViewportMatch,
17
- useMergeRefs,
18
- useDebounce,
19
- } from '@wordpress/compose';
15
+ import { useMergeRefs, useDebounce } from '@wordpress/compose';
20
16
  import {
21
17
  createContext,
22
18
  useMemo,
@@ -46,7 +42,6 @@ export const IntersectionObserver = createContext();
46
42
  const pendingBlockVisibilityUpdatesPerRegistry = new WeakMap();
47
43
 
48
44
  function Root( { className, ...settings } ) {
49
- const isLargeViewport = useViewportMatch( 'medium' );
50
45
  const { isOutlineMode, isFocusMode, temporarilyEditingAsBlocks } =
51
46
  useSelect( ( select ) => {
52
47
  const { getSettings, getTemporarilyEditingAsBlocks, isTyping } =
@@ -105,7 +100,7 @@ function Root( { className, ...settings } ) {
105
100
  ] ),
106
101
  className: clsx( 'is-root-container', className, {
107
102
  'is-outline-mode': isOutlineMode,
108
- 'is-focus-mode': isFocusMode && isLargeViewport,
103
+ 'is-focus-mode': isFocusMode,
109
104
  } ),
110
105
  },
111
106
  settings
@@ -29,7 +29,7 @@ import { useBlockRefProvider } from './use-block-refs';
29
29
  import { useIntersectionObserver } from './use-intersection-observer';
30
30
  import { useScrollIntoView } from './use-scroll-into-view';
31
31
  import { useFlashEditableBlocks } from '../../use-flash-editable-blocks';
32
- import { canBindBlock } from '../../../hooks/use-bindings-attributes';
32
+ import { canBindBlock } from '../../../utils/block-bindings';
33
33
  import { useFirefoxDraggableCompatibility } from './use-firefox-draggable-compatibility';
34
34
 
35
35
  /**
@@ -33,6 +33,7 @@ export function ZoomOutSeparator( {
33
33
  insertionPoint,
34
34
  blockInsertionPointVisible,
35
35
  blockInsertionPoint,
36
+ blocksBeingDragged,
36
37
  } = useSelect( ( select ) => {
37
38
  const {
38
39
  getInsertionPoint,
@@ -40,6 +41,7 @@ export function ZoomOutSeparator( {
40
41
  getSectionRootClientId,
41
42
  isBlockInsertionPointVisible,
42
43
  getBlockInsertionPoint,
44
+ getDraggedBlockClientIds,
43
45
  } = unlock( select( blockEditorStore ) );
44
46
 
45
47
  const root = getSectionRootClientId();
@@ -51,6 +53,7 @@ export function ZoomOutSeparator( {
51
53
  insertionPoint: getInsertionPoint(),
52
54
  blockInsertionPoint: getBlockInsertionPoint(),
53
55
  blockInsertionPointVisible: isBlockInsertionPointVisible(),
56
+ blocksBeingDragged: getDraggedBlockClientIds(),
54
57
  };
55
58
  }, [] );
56
59
 
@@ -78,6 +81,7 @@ export function ZoomOutSeparator( {
78
81
  insertionPoint &&
79
82
  insertionPoint.hasOwnProperty( 'index' ) &&
80
83
  clientId === sectionClientIds[ insertionPoint.index - 1 ];
84
+
81
85
  // We want to show the zoom out separator in either of these conditions:
82
86
  // 1. If the inserter has an insertion index set
83
87
  // 2. We are dragging a pattern over an insertion point
@@ -97,6 +101,32 @@ export function ZoomOutSeparator( {
97
101
  sectionClientIds[ blockInsertionPoint.index - 1 ] );
98
102
  }
99
103
 
104
+ const blockBeingDraggedClientId = blocksBeingDragged[ 0 ];
105
+
106
+ const isCurrentBlockBeingDragged = blocksBeingDragged.includes( clientId );
107
+
108
+ const blockBeingDraggedIndex = sectionClientIds.indexOf(
109
+ blockBeingDraggedClientId
110
+ );
111
+ const blockBeingDraggedPreviousSiblingClientId =
112
+ blockBeingDraggedIndex > 0
113
+ ? sectionClientIds[ blockBeingDraggedIndex - 1 ]
114
+ : null;
115
+
116
+ const isCurrentBlockPreviousSiblingOfBlockBeingDragged =
117
+ blockBeingDraggedPreviousSiblingClientId === clientId;
118
+
119
+ // The separators are visually top/bottom of the block, but in actual fact
120
+ // the "top" separator is the "bottom" separator of the previous block.
121
+ // Therefore, this logic hides the separator if the current block is being dragged
122
+ // or if the current block is the previous sibling of the block being dragged.
123
+ if (
124
+ isCurrentBlockBeingDragged ||
125
+ isCurrentBlockPreviousSiblingOfBlockBeingDragged
126
+ ) {
127
+ isVisible = false;
128
+ }
129
+
100
130
  return (
101
131
  <AnimatePresence>
102
132
  { isVisible && (
@@ -65,7 +65,6 @@ export function BlockSettingsDropdown( {
65
65
  selectedBlockClientIds,
66
66
  openedBlockSettingsMenu,
67
67
  isContentOnly,
68
- isZoomOut,
69
68
  } = useSelect(
70
69
  ( select ) => {
71
70
  const {
@@ -76,7 +75,6 @@ export function BlockSettingsDropdown( {
76
75
  getBlockAttributes,
77
76
  getOpenedBlockSettingsMenu,
78
77
  getBlockEditingMode,
79
- isZoomOut: _isZoomOut,
80
78
  } = unlock( select( blockEditorStore ) );
81
79
 
82
80
  const { getActiveBlockVariation } = select( blocksStore );
@@ -101,7 +99,6 @@ export function BlockSettingsDropdown( {
101
99
  openedBlockSettingsMenu: getOpenedBlockSettingsMenu(),
102
100
  isContentOnly:
103
101
  getBlockEditingMode( firstBlockClientId ) === 'contentOnly',
104
- isZoomOut: _isZoomOut(),
105
102
  };
106
103
  },
107
104
  [ firstBlockClientId ]
@@ -253,15 +250,13 @@ export function BlockSettingsDropdown( {
253
250
  clientId={ firstBlockClientId }
254
251
  />
255
252
  ) }
256
- { ( ! isContentOnly || isZoomOut ) && (
257
- <CopyMenuItem
258
- clientIds={ clientIds }
259
- onCopy={ onCopy }
260
- shortcut={ displayShortcut.primary(
261
- 'c'
262
- ) }
263
- />
264
- ) }
253
+ <CopyMenuItem
254
+ clientIds={ clientIds }
255
+ onCopy={ onCopy }
256
+ shortcut={ displayShortcut.primary(
257
+ 'c'
258
+ ) }
259
+ />
265
260
  { canDuplicate && (
266
261
  <MenuItem
267
262
  onClick={ pipe(
@@ -316,14 +311,16 @@ export function BlockSettingsDropdown( {
316
311
  </MenuItem>
317
312
  </MenuGroup>
318
313
  ) }
319
- <BlockSettingsMenuControls.Slot
320
- fillProps={ {
321
- onClose,
322
- count,
323
- firstBlockClientId,
324
- } }
325
- clientIds={ clientIds }
326
- />
314
+ { ! isContentOnly && (
315
+ <BlockSettingsMenuControls.Slot
316
+ fillProps={ {
317
+ onClose,
318
+ count,
319
+ firstBlockClientId,
320
+ } }
321
+ clientIds={ clientIds }
322
+ />
323
+ ) }
327
324
  { typeof children === 'function'
328
325
  ? children( { onClose } )
329
326
  : Children.map( ( child ) =>
@@ -10,7 +10,7 @@ import { _x } from '@wordpress/i18n';
10
10
  * @param {Array} styles Block styles.
11
11
  * @param {string} className Class name
12
12
  *
13
- * @return {Object?} The active style.
13
+ * @return {?Object} The active style.
14
14
  */
15
15
  export function getActiveStyle( styles, className ) {
16
16
  for ( const style of new TokenList( className ).values() ) {
@@ -34,7 +34,7 @@ export function getActiveStyle( styles, className ) {
34
34
  * Replaces the active style in the block's className.
35
35
  *
36
36
  * @param {string} className Class name.
37
- * @param {Object?} activeStyle The replaced style.
37
+ * @param {?Object} activeStyle The replaced style.
38
38
  * @param {Object} newStyle The replacing style.
39
39
  *
40
40
  * @return {string} The updated className.
@@ -83,7 +83,7 @@ export function getRenderedStyles( styles ) {
83
83
  *
84
84
  * @param {Array} styles Block styles.
85
85
  *
86
- * @return {Object?} The default style object, if found.
86
+ * @return {?Object} The default style object, if found.
87
87
  */
88
88
  export function getDefaultStyle( styles ) {
89
89
  return styles?.find( ( style ) => style.isDefault );