@@ -25,13 +25,15 @@ export const removeWidget = removeDecoration;
2525export type ImageWidgetDescriptorOpts = {
2626 needToSetDimensionsForUploadedImages : boolean ;
2727 uploadImages ?: FileUploadHandler ;
28+ enableNewImageSizeCalculation ?: boolean ;
2829} ;
2930
3031class ImageWidgetDescriptor extends ReactWidgetDescriptor {
3132 private readonly domElem ;
3233 private readonly deps ;
3334 private readonly uploadImages ;
3435 private readonly needToSetDimensionsForUploadedImages : boolean ;
36+ private readonly enableNewImageSizeCalculation ?: boolean ;
3537
3638 private widgetHandler : ImageWidgetHandler | null = null ;
3739
@@ -41,6 +43,7 @@ class ImageWidgetDescriptor extends ReactWidgetDescriptor {
4143 this . deps = deps ;
4244 this . uploadImages = opts . uploadImages ;
4345 this . needToSetDimensionsForUploadedImages = opts . needToSetDimensionsForUploadedImages ;
46+ this . enableNewImageSizeCalculation = opts . enableNewImageSizeCalculation ;
4447 }
4548
4649 getWidgetHandler ( view : EditorView , getPos : ( ) => number ) : ImageWidgetHandler {
@@ -52,6 +55,7 @@ class ImageWidgetDescriptor extends ReactWidgetDescriptor {
5255 decoId : this . id ,
5356 uploadImages : this . uploadImages ,
5457 needToSetDimensionsForUploadedImages : this . needToSetDimensionsForUploadedImages ,
58+ enableNewImageSizeCalculation : this . enableNewImageSizeCalculation ,
5559 } ,
5660 this . deps ,
5761 ) ;
@@ -80,6 +84,7 @@ type ImageWidgetHandlerProps = {
8084 getPos : ( ) => number ;
8185 uploadImages ?: FileUploadHandler ;
8286 needToSetDimensionsForUploadedImages : boolean ;
87+ enableNewImageSizeCalculation ?: boolean ;
8388} ;
8489
8590class ImageWidgetHandler {
@@ -90,6 +95,7 @@ class ImageWidgetHandler {
9095 private readonly uploadImages ;
9196 private readonly normalizeUrl ;
9297 private readonly needToSetDimensionsForUploadedImages : boolean ;
98+ private readonly enableNewImageSizeCalculation ?: boolean ;
9399
94100 private cancelled = false ;
95101
@@ -100,6 +106,7 @@ class ImageWidgetHandler {
100106 getPos,
101107 uploadImages,
102108 needToSetDimensionsForUploadedImages,
109+ enableNewImageSizeCalculation,
103110 } : ImageWidgetHandlerProps ,
104111 deps : ExtensionDeps ,
105112 ) {
@@ -109,6 +116,7 @@ class ImageWidgetHandler {
109116 this . uploadImages = uploadImages ;
110117 this . normalizeUrl = normalizeUrlFactory ( deps ) ;
111118 this . needToSetDimensionsForUploadedImages = needToSetDimensionsForUploadedImages ;
119+ this . enableNewImageSizeCalculation = enableNewImageSizeCalculation ;
112120 }
113121
114122 destruct ( ) {
@@ -157,6 +165,7 @@ class ImageWidgetHandler {
157165 const { view} = this ;
158166 new ImagesUploadProcess ( view , files , this . uploadImages , this . getPos ( ) , {
159167 needDimensions : this . needToSetDimensionsForUploadedImages ,
168+ enableNewImageSizeCalculation : this . enableNewImageSizeCalculation ,
160169 } ) . run ( ) ;
161170 view . dispatch ( removeWidget ( view . state . tr , this . decoId ) ) ;
162171 view . focus ( ) ;
0 commit comments