@wordpress/block-editor 12.0.0 → 12.1.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 (311) hide show
  1. package/CHANGELOG.md +4 -0
  2. package/README.md +1 -1
  3. package/build/components/block-controls/slot.js +12 -4
  4. package/build/components/block-controls/slot.js.map +1 -1
  5. package/build/components/block-controls/slot.native.js +10 -1
  6. package/build/components/block-controls/slot.native.js.map +1 -1
  7. package/build/components/block-draggable/index.js +11 -7
  8. package/build/components/block-draggable/index.js.map +1 -1
  9. package/build/components/block-draggable/use-scroll-when-dragging.js +2 -2
  10. package/build/components/block-draggable/use-scroll-when-dragging.js.map +1 -1
  11. package/build/components/block-list/block-invalid-warning.native.js +15 -7
  12. package/build/components/block-list/block-invalid-warning.native.js.map +1 -1
  13. package/build/components/block-list/block-list-item-cell.native.js +15 -2
  14. package/build/components/block-list/block-list-item-cell.native.js.map +1 -1
  15. package/build/components/block-list/block-list-item.native.js +158 -195
  16. package/build/components/block-list/block-list-item.native.js.map +1 -1
  17. package/build/components/block-list/block-outline.native.js +57 -0
  18. package/build/components/block-list/block-outline.native.js.map +1 -0
  19. package/build/components/block-list/block.native.js +343 -299
  20. package/build/components/block-list/block.native.js.map +1 -1
  21. package/build/components/block-list/index.native.js +202 -298
  22. package/build/components/block-list/index.native.js.map +1 -1
  23. package/build/components/block-list/insertion-point.native.js +4 -2
  24. package/build/components/block-list/insertion-point.native.js.map +1 -1
  25. package/build/components/block-mobile-toolbar/block-actions-menu.native.js +1 -1
  26. package/build/components/block-mobile-toolbar/block-actions-menu.native.js.map +1 -1
  27. package/build/components/block-settings-menu/block-settings-dropdown.js +8 -10
  28. package/build/components/block-settings-menu/block-settings-dropdown.js.map +1 -1
  29. package/build/components/block-settings-menu-controls/index.js +15 -4
  30. package/build/components/block-settings-menu-controls/index.js.map +1 -1
  31. package/build/components/block-tools/block-contextual-toolbar.js +17 -62
  32. package/build/components/block-tools/block-contextual-toolbar.js.map +1 -1
  33. package/build/components/block-tools/selected-block-popover.js +3 -8
  34. package/build/components/block-tools/selected-block-popover.js.map +1 -1
  35. package/build/components/colors-gradients/use-multiple-origin-colors-and-gradients.js +3 -2
  36. package/build/components/colors-gradients/use-multiple-origin-colors-and-gradients.js.map +1 -1
  37. package/build/components/global-styles/advanced-panel.js +86 -0
  38. package/build/components/global-styles/advanced-panel.js.map +1 -0
  39. package/build/components/global-styles/color-panel.js +4 -1
  40. package/build/components/global-styles/color-panel.js.map +1 -1
  41. package/build/components/global-styles/dimensions-panel.js +6 -6
  42. package/build/components/global-styles/dimensions-panel.js.map +1 -1
  43. package/build/components/global-styles/hooks.js +1 -2
  44. package/build/components/global-styles/hooks.js.map +1 -1
  45. package/build/components/global-styles/index.js +24 -0
  46. package/build/components/global-styles/index.js.map +1 -1
  47. package/build/components/global-styles/typography-panel.js +1 -1
  48. package/build/components/global-styles/typography-panel.js.map +1 -1
  49. package/build/components/global-styles/use-global-styles-output.js +27 -4
  50. package/build/components/global-styles/use-global-styles-output.js.map +1 -1
  51. package/build/components/global-styles/utils.js +30 -0
  52. package/build/components/global-styles/utils.js.map +1 -1
  53. package/build/components/image-editor/use-save-image.js +24 -8
  54. package/build/components/image-editor/use-save-image.js.map +1 -1
  55. package/build/components/inserter-draggable-blocks/index.js +5 -0
  56. package/build/components/inserter-draggable-blocks/index.js.map +1 -1
  57. package/build/components/inspector-controls/fill.js +1 -1
  58. package/build/components/inspector-controls/fill.js.map +1 -1
  59. package/build/components/inspector-controls/fill.native.js +1 -1
  60. package/build/components/inspector-controls/fill.native.js.map +1 -1
  61. package/build/components/inspector-controls/slot.js +3 -6
  62. package/build/components/inspector-controls/slot.js.map +1 -1
  63. package/build/components/inspector-controls/slot.native.js +1 -1
  64. package/build/components/inspector-controls/slot.native.js.map +1 -1
  65. package/build/components/line-height-control/index.js +7 -2
  66. package/build/components/line-height-control/index.js.map +1 -1
  67. package/build/components/link-control/use-internal-input-value.js +9 -8
  68. package/build/components/link-control/use-internal-input-value.js.map +1 -1
  69. package/build/components/list-view/block-contents.js +7 -2
  70. package/build/components/list-view/block-contents.js.map +1 -1
  71. package/build/components/list-view/block-select-button.js +2 -1
  72. package/build/components/list-view/block-select-button.js.map +1 -1
  73. package/build/components/list-view/block.js +4 -4
  74. package/build/components/list-view/block.js.map +1 -1
  75. package/build/components/list-view/index.js +32 -18
  76. package/build/components/list-view/index.js.map +1 -1
  77. package/build/components/list-view/use-list-view-drop-zone.js +163 -11
  78. package/build/components/list-view/use-list-view-drop-zone.js.map +1 -1
  79. package/build/components/media-placeholder/index.js +68 -7
  80. package/build/components/media-placeholder/index.js.map +1 -1
  81. package/build/components/multi-selection-inspector/index.js +2 -2
  82. package/build/components/multi-selection-inspector/index.js.map +1 -1
  83. package/build/components/off-canvas-editor/leaf-more-menu.js +3 -1
  84. package/build/components/off-canvas-editor/leaf-more-menu.js.map +1 -1
  85. package/build/components/preview-options/index.js +6 -1
  86. package/build/components/preview-options/index.js.map +1 -1
  87. package/build/components/spacing-sizes-control/spacing-input-control.js +1 -1
  88. package/build/components/spacing-sizes-control/spacing-input-control.js.map +1 -1
  89. package/build/components/url-input/index.js +1 -2
  90. package/build/components/url-input/index.js.map +1 -1
  91. package/build/hooks/align.js +1 -1
  92. package/build/hooks/align.js.map +1 -1
  93. package/build/hooks/border.js +1 -1
  94. package/build/hooks/border.js.map +1 -1
  95. package/build/hooks/color.js +1 -1
  96. package/build/hooks/color.js.map +1 -1
  97. package/build/hooks/content-lock-ui.js +8 -12
  98. package/build/hooks/content-lock-ui.js.map +1 -1
  99. package/build/hooks/duotone.js +1 -1
  100. package/build/hooks/duotone.js.map +1 -1
  101. package/build/hooks/index.native.js +8 -0
  102. package/build/hooks/index.native.js.map +1 -1
  103. package/build/hooks/layout.js +2 -2
  104. package/build/hooks/layout.js.map +1 -1
  105. package/build/hooks/position.js +1 -1
  106. package/build/hooks/position.js.map +1 -1
  107. package/build/hooks/style.js +1 -1
  108. package/build/hooks/style.js.map +1 -1
  109. package/build/hooks/use-editor-wrapper-styles.native.js +255 -0
  110. package/build/hooks/use-editor-wrapper-styles.native.js.map +1 -0
  111. package/build/hooks/use-typography-props.js +14 -10
  112. package/build/hooks/use-typography-props.js.map +1 -1
  113. package/build/index.native.js +31 -0
  114. package/build/index.native.js.map +1 -0
  115. package/build/utils/use-should-contextual-toolbar-show.js +16 -12
  116. package/build/utils/use-should-contextual-toolbar-show.js.map +1 -1
  117. package/build-module/components/block-controls/slot.js +11 -4
  118. package/build-module/components/block-controls/slot.js.map +1 -1
  119. package/build-module/components/block-controls/slot.native.js +9 -1
  120. package/build-module/components/block-controls/slot.native.js.map +1 -1
  121. package/build-module/components/block-draggable/index.js +10 -6
  122. package/build-module/components/block-draggable/index.js.map +1 -1
  123. package/build-module/components/block-draggable/use-scroll-when-dragging.js +2 -2
  124. package/build-module/components/block-draggable/use-scroll-when-dragging.js.map +1 -1
  125. package/build-module/components/block-list/block-invalid-warning.native.js +16 -8
  126. package/build-module/components/block-list/block-invalid-warning.native.js.map +1 -1
  127. package/build-module/components/block-list/block-list-item-cell.native.js +13 -2
  128. package/build-module/components/block-list/block-list-item-cell.native.js.map +1 -1
  129. package/build-module/components/block-list/block-list-item.native.js +160 -190
  130. package/build-module/components/block-list/block-list-item.native.js.map +1 -1
  131. package/build-module/components/block-list/block-outline.native.js +44 -0
  132. package/build-module/components/block-list/block-outline.native.js.map +1 -0
  133. package/build-module/components/block-list/block.native.js +341 -298
  134. package/build-module/components/block-list/block.native.js.map +1 -1
  135. package/build-module/components/block-list/index.native.js +203 -293
  136. package/build-module/components/block-list/index.native.js.map +1 -1
  137. package/build-module/components/block-list/insertion-point.native.js +4 -2
  138. package/build-module/components/block-list/insertion-point.native.js.map +1 -1
  139. package/build-module/components/block-mobile-toolbar/block-actions-menu.native.js +1 -1
  140. package/build-module/components/block-mobile-toolbar/block-actions-menu.native.js.map +1 -1
  141. package/build-module/components/block-settings-menu/block-settings-dropdown.js +8 -9
  142. package/build-module/components/block-settings-menu/block-settings-dropdown.js.map +1 -1
  143. package/build-module/components/block-settings-menu-controls/index.js +13 -5
  144. package/build-module/components/block-settings-menu-controls/index.js.map +1 -1
  145. package/build-module/components/block-tools/block-contextual-toolbar.js +18 -62
  146. package/build-module/components/block-tools/block-contextual-toolbar.js.map +1 -1
  147. package/build-module/components/block-tools/selected-block-popover.js +3 -7
  148. package/build-module/components/block-tools/selected-block-popover.js.map +1 -1
  149. package/build-module/components/colors-gradients/use-multiple-origin-colors-and-gradients.js +3 -2
  150. package/build-module/components/colors-gradients/use-multiple-origin-colors-and-gradients.js.map +1 -1
  151. package/build-module/components/global-styles/advanced-panel.js +74 -0
  152. package/build-module/components/global-styles/advanced-panel.js.map +1 -0
  153. package/build-module/components/global-styles/color-panel.js +5 -2
  154. package/build-module/components/global-styles/color-panel.js.map +1 -1
  155. package/build-module/components/global-styles/dimensions-panel.js +6 -6
  156. package/build-module/components/global-styles/dimensions-panel.js.map +1 -1
  157. package/build-module/components/global-styles/hooks.js +1 -2
  158. package/build-module/components/global-styles/hooks.js.map +1 -1
  159. package/build-module/components/global-styles/index.js +3 -1
  160. package/build-module/components/global-styles/index.js.map +1 -1
  161. package/build-module/components/global-styles/typography-panel.js +1 -1
  162. package/build-module/components/global-styles/typography-panel.js.map +1 -1
  163. package/build-module/components/global-styles/use-global-styles-output.js +25 -4
  164. package/build-module/components/global-styles/use-global-styles-output.js.map +1 -1
  165. package/build-module/components/global-styles/utils.js +25 -0
  166. package/build-module/components/global-styles/utils.js.map +1 -1
  167. package/build-module/components/image-editor/use-save-image.js +24 -8
  168. package/build-module/components/image-editor/use-save-image.js.map +1 -1
  169. package/build-module/components/inserter-draggable-blocks/index.js +4 -0
  170. package/build-module/components/inserter-draggable-blocks/index.js.map +1 -1
  171. package/build-module/components/inspector-controls/fill.js +1 -1
  172. package/build-module/components/inspector-controls/fill.js.map +1 -1
  173. package/build-module/components/inspector-controls/fill.native.js +1 -1
  174. package/build-module/components/inspector-controls/fill.native.js.map +1 -1
  175. package/build-module/components/inspector-controls/slot.js +4 -7
  176. package/build-module/components/inspector-controls/slot.js.map +1 -1
  177. package/build-module/components/inspector-controls/slot.native.js +1 -1
  178. package/build-module/components/inspector-controls/slot.native.js.map +1 -1
  179. package/build-module/components/line-height-control/index.js +7 -2
  180. package/build-module/components/line-height-control/index.js.map +1 -1
  181. package/build-module/components/link-control/use-internal-input-value.js +9 -8
  182. package/build-module/components/link-control/use-internal-input-value.js.map +1 -1
  183. package/build-module/components/list-view/block-contents.js +7 -3
  184. package/build-module/components/list-view/block-contents.js.map +1 -1
  185. package/build-module/components/list-view/block-select-button.js +2 -1
  186. package/build-module/components/list-view/block-select-button.js.map +1 -1
  187. package/build-module/components/list-view/block.js +4 -4
  188. package/build-module/components/list-view/block.js.map +1 -1
  189. package/build-module/components/list-view/index.js +32 -18
  190. package/build-module/components/list-view/index.js.map +1 -1
  191. package/build-module/components/list-view/use-list-view-drop-zone.js +160 -11
  192. package/build-module/components/list-view/use-list-view-drop-zone.js.map +1 -1
  193. package/build-module/components/media-placeholder/index.js +66 -7
  194. package/build-module/components/media-placeholder/index.js.map +1 -1
  195. package/build-module/components/multi-selection-inspector/index.js +2 -2
  196. package/build-module/components/multi-selection-inspector/index.js.map +1 -1
  197. package/build-module/components/off-canvas-editor/leaf-more-menu.js +3 -1
  198. package/build-module/components/off-canvas-editor/leaf-more-menu.js.map +1 -1
  199. package/build-module/components/preview-options/index.js +7 -2
  200. package/build-module/components/preview-options/index.js.map +1 -1
  201. package/build-module/components/spacing-sizes-control/spacing-input-control.js +1 -1
  202. package/build-module/components/spacing-sizes-control/spacing-input-control.js.map +1 -1
  203. package/build-module/components/url-input/index.js +1 -2
  204. package/build-module/components/url-input/index.js.map +1 -1
  205. package/build-module/hooks/align.js +1 -1
  206. package/build-module/hooks/align.js.map +1 -1
  207. package/build-module/hooks/border.js +1 -1
  208. package/build-module/hooks/border.js.map +1 -1
  209. package/build-module/hooks/color.js +1 -1
  210. package/build-module/hooks/color.js.map +1 -1
  211. package/build-module/hooks/content-lock-ui.js +8 -11
  212. package/build-module/hooks/content-lock-ui.js.map +1 -1
  213. package/build-module/hooks/duotone.js +1 -1
  214. package/build-module/hooks/duotone.js.map +1 -1
  215. package/build-module/hooks/index.native.js +1 -0
  216. package/build-module/hooks/index.native.js.map +1 -1
  217. package/build-module/hooks/layout.js +2 -2
  218. package/build-module/hooks/layout.js.map +1 -1
  219. package/build-module/hooks/position.js +1 -1
  220. package/build-module/hooks/position.js.map +1 -1
  221. package/build-module/hooks/style.js +1 -1
  222. package/build-module/hooks/style.js.map +1 -1
  223. package/build-module/hooks/use-editor-wrapper-styles.native.js +242 -0
  224. package/build-module/hooks/use-editor-wrapper-styles.native.js.map +1 -0
  225. package/build-module/hooks/use-typography-props.js +14 -10
  226. package/build-module/hooks/use-typography-props.js.map +1 -1
  227. package/build-module/index.native.js +6 -0
  228. package/build-module/index.native.js.map +1 -0
  229. package/build-module/utils/use-should-contextual-toolbar-show.js +16 -12
  230. package/build-module/utils/use-should-contextual-toolbar-show.js.map +1 -1
  231. package/build-style/content-rtl.css +0 -1
  232. package/build-style/content.css +0 -1
  233. package/build-style/style-rtl.css +37 -13
  234. package/build-style/style.css +37 -13
  235. package/package.json +31 -31
  236. package/src/components/block-breadcrumb/style.scss +2 -1
  237. package/src/components/block-controls/slot.js +8 -4
  238. package/src/components/block-controls/slot.native.js +6 -1
  239. package/src/components/block-draggable/index.js +10 -6
  240. package/src/components/block-draggable/use-scroll-when-dragging.js +8 -2
  241. package/src/components/block-list/block-invalid-warning.native.js +17 -9
  242. package/src/components/block-list/block-list-item-cell.native.js +10 -1
  243. package/src/components/block-list/block-list-item.native.js +180 -208
  244. package/src/components/block-list/block-outline.native.js +58 -0
  245. package/src/components/block-list/block.native.js +564 -523
  246. package/src/components/block-list/content.scss +0 -1
  247. package/src/components/block-list/index.native.js +229 -298
  248. package/src/components/block-list/insertion-point.native.js +2 -2
  249. package/src/components/block-list/test/block-invalid-warning.native.js +48 -0
  250. package/src/components/block-list/test/index.native.js +205 -0
  251. package/src/components/block-mobile-toolbar/block-actions-menu.native.js +3 -1
  252. package/src/components/block-pattern-setup/style.scss +1 -4
  253. package/src/components/block-patterns-list/style.scss +1 -4
  254. package/src/components/block-settings-menu/block-settings-dropdown.js +10 -17
  255. package/src/components/block-settings-menu-controls/index.js +24 -4
  256. package/src/components/block-styles/style.scss +4 -4
  257. package/src/components/block-tools/block-contextual-toolbar.js +28 -62
  258. package/src/components/block-tools/selected-block-popover.js +3 -5
  259. package/src/components/block-tools/style.scss +8 -0
  260. package/src/components/colors-gradients/use-multiple-origin-colors-and-gradients.js +16 -2
  261. package/src/components/global-styles/advanced-panel.js +82 -0
  262. package/src/components/global-styles/color-panel.js +6 -1
  263. package/src/components/global-styles/dimensions-panel.js +6 -6
  264. package/src/components/global-styles/hooks.js +1 -5
  265. package/src/components/global-styles/index.js +6 -1
  266. package/src/components/global-styles/style.scss +14 -0
  267. package/src/components/global-styles/test/utils.js +57 -1
  268. package/src/components/global-styles/typography-panel.js +1 -1
  269. package/src/components/global-styles/use-global-styles-output.js +21 -3
  270. package/src/components/global-styles/utils.js +27 -0
  271. package/src/components/image-editor/use-save-image.js +20 -9
  272. package/src/components/inserter-draggable-blocks/index.js +4 -0
  273. package/src/components/inspector-controls/fill.js +1 -1
  274. package/src/components/inspector-controls/fill.native.js +1 -1
  275. package/src/components/inspector-controls/slot.js +4 -9
  276. package/src/components/inspector-controls/slot.native.js +1 -1
  277. package/src/components/line-height-control/index.js +7 -2
  278. package/src/components/line-height-control/stories/index.js +1 -1
  279. package/src/components/link-control/test/index.js +42 -0
  280. package/src/components/link-control/use-internal-input-value.js +8 -7
  281. package/src/components/list-view/block-contents.js +26 -20
  282. package/src/components/list-view/block-select-button.js +5 -1
  283. package/src/components/list-view/block.js +5 -2
  284. package/src/components/list-view/index.js +26 -14
  285. package/src/components/list-view/style.scss +5 -2
  286. package/src/components/list-view/test/use-list-view-drop-zone.js +88 -12
  287. package/src/components/list-view/use-list-view-drop-zone.js +194 -11
  288. package/src/components/media-placeholder/index.js +74 -1
  289. package/src/components/multi-selection-inspector/index.js +2 -2
  290. package/src/components/off-canvas-editor/leaf-more-menu.js +2 -1
  291. package/src/components/preview-options/index.js +9 -2
  292. package/src/components/spacing-sizes-control/spacing-input-control.js +1 -0
  293. package/src/components/url-input/index.js +1 -2
  294. package/src/hooks/align.js +2 -1
  295. package/src/hooks/border.js +2 -1
  296. package/src/hooks/color.js +2 -1
  297. package/src/hooks/content-lock-ui.js +3 -15
  298. package/src/hooks/duotone.js +1 -0
  299. package/src/hooks/index.native.js +1 -0
  300. package/src/hooks/layout.js +4 -2
  301. package/src/hooks/position.js +2 -1
  302. package/src/hooks/style.js +2 -1
  303. package/src/hooks/test/use-editor-wrapper-styles.native.js +282 -0
  304. package/src/hooks/test/use-typography-props.js +47 -2
  305. package/src/hooks/use-editor-wrapper-styles.native.js +250 -0
  306. package/src/hooks/use-editor-wrapper-styles.native.scss +11 -0
  307. package/src/hooks/use-typography-props.js +10 -11
  308. package/src/index.native.js +6 -0
  309. package/src/utils/use-should-contextual-toolbar-show.js +19 -9
  310. package/tsconfig.json +1 -0
  311. package/tsconfig.tsbuildinfo +1 -1
@@ -0,0 +1,82 @@
1
+ /**
2
+ * WordPress dependencies
3
+ */
4
+ import {
5
+ TextareaControl,
6
+ Tooltip,
7
+ __experimentalVStack as VStack,
8
+ } from '@wordpress/components';
9
+ import { useState } from '@wordpress/element';
10
+ import { __ } from '@wordpress/i18n';
11
+ import { Icon, info } from '@wordpress/icons';
12
+
13
+ /**
14
+ * Internal dependencies
15
+ */
16
+ import { default as transformStyles } from '../../utils/transform-styles';
17
+
18
+ export default function AdvancedPanel( {
19
+ value,
20
+ onChange,
21
+ inheritedValue = value,
22
+ } ) {
23
+ // Custom CSS
24
+ const [ cssError, setCSSError ] = useState( null );
25
+ const customCSS = inheritedValue?.css;
26
+ function handleOnChange( newValue ) {
27
+ onChange( {
28
+ ...value,
29
+ css: newValue,
30
+ } );
31
+ if ( cssError ) {
32
+ const [ transformed ] = transformStyles(
33
+ [ { css: value } ],
34
+ '.editor-styles-wrapper'
35
+ );
36
+ if ( transformed ) {
37
+ setCSSError( null );
38
+ }
39
+ }
40
+ }
41
+ function handleOnBlur( event ) {
42
+ if ( ! event?.target?.value ) {
43
+ setCSSError( null );
44
+ return;
45
+ }
46
+
47
+ const [ transformed ] = transformStyles(
48
+ [ { css: event.target.value } ],
49
+ '.editor-styles-wrapper'
50
+ );
51
+
52
+ setCSSError(
53
+ transformed === null
54
+ ? __( 'There is an error with your CSS structure.' )
55
+ : null
56
+ );
57
+ }
58
+
59
+ return (
60
+ <VStack spacing={ 3 }>
61
+ <TextareaControl
62
+ label={ __( 'Additional CSS' ) }
63
+ __nextHasNoMarginBottom
64
+ value={ customCSS }
65
+ onChange={ ( newValue ) => handleOnChange( newValue ) }
66
+ onBlur={ handleOnBlur }
67
+ className="block-editor-global-styles-advanced-panel__custom-css-input"
68
+ spellCheck={ false }
69
+ />
70
+ { cssError && (
71
+ <Tooltip text={ cssError }>
72
+ <div className="block-editor-global-styles-advanced-panel__custom-css-validation-wrapper">
73
+ <Icon
74
+ icon={ info }
75
+ className="block-editor-global-styles-advanced-panel__custom-css-validation-icon"
76
+ />
77
+ </div>
78
+ </Tooltip>
79
+ ) }
80
+ </VStack>
81
+ );
82
+ }
@@ -20,7 +20,7 @@ import {
20
20
  Button,
21
21
  } from '@wordpress/components';
22
22
  import { useCallback } from '@wordpress/element';
23
- import { __ } from '@wordpress/i18n';
23
+ import { __, sprintf } from '@wordpress/i18n';
24
24
 
25
25
  /**
26
26
  * Internal dependencies
@@ -230,6 +230,11 @@ function ColorPanelDropdown( {
230
230
  { 'is-open': isOpen }
231
231
  ),
232
232
  'aria-expanded': isOpen,
233
+ 'aria-label': sprintf(
234
+ /* translators: %s is the type of color property, e.g., "background" */
235
+ __( 'Color %s styles' ),
236
+ label
237
+ ),
233
238
  };
234
239
 
235
240
  return (
@@ -184,12 +184,12 @@ function DimensionsToolsPanel( {
184
184
  }
185
185
 
186
186
  const DEFAULT_CONTROLS = {
187
- contentSize: false,
188
- wideSize: false,
189
- padding: false,
190
- margin: false,
191
- blockGap: false,
192
- minHeight: false,
187
+ contentSize: true,
188
+ wideSize: true,
189
+ padding: true,
190
+ margin: true,
191
+ blockGap: true,
192
+ minHeight: true,
193
193
  childLayout: true,
194
194
  };
195
195
 
@@ -181,11 +181,7 @@ export function useGlobalStyle(
181
181
  let rawResult, result;
182
182
  switch ( source ) {
183
183
  case 'all':
184
- rawResult =
185
- // The styles.css path is allowed to be empty, so don't revert to base if undefined.
186
- finalPath === 'styles.css'
187
- ? get( userConfig, finalPath )
188
- : get( mergedConfig, finalPath );
184
+ rawResult = get( mergedConfig, finalPath );
189
185
  result = shouldDecodeEncode
190
186
  ? getValueFromVariable( mergedConfig, blockName, rawResult )
191
187
  : rawResult;
@@ -5,7 +5,10 @@ export {
5
5
  useSettingsForBlockElement,
6
6
  } from './hooks';
7
7
  export { getBlockCSSSelector } from './get-block-css-selector';
8
- export { useGlobalStylesOutput } from './use-global-styles-output';
8
+ export {
9
+ useGlobalStylesOutput,
10
+ useGlobalStylesOutputWithConfig,
11
+ } from './use-global-styles-output';
9
12
  export { GlobalStylesContext } from './context';
10
13
  export {
11
14
  default as TypographyPanel,
@@ -19,3 +22,5 @@ export { default as BorderPanel, useHasBorderPanel } from './border-panel';
19
22
  export { default as ColorPanel, useHasColorPanel } from './color-panel';
20
23
  export { default as EffectsPanel, useHasEffectsPanel } from './effects-panel';
21
24
  export { default as FiltersPanel, useHasFiltersPanel } from './filters-panel';
25
+ export { default as AdvancedPanel } from './advanced-panel';
26
+ export { areGlobalStyleConfigsEqual } from './utils';
@@ -41,3 +41,17 @@
41
41
  height: 24px;
42
42
  width: 24px;
43
43
  }
44
+
45
+ .block-editor-global-styles-advanced-panel__custom-css-input textarea {
46
+ font-family: $editor_html_font;
47
+ }
48
+
49
+ .block-editor-global-styles-advanced-panel__custom-css-validation-wrapper {
50
+ position: absolute;
51
+ bottom: $grid-unit-20;
52
+ right: $grid-unit * 3;
53
+ }
54
+
55
+ .block-editor-global-styles-advanced-panel__custom-css-validation-icon {
56
+ fill: $alert-red;
57
+ }
@@ -1,7 +1,11 @@
1
1
  /**
2
2
  * Internal dependencies
3
3
  */
4
- import { getPresetVariableFromValue, getValueFromVariable } from '../utils';
4
+ import {
5
+ areGlobalStyleConfigsEqual,
6
+ getPresetVariableFromValue,
7
+ getValueFromVariable,
8
+ } from '../utils';
5
9
 
6
10
  describe( 'editor utils', () => {
7
11
  const themeJson = {
@@ -203,4 +207,56 @@ describe( 'editor utils', () => {
203
207
  } );
204
208
  } );
205
209
  } );
210
+
211
+ describe( 'areGlobalStyleConfigsEqual', () => {
212
+ test.each( [
213
+ { original: null, variation: null, expected: true },
214
+ { original: {}, variation: {}, expected: true },
215
+ { original: {}, variation: undefined, expected: false },
216
+ {
217
+ original: {
218
+ styles: {
219
+ color: { text: 'var(--wp--preset--color--red)' },
220
+ },
221
+ },
222
+ variation: {
223
+ styles: {
224
+ color: { text: 'var(--wp--preset--color--blue)' },
225
+ },
226
+ },
227
+ expected: false,
228
+ },
229
+ { original: {}, variation: undefined, expected: false },
230
+ {
231
+ original: {
232
+ styles: {
233
+ color: { text: 'var(--wp--preset--color--red)' },
234
+ },
235
+ settings: {
236
+ typography: {
237
+ fontSize: true,
238
+ },
239
+ },
240
+ },
241
+ variation: {
242
+ styles: {
243
+ color: { text: 'var(--wp--preset--color--red)' },
244
+ },
245
+ settings: {
246
+ typography: {
247
+ fontSize: true,
248
+ },
249
+ },
250
+ },
251
+ expected: true,
252
+ },
253
+ ] )(
254
+ '.areGlobalStyleConfigsEqual( $original, $variation )',
255
+ ( { original, variation, expected } ) => {
256
+ expect(
257
+ areGlobalStyleConfigsEqual( original, variation )
258
+ ).toBe( expected );
259
+ }
260
+ );
261
+ } );
206
262
  } );
@@ -238,7 +238,7 @@ export default function TypographyPanel( {
238
238
  )
239
239
  );
240
240
  };
241
- const hasLineHeight = () => !! value?.typography?.lineHeight;
241
+ const hasLineHeight = () => value?.typography?.lineHeight !== undefined;
242
242
  const resetLineHeight = () => setLineHeight( undefined );
243
243
 
244
244
  // Letter Spacing
@@ -1106,9 +1106,17 @@ const processCSSNesting = ( css, blockSelector ) => {
1106
1106
  return processedCSS;
1107
1107
  };
1108
1108
 
1109
- export function useGlobalStylesOutput() {
1110
- let { merged: mergedConfig } = useContext( GlobalStylesContext );
1111
-
1109
+ /**
1110
+ * Returns the global styles output using a global styles configuration.
1111
+ * If wishing to generate global styles and settings based on the
1112
+ * global styles config loaded in the editor context, use `useGlobalStylesOutput()`.
1113
+ * The use case for a custom config is to generate bespoke styles
1114
+ * and settings for previews, or other out-of-editor experiences.
1115
+ *
1116
+ * @param {Object} mergedConfig Global styles configuration.
1117
+ * @return {Array} Array of stylesheets and settings.
1118
+ */
1119
+ export function useGlobalStylesOutputWithConfig( mergedConfig = {} ) {
1112
1120
  const [ blockGap ] = useGlobalSetting( 'spacing.blockGap' );
1113
1121
  const hasBlockGapSupport = blockGap !== null;
1114
1122
  const hasFallbackGapSupport = ! hasBlockGapSupport; // This setting isn't useful yet: it exists as a placeholder for a future explicit fallback styles support.
@@ -1190,3 +1198,13 @@ export function useGlobalStylesOutput() {
1190
1198
  disableLayoutStyles,
1191
1199
  ] );
1192
1200
  }
1201
+
1202
+ /**
1203
+ * Returns the global styles output based on the current state of global styles config loaded in the editor context.
1204
+ *
1205
+ * @return {Array} Array of stylesheets and settings.
1206
+ */
1207
+ export function useGlobalStylesOutput() {
1208
+ const { merged: mergedConfig } = useContext( GlobalStylesContext );
1209
+ return useGlobalStylesOutputWithConfig( mergedConfig );
1210
+ }
@@ -2,6 +2,7 @@
2
2
  * External dependencies
3
3
  */
4
4
  import { get } from 'lodash';
5
+ import fastDeepEqual from 'fast-deep-equal/es6';
5
6
 
6
7
  /**
7
8
  * Internal dependencies
@@ -376,3 +377,29 @@ export function scopeSelector( scope, selector ) {
376
377
 
377
378
  return selectorsScoped.join( ', ' );
378
379
  }
380
+
381
+ /**
382
+ * Compares global style variations according to their styles and settings properties.
383
+ *
384
+ * @example
385
+ * ```js
386
+ * const globalStyles = { styles: { typography: { fontSize: '10px' } }, settings: {} };
387
+ * const variation = { styles: { typography: { fontSize: '10000px' } }, settings: {} };
388
+ * const isEqual = areGlobalStyleConfigsEqual( globalStyles, variation );
389
+ * // false
390
+ * ```
391
+ *
392
+ * @param {Object} original A global styles object.
393
+ * @param {Object} variation A global styles object.
394
+ *
395
+ * @return {boolean} Whether `original` and `variation` match.
396
+ */
397
+ export function areGlobalStyleConfigsEqual( original, variation ) {
398
+ if ( typeof original !== 'object' || typeof variation !== 'object' ) {
399
+ return original === variation;
400
+ }
401
+ return (
402
+ fastDeepEqual( original?.styles, variation?.styles ) &&
403
+ fastDeepEqual( original?.settings, variation?.settings )
404
+ );
405
+ }
@@ -32,24 +32,35 @@ export default function useSaveImage( {
32
32
  const apply = useCallback( () => {
33
33
  setIsInProgress( true );
34
34
 
35
- let attrs = {};
35
+ const modifiers = [];
36
+
37
+ if ( rotation > 0 ) {
38
+ modifiers.push( {
39
+ type: 'rotate',
40
+ args: {
41
+ angle: rotation,
42
+ },
43
+ } );
44
+ }
36
45
 
37
46
  // The crop script may return some very small, sub-pixel values when the image was not cropped.
38
47
  // Crop only when the new size has changed by more than 0.1%.
39
48
  if ( crop.width < 99.9 || crop.height < 99.9 ) {
40
- attrs = crop;
41
- }
42
-
43
- if ( rotation > 0 ) {
44
- attrs.rotation = rotation;
49
+ modifiers.push( {
50
+ type: 'crop',
51
+ args: {
52
+ left: crop.x,
53
+ top: crop.y,
54
+ width: crop.width,
55
+ height: crop.height,
56
+ },
57
+ } );
45
58
  }
46
59
 
47
- attrs.src = url;
48
-
49
60
  apiFetch( {
50
61
  path: `/wp/v2/media/${ id }/edit`,
51
62
  method: 'POST',
52
- data: attrs,
63
+ data: { src: url, modifiers },
53
64
  } )
54
65
  .then( ( response ) => {
55
66
  onSaveImage( {
@@ -2,6 +2,7 @@
2
2
  * WordPress dependencies
3
3
  */
4
4
  import { Draggable } from '@wordpress/components';
5
+ import { serialize } from '@wordpress/blocks';
5
6
  /**
6
7
  * Internal dependencies
7
8
  */
@@ -23,6 +24,9 @@ const InserterDraggableBlocks = ( {
23
24
  <Draggable
24
25
  __experimentalTransferDataType="wp-blocks"
25
26
  transferData={ transferData }
27
+ onDragStart={ ( event ) => {
28
+ event.dataTransfer.setData( 'text/html', serialize( blocks ) );
29
+ } }
26
30
  __experimentalDragComponent={
27
31
  <BlockDraggableChip
28
32
  count={ blocks.length }
@@ -41,7 +41,7 @@ export default function InspectorControlsFill( {
41
41
  const isDisplayed = useDisplayBlockControls();
42
42
  const Fill = groups[ group ]?.Fill;
43
43
  if ( ! Fill ) {
44
- warning( `Unknown InspectorControl group "${ group }" provided.` );
44
+ warning( `Unknown InspectorControls group "${ group }" provided.` );
45
45
  return null;
46
46
  }
47
47
  if ( ! isDisplayed ) {
@@ -39,7 +39,7 @@ export default function InspectorControlsFill( {
39
39
 
40
40
  const Fill = groups[ group ]?.Fill;
41
41
  if ( ! Fill ) {
42
- warning( `Unknown InspectorControl group "${ group }" provided.` );
42
+ warning( `Unknown InspectorControls group "${ group }" provided.` );
43
43
  return null;
44
44
  }
45
45
  if ( ! isDisplayed ) {
@@ -1,10 +1,7 @@
1
1
  /**
2
2
  * WordPress dependencies
3
3
  */
4
- import {
5
- __experimentalUseSlot as useSlot,
6
- __experimentalUseSlotFills as useSlotFills,
7
- } from '@wordpress/components';
4
+ import { __experimentalUseSlotFills as useSlotFills } from '@wordpress/components';
8
5
  import warning from '@wordpress/warning';
9
6
  import deprecated from '@wordpress/deprecated';
10
7
 
@@ -33,15 +30,13 @@ export default function InspectorControlsSlot( {
33
30
  group = __experimentalGroup;
34
31
  }
35
32
  const Slot = groups[ group ]?.Slot;
36
- const slot = useSlot( Slot?.__unstableName );
37
33
  const fills = useSlotFills( Slot?.__unstableName );
38
- if ( ! Slot || ! slot ) {
39
- warning( `Unknown InspectorControl group "${ group }" provided.` );
34
+ if ( ! Slot ) {
35
+ warning( `Unknown InspectorControls group "${ group }" provided.` );
40
36
  return null;
41
37
  }
42
38
 
43
- const hasFills = Boolean( fills && fills.length );
44
- if ( ! hasFills ) {
39
+ if ( ! fills?.length ) {
45
40
  return null;
46
41
  }
47
42
 
@@ -27,7 +27,7 @@ export default function InspectorControlsSlot( {
27
27
  }
28
28
  const Slot = groups[ group ]?.Slot;
29
29
  if ( ! Slot ) {
30
- warning( `Unknown InspectorControl group "${ group }" provided.` );
30
+ warning( `Unknown InspectorControls group "${ group }" provided.` );
31
31
  return null;
32
32
  }
33
33
 
@@ -85,12 +85,17 @@ const LineHeightControl = ( {
85
85
  : { marginBottom: 24 };
86
86
 
87
87
  const handleOnChange = ( nextValue, { event } ) => {
88
+ if ( nextValue === '' ) {
89
+ onChange();
90
+ return;
91
+ }
92
+
88
93
  if ( event.type === 'click' ) {
89
- onChange( adjustNextValue( nextValue, false ) );
94
+ onChange( adjustNextValue( `${ nextValue }`, false ) );
90
95
  return;
91
96
  }
92
97
 
93
- onChange( nextValue );
98
+ onChange( `${ nextValue }` );
94
99
  };
95
100
 
96
101
  return (
@@ -23,7 +23,7 @@ const Template = ( props ) => {
23
23
  export const Default = Template.bind( {} );
24
24
  Default.args = {
25
25
  __nextHasNoMarginBottom: true,
26
- __unstableInputWidth: '60px',
26
+ __unstableInputWidth: '100px',
27
27
  };
28
28
 
29
29
  export const UnconstrainedWidth = Template.bind( {} );
@@ -2235,6 +2235,48 @@ describe( 'Controlling link title text', () => {
2235
2235
  screen.queryByRole( 'textbox', { name: 'Text' } )
2236
2236
  ).not.toBeInTheDocument();
2237
2237
  } );
2238
+
2239
+ it( 'should reset state on value change', async () => {
2240
+ const user = userEvent.setup();
2241
+ const textValue = 'My new text value';
2242
+ const mockOnChange = jest.fn();
2243
+
2244
+ const { rerender } = render(
2245
+ <LinkControl
2246
+ value={ selectedLink }
2247
+ forceIsEditingLink
2248
+ hasTextControl
2249
+ onChange={ mockOnChange }
2250
+ />
2251
+ );
2252
+
2253
+ await toggleSettingsDrawer( user );
2254
+
2255
+ const textInput = screen.queryByRole( 'textbox', { name: 'Text' } );
2256
+
2257
+ expect( textInput ).toBeVisible();
2258
+
2259
+ await user.clear( textInput );
2260
+ await user.keyboard( textValue );
2261
+
2262
+ // Was originally title: 'Hello Page', but we've changed it.
2263
+ rerender(
2264
+ <LinkControl
2265
+ value={ {
2266
+ ...selectedLink,
2267
+ title: 'Something else',
2268
+ } }
2269
+ forceIsEditingLink
2270
+ hasTextControl
2271
+ onChange={ mockOnChange }
2272
+ />
2273
+ );
2274
+
2275
+ // The text input should not be showing as the form is submitted.
2276
+ expect( screen.queryByRole( 'textbox', { name: 'Text' } ) ).toHaveValue(
2277
+ 'Something else'
2278
+ );
2279
+ } );
2238
2280
  } );
2239
2281
 
2240
2282
  async function toggleSettingsDrawer( user ) {
@@ -8,14 +8,15 @@ export default function useInternalInputValue( value ) {
8
8
  value || ''
9
9
  );
10
10
 
11
+ // If the value prop changes, update the internal state.
11
12
  useEffect( () => {
12
- /**
13
- * If the value changes then sync this
14
- * back up with state.
15
- */
16
- if ( value && value !== internalInputValue ) {
17
- setInternalInputValue( value );
18
- }
13
+ setInternalInputValue( ( prevValue ) => {
14
+ if ( value && value !== prevValue ) {
15
+ return value;
16
+ }
17
+
18
+ return prevValue;
19
+ } );
19
20
  }, [ value ] );
20
21
 
21
22
  return [ internalInputValue, setInternalInputValue ];
@@ -15,6 +15,7 @@ import { forwardRef } from '@wordpress/element';
15
15
  import ListViewBlockSelectButton from './block-select-button';
16
16
  import BlockDraggable from '../block-draggable';
17
17
  import { store as blockEditorStore } from '../../store';
18
+ import { useListViewContext } from './context';
18
19
 
19
20
  const ListViewBlockContents = forwardRef(
20
21
  (
@@ -46,6 +47,8 @@ const ListViewBlockContents = forwardRef(
46
47
  [ clientId ]
47
48
  );
48
49
 
50
+ const { renderAdditionalBlockUI } = useListViewContext();
51
+
49
52
  const isBlockMoveTarget =
50
53
  blockMovingClientId && selectedBlockInBlockEditor === clientId;
51
54
 
@@ -62,26 +65,29 @@ const ListViewBlockContents = forwardRef(
62
65
  : [ clientId ];
63
66
 
64
67
  return (
65
- <BlockDraggable clientIds={ draggableClientIds }>
66
- { ( { draggable, onDragStart, onDragEnd } ) => (
67
- <ListViewBlockSelectButton
68
- ref={ ref }
69
- className={ className }
70
- block={ block }
71
- onClick={ onClick }
72
- onToggleExpanded={ onToggleExpanded }
73
- isSelected={ isSelected }
74
- position={ position }
75
- siblingBlockCount={ siblingBlockCount }
76
- level={ level }
77
- draggable={ draggable }
78
- onDragStart={ onDragStart }
79
- onDragEnd={ onDragEnd }
80
- isExpanded={ isExpanded }
81
- { ...props }
82
- />
83
- ) }
84
- </BlockDraggable>
68
+ <>
69
+ { renderAdditionalBlockUI && renderAdditionalBlockUI( block ) }
70
+ <BlockDraggable clientIds={ draggableClientIds }>
71
+ { ( { draggable, onDragStart, onDragEnd } ) => (
72
+ <ListViewBlockSelectButton
73
+ ref={ ref }
74
+ className={ className }
75
+ block={ block }
76
+ onClick={ onClick }
77
+ onToggleExpanded={ onToggleExpanded }
78
+ isSelected={ isSelected }
79
+ position={ position }
80
+ siblingBlockCount={ siblingBlockCount }
81
+ level={ level }
82
+ draggable={ draggable }
83
+ onDragStart={ onDragStart }
84
+ onDragEnd={ onDragEnd }
85
+ isExpanded={ isExpanded }
86
+ { ...props }
87
+ />
88
+ ) }
89
+ </BlockDraggable>
90
+ </>
85
91
  );
86
92
  }
87
93
  );
@@ -84,7 +84,11 @@ function ListViewBlockSelectButton(
84
84
  aria-expanded={ isExpanded }
85
85
  >
86
86
  <ListViewExpander onClick={ onToggleExpanded } />
87
- <BlockIcon icon={ blockInformation?.icon } showColors />
87
+ <BlockIcon
88
+ icon={ blockInformation?.icon }
89
+ showColors
90
+ context="list-view"
91
+ />
88
92
  <HStack
89
93
  alignment="center"
90
94
  className="block-editor-list-view-block-select-button__label-wrapper"
@@ -40,7 +40,7 @@ import useBlockDisplayInformation from '../use-block-display-information';
40
40
  import { useBlockLock } from '../block-lock';
41
41
 
42
42
  function ListViewBlock( {
43
- block,
43
+ block: { clientId },
44
44
  isDragged,
45
45
  isSelected,
46
46
  isBranchSelected,
@@ -58,7 +58,6 @@ function ListViewBlock( {
58
58
  const cellRef = useRef( null );
59
59
  const rowRef = useRef( null );
60
60
  const [ isHovered, setIsHovered ] = useState( false );
61
- const { clientId } = block;
62
61
 
63
62
  const { isLocked, isContentLocked, canEdit } = useBlockLock( clientId );
64
63
  const forceSelectionContentLock = useSelect(
@@ -90,6 +89,10 @@ function ListViewBlock( {
90
89
 
91
90
  const blockInformation = useBlockDisplayInformation( clientId );
92
91
  const blockTitle = blockInformation?.title || __( 'Untitled' );
92
+ const block = useSelect(
93
+ ( select ) => select( blockEditorStore ).getBlock( clientId ),
94
+ [ clientId ]
95
+ );
93
96
  const blockName = useSelect(
94
97
  ( select ) => select( blockEditorStore ).getBlockName( clientId ),
95
98
  [ clientId ]