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