@wordpress/block-editor 11.4.0 → 11.5.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 (288) hide show
  1. package/CHANGELOG.md +6 -0
  2. package/build/components/block-inspector/index.js +11 -10
  3. package/build/components/block-inspector/index.js.map +1 -1
  4. package/build/components/block-inspector/useBlockInspectorAnimationSettings.js +46 -0
  5. package/build/components/block-inspector/useBlockInspectorAnimationSettings.js.map +1 -0
  6. package/build/components/block-lock/modal.js +1 -0
  7. package/build/components/block-lock/modal.js.map +1 -1
  8. package/build/components/block-settings-menu/block-settings-dropdown.js +2 -2
  9. package/build/components/block-settings-menu/block-settings-dropdown.js.map +1 -1
  10. package/build/components/block-styles/index.js +2 -1
  11. package/build/components/block-styles/index.js.map +1 -1
  12. package/build/components/child-layout-control/index.js +107 -0
  13. package/build/components/child-layout-control/index.js.map +1 -0
  14. package/build/components/date-format-picker/index.js +3 -3
  15. package/build/components/date-format-picker/index.js.map +1 -1
  16. package/build/components/global-styles/dimensions-panel.js +594 -0
  17. package/build/components/global-styles/dimensions-panel.js.map +1 -0
  18. package/build/components/global-styles/hooks.js +72 -36
  19. package/build/components/global-styles/hooks.js.map +1 -1
  20. package/build/components/global-styles/index.js +20 -6
  21. package/build/components/global-styles/index.js.map +1 -1
  22. package/build/components/global-styles/typography-panel.js +25 -12
  23. package/build/components/global-styles/typography-panel.js.map +1 -1
  24. package/build/components/global-styles/use-global-styles-output.js +1 -1
  25. package/build/components/global-styles/use-global-styles-output.js.map +1 -1
  26. package/build/components/global-styles/utils.js +2 -0
  27. package/build/components/global-styles/utils.js.map +1 -1
  28. package/build/components/index.native.js +23 -0
  29. package/build/components/index.native.js.map +1 -1
  30. package/build/components/inserter/media-tab/hooks.js +10 -11
  31. package/build/components/inserter/media-tab/hooks.js.map +1 -1
  32. package/build/components/inserter/media-tab/media-list.js +5 -108
  33. package/build/components/inserter/media-tab/media-list.js.map +1 -1
  34. package/build/components/inserter/media-tab/media-preview.js +242 -0
  35. package/build/components/inserter/media-tab/media-preview.js.map +1 -0
  36. package/build/components/inspector-controls/block-support-tools-panel.js +1 -1
  37. package/build/components/inspector-controls/block-support-tools-panel.js.map +1 -1
  38. package/build/components/inspector-controls/fill.js +38 -9
  39. package/build/components/inspector-controls/fill.js.map +1 -1
  40. package/build/components/link-control/settings-drawer.js +1 -1
  41. package/build/components/link-control/settings-drawer.js.map +1 -1
  42. package/build/components/link-control/settings.js +1 -0
  43. package/build/components/link-control/settings.js.map +1 -1
  44. package/build/components/list-view/block.js +17 -3
  45. package/build/components/list-view/block.js.map +1 -1
  46. package/build/components/list-view/branch.js +2 -2
  47. package/build/components/list-view/branch.js.map +1 -1
  48. package/build/components/list-view/expander.js +2 -1
  49. package/build/components/list-view/expander.js.map +1 -1
  50. package/build/components/list-view/leaf.js +10 -6
  51. package/build/components/list-view/leaf.js.map +1 -1
  52. package/build/components/list-view/use-list-view-scroll-into-view.js +51 -0
  53. package/build/components/list-view/use-list-view-scroll-into-view.js.map +1 -0
  54. package/build/components/off-canvas-editor/appender.js +5 -10
  55. package/build/components/off-canvas-editor/appender.js.map +1 -1
  56. package/build/components/off-canvas-editor/branch.js +1 -0
  57. package/build/components/off-canvas-editor/branch.js.map +1 -1
  58. package/build/components/off-canvas-editor/index.js +7 -3
  59. package/build/components/off-canvas-editor/index.js.map +1 -1
  60. package/build/components/off-canvas-editor/leaf-more-menu.js +34 -4
  61. package/build/components/off-canvas-editor/leaf-more-menu.js.map +1 -1
  62. package/build/components/off-canvas-editor/link-ui.js +1 -0
  63. package/build/components/off-canvas-editor/link-ui.js.map +1 -1
  64. package/build/components/responsive-block-control/index.js +1 -0
  65. package/build/components/responsive-block-control/index.js.map +1 -1
  66. package/build/components/rich-text/index.js +9 -43
  67. package/build/components/rich-text/index.js.map +1 -1
  68. package/build/components/rich-text/use-delete.js +73 -0
  69. package/build/components/rich-text/use-delete.js.map +1 -0
  70. package/build/components/rich-text/use-input-rules.js +14 -6
  71. package/build/components/rich-text/use-input-rules.js.map +1 -1
  72. package/build/components/writing-flow/use-selection-observer.js +4 -1
  73. package/build/components/writing-flow/use-selection-observer.js.map +1 -1
  74. package/build/hooks/align.js +3 -1
  75. package/build/hooks/align.js.map +1 -1
  76. package/build/hooks/dimensions.js +72 -190
  77. package/build/hooks/dimensions.js.map +1 -1
  78. package/build/hooks/duotone.js +94 -25
  79. package/build/hooks/duotone.js.map +1 -1
  80. package/build/hooks/gap.js +0 -202
  81. package/build/hooks/gap.js.map +1 -1
  82. package/build/hooks/layout.js +14 -5
  83. package/build/hooks/layout.js.map +1 -1
  84. package/build/hooks/margin.js +7 -163
  85. package/build/hooks/margin.js.map +1 -1
  86. package/build/hooks/padding.js +7 -163
  87. package/build/hooks/padding.js.map +1 -1
  88. package/build/hooks/typography.js +50 -65
  89. package/build/hooks/typography.js.map +1 -1
  90. package/build/hooks/utils.js +75 -0
  91. package/build/hooks/utils.js.map +1 -1
  92. package/build/layouts/flex.js +1 -0
  93. package/build/layouts/flex.js.map +1 -1
  94. package/build/store/actions.js +24 -12
  95. package/build/store/actions.js.map +1 -1
  96. package/build/store/defaults.js +28 -1
  97. package/build/store/defaults.js.map +1 -1
  98. package/build/store/reducer.js +53 -47
  99. package/build/store/reducer.js.map +1 -1
  100. package/build/store/selectors.js +5 -1
  101. package/build/store/selectors.js.map +1 -1
  102. package/build/utils/parse-css-unit-to-px.js +36 -3
  103. package/build/utils/parse-css-unit-to-px.js.map +1 -1
  104. package/build-module/components/block-inspector/index.js +9 -9
  105. package/build-module/components/block-inspector/index.js.map +1 -1
  106. package/build-module/components/block-inspector/useBlockInspectorAnimationSettings.js +37 -0
  107. package/build-module/components/block-inspector/useBlockInspectorAnimationSettings.js.map +1 -0
  108. package/build-module/components/block-lock/modal.js +1 -0
  109. package/build-module/components/block-lock/modal.js.map +1 -1
  110. package/build-module/components/block-settings-menu/block-settings-dropdown.js +2 -2
  111. package/build-module/components/block-settings-menu/block-settings-dropdown.js.map +1 -1
  112. package/build-module/components/block-styles/index.js +2 -1
  113. package/build-module/components/block-styles/index.js.map +1 -1
  114. package/build-module/components/child-layout-control/index.js +98 -0
  115. package/build-module/components/child-layout-control/index.js.map +1 -0
  116. package/build-module/components/date-format-picker/index.js +4 -4
  117. package/build-module/components/date-format-picker/index.js.map +1 -1
  118. package/build-module/components/global-styles/dimensions-panel.js +574 -0
  119. package/build-module/components/global-styles/dimensions-panel.js.map +1 -0
  120. package/build-module/components/global-styles/hooks.js +71 -33
  121. package/build-module/components/global-styles/hooks.js.map +1 -1
  122. package/build-module/components/global-styles/index.js +2 -1
  123. package/build-module/components/global-styles/index.js.map +1 -1
  124. package/build-module/components/global-styles/typography-panel.js +26 -11
  125. package/build-module/components/global-styles/typography-panel.js.map +1 -1
  126. package/build-module/components/global-styles/use-global-styles-output.js +1 -1
  127. package/build-module/components/global-styles/use-global-styles-output.js.map +1 -1
  128. package/build-module/components/global-styles/utils.js +2 -0
  129. package/build-module/components/global-styles/utils.js.map +1 -1
  130. package/build-module/components/index.native.js +2 -1
  131. package/build-module/components/index.native.js.map +1 -1
  132. package/build-module/components/inserter/media-tab/hooks.js +10 -11
  133. package/build-module/components/inserter/media-tab/hooks.js.map +1 -1
  134. package/build-module/components/inserter/media-tab/media-list.js +6 -105
  135. package/build-module/components/inserter/media-tab/media-list.js.map +1 -1
  136. package/build-module/components/inserter/media-tab/media-preview.js +222 -0
  137. package/build-module/components/inserter/media-tab/media-preview.js.map +1 -0
  138. package/build-module/components/inspector-controls/block-support-tools-panel.js +1 -1
  139. package/build-module/components/inspector-controls/block-support-tools-panel.js.map +1 -1
  140. package/build-module/components/inspector-controls/fill.js +39 -9
  141. package/build-module/components/inspector-controls/fill.js.map +1 -1
  142. package/build-module/components/link-control/settings-drawer.js +1 -1
  143. package/build-module/components/link-control/settings-drawer.js.map +1 -1
  144. package/build-module/components/link-control/settings.js +1 -0
  145. package/build-module/components/link-control/settings.js.map +1 -1
  146. package/build-module/components/list-view/block.js +16 -3
  147. package/build-module/components/list-view/block.js.map +1 -1
  148. package/build-module/components/list-view/branch.js +2 -2
  149. package/build-module/components/list-view/branch.js.map +1 -1
  150. package/build-module/components/list-view/expander.js +2 -1
  151. package/build-module/components/list-view/expander.js.map +1 -1
  152. package/build-module/components/list-view/leaf.js +8 -4
  153. package/build-module/components/list-view/leaf.js.map +1 -1
  154. package/build-module/components/list-view/use-list-view-scroll-into-view.js +42 -0
  155. package/build-module/components/list-view/use-list-view-scroll-into-view.js.map +1 -0
  156. package/build-module/components/off-canvas-editor/appender.js +5 -10
  157. package/build-module/components/off-canvas-editor/appender.js.map +1 -1
  158. package/build-module/components/off-canvas-editor/branch.js +1 -0
  159. package/build-module/components/off-canvas-editor/branch.js.map +1 -1
  160. package/build-module/components/off-canvas-editor/index.js +7 -3
  161. package/build-module/components/off-canvas-editor/index.js.map +1 -1
  162. package/build-module/components/off-canvas-editor/leaf-more-menu.js +36 -7
  163. package/build-module/components/off-canvas-editor/leaf-more-menu.js.map +1 -1
  164. package/build-module/components/off-canvas-editor/link-ui.js +1 -0
  165. package/build-module/components/off-canvas-editor/link-ui.js.map +1 -1
  166. package/build-module/components/responsive-block-control/index.js +1 -0
  167. package/build-module/components/responsive-block-control/index.js.map +1 -1
  168. package/build-module/components/rich-text/index.js +9 -43
  169. package/build-module/components/rich-text/index.js.map +1 -1
  170. package/build-module/components/rich-text/use-delete.js +62 -0
  171. package/build-module/components/rich-text/use-delete.js.map +1 -0
  172. package/build-module/components/rich-text/use-input-rules.js +14 -6
  173. package/build-module/components/rich-text/use-input-rules.js.map +1 -1
  174. package/build-module/components/writing-flow/use-selection-observer.js +4 -1
  175. package/build-module/components/writing-flow/use-selection-observer.js.map +1 -1
  176. package/build-module/hooks/align.js +3 -1
  177. package/build-module/hooks/align.js.map +1 -1
  178. package/build-module/hooks/dimensions.js +75 -187
  179. package/build-module/hooks/dimensions.js.map +1 -1
  180. package/build-module/hooks/duotone.js +86 -24
  181. package/build-module/hooks/duotone.js.map +1 -1
  182. package/build-module/hooks/gap.js +0 -183
  183. package/build-module/hooks/gap.js.map +1 -1
  184. package/build-module/hooks/layout.js +14 -5
  185. package/build-module/hooks/layout.js.map +1 -1
  186. package/build-module/hooks/margin.js +4 -143
  187. package/build-module/hooks/margin.js.map +1 -1
  188. package/build-module/hooks/padding.js +4 -143
  189. package/build-module/hooks/padding.js.map +1 -1
  190. package/build-module/hooks/typography.js +52 -65
  191. package/build-module/hooks/typography.js.map +1 -1
  192. package/build-module/hooks/utils.js +70 -0
  193. package/build-module/hooks/utils.js.map +1 -1
  194. package/build-module/layouts/flex.js +1 -0
  195. package/build-module/layouts/flex.js.map +1 -1
  196. package/build-module/store/actions.js +24 -12
  197. package/build-module/store/actions.js.map +1 -1
  198. package/build-module/store/defaults.js +28 -1
  199. package/build-module/store/defaults.js.map +1 -1
  200. package/build-module/store/reducer.js +53 -45
  201. package/build-module/store/reducer.js.map +1 -1
  202. package/build-module/store/selectors.js +5 -1
  203. package/build-module/store/selectors.js.map +1 -1
  204. package/build-module/utils/parse-css-unit-to-px.js +36 -3
  205. package/build-module/utils/parse-css-unit-to-px.js.map +1 -1
  206. package/build-style/style-rtl.css +33 -21
  207. package/build-style/style.css +33 -21
  208. package/package.json +31 -31
  209. package/src/components/block-draggable/test/__snapshots__/index.native.js.snap +24 -24
  210. package/src/components/block-inspector/index.js +11 -14
  211. package/src/components/block-inspector/useBlockInspectorAnimationSettings.js +53 -0
  212. package/src/components/block-lock/modal.js +1 -0
  213. package/src/components/block-lock/style.scss +0 -9
  214. package/src/components/block-mobile-toolbar/test/__snapshots__/block-actions-menu.native.js.snap +20 -20
  215. package/src/components/block-mover/test/__snapshots__/index.native.js.snap +15 -15
  216. package/src/components/block-settings-menu/block-settings-dropdown.js +4 -1
  217. package/src/components/block-styles/index.js +5 -1
  218. package/src/components/child-layout-control/index.js +106 -0
  219. package/src/components/color-palette/test/__snapshots__/control.js.snap +1 -1
  220. package/src/components/date-format-picker/index.js +6 -8
  221. package/src/components/date-format-picker/style.scss +0 -5
  222. package/src/components/global-styles/dimensions-panel.js +627 -0
  223. package/src/components/global-styles/hooks.js +88 -45
  224. package/src/components/global-styles/index.js +5 -1
  225. package/src/components/global-styles/typography-panel.js +33 -8
  226. package/src/components/global-styles/use-global-styles-output.js +4 -3
  227. package/src/components/global-styles/utils.js +2 -0
  228. package/src/components/index.native.js +5 -0
  229. package/src/components/inner-blocks/test/__snapshots__/index.js.snap +1 -1
  230. package/src/components/inserter/media-tab/hooks.js +9 -8
  231. package/src/components/inserter/media-tab/media-list.js +3 -122
  232. package/src/components/inserter/media-tab/media-preview.js +268 -0
  233. package/src/components/inserter/style.scss +22 -0
  234. package/src/components/inserter/test/__snapshots__/index.native.js.snap +15 -15
  235. package/src/components/inspector-controls/block-support-tools-panel.js +0 -1
  236. package/src/components/inspector-controls/fill.js +32 -8
  237. package/src/components/link-control/settings-drawer.js +2 -1
  238. package/src/components/link-control/settings.js +1 -0
  239. package/src/components/link-control/style.scss +18 -8
  240. package/src/components/link-control/test/index.js +3 -3
  241. package/src/components/list-view/block.js +19 -1
  242. package/src/components/list-view/branch.js +1 -2
  243. package/src/components/list-view/expander.js +1 -0
  244. package/src/components/list-view/leaf.js +43 -29
  245. package/src/components/list-view/use-list-view-scroll-into-view.js +48 -0
  246. package/src/components/media-replace-flow/style.scss +7 -9
  247. package/src/components/off-canvas-editor/appender.js +13 -16
  248. package/src/components/off-canvas-editor/branch.js +1 -0
  249. package/src/components/off-canvas-editor/index.js +8 -2
  250. package/src/components/off-canvas-editor/leaf-more-menu.js +57 -15
  251. package/src/components/off-canvas-editor/link-ui.js +1 -0
  252. package/src/components/responsive-block-control/index.js +1 -0
  253. package/src/components/rich-text/index.js +8 -44
  254. package/src/components/rich-text/use-delete.js +59 -0
  255. package/src/components/rich-text/use-input-rules.js +13 -5
  256. package/src/components/spacing-sizes-control/style.scss +1 -1
  257. package/src/components/url-popover/stories/index.js +1 -0
  258. package/src/components/writing-flow/use-selection-observer.js +5 -1
  259. package/src/hooks/align.js +1 -1
  260. package/src/hooks/dimensions.js +85 -269
  261. package/src/hooks/duotone.js +100 -30
  262. package/src/hooks/gap.js +0 -208
  263. package/src/hooks/layout.js +19 -6
  264. package/src/hooks/margin.js +1 -164
  265. package/src/hooks/padding.js +1 -163
  266. package/src/hooks/test/__snapshots__/align.native.js.snap +24 -24
  267. package/src/hooks/test/duotone.js +102 -0
  268. package/src/hooks/typography.js +66 -88
  269. package/src/hooks/utils.js +90 -0
  270. package/src/layouts/flex.js +1 -0
  271. package/src/store/actions.js +12 -4
  272. package/src/store/defaults.js +14 -1
  273. package/src/store/reducer.js +68 -43
  274. package/src/store/selectors.js +8 -1
  275. package/src/store/test/actions.js +4 -2
  276. package/src/utils/parse-css-unit-to-px.js +35 -5
  277. package/src/utils/test/parse-css-unit-to-px.js +12 -0
  278. package/tsconfig.tsbuildinfo +1 -1
  279. package/build/hooks/child-layout.js +0 -213
  280. package/build/hooks/child-layout.js.map +0 -1
  281. package/build/hooks/min-height.js +0 -139
  282. package/build/hooks/min-height.js.map +0 -1
  283. package/build-module/hooks/child-layout.js +0 -193
  284. package/build-module/hooks/child-layout.js.map +0 -1
  285. package/build-module/hooks/min-height.js +0 -116
  286. package/build-module/hooks/min-height.js.map +0 -1
  287. package/src/hooks/child-layout.js +0 -195
  288. package/src/hooks/min-height.js +0 -104
@@ -1,73 +1,73 @@
1
1
  // Jest Snapshot v1, https://goo.gl/fbAQLP
2
2
 
3
3
  exports[`Align options for group block sets Full width option 1`] = `
4
- "<!-- wp:group {\\"align\\":\\"full\\",\\"layout\\":{\\"type\\":\\"constrained\\"}} -->
5
- <div class=\\"wp-block-group alignfull\\"></div>
4
+ "<!-- wp:group {"align":"full","layout":{"type":"constrained"}} -->
5
+ <div class="wp-block-group alignfull"></div>
6
6
  <!-- /wp:group -->"
7
7
  `;
8
8
 
9
9
  exports[`Align options for group block sets None option 1`] = `
10
- "<!-- wp:group {\\"layout\\":{\\"type\\":\\"constrained\\"}} -->
11
- <div class=\\"wp-block-group\\"></div>
10
+ "<!-- wp:group {"layout":{"type":"constrained"}} -->
11
+ <div class="wp-block-group"></div>
12
12
  <!-- /wp:group -->"
13
13
  `;
14
14
 
15
15
  exports[`Align options for group block sets Wide width option 1`] = `
16
- "<!-- wp:group {\\"align\\":\\"wide\\",\\"layout\\":{\\"type\\":\\"constrained\\"}} -->
17
- <div class=\\"wp-block-group alignwide\\"></div>
16
+ "<!-- wp:group {"align":"wide","layout":{"type":"constrained"}} -->
17
+ <div class="wp-block-group alignwide"></div>
18
18
  <!-- /wp:group -->"
19
19
  `;
20
20
 
21
21
  exports[`Align options for media block sets Align center option 1`] = `
22
- "<!-- wp:image {\\"align\\":\\"center\\",\\"id\\":1,\\"sizeSlug\\":\\"large\\",\\"linkDestination\\":\\"none\\"} -->
23
- <figure class=\\"wp-block-image aligncenter size-large\\"><img src=\\"https://test-site.files.wordpress.com/local-image-1.jpeg\\" alt=\\"\\" class=\\"wp-image-1\\"/></figure>
22
+ "<!-- wp:image {"align":"center","id":1,"sizeSlug":"large","linkDestination":"none"} -->
23
+ <figure class="wp-block-image aligncenter size-large"><img src="https://test-site.files.wordpress.com/local-image-1.jpeg" alt="" class="wp-image-1"/></figure>
24
24
  <!-- /wp:image -->"
25
25
  `;
26
26
 
27
27
  exports[`Align options for media block sets Align left option 1`] = `
28
- "<!-- wp:image {\\"align\\":\\"left\\",\\"id\\":1,\\"sizeSlug\\":\\"large\\",\\"linkDestination\\":\\"none\\"} -->
29
- <figure class=\\"wp-block-image alignleft size-large\\"><img src=\\"https://test-site.files.wordpress.com/local-image-1.jpeg\\" alt=\\"\\" class=\\"wp-image-1\\"/></figure>
28
+ "<!-- wp:image {"align":"left","id":1,"sizeSlug":"large","linkDestination":"none"} -->
29
+ <figure class="wp-block-image alignleft size-large"><img src="https://test-site.files.wordpress.com/local-image-1.jpeg" alt="" class="wp-image-1"/></figure>
30
30
  <!-- /wp:image -->"
31
31
  `;
32
32
 
33
33
  exports[`Align options for media block sets Align right option 1`] = `
34
- "<!-- wp:image {\\"align\\":\\"right\\",\\"id\\":1,\\"sizeSlug\\":\\"large\\",\\"linkDestination\\":\\"none\\"} -->
35
- <figure class=\\"wp-block-image alignright size-large\\"><img src=\\"https://test-site.files.wordpress.com/local-image-1.jpeg\\" alt=\\"\\" class=\\"wp-image-1\\"/></figure>
34
+ "<!-- wp:image {"align":"right","id":1,"sizeSlug":"large","linkDestination":"none"} -->
35
+ <figure class="wp-block-image alignright size-large"><img src="https://test-site.files.wordpress.com/local-image-1.jpeg" alt="" class="wp-image-1"/></figure>
36
36
  <!-- /wp:image -->"
37
37
  `;
38
38
 
39
39
  exports[`Align options for media block sets Full width option 1`] = `
40
- "<!-- wp:image {\\"align\\":\\"full\\",\\"id\\":1,\\"sizeSlug\\":\\"large\\",\\"linkDestination\\":\\"none\\"} -->
41
- <figure class=\\"wp-block-image alignfull size-large\\"><img src=\\"https://test-site.files.wordpress.com/local-image-1.jpeg\\" alt=\\"\\" class=\\"wp-image-1\\"/></figure>
40
+ "<!-- wp:image {"align":"full","id":1,"sizeSlug":"large","linkDestination":"none"} -->
41
+ <figure class="wp-block-image alignfull size-large"><img src="https://test-site.files.wordpress.com/local-image-1.jpeg" alt="" class="wp-image-1"/></figure>
42
42
  <!-- /wp:image -->"
43
43
  `;
44
44
 
45
45
  exports[`Align options for media block sets None option 1`] = `
46
- "<!-- wp:image {\\"id\\":1,\\"sizeSlug\\":\\"large\\",\\"linkDestination\\":\\"none\\"} -->
47
- <figure class=\\"wp-block-image size-large\\"><img src=\\"https://test-site.files.wordpress.com/local-image-1.jpeg\\" alt=\\"\\" class=\\"wp-image-1\\"/></figure>
46
+ "<!-- wp:image {"id":1,"sizeSlug":"large","linkDestination":"none"} -->
47
+ <figure class="wp-block-image size-large"><img src="https://test-site.files.wordpress.com/local-image-1.jpeg" alt="" class="wp-image-1"/></figure>
48
48
  <!-- /wp:image -->"
49
49
  `;
50
50
 
51
51
  exports[`Align options for media block sets Wide width option 1`] = `
52
- "<!-- wp:image {\\"align\\":\\"wide\\",\\"id\\":1,\\"sizeSlug\\":\\"large\\",\\"linkDestination\\":\\"none\\"} -->
53
- <figure class=\\"wp-block-image alignwide size-large\\"><img src=\\"https://test-site.files.wordpress.com/local-image-1.jpeg\\" alt=\\"\\" class=\\"wp-image-1\\"/></figure>
52
+ "<!-- wp:image {"align":"wide","id":1,"sizeSlug":"large","linkDestination":"none"} -->
53
+ <figure class="wp-block-image alignwide size-large"><img src="https://test-site.files.wordpress.com/local-image-1.jpeg" alt="" class="wp-image-1"/></figure>
54
54
  <!-- /wp:image -->"
55
55
  `;
56
56
 
57
57
  exports[`Align options for text block sets Align text center option 1`] = `
58
- "<!-- wp:paragraph {\\"align\\":\\"center\\"} -->
59
- <p class=\\"has-text-align-center\\"></p>
58
+ "<!-- wp:paragraph {"align":"center"} -->
59
+ <p class="has-text-align-center"></p>
60
60
  <!-- /wp:paragraph -->"
61
61
  `;
62
62
 
63
63
  exports[`Align options for text block sets Align text left option 1`] = `
64
- "<!-- wp:paragraph {\\"align\\":\\"left\\"} -->
65
- <p class=\\"has-text-align-left\\"></p>
64
+ "<!-- wp:paragraph {"align":"left"} -->
65
+ <p class="has-text-align-left"></p>
66
66
  <!-- /wp:paragraph -->"
67
67
  `;
68
68
 
69
69
  exports[`Align options for text block sets Align text right option 1`] = `
70
- "<!-- wp:paragraph {\\"align\\":\\"right\\"} -->
71
- <p class=\\"has-text-align-right\\"></p>
70
+ "<!-- wp:paragraph {"align":"right"} -->
71
+ <p class="has-text-align-right"></p>
72
72
  <!-- /wp:paragraph -->"
73
73
  `;
@@ -0,0 +1,102 @@
1
+ /**
2
+ * Internal dependencies
3
+ */
4
+ import {
5
+ getColorsFromDuotonePreset,
6
+ getDuotonePresetFromColors,
7
+ } from '../duotone';
8
+
9
+ describe( 'Duotone utilities', () => {
10
+ const duotonePalette = [
11
+ {
12
+ name: 'Dark grayscale',
13
+ colors: [ '#000000', '#7f7f7f' ],
14
+ slug: 'dark-grayscale',
15
+ },
16
+ {
17
+ name: 'Grayscale',
18
+ colors: [ '#000000', '#ffffff' ],
19
+ slug: 'grayscale',
20
+ },
21
+ {
22
+ name: 'Purple and yellow',
23
+ colors: [ '#8c00b7', '#fcff41' ],
24
+ slug: 'purple-yellow',
25
+ },
26
+ ];
27
+ describe( 'getColorsFromDuotonePreset', () => {
28
+ it( 'should return undefined if no arguments are provided', () => {
29
+ expect( getColorsFromDuotonePreset() ).toBeUndefined();
30
+ } );
31
+
32
+ it( 'should return undefined if no duotone preset is provided', () => {
33
+ expect(
34
+ getColorsFromDuotonePreset( undefined, duotonePalette )
35
+ ).toBeUndefined();
36
+ } );
37
+
38
+ it( 'should return undefined if a non-existent preset is provided', () => {
39
+ expect(
40
+ getColorsFromDuotonePreset(
41
+ `var:preset|duotone|does-not-exist`,
42
+ duotonePalette
43
+ )
44
+ ).toBeUndefined();
45
+ } );
46
+
47
+ it( 'should return the colors from the preset if found', () => {
48
+ expect(
49
+ getColorsFromDuotonePreset(
50
+ `var:preset|duotone|${ duotonePalette[ 2 ].slug }`,
51
+ duotonePalette
52
+ )
53
+ ).toEqual( duotonePalette[ 2 ].colors );
54
+ } );
55
+ } );
56
+
57
+ describe( 'getDuotonePresetFromColors', () => {
58
+ it( 'should return undefined if no arguments are provided', () => {
59
+ expect( getDuotonePresetFromColors() ).toBeUndefined();
60
+ } );
61
+
62
+ it( 'should return undefined if no colors are provided', () => {
63
+ expect(
64
+ getDuotonePresetFromColors( undefined, duotonePalette )
65
+ ).toBeUndefined();
66
+ } );
67
+
68
+ it( 'should return undefined if provided colors is not of valid type', () => {
69
+ const notAnArrayOfColorStrings = 'purple-yellow';
70
+ expect(
71
+ getDuotonePresetFromColors(
72
+ notAnArrayOfColorStrings,
73
+ duotonePalette
74
+ )
75
+ ).toBeUndefined();
76
+ } );
77
+
78
+ it( 'should return undefined if no duotone palette is provided', () => {
79
+ expect(
80
+ getDuotonePresetFromColors( [ '#8c00b7', '#fcff41' ] )
81
+ ).toBeUndefined();
82
+ } );
83
+
84
+ it( 'should return undefined if the provided colors do not match any preset', () => {
85
+ expect(
86
+ getDuotonePresetFromColors(
87
+ [ '#000000', '#000000' ],
88
+ duotonePalette
89
+ )
90
+ ).toBeUndefined();
91
+ } );
92
+
93
+ it( 'should return the slug of the preset if found', () => {
94
+ expect(
95
+ getDuotonePresetFromColors(
96
+ duotonePalette[ 2 ].colors,
97
+ duotonePalette
98
+ )
99
+ ).toEqual( `var:preset|duotone|${ duotonePalette[ 2 ].slug }` );
100
+ } );
101
+ } );
102
+ } );
@@ -2,7 +2,7 @@
2
2
  * WordPress dependencies
3
3
  */
4
4
  import { getBlockSupport, hasBlockSupport } from '@wordpress/blocks';
5
- import { useMemo } from '@wordpress/element';
5
+ import { useMemo, useCallback } from '@wordpress/element';
6
6
 
7
7
  /**
8
8
  * Internal dependencies
@@ -16,12 +16,7 @@ import {
16
16
  import { LINE_HEIGHT_SUPPORT_KEY } from './line-height';
17
17
  import { FONT_FAMILY_SUPPORT_KEY } from './font-family';
18
18
  import { FONT_SIZE_SUPPORT_KEY } from './font-size';
19
- import { useSetting } from '../components';
20
- import { cleanEmptyObject } from './utils';
21
- import {
22
- overrideSettingsWithSupports,
23
- useSupportedStyles,
24
- } from '../components/global-styles/hooks';
19
+ import { cleanEmptyObject, useBlockSettings } from './utils';
25
20
 
26
21
  function omit( object, keys ) {
27
22
  return Object.fromEntries(
@@ -46,55 +41,65 @@ export const TYPOGRAPHY_SUPPORT_KEYS = [
46
41
  LETTER_SPACING_SUPPORT_KEY,
47
42
  ];
48
43
 
49
- function TypographyInspectorControl( { children } ) {
50
- return (
51
- <InspectorControls group="typography">{ children }</InspectorControls>
52
- );
44
+ function styleToAttributes( style ) {
45
+ const updatedStyle = { ...omit( style, [ 'fontFamily' ] ) };
46
+ const fontSizeValue = style?.typography?.fontSize;
47
+ const fontFamilyValue = style?.typography?.fontFamily;
48
+ const fontSizeSlug = fontSizeValue?.startsWith( 'var:preset|font-size|' )
49
+ ? fontSizeValue.substring( 'var:preset|font-size|'.length )
50
+ : undefined;
51
+ const fontFamilySlug = fontFamilyValue?.startsWith(
52
+ 'var:preset|font-family|'
53
+ )
54
+ ? fontFamilyValue.substring( 'var:preset|font-family|'.length )
55
+ : undefined;
56
+ updatedStyle.typography = {
57
+ ...omit( updatedStyle.typography, [ 'fontFamily' ] ),
58
+ fontSize: fontSizeSlug ? undefined : fontSizeValue,
59
+ };
60
+ return {
61
+ style: cleanEmptyObject( updatedStyle ),
62
+ fontFamily: fontFamilySlug,
63
+ fontSize: fontSizeSlug,
64
+ };
65
+ }
66
+
67
+ function attributesToStyle( attributes ) {
68
+ return {
69
+ ...attributes.style,
70
+ typography: {
71
+ ...attributes.style?.typography,
72
+ fontFamily: attributes.fontFamily
73
+ ? 'var:preset|font-family|' + attributes.fontFamily
74
+ : undefined,
75
+ fontSize: attributes.fontSize
76
+ ? 'var:preset|font-size|' + attributes.fontSize
77
+ : attributes.style?.typography?.fontSize,
78
+ },
79
+ };
53
80
  }
54
81
 
55
- function useBlockSettings( name ) {
56
- const fontFamilies = useSetting( 'typography.fontFamilies' );
57
- const fontSizes = useSetting( 'typography.fontSizes' );
58
- const customFontSize = useSetting( 'typography.customFontSize' );
59
- const fontStyle = useSetting( 'typography.fontStyle' );
60
- const fontWeight = useSetting( 'typography.fontWeight' );
61
- const lineHeight = useSetting( 'typography.lineHeight' );
62
- const textDecoration = useSetting( 'typography.textDecoration' );
63
- const textTransform = useSetting( 'typography.textTransform' );
64
- const letterSpacing = useSetting( 'typography.letterSpacing' );
65
- const supports = useSupportedStyles( name, null );
82
+ function TypographyInspectorControl( { children, resetAllFilter } ) {
83
+ const attributesResetAllFilter = useCallback(
84
+ ( attributes ) => {
85
+ const existingStyle = attributesToStyle( attributes );
86
+ const updatedStyle = resetAllFilter( existingStyle );
87
+ return {
88
+ ...attributes,
89
+ ...styleToAttributes( updatedStyle ),
90
+ };
91
+ },
92
+ [ resetAllFilter ]
93
+ );
66
94
 
67
- return useMemo( () => {
68
- const rawSettings = {
69
- typography: {
70
- fontFamilies: {
71
- custom: fontFamilies,
72
- },
73
- fontSizes: {
74
- custom: fontSizes,
75
- },
76
- customFontSize,
77
- fontStyle,
78
- fontWeight,
79
- lineHeight,
80
- textDecoration,
81
- textTransform,
82
- letterSpacing,
83
- },
84
- };
85
- return overrideSettingsWithSupports( rawSettings, supports );
86
- }, [
87
- fontFamilies,
88
- fontSizes,
89
- customFontSize,
90
- fontStyle,
91
- fontWeight,
92
- lineHeight,
93
- textDecoration,
94
- textTransform,
95
- letterSpacing,
96
- supports,
97
- ] );
95
+ return (
96
+ <InspectorControls
97
+ group="typography"
98
+ resetAllFilter={ attributesResetAllFilter }
99
+ >
100
+ { children }
101
+ </InspectorControls>
102
+ );
98
103
  }
99
104
 
100
105
  export function TypographyPanel( {
@@ -102,47 +107,20 @@ export function TypographyPanel( {
102
107
  name,
103
108
  attributes,
104
109
  setAttributes,
110
+ __unstableParentLayout,
105
111
  } ) {
106
- const settings = useBlockSettings( name );
112
+ const settings = useBlockSettings( name, __unstableParentLayout );
107
113
  const isEnabled = useHasTypographyPanel( settings );
108
114
  const value = useMemo( () => {
109
- return {
110
- ...attributes.style,
111
- typography: {
112
- ...attributes.style?.typography,
113
- fontFamily: attributes.fontFamily
114
- ? 'var:preset|font-family|' + attributes.fontFamily
115
- : undefined,
116
- fontSize: attributes.fontSize
117
- ? 'var:preset|font-size|' + attributes.fontSize
118
- : attributes.style?.typography?.fontSize,
119
- },
120
- };
115
+ return attributesToStyle( {
116
+ style: attributes.style,
117
+ fontFamily: attributes.fontFamily,
118
+ fontSize: attributes.fontSize,
119
+ } );
121
120
  }, [ attributes.style, attributes.fontSize, attributes.fontFamily ] );
122
121
 
123
122
  const onChange = ( newStyle ) => {
124
- const updatedStyle = { ...omit( newStyle, [ 'fontFamily' ] ) };
125
- const fontSizeValue = newStyle?.typography?.fontSize;
126
- const fontFamilyValue = newStyle?.typography?.fontFamily;
127
- const fontSizeSlug = fontSizeValue?.startsWith(
128
- 'var:preset|font-size|'
129
- )
130
- ? fontSizeValue.substring( 'var:preset|font-size|'.length )
131
- : undefined;
132
- const fontFamilySlug = fontFamilyValue?.startsWith(
133
- 'var:preset|font-family|'
134
- )
135
- ? fontFamilyValue.substring( 'var:preset|font-family|'.length )
136
- : undefined;
137
- updatedStyle.typography = {
138
- ...omit( updatedStyle.typography, [ 'fontFamily' ] ),
139
- fontSize: fontSizeSlug ? undefined : fontSizeValue,
140
- };
141
- setAttributes( {
142
- style: cleanEmptyObject( updatedStyle ),
143
- fontFamily: fontFamilySlug,
144
- fontSize: fontSizeSlug,
145
- } );
123
+ setAttributes( styleToAttributes( newStyle ) );
146
124
  };
147
125
 
148
126
  if ( ! isEnabled ) {
@@ -7,6 +7,13 @@ import { isEmpty, mapValues, get } from 'lodash';
7
7
  * WordPress dependencies
8
8
  */
9
9
  import { getBlockSupport } from '@wordpress/blocks';
10
+ import { useMemo } from '@wordpress/element';
11
+
12
+ /**
13
+ * Internal dependencies
14
+ */
15
+ import { useSetting } from '../components';
16
+ import { useSettingsForBlockElement } from '../components/global-styles/hooks';
10
17
 
11
18
  /**
12
19
  * Removed falsy values from nested object.
@@ -177,3 +184,86 @@ export function shouldSkipSerialization( blockType, featureSet, feature ) {
177
184
 
178
185
  return skipSerialization;
179
186
  }
187
+
188
+ /**
189
+ * Based on the block and its context, returns an object of all the block settings.
190
+ * This object can be passed as a prop to all the Styles UI components
191
+ * (TypographyPanel, DimensionsPanel...).
192
+ *
193
+ * @param {string} name Block name.
194
+ * @param {*} parentLayout Parent layout.
195
+ *
196
+ * @return {Object} Settings object.
197
+ */
198
+ export function useBlockSettings( name, parentLayout ) {
199
+ const fontFamilies = useSetting( 'typography.fontFamilies' );
200
+ const fontSizes = useSetting( 'typography.fontSizes' );
201
+ const customFontSize = useSetting( 'typography.customFontSize' );
202
+ const fontStyle = useSetting( 'typography.fontStyle' );
203
+ const fontWeight = useSetting( 'typography.fontWeight' );
204
+ const lineHeight = useSetting( 'typography.lineHeight' );
205
+ const textDecoration = useSetting( 'typography.textDecoration' );
206
+ const textTransform = useSetting( 'typography.textTransform' );
207
+ const letterSpacing = useSetting( 'typography.letterSpacing' );
208
+ const padding = useSetting( 'spacing.padding' );
209
+ const margin = useSetting( 'spacing.margin' );
210
+ const blockGap = useSetting( 'spacing.blockGap' );
211
+ const spacingSizes = useSetting( 'spacing.spacingSizes' );
212
+ const units = useSetting( 'spacing.units' );
213
+ const minHeight = useSetting( 'dimensions.minHeight' );
214
+ const layout = useSetting( 'layout' );
215
+
216
+ const rawSettings = useMemo( () => {
217
+ return {
218
+ typography: {
219
+ fontFamilies: {
220
+ custom: fontFamilies,
221
+ },
222
+ fontSizes: {
223
+ custom: fontSizes,
224
+ },
225
+ customFontSize,
226
+ fontStyle,
227
+ fontWeight,
228
+ lineHeight,
229
+ textDecoration,
230
+ textTransform,
231
+ letterSpacing,
232
+ },
233
+ spacing: {
234
+ spacingSizes: {
235
+ custom: spacingSizes,
236
+ },
237
+ padding,
238
+ margin,
239
+ blockGap,
240
+ units,
241
+ },
242
+ dimensions: {
243
+ minHeight,
244
+ },
245
+ layout,
246
+ parentLayout,
247
+ };
248
+ }, [
249
+ fontFamilies,
250
+ fontSizes,
251
+ customFontSize,
252
+ fontStyle,
253
+ fontWeight,
254
+ lineHeight,
255
+ textDecoration,
256
+ textTransform,
257
+ letterSpacing,
258
+ padding,
259
+ margin,
260
+ blockGap,
261
+ spacingSizes,
262
+ units,
263
+ minHeight,
264
+ layout,
265
+ parentLayout,
266
+ ] );
267
+
268
+ return useSettingsForBlockElement( rawSettings, name );
269
+ }
@@ -347,6 +347,7 @@ function FlexWrapControl( { layout, onChange } ) {
347
347
  const { flexWrap = 'wrap' } = layout;
348
348
  return (
349
349
  <ToggleControl
350
+ __nextHasNoMarginBottom
350
351
  label={ __( 'Allow to wrap to multiple lines' ) }
351
352
  onChange={ ( value ) => {
352
353
  onChange( {
@@ -232,17 +232,24 @@ export function selectBlock( clientId, initialPosition = 0 ) {
232
232
 
233
233
  /**
234
234
  * Yields action objects used in signalling that the block preceding the given
235
- * clientId should be selected.
235
+ * clientId (or optionally, its first parent from bottom to top)
236
+ * should be selected.
236
237
  *
237
- * @param {string} clientId Block client ID.
238
+ * @param {string} clientId Block client ID.
239
+ * @param {boolean} orFirstParent If true, select the first parent if there is no previous block.
238
240
  */
239
241
  export const selectPreviousBlock =
240
- ( clientId ) =>
242
+ ( clientId, orFirstParent = false ) =>
241
243
  ( { select, dispatch } ) => {
242
244
  const previousBlockClientId =
243
245
  select.getPreviousBlockClientId( clientId );
244
246
  if ( previousBlockClientId ) {
245
247
  dispatch.selectBlock( previousBlockClientId, -1 );
248
+ } else if ( orFirstParent ) {
249
+ const firstParentClientId = select.getBlockRootClientId( clientId );
250
+ if ( firstParentClientId ) {
251
+ dispatch.selectBlock( firstParentClientId, -1 );
252
+ }
246
253
  }
247
254
  };
248
255
 
@@ -1197,7 +1204,8 @@ export const removeBlocks =
1197
1204
  }
1198
1205
 
1199
1206
  if ( selectPrevious ) {
1200
- dispatch.selectPreviousBlock( clientIds[ 0 ] );
1207
+ const shouldSelectParent = true;
1208
+ dispatch.selectPreviousBlock( clientIds[ 0 ], shouldSelectParent );
1201
1209
  }
1202
1210
 
1203
1211
  dispatch( { type: 'REMOVE_BLOCKS', clientIds } );
@@ -170,11 +170,24 @@ export const SETTINGS_DEFAULTS = {
170
170
  __unstableGalleryWithImageBlocks: false,
171
171
  __unstableIsPreviewMode: false,
172
172
 
173
- // This setting is `private` now with `lock` API.
173
+ // These settings will be completely revamped in the future.
174
+ // The goal is to evolve this into an API which will instruct
175
+ // the block inspector to animate transitions between what it
176
+ // displays based on the relationship between the selected block
177
+ // and its parent, and only enable it if the parent is controlling
178
+ // its children blocks.
174
179
  blockInspectorAnimation: {
180
+ animationParent: 'core/navigation',
175
181
  'core/navigation': { enterDirection: 'leftToRight' },
176
182
  'core/navigation-submenu': { enterDirection: 'rightToLeft' },
177
183
  'core/navigation-link': { enterDirection: 'rightToLeft' },
184
+ 'core/search': { enterDirection: 'rightToLeft' },
185
+ 'core/social-links': { enterDirection: 'rightToLeft' },
186
+ 'core/page-list': { enterDirection: 'rightToLeft' },
187
+ 'core/spacer': { enterDirection: 'rightToLeft' },
188
+ 'core/home-link': { enterDirection: 'rightToLeft' },
189
+ 'core/site-title': { enterDirection: 'rightToLeft' },
190
+ 'core/site-logo': { enterDirection: 'rightToLeft' },
178
191
  },
179
192
 
180
193
  generateAnchors: false,