editorjs-image 1.0.11 → 1.0.12

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 CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "editorjs-image",
3
- "version": "1.0.11",
3
+ "version": "1.0.12",
4
4
  "description": "Image tool plugin for Editor.js",
5
5
  "main": "src/index.js",
6
6
  "scripts": {
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-tool__image-picture { max-height:500px; }
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
- right: 0;
145
- padding: 5px;
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
@@ -271,9 +271,6 @@ export class ImageToolTune {
271
271
  this.apply( blockContent );
272
272
 
273
273
  this.block.dispatchChange();
274
-
275
-
276
-
277
274
  }
278
275
 
279
276
 
@@ -512,7 +509,8 @@ export class ImageToolTune {
512
509
 
513
510
  //remove isCropped class
514
511
 
515
- blockContent.getElementsByClassName( 'cdx-block' )[ 0 ].getElementsByTagName( 'img' )[ 0 ].classList.remove( 'isCropped' );
512
+ var img = blockContent.getElementsByClassName( 'cdx-block' )[ 0 ]?.getElementsByTagName( 'img' )[ 0 ] || undefined;
513
+ if(img) img.classList.remove( 'isCropped' );
516
514
 
517
515
  //remove isCropping class
518
516
  blockContent.getElementsByClassName( 'cdx-block' )[ 0 ].classList.remove( 'isCropping' );
@@ -522,38 +520,42 @@ export class ImageToolTune {
522
520
  blockContent.getElementsByClassName( 'cdx-block' )[ 0 ].style.maxWidth = '';
523
521
 
524
522
  //remove image width and height
525
- blockContent.getElementsByClassName( 'image-tool__image' )[ 0 ].style.width = '';
526
- blockContent.getElementsByClassName( 'image-tool__image' )[ 0 ].style.height = '';
523
+ var imgBlockEl = blockContent.getElementsByClassName( 'image-tool__image' )[ 0 ];
524
+ if (imgBlockEl) {
525
+ imgBlockEl.style.width = '';
526
+ imgBlockEl.style.height = '';
527
+ }
527
528
 
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 = '';
529
+ var imgEl = imgBlockEl?.getElementsByTagName( 'img' )[ 0 ] || undefined;
530
+ if(imgEl) {
531
531
 
532
- //remove image width and height
533
- blockContent.getElementsByClassName( 'image-tool__image' )[ 0 ].getElementsByTagName( 'img' )[ 0 ].style.width = '';
534
- blockContent.getElementsByClassName( 'image-tool__image' )[ 0 ].getElementsByTagName( 'img' )[ 0 ].style.height = '';
532
+ //remove image left and top
533
+ imgEl.style.left = '';
534
+ imgEl.style.top = '';
535
535
 
536
+ //remove image width and height
537
+ imgEl.style.width = '';
538
+ imgEl.style.height = '';
539
+ }
536
540
 
537
541
 
538
542
  blockContent.classList.remove( 'isCropping' );
539
543
 
540
-
541
-
542
544
  //remove cropper interface
545
+
543
546
  if ( this.cropperInterface ) {
544
547
  this.cropperInterface.destroy();
545
- }
546
548
 
547
- //remove crop data
548
- this.data.cropperFrameHeight = 0;
549
- this.data.cropperFrameWidth = 0;
550
- this.data.cropperFrameLeft = 0;
551
- this.data.cropperFrameTop = 0;
552
- this.data.cropperImageHeight = 0;
553
- this.data.cropperImageWidth = 0;
554
-
555
- this.block.dispatchChange();
549
+ //remove crop data
550
+ this.data.cropperFrameHeight = 0;
551
+ this.data.cropperFrameWidth = 0;
552
+ this.data.cropperFrameLeft = 0;
553
+ this.data.cropperFrameTop = 0;
554
+ this.data.cropperImageHeight = 0;
555
+ this.data.cropperImageWidth = 0;
556
556
 
557
+ this.block.dispatchChange();
558
+ }
557
559
  }
558
560
 
559
561
 
@@ -708,6 +710,8 @@ export class ImageToolTune {
708
710
  button.classList.remove( this.CSS.buttonActive );
709
711
  } );
710
712
 
713
+ blockContent.classList.remove( this.CSS.wrapper );
714
+
711
715
  //remove isFloatLeft class
712
716
  blockContent.classList.remove( this.CSS.isFloatLeft );
713
717
 
@@ -802,6 +806,7 @@ export class ImageToolTune {
802
806
  this.wrapper = this.createView();
803
807
  }
804
808
 
809
+ blockContent.classList.add( this.CSS.wrapper );
805
810
 
806
811
  this.apply( blockContent );
807
812