editorjs-image 1.0.11 → 1.0.13
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 +22 -7
- package/src/index.js +54 -40
package/package.json
CHANGED
package/src/index.css
CHANGED
|
@@ -39,7 +39,7 @@
|
|
|
39
39
|
}
|
|
40
40
|
|
|
41
41
|
|
|
42
|
-
|
|
42
|
+
.cdx-image-tool-tune--sizeSmall .image-tool__caption { max-height: 200px; }
|
|
43
43
|
.cdx-image-tool-tune--sizeSmall img {
|
|
44
44
|
max-height: 200px !important;
|
|
45
45
|
object-fit:cover;
|
|
@@ -49,6 +49,7 @@
|
|
|
49
49
|
max-width: 25% !important;
|
|
50
50
|
}
|
|
51
51
|
|
|
52
|
+
.cdx-image-tool-tune--sizeMiddle .image-tool__caption { max-height: 300px; }
|
|
52
53
|
.cdx-image-tool-tune--sizeMiddle img {
|
|
53
54
|
max-height: 300px !important;
|
|
54
55
|
object-fit:cover;
|
|
@@ -56,9 +57,8 @@
|
|
|
56
57
|
.cdx-image-tool-tune--sizeMiddle .cdx-block {
|
|
57
58
|
max-width: 50% !important;
|
|
58
59
|
}
|
|
59
|
-
|
|
60
|
-
.image-
|
|
61
|
-
|
|
60
|
+
|
|
61
|
+
.cdx-image-tool-tune--sizeLarge .image-tool__caption { max-height: 400px; }
|
|
62
62
|
.cdx-image-tool-tune--sizeLarge img {
|
|
63
63
|
max-height: 400px !important;
|
|
64
64
|
object-fit:cover;
|
|
@@ -67,6 +67,22 @@
|
|
|
67
67
|
max-width: 75% !important;
|
|
68
68
|
}
|
|
69
69
|
|
|
70
|
+
.cdx-image-tool-tune--sizeLarge img,
|
|
71
|
+
.cdx-image-tool-tune--sizeMiddle img,
|
|
72
|
+
.cdx-image-tool-tune--sizeSmall img,
|
|
73
|
+
.cdx-image-tool-tune--floatLeft img,
|
|
74
|
+
.cdx-image-tool-tune--floatRight img
|
|
75
|
+
{ max-height:500px; }
|
|
76
|
+
|
|
77
|
+
.cdx-image-tool-tune--sizeLarge .image-tool__caption,
|
|
78
|
+
.cdx-image-tool-tune--sizeMiddle .image-tool__caption,
|
|
79
|
+
.cdx-image-tool-tune--sizeSmall .image-tool__caption,
|
|
80
|
+
.cdx-image-tool-tune--floatLeft .image-tool__caption,
|
|
81
|
+
.cdx-image-tool-tune--floatRight .image-tool__caption
|
|
82
|
+
{
|
|
83
|
+
max-height:500px;
|
|
84
|
+
}
|
|
85
|
+
|
|
70
86
|
.codex-editor.read-only .cdx-input.image-tool__caption:empty,
|
|
71
87
|
.read-only > .codex-editor .cdx-input.image-tool__caption:empty
|
|
72
88
|
{
|
|
@@ -141,10 +157,9 @@
|
|
|
141
157
|
.cdx-image-tool-tune--crop .image-tool__image .crop-save {
|
|
142
158
|
position: absolute;
|
|
143
159
|
top: 0;
|
|
144
|
-
|
|
145
|
-
padding:
|
|
160
|
+
left: 0;
|
|
161
|
+
padding: 7px;
|
|
146
162
|
background: #4286f4;
|
|
147
|
-
border-radius: 5px;
|
|
148
163
|
color: white;
|
|
149
164
|
text-align: center;
|
|
150
165
|
line-height: 20px;
|
package/src/index.js
CHANGED
|
@@ -348,6 +348,10 @@ export class ImageToolTune {
|
|
|
348
348
|
blockContent.classList.remove( this.CSS.isCrop );
|
|
349
349
|
this.uncrop( blockContent );
|
|
350
350
|
}
|
|
351
|
+
|
|
352
|
+
|
|
353
|
+
|
|
354
|
+
|
|
351
355
|
}
|
|
352
356
|
|
|
353
357
|
|
|
@@ -386,22 +390,20 @@ export class ImageToolTune {
|
|
|
386
390
|
if ( this.api.readOnly.isEnabled ) return;
|
|
387
391
|
|
|
388
392
|
this.uncrop( blockContent );
|
|
393
|
+
var imageBlock = blockContent.getElementsByClassName( 'cdx-block' )[ 0 ];
|
|
394
|
+
const image = imageBlock.getElementsByTagName( 'img' )[ 0 ];
|
|
395
|
+
imageBlock.classList.add( 'isCropping' );
|
|
396
|
+
this.cropperInterface = new Cropper( image, {
|
|
397
|
+
crop( event ) {
|
|
398
|
+
// console.log( event.detail.x );
|
|
399
|
+
// console.log( event.detail.y );
|
|
400
|
+
// console.log( event.detail.width );
|
|
401
|
+
// console.log( event.detail.height );
|
|
402
|
+
// console.log( event.detail.scaleX );
|
|
403
|
+
// console.log( event.detail.scaleY );
|
|
404
|
+
},
|
|
405
|
+
} );
|
|
389
406
|
|
|
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
|
-
}
|
|
405
407
|
|
|
406
408
|
//append save crop button
|
|
407
409
|
const cropSaveBtn = document.createElement( 'div' );
|
|
@@ -419,7 +421,9 @@ export class ImageToolTune {
|
|
|
419
421
|
this.data.cropperImageWidth = this.cropperInterface.getImageData().width;
|
|
420
422
|
|
|
421
423
|
this.applyCrop( blockContent );
|
|
422
|
-
|
|
424
|
+
|
|
425
|
+
}
|
|
426
|
+
);
|
|
423
427
|
|
|
424
428
|
blockContent.getElementsByClassName( 'image-tool__image' )[ 0 ].appendChild( cropSaveBtn );
|
|
425
429
|
|
|
@@ -498,41 +502,50 @@ export class ImageToolTune {
|
|
|
498
502
|
if ( this.api.readOnly.isEnabled ) return;
|
|
499
503
|
|
|
500
504
|
//remove crop and save button
|
|
501
|
-
const cropSaveBtn = blockContent.getElementsByClassName( 'btn-crop-action' )[ 0 ]
|
|
505
|
+
const cropSaveBtn = blockContent.getElementsByClassName( 'btn-crop-action' )[ 0 ] ?? undefined
|
|
502
506
|
if ( cropSaveBtn ) {
|
|
503
507
|
blockContent.getElementsByClassName( 'image-tool__image' )[ 0 ].removeChild( cropSaveBtn );
|
|
504
508
|
}
|
|
505
509
|
|
|
506
510
|
|
|
507
511
|
//remove crop button
|
|
508
|
-
const cropBtn = blockContent.getElementsByClassName( 'btn-crop-action' )[ 0 ]
|
|
512
|
+
const cropBtn = blockContent.getElementsByClassName( 'btn-crop-action' )[ 0 ] ?? undefined
|
|
509
513
|
if ( cropBtn ) {
|
|
510
514
|
blockContent.getElementsByClassName( 'image-tool__image' )[ 0 ].removeChild( cropBtn );
|
|
511
515
|
}
|
|
512
516
|
|
|
513
517
|
//remove isCropped class
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
//remove image left and top
|
|
529
|
-
blockContent.getElementsByClassName( 'image-tool__image' )[ 0 ].getElementsByTagName( 'img' )[ 0 ].style.left = '';
|
|
530
|
-
blockContent.getElementsByClassName( 'image-tool__image' )[ 0 ].getElementsByTagName( 'img' )[ 0 ].style.top = '';
|
|
518
|
+
var blockEl = blockContent.getElementsByClassName( 'cdx-block' )[ 0 ] ?? undefined
|
|
519
|
+
if (blockEl) {
|
|
520
|
+
|
|
521
|
+
var img = blockEl.getElementsByTagName( 'img' )[ 0 ] || undefined;
|
|
522
|
+
if (img) img.classList.remove( 'isCropped' );
|
|
523
|
+
|
|
524
|
+
//remove isCropping class
|
|
525
|
+
blockEl.classList.remove( 'isCropping' );
|
|
526
|
+
|
|
527
|
+
//remove min and max width
|
|
528
|
+
blockEl.style.minWidth = '';
|
|
529
|
+
blockEl.style.maxWidth = '';
|
|
530
|
+
}
|
|
531
531
|
|
|
532
532
|
//remove image width and height
|
|
533
|
-
blockContent.getElementsByClassName( 'image-tool__image' )[ 0 ]
|
|
534
|
-
|
|
535
|
-
|
|
533
|
+
var imgEl = blockContent.getElementsByClassName( 'image-tool__image' )[ 0 ] ?? undefined;
|
|
534
|
+
if (imgEl) {
|
|
535
|
+
imgEl.style.width = '';
|
|
536
|
+
imgEl.style.height = '';
|
|
537
|
+
|
|
538
|
+
//remove image left and top
|
|
539
|
+
var img = imgEl.getElementsByTagName( 'img' )[ 0 ] ?? undefined;
|
|
540
|
+
if (img) {
|
|
541
|
+
img.style.left = '';
|
|
542
|
+
img.style.top = '';
|
|
543
|
+
|
|
544
|
+
//remove image width and height
|
|
545
|
+
img.style.width = '';
|
|
546
|
+
img.style.height = '';
|
|
547
|
+
}
|
|
548
|
+
}
|
|
536
549
|
|
|
537
550
|
|
|
538
551
|
blockContent.classList.remove( 'isCropping' );
|
|
@@ -552,8 +565,7 @@ export class ImageToolTune {
|
|
|
552
565
|
this.data.cropperImageHeight = 0;
|
|
553
566
|
this.data.cropperImageWidth = 0;
|
|
554
567
|
|
|
555
|
-
this.block.dispatchChange();
|
|
556
|
-
|
|
568
|
+
// this.block.dispatchChange();
|
|
557
569
|
}
|
|
558
570
|
|
|
559
571
|
|
|
@@ -568,11 +580,13 @@ export class ImageToolTune {
|
|
|
568
580
|
* */
|
|
569
581
|
resize( blockContent ) {
|
|
570
582
|
|
|
583
|
+
|
|
571
584
|
const resizable = document.createElement( 'div' );
|
|
572
585
|
resizable.classList.add( 'resizable' );
|
|
573
586
|
|
|
574
587
|
// console.log( resizable );
|
|
575
588
|
|
|
589
|
+
|
|
576
590
|
const resizers = document.createElement( 'div' );
|
|
577
591
|
resizers.classList.add( 'resizers' );
|
|
578
592
|
|