@@ -27,13 +27,15 @@ export const removeWidget = removeDecoration;
27
27
export type ImageWidgetDescriptorOpts = {
28
28
needToSetDimensionsForUploadedImages : boolean ;
29
29
uploadImages ?: FileUploadHandler ;
30
+ enableNewImageSizeCalculation ?: boolean ;
30
31
} ;
31
32
32
33
class ImageWidgetDescriptor extends ReactWidgetDescriptor {
33
34
private readonly domElem ;
34
35
private readonly deps ;
35
36
private readonly uploadImages ;
36
37
private readonly needToSetDimensionsForUploadedImages : boolean ;
38
+ private readonly enableNewImageSizeCalculation ?: boolean ;
37
39
38
40
private widgetHandler : ImageWidgetHandler | null = null ;
39
41
@@ -43,6 +45,7 @@ class ImageWidgetDescriptor extends ReactWidgetDescriptor {
43
45
this . deps = deps ;
44
46
this . uploadImages = opts . uploadImages ;
45
47
this . needToSetDimensionsForUploadedImages = opts . needToSetDimensionsForUploadedImages ;
48
+ this . enableNewImageSizeCalculation = opts . enableNewImageSizeCalculation ;
46
49
}
47
50
48
51
getWidgetHandler ( view : EditorView , getPos : ( ) => number ) : ImageWidgetHandler {
@@ -54,6 +57,7 @@ class ImageWidgetDescriptor extends ReactWidgetDescriptor {
54
57
decoId : this . id ,
55
58
uploadImages : this . uploadImages ,
56
59
needToSetDimensionsForUploadedImages : this . needToSetDimensionsForUploadedImages ,
60
+ enableNewImageSizeCalculation : this . enableNewImageSizeCalculation ,
57
61
} ,
58
62
this . deps ,
59
63
) ;
@@ -82,6 +86,7 @@ type ImageWidgetHandlerProps = {
82
86
getPos : ( ) => number ;
83
87
uploadImages ?: FileUploadHandler ;
84
88
needToSetDimensionsForUploadedImages : boolean ;
89
+ enableNewImageSizeCalculation ?: boolean ;
85
90
} ;
86
91
87
92
class ImageWidgetHandler {
@@ -92,6 +97,7 @@ class ImageWidgetHandler {
92
97
private readonly uploadImages ;
93
98
private readonly normalizeUrl ;
94
99
private readonly needToSetDimensionsForUploadedImages : boolean ;
100
+ private readonly enableNewImageSizeCalculation ?: boolean ;
95
101
96
102
private cancelled = false ;
97
103
@@ -102,6 +108,7 @@ class ImageWidgetHandler {
102
108
getPos,
103
109
uploadImages,
104
110
needToSetDimensionsForUploadedImages,
111
+ enableNewImageSizeCalculation,
105
112
} : ImageWidgetHandlerProps ,
106
113
deps : ExtensionDeps ,
107
114
) {
@@ -111,6 +118,7 @@ class ImageWidgetHandler {
111
118
this . uploadImages = uploadImages ;
112
119
this . normalizeUrl = normalizeUrlFactory ( deps ) ;
113
120
this . needToSetDimensionsForUploadedImages = needToSetDimensionsForUploadedImages ;
121
+ this . enableNewImageSizeCalculation = enableNewImageSizeCalculation ;
114
122
}
115
123
116
124
destruct ( ) {
@@ -159,6 +167,7 @@ class ImageWidgetHandler {
159
167
const { view} = this ;
160
168
new ImagesUploadProcess ( view , files , this . uploadImages , this . getPos ( ) , {
161
169
needDimensions : this . needToSetDimensionsForUploadedImages ,
170
+ enableNewImageSizeCalculation : this . enableNewImageSizeCalculation ,
162
171
} ) . run ( ) ;
163
172
view . dispatch ( removeWidget ( view . state . tr , this . decoId ) ) ;
164
173
view . focus ( ) ;
0 commit comments