@wordpress/block-editor 14.7.0 → 14.8.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 (204) hide show
  1. package/CHANGELOG.md +2 -0
  2. package/build/components/block-controls/slot.js +6 -3
  3. package/build/components/block-controls/slot.js.map +1 -1
  4. package/build/components/block-inspector/index.js +1 -2
  5. package/build/components/block-inspector/index.js.map +1 -1
  6. package/build/components/block-lock/modal.js +1 -1
  7. package/build/components/block-lock/modal.js.map +1 -1
  8. package/build/components/block-manager/category.js +79 -0
  9. package/build/components/block-manager/category.js.map +1 -0
  10. package/build/components/block-manager/checklist.js +40 -0
  11. package/build/components/block-manager/checklist.js.map +1 -0
  12. package/build/components/block-manager/index.js +108 -0
  13. package/build/components/block-manager/index.js.map +1 -0
  14. package/build/components/block-settings-menu/block-settings-dropdown.js.map +1 -1
  15. package/build/components/block-settings-menu/index.js.map +1 -1
  16. package/build/components/block-toolbar/index.js +16 -4
  17. package/build/components/block-toolbar/index.js.map +1 -1
  18. package/build/components/block-toolbar/switch-section-style.js +105 -0
  19. package/build/components/block-toolbar/switch-section-style.js.map +1 -0
  20. package/build/components/collab/block-comment-icon-slot.js +2 -6
  21. package/build/components/collab/block-comment-icon-slot.js.map +1 -1
  22. package/build/components/collab/block-comment-icon-toolbar-slot.js +2 -6
  23. package/build/components/collab/block-comment-icon-toolbar-slot.js.map +1 -1
  24. package/build/components/color-palette/with-color-context.js +4 -2
  25. package/build/components/color-palette/with-color-context.js.map +1 -1
  26. package/build/components/font-family/index.js +14 -13
  27. package/build/components/font-family/index.js.map +1 -1
  28. package/build/components/global-styles/use-global-styles-output.js +1 -1
  29. package/build/components/global-styles/use-global-styles-output.js.map +1 -1
  30. package/build/components/iframe/index.js +13 -100
  31. package/build/components/iframe/index.js.map +1 -1
  32. package/build/components/iframe/use-scale-canvas.js +377 -0
  33. package/build/components/iframe/use-scale-canvas.js.map +1 -0
  34. package/build/components/image-editor/use-save-image.js +22 -3
  35. package/build/components/image-editor/use-save-image.js.map +1 -1
  36. package/build/components/inserter/block-patterns-tab/pattern-category-previews.js +1 -5
  37. package/build/components/inserter/block-patterns-tab/pattern-category-previews.js.map +1 -1
  38. package/build/components/inserter/category-tabs/index.js +7 -8
  39. package/build/components/inserter/category-tabs/index.js.map +1 -1
  40. package/build/components/inserter-draggable-blocks/index.js +2 -1
  41. package/build/components/inserter-draggable-blocks/index.js.map +1 -1
  42. package/build/components/inspector-controls/slot.js +7 -4
  43. package/build/components/inspector-controls/slot.js.map +1 -1
  44. package/build/components/inspector-controls-tabs/position-controls-panel.js +1 -1
  45. package/build/components/inspector-controls-tabs/position-controls-panel.js.map +1 -1
  46. package/build/components/inspector-controls-tabs/use-inspector-controls-tabs.js +4 -4
  47. package/build/components/inspector-controls-tabs/use-inspector-controls-tabs.js.map +1 -1
  48. package/build/components/media-placeholder/index.js +29 -21
  49. package/build/components/media-placeholder/index.js.map +1 -1
  50. package/build/hooks/border.js +3 -3
  51. package/build/hooks/border.js.map +1 -1
  52. package/build/hooks/color.js +1 -1
  53. package/build/hooks/color.js.map +1 -1
  54. package/build/hooks/dimensions.js +2 -2
  55. package/build/hooks/dimensions.js.map +1 -1
  56. package/build/hooks/style.js +6 -6
  57. package/build/hooks/style.js.map +1 -1
  58. package/build/hooks/supports.js +1 -1
  59. package/build/hooks/supports.js.map +1 -1
  60. package/build/hooks/typography.js +1 -1
  61. package/build/hooks/typography.js.map +1 -1
  62. package/build/hooks/utils.js +1 -1
  63. package/build/hooks/utils.js.map +1 -1
  64. package/build/layouts/flex.js +11 -9
  65. package/build/layouts/flex.js.map +1 -1
  66. package/build/private-apis.js +4 -4
  67. package/build/private-apis.js.map +1 -1
  68. package/build/store/private-selectors.js +1 -1
  69. package/build/store/private-selectors.js.map +1 -1
  70. package/build/store/selectors.js +3 -0
  71. package/build/store/selectors.js.map +1 -1
  72. package/build-module/components/block-controls/slot.js +6 -3
  73. package/build-module/components/block-controls/slot.js.map +1 -1
  74. package/build-module/components/block-inspector/index.js +1 -2
  75. package/build-module/components/block-inspector/index.js.map +1 -1
  76. package/build-module/components/block-lock/modal.js +1 -1
  77. package/build-module/components/block-lock/modal.js.map +1 -1
  78. package/build-module/components/block-manager/category.js +71 -0
  79. package/build-module/components/block-manager/category.js.map +1 -0
  80. package/build-module/components/block-manager/checklist.js +32 -0
  81. package/build-module/components/block-manager/checklist.js.map +1 -0
  82. package/build-module/components/block-manager/index.js +102 -0
  83. package/build-module/components/block-manager/index.js.map +1 -0
  84. package/build-module/components/block-settings-menu/block-settings-dropdown.js +2 -2
  85. package/build-module/components/block-settings-menu/block-settings-dropdown.js.map +1 -1
  86. package/build-module/components/block-settings-menu/index.js +2 -2
  87. package/build-module/components/block-settings-menu/index.js.map +1 -1
  88. package/build-module/components/block-toolbar/index.js +16 -4
  89. package/build-module/components/block-toolbar/index.js.map +1 -1
  90. package/build-module/components/block-toolbar/switch-section-style.js +97 -0
  91. package/build-module/components/block-toolbar/switch-section-style.js.map +1 -0
  92. package/build-module/components/collab/block-comment-icon-slot.js +2 -6
  93. package/build-module/components/collab/block-comment-icon-slot.js.map +1 -1
  94. package/build-module/components/collab/block-comment-icon-toolbar-slot.js +2 -6
  95. package/build-module/components/collab/block-comment-icon-toolbar-slot.js.map +1 -1
  96. package/build-module/components/color-palette/with-color-context.js +4 -2
  97. package/build-module/components/color-palette/with-color-context.js.map +1 -1
  98. package/build-module/components/font-family/index.js +15 -14
  99. package/build-module/components/font-family/index.js.map +1 -1
  100. package/build-module/components/global-styles/use-global-styles-output.js +1 -1
  101. package/build-module/components/global-styles/use-global-styles-output.js.map +1 -1
  102. package/build-module/components/iframe/index.js +15 -102
  103. package/build-module/components/iframe/index.js.map +1 -1
  104. package/build-module/components/iframe/use-scale-canvas.js +371 -0
  105. package/build-module/components/iframe/use-scale-canvas.js.map +1 -0
  106. package/build-module/components/image-editor/use-save-image.js +22 -3
  107. package/build-module/components/image-editor/use-save-image.js.map +1 -1
  108. package/build-module/components/inserter/block-patterns-tab/pattern-category-previews.js +1 -5
  109. package/build-module/components/inserter/block-patterns-tab/pattern-category-previews.js.map +1 -1
  110. package/build-module/components/inserter/category-tabs/index.js +8 -9
  111. package/build-module/components/inserter/category-tabs/index.js.map +1 -1
  112. package/build-module/components/inserter-draggable-blocks/index.js +2 -1
  113. package/build-module/components/inserter-draggable-blocks/index.js.map +1 -1
  114. package/build-module/components/inspector-controls/slot.js +7 -4
  115. package/build-module/components/inspector-controls/slot.js.map +1 -1
  116. package/build-module/components/inspector-controls-tabs/position-controls-panel.js +1 -1
  117. package/build-module/components/inspector-controls-tabs/position-controls-panel.js.map +1 -1
  118. package/build-module/components/inspector-controls-tabs/use-inspector-controls-tabs.js +4 -4
  119. package/build-module/components/inspector-controls-tabs/use-inspector-controls-tabs.js.map +1 -1
  120. package/build-module/components/media-placeholder/index.js +29 -21
  121. package/build-module/components/media-placeholder/index.js.map +1 -1
  122. package/build-module/hooks/border.js +3 -3
  123. package/build-module/hooks/border.js.map +1 -1
  124. package/build-module/hooks/color.js +1 -1
  125. package/build-module/hooks/color.js.map +1 -1
  126. package/build-module/hooks/dimensions.js +2 -2
  127. package/build-module/hooks/dimensions.js.map +1 -1
  128. package/build-module/hooks/style.js +6 -6
  129. package/build-module/hooks/style.js.map +1 -1
  130. package/build-module/hooks/supports.js +1 -1
  131. package/build-module/hooks/supports.js.map +1 -1
  132. package/build-module/hooks/typography.js +1 -1
  133. package/build-module/hooks/typography.js.map +1 -1
  134. package/build-module/hooks/utils.js +1 -1
  135. package/build-module/hooks/utils.js.map +1 -1
  136. package/build-module/layouts/flex.js +11 -9
  137. package/build-module/layouts/flex.js.map +1 -1
  138. package/build-module/private-apis.js +6 -6
  139. package/build-module/private-apis.js.map +1 -1
  140. package/build-module/store/private-selectors.js +1 -1
  141. package/build-module/store/private-selectors.js.map +1 -1
  142. package/build-module/store/selectors.js +3 -0
  143. package/build-module/store/selectors.js.map +1 -1
  144. package/build-style/content-rtl.css +27 -28
  145. package/build-style/content.css +27 -28
  146. package/build-style/style-rtl.css +108 -0
  147. package/build-style/style.css +108 -0
  148. package/package.json +2 -2
  149. package/src/components/block-canvas/style.scss +2 -1
  150. package/src/components/block-controls/slot.js +5 -3
  151. package/src/components/block-inspector/index.js +0 -2
  152. package/src/components/block-lock/modal.js +1 -1
  153. package/src/components/block-manager/category.js +102 -0
  154. package/src/components/block-manager/checklist.js +34 -0
  155. package/src/components/block-manager/index.js +127 -0
  156. package/src/components/block-manager/style.scss +82 -0
  157. package/src/components/block-mover/README.md +15 -8
  158. package/src/components/block-mover/stories/index.story.js +73 -71
  159. package/src/components/block-mover/style.scss +3 -0
  160. package/src/components/block-settings-menu/block-settings-dropdown.js +2 -2
  161. package/src/components/block-settings-menu/index.js +2 -2
  162. package/src/components/block-toolbar/index.js +14 -0
  163. package/src/components/block-toolbar/switch-section-style.js +115 -0
  164. package/src/components/block-tools/style.scss +39 -0
  165. package/src/components/collab/block-comment-icon-slot.js +2 -6
  166. package/src/components/collab/block-comment-icon-toolbar-slot.js +3 -5
  167. package/src/components/color-palette/test/__snapshots__/control.js.snap +2 -2
  168. package/src/components/color-palette/with-color-context.js +25 -7
  169. package/src/components/font-family/index.js +13 -13
  170. package/src/components/global-styles/test/use-global-styles-output.js +1 -1
  171. package/src/components/global-styles/use-global-styles-output.js +1 -1
  172. package/src/components/iframe/content.scss +49 -43
  173. package/src/components/iframe/index.js +14 -171
  174. package/src/components/iframe/use-scale-canvas.js +468 -0
  175. package/src/components/image-editor/use-save-image.js +27 -2
  176. package/src/components/inserter/block-patterns-tab/pattern-category-previews.js +7 -16
  177. package/src/components/inserter/category-tabs/index.js +8 -9
  178. package/src/components/inserter-draggable-blocks/index.js +10 -1
  179. package/src/components/inspector-controls/README.md +2 -0
  180. package/src/components/inspector-controls/slot.js +6 -4
  181. package/src/components/inspector-controls-tabs/position-controls-panel.js +1 -3
  182. package/src/components/inspector-controls-tabs/use-inspector-controls-tabs.js +10 -10
  183. package/src/components/media-placeholder/index.js +37 -33
  184. package/src/components/provider/test/use-block-sync.js +3 -1
  185. package/src/components/rich-text/content.scss +15 -10
  186. package/src/hooks/border.js +3 -9
  187. package/src/hooks/color.js +1 -1
  188. package/src/hooks/dimensions.js +2 -2
  189. package/src/hooks/style.js +6 -12
  190. package/src/hooks/supports.js +1 -1
  191. package/src/hooks/test/style.js +1 -2
  192. package/src/hooks/typography.js +1 -1
  193. package/src/hooks/utils.js +1 -1
  194. package/src/layouts/flex.js +26 -18
  195. package/src/private-apis.js +6 -6
  196. package/src/store/private-selectors.js +1 -1
  197. package/src/store/selectors.js +3 -0
  198. package/src/store/test/selectors.js +87 -58
  199. package/src/style.scss +1 -0
  200. package/build/components/block-info-slot-fill/index.js +0 -39
  201. package/build/components/block-info-slot-fill/index.js.map +0 -1
  202. package/build-module/components/block-info-slot-fill/index.js +0 -32
  203. package/build-module/components/block-info-slot-fill/index.js.map +0 -1
  204. package/src/components/block-info-slot-fill/index.js +0 -27
@@ -1 +1 @@
1
- {"version":3,"names":["_clsx","_interopRequireDefault","require","_element","_i18n","_compose","_components","_data","_blockSelectionClearer","_writingFlow","_getCompatibilityStyles","_store","_jsxRuntime","bubbleEvent","event","Constructor","frame","init","key","contentDocument","defaultView","MouseEvent","rect","getBoundingClientRect","clientX","left","clientY","top","newEvent","type","defaultPrevented","preventDefault","cancelled","dispatchEvent","useBubbleEvents","iframeDocument","useRefEffect","frameElement","html","documentElement","eventTypes","handlers","name","prototype","Object","getPrototypeOf","constructorName","constructor","window","addEventListener","removeEventListener","Iframe","contentRef","children","tabIndex","scale","frameSize","readonly","forwardedRef","ref","title","__","props","resolvedAssets","isPreviewMode","useSelect","select","getSettings","blockEditorStore","settings","__unstableResolvedAssets","styles","scripts","setIframeDocument","useState","initialContainerWidthRef","useRef","bodyClasses","setBodyClasses","clearerRef","useBlockSelectionClearer","before","writingFlowRef","after","useWritingFlow","contentResizeListener","height","contentHeight","useResizeObserver","containerResizeListener","width","containerWidth","setRef","node","_load","iFrameDocument","preventFileDropDefault","onLoad","ownerDocument","classList","add","Array","from","body","filter","startsWith","dir","compatStyle","getCompatibilityStyles","getElementById","id","head","appendChild","cloneNode","console","warn","target","tagName","href","getAttribute","location","hash","slice","iframeWindowInnerHeight","setIframeWindowInnerHeight","iframeResizeRef","nodeWindow","innerHeight","onResize","windowInnerWidth","setWindowInnerWidth","windowResizeRef","innerWidth","isZoomedOut","useEffect","current","scaleContainerWidth","Math","max","disabledRef","useDisabled","isDisabled","bodyRef","useMergeRefs","origin","src","cleanup","useMemo","_src","URL","createObjectURL","Blob","revokeObjectURL","zoomOutAnimationClassnameRef","handleZoomOutAnimationClassname","clearTimeout","setTimeout","remove","maxWidth","style","setProperty","min","parseInt","removeProperty","shouldRenderFocusCaptureElements","iframe","jsxs","Fragment","jsx","border","onKeyDown","currentTarget","stopPropagation","nativeEvent","KeyboardEvent","createPortal","className","clsx","__experimentalStyleProvider","document","IframeIfReady","isInitialised","__internalIsInitialized","_default","exports","default","forwardRef"],"sources":["@wordpress/block-editor/src/components/iframe/index.js"],"sourcesContent":["/**\n * External dependencies\n */\nimport clsx from 'clsx';\n\n/**\n * WordPress dependencies\n */\nimport {\n\tuseState,\n\tcreatePortal,\n\tforwardRef,\n\tuseMemo,\n\tuseEffect,\n\tuseRef,\n} from '@wordpress/element';\nimport { __ } from '@wordpress/i18n';\nimport {\n\tuseResizeObserver,\n\tuseMergeRefs,\n\tuseRefEffect,\n\tuseDisabled,\n} from '@wordpress/compose';\nimport { __experimentalStyleProvider as StyleProvider } from '@wordpress/components';\nimport { useSelect } from '@wordpress/data';\n\n/**\n * Internal dependencies\n */\nimport { useBlockSelectionClearer } from '../block-selection-clearer';\nimport { useWritingFlow } from '../writing-flow';\nimport { getCompatibilityStyles } from './get-compatibility-styles';\nimport { store as blockEditorStore } from '../../store';\n\nfunction bubbleEvent( event, Constructor, frame ) {\n\tconst init = {};\n\n\tfor ( const key in event ) {\n\t\tinit[ key ] = event[ key ];\n\t}\n\n\t// Check if the event is a MouseEvent generated within the iframe.\n\t// If so, adjust the coordinates to be relative to the position of\n\t// the iframe. This ensures that components such as Draggable\n\t// receive coordinates relative to the window, instead of relative\n\t// to the iframe. Without this, the Draggable event handler would\n\t// result in components \"jumping\" position as soon as the user\n\t// drags over the iframe.\n\tif ( event instanceof frame.contentDocument.defaultView.MouseEvent ) {\n\t\tconst rect = frame.getBoundingClientRect();\n\t\tinit.clientX += rect.left;\n\t\tinit.clientY += rect.top;\n\t}\n\n\tconst newEvent = new Constructor( event.type, init );\n\tif ( init.defaultPrevented ) {\n\t\tnewEvent.preventDefault();\n\t}\n\tconst cancelled = ! frame.dispatchEvent( newEvent );\n\n\tif ( cancelled ) {\n\t\tevent.preventDefault();\n\t}\n}\n\n/**\n * Bubbles some event types (keydown, keypress, and dragover) to parent document\n * document to ensure that the keyboard shortcuts and drag and drop work.\n *\n * Ideally, we should remove event bubbling in the future. Keyboard shortcuts\n * should be context dependent, e.g. actions on blocks like Cmd+A should not\n * work globally outside the block editor.\n *\n * @param {Document} iframeDocument Document to attach listeners to.\n */\nfunction useBubbleEvents( iframeDocument ) {\n\treturn useRefEffect( () => {\n\t\tconst { defaultView } = iframeDocument;\n\t\tif ( ! defaultView ) {\n\t\t\treturn;\n\t\t}\n\t\tconst { frameElement } = defaultView;\n\t\tconst html = iframeDocument.documentElement;\n\t\tconst eventTypes = [ 'dragover', 'mousemove' ];\n\t\tconst handlers = {};\n\t\tfor ( const name of eventTypes ) {\n\t\t\thandlers[ name ] = ( event ) => {\n\t\t\t\tconst prototype = Object.getPrototypeOf( event );\n\t\t\t\tconst constructorName = prototype.constructor.name;\n\t\t\t\tconst Constructor = window[ constructorName ];\n\t\t\t\tbubbleEvent( event, Constructor, frameElement );\n\t\t\t};\n\t\t\thtml.addEventListener( name, handlers[ name ] );\n\t\t}\n\n\t\treturn () => {\n\t\t\tfor ( const name of eventTypes ) {\n\t\t\t\thtml.removeEventListener( name, handlers[ name ] );\n\t\t\t}\n\t\t};\n\t} );\n}\n\nfunction Iframe( {\n\tcontentRef,\n\tchildren,\n\ttabIndex = 0,\n\tscale = 1,\n\tframeSize = 0,\n\treadonly,\n\tforwardedRef: ref,\n\ttitle = __( 'Editor canvas' ),\n\t...props\n} ) {\n\tconst { resolvedAssets, isPreviewMode } = useSelect( ( select ) => {\n\t\tconst { getSettings } = select( blockEditorStore );\n\t\tconst settings = getSettings();\n\t\treturn {\n\t\t\tresolvedAssets: settings.__unstableResolvedAssets,\n\t\t\tisPreviewMode: settings.isPreviewMode,\n\t\t};\n\t}, [] );\n\tconst { styles = '', scripts = '' } = resolvedAssets;\n\tconst [ iframeDocument, setIframeDocument ] = useState();\n\tconst initialContainerWidthRef = useRef( 0 );\n\tconst [ bodyClasses, setBodyClasses ] = useState( [] );\n\tconst clearerRef = useBlockSelectionClearer();\n\tconst [ before, writingFlowRef, after ] = useWritingFlow();\n\tconst [ contentResizeListener, { height: contentHeight } ] =\n\t\tuseResizeObserver();\n\tconst [ containerResizeListener, { width: containerWidth } ] =\n\t\tuseResizeObserver();\n\n\tconst setRef = useRefEffect( ( node ) => {\n\t\tnode._load = () => {\n\t\t\tsetIframeDocument( node.contentDocument );\n\t\t};\n\t\tlet iFrameDocument;\n\t\t// Prevent the default browser action for files dropped outside of dropzones.\n\t\tfunction preventFileDropDefault( event ) {\n\t\t\tevent.preventDefault();\n\t\t}\n\t\tfunction onLoad() {\n\t\t\tconst { contentDocument, ownerDocument } = node;\n\t\t\tconst { documentElement } = contentDocument;\n\t\t\tiFrameDocument = contentDocument;\n\n\t\t\tdocumentElement.classList.add( 'block-editor-iframe__html' );\n\n\t\t\tclearerRef( documentElement );\n\n\t\t\t// Ideally ALL classes that are added through get_body_class should\n\t\t\t// be added in the editor too, which we'll somehow have to get from\n\t\t\t// the server in the future (which will run the PHP filters).\n\t\t\tsetBodyClasses(\n\t\t\t\tArray.from( ownerDocument.body.classList ).filter(\n\t\t\t\t\t( name ) =>\n\t\t\t\t\t\tname.startsWith( 'admin-color-' ) ||\n\t\t\t\t\t\tname.startsWith( 'post-type-' ) ||\n\t\t\t\t\t\tname === 'wp-embed-responsive'\n\t\t\t\t)\n\t\t\t);\n\n\t\t\tcontentDocument.dir = ownerDocument.dir;\n\n\t\t\tfor ( const compatStyle of getCompatibilityStyles() ) {\n\t\t\t\tif ( contentDocument.getElementById( compatStyle.id ) ) {\n\t\t\t\t\tcontinue;\n\t\t\t\t}\n\n\t\t\t\tcontentDocument.head.appendChild(\n\t\t\t\t\tcompatStyle.cloneNode( true )\n\t\t\t\t);\n\n\t\t\t\tif ( ! isPreviewMode ) {\n\t\t\t\t\t// eslint-disable-next-line no-console\n\t\t\t\t\tconsole.warn(\n\t\t\t\t\t\t`${ compatStyle.id } was added to the iframe incorrectly. Please use block.json or enqueue_block_assets to add styles to the iframe.`,\n\t\t\t\t\t\tcompatStyle\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tiFrameDocument.addEventListener(\n\t\t\t\t'dragover',\n\t\t\t\tpreventFileDropDefault,\n\t\t\t\tfalse\n\t\t\t);\n\t\t\tiFrameDocument.addEventListener(\n\t\t\t\t'drop',\n\t\t\t\tpreventFileDropDefault,\n\t\t\t\tfalse\n\t\t\t);\n\t\t\t// Prevent clicks on links from navigating away. Note that links\n\t\t\t// inside `contenteditable` are already disabled by the browser, so\n\t\t\t// this is for links in blocks outside of `contenteditable`.\n\t\t\tiFrameDocument.addEventListener( 'click', ( event ) => {\n\t\t\t\tif ( event.target.tagName === 'A' ) {\n\t\t\t\t\tevent.preventDefault();\n\n\t\t\t\t\t// Appending a hash to the current URL will not reload the\n\t\t\t\t\t// page. This is useful for e.g. footnotes.\n\t\t\t\t\tconst href = event.target.getAttribute( 'href' );\n\t\t\t\t\tif ( href.startsWith( '#' ) ) {\n\t\t\t\t\t\tiFrameDocument.defaultView.location.hash =\n\t\t\t\t\t\t\thref.slice( 1 );\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t} );\n\t\t}\n\n\t\tnode.addEventListener( 'load', onLoad );\n\n\t\treturn () => {\n\t\t\tdelete node._load;\n\t\t\tnode.removeEventListener( 'load', onLoad );\n\t\t\tiFrameDocument?.removeEventListener(\n\t\t\t\t'dragover',\n\t\t\t\tpreventFileDropDefault\n\t\t\t);\n\t\t\tiFrameDocument?.removeEventListener(\n\t\t\t\t'drop',\n\t\t\t\tpreventFileDropDefault\n\t\t\t);\n\t\t};\n\t}, [] );\n\n\tconst [ iframeWindowInnerHeight, setIframeWindowInnerHeight ] = useState();\n\n\tconst iframeResizeRef = useRefEffect( ( node ) => {\n\t\tconst nodeWindow = node.ownerDocument.defaultView;\n\n\t\tsetIframeWindowInnerHeight( nodeWindow.innerHeight );\n\t\tconst onResize = () => {\n\t\t\tsetIframeWindowInnerHeight( nodeWindow.innerHeight );\n\t\t};\n\t\tnodeWindow.addEventListener( 'resize', onResize );\n\t\treturn () => {\n\t\t\tnodeWindow.removeEventListener( 'resize', onResize );\n\t\t};\n\t}, [] );\n\n\tconst [ windowInnerWidth, setWindowInnerWidth ] = useState();\n\n\tconst windowResizeRef = useRefEffect( ( node ) => {\n\t\tconst nodeWindow = node.ownerDocument.defaultView;\n\n\t\tsetWindowInnerWidth( nodeWindow.innerWidth );\n\t\tconst onResize = () => {\n\t\t\tsetWindowInnerWidth( nodeWindow.innerWidth );\n\t\t};\n\t\tnodeWindow.addEventListener( 'resize', onResize );\n\t\treturn () => {\n\t\t\tnodeWindow.removeEventListener( 'resize', onResize );\n\t\t};\n\t}, [] );\n\n\tconst isZoomedOut = scale !== 1;\n\n\tuseEffect( () => {\n\t\tif ( ! isZoomedOut ) {\n\t\t\tinitialContainerWidthRef.current = containerWidth;\n\t\t}\n\t}, [ containerWidth, isZoomedOut ] );\n\n\tconst scaleContainerWidth = Math.max(\n\t\tinitialContainerWidthRef.current,\n\t\tcontainerWidth\n\t);\n\n\tconst disabledRef = useDisabled( { isDisabled: ! readonly } );\n\tconst bodyRef = useMergeRefs( [\n\t\tuseBubbleEvents( iframeDocument ),\n\t\tcontentRef,\n\t\tclearerRef,\n\t\twritingFlowRef,\n\t\tdisabledRef,\n\t\t// Avoid resize listeners when not needed, these will trigger\n\t\t// unnecessary re-renders when animating the iframe width, or when\n\t\t// expanding preview iframes.\n\t\tisZoomedOut ? iframeResizeRef : null,\n\t] );\n\n\t// Correct doctype is required to enable rendering in standards\n\t// mode. Also preload the styles to avoid a flash of unstyled\n\t// content.\n\tconst html = `<!doctype html>\n<html>\n\t<head>\n\t\t<meta charset=\"utf-8\">\n\t\t<base href=\"${ window.location.origin }\">\n\t\t<script>window.frameElement._load()</script>\n\t\t<style>\n\t\t\thtml{\n\t\t\t\theight: auto !important;\n\t\t\t\tmin-height: 100%;\n\t\t\t}\n\t\t\t/* Lowest specificity to not override global styles */\n\t\t\t:where(body) {\n\t\t\t\tmargin: 0;\n\t\t\t\t/* Default background color in case zoom out mode background\n\t\t\t\tcolors the html element */\n\t\t\t\tbackground-color: white;\n\t\t\t}\n\t\t</style>\n\t\t${ styles }\n\t\t${ scripts }\n\t</head>\n\t<body>\n\t\t<script>document.currentScript.parentElement.remove()</script>\n\t</body>\n</html>`;\n\n\tconst [ src, cleanup ] = useMemo( () => {\n\t\tconst _src = URL.createObjectURL(\n\t\t\tnew window.Blob( [ html ], { type: 'text/html' } )\n\t\t);\n\t\treturn [ _src, () => URL.revokeObjectURL( _src ) ];\n\t}, [ html ] );\n\n\tuseEffect( () => cleanup, [ cleanup ] );\n\n\tconst zoomOutAnimationClassnameRef = useRef( null );\n\n\t// Toggle zoom out CSS Classes only when zoom out mode changes. We could add these into the useEffect\n\t// that controls settings the CSS variables, but then we would need to do more work to ensure we're\n\t// only toggling these when the zoom out mode changes, as that useEffect is also triggered by a large\n\t// number of dependencies.\n\tuseEffect( () => {\n\t\tif ( ! iframeDocument || ! isZoomedOut ) {\n\t\t\treturn;\n\t\t}\n\n\t\tconst handleZoomOutAnimationClassname = () => {\n\t\t\tclearTimeout( zoomOutAnimationClassnameRef.current );\n\n\t\t\tiframeDocument.documentElement.classList.add(\n\t\t\t\t'zoom-out-animation'\n\t\t\t);\n\n\t\t\tzoomOutAnimationClassnameRef.current = setTimeout( () => {\n\t\t\t\tiframeDocument.documentElement.classList.remove(\n\t\t\t\t\t'zoom-out-animation'\n\t\t\t\t);\n\t\t\t}, 400 ); // 400ms should match the animation speed used in components/iframe/content.scss\n\t\t};\n\n\t\thandleZoomOutAnimationClassname();\n\t\tiframeDocument.documentElement.classList.add( 'is-zoomed-out' );\n\n\t\treturn () => {\n\t\t\thandleZoomOutAnimationClassname();\n\t\t\tiframeDocument.documentElement.classList.remove( 'is-zoomed-out' );\n\t\t};\n\t}, [ iframeDocument, isZoomedOut ] );\n\n\t// Calculate the scaling and CSS variables for the zoom out canvas\n\tuseEffect( () => {\n\t\tif ( ! iframeDocument || ! isZoomedOut ) {\n\t\t\treturn;\n\t\t}\n\n\t\tconst maxWidth = 750;\n\t\t// Note: When we initialize the zoom out when the canvas is smaller (sidebars open),\n\t\t// initialContainerWidthRef will be smaller than the full page, and reflow will happen\n\t\t// when the canvas area becomes larger due to sidebars closing. This is a known but\n\t\t// minor divergence for now.\n\n\t\t// This scaling calculation has to happen within the JS because CSS calc() can\n\t\t// only divide and multiply by a unitless value. I.e. calc( 100px / 2 ) is valid\n\t\t// but calc( 100px / 2px ) is not.\n\t\tiframeDocument.documentElement.style.setProperty(\n\t\t\t'--wp-block-editor-iframe-zoom-out-scale',\n\t\t\tscale === 'auto-scaled'\n\t\t\t\t? ( Math.min( containerWidth, maxWidth ) -\n\t\t\t\t\t\tparseInt( frameSize ) * 2 ) /\n\t\t\t\t\t\tscaleContainerWidth\n\t\t\t\t: scale\n\t\t);\n\n\t\t// frameSize has to be a px value for the scaling and frame size to be computed correctly.\n\t\tiframeDocument.documentElement.style.setProperty(\n\t\t\t'--wp-block-editor-iframe-zoom-out-frame-size',\n\t\t\ttypeof frameSize === 'number' ? `${ frameSize }px` : frameSize\n\t\t);\n\t\tiframeDocument.documentElement.style.setProperty(\n\t\t\t'--wp-block-editor-iframe-zoom-out-content-height',\n\t\t\t`${ contentHeight }px`\n\t\t);\n\t\tiframeDocument.documentElement.style.setProperty(\n\t\t\t'--wp-block-editor-iframe-zoom-out-inner-height',\n\t\t\t`${ iframeWindowInnerHeight }px`\n\t\t);\n\t\tiframeDocument.documentElement.style.setProperty(\n\t\t\t'--wp-block-editor-iframe-zoom-out-container-width',\n\t\t\t`${ containerWidth }px`\n\t\t);\n\t\tiframeDocument.documentElement.style.setProperty(\n\t\t\t'--wp-block-editor-iframe-zoom-out-scale-container-width',\n\t\t\t`${ scaleContainerWidth }px`\n\t\t);\n\n\t\treturn () => {\n\t\t\tiframeDocument.documentElement.style.removeProperty(\n\t\t\t\t'--wp-block-editor-iframe-zoom-out-scale'\n\t\t\t);\n\t\t\tiframeDocument.documentElement.style.removeProperty(\n\t\t\t\t'--wp-block-editor-iframe-zoom-out-frame-size'\n\t\t\t);\n\t\t\tiframeDocument.documentElement.style.removeProperty(\n\t\t\t\t'--wp-block-editor-iframe-zoom-out-content-height'\n\t\t\t);\n\t\t\tiframeDocument.documentElement.style.removeProperty(\n\t\t\t\t'--wp-block-editor-iframe-zoom-out-inner-height'\n\t\t\t);\n\t\t\tiframeDocument.documentElement.style.removeProperty(\n\t\t\t\t'--wp-block-editor-iframe-zoom-out-container-width'\n\t\t\t);\n\t\t\tiframeDocument.documentElement.style.removeProperty(\n\t\t\t\t'--wp-block-editor-iframe-zoom-out-scale-container-width'\n\t\t\t);\n\t\t};\n\t}, [\n\t\tscale,\n\t\tframeSize,\n\t\tiframeDocument,\n\t\tiframeWindowInnerHeight,\n\t\tcontentHeight,\n\t\tcontainerWidth,\n\t\twindowInnerWidth,\n\t\tisZoomedOut,\n\t\tscaleContainerWidth,\n\t] );\n\n\t// Make sure to not render the before and after focusable div elements in view\n\t// mode. They're only needed to capture focus in edit mode.\n\tconst shouldRenderFocusCaptureElements = tabIndex >= 0 && ! isPreviewMode;\n\n\tconst iframe = (\n\t\t<>\n\t\t\t{ shouldRenderFocusCaptureElements && before }\n\t\t\t{ /* eslint-disable-next-line jsx-a11y/no-noninteractive-element-interactions */ }\n\t\t\t<iframe\n\t\t\t\t{ ...props }\n\t\t\t\tstyle={ {\n\t\t\t\t\t...props.style,\n\t\t\t\t\theight: props.style?.height,\n\t\t\t\t\tborder: 0,\n\t\t\t\t} }\n\t\t\t\tref={ useMergeRefs( [ ref, setRef ] ) }\n\t\t\t\ttabIndex={ tabIndex }\n\t\t\t\t// Correct doctype is required to enable rendering in standards\n\t\t\t\t// mode. Also preload the styles to avoid a flash of unstyled\n\t\t\t\t// content.\n\t\t\t\tsrc={ src }\n\t\t\t\ttitle={ title }\n\t\t\t\tonKeyDown={ ( event ) => {\n\t\t\t\t\tif ( props.onKeyDown ) {\n\t\t\t\t\t\tprops.onKeyDown( event );\n\t\t\t\t\t}\n\t\t\t\t\t// If the event originates from inside the iframe, it means\n\t\t\t\t\t// it bubbled through the portal, but only with React\n\t\t\t\t\t// events. We need to to bubble native events as well,\n\t\t\t\t\t// though by doing so we also trigger another React event,\n\t\t\t\t\t// so we need to stop the propagation of this event to avoid\n\t\t\t\t\t// duplication.\n\t\t\t\t\tif (\n\t\t\t\t\t\tevent.currentTarget.ownerDocument !==\n\t\t\t\t\t\tevent.target.ownerDocument\n\t\t\t\t\t) {\n\t\t\t\t\t\t// We should only stop propagation of the React event,\n\t\t\t\t\t\t// the native event should further bubble inside the\n\t\t\t\t\t\t// iframe to the document and window.\n\t\t\t\t\t\t// Alternatively, we could consider redispatching the\n\t\t\t\t\t\t// native event in the iframe.\n\t\t\t\t\t\tconst { stopPropagation } = event.nativeEvent;\n\t\t\t\t\t\tevent.nativeEvent.stopPropagation = () => {};\n\t\t\t\t\t\tevent.stopPropagation();\n\t\t\t\t\t\tevent.nativeEvent.stopPropagation = stopPropagation;\n\t\t\t\t\t\tbubbleEvent(\n\t\t\t\t\t\t\tevent,\n\t\t\t\t\t\t\twindow.KeyboardEvent,\n\t\t\t\t\t\t\tevent.currentTarget\n\t\t\t\t\t\t);\n\t\t\t\t\t}\n\t\t\t\t} }\n\t\t\t>\n\t\t\t\t{ iframeDocument &&\n\t\t\t\t\tcreatePortal(\n\t\t\t\t\t\t// We want to prevent React events from bubbling throught the iframe\n\t\t\t\t\t\t// we bubble these manually.\n\t\t\t\t\t\t/* eslint-disable-next-line jsx-a11y/no-noninteractive-element-interactions */\n\t\t\t\t\t\t<body\n\t\t\t\t\t\t\tref={ bodyRef }\n\t\t\t\t\t\t\tclassName={ clsx(\n\t\t\t\t\t\t\t\t'block-editor-iframe__body',\n\t\t\t\t\t\t\t\t'editor-styles-wrapper',\n\t\t\t\t\t\t\t\t...bodyClasses\n\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t>\n\t\t\t\t\t\t\t{ contentResizeListener }\n\t\t\t\t\t\t\t<StyleProvider document={ iframeDocument }>\n\t\t\t\t\t\t\t\t{ children }\n\t\t\t\t\t\t\t</StyleProvider>\n\t\t\t\t\t\t</body>,\n\t\t\t\t\t\tiframeDocument.documentElement\n\t\t\t\t\t) }\n\t\t\t</iframe>\n\t\t\t{ shouldRenderFocusCaptureElements && after }\n\t\t</>\n\t);\n\n\treturn (\n\t\t<div className=\"block-editor-iframe__container\" ref={ windowResizeRef }>\n\t\t\t{ containerResizeListener }\n\t\t\t<div\n\t\t\t\tclassName={ clsx(\n\t\t\t\t\t'block-editor-iframe__scale-container',\n\t\t\t\t\tisZoomedOut && 'is-zoomed-out'\n\t\t\t\t) }\n\t\t\t\tstyle={ {\n\t\t\t\t\t'--wp-block-editor-iframe-zoom-out-scale-container-width':\n\t\t\t\t\t\tisZoomedOut && `${ scaleContainerWidth }px`,\n\t\t\t\t} }\n\t\t\t>\n\t\t\t\t{ iframe }\n\t\t\t</div>\n\t\t</div>\n\t);\n}\n\nfunction IframeIfReady( props, ref ) {\n\tconst isInitialised = useSelect(\n\t\t( select ) =>\n\t\t\tselect( blockEditorStore ).getSettings().__internalIsInitialized,\n\t\t[]\n\t);\n\n\t// We shouldn't render the iframe until the editor settings are initialised.\n\t// The initial settings are needed to get the styles for the srcDoc, which\n\t// cannot be changed after the iframe is mounted. srcDoc is used to to set\n\t// the initial iframe HTML, which is required to avoid a flash of unstyled\n\t// content.\n\tif ( ! isInitialised ) {\n\t\treturn null;\n\t}\n\n\treturn <Iframe { ...props } forwardedRef={ ref } />;\n}\n\nexport default forwardRef( IframeIfReady );\n"],"mappings":";;;;;;;;AAGA,IAAAA,KAAA,GAAAC,sBAAA,CAAAC,OAAA;AAKA,IAAAC,QAAA,GAAAD,OAAA;AAQA,IAAAE,KAAA,GAAAF,OAAA;AACA,IAAAG,QAAA,GAAAH,OAAA;AAMA,IAAAI,WAAA,GAAAJ,OAAA;AACA,IAAAK,KAAA,GAAAL,OAAA;AAKA,IAAAM,sBAAA,GAAAN,OAAA;AACA,IAAAO,YAAA,GAAAP,OAAA;AACA,IAAAQ,uBAAA,GAAAR,OAAA;AACA,IAAAS,MAAA,GAAAT,OAAA;AAAwD,IAAAU,WAAA,GAAAV,OAAA;AAhCxD;AACA;AACA;;AAGA;AACA;AACA;;AAmBA;AACA;AACA;;AAMA,SAASW,WAAWA,CAAEC,KAAK,EAAEC,WAAW,EAAEC,KAAK,EAAG;EACjD,MAAMC,IAAI,GAAG,CAAC,CAAC;EAEf,KAAM,MAAMC,GAAG,IAAIJ,KAAK,EAAG;IAC1BG,IAAI,CAAEC,GAAG,CAAE,GAAGJ,KAAK,CAAEI,GAAG,CAAE;EAC3B;;EAEA;EACA;EACA;EACA;EACA;EACA;EACA;EACA,IAAKJ,KAAK,YAAYE,KAAK,CAACG,eAAe,CAACC,WAAW,CAACC,UAAU,EAAG;IACpE,MAAMC,IAAI,GAAGN,KAAK,CAACO,qBAAqB,CAAC,CAAC;IAC1CN,IAAI,CAACO,OAAO,IAAIF,IAAI,CAACG,IAAI;IACzBR,IAAI,CAACS,OAAO,IAAIJ,IAAI,CAACK,GAAG;EACzB;EAEA,MAAMC,QAAQ,GAAG,I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ChB;IAAC,CACK,CAAC,EACP6H,gCAAgC,IAAIjF,KAAK;EAAA,CAC1C,CACF;EAED,oBACC,IAAAvE,WAAA,CAAA0J,IAAA;IAAKU,SAAS,EAAC,gCAAgC;IAACrH,GAAG,EAAGwE,eAAiB;IAAA9E,QAAA,GACpEoC,uBAAuB,eACzB,IAAA7E,WAAA,CAAA4J,GAAA;MACCQ,SAAS,EAAG,IAAAC,aAAI,EACf,sCAAsC,EACtC5C,WAAW,IAAI,eAChB,CAAG;MACH0B,KAAK,EAAG;QACP,yDAAyD,EACxD1B,WAAW,IAAI,GAAIG,mBAAmB;MACxC,CAAG;MAAAnF,QAAA,EAEDgH;IAAM,CACJ,CAAC;EAAA,CACF,CAAC;AAER;AAEA,SAASe,aAAaA,CAAEtH,KAAK,EAAEH,GAAG,EAAG;EACpC,MAAM0H,aAAa,GAAG,IAAApH,eAAS,EAC5BC,MAAM,IACPA,MAAM,CAAEE,YAAiB,CAAC,CAACD,WAAW,CAAC,CAAC,CAACmH,uBAAuB,EACjE,EACD,CAAC;;EAED;EACA;EACA;EACA;EACA;EACA,IAAK,CAAED,aAAa,EAAG;IACtB,OAAO,IAAI;EACZ;EAEA,oBAAO,IAAAzK,WAAA,CAAA4J,GAAA,EAACrH,MAAM;IAAA,GAAMW,KAAK;IAAGJ,YAAY,EAAGC;EAAK,CAAE,CAAC;AACpD;AAAC,IAAA4H,QAAA,GAAAC,OAAA,CAAAC,OAAA,GAEc,IAAAC,mBAAU,EAAEN,aAAc,CAAC","ignoreList":[]}
1
+ {"version":3,"names":["_clsx","_interopRequireDefault","require","_element","_i18n","_compose","_components","_data","_blockSelectionClearer","_writingFlow","_getCompatibilityStyles","_useScaleCanvas","_store","_jsxRuntime","bubbleEvent","event","Constructor","frame","init","key","contentDocument","defaultView","MouseEvent","rect","getBoundingClientRect","clientX","left","clientY","top","newEvent","type","defaultPrevented","preventDefault","cancelled","dispatchEvent","useBubbleEvents","iframeDocument","useRefEffect","frameElement","html","documentElement","eventTypes","handlers","name","prototype","Object","getPrototypeOf","constructorName","constructor","window","addEventListener","removeEventListener","Iframe","contentRef","children","tabIndex","scale","frameSize","readonly","forwardedRef","ref","title","__","props","resolvedAssets","isPreviewMode","useSelect","select","getSettings","blockEditorStore","settings","__unstableResolvedAssets","styles","scripts","setIframeDocument","useState","bodyClasses","setBodyClasses","clearerRef","useBlockSelectionClearer","before","writingFlowRef","after","useWritingFlow","setRef","node","_load","iFrameDocument","preventFileDropDefault","onLoad","ownerDocument","classList","add","Array","from","body","filter","startsWith","dir","compatStyle","getCompatibilityStyles","getElementById","id","head","appendChild","cloneNode","console","warn","target","tagName","href","getAttribute","location","hash","slice","contentResizeListener","containerResizeListener","isZoomedOut","scaleContainerWidth","useScaleCanvas","parseInt","disabledRef","useDisabled","isDisabled","bodyRef","useMergeRefs","origin","src","cleanup","useMemo","_src","URL","createObjectURL","Blob","revokeObjectURL","useEffect","shouldRenderFocusCaptureElements","iframe","jsxs","Fragment","jsx","style","height","border","onKeyDown","currentTarget","stopPropagation","nativeEvent","KeyboardEvent","createPortal","className","clsx","__experimentalStyleProvider","document","IframeIfReady","isInitialised","__internalIsInitialized","_default","exports","default","forwardRef"],"sources":["@wordpress/block-editor/src/components/iframe/index.js"],"sourcesContent":["/**\n * External dependencies\n */\nimport clsx from 'clsx';\n\n/**\n * WordPress dependencies\n */\nimport {\n\tuseState,\n\tcreatePortal,\n\tforwardRef,\n\tuseMemo,\n\tuseEffect,\n} from '@wordpress/element';\nimport { __ } from '@wordpress/i18n';\nimport { useMergeRefs, useRefEffect, useDisabled } from '@wordpress/compose';\nimport { __experimentalStyleProvider as StyleProvider } from '@wordpress/components';\nimport { useSelect } from '@wordpress/data';\n\n/**\n * Internal dependencies\n */\nimport { useBlockSelectionClearer } from '../block-selection-clearer';\nimport { useWritingFlow } from '../writing-flow';\nimport { getCompatibilityStyles } from './get-compatibility-styles';\nimport { useScaleCanvas } from './use-scale-canvas';\nimport { store as blockEditorStore } from '../../store';\n\nfunction bubbleEvent( event, Constructor, frame ) {\n\tconst init = {};\n\n\tfor ( const key in event ) {\n\t\tinit[ key ] = event[ key ];\n\t}\n\n\t// Check if the event is a MouseEvent generated within the iframe.\n\t// If so, adjust the coordinates to be relative to the position of\n\t// the iframe. This ensures that components such as Draggable\n\t// receive coordinates relative to the window, instead of relative\n\t// to the iframe. Without this, the Draggable event handler would\n\t// result in components \"jumping\" position as soon as the user\n\t// drags over the iframe.\n\tif ( event instanceof frame.contentDocument.defaultView.MouseEvent ) {\n\t\tconst rect = frame.getBoundingClientRect();\n\t\tinit.clientX += rect.left;\n\t\tinit.clientY += rect.top;\n\t}\n\n\tconst newEvent = new Constructor( event.type, init );\n\tif ( init.defaultPrevented ) {\n\t\tnewEvent.preventDefault();\n\t}\n\tconst cancelled = ! frame.dispatchEvent( newEvent );\n\n\tif ( cancelled ) {\n\t\tevent.preventDefault();\n\t}\n}\n\n/**\n * Bubbles some event types (keydown, keypress, and dragover) to parent document\n * document to ensure that the keyboard shortcuts and drag and drop work.\n *\n * Ideally, we should remove event bubbling in the future. Keyboard shortcuts\n * should be context dependent, e.g. actions on blocks like Cmd+A should not\n * work globally outside the block editor.\n *\n * @param {Document} iframeDocument Document to attach listeners to.\n */\nfunction useBubbleEvents( iframeDocument ) {\n\treturn useRefEffect( () => {\n\t\tconst { defaultView } = iframeDocument;\n\t\tif ( ! defaultView ) {\n\t\t\treturn;\n\t\t}\n\t\tconst { frameElement } = defaultView;\n\t\tconst html = iframeDocument.documentElement;\n\t\tconst eventTypes = [ 'dragover', 'mousemove' ];\n\t\tconst handlers = {};\n\t\tfor ( const name of eventTypes ) {\n\t\t\thandlers[ name ] = ( event ) => {\n\t\t\t\tconst prototype = Object.getPrototypeOf( event );\n\t\t\t\tconst constructorName = prototype.constructor.name;\n\t\t\t\tconst Constructor = window[ constructorName ];\n\t\t\t\tbubbleEvent( event, Constructor, frameElement );\n\t\t\t};\n\t\t\thtml.addEventListener( name, handlers[ name ] );\n\t\t}\n\n\t\treturn () => {\n\t\t\tfor ( const name of eventTypes ) {\n\t\t\t\thtml.removeEventListener( name, handlers[ name ] );\n\t\t\t}\n\t\t};\n\t} );\n}\n\nfunction Iframe( {\n\tcontentRef,\n\tchildren,\n\ttabIndex = 0,\n\tscale = 1,\n\tframeSize = 0,\n\treadonly,\n\tforwardedRef: ref,\n\ttitle = __( 'Editor canvas' ),\n\t...props\n} ) {\n\tconst { resolvedAssets, isPreviewMode } = useSelect( ( select ) => {\n\t\tconst { getSettings } = select( blockEditorStore );\n\t\tconst settings = getSettings();\n\t\treturn {\n\t\t\tresolvedAssets: settings.__unstableResolvedAssets,\n\t\t\tisPreviewMode: settings.isPreviewMode,\n\t\t};\n\t}, [] );\n\tconst { styles = '', scripts = '' } = resolvedAssets;\n\t/** @type {[Document, import('react').Dispatch<Document>]} */\n\tconst [ iframeDocument, setIframeDocument ] = useState();\n\tconst [ bodyClasses, setBodyClasses ] = useState( [] );\n\tconst clearerRef = useBlockSelectionClearer();\n\tconst [ before, writingFlowRef, after ] = useWritingFlow();\n\n\tconst setRef = useRefEffect( ( node ) => {\n\t\tnode._load = () => {\n\t\t\tsetIframeDocument( node.contentDocument );\n\t\t};\n\t\tlet iFrameDocument;\n\t\t// Prevent the default browser action for files dropped outside of dropzones.\n\t\tfunction preventFileDropDefault( event ) {\n\t\t\tevent.preventDefault();\n\t\t}\n\t\tfunction onLoad() {\n\t\t\tconst { contentDocument, ownerDocument } = node;\n\t\t\tconst { documentElement } = contentDocument;\n\t\t\tiFrameDocument = contentDocument;\n\n\t\t\tdocumentElement.classList.add( 'block-editor-iframe__html' );\n\n\t\t\tclearerRef( documentElement );\n\n\t\t\t// Ideally ALL classes that are added through get_body_class should\n\t\t\t// be added in the editor too, which we'll somehow have to get from\n\t\t\t// the server in the future (which will run the PHP filters).\n\t\t\tsetBodyClasses(\n\t\t\t\tArray.from( ownerDocument.body.classList ).filter(\n\t\t\t\t\t( name ) =>\n\t\t\t\t\t\tname.startsWith( 'admin-color-' ) ||\n\t\t\t\t\t\tname.startsWith( 'post-type-' ) ||\n\t\t\t\t\t\tname === 'wp-embed-responsive'\n\t\t\t\t)\n\t\t\t);\n\n\t\t\tcontentDocument.dir = ownerDocument.dir;\n\n\t\t\tfor ( const compatStyle of getCompatibilityStyles() ) {\n\t\t\t\tif ( contentDocument.getElementById( compatStyle.id ) ) {\n\t\t\t\t\tcontinue;\n\t\t\t\t}\n\n\t\t\t\tcontentDocument.head.appendChild(\n\t\t\t\t\tcompatStyle.cloneNode( true )\n\t\t\t\t);\n\n\t\t\t\tif ( ! isPreviewMode ) {\n\t\t\t\t\t// eslint-disable-next-line no-console\n\t\t\t\t\tconsole.warn(\n\t\t\t\t\t\t`${ compatStyle.id } was added to the iframe incorrectly. Please use block.json or enqueue_block_assets to add styles to the iframe.`,\n\t\t\t\t\t\tcompatStyle\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tiFrameDocument.addEventListener(\n\t\t\t\t'dragover',\n\t\t\t\tpreventFileDropDefault,\n\t\t\t\tfalse\n\t\t\t);\n\t\t\tiFrameDocument.addEventListener(\n\t\t\t\t'drop',\n\t\t\t\tpreventFileDropDefault,\n\t\t\t\tfalse\n\t\t\t);\n\t\t\t// Prevent clicks on links from navigating away. Note that links\n\t\t\t// inside `contenteditable` are already disabled by the browser, so\n\t\t\t// this is for links in blocks outside of `contenteditable`.\n\t\t\tiFrameDocument.addEventListener( 'click', ( event ) => {\n\t\t\t\tif ( event.target.tagName === 'A' ) {\n\t\t\t\t\tevent.preventDefault();\n\n\t\t\t\t\t// Appending a hash to the current URL will not reload the\n\t\t\t\t\t// page. This is useful for e.g. footnotes.\n\t\t\t\t\tconst href = event.target.getAttribute( 'href' );\n\t\t\t\t\tif ( href.startsWith( '#' ) ) {\n\t\t\t\t\t\tiFrameDocument.defaultView.location.hash =\n\t\t\t\t\t\t\thref.slice( 1 );\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t} );\n\t\t}\n\n\t\tnode.addEventListener( 'load', onLoad );\n\n\t\treturn () => {\n\t\t\tdelete node._load;\n\t\t\tnode.removeEventListener( 'load', onLoad );\n\t\t\tiFrameDocument?.removeEventListener(\n\t\t\t\t'dragover',\n\t\t\t\tpreventFileDropDefault\n\t\t\t);\n\t\t\tiFrameDocument?.removeEventListener(\n\t\t\t\t'drop',\n\t\t\t\tpreventFileDropDefault\n\t\t\t);\n\t\t};\n\t}, [] );\n\n\tconst {\n\t\tcontentResizeListener,\n\t\tcontainerResizeListener,\n\t\tisZoomedOut,\n\t\tscaleContainerWidth,\n\t} = useScaleCanvas( {\n\t\tscale,\n\t\tframeSize: parseInt( frameSize ),\n\t\tiframeDocument,\n\t} );\n\n\tconst disabledRef = useDisabled( { isDisabled: ! readonly } );\n\tconst bodyRef = useMergeRefs( [\n\t\tuseBubbleEvents( iframeDocument ),\n\t\tcontentRef,\n\t\tclearerRef,\n\t\twritingFlowRef,\n\t\tdisabledRef,\n\t] );\n\n\t// Correct doctype is required to enable rendering in standards\n\t// mode. Also preload the styles to avoid a flash of unstyled\n\t// content.\n\tconst html = `<!doctype html>\n<html>\n\t<head>\n\t\t<meta charset=\"utf-8\">\n\t\t<base href=\"${ window.location.origin }\">\n\t\t<script>window.frameElement._load()</script>\n\t\t<style>\n\t\t\thtml{\n\t\t\t\theight: auto !important;\n\t\t\t\tmin-height: 100%;\n\t\t\t}\n\t\t\t/* Lowest specificity to not override global styles */\n\t\t\t:where(body) {\n\t\t\t\tmargin: 0;\n\t\t\t\t/* Default background color in case zoom out mode background\n\t\t\t\tcolors the html element */\n\t\t\t\tbackground-color: white;\n\t\t\t}\n\t\t</style>\n\t\t${ styles }\n\t\t${ scripts }\n\t</head>\n\t<body>\n\t\t<script>document.currentScript.parentElement.remove()</script>\n\t</body>\n</html>`;\n\n\tconst [ src, cleanup ] = useMemo( () => {\n\t\tconst _src = URL.createObjectURL(\n\t\t\tnew window.Blob( [ html ], { type: 'text/html' } )\n\t\t);\n\t\treturn [ _src, () => URL.revokeObjectURL( _src ) ];\n\t}, [ html ] );\n\n\tuseEffect( () => cleanup, [ cleanup ] );\n\n\t// Make sure to not render the before and after focusable div elements in view\n\t// mode. They're only needed to capture focus in edit mode.\n\tconst shouldRenderFocusCaptureElements = tabIndex >= 0 && ! isPreviewMode;\n\n\tconst iframe = (\n\t\t<>\n\t\t\t{ shouldRenderFocusCaptureElements && before }\n\t\t\t{ /* eslint-disable-next-line jsx-a11y/no-noninteractive-element-interactions */ }\n\t\t\t<iframe\n\t\t\t\t{ ...props }\n\t\t\t\tstyle={ {\n\t\t\t\t\t...props.style,\n\t\t\t\t\theight: props.style?.height,\n\t\t\t\t\tborder: 0,\n\t\t\t\t} }\n\t\t\t\tref={ useMergeRefs( [ ref, setRef ] ) }\n\t\t\t\ttabIndex={ tabIndex }\n\t\t\t\t// Correct doctype is required to enable rendering in standards\n\t\t\t\t// mode. Also preload the styles to avoid a flash of unstyled\n\t\t\t\t// content.\n\t\t\t\tsrc={ src }\n\t\t\t\ttitle={ title }\n\t\t\t\tonKeyDown={ ( event ) => {\n\t\t\t\t\tif ( props.onKeyDown ) {\n\t\t\t\t\t\tprops.onKeyDown( event );\n\t\t\t\t\t}\n\t\t\t\t\t// If the event originates from inside the iframe, it means\n\t\t\t\t\t// it bubbled through the portal, but only with React\n\t\t\t\t\t// events. We need to to bubble native events as well,\n\t\t\t\t\t// though by doing so we also trigger another React event,\n\t\t\t\t\t// so we need to stop the propagation of this event to avoid\n\t\t\t\t\t// duplication.\n\t\t\t\t\tif (\n\t\t\t\t\t\tevent.currentTarget.ownerDocument !==\n\t\t\t\t\t\tevent.target.ownerDocument\n\t\t\t\t\t) {\n\t\t\t\t\t\t// We should only stop propagation of the React event,\n\t\t\t\t\t\t// the native event should further bubble inside the\n\t\t\t\t\t\t// iframe to the document and window.\n\t\t\t\t\t\t// Alternatively, we could consider redispatching the\n\t\t\t\t\t\t// native event in the iframe.\n\t\t\t\t\t\tconst { stopPropagation } = event.nativeEvent;\n\t\t\t\t\t\tevent.nativeEvent.stopPropagation = () => {};\n\t\t\t\t\t\tevent.stopPropagation();\n\t\t\t\t\t\tevent.nativeEvent.stopPropagation = stopPropagation;\n\t\t\t\t\t\tbubbleEvent(\n\t\t\t\t\t\t\tevent,\n\t\t\t\t\t\t\twindow.KeyboardEvent,\n\t\t\t\t\t\t\tevent.currentTarget\n\t\t\t\t\t\t);\n\t\t\t\t\t}\n\t\t\t\t} }\n\t\t\t>\n\t\t\t\t{ iframeDocument &&\n\t\t\t\t\tcreatePortal(\n\t\t\t\t\t\t// We want to prevent React events from bubbling throught the iframe\n\t\t\t\t\t\t// we bubble these manually.\n\t\t\t\t\t\t/* eslint-disable-next-line jsx-a11y/no-noninteractive-element-interactions */\n\t\t\t\t\t\t<body\n\t\t\t\t\t\t\tref={ bodyRef }\n\t\t\t\t\t\t\tclassName={ clsx(\n\t\t\t\t\t\t\t\t'block-editor-iframe__body',\n\t\t\t\t\t\t\t\t'editor-styles-wrapper',\n\t\t\t\t\t\t\t\t...bodyClasses\n\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t>\n\t\t\t\t\t\t\t{ contentResizeListener }\n\t\t\t\t\t\t\t<StyleProvider document={ iframeDocument }>\n\t\t\t\t\t\t\t\t{ children }\n\t\t\t\t\t\t\t</StyleProvider>\n\t\t\t\t\t\t</body>,\n\t\t\t\t\t\tiframeDocument.documentElement\n\t\t\t\t\t) }\n\t\t\t</iframe>\n\t\t\t{ shouldRenderFocusCaptureElements && after }\n\t\t</>\n\t);\n\n\treturn (\n\t\t<div className=\"block-editor-iframe__container\">\n\t\t\t{ containerResizeListener }\n\t\t\t<div\n\t\t\t\tclassName={ clsx(\n\t\t\t\t\t'block-editor-iframe__scale-container',\n\t\t\t\t\tisZoomedOut && 'is-zoomed-out'\n\t\t\t\t) }\n\t\t\t\tstyle={ {\n\t\t\t\t\t'--wp-block-editor-iframe-zoom-out-scale-container-width':\n\t\t\t\t\t\tisZoomedOut && `${ scaleContainerWidth }px`,\n\t\t\t\t} }\n\t\t\t>\n\t\t\t\t{ iframe }\n\t\t\t</div>\n\t\t</div>\n\t);\n}\n\nfunction IframeIfReady( props, ref ) {\n\tconst isInitialised = useSelect(\n\t\t( select ) =>\n\t\t\tselect( blockEditorStore ).getSettings().__internalIsInitialized,\n\t\t[]\n\t);\n\n\t// We shouldn't render the iframe until the editor settings are initialised.\n\t// The initial settings are needed to get the styles for the srcDoc, which\n\t// cannot be changed after the iframe is mounted. srcDoc is used to to set\n\t// the initial iframe HTML, which is required to avoid a flash of unstyled\n\t// content.\n\tif ( ! isInitialised ) {\n\t\treturn null;\n\t}\n\n\treturn <Iframe { ...props } forwardedRef={ ref } />;\n}\n\nexport default forwardRef( IframeIfReady );\n"],"mappings":";;;;;;;;AAGA,IAAAA,KAAA,GAAAC,sBAAA,CAAAC,OAAA;AAKA,IAAAC,QAAA,GAAAD,OAAA;AAOA,IAAAE,KAAA,GAAAF,OAAA;AACA,IAAAG,QAAA,GAAAH,OAAA;AACA,IAAAI,WAAA,GAAAJ,OAAA;AACA,IAAAK,KAAA,GAAAL,OAAA;AAKA,IAAAM,sBAAA,GAAAN,OAAA;AACA,IAAAO,YAAA,GAAAP,OAAA;AACA,IAAAQ,uBAAA,GAAAR,OAAA;AACA,IAAAS,eAAA,GAAAT,OAAA;AACA,IAAAU,MAAA,GAAAV,OAAA;AAAwD,IAAAW,WAAA,GAAAX,OAAA;AA3BxD;AACA;AACA;;AAGA;AACA;AACA;;AAaA;AACA;AACA;;AAOA,SAASY,WAAWA,CAAEC,KAAK,EAAEC,WAAW,EAAEC,KAAK,EAAG;EACjD,MAAMC,IAAI,GAAG,CAAC,CAAC;EAEf,KAAM,MAAMC,GAAG,IAAIJ,KAAK,EAAG;IAC1BG,IAAI,CAAEC,GAAG,CAAE,GAAGJ,KAAK,CAAEI,GAAG,CAAE;EAC3B;;EAEA;EACA;EACA;EACA;EACA;EACA;EACA;EACA,IAAKJ,KAAK,YAAYE,KAAK,CAACG,eAAe,CAACC,WAAW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IAAItD,KAAK;EAAA,CAC1C,CACF;EAED,oBACC,IAAArE,WAAA,CAAA6H,IAAA;IAAKY,SAAS,EAAC,gCAAgC;IAAAhG,QAAA,GAC5C8D,uBAAuB,eACzB,IAAAvG,WAAA,CAAA+H,GAAA;MACCU,SAAS,EAAG,IAAAC,aAAI,EACf,sCAAsC,EACtClC,WAAW,IAAI,eAChB,CAAG;MACHwB,KAAK,EAAG;QACP,yDAAyD,EACxDxB,WAAW,IAAI,GAAIC,mBAAmB;MACxC,CAAG;MAAAhE,QAAA,EAEDmF;IAAM,CACJ,CAAC;EAAA,CACF,CAAC;AAER;AAEA,SAASiB,aAAaA,CAAE3F,KAAK,EAAEH,GAAG,EAAG;EACpC,MAAM+F,aAAa,GAAG,IAAAzF,eAAS,EAC5BC,MAAM,IACPA,MAAM,CAAEE,YAAiB,CAAC,CAACD,WAAW,CAAC,CAAC,CAACwF,uBAAuB,EACjE,EACD,CAAC;;EAED;EACA;EACA;EACA;EACA;EACA,IAAK,CAAED,aAAa,EAAG;IACtB,OAAO,IAAI;EACZ;EAEA,oBAAO,IAAA9I,WAAA,CAAA+H,GAAA,EAACxF,MAAM;IAAA,GAAMW,KAAK;IAAGJ,YAAY,EAAGC;EAAK,CAAE,CAAC;AACpD;AAAC,IAAAiG,QAAA,GAAAC,OAAA,CAAAC,OAAA,GAEc,IAAAC,mBAAU,EAAEN,aAAc,CAAC","ignoreList":[]}
@@ -0,0 +1,377 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.useScaleCanvas = useScaleCanvas;
7
+ var _element = require("@wordpress/element");
8
+ var _compose = require("@wordpress/compose");
9
+ /**
10
+ * WordPress dependencies
11
+ */
12
+
13
+ /**
14
+ * @typedef {Object} TransitionState
15
+ * @property {number} scaleValue Scale of the canvas.
16
+ * @property {number} frameSize Size of the frame/offset around the canvas.
17
+ * @property {number} clientHeight ClientHeight of the iframe.
18
+ * @property {number} scrollTop ScrollTop of the iframe.
19
+ * @property {number} scrollHeight ScrollHeight of the iframe.
20
+ */
21
+
22
+ /**
23
+ * Calculate the scale of the canvas.
24
+ *
25
+ * @param {Object} options Object of options
26
+ * @param {number} options.frameSize Size of the frame/offset around the canvas
27
+ * @param {number} options.containerWidth Actual width of the canvas container
28
+ * @param {number} options.maxContainerWidth Maximum width of the container to use for the scale calculation. This locks the canvas to a maximum width when zooming out.
29
+ * @param {number} options.scaleContainerWidth Width the of the container wrapping the canvas container
30
+ * @return {number} Scale value between 0 and/or equal to 1
31
+ */
32
+ function calculateScale({
33
+ frameSize,
34
+ containerWidth,
35
+ maxContainerWidth,
36
+ scaleContainerWidth
37
+ }) {
38
+ return (Math.min(containerWidth, maxContainerWidth) - frameSize * 2) / scaleContainerWidth;
39
+ }
40
+
41
+ /**
42
+ * Compute the next scrollTop position after scaling the iframe content.
43
+ *
44
+ * @param {TransitionState} transitionFrom Starting point of the transition
45
+ * @param {TransitionState} transitionTo Ending state of the transition
46
+ * @return {number} Next scrollTop position after scaling the iframe content.
47
+ */
48
+ function computeScrollTopNext(transitionFrom, transitionTo) {
49
+ const {
50
+ clientHeight: prevClientHeight,
51
+ frameSize: prevFrameSize,
52
+ scaleValue: prevScale,
53
+ scrollTop,
54
+ scrollHeight
55
+ } = transitionFrom;
56
+ const {
57
+ clientHeight,
58
+ frameSize,
59
+ scaleValue
60
+ } = transitionTo;
61
+ // Step 0: Start with the current scrollTop.
62
+ let scrollTopNext = scrollTop;
63
+ // Step 1: Undo the effects of the previous scale and frame around the
64
+ // midpoint of the visible area.
65
+ scrollTopNext = (scrollTopNext + prevClientHeight / 2 - prevFrameSize) / prevScale - prevClientHeight / 2;
66
+
67
+ // Step 2: Apply the new scale and frame around the midpoint of the
68
+ // visible area.
69
+ scrollTopNext = (scrollTopNext + clientHeight / 2) * scaleValue + frameSize - clientHeight / 2;
70
+
71
+ // Step 3: Handle an edge case so that you scroll to the top of the
72
+ // iframe if the top of the iframe content is visible in the container.
73
+ // The same edge case for the bottom is skipped because changing content
74
+ // makes calculating it impossible.
75
+ scrollTopNext = scrollTop <= prevFrameSize ? 0 : scrollTopNext;
76
+
77
+ // This is the scrollTop value if you are scrolled to the bottom of the
78
+ // iframe. We can't just let the browser handle it because we need to
79
+ // animate the scaling.
80
+ const maxScrollTop = scrollHeight * (scaleValue / prevScale) + frameSize * 2 - clientHeight;
81
+
82
+ // Step 4: Clamp the scrollTopNext between the minimum and maximum
83
+ // possible scrollTop positions. Round the value to avoid subpixel
84
+ // truncation by the browser which sometimes causes a 1px error.
85
+ return Math.round(Math.min(Math.max(0, scrollTopNext), Math.max(0, maxScrollTop)));
86
+ }
87
+
88
+ /**
89
+ * Generate the keyframes to use for the zoom out animation.
90
+ *
91
+ * @param {TransitionState} transitionFrom Starting transition state.
92
+ * @param {TransitionState} transitionTo Ending transition state.
93
+ * @return {Object[]} An array of keyframes to use for the animation.
94
+ */
95
+ function getAnimationKeyframes(transitionFrom, transitionTo) {
96
+ const {
97
+ scaleValue: prevScale,
98
+ frameSize: prevFrameSize,
99
+ scrollTop
100
+ } = transitionFrom;
101
+ const {
102
+ scaleValue,
103
+ frameSize,
104
+ scrollTop: scrollTopNext
105
+ } = transitionTo;
106
+ return [{
107
+ translate: `0 0`,
108
+ scale: prevScale,
109
+ paddingTop: `${prevFrameSize / prevScale}px`,
110
+ paddingBottom: `${prevFrameSize / prevScale}px`
111
+ }, {
112
+ translate: `0 ${scrollTop - scrollTopNext}px`,
113
+ scale: scaleValue,
114
+ paddingTop: `${frameSize / scaleValue}px`,
115
+ paddingBottom: `${frameSize / scaleValue}px`
116
+ }];
117
+ }
118
+
119
+ /**
120
+ * @typedef {Object} ScaleCanvasResult
121
+ * @property {boolean} isZoomedOut A boolean indicating if the canvas is zoomed out.
122
+ * @property {number} scaleContainerWidth The width of the container used to calculate the scale.
123
+ * @property {Object} contentResizeListener A resize observer for the content.
124
+ * @property {Object} containerResizeListener A resize observer for the container.
125
+ */
126
+
127
+ /**
128
+ * Handles scaling the canvas for the zoom out mode and animating between
129
+ * the states.
130
+ *
131
+ * @param {Object} options Object of options.
132
+ * @param {number} options.frameSize Size of the frame around the content.
133
+ * @param {Document} options.iframeDocument Document of the iframe.
134
+ * @param {number} options.maxContainerWidth Max width of the canvas to use as the starting scale point. Defaults to 750.
135
+ * @param {number|string} options.scale Scale of the canvas. Can be an decimal between 0 and 1, 1, or 'auto-scaled'.
136
+ * @return {ScaleCanvasResult} Properties of the result.
137
+ */
138
+ function useScaleCanvas({
139
+ frameSize,
140
+ iframeDocument,
141
+ maxContainerWidth = 750,
142
+ scale
143
+ }) {
144
+ const [contentResizeListener, {
145
+ height: contentHeight
146
+ }] = (0, _compose.useResizeObserver)();
147
+ const [containerResizeListener, {
148
+ width: containerWidth
149
+ }] = (0, _compose.useResizeObserver)();
150
+ const initialContainerWidthRef = (0, _element.useRef)(0);
151
+ const isZoomedOut = scale !== 1;
152
+ const prefersReducedMotion = (0, _compose.useReducedMotion)();
153
+ const isAutoScaled = scale === 'auto-scaled';
154
+ // Track if the animation should start when the useEffect runs.
155
+ const startAnimationRef = (0, _element.useRef)(false);
156
+ // Track the animation so we know if we have an animation running,
157
+ // and can cancel it, reverse it, call a finish event, etc.
158
+ const animationRef = (0, _element.useRef)(null);
159
+ (0, _element.useEffect)(() => {
160
+ if (!isZoomedOut) {
161
+ initialContainerWidthRef.current = containerWidth;
162
+ }
163
+ }, [containerWidth, isZoomedOut]);
164
+ const scaleContainerWidth = Math.max(initialContainerWidthRef.current, containerWidth);
165
+ const scaleValue = isAutoScaled ? calculateScale({
166
+ frameSize,
167
+ containerWidth,
168
+ maxContainerWidth,
169
+ scaleContainerWidth
170
+ }) : scale;
171
+
172
+ /**
173
+ * The starting transition state for the zoom out animation.
174
+ * @type {import('react').RefObject<TransitionState>}
175
+ */
176
+ const transitionFromRef = (0, _element.useRef)({
177
+ scaleValue,
178
+ frameSize,
179
+ clientHeight: 0,
180
+ scrollTop: 0,
181
+ scrollHeight: 0
182
+ });
183
+
184
+ /**
185
+ * The ending transition state for the zoom out animation.
186
+ * @type {import('react').RefObject<TransitionState>}
187
+ */
188
+ const transitionToRef = (0, _element.useRef)({
189
+ scaleValue,
190
+ frameSize,
191
+ clientHeight: 0,
192
+ scrollTop: 0,
193
+ scrollHeight: 0
194
+ });
195
+
196
+ /**
197
+ * Start the zoom out animation. This sets the necessary CSS variables
198
+ * for animating the canvas and returns the Animation object.
199
+ *
200
+ * @return {Animation} The animation object for the zoom out animation.
201
+ */
202
+ const startZoomOutAnimation = (0, _element.useCallback)(() => {
203
+ const {
204
+ scrollTop
205
+ } = transitionFromRef.current;
206
+ const {
207
+ scrollTop: scrollTopNext
208
+ } = transitionToRef.current;
209
+ iframeDocument.documentElement.style.setProperty('--wp-block-editor-iframe-zoom-out-scroll-top', `${scrollTop}px`);
210
+ iframeDocument.documentElement.style.setProperty('--wp-block-editor-iframe-zoom-out-scroll-top-next', `${scrollTopNext}px`);
211
+ iframeDocument.documentElement.classList.add('zoom-out-animation');
212
+ return iframeDocument.documentElement.animate(getAnimationKeyframes(transitionFromRef.current, transitionToRef.current), {
213
+ easing: 'cubic-bezier(0.46, 0.03, 0.52, 0.96)',
214
+ duration: 400
215
+ });
216
+ }, [iframeDocument]);
217
+
218
+ /**
219
+ * Callback when the zoom out animation is finished.
220
+ * - Cleans up animations refs.
221
+ * - Adds final CSS vars for scale and frame size to preserve the state.
222
+ * - Removes the 'zoom-out-animation' class (which has the fixed positioning).
223
+ * - Sets the final scroll position after the canvas is no longer in fixed position.
224
+ * - Removes CSS vars related to the animation.
225
+ * - Sets the transitionFrom to the transitionTo state to be ready for the next animation.
226
+ */
227
+ const finishZoomOutAnimation = (0, _element.useCallback)(() => {
228
+ startAnimationRef.current = false;
229
+ animationRef.current = null;
230
+
231
+ // Add our final scale and frame size now that the animation is done.
232
+ iframeDocument.documentElement.style.setProperty('--wp-block-editor-iframe-zoom-out-scale', transitionToRef.current.scaleValue);
233
+ iframeDocument.documentElement.style.setProperty('--wp-block-editor-iframe-zoom-out-frame-size', `${transitionToRef.current.frameSize}px`);
234
+ iframeDocument.documentElement.classList.remove('zoom-out-animation');
235
+
236
+ // Set the final scroll position that was just animated to.
237
+ // Disable reason: Eslint isn't smart enough to know that this is a
238
+ // DOM element. https://github.com/facebook/react/issues/31483
239
+ // eslint-disable-next-line react-compiler/react-compiler
240
+ iframeDocument.documentElement.scrollTop = transitionToRef.current.scrollTop;
241
+ iframeDocument.documentElement.style.removeProperty('--wp-block-editor-iframe-zoom-out-scroll-top');
242
+ iframeDocument.documentElement.style.removeProperty('--wp-block-editor-iframe-zoom-out-scroll-top-next');
243
+
244
+ // Update previous values.
245
+ transitionFromRef.current = transitionToRef.current;
246
+ }, [iframeDocument]);
247
+
248
+ /**
249
+ * Runs when zoom out mode is toggled, and sets the startAnimation flag
250
+ * so the animation will start when the next useEffect runs. We _only_
251
+ * want to animate when the zoom out mode is toggled, not when the scale
252
+ * changes due to the container resizing.
253
+ */
254
+ (0, _element.useEffect)(() => {
255
+ if (!iframeDocument) {
256
+ return;
257
+ }
258
+ if (isZoomedOut) {
259
+ iframeDocument.documentElement.classList.add('is-zoomed-out');
260
+ }
261
+ startAnimationRef.current = true;
262
+ return () => {
263
+ iframeDocument.documentElement.classList.remove('is-zoomed-out');
264
+ };
265
+ }, [iframeDocument, isZoomedOut]);
266
+
267
+ /**
268
+ * This handles:
269
+ * 1. Setting the correct scale and vars of the canvas when zoomed out
270
+ * 2. If zoom out mode has been toggled, runs the animation of zooming in/out
271
+ */
272
+ (0, _element.useEffect)(() => {
273
+ if (!iframeDocument) {
274
+ return;
275
+ }
276
+
277
+ // We need to update the appropriate scale to exit from. If sidebars have been opened since setting the
278
+ // original scale, we will snap to a much smaller scale due to the scale container immediately changing sizes when exiting.
279
+ if (isAutoScaled && transitionFromRef.current.scaleValue !== 1) {
280
+ // We use containerWidth as the divisor, as scaleContainerWidth will always match the containerWidth when
281
+ // exiting.
282
+ transitionFromRef.current.scaleValue = calculateScale({
283
+ frameSize: transitionFromRef.current.frameSize,
284
+ containerWidth,
285
+ maxContainerWidth,
286
+ scaleContainerWidth: containerWidth
287
+ });
288
+ }
289
+
290
+ // If we are not going to animate the transition, set the scale and frame size directly.
291
+ // If we are animating, these values will be set when the animation is finished.
292
+ // Example: Opening sidebars that reduce the scale of the canvas, but we don't want to
293
+ // animate the transition.
294
+ if (!startAnimationRef.current) {
295
+ iframeDocument.documentElement.style.setProperty('--wp-block-editor-iframe-zoom-out-scale', scaleValue);
296
+ iframeDocument.documentElement.style.setProperty('--wp-block-editor-iframe-zoom-out-frame-size', `${frameSize}px`);
297
+ }
298
+ iframeDocument.documentElement.style.setProperty('--wp-block-editor-iframe-zoom-out-content-height', `${contentHeight}px`);
299
+ const clientHeight = iframeDocument.documentElement.clientHeight;
300
+ iframeDocument.documentElement.style.setProperty('--wp-block-editor-iframe-zoom-out-inner-height', `${clientHeight}px`);
301
+ iframeDocument.documentElement.style.setProperty('--wp-block-editor-iframe-zoom-out-container-width', `${containerWidth}px`);
302
+ iframeDocument.documentElement.style.setProperty('--wp-block-editor-iframe-zoom-out-scale-container-width', `${scaleContainerWidth}px`);
303
+
304
+ /**
305
+ * Handle the zoom out animation:
306
+ *
307
+ * - Get the current scrollTop position.
308
+ * - Calculate where the same scroll position is after scaling.
309
+ * - Apply fixed positioning to the canvas with a transform offset
310
+ * to keep the canvas centered.
311
+ * - Animate the scale and padding to the new scale and frame size.
312
+ * - After the animation is complete, remove the fixed positioning
313
+ * and set the scroll position that keeps everything centered.
314
+ */
315
+ if (startAnimationRef.current) {
316
+ // Don't allow a new transition to start again unless it was started by the zoom out mode changing.
317
+ startAnimationRef.current = false;
318
+
319
+ /**
320
+ * If we already have an animation running, reverse it.
321
+ */
322
+ if (animationRef.current) {
323
+ animationRef.current.reverse();
324
+ // Swap the transition to/from refs so that we set the correct values when
325
+ // finishZoomOutAnimation runs.
326
+ const tempTransitionFrom = transitionFromRef.current;
327
+ const tempTransitionTo = transitionToRef.current;
328
+ transitionFromRef.current = tempTransitionTo;
329
+ transitionToRef.current = tempTransitionFrom;
330
+ } else {
331
+ var _transitionFromRef$cu;
332
+ /**
333
+ * Start a new zoom animation.
334
+ */
335
+
336
+ // We can't trust the set value from contentHeight, as it was measured
337
+ // before the zoom out mode was changed. After zoom out mode is changed,
338
+ // appenders may appear or disappear, so we need to get the height from
339
+ // the iframe at this point when we're about to animate the zoom out.
340
+ // The iframe scrollTop, scrollHeight, and clientHeight will all be
341
+ // the most accurate.
342
+ transitionFromRef.current.clientHeight = (_transitionFromRef$cu = transitionFromRef.current.clientHeight) !== null && _transitionFromRef$cu !== void 0 ? _transitionFromRef$cu : clientHeight;
343
+ transitionFromRef.current.scrollTop = iframeDocument.documentElement.scrollTop;
344
+ transitionFromRef.current.scrollHeight = iframeDocument.documentElement.scrollHeight;
345
+ transitionToRef.current = {
346
+ scaleValue,
347
+ frameSize,
348
+ clientHeight
349
+ };
350
+ transitionToRef.current.scrollTop = computeScrollTopNext(transitionFromRef.current, transitionToRef.current);
351
+ animationRef.current = startZoomOutAnimation();
352
+
353
+ // If the user prefers reduced motion, finish the animation immediately and set the final state.
354
+ if (prefersReducedMotion) {
355
+ finishZoomOutAnimation();
356
+ } else {
357
+ animationRef.current.onfinish = finishZoomOutAnimation;
358
+ }
359
+ }
360
+ }
361
+ return () => {
362
+ iframeDocument.documentElement.style.removeProperty('--wp-block-editor-iframe-zoom-out-scale');
363
+ iframeDocument.documentElement.style.removeProperty('--wp-block-editor-iframe-zoom-out-frame-size');
364
+ iframeDocument.documentElement.style.removeProperty('--wp-block-editor-iframe-zoom-out-content-height');
365
+ iframeDocument.documentElement.style.removeProperty('--wp-block-editor-iframe-zoom-out-inner-height');
366
+ iframeDocument.documentElement.style.removeProperty('--wp-block-editor-iframe-zoom-out-container-width');
367
+ iframeDocument.documentElement.style.removeProperty('--wp-block-editor-iframe-zoom-out-scale-container-width');
368
+ };
369
+ }, [startZoomOutAnimation, finishZoomOutAnimation, prefersReducedMotion, isAutoScaled, scaleValue, frameSize, iframeDocument, contentHeight, containerWidth, maxContainerWidth, scaleContainerWidth]);
370
+ return {
371
+ isZoomedOut,
372
+ scaleContainerWidth,
373
+ contentResizeListener,
374
+ containerResizeListener
375
+ };
376
+ }
377
+ //# sourceMappingURL=use-scale-canvas.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["_element","require","_compose","calculateScale","frameSize","containerWidth","maxContainerWidth","scaleContainerWidth","Math","min","computeScrollTopNext","transitionFrom","transitionTo","clientHeight","prevClientHeight","prevFrameSize","scaleValue","prevScale","scrollTop","scrollHeight","scrollTopNext","maxScrollTop","round","max","getAnimationKeyframes","translate","scale","paddingTop","paddingBottom","useScaleCanvas","iframeDocument","contentResizeListener","height","contentHeight","useResizeObserver","containerResizeListener","width","initialContainerWidthRef","useRef","isZoomedOut","prefersReducedMotion","useReducedMotion","isAutoScaled","startAnimationRef","animationRef","useEffect","current","transitionFromRef","transitionToRef","startZoomOutAnimation","useCallback","documentElement","style","setProperty","classList","add","animate","easing","duration","finishZoomOutAnimation","remove","removeProperty","reverse","tempTransitionFrom","tempTransitionTo","_transitionFromRef$cu","onfinish"],"sources":["@wordpress/block-editor/src/components/iframe/use-scale-canvas.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { useEffect, useRef, useCallback } from '@wordpress/element';\nimport { useReducedMotion, useResizeObserver } from '@wordpress/compose';\n\n/**\n * @typedef {Object} TransitionState\n * @property {number} scaleValue Scale of the canvas.\n * @property {number} frameSize Size of the frame/offset around the canvas.\n * @property {number} clientHeight ClientHeight of the iframe.\n * @property {number} scrollTop ScrollTop of the iframe.\n * @property {number} scrollHeight ScrollHeight of the iframe.\n */\n\n/**\n * Calculate the scale of the canvas.\n *\n * @param {Object} options Object of options\n * @param {number} options.frameSize Size of the frame/offset around the canvas\n * @param {number} options.containerWidth Actual width of the canvas container\n * @param {number} options.maxContainerWidth Maximum width of the container to use for the scale calculation. This locks the canvas to a maximum width when zooming out.\n * @param {number} options.scaleContainerWidth Width the of the container wrapping the canvas container\n * @return {number} Scale value between 0 and/or equal to 1\n */\nfunction calculateScale( {\n\tframeSize,\n\tcontainerWidth,\n\tmaxContainerWidth,\n\tscaleContainerWidth,\n} ) {\n\treturn (\n\t\t( Math.min( containerWidth, maxContainerWidth ) - frameSize * 2 ) /\n\t\tscaleContainerWidth\n\t);\n}\n\n/**\n * Compute the next scrollTop position after scaling the iframe content.\n *\n * @param {TransitionState} transitionFrom Starting point of the transition\n * @param {TransitionState} transitionTo Ending state of the transition\n * @return {number} Next scrollTop position after scaling the iframe content.\n */\nfunction computeScrollTopNext( transitionFrom, transitionTo ) {\n\tconst {\n\t\tclientHeight: prevClientHeight,\n\t\tframeSize: prevFrameSize,\n\t\tscaleValue: prevScale,\n\t\tscrollTop,\n\t\tscrollHeight,\n\t} = transitionFrom;\n\tconst { clientHeight, frameSize, scaleValue } = transitionTo;\n\t// Step 0: Start with the current scrollTop.\n\tlet scrollTopNext = scrollTop;\n\t// Step 1: Undo the effects of the previous scale and frame around the\n\t// midpoint of the visible area.\n\tscrollTopNext =\n\t\t( scrollTopNext + prevClientHeight / 2 - prevFrameSize ) / prevScale -\n\t\tprevClientHeight / 2;\n\n\t// Step 2: Apply the new scale and frame around the midpoint of the\n\t// visible area.\n\tscrollTopNext =\n\t\t( scrollTopNext + clientHeight / 2 ) * scaleValue +\n\t\tframeSize -\n\t\tclientHeight / 2;\n\n\t// Step 3: Handle an edge case so that you scroll to the top of the\n\t// iframe if the top of the iframe content is visible in the container.\n\t// The same edge case for the bottom is skipped because changing content\n\t// makes calculating it impossible.\n\tscrollTopNext = scrollTop <= prevFrameSize ? 0 : scrollTopNext;\n\n\t// This is the scrollTop value if you are scrolled to the bottom of the\n\t// iframe. We can't just let the browser handle it because we need to\n\t// animate the scaling.\n\tconst maxScrollTop =\n\t\tscrollHeight * ( scaleValue / prevScale ) +\n\t\tframeSize * 2 -\n\t\tclientHeight;\n\n\t// Step 4: Clamp the scrollTopNext between the minimum and maximum\n\t// possible scrollTop positions. Round the value to avoid subpixel\n\t// truncation by the browser which sometimes causes a 1px error.\n\treturn Math.round(\n\t\tMath.min( Math.max( 0, scrollTopNext ), Math.max( 0, maxScrollTop ) )\n\t);\n}\n\n/**\n * Generate the keyframes to use for the zoom out animation.\n *\n * @param {TransitionState} transitionFrom Starting transition state.\n * @param {TransitionState} transitionTo Ending transition state.\n * @return {Object[]} An array of keyframes to use for the animation.\n */\nfunction getAnimationKeyframes( transitionFrom, transitionTo ) {\n\tconst {\n\t\tscaleValue: prevScale,\n\t\tframeSize: prevFrameSize,\n\t\tscrollTop,\n\t} = transitionFrom;\n\tconst { scaleValue, frameSize, scrollTop: scrollTopNext } = transitionTo;\n\n\treturn [\n\t\t{\n\t\t\ttranslate: `0 0`,\n\t\t\tscale: prevScale,\n\t\t\tpaddingTop: `${ prevFrameSize / prevScale }px`,\n\t\t\tpaddingBottom: `${ prevFrameSize / prevScale }px`,\n\t\t},\n\t\t{\n\t\t\ttranslate: `0 ${ scrollTop - scrollTopNext }px`,\n\t\t\tscale: scaleValue,\n\t\t\tpaddingTop: `${ frameSize / scaleValue }px`,\n\t\t\tpaddingBottom: `${ frameSize / scaleValue }px`,\n\t\t},\n\t];\n}\n\n/**\n * @typedef {Object} ScaleCanvasResult\n * @property {boolean} isZoomedOut A boolean indicating if the canvas is zoomed out.\n * @property {number} scaleContainerWidth The width of the container used to calculate the scale.\n * @property {Object} contentResizeListener A resize observer for the content.\n * @property {Object} containerResizeListener A resize observer for the container.\n */\n\n/**\n * Handles scaling the canvas for the zoom out mode and animating between\n * the states.\n *\n * @param {Object} options Object of options.\n * @param {number} options.frameSize Size of the frame around the content.\n * @param {Document} options.iframeDocument Document of the iframe.\n * @param {number} options.maxContainerWidth Max width of the canvas to use as the starting scale point. Defaults to 750.\n * @param {number|string} options.scale Scale of the canvas. Can be an decimal between 0 and 1, 1, or 'auto-scaled'.\n * @return {ScaleCanvasResult} Properties of the result.\n */\nexport function useScaleCanvas( {\n\tframeSize,\n\tiframeDocument,\n\tmaxContainerWidth = 750,\n\tscale,\n} ) {\n\tconst [ contentResizeListener, { height: contentHeight } ] =\n\t\tuseResizeObserver();\n\tconst [ containerResizeListener, { width: containerWidth } ] =\n\t\tuseResizeObserver();\n\n\tconst initialContainerWidthRef = useRef( 0 );\n\tconst isZoomedOut = scale !== 1;\n\tconst prefersReducedMotion = useReducedMotion();\n\tconst isAutoScaled = scale === 'auto-scaled';\n\t// Track if the animation should start when the useEffect runs.\n\tconst startAnimationRef = useRef( false );\n\t// Track the animation so we know if we have an animation running,\n\t// and can cancel it, reverse it, call a finish event, etc.\n\tconst animationRef = useRef( null );\n\n\tuseEffect( () => {\n\t\tif ( ! isZoomedOut ) {\n\t\t\tinitialContainerWidthRef.current = containerWidth;\n\t\t}\n\t}, [ containerWidth, isZoomedOut ] );\n\n\tconst scaleContainerWidth = Math.max(\n\t\tinitialContainerWidthRef.current,\n\t\tcontainerWidth\n\t);\n\n\tconst scaleValue = isAutoScaled\n\t\t? calculateScale( {\n\t\t\t\tframeSize,\n\t\t\t\tcontainerWidth,\n\t\t\t\tmaxContainerWidth,\n\t\t\t\tscaleContainerWidth,\n\t\t } )\n\t\t: scale;\n\n\t/**\n\t * The starting transition state for the zoom out animation.\n\t * @type {import('react').RefObject<TransitionState>}\n\t */\n\tconst transitionFromRef = useRef( {\n\t\tscaleValue,\n\t\tframeSize,\n\t\tclientHeight: 0,\n\t\tscrollTop: 0,\n\t\tscrollHeight: 0,\n\t} );\n\n\t/**\n\t * The ending transition state for the zoom out animation.\n\t * @type {import('react').RefObject<TransitionState>}\n\t */\n\tconst transitionToRef = useRef( {\n\t\tscaleValue,\n\t\tframeSize,\n\t\tclientHeight: 0,\n\t\tscrollTop: 0,\n\t\tscrollHeight: 0,\n\t} );\n\n\t/**\n\t * Start the zoom out animation. This sets the necessary CSS variables\n\t * for animating the canvas and returns the Animation object.\n\t *\n\t * @return {Animation} The animation object for the zoom out animation.\n\t */\n\tconst startZoomOutAnimation = useCallback( () => {\n\t\tconst { scrollTop } = transitionFromRef.current;\n\t\tconst { scrollTop: scrollTopNext } = transitionToRef.current;\n\n\t\tiframeDocument.documentElement.style.setProperty(\n\t\t\t'--wp-block-editor-iframe-zoom-out-scroll-top',\n\t\t\t`${ scrollTop }px`\n\t\t);\n\n\t\tiframeDocument.documentElement.style.setProperty(\n\t\t\t'--wp-block-editor-iframe-zoom-out-scroll-top-next',\n\t\t\t`${ scrollTopNext }px`\n\t\t);\n\n\t\tiframeDocument.documentElement.classList.add( 'zoom-out-animation' );\n\n\t\treturn iframeDocument.documentElement.animate(\n\t\t\tgetAnimationKeyframes(\n\t\t\t\ttransitionFromRef.current,\n\t\t\t\ttransitionToRef.current\n\t\t\t),\n\t\t\t{\n\t\t\t\teasing: 'cubic-bezier(0.46, 0.03, 0.52, 0.96)',\n\t\t\t\tduration: 400,\n\t\t\t}\n\t\t);\n\t}, [ iframeDocument ] );\n\n\t/**\n\t * Callback when the zoom out animation is finished.\n\t * - Cleans up animations refs.\n\t * - Adds final CSS vars for scale and frame size to preserve the state.\n\t * - Removes the 'zoom-out-animation' class (which has the fixed positioning).\n\t * - Sets the final scroll position after the canvas is no longer in fixed position.\n\t * - Removes CSS vars related to the animation.\n\t * - Sets the transitionFrom to the transitionTo state to be ready for the next animation.\n\t */\n\tconst finishZoomOutAnimation = useCallback( () => {\n\t\tstartAnimationRef.current = false;\n\t\tanimationRef.current = null;\n\n\t\t// Add our final scale and frame size now that the animation is done.\n\t\tiframeDocument.documentElement.style.setProperty(\n\t\t\t'--wp-block-editor-iframe-zoom-out-scale',\n\t\t\ttransitionToRef.current.scaleValue\n\t\t);\n\t\tiframeDocument.documentElement.style.setProperty(\n\t\t\t'--wp-block-editor-iframe-zoom-out-frame-size',\n\t\t\t`${ transitionToRef.current.frameSize }px`\n\t\t);\n\n\t\tiframeDocument.documentElement.classList.remove( 'zoom-out-animation' );\n\n\t\t// Set the final scroll position that was just animated to.\n\t\t// Disable reason: Eslint isn't smart enough to know that this is a\n\t\t// DOM element. https://github.com/facebook/react/issues/31483\n\t\t// eslint-disable-next-line react-compiler/react-compiler\n\t\tiframeDocument.documentElement.scrollTop =\n\t\t\ttransitionToRef.current.scrollTop;\n\n\t\tiframeDocument.documentElement.style.removeProperty(\n\t\t\t'--wp-block-editor-iframe-zoom-out-scroll-top'\n\t\t);\n\t\tiframeDocument.documentElement.style.removeProperty(\n\t\t\t'--wp-block-editor-iframe-zoom-out-scroll-top-next'\n\t\t);\n\n\t\t// Update previous values.\n\t\ttransitionFromRef.current = transitionToRef.current;\n\t}, [ iframeDocument ] );\n\n\t/**\n\t * Runs when zoom out mode is toggled, and sets the startAnimation flag\n\t * so the animation will start when the next useEffect runs. We _only_\n\t * want to animate when the zoom out mode is toggled, not when the scale\n\t * changes due to the container resizing.\n\t */\n\tuseEffect( () => {\n\t\tif ( ! iframeDocument ) {\n\t\t\treturn;\n\t\t}\n\n\t\tif ( isZoomedOut ) {\n\t\t\tiframeDocument.documentElement.classList.add( 'is-zoomed-out' );\n\t\t}\n\n\t\tstartAnimationRef.current = true;\n\n\t\treturn () => {\n\t\t\tiframeDocument.documentElement.classList.remove( 'is-zoomed-out' );\n\t\t};\n\t}, [ iframeDocument, isZoomedOut ] );\n\n\t/**\n\t * This handles:\n\t * 1. Setting the correct scale and vars of the canvas when zoomed out\n\t * 2. If zoom out mode has been toggled, runs the animation of zooming in/out\n\t */\n\tuseEffect( () => {\n\t\tif ( ! iframeDocument ) {\n\t\t\treturn;\n\t\t}\n\n\t\t// We need to update the appropriate scale to exit from. If sidebars have been opened since setting the\n\t\t// original scale, we will snap to a much smaller scale due to the scale container immediately changing sizes when exiting.\n\t\tif ( isAutoScaled && transitionFromRef.current.scaleValue !== 1 ) {\n\t\t\t// We use containerWidth as the divisor, as scaleContainerWidth will always match the containerWidth when\n\t\t\t// exiting.\n\t\t\ttransitionFromRef.current.scaleValue = calculateScale( {\n\t\t\t\tframeSize: transitionFromRef.current.frameSize,\n\t\t\t\tcontainerWidth,\n\t\t\t\tmaxContainerWidth,\n\t\t\t\tscaleContainerWidth: containerWidth,\n\t\t\t} );\n\t\t}\n\n\t\t// If we are not going to animate the transition, set the scale and frame size directly.\n\t\t// If we are animating, these values will be set when the animation is finished.\n\t\t// Example: Opening sidebars that reduce the scale of the canvas, but we don't want to\n\t\t// animate the transition.\n\t\tif ( ! startAnimationRef.current ) {\n\t\t\tiframeDocument.documentElement.style.setProperty(\n\t\t\t\t'--wp-block-editor-iframe-zoom-out-scale',\n\t\t\t\tscaleValue\n\t\t\t);\n\t\t\tiframeDocument.documentElement.style.setProperty(\n\t\t\t\t'--wp-block-editor-iframe-zoom-out-frame-size',\n\t\t\t\t`${ frameSize }px`\n\t\t\t);\n\t\t}\n\n\t\tiframeDocument.documentElement.style.setProperty(\n\t\t\t'--wp-block-editor-iframe-zoom-out-content-height',\n\t\t\t`${ contentHeight }px`\n\t\t);\n\n\t\tconst clientHeight = iframeDocument.documentElement.clientHeight;\n\t\tiframeDocument.documentElement.style.setProperty(\n\t\t\t'--wp-block-editor-iframe-zoom-out-inner-height',\n\t\t\t`${ clientHeight }px`\n\t\t);\n\n\t\tiframeDocument.documentElement.style.setProperty(\n\t\t\t'--wp-block-editor-iframe-zoom-out-container-width',\n\t\t\t`${ containerWidth }px`\n\t\t);\n\t\tiframeDocument.documentElement.style.setProperty(\n\t\t\t'--wp-block-editor-iframe-zoom-out-scale-container-width',\n\t\t\t`${ scaleContainerWidth }px`\n\t\t);\n\n\t\t/**\n\t\t * Handle the zoom out animation:\n\t\t *\n\t\t * - Get the current scrollTop position.\n\t\t * - Calculate where the same scroll position is after scaling.\n\t\t * - Apply fixed positioning to the canvas with a transform offset\n\t\t * to keep the canvas centered.\n\t\t * - Animate the scale and padding to the new scale and frame size.\n\t\t * - After the animation is complete, remove the fixed positioning\n\t\t * and set the scroll position that keeps everything centered.\n\t\t */\n\t\tif ( startAnimationRef.current ) {\n\t\t\t// Don't allow a new transition to start again unless it was started by the zoom out mode changing.\n\t\t\tstartAnimationRef.current = false;\n\n\t\t\t/**\n\t\t\t * If we already have an animation running, reverse it.\n\t\t\t */\n\t\t\tif ( animationRef.current ) {\n\t\t\t\tanimationRef.current.reverse();\n\t\t\t\t// Swap the transition to/from refs so that we set the correct values when\n\t\t\t\t// finishZoomOutAnimation runs.\n\t\t\t\tconst tempTransitionFrom = transitionFromRef.current;\n\t\t\t\tconst tempTransitionTo = transitionToRef.current;\n\t\t\t\ttransitionFromRef.current = tempTransitionTo;\n\t\t\t\ttransitionToRef.current = tempTransitionFrom;\n\t\t\t} else {\n\t\t\t\t/**\n\t\t\t\t * Start a new zoom animation.\n\t\t\t\t */\n\n\t\t\t\t// We can't trust the set value from contentHeight, as it was measured\n\t\t\t\t// before the zoom out mode was changed. After zoom out mode is changed,\n\t\t\t\t// appenders may appear or disappear, so we need to get the height from\n\t\t\t\t// the iframe at this point when we're about to animate the zoom out.\n\t\t\t\t// The iframe scrollTop, scrollHeight, and clientHeight will all be\n\t\t\t\t// the most accurate.\n\t\t\t\ttransitionFromRef.current.clientHeight =\n\t\t\t\t\ttransitionFromRef.current.clientHeight ?? clientHeight;\n\t\t\t\ttransitionFromRef.current.scrollTop =\n\t\t\t\t\tiframeDocument.documentElement.scrollTop;\n\t\t\t\ttransitionFromRef.current.scrollHeight =\n\t\t\t\t\tiframeDocument.documentElement.scrollHeight;\n\n\t\t\t\ttransitionToRef.current = {\n\t\t\t\t\tscaleValue,\n\t\t\t\t\tframeSize,\n\t\t\t\t\tclientHeight,\n\t\t\t\t};\n\t\t\t\ttransitionToRef.current.scrollTop = computeScrollTopNext(\n\t\t\t\t\ttransitionFromRef.current,\n\t\t\t\t\ttransitionToRef.current\n\t\t\t\t);\n\n\t\t\t\tanimationRef.current = startZoomOutAnimation();\n\n\t\t\t\t// If the user prefers reduced motion, finish the animation immediately and set the final state.\n\t\t\t\tif ( prefersReducedMotion ) {\n\t\t\t\t\tfinishZoomOutAnimation();\n\t\t\t\t} else {\n\t\t\t\t\tanimationRef.current.onfinish = finishZoomOutAnimation;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\treturn () => {\n\t\t\tiframeDocument.documentElement.style.removeProperty(\n\t\t\t\t'--wp-block-editor-iframe-zoom-out-scale'\n\t\t\t);\n\t\t\tiframeDocument.documentElement.style.removeProperty(\n\t\t\t\t'--wp-block-editor-iframe-zoom-out-frame-size'\n\t\t\t);\n\t\t\tiframeDocument.documentElement.style.removeProperty(\n\t\t\t\t'--wp-block-editor-iframe-zoom-out-content-height'\n\t\t\t);\n\t\t\tiframeDocument.documentElement.style.removeProperty(\n\t\t\t\t'--wp-block-editor-iframe-zoom-out-inner-height'\n\t\t\t);\n\t\t\tiframeDocument.documentElement.style.removeProperty(\n\t\t\t\t'--wp-block-editor-iframe-zoom-out-container-width'\n\t\t\t);\n\t\t\tiframeDocument.documentElement.style.removeProperty(\n\t\t\t\t'--wp-block-editor-iframe-zoom-out-scale-container-width'\n\t\t\t);\n\t\t};\n\t}, [\n\t\tstartZoomOutAnimation,\n\t\tfinishZoomOutAnimation,\n\t\tprefersReducedMotion,\n\t\tisAutoScaled,\n\t\tscaleValue,\n\t\tframeSize,\n\t\tiframeDocument,\n\t\tcontentHeight,\n\t\tcontainerWidth,\n\t\tmaxContainerWidth,\n\t\tscaleContainerWidth,\n\t] );\n\n\treturn {\n\t\tisZoomedOut,\n\t\tscaleContainerWidth,\n\t\tcontentResizeListener,\n\t\tcontainerResizeListener,\n\t};\n}\n"],"mappings":";;;;;;AAGA,IAAAA,QAAA,GAAAC,OAAA;AACA,IAAAC,QAAA,GAAAD,OAAA;AAJA;AACA;AACA;;AAIA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,SAASE,cAAcA,CAAE;EACxBC,SAAS;EACTC,cAAc;EACdC,iBAAiB;EACjBC;AACD,CAAC,EAAG;EACH,OACC,CAAEC,IAAI,CAACC,GAAG,CAAEJ,cAAc,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AE9C;QACA,IAAKT,oBAAoB,EAAG;UAC3BmB,sBAAsB,CAAC,CAAC;QACzB,CAAC,MAAM;UACNf,YAAY,CAACE,OAAO,CAACoB,QAAQ,GAAGP,sBAAsB;QACvD;MACD;IACD;IAEA,OAAO,MAAM;MACZ7B,cAAc,CAACqB,eAAe,CAACC,KAAK,CAACS,cAAc,CAClD,yCACD,CAAC;MACD/B,cAAc,CAACqB,eAAe,CAACC,KAAK,CAACS,cAAc,CAClD,8CACD,CAAC;MACD/B,cAAc,CAACqB,eAAe,CAACC,KAAK,CAACS,cAAc,CAClD,kDACD,CAAC;MACD/B,cAAc,CAACqB,eAAe,CAACC,KAAK,CAACS,cAAc,CAClD,gDACD,CAAC;MACD/B,cAAc,CAACqB,eAAe,CAACC,KAAK,CAACS,cAAc,CAClD,mDACD,CAAC;MACD/B,cAAc,CAACqB,eAAe,CAACC,KAAK,CAACS,cAAc,CAClD,yDACD,CAAC;IACF,CAAC;EACF,CAAC,EAAE,CACFZ,qBAAqB,EACrBU,sBAAsB,EACtBnB,oBAAoB,EACpBE,YAAY,EACZ1B,UAAU,EACVZ,SAAS,EACT0B,cAAc,EACdG,aAAa,EACb5B,cAAc,EACdC,iBAAiB,EACjBC,mBAAmB,CAClB,CAAC;EAEH,OAAO;IACNgC,WAAW;IACXhC,mBAAmB;IACnBwB,qBAAqB;IACrBI;EACD,CAAC;AACF","ignoreList":[]}
@@ -17,6 +17,11 @@ var _dom = require("@wordpress/dom");
17
17
  // Disable Reason: Needs to be refactored.
18
18
  // eslint-disable-next-line no-restricted-imports
19
19
 
20
+ const messages = {
21
+ crop: (0, _i18n.__)('Image cropped.'),
22
+ rotate: (0, _i18n.__)('Image rotated.'),
23
+ cropAndRotate: (0, _i18n.__)('Image cropped and rotated.')
24
+ };
20
25
  function useSaveImage({
21
26
  crop,
22
27
  rotation,
@@ -26,7 +31,8 @@ function useSaveImage({
26
31
  onFinishEditing
27
32
  }) {
28
33
  const {
29
- createErrorNotice
34
+ createErrorNotice,
35
+ createSuccessNotice
30
36
  } = (0, _data.useDispatch)(_notices.store);
31
37
  const [isInProgress, setIsInProgress] = (0, _element.useState)(false);
32
38
  const cancel = (0, _element.useCallback)(() => {
@@ -64,6 +70,7 @@ function useSaveImage({
64
70
  onFinishEditing();
65
71
  return;
66
72
  }
73
+ const modifierType = modifiers.length === 1 ? modifiers[0].type : 'cropAndRotate';
67
74
  (0, _apiFetch.default)({
68
75
  path: `/wp/v2/media/${id}/edit`,
69
76
  method: 'POST',
@@ -76,8 +83,20 @@ function useSaveImage({
76
83
  id: response.id,
77
84
  url: response.source_url
78
85
  });
86
+ createSuccessNotice(messages[modifierType], {
87
+ type: 'snackbar',
88
+ actions: [{
89
+ label: (0, _i18n.__)('Undo'),
90
+ onClick: () => {
91
+ onSaveImage({
92
+ id,
93
+ url
94
+ });
95
+ }
96
+ }]
97
+ });
79
98
  }).catch(error => {
80
- createErrorNotice((0, _i18n.sprintf)(/* translators: 1. Error message */
99
+ createErrorNotice((0, _i18n.sprintf)(/* translators: %s: Error message. */
81
100
  (0, _i18n.__)('Could not edit image. %s'), (0, _dom.__unstableStripHTML)(error.message)), {
82
101
  id: 'image-editing-error',
83
102
  type: 'snackbar'
@@ -86,7 +105,7 @@ function useSaveImage({
86
105
  setIsInProgress(false);
87
106
  onFinishEditing();
88
107
  });
89
- }, [crop, rotation, id, url, onSaveImage, createErrorNotice, onFinishEditing]);
108
+ }, [crop, rotation, id, url, onSaveImage, createErrorNotice, createSuccessNotice, onFinishEditing]);
90
109
  return (0, _element.useMemo)(() => ({
91
110
  isInProgress,
92
111
  apply,