@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
@@ -9,6 +9,7 @@ import {
9
9
  within,
10
10
  getEditorHtml,
11
11
  typeInRichText,
12
+ openBlockActionsMenu,
12
13
  } from 'test/helpers';
13
14
 
14
15
  /**
@@ -36,15 +37,14 @@ describe( 'Block Actions Menu', () => {
36
37
  <p></p>
37
38
  <!-- /wp:paragraph -->`,
38
39
  } );
39
- const { getByLabelText, getByRole } = screen;
40
+ const { getByRole } = screen;
40
41
 
41
42
  // Get block
42
43
  const paragraphBlock = await getBlock( screen, 'Paragraph' );
43
44
  fireEvent.press( paragraphBlock );
44
45
 
45
46
  // Open block actions menu
46
- const blockActionsButton = getByLabelText( /Open Block Actions Menu/ );
47
- fireEvent.press( blockActionsButton );
47
+ await openBlockActionsMenu( screen );
48
48
 
49
49
  // Get Picker title
50
50
  const pickerHeader = getByRole( 'header' );
@@ -56,10 +56,8 @@ describe( 'Block Actions Menu', () => {
56
56
 
57
57
  describe( 'moving blocks', () => {
58
58
  it( 'moves blocks up and down', async () => {
59
- const screen = await initializeEditor( {
60
- screenWidth: 100, // To collapse the up/arrow buttons bellow blocks
61
- } );
62
- const { getByLabelText, getByTestId } = screen;
59
+ const screen = await initializeEditor();
60
+ const { getByLabelText } = screen;
63
61
 
64
62
  // Add Paragraph block
65
63
  await addBlock( screen, 'Paragraph' );
@@ -85,16 +83,8 @@ describe( 'Block Actions Menu', () => {
85
83
  } );
86
84
  fireEvent.press( spacerBlock );
87
85
 
88
- // Open block actions menu
89
- fireEvent.press( getByLabelText( /Open Block Actions Menu/ ) );
90
-
91
- // Get block actions modal
92
- let blockActionsMenu = await getByTestId( 'block-actions-menu' );
93
-
94
86
  // Tap on the Move Down button
95
- fireEvent.press(
96
- within( blockActionsMenu ).getByLabelText( 'Move block down' )
97
- );
87
+ fireEvent.press( getByLabelText( /Move block down/ ) );
98
88
 
99
89
  // Get Heading block
100
90
  const headingBlock = await getBlock( screen, 'Heading', {
@@ -102,25 +92,15 @@ describe( 'Block Actions Menu', () => {
102
92
  } );
103
93
  fireEvent.press( headingBlock );
104
94
 
105
- // Open block actions menu
106
- fireEvent.press( getByLabelText( /Open Block Actions Menu/ ) );
107
-
108
- // Get block actions modal
109
- blockActionsMenu = await getByTestId( 'block-actions-menu' );
110
-
111
95
  // Tap on the Move Up button
112
- fireEvent.press(
113
- within( blockActionsMenu ).getByLabelText( 'Move block up' )
114
- );
96
+ fireEvent.press( getByLabelText( /Move block up/ ) );
115
97
 
116
98
  expect( getEditorHtml() ).toMatchSnapshot();
117
99
  } );
118
100
 
119
101
  it( 'disables the Move Up button for the first block', async () => {
120
- const screen = await initializeEditor( {
121
- screenWidth: 100, // To collapse the up/arrow buttons bellow blocks
122
- } );
123
- const { getByLabelText, getByTestId } = screen;
102
+ const screen = await initializeEditor();
103
+ const { getByLabelText } = screen;
124
104
 
125
105
  // Add Paragraph block
126
106
  await addBlock( screen, 'Paragraph' );
@@ -144,15 +124,8 @@ describe( 'Block Actions Menu', () => {
144
124
  paragraphBlock = await getBlock( screen, 'Paragraph' );
145
125
  fireEvent.press( paragraphBlock );
146
126
 
147
- // Open block actions menu
148
- fireEvent.press( getByLabelText( /Open Block Actions Menu/ ) );
149
-
150
- // Get block actions modal
151
- const blockActionsMenu = await getByTestId( 'block-actions-menu' );
152
-
153
127
  // Get the Move Up button
154
- const upButton =
155
- within( blockActionsMenu ).getByLabelText( 'Move block up' );
128
+ const upButton = getByLabelText( /Move block up/ );
156
129
  const isUpButtonDisabled =
157
130
  upButton.props.accessibilityState?.disabled;
158
131
  expect( isUpButtonDisabled ).toBe( true );
@@ -167,7 +140,7 @@ describe( 'Block Actions Menu', () => {
167
140
  const screen = await initializeEditor( {
168
141
  screenWidth: 100,
169
142
  } );
170
- const { getByLabelText, getByTestId } = screen;
143
+ const { getByLabelText } = screen;
171
144
 
172
145
  // Add Paragraph block
173
146
  await addBlock( screen, 'Paragraph' );
@@ -193,15 +166,8 @@ describe( 'Block Actions Menu', () => {
193
166
  } );
194
167
  fireEvent.press( headingBlock );
195
168
 
196
- // Open block actions menu
197
- fireEvent.press( getByLabelText( /Open Block Actions Menu/ ) );
198
-
199
- // Get block actions modal
200
- const blockActionsMenu = await getByTestId( 'block-actions-menu' );
201
-
202
169
  // Get the Move Down button
203
- const downButton =
204
- within( blockActionsMenu ).getByLabelText( 'Move block down' );
170
+ const downButton = getByLabelText( /Move block down/ );
205
171
  const isDownButtonDisabled =
206
172
  downButton.props.accessibilityState?.disabled;
207
173
  expect( isDownButtonDisabled ).toBe( true );
@@ -243,7 +209,7 @@ describe( 'Block Actions Menu', () => {
243
209
  fireEvent.press( headingBlock );
244
210
 
245
211
  // Open block actions menu
246
- fireEvent.press( getByLabelText( /Open Block Actions Menu/ ) );
212
+ await openBlockActionsMenu( screen );
247
213
 
248
214
  // Tap on the Copy button
249
215
  fireEvent.press( getByLabelText( /Copy/ ) );
@@ -253,7 +219,7 @@ describe( 'Block Actions Menu', () => {
253
219
  fireEvent.press( paragraphBlock );
254
220
 
255
221
  // Open block actions menu
256
- fireEvent.press( getByLabelText( /Open Block Actions Menu/ ) );
222
+ await openBlockActionsMenu( screen );
257
223
 
258
224
  // Tap on the Paste block after button
259
225
  fireEvent.press( getByLabelText( /Paste block after/ ) );
@@ -290,7 +256,7 @@ describe( 'Block Actions Menu', () => {
290
256
  fireEvent.press( headingBlock );
291
257
 
292
258
  // Open block actions menu
293
- fireEvent.press( getByLabelText( /Open Block Actions Menu/ ) );
259
+ await openBlockActionsMenu( screen );
294
260
 
295
261
  // Tap on the Copy button
296
262
  fireEvent.press( getByLabelText( /Copy/ ) );
@@ -300,7 +266,7 @@ describe( 'Block Actions Menu', () => {
300
266
  fireEvent.press( paragraphBlock );
301
267
 
302
268
  // Open block actions menu
303
- fireEvent.press( getByLabelText( /Open Block Actions Menu/ ) );
269
+ await openBlockActionsMenu( screen );
304
270
 
305
271
  // Tap on the Past block after button
306
272
  fireEvent.press( getByLabelText( /Paste block after/ ) );
@@ -335,7 +301,7 @@ describe( 'Block Actions Menu', () => {
335
301
  fireEvent.press( paragraphBlock );
336
302
 
337
303
  // Open block actions menu
338
- fireEvent.press( getByLabelText( /Open Block Actions Menu/ ) );
304
+ await openBlockActionsMenu( screen );
339
305
 
340
306
  // Tap on the Cut button
341
307
  fireEvent.press( getByLabelText( /Cut block/ ) );
@@ -346,7 +312,7 @@ describe( 'Block Actions Menu', () => {
346
312
  fireEvent.press( headingBlock );
347
313
 
348
314
  // Open block actions menu
349
- fireEvent.press( getByLabelText( /Open Block Actions Menu/ ) );
315
+ await openBlockActionsMenu( screen );
350
316
 
351
317
  // Tap on the Cut button
352
318
  fireEvent.press( getByLabelText( /Paste block after/ ) );
@@ -383,7 +349,7 @@ describe( 'Block Actions Menu', () => {
383
349
  fireEvent.press( spacerBlock );
384
350
 
385
351
  // Open block actions menu
386
- fireEvent.press( getByLabelText( /Open Block Actions Menu/ ) );
352
+ await openBlockActionsMenu( screen );
387
353
 
388
354
  // Tap on the Duplicate button
389
355
  fireEvent.press( getByLabelText( /Duplicate block/ ) );
@@ -418,7 +384,7 @@ describe( 'Block Actions Menu', () => {
418
384
  fireEvent.press( paragraphBlock );
419
385
 
420
386
  // Open block actions menu
421
- fireEvent.press( getByLabelText( /Open Block Actions Menu/ ) );
387
+ await openBlockActionsMenu( screen );
422
388
 
423
389
  // Tap on the Transform block button
424
390
  fireEvent.press( getByLabelText( /Transform block…/ ) );
@@ -0,0 +1,42 @@
1
+ /**
2
+ * External dependencies
3
+ */
4
+ import {
5
+ addBlock,
6
+ fireEvent,
7
+ getBlock,
8
+ initializeEditor,
9
+ setupCoreBlocks,
10
+ } from 'test/helpers';
11
+
12
+ setupCoreBlocks();
13
+
14
+ describe( 'Block Toolbar', () => {
15
+ it( "doesn't render the block settings button if there aren't any settings for the current selected block", async () => {
16
+ // Arrange
17
+ const screen = await initializeEditor();
18
+ await addBlock( screen, 'Image' );
19
+
20
+ // Act
21
+ fireEvent(
22
+ screen.getByTestId( 'media-options-picker' ),
23
+ 'backdropPress'
24
+ );
25
+
26
+ // Assert
27
+ expect( screen.queryByLabelText( 'Open Settings' ) ).toBeNull();
28
+ } );
29
+
30
+ it( 'renders the block settings button for the current selected block', async () => {
31
+ // Arrange
32
+ const screen = await initializeEditor();
33
+ await addBlock( screen, 'Paragraph' );
34
+
35
+ // Act
36
+ const paragraphBlock = await getBlock( screen, 'Paragraph' );
37
+ fireEvent.press( paragraphBlock );
38
+
39
+ // Assert
40
+ expect( screen.queryByLabelText( 'Open Settings' ) ).toBeVisible();
41
+ } );
42
+ } );
@@ -3,8 +3,8 @@
3
3
  align-items: center;
4
4
  justify-content: center;
5
5
  padding: 9px;
6
- margin-left: 0;
7
- margin-right: 0;
6
+ margin-left: $grid-unit;
7
+ margin-right: $grid-unit;
8
8
  border-radius: 4px;
9
9
  }
10
10
 
@@ -0,0 +1,49 @@
1
+ ## Caption
2
+
3
+ The `Caption` component renders the [caption part](https://wordpress.org/documentation/article/gallery-block/#caption) of some blocks (image, gallery...).
4
+
5
+ This component encapsulates the "caption" behaviour and styles over a `<RichText>` so it can be used in other components such as the `BlockCaption` component.
6
+
7
+ ## Table of contents
8
+
9
+ 1. [Development guidelines](#development-guidelines)
10
+ 2. [Related components](#related-components)
11
+
12
+ ## Development guidelines
13
+
14
+ ### Usage
15
+
16
+ Renders a Caption area:
17
+
18
+ ```jsx
19
+ import { Caption } from '@wordpress/block-editor';
20
+ const BlockCaption = ( {
21
+ onBlur,
22
+ onChange,
23
+ onFocus,
24
+ isSelected,
25
+ shouldDisplay,
26
+ text,
27
+ insertBlocksAfter,
28
+ } ) => (
29
+ <View >
30
+ <Caption
31
+ isSelected={ isSelected }
32
+ onBlur={ onBlur }
33
+ onChange={ onChange }
34
+ onFocus={ onFocus }
35
+ shouldDisplay={ shouldDisplay }
36
+ value={ text }
37
+ insertBlocksAfter={ insertBlocksAfter }
38
+ />
39
+ </View>
40
+ );
41
+ ```
42
+
43
+ ### Props
44
+
45
+ The properties `isSelected`, `onBlur`, `onChange`, `onFocus`, `shouldDisplay`, `value`, `insertBlocksAfter` of this component are passed directly to their related props of its inner `<RichText>` component ([see detailed info about the RichText component's props](https://github.com/WordPress/gutenberg/blob/HEAD/packages/block-editor/src/components/rich-text/README.md)).
46
+
47
+ ## Related components
48
+
49
+ Caption components is mostly used by the [`BlockCaption`](https://github.com/WordPress/gutenberg/blob/HEAD/packages/block-editor/src/components/block-caption) component.
@@ -6,6 +6,7 @@ import classnames from 'classnames';
6
6
  /**
7
7
  * WordPress dependencies
8
8
  */
9
+ import { __ } from '@wordpress/i18n';
9
10
  import {
10
11
  BaseControl,
11
12
  __experimentalVStack as VStack,
@@ -28,12 +29,12 @@ const colorsAndGradientKeys = [
28
29
 
29
30
  const TAB_COLOR = {
30
31
  name: 'color',
31
- title: 'Solid',
32
+ title: __( 'Solid' ),
32
33
  value: 'color',
33
34
  };
34
35
  const TAB_GRADIENT = {
35
36
  name: 'gradient',
36
- title: 'Gradient',
37
+ title: __( 'Gradient' ),
37
38
  value: 'gradient',
38
39
  };
39
40
 
@@ -328,22 +328,6 @@ export default function ColorPanel( {
328
328
  : gradientValue;
329
329
  };
330
330
 
331
- // Text Color
332
- const showTextPanel = useHasTextPanel( settings );
333
- const textColor = decodeValue( inheritedValue?.color?.text );
334
- const userTextColor = decodeValue( value?.color?.text );
335
- const hasTextColor = () => !! userTextColor;
336
- const setTextColor = ( newColor ) => {
337
- onChange(
338
- setImmutably(
339
- value,
340
- [ 'color', 'text' ],
341
- encodeColorValue( newColor )
342
- )
343
- );
344
- };
345
- const resetTextColor = () => setTextColor( undefined );
346
-
347
331
  // BackgroundColor
348
332
  const showBackgroundPanel = useHasBackgroundPanel( settings );
349
333
  const backgroundColor = decodeValue( inheritedValue?.color?.background );
@@ -424,6 +408,29 @@ export default function ColorPanel( {
424
408
  onChange( newValue );
425
409
  };
426
410
 
411
+ // Text Color
412
+ const showTextPanel = useHasTextPanel( settings );
413
+ const textColor = decodeValue( inheritedValue?.color?.text );
414
+ const userTextColor = decodeValue( value?.color?.text );
415
+ const hasTextColor = () => !! userTextColor;
416
+ const setTextColor = ( newColor ) => {
417
+ let changedObject = setImmutably(
418
+ value,
419
+ [ 'color', 'text' ],
420
+ encodeColorValue( newColor )
421
+ );
422
+ if ( textColor === linkColor ) {
423
+ changedObject = setImmutably(
424
+ changedObject,
425
+ [ 'elements', 'link', 'color', 'text' ],
426
+ encodeColorValue( newColor )
427
+ );
428
+ }
429
+
430
+ onChange( changedObject );
431
+ };
432
+ const resetTextColor = () => setTextColor( undefined );
433
+
427
434
  // Elements
428
435
  const elements = [
429
436
  {
@@ -207,18 +207,24 @@ export default function DimensionsPanel( {
207
207
  // in global styles but not in block inspector.
208
208
  includeLayoutControls = false,
209
209
  } ) {
210
+ const { dimensions, spacing } = settings;
211
+
210
212
  const decodeValue = ( rawValue ) => {
211
213
  if ( rawValue && typeof rawValue === 'object' ) {
212
214
  return Object.keys( rawValue ).reduce( ( acc, key ) => {
213
215
  acc[ key ] = getValueFromVariable(
214
- { settings },
216
+ { settings: { dimensions, spacing } },
215
217
  '',
216
218
  rawValue[ key ]
217
219
  );
218
220
  return acc;
219
221
  }, {} );
220
222
  }
221
- return getValueFromVariable( { settings }, '', rawValue );
223
+ return getValueFromVariable(
224
+ { settings: { dimensions, spacing } },
225
+ '',
226
+ rawValue
227
+ );
222
228
  };
223
229
 
224
230
  const showSpacingPresetsControl = useHasSpacingPresets( settings );
@@ -1,12 +1,8 @@
1
- /**
2
- * External dependencies
3
- */
4
- import { get } from 'lodash';
5
-
6
1
  /**
7
2
  * Internal dependencies
8
3
  */
9
4
  import { scopeSelector } from './utils';
5
+ import { getValueFromObjectPath } from '../../utils/object';
10
6
 
11
7
  /**
12
8
  * Determine the CSS selector for the block type and target provided, returning
@@ -69,15 +65,15 @@ export function getBlockCSSSelector(
69
65
  if ( hasSelectors ) {
70
66
  // Get selector from either `feature.root` or shorthand path.
71
67
  const featureSelector =
72
- get( selectors, `${ path }.root`, null ) ||
73
- get( selectors, path, null );
68
+ getValueFromObjectPath( selectors, `${ path }.root`, null ) ||
69
+ getValueFromObjectPath( selectors, path, null );
74
70
 
75
71
  // Return feature selector if found or any available fallback.
76
72
  return featureSelector || fallbackSelector;
77
73
  }
78
74
 
79
75
  // Try getting old experimental supports selector value.
80
- const featureSelector = get(
76
+ const featureSelector = getValueFromObjectPath(
81
77
  supports,
82
78
  `${ path }.__experimentalSelector`,
83
79
  null
@@ -98,7 +94,7 @@ export function getBlockCSSSelector(
98
94
 
99
95
  // Use selectors API if available.
100
96
  if ( hasSelectors ) {
101
- subfeatureSelector = get( selectors, path, null );
97
+ subfeatureSelector = getValueFromObjectPath( selectors, path, null );
102
98
  }
103
99
 
104
100
  // Only return if we have a subfeature selector.
@@ -2,7 +2,6 @@
2
2
  * External dependencies
3
3
  */
4
4
  import fastDeepEqual from 'fast-deep-equal/es6';
5
- import { get, set } from 'lodash';
6
5
 
7
6
  /**
8
7
  * WordPress dependencies
@@ -16,6 +15,7 @@ import { _x } from '@wordpress/i18n';
16
15
  * Internal dependencies
17
16
  */
18
17
  import { getValueFromVariable, getPresetVariableFromValue } from './utils';
18
+ import { getValueFromObjectPath, setImmutably } from '../../utils/object';
19
19
  import { GlobalStylesContext } from './context';
20
20
  import { unlock } from '../../lock-unlock';
21
21
 
@@ -103,20 +103,21 @@ export function useGlobalSetting( propertyPath, blockName, source = 'all' ) {
103
103
 
104
104
  if ( propertyPath ) {
105
105
  return (
106
- get( configToUse, contextualPath ) ??
107
- get( configToUse, globalPath )
106
+ getValueFromObjectPath( configToUse, contextualPath ) ??
107
+ getValueFromObjectPath( configToUse, globalPath )
108
108
  );
109
109
  }
110
110
 
111
- const result = {};
111
+ let result = {};
112
112
  VALID_SETTINGS.forEach( ( setting ) => {
113
113
  const value =
114
- get(
114
+ getValueFromObjectPath(
115
115
  configToUse,
116
116
  `settings${ appendedBlockPath }.${ setting }`
117
- ) ?? get( configToUse, `settings.${ setting }` );
117
+ ) ??
118
+ getValueFromObjectPath( configToUse, `settings.${ setting }` );
118
119
  if ( value ) {
119
- set( result, setting, value );
120
+ result = setImmutably( result, setting.split( '.' ), value );
120
121
  }
121
122
  } );
122
123
  return result;
@@ -130,13 +131,9 @@ export function useGlobalSetting( propertyPath, blockName, source = 'all' ) {
130
131
  ] );
131
132
 
132
133
  const setSetting = ( newValue ) => {
133
- setUserConfig( ( currentConfig ) => {
134
- // Deep clone `currentConfig` to avoid mutating it later.
135
- const newUserConfig = JSON.parse( JSON.stringify( currentConfig ) );
136
- set( newUserConfig, contextualPath, newValue );
137
-
138
- return newUserConfig;
139
- } );
134
+ setUserConfig( ( currentConfig ) =>
135
+ setImmutably( currentConfig, contextualPath.split( '.' ), newValue )
136
+ );
140
137
  };
141
138
 
142
139
  return [ settingValue, setSetting ];
@@ -160,12 +157,10 @@ export function useGlobalStyle(
160
157
  : `styles.blocks.${ blockName }${ appendedPath }`;
161
158
 
162
159
  const setStyle = ( newValue ) => {
163
- setUserConfig( ( currentConfig ) => {
164
- // Deep clone `currentConfig` to avoid mutating it later.
165
- const newUserConfig = JSON.parse( JSON.stringify( currentConfig ) );
166
- set(
167
- newUserConfig,
168
- finalPath,
160
+ setUserConfig( ( currentConfig ) =>
161
+ setImmutably(
162
+ currentConfig,
163
+ finalPath.split( '.' ),
169
164
  shouldDecodeEncode
170
165
  ? getPresetVariableFromValue(
171
166
  mergedConfig.settings,
@@ -174,27 +169,26 @@ export function useGlobalStyle(
174
169
  newValue
175
170
  )
176
171
  : newValue
177
- );
178
- return newUserConfig;
179
- } );
172
+ )
173
+ );
180
174
  };
181
175
 
182
176
  let rawResult, result;
183
177
  switch ( source ) {
184
178
  case 'all':
185
- rawResult = get( mergedConfig, finalPath );
179
+ rawResult = getValueFromObjectPath( mergedConfig, finalPath );
186
180
  result = shouldDecodeEncode
187
181
  ? getValueFromVariable( mergedConfig, blockName, rawResult )
188
182
  : rawResult;
189
183
  break;
190
184
  case 'user':
191
- rawResult = get( userConfig, finalPath );
185
+ rawResult = getValueFromObjectPath( userConfig, finalPath );
192
186
  result = shouldDecodeEncode
193
187
  ? getValueFromVariable( mergedConfig, blockName, rawResult )
194
188
  : rawResult;
195
189
  break;
196
190
  case 'base':
197
- rawResult = get( baseConfig, finalPath );
191
+ rawResult = getValueFromObjectPath( baseConfig, finalPath );
198
192
  result = shouldDecodeEncode
199
193
  ? getValueFromVariable( baseConfig, blockName, rawResult )
200
194
  : rawResult;
@@ -114,6 +114,21 @@ function useHasTextColumnsControl( settings ) {
114
114
  return settings?.typography?.textColumns;
115
115
  }
116
116
 
117
+ function getUniqueFontSizesBySlug( settings ) {
118
+ const fontSizesPerOrigin = settings?.typography?.fontSizes ?? {};
119
+ const fontSizes = []
120
+ .concat( fontSizesPerOrigin?.custom ?? [] )
121
+ .concat( fontSizesPerOrigin?.theme ?? [] )
122
+ .concat( fontSizesPerOrigin.default ?? [] );
123
+
124
+ return fontSizes.reduce( ( acc, currentSize ) => {
125
+ if ( ! acc.some( ( { slug } ) => slug === currentSize.slug ) ) {
126
+ acc.push( currentSize );
127
+ }
128
+ return acc;
129
+ }, [] );
130
+ }
131
+
117
132
  function TypographyToolsPanel( {
118
133
  resetAllFilter,
119
134
  onChange,
@@ -189,11 +204,8 @@ export default function TypographyPanel( {
189
204
  // Font Size
190
205
  const hasFontSizeEnabled = useHasFontSizeControl( settings );
191
206
  const disableCustomFontSizes = ! settings?.typography?.customFontSize;
192
- const fontSizesPerOrigin = settings?.typography?.fontSizes ?? {};
193
- const fontSizes = []
194
- .concat( fontSizesPerOrigin?.custom ?? [] )
195
- .concat( fontSizesPerOrigin?.theme ?? [] )
196
- .concat( fontSizesPerOrigin.default ?? [] );
207
+ const fontSizes = getUniqueFontSizesBySlug( settings );
208
+
197
209
  const fontSize = decodeValue( inheritedValue?.typography?.fontSize );
198
210
  const setFontSize = ( newValue, metadata ) => {
199
211
  const actualValue = !! metadata?.slug