@wordpress/block-editor 12.11.1 → 12.12.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 (215) hide show
  1. package/CHANGELOG.md +2 -0
  2. package/build/components/block-controls/hook.js +4 -1
  3. package/build/components/block-controls/hook.js.map +1 -1
  4. package/build/components/block-list/block-outline.native.js +1 -1
  5. package/build/components/block-list/block-outline.native.js.map +1 -1
  6. package/build/components/block-list/block.js +2 -0
  7. package/build/components/block-list/block.js.map +1 -1
  8. package/build/components/block-preview/index.js +4 -1
  9. package/build/components/block-preview/index.js.map +1 -1
  10. package/build/components/block-styles/index.js +1 -2
  11. package/build/components/block-styles/index.js.map +1 -1
  12. package/build/components/block-switcher/pattern-transformations-menu.js +2 -4
  13. package/build/components/block-switcher/pattern-transformations-menu.js.map +1 -1
  14. package/build/components/block-tools/block-contextual-toolbar.js +1 -0
  15. package/build/components/block-tools/block-contextual-toolbar.js.map +1 -1
  16. package/build/components/dimensions-tool/index.js +22 -22
  17. package/build/components/dimensions-tool/index.js.map +1 -1
  18. package/build/components/dimensions-tool/scale-tool.js +1 -1
  19. package/build/components/dimensions-tool/scale-tool.js.map +1 -1
  20. package/build/components/height-control/index.js +90 -2
  21. package/build/components/height-control/index.js.map +1 -1
  22. package/build/components/iframe/index.js +9 -1
  23. package/build/components/iframe/index.js.map +1 -1
  24. package/build/components/image-editor/aspect-ratio-dropdown.js +0 -6
  25. package/build/components/image-editor/aspect-ratio-dropdown.js.map +1 -1
  26. package/build/components/index.native.js +8 -0
  27. package/build/components/index.native.js.map +1 -1
  28. package/build/components/link-control/link-preview.js +5 -2
  29. package/build/components/link-control/link-preview.js.map +1 -1
  30. package/build/components/link-control/use-internal-value.js +14 -8
  31. package/build/components/link-control/use-internal-value.js.map +1 -1
  32. package/build/components/list-view/index.js +6 -5
  33. package/build/components/list-view/index.js.map +1 -1
  34. package/build/components/media-replace-flow/index.js +2 -4
  35. package/build/components/media-replace-flow/index.js.map +1 -1
  36. package/build/components/provider/use-block-sync.js +2 -2
  37. package/build/components/provider/use-block-sync.js.map +1 -1
  38. package/build/components/rich-text/index.native.js +14 -3
  39. package/build/components/rich-text/index.native.js.map +1 -1
  40. package/build/components/rich-text/use-delete.js +1 -1
  41. package/build/components/rich-text/use-delete.js.map +1 -1
  42. package/build/components/rich-text/use-paste-handler.js +25 -22
  43. package/build/components/rich-text/use-paste-handler.js.map +1 -1
  44. package/build/components/spacing-sizes-control/input-controls/spacing-input-control.js +88 -0
  45. package/build/components/spacing-sizes-control/input-controls/spacing-input-control.js.map +1 -1
  46. package/build/components/tool-selector/index.js +1 -2
  47. package/build/components/tool-selector/index.js.map +1 -1
  48. package/build/components/use-block-commands/index.js +90 -46
  49. package/build/components/use-block-commands/index.js.map +1 -1
  50. package/build/components/use-setting/index.js +4 -2
  51. package/build/components/use-setting/index.js.map +1 -1
  52. package/build/components/writing-flow/use-arrow-nav.js +4 -0
  53. package/build/components/writing-flow/use-arrow-nav.js.map +1 -1
  54. package/build/hooks/block-rename-ui.js +5 -5
  55. package/build/hooks/block-rename-ui.js.map +1 -1
  56. package/build/hooks/{metadata-name.js → block-renaming.js} +3 -7
  57. package/build/hooks/block-renaming.js.map +1 -0
  58. package/build/hooks/custom-class-name.js +28 -21
  59. package/build/hooks/custom-class-name.js.map +1 -1
  60. package/build/hooks/duotone.js +28 -1
  61. package/build/hooks/duotone.js.map +1 -1
  62. package/build/hooks/index.js +1 -1
  63. package/build/hooks/index.js.map +1 -1
  64. package/build/hooks/layout.js +6 -6
  65. package/build/hooks/layout.js.map +1 -1
  66. package/build/hooks/metadata.js +6 -27
  67. package/build/hooks/metadata.js.map +1 -1
  68. package/build/hooks/utils.js +1 -1
  69. package/build/hooks/utils.js.map +1 -1
  70. package/build/layouts/grid.js +25 -3
  71. package/build/layouts/grid.js.map +1 -1
  72. package/build/layouts/utils.js +1 -1
  73. package/build/layouts/utils.js.map +1 -1
  74. package/build/lock-unlock.js +1 -1
  75. package/build/lock-unlock.js.map +1 -1
  76. package/build/store/actions.js +13 -5
  77. package/build/store/actions.js.map +1 -1
  78. package/build/utils/parse-css-unit-to-px.js +20 -0
  79. package/build/utils/parse-css-unit-to-px.js.map +1 -1
  80. package/build/utils/pasting.js +1 -1
  81. package/build/utils/pasting.js.map +1 -1
  82. package/build-module/components/block-controls/hook.js +4 -1
  83. package/build-module/components/block-controls/hook.js.map +1 -1
  84. package/build-module/components/block-list/block-outline.native.js +1 -1
  85. package/build-module/components/block-list/block-outline.native.js.map +1 -1
  86. package/build-module/components/block-list/block.js +2 -0
  87. package/build-module/components/block-list/block.js.map +1 -1
  88. package/build-module/components/block-preview/index.js +4 -1
  89. package/build-module/components/block-preview/index.js.map +1 -1
  90. package/build-module/components/block-styles/index.js +1 -2
  91. package/build-module/components/block-styles/index.js.map +1 -1
  92. package/build-module/components/block-switcher/pattern-transformations-menu.js +2 -4
  93. package/build-module/components/block-switcher/pattern-transformations-menu.js.map +1 -1
  94. package/build-module/components/block-tools/block-contextual-toolbar.js +1 -0
  95. package/build-module/components/block-tools/block-contextual-toolbar.js.map +1 -1
  96. package/build-module/components/dimensions-tool/index.js +22 -22
  97. package/build-module/components/dimensions-tool/index.js.map +1 -1
  98. package/build-module/components/dimensions-tool/scale-tool.js +1 -1
  99. package/build-module/components/dimensions-tool/scale-tool.js.map +1 -1
  100. package/build-module/components/height-control/index.js +90 -2
  101. package/build-module/components/height-control/index.js.map +1 -1
  102. package/build-module/components/iframe/index.js +9 -1
  103. package/build-module/components/iframe/index.js.map +1 -1
  104. package/build-module/components/image-editor/aspect-ratio-dropdown.js +0 -6
  105. package/build-module/components/image-editor/aspect-ratio-dropdown.js.map +1 -1
  106. package/build-module/components/index.native.js +1 -0
  107. package/build-module/components/index.native.js.map +1 -1
  108. package/build-module/components/link-control/link-preview.js +6 -3
  109. package/build-module/components/link-control/link-preview.js.map +1 -1
  110. package/build-module/components/link-control/use-internal-value.js +14 -9
  111. package/build-module/components/link-control/use-internal-value.js.map +1 -1
  112. package/build-module/components/list-view/index.js +7 -6
  113. package/build-module/components/list-view/index.js.map +1 -1
  114. package/build-module/components/media-replace-flow/index.js +3 -5
  115. package/build-module/components/media-replace-flow/index.js.map +1 -1
  116. package/build-module/components/provider/use-block-sync.js +2 -2
  117. package/build-module/components/provider/use-block-sync.js.map +1 -1
  118. package/build-module/components/rich-text/index.native.js +15 -4
  119. package/build-module/components/rich-text/index.native.js.map +1 -1
  120. package/build-module/components/rich-text/use-delete.js +1 -1
  121. package/build-module/components/rich-text/use-delete.js.map +1 -1
  122. package/build-module/components/rich-text/use-paste-handler.js +25 -22
  123. package/build-module/components/rich-text/use-paste-handler.js.map +1 -1
  124. package/build-module/components/spacing-sizes-control/input-controls/spacing-input-control.js +88 -0
  125. package/build-module/components/spacing-sizes-control/input-controls/spacing-input-control.js.map +1 -1
  126. package/build-module/components/tool-selector/index.js +1 -2
  127. package/build-module/components/tool-selector/index.js.map +1 -1
  128. package/build-module/components/use-block-commands/index.js +90 -46
  129. package/build-module/components/use-block-commands/index.js.map +1 -1
  130. package/build-module/components/use-setting/index.js +4 -2
  131. package/build-module/components/use-setting/index.js.map +1 -1
  132. package/build-module/components/writing-flow/use-arrow-nav.js +4 -0
  133. package/build-module/components/writing-flow/use-arrow-nav.js.map +1 -1
  134. package/build-module/hooks/block-rename-ui.js +6 -6
  135. package/build-module/hooks/block-rename-ui.js.map +1 -1
  136. package/build-module/hooks/{metadata-name.js → block-renaming.js} +3 -6
  137. package/build-module/hooks/block-renaming.js.map +1 -0
  138. package/build-module/hooks/custom-class-name.js +28 -21
  139. package/build-module/hooks/custom-class-name.js.map +1 -1
  140. package/build-module/hooks/duotone.js +28 -1
  141. package/build-module/hooks/duotone.js.map +1 -1
  142. package/build-module/hooks/index.js +1 -1
  143. package/build-module/hooks/index.js.map +1 -1
  144. package/build-module/hooks/layout.js +6 -6
  145. package/build-module/hooks/layout.js.map +1 -1
  146. package/build-module/hooks/metadata.js +6 -25
  147. package/build-module/hooks/metadata.js.map +1 -1
  148. package/build-module/hooks/utils.js +1 -1
  149. package/build-module/hooks/utils.js.map +1 -1
  150. package/build-module/layouts/grid.js +25 -3
  151. package/build-module/layouts/grid.js.map +1 -1
  152. package/build-module/layouts/utils.js +1 -1
  153. package/build-module/layouts/utils.js.map +1 -1
  154. package/build-module/lock-unlock.js +1 -1
  155. package/build-module/lock-unlock.js.map +1 -1
  156. package/build-module/store/actions.js +14 -6
  157. package/build-module/store/actions.js.map +1 -1
  158. package/build-module/utils/parse-css-unit-to-px.js +20 -0
  159. package/build-module/utils/parse-css-unit-to-px.js.map +1 -1
  160. package/build-module/utils/pasting.js +1 -1
  161. package/build-module/utils/pasting.js.map +1 -1
  162. package/build-style/style-rtl.css +11 -6
  163. package/build-style/style.css +11 -6
  164. package/package.json +31 -31
  165. package/src/components/block-controls/hook.js +6 -3
  166. package/src/components/block-list/block-outline.native.js +1 -1
  167. package/src/components/block-list/block.js +2 -0
  168. package/src/components/block-preview/index.js +7 -1
  169. package/src/components/block-styles/index.js +1 -4
  170. package/src/components/block-switcher/pattern-transformations-menu.js +1 -4
  171. package/src/components/block-switcher/style.scss +6 -0
  172. package/src/components/block-tools/block-contextual-toolbar.js +1 -0
  173. package/src/components/block-tools/style.scss +0 -1
  174. package/src/components/color-palette/test/__snapshots__/control.js.snap +3 -1
  175. package/src/components/colors-gradients/style.scss +4 -2
  176. package/src/components/dimensions-tool/index.js +25 -25
  177. package/src/components/dimensions-tool/scale-tool.js +1 -1
  178. package/src/components/height-control/index.js +50 -2
  179. package/src/components/iframe/index.js +8 -1
  180. package/src/components/image-editor/aspect-ratio-dropdown.js +0 -8
  181. package/src/components/index.native.js +1 -0
  182. package/src/components/link-control/README.md +43 -0
  183. package/src/components/link-control/link-preview.js +11 -5
  184. package/src/components/link-control/style.scss +3 -3
  185. package/src/components/link-control/test/index.js +19 -0
  186. package/src/components/link-control/use-internal-value.js +14 -10
  187. package/src/components/list-view/index.js +13 -3
  188. package/src/components/media-replace-flow/index.js +9 -14
  189. package/src/components/provider/test/use-block-sync.js +1 -1
  190. package/src/components/provider/use-block-sync.js +2 -2
  191. package/src/components/rich-text/index.native.js +19 -3
  192. package/src/components/rich-text/use-delete.js +1 -1
  193. package/src/components/rich-text/use-paste-handler.js +27 -24
  194. package/src/components/spacing-sizes-control/input-controls/spacing-input-control.js +22 -0
  195. package/src/components/tool-selector/index.js +1 -1
  196. package/src/components/use-block-commands/index.js +91 -46
  197. package/src/components/use-setting/index.js +6 -1
  198. package/src/components/writing-flow/use-arrow-nav.js +4 -0
  199. package/src/hooks/block-rename-ui.js +5 -14
  200. package/src/hooks/{metadata-name.js → block-renaming.js} +4 -7
  201. package/src/hooks/custom-class-name.js +36 -31
  202. package/src/hooks/duotone.js +33 -0
  203. package/src/hooks/index.js +1 -1
  204. package/src/hooks/layout.js +6 -6
  205. package/src/hooks/metadata.js +6 -38
  206. package/src/hooks/utils.js +2 -0
  207. package/src/layouts/grid.js +50 -2
  208. package/src/layouts/utils.js +2 -1
  209. package/src/lock-unlock.js +1 -1
  210. package/src/store/actions.js +25 -8
  211. package/src/utils/parse-css-unit-to-px.js +20 -0
  212. package/src/utils/pasting.js +1 -4
  213. package/src/utils/test/pasting.js +12 -19
  214. package/build/hooks/metadata-name.js.map +0 -1
  215. package/build-module/hooks/metadata-name.js.map +0 -1
@@ -1 +1 @@
1
- {"version":3,"names":["classnames","__","useLayoutEffect","useEffect","useRef","useState","hasBlockSupport","store","blocksStore","useSelect","ToolbarItem","ToolbarButton","ToolbarGroup","next","previous","useViewportMatch","NavigableToolbar","BlockToolbar","blockEditorStore","useHasAnyBlockControls","BlockContextualToolbar","focusOnMount","isFixed","props","isCollapsed","setIsCollapsed","toolbarButtonRef","isLargeViewport","blockType","blockEditingMode","hasParents","showParentSelector","selectedBlockClientId","select","getBlockName","getBlockParents","getSelectedBlockClientIds","getBlockEditingMode","getBlockType","selectedBlockClientIds","_selectedBlockClientId","parents","firstParentClientId","length","parentBlockName","parentBlockType","isLargerThanTabletViewport","isFullscreen","document","body","classList","contains","blockToolbar","querySelector","style","width","pinnedItems","leftHeader","computedToolbarStyle","window","getComputedStyle","computedPinnedItemsStyle","computedLeftHeaderStyle","marginLeft","parseFloat","pinnedItemsWidth","leftHeaderWidth","isToolbarEnabled","hasAnyBlockControls","classes","createElement","className","hideDragHandle","as","ref","icon","onClick","collapsed","current","focus","label"],"sources":["@wordpress/block-editor/src/components/block-tools/block-contextual-toolbar.js"],"sourcesContent":["/**\n * External dependencies\n */\nimport classnames from 'classnames';\n\n/**\n * WordPress dependencies\n */\nimport { __ } from '@wordpress/i18n';\nimport {\n\tuseLayoutEffect,\n\tuseEffect,\n\tuseRef,\n\tuseState,\n} from '@wordpress/element';\nimport { hasBlockSupport, store as blocksStore } from '@wordpress/blocks';\nimport { useSelect } from '@wordpress/data';\nimport {\n\tToolbarItem,\n\tToolbarButton,\n\tToolbarGroup,\n} from '@wordpress/components';\nimport { next, previous } from '@wordpress/icons';\nimport { useViewportMatch } from '@wordpress/compose';\n\n/**\n * Internal dependencies\n */\nimport NavigableToolbar from '../navigable-toolbar';\nimport BlockToolbar from '../block-toolbar';\nimport { store as blockEditorStore } from '../../store';\nimport { useHasAnyBlockControls } from '../block-controls/use-has-block-controls';\n\nfunction BlockContextualToolbar( { focusOnMount, isFixed, ...props } ) {\n\t// When the toolbar is fixed it can be collapsed\n\tconst [ isCollapsed, setIsCollapsed ] = useState( false );\n\tconst toolbarButtonRef = useRef();\n\n\tconst isLargeViewport = useViewportMatch( 'medium' );\n\tconst {\n\t\tblockType,\n\t\tblockEditingMode,\n\t\thasParents,\n\t\tshowParentSelector,\n\t\tselectedBlockClientId,\n\t} = useSelect( ( select ) => {\n\t\tconst {\n\t\t\tgetBlockName,\n\t\t\tgetBlockParents,\n\t\t\tgetSelectedBlockClientIds,\n\t\t\tgetBlockEditingMode,\n\t\t} = select( blockEditorStore );\n\t\tconst { getBlockType } = select( blocksStore );\n\t\tconst selectedBlockClientIds = getSelectedBlockClientIds();\n\t\tconst _selectedBlockClientId = selectedBlockClientIds[ 0 ];\n\t\tconst parents = getBlockParents( _selectedBlockClientId );\n\t\tconst firstParentClientId = parents[ parents.length - 1 ];\n\t\tconst parentBlockName = getBlockName( firstParentClientId );\n\t\tconst parentBlockType = getBlockType( parentBlockName );\n\n\t\treturn {\n\t\t\tselectedBlockClientId: _selectedBlockClientId,\n\t\t\tblockType:\n\t\t\t\t_selectedBlockClientId &&\n\t\t\t\tgetBlockType( getBlockName( _selectedBlockClientId ) ),\n\t\t\tblockEditingMode: getBlockEditingMode( _selectedBlockClientId ),\n\t\t\thasParents: parents.length,\n\t\t\tshowParentSelector:\n\t\t\t\tparentBlockType &&\n\t\t\t\tgetBlockEditingMode( firstParentClientId ) === 'default' &&\n\t\t\t\thasBlockSupport(\n\t\t\t\t\tparentBlockType,\n\t\t\t\t\t'__experimentalParentSelector',\n\t\t\t\t\ttrue\n\t\t\t\t) &&\n\t\t\t\tselectedBlockClientIds.length <= 1 &&\n\t\t\t\tgetBlockEditingMode( _selectedBlockClientId ) === 'default',\n\t\t};\n\t}, [] );\n\n\tuseEffect( () => {\n\t\tsetIsCollapsed( false );\n\t}, [ selectedBlockClientId ] );\n\n\tconst isLargerThanTabletViewport = useViewportMatch( 'large', '>=' );\n\tconst isFullscreen =\n\t\tdocument.body.classList.contains( 'is-fullscreen-mode' );\n\n\t/**\n\t * The following code is a workaround to fix the width of the toolbar\n\t * it should be removed when the toolbar will be rendered inline\n\t * FIXME: remove this layout effect when the toolbar is no longer\n\t * \t\t\t\tabsolutely positioned\n\t */\n\tuseLayoutEffect( () => {\n\t\t// don't do anything if not fixed toolbar\n\t\tif ( ! isFixed ) {\n\t\t\treturn;\n\t\t}\n\n\t\tconst blockToolbar = document.querySelector(\n\t\t\t'.block-editor-block-contextual-toolbar'\n\t\t);\n\n\t\tif ( ! blockToolbar ) {\n\t\t\treturn;\n\t\t}\n\n\t\tif ( ! blockType ) {\n\t\t\tblockToolbar.style.width = 'initial';\n\t\t\treturn;\n\t\t}\n\n\t\tif ( ! isLargerThanTabletViewport ) {\n\t\t\t// set the width of the toolbar to auto\n\t\t\tblockToolbar.style = {};\n\t\t\treturn;\n\t\t}\n\n\t\tif ( isCollapsed ) {\n\t\t\t// set the width of the toolbar to auto\n\t\t\tblockToolbar.style.width = 'auto';\n\t\t\treturn;\n\t\t}\n\n\t\t// get the width of the pinned items in the post editor or widget editor\n\t\tconst pinnedItems = document.querySelector(\n\t\t\t'.edit-post-header__settings, .edit-widgets-header__actions'\n\t\t);\n\t\t// get the width of the left header in the site editor\n\t\tconst leftHeader = document.querySelector(\n\t\t\t'.edit-site-header-edit-mode__end'\n\t\t);\n\n\t\tconst computedToolbarStyle = window.getComputedStyle( blockToolbar );\n\t\tconst computedPinnedItemsStyle = pinnedItems\n\t\t\t? window.getComputedStyle( pinnedItems )\n\t\t\t: false;\n\t\tconst computedLeftHeaderStyle = leftHeader\n\t\t\t? window.getComputedStyle( leftHeader )\n\t\t\t: false;\n\n\t\tconst marginLeft = parseFloat( computedToolbarStyle.marginLeft );\n\t\tconst pinnedItemsWidth = computedPinnedItemsStyle\n\t\t\t? parseFloat( computedPinnedItemsStyle.width )\n\t\t\t: 0;\n\t\tconst leftHeaderWidth = computedLeftHeaderStyle\n\t\t\t? parseFloat( computedLeftHeaderStyle.width )\n\t\t\t: 0;\n\n\t\t// set the new witdth of the toolbar\n\t\tblockToolbar.style.width = `calc(100% - ${\n\t\t\tleftHeaderWidth +\n\t\t\tpinnedItemsWidth +\n\t\t\tmarginLeft +\n\t\t\t( pinnedItems || leftHeader ? 2 : 0 ) + // Prevents button focus border from being cut off\n\t\t\t( isFullscreen ? 0 : 160 ) // the width of the admin sidebar expanded\n\t\t}px)`;\n\t}, [\n\t\tisFixed,\n\t\tisLargerThanTabletViewport,\n\t\tisCollapsed,\n\t\tisFullscreen,\n\t\tblockType,\n\t] );\n\n\tconst isToolbarEnabled =\n\t\t! blockType ||\n\t\thasBlockSupport( blockType, '__experimentalToolbar', true );\n\tconst hasAnyBlockControls = useHasAnyBlockControls();\n\tif (\n\t\t! isToolbarEnabled ||\n\t\t( blockEditingMode !== 'default' && ! hasAnyBlockControls )\n\t) {\n\t\treturn null;\n\t}\n\n\t// Shifts the toolbar to make room for the parent block selector.\n\tconst classes = classnames( 'block-editor-block-contextual-toolbar', {\n\t\t'has-parent': hasParents && showParentSelector,\n\t\t'is-fixed': isFixed,\n\t\t'is-collapsed': isCollapsed,\n\t} );\n\n\treturn (\n\t\t<NavigableToolbar\n\t\t\tfocusOnMount={ focusOnMount }\n\t\t\tclassName={ classes }\n\t\t\t/* translators: accessibility text for the block toolbar */\n\t\t\taria-label={ __( 'Block tools' ) }\n\t\t\t{ ...props }\n\t\t>\n\t\t\t{ ! isCollapsed && <BlockToolbar hideDragHandle={ isFixed } /> }\n\t\t\t{ isFixed && isLargeViewport && blockType && (\n\t\t\t\t<ToolbarGroup\n\t\t\t\t\tclassName={\n\t\t\t\t\t\tisCollapsed\n\t\t\t\t\t\t\t? 'block-editor-block-toolbar__group-expand-fixed-toolbar'\n\t\t\t\t\t\t\t: 'block-editor-block-toolbar__group-collapse-fixed-toolbar'\n\t\t\t\t\t}\n\t\t\t\t>\n\t\t\t\t\t<ToolbarItem\n\t\t\t\t\t\tas={ ToolbarButton }\n\t\t\t\t\t\tref={ toolbarButtonRef }\n\t\t\t\t\t\ticon={ isCollapsed ? next : previous }\n\t\t\t\t\t\tonClick={ () => {\n\t\t\t\t\t\t\tsetIsCollapsed( ( collapsed ) => ! collapsed );\n\t\t\t\t\t\t\ttoolbarButtonRef.current.focus();\n\t\t\t\t\t\t} }\n\t\t\t\t\t\tlabel={\n\t\t\t\t\t\t\tisCollapsed\n\t\t\t\t\t\t\t\t? __( 'Show block tools' )\n\t\t\t\t\t\t\t\t: __( 'Hide block tools' )\n\t\t\t\t\t\t}\n\t\t\t\t\t/>\n\t\t\t\t</ToolbarGroup>\n\t\t\t) }\n\t\t</NavigableToolbar>\n\t);\n}\n\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B;AAEA,eAAemB,sBAAsB"}
1
+ {"version":3,"names":["classnames","__","useLayoutEffect","useEffect","useRef","useState","hasBlockSupport","store","blocksStore","useSelect","ToolbarItem","ToolbarButton","ToolbarGroup","next","previous","useViewportMatch","NavigableToolbar","BlockToolbar","blockEditorStore","useHasAnyBlockControls","BlockContextualToolbar","focusOnMount","isFixed","props","isCollapsed","setIsCollapsed","toolbarButtonRef","isLargeViewport","blockType","blockEditingMode","hasParents","showParentSelector","selectedBlockClientId","select","getBlockName","getBlockParents","getSelectedBlockClientIds","getBlockEditingMode","getBlockType","selectedBlockClientIds","_selectedBlockClientId","parents","firstParentClientId","length","parentBlockName","parentBlockType","isLargerThanTabletViewport","isFullscreen","document","body","classList","contains","blockToolbar","querySelector","style","width","pinnedItems","leftHeader","computedToolbarStyle","window","getComputedStyle","computedPinnedItemsStyle","computedLeftHeaderStyle","marginLeft","parseFloat","pinnedItemsWidth","leftHeaderWidth","isToolbarEnabled","hasAnyBlockControls","classes","createElement","className","variant","undefined","hideDragHandle","as","ref","icon","onClick","collapsed","current","focus","label"],"sources":["@wordpress/block-editor/src/components/block-tools/block-contextual-toolbar.js"],"sourcesContent":["/**\n * External dependencies\n */\nimport classnames from 'classnames';\n\n/**\n * WordPress dependencies\n */\nimport { __ } from '@wordpress/i18n';\nimport {\n\tuseLayoutEffect,\n\tuseEffect,\n\tuseRef,\n\tuseState,\n} from '@wordpress/element';\nimport { hasBlockSupport, store as blocksStore } from '@wordpress/blocks';\nimport { useSelect } from '@wordpress/data';\nimport {\n\tToolbarItem,\n\tToolbarButton,\n\tToolbarGroup,\n} from '@wordpress/components';\nimport { next, previous } from '@wordpress/icons';\nimport { useViewportMatch } from '@wordpress/compose';\n\n/**\n * Internal dependencies\n */\nimport NavigableToolbar from '../navigable-toolbar';\nimport BlockToolbar from '../block-toolbar';\nimport { store as blockEditorStore } from '../../store';\nimport { useHasAnyBlockControls } from '../block-controls/use-has-block-controls';\n\nfunction BlockContextualToolbar( { focusOnMount, isFixed, ...props } ) {\n\t// When the toolbar is fixed it can be collapsed\n\tconst [ isCollapsed, setIsCollapsed ] = useState( false );\n\tconst toolbarButtonRef = useRef();\n\n\tconst isLargeViewport = useViewportMatch( 'medium' );\n\tconst {\n\t\tblockType,\n\t\tblockEditingMode,\n\t\thasParents,\n\t\tshowParentSelector,\n\t\tselectedBlockClientId,\n\t} = useSelect( ( select ) => {\n\t\tconst {\n\t\t\tgetBlockName,\n\t\t\tgetBlockParents,\n\t\t\tgetSelectedBlockClientIds,\n\t\t\tgetBlockEditingMode,\n\t\t} = select( blockEditorStore );\n\t\tconst { getBlockType } = select( blocksStore );\n\t\tconst selectedBlockClientIds = getSelectedBlockClientIds();\n\t\tconst _selectedBlockClientId = selectedBlockClientIds[ 0 ];\n\t\tconst parents = getBlockParents( _selectedBlockClientId );\n\t\tconst firstParentClientId = parents[ parents.length - 1 ];\n\t\tconst parentBlockName = getBlockName( firstParentClientId );\n\t\tconst parentBlockType = getBlockType( parentBlockName );\n\n\t\treturn {\n\t\t\tselectedBlockClientId: _selectedBlockClientId,\n\t\t\tblockType:\n\t\t\t\t_selectedBlockClientId &&\n\t\t\t\tgetBlockType( getBlockName( _selectedBlockClientId ) ),\n\t\t\tblockEditingMode: getBlockEditingMode( _selectedBlockClientId ),\n\t\t\thasParents: parents.length,\n\t\t\tshowParentSelector:\n\t\t\t\tparentBlockType &&\n\t\t\t\tgetBlockEditingMode( firstParentClientId ) === 'default' &&\n\t\t\t\thasBlockSupport(\n\t\t\t\t\tparentBlockType,\n\t\t\t\t\t'__experimentalParentSelector',\n\t\t\t\t\ttrue\n\t\t\t\t) &&\n\t\t\t\tselectedBlockClientIds.length <= 1 &&\n\t\t\t\tgetBlockEditingMode( _selectedBlockClientId ) === 'default',\n\t\t};\n\t}, [] );\n\n\tuseEffect( () => {\n\t\tsetIsCollapsed( false );\n\t}, [ selectedBlockClientId ] );\n\n\tconst isLargerThanTabletViewport = useViewportMatch( 'large', '>=' );\n\tconst isFullscreen =\n\t\tdocument.body.classList.contains( 'is-fullscreen-mode' );\n\n\t/**\n\t * The following code is a workaround to fix the width of the toolbar\n\t * it should be removed when the toolbar will be rendered inline\n\t * FIXME: remove this layout effect when the toolbar is no longer\n\t * \t\t\t\tabsolutely positioned\n\t */\n\tuseLayoutEffect( () => {\n\t\t// don't do anything if not fixed toolbar\n\t\tif ( ! isFixed ) {\n\t\t\treturn;\n\t\t}\n\n\t\tconst blockToolbar = document.querySelector(\n\t\t\t'.block-editor-block-contextual-toolbar'\n\t\t);\n\n\t\tif ( ! blockToolbar ) {\n\t\t\treturn;\n\t\t}\n\n\t\tif ( ! blockType ) {\n\t\t\tblockToolbar.style.width = 'initial';\n\t\t\treturn;\n\t\t}\n\n\t\tif ( ! isLargerThanTabletViewport ) {\n\t\t\t// set the width of the toolbar to auto\n\t\t\tblockToolbar.style = {};\n\t\t\treturn;\n\t\t}\n\n\t\tif ( isCollapsed ) {\n\t\t\t// set the width of the toolbar to auto\n\t\t\tblockToolbar.style.width = 'auto';\n\t\t\treturn;\n\t\t}\n\n\t\t// get the width of the pinned items in the post editor or widget editor\n\t\tconst pinnedItems = document.querySelector(\n\t\t\t'.edit-post-header__settings, .edit-widgets-header__actions'\n\t\t);\n\t\t// get the width of the left header in the site editor\n\t\tconst leftHeader = document.querySelector(\n\t\t\t'.edit-site-header-edit-mode__end'\n\t\t);\n\n\t\tconst computedToolbarStyle = window.getComputedStyle( blockToolbar );\n\t\tconst computedPinnedItemsStyle = pinnedItems\n\t\t\t? window.getComputedStyle( pinnedItems )\n\t\t\t: false;\n\t\tconst computedLeftHeaderStyle = leftHeader\n\t\t\t? window.getComputedStyle( leftHeader )\n\t\t\t: false;\n\n\t\tconst marginLeft = parseFloat( computedToolbarStyle.marginLeft );\n\t\tconst pinnedItemsWidth = computedPinnedItemsStyle\n\t\t\t? parseFloat( computedPinnedItemsStyle.width )\n\t\t\t: 0;\n\t\tconst leftHeaderWidth = computedLeftHeaderStyle\n\t\t\t? parseFloat( computedLeftHeaderStyle.width )\n\t\t\t: 0;\n\n\t\t// set the new witdth of the toolbar\n\t\tblockToolbar.style.width = `calc(100% - ${\n\t\t\tleftHeaderWidth +\n\t\t\tpinnedItemsWidth +\n\t\t\tmarginLeft +\n\t\t\t( pinnedItems || leftHeader ? 2 : 0 ) + // Prevents button focus border from being cut off\n\t\t\t( isFullscreen ? 0 : 160 ) // the width of the admin sidebar expanded\n\t\t}px)`;\n\t}, [\n\t\tisFixed,\n\t\tisLargerThanTabletViewport,\n\t\tisCollapsed,\n\t\tisFullscreen,\n\t\tblockType,\n\t] );\n\n\tconst isToolbarEnabled =\n\t\t! blockType ||\n\t\thasBlockSupport( blockType, '__experimentalToolbar', true );\n\tconst hasAnyBlockControls = useHasAnyBlockControls();\n\tif (\n\t\t! isToolbarEnabled ||\n\t\t( blockEditingMode !== 'default' && ! hasAnyBlockControls )\n\t) {\n\t\treturn null;\n\t}\n\n\t// Shifts the toolbar to make room for the parent block selector.\n\tconst classes = classnames( 'block-editor-block-contextual-toolbar', {\n\t\t'has-parent': hasParents && showParentSelector,\n\t\t'is-fixed': isFixed,\n\t\t'is-collapsed': isCollapsed,\n\t} );\n\n\treturn (\n\t\t<NavigableToolbar\n\t\t\tfocusOnMount={ focusOnMount }\n\t\t\tclassName={ classes }\n\t\t\t/* translators: accessibility text for the block toolbar */\n\t\t\taria-label={ __( 'Block tools' ) }\n\t\t\tvariant={ isFixed ? 'unstyled' : undefined }\n\t\t\t{ ...props }\n\t\t>\n\t\t\t{ ! isCollapsed && <BlockToolbar hideDragHandle={ isFixed } /> }\n\t\t\t{ isFixed && isLargeViewport && blockType && (\n\t\t\t\t<ToolbarGroup\n\t\t\t\t\tclassName={\n\t\t\t\t\t\tisCollapsed\n\t\t\t\t\t\t\t? 'block-editor-block-toolbar__group-expand-fixed-toolbar'\n\t\t\t\t\t\t\t: 'block-editor-block-toolbar__group-collapse-fixed-toolbar'\n\t\t\t\t\t}\n\t\t\t\t>\n\t\t\t\t\t<ToolbarItem\n\t\t\t\t\t\tas={ ToolbarButton }\n\t\t\t\t\t\tref={ toolbarButtonRef }\n\t\t\t\t\t\ticon={ isCollapsed ? next : previous }\n\t\t\t\t\t\tonClick={ () => {\n\t\t\t\t\t\t\tsetIsCollapsed( ( collapsed ) => ! collapsed );\n\t\t\t\t\t\t\ttoolbarButtonRef.current.focus();\n\t\t\t\t\t\t} }\n\t\t\t\t\t\tlabel={\n\t\t\t\t\t\t\tisCollapsed\n\t\t\t\t\t\t\t\t? __( 'Show block tools' )\n\t\t\t\t\t\t\t\t: __( 'Hide block tools' )\n\t\t\t\t\t\t}\n\t\t\t\t\t/>\n\t\t\t\t</ToolbarGroup>\n\t\t\t) }\n\t\t</NavigableToolbar>\n\t);\n}\n\nexport default BlockContextualToolbar;\n"],"mappings":";AAAA;AACA;AACA;AACA,OAAOA,UAAU,MAAM,YAAY;;AAEnC;AACA;AACA;AACA,SAASC,EAAE,QAAQ,iBAAiB;AACpC,SACCC,eAAe,EACfC,SAAS,EACTC,MAAM,EACNC,QAAQ,QACF,oBAAoB;AAC3B,SAASC,eAAe,EAAEC,KAAK,IAAIC,WAAW,QAAQ,mBAAmB;AACzE,SAASC,SAAS,QAAQ,iBAAiB;AAC3C,SACCC,WAAW,EACXC,aAAa,EACbC,YAAY,QACN,uBAAuB;AAC9B,SAASC,IAAI,EAAEC,QAAQ,QAAQ,kBAAkB;AACjD,SAASC,gBAAgB,QAAQ,oBAAoB;;AAErD;AACA;AACA;AACA,OAAOC,gBAAgB,MAAM,sBAAsB;AACnD,OAAOC,YAAY,MAAM,kBAAkB;AAC3C,SAASV,KAAK,IAAIW,gBAAgB,QAAQ,aAAa;AACvD,SAASC,sBAAsB,QAAQ,0CAA0C;AAEjF,SAASC,sBAAsBA,CAAE;EAAEC,YAAY;EAAEC,OAAO;EAAE,GAAGC;AAAM,CAAC,EAAG;EACtE;EACA,MAAM,CAAEC,WAAW,EAAEC,cAAc,CAAE,GAAGpB,QAAQ,CAAE,KAAM,CAA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,eAAe,IAAIC,SAAS,IACxC0C,aAAA,CAAC1D,YAAY;IACZ2D,SAAS,EACR/C,WAAW,GACR,wDAAwD,GACxD;EACH,GAED8C,aAAA,CAAC5D,WAAW;IACXiE,EAAE,EAAGhE,aAAe;IACpBiE,GAAG,EAAGlD,gBAAkB;IACxBmD,IAAI,EAAGrD,WAAW,GAAGX,IAAI,GAAGC,QAAU;IACtCgE,OAAO,EAAGA,CAAA,KAAM;MACfrD,cAAc,CAAIsD,SAAS,IAAM,CAAEA,SAAU,CAAC;MAC9CrD,gBAAgB,CAACsD,OAAO,CAACC,KAAK,CAAC,CAAC;IACjC,CAAG;IACHC,KAAK,EACJ1D,WAAW,GACRvB,EAAE,CAAE,kBAAmB,CAAC,GACxBA,EAAE,CAAE,kBAAmB;EAC1B,CACD,CACY,CAEE,CAAC;AAErB;AAEA,eAAemB,sBAAsB"}
@@ -118,28 +118,6 @@ function DimensionsTool({
118
118
  }
119
119
  onChange(nextValue);
120
120
  }
121
- }), showScaleControl && createElement(ScaleTool, {
122
- panelId: panelId,
123
- options: scaleOptions,
124
- defaultValue: defaultScale,
125
- value: lastScale,
126
- onChange: nextScale => {
127
- const nextValue = {
128
- ...value
129
- };
130
-
131
- // 'fill' is CSS default, so it gets treated as null.
132
- nextScale = nextScale === 'fill' ? null : nextScale;
133
- setLastScale(nextScale);
134
-
135
- // Update scale.
136
- if (!nextScale) {
137
- delete nextValue.scale;
138
- } else {
139
- nextValue.scale = nextScale;
140
- }
141
- onChange(nextValue);
142
- }
143
121
  }), createElement(WidthHeightTool, {
144
122
  panelId: panelId,
145
123
  units: unitsOptions,
@@ -195,6 +173,28 @@ function DimensionsTool({
195
173
  }
196
174
  onChange(nextValue);
197
175
  }
176
+ }), showScaleControl && createElement(ScaleTool, {
177
+ panelId: panelId,
178
+ options: scaleOptions,
179
+ defaultValue: defaultScale,
180
+ value: lastScale,
181
+ onChange: nextScale => {
182
+ const nextValue = {
183
+ ...value
184
+ };
185
+
186
+ // 'fill' is CSS default, so it gets treated as null.
187
+ nextScale = nextScale === 'fill' ? null : nextScale;
188
+ setLastScale(nextScale);
189
+
190
+ // Update scale.
191
+ if (!nextScale) {
192
+ delete nextValue.scale;
193
+ } else {
194
+ nextValue.scale = nextScale;
195
+ }
196
+ onChange(nextValue);
197
+ }
198
198
  }));
199
199
  }
200
200
  export default DimensionsTool;
@@ -1 +1 @@
1
- {"version":3,"names":["useState","AspectRatioTool","ScaleTool","WidthHeightTool","DimensionsTool","panelId","value","onChange","aspectRatioOptions","defaultAspectRatio","scaleOptions","defaultScale","unitsOptions","width","undefined","height","aspectRatio","scale","lastScale","setLastScale","lastAspectRatio","setLastAspectRatio","aspectRatioValue","showScaleControl","createElement","Fragment","options","defaultValue","nextAspectRatio","nextValue","nextScale","units","nextWidth","nextHeight"],"sources":["@wordpress/block-editor/src/components/dimensions-tool/index.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { useState } from '@wordpress/element';\n\n/**\n * Internal dependencies\n */\nimport AspectRatioTool from './aspect-ratio-tool';\nimport ScaleTool from './scale-tool';\nimport WidthHeightTool from './width-height-tool';\n\n/**\n * @typedef {import('@wordpress/components/build-types/select-control/types').SelectControlProps} SelectControlProps\n */\n\n/**\n * @typedef {import('@wordpress/components/build-types/unit-control/types').WPUnitControlUnit} WPUnitControlUnit\n */\n\n/**\n * @typedef {Object} Dimensions\n * @property {string} [width] CSS width property.\n * @property {string} [height] CSS height property.\n * @property {string} [scale] CSS object-fit property.\n * @property {string} [aspectRatio] CSS aspect-ratio property.\n */\n\n/**\n * @callback DimensionsControlsOnChange\n * @param {Dimensions} nextValue\n * @return {void}\n */\n\n/**\n * @typedef {Object} DimensionsControlsProps\n * @property {string} [panelId] ID of the panel that contains the controls.\n * @property {Dimensions} [value] Current dimensions values.\n * @property {DimensionsControlsOnChange} [onChange] Callback to update the dimensions values.\n * @property {SelectControlProps[]} [aspectRatioOptions] Aspect ratio options.\n * @property {SelectControlProps[]} [scaleOptions] Scale options.\n * @property {WPUnitControlUnit[]} [unitsOptions] Units options.\n */\n\n/**\n * Component that renders controls to edit the dimensions of an image or container.\n *\n * @param {DimensionsControlsProps} props The component props.\n *\n * @return {Element} The dimensions controls.\n */\nfunction DimensionsTool( {\n\tpanelId,\n\tvalue = {},\n\tonChange = () => {},\n\taspectRatioOptions, // Default options handled by AspectRatioTool.\n\tdefaultAspectRatio = 'auto', // Match CSS default value for aspect-ratio.\n\tscaleOptions, // Default options handled by ScaleTool.\n\tdefaultScale = 'fill', // Match CSS default value for object-fit.\n\tunitsOptions, // Default options handled by UnitControl.\n} ) {\n\t// Coerce undefined and CSS default values to be null.\n\tconst width =\n\t\tvalue.width === undefined || value.width === 'auto'\n\t\t\t? null\n\t\t\t: value.width;\n\tconst height =\n\t\tvalue.height === undefined || value.height === 'auto'\n\t\t\t? null\n\t\t\t: value.height;\n\tconst aspectRatio =\n\t\tvalue.aspectRatio === undefined || value.aspectRatio === 'auto'\n\t\t\t? null\n\t\t\t: value.aspectRatio;\n\tconst scale =\n\t\tvalue.scale === undefined || value.scale === 'fill'\n\t\t\t? null\n\t\t\t: value.scale;\n\n\t// Keep track of state internally, so when the value is cleared by means\n\t// other than directly editing that field, it's easier to restore the\n\t// previous value.\n\tconst [ lastScale, setLastScale ] = useState( scale );\n\tconst [ lastAspectRatio, setLastAspectRatio ] = useState( aspectRatio );\n\n\t// 'custom' is not a valid value for CSS aspect-ratio, but it is used in the\n\t// dropdown to indicate that setting both the width and height is the same\n\t// as a custom aspect ratio.\n\tconst aspectRatioValue = width && height ? 'custom' : lastAspectRatio;\n\n\tconst showScaleControl = aspectRatio || ( width && height );\n\n\treturn (\n\t\t<>\n\t\t\t<AspectRatioTool\n\t\t\t\tpanelId={ panelId }\n\t\t\t\toptions={ aspectRatioOptions }\n\t\t\t\tdefaultValue={ defaultAspectRatio }\n\t\t\t\tvalue={ aspectRatioValue }\n\t\t\t\tonChange={ ( nextAspectRatio ) => {\n\t\t\t\t\tconst nextValue = { ...value };\n\n\t\t\t\t\t// 'auto' is CSS default, so it gets treated as null.\n\t\t\t\t\tnextAspectRatio =\n\t\t\t\t\t\tnextAspectRatio === 'auto' ? null : nextAspectRatio;\n\n\t\t\t\t\tsetLastAspectRatio( nextAspectRatio );\n\n\t\t\t\t\t// Update aspectRatio.\n\t\t\t\t\tif ( ! nextAspectRatio ) {\n\t\t\t\t\t\tdelete nextValue.aspectRatio;\n\t\t\t\t\t} else {\n\t\t\t\t\t\tnextValue.aspectRatio = nextAspectRatio;\n\t\t\t\t\t}\n\n\t\t\t\t\t// Auto-update scale.\n\t\t\t\t\tif ( ! nextAspectRatio ) {\n\t\t\t\t\t\tdelete nextValue.scale;\n\t\t\t\t\t} else if ( lastScale ) {\n\t\t\t\t\t\tnextValue.scale = lastScale;\n\t\t\t\t\t} else {\n\t\t\t\t\t\tnextValue.scale = defaultScale;\n\t\t\t\t\t\tsetLastScale( defaultScale );\n\t\t\t\t\t}\n\n\t\t\t\t\t// Auto-update width and height.\n\t\t\t\t\tif ( 'custom' !== nextAspectRatio && width && height ) {\n\t\t\t\t\t\tdelete nextValue.height;\n\t\t\t\t\t}\n\n\t\t\t\t\tonChange( nextValue );\n\t\t\t\t} }\n\t\t\t/>\n\t\t\t{ showScaleControl && (\n\t\t\t\t<ScaleTool\n\t\t\t\t\tpanelId={ panelId }\n\t\t\t\t\toptions={ scaleOptions }\n\t\t\t\t\tdefaultValue={ defaultScale }\n\t\t\t\t\tvalue={ lastScale }\n\t\t\t\t\tonChange={ ( nextScale ) => {\n\t\t\t\t\t\tconst nextValue = { ...value };\n\n\t\t\t\t\t\t// 'fill' is CSS default, so it gets treated as null.\n\t\t\t\t\t\tnextScale = nextScale === 'fill' ? null : nextScale;\n\n\t\t\t\t\t\tsetLastScale( nextScale );\n\n\t\t\t\t\t\t// Update scale.\n\t\t\t\t\t\tif ( ! nextScale ) {\n\t\t\t\t\t\t\tdelete nextValue.scale;\n\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\tnextValue.scale = nextScale;\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\tonChange( nextValue );\n\t\t\t\t\t} }\n\t\t\t\t/>\n\t\t\t) }\n\t\t\t<WidthHeightTool\n\t\t\t\tpanelId={ panelId }\n\t\t\t\tunits={ unitsOptions }\n\t\t\t\tvalue={ { width, height } }\n\t\t\t\tonChange={ ( { width: nextWidth, height: nextHeight } ) => {\n\t\t\t\t\tconst nextValue = { ...value };\n\n\t\t\t\t\t// 'auto' is CSS default, so it gets treated as null.\n\t\t\t\t\tnextWidth = nextWidth === 'auto' ? null : nextWidth;\n\t\t\t\t\tnextHeight = nextHeight === 'auto' ? null : nextHeight;\n\n\t\t\t\t\t// Update width.\n\t\t\t\t\tif ( ! nextWidth ) {\n\t\t\t\t\t\tdelete nextValue.width;\n\t\t\t\t\t} else {\n\t\t\t\t\t\tnextValue.width = nextWidth;\n\t\t\t\t\t}\n\n\t\t\t\t\t// Update height.\n\t\t\t\t\tif ( ! nextHeight ) {\n\t\t\t\t\t\tdelete nextValue.height;\n\t\t\t\t\t} else {\n\t\t\t\t\t\tnextValue.height = nextHeight;\n\t\t\t\t\t}\n\n\t\t\t\t\t// Auto-update aspectRatio.\n\t\t\t\t\tif ( nextWidth && nextHeight ) {\n\t\t\t\t\t\tdelete nextValue.aspectRatio;\n\t\t\t\t\t} else if ( lastAspectRatio ) {\n\t\t\t\t\t\tnextValue.aspectRatio = lastAspectRatio;\n\t\t\t\t\t} else {\n\t\t\t\t\t\t// No setting defaultAspectRatio here, because\n\t\t\t\t\t\t// aspectRatio is optional in this scenario,\n\t\t\t\t\t\t// unlike scale.\n\t\t\t\t\t}\n\n\t\t\t\t\t// Auto-update scale.\n\t\t\t\t\tif ( ! lastAspectRatio && !! nextWidth !== !! nextHeight ) {\n\t\t\t\t\t\tdelete nextValue.scale;\n\t\t\t\t\t} else if ( lastScale ) {\n\t\t\t\t\t\tnextValue.scale = lastScale;\n\t\t\t\t\t} else {\n\t\t\t\t\t\tnextValue.scale = defaultScale;\n\t\t\t\t\t\tsetLastScale( defaultScale );\n\t\t\t\t\t}\n\n\t\t\t\t\tonChange( nextValue );\n\t\t\t\t} }\n\t\t\t/>\n\t\t</>\n\t);\n}\n\nexport default DimensionsTool;\n"],"mappings":";AAAA;AACA;AACA;AACA,SAASA,QAAQ,QAAQ,oBAAoB;;AAE7C;AACA;AACA;AACA,OAAOC,eAAe,MAAM,qBAAqB;AACjD,OAAOC,SAAS,MAAM,cAAc;AACpC,OAAOC,eAAe,MAAM,qBAAqB;;AAEjD;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,SAASC,cAAcA,CAAE;EACxBC,OAAO;EACPC,KAAK,GAAG,CAAC,CAAC;EACVC,QAAQ,GAAGA,CAAA,KAAM,CAAC,CAAC;EACnBC,kBAAkB;EAAE;EACpBC,kBAAkB,GAAG,MAAM;EAAE;EAC7BC,YAAY;EAAE;EACdC,YAAY,GAAG,MAAM;EAAE;EACvBC,YAAY,CAAE;AACf,CAAC,EAAG;EACH;EACA,MAAMC,KAAK,GACVP,KAAK,CAACO,KAAK,KAAKC,SAAS,IAAIR,KAAK,CAACO,KAAK,KAAK,MAAM,GAChD,IAAI,GACJP,KAAK,CAACO,KAAK;EACf,MAAME,MAAM,GACXT,KAAK,CAACS,MAAM,KAAKD,SAAS,IAAIR,KAAK,CAACS,MAAM,KAAK,MAAM,GAClD,IAAI,GACJT,KAAK,CAACS,MAAM;EAChB,MAAMC,WAAW,GAChBV,KAAK,CAACU,WAAW,KAAKF,SAAS,IAAIR,KAAK,CAACU,WAAW,KAAK,MAAM,GAC5D,IAAI,GACJV,KAAK,CAACU,WAAW;EACrB,MAAMC,KAAK,GACVX,KAAK,CAACW,KAAK,KAAKH,SAAS,IAAIR,KAAK,CAACW,KAAK,KAAK,M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C,MAAM;QACNc,SAAS,CAACd,MAAM,GAAGkB,UAAU;MAC9B;;MAEA;MACA,IAAKD,SAAS,IAAIC,UAAU,EAAG;QAC9B,OAAOJ,SAAS,CAACb,WAAW;MAC7B,CAAC,MAAM,IAAKI,eAAe,EAAG;QAC7BS,SAAS,CAACb,WAAW,GAAGI,eAAe;MACxC,CAAC,MAAM;QACN;QACA;QACA;MAAA;;MAGD;MACA,IAAK,CAAEA,eAAe,IAAI,CAAC,CAAEY,SAAS,KAAK,CAAC,CAAEC,UAAU,EAAG;QAC1D,OAAOJ,SAAS,CAACZ,KAAK;MACvB,CAAC,MAAM,IAAKC,SAAS,EAAG;QACvBW,SAAS,CAACZ,KAAK,GAAGC,SAAS;MAC5B,CAAC,MAAM;QACNW,SAAS,CAACZ,KAAK,GAAGN,YAAY;QAC9BQ,YAAY,CAAER,YAAa,CAAC;MAC7B;MAEAJ,QAAQ,CAAEsB,SAAU,CAAC;IACtB;EAAG,CACH,CACA,CAAC;AAEL;AAEA,eAAezB,cAAc"}
1
+ {"version":3,"names":["useState","AspectRatioTool","ScaleTool","WidthHeightTool","DimensionsTool","panelId","value","onChange","aspectRatioOptions","defaultAspectRatio","scaleOptions","defaultScale","unitsOptions","width","undefined","height","aspectRatio","scale","lastScale","setLastScale","lastAspectRatio","setLastAspectRatio","aspectRatioValue","showScaleControl","createElement","Fragment","options","defaultValue","nextAspectRatio","nextValue","units","nextWidth","nextHeight","nextScale"],"sources":["@wordpress/block-editor/src/components/dimensions-tool/index.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { useState } from '@wordpress/element';\n\n/**\n * Internal dependencies\n */\nimport AspectRatioTool from './aspect-ratio-tool';\nimport ScaleTool from './scale-tool';\nimport WidthHeightTool from './width-height-tool';\n\n/**\n * @typedef {import('@wordpress/components/build-types/select-control/types').SelectControlProps} SelectControlProps\n */\n\n/**\n * @typedef {import('@wordpress/components/build-types/unit-control/types').WPUnitControlUnit} WPUnitControlUnit\n */\n\n/**\n * @typedef {Object} Dimensions\n * @property {string} [width] CSS width property.\n * @property {string} [height] CSS height property.\n * @property {string} [scale] CSS object-fit property.\n * @property {string} [aspectRatio] CSS aspect-ratio property.\n */\n\n/**\n * @callback DimensionsControlsOnChange\n * @param {Dimensions} nextValue\n * @return {void}\n */\n\n/**\n * @typedef {Object} DimensionsControlsProps\n * @property {string} [panelId] ID of the panel that contains the controls.\n * @property {Dimensions} [value] Current dimensions values.\n * @property {DimensionsControlsOnChange} [onChange] Callback to update the dimensions values.\n * @property {SelectControlProps[]} [aspectRatioOptions] Aspect ratio options.\n * @property {SelectControlProps[]} [scaleOptions] Scale options.\n * @property {WPUnitControlUnit[]} [unitsOptions] Units options.\n */\n\n/**\n * Component that renders controls to edit the dimensions of an image or container.\n *\n * @param {DimensionsControlsProps} props The component props.\n *\n * @return {Element} The dimensions controls.\n */\nfunction DimensionsTool( {\n\tpanelId,\n\tvalue = {},\n\tonChange = () => {},\n\taspectRatioOptions, // Default options handled by AspectRatioTool.\n\tdefaultAspectRatio = 'auto', // Match CSS default value for aspect-ratio.\n\tscaleOptions, // Default options handled by ScaleTool.\n\tdefaultScale = 'fill', // Match CSS default value for object-fit.\n\tunitsOptions, // Default options handled by UnitControl.\n} ) {\n\t// Coerce undefined and CSS default values to be null.\n\tconst width =\n\t\tvalue.width === undefined || value.width === 'auto'\n\t\t\t? null\n\t\t\t: value.width;\n\tconst height =\n\t\tvalue.height === undefined || value.height === 'auto'\n\t\t\t? null\n\t\t\t: value.height;\n\tconst aspectRatio =\n\t\tvalue.aspectRatio === undefined || value.aspectRatio === 'auto'\n\t\t\t? null\n\t\t\t: value.aspectRatio;\n\tconst scale =\n\t\tvalue.scale === undefined || value.scale === 'fill'\n\t\t\t? null\n\t\t\t: value.scale;\n\n\t// Keep track of state internally, so when the value is cleared by means\n\t// other than directly editing that field, it's easier to restore the\n\t// previous value.\n\tconst [ lastScale, setLastScale ] = useState( scale );\n\tconst [ lastAspectRatio, setLastAspectRatio ] = useState( aspectRatio );\n\n\t// 'custom' is not a valid value for CSS aspect-ratio, but it is used in the\n\t// dropdown to indicate that setting both the width and height is the same\n\t// as a custom aspect ratio.\n\tconst aspectRatioValue = width && height ? 'custom' : lastAspectRatio;\n\n\tconst showScaleControl = aspectRatio || ( width && height );\n\n\treturn (\n\t\t<>\n\t\t\t<AspectRatioTool\n\t\t\t\tpanelId={ panelId }\n\t\t\t\toptions={ aspectRatioOptions }\n\t\t\t\tdefaultValue={ defaultAspectRatio }\n\t\t\t\tvalue={ aspectRatioValue }\n\t\t\t\tonChange={ ( nextAspectRatio ) => {\n\t\t\t\t\tconst nextValue = { ...value };\n\n\t\t\t\t\t// 'auto' is CSS default, so it gets treated as null.\n\t\t\t\t\tnextAspectRatio =\n\t\t\t\t\t\tnextAspectRatio === 'auto' ? null : nextAspectRatio;\n\n\t\t\t\t\tsetLastAspectRatio( nextAspectRatio );\n\n\t\t\t\t\t// Update aspectRatio.\n\t\t\t\t\tif ( ! nextAspectRatio ) {\n\t\t\t\t\t\tdelete nextValue.aspectRatio;\n\t\t\t\t\t} else {\n\t\t\t\t\t\tnextValue.aspectRatio = nextAspectRatio;\n\t\t\t\t\t}\n\n\t\t\t\t\t// Auto-update scale.\n\t\t\t\t\tif ( ! nextAspectRatio ) {\n\t\t\t\t\t\tdelete nextValue.scale;\n\t\t\t\t\t} else if ( lastScale ) {\n\t\t\t\t\t\tnextValue.scale = lastScale;\n\t\t\t\t\t} else {\n\t\t\t\t\t\tnextValue.scale = defaultScale;\n\t\t\t\t\t\tsetLastScale( defaultScale );\n\t\t\t\t\t}\n\n\t\t\t\t\t// Auto-update width and height.\n\t\t\t\t\tif ( 'custom' !== nextAspectRatio && width && height ) {\n\t\t\t\t\t\tdelete nextValue.height;\n\t\t\t\t\t}\n\n\t\t\t\t\tonChange( nextValue );\n\t\t\t\t} }\n\t\t\t/>\n\t\t\t<WidthHeightTool\n\t\t\t\tpanelId={ panelId }\n\t\t\t\tunits={ unitsOptions }\n\t\t\t\tvalue={ { width, height } }\n\t\t\t\tonChange={ ( { width: nextWidth, height: nextHeight } ) => {\n\t\t\t\t\tconst nextValue = { ...value };\n\n\t\t\t\t\t// 'auto' is CSS default, so it gets treated as null.\n\t\t\t\t\tnextWidth = nextWidth === 'auto' ? null : nextWidth;\n\t\t\t\t\tnextHeight = nextHeight === 'auto' ? null : nextHeight;\n\n\t\t\t\t\t// Update width.\n\t\t\t\t\tif ( ! nextWidth ) {\n\t\t\t\t\t\tdelete nextValue.width;\n\t\t\t\t\t} else {\n\t\t\t\t\t\tnextValue.width = nextWidth;\n\t\t\t\t\t}\n\n\t\t\t\t\t// Update height.\n\t\t\t\t\tif ( ! nextHeight ) {\n\t\t\t\t\t\tdelete nextValue.height;\n\t\t\t\t\t} else {\n\t\t\t\t\t\tnextValue.height = nextHeight;\n\t\t\t\t\t}\n\n\t\t\t\t\t// Auto-update aspectRatio.\n\t\t\t\t\tif ( nextWidth && nextHeight ) {\n\t\t\t\t\t\tdelete nextValue.aspectRatio;\n\t\t\t\t\t} else if ( lastAspectRatio ) {\n\t\t\t\t\t\tnextValue.aspectRatio = lastAspectRatio;\n\t\t\t\t\t} else {\n\t\t\t\t\t\t// No setting defaultAspectRatio here, because\n\t\t\t\t\t\t// aspectRatio is optional in this scenario,\n\t\t\t\t\t\t// unlike scale.\n\t\t\t\t\t}\n\n\t\t\t\t\t// Auto-update scale.\n\t\t\t\t\tif ( ! lastAspectRatio && !! nextWidth !== !! nextHeight ) {\n\t\t\t\t\t\tdelete nextValue.scale;\n\t\t\t\t\t} else if ( lastScale ) {\n\t\t\t\t\t\tnextValue.scale = lastScale;\n\t\t\t\t\t} else {\n\t\t\t\t\t\tnextValue.scale = defaultScale;\n\t\t\t\t\t\tsetLastScale( defaultScale );\n\t\t\t\t\t}\n\n\t\t\t\t\tonChange( nextValue );\n\t\t\t\t} }\n\t\t\t/>\n\t\t\t{ showScaleControl && (\n\t\t\t\t<ScaleTool\n\t\t\t\t\tpanelId={ panelId }\n\t\t\t\t\toptions={ scaleOptions }\n\t\t\t\t\tdefaultValue={ defaultScale }\n\t\t\t\t\tvalue={ lastScale }\n\t\t\t\t\tonChange={ ( nextScale ) => {\n\t\t\t\t\t\tconst nextValue = { ...value };\n\n\t\t\t\t\t\t// 'fill' is CSS default, so it gets treated as null.\n\t\t\t\t\t\tnextScale = nextScale === 'fill' ? null : nextScale;\n\n\t\t\t\t\t\tsetLastScale( nextScale );\n\n\t\t\t\t\t\t// Update scale.\n\t\t\t\t\t\tif ( ! nextScale ) {\n\t\t\t\t\t\t\tdelete nextValue.scale;\n\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\tnextValue.scale = nextScale;\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\tonChange( nextValue );\n\t\t\t\t\t} }\n\t\t\t\t/>\n\t\t\t) }\n\t\t</>\n\t);\n}\n\nexport default DimensionsTool;\n"],"mappings":";AAAA;AACA;AACA;AACA,SAASA,QAAQ,QAAQ,oBAAoB;;AAE7C;AACA;AACA;AACA,OAAOC,eAAe,MAAM,qBAAqB;AACjD,OAAOC,SAAS,MAAM,cAAc;AACpC,OAAOC,eAAe,MAAM,qBAAqB;;AAEjD;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,SAASC,cAAcA,CAAE;EACxBC,OAAO;EACPC,KAAK,GAAG,CAAC,CAAC;EACVC,QAAQ,GAAGA,CAAA,KAAM,CAAC,CAAC;EACnBC,kBAAkB;EAAE;EACpBC,kBAAkB,GAAG,MAAM;EAAE;EAC7BC,YAAY;EAAE;EACdC,YAAY,GAAG,MAAM;EAAE;EACvBC,YAAY,CAAE;AACf,CAAC,EAAG;EACH;EACA,MAAMC,KAAK,GACVP,KAAK,CAACO,KAAK,KAAKC,SAAS,IAAIR,KAAK,CAACO,KAA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C,MAAM,IAAKI,eAAe,EAAG;QAC7BS,SAAS,CAACb,WAAW,GAAGI,eAAe;MACxC,CAAC,MAAM;QACN;QACA;QACA;MAAA;;MAGD;MACA,IAAK,CAAEA,eAAe,IAAI,CAAC,CAAEW,SAAS,KAAK,CAAC,CAAEC,UAAU,EAAG;QAC1D,OAAOH,SAAS,CAACZ,KAAK;MACvB,CAAC,MAAM,IAAKC,SAAS,EAAG;QACvBW,SAAS,CAACZ,KAAK,GAAGC,SAAS;MAC5B,CAAC,MAAM;QACNW,SAAS,CAACZ,KAAK,GAAGN,YAAY;QAC9BQ,YAAY,CAAER,YAAa,CAAC;MAC7B;MAEAJ,QAAQ,CAAEsB,SAAU,CAAC;IACtB;EAAG,CACH,CAAC,EACAN,gBAAgB,IACjBC,aAAA,CAACtB,SAAS;IACTG,OAAO,EAAGA,OAAS;IACnBqB,OAAO,EAAGhB,YAAc;IACxBiB,YAAY,EAAGhB,YAAc;IAC7BL,KAAK,EAAGY,SAAW;IACnBX,QAAQ,EAAK0B,SAAS,IAAM;MAC3B,MAAMJ,SAAS,GAAG;QAAE,GAAGvB;MAAM,CAAC;;MAE9B;MACA2B,SAAS,GAAGA,SAAS,KAAK,MAAM,GAAG,IAAI,GAAGA,SAAS;MAEnDd,YAAY,CAAEc,SAAU,CAAC;;MAEzB;MACA,IAAK,CAAEA,SAAS,EAAG;QAClB,OAAOJ,SAAS,CAACZ,KAAK;MACvB,CAAC,MAAM;QACNY,SAAS,CAACZ,KAAK,GAAGgB,SAAS;MAC5B;MAEA1B,QAAQ,CAAEsB,SAAU,CAAC;IACtB;EAAG,CACH,CAED,CAAC;AAEL;AAEA,eAAezB,cAAc"}
@@ -93,7 +93,7 @@ export default function ScaleTool({
93
93
  help: scaleHelp[displayValue],
94
94
  value: displayValue,
95
95
  onChange: onChange,
96
- __nextHasNoMarginBottom: true
96
+ size: '__unstable-large'
97
97
  }, options.map(option => createElement(ToggleGroupControlOption, {
98
98
  key: option.value,
99
99
  ...option
@@ -1 +1 @@
1
- {"version":3,"names":["__experimentalToolsPanelItem","ToolsPanelItem","__experimentalToggleGroupControl","ToggleGroupControl","__experimentalToggleGroupControlOption","ToggleGroupControlOption","useMemo","__","_x","DEFAULT_SCALE_OPTIONS","value","label","help","ScaleTool","panelId","onChange","options","defaultValue","isShownByDefault","displayValue","scaleHelp","reduce","acc","option","createElement","hasValue","onDeselect","isBlock","__nextHasNoMarginBottom","map","key"],"sources":["@wordpress/block-editor/src/components/dimensions-tool/scale-tool.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport {\n\t__experimentalToolsPanelItem as ToolsPanelItem,\n\t__experimentalToggleGroupControl as ToggleGroupControl,\n\t__experimentalToggleGroupControlOption as ToggleGroupControlOption,\n} from '@wordpress/components';\nimport { useMemo } from '@wordpress/element';\nimport { __, _x } from '@wordpress/i18n';\n\n/**\n * @typedef {import('@wordpress/components/build-types/select-control/types').SelectControlProps} SelectControlProps\n */\n\n/**\n * The descriptions are purposely made generic as object-fit could be used for\n * any replaced element. Provide your own set of options if you need different\n * help text or labels.\n *\n * @see https://developer.mozilla.org/en-US/docs/Web/CSS/Replaced_element\n *\n * @type {SelectControlProps[]}\n */\nconst DEFAULT_SCALE_OPTIONS = [\n\t{\n\t\tvalue: 'fill',\n\t\tlabel: _x( 'Fill', 'Scale option for dimensions control' ),\n\t\thelp: __( 'Fill the space by stretching the content.' ),\n\t},\n\t{\n\t\tvalue: 'contain',\n\t\tlabel: _x( 'Contain', 'Scale option for dimensions control' ),\n\t\thelp: __( 'Fit the content to the space without clipping.' ),\n\t},\n\t{\n\t\tvalue: 'cover',\n\t\tlabel: _x( 'Cover', 'Scale option for dimensions control' ),\n\t\thelp: __( \"Fill the space by clipping what doesn't fit.\" ),\n\t},\n\t{\n\t\tvalue: 'none',\n\t\tlabel: _x( 'None', 'Scale option for dimensions control' ),\n\t\thelp: __(\n\t\t\t'Do not adjust the sizing of the content. Content that is too large will be clipped, and content that is too small will have additional padding.'\n\t\t),\n\t},\n\t{\n\t\tvalue: 'scale-down',\n\t\tlabel: _x( 'Scale down', 'Scale option for dimensions control' ),\n\t\thelp: __(\n\t\t\t'Scale down the content to fit the space if it is too big. Content that is too small will have additional padding.'\n\t\t),\n\t},\n];\n\n/**\n * @callback ScaleToolPropsOnChange\n * @param {string} nextValue New scale value.\n * @return {void}\n */\n\n/**\n * @typedef {Object} ScaleToolProps\n * @property {string} [panelId] ID of the panel that contains the controls.\n * @property {string} [value] Current scale value.\n * @property {ScaleToolPropsOnChange} [onChange] Callback to update the scale value.\n * @property {SelectControlProps[]} [options] Scale options.\n * @property {string} [defaultValue] Default scale value.\n * @property {boolean} [showControl=true] Whether to show the control.\n * @property {boolean} [isShownByDefault=true] Whether the tool panel is shown by default.\n */\n\n/**\n * A tool to select the CSS object-fit property for the image.\n *\n * @param {ScaleToolProps} props\n *\n * @return {import('react').ReactElement} The scale tool.\n */\nexport default function ScaleTool( {\n\tpanelId,\n\tvalue,\n\tonChange,\n\toptions = DEFAULT_SCALE_OPTIONS,\n\tdefaultValue = DEFAULT_SCALE_OPTIONS[ 0 ].value,\n\tisShownByDefault = true,\n} ) {\n\t// Match the CSS default so if the value is used directly in CSS it will look correct in the control.\n\tconst displayValue = value ?? 'fill';\n\n\tconst scaleHelp = useMemo( () => {\n\t\treturn options.reduce( ( acc, option ) => {\n\t\t\tacc[ option.value ] = option.help;\n\t\t\treturn acc;\n\t\t}, {} );\n\t}, [ options ] );\n\n\treturn (\n\t\t<ToolsPanelItem\n\t\t\tlabel={ __( 'Scale' ) }\n\t\t\tisShownByDefault={ isShownByDefault }\n\t\t\thasValue={ () => displayValue !== defaultValue }\n\t\t\tonDeselect={ () => onChange( defaultValue ) }\n\t\t\tpanelId={ panelId }\n\t\t>\n\t\t\t<ToggleGroupControl\n\t\t\t\tlabel={ __( 'Scale' ) }\n\t\t\t\tisBlock\n\t\t\t\thelp={ scaleHelp[ displayValue ] }\n\t\t\t\tvalue={ displayValue }\n\t\t\t\tonChange={ onChange }\n\t\t\t\t__nextHasNoMarginBottom\n\t\t\t>\n\t\t\t\t{ options.map( ( option ) => (\n\t\t\t\t\t<ToggleGroupControlOption\n\t\t\t\t\t\tkey={ option.value }\n\t\t\t\t\t\t{ ...option }\n\t\t\t\t\t/>\n\t\t\t\t) ) }\n\t\t\t</ToggleGroupControl>\n\t\t</ToolsPanelItem>\n\t);\n}\n"],"mappings":";AAAA;AACA;AACA;AACA,SACCA,4BAA4B,IAAIC,cAAc,EAC9CC,gCAAgC,IAAIC,kBAAkB,EACtDC,sCAAsC,IAAIC,wBAAwB,QAC5D,uBAAuB;AAC9B,SAASC,OAAO,QAAQ,oBAAoB;AAC5C,SAASC,EAAE,EAAEC,EAAE,QAAQ,iBAAiB;;AAExC;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,MAAMC,qBAAqB,GAAG,CAC7B;EACCC,KAAK,EAAE,MAAM;EACbC,KAAK,EAAEH,EAAE,CAAE,MAAM,EAAE,qCAAsC,CAAC;EAC1DI,IAAI,EAAEL,EAAE,CAAE,2CAA4C;AACvD,CAAC,EACD;EACCG,KAAK,EAAE,SAAS;EAChBC,KAAK,EAAEH,EAAE,CAAE,SAAS,EAAE,qCAAsC,CAAC;EAC7DI,IAAI,EAAEL,EAAE,CAAE,gDAAiD;AAC5D,CAAC,EACD;EACCG,KAAK,EAAE,OAAO;EACdC,KAAK,EAAEH,EAAE,CAAE,OAAO,EAAE,qCAAsC,CAAC;EAC3DI,IAAI,EAAEL,EAAE,CAAE,8CAA+C;AAC1D,CAAC,EACD;EACCG,KAAK,EAAE,MAAM;EACbC,KAAK,EAAEH,EAAE,CAAE,MAAM,EAAE,qCAAsC,CAAC;EAC1DI,IAAI,EAAEL,EAAE,CACP,iJACD;AACD,CAAC,EACD;EACCG,KAAK,EAAE,YAAY;EACnBC,KAAK,EAAEH,EAAE,CAAE,YAAY,EAAE,qCAAsC,CAAC;EAChEI,IAAI,EAAEL,EAAE,CACP,mHACD;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AGP,MAAM,CAACb,KAAO;IAAA,GACfa;EAAM,CACX,CACA,CACiB,CACL,CAAC;AAEnB"}
1
+ {"version":3,"names":["__experimentalToolsPanelItem","ToolsPanelItem","__experimentalToggleGroupControl","ToggleGroupControl","__experimentalToggleGroupControlOption","ToggleGroupControlOption","useMemo","__","_x","DEFAULT_SCALE_OPTIONS","value","label","help","ScaleTool","panelId","onChange","options","defaultValue","isShownByDefault","displayValue","scaleHelp","reduce","acc","option","createElement","hasValue","onDeselect","isBlock","size","map","key"],"sources":["@wordpress/block-editor/src/components/dimensions-tool/scale-tool.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport {\n\t__experimentalToolsPanelItem as ToolsPanelItem,\n\t__experimentalToggleGroupControl as ToggleGroupControl,\n\t__experimentalToggleGroupControlOption as ToggleGroupControlOption,\n} from '@wordpress/components';\nimport { useMemo } from '@wordpress/element';\nimport { __, _x } from '@wordpress/i18n';\n\n/**\n * @typedef {import('@wordpress/components/build-types/select-control/types').SelectControlProps} SelectControlProps\n */\n\n/**\n * The descriptions are purposely made generic as object-fit could be used for\n * any replaced element. Provide your own set of options if you need different\n * help text or labels.\n *\n * @see https://developer.mozilla.org/en-US/docs/Web/CSS/Replaced_element\n *\n * @type {SelectControlProps[]}\n */\nconst DEFAULT_SCALE_OPTIONS = [\n\t{\n\t\tvalue: 'fill',\n\t\tlabel: _x( 'Fill', 'Scale option for dimensions control' ),\n\t\thelp: __( 'Fill the space by stretching the content.' ),\n\t},\n\t{\n\t\tvalue: 'contain',\n\t\tlabel: _x( 'Contain', 'Scale option for dimensions control' ),\n\t\thelp: __( 'Fit the content to the space without clipping.' ),\n\t},\n\t{\n\t\tvalue: 'cover',\n\t\tlabel: _x( 'Cover', 'Scale option for dimensions control' ),\n\t\thelp: __( \"Fill the space by clipping what doesn't fit.\" ),\n\t},\n\t{\n\t\tvalue: 'none',\n\t\tlabel: _x( 'None', 'Scale option for dimensions control' ),\n\t\thelp: __(\n\t\t\t'Do not adjust the sizing of the content. Content that is too large will be clipped, and content that is too small will have additional padding.'\n\t\t),\n\t},\n\t{\n\t\tvalue: 'scale-down',\n\t\tlabel: _x( 'Scale down', 'Scale option for dimensions control' ),\n\t\thelp: __(\n\t\t\t'Scale down the content to fit the space if it is too big. Content that is too small will have additional padding.'\n\t\t),\n\t},\n];\n\n/**\n * @callback ScaleToolPropsOnChange\n * @param {string} nextValue New scale value.\n * @return {void}\n */\n\n/**\n * @typedef {Object} ScaleToolProps\n * @property {string} [panelId] ID of the panel that contains the controls.\n * @property {string} [value] Current scale value.\n * @property {ScaleToolPropsOnChange} [onChange] Callback to update the scale value.\n * @property {SelectControlProps[]} [options] Scale options.\n * @property {string} [defaultValue] Default scale value.\n * @property {boolean} [showControl=true] Whether to show the control.\n * @property {boolean} [isShownByDefault=true] Whether the tool panel is shown by default.\n */\n\n/**\n * A tool to select the CSS object-fit property for the image.\n *\n * @param {ScaleToolProps} props\n *\n * @return {import('react').ReactElement} The scale tool.\n */\nexport default function ScaleTool( {\n\tpanelId,\n\tvalue,\n\tonChange,\n\toptions = DEFAULT_SCALE_OPTIONS,\n\tdefaultValue = DEFAULT_SCALE_OPTIONS[ 0 ].value,\n\tisShownByDefault = true,\n} ) {\n\t// Match the CSS default so if the value is used directly in CSS it will look correct in the control.\n\tconst displayValue = value ?? 'fill';\n\n\tconst scaleHelp = useMemo( () => {\n\t\treturn options.reduce( ( acc, option ) => {\n\t\t\tacc[ option.value ] = option.help;\n\t\t\treturn acc;\n\t\t}, {} );\n\t}, [ options ] );\n\n\treturn (\n\t\t<ToolsPanelItem\n\t\t\tlabel={ __( 'Scale' ) }\n\t\t\tisShownByDefault={ isShownByDefault }\n\t\t\thasValue={ () => displayValue !== defaultValue }\n\t\t\tonDeselect={ () => onChange( defaultValue ) }\n\t\t\tpanelId={ panelId }\n\t\t>\n\t\t\t<ToggleGroupControl\n\t\t\t\tlabel={ __( 'Scale' ) }\n\t\t\t\tisBlock\n\t\t\t\thelp={ scaleHelp[ displayValue ] }\n\t\t\t\tvalue={ displayValue }\n\t\t\t\tonChange={ onChange }\n\t\t\t\tsize={ '__unstable-large' }\n\t\t\t>\n\t\t\t\t{ options.map( ( option ) => (\n\t\t\t\t\t<ToggleGroupControlOption\n\t\t\t\t\t\tkey={ option.value }\n\t\t\t\t\t\t{ ...option }\n\t\t\t\t\t/>\n\t\t\t\t) ) }\n\t\t\t</ToggleGroupControl>\n\t\t</ToolsPanelItem>\n\t);\n}\n"],"mappings":";AAAA;AACA;AACA;AACA,SACCA,4BAA4B,IAAIC,cAAc,EAC9CC,gCAAgC,IAAIC,kBAAkB,EACtDC,sCAAsC,IAAIC,wBAAwB,QAC5D,uBAAuB;AAC9B,SAASC,OAAO,QAAQ,oBAAoB;AAC5C,SAASC,EAAE,EAAEC,EAAE,QAAQ,iBAAiB;;AAExC;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,MAAMC,qBAAqB,GAAG,CAC7B;EACCC,KAAK,EAAE,MAAM;EACbC,KAAK,EAAEH,EAAE,CAAE,MAAM,EAAE,qCAAsC,CAAC;EAC1DI,IAAI,EAAEL,EAAE,CAAE,2CAA4C;AACvD,CAAC,EACD;EACCG,KAAK,EAAE,SAAS;EAChBC,KAAK,EAAEH,EAAE,CAAE,SAAS,EAAE,qCAAsC,CAAC;EAC7DI,IAAI,EAAEL,EAAE,CAAE,gDAAiD;AAC5D,CAAC,EACD;EACCG,KAAK,EAAE,OAAO;EACdC,KAAK,EAAEH,EAAE,CAAE,OAAO,EAAE,qCAAsC,CAAC;EAC3DI,IAAI,EAAEL,EAAE,CAAE,8CAA+C;AAC1D,CAAC,EACD;EACCG,KAAK,EAAE,MAAM;EACbC,KAAK,EAAEH,EAAE,CAAE,MAAM,EAAE,qCAAsC,CAAC;EAC1DI,IAAI,EAAEL,EAAE,CACP,iJACD;AACD,CAAC,EACD;EACCG,KAAK,EAAE,YAAY;EACnBC,KAAK,EAAEH,EAAE,CAAE,YAAY,EAAE,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CAAIN,MAAM,IACtBC,aAAA,CAACnB,wBAAwB;IACxByB,GAAG,EAAGP,MAAM,CAACb,KAAO;IAAA,GACfa;EAAM,CACX,CACA,CACiB,CACL,CAAC;AAEnB"}
@@ -34,6 +34,94 @@ const RANGE_CONTROL_CUSTOM_SETTINGS = {
34
34
  rem: {
35
35
  max: 50,
36
36
  step: 0.1
37
+ },
38
+ svw: {
39
+ max: 100,
40
+ step: 1
41
+ },
42
+ lvw: {
43
+ max: 100,
44
+ step: 1
45
+ },
46
+ dvw: {
47
+ max: 100,
48
+ step: 1
49
+ },
50
+ svh: {
51
+ max: 100,
52
+ step: 1
53
+ },
54
+ lvh: {
55
+ max: 100,
56
+ step: 1
57
+ },
58
+ dvh: {
59
+ max: 100,
60
+ step: 1
61
+ },
62
+ vi: {
63
+ max: 100,
64
+ step: 1
65
+ },
66
+ svi: {
67
+ max: 100,
68
+ step: 1
69
+ },
70
+ lvi: {
71
+ max: 100,
72
+ step: 1
73
+ },
74
+ dvi: {
75
+ max: 100,
76
+ step: 1
77
+ },
78
+ vb: {
79
+ max: 100,
80
+ step: 1
81
+ },
82
+ svb: {
83
+ max: 100,
84
+ step: 1
85
+ },
86
+ lvb: {
87
+ max: 100,
88
+ step: 1
89
+ },
90
+ dvb: {
91
+ max: 100,
92
+ step: 1
93
+ },
94
+ vmin: {
95
+ max: 100,
96
+ step: 1
97
+ },
98
+ svmin: {
99
+ max: 100,
100
+ step: 1
101
+ },
102
+ lvmin: {
103
+ max: 100,
104
+ step: 1
105
+ },
106
+ dvmin: {
107
+ max: 100,
108
+ step: 1
109
+ },
110
+ vmax: {
111
+ max: 100,
112
+ step: 1
113
+ },
114
+ svmax: {
115
+ max: 100,
116
+ step: 1
117
+ },
118
+ lvmax: {
119
+ max: 100,
120
+ step: 1
121
+ },
122
+ dvmax: {
123
+ max: 100,
124
+ step: 1
37
125
  }
38
126
  };
39
127
 
@@ -73,8 +161,8 @@ export default function HeightControl({
73
161
  } else if (['em', 'rem'].includes(currentUnit) && newUnit === 'px') {
74
162
  // Convert to pixel value assuming a root size of 16px.
75
163
  onChange(Math.round(currentValue * 16) + newUnit);
76
- } else if (['vh', 'vw', '%'].includes(newUnit) && currentValue > 100) {
77
- // When converting to `vh`, `vw`, or `%` units, cap the new value at 100.
164
+ } else if (['%', 'vw', 'svw', 'lvw', 'dvw', 'vh', 'svh', 'lvh', 'dvh', 'vi', 'svi', 'lvi', 'dvi', 'vb', 'svb', 'lvb', 'dvb', 'vmin', 'svmin', 'lvmin', 'dvmin', 'vmax', 'svmax', 'lvmax', 'dvmax'].includes(newUnit) && currentValue > 100) {
165
+ // When converting to `%` or viewport-relative units, cap the new value at 100.
78
166
  onChange(100 + newUnit);
79
167
  }
80
168
  };
@@ -1 +1 @@
1
- {"version":3,"names":["useMemo","BaseControl","RangeControl","Flex","FlexItem","__experimentalSpacer","Spacer","__experimentalUseCustomUnits","useCustomUnits","__experimentalUnitControl","UnitControl","__experimentalParseQuantityAndUnitFromRawValue","parseQuantityAndUnitFromRawValue","__","useSetting","RANGE_CONTROL_CUSTOM_SETTINGS","px","max","step","vw","vh","em","rem","HeightControl","label","onChange","value","_RANGE_CONTROL_CUSTOM","_RANGE_CONTROL_CUSTOM2","customRangeValue","parseFloat","units","availableUnits","selectedUnit","handleSliderChange","next","join","handleUnitChange","newUnit","currentValue","currentUnit","includes","toFixed","Math","round","createElement","className","VisualLabel","as","isBlock","onUnitChange","min","size","marginX","marginBottom","withInputField","__nextHasNoMarginBottom"],"sources":["@wordpress/block-editor/src/components/height-control/index.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { useMemo } from '@wordpress/element';\nimport {\n\tBaseControl,\n\tRangeControl,\n\tFlex,\n\tFlexItem,\n\t__experimentalSpacer as Spacer,\n\t__experimentalUseCustomUnits as useCustomUnits,\n\t__experimentalUnitControl as UnitControl,\n\t__experimentalParseQuantityAndUnitFromRawValue as parseQuantityAndUnitFromRawValue,\n} from '@wordpress/components';\nimport { __ } from '@wordpress/i18n';\n\n/**\n * Internal dependencies\n */\nimport useSetting from '../use-setting';\n\nconst RANGE_CONTROL_CUSTOM_SETTINGS = {\n\tpx: { max: 1000, step: 1 },\n\t'%': { max: 100, step: 1 },\n\tvw: { max: 100, step: 1 },\n\tvh: { max: 100, step: 1 },\n\tem: { max: 50, step: 0.1 },\n\trem: { max: 50, step: 0.1 },\n};\n\n/**\n * HeightControl renders a linked unit control and range control for adjusting the height of a block.\n *\n * @see https://github.com/WordPress/gutenberg/blob/HEAD/packages/block-editor/src/components/height-control/README.md\n *\n * @param {Object} props\n * @param {?string} props.label A label for the control.\n * @param {( value: string ) => void } props.onChange Called when the height changes.\n * @param {string} props.value The current height value.\n *\n * @return {Component} The component to be rendered.\n */\nexport default function HeightControl( {\n\tlabel = __( 'Height' ),\n\tonChange,\n\tvalue,\n} ) {\n\tconst customRangeValue = parseFloat( value );\n\n\tconst units = useCustomUnits( {\n\t\tavailableUnits: useSetting( 'spacing.units' ) || [\n\t\t\t'%',\n\t\t\t'px',\n\t\t\t'em',\n\t\t\t'rem',\n\t\t\t'vh',\n\t\t\t'vw',\n\t\t],\n\t} );\n\n\tconst selectedUnit =\n\t\tuseMemo(\n\t\t\t() => parseQuantityAndUnitFromRawValue( value ),\n\t\t\t[ value ]\n\t\t)[ 1 ] ||\n\t\tunits[ 0 ]?.value ||\n\t\t'px';\n\n\tconst handleSliderChange = ( next ) => {\n\t\tonChange( [ next, selectedUnit ].join( '' ) );\n\t};\n\n\tconst handleUnitChange = ( newUnit ) => {\n\t\t// Attempt to smooth over differences between currentUnit and newUnit.\n\t\t// This should slightly improve the experience of switching between unit types.\n\t\tconst [ currentValue, currentUnit ] =\n\t\t\tparseQuantityAndUnitFromRawValue( value );\n\n\t\tif ( [ 'em', 'rem' ].includes( newUnit ) && currentUnit === 'px' ) {\n\t\t\t// Convert pixel value to an approximate of the new unit, assuming a root size of 16px.\n\t\t\tonChange( ( currentValue / 16 ).toFixed( 2 ) + newUnit );\n\t\t} else if (\n\t\t\t[ 'em', 'rem' ].includes( currentUnit ) &&\n\t\t\tnewUnit === 'px'\n\t\t) {\n\t\t\t// Convert to pixel value assuming a root size of 16px.\n\t\t\tonChange( Math.round( currentValue * 16 ) + newUnit );\n\t\t} else if (\n\t\t\t[ 'vh', 'vw', '%' ].includes( newUnit ) &&\n\t\t\tcurrentValue > 100\n\t\t) {\n\t\t\t// When converting to `vh`, `vw`, or `%` units, cap the new value at 100.\n\t\t\tonChange( 100 + newUnit );\n\t\t}\n\t};\n\n\treturn (\n\t\t<fieldset className=\"block-editor-height-control\">\n\t\t\t<BaseControl.VisualLabel as=\"legend\">\n\t\t\t\t{ label }\n\t\t\t</BaseControl.VisualLabel>\n\t\t\t<Flex>\n\t\t\t\t<FlexItem isBlock>\n\t\t\t\t\t<UnitControl\n\t\t\t\t\t\tvalue={ value }\n\t\t\t\t\t\tunits={ units }\n\t\t\t\t\t\tonChange={ onChange }\n\t\t\t\t\t\tonUnitChange={ handleUnitChange }\n\t\t\t\t\t\tmin={ 0 }\n\t\t\t\t\t\tsize={ '__unstable-large' }\n\t\t\t\t\t/>\n\t\t\t\t</FlexItem>\n\t\t\t\t<FlexItem isBlock>\n\t\t\t\t\t<Spacer marginX={ 2 } marginBottom={ 0 }>\n\t\t\t\t\t\t<RangeControl\n\t\t\t\t\t\t\tvalue={ customRangeValue }\n\t\t\t\t\t\t\tmin={ 0 }\n\t\t\t\t\t\t\tmax={\n\t\t\t\t\t\t\t\tRANGE_CONTROL_CUSTOM_SETTINGS[ selectedUnit ]\n\t\t\t\t\t\t\t\t\t?.max ?? 100\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\tstep={\n\t\t\t\t\t\t\t\tRANGE_CONTROL_CUSTOM_SETTINGS[ selectedUnit ]\n\t\t\t\t\t\t\t\t\t?.step ?? 0.1\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\twithInputField={ false }\n\t\t\t\t\t\t\tonChange={ handleSliderChange }\n\t\t\t\t\t\t\t__nextHasN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CO,aAAA;IAAUC,SAAS,EAAC;EAA6B,GAChDD,aAAA,CAAC5C,WAAW,CAAC8C,WAAW;IAACC,EAAE,EAAC;EAAQ,GACjCxB,KACsB,CAAC,EAC1BqB,aAAA,CAAC1C,IAAI,QACJ0C,aAAA,CAACzC,QAAQ;IAAC6C,OAAO;EAAA,GAChBJ,aAAA,CAACnC,WAAW;IACXgB,KAAK,EAAGA,KAAO;IACfK,KAAK,EAAGA,KAAO;IACfN,QAAQ,EAAGA,QAAU;IACrByB,YAAY,EAAGb,gBAAkB;IACjCc,GAAG,EAAG,CAAG;IACTC,IAAI,EAAG;EAAoB,CAC3B,CACQ,CAAC,EACXP,aAAA,CAACzC,QAAQ;IAAC6C,OAAO;EAAA,GAChBJ,aAAA,CAACvC,MAAM;IAAC+C,OAAO,EAAG,CAAG;IAACC,YAAY,EAAG;EAAG,GACvCT,aAAA,CAAC3C,YAAY;IACZwB,KAAK,EAAGG,gBAAkB;IAC1BsB,GAAG,EAAG,CAAG;IACTlC,GAAG,GAAAU,qBAAA,GACFZ,6BAA6B,CAAEkB,YAAY,CAAE,EAC1ChB,GAAG,cAAAU,qBAAA,cAAAA,qBAAA,GAAI,GACV;IACDT,IAAI,GAAAU,sBAAA,GACHb,6BAA6B,CAAEkB,YAAY,CAAE,EAC1Cf,IAAI,cAAAU,sBAAA,cAAAA,sBAAA,GAAI,GACX;IACD2B,cAAc,EAAG,KAAO;IACxB9B,QAAQ,EAAGS,kBAAoB;IAC/BsB,uBAAuB;EAAA,CACvB,CACM,CACC,CACL,CACG,CAAC;AAEb"}
1
+ {"version":3,"names":["useMemo","BaseControl","RangeControl","Flex","FlexItem","__experimentalSpacer","Spacer","__experimentalUseCustomUnits","useCustomUnits","__experimentalUnitControl","UnitControl","__experimentalParseQuantityAndUnitFromRawValue","parseQuantityAndUnitFromRawValue","__","useSetting","RANGE_CONTROL_CUSTOM_SETTINGS","px","max","step","vw","vh","em","rem","svw","lvw","dvw","svh","lvh","dvh","vi","svi","lvi","dvi","vb","svb","lvb","dvb","vmin","svmin","lvmin","dvmin","vmax","svmax","lvmax","dvmax","HeightControl","label","onChange","value","_RANGE_CONTROL_CUSTOM","_RANGE_CONTROL_CUSTOM2","customRangeValue","parseFloat","units","availableUnits","selectedUnit","handleSliderChange","next","join","handleUnitChange","newUnit","currentValue","currentUnit","includes","toFixed","Math","round","createElement","className","VisualLabel","as","isBlock","onUnitChange","min","size","marginX","marginBottom","withInputField","__nextHasNoMarginBottom"],"sources":["@wordpress/block-editor/src/components/height-control/index.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { useMemo } from '@wordpress/element';\nimport {\n\tBaseControl,\n\tRangeControl,\n\tFlex,\n\tFlexItem,\n\t__experimentalSpacer as Spacer,\n\t__experimentalUseCustomUnits as useCustomUnits,\n\t__experimentalUnitControl as UnitControl,\n\t__experimentalParseQuantityAndUnitFromRawValue as parseQuantityAndUnitFromRawValue,\n} from '@wordpress/components';\nimport { __ } from '@wordpress/i18n';\n\n/**\n * Internal dependencies\n */\nimport useSetting from '../use-setting';\n\nconst RANGE_CONTROL_CUSTOM_SETTINGS = {\n\tpx: { max: 1000, step: 1 },\n\t'%': { max: 100, step: 1 },\n\tvw: { max: 100, step: 1 },\n\tvh: { max: 100, step: 1 },\n\tem: { max: 50, step: 0.1 },\n\trem: { max: 50, step: 0.1 },\n\tsvw: { max: 100, step: 1 },\n\tlvw: { max: 100, step: 1 },\n\tdvw: { max: 100, step: 1 },\n\tsvh: { max: 100, step: 1 },\n\tlvh: { max: 100, step: 1 },\n\tdvh: { max: 100, step: 1 },\n\tvi: { max: 100, step: 1 },\n\tsvi: { max: 100, step: 1 },\n\tlvi: { max: 100, step: 1 },\n\tdvi: { max: 100, step: 1 },\n\tvb: { max: 100, step: 1 },\n\tsvb: { max: 100, step: 1 },\n\tlvb: { max: 100, step: 1 },\n\tdvb: { max: 100, step: 1 },\n\tvmin: { max: 100, step: 1 },\n\tsvmin: { max: 100, step: 1 },\n\tlvmin: { max: 100, step: 1 },\n\tdvmin: { max: 100, step: 1 },\n\tvmax: { max: 100, step: 1 },\n\tsvmax: { max: 100, step: 1 },\n\tlvmax: { max: 100, step: 1 },\n\tdvmax: { max: 100, step: 1 },\n};\n\n/**\n * HeightControl renders a linked unit control and range control for adjusting the height of a block.\n *\n * @see https://github.com/WordPress/gutenberg/blob/HEAD/packages/block-editor/src/components/height-control/README.md\n *\n * @param {Object} props\n * @param {?string} props.label A label for the control.\n * @param {( value: string ) => void } props.onChange Called when the height changes.\n * @param {string} props.value The current height value.\n *\n * @return {Component} The component to be rendered.\n */\nexport default function HeightControl( {\n\tlabel = __( 'Height' ),\n\tonChange,\n\tvalue,\n} ) {\n\tconst customRangeValue = parseFloat( value );\n\n\tconst units = useCustomUnits( {\n\t\tavailableUnits: useSetting( 'spacing.units' ) || [\n\t\t\t'%',\n\t\t\t'px',\n\t\t\t'em',\n\t\t\t'rem',\n\t\t\t'vh',\n\t\t\t'vw',\n\t\t],\n\t} );\n\n\tconst selectedUnit =\n\t\tuseMemo(\n\t\t\t() => parseQuantityAndUnitFromRawValue( value ),\n\t\t\t[ value ]\n\t\t)[ 1 ] ||\n\t\tunits[ 0 ]?.value ||\n\t\t'px';\n\n\tconst handleSliderChange = ( next ) => {\n\t\tonChange( [ next, selectedUnit ].join( '' ) );\n\t};\n\n\tconst handleUnitChange = ( newUnit ) => {\n\t\t// Attempt to smooth over differences between currentUnit and newUnit.\n\t\t// This should slightly improve the experience of switching between unit types.\n\t\tconst [ currentValue, currentUnit ] =\n\t\t\tparseQuantityAndUnitFromRawValue( value );\n\n\t\tif ( [ 'em', 'rem' ].includes( newUnit ) && currentUnit === 'px' ) {\n\t\t\t// Convert pixel value to an approximate of the new unit, assuming a root size of 16px.\n\t\t\tonChange( ( currentValue / 16 ).toFixed( 2 ) + newUnit );\n\t\t} else if (\n\t\t\t[ 'em', 'rem' ].includes( currentUnit ) &&\n\t\t\tnewUnit === 'px'\n\t\t) {\n\t\t\t// Convert to pixel value assuming a root size of 16px.\n\t\t\tonChange( Math.round( currentValue * 16 ) + newUnit );\n\t\t} else if (\n\t\t\t[\n\t\t\t\t'%',\n\t\t\t\t'vw',\n\t\t\t\t'svw',\n\t\t\t\t'lvw',\n\t\t\t\t'dvw',\n\t\t\t\t'vh',\n\t\t\t\t'svh',\n\t\t\t\t'lvh',\n\t\t\t\t'dvh',\n\t\t\t\t'vi',\n\t\t\t\t'svi',\n\t\t\t\t'lvi',\n\t\t\t\t'dvi',\n\t\t\t\t'vb',\n\t\t\t\t'svb',\n\t\t\t\t'lvb',\n\t\t\t\t'dvb',\n\t\t\t\t'vmin',\n\t\t\t\t'svmin',\n\t\t\t\t'lvmin',\n\t\t\t\t'dvmin',\n\t\t\t\t'vmax',\n\t\t\t\t'svmax',\n\t\t\t\t'lvmax',\n\t\t\t\t'dvmax',\n\t\t\t].includes( newUnit ) &&\n\t\t\tcurrentValue > 100\n\t\t) {\n\t\t\t// When converting to `%` or viewport-relative units, cap the new value at 100.\n\t\t\tonChange( 100 + newUnit );\n\t\t}\n\t};\n\n\treturn (\n\t\t<fieldset className=\"block-editor-height-control\">\n\t\t\t<BaseControl.VisualLabel as=\"legend\">\n\t\t\t\t{ label }\n\t\t\t</BaseControl.VisualLabel>\n\t\t\t<Flex>\n\t\t\t\t<FlexItem isBlock>\n\t\t\t\t\t<UnitControl\n\t\t\t\t\t\tvalue={ value }\n\t\t\t\t\t\tunits={ units }\n\t\t\t\t\t\tonChange={ onChange }\n\t\t\t\t\t\tonUnitChange={ handleUnitChange }\n\t\t\t\t\t\tmin={ 0 }\n\t\t\t\t\t\tsize={ '__unstable-large' }\n\t\t\t\t\t/>\n\t\t\t\t</FlexItem>\n\t\t\t\t<FlexItem isBlock>\n\t\t\t\t\t<Spacer marginX={ 2 } marginBottom={ 0 }>\n\t\t\t\t\t\t<RangeControl\n\t\t\t\t\t\t\tvalue={ customRangeValue }\n\t\t\t\t\t\t\tmin={ 0 }\n\t\t\t\t\t\t\tmax={\n\t\t\t\t\t\t\t\tRANGE_CONTROL_CUSTOM_SETTINGS[ selectedUnit ]\n\t\t\t\t\t\t\t\t\t?.max ?? 100\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\tstep={\n\t\t\t\t\t\t\t\tRANGE_CONTROL_CUSTOM_SETTINGS[ selectedUnit ]\n\t\t\t\t\t\t\t\t\t?.step ?? 0.1\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\twithInputField={ false }\n\t\t\t\t\t\t\tonChange={ handleSliderChange }\n\t\t\t\t\t\t\t__nextHasNoMarginBottom\n\t\t\t\t\t\t/>\n\t\t\t\t\t</Spacer>\n\t\t\t\t</FlexItem>\n\t\t\t</Flex>\n\t\t</fieldset>\n\t);\n}\n"],"mappings":";AAAA;AACA;AACA;AACA,SAASA,OAAO,QAAQ,oBAAoB;AAC5C,SACCC,WAAW,EACXC,YAAY,EACZC,IAAI,EACJC,QAAQ,EACRC,oBAAoB,IAAIC,MAAM,EAC9BC,4BAA4B,IAAIC,cAAc,EAC9CC,yBAAyB,IAAIC,WAAW,EACxCC,8CAA8C,IAAIC,gCAAgC,QAC5E,uBAAuB;AAC9B,SAASC,EAAE,QAAQ,iBAAiB;;AAEpC;AACA;AACA;AACA,OAAOC,UAAU,MAAM,gBAAgB;AAEvC,MAAMC,6BAA6B,GAAG;EACrCC,EAAE,EAAE;IAAEC,GAAG,EAAE,IAAI;IAAEC,IAAI,EAAE;EAAE,CAAC;EAC1B,GAAG,EAAE;IAAED,GAAG,EAAE,GAAG;IAAEC,IAAI,EAAE;EAAE,CAAC;EAC1BC,EAAE,EAAE;IAAEF,GAAG,EAAE,GAAG;IAAEC,IAAI,EAAE;EAAE,CAAC;EACzBE,EAAE,EAAE;IAAEH,GAAG,EAAE,GAAG;IAAEC,IAAI,EAAE;EAAE,CAAC;EACzBG,EAAE,EAAE;IAAEJ,GAAG,EAAE,EAAE;IAAEC,IAAI,EAAE;EAAI,CAAC;EAC1BI,GAAG,EAAE;IAAEL,GAAG,EAA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,CAAC/D,QAAQ;IAACmE,OAAO;EAAA,GAChBJ,aAAA,CAACzD,WAAW;IACXsC,KAAK,EAAGA,KAAO;IACfK,KAAK,EAAGA,KAAO;IACfN,QAAQ,EAAGA,QAAU;IACrByB,YAAY,EAAGb,gBAAkB;IACjCc,GAAG,EAAG,CAAG;IACTC,IAAI,EAAG;EAAoB,CAC3B,CACQ,CAAC,EACXP,aAAA,CAAC/D,QAAQ;IAACmE,OAAO;EAAA,GAChBJ,aAAA,CAAC7D,MAAM;IAACqE,OAAO,EAAG,CAAG;IAACC,YAAY,EAAG;EAAG,GACvCT,aAAA,CAACjE,YAAY;IACZ8C,KAAK,EAAGG,gBAAkB;IAC1BsB,GAAG,EAAG,CAAG;IACTxD,GAAG,GAAAgC,qBAAA,GACFlC,6BAA6B,CAAEwC,YAAY,CAAE,EAC1CtC,GAAG,cAAAgC,qBAAA,cAAAA,qBAAA,GAAI,GACV;IACD/B,IAAI,GAAAgC,sBAAA,GACHnC,6BAA6B,CAAEwC,YAAY,CAAE,EAC1CrC,IAAI,cAAAgC,sBAAA,cAAAA,sBAAA,GAAI,GACX;IACD2B,cAAc,EAAG,KAAO;IACxB9B,QAAQ,EAAGS,kBAAoB;IAC/BsB,uBAAuB;EAAA,CACvB,CACM,CACC,CACL,CACG,CAAC;AAEb"}
@@ -25,7 +25,15 @@ function bubbleEvent(event, Constructor, frame) {
25
25
  for (const key in event) {
26
26
  init[key] = event[key];
27
27
  }
28
- if (event instanceof frame.ownerDocument.defaultView.MouseEvent) {
28
+
29
+ // Check if the event is a MouseEvent generated within the iframe.
30
+ // If so, adjust the coordinates to be relative to the position of
31
+ // the iframe. This ensures that components such as Draggable
32
+ // receive coordinates relative to the window, instead of relative
33
+ // to the iframe. Without this, the Draggable event handler would
34
+ // result in components "jumping" position as soon as the user
35
+ // drags over the iframe.
36
+ if (event instanceof frame.contentDocument.defaultView.MouseEvent) {
29
37
  const rect = frame.getBoundingClientRect();
30
38
  init.clientX += rect.left;
31
39
  init.clientY += rect.top;
@@ -1 +1 @@
1
- {"version":3,"names":["classnames","useState","createPortal","forwardRef","useMemo","useEffect","__","useResizeObserver","useMergeRefs","useRefEffect","useDisabled","__experimentalStyleProvider","StyleProvider","useSelect","useBlockSelectionClearer","useWritingFlow","useCompatibilityStyles","store","blockEditorStore","bubbleEvent","event","Constructor","frame","init","key","ownerDocument","defaultView","MouseEvent","rect","getBoundingClientRect","clientX","left","clientY","top","newEvent","type","defaultPrevented","preventDefault","cancelled","dispatchEvent","useBubbleEvents","iframeDocument","body","frameElement","eventTypes","handlers","name","prototype","Object","getPrototypeOf","constructorName","constructor","window","addEventListener","removeEventListener","Iframe","contentRef","children","tabIndex","scale","frameSize","expand","readonly","forwardedRef","ref","props","resolvedAssets","isPreviewMode","select","settings","getSettings","__unstableResolvedAssets","__unstableIsPreviewMode","styles","scripts","setIframeDocument","bodyClasses","setBodyClasses","compatStyles","clearerRef","before","writingFlowRef","after","contentResizeListener","height","contentHeight","setRef","node","_load","contentDocument","iFrameDocument","preventFileDropDefault","onLoad","documentElement","Array","from","classList","filter","startsWith","dir","compatStyle","getElementById","id","head","appendChild","cloneNode","console","warn","disabledRef","isDisabled","bodyRef","html","src","cleanup","_src","URL","createObjectURL","Blob","revokeObjectURL","marginFromScaling","createElement","Fragment","style","border","marginTop","marginBottom","transform","transition","title","onKeyDown","currentTarget","target","stopPropagation","KeyboardEvent","className","document","IframeIfReady","isInitialised","__internalIsInitialized"],"sources":["@wordpress/block-editor/src/components/iframe/index.js"],"sourcesContent":["/**\n * External dependencies\n */\nimport classnames from 'classnames';\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 {\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 { useCompatibilityStyles } from './use-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\tif ( event instanceof frame.ownerDocument.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( ( body ) => {\n\t\tconst { defaultView } = iframeDocument;\n\t\tif ( ! defaultView ) {\n\t\t\treturn;\n\t\t}\n\t\tconst { frameElement } = defaultView;\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\tbody.addEventListener( name, handlers[ name ] );\n\t\t}\n\n\t\treturn () => {\n\t\t\tfor ( const name of eventTypes ) {\n\t\t\t\tbody.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\texpand = false,\n\treadonly,\n\tforwardedRef: ref,\n\t...props\n} ) {\n\tconst { resolvedAssets, isPreviewMode } = useSelect( ( select ) => {\n\t\tconst settings = select( blockEditorStore ).getSettings();\n\t\treturn {\n\t\t\tresolvedAssets: settings.__unstableResolvedAssets,\n\t\t\tisPreviewMode: settings.__unstableIsPreviewMode,\n\t\t};\n\t}, [] );\n\tconst { styles = '', scripts = '' } = resolvedAssets;\n\tconst [ iframeDocument, setIframeDocument ] = useState();\n\tconst [ bodyClasses, setBodyClasses ] = useState( [] );\n\tconst compatStyles = useCompatibilityStyles();\n\tconst clearerRef = useBlockSelectionClearer();\n\tconst [ before, writingFlowRef, after ] = useWritingFlow();\n\tconst [ contentResizeListener, { height: contentHeight } ] =\n\t\tuseResizeObserver();\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\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 compatStyles ) {\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}\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 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<script>window.frameElement._load()</script>\n\t\t<style>html{height:auto!important;min-height:100%;}body{margin:0}</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// We need to counter the margin created by scaling the iframe. If the scale\n\t// is e.g. 0.45, then the top + bottom margin is 0.55 (1 - scale). Just the\n\t// top or bottom margin is 0.55 / 2 ((1 - scale) / 2).\n\tconst marginFromScaling = ( contentHeight * ( 1 - scale ) ) / 2;\n\n\treturn (\n\t\t<>\n\t\t\t{ tabIndex >= 0 && 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\tborder: 0,\n\t\t\t\t\t...props.style,\n\t\t\t\t\theight: expand ? contentHeight : props.style?.height,\n\t\t\t\t\tmarginTop:\n\t\t\t\t\t\tscale !== 1\n\t\t\t\t\t\t\t? -marginFromScaling + frameSize\n\t\t\t\t\t\t\t: props.style?.marginTop,\n\t\t\t\t\tmarginBottom:\n\t\t\t\t\t\tscale !== 1\n\t\t\t\t\t\t\t? -marginFromScaling + frameSize\n\t\t\t\t\t\t\t: props.style?.marginBottom,\n\t\t\t\t\ttransform:\n\t\t\t\t\t\tscale !== 1\n\t\t\t\t\t\t\t? `scale( ${ scale } )`\n\t\t\t\t\t\t\t: props.style?.transform,\n\t\t\t\t\ttransition: 'all .3s',\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={ __( 'Editor canvas' ) }\n\t\t\t\tonKeyDown={ ( event ) => {\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\tevent.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={ classnames(\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{ tabIndex >= 0 && after }\n\t\t</>\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":";AAAA;AACA;AACA;AACA,OAAOA,UAAU,MAAM,YAAY;;AAEnC;AACA;AACA;AACA,SACCC,QAAQ,EACRC,YAAY,EACZC,UAAU,EACVC,OAAO,EACPC,SAAS,QACH,oBAAoB;AAC3B,SAASC,EAAE,QAAQ,iBAAiB;AACpC,SACCC,iBAAiB,EACjBC,YAAY,EACZC,YAAY,EACZC,WAAW,QACL,oBAAoB;AAC3B,SAASC,2BAA2B,IAAIC,aAAa,QAAQ,uBAAuB;AACpF,SAASC,SAAS,QAAQ,iBAAiB;;AAE3C;AACA;AACA;AACA,SAASC,wBAAwB,QAAQ,4BAA4B;AACrE,SAASC,cAAc,QAAQ,iBAAiB;AAChD,SAASC,sBAAsB,QAAQ,4BAA4B;AACnE,SAASC,KAAK,IAAIC,gBAAgB,QAAQ,aAAa;AAEvD,SAASC,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,IAAKJ,KAAK,Y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;IACD;EAAG,GAEDzF,cAAc,IACfvC,YAAY;EACX;EACA;EACA;EACAsH,aAAA;IACCxD,GAAG,EAAG8C,OAAS;IACfwB,SAAS,EAAGtI,UAAU,CACrB,2BAA2B,EAC3B,uBAAuB,EACvB,GAAG4E,WACJ;EAAG,GAEDO,qBAAqB,EACvBqC,aAAA,CAAC5G,aAAa;IAAC2H,QAAQ,EAAG9F;EAAgB,GACvCgB,QACY,CACV,CAAC,EACPhB,cAAc,CAACoD,eAChB,CACM,CAAC,EACPnC,QAAQ,IAAI,CAAC,IAAIwB,KAClB,CAAC;AAEL;AAEA,SAASsD,aAAaA,CAAEvE,KAAK,EAAED,GAAG,EAAG;EACpC,MAAMyE,aAAa,GAAG5H,SAAS,CAC5BuD,MAAM,IACPA,MAAM,CAAElD,gBAAiB,CAAC,CAACoD,WAAW,CAAC,CAAC,CAACoE,uBAAuB,EACjE,EACD,CAAC;;EAED;EACA;EACA;EACA;EACA;EACA,IAAK,CAAED,aAAa,EAAG;IACtB,OAAO,IAAI;EACZ;EAEA,OAAOjB,aAAA,CAACjE,MAAM;IAAA,GAAMU,KAAK;IAAGF,YAAY,EAAGC;EAAK,CAAE,CAAC;AACpD;AAEA,eAAe7D,UAAU,CAAEqI,aAAc,CAAC"}
1
+ {"version":3,"names":["classnames","useState","createPortal","forwardRef","useMemo","useEffect","__","useResizeObserver","useMergeRefs","useRefEffect","useDisabled","__experimentalStyleProvider","StyleProvider","useSelect","useBlockSelectionClearer","useWritingFlow","useCompatibilityStyles","store","blockEditorStore","bubbleEvent","event","Constructor","frame","init","key","contentDocument","defaultView","MouseEvent","rect","getBoundingClientRect","clientX","left","clientY","top","newEvent","type","defaultPrevented","preventDefault","cancelled","dispatchEvent","useBubbleEvents","iframeDocument","body","frameElement","eventTypes","handlers","name","prototype","Object","getPrototypeOf","constructorName","constructor","window","addEventListener","removeEventListener","Iframe","contentRef","children","tabIndex","scale","frameSize","expand","readonly","forwardedRef","ref","props","resolvedAssets","isPreviewMode","select","settings","getSettings","__unstableResolvedAssets","__unstableIsPreviewMode","styles","scripts","setIframeDocument","bodyClasses","setBodyClasses","compatStyles","clearerRef","before","writingFlowRef","after","contentResizeListener","height","contentHeight","setRef","node","_load","iFrameDocument","preventFileDropDefault","onLoad","ownerDocument","documentElement","Array","from","classList","filter","startsWith","dir","compatStyle","getElementById","id","head","appendChild","cloneNode","console","warn","disabledRef","isDisabled","bodyRef","html","src","cleanup","_src","URL","createObjectURL","Blob","revokeObjectURL","marginFromScaling","createElement","Fragment","style","border","marginTop","marginBottom","transform","transition","title","onKeyDown","currentTarget","target","stopPropagation","KeyboardEvent","className","document","IframeIfReady","isInitialised","__internalIsInitialized"],"sources":["@wordpress/block-editor/src/components/iframe/index.js"],"sourcesContent":["/**\n * External dependencies\n */\nimport classnames from 'classnames';\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 {\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 { useCompatibilityStyles } from './use-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( ( body ) => {\n\t\tconst { defaultView } = iframeDocument;\n\t\tif ( ! defaultView ) {\n\t\t\treturn;\n\t\t}\n\t\tconst { frameElement } = defaultView;\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\tbody.addEventListener( name, handlers[ name ] );\n\t\t}\n\n\t\treturn () => {\n\t\t\tfor ( const name of eventTypes ) {\n\t\t\t\tbody.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\texpand = false,\n\treadonly,\n\tforwardedRef: ref,\n\t...props\n} ) {\n\tconst { resolvedAssets, isPreviewMode } = useSelect( ( select ) => {\n\t\tconst settings = select( blockEditorStore ).getSettings();\n\t\treturn {\n\t\t\tresolvedAssets: settings.__unstableResolvedAssets,\n\t\t\tisPreviewMode: settings.__unstableIsPreviewMode,\n\t\t};\n\t}, [] );\n\tconst { styles = '', scripts = '' } = resolvedAssets;\n\tconst [ iframeDocument, setIframeDocument ] = useState();\n\tconst [ bodyClasses, setBodyClasses ] = useState( [] );\n\tconst compatStyles = useCompatibilityStyles();\n\tconst clearerRef = useBlockSelectionClearer();\n\tconst [ before, writingFlowRef, after ] = useWritingFlow();\n\tconst [ contentResizeListener, { height: contentHeight } ] =\n\t\tuseResizeObserver();\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\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 compatStyles ) {\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}\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 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<script>window.frameElement._load()</script>\n\t\t<style>html{height:auto!important;min-height:100%;}body{margin:0}</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// We need to counter the margin created by scaling the iframe. If the scale\n\t// is e.g. 0.45, then the top + bottom margin is 0.55 (1 - scale). Just the\n\t// top or bottom margin is 0.55 / 2 ((1 - scale) / 2).\n\tconst marginFromScaling = ( contentHeight * ( 1 - scale ) ) / 2;\n\n\treturn (\n\t\t<>\n\t\t\t{ tabIndex >= 0 && 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\tborder: 0,\n\t\t\t\t\t...props.style,\n\t\t\t\t\theight: expand ? contentHeight : props.style?.height,\n\t\t\t\t\tmarginTop:\n\t\t\t\t\t\tscale !== 1\n\t\t\t\t\t\t\t? -marginFromScaling + frameSize\n\t\t\t\t\t\t\t: props.style?.marginTop,\n\t\t\t\t\tmarginBottom:\n\t\t\t\t\t\tscale !== 1\n\t\t\t\t\t\t\t? -marginFromScaling + frameSize\n\t\t\t\t\t\t\t: props.style?.marginBottom,\n\t\t\t\t\ttransform:\n\t\t\t\t\t\tscale !== 1\n\t\t\t\t\t\t\t? `scale( ${ scale } )`\n\t\t\t\t\t\t\t: props.style?.transform,\n\t\t\t\t\ttransition: 'all .3s',\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={ __( 'Editor canvas' ) }\n\t\t\t\tonKeyDown={ ( event ) => {\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\tevent.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={ classnames(\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{ tabIndex >= 0 && after }\n\t\t</>\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":";AAAA;AACA;AACA;AACA,OAAOA,UAAU,MAAM,YAAY;;AAEnC;AACA;AACA;AACA,SACCC,QAAQ,EACRC,YAAY,EACZC,UAAU,EACVC,OAAO,EACPC,SAAS,QACH,oBAAoB;AAC3B,SAASC,EAAE,QAAQ,iBAAiB;AACpC,SACCC,iBAAiB,EACjBC,YAAY,EACZC,YAAY,EACZC,WAAW,QACL,oBAAoB;AAC3B,SAASC,2BAA2B,IAAIC,aAAa,QAAQ,uBAAuB;AACpF,SAASC,SAAS,QAAQ,iBAAiB;;AAE3C;AACA;AACA;AACA,SAASC,wBAAwB,QAAQ,4BAA4B;AACrE,SAASC,cAAc,QAAQ,iBAAiB;AAChD,SAASC,sBAAsB,QAAQ,4BAA4B;AACnE,SAASC,KAAK,IAAIC,gBAAgB,QAAQ,aAAa;AAEvD,SAASC,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,IAAIb,WA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F;EAAgB,GACvCgB,QACY,CACV,CAAC,EACPhB,cAAc,CAACoD,eAChB,CACM,CAAC,EACPnC,QAAQ,IAAI,CAAC,IAAIwB,KAClB,CAAC;AAEL;AAEA,SAASsD,aAAaA,CAAEvE,KAAK,EAAED,GAAG,EAAG;EACpC,MAAMyE,aAAa,GAAG5H,SAAS,CAC5BuD,MAAM,IACPA,MAAM,CAAElD,gBAAiB,CAAC,CAACoD,WAAW,CAAC,CAAC,CAACoE,uBAAuB,EACjE,EACD,CAAC;;EAED;EACA;EACA;EACA;EACA;EACA,IAAK,CAAED,aAAa,EAAG;IACtB,OAAO,IAAI;EACZ;EAEA,OAAOjB,aAAA,CAACjE,MAAM;IAAA,GAAMU,KAAK;IAAGF,YAAY,EAAGC;EAAK,CAAE,CAAC;AACpD;AAEA,eAAe7D,UAAU,CAAEqI,aAAc,CAAC"}
@@ -76,9 +76,6 @@ export default function AspectRatioDropdown({
76
76
  },
77
77
  value: aspect,
78
78
  aspectRatios: [{
79
- title: __('16:10'),
80
- aspect: 16 / 10
81
- }, {
82
79
  title: __('16:9'),
83
80
  aspect: 16 / 9
84
81
  }, {
@@ -97,9 +94,6 @@ export default function AspectRatioDropdown({
97
94
  },
98
95
  value: aspect,
99
96
  aspectRatios: [{
100
- title: __('10:16'),
101
- aspect: 10 / 16
102
- }, {
103
97
  title: __('9:16'),
104
98
  aspect: 9 / 16
105
99
  }, {
@@ -1 +1 @@
1
- {"version":3,"names":["check","aspectRatio","aspectRatioIcon","DropdownMenu","MenuGroup","MenuItem","__","POPOVER_PROPS","useImageEditingContext","AspectGroup","aspectRatios","isDisabled","label","onClick","value","createElement","map","title","aspect","key","disabled","role","isSelected","icon","undefined","AspectRatioDropdown","toggleProps","isInProgress","setAspect","defaultAspect","popoverProps","className","onClose","Fragment","newAspect"],"sources":["@wordpress/block-editor/src/components/image-editor/aspect-ratio-dropdown.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { check, aspectRatio as aspectRatioIcon } from '@wordpress/icons';\nimport { DropdownMenu, MenuGroup, MenuItem } from '@wordpress/components';\nimport { __ } from '@wordpress/i18n';\n\n/**\n * Internal dependencies\n */\nimport { POPOVER_PROPS } from './constants';\nimport { useImageEditingContext } from './context';\n\nfunction AspectGroup( { aspectRatios, isDisabled, label, onClick, value } ) {\n\treturn (\n\t\t<MenuGroup label={ label }>\n\t\t\t{ aspectRatios.map( ( { title, aspect } ) => (\n\t\t\t\t<MenuItem\n\t\t\t\t\tkey={ aspect }\n\t\t\t\t\tdisabled={ isDisabled }\n\t\t\t\t\tonClick={ () => {\n\t\t\t\t\t\tonClick( aspect );\n\t\t\t\t\t} }\n\t\t\t\t\trole=\"menuitemradio\"\n\t\t\t\t\tisSelected={ aspect === value }\n\t\t\t\t\ticon={ aspect === value ? check : undefined }\n\t\t\t\t>\n\t\t\t\t\t{ title }\n\t\t\t\t</MenuItem>\n\t\t\t) ) }\n\t\t</MenuGroup>\n\t);\n}\n\nexport default function AspectRatioDropdown( { toggleProps } ) {\n\tconst { isInProgress, aspect, setAspect, defaultAspect } =\n\t\tuseImageEditingContext();\n\n\treturn (\n\t\t<DropdownMenu\n\t\t\ticon={ aspectRatioIcon }\n\t\t\tlabel={ __( 'Aspect Ratio' ) }\n\t\t\tpopoverProps={ POPOVER_PROPS }\n\t\t\ttoggleProps={ toggleProps }\n\t\t\tclassName=\"wp-block-image__aspect-ratio\"\n\t\t>\n\t\t\t{ ( { onClose } ) => (\n\t\t\t\t<>\n\t\t\t\t\t<AspectGroup\n\t\t\t\t\t\tisDisabled={ isInProgress }\n\t\t\t\t\t\tonClick={ ( newAspect ) => {\n\t\t\t\t\t\t\tsetAspect( newAspect );\n\t\t\t\t\t\t\tonClose();\n\t\t\t\t\t\t} }\n\t\t\t\t\t\tvalue={ aspect }\n\t\t\t\t\t\taspectRatios={ [\n\t\t\t\t\t\t\t// All ratios should be mirrored in AspectRatioTool in @wordpress/block-editor.\n\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\ttitle: __( 'Original' ),\n\t\t\t\t\t\t\t\taspect: defaultAspect,\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\ttitle: __( 'Square' ),\n\t\t\t\t\t\t\t\taspect: 1,\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t] }\n\t\t\t\t\t/>\n\t\t\t\t\t<AspectGroup\n\t\t\t\t\t\tlabel={ __( 'Landscape' ) }\n\t\t\t\t\t\tisDisabled={ isInProgress }\n\t\t\t\t\t\tonClick={ ( newAspect ) => {\n\t\t\t\t\t\t\tsetAspect( newAspect );\n\t\t\t\t\t\t\tonClose();\n\t\t\t\t\t\t} }\n\t\t\t\t\t\tvalue={ aspect }\n\t\t\t\t\t\taspectRatios={ [\n\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\ttitle: __( '16:10' ),\n\t\t\t\t\t\t\t\taspect: 16 / 10,\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\ttitle: __( '16:9' ),\n\t\t\t\t\t\t\t\taspect: 16 / 9,\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\ttitle: __( '4:3' ),\n\t\t\t\t\t\t\t\taspect: 4 / 3,\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\ttitle: __( '3:2' ),\n\t\t\t\t\t\t\t\taspect: 3 / 2,\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t] }\n\t\t\t\t\t/>\n\t\t\t\t\t<AspectGroup\n\t\t\t\t\t\tlabel={ __( 'Portrait' ) }\n\t\t\t\t\t\tisDisabled={ isInProgress }\n\t\t\t\t\t\tonClick={ ( newAspect ) => {\n\t\t\t\t\t\t\tsetAspect( newAspect );\n\t\t\t\t\t\t\tonClose();\n\t\t\t\t\t\t} }\n\t\t\t\t\t\tvalue={ aspect }\n\t\t\t\t\t\taspectRatios={ [\n\t\t\t\t\t\t\t{\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;IACd,CAAC,EACD;MACCD,KAAK,EAAEX,EAAE,CAAE,MAAO,CAAC;MACnBY,MAAM,EAAE,EAAE,GAAG;IACd,CAAC,EACD;MACCD,KAAK,EAAEX,EAAE,CAAE,KAAM,CAAC;MAClBY,MAAM,EAAE,CAAC,GAAG;IACb,CAAC,EACD;MACCD,KAAK,EAAEX,EAAE,CAAE,KAAM,CAAC;MAClBY,MAAM,EAAE,CAAC,GAAG;IACb,CAAC;EACC,CACH,CAAC,EACFH,aAAA,CAACN,WAAW;IACXG,KAAK,EAAGN,EAAE,CAAE,UAAW,CAAG;IAC1BK,UAAU,EAAGgB,YAAc;IAC3Bd,OAAO,EAAKqB,SAAS,IAAM;MAC1BN,SAAS,CAAEM,SAAU,CAAC;MACtBF,OAAO,CAAC,CAAC;IACV,CAAG;IACHlB,KAAK,EAAGI,MAAQ;IAChBR,YAAY,EAAG,CACd;MACCO,KAAK,EAAEX,EAAE,CAAE,OAAQ,CAAC;MACpBY,MAAM,EAAE,EAAE,GAAG;IACd,CAAC,EACD;MACCD,KAAK,EAAEX,EAAE,CAAE,MAAO,CAAC;MACnBY,MAAM,EAAE,CAAC,GAAG;IACb,CAAC,EACD;MACCD,KAAK,EAAEX,EAAE,CAAE,KAAM,CAAC;MAClBY,MAAM,EAAE,CAAC,GAAG;IACb,CAAC,EACD;MACCD,KAAK,EAAEX,EAAE,CAAE,KAAM,CAAC;MAClBY,MAAM,EAAE,CAAC,GAAG;IACb,CAAC;EACC,CACH,CACA,CAEU,CAAC;AAEjB"}
1
+ {"version":3,"names":["check","aspectRatio","aspectRatioIcon","DropdownMenu","MenuGroup","MenuItem","__","POPOVER_PROPS","useImageEditingContext","AspectGroup","aspectRatios","isDisabled","label","onClick","value","createElement","map","title","aspect","key","disabled","role","isSelected","icon","undefined","AspectRatioDropdown","toggleProps","isInProgress","setAspect","defaultAspect","popoverProps","className","onClose","Fragment","newAspect"],"sources":["@wordpress/block-editor/src/components/image-editor/aspect-ratio-dropdown.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { check, aspectRatio as aspectRatioIcon } from '@wordpress/icons';\nimport { DropdownMenu, MenuGroup, MenuItem } from '@wordpress/components';\nimport { __ } from '@wordpress/i18n';\n\n/**\n * Internal dependencies\n */\nimport { POPOVER_PROPS } from './constants';\nimport { useImageEditingContext } from './context';\n\nfunction AspectGroup( { aspectRatios, isDisabled, label, onClick, value } ) {\n\treturn (\n\t\t<MenuGroup label={ label }>\n\t\t\t{ aspectRatios.map( ( { title, aspect } ) => (\n\t\t\t\t<MenuItem\n\t\t\t\t\tkey={ aspect }\n\t\t\t\t\tdisabled={ isDisabled }\n\t\t\t\t\tonClick={ () => {\n\t\t\t\t\t\tonClick( aspect );\n\t\t\t\t\t} }\n\t\t\t\t\trole=\"menuitemradio\"\n\t\t\t\t\tisSelected={ aspect === value }\n\t\t\t\t\ticon={ aspect === value ? check : undefined }\n\t\t\t\t>\n\t\t\t\t\t{ title }\n\t\t\t\t</MenuItem>\n\t\t\t) ) }\n\t\t</MenuGroup>\n\t);\n}\n\nexport default function AspectRatioDropdown( { toggleProps } ) {\n\tconst { isInProgress, aspect, setAspect, defaultAspect } =\n\t\tuseImageEditingContext();\n\n\treturn (\n\t\t<DropdownMenu\n\t\t\ticon={ aspectRatioIcon }\n\t\t\tlabel={ __( 'Aspect Ratio' ) }\n\t\t\tpopoverProps={ POPOVER_PROPS }\n\t\t\ttoggleProps={ toggleProps }\n\t\t\tclassName=\"wp-block-image__aspect-ratio\"\n\t\t>\n\t\t\t{ ( { onClose } ) => (\n\t\t\t\t<>\n\t\t\t\t\t<AspectGroup\n\t\t\t\t\t\tisDisabled={ isInProgress }\n\t\t\t\t\t\tonClick={ ( newAspect ) => {\n\t\t\t\t\t\t\tsetAspect( newAspect );\n\t\t\t\t\t\t\tonClose();\n\t\t\t\t\t\t} }\n\t\t\t\t\t\tvalue={ aspect }\n\t\t\t\t\t\taspectRatios={ [\n\t\t\t\t\t\t\t// All ratios should be mirrored in AspectRatioTool in @wordpress/block-editor.\n\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\ttitle: __( 'Original' ),\n\t\t\t\t\t\t\t\taspect: defaultAspect,\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\ttitle: __( 'Square' ),\n\t\t\t\t\t\t\t\taspect: 1,\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t] }\n\t\t\t\t\t/>\n\t\t\t\t\t<AspectGroup\n\t\t\t\t\t\tlabel={ __( 'Landscape' ) }\n\t\t\t\t\t\tisDisabled={ isInProgress }\n\t\t\t\t\t\tonClick={ ( newAspect ) => {\n\t\t\t\t\t\t\tsetAspect( newAspect );\n\t\t\t\t\t\t\tonClose();\n\t\t\t\t\t\t} }\n\t\t\t\t\t\tvalue={ aspect }\n\t\t\t\t\t\taspectRatios={ [\n\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\ttitle: __( '16:9' ),\n\t\t\t\t\t\t\t\taspect: 16 / 9,\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\ttitle: __( '4:3' ),\n\t\t\t\t\t\t\t\taspect: 4 / 3,\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\ttitle: __( '3:2' ),\n\t\t\t\t\t\t\t\taspect: 3 / 2,\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t] }\n\t\t\t\t\t/>\n\t\t\t\t\t<AspectGroup\n\t\t\t\t\t\tlabel={ __( 'Portrait' ) }\n\t\t\t\t\t\tisDisabled={ isInProgress }\n\t\t\t\t\t\tonClick={ ( newAspect ) => {\n\t\t\t\t\t\t\tsetAspect( newAspect );\n\t\t\t\t\t\t\tonClose();\n\t\t\t\t\t\t} }\n\t\t\t\t\t\tvalue={ aspect }\n\t\t\t\t\t\taspectRatios={ [\n\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\ttitle: __( '9:16' ),\n\t\t\t\t\t\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AAE,CAAC,GAAG;IACb,CAAC;EACC,CACH,CAAC,EACFH,aAAA,CAACN,WAAW;IACXG,KAAK,EAAGN,EAAE,CAAE,UAAW,CAAG;IAC1BK,UAAU,EAAGgB,YAAc;IAC3Bd,OAAO,EAAKqB,SAAS,IAAM;MAC1BN,SAAS,CAAEM,SAAU,CAAC;MACtBF,OAAO,CAAC,CAAC;IACV,CAAG;IACHlB,KAAK,EAAGI,MAAQ;IAChBR,YAAY,EAAG,CACd;MACCO,KAAK,EAAEX,EAAE,CAAE,MAAO,CAAC;MACnBY,MAAM,EAAE,CAAC,GAAG;IACb,CAAC,EACD;MACCD,KAAK,EAAEX,EAAE,CAAE,KAAM,CAAC;MAClBY,MAAM,EAAE,CAAC,GAAG;IACb,CAAC,EACD;MACCD,KAAK,EAAEX,EAAE,CAAE,KAAM,CAAC;MAClBY,MAAM,EAAE,CAAC,GAAG;IACb,CAAC;EACC,CACH,CACA,CAEU,CAAC;AAEjB"}
@@ -33,6 +33,7 @@ export { RecursionProvider as __experimentalRecursionProvider, useHasRecursion a
33
33
  export { default as Warning } from './warning';
34
34
  export { default as ContrastChecker } from './contrast-checker';
35
35
  export { default as useMultipleOriginColorsAndGradients } from './colors-gradients/use-multiple-origin-colors-and-gradients';
36
+ export { default as UnsupportedBlockDetails } from './unsupported-block-details';
36
37
  export { BottomSheetSettings, BlockSettingsButton, blockSettingsScreens } from './block-settings';
37
38
  export { default as VideoPlayer, VIDEO_ASPECT_RATIO } from './video-player';
38
39
  export { getSpacingPresetCssVar, getCustomValueFromPreset, isValueSpacingPreset } from './spacing-sizes-control/utils';