@wordpress/block-library 9.19.1 → 9.20.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 (67) hide show
  1. package/CHANGELOG.md +2 -0
  2. package/build/archives/edit.js +2 -2
  3. package/build/archives/edit.js.map +1 -1
  4. package/build/audio/edit.js +66 -33
  5. package/build/audio/edit.js.map +1 -1
  6. package/build/avatar/index.js +8 -3
  7. package/build/avatar/index.js.map +1 -1
  8. package/build/button/edit.js +43 -16
  9. package/build/button/edit.js.map +1 -1
  10. package/build/comment-template/hooks.js +6 -0
  11. package/build/comment-template/hooks.js.map +1 -1
  12. package/build/cover/index.js +8 -1
  13. package/build/cover/index.js.map +1 -1
  14. package/build/image/constants.js +2 -1
  15. package/build/image/constants.js.map +1 -1
  16. package/build/image/image.js +85 -72
  17. package/build/image/image.js.map +1 -1
  18. package/build/post-author/index.js +8 -1
  19. package/build/post-author/index.js.map +1 -1
  20. package/build/site-logo/index.js +8 -1
  21. package/build/site-logo/index.js.map +1 -1
  22. package/build/social-links/index.js +1 -0
  23. package/build/social-links/index.js.map +1 -1
  24. package/build/table-of-contents/hooks.js +6 -3
  25. package/build/table-of-contents/hooks.js.map +1 -1
  26. package/build-module/archives/edit.js +2 -2
  27. package/build-module/archives/edit.js.map +1 -1
  28. package/build-module/audio/edit.js +68 -35
  29. package/build-module/audio/edit.js.map +1 -1
  30. package/build-module/avatar/index.js +8 -3
  31. package/build-module/avatar/index.js.map +1 -1
  32. package/build-module/button/edit.js +44 -17
  33. package/build-module/button/edit.js.map +1 -1
  34. package/build-module/comment-template/hooks.js +6 -0
  35. package/build-module/comment-template/hooks.js.map +1 -1
  36. package/build-module/cover/index.js +8 -1
  37. package/build-module/cover/index.js.map +1 -1
  38. package/build-module/image/constants.js +1 -0
  39. package/build-module/image/constants.js.map +1 -1
  40. package/build-module/image/image.js +88 -75
  41. package/build-module/image/image.js.map +1 -1
  42. package/build-module/post-author/index.js +8 -1
  43. package/build-module/post-author/index.js.map +1 -1
  44. package/build-module/site-logo/index.js +8 -1
  45. package/build-module/site-logo/index.js.map +1 -1
  46. package/build-module/social-links/index.js +1 -0
  47. package/build-module/social-links/index.js.map +1 -1
  48. package/build-module/table-of-contents/hooks.js +6 -3
  49. package/build-module/table-of-contents/hooks.js.map +1 -1
  50. package/build-style/editor-rtl.css +0 -9
  51. package/build-style/editor.css +0 -9
  52. package/build-style/image/editor-rtl.css +0 -9
  53. package/build-style/image/editor.css +0 -9
  54. package/package.json +35 -35
  55. package/src/archives/edit.js +2 -2
  56. package/src/audio/edit.js +84 -33
  57. package/src/avatar/block.json +8 -3
  58. package/src/button/edit.js +69 -24
  59. package/src/comment-template/hooks.js +14 -6
  60. package/src/cover/block.json +8 -1
  61. package/src/image/constants.js +1 -0
  62. package/src/image/editor.scss +0 -13
  63. package/src/image/image.js +115 -122
  64. package/src/post-author/block.json +8 -1
  65. package/src/site-logo/block.json +8 -1
  66. package/src/social-links/block.json +1 -0
  67. package/src/table-of-contents/hooks.js +5 -2
@@ -1 +1 @@
1
- {"version":3,"names":["__","cover","icon","initBlock","deprecated","edit","metadata","$schema","apiVersion","name","title","category","description","textdomain","attributes","url","type","useFeaturedImage","id","alt","hasParallax","isRepeated","dimRatio","overlayColor","customOverlayColor","isUserOverlayColor","backgroundType","focalPoint","minHeight","minHeightUnit","gradient","customGradient","contentPosition","isDark","allowedBlocks","templateLock","tagName","sizeSlug","usesContext","supports","anchor","align","html","shadow","spacing","padding","margin","blockGap","__experimentalDefaultControls","__experimentalBorder","color","radius","style","width","__experimentalDuotone","heading","text","background","__experimentalSkipSerialization","enableContrastChecker","dimensions","aspectRatio","typography","fontSize","lineHeight","__experimentalFontFamily","__experimentalFontWeight","__experimentalFontStyle","__experimentalTextTransform","__experimentalTextDecoration","__experimentalLetterSpacing","layout","allowJustification","interactivity","clientNavigation","editorStyle","save","transforms","variations","settings","example","innerBlocks","content","init"],"sources":["@wordpress/block-library/src/cover/index.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { __ } from '@wordpress/i18n';\nimport { cover as icon } from '@wordpress/icons';\n\n/**\n * Internal dependencies\n */\nimport initBlock from '../utils/init-block';\nimport deprecated from './deprecated';\nimport edit from './edit';\nimport metadata from './block.json';\nimport save from './save';\nimport transforms from './transforms';\nimport variations from './variations';\n\nconst { name } = metadata;\n\nexport { metadata, name };\n\nexport const settings = {\n\ticon,\n\texample: {\n\t\tattributes: {\n\t\t\tcustomOverlayColor: '#065174',\n\t\t\tdimRatio: 40,\n\t\t\turl: 'https://s.w.org/images/core/5.3/Windbuchencom.jpg',\n\t\t\tstyle: {\n\t\t\t\ttypography: {\n\t\t\t\t\tfontSize: 48,\n\t\t\t\t},\n\t\t\t\tcolor: {\n\t\t\t\t\ttext: 'white',\n\t\t\t\t},\n\t\t\t},\n\t\t},\n\t\tinnerBlocks: [\n\t\t\t{\n\t\t\t\tname: 'core/paragraph',\n\t\t\t\tattributes: {\n\t\t\t\t\tcontent: __( '<strong>Snow Patrol</strong>' ),\n\t\t\t\t\talign: 'center',\n\t\t\t\t},\n\t\t\t},\n\t\t],\n\t},\n\ttransforms,\n\tsave,\n\tedit,\n\tdeprecated,\n\tvariations,\n};\n\nexport const init = () => initBlock( { name, metadata, settings } );\n"],"mappings":"AAAA;AACA;AACA;AACA,SAASA,EAAE,QAAQ,iBAAiB;AACpC,SAASC,KAAK,IAAIC,IAAI,QAAQ,kBAAkB;;AAEhD;AACA;AACA;AACA,OAAOC,SAAS,MAAM,qBAAqB;AAC3C,OAAOC,UAAU,MAAM,cAAc;AACrC,OAAOC,IAAI,MAAM,QAAQ;AAAC,MAAAC,QAAA;EAAAC,OAAA;EAAAC,UAAA;EAAAC,IAAA;EAAAC,KAAA;EAAAC,QAAA;EAAAC,WAAA;EAAAC,UAAA;EAAAC,UAAA;IAAAC,GAAA;MAAAC,IAAA;IAAA;IAAAC,gBAAA;MAAAD,IAAA;MAAA;IAAA;IAAAE,EAAA;MAAAF,IAAA;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MAAAC,uBAAA;MAAAC,2BAAA;MAAAC,4BAAA;MAAAC,2BAAA;MAAAtB,6BAAA;QAAAe,QAAA;MAAA;IAAA;IAAAQ,MAAA;MAAAC,kBAAA;IAAA;IAAAC,aAAA;MAAAC,gBAAA;IAAA;EAAA;EAAAC,WAAA;EAAAvB,KAAA;AAAA;AAE1B,OAAOwB,IAAI,MAAM,QAAQ;AACzB,OAAOC,UAAU,MAAM,cAAc;AACrC,OAAOC,UAAU,MAAM,cAAc;AAErC,MAAM;EAAErE;AAAK,CAAC,GAAGH,QAAQ;AAEzB,SAASA,QAAQ,EAAEG,IAAI;AAEvB,OAAO,MAAMsE,QAAQ,GAAG;EACvB7E,IAAI;EACJ8E,OAAO,EAAE;IACRlE,UAAU,EAAE;MACXU,kBAAkB,EAAE,SAAS;MAC7BF,QAAQ,EAAE,EAAE;MACZP,GAAG,EAAE,mDAAmD;MACxDqC,KAAK,EAAE;QACNU,UAAU,EAAE;UACXC,QAAQ,EAAE;QACX,CAAC;QACDb,KAAK,EAAE;UACNM,IAAI,EAAE;QACP;MACD;IACD,CAAC;IACDyB,WAAW,EAAE,CACZ;MACCxE,IAAI,EAAE,gBAAgB;MACtBK,UAAU,EAAE;QACXoE,OAAO,EAAElF,EAAE,CAAE,8BAA+B,CAAC;QAC7CyC,KAAK,EAAE;MACR;IACD,CAAC;EAEH,CAAC;EACDoC,UAAU;EACVD,IAAI;EACJvE,IAAI;EACJD,UAAU;EACV0E;AACD,CAAC;AAED,OAAO,MAAMK,IAAI,GAAGA,CAAA,KAAMhF,SAAS,CAAE;EAAEM,IAAI;EAAEH,QAAQ;EAAEyE;AAAS,CAAE,CAAC","ignoreList":[]}
1
+ {"version":3,"names":["__","cover","icon","initBlock","deprecated","edit","metadata","$schema","apiVersion","name","title","category","description","textdomain","attributes","url","type","useFeaturedImage","id","alt","hasParallax","isRepeated","dimRatio","overlayColor","customOverlayColor","isUserOverlayColor","backgroundType","focalPoint","minHeight","minHeightUnit","gradient","customGradient","contentPosition","isDark","allowedBlocks","templateLock","tagName","sizeSlug","usesContext","supports","anchor","align","html","shadow","spacing","padding","margin","blockGap","__experimentalDefaultControls","__experimentalBorder","color","radius","style","width","heading","text","background","__experimentalSkipSerialization","enableContrastChecker","dimensions","aspectRatio","typography","fontSize","lineHeight","__experimentalFontFamily","__experimentalFontWeight","__experimentalFontStyle","__experimentalTextTransform","__experimentalTextDecoration","__experimentalLetterSpacing","layout","allowJustification","interactivity","clientNavigation","filter","duotone","selectors","editorStyle","save","transforms","variations","settings","example","innerBlocks","content","init"],"sources":["@wordpress/block-library/src/cover/index.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { __ } from '@wordpress/i18n';\nimport { cover as icon } from '@wordpress/icons';\n\n/**\n * Internal dependencies\n */\nimport initBlock from '../utils/init-block';\nimport deprecated from './deprecated';\nimport edit from './edit';\nimport metadata from './block.json';\nimport save from './save';\nimport transforms from './transforms';\nimport variations from './variations';\n\nconst { name } = metadata;\n\nexport { metadata, name };\n\nexport const settings = {\n\ticon,\n\texample: {\n\t\tattributes: {\n\t\t\tcustomOverlayColor: '#065174',\n\t\t\tdimRatio: 40,\n\t\t\turl: 'https://s.w.org/images/core/5.3/Windbuchencom.jpg',\n\t\t\tstyle: {\n\t\t\t\ttypography: {\n\t\t\t\t\tfontSize: 48,\n\t\t\t\t},\n\t\t\t\tcolor: {\n\t\t\t\t\ttext: 'white',\n\t\t\t\t},\n\t\t\t},\n\t\t},\n\t\tinnerBlocks: [\n\t\t\t{\n\t\t\t\tname: 'core/paragraph',\n\t\t\t\tattributes: {\n\t\t\t\t\tcontent: __( '<strong>Snow Patrol</strong>' ),\n\t\t\t\t\talign: 'center',\n\t\t\t\t},\n\t\t\t},\n\t\t],\n\t},\n\ttransforms,\n\tsave,\n\tedit,\n\tdeprecated,\n\tvariations,\n};\n\nexport const init = () => initBlock( { name, metadata, settings } );\n"],"mappings":"AAAA;AACA;AACA;AACA,SAASA,EAAE,QAAQ,iBAAiB;AACpC,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E,8BAA+B,CAAC;QAC7CyC,KAAK,EAAE;MACR;IACD,CAAC;EAEH,CAAC;EACDsC,UAAU;EACVD,IAAI;EACJzE,IAAI;EACJD,UAAU;EACV4E;AACD,CAAC;AAED,OAAO,MAAMK,IAAI,GAAGA,CAAA,KAAMlF,SAAS,CAAE;EAAEM,IAAI;EAAEH,QAAQ;EAAE2E;AAAS,CAAE,CAAC","ignoreList":[]}
@@ -6,4 +6,5 @@ export const LINK_DESTINATION_CUSTOM = 'custom';
6
6
  export const NEW_TAB_REL = ['noreferrer', 'noopener'];
7
7
  export const ALLOWED_MEDIA_TYPES = ['image'];
8
8
  export const MEDIA_ID_NO_FEATURED_IMAGE_SET = 0;
9
+ export const SIZED_LAYOUTS = ['flex', 'grid'];
9
10
  //# sourceMappingURL=constants.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["MIN_SIZE","LINK_DESTINATION_NONE","LINK_DESTINATION_MEDIA","LINK_DESTINATION_ATTACHMENT","LINK_DESTINATION_CUSTOM","NEW_TAB_REL","ALLOWED_MEDIA_TYPES","MEDIA_ID_NO_FEATURED_IMAGE_SET"],"sources":["@wordpress/block-library/src/image/constants.js"],"sourcesContent":["export const MIN_SIZE = 20;\nexport const LINK_DESTINATION_NONE = 'none';\nexport const LINK_DESTINATION_MEDIA = 'media';\nexport const LINK_DESTINATION_ATTACHMENT = 'attachment';\nexport const LINK_DESTINATION_CUSTOM = 'custom';\nexport const NEW_TAB_REL = [ 'noreferrer', 'noopener' ];\nexport const ALLOWED_MEDIA_TYPES = [ 'image' ];\nexport const MEDIA_ID_NO_FEATURED_IMAGE_SET = 0;\n"],"mappings":"AAAA,OAAO,MAAMA,QAAQ,GAAG,EAAE;AAC1B,OAAO,MAAMC,qBAAqB,GAAG,MAAM;AAC3C,OAAO,MAAMC,sBAAsB,GAAG,OAAO;AAC7C,OAAO,MAAMC,2BAA2B,GAAG,YAAY;AACvD,OAAO,MAAMC,uBAAuB,GAAG,QAAQ;AAC/C,OAAO,MAAMC,WAAW,GAAG,CAAE,YAAY,EAAE,UAAU,CAAE;AACvD,OAAO,MAAMC,mBAAmB,GAAG,CAAE,OAAO,CAAE;AAC9C,OAAO,MAAMC,8BAA8B,GAAG,CAAC","ignoreList":[]}
1
+ {"version":3,"names":["MIN_SIZE","LINK_DESTINATION_NONE","LINK_DESTINATION_MEDIA","LINK_DESTINATION_ATTACHMENT","LINK_DESTINATION_CUSTOM","NEW_TAB_REL","ALLOWED_MEDIA_TYPES","MEDIA_ID_NO_FEATURED_IMAGE_SET","SIZED_LAYOUTS"],"sources":["@wordpress/block-library/src/image/constants.js"],"sourcesContent":["export const MIN_SIZE = 20;\nexport const LINK_DESTINATION_NONE = 'none';\nexport const LINK_DESTINATION_MEDIA = 'media';\nexport const LINK_DESTINATION_ATTACHMENT = 'attachment';\nexport const LINK_DESTINATION_CUSTOM = 'custom';\nexport const NEW_TAB_REL = [ 'noreferrer', 'noopener' ];\nexport const ALLOWED_MEDIA_TYPES = [ 'image' ];\nexport const MEDIA_ID_NO_FEATURED_IMAGE_SET = 0;\nexport const SIZED_LAYOUTS = [ 'flex', 'grid' ];\n"],"mappings":"AAAA,OAAO,MAAMA,QAAQ,GAAG,EAAE;AAC1B,OAAO,MAAMC,qBAAqB,GAAG,MAAM;AAC3C,OAAO,MAAMC,sBAAsB,GAAG,OAAO;AAC7C,OAAO,MAAMC,2BAA2B,GAAG,YAAY;AACvD,OAAO,MAAMC,uBAAuB,GAAG,QAAQ;AAC/C,OAAO,MAAMC,WAAW,GAAG,CAAE,YAAY,EAAE,UAAU,CAAE;AACvD,OAAO,MAAMC,mBAAmB,GAAG,CAAE,OAAO,CAAE;AAC9C,OAAO,MAAMC,8BAA8B,GAAG,CAAC;AAC/C,OAAO,MAAMC,aAAa,GAAG,CAAE,MAAM,EAAE,MAAM,CAAE","ignoreList":[]}
@@ -3,10 +3,10 @@
3
3
  */
4
4
  import { isBlobURL } from '@wordpress/blob';
5
5
  import { ExternalLink, ResizableBox, Spinner, TextareaControl, TextControl, ToolbarButton, ToolbarGroup, __experimentalToolsPanel as ToolsPanel, __experimentalToolsPanelItem as ToolsPanelItem, __experimentalUseCustomUnits as useCustomUnits, Placeholder, MenuItem, ToolbarItem, DropdownMenu, Popover } from '@wordpress/components';
6
- import { useViewportMatch } from '@wordpress/compose';
6
+ import { useMergeRefs, useResizeObserver, useViewportMatch } from '@wordpress/compose';
7
7
  import { useSelect, useDispatch } from '@wordpress/data';
8
8
  import { BlockControls, InspectorControls, __experimentalImageURLInputUI as ImageURLInputUI, MediaReplaceFlow, store as blockEditorStore, useSettings, __experimentalImageEditor as ImageEditor, __experimentalUseBorderProps as useBorderProps, __experimentalGetShadowClassesAndStyles as getShadowClassesAndStyles, privateApis as blockEditorPrivateApis, BlockSettingsMenuControls } from '@wordpress/block-editor';
9
- import { useEffect, useMemo, useState, useRef } from '@wordpress/element';
9
+ import { useCallback, useEffect, useMemo, useState } from '@wordpress/element';
10
10
  import { __, _x, sprintf, isRTL } from '@wordpress/i18n';
11
11
  import { getFilename } from '@wordpress/url';
12
12
  import { getBlockBindingsSource, switchToBlockType } from '@wordpress/blocks';
@@ -26,7 +26,7 @@ import { Caption } from '../utils/caption';
26
26
  * Module constants
27
27
  */
28
28
  import { useToolsPanelDropdownMenuProps } from '../utils/hooks';
29
- import { MIN_SIZE, ALLOWED_MEDIA_TYPES } from './constants';
29
+ import { MIN_SIZE, ALLOWED_MEDIA_TYPES, SIZED_LAYOUTS } from './constants';
30
30
  import { evalAspectRatio } from './utils';
31
31
  import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
32
32
  const {
@@ -210,11 +210,26 @@ export default function Image({
210
210
  lightbox,
211
211
  metadata
212
212
  } = attributes;
213
-
214
- // The only supported unit is px, so we can parseInt to strip the px here.
215
- const numericWidth = width ? parseInt(width, 10) : undefined;
216
- const numericHeight = height ? parseInt(height, 10) : undefined;
217
- const imageRef = useRef();
213
+ const [imageElement, setImageElement] = useState();
214
+ const [resizeDelta, setResizeDelta] = useState(null);
215
+ const [pixelSize, setPixelSize] = useState({});
216
+ const [offsetTop, setOffsetTop] = useState(0);
217
+ const setResizeObserved = useResizeObserver(([entry]) => {
218
+ if (!resizeDelta) {
219
+ const [box] = entry.borderBoxSize;
220
+ setPixelSize({
221
+ width: box.inlineSize,
222
+ height: box.blockSize
223
+ });
224
+ }
225
+ // This is usually 0 unless the image height is less than the line-height.
226
+ setOffsetTop(entry.target.offsetTop);
227
+ });
228
+ const effectResizeableBoxPlacement = useCallback(() => {
229
+ var _imageElement$offsetT;
230
+ setOffsetTop((_imageElement$offsetT = imageElement?.offsetTop) !== null && _imageElement$offsetT !== void 0 ? _imageElement$offsetT : 0);
231
+ }, [imageElement]);
232
+ const setRefs = useMergeRefs([setImageElement, setResizeObserved]);
218
233
  const {
219
234
  allowResize = true
220
235
  } = context;
@@ -292,7 +307,7 @@ export default function Image({
292
307
  .catch(() => {});
293
308
  }, [id, url, isSingleSelected, externalBlob]);
294
309
 
295
- // Get naturalWidth and naturalHeight from image ref, and fall back to loaded natural
310
+ // Get naturalWidth and naturalHeight from image, and fall back to loaded natural
296
311
  // width and height. This resolves an issue in Safari where the loaded natural
297
312
  // width and height is otherwise lost when switching between alignments.
298
313
  // See: https://github.com/WordPress/gutenberg/pull/37210.
@@ -301,16 +316,10 @@ export default function Image({
301
316
  naturalHeight
302
317
  } = useMemo(() => {
303
318
  return {
304
- naturalWidth: imageRef.current?.naturalWidth || loadedNaturalWidth || undefined,
305
- naturalHeight: imageRef.current?.naturalHeight || loadedNaturalHeight || undefined
319
+ naturalWidth: imageElement?.naturalWidth || loadedNaturalWidth || undefined,
320
+ naturalHeight: imageElement?.naturalHeight || loadedNaturalHeight || undefined
306
321
  };
307
- }, [loadedNaturalWidth, loadedNaturalHeight, imageRef.current?.complete]);
308
- function onResizeStart() {
309
- toggleSelection(false);
310
- }
311
- function onResizeStop() {
312
- toggleSelection(true);
313
- }
322
+ }, [loadedNaturalWidth, loadedNaturalHeight, imageElement?.complete]);
314
323
  function onImageError() {
315
324
  setHasImageErrored(true);
316
325
 
@@ -444,7 +453,21 @@ export default function Image({
444
453
  !!lightbox && lightbox?.enabled !== lightboxSetting?.enabled || lightboxSetting?.allowEditing;
445
454
  const lightboxChecked = !!lightbox?.enabled || !lightbox && !!lightboxSetting?.enabled;
446
455
  const dropdownMenuProps = useToolsPanelDropdownMenuProps();
447
- const dimensionsControl = /*#__PURE__*/_jsx(DimensionsTool, {
456
+ const dimensionsControl = isResizable && (SIZED_LAYOUTS.includes(parentLayoutType) ? /*#__PURE__*/_jsx(DimensionsTool, {
457
+ value: {
458
+ aspectRatio
459
+ },
460
+ onChange: ({
461
+ aspectRatio: newAspectRatio
462
+ }) => {
463
+ setAttributes({
464
+ aspectRatio: newAspectRatio,
465
+ scale: 'cover'
466
+ });
467
+ },
468
+ defaultAspectRatio: "auto",
469
+ tools: ['aspectRatio']
470
+ }) : /*#__PURE__*/_jsx(DimensionsTool, {
448
471
  value: {
449
472
  width,
450
473
  height,
@@ -475,22 +498,7 @@ export default function Image({
475
498
  defaultAspectRatio: "auto",
476
499
  scaleOptions: scaleOptions,
477
500
  unitsOptions: dimensionsUnitsOptions
478
- });
479
- const aspectRatioControl = /*#__PURE__*/_jsx(DimensionsTool, {
480
- value: {
481
- aspectRatio
482
- },
483
- onChange: ({
484
- aspectRatio: newAspectRatio
485
- }) => {
486
- setAttributes({
487
- aspectRatio: newAspectRatio,
488
- scale: 'cover'
489
- });
490
- },
491
- defaultAspectRatio: "auto",
492
- tools: ['aspectRatio']
493
- });
501
+ }));
494
502
  const resetAll = () => {
495
503
  setAttributes({
496
504
  alt: undefined,
@@ -506,7 +514,7 @@ export default function Image({
506
514
  label: __('Settings'),
507
515
  resetAll: resetAll,
508
516
  dropdownMenuProps: dropdownMenuProps,
509
- children: isResizable && (parentLayoutType === 'grid' ? aspectRatioControl : dimensionsControl)
517
+ children: dimensionsControl
510
518
  })
511
519
  });
512
520
  const arePatternOverridesEnabled = metadata?.bindings?.__default?.source === 'core/pattern-overrides';
@@ -658,7 +666,7 @@ export default function Image({
658
666
  }),
659
667
  __nextHasNoMarginBottom: true
660
668
  })
661
- }), isResizable && (parentLayoutType === 'grid' ? aspectRatioControl : dimensionsControl), !!imageSizeOptions.length && /*#__PURE__*/_jsx(ResolutionTool, {
669
+ }), dimensionsControl, !!imageSizeOptions.length && /*#__PURE__*/_jsx(ResolutionTool, {
662
670
  value: sizeSlug,
663
671
  onChange: updateImage,
664
672
  options: imageSizeOptions
@@ -723,11 +731,19 @@ export default function Image({
723
731
  alt: defaultedAlt,
724
732
  onError: onImageError,
725
733
  onLoad: onImageLoad,
726
- ref: imageRef,
734
+ ref: setRefs,
727
735
  className: borderProps.className,
736
+ width: naturalWidth,
737
+ height: naturalHeight,
728
738
  style: {
729
- width: width && height || aspectRatio ? '100%' : undefined,
730
- height: width && height || aspectRatio ? '100%' : undefined,
739
+ aspectRatio,
740
+ ...(resizeDelta ? {
741
+ width: pixelSize.width + resizeDelta.width,
742
+ height: pixelSize.height + resizeDelta.height
743
+ } : {
744
+ width,
745
+ height
746
+ }),
731
747
  objectFit: scale,
732
748
  ...borderProps.style,
733
749
  ...shadowProps.style
@@ -741,8 +757,7 @@ export default function Image({
741
757
  children: /*#__PURE__*/_jsx(ImageEditor, {
742
758
  id: id,
743
759
  url: url,
744
- width: numericWidth,
745
- height: numericHeight,
760
+ ...pixelSize,
746
761
  naturalHeight: naturalHeight,
747
762
  naturalWidth: naturalWidth,
748
763
  onSaveImage: imageAttributes => setAttributes(imageAttributes),
@@ -752,25 +767,18 @@ export default function Image({
752
767
  borderProps: isRounded ? undefined : borderProps
753
768
  })
754
769
  });
755
- } else if (!isResizable || parentLayoutType === 'grid') {
756
- img = /*#__PURE__*/_jsx("div", {
757
- style: {
758
- width,
759
- height,
760
- aspectRatio
761
- },
762
- children: /*#__PURE__*/_jsx(ImageWrapper, {
763
- href: href,
764
- children: img
765
- })
766
- });
767
770
  } else {
771
+ img = /*#__PURE__*/_jsx(ImageWrapper, {
772
+ href: href,
773
+ children: img
774
+ });
775
+ }
776
+ let resizableBox;
777
+ if (isResizable && isSingleSelected && !isEditingImage && !SIZED_LAYOUTS.includes(parentLayoutType)) {
768
778
  const numericRatio = aspectRatio && evalAspectRatio(aspectRatio);
769
- const customRatio = numericWidth / numericHeight;
779
+ const customRatio = pixelSize.width / pixelSize.height;
770
780
  const naturalRatio = naturalWidth / naturalHeight;
771
781
  const ratio = numericRatio || customRatio || naturalRatio || 1;
772
- const currentWidth = !numericWidth && numericHeight ? numericHeight * ratio : numericWidth;
773
- const currentHeight = !numericHeight && numericWidth ? numericWidth / ratio : numericHeight;
774
782
  const minWidth = naturalWidth < naturalHeight ? MIN_SIZE : MIN_SIZE * ratio;
775
783
  const minHeight = naturalHeight < naturalWidth ? MIN_SIZE : MIN_SIZE / ratio;
776
784
 
@@ -813,17 +821,16 @@ export default function Image({
813
821
  }
814
822
  }
815
823
  /* eslint-enable no-lonely-if */
816
- img = /*#__PURE__*/_jsx(ResizableBox, {
824
+ resizableBox = /*#__PURE__*/_jsx(ResizableBox, {
825
+ ref: effectResizeableBoxPlacement,
817
826
  style: {
818
- display: 'block',
819
- objectFit: scale,
820
- aspectRatio: !width && !height && aspectRatio ? aspectRatio : undefined
821
- },
822
- size: {
823
- width: currentWidth !== null && currentWidth !== void 0 ? currentWidth : 'auto',
824
- height: currentHeight !== null && currentHeight !== void 0 ? currentHeight : 'auto'
827
+ position: 'absolute',
828
+ // To match the vertical-align: bottom of the img (from style.scss)
829
+ // syncs the top with the img. This matters when the img height is
830
+ // less than the line-height.
831
+ inset: `${offsetTop}px 0 0 0`
825
832
  },
826
- showHandle: isSingleSelected,
833
+ size: pixelSize,
827
834
  minWidth: minWidth,
828
835
  maxWidth: maxResizeWidth,
829
836
  minHeight: minHeight,
@@ -835,9 +842,19 @@ export default function Image({
835
842
  bottom: true,
836
843
  left: showLeftHandle
837
844
  },
838
- onResizeStart: onResizeStart,
839
- onResizeStop: (event, direction, elt) => {
840
- onResizeStop();
845
+ onResizeStart: () => {
846
+ toggleSelection(false);
847
+ },
848
+ onResize: (event, direction, elt, delta) => {
849
+ setResizeDelta(delta);
850
+ },
851
+ onResizeStop: (event, direction, elt, delta) => {
852
+ toggleSelection(true);
853
+ setResizeDelta(null);
854
+ setPixelSize(current => ({
855
+ width: current.width + delta.width,
856
+ height: current.height + delta.height
857
+ }));
841
858
 
842
859
  // Clear hardcoded width if the resized width is close to the max-content width.
843
860
  if (maxContentWidth &&
@@ -861,11 +878,7 @@ export default function Image({
861
878
  aspectRatio: ratio === naturalRatio ? undefined : String(ratio)
862
879
  });
863
880
  },
864
- resizeRatio: align === 'center' ? 2 : 1,
865
- children: /*#__PURE__*/_jsx(ImageWrapper, {
866
- href: href,
867
- children: img
868
- })
881
+ resizeRatio: align === 'center' ? 2 : 1
869
882
  });
870
883
  }
871
884
  if (!url && !temporaryURL) {
@@ -892,7 +905,7 @@ export default function Image({
892
905
  })
893
906
  });
894
907
  return /*#__PURE__*/_jsxs(_Fragment, {
895
- children: [mediaReplaceFlow, controls, featuredImageControl, img, /*#__PURE__*/_jsx(Caption, {
908
+ children: [mediaReplaceFlow, controls, featuredImageControl, img, resizableBox, /*#__PURE__*/_jsx(Caption, {
896
909
  attributes: attributes,
897
910
  setAttributes: setAttributes,
898
911
  isSelected: isSingleSelected,