editorjs-image 1.0.8 → 1.0.10
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -1
- package/src/index.css +10 -18
- package/src/index.js +17 -27
package/package.json
CHANGED
package/src/index.css
CHANGED
|
@@ -1,20 +1,15 @@
|
|
|
1
1
|
.cdx-image-tool-tune--floatLeft.ce-block__content,
|
|
2
|
-
.cdx-image-tool-tune--floatRight.ce-block__content {
|
|
3
|
-
min-height: 20px;
|
|
4
|
-
}
|
|
2
|
+
.cdx-image-tool-tune--floatRight.ce-block__content { min-height: 20px; }
|
|
5
3
|
|
|
6
4
|
.cdx-image-tool-tune--floatLeft.ce-block__content .image-tool__image,
|
|
7
|
-
.cdx-image-tool-tune--floatRight.ce-block__content .image-tool__image {
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
}
|
|
5
|
+
.cdx-image-tool-tune--floatRight.ce-block__content .image-tool__image { margin-top: 40px; }
|
|
6
|
+
.cdx-image-tool-tune--floatLeft.ce-block__content .image-tool__image { margin-left: 20px; }
|
|
7
|
+
.cdx-image-tool-tune--floatRight.ce-block__content .image-tool__image { margin-right: 20px; }
|
|
11
8
|
|
|
12
9
|
.cdx-image-tool-tune--floatLeft.ce-block__content .cdx-input,
|
|
13
|
-
.cdx-image-tool-tune--floatRight.ce-block__content .cdx-input
|
|
14
|
-
{
|
|
15
|
-
|
|
16
|
-
width: calc(100% - 20px);
|
|
17
|
-
}
|
|
10
|
+
.cdx-image-tool-tune--floatRight.ce-block__content .cdx-input { width: calc(100% - 20px); }
|
|
11
|
+
.cdx-image-tool-tune--floatLeft.ce-block__content .cdx-input { margin-left: 20px; }
|
|
12
|
+
.cdx-image-tool-tune--floatRight.ce-block__content .cdx-input { margin-right: 20px; }
|
|
18
13
|
|
|
19
14
|
.cdx-image-tool-tune--floatLeft .cdx-block,
|
|
20
15
|
.cdx-image-tool-tune--center .cdx-block,
|
|
@@ -31,9 +26,7 @@
|
|
|
31
26
|
align-items: center;
|
|
32
27
|
}
|
|
33
28
|
|
|
34
|
-
.cdx-image-tool-tune--center .cdx-block {
|
|
35
|
-
margin: auto;
|
|
36
|
-
}
|
|
29
|
+
.cdx-image-tool-tune--center .cdx-block { margin: auto; }
|
|
37
30
|
|
|
38
31
|
.cdx-image-tool-tune--floatLeft .cdx-block {
|
|
39
32
|
float: left;
|
|
@@ -45,6 +38,8 @@
|
|
|
45
38
|
margin-left: 10px;
|
|
46
39
|
}
|
|
47
40
|
|
|
41
|
+
|
|
42
|
+
|
|
48
43
|
.cdx-image-tool-tune--sizeSmall img {
|
|
49
44
|
max-height: 200px !important;
|
|
50
45
|
object-fit:cover;
|
|
@@ -123,9 +118,6 @@
|
|
|
123
118
|
cursor: nwse-resize;
|
|
124
119
|
}
|
|
125
120
|
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
121
|
.cdx-image-tool-tune--crop:hover,
|
|
130
122
|
.cdx-image-tool-tune--crop.isCropping,
|
|
131
123
|
.cdx-image-tool-tune--resize:hover {
|
package/src/index.js
CHANGED
|
@@ -348,10 +348,6 @@ export class ImageToolTune {
|
|
|
348
348
|
blockContent.classList.remove( this.CSS.isCrop );
|
|
349
349
|
this.uncrop( blockContent );
|
|
350
350
|
}
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
351
|
}
|
|
356
352
|
|
|
357
353
|
|
|
@@ -390,19 +386,22 @@ export class ImageToolTune {
|
|
|
390
386
|
if ( this.api.readOnly.isEnabled ) return;
|
|
391
387
|
|
|
392
388
|
this.uncrop( blockContent );
|
|
393
|
-
const image = blockContent.getElementsByClassName( 'cdx-block' )[ 0 ].getElementsByTagName( 'img' )[ 0 ];
|
|
394
|
-
blockContent.getElementsByClassName( 'cdx-block' )[ 0 ].classList.add( 'isCropping' );
|
|
395
|
-
this.cropperInterface = new Cropper( image, {
|
|
396
|
-
crop( event ) {
|
|
397
|
-
// console.log( event.detail.x );
|
|
398
|
-
// console.log( event.detail.y );
|
|
399
|
-
// console.log( event.detail.width );
|
|
400
|
-
// console.log( event.detail.height );
|
|
401
|
-
// console.log( event.detail.scaleX );
|
|
402
|
-
// console.log( event.detail.scaleY );
|
|
403
|
-
},
|
|
404
|
-
} );
|
|
405
389
|
|
|
390
|
+
var element = blockContent.getElementsByClassName( 'cdx-block' )[ 0 ];
|
|
391
|
+
const image = element.getElementsByTagName( 'img' )[ 0 ];
|
|
392
|
+
if(image && element) {
|
|
393
|
+
element.classList.add( 'isCropping' );
|
|
394
|
+
this.cropperInterface = new Cropper( image, {
|
|
395
|
+
crop( event ) {
|
|
396
|
+
// console.log( event.detail.x );
|
|
397
|
+
// console.log( event.detail.y );
|
|
398
|
+
// console.log( event.detail.width );
|
|
399
|
+
// console.log( event.detail.height );
|
|
400
|
+
// console.log( event.detail.scaleX );
|
|
401
|
+
// console.log( event.detail.scaleY );
|
|
402
|
+
},
|
|
403
|
+
} );
|
|
404
|
+
}
|
|
406
405
|
|
|
407
406
|
//append save crop button
|
|
408
407
|
const cropSaveBtn = document.createElement( 'div' );
|
|
@@ -412,11 +411,6 @@ export class ImageToolTune {
|
|
|
412
411
|
|
|
413
412
|
cropSaveBtn.addEventListener( 'click', e => {
|
|
414
413
|
|
|
415
|
-
console.log( this.cropperInterface.getCropBoxData() );
|
|
416
|
-
console.log( this.cropperInterface.getImageData() );
|
|
417
|
-
console.log( this.cropperInterface.getCanvasData() );
|
|
418
|
-
|
|
419
|
-
|
|
420
414
|
this.data.cropperFrameHeight = this.cropperInterface.getCropBoxData().height;
|
|
421
415
|
this.data.cropperFrameWidth = this.cropperInterface.getCropBoxData().width;
|
|
422
416
|
this.data.cropperFrameLeft = this.cropperInterface.getCanvasData().left - this.cropperInterface.getCropBoxData().left;
|
|
@@ -425,9 +419,7 @@ export class ImageToolTune {
|
|
|
425
419
|
this.data.cropperImageWidth = this.cropperInterface.getImageData().width;
|
|
426
420
|
|
|
427
421
|
this.applyCrop( blockContent );
|
|
428
|
-
|
|
429
|
-
}
|
|
430
|
-
);
|
|
422
|
+
});
|
|
431
423
|
|
|
432
424
|
blockContent.getElementsByClassName( 'image-tool__image' )[ 0 ].appendChild( cropSaveBtn );
|
|
433
425
|
|
|
@@ -576,13 +568,11 @@ export class ImageToolTune {
|
|
|
576
568
|
* */
|
|
577
569
|
resize( blockContent ) {
|
|
578
570
|
|
|
579
|
-
|
|
580
571
|
const resizable = document.createElement( 'div' );
|
|
581
572
|
resizable.classList.add( 'resizable' );
|
|
582
573
|
|
|
583
574
|
// console.log( resizable );
|
|
584
575
|
|
|
585
|
-
|
|
586
576
|
const resizers = document.createElement( 'div' );
|
|
587
577
|
resizers.classList.add( 'resizers' );
|
|
588
578
|
|
|
@@ -712,7 +702,7 @@ export class ImageToolTune {
|
|
|
712
702
|
* @return {HTMLElement}
|
|
713
703
|
*/
|
|
714
704
|
unwrap( blockContent ) {
|
|
715
|
-
|
|
705
|
+
|
|
716
706
|
//remove tunes from block
|
|
717
707
|
this.buttons.forEach( button => {
|
|
718
708
|
button.classList.remove( this.CSS.buttonActive );
|