@wordpress/block-editor 12.5.0 → 12.6.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 (298) hide show
  1. package/CHANGELOG.md +2 -0
  2. package/README.md +0 -4
  3. package/build/components/block-draggable/index.js +6 -3
  4. package/build/components/block-draggable/index.js.map +1 -1
  5. package/build/components/block-draggable/index.native.js +2 -2
  6. package/build/components/block-draggable/index.native.js.map +1 -1
  7. package/build/components/block-edit/edit.js +25 -13
  8. package/build/components/block-edit/edit.js.map +1 -1
  9. package/build/components/block-list/block-outline.native.js +14 -18
  10. package/build/components/block-list/block-outline.native.js.map +1 -1
  11. package/build/components/block-list/block.native.js +21 -42
  12. package/build/components/block-list/block.native.js.map +1 -1
  13. package/build/components/block-mover/index.native.js +1 -1
  14. package/build/components/block-mover/index.native.js.map +1 -1
  15. package/build/components/block-removal-warning-modal/index.js +1 -4
  16. package/build/components/block-removal-warning-modal/index.js.map +1 -1
  17. package/build/components/block-settings/button.native.js +2 -2
  18. package/build/components/block-settings/button.native.js.map +1 -1
  19. package/build/components/{block-mobile-toolbar/block-actions-menu.native.js → block-toolbar/block-toolbar-menu.native.js} +7 -5
  20. package/build/components/block-toolbar/block-toolbar-menu.native.js.map +1 -0
  21. package/build/components/block-toolbar/index.js +4 -3
  22. package/build/components/block-toolbar/index.js.map +1 -1
  23. package/build/components/block-toolbar/index.native.js +62 -3
  24. package/build/components/block-toolbar/index.native.js.map +1 -1
  25. package/build/components/colors-gradients/control.js +4 -2
  26. package/build/components/colors-gradients/control.js.map +1 -1
  27. package/build/components/global-styles/color-panel.js +21 -15
  28. package/build/components/global-styles/color-panel.js.map +1 -1
  29. package/build/components/global-styles/dimensions-panel.js +13 -2
  30. package/build/components/global-styles/dimensions-panel.js.map +1 -1
  31. package/build/components/global-styles/get-block-css-selector.js +4 -8
  32. package/build/components/global-styles/get-block-css-selector.js.map +1 -1
  33. package/build/components/global-styles/hooks.js +13 -23
  34. package/build/components/global-styles/hooks.js.map +1 -1
  35. package/build/components/global-styles/typography-panel.js +18 -3
  36. package/build/components/global-styles/typography-panel.js.map +1 -1
  37. package/build/components/global-styles/use-global-styles-output.js +12 -18
  38. package/build/components/global-styles/use-global-styles-output.js.map +1 -1
  39. package/build/components/global-styles/utils.js +6 -6
  40. package/build/components/global-styles/utils.js.map +1 -1
  41. package/build/components/iframe/index.js +36 -48
  42. package/build/components/iframe/index.js.map +1 -1
  43. package/build/components/iframe/use-compatibility-styles.js +5 -0
  44. package/build/components/iframe/use-compatibility-styles.js.map +1 -1
  45. package/build/components/index.js +1 -10
  46. package/build/components/index.js.map +1 -1
  47. package/build/components/inner-blocks/index.js +3 -1
  48. package/build/components/inner-blocks/index.js.map +1 -1
  49. package/build/components/inner-blocks/index.native.js +3 -1
  50. package/build/components/inner-blocks/index.native.js.map +1 -1
  51. package/build/components/inner-blocks/use-nested-settings-update.js +33 -7
  52. package/build/components/inner-blocks/use-nested-settings-update.js.map +1 -1
  53. package/build/components/inserter/index.js +2 -4
  54. package/build/components/inserter/index.js.map +1 -1
  55. package/build/components/inserter/index.native.js +21 -32
  56. package/build/components/inserter/index.native.js.map +1 -1
  57. package/build/components/inserter/reusable-block-rename-hint.js +23 -3
  58. package/build/components/inserter/reusable-block-rename-hint.js.map +1 -1
  59. package/build/components/link-control/index.js +4 -1
  60. package/build/components/link-control/index.js.map +1 -1
  61. package/build/components/link-control/search-item.js +1 -1
  62. package/build/components/link-control/search-item.js.map +1 -1
  63. package/build/components/list-view/use-list-view-client-ids.js +2 -2
  64. package/build/components/list-view/use-list-view-client-ids.js.map +1 -1
  65. package/build/components/media-placeholder/index.native.js +65 -31
  66. package/build/components/media-placeholder/index.native.js.map +1 -1
  67. package/build/components/preview-options/index.js +2 -2
  68. package/build/components/preview-options/index.js.map +1 -1
  69. package/build/components/rich-text/content.js +0 -36
  70. package/build/components/rich-text/content.js.map +1 -1
  71. package/build/components/rich-text/get-rich-text-values.js +118 -0
  72. package/build/components/rich-text/get-rich-text-values.js.map +1 -0
  73. package/build/components/spacing-sizes-control/hooks/use-spacing-sizes.js +1 -1
  74. package/build/components/spacing-sizes-control/hooks/use-spacing-sizes.js.map +1 -1
  75. package/build/components/spacing-sizes-control/input-controls/axial.js +6 -2
  76. package/build/components/spacing-sizes-control/input-controls/axial.js.map +1 -1
  77. package/build/components/spacing-sizes-control/input-controls/separated.js +5 -1
  78. package/build/components/spacing-sizes-control/input-controls/separated.js.map +1 -1
  79. package/build/components/spacing-sizes-control/input-controls/single.js +5 -1
  80. package/build/components/spacing-sizes-control/input-controls/single.js.map +1 -1
  81. package/build/components/spacing-sizes-control/utils.js +1 -1
  82. package/build/components/spacing-sizes-control/utils.js.map +1 -1
  83. package/build/components/use-block-display-information/index.js +7 -3
  84. package/build/components/use-block-display-information/index.js.map +1 -1
  85. package/build/components/use-block-drop-zone/index.native.js +49 -8
  86. package/build/components/use-block-drop-zone/index.native.js.map +1 -1
  87. package/build/components/use-setting/index.js +5 -9
  88. package/build/components/use-setting/index.js.map +1 -1
  89. package/build/hooks/margin.js +1 -1
  90. package/build/hooks/margin.js.map +1 -1
  91. package/build/hooks/padding.js +1 -1
  92. package/build/hooks/padding.js.map +1 -1
  93. package/build/hooks/utils.js +1 -7
  94. package/build/hooks/utils.js.map +1 -1
  95. package/build/private-apis.js +7 -3
  96. package/build/private-apis.js.map +1 -1
  97. package/build/store/actions.js +1 -1
  98. package/build/store/actions.js.map +1 -1
  99. package/build/store/private-selectors.js +5 -6
  100. package/build/store/private-selectors.js.map +1 -1
  101. package/build/store/reducer.js +0 -1
  102. package/build/store/reducer.js.map +1 -1
  103. package/build/store/selectors.js +19 -8
  104. package/build/store/selectors.js.map +1 -1
  105. package/build/utils/object.js +38 -2
  106. package/build/utils/object.js.map +1 -1
  107. package/build-module/components/block-draggable/index.js +6 -3
  108. package/build-module/components/block-draggable/index.js.map +1 -1
  109. package/build-module/components/block-draggable/index.native.js +2 -2
  110. package/build-module/components/block-draggable/index.native.js.map +1 -1
  111. package/build-module/components/block-edit/edit.js +27 -10
  112. package/build-module/components/block-edit/edit.js.map +1 -1
  113. package/build-module/components/block-list/block-outline.native.js +14 -18
  114. package/build-module/components/block-list/block-outline.native.js.map +1 -1
  115. package/build-module/components/block-list/block.native.js +24 -43
  116. package/build-module/components/block-list/block.native.js.map +1 -1
  117. package/build-module/components/block-mover/index.native.js +3 -3
  118. package/build-module/components/block-mover/index.native.js.map +1 -1
  119. package/build-module/components/block-removal-warning-modal/index.js +1 -4
  120. package/build-module/components/block-removal-warning-modal/index.js.map +1 -1
  121. package/build-module/components/block-settings/button.native.js +3 -3
  122. package/build-module/components/block-settings/button.native.js.map +1 -1
  123. package/build-module/components/{block-mobile-toolbar/block-actions-menu.native.js → block-toolbar/block-toolbar-menu.native.js} +9 -7
  124. package/build-module/components/block-toolbar/block-toolbar-menu.native.js.map +1 -0
  125. package/build-module/components/block-toolbar/index.js +4 -3
  126. package/build-module/components/block-toolbar/index.js.map +1 -1
  127. package/build-module/components/block-toolbar/index.native.js +60 -4
  128. package/build-module/components/block-toolbar/index.native.js.map +1 -1
  129. package/build-module/components/colors-gradients/control.js +3 -2
  130. package/build-module/components/colors-gradients/control.js.map +1 -1
  131. package/build-module/components/global-styles/color-panel.js +21 -15
  132. package/build-module/components/global-styles/color-panel.js.map +1 -1
  133. package/build-module/components/global-styles/dimensions-panel.js +13 -2
  134. package/build-module/components/global-styles/dimensions-panel.js.map +1 -1
  135. package/build-module/components/global-styles/get-block-css-selector.js +4 -8
  136. package/build-module/components/global-styles/get-block-css-selector.js.map +1 -1
  137. package/build-module/components/global-styles/hooks.js +12 -22
  138. package/build-module/components/global-styles/hooks.js.map +1 -1
  139. package/build-module/components/global-styles/typography-panel.js +18 -3
  140. package/build-module/components/global-styles/typography-panel.js.map +1 -1
  141. package/build-module/components/global-styles/use-global-styles-output.js +13 -18
  142. package/build-module/components/global-styles/use-global-styles-output.js.map +1 -1
  143. package/build-module/components/global-styles/utils.js +5 -5
  144. package/build-module/components/global-styles/utils.js.map +1 -1
  145. package/build-module/components/iframe/index.js +37 -49
  146. package/build-module/components/iframe/index.js.map +1 -1
  147. package/build-module/components/iframe/use-compatibility-styles.js +5 -0
  148. package/build-module/components/iframe/use-compatibility-styles.js.map +1 -1
  149. package/build-module/components/index.js +0 -5
  150. package/build-module/components/index.js.map +1 -1
  151. package/build-module/components/inner-blocks/index.js +3 -1
  152. package/build-module/components/inner-blocks/index.js.map +1 -1
  153. package/build-module/components/inner-blocks/index.native.js +3 -1
  154. package/build-module/components/inner-blocks/index.native.js.map +1 -1
  155. package/build-module/components/inner-blocks/use-nested-settings-update.js +30 -7
  156. package/build-module/components/inner-blocks/use-nested-settings-update.js.map +1 -1
  157. package/build-module/components/inserter/index.js +2 -4
  158. package/build-module/components/inserter/index.js.map +1 -1
  159. package/build-module/components/inserter/index.native.js +22 -33
  160. package/build-module/components/inserter/index.native.js.map +1 -1
  161. package/build-module/components/inserter/reusable-block-rename-hint.js +22 -3
  162. package/build-module/components/inserter/reusable-block-rename-hint.js.map +1 -1
  163. package/build-module/components/link-control/index.js +4 -1
  164. package/build-module/components/link-control/index.js.map +1 -1
  165. package/build-module/components/link-control/search-item.js +1 -1
  166. package/build-module/components/link-control/search-item.js.map +1 -1
  167. package/build-module/components/list-view/use-list-view-client-ids.js +2 -2
  168. package/build-module/components/list-view/use-list-view-client-ids.js.map +1 -1
  169. package/build-module/components/media-placeholder/index.native.js +66 -33
  170. package/build-module/components/media-placeholder/index.native.js.map +1 -1
  171. package/build-module/components/preview-options/index.js +2 -2
  172. package/build-module/components/preview-options/index.js.map +1 -1
  173. package/build-module/components/rich-text/content.js +1 -36
  174. package/build-module/components/rich-text/content.js.map +1 -1
  175. package/build-module/components/rich-text/get-rich-text-values.js +105 -0
  176. package/build-module/components/rich-text/get-rich-text-values.js.map +1 -0
  177. package/build-module/components/spacing-sizes-control/hooks/use-spacing-sizes.js +1 -1
  178. package/build-module/components/spacing-sizes-control/hooks/use-spacing-sizes.js.map +1 -1
  179. package/build-module/components/spacing-sizes-control/input-controls/axial.js +7 -3
  180. package/build-module/components/spacing-sizes-control/input-controls/axial.js.map +1 -1
  181. package/build-module/components/spacing-sizes-control/input-controls/separated.js +6 -2
  182. package/build-module/components/spacing-sizes-control/input-controls/separated.js.map +1 -1
  183. package/build-module/components/spacing-sizes-control/input-controls/single.js +6 -2
  184. package/build-module/components/spacing-sizes-control/input-controls/single.js.map +1 -1
  185. package/build-module/components/spacing-sizes-control/utils.js +1 -1
  186. package/build-module/components/spacing-sizes-control/utils.js.map +1 -1
  187. package/build-module/components/use-block-display-information/index.js +7 -3
  188. package/build-module/components/use-block-display-information/index.js.map +1 -1
  189. package/build-module/components/use-block-drop-zone/index.native.js +50 -8
  190. package/build-module/components/use-block-drop-zone/index.native.js.map +1 -1
  191. package/build-module/components/use-setting/index.js +5 -9
  192. package/build-module/components/use-setting/index.js.map +1 -1
  193. package/build-module/hooks/margin.js +1 -1
  194. package/build-module/hooks/margin.js.map +1 -1
  195. package/build-module/hooks/padding.js +1 -1
  196. package/build-module/hooks/padding.js.map +1 -1
  197. package/build-module/hooks/utils.js +2 -7
  198. package/build-module/hooks/utils.js.map +1 -1
  199. package/build-module/private-apis.js +5 -2
  200. package/build-module/private-apis.js.map +1 -1
  201. package/build-module/store/actions.js +2 -2
  202. package/build-module/store/actions.js.map +1 -1
  203. package/build-module/store/private-selectors.js +3 -3
  204. package/build-module/store/private-selectors.js.map +1 -1
  205. package/build-module/store/reducer.js +0 -1
  206. package/build-module/store/reducer.js.map +1 -1
  207. package/build-module/store/selectors.js +16 -6
  208. package/build-module/store/selectors.js.map +1 -1
  209. package/build-module/utils/object.js +34 -2
  210. package/build-module/utils/object.js.map +1 -1
  211. package/build-style/content-rtl.css +2 -1
  212. package/build-style/content.css +2 -1
  213. package/build-style/style-rtl.css +7 -1
  214. package/build-style/style.css +7 -1
  215. package/package.json +32 -32
  216. package/src/components/block-controls/README.md +89 -0
  217. package/src/components/block-draggable/index.js +13 -4
  218. package/src/components/block-draggable/index.native.js +7 -3
  219. package/src/components/block-draggable/test/index.native.js +0 -54
  220. package/src/components/block-edit/edit.js +26 -9
  221. package/src/components/block-edit/test/edit.js +1 -1
  222. package/src/components/block-list/block-outline.native.js +26 -25
  223. package/src/components/block-list/block.native.js +24 -38
  224. package/src/components/block-list/block.native.scss +18 -40
  225. package/src/components/block-list/style.native.scss +3 -3
  226. package/src/components/block-mover/index.native.js +3 -3
  227. package/src/components/block-mover/test/__snapshots__/index.native.js.snap +16 -6
  228. package/src/components/block-removal-warning-modal/index.js +0 -3
  229. package/src/components/block-settings/button.native.js +12 -6
  230. package/src/components/{block-mobile-toolbar/block-actions-menu.native.js → block-toolbar/block-toolbar-menu.native.js} +15 -10
  231. package/src/components/block-toolbar/index.js +2 -3
  232. package/src/components/block-toolbar/index.native.js +86 -6
  233. package/src/components/{block-mobile-toolbar/test/block-actions-menu.native.js → block-toolbar/test/block-toolbar-menu.native.js} +20 -54
  234. package/src/components/block-toolbar/test/index.native.js +42 -0
  235. package/src/components/button-block-appender/styles.native.scss +2 -2
  236. package/src/components/caption/README.md +49 -0
  237. package/src/components/colors-gradients/control.js +3 -2
  238. package/src/components/global-styles/color-panel.js +23 -16
  239. package/src/components/global-styles/dimensions-panel.js +8 -2
  240. package/src/components/global-styles/get-block-css-selector.js +5 -9
  241. package/src/components/global-styles/hooks.js +20 -26
  242. package/src/components/global-styles/typography-panel.js +17 -5
  243. package/src/components/global-styles/use-global-styles-output.js +36 -18
  244. package/src/components/global-styles/utils.js +15 -6
  245. package/src/components/iframe/index.js +30 -56
  246. package/src/components/iframe/use-compatibility-styles.js +5 -0
  247. package/src/components/index.js +0 -5
  248. package/src/components/inner-blocks/README.md +10 -0
  249. package/src/components/inner-blocks/index.js +4 -0
  250. package/src/components/inner-blocks/index.native.js +4 -0
  251. package/src/components/inner-blocks/use-nested-settings-update.js +32 -5
  252. package/src/components/inserter/index.js +2 -3
  253. package/src/components/inserter/index.native.js +17 -36
  254. package/src/components/inserter/reusable-block-rename-hint.js +18 -1
  255. package/src/components/inserter/style.native.scss +10 -15
  256. package/src/components/link-control/index.js +4 -1
  257. package/src/components/link-control/search-item.js +1 -1
  258. package/src/components/link-control/style.scss +8 -1
  259. package/src/components/link-control/test/index.js +26 -0
  260. package/src/components/list-view/use-list-view-client-ids.js +2 -2
  261. package/src/components/media-placeholder/index.native.js +108 -59
  262. package/src/components/media-placeholder/styles.native.scss +59 -24
  263. package/src/components/preview-options/README.md +18 -17
  264. package/src/components/preview-options/index.js +2 -2
  265. package/src/components/rich-text/content.js +1 -46
  266. package/src/components/rich-text/get-rich-text-values.js +105 -0
  267. package/src/components/spacing-sizes-control/hooks/use-spacing-sizes.js +1 -1
  268. package/src/components/spacing-sizes-control/input-controls/axial.js +17 -2
  269. package/src/components/spacing-sizes-control/input-controls/separated.js +17 -2
  270. package/src/components/spacing-sizes-control/input-controls/single.js +12 -2
  271. package/src/components/spacing-sizes-control/utils.js +1 -1
  272. package/src/components/text-transform-control/README.md +44 -0
  273. package/src/components/use-block-display-information/index.js +12 -5
  274. package/src/components/use-block-drop-zone/index.native.js +65 -28
  275. package/src/components/use-setting/index.js +8 -8
  276. package/src/hooks/margin.js +4 -1
  277. package/src/hooks/padding.js +4 -1
  278. package/src/hooks/utils.js +5 -7
  279. package/src/private-apis.js +7 -1
  280. package/src/store/actions.js +1 -2
  281. package/src/store/private-selectors.js +3 -6
  282. package/src/store/reducer.js +0 -1
  283. package/src/store/selectors.js +33 -5
  284. package/src/store/test/actions.js +3 -0
  285. package/src/store/test/private-selectors.js +5 -5
  286. package/src/store/test/reducer.js +14 -7
  287. package/src/store/test/selectors.js +1 -1
  288. package/src/utils/object.js +32 -2
  289. package/src/utils/test/object.js +36 -0
  290. package/build/components/block-mobile-toolbar/block-actions-menu.native.js.map +0 -1
  291. package/build/components/block-mobile-toolbar/index.native.js +0 -135
  292. package/build/components/block-mobile-toolbar/index.native.js.map +0 -1
  293. package/build-module/components/block-mobile-toolbar/block-actions-menu.native.js.map +0 -1
  294. package/build-module/components/block-mobile-toolbar/index.native.js +0 -116
  295. package/build-module/components/block-mobile-toolbar/index.native.js.map +0 -1
  296. package/src/components/block-mobile-toolbar/index.native.js +0 -127
  297. package/src/components/block-mobile-toolbar/style.native.scss +0 -16
  298. /package/src/components/{block-mobile-toolbar/test/__snapshots__/block-actions-menu.native.js.snap → block-toolbar/test/__snapshots__/block-toolbar-menu.native.js.snap} +0 -0
@@ -2,7 +2,12 @@
2
2
  * Internal dependencies
3
3
  */
4
4
  import SpacingInputControl from './spacing-input-control';
5
- import { LABELS, ICONS, hasAxisSupport } from '../utils';
5
+ import {
6
+ LABELS,
7
+ ICONS,
8
+ getPresetValueFromCustomValue,
9
+ hasAxisSupport,
10
+ } from '../utils';
6
11
 
7
12
  const groupedSides = [ 'vertical', 'horizontal' ];
8
13
 
@@ -20,7 +25,17 @@ export default function AxialInputControls( {
20
25
  if ( ! onChange ) {
21
26
  return;
22
27
  }
23
- const nextValues = { ...values };
28
+
29
+ // Encode the existing value into the preset value if the passed in value matches the value of one of the spacingSizes.
30
+ const nextValues = {
31
+ ...Object.keys( values ).reduce( ( acc, key ) => {
32
+ acc[ key ] = getPresetValueFromCustomValue(
33
+ values[ key ],
34
+ spacingSizes
35
+ );
36
+ return acc;
37
+ }, {} ),
38
+ };
24
39
 
25
40
  if ( side === 'vertical' ) {
26
41
  nextValues.top = next;
@@ -2,7 +2,12 @@
2
2
  * Internal dependencies
3
3
  */
4
4
  import SpacingInputControl from './spacing-input-control';
5
- import { ALL_SIDES, LABELS, ICONS } from '../utils';
5
+ import {
6
+ ALL_SIDES,
7
+ LABELS,
8
+ ICONS,
9
+ getPresetValueFromCustomValue,
10
+ } from '../utils';
6
11
 
7
12
  export default function SeparatedInputControls( {
8
13
  minimumCustomValue,
@@ -20,7 +25,17 @@ export default function SeparatedInputControls( {
20
25
  : ALL_SIDES;
21
26
 
22
27
  const createHandleOnChange = ( side ) => ( next ) => {
23
- const nextValues = { ...values };
28
+ // Encode the existing value into the preset value if the passed in value matches the value of one of the spacingSizes.
29
+ const nextValues = {
30
+ ...Object.keys( values ).reduce( ( acc, key ) => {
31
+ acc[ key ] = getPresetValueFromCustomValue(
32
+ values[ key ],
33
+ spacingSizes
34
+ );
35
+ return acc;
36
+ }, {} ),
37
+ };
38
+
24
39
  nextValues[ side ] = next;
25
40
 
26
41
  onChange( nextValues );
@@ -2,7 +2,7 @@
2
2
  * Internal dependencies
3
3
  */
4
4
  import SpacingInputControl from './spacing-input-control';
5
- import { LABELS } from '../utils';
5
+ import { LABELS, getPresetValueFromCustomValue } from '../utils';
6
6
 
7
7
  export default function SingleInputControl( {
8
8
  minimumCustomValue,
@@ -16,7 +16,17 @@ export default function SingleInputControl( {
16
16
  values,
17
17
  } ) {
18
18
  const createHandleOnChange = ( currentSide ) => ( next ) => {
19
- const nextValues = { ...values };
19
+ // Encode the existing value into the preset value if the passed in value matches the value of one of the spacingSizes.
20
+ const nextValues = {
21
+ ...Object.keys( values ).reduce( ( acc, key ) => {
22
+ acc[ key ] = getPresetValueFromCustomValue(
23
+ values[ key ],
24
+ spacingSizes
25
+ );
26
+ return acc;
27
+ }, {} ),
28
+ };
29
+
20
30
  nextValues[ currentSide ] = next;
21
31
 
22
32
  onChange( nextValues );
@@ -102,7 +102,7 @@ export function getCustomValueFromPreset( value, spacingSizes ) {
102
102
  */
103
103
  export function getPresetValueFromCustomValue( value, spacingSizes ) {
104
104
  // Return value as-is if it is already a preset;
105
- if ( isValueSpacingPreset( value ) ) {
105
+ if ( isValueSpacingPreset( value ) || value === '0' ) {
106
106
  return value;
107
107
  }
108
108
 
@@ -0,0 +1,44 @@
1
+ # TextTransformControl
2
+
3
+ The `TextTransformControl` component is responsible for rendering a control element that allows users to select and apply text transformation options to blocks or elements in the Gutenberg editor. It provides an intuitive interface for changing the text appearance by applying different transformations such as `none`, `uppercase`, `lowercase`, `capitalize`.
4
+
5
+ ![TextTransformConrol Element in Inspector Control](https://raw.githubusercontent.com/WordPress/gutenberg/HEAD/docs/assets/text-transform-component.png?raw=true)
6
+
7
+ ## Table of contents
8
+
9
+ 1. [Development guidelines](#development-guidelines)
10
+
11
+ ## Development guidelines
12
+
13
+ ### Usage
14
+
15
+ Renders the Text Transform Component with `none`, `uppercase`, `lowercase`, `capitalize` options.
16
+
17
+ ```jsx
18
+ import { TextTransformControl } from '@wordpress/block-editor';
19
+
20
+ const MyTextTransformControlComponent = () => (
21
+ <TextTransformControl
22
+ value={ textTransform }
23
+ onChange={ ( value ) => {
24
+ setAttributes( { textTransform: value } );
25
+ } }
26
+ />
27
+ );
28
+ ```
29
+
30
+ ### Props
31
+
32
+ ### `value`
33
+
34
+ - **Type:** `String`
35
+ - **Default:** `none`
36
+ - **Options:** `none`, `uppercase`, `lowercase`, `capitalize`
37
+
38
+ The current value of the Text Transform setting. You may only choose from the `Options` listed above.
39
+
40
+ ### `onChange`
41
+
42
+ - **Type:** `Function`
43
+
44
+ A callback function invoked when the Text Transform value is changed via an interaction with any of the buttons. Called with the Text Transform value (`none`, `uppercase`, `lowercase`, `capitalize`) as the only argument.
@@ -67,8 +67,11 @@ export default function useBlockDisplayInformation( clientId ) {
67
67
  return useSelect(
68
68
  ( select ) => {
69
69
  if ( ! clientId ) return null;
70
- const { getBlockName, getBlockAttributes } =
71
- select( blockEditorStore );
70
+ const {
71
+ getBlockName,
72
+ getBlockAttributes,
73
+ __experimentalGetReusableBlockTitle,
74
+ } = select( blockEditorStore );
72
75
  const { getBlockType, getActiveBlockVariation } =
73
76
  select( blocksStore );
74
77
  const blockName = getBlockName( clientId );
@@ -76,12 +79,16 @@ export default function useBlockDisplayInformation( clientId ) {
76
79
  if ( ! blockType ) return null;
77
80
  const attributes = getBlockAttributes( clientId );
78
81
  const match = getActiveBlockVariation( blockName, attributes );
79
- const isSynced =
80
- isReusableBlock( blockType ) || isTemplatePart( blockType );
82
+ const isReusable = isReusableBlock( blockType );
83
+ const resusableTitle = isReusable
84
+ ? __experimentalGetReusableBlockTitle( attributes.ref )
85
+ : undefined;
86
+ const title = resusableTitle || blockType.title;
87
+ const isSynced = isReusable || isTemplatePart( blockType );
81
88
  const positionLabel = getPositionTypeLabel( attributes );
82
89
  const blockTypeInfo = {
83
90
  isSynced,
84
- title: blockType.title,
91
+ title,
85
92
  icon: blockType.icon,
86
93
  description: blockType.description,
87
94
  anchor: attributes?.anchor,
@@ -1,14 +1,17 @@
1
1
  /**
2
2
  * External dependencies
3
3
  */
4
- import { useSharedValue } from 'react-native-reanimated';
4
+ import {
5
+ runOnJS,
6
+ useDerivedValue,
7
+ useSharedValue,
8
+ } from 'react-native-reanimated';
5
9
 
6
10
  /**
7
11
  * WordPress dependencies
8
12
  */
9
13
  import { useSelect } from '@wordpress/data';
10
14
  import { useCallback } from '@wordpress/element';
11
- import { useThrottle } from '@wordpress/compose';
12
15
 
13
16
  /**
14
17
  * Internal dependencies
@@ -18,6 +21,8 @@ import { useBlockListContext } from '../block-list/block-list-context';
18
21
  import { getDistanceToNearestEdge } from '../../utils/math';
19
22
  import useOnBlockDrop from '../use-on-block-drop';
20
23
 
24
+ const UPDATE_TARGET_BLOCK_INDEX_THRESHOLD = 20; // In pixels
25
+
21
26
  /** @typedef {import('../../utils/math').WPPoint} WPPoint */
22
27
 
23
28
  /**
@@ -111,6 +116,14 @@ export default function useBlockDropZone( {
111
116
  rootClientId: targetRootClientId = '',
112
117
  } = {} ) {
113
118
  const targetBlockIndex = useSharedValue( null );
119
+ const dragPosition = {
120
+ x: useSharedValue( 0 ),
121
+ y: useSharedValue( 0 ),
122
+ };
123
+ const prevDragPosition = {
124
+ x: useSharedValue( 0 ),
125
+ y: useSharedValue( 0 ),
126
+ };
114
127
 
115
128
  const { getBlockListSettings, getSettings } = useSelect( blockEditorStore );
116
129
  const { blocksLayouts, getBlockLayoutsOrderedByYCoord } =
@@ -118,43 +131,67 @@ export default function useBlockDropZone( {
118
131
 
119
132
  const getSortedBlocksLayouts = useCallback( () => {
120
133
  return getBlockLayoutsOrderedByYCoord( blocksLayouts.current );
134
+ // We use the value of `blocksLayouts` as the dependency.
135
+ // eslint-disable-next-line react-hooks/exhaustive-deps
121
136
  }, [ blocksLayouts.current ] );
122
137
 
123
138
  const isRTL = getSettings().isRTL;
124
139
 
125
140
  const onBlockDrop = useOnBlockDrop();
126
141
 
127
- const throttled = useThrottle(
128
- useCallback(
129
- ( event ) => {
130
- const sortedBlockLayouts = getSortedBlocksLayouts();
131
-
132
- const targetIndex = getNearestBlockIndex(
133
- sortedBlockLayouts,
134
- { x: event.x, y: event.y },
135
- getBlockListSettings( targetRootClientId )?.orientation,
136
- isRTL
137
- );
138
- if ( targetIndex !== null ) {
139
- targetBlockIndex.value = targetIndex ?? 0;
140
- }
141
- },
142
- [
143
- getSortedBlocksLayouts,
144
- getNearestBlockIndex,
145
- getBlockListSettings,
146
- targetBlockIndex,
147
- ]
148
- ),
149
- 200
142
+ const updateTargetBlockIndex = useCallback(
143
+ ( event ) => {
144
+ const sortedBlockLayouts = getSortedBlocksLayouts();
145
+
146
+ const targetIndex = getNearestBlockIndex(
147
+ sortedBlockLayouts,
148
+ { x: event.x, y: event.y },
149
+ getBlockListSettings( targetRootClientId )?.orientation,
150
+ isRTL
151
+ );
152
+ if ( targetIndex !== null ) {
153
+ targetBlockIndex.value = targetIndex ?? 0;
154
+ }
155
+ },
156
+ [
157
+ getSortedBlocksLayouts,
158
+ getBlockListSettings,
159
+ targetRootClientId,
160
+ isRTL,
161
+ targetBlockIndex,
162
+ ]
150
163
  );
151
164
 
165
+ useDerivedValue( () => {
166
+ const x = dragPosition.x.value;
167
+ const y = dragPosition.y.value;
168
+ const prevX = prevDragPosition.x.value;
169
+ const prevY = prevDragPosition.y.value;
170
+ // `updateTargetBlockIndex` performs expensive calculations, so we throttle
171
+ // the call using a offset threshold based on the dragging position.
172
+ if (
173
+ Math.abs( x - prevX ) >= UPDATE_TARGET_BLOCK_INDEX_THRESHOLD ||
174
+ Math.abs( y - prevY ) >= UPDATE_TARGET_BLOCK_INDEX_THRESHOLD
175
+ ) {
176
+ runOnJS( updateTargetBlockIndex )( { x, y } );
177
+ prevDragPosition.x.value = x;
178
+ prevDragPosition.y.value = y;
179
+ return true;
180
+ }
181
+ return false;
182
+ } );
183
+
152
184
  return {
153
- onBlockDragOver( event ) {
154
- throttled( event );
185
+ onBlockDragOver( { x, y } ) {
186
+ dragPosition.x.value = x;
187
+ dragPosition.y.value = y;
188
+ },
189
+ onBlockDragOverWorklet( { x, y } ) {
190
+ 'worklet';
191
+ dragPosition.x.value = x;
192
+ dragPosition.y.value = y;
155
193
  },
156
194
  onBlockDragEnd() {
157
- throttled.cancel();
158
195
  targetBlockIndex.value = null;
159
196
  },
160
197
  onBlockDrop: ( event ) => {
@@ -1,8 +1,3 @@
1
- /**
2
- * External dependencies
3
- */
4
- import { get } from 'lodash';
5
-
6
1
  /**
7
2
  * WordPress dependencies
8
3
  */
@@ -18,6 +13,7 @@ import { applyFilters } from '@wordpress/hooks';
18
13
  */
19
14
  import { useBlockEditContext } from '../block-edit';
20
15
  import { store as blockEditorStore } from '../../store';
16
+ import { getValueFromObjectPath } from '../../utils/object';
21
17
 
22
18
  const blockedPaths = [
23
19
  'color',
@@ -165,11 +161,14 @@ export default function useSetting( path ) {
165
161
  candidateClientId
166
162
  );
167
163
  result =
168
- get(
164
+ getValueFromObjectPath(
169
165
  candidateAtts,
170
166
  `settings.blocks.${ blockName }.${ normalizedPath }`
171
167
  ) ??
172
- get( candidateAtts, `settings.${ normalizedPath }` );
168
+ getValueFromObjectPath(
169
+ candidateAtts,
170
+ `settings.${ normalizedPath }`
171
+ );
173
172
  if ( result !== undefined ) {
174
173
  // Stop the search for more distant ancestors and move on.
175
174
  break;
@@ -183,7 +182,8 @@ export default function useSetting( path ) {
183
182
  const defaultsPath = `__experimentalFeatures.${ normalizedPath }`;
184
183
  const blockPath = `__experimentalFeatures.blocks.${ blockName }.${ normalizedPath }`;
185
184
  result =
186
- get( settings, blockPath ) ?? get( settings, defaultsPath );
185
+ getValueFromObjectPath( settings, blockPath ) ??
186
+ getValueFromObjectPath( settings, defaultsPath );
187
187
  }
188
188
 
189
189
  // Return if the setting was found in either the block instance or the store.
@@ -23,7 +23,10 @@ export function MarginVisualizer( { clientId, attributes, forceShow } ) {
23
23
  const margin = attributes?.style?.spacing?.margin;
24
24
 
25
25
  useEffect( () => {
26
- if ( ! blockElement ) {
26
+ if (
27
+ ! blockElement ||
28
+ null === blockElement.ownerDocument.defaultView
29
+ ) {
27
30
  return;
28
31
  }
29
32
 
@@ -23,7 +23,10 @@ export function PaddingVisualizer( { clientId, attributes, forceShow } ) {
23
23
  const padding = attributes?.style?.spacing?.padding;
24
24
 
25
25
  useEffect( () => {
26
- if ( ! blockElement ) {
26
+ if (
27
+ ! blockElement ||
28
+ null === blockElement.ownerDocument.defaultView
29
+ ) {
27
30
  return;
28
31
  }
29
32
 
@@ -1,8 +1,3 @@
1
- /**
2
- * External dependencies
3
- */
4
- import { get } from 'lodash';
5
-
6
1
  /**
7
2
  * WordPress dependencies
8
3
  */
@@ -14,7 +9,7 @@ import { useMemo } from '@wordpress/element';
14
9
  */
15
10
  import { useSetting } from '../components';
16
11
  import { useSettingsForBlockElement } from '../components/global-styles/hooks';
17
- import { setImmutably } from '../utils/object';
12
+ import { getValueFromObjectPath, setImmutably } from '../utils/object';
18
13
 
19
14
  /**
20
15
  * Removed falsy values from nested object.
@@ -79,7 +74,10 @@ export function transformStyles(
79
74
  Object.entries( activeSupports ).forEach( ( [ support, isActive ] ) => {
80
75
  if ( isActive ) {
81
76
  migrationPaths[ support ].forEach( ( path ) => {
82
- const styleValue = get( referenceBlockAttributes, path );
77
+ const styleValue = getValueFromObjectPath(
78
+ referenceBlockAttributes,
79
+ path
80
+ );
83
81
  if ( styleValue ) {
84
82
  returnBlock = {
85
83
  ...returnBlock,
@@ -4,7 +4,7 @@
4
4
  import * as globalStyles from './components/global-styles';
5
5
  import { ExperimentalBlockEditorProvider } from './components/provider';
6
6
  import { lock } from './lock-unlock';
7
- import { getRichTextValues } from './components/rich-text/content';
7
+ import { getRichTextValues } from './components/rich-text/get-rich-text-values';
8
8
  import { kebabCase } from './utils/object';
9
9
  import ResizableBoxPopover from './components/resizable-box-popover';
10
10
  import { ComposedPrivateInserter as PrivateInserter } from './components/inserter';
@@ -19,6 +19,10 @@ import { BlockRemovalWarningModal } from './components/block-removal-warning-mod
19
19
  import { useLayoutClasses, useLayoutStyles } from './hooks';
20
20
  import DimensionsTool from './components/dimensions-tool';
21
21
  import ResolutionTool from './components/resolution-tool';
22
+ import {
23
+ default as ReusableBlocksRenameHint,
24
+ useReusableBlocksRenameHint,
25
+ } from './components/inserter/reusable-block-rename-hint';
22
26
 
23
27
  /**
24
28
  * Private @wordpress/block-editor APIs.
@@ -43,4 +47,6 @@ lock( privateApis, {
43
47
  useLayoutStyles,
44
48
  DimensionsTool,
45
49
  ResolutionTool,
50
+ ReusableBlocksRenameHint,
51
+ useReusableBlocksRenameHint,
46
52
  } );
@@ -28,7 +28,6 @@ import {
28
28
  } from '../utils/selection';
29
29
  import {
30
30
  __experimentalUpdateSettings,
31
- ensureDefaultBlock,
32
31
  privateRemoveBlocks,
33
32
  } from './private-actions';
34
33
 
@@ -403,7 +402,7 @@ export const replaceBlocks =
403
402
  initialPosition,
404
403
  meta,
405
404
  } );
406
- dispatch( ensureDefaultBlock() );
405
+ dispatch.ensureDefaultBlock();
407
406
  };
408
407
 
409
408
  /**
@@ -136,21 +136,18 @@ export const isBlockSubtreeDisabled = createSelector(
136
136
  *
137
137
  * @return {Object[]} Tree of block objects with only clientID and innerBlocks set.
138
138
  */
139
- export const getListViewClientIdsTree = createSelector(
139
+ export const getEnabledClientIdsTree = createSelector(
140
140
  ( state, rootClientId = '' ) => {
141
141
  return getBlockOrder( state, rootClientId ).flatMap( ( clientId ) => {
142
142
  if ( getBlockEditingMode( state, clientId ) !== 'disabled' ) {
143
143
  return [
144
144
  {
145
145
  clientId,
146
- innerBlocks: getListViewClientIdsTree(
147
- state,
148
- clientId
149
- ),
146
+ innerBlocks: getEnabledClientIdsTree( state, clientId ),
150
147
  },
151
148
  ];
152
149
  }
153
- return getListViewClientIdsTree( state, clientId );
150
+ return getEnabledClientIdsTree( state, clientId );
154
151
  } );
155
152
  },
156
153
  ( state ) => [
@@ -1855,7 +1855,6 @@ export function lastBlockInserted( state = {}, action ) {
1855
1855
  switch ( action.type ) {
1856
1856
  case 'INSERT_BLOCKS':
1857
1857
  case 'REPLACE_BLOCKS':
1858
- case 'REPLACE_INNER_BLOCKS':
1859
1858
  if ( ! action.blocks.length ) {
1860
1859
  return state;
1861
1860
  }
@@ -2018,7 +2018,7 @@ export const getInserterItems = createSelector(
2018
2018
  title: reusableBlock.title.raw,
2019
2019
  icon,
2020
2020
  category: 'reusable',
2021
- keywords: [],
2021
+ keywords: [ 'reusable' ],
2022
2022
  isDisabled: false,
2023
2023
  utility: 1, // Deprecated.
2024
2024
  frecency,
@@ -2214,15 +2214,24 @@ export const getAllowedBlocks = createSelector(
2214
2214
  return;
2215
2215
  }
2216
2216
 
2217
- return getBlockTypes().filter( ( blockType ) =>
2217
+ const blockTypes = getBlockTypes().filter( ( blockType ) =>
2218
2218
  canIncludeBlockTypeInInserter( state, blockType, rootClientId )
2219
2219
  );
2220
+ const hasReusableBlock =
2221
+ canInsertBlockTypeUnmemoized( state, 'core/block', rootClientId ) &&
2222
+ getReusableBlocks( state ).length > 0;
2223
+
2224
+ return [
2225
+ ...blockTypes,
2226
+ ...( hasReusableBlock ? [ 'core/block' ] : [] ),
2227
+ ];
2220
2228
  },
2221
2229
  ( state, rootClientId ) => [
2222
2230
  state.blockListSettings[ rootClientId ],
2223
2231
  state.blocks.byClientId,
2224
2232
  state.settings.allowedBlockTypes,
2225
2233
  state.settings.templateLock,
2234
+ getReusableBlocks( state ),
2226
2235
  getBlockTypes(),
2227
2236
  ]
2228
2237
  );
@@ -2258,15 +2267,15 @@ export const __experimentalGetAllowedBlocks = createSelector(
2258
2267
  * @property {?Object} attributes Attributes to pass to the newly created block.
2259
2268
  * @property {?Array<string>} attributesToCopy Attributes to be copied from adjecent blocks when inserted.
2260
2269
  */
2261
- export const __experimentalGetDirectInsertBlock = createSelector(
2270
+ export const getDirectInsertBlock = createSelector(
2262
2271
  ( state, rootClientId = null ) => {
2263
2272
  if ( ! rootClientId ) {
2264
2273
  return;
2265
2274
  }
2266
2275
  const defaultBlock =
2267
- state.blockListSettings[ rootClientId ]?.__experimentalDefaultBlock;
2276
+ state.blockListSettings[ rootClientId ]?.defaultBlock;
2268
2277
  const directInsert =
2269
- state.blockListSettings[ rootClientId ]?.__experimentalDirectInsert;
2278
+ state.blockListSettings[ rootClientId ]?.directInsert;
2270
2279
  if ( ! defaultBlock || ! directInsert ) {
2271
2280
  return;
2272
2281
  }
@@ -2283,6 +2292,25 @@ export const __experimentalGetDirectInsertBlock = createSelector(
2283
2292
  ]
2284
2293
  );
2285
2294
 
2295
+ export const __experimentalGetDirectInsertBlock = createSelector(
2296
+ ( state, rootClientId = null ) => {
2297
+ deprecated(
2298
+ 'wp.data.select( "core/block-editor" ).__experimentalGetDirectInsertBlock',
2299
+ {
2300
+ alternative:
2301
+ 'wp.data.select( "core/block-editor" ).getDirectInsertBlock',
2302
+ since: '6.3',
2303
+ version: '6.4',
2304
+ }
2305
+ );
2306
+ return getDirectInsertBlock( state, rootClientId );
2307
+ },
2308
+ ( state, rootClientId ) => [
2309
+ state.blockListSettings[ rootClientId ],
2310
+ state.blocks.tree.get( rootClientId ),
2311
+ ]
2312
+ );
2313
+
2286
2314
  const checkAllowListRecursive = ( blocks, allowedBlockTypes ) => {
2287
2315
  if ( typeof allowedBlockTypes === 'boolean' ) {
2288
2316
  return allowedBlockTypes;
@@ -216,6 +216,7 @@ describe( 'actions', () => {
216
216
  getBlockCount: () => 1,
217
217
  };
218
218
  const dispatch = jest.fn();
219
+ dispatch.ensureDefaultBlock = jest.fn();
219
220
 
220
221
  replaceBlock( 'chicken', block )( { select, dispatch } );
221
222
 
@@ -281,6 +282,7 @@ describe( 'actions', () => {
281
282
  getBlockCount: () => 1,
282
283
  };
283
284
  const dispatch = jest.fn();
285
+ dispatch.ensureDefaultBlock = jest.fn();
284
286
 
285
287
  replaceBlocks( [ 'chicken' ], blocks )( { select, dispatch } );
286
288
 
@@ -314,6 +316,7 @@ describe( 'actions', () => {
314
316
  getBlockCount: () => 1,
315
317
  };
316
318
  const dispatch = jest.fn();
319
+ dispatch.ensureDefaultBlock = jest.fn();
317
320
 
318
321
  replaceBlocks(
319
322
  [ 'chicken' ],
@@ -11,7 +11,7 @@ import {
11
11
  getLastInsertedBlocksClientIds,
12
12
  getBlockEditingMode,
13
13
  isBlockSubtreeDisabled,
14
- getListViewClientIdsTree,
14
+ getEnabledClientIdsTree,
15
15
  getEnabledBlockParents,
16
16
  } from '../private-selectors';
17
17
 
@@ -391,7 +391,7 @@ describe( 'private selectors', () => {
391
391
  } );
392
392
  } );
393
393
 
394
- describe( 'getListViewClientIdsTree', () => {
394
+ describe( 'getEnabledClientIdsTree', () => {
395
395
  const baseState = {
396
396
  settings: {},
397
397
  blocks: {
@@ -462,7 +462,7 @@ describe( 'private selectors', () => {
462
462
  ...baseState,
463
463
  blockEditingModes: new Map( [] ),
464
464
  };
465
- expect( getListViewClientIdsTree( state ) ).toEqual( [
465
+ expect( getEnabledClientIdsTree( state ) ).toEqual( [
466
466
  {
467
467
  clientId: '6cf70164-9097-4460-bcbf-200560546988',
468
468
  innerBlocks: [],
@@ -500,7 +500,7 @@ describe( 'private selectors', () => {
500
500
  blockEditingModes: new Map( [] ),
501
501
  };
502
502
  expect(
503
- getListViewClientIdsTree(
503
+ getEnabledClientIdsTree(
504
504
  state,
505
505
  'ef45d5fd-5234-4fd5-ac4f-c3736c7f9337'
506
506
  )
@@ -534,7 +534,7 @@ describe( 'private selectors', () => {
534
534
  [ '9b9c5c3f-2e46-4f02-9e14-9fe9515b958f', 'contentOnly' ],
535
535
  ] ),
536
536
  };
537
- expect( getListViewClientIdsTree( state ) ).toEqual( [
537
+ expect( getEnabledClientIdsTree( state ) ).toEqual( [
538
538
  {
539
539
  clientId: 'b26fc763-417d-4f01-b81c-2ec61e14a972',
540
540
  innerBlocks: [],