@wordpress/block-editor 10.2.0 → 10.3.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 (285) hide show
  1. package/CHANGELOG.md +12 -0
  2. package/README.md +41 -0
  3. package/build/components/block-draggable/draggable-chip.js +4 -2
  4. package/build/components/block-draggable/draggable-chip.js.map +1 -1
  5. package/build/components/block-inspector/index.js +4 -4
  6. package/build/components/block-inspector/index.js.map +1 -1
  7. package/build/components/block-list/block-list-compact.native.js +1 -0
  8. package/build/components/block-list/block-list-compact.native.js.map +1 -1
  9. package/build/components/block-list/block.js +72 -14
  10. package/build/components/block-list/block.js.map +1 -1
  11. package/build/components/block-list/block.native.js +79 -12
  12. package/build/components/block-list/block.native.js.map +1 -1
  13. package/build/components/block-list/use-in-between-inserter.js +7 -23
  14. package/build/components/block-list/use-in-between-inserter.js.map +1 -1
  15. package/build/components/block-lock/modal.js +9 -6
  16. package/build/components/block-lock/modal.js.map +1 -1
  17. package/build/components/block-parent-selector/index.js +3 -3
  18. package/build/components/block-parent-selector/index.js.map +1 -1
  19. package/build/components/block-patterns-list/index.js +5 -4
  20. package/build/components/block-patterns-list/index.js.map +1 -1
  21. package/build/components/block-popover/drop-zone.js +85 -0
  22. package/build/components/block-popover/drop-zone.js.map +1 -0
  23. package/build/components/block-popover/index.js +2 -1
  24. package/build/components/block-popover/index.js.map +1 -1
  25. package/build/components/block-preview/auto.js +2 -2
  26. package/build/components/block-preview/auto.js.map +1 -1
  27. package/build/components/block-preview/index.js +6 -9
  28. package/build/components/block-preview/index.js.map +1 -1
  29. package/build/components/block-preview/live.js +3 -7
  30. package/build/components/block-preview/live.js.map +1 -1
  31. package/build/components/block-selection-clearer/index.js +9 -1
  32. package/build/components/block-selection-clearer/index.js.map +1 -1
  33. package/build/components/block-settings-menu/block-settings-dropdown.js +17 -11
  34. package/build/components/block-settings-menu/block-settings-dropdown.js.map +1 -1
  35. package/build/components/block-styles/index.js +18 -42
  36. package/build/components/block-styles/index.js.map +1 -1
  37. package/build/components/block-toolbar/index.js +4 -4
  38. package/build/components/block-toolbar/index.js.map +1 -1
  39. package/build/components/block-tools/back-compat.js +2 -1
  40. package/build/components/block-tools/back-compat.js.map +1 -1
  41. package/build/components/block-tools/insertion-point.js +50 -20
  42. package/build/components/block-tools/insertion-point.js.map +1 -1
  43. package/build/components/block-tools/selected-block-popover.js +15 -3
  44. package/build/components/block-tools/selected-block-popover.js.map +1 -1
  45. package/build/components/colors-gradients/control.js +1 -1
  46. package/build/components/colors-gradients/control.js.map +1 -1
  47. package/build/components/colors-gradients/panel-color-gradient-settings.js +2 -2
  48. package/build/components/colors-gradients/panel-color-gradient-settings.js.map +1 -1
  49. package/build/components/font-sizes/fluid-utils.js +256 -0
  50. package/build/components/font-sizes/fluid-utils.js.map +1 -0
  51. package/build/components/font-sizes/index.js +8 -0
  52. package/build/components/font-sizes/index.js.map +1 -1
  53. package/build/components/index.js +0 -9
  54. package/build/components/index.js.map +1 -1
  55. package/build/components/inner-blocks/use-inner-block-template-sync.js +3 -2
  56. package/build/components/inner-blocks/use-inner-block-template-sync.js.map +1 -1
  57. package/build/components/inserter/block-patterns-tab.js +151 -78
  58. package/build/components/inserter/block-patterns-tab.js.map +1 -1
  59. package/build/components/inserter/menu.js +14 -3
  60. package/build/components/inserter/menu.js.map +1 -1
  61. package/build/components/inserter-draggable-blocks/index.js +4 -2
  62. package/build/components/inserter-draggable-blocks/index.js.map +1 -1
  63. package/build/components/list-view/use-list-view-drop-zone.js +1 -14
  64. package/build/components/list-view/use-list-view-drop-zone.js.map +1 -1
  65. package/build/components/preview-options/index.js +2 -3
  66. package/build/components/preview-options/index.js.map +1 -1
  67. package/build/components/spacing-sizes-control/spacing-input-control.js +35 -5
  68. package/build/components/spacing-sizes-control/spacing-input-control.js.map +1 -1
  69. package/build/components/use-block-drop-zone/index.js +98 -57
  70. package/build/components/use-block-drop-zone/index.js.map +1 -1
  71. package/build/components/use-on-block-drop/index.js +12 -12
  72. package/build/components/use-on-block-drop/index.js.map +1 -1
  73. package/build/components/use-on-block-drop/types.js +6 -0
  74. package/build/components/use-on-block-drop/types.js.map +1 -0
  75. package/build/hooks/align.js +1 -3
  76. package/build/hooks/align.js.map +1 -1
  77. package/build/hooks/align.native.js +1 -7
  78. package/build/hooks/align.native.js.map +1 -1
  79. package/build/hooks/font-size.js +60 -0
  80. package/build/hooks/font-size.js.map +1 -1
  81. package/build/hooks/margin.js +6 -5
  82. package/build/hooks/margin.js.map +1 -1
  83. package/build/hooks/padding.js +2 -1
  84. package/build/hooks/padding.js.map +1 -1
  85. package/build/hooks/style.js +126 -4
  86. package/build/hooks/style.js.map +1 -1
  87. package/build/hooks/use-typography-props.js +17 -3
  88. package/build/hooks/use-typography-props.js.map +1 -1
  89. package/build/hooks/utils.js +1 -1
  90. package/build/hooks/utils.js.map +1 -1
  91. package/build/store/actions.js +59 -45
  92. package/build/store/actions.js.map +1 -1
  93. package/build/store/defaults.js +3 -0
  94. package/build/store/defaults.js.map +1 -1
  95. package/build/store/reducer.js +31 -15
  96. package/build/store/reducer.js.map +1 -1
  97. package/build/utils/math.js +14 -0
  98. package/build/utils/math.js.map +1 -1
  99. package/build/utils/pre-parse-patterns.js +19 -2
  100. package/build/utils/pre-parse-patterns.js.map +1 -1
  101. package/build-module/components/block-draggable/draggable-chip.js +7 -3
  102. package/build-module/components/block-draggable/draggable-chip.js.map +1 -1
  103. package/build-module/components/block-inspector/index.js +4 -4
  104. package/build-module/components/block-inspector/index.js.map +1 -1
  105. package/build-module/components/block-list/block-list-compact.native.js +1 -0
  106. package/build-module/components/block-list/block-list-compact.native.js.map +1 -1
  107. package/build-module/components/block-list/block.js +72 -14
  108. package/build-module/components/block-list/block.js.map +1 -1
  109. package/build-module/components/block-list/block.native.js +80 -13
  110. package/build-module/components/block-list/block.native.js.map +1 -1
  111. package/build-module/components/block-list/use-in-between-inserter.js +8 -24
  112. package/build-module/components/block-list/use-in-between-inserter.js.map +1 -1
  113. package/build-module/components/block-lock/modal.js +10 -8
  114. package/build-module/components/block-lock/modal.js.map +1 -1
  115. package/build-module/components/block-parent-selector/index.js +3 -3
  116. package/build-module/components/block-parent-selector/index.js.map +1 -1
  117. package/build-module/components/block-patterns-list/index.js +5 -4
  118. package/build-module/components/block-patterns-list/index.js.map +1 -1
  119. package/build-module/components/block-popover/drop-zone.js +70 -0
  120. package/build-module/components/block-popover/drop-zone.js.map +1 -0
  121. package/build-module/components/block-popover/index.js +2 -1
  122. package/build-module/components/block-popover/index.js.map +1 -1
  123. package/build-module/components/block-preview/auto.js +1 -1
  124. package/build-module/components/block-preview/auto.js.map +1 -1
  125. package/build-module/components/block-preview/index.js +6 -9
  126. package/build-module/components/block-preview/index.js.map +1 -1
  127. package/build-module/components/block-preview/live.js +3 -6
  128. package/build-module/components/block-preview/live.js.map +1 -1
  129. package/build-module/components/block-selection-clearer/index.js +9 -1
  130. package/build-module/components/block-selection-clearer/index.js.map +1 -1
  131. package/build-module/components/block-settings-menu/block-settings-dropdown.js +18 -12
  132. package/build-module/components/block-settings-menu/block-settings-dropdown.js.map +1 -1
  133. package/build-module/components/block-styles/index.js +19 -44
  134. package/build-module/components/block-styles/index.js.map +1 -1
  135. package/build-module/components/block-toolbar/index.js +4 -4
  136. package/build-module/components/block-toolbar/index.js.map +1 -1
  137. package/build-module/components/block-tools/back-compat.js +2 -1
  138. package/build-module/components/block-tools/back-compat.js.map +1 -1
  139. package/build-module/components/block-tools/insertion-point.js +48 -20
  140. package/build-module/components/block-tools/insertion-point.js.map +1 -1
  141. package/build-module/components/block-tools/selected-block-popover.js +15 -3
  142. package/build-module/components/block-tools/selected-block-popover.js.map +1 -1
  143. package/build-module/components/colors-gradients/control.js +2 -2
  144. package/build-module/components/colors-gradients/control.js.map +1 -1
  145. package/build-module/components/colors-gradients/panel-color-gradient-settings.js +3 -3
  146. package/build-module/components/colors-gradients/panel-color-gradient-settings.js.map +1 -1
  147. package/build-module/components/font-sizes/fluid-utils.js +245 -0
  148. package/build-module/components/font-sizes/fluid-utils.js.map +1 -0
  149. package/build-module/components/font-sizes/index.js +1 -0
  150. package/build-module/components/font-sizes/index.js.map +1 -1
  151. package/build-module/components/index.js +0 -1
  152. package/build-module/components/index.js.map +1 -1
  153. package/build-module/components/inner-blocks/use-inner-block-template-sync.js +3 -2
  154. package/build-module/components/inner-blocks/use-inner-block-template-sync.js.map +1 -1
  155. package/build-module/components/inserter/block-patterns-tab.js +148 -81
  156. package/build-module/components/inserter/block-patterns-tab.js.map +1 -1
  157. package/build-module/components/inserter/menu.js +10 -3
  158. package/build-module/components/inserter/menu.js.map +1 -1
  159. package/build-module/components/inserter-draggable-blocks/index.js +4 -2
  160. package/build-module/components/inserter-draggable-blocks/index.js.map +1 -1
  161. package/build-module/components/list-view/use-list-view-drop-zone.js +1 -14
  162. package/build-module/components/list-view/use-list-view-drop-zone.js.map +1 -1
  163. package/build-module/components/preview-options/index.js +2 -3
  164. package/build-module/components/preview-options/index.js.map +1 -1
  165. package/build-module/components/spacing-sizes-control/spacing-input-control.js +34 -5
  166. package/build-module/components/spacing-sizes-control/spacing-input-control.js.map +1 -1
  167. package/build-module/components/use-block-drop-zone/index.js +98 -58
  168. package/build-module/components/use-block-drop-zone/index.js.map +1 -1
  169. package/build-module/components/use-on-block-drop/index.js +12 -12
  170. package/build-module/components/use-on-block-drop/index.js.map +1 -1
  171. package/build-module/components/use-on-block-drop/types.js +2 -0
  172. package/build-module/components/use-on-block-drop/types.js.map +1 -0
  173. package/build-module/hooks/align.js +1 -2
  174. package/build-module/hooks/align.js.map +1 -1
  175. package/build-module/hooks/align.native.js +1 -6
  176. package/build-module/hooks/align.native.js.map +1 -1
  177. package/build-module/hooks/font-size.js +59 -1
  178. package/build-module/hooks/font-size.js.map +1 -1
  179. package/build-module/hooks/margin.js +6 -5
  180. package/build-module/hooks/margin.js.map +1 -1
  181. package/build-module/hooks/padding.js +2 -1
  182. package/build-module/hooks/padding.js.map +1 -1
  183. package/build-module/hooks/style.js +124 -3
  184. package/build-module/hooks/style.js.map +1 -1
  185. package/build-module/hooks/use-typography-props.js +17 -4
  186. package/build-module/hooks/use-typography-props.js.map +1 -1
  187. package/build-module/hooks/utils.js +2 -2
  188. package/build-module/hooks/utils.js.map +1 -1
  189. package/build-module/store/actions.js +55 -42
  190. package/build-module/store/actions.js.map +1 -1
  191. package/build-module/store/defaults.js +3 -0
  192. package/build-module/store/defaults.js.map +1 -1
  193. package/build-module/store/reducer.js +32 -16
  194. package/build-module/store/reducer.js.map +1 -1
  195. package/build-module/utils/math.js +12 -0
  196. package/build-module/utils/math.js.map +1 -1
  197. package/build-module/utils/pre-parse-patterns.js +19 -2
  198. package/build-module/utils/pre-parse-patterns.js.map +1 -1
  199. package/build-style/style-rtl.css +243 -144
  200. package/build-style/style.css +243 -144
  201. package/package.json +28 -28
  202. package/src/components/block-breadcrumb/test/index.js +1 -1
  203. package/src/components/block-draggable/draggable-chip.js +4 -2
  204. package/src/components/block-inspector/index.js +8 -7
  205. package/src/components/block-list/block-list-compact.native.js +1 -0
  206. package/src/components/block-list/block.js +111 -7
  207. package/src/components/block-list/block.native.js +123 -9
  208. package/src/components/block-list/style.scss +93 -126
  209. package/src/components/block-list/use-in-between-inserter.js +8 -19
  210. package/src/components/block-lock/modal.js +12 -7
  211. package/src/components/block-mover/style.scss +0 -1
  212. package/src/components/block-parent-selector/index.js +3 -3
  213. package/src/components/block-patterns-list/index.js +9 -5
  214. package/src/components/block-patterns-list/style.scss +7 -3
  215. package/src/components/block-popover/README.md +8 -0
  216. package/src/components/block-popover/drop-zone.js +63 -0
  217. package/src/components/block-popover/index.js +2 -1
  218. package/src/components/block-popover/style.scss +17 -1
  219. package/src/components/block-preview/auto.js +1 -1
  220. package/src/components/block-preview/index.js +7 -8
  221. package/src/components/block-preview/live.js +2 -7
  222. package/src/components/block-preview/test/index.js +1 -7
  223. package/src/components/block-selection-clearer/index.js +7 -2
  224. package/src/components/block-selection-clearer/test/index.js +118 -0
  225. package/src/components/block-settings-menu/block-settings-dropdown.js +25 -11
  226. package/src/components/block-settings-menu/test/block-mode-toggle.js +17 -17
  227. package/src/components/block-styles/index.js +26 -49
  228. package/src/components/block-switcher/test/index.js +2 -2
  229. package/src/components/block-toolbar/index.js +4 -6
  230. package/src/components/block-toolbar/style.scss +38 -14
  231. package/src/components/block-tools/back-compat.js +1 -0
  232. package/src/components/block-tools/insertion-point.js +42 -17
  233. package/src/components/block-tools/selected-block-popover.js +14 -1
  234. package/src/components/button-block-appender/style.scss +4 -2
  235. package/src/components/color-palette/test/__snapshots__/control.js.snap +32 -52
  236. package/src/components/color-palette/test/control.js +11 -15
  237. package/src/components/colors-gradients/control.js +2 -2
  238. package/src/components/colors-gradients/panel-color-gradient-settings.js +3 -4
  239. package/src/components/colors-gradients/test/control.js +49 -77
  240. package/src/components/font-sizes/fluid-utils.js +296 -0
  241. package/src/components/font-sizes/index.js +1 -0
  242. package/src/components/font-sizes/test/fluid-utils.js +168 -0
  243. package/src/components/image-size-control/test/index.js +47 -60
  244. package/src/components/index.js +0 -1
  245. package/src/components/inner-blocks/use-inner-block-template-sync.js +3 -2
  246. package/src/components/inserter/block-patterns-tab.js +232 -98
  247. package/src/components/inserter/menu.js +15 -2
  248. package/src/components/inserter/style.scss +94 -9
  249. package/src/components/inserter/test/reusable-blocks-tab.js +6 -6
  250. package/src/components/inserter-draggable-blocks/index.js +12 -2
  251. package/src/components/inserter-list-item/style.scss +20 -1
  252. package/src/components/link-control/test/index.js +1 -1
  253. package/src/components/list-view/use-list-view-drop-zone.js +4 -18
  254. package/src/components/panel-color-settings/test/index.js +4 -4
  255. package/src/components/preview-options/index.js +2 -2
  256. package/src/components/preview-options/style.scss +1 -1
  257. package/src/components/provider/test/use-block-sync.js +131 -165
  258. package/src/components/responsive-block-control/test/index.js +4 -4
  259. package/src/components/spacing-sizes-control/spacing-input-control.js +16 -2
  260. package/src/components/spacing-sizes-control/style.scss +26 -19
  261. package/src/components/use-block-drop-zone/index.js +136 -79
  262. package/src/components/use-block-drop-zone/test/index.js +333 -81
  263. package/src/components/use-on-block-drop/index.js +11 -12
  264. package/src/components/use-on-block-drop/types.ts +1 -0
  265. package/src/hooks/align.js +3 -2
  266. package/src/hooks/align.native.js +5 -8
  267. package/src/hooks/font-size.js +75 -0
  268. package/src/hooks/margin.js +5 -4
  269. package/src/hooks/padding.js +1 -0
  270. package/src/hooks/style.js +122 -3
  271. package/src/hooks/test/style.js +206 -1
  272. package/src/hooks/test/use-typography-props.js +22 -0
  273. package/src/hooks/use-typography-props.js +18 -3
  274. package/src/hooks/utils.js +6 -2
  275. package/src/store/actions.js +20 -12
  276. package/src/store/defaults.js +3 -0
  277. package/src/store/reducer.js +31 -24
  278. package/src/store/test/actions.js +0 -9
  279. package/src/utils/math.js +17 -0
  280. package/src/utils/pre-parse-patterns.js +12 -7
  281. package/build/components/inserter/pattern-panel.js +0 -87
  282. package/build/components/inserter/pattern-panel.js.map +0 -1
  283. package/build-module/components/inserter/pattern-panel.js +0 -74
  284. package/build-module/components/inserter/pattern-panel.js.map +0 -1
  285. package/src/components/inserter/pattern-panel.js +0 -93
@@ -1,8 +1,3 @@
1
- /**
2
- * External dependencies
3
- */
4
- import { without } from 'lodash';
5
-
6
1
  /**
7
2
  * WordPress dependencies
8
3
  */
@@ -28,9 +23,11 @@ addFilter(
28
23
  settings.supports = {
29
24
  ...settings.supports,
30
25
  align: Array.isArray( blockAlign )
31
- ? without(
32
- blockAlign,
33
- ...Object.values( WIDE_ALIGNMENTS.alignments )
26
+ ? blockAlign.filter(
27
+ ( alignment ) =>
28
+ ! Object.values(
29
+ WIDE_ALIGNMENTS.alignments
30
+ ).includes( alignment )
34
31
  )
35
32
  : blockAlign,
36
33
  alignWide: false,
@@ -5,6 +5,7 @@ import { addFilter } from '@wordpress/hooks';
5
5
  import { hasBlockSupport } from '@wordpress/blocks';
6
6
  import TokenList from '@wordpress/token-list';
7
7
  import { createHigherOrderComponent } from '@wordpress/compose';
8
+ import { select } from '@wordpress/data';
8
9
 
9
10
  /**
10
11
  * Internal dependencies
@@ -14,6 +15,7 @@ import {
14
15
  getFontSizeClass,
15
16
  getFontSizeObjectByValue,
16
17
  FontSizePicker,
18
+ getComputedFluidTypographyValue,
17
19
  } from '../components/font-sizes';
18
20
  import { TYPOGRAPHY_SUPPORT_KEY } from './typography';
19
21
  import {
@@ -22,6 +24,7 @@ import {
22
24
  shouldSkipSerialization,
23
25
  } from './utils';
24
26
  import useSetting from '../components/use-setting';
27
+ import { store as blockEditorStore } from '../store';
25
28
 
26
29
  export const FONT_SIZE_SUPPORT_KEY = 'typography.fontSize';
27
30
 
@@ -282,6 +285,69 @@ export function addTransforms( result, source, index, results ) {
282
285
  );
283
286
  }
284
287
 
288
+ /**
289
+ * Allow custom font sizes to appear fluid when fluid typography is enabled at
290
+ * the theme level.
291
+ *
292
+ * Adds a custom getEditWrapperProps() callback to all block types that support
293
+ * font sizes. Then, if fluid typography is enabled, this callback will swap any
294
+ * custom font size in style.fontSize with a fluid font size (i.e. one that uses
295
+ * clamp()).
296
+ *
297
+ * It's important that this hook runs after 'core/style/addEditProps' sets
298
+ * style.fontSize as otherwise fontSize will be overwritten.
299
+ *
300
+ * @param {Object} blockType Block settings object.
301
+ */
302
+ function addEditPropsForFluidCustomFontSizes( blockType ) {
303
+ if (
304
+ ! hasBlockSupport( blockType, FONT_SIZE_SUPPORT_KEY ) ||
305
+ shouldSkipSerialization( blockType, TYPOGRAPHY_SUPPORT_KEY, 'fontSize' )
306
+ ) {
307
+ return blockType;
308
+ }
309
+
310
+ const existingGetEditWrapperProps = blockType.getEditWrapperProps;
311
+
312
+ blockType.getEditWrapperProps = ( attributes ) => {
313
+ const wrapperProps = existingGetEditWrapperProps
314
+ ? existingGetEditWrapperProps( attributes )
315
+ : {};
316
+
317
+ const fontSize = wrapperProps?.style?.fontSize;
318
+
319
+ // TODO: This sucks! We should be using useSetting( 'typography.fluid' )
320
+ // or even useSelect( blockEditorStore ). We can't do either here
321
+ // because getEditWrapperProps is a plain JavaScript function called by
322
+ // BlockListBlock and not a React component rendered within
323
+ // BlockListContext.Provider. If we set fontSize using editor.
324
+ // BlockListBlock instead of using getEditWrapperProps then the value is
325
+ // clobbered when the core/style/addEditProps filter runs.
326
+ const isFluidTypographyEnabled =
327
+ !! select( blockEditorStore ).getSettings().__experimentalFeatures
328
+ ?.typography?.fluid;
329
+
330
+ const newFontSize =
331
+ fontSize && isFluidTypographyEnabled
332
+ ? getComputedFluidTypographyValue( { fontSize } )
333
+ : null;
334
+
335
+ if ( newFontSize === null ) {
336
+ return wrapperProps;
337
+ }
338
+
339
+ return {
340
+ ...wrapperProps,
341
+ style: {
342
+ ...wrapperProps?.style,
343
+ fontSize: newFontSize,
344
+ },
345
+ };
346
+ };
347
+
348
+ return blockType;
349
+ }
350
+
285
351
  addFilter(
286
352
  'blocks.registerBlockType',
287
353
  'core/font/addAttribute',
@@ -307,3 +373,12 @@ addFilter(
307
373
  'core/font-size/addTransforms',
308
374
  addTransforms
309
375
  );
376
+
377
+ addFilter(
378
+ 'blocks.registerBlockType',
379
+ 'core/font-size/addEditPropsForFluidCustomFontSizes',
380
+ addEditPropsForFluidCustomFontSizes,
381
+ // Run after 'core/style/addEditProps' so that the style object has already
382
+ // been translated into inline CSS.
383
+ 11
384
+ );
@@ -190,10 +190,10 @@ export function MarginVisualizer( { clientId, attributes } ) {
190
190
  borderRightWidth: marginRight,
191
191
  borderBottomWidth: marginBottom,
192
192
  borderLeftWidth: marginLeft,
193
- top: marginTop !== 0 ? `-${ marginTop }` : 0,
194
- right: marginRight !== 0 ? `-${ marginRight }` : 0,
195
- bottom: marginBottom !== 0 ? `-${ marginBottom }` : 0,
196
- left: marginLeft !== 0 ? `-${ marginLeft }` : 0,
193
+ top: marginTop !== 0 ? `calc(${ marginTop } * -1)` : 0,
194
+ right: marginRight !== 0 ? `calc(${ marginRight } * -1)` : 0,
195
+ bottom: marginBottom !== 0 ? `calc(${ marginBottom } * -1)` : 0,
196
+ left: marginLeft !== 0 ? `calc(${ marginLeft } * -1)` : 0,
197
197
  };
198
198
  }, [ margin ] );
199
199
 
@@ -231,6 +231,7 @@ export function MarginVisualizer( { clientId, attributes } ) {
231
231
  clientId={ clientId }
232
232
  __unstableCoverTarget
233
233
  __unstableRefreshSize={ margin }
234
+ shift={ false }
234
235
  >
235
236
  <div className="block-editor__padding-visualizer" style={ style } />
236
237
  </BlockPopover>
@@ -222,6 +222,7 @@ export function PaddingVisualizer( { clientId, attributes } ) {
222
222
  clientId={ clientId }
223
223
  __unstableCoverTarget
224
224
  __unstableRefreshSize={ padding }
225
+ shift={ false }
225
226
  >
226
227
  <div className="block-editor__padding-visualizer" style={ style } />
227
228
  </BlockPopover>
@@ -1,7 +1,6 @@
1
1
  /**
2
2
  * External dependencies
3
3
  */
4
- import { omit } from 'lodash';
5
4
  import classnames from 'classnames';
6
5
 
7
6
  /**
@@ -134,6 +133,126 @@ const skipSerializationPathsSave = {
134
133
  */
135
134
  const renamedFeatures = { gradients: 'gradient' };
136
135
 
136
+ /**
137
+ * A utility function used to remove one or more paths from a style object.
138
+ * Works in a way similar to Lodash's `omit()`. See unit tests and examples below.
139
+ *
140
+ * It supports a single string path:
141
+ *
142
+ * ```
143
+ * omitStyle( { color: 'red' }, 'color' ); // {}
144
+ * ```
145
+ *
146
+ * or an array of paths:
147
+ *
148
+ * ```
149
+ * omitStyle( { color: 'red', background: '#fff' }, [ 'color', 'background' ] ); // {}
150
+ * ```
151
+ *
152
+ * It also allows you to specify paths at multiple levels in a string.
153
+ *
154
+ * ```
155
+ * omitStyle( { typography: { textDecoration: 'underline' } }, 'typography.textDecoration' ); // {}
156
+ * ```
157
+ *
158
+ * You can remove multiple paths at the same time:
159
+ *
160
+ * ```
161
+ * omitStyle(
162
+ * {
163
+ * typography: {
164
+ * textDecoration: 'underline',
165
+ * textTransform: 'uppercase',
166
+ * }
167
+ * },
168
+ * [
169
+ * 'typography.textDecoration',
170
+ * 'typography.textTransform',
171
+ * ]
172
+ * );
173
+ * // {}
174
+ * ```
175
+ *
176
+ * You can also specify nested paths as arrays:
177
+ *
178
+ * ```
179
+ * omitStyle(
180
+ * {
181
+ * typography: {
182
+ * textDecoration: 'underline',
183
+ * textTransform: 'uppercase',
184
+ * }
185
+ * },
186
+ * [
187
+ * [ 'typography', 'textDecoration' ],
188
+ * [ 'typography', 'textTransform' ],
189
+ * ]
190
+ * );
191
+ * // {}
192
+ * ```
193
+ *
194
+ * With regards to nesting of styles, infinite depth is supported:
195
+ *
196
+ * ```
197
+ * omitStyle(
198
+ * {
199
+ * border: {
200
+ * radius: {
201
+ * topLeft: '10px',
202
+ * topRight: '0.5rem',
203
+ * }
204
+ * }
205
+ * },
206
+ * [
207
+ * [ 'border', 'radius', 'topRight' ],
208
+ * ]
209
+ * );
210
+ * // { border: { radius: { topLeft: '10px' } } }
211
+ * ```
212
+ *
213
+ * The third argument, `preserveReference`, defines how to treat the input style object.
214
+ * It is mostly necessary to properly handle mutation when recursively handling the style object.
215
+ * Defaulting to `false`, this will always create a new object, avoiding to mutate `style`.
216
+ * However, when recursing, we change that value to `true` in order to work with a single copy
217
+ * of the original style object.
218
+ *
219
+ * @see https://lodash.com/docs/4.17.15#omit
220
+ *
221
+ * @param {Object} style Styles object.
222
+ * @param {Array|string} paths Paths to remove.
223
+ * @param {boolean} preserveReference True to mutate the `style` object, false otherwise.
224
+ * @return {Object} Styles object with the specified paths removed.
225
+ */
226
+ export function omitStyle( style, paths, preserveReference = false ) {
227
+ if ( ! style ) {
228
+ return style;
229
+ }
230
+
231
+ let newStyle = style;
232
+ if ( ! preserveReference ) {
233
+ newStyle = JSON.parse( JSON.stringify( style ) );
234
+ }
235
+
236
+ if ( ! Array.isArray( paths ) ) {
237
+ paths = [ paths ];
238
+ }
239
+
240
+ paths.forEach( ( path ) => {
241
+ if ( ! Array.isArray( path ) ) {
242
+ path = path.split( '.' );
243
+ }
244
+
245
+ if ( path.length > 1 ) {
246
+ const [ firstSubpath, ...restPath ] = path;
247
+ omitStyle( newStyle[ firstSubpath ], [ restPath ], true );
248
+ } else if ( path.length === 1 ) {
249
+ delete newStyle[ path[ 0 ] ];
250
+ }
251
+ } );
252
+
253
+ return newStyle;
254
+ }
255
+
137
256
  /**
138
257
  * Override props assigned to save component to inject the CSS variables definition.
139
258
  *
@@ -159,13 +278,13 @@ export function addSaveProps(
159
278
  const skipSerialization = getBlockSupport( blockType, indicator );
160
279
 
161
280
  if ( skipSerialization === true ) {
162
- style = omit( style, path );
281
+ style = omitStyle( style, path );
163
282
  }
164
283
 
165
284
  if ( Array.isArray( skipSerialization ) ) {
166
285
  skipSerialization.forEach( ( featureName ) => {
167
286
  const feature = renamedFeatures[ featureName ] || featureName;
168
- style = omit( style, [ [ ...path, feature ] ] );
287
+ style = omitStyle( style, [ [ ...path, feature ] ] );
169
288
  } );
170
289
  }
171
290
  } );
@@ -6,7 +6,7 @@ import { applyFilters } from '@wordpress/hooks';
6
6
  /**
7
7
  * Internal dependencies
8
8
  */
9
- import { getInlineStyles } from '../style';
9
+ import { getInlineStyles, omitStyle } from '../style';
10
10
 
11
11
  describe( 'getInlineStyles', () => {
12
12
  it( 'should return an empty object when called with undefined', () => {
@@ -202,3 +202,208 @@ describe( 'addSaveProps', () => {
202
202
  } );
203
203
  } );
204
204
  } );
205
+
206
+ describe( 'omitStyle', () => {
207
+ it( 'should remove a single path', () => {
208
+ const style = { color: '#d92828', padding: '10px' };
209
+ const path = 'color';
210
+ const expected = { padding: '10px' };
211
+
212
+ expect( omitStyle( style, path ) ).toEqual( expected );
213
+ } );
214
+
215
+ it( 'should remove multiple paths', () => {
216
+ const style = { color: '#d92828', padding: '10px', background: 'red' };
217
+ const path = [ 'color', 'background' ];
218
+ const expected = { padding: '10px' };
219
+
220
+ expect( omitStyle( style, path ) ).toEqual( expected );
221
+ } );
222
+
223
+ it( 'should remove nested paths when specified as a string', () => {
224
+ const style = {
225
+ color: {
226
+ text: '#d92828',
227
+ },
228
+ typography: {
229
+ textDecoration: 'underline',
230
+ textTransform: 'uppercase',
231
+ },
232
+ };
233
+ const path = 'typography.textTransform';
234
+ const expected = {
235
+ color: {
236
+ text: '#d92828',
237
+ },
238
+ typography: {
239
+ textDecoration: 'underline',
240
+ },
241
+ };
242
+
243
+ expect( omitStyle( style, path ) ).toEqual( expected );
244
+ } );
245
+
246
+ it( 'should remove nested paths when specified as an array', () => {
247
+ const style = {
248
+ color: {
249
+ text: '#d92828',
250
+ },
251
+ typography: {
252
+ textDecoration: 'underline',
253
+ textTransform: 'uppercase',
254
+ },
255
+ };
256
+ const path = [ [ 'typography', 'textTransform' ] ];
257
+ const expected = {
258
+ color: {
259
+ text: '#d92828',
260
+ },
261
+ typography: {
262
+ textDecoration: 'underline',
263
+ },
264
+ };
265
+
266
+ expect( omitStyle( style, path ) ).toEqual( expected );
267
+ } );
268
+
269
+ it( 'should remove multiple nested paths', () => {
270
+ const style = {
271
+ color: {
272
+ text: '#d92828',
273
+ },
274
+ typography: {
275
+ textDecoration: 'underline',
276
+ textTransform: 'uppercase',
277
+ },
278
+ };
279
+ const path = [
280
+ [ 'typography', 'textTransform' ],
281
+ 'typography.textDecoration',
282
+ ];
283
+ const expected = {
284
+ color: {
285
+ text: '#d92828',
286
+ },
287
+ typography: {},
288
+ };
289
+
290
+ expect( omitStyle( style, path ) ).toEqual( expected );
291
+ } );
292
+
293
+ it( 'should remove paths with different nesting', () => {
294
+ const style = {
295
+ color: {
296
+ text: '#d92828',
297
+ },
298
+ typography: {
299
+ textDecoration: 'underline',
300
+ textTransform: 'uppercase',
301
+ },
302
+ };
303
+ const path = [
304
+ 'color',
305
+ [ 'typography', 'textTransform' ],
306
+ 'typography.textDecoration',
307
+ ];
308
+ const expected = {
309
+ typography: {},
310
+ };
311
+
312
+ expect( omitStyle( style, path ) ).toEqual( expected );
313
+ } );
314
+
315
+ it( 'should support beyond 2 levels of nesting when passed as a single string', () => {
316
+ const style = {
317
+ border: {
318
+ radius: {
319
+ topLeft: '10px',
320
+ topRight: '0.5rem',
321
+ },
322
+ },
323
+ };
324
+ const path = 'border.radius.topRight';
325
+ const expected = {
326
+ border: {
327
+ radius: {
328
+ topLeft: '10px',
329
+ },
330
+ },
331
+ };
332
+
333
+ expect( omitStyle( style, path ) ).toEqual( expected );
334
+ } );
335
+
336
+ it( 'should support beyond 2 levels of nesting when passed as array of strings', () => {
337
+ const style = {
338
+ border: {
339
+ radius: {
340
+ topLeft: '10px',
341
+ topRight: '0.5rem',
342
+ },
343
+ },
344
+ };
345
+ const path = [ 'border.radius.topRight' ];
346
+ const expected = {
347
+ border: {
348
+ radius: {
349
+ topLeft: '10px',
350
+ },
351
+ },
352
+ };
353
+
354
+ expect( omitStyle( style, path ) ).toEqual( expected );
355
+ } );
356
+
357
+ it( 'should support beyond 2 levels of nesting when passed as array of arrays', () => {
358
+ const style = {
359
+ border: {
360
+ radius: {
361
+ topLeft: '10px',
362
+ topRight: '0.5rem',
363
+ },
364
+ },
365
+ };
366
+ const path = [ [ 'border', 'radius', 'topRight' ] ];
367
+ const expected = {
368
+ border: {
369
+ radius: {
370
+ topLeft: '10px',
371
+ },
372
+ },
373
+ };
374
+
375
+ expect( omitStyle( style, path ) ).toEqual( expected );
376
+ } );
377
+
378
+ it( 'should ignore a nullish style object', () => {
379
+ expect( omitStyle( undefined, 'color' ) ).toEqual( undefined );
380
+ expect( omitStyle( null, 'color' ) ).toEqual( null );
381
+ } );
382
+
383
+ it( 'should ignore a missing object property', () => {
384
+ const style1 = { typography: {} };
385
+ expect( omitStyle( style1, 'color' ) ).toEqual( style1 );
386
+
387
+ const style2 = { color: { text: '#d92828' } };
388
+ expect( omitStyle( style2, 'color.something' ) ).toEqual( style2 );
389
+
390
+ const style3 = {
391
+ border: {
392
+ radius: {
393
+ topLeft: '10px',
394
+ topRight: '0.5rem',
395
+ },
396
+ },
397
+ };
398
+ expect(
399
+ omitStyle( style3, [ [ 'border', 'radius', 'bottomLeft' ] ] )
400
+ ).toEqual( style3 );
401
+ } );
402
+
403
+ it( 'should ignore an empty array path', () => {
404
+ const style = { typography: {}, '': 'test' };
405
+
406
+ expect( omitStyle( style, [] ) ).toEqual( style );
407
+ expect( omitStyle( style, [ [] ] ) ).toEqual( style );
408
+ } );
409
+ } );
@@ -25,4 +25,26 @@ describe( 'getTypographyClassesAndStyles', () => {
25
25
  },
26
26
  } );
27
27
  } );
28
+
29
+ it( 'should return fluid font size styles', () => {
30
+ const attributes = {
31
+ fontFamily: 'tofu',
32
+ style: {
33
+ typography: {
34
+ letterSpacing: '22px',
35
+ fontSize: '2rem',
36
+ textTransform: 'uppercase',
37
+ },
38
+ },
39
+ };
40
+ expect( getTypographyClassesAndStyles( attributes, true ) ).toEqual( {
41
+ className: 'has-tofu-font-family',
42
+ style: {
43
+ letterSpacing: '22px',
44
+ fontSize:
45
+ 'clamp(1.5rem, 1.5rem + ((1vw - 0.48rem) * 2.885), 3rem)',
46
+ textTransform: 'uppercase',
47
+ },
48
+ } );
49
+ } );
28
50
  } );
@@ -9,6 +9,7 @@ import classnames from 'classnames';
9
9
  */
10
10
  import { getInlineStyles } from './style';
11
11
  import { getFontSizeClass } from '../components/font-sizes';
12
+ import { getComputedFluidTypographyValue } from '../components/font-sizes/fluid-utils';
12
13
 
13
14
  // This utility is intended to assist where the serialization of the typography
14
15
  // block support is being skipped for a block but the typography related CSS
@@ -18,12 +19,26 @@ import { getFontSizeClass } from '../components/font-sizes';
18
19
  * Provides the CSS class names and inline styles for a block's typography support
19
20
  * attributes.
20
21
  *
21
- * @param {Object} attributes Block attributes.
22
+ * @param {Object} attributes Block attributes.
23
+ * @param {boolean} isFluidFontSizeActive Whether the function should try to convert font sizes to fluid values.
22
24
  *
23
25
  * @return {Object} Typography block support derived CSS classes & styles.
24
26
  */
25
- export function getTypographyClassesAndStyles( attributes ) {
26
- const typographyStyles = attributes?.style?.typography || {};
27
+ export function getTypographyClassesAndStyles(
28
+ attributes,
29
+ isFluidFontSizeActive
30
+ ) {
31
+ let typographyStyles = attributes?.style?.typography || {};
32
+
33
+ if ( isFluidFontSizeActive ) {
34
+ typographyStyles = {
35
+ ...typographyStyles,
36
+ fontSize: getComputedFluidTypographyValue( {
37
+ fontSize: attributes?.style?.typography?.fontSize,
38
+ } ),
39
+ };
40
+ }
41
+
27
42
  const style = getInlineStyles( { typography: typographyStyles } );
28
43
  const fontFamilyClassName = !! attributes?.fontFamily
29
44
  ? `has-${ kebabCase( attributes.fontFamily ) }-font-family`
@@ -1,7 +1,7 @@
1
1
  /**
2
2
  * External dependencies
3
3
  */
4
- import { pickBy, isEmpty, mapValues, get, setWith, clone, every } from 'lodash';
4
+ import { pickBy, isEmpty, mapValues, get, setWith, clone } from 'lodash';
5
5
 
6
6
  /**
7
7
  * WordPress dependencies
@@ -44,7 +44,11 @@ export function transformStyles(
44
44
  results
45
45
  ) {
46
46
  // If there are no active supports return early.
47
- if ( every( activeSupports, ( isActive ) => ! isActive ) ) {
47
+ if (
48
+ Object.values( activeSupports ?? {} ).every(
49
+ ( isActive ) => ! isActive
50
+ )
51
+ ) {
48
52
  return result;
49
53
  }
50
54
  // If the condition verifies we are probably in the presence of a wrapping transform
@@ -26,6 +26,8 @@ import {
26
26
  START_OF_SELECTED_AREA,
27
27
  } from '../utils/selection';
28
28
 
29
+ /** @typedef {import('../components/use-on-block-drop/types').WPDropOperation} WPDropOperation */
30
+
29
31
  const castArray = ( maybeArray ) =>
30
32
  Array.isArray( maybeArray ) ? maybeArray : [ maybeArray ];
31
33
 
@@ -624,10 +626,13 @@ export const insertBlocks =
624
626
  /**
625
627
  * Action that shows the insertion point.
626
628
  *
627
- * @param {?string} rootClientId Optional root client ID of block list on
628
- * which to insert.
629
- * @param {?number} index Index at which block should be inserted.
630
- * @param {Object} __unstableOptions Whether or not to show an inserter button.
629
+ * @param {?string} rootClientId Optional root client ID of block list on
630
+ * which to insert.
631
+ * @param {?number} index Index at which block should be inserted.
632
+ * @param {?Object} __unstableOptions Additional options.
633
+ * @property {boolean} __unstableWithInserter Whether or not to show an inserter button.
634
+ * @property {WPDropOperation} operation The operation to perform when applied,
635
+ * either 'insert' or 'replace' for now.
631
636
  *
632
637
  * @return {Object} Action object.
633
638
  */
@@ -636,25 +641,28 @@ export function showInsertionPoint(
636
641
  index,
637
642
  __unstableOptions = {}
638
643
  ) {
639
- const { __unstableWithInserter } = __unstableOptions;
644
+ const { __unstableWithInserter, operation } = __unstableOptions;
640
645
  return {
641
646
  type: 'SHOW_INSERTION_POINT',
642
647
  rootClientId,
643
648
  index,
644
649
  __unstableWithInserter,
650
+ operation,
645
651
  };
646
652
  }
647
-
648
653
  /**
649
654
  * Action that hides the insertion point.
650
- *
651
- * @return {Object} Action object.
652
655
  */
653
- export function hideInsertionPoint() {
654
- return {
655
- type: 'HIDE_INSERTION_POINT',
656
+ export const hideInsertionPoint =
657
+ () =>
658
+ ( { select, dispatch } ) => {
659
+ if ( ! select.isBlockInsertionPointVisible() ) {
660
+ return;
661
+ }
662
+ dispatch( {
663
+ type: 'HIDE_INSERTION_POINT',
664
+ } );
656
665
  };
657
- }
658
666
 
659
667
  /**
660
668
  * Action that resets the template validity.