@@ -3,6 +3,7 @@ import D from "cropperjs";
33const h = [ "src" , "alt" , "crossorigin" ] , x = /* @__PURE__ */ s ( {
44 __name : "VueCropper" ,
55 props : {
6+ // custom props
67 src : {
78 type : String ,
89 required : ! 0
@@ -19,114 +20,145 @@ const h = ["src", "alt", "crossorigin"], x = /* @__PURE__ */ s({
1920 type : String ,
2021 default : void 0
2122 } ,
23+ // ========= CropperJS options =======
24+ // Define the view mode of the cropper
2225 viewMode : {
2326 type : Number ,
27+ // 0, 1, 2, 3
2428 default : 0
2529 } ,
30+ // Define the dragging mode of the cropper
2631 dragMode : {
2732 type : String ,
33+ // 'crop', 'move' or 'none'
2834 default : "crop"
2935 } ,
36+ // Define the initial aspect ratio of the crop box
3037 initialAspectRatio : {
3138 type : Number ,
3239 default : NaN
3340 } ,
41+ // Define the aspect ratio of the crop box
3442 aspectRatio : {
3543 type : Number ,
3644 default : NaN
3745 } ,
46+ // An object with the previous cropping result data
3847 data : {
3948 type : Object ,
4049 default : void 0
4150 } ,
51+ // A selector for adding extra containers to preview
4252 preview : {
4353 type : [ String , Array , Object ] ,
4454 default : ""
4555 } ,
56+ // Re-render the cropper when resize the window
4657 responsive : {
4758 type : Boolean ,
4859 default : ! 0
4960 } ,
61+ // Restore the cropped area after resize the window
5062 restore : {
5163 type : Boolean ,
5264 default : ! 0
5365 } ,
66+ // Check if the current image is a cross-origin image
5467 checkCrossOrigin : {
5568 type : Boolean ,
5669 default : ! 0
5770 } ,
71+ // Check the current image's Exif Orientation information
5872 checkOrientation : {
5973 type : Boolean ,
6074 default : ! 0
6175 } ,
76+ // Show the black modal
6277 modal : {
6378 type : Boolean ,
6479 default : ! 0
6580 } ,
81+ // Show the dashed lines for guiding
6682 guides : {
6783 type : Boolean ,
6884 default : ! 0
6985 } ,
86+ // Show the center indicator for guiding
7087 center : {
7188 type : Boolean ,
7289 default : ! 0
7390 } ,
91+ // Show the white modal to highlight the crop box
7492 highlight : {
7593 type : Boolean ,
7694 default : ! 0
7795 } ,
96+ // Show the grid background
7897 background : {
7998 type : Boolean ,
8099 default : ! 0
81100 } ,
101+ // Enable to crop the image automatically when initialize
82102 autoCrop : {
83103 type : Boolean ,
84104 default : ! 0
85105 } ,
106+ // Define the percentage of automatic cropping area when initializes
86107 autoCropArea : {
87108 type : Number ,
88109 default : 0.8
89110 } ,
111+ // Enable to move the image
90112 movable : {
91113 type : Boolean ,
92114 default : ! 0
93115 } ,
116+ // Enable to rotate the image
94117 rotatable : {
95118 type : Boolean ,
96119 default : ! 0
97120 } ,
121+ // Enable to scale the image
98122 scalable : {
99123 type : Boolean ,
100124 default : ! 0
101125 } ,
126+ // Enable to zoom the image
102127 zoomable : {
103128 type : Boolean ,
104129 default : ! 0
105130 } ,
131+ // Enable to zoom the image by dragging touch
106132 zoomOnTouch : {
107133 type : Boolean ,
108134 default : ! 0
109135 } ,
136+ // Enable to zoom the image by wheeling mouse
110137 zoomOnWheel : {
111138 type : Boolean ,
112139 default : ! 0
113140 } ,
141+ // Define zoom ratio when zoom the image by wheeling mouse
114142 wheelZoomRatio : {
115143 type : Number ,
116144 default : 0.1
117145 } ,
146+ // Enable to move the crop box
118147 cropBoxMovable : {
119148 type : Boolean ,
120149 default : ! 0
121150 } ,
151+ // Enable to resize the crop box
122152 cropBoxResizable : {
123153 type : Boolean ,
124154 default : ! 0
125155 } ,
156+ // Toggle drag mode between "crop" and "move" when click twice on the cropper
126157 toggleDragModeOnDblclick : {
127158 type : Boolean ,
128159 default : ! 0
129160 } ,
161+ // Size limitation
130162 minCanvasWidth : {
131163 type : Number ,
132164 default : 0
@@ -151,6 +183,7 @@ const h = ["src", "alt", "crossorigin"], x = /* @__PURE__ */ s({
151183 type : Number ,
152184 default : 100
153185 } ,
186+ // Shortcuts of events
154187 ready : {
155188 type : Function ,
156189 default : void 0
@@ -179,6 +212,7 @@ const h = ["src", "alt", "crossorigin"], x = /* @__PURE__ */ s({
179212 setup ( o , { expose : i } ) {
180213 const n = o , d = {
181214 display : "block" ,
215+ /* This rule is very important, please don't ignore this */
182216 maxWidth : "100%"
183217 } , u = r ( ) ;
184218 let e ;
@@ -192,93 +226,214 @@ const h = ["src", "alt", "crossorigin"], x = /* @__PURE__ */ s({
192226 } ,
193227 { deep : ! 0 }
194228 ) , i ( {
229+ // Clear the crop box
195230 clear ( ) {
196231 return e == null ? void 0 : e . clear ( ) ;
197232 } ,
233+ // Show the crop box manually
198234 crop ( ) {
199235 return e == null ? void 0 : e . crop ( ) ;
200236 } ,
237+ /**
238+ * Destroy the cropper and remove the instance from the image
239+ * @returns {Cropper } this
240+ */
201241 destroy ( ) {
202242 return e == null ? void 0 : e . destroy ( ) ;
203243 } ,
244+ // Disable (freeze) the cropper
204245 disable ( ) {
205246 return e == null ? void 0 : e . disable ( ) ;
206247 } ,
248+ // Enable (unfreeze) the cropper
207249 enable ( ) {
208250 return e == null ? void 0 : e . enable ( ) ;
209251 } ,
252+ /**
253+ * Get the canvas position and size data.
254+ * @returns {Object } The result canvas data.
255+ */
210256 getCanvasData ( ) {
211257 return e == null ? void 0 : e . getCanvasData ( ) ;
212258 } ,
259+ /**
260+ * Get the container size data.
261+ * @returns {Object } The result container data.
262+ */
213263 getContainerData ( ) {
214264 return e == null ? void 0 : e . getContainerData ( ) ;
215265 } ,
266+ /**
267+ * Get the crop box position and size data.
268+ * @returns {Object } The result crop box data.
269+ */
216270 getCropBoxData ( ) {
217271 return e == null ? void 0 : e . getCropBoxData ( ) ;
218272 } ,
273+ /**
274+ * Get a canvas drawn the cropped image.
275+ * @param {Object } [options={}] - The config options.
276+ * @returns {HTMLCanvasElement } - The result canvas.
277+ */
219278 getCroppedCanvas ( t ) {
220279 return e == null ? void 0 : e . getCroppedCanvas ( t ) ;
221280 } ,
281+ /**
282+ * Get the cropped area position and size data (base on the original image)
283+ * @param {boolean } [rounded=false] - Indicate if round the data values or not.
284+ * @returns {Object } The result cropped data.
285+ */
222286 getData ( t ) {
223287 return e == null ? void 0 : e . getData ( t ) ;
224288 } ,
289+ /**
290+ * Get the image position and size data.
291+ * @returns {Object } The result image data.
292+ */
225293 getImageData ( ) {
226294 return e == null ? void 0 : e . getImageData ( ) ;
227295 } ,
296+ /**
297+ * Move the canvas with relative offsets
298+ * @param {number } offsetX - The relative offset distance on the x-axis.
299+ * @param {number } [offsetY=offsetX] - The relative offset distance on the y-axis.
300+ * @returns {Cropper } this
301+ */
228302 move ( t , a ) {
229303 return e == null ? void 0 : e . move ( t , a ) ;
230304 } ,
305+ /**
306+ * Move the canvas to an absolute point
307+ * @param {number } x - The x-axis coordinate.
308+ * @param {number } [y=x] - The y-axis coordinate.
309+ * @returns {Cropper } this
310+ */
231311 moveTo ( t , a ) {
232312 return e == null ? void 0 : e . moveTo ( t , a ) ;
233313 } ,
314+ /**
315+ * Replace the image's src and rebuild the cropper
316+ * @param {string } url - The new URL.
317+ * @param {boolean } [hasSameSize] - Indicate if the new image has the same size as the old one.
318+ * @returns {Cropper } this
319+ */
234320 replace ( t , a ) {
235321 return e == null ? void 0 : e . replace ( t , a ) ;
236322 } ,
323+ // Reset the image and crop box to their initial states
237324 reset ( ) {
238325 return e == null ? void 0 : e . reset ( ) ;
239326 } ,
327+ /**
328+ * Rotate the canvas with a relative degree
329+ * @param {number } degree - The rotate degree.
330+ * @returns {Cropper } this
331+ */
240332 rotate ( t ) {
241333 return e == null ? void 0 : e . rotate ( t ) ;
242334 } ,
335+ /**
336+ * Rotate the canvas to an absolute degree
337+ * @param {number } degree - The rotate degree.
338+ * @returns {Cropper } this
339+ */
243340 rotateTo ( t ) {
244341 return e == null ? void 0 : e . rotateTo ( t ) ;
245342 } ,
343+ /**
344+ * Scale the image
345+ * @param {number } scaleX - The scale ratio on the x-axis.
346+ * @param {number } [scaleY=scaleX] - The scale ratio on the y-axis.
347+ * @returns {Cropper } this
348+ */
246349 scale ( t , a ) {
247350 return e == null ? void 0 : e . scale ( t , a ) ;
248351 } ,
352+ /**
353+ * Scale the image on the x-axis.
354+ * @param {number } scaleX - The scale ratio on the x-axis.
355+ * @returns {Cropper } this
356+ */
249357 scaleX ( t ) {
250358 return e == null ? void 0 : e . scaleX ( t ) ;
251359 } ,
360+ /**
361+ * Scale the image on the y-axis.
362+ * @param {number } scaleY - The scale ratio on the y-axis.
363+ * @returns {Cropper } this
364+ */
252365 scaleY ( t ) {
253366 return e == null ? void 0 : e . scaleY ( t ) ;
254367 } ,
368+ /**
369+ * Change the aspect ratio of the crop box.
370+ * @param {number } aspectRatio - The new aspect ratio.
371+ * @returns {Cropper } this
372+ */
255373 setAspectRatio ( t ) {
256374 return e == null ? void 0 : e . setAspectRatio ( t ) ;
257375 } ,
376+ /**
377+ * Set the canvas position and size with new data.
378+ * @param {Object } data - The new canvas data.
379+ * @returns {Cropper } this
380+ */
258381 setCanvasData ( t ) {
259382 return e == null ? void 0 : e . setCanvasData ( t ) ;
260383 } ,
384+ /**
385+ * Set the crop box position and size with new data.
386+ * @param {Object } data - The new crop box data.
387+ * @returns {Cropper } this
388+ */
261389 setCropBoxData ( t ) {
262390 return e == null ? void 0 : e . setCropBoxData ( t ) ;
263391 } ,
392+ /**
393+ * Set the cropped area position and size with new data
394+ * @param {Object } data - The new data.
395+ * @returns {Cropper } this
396+ */
264397 setData ( t ) {
265398 return e == null ? void 0 : e . setData ( t ) ;
266399 } ,
400+ /**
401+ * Change the drag mode.
402+ * @param {string } dragMode - The new drag mode.
403+ * @returns {Cropper } this
404+ */
267405 setDragMode ( t ) {
268406 return e == null ? void 0 : e . setDragMode ( t ) ;
269407 } ,
408+ /**
409+ * Zoom the canvas with a relative ratio
410+ * @param {number } ratio - The target ratio.
411+ * @returns {Cropper } this
412+ */
270413 zoom ( t ) {
271414 return e == null ? void 0 : e . zoom ( t ) ;
272415 } ,
416+ /**
417+ * Zoom the canvas to an absolute ratio
418+ * @param {number } ratio - The target ratio.
419+ * @param {Object } pivot - The zoom pivot point coordinate.
420+ * @returns {Cropper } this
421+ */
273422 zoomTo ( t , a ) {
274423 return e == null ? void 0 : e . zoomTo ( t , a ) ;
275424 } ,
425+ /**
426+ * flip the image horizontally
427+ */
276428 flipX ( ) {
277429 if ( e ) {
278430 const { scaleX : t } = e . getData ( ) ;
279431 e . scaleX ( - t ) ;
280432 }
281433 } ,
434+ /**
435+ * flip the image vertically
436+ */
282437 flipY ( ) {
283438 if ( e ) {
284439 const { scaleY : t } = e . getData ( ) ;
0 commit comments