@wordpress/block-editor 13.4.0 → 14.0.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 (331) hide show
  1. package/CHANGELOG.md +11 -0
  2. package/README.md +11 -1
  3. package/build/components/block-breadcrumb/index.js +3 -1
  4. package/build/components/block-breadcrumb/index.js.map +1 -1
  5. package/build/components/block-draggable/index.js +2 -2
  6. package/build/components/block-draggable/index.js.map +1 -1
  7. package/build/components/block-list/use-block-props/use-block-refs.js +24 -32
  8. package/build/components/block-list/use-block-props/use-block-refs.js.map +1 -1
  9. package/build/components/block-mover/index.js +1 -2
  10. package/build/components/block-mover/index.js.map +1 -1
  11. package/build/components/block-popover/cover.js +1 -1
  12. package/build/components/block-popover/cover.js.map +1 -1
  13. package/build/components/block-popover/inbetween.js +2 -2
  14. package/build/components/block-popover/inbetween.js.map +1 -1
  15. package/build/components/block-popover/index.js +2 -2
  16. package/build/components/block-popover/index.js.map +1 -1
  17. package/build/components/block-tools/block-selection-button.js +1 -2
  18. package/build/components/block-tools/block-selection-button.js.map +1 -1
  19. package/build/components/block-tools/index.js +1 -1
  20. package/build/components/block-tools/index.js.map +1 -1
  21. package/build/components/block-tools/use-block-toolbar-popover-props.js +1 -1
  22. package/build/components/block-tools/use-block-toolbar-popover-props.js.map +1 -1
  23. package/build/components/block-tools/zoom-out-mode-inserters.js +15 -16
  24. package/build/components/block-tools/zoom-out-mode-inserters.js.map +1 -1
  25. package/build/components/block-tools/zoom-out-toolbar.js +0 -1
  26. package/build/components/block-tools/zoom-out-toolbar.js.map +1 -1
  27. package/build/components/child-layout-control/index.js +3 -1
  28. package/build/components/child-layout-control/index.js.map +1 -1
  29. package/build/components/dimensions-tool/scale-tool.js +1 -0
  30. package/build/components/dimensions-tool/scale-tool.js.map +1 -1
  31. package/build/components/font-family/index.js +12 -0
  32. package/build/components/font-family/index.js.map +1 -1
  33. package/build/components/global-styles/background-panel.js +55 -51
  34. package/build/components/global-styles/background-panel.js.map +1 -1
  35. package/build/components/global-styles/image-settings-panel.js +1 -0
  36. package/build/components/global-styles/image-settings-panel.js.map +1 -1
  37. package/build/components/global-styles/theme-file-uri-utils.js +0 -59
  38. package/build/components/global-styles/theme-file-uri-utils.js.map +1 -1
  39. package/build/components/global-styles/typography-panel.js +0 -1
  40. package/build/components/global-styles/typography-panel.js.map +1 -1
  41. package/build/components/global-styles/use-global-styles-output.js +58 -39
  42. package/build/components/global-styles/use-global-styles-output.js.map +1 -1
  43. package/build/components/global-styles/utils.js +96 -0
  44. package/build/components/global-styles/utils.js.map +1 -1
  45. package/build/components/grid/grid-item-movers.js +30 -26
  46. package/build/components/grid/grid-item-movers.js.map +1 -1
  47. package/build/components/grid/grid-item-resizer.js +14 -15
  48. package/build/components/grid/grid-item-resizer.js.map +1 -1
  49. package/build/components/grid/grid-visualizer.js +1 -1
  50. package/build/components/grid/grid-visualizer.js.map +1 -1
  51. package/build/components/grid/use-grid-layout-sync.js +56 -20
  52. package/build/components/grid/use-grid-layout-sync.js.map +1 -1
  53. package/build/components/iframe/index.js +4 -8
  54. package/build/components/iframe/index.js.map +1 -1
  55. package/build/components/inserter/category-tabs/index.js +29 -2
  56. package/build/components/inserter/category-tabs/index.js.map +1 -1
  57. package/build/components/inserter/menu.js +2 -2
  58. package/build/components/inserter/menu.js.map +1 -1
  59. package/build/components/line-height-control/index.js +0 -15
  60. package/build/components/line-height-control/index.js.map +1 -1
  61. package/build/components/link-control/search-input.js +0 -1
  62. package/build/components/link-control/search-input.js.map +1 -1
  63. package/build/components/media-replace-flow/index.js +3 -1
  64. package/build/components/media-replace-flow/index.js.map +1 -1
  65. package/build/components/resolution-tool/index.js +1 -0
  66. package/build/components/resolution-tool/index.js.map +1 -1
  67. package/build/components/skip-to-selected-block/index.js +4 -2
  68. package/build/components/skip-to-selected-block/index.js.map +1 -1
  69. package/build/components/spacing-sizes-control/input-controls/spacing-input-control.js +4 -6
  70. package/build/components/spacing-sizes-control/input-controls/spacing-input-control.js.map +1 -1
  71. package/build/components/url-input/button.js +0 -1
  72. package/build/components/url-input/button.js.map +1 -1
  73. package/build/components/url-input/index.js +1 -11
  74. package/build/components/url-input/index.js.map +1 -1
  75. package/build/components/url-popover/link-editor.js +0 -1
  76. package/build/components/url-popover/link-editor.js.map +1 -1
  77. package/build/components/use-block-drop-zone/index.js +30 -4
  78. package/build/components/use-block-drop-zone/index.js.map +1 -1
  79. package/build/components/use-on-block-drop/index.js +3 -6
  80. package/build/components/use-on-block-drop/index.js.map +1 -1
  81. package/build/components/use-resize-canvas/index.js +1 -3
  82. package/build/components/use-resize-canvas/index.js.map +1 -1
  83. package/build/components/use-settings/index.js +2 -1
  84. package/build/components/use-settings/index.js.map +1 -1
  85. package/build/hooks/block-bindings.js +248 -36
  86. package/build/hooks/block-bindings.js.map +1 -1
  87. package/build/hooks/block-hooks.js +1 -0
  88. package/build/hooks/block-hooks.js.map +1 -1
  89. package/build/hooks/block-style-variation.js +2 -2
  90. package/build/hooks/block-style-variation.js.map +1 -1
  91. package/build/hooks/contrast-checker.js +6 -6
  92. package/build/hooks/contrast-checker.js.map +1 -1
  93. package/build/hooks/duotone.js +3 -3
  94. package/build/hooks/duotone.js.map +1 -1
  95. package/build/hooks/index.js +7 -1
  96. package/build/hooks/index.js.map +1 -1
  97. package/build/hooks/line-height.js +0 -1
  98. package/build/hooks/line-height.js.map +1 -1
  99. package/build/hooks/spacing-visualizer.js +1 -1
  100. package/build/hooks/spacing-visualizer.js.map +1 -1
  101. package/build/hooks/use-bindings-attributes.js +4 -0
  102. package/build/hooks/use-bindings-attributes.js.map +1 -1
  103. package/build/hooks/use-zoom-out.js +1 -1
  104. package/build/hooks/use-zoom-out.js.map +1 -1
  105. package/build/hooks/utils.js +20 -0
  106. package/build/hooks/utils.js.map +1 -1
  107. package/build/index.js +7 -0
  108. package/build/index.js.map +1 -1
  109. package/build/private-apis.js +0 -1
  110. package/build/private-apis.js.map +1 -1
  111. package/build/store/actions.js +9 -1
  112. package/build/store/actions.js.map +1 -1
  113. package/build/store/selectors.js +4 -4
  114. package/build/store/selectors.js.map +1 -1
  115. package/build/utils/get-editor-region.js +1 -1
  116. package/build/utils/get-editor-region.js.map +1 -1
  117. package/build/utils/get-px-from-css-unit.js +1 -1
  118. package/build/utils/get-px-from-css-unit.js.map +1 -1
  119. package/build-module/components/block-breadcrumb/index.js +4 -2
  120. package/build-module/components/block-breadcrumb/index.js.map +1 -1
  121. package/build-module/components/block-draggable/index.js +3 -3
  122. package/build-module/components/block-draggable/index.js.map +1 -1
  123. package/build-module/components/block-list/use-block-props/use-block-refs.js +24 -34
  124. package/build-module/components/block-list/use-block-props/use-block-refs.js.map +1 -1
  125. package/build-module/components/block-mover/index.js +1 -2
  126. package/build-module/components/block-mover/index.js.map +1 -1
  127. package/build-module/components/block-popover/cover.js +1 -1
  128. package/build-module/components/block-popover/cover.js.map +1 -1
  129. package/build-module/components/block-popover/inbetween.js +1 -1
  130. package/build-module/components/block-popover/inbetween.js.map +1 -1
  131. package/build-module/components/block-popover/index.js +1 -1
  132. package/build-module/components/block-popover/index.js.map +1 -1
  133. package/build-module/components/block-tools/block-selection-button.js +1 -2
  134. package/build-module/components/block-tools/block-selection-button.js.map +1 -1
  135. package/build-module/components/block-tools/index.js +1 -1
  136. package/build-module/components/block-tools/index.js.map +1 -1
  137. package/build-module/components/block-tools/use-block-toolbar-popover-props.js +1 -1
  138. package/build-module/components/block-tools/use-block-toolbar-popover-props.js.map +1 -1
  139. package/build-module/components/block-tools/zoom-out-mode-inserters.js +16 -17
  140. package/build-module/components/block-tools/zoom-out-mode-inserters.js.map +1 -1
  141. package/build-module/components/block-tools/zoom-out-toolbar.js +0 -1
  142. package/build-module/components/block-tools/zoom-out-toolbar.js.map +1 -1
  143. package/build-module/components/child-layout-control/index.js +3 -1
  144. package/build-module/components/child-layout-control/index.js.map +1 -1
  145. package/build-module/components/dimensions-tool/scale-tool.js +1 -0
  146. package/build-module/components/dimensions-tool/scale-tool.js.map +1 -1
  147. package/build-module/components/font-family/index.js +11 -0
  148. package/build-module/components/font-family/index.js.map +1 -1
  149. package/build-module/components/global-styles/background-panel.js +55 -51
  150. package/build-module/components/global-styles/background-panel.js.map +1 -1
  151. package/build-module/components/global-styles/image-settings-panel.js +1 -0
  152. package/build-module/components/global-styles/image-settings-panel.js.map +1 -1
  153. package/build-module/components/global-styles/theme-file-uri-utils.js +0 -58
  154. package/build-module/components/global-styles/theme-file-uri-utils.js.map +1 -1
  155. package/build-module/components/global-styles/typography-panel.js +0 -1
  156. package/build-module/components/global-styles/typography-panel.js.map +1 -1
  157. package/build-module/components/global-styles/use-global-styles-output.js +57 -38
  158. package/build-module/components/global-styles/use-global-styles-output.js.map +1 -1
  159. package/build-module/components/global-styles/utils.js +92 -0
  160. package/build-module/components/global-styles/utils.js.map +1 -1
  161. package/build-module/components/grid/grid-item-movers.js +30 -26
  162. package/build-module/components/grid/grid-item-movers.js.map +1 -1
  163. package/build-module/components/grid/grid-item-resizer.js +14 -15
  164. package/build-module/components/grid/grid-item-resizer.js.map +1 -1
  165. package/build-module/components/grid/grid-visualizer.js +1 -1
  166. package/build-module/components/grid/grid-visualizer.js.map +1 -1
  167. package/build-module/components/grid/use-grid-layout-sync.js +56 -20
  168. package/build-module/components/grid/use-grid-layout-sync.js.map +1 -1
  169. package/build-module/components/iframe/index.js +4 -8
  170. package/build-module/components/iframe/index.js.map +1 -1
  171. package/build-module/components/inserter/category-tabs/index.js +30 -3
  172. package/build-module/components/inserter/category-tabs/index.js.map +1 -1
  173. package/build-module/components/inserter/menu.js +2 -2
  174. package/build-module/components/inserter/menu.js.map +1 -1
  175. package/build-module/components/line-height-control/index.js +0 -14
  176. package/build-module/components/line-height-control/index.js.map +1 -1
  177. package/build-module/components/link-control/search-input.js +0 -1
  178. package/build-module/components/link-control/search-input.js.map +1 -1
  179. package/build-module/components/media-replace-flow/index.js +3 -1
  180. package/build-module/components/media-replace-flow/index.js.map +1 -1
  181. package/build-module/components/resolution-tool/index.js +1 -0
  182. package/build-module/components/resolution-tool/index.js.map +1 -1
  183. package/build-module/components/skip-to-selected-block/index.js +5 -3
  184. package/build-module/components/skip-to-selected-block/index.js.map +1 -1
  185. package/build-module/components/spacing-sizes-control/input-controls/spacing-input-control.js +4 -6
  186. package/build-module/components/spacing-sizes-control/input-controls/spacing-input-control.js.map +1 -1
  187. package/build-module/components/url-input/button.js +0 -1
  188. package/build-module/components/url-input/button.js.map +1 -1
  189. package/build-module/components/url-input/index.js +1 -11
  190. package/build-module/components/url-input/index.js.map +1 -1
  191. package/build-module/components/url-popover/link-editor.js +0 -1
  192. package/build-module/components/url-popover/link-editor.js.map +1 -1
  193. package/build-module/components/use-block-drop-zone/index.js +30 -4
  194. package/build-module/components/use-block-drop-zone/index.js.map +1 -1
  195. package/build-module/components/use-on-block-drop/index.js +3 -6
  196. package/build-module/components/use-on-block-drop/index.js.map +1 -1
  197. package/build-module/components/use-resize-canvas/index.js +1 -3
  198. package/build-module/components/use-resize-canvas/index.js.map +1 -1
  199. package/build-module/components/use-settings/index.js +2 -1
  200. package/build-module/components/use-settings/index.js.map +1 -1
  201. package/build-module/hooks/block-bindings.js +253 -40
  202. package/build-module/hooks/block-bindings.js.map +1 -1
  203. package/build-module/hooks/block-hooks.js +1 -0
  204. package/build-module/hooks/block-hooks.js.map +1 -1
  205. package/build-module/hooks/block-style-variation.js +3 -3
  206. package/build-module/hooks/block-style-variation.js.map +1 -1
  207. package/build-module/hooks/contrast-checker.js +7 -7
  208. package/build-module/hooks/contrast-checker.js.map +1 -1
  209. package/build-module/hooks/duotone.js +4 -4
  210. package/build-module/hooks/duotone.js.map +1 -1
  211. package/build-module/hooks/index.js +2 -1
  212. package/build-module/hooks/index.js.map +1 -1
  213. package/build-module/hooks/line-height.js +0 -1
  214. package/build-module/hooks/line-height.js.map +1 -1
  215. package/build-module/hooks/spacing-visualizer.js +1 -1
  216. package/build-module/hooks/spacing-visualizer.js.map +1 -1
  217. package/build-module/hooks/use-bindings-attributes.js +3 -0
  218. package/build-module/hooks/use-bindings-attributes.js.map +1 -1
  219. package/build-module/hooks/use-zoom-out.js +1 -1
  220. package/build-module/hooks/use-zoom-out.js.map +1 -1
  221. package/build-module/hooks/utils.js +19 -0
  222. package/build-module/hooks/utils.js.map +1 -1
  223. package/build-module/index.js +1 -1
  224. package/build-module/index.js.map +1 -1
  225. package/build-module/private-apis.js +1 -2
  226. package/build-module/private-apis.js.map +1 -1
  227. package/build-module/store/actions.js +9 -1
  228. package/build-module/store/actions.js.map +1 -1
  229. package/build-module/store/selectors.js +4 -4
  230. package/build-module/store/selectors.js.map +1 -1
  231. package/build-module/utils/get-editor-region.js +1 -1
  232. package/build-module/utils/get-editor-region.js.map +1 -1
  233. package/build-module/utils/get-px-from-css-unit.js +1 -1
  234. package/build-module/utils/get-px-from-css-unit.js.map +1 -1
  235. package/build-style/content-rtl.css +5 -12
  236. package/build-style/content.css +5 -12
  237. package/build-style/default-editor-styles-rtl.css +3 -0
  238. package/build-style/default-editor-styles.css +3 -0
  239. package/build-style/style-rtl.css +88 -46
  240. package/build-style/style.css +88 -46
  241. package/package.json +31 -31
  242. package/src/autocompleters/style.scss +4 -0
  243. package/src/components/block-breadcrumb/index.js +4 -2
  244. package/src/components/block-canvas/style.scss +1 -0
  245. package/src/components/block-draggable/index.js +3 -3
  246. package/src/components/block-list/use-block-props/use-block-refs.js +27 -43
  247. package/src/components/block-mover/index.js +5 -2
  248. package/src/components/block-popover/cover.js +1 -1
  249. package/src/components/block-popover/inbetween.js +1 -1
  250. package/src/components/block-popover/index.js +1 -1
  251. package/src/components/block-tools/block-selection-button.js +1 -2
  252. package/src/components/block-tools/index.js +5 -6
  253. package/src/components/block-tools/use-block-toolbar-popover-props.js +1 -1
  254. package/src/components/block-tools/zoom-out-mode-inserters.js +14 -18
  255. package/src/components/block-tools/zoom-out-toolbar.js +0 -1
  256. package/src/components/button-block-appender/content.scss +1 -1
  257. package/src/components/child-layout-control/index.js +2 -0
  258. package/src/components/color-palette/test/__snapshots__/control.js.snap +2 -2
  259. package/src/components/colors-gradients/test/control.js +3 -2
  260. package/src/components/dimensions-tool/scale-tool.js +1 -0
  261. package/src/components/font-family/README.md +8 -0
  262. package/src/components/font-family/index.js +16 -0
  263. package/src/components/font-family/stories/index.story.js +54 -0
  264. package/src/components/global-styles/background-panel.js +69 -61
  265. package/src/components/global-styles/image-settings-panel.js +1 -0
  266. package/src/components/global-styles/style.scss +0 -10
  267. package/src/components/global-styles/test/theme-file-uri-utils.js +1 -26
  268. package/src/components/global-styles/test/use-global-styles-output.js +49 -4
  269. package/src/components/global-styles/test/utils.js +120 -0
  270. package/src/components/global-styles/theme-file-uri-utils.js +0 -59
  271. package/src/components/global-styles/typography-panel.js +0 -1
  272. package/src/components/global-styles/use-global-styles-output.js +67 -48
  273. package/src/components/global-styles/utils.js +112 -0
  274. package/src/components/grid/grid-item-movers.js +46 -44
  275. package/src/components/grid/grid-item-resizer.js +11 -17
  276. package/src/components/grid/grid-visualizer.js +1 -1
  277. package/src/components/grid/style.scss +60 -10
  278. package/src/components/grid/use-grid-layout-sync.js +68 -14
  279. package/src/components/iframe/content.scss +2 -2
  280. package/src/components/iframe/index.js +3 -7
  281. package/src/components/inserter/category-tabs/index.js +35 -2
  282. package/src/components/inserter/menu.js +2 -2
  283. package/src/components/inserter/style.scss +16 -11
  284. package/src/components/inspector-controls/README.md +5 -0
  285. package/src/components/line-height-control/README.md +0 -8
  286. package/src/components/line-height-control/index.js +1 -21
  287. package/src/components/line-height-control/stories/index.story.js +0 -1
  288. package/src/components/line-height-control/test/index.js +1 -7
  289. package/src/components/link-control/search-input.js +0 -1
  290. package/src/components/media-replace-flow/README.md +7 -0
  291. package/src/components/media-replace-flow/index.js +3 -1
  292. package/src/components/resolution-tool/index.js +1 -0
  293. package/src/components/responsive-block-control/test/index.js +5 -1
  294. package/src/components/skip-to-selected-block/index.js +5 -3
  295. package/src/components/spacing-sizes-control/input-controls/spacing-input-control.js +3 -6
  296. package/src/components/tabbed-sidebar/style.scss +1 -19
  297. package/src/components/url-input/README.md +0 -5
  298. package/src/components/url-input/button.js +0 -1
  299. package/src/components/url-input/index.js +1 -15
  300. package/src/components/url-popover/link-editor.js +0 -1
  301. package/src/components/use-block-drop-zone/index.js +66 -14
  302. package/src/components/use-on-block-drop/index.js +1 -9
  303. package/src/components/use-resize-canvas/index.js +1 -3
  304. package/src/components/use-settings/index.js +2 -1
  305. package/src/hooks/block-bindings.js +303 -52
  306. package/src/hooks/block-bindings.scss +13 -2
  307. package/src/hooks/block-hooks.js +1 -0
  308. package/src/hooks/block-hooks.scss +1 -0
  309. package/src/hooks/block-style-variation.js +3 -3
  310. package/src/hooks/contrast-checker.js +7 -7
  311. package/src/hooks/duotone.js +4 -4
  312. package/src/hooks/index.js +2 -1
  313. package/src/hooks/line-height.js +0 -1
  314. package/src/hooks/spacing-visualizer.js +1 -1
  315. package/src/hooks/use-bindings-attributes.js +4 -0
  316. package/src/hooks/use-editor-wrapper-styles.native.scss +1 -0
  317. package/src/hooks/use-zoom-out.js +1 -1
  318. package/src/hooks/utils.js +14 -1
  319. package/src/index.js +1 -0
  320. package/src/private-apis.js +1 -2
  321. package/src/store/actions.js +13 -5
  322. package/src/store/selectors.js +4 -4
  323. package/src/style.scss +1 -1
  324. package/src/utils/get-editor-region.js +1 -1
  325. package/src/utils/get-px-from-css-unit.js +1 -1
  326. package/tsconfig.tsbuildinfo +1 -1
  327. package/build/components/inserter/block-patterns-tab/pattern-category-preview-panel.js +0 -30
  328. package/build/components/inserter/block-patterns-tab/pattern-category-preview-panel.js.map +0 -1
  329. package/build-module/components/inserter/block-patterns-tab/pattern-category-preview-panel.js +0 -23
  330. package/build-module/components/inserter/block-patterns-tab/pattern-category-preview-panel.js.map +0 -1
  331. package/src/components/inserter/block-patterns-tab/pattern-category-preview-panel.js +0 -25
@@ -232,7 +232,6 @@ export default function useOnBlockDrop(
232
232
  getBlocksByClientId,
233
233
  getSettings,
234
234
  getBlock,
235
- isGroupable,
236
235
  } = useSelect( blockEditorStore );
237
236
  const { getGroupingBlockName } = useSelect( blocksStore );
238
237
  const {
@@ -255,17 +254,11 @@ export default function useOnBlockDrop(
255
254
  if ( ! Array.isArray( blocks ) ) {
256
255
  blocks = [ blocks ];
257
256
  }
258
-
259
257
  const clientIds = getBlockOrder( targetRootClientId );
260
258
  const clientId = clientIds[ targetBlockIndex ];
261
- const blocksClientIds = blocks.map( ( block ) => block.clientId );
262
- const areGroupableBlocks = isGroupable( [
263
- ...blocksClientIds,
264
- clientId,
265
- ] );
266
259
  if ( operation === 'replace' ) {
267
260
  replaceBlocks( clientId, blocks, undefined, initialPosition );
268
- } else if ( operation === 'group' && areGroupableBlocks ) {
261
+ } else if ( operation === 'group' ) {
269
262
  const targetBlock = getBlock( clientId );
270
263
  if ( nearestSide === 'left' ) {
271
264
  blocks.push( targetBlock );
@@ -325,7 +318,6 @@ export default function useOnBlockDrop(
325
318
  getBlockOrder,
326
319
  targetRootClientId,
327
320
  targetBlockIndex,
328
- isGroupable,
329
321
  operation,
330
322
  replaceBlocks,
331
323
  getBlock,
@@ -43,7 +43,7 @@ export default function useResizeCanvas( deviceType ) {
43
43
  return deviceWidth < actualWidth ? deviceWidth : actualWidth;
44
44
  };
45
45
 
46
- const marginValue = () => ( window.innerHeight < 800 ? 36 : 72 );
46
+ const marginValue = () => ( window.innerHeight < 800 ? 36 : 64 );
47
47
 
48
48
  const contentInlineStyles = ( device ) => {
49
49
  const height = device === 'Mobile' ? '768px' : '1024px';
@@ -62,8 +62,6 @@ export default function useResizeCanvas( deviceType ) {
62
62
  marginLeft: marginHorizontal,
63
63
  marginRight: marginHorizontal,
64
64
  height,
65
- borderRadius: '2px 2px 2px 2px',
66
- border: '1px solid #ddd',
67
65
  overflowY: 'auto',
68
66
  };
69
67
  default:
@@ -43,9 +43,10 @@ export function useSettings( ...paths ) {
43
43
  * It looks up the setting first in the block instance hierarchy.
44
44
  * If none is found, it'll look it up in the block editor settings.
45
45
  *
46
+ * @deprecated 6.5.0 Use useSettings instead.
47
+ *
46
48
  * @param {string} path The path to the setting.
47
49
  * @return {any} Returns the value defined for the setting.
48
- * @deprecated 6.5.0 Use useSettings instead.
49
50
  * @example
50
51
  * ```js
51
52
  * const isEnabled = useSetting( 'typography.dropCap' );
@@ -2,42 +2,199 @@
2
2
  * WordPress dependencies
3
3
  */
4
4
  import { __ } from '@wordpress/i18n';
5
- import { store as blocksStore } from '@wordpress/blocks';
5
+ import { privateApis as blocksPrivateApis } from '@wordpress/blocks';
6
6
  import {
7
- BaseControl,
8
- PanelBody,
9
- __experimentalHStack as HStack,
10
7
  __experimentalItemGroup as ItemGroup,
11
8
  __experimentalItem as Item,
9
+ __experimentalText as Text,
10
+ __experimentalToolsPanel as ToolsPanel,
11
+ __experimentalToolsPanelItem as ToolsPanelItem,
12
+ __experimentalTruncate as Truncate,
13
+ __experimentalVStack as VStack,
14
+ privateApis as componentsPrivateApis,
12
15
  } from '@wordpress/components';
13
- import { useSelect } from '@wordpress/data';
16
+ import { useSelect, useDispatch, useRegistry } from '@wordpress/data';
17
+ import { useContext, Fragment } from '@wordpress/element';
18
+ import { useViewportMatch } from '@wordpress/compose';
14
19
 
15
20
  /**
16
21
  * Internal dependencies
17
22
  */
18
- import { canBindAttribute } from '../hooks/use-bindings-attributes';
23
+ import {
24
+ canBindAttribute,
25
+ getBindableAttributes,
26
+ } from '../hooks/use-bindings-attributes';
27
+ import { store as blockEditorStore } from '../store';
19
28
  import { unlock } from '../lock-unlock';
20
29
  import InspectorControls from '../components/inspector-controls';
30
+ import BlockContext from '../components/block-context';
31
+
32
+ const {
33
+ DropdownMenuV2: DropdownMenu,
34
+ DropdownMenuGroupV2: DropdownMenuGroup,
35
+ DropdownMenuRadioItemV2: DropdownMenuRadioItem,
36
+ DropdownMenuItemLabelV2: DropdownMenuItemLabel,
37
+ DropdownMenuItemHelpTextV2: DropdownMenuItemHelpText,
38
+ DropdownMenuSeparatorV2: DropdownMenuSeparator,
39
+ } = unlock( componentsPrivateApis );
40
+
41
+ const useToolsPanelDropdownMenuProps = () => {
42
+ const isMobile = useViewportMatch( 'medium', '<' );
43
+ return ! isMobile
44
+ ? {
45
+ popoverProps: {
46
+ placement: 'left-start',
47
+ // For non-mobile, inner sidebar width (248px) - button width (24px) - border (1px) + padding (16px) + spacing (20px)
48
+ offset: 259,
49
+ },
50
+ }
51
+ : {};
52
+ };
53
+
54
+ function BlockBindingsPanelDropdown( {
55
+ fieldsList,
56
+ addConnection,
57
+ attribute,
58
+ binding,
59
+ } ) {
60
+ const currentKey = binding?.args?.key;
61
+ return (
62
+ <>
63
+ { Object.entries( fieldsList ).map( ( [ label, fields ], i ) => (
64
+ <Fragment key={ label }>
65
+ <DropdownMenuGroup>
66
+ { Object.keys( fieldsList ).length > 1 && (
67
+ <Text
68
+ className="block-editor-bindings__source-label"
69
+ upperCase
70
+ variant="muted"
71
+ aria-hidden
72
+ >
73
+ { label }
74
+ </Text>
75
+ ) }
76
+ { Object.entries( fields ).map( ( [ key, value ] ) => (
77
+ <DropdownMenuRadioItem
78
+ key={ key }
79
+ onChange={ () =>
80
+ addConnection( key, attribute )
81
+ }
82
+ name={ attribute + '-binding' }
83
+ value={ key }
84
+ checked={ key === currentKey }
85
+ >
86
+ <DropdownMenuItemLabel>
87
+ { key }
88
+ </DropdownMenuItemLabel>
89
+ <DropdownMenuItemHelpText>
90
+ { value }
91
+ </DropdownMenuItemHelpText>
92
+ </DropdownMenuRadioItem>
93
+ ) ) }
94
+ </DropdownMenuGroup>
95
+ { i !== Object.keys( fieldsList ).length - 1 && (
96
+ <DropdownMenuSeparator />
97
+ ) }
98
+ </Fragment>
99
+ ) ) }
100
+ </>
101
+ );
102
+ }
103
+
104
+ function BlockBindingsAttribute( { attribute, binding } ) {
105
+ const { source: sourceName, args } = binding || {};
106
+ const sourceProps =
107
+ unlock( blocksPrivateApis ).getBlockBindingsSource( sourceName );
108
+ return (
109
+ <VStack>
110
+ <Truncate>{ attribute }</Truncate>
111
+ { !! binding && (
112
+ <Text
113
+ variant="muted"
114
+ className="block-editor-bindings__item-explanation"
115
+ >
116
+ <Truncate>
117
+ { args?.key || sourceProps?.label || sourceName }
118
+ </Truncate>
119
+ </Text>
120
+ ) }
121
+ </VStack>
122
+ );
123
+ }
124
+
125
+ function ReadOnlyBlockBindingsPanelItems( { bindings } ) {
126
+ return (
127
+ <>
128
+ { Object.entries( bindings ).map( ( [ attribute, binding ] ) => (
129
+ <Item key={ attribute }>
130
+ <BlockBindingsAttribute
131
+ attribute={ attribute }
132
+ binding={ binding }
133
+ />
134
+ </Item>
135
+ ) ) }
136
+ </>
137
+ );
138
+ }
139
+
140
+ function EditableBlockBindingsPanelItems( {
141
+ attributes,
142
+ bindings,
143
+ fieldsList,
144
+ addConnection,
145
+ removeConnection,
146
+ } ) {
147
+ const isMobile = useViewportMatch( 'medium', '<' );
148
+ return (
149
+ <>
150
+ { attributes.map( ( attribute ) => {
151
+ const binding = bindings[ attribute ];
152
+ return (
153
+ <ToolsPanelItem
154
+ key={ attribute }
155
+ hasValue={ () => !! binding }
156
+ label={ attribute }
157
+ onDeselect={ () => {
158
+ removeConnection( attribute );
159
+ } }
160
+ >
161
+ <DropdownMenu
162
+ placement={
163
+ isMobile ? 'bottom-start' : 'left-start'
164
+ }
165
+ gutter={ isMobile ? 8 : 36 }
166
+ className="block-editor-bindings__popover"
167
+ trigger={
168
+ <Item>
169
+ <BlockBindingsAttribute
170
+ attribute={ attribute }
171
+ binding={ binding }
172
+ />
173
+ </Item>
174
+ }
175
+ >
176
+ <BlockBindingsPanelDropdown
177
+ fieldsList={ fieldsList }
178
+ addConnection={ addConnection }
179
+ attribute={ attribute }
180
+ binding={ binding }
181
+ />
182
+ </DropdownMenu>
183
+ </ToolsPanelItem>
184
+ );
185
+ } ) }
186
+ </>
187
+ );
188
+ }
21
189
 
22
190
  export const BlockBindingsPanel = ( { name, metadata } ) => {
191
+ const registry = useRegistry();
192
+ const blockContext = useContext( BlockContext );
23
193
  const { bindings } = metadata || {};
24
- const { sources } = useSelect( ( select ) => {
25
- const _sources = unlock(
26
- select( blocksStore )
27
- ).getAllBlockBindingsSources();
28
194
 
29
- return {
30
- sources: _sources,
31
- };
32
- }, [] );
33
-
34
- if ( ! bindings ) {
35
- return null;
36
- }
195
+ const bindableAttributes = getBindableAttributes( name );
196
+ const dropdownMenuProps = useToolsPanelDropdownMenuProps();
37
197
 
38
- // Don't show not allowed attributes.
39
- // Don't show the bindings connected to pattern overrides in the inspectors panel.
40
- // TODO: Explore if this should be abstracted to let other sources decide.
41
198
  const filteredBindings = { ...bindings };
42
199
  Object.keys( filteredBindings ).forEach( ( key ) => {
43
200
  if (
@@ -48,43 +205,137 @@ export const BlockBindingsPanel = ( { name, metadata } ) => {
48
205
  }
49
206
  } );
50
207
 
51
- if ( Object.keys( filteredBindings ).length === 0 ) {
208
+ const { updateBlockAttributes } = useDispatch( blockEditorStore );
209
+
210
+ const { _id } = useSelect( ( select ) => {
211
+ const { getSelectedBlockClientId } = select( blockEditorStore );
212
+
213
+ return {
214
+ _id: getSelectedBlockClientId(),
215
+ };
216
+ }, [] );
217
+
218
+ if ( ! bindableAttributes || bindableAttributes.length === 0 ) {
219
+ return null;
220
+ }
221
+
222
+ const removeAllConnections = () => {
223
+ const newMetadata = { ...metadata };
224
+ delete newMetadata.bindings;
225
+ updateBlockAttributes( _id, {
226
+ metadata:
227
+ Object.keys( newMetadata ).length === 0
228
+ ? undefined
229
+ : newMetadata,
230
+ } );
231
+ };
232
+
233
+ const addConnection = ( value, attribute ) => {
234
+ // Assuming the block expects a flat structure for its metadata attribute
235
+ const newMetadata = {
236
+ ...metadata,
237
+ // Adjust this according to the actual structure expected by your block
238
+ bindings: {
239
+ ...metadata?.bindings,
240
+ [ attribute ]: {
241
+ source: 'core/post-meta',
242
+ args: { key: value },
243
+ },
244
+ },
245
+ };
246
+ // Update the block's attributes with the new metadata
247
+ updateBlockAttributes( _id, {
248
+ metadata: newMetadata,
249
+ } );
250
+ };
251
+
252
+ const removeConnection = ( key ) => {
253
+ const newMetadata = { ...metadata };
254
+ if ( ! newMetadata.bindings ) {
255
+ return;
256
+ }
257
+
258
+ delete newMetadata.bindings[ key ];
259
+ if ( Object.keys( newMetadata.bindings ).length === 0 ) {
260
+ delete newMetadata.bindings;
261
+ }
262
+ updateBlockAttributes( _id, {
263
+ metadata:
264
+ Object.keys( newMetadata ).length === 0
265
+ ? undefined
266
+ : newMetadata,
267
+ } );
268
+ };
269
+
270
+ const fieldsList = {};
271
+ const { getBlockBindingsSources } = unlock( blocksPrivateApis );
272
+ const registeredSources = getBlockBindingsSources();
273
+ Object.values( registeredSources ).forEach(
274
+ ( { getFieldsList, label, usesContext } ) => {
275
+ if ( getFieldsList ) {
276
+ // Populate context.
277
+ const context = {};
278
+ if ( usesContext?.length ) {
279
+ for ( const key of usesContext ) {
280
+ context[ key ] = blockContext[ key ];
281
+ }
282
+ }
283
+ const sourceList = getFieldsList( {
284
+ registry,
285
+ context,
286
+ } );
287
+ // Only add source if the list is not empty.
288
+ if ( sourceList ) {
289
+ fieldsList[ label ] = { ...sourceList };
290
+ }
291
+ }
292
+ }
293
+ );
294
+ // Remove empty sources.
295
+ Object.entries( fieldsList ).forEach( ( [ key, value ] ) => {
296
+ if ( ! Object.keys( value ).length ) {
297
+ delete fieldsList[ key ];
298
+ }
299
+ } );
300
+
301
+ // Lock the UI when the experiment is not enabled or there are no fields to connect to.
302
+ const readOnly =
303
+ ! window.__experimentalBlockBindingsUI ||
304
+ ! Object.keys( fieldsList ).length;
305
+
306
+ if ( readOnly && Object.keys( filteredBindings ).length === 0 ) {
52
307
  return null;
53
308
  }
54
309
 
55
310
  return (
56
311
  <InspectorControls>
57
- <PanelBody
58
- title={ __( 'Attributes' ) }
59
- className="components-panel__block-bindings-panel"
312
+ <ToolsPanel
313
+ label={ __( 'Attributes' ) }
314
+ resetAll={ () => {
315
+ removeAllConnections();
316
+ } }
317
+ dropdownMenuProps={ dropdownMenuProps }
318
+ className="block-editor-bindings__panel"
60
319
  >
61
- <BaseControl
62
- help={ __( 'Attributes connected to various sources.' ) }
63
- >
64
- <ItemGroup isBordered isSeparated size="large">
65
- { Object.keys( filteredBindings ).map( ( key ) => {
66
- return (
67
- <Item key={ key }>
68
- <HStack>
69
- <span>{ key }</span>
70
- <span className="components-item__block-bindings-source">
71
- { sources[
72
- filteredBindings[ key ].source
73
- ]
74
- ? sources[
75
- filteredBindings[ key ]
76
- .source
77
- ].label
78
- : filteredBindings[ key ]
79
- .source }
80
- </span>
81
- </HStack>
82
- </Item>
83
- );
84
- } ) }
85
- </ItemGroup>
86
- </BaseControl>
87
- </PanelBody>
320
+ <ItemGroup isBordered isSeparated>
321
+ { readOnly ? (
322
+ <ReadOnlyBlockBindingsPanelItems
323
+ bindings={ filteredBindings }
324
+ />
325
+ ) : (
326
+ <EditableBlockBindingsPanelItems
327
+ attributes={ bindableAttributes }
328
+ bindings={ filteredBindings }
329
+ fieldsList={ fieldsList }
330
+ addConnection={ addConnection }
331
+ removeConnection={ removeConnection }
332
+ />
333
+ ) }
334
+ </ItemGroup>
335
+ <Text variant="muted">
336
+ { __( 'Attributes connected to various sources.' ) }
337
+ </Text>
338
+ </ToolsPanel>
88
339
  </InspectorControls>
89
340
  );
90
341
  };
@@ -1,3 +1,14 @@
1
- .components-panel__block-bindings-panel .components-item__block-bindings-source {
2
- color: $gray-700;
1
+ div.block-editor-bindings__panel {
2
+ grid-template-columns: auto;
3
+ button:hover .block-editor-bindings__item-explanation {
4
+ color: inherit;
5
+ }
6
+ }
7
+
8
+ .block-editor-bindings__popover {
9
+ // This won't be needed if `DropdownMenuGroup` component handles the label.
10
+ .block-editor-bindings__source-label {
11
+ grid-column: 2;
12
+ margin: $grid-unit-10 0;
13
+ }
3
14
  }
@@ -201,6 +201,7 @@ function BlockHooksControlPure( {
201
201
 
202
202
  return (
203
203
  <ToggleControl
204
+ __nextHasNoMarginBottom
204
205
  checked={ checked }
205
206
  key={ block.title }
206
207
  label={
@@ -4,6 +4,7 @@
4
4
  * we need to right-align the toggle.
5
5
  */
6
6
  .components-toggle-control .components-h-stack {
7
+ /* stylelint-disable-next-line declaration-property-value-allowed-list -- This should be refactored to not use the row-reverse value. */
7
8
  flex-direction: row-reverse;
8
9
  }
9
10
 
@@ -13,7 +13,7 @@ import {
13
13
  toStyles,
14
14
  getBlockSelectors,
15
15
  } from '../components/global-styles';
16
- import { useStyleOverride } from './utils';
16
+ import { usePrivateStyleOverride } from './utils';
17
17
  import { getValueFromObjectPath } from '../utils/object';
18
18
  import { store as blockEditorStore } from '../store';
19
19
  import { globalStylesDataKey } from '../store/private-keys';
@@ -63,7 +63,7 @@ function getVariationNameFromClass( className, registeredStyles = [] ) {
63
63
 
64
64
  // A helper component to apply a style override using the useStyleOverride hook.
65
65
  function OverrideStyles( { override } ) {
66
- useStyleOverride( override );
66
+ usePrivateStyleOverride( override );
67
67
  }
68
68
 
69
69
  /**
@@ -351,7 +351,7 @@ function useBlockProps( { name, className, clientId } ) {
351
351
  );
352
352
  }, [ variation, settings, styles, getBlockStyles, clientId ] );
353
353
 
354
- useStyleOverride( {
354
+ usePrivateStyleOverride( {
355
355
  id: `variation-${ clientId }`,
356
356
  css: variationStyles,
357
357
  __unstableType: 'variation',
@@ -7,7 +7,7 @@ import { useState, useEffect } from '@wordpress/element';
7
7
  * Internal dependencies
8
8
  */
9
9
  import ContrastChecker from '../components/contrast-checker';
10
- import { __unstableUseBlockRef as useBlockRef } from '../components/block-list/use-block-props/use-block-refs';
10
+ import { useBlockElement } from '../components/block-list/use-block-props/use-block-refs';
11
11
 
12
12
  function getComputedStyle( node ) {
13
13
  return node.ownerDocument.defaultView.getComputedStyle( node );
@@ -17,23 +17,23 @@ export default function BlockColorContrastChecker( { clientId } ) {
17
17
  const [ detectedBackgroundColor, setDetectedBackgroundColor ] = useState();
18
18
  const [ detectedColor, setDetectedColor ] = useState();
19
19
  const [ detectedLinkColor, setDetectedLinkColor ] = useState();
20
- const ref = useBlockRef( clientId );
20
+ const blockEl = useBlockElement( clientId );
21
21
 
22
22
  // There are so many things that can change the color of a block
23
23
  // So we perform this check on every render.
24
24
  // eslint-disable-next-line react-hooks/exhaustive-deps
25
25
  useEffect( () => {
26
- if ( ! ref.current ) {
26
+ if ( ! blockEl ) {
27
27
  return;
28
28
  }
29
- setDetectedColor( getComputedStyle( ref.current ).color );
29
+ setDetectedColor( getComputedStyle( blockEl ).color );
30
30
 
31
- const firstLinkElement = ref.current?.querySelector( 'a' );
31
+ const firstLinkElement = blockEl.querySelector( 'a' );
32
32
  if ( firstLinkElement && !! firstLinkElement.innerText ) {
33
33
  setDetectedLinkColor( getComputedStyle( firstLinkElement ).color );
34
34
  }
35
35
 
36
- let backgroundColorNode = ref.current;
36
+ let backgroundColorNode = blockEl;
37
37
  let backgroundColor =
38
38
  getComputedStyle( backgroundColorNode ).backgroundColor;
39
39
  while (
@@ -48,7 +48,7 @@ export default function BlockColorContrastChecker( { clientId } ) {
48
48
  }
49
49
 
50
50
  setDetectedBackgroundColor( backgroundColor );
51
- } );
51
+ }, [ blockEl ] );
52
52
 
53
53
  return (
54
54
  <ContrastChecker
@@ -32,10 +32,10 @@ import {
32
32
  } from '../components/duotone/utils';
33
33
  import { getBlockCSSSelector } from '../components/global-styles/get-block-css-selector';
34
34
  import { scopeSelector } from '../components/global-styles/utils';
35
- import { useBlockSettings, useStyleOverride } from './utils';
35
+ import { useBlockSettings, usePrivateStyleOverride } from './utils';
36
36
  import { default as StylesFiltersPanel } from '../components/global-styles/filters-panel';
37
37
  import { useBlockEditingMode } from '../components/block-editing-mode';
38
- import { __unstableUseBlockElement as useBlockElement } from '../components/block-list/use-block-props/use-block-refs';
38
+ import { useBlockElement } from '../components/block-list/use-block-props/use-block-refs';
39
39
 
40
40
  const EMPTY_ARRAY = [];
41
41
 
@@ -265,7 +265,7 @@ function useDuotoneStyles( {
265
265
 
266
266
  const isValidFilter = Array.isArray( colors ) || colors === 'unset';
267
267
 
268
- useStyleOverride(
268
+ usePrivateStyleOverride(
269
269
  isValidFilter
270
270
  ? {
271
271
  css:
@@ -276,7 +276,7 @@ function useDuotoneStyles( {
276
276
  }
277
277
  : undefined
278
278
  );
279
- useStyleOverride(
279
+ usePrivateStyleOverride(
280
280
  isValidFilter
281
281
  ? {
282
282
  assets:
@@ -37,7 +37,6 @@ import './grid-visualizer';
37
37
 
38
38
  createBlockEditFilter(
39
39
  [
40
- blockBindingsPanel,
41
40
  align,
42
41
  textAlign,
43
42
  anchor,
@@ -48,6 +47,7 @@ createBlockEditFilter(
48
47
  layout,
49
48
  contentLockUI,
50
49
  blockHooks,
50
+ blockBindingsPanel,
51
51
  childLayout,
52
52
  ].filter( Boolean )
53
53
  );
@@ -91,3 +91,4 @@ export { useCachedTruthy } from './use-cached-truthy';
91
91
  export { setBackgroundStyleDefaults } from './background';
92
92
  export { useZoomOut } from './use-zoom-out';
93
93
  export { __unstableBlockStyleVariationOverridesWithConfig } from './block-style-variation';
94
+ export { useStyleOverride } from './utils';
@@ -39,7 +39,6 @@ export function LineHeightEdit( props ) {
39
39
  return (
40
40
  <LineHeightControl
41
41
  __unstableInputWidth="100%"
42
- __nextHasNoMarginBottom
43
42
  value={ style?.typography?.lineHeight }
44
43
  onChange={ onChange }
45
44
  size="__unstable-large"
@@ -14,7 +14,7 @@ import isShallowEqual from '@wordpress/is-shallow-equal';
14
14
  * Internal dependencies
15
15
  */
16
16
  import BlockPopoverCover from '../components/block-popover/cover';
17
- import { __unstableUseBlockElement as useBlockElement } from '../components/block-list/use-block-props/use-block-refs';
17
+ import { useBlockElement } from '../components/block-list/use-block-props/use-block-refs';
18
18
 
19
19
  function SpacingVisualizer( { clientId, value, computeStyle, forceShow } ) {
20
20
  const blockElement = useBlockElement( clientId );
@@ -91,6 +91,10 @@ export function canBindAttribute( blockName, attributeName ) {
91
91
  );
92
92
  }
93
93
 
94
+ export function getBindableAttributes( blockName ) {
95
+ return BLOCK_BINDINGS_ALLOWED_BLOCKS[ blockName ];
96
+ }
97
+
94
98
  export const withBlockBindingSupport = createHigherOrderComponent(
95
99
  ( BlockEdit ) => ( props ) => {
96
100
  const registry = useRegistry();
@@ -5,6 +5,7 @@
5
5
  }
6
6
 
7
7
  .use-editor-wrapper-styles--reversed {
8
+ /* stylelint-disable-next-line declaration-property-value-allowed-list -- This should be refactored to not use the column-reverse value. */
8
9
  flex-direction: column-reverse;
9
10
  width: 100%;
10
11
  max-width: 580;
@@ -49,5 +49,5 @@ export function useZoomOut( zoomOut = true ) {
49
49
  ) {
50
50
  __unstableSetEditorMode( originalEditingMode.current );
51
51
  }
52
- }, [ __unstableSetEditorMode, zoomOut, mode ] );
52
+ }, [ __unstableGetEditorMode, __unstableSetEditorMode, zoomOut ] ); // Mode is deliberately excluded from the dependencies so that the effect does not run when mode changes.
53
53
  }
@@ -135,7 +135,20 @@ export function shouldSkipSerialization(
135
135
 
136
136
  const pendingStyleOverrides = new WeakMap();
137
137
 
138
- export function useStyleOverride( {
138
+ /**
139
+ * Override a block editor settings style. Leave the ID blank to create a new
140
+ * style.
141
+ *
142
+ * @param {Object} override Override object.
143
+ * @param {?string} override.id Id of the style override, leave blank to create
144
+ * a new style.
145
+ * @param {string} override.css CSS to apply.
146
+ */
147
+ export function useStyleOverride( { id, css } ) {
148
+ return usePrivateStyleOverride( { id, css } );
149
+ }
150
+
151
+ export function usePrivateStyleOverride( {
139
152
  id,
140
153
  css,
141
154
  assets,