@wordpress/block-editor 14.7.1-next.082ed6819.0 → 14.8.1-next.a9f418477.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 (303) hide show
  1. package/CHANGELOG.md +2 -0
  2. package/build/autocompleters/block.js +2 -4
  3. package/build/autocompleters/block.js.map +1 -1
  4. package/build/autocompleters/link.js +2 -4
  5. package/build/autocompleters/link.js.map +1 -1
  6. package/build/components/block-canvas/index.js +3 -6
  7. package/build/components/block-canvas/index.js.map +1 -1
  8. package/build/components/block-list/block.js +6 -5
  9. package/build/components/block-list/block.js.map +1 -1
  10. package/build/components/block-list/index.js +0 -1
  11. package/build/components/block-list/index.js.map +1 -1
  12. package/build/components/block-list/use-block-props/index.js +6 -2
  13. package/build/components/block-list/use-block-props/index.js.map +1 -1
  14. package/build/components/block-list/use-block-props/use-firefox-draggable-compatibility.js +87 -0
  15. package/build/components/block-list/use-block-props/use-firefox-draggable-compatibility.js.map +1 -0
  16. package/build/components/block-list/use-block-props/use-selected-block-event-handlers.js +98 -5
  17. package/build/components/block-list/use-block-props/use-selected-block-event-handlers.js.map +1 -1
  18. package/build/components/block-lock/modal.js +4 -4
  19. package/build/components/block-lock/modal.js.map +1 -1
  20. package/build/components/block-parent-selector/index.js +2 -15
  21. package/build/components/block-parent-selector/index.js.map +1 -1
  22. package/build/components/block-patterns-list/index.js +13 -4
  23. package/build/components/block-patterns-list/index.js.map +1 -1
  24. package/build/components/block-popover/inbetween.js +4 -0
  25. package/build/components/block-popover/inbetween.js.map +1 -1
  26. package/build/components/block-settings-menu/block-settings-dropdown.js +7 -4
  27. package/build/components/block-settings-menu/block-settings-dropdown.js.map +1 -1
  28. package/build/components/block-settings-menu-controls/index.js +1 -1
  29. package/build/components/block-settings-menu-controls/index.js.map +1 -1
  30. package/build/components/block-switcher/index.js +12 -22
  31. package/build/components/block-switcher/index.js.map +1 -1
  32. package/build/components/block-switcher/use-transformed-patterns.js +0 -1
  33. package/build/components/block-switcher/use-transformed-patterns.js.map +1 -1
  34. package/build/components/block-switcher/utils.js +0 -1
  35. package/build/components/block-switcher/utils.js.map +1 -1
  36. package/build/components/block-toolbar/index.js +17 -9
  37. package/build/components/block-toolbar/index.js.map +1 -1
  38. package/build/components/block-variation-transforms/index.js +0 -1
  39. package/build/components/block-variation-transforms/index.js.map +1 -1
  40. package/build/components/date-format-picker/index.js +0 -1
  41. package/build/components/date-format-picker/index.js.map +1 -1
  42. package/build/components/font-appearance-control/index.js +1 -0
  43. package/build/components/font-appearance-control/index.js.map +1 -1
  44. package/build/components/font-family/index.js +10 -0
  45. package/build/components/font-family/index.js.map +1 -1
  46. package/build/components/global-styles/dimensions-panel.js +17 -16
  47. package/build/components/global-styles/dimensions-panel.js.map +1 -1
  48. package/build/components/global-styles/get-global-styles-changes.js +0 -1
  49. package/build/components/global-styles/get-global-styles-changes.js.map +1 -1
  50. package/build/components/iframe/index.js +12 -216
  51. package/build/components/iframe/index.js.map +1 -1
  52. package/build/components/iframe/use-scale-canvas.js +398 -0
  53. package/build/components/iframe/use-scale-canvas.js.map +1 -0
  54. package/build/components/image-editor/use-save-image.js +22 -3
  55. package/build/components/image-editor/use-save-image.js.map +1 -1
  56. package/build/components/inserter/block-patterns-tab/index.js +0 -10
  57. package/build/components/inserter/block-patterns-tab/index.js.map +1 -1
  58. package/build/components/inserter/menu.js +2 -1
  59. package/build/components/inserter/menu.js.map +1 -1
  60. package/build/components/inserter-draggable-blocks/index.js +19 -10
  61. package/build/components/inserter-draggable-blocks/index.js.map +1 -1
  62. package/build/components/inspector-controls/slot.js +2 -13
  63. package/build/components/inspector-controls/slot.js.map +1 -1
  64. package/build/components/letter-spacing-control/index.js +10 -0
  65. package/build/components/letter-spacing-control/index.js.map +1 -1
  66. package/build/components/line-height-control/index.js +1 -0
  67. package/build/components/line-height-control/index.js.map +1 -1
  68. package/build/components/media-placeholder/index.js +18 -18
  69. package/build/components/media-placeholder/index.js.map +1 -1
  70. package/build/components/multi-selection-inspector/index.js +9 -25
  71. package/build/components/multi-selection-inspector/index.js.map +1 -1
  72. package/build/components/observe-typing/index.js +0 -1
  73. package/build/components/observe-typing/index.js.map +1 -1
  74. package/build/components/recursion-provider/index.js +0 -1
  75. package/build/components/recursion-provider/index.js.map +1 -1
  76. package/build/components/rich-text/index.js +5 -1
  77. package/build/components/rich-text/index.js.map +1 -1
  78. package/build/components/rich-text/native/use-format-types.js +0 -1
  79. package/build/components/rich-text/native/use-format-types.js.map +1 -1
  80. package/build/components/rich-text/use-format-types.js +0 -1
  81. package/build/components/rich-text/use-format-types.js.map +1 -1
  82. package/build/components/spacing-sizes-control/utils.js +0 -1
  83. package/build/components/spacing-sizes-control/utils.js.map +1 -1
  84. package/build/components/typewriter/index.js +0 -1
  85. package/build/components/typewriter/index.js.map +1 -1
  86. package/build/components/use-block-drop-zone/index.js +11 -2
  87. package/build/components/use-block-drop-zone/index.js.map +1 -1
  88. package/build/components/use-moving-animation/index.js +15 -2
  89. package/build/components/use-moving-animation/index.js.map +1 -1
  90. package/build/components/use-resize-canvas/index.js +1 -1
  91. package/build/components/use-resize-canvas/index.js.map +1 -1
  92. package/build/components/warning/index.js +2 -3
  93. package/build/components/warning/index.js.map +1 -1
  94. package/build/components/writing-flow/use-drag-selection.js +11 -0
  95. package/build/components/writing-flow/use-drag-selection.js.map +1 -1
  96. package/build/components/writing-flow/use-tab-nav.js +6 -2
  97. package/build/components/writing-flow/use-tab-nav.js.map +1 -1
  98. package/build/hooks/block-bindings.js +4 -3
  99. package/build/hooks/block-bindings.js.map +1 -1
  100. package/build/hooks/gap.js +1 -1
  101. package/build/hooks/gap.js.map +1 -1
  102. package/build/hooks/generated-class-name.js +0 -1
  103. package/build/hooks/generated-class-name.js.map +1 -1
  104. package/build/hooks/use-zoom-out.js +47 -14
  105. package/build/hooks/use-zoom-out.js.map +1 -1
  106. package/build/store/private-selectors.js +1 -7
  107. package/build/store/private-selectors.js.map +1 -1
  108. package/build/store/reducer.js +478 -2
  109. package/build/store/reducer.js.map +1 -1
  110. package/build/store/selectors.js +12 -55
  111. package/build/store/selectors.js.map +1 -1
  112. package/build/utils/object.js +0 -1
  113. package/build/utils/object.js.map +1 -1
  114. package/build-module/autocompleters/block.js +2 -4
  115. package/build-module/autocompleters/block.js.map +1 -1
  116. package/build-module/autocompleters/link.js +2 -4
  117. package/build-module/autocompleters/link.js.map +1 -1
  118. package/build-module/components/block-canvas/index.js +3 -6
  119. package/build-module/components/block-canvas/index.js.map +1 -1
  120. package/build-module/components/block-list/block.js +8 -7
  121. package/build-module/components/block-list/block.js.map +1 -1
  122. package/build-module/components/block-list/index.js +0 -1
  123. package/build-module/components/block-list/index.js.map +1 -1
  124. package/build-module/components/block-list/use-block-props/index.js +6 -2
  125. package/build-module/components/block-list/use-block-props/index.js.map +1 -1
  126. package/build-module/components/block-list/use-block-props/use-firefox-draggable-compatibility.js +80 -0
  127. package/build-module/components/block-list/use-block-props/use-firefox-draggable-compatibility.js.map +1 -0
  128. package/build-module/components/block-list/use-block-props/use-selected-block-event-handlers.js +97 -5
  129. package/build-module/components/block-list/use-block-props/use-selected-block-event-handlers.js.map +1 -1
  130. package/build-module/components/block-lock/modal.js +4 -4
  131. package/build-module/components/block-lock/modal.js.map +1 -1
  132. package/build-module/components/block-parent-selector/index.js +2 -15
  133. package/build-module/components/block-parent-selector/index.js.map +1 -1
  134. package/build-module/components/block-patterns-list/index.js +13 -4
  135. package/build-module/components/block-patterns-list/index.js.map +1 -1
  136. package/build-module/components/block-popover/inbetween.js +4 -0
  137. package/build-module/components/block-popover/inbetween.js.map +1 -1
  138. package/build-module/components/block-settings-menu/block-settings-dropdown.js +7 -4
  139. package/build-module/components/block-settings-menu/block-settings-dropdown.js.map +1 -1
  140. package/build-module/components/block-settings-menu-controls/index.js +1 -1
  141. package/build-module/components/block-settings-menu-controls/index.js.map +1 -1
  142. package/build-module/components/block-switcher/index.js +13 -23
  143. package/build-module/components/block-switcher/index.js.map +1 -1
  144. package/build-module/components/block-switcher/use-transformed-patterns.js +0 -1
  145. package/build-module/components/block-switcher/use-transformed-patterns.js.map +1 -1
  146. package/build-module/components/block-switcher/utils.js +0 -1
  147. package/build-module/components/block-switcher/utils.js.map +1 -1
  148. package/build-module/components/block-toolbar/index.js +17 -9
  149. package/build-module/components/block-toolbar/index.js.map +1 -1
  150. package/build-module/components/block-variation-transforms/index.js +0 -1
  151. package/build-module/components/block-variation-transforms/index.js.map +1 -1
  152. package/build-module/components/date-format-picker/index.js +0 -1
  153. package/build-module/components/date-format-picker/index.js.map +1 -1
  154. package/build-module/components/font-appearance-control/index.js +1 -0
  155. package/build-module/components/font-appearance-control/index.js.map +1 -1
  156. package/build-module/components/font-family/index.js +10 -0
  157. package/build-module/components/font-family/index.js.map +1 -1
  158. package/build-module/components/global-styles/dimensions-panel.js +17 -16
  159. package/build-module/components/global-styles/dimensions-panel.js.map +1 -1
  160. package/build-module/components/global-styles/get-global-styles-changes.js +0 -1
  161. package/build-module/components/global-styles/get-global-styles-changes.js.map +1 -1
  162. package/build-module/components/iframe/index.js +14 -218
  163. package/build-module/components/iframe/index.js.map +1 -1
  164. package/build-module/components/iframe/use-scale-canvas.js +392 -0
  165. package/build-module/components/iframe/use-scale-canvas.js.map +1 -0
  166. package/build-module/components/image-editor/use-save-image.js +22 -3
  167. package/build-module/components/image-editor/use-save-image.js.map +1 -1
  168. package/build-module/components/inserter/block-patterns-tab/index.js +1 -11
  169. package/build-module/components/inserter/block-patterns-tab/index.js.map +1 -1
  170. package/build-module/components/inserter/menu.js +2 -1
  171. package/build-module/components/inserter/menu.js.map +1 -1
  172. package/build-module/components/inserter-draggable-blocks/index.js +20 -11
  173. package/build-module/components/inserter-draggable-blocks/index.js.map +1 -1
  174. package/build-module/components/inspector-controls/slot.js +3 -14
  175. package/build-module/components/inspector-controls/slot.js.map +1 -1
  176. package/build-module/components/letter-spacing-control/index.js +9 -0
  177. package/build-module/components/letter-spacing-control/index.js.map +1 -1
  178. package/build-module/components/line-height-control/index.js +1 -0
  179. package/build-module/components/line-height-control/index.js.map +1 -1
  180. package/build-module/components/media-placeholder/index.js +18 -18
  181. package/build-module/components/media-placeholder/index.js.map +1 -1
  182. package/build-module/components/multi-selection-inspector/index.js +9 -25
  183. package/build-module/components/multi-selection-inspector/index.js.map +1 -1
  184. package/build-module/components/observe-typing/index.js +0 -1
  185. package/build-module/components/observe-typing/index.js.map +1 -1
  186. package/build-module/components/recursion-provider/index.js +0 -1
  187. package/build-module/components/recursion-provider/index.js.map +1 -1
  188. package/build-module/components/rich-text/index.js +5 -1
  189. package/build-module/components/rich-text/index.js.map +1 -1
  190. package/build-module/components/rich-text/native/use-format-types.js +0 -1
  191. package/build-module/components/rich-text/native/use-format-types.js.map +1 -1
  192. package/build-module/components/rich-text/use-format-types.js +0 -1
  193. package/build-module/components/rich-text/use-format-types.js.map +1 -1
  194. package/build-module/components/spacing-sizes-control/utils.js +0 -1
  195. package/build-module/components/spacing-sizes-control/utils.js.map +1 -1
  196. package/build-module/components/typewriter/index.js +0 -1
  197. package/build-module/components/typewriter/index.js.map +1 -1
  198. package/build-module/components/use-block-drop-zone/index.js +11 -2
  199. package/build-module/components/use-block-drop-zone/index.js.map +1 -1
  200. package/build-module/components/use-moving-animation/index.js +15 -2
  201. package/build-module/components/use-moving-animation/index.js.map +1 -1
  202. package/build-module/components/use-resize-canvas/index.js +1 -1
  203. package/build-module/components/use-resize-canvas/index.js.map +1 -1
  204. package/build-module/components/warning/index.js +2 -3
  205. package/build-module/components/warning/index.js.map +1 -1
  206. package/build-module/components/writing-flow/use-drag-selection.js +11 -0
  207. package/build-module/components/writing-flow/use-drag-selection.js.map +1 -1
  208. package/build-module/components/writing-flow/use-tab-nav.js +6 -2
  209. package/build-module/components/writing-flow/use-tab-nav.js.map +1 -1
  210. package/build-module/hooks/block-bindings.js +4 -3
  211. package/build-module/hooks/block-bindings.js.map +1 -1
  212. package/build-module/hooks/gap.js +1 -1
  213. package/build-module/hooks/gap.js.map +1 -1
  214. package/build-module/hooks/generated-class-name.js +0 -1
  215. package/build-module/hooks/generated-class-name.js.map +1 -1
  216. package/build-module/hooks/use-zoom-out.js +48 -15
  217. package/build-module/hooks/use-zoom-out.js.map +1 -1
  218. package/build-module/store/private-selectors.js +1 -6
  219. package/build-module/store/private-selectors.js.map +1 -1
  220. package/build-module/store/reducer.js +479 -3
  221. package/build-module/store/reducer.js.map +1 -1
  222. package/build-module/store/selectors.js +12 -55
  223. package/build-module/store/selectors.js.map +1 -1
  224. package/build-module/utils/object.js +0 -1
  225. package/build-module/utils/object.js.map +1 -1
  226. package/build-style/content-rtl.css +25 -27
  227. package/build-style/content.css +25 -27
  228. package/build-style/style-rtl.css +55 -64
  229. package/build-style/style.css +55 -64
  230. package/package.json +32 -32
  231. package/src/autocompleters/block.js +2 -4
  232. package/src/autocompleters/link.js +2 -4
  233. package/src/components/alignment-control/stories/aliginment-toolbar.story.js +47 -0
  234. package/src/components/alignment-control/stories/index.story.js +51 -0
  235. package/src/components/alignment-control/test/__snapshots__/index.js.snap +5 -5
  236. package/src/components/block-alignment-control/test/__snapshots__/index.js.snap +4 -4
  237. package/src/components/block-canvas/index.js +3 -5
  238. package/src/components/block-canvas/style.scss +2 -1
  239. package/src/components/block-draggable/content.scss +11 -5
  240. package/src/components/block-list/block.js +7 -13
  241. package/src/components/block-list/content.scss +6 -0
  242. package/src/components/block-list/use-block-props/index.js +5 -0
  243. package/src/components/block-list/use-block-props/use-firefox-draggable-compatibility.js +83 -0
  244. package/src/components/block-list/use-block-props/use-selected-block-event-handlers.js +112 -8
  245. package/src/components/block-lock/modal.js +4 -6
  246. package/src/components/block-parent-selector/index.js +1 -19
  247. package/src/components/block-patterns-list/index.js +12 -1
  248. package/src/components/block-patterns-list/stories/fixtures.js +1 -0
  249. package/src/components/block-patterns-list/style.scss +16 -5
  250. package/src/components/block-popover/inbetween.js +4 -0
  251. package/src/components/block-settings-menu/block-settings-dropdown.js +6 -1
  252. package/src/components/block-settings-menu-controls/index.js +2 -1
  253. package/src/components/block-switcher/index.js +19 -21
  254. package/src/components/block-switcher/style.scss +0 -9
  255. package/src/components/block-title/test/index.js +2 -0
  256. package/src/components/block-toolbar/index.js +17 -6
  257. package/src/components/block-tools/style.scss +44 -0
  258. package/src/components/block-vertical-alignment-control/test/__snapshots__/index.js.snap +3 -3
  259. package/src/components/color-palette/test/__snapshots__/control.js.snap +2 -2
  260. package/src/components/dimensions-tool/stories/aspect-ratio-tool.story.js +1 -1
  261. package/src/components/dimensions-tool/stories/index.story.js +1 -1
  262. package/src/components/dimensions-tool/stories/scale-tool.story.js +1 -1
  263. package/src/components/dimensions-tool/stories/width-height-tool.story.js +1 -1
  264. package/src/components/font-appearance-control/index.js +1 -0
  265. package/src/components/font-family/index.js +10 -0
  266. package/src/components/font-family/style.scss +5 -0
  267. package/src/components/global-styles/dimensions-panel.js +16 -16
  268. package/src/components/iframe/content.scss +40 -42
  269. package/src/components/iframe/index.js +13 -313
  270. package/src/components/iframe/use-scale-canvas.js +490 -0
  271. package/src/components/image-editor/use-save-image.js +27 -2
  272. package/src/components/inserter/block-patterns-tab/index.js +1 -17
  273. package/src/components/inserter/menu.js +8 -1
  274. package/src/components/inserter-draggable-blocks/index.js +19 -29
  275. package/src/components/inspector-controls/slot.js +3 -22
  276. package/src/components/letter-spacing-control/README.md +2 -1
  277. package/src/components/letter-spacing-control/index.js +17 -0
  278. package/src/components/line-height-control/index.js +1 -0
  279. package/src/components/media-placeholder/index.js +25 -28
  280. package/src/components/multi-selection-inspector/index.js +17 -27
  281. package/src/components/multi-selection-inspector/style.scss +0 -12
  282. package/src/components/resolution-tool/stories/index.story.js +1 -1
  283. package/src/components/rich-text/index.js +5 -0
  284. package/src/components/spacing-sizes-control/style.scss +0 -29
  285. package/src/components/text-alignment-control/stories/index.story.js +1 -1
  286. package/src/components/use-block-drop-zone/index.js +18 -1
  287. package/src/components/use-moving-animation/index.js +15 -0
  288. package/src/components/use-resize-canvas/index.js +1 -1
  289. package/src/components/warning/index.js +3 -4
  290. package/src/components/warning/test/index.js +3 -1
  291. package/src/components/writing-flow/use-drag-selection.js +11 -0
  292. package/src/components/writing-flow/use-tab-nav.js +9 -6
  293. package/src/hooks/block-bindings.js +8 -4
  294. package/src/hooks/gap.js +1 -1
  295. package/src/hooks/use-zoom-out.js +48 -16
  296. package/src/store/private-selectors.js +2 -17
  297. package/src/store/reducer.js +639 -2
  298. package/src/store/selectors.js +19 -69
  299. package/src/store/test/private-selectors.js +1 -0
  300. package/src/store/test/reducer.js +849 -0
  301. package/src/store/test/selectors.js +4 -110
  302. package/src/style.scss +1 -0
  303. package/tsconfig.tsbuildinfo +1 -1
@@ -219,7 +219,7 @@ exports[`ColorPaletteControl matches the snapshot 1`] = `
219
219
  <button
220
220
  aria-label="Color: red"
221
221
  aria-selected="true"
222
- class="components-button components-circular-option-picker__option"
222
+ class="components-button components-circular-option-picker__option is-next-40px-default-size"
223
223
  data-active-item="true"
224
224
  id="components-circular-option-picker-0-0"
225
225
  role="option"
@@ -247,7 +247,7 @@ exports[`ColorPaletteControl matches the snapshot 1`] = `
247
247
  class="components-circular-option-picker__custom-clear-wrapper"
248
248
  >
249
249
  <button
250
- class="components-button components-circular-option-picker__clear is-tertiary"
250
+ class="components-button components-circular-option-picker__clear is-next-40px-default-size is-tertiary"
251
251
  type="button"
252
252
  >
253
253
  Clear
@@ -16,7 +16,7 @@ export default {
16
16
  title: 'BlockEditor (Private APIs)/DimensionsTool/AspectRatioTool',
17
17
  component: AspectRatioTool,
18
18
  argTypes: {
19
- panelId: { control: { type: null } },
19
+ panelId: { control: false },
20
20
  onChange: { action: 'changed' },
21
21
  },
22
22
  };
@@ -16,7 +16,7 @@ export default {
16
16
  title: 'BlockEditor (Private APIs)/DimensionsTool',
17
17
  component: DimensionsTool,
18
18
  argTypes: {
19
- panelId: { control: { type: null } },
19
+ panelId: { control: false },
20
20
  onChange: { action: 'changed' },
21
21
  },
22
22
  };
@@ -16,7 +16,7 @@ export default {
16
16
  title: 'BlockEditor (Private APIs)/DimensionsTool/ScaleTool',
17
17
  component: ScaleTool,
18
18
  argTypes: {
19
- panelId: { control: { type: null } },
19
+ panelId: { control: false },
20
20
  onChange: { action: 'changed' },
21
21
  },
22
22
  };
@@ -16,7 +16,7 @@ export default {
16
16
  title: 'BlockEditor (Private APIs)/DimensionsTool/WidthHeightTool',
17
17
  component: WidthHeightTool,
18
18
  argTypes: {
19
- panelId: { control: { type: null } },
19
+ panelId: { control: false },
20
20
  onChange: { action: 'changed' },
21
21
  },
22
22
  };
@@ -153,6 +153,7 @@ export default function FontAppearanceControl( props ) {
153
153
  { ...otherProps }
154
154
  className="components-font-appearance-control"
155
155
  __next40pxDefaultSize={ __next40pxDefaultSize }
156
+ __shouldNotWarnDeprecated36pxSize
156
157
  label={ label }
157
158
  describedBy={ getDescribedBy() }
158
159
  options={ selectOptions }
@@ -1,3 +1,8 @@
1
+ /**
2
+ * External dependencies
3
+ */
4
+ import clsx from 'clsx';
5
+
1
6
  /**
2
7
  * WordPress dependencies
3
8
  */
@@ -18,6 +23,7 @@ export default function FontFamilyControl( {
18
23
  value = '',
19
24
  onChange,
20
25
  fontFamilies,
26
+ className,
21
27
  ...props
22
28
  } ) {
23
29
  const [ blockLevelFontFamilies ] = useSettings( 'typography.fontFamilies' );
@@ -55,10 +61,14 @@ export default function FontFamilyControl( {
55
61
  return (
56
62
  <CustomSelectControl
57
63
  __next40pxDefaultSize={ __next40pxDefaultSize }
64
+ __shouldNotWarnDeprecated36pxSize
58
65
  label={ __( 'Font' ) }
59
66
  value={ value }
60
67
  onChange={ ( { selectedItem } ) => onChange( selectedItem.key ) }
61
68
  options={ options }
69
+ className={ clsx( 'block-editor-font-family-control', className, {
70
+ 'is-next-has-no-margin-bottom': __nextHasNoMarginBottom,
71
+ } ) }
62
72
  { ...props }
63
73
  />
64
74
  );
@@ -0,0 +1,5 @@
1
+ .block-editor-font-family-control {
2
+ &:not(.is-next-has-no-margin-bottom) {
3
+ margin-bottom: $grid-unit-10;
4
+ }
5
+ }
@@ -444,17 +444,6 @@ export default function DimensionsPanel( {
444
444
 
445
445
  const onMouseLeaveControls = () => onVisualize( false );
446
446
 
447
- const inputProps = {
448
- min: minMarginValue,
449
- onDragStart: () => {
450
- //Reset to 0 in case the value was negative.
451
- setMinMarginValue( 0 );
452
- },
453
- onDragEnd: () => {
454
- setMinMarginValue( minimumMargin );
455
- },
456
- };
457
-
458
447
  return (
459
448
  <Wrapper
460
449
  resetAllFilter={ resetAllFilter }
@@ -545,8 +534,10 @@ export default function DimensionsPanel( {
545
534
  units={ units }
546
535
  allowReset={ false }
547
536
  splitOnAxis={ isAxialPadding }
548
- onMouseOver={ onMouseOverPadding }
549
- onMouseOut={ onMouseLeaveControls }
537
+ inputProps={ {
538
+ onMouseOver: onMouseOverPadding,
539
+ onMouseOut: onMouseLeaveControls,
540
+ } }
550
541
  />
551
542
  ) }
552
543
  { showSpacingPresetsControl && (
@@ -581,14 +572,23 @@ export default function DimensionsPanel( {
581
572
  __next40pxDefaultSize
582
573
  values={ marginValues }
583
574
  onChange={ setMarginValues }
584
- inputProps={ inputProps }
575
+ inputProps={ {
576
+ min: minMarginValue,
577
+ onDragStart: () => {
578
+ // Reset to 0 in case the value was negative.
579
+ setMinMarginValue( 0 );
580
+ },
581
+ onDragEnd: () => {
582
+ setMinMarginValue( minimumMargin );
583
+ },
584
+ onMouseOver: onMouseOverMargin,
585
+ onMouseOut: onMouseLeaveControls,
586
+ } }
585
587
  label={ __( 'Margin' ) }
586
588
  sides={ marginSides }
587
589
  units={ units }
588
590
  allowReset={ false }
589
591
  splitOnAxis={ isAxialMargin }
590
- onMouseOver={ onMouseOverMargin }
591
- onMouseOut={ onMouseLeaveControls }
592
592
  />
593
593
  ) }
594
594
  { showSpacingPresetsControl && (
@@ -4,68 +4,66 @@
4
4
 
5
5
  .block-editor-iframe__html {
6
6
  transform-origin: top center;
7
- // We don't want to animate the transform of the translateX because it is used
8
- // to "center" the canvas. Leaving it on causes the canvas to slide around in
9
- // odd ways.
10
- @include editor-canvas-resize-animation( transform 0s, scale 0s, padding 0s, translate 0s);
7
+ // Prevents a flash of background color change when entering/exiting zoom out
8
+ transition: background-color 400ms;
11
9
 
12
10
  &.zoom-out-animation {
13
11
  $scroll-top: var(--wp-block-editor-iframe-zoom-out-scroll-top, 0);
14
12
  $scroll-top-next: var(--wp-block-editor-iframe-zoom-out-scroll-top-next, 0);
13
+ $overflow-behavior: var(--wp-block-editor-iframe-zoom-out-overflow-behavior, scroll);
15
14
 
16
15
  position: fixed;
17
16
  left: 0;
18
17
  right: 0;
19
18
  top: calc(-1 * #{$scroll-top});
20
19
  bottom: 0;
21
- translate: 0 calc(#{$scroll-top} - #{$scroll-top-next});
22
20
  // Force preserving a scrollbar gutter as scrollbar-gutter isn't supported in all browsers yet,
23
21
  // and removing the scrollbar causes the content to shift.
24
- overflow-y: scroll;
25
-
26
- // We only want to animate the scaling when entering zoom out. When sidebars
27
- // are toggled, the resizing of the iframe handles scaling the canvas as well,
28
- // and the doubled animations cause very odd animations.
29
- @include editor-canvas-resize-animation( transform 0s, top 0s, bottom 0s, right 0s, left 0s );
22
+ overflow-y: $overflow-behavior;
30
23
  }
31
- }
32
24
 
33
- .block-editor-iframe__html.is-zoomed-out {
34
- $scale: var(--wp-block-editor-iframe-zoom-out-scale);
35
- $frame-size: var(--wp-block-editor-iframe-zoom-out-frame-size);
36
- $inner-height: var(--wp-block-editor-iframe-zoom-out-inner-height);
37
- $content-height: var(--wp-block-editor-iframe-zoom-out-content-height);
38
- $scale-container-width: var(--wp-block-editor-iframe-zoom-out-scale-container-width);
39
- $container-width: var(--wp-block-editor-iframe-zoom-out-container-width, 100vw);
40
- // Apply an X translation to center the scaled content within the available space.
41
- transform: translateX(calc((#{$scale-container-width} - #{$container-width}) / 2 / #{$scale}));
42
- scale: #{$scale};
43
- background-color: $gray-300;
25
+ &.is-zoomed-out {
26
+ $scale: var(--wp-block-editor-iframe-zoom-out-scale, 1);
27
+ $frame-size: var(--wp-block-editor-iframe-zoom-out-frame-size, 0);
28
+ $inner-height: var(--wp-block-editor-iframe-zoom-out-inner-height);
29
+ $content-height: var(--wp-block-editor-iframe-zoom-out-content-height);
30
+ $scale-container-width: var(--wp-block-editor-iframe-zoom-out-scale-container-width);
31
+ $container-width: var(--wp-block-editor-iframe-zoom-out-container-width, 100vw);
32
+ // Apply an X translation to center the scaled content within the available space.
33
+ transform: translateX(calc((#{$scale-container-width} - #{$container-width}) / 2 / #{$scale}));
34
+ scale: $scale;
35
+ background-color: $gray-300;
44
36
 
45
- // Chrome seems to respect that transform scale shouldn't affect the layout size of the element,
46
- // so we need to adjust the height of the content to match the scale by using negative margins.
47
- $extra-content-height: calc(#{$content-height} * (1 - #{$scale}));
48
- $total-frame-height: calc(2 * #{$frame-size} / #{$scale});
49
- $total-height: calc(#{$extra-content-height} + #{$total-frame-height} + 2px);
50
- margin-bottom: calc(-1 * #{$total-height});
51
- // Add the top/bottom frame size. We use scaling to account for the left/right, as
52
- // the padding left/right causes the contents to reflow, which breaks the 1:1 scaling
53
- // of the content.
54
- padding-top: calc(#{$frame-size} / #{$scale});
55
- padding-bottom: calc(#{$frame-size} / #{$scale});
37
+ // Chrome seems to respect that transform scale shouldn't affect the layout size of the element,
38
+ // so we need to adjust the height of the content to match the scale by using negative margins.
39
+ $extra-content-height: calc(#{$content-height} * (1 - #{$scale}));
40
+ $total-frame-height: calc(2 * #{$frame-size} / #{$scale});
41
+ $total-height: calc(#{$extra-content-height} + #{$total-frame-height} + 2px);
42
+ margin-bottom: calc(-1 * #{$total-height});
56
43
 
57
- body {
58
- min-height: calc((#{$inner-height} - #{$total-frame-height}) / #{$scale});
44
+ // Add the top/bottom frame size. We use scaling to account for the left/right, as
45
+ // the padding left/right causes the contents to reflow, which breaks the 1:1 scaling
46
+ // of the content.
47
+ padding-top: calc(#{$frame-size} / #{$scale});
48
+ padding-bottom: calc(#{$frame-size} / #{$scale});
59
49
 
60
- > .is-root-container:not(.wp-block-post-content) {
61
- flex: 1;
62
- display: flex;
63
- flex-direction: column;
64
- height: 100%;
50
+ body {
51
+ min-height: calc((#{$inner-height} - #{$total-frame-height}) / #{$scale});
65
52
 
66
- > main {
53
+ > .is-root-container:not(.wp-block-post-content) {
67
54
  flex: 1;
55
+ display: flex;
56
+ flex-direction: column;
57
+ height: 100%;
58
+
59
+ > main {
60
+ flex: 1;
61
+ }
68
62
  }
69
63
  }
64
+
65
+ .wp-block[draggable] {
66
+ cursor: grab;
67
+ }
70
68
  }
71
69
  }
@@ -12,16 +12,9 @@ import {
12
12
  forwardRef,
13
13
  useMemo,
14
14
  useEffect,
15
- useRef,
16
15
  } from '@wordpress/element';
17
16
  import { __ } from '@wordpress/i18n';
18
- import {
19
- useResizeObserver,
20
- useMergeRefs,
21
- useRefEffect,
22
- useDisabled,
23
- useReducedMotion,
24
- } from '@wordpress/compose';
17
+ import { useMergeRefs, useRefEffect, useDisabled } from '@wordpress/compose';
25
18
  import { __experimentalStyleProvider as StyleProvider } from '@wordpress/components';
26
19
  import { useSelect } from '@wordpress/data';
27
20
 
@@ -31,6 +24,7 @@ import { useSelect } from '@wordpress/data';
31
24
  import { useBlockSelectionClearer } from '../block-selection-clearer';
32
25
  import { useWritingFlow } from '../writing-flow';
33
26
  import { getCompatibilityStyles } from './get-compatibility-styles';
27
+ import { useScaleCanvas } from './use-scale-canvas';
34
28
  import { store as blockEditorStore } from '../../store';
35
29
 
36
30
  function bubbleEvent( event, Constructor, frame ) {
@@ -124,15 +118,9 @@ function Iframe( {
124
118
  const { styles = '', scripts = '' } = resolvedAssets;
125
119
  /** @type {[Document, import('react').Dispatch<Document>]} */
126
120
  const [ iframeDocument, setIframeDocument ] = useState();
127
- const initialContainerWidthRef = useRef( 0 );
128
121
  const [ bodyClasses, setBodyClasses ] = useState( [] );
129
122
  const clearerRef = useBlockSelectionClearer();
130
123
  const [ before, writingFlowRef, after ] = useWritingFlow();
131
- const [ contentResizeListener, { height: contentHeight } ] =
132
- useResizeObserver();
133
- const [ containerResizeListener, { width: containerWidth } ] =
134
- useResizeObserver();
135
- const prefersReducedMotion = useReducedMotion();
136
124
 
137
125
  const setRef = useRefEffect( ( node ) => {
138
126
  node._load = () => {
@@ -228,61 +216,16 @@ function Iframe( {
228
216
  };
229
217
  }, [] );
230
218
 
231
- const [ iframeWindowInnerHeight, setIframeWindowInnerHeight ] = useState();
232
-
233
- const iframeResizeRef = useRefEffect( ( node ) => {
234
- const nodeWindow = node.ownerDocument.defaultView;
235
-
236
- setIframeWindowInnerHeight( nodeWindow.innerHeight );
237
- const onResize = () => {
238
- setIframeWindowInnerHeight( nodeWindow.innerHeight );
239
- };
240
- nodeWindow.addEventListener( 'resize', onResize );
241
- return () => {
242
- nodeWindow.removeEventListener( 'resize', onResize );
243
- };
244
- }, [] );
245
-
246
- const [ windowInnerWidth, setWindowInnerWidth ] = useState();
247
-
248
- const windowResizeRef = useRefEffect( ( node ) => {
249
- const nodeWindow = node.ownerDocument.defaultView;
250
-
251
- setWindowInnerWidth( nodeWindow.innerWidth );
252
- const onResize = () => {
253
- setWindowInnerWidth( nodeWindow.innerWidth );
254
- };
255
- nodeWindow.addEventListener( 'resize', onResize );
256
- return () => {
257
- nodeWindow.removeEventListener( 'resize', onResize );
258
- };
259
- }, [] );
260
-
261
- const isZoomedOut = scale !== 1;
262
-
263
- useEffect( () => {
264
- if ( ! isZoomedOut ) {
265
- initialContainerWidthRef.current = containerWidth;
266
- }
267
- }, [ containerWidth, isZoomedOut ] );
268
-
269
- const scaleContainerWidth = Math.max(
270
- initialContainerWidthRef.current,
271
- containerWidth
272
- );
273
-
274
- const frameSizeValue = parseInt( frameSize );
275
-
276
- const maxWidth = 750;
277
- const scaleValue =
278
- scale === 'auto-scaled'
279
- ? ( Math.min( containerWidth, maxWidth ) - frameSizeValue * 2 ) /
280
- scaleContainerWidth
281
- : scale;
282
-
283
- const prevScaleRef = useRef( scaleValue );
284
- const prevFrameSizeRef = useRef( frameSizeValue );
285
- const prevClientHeightRef = useRef( /* Initialized in the useEffect. */ );
219
+ const {
220
+ contentResizeListener,
221
+ containerResizeListener,
222
+ isZoomedOut,
223
+ scaleContainerWidth,
224
+ } = useScaleCanvas( {
225
+ scale,
226
+ frameSize: parseInt( frameSize ),
227
+ iframeDocument,
228
+ } );
286
229
 
287
230
  const disabledRef = useDisabled( { isDisabled: ! readonly } );
288
231
  const bodyRef = useMergeRefs( [
@@ -291,10 +234,6 @@ function Iframe( {
291
234
  clearerRef,
292
235
  writingFlowRef,
293
236
  disabledRef,
294
- // Avoid resize listeners when not needed, these will trigger
295
- // unnecessary re-renders when animating the iframe width, or when
296
- // expanding preview iframes.
297
- isZoomedOut ? iframeResizeRef : null,
298
237
  ] );
299
238
 
300
239
  // Correct doctype is required to enable rendering in standards
@@ -336,245 +275,6 @@ function Iframe( {
336
275
 
337
276
  useEffect( () => cleanup, [ cleanup ] );
338
277
 
339
- useEffect( () => {
340
- if (
341
- ! iframeDocument ||
342
- // HACK: Checking if isZoomedOut differs from prevIsZoomedOut here
343
- // instead of the dependency array to appease the linter.
344
- ( scaleValue === 1 ) === ( prevScaleRef.current === 1 )
345
- ) {
346
- return;
347
- }
348
-
349
- // Unscaled height of the current iframe container.
350
- const clientHeight = iframeDocument.documentElement.clientHeight;
351
-
352
- // Scaled height of the current iframe content.
353
- const scrollHeight = iframeDocument.documentElement.scrollHeight;
354
-
355
- // Previous scale value.
356
- const prevScale = prevScaleRef.current;
357
-
358
- // Unscaled size of the previous padding around the iframe content.
359
- const prevFrameSize = prevFrameSizeRef.current;
360
-
361
- // Unscaled height of the previous iframe container.
362
- const prevClientHeight = prevClientHeightRef.current ?? clientHeight;
363
-
364
- // We can't trust the set value from contentHeight, as it was measured
365
- // before the zoom out mode was changed. After zoom out mode is changed,
366
- // appenders may appear or disappear, so we need to get the height from
367
- // the iframe at this point when we're about to animate the zoom out.
368
- // The iframe scrollTop, scrollHeight, and clientHeight will all be
369
- // accurate. The client height also does change when the zoom out mode
370
- // is toggled, as the bottom bar about selecting the template is
371
- // added/removed when toggling zoom out mode.
372
- const scrollTop = iframeDocument.documentElement.scrollTop;
373
-
374
- // Step 0: Start with the current scrollTop.
375
- let scrollTopNext = scrollTop;
376
-
377
- // Step 1: Undo the effects of the previous scale and frame around the
378
- // midpoint of the visible area.
379
- scrollTopNext =
380
- ( scrollTopNext + prevClientHeight / 2 - prevFrameSize ) /
381
- prevScale -
382
- prevClientHeight / 2;
383
-
384
- // Step 2: Apply the new scale and frame around the midpoint of the
385
- // visible area.
386
- scrollTopNext =
387
- ( scrollTopNext + clientHeight / 2 ) * scaleValue +
388
- frameSizeValue -
389
- clientHeight / 2;
390
-
391
- // Step 3: Handle an edge case so that you scroll to the top of the
392
- // iframe if the top of the iframe content is visible in the container.
393
- // The same edge case for the bottom is skipped because changing content
394
- // makes calculating it impossible.
395
- scrollTopNext = scrollTop <= prevFrameSize ? 0 : scrollTopNext;
396
-
397
- // This is the scrollTop value if you are scrolled to the bottom of the
398
- // iframe. We can't just let the browser handle it because we need to
399
- // animate the scaling.
400
- const maxScrollTop =
401
- scrollHeight * ( scaleValue / prevScale ) +
402
- frameSizeValue * 2 -
403
- clientHeight;
404
-
405
- // Step 4: Clamp the scrollTopNext between the minimum and maximum
406
- // possible scrollTop positions. Round the value to avoid subpixel
407
- // truncation by the browser which sometimes causes a 1px error.
408
- scrollTopNext = Math.round(
409
- Math.min(
410
- Math.max( 0, scrollTopNext ),
411
- Math.max( 0, maxScrollTop )
412
- )
413
- );
414
-
415
- iframeDocument.documentElement.style.setProperty(
416
- '--wp-block-editor-iframe-zoom-out-scroll-top',
417
- `${ scrollTop }px`
418
- );
419
-
420
- iframeDocument.documentElement.style.setProperty(
421
- '--wp-block-editor-iframe-zoom-out-scroll-top-next',
422
- `${ scrollTopNext }px`
423
- );
424
-
425
- iframeDocument.documentElement.classList.add( 'zoom-out-animation' );
426
-
427
- function onZoomOutTransitionEnd() {
428
- // Remove the position fixed for the animation.
429
- iframeDocument.documentElement.classList.remove(
430
- 'zoom-out-animation'
431
- );
432
-
433
- // Update previous values.
434
- prevClientHeightRef.current = clientHeight;
435
- prevFrameSizeRef.current = frameSizeValue;
436
- prevScaleRef.current = scaleValue;
437
-
438
- // Set the final scroll position that was just animated to.
439
- // Disable reason: Eslint isn't smart enough to know that this is a
440
- // DOM element. https://github.com/facebook/react/issues/31483
441
- // eslint-disable-next-line react-compiler/react-compiler
442
- iframeDocument.documentElement.scrollTop = scrollTopNext;
443
- }
444
-
445
- let raf;
446
- if ( prefersReducedMotion ) {
447
- // Hack: Wait for the window values to recalculate.
448
- raf = iframeDocument.defaultView.requestAnimationFrame(
449
- onZoomOutTransitionEnd
450
- );
451
- } else {
452
- iframeDocument.documentElement.addEventListener(
453
- 'transitionend',
454
- onZoomOutTransitionEnd,
455
- { once: true }
456
- );
457
- }
458
-
459
- return () => {
460
- iframeDocument.documentElement.style.removeProperty(
461
- '--wp-block-editor-iframe-zoom-out-scroll-top'
462
- );
463
- iframeDocument.documentElement.style.removeProperty(
464
- '--wp-block-editor-iframe-zoom-out-scroll-top-next'
465
- );
466
- iframeDocument.documentElement.classList.remove(
467
- 'zoom-out-animation'
468
- );
469
- if ( prefersReducedMotion ) {
470
- iframeDocument.defaultView.cancelAnimationFrame( raf );
471
- } else {
472
- iframeDocument.documentElement.removeEventListener(
473
- 'transitionend',
474
- onZoomOutTransitionEnd
475
- );
476
- }
477
- };
478
- }, [ iframeDocument, scaleValue, frameSizeValue, prefersReducedMotion ] );
479
-
480
- // Toggle zoom out CSS Classes only when zoom out mode changes. We could add these into the useEffect
481
- // that controls settings the CSS variables, but then we would need to do more work to ensure we're
482
- // only toggling these when the zoom out mode changes, as that useEffect is also triggered by a large
483
- // number of dependencies.
484
- useEffect( () => {
485
- if ( ! iframeDocument ) {
486
- return;
487
- }
488
-
489
- if ( isZoomedOut ) {
490
- iframeDocument.documentElement.classList.add( 'is-zoomed-out' );
491
- } else {
492
- // HACK: Since we can't remove this in the cleanup, we need to do it here.
493
- iframeDocument.documentElement.classList.remove( 'is-zoomed-out' );
494
- }
495
-
496
- return () => {
497
- // HACK: Skipping cleanup because it causes issues with the zoom out
498
- // animation. More refactoring is needed to fix this properly.
499
- // iframeDocument.documentElement.classList.remove( 'is-zoomed-out' );
500
- };
501
- }, [ iframeDocument, isZoomedOut ] );
502
-
503
- // Calculate the scaling and CSS variables for the zoom out canvas
504
- useEffect( () => {
505
- if ( ! iframeDocument ) {
506
- return;
507
- }
508
-
509
- // Note: When we initialize the zoom out when the canvas is smaller (sidebars open),
510
- // initialContainerWidthRef will be smaller than the full page, and reflow will happen
511
- // when the canvas area becomes larger due to sidebars closing. This is a known but
512
- // minor divergence for now.
513
-
514
- // This scaling calculation has to happen within the JS because CSS calc() can
515
- // only divide and multiply by a unitless value. I.e. calc( 100px / 2 ) is valid
516
- // but calc( 100px / 2px ) is not.
517
- iframeDocument.documentElement.style.setProperty(
518
- '--wp-block-editor-iframe-zoom-out-scale',
519
- scaleValue
520
- );
521
-
522
- // frameSize has to be a px value for the scaling and frame size to be computed correctly.
523
- iframeDocument.documentElement.style.setProperty(
524
- '--wp-block-editor-iframe-zoom-out-frame-size',
525
- typeof frameSize === 'number' ? `${ frameSize }px` : frameSize
526
- );
527
- iframeDocument.documentElement.style.setProperty(
528
- '--wp-block-editor-iframe-zoom-out-content-height',
529
- `${ contentHeight }px`
530
- );
531
- iframeDocument.documentElement.style.setProperty(
532
- '--wp-block-editor-iframe-zoom-out-inner-height',
533
- `${ iframeWindowInnerHeight }px`
534
- );
535
- iframeDocument.documentElement.style.setProperty(
536
- '--wp-block-editor-iframe-zoom-out-container-width',
537
- `${ containerWidth }px`
538
- );
539
- iframeDocument.documentElement.style.setProperty(
540
- '--wp-block-editor-iframe-zoom-out-scale-container-width',
541
- `${ scaleContainerWidth }px`
542
- );
543
-
544
- return () => {
545
- // HACK: Skipping cleanup because it causes issues with the zoom out
546
- // animation. More refactoring is needed to fix this properly.
547
- // iframeDocument.documentElement.style.removeProperty(
548
- // '--wp-block-editor-iframe-zoom-out-scale'
549
- // );
550
- // iframeDocument.documentElement.style.removeProperty(
551
- // '--wp-block-editor-iframe-zoom-out-frame-size'
552
- // );
553
- // iframeDocument.documentElement.style.removeProperty(
554
- // '--wp-block-editor-iframe-zoom-out-content-height'
555
- // );
556
- // iframeDocument.documentElement.style.removeProperty(
557
- // '--wp-block-editor-iframe-zoom-out-inner-height'
558
- // );
559
- // iframeDocument.documentElement.style.removeProperty(
560
- // '--wp-block-editor-iframe-zoom-out-container-width'
561
- // );
562
- // iframeDocument.documentElement.style.removeProperty(
563
- // '--wp-block-editor-iframe-zoom-out-scale-container-width'
564
- // );
565
- };
566
- }, [
567
- scaleValue,
568
- frameSize,
569
- iframeDocument,
570
- iframeWindowInnerHeight,
571
- contentHeight,
572
- containerWidth,
573
- windowInnerWidth,
574
- isZoomedOut,
575
- scaleContainerWidth,
576
- ] );
577
-
578
278
  // Make sure to not render the before and after focusable div elements in view
579
279
  // mode. They're only needed to capture focus in edit mode.
580
280
  const shouldRenderFocusCaptureElements = tabIndex >= 0 && ! isPreviewMode;
@@ -654,7 +354,7 @@ function Iframe( {
654
354
  );
655
355
 
656
356
  return (
657
- <div className="block-editor-iframe__container" ref={ windowResizeRef }>
357
+ <div className="block-editor-iframe__container">
658
358
  { containerResizeListener }
659
359
  <div
660
360
  className={ clsx(