@@ -27,13 +27,15 @@ export const removeWidget = removeDecoration;
2727export type ImageWidgetDescriptorOpts = {
2828 needToSetDimensionsForUploadedImages : boolean ;
2929 uploadImages ?: FileUploadHandler ;
30+ enableNewImageSizeCalculation ?: boolean ;
3031} ;
3132
3233class ImageWidgetDescriptor extends ReactWidgetDescriptor {
3334 private readonly domElem ;
3435 private readonly deps ;
3536 private readonly uploadImages ;
3637 private readonly needToSetDimensionsForUploadedImages : boolean ;
38+ private readonly enableNewImageSizeCalculation ?: boolean ;
3739
3840 private widgetHandler : ImageWidgetHandler | null = null ;
3941
@@ -43,6 +45,7 @@ class ImageWidgetDescriptor extends ReactWidgetDescriptor {
4345 this . deps = deps ;
4446 this . uploadImages = opts . uploadImages ;
4547 this . needToSetDimensionsForUploadedImages = opts . needToSetDimensionsForUploadedImages ;
48+ this . enableNewImageSizeCalculation = opts . enableNewImageSizeCalculation ;
4649 }
4750
4851 getWidgetHandler ( view : EditorView , getPos : ( ) => number ) : ImageWidgetHandler {
@@ -54,6 +57,7 @@ class ImageWidgetDescriptor extends ReactWidgetDescriptor {
5457 decoId : this . id ,
5558 uploadImages : this . uploadImages ,
5659 needToSetDimensionsForUploadedImages : this . needToSetDimensionsForUploadedImages ,
60+ enableNewImageSizeCalculation : this . enableNewImageSizeCalculation ,
5761 } ,
5862 this . deps ,
5963 ) ;
@@ -82,6 +86,7 @@ type ImageWidgetHandlerProps = {
8286 getPos : ( ) => number ;
8387 uploadImages ?: FileUploadHandler ;
8488 needToSetDimensionsForUploadedImages : boolean ;
89+ enableNewImageSizeCalculation ?: boolean ;
8590} ;
8691
8792class ImageWidgetHandler {
@@ -92,6 +97,7 @@ class ImageWidgetHandler {
9297 private readonly uploadImages ;
9398 private readonly normalizeUrl ;
9499 private readonly needToSetDimensionsForUploadedImages : boolean ;
100+ private readonly enableNewImageSizeCalculation ?: boolean ;
95101
96102 private cancelled = false ;
97103
@@ -102,6 +108,7 @@ class ImageWidgetHandler {
102108 getPos,
103109 uploadImages,
104110 needToSetDimensionsForUploadedImages,
111+ enableNewImageSizeCalculation,
105112 } : ImageWidgetHandlerProps ,
106113 deps : ExtensionDeps ,
107114 ) {
@@ -111,6 +118,7 @@ class ImageWidgetHandler {
111118 this . uploadImages = uploadImages ;
112119 this . normalizeUrl = normalizeUrlFactory ( deps ) ;
113120 this . needToSetDimensionsForUploadedImages = needToSetDimensionsForUploadedImages ;
121+ this . enableNewImageSizeCalculation = enableNewImageSizeCalculation ;
114122 }
115123
116124 destruct ( ) {
@@ -159,6 +167,7 @@ class ImageWidgetHandler {
159167 const { view} = this ;
160168 new ImagesUploadProcess ( view , files , this . uploadImages , this . getPos ( ) , {
161169 needDimensions : this . needToSetDimensionsForUploadedImages ,
170+ enableNewImageSizeCalculation : this . enableNewImageSizeCalculation ,
162171 } ) . run ( ) ;
163172 view . dispatch ( removeWidget ( view . state . tr , this . decoId ) ) ;
164173 view . focus ( ) ;
0 commit comments