jodit icon indicating copy to clipboard operation
jodit copied to clipboard

improvement for image editor (event, ratio change)

Open coolibry opened this issue 2 years ago • 1 comments

Jodit Version: 3.16.5

Browser: Chrome & Firefox OS: Windows &Linux Is React App: False

Code for event afterImageEditor

var editor = new Jodit('#editor', {
	imageDefaultWidth: 600,
	events: {
		afterImageEditor: function(ev){ //this don't launch
			console.log(ev);
  	      },
		afterInsertImage: function(ev){
			Jodit.modules.resize_small_img(ev, "editor");
		},
	}
});

Jodit.modules.resize_small_img = function (img, jodit) {
	img.onload = function(){//wait img to load
		if (img.width >= img.naturalWidth){ //resize img if is smaller
			img.width = img.naturalWidth;
			img.height = img.naturalHeight;
		}
		jodit = window[jodit];
		jodit.synchronizeValues(); //sync to jodit
	}
}

Expected behavior: afterImageEditor event launch after resize or crop image afterInsertImage normally launch

Actual behavior: afterImageEditor event do not launch after resize or crop image

main goal to this :

  • when picture is smaller than imageDefaultWidth, we prefer to set the real size of picture
  • when ratio change (with crop function of image editor), update ratio to image

coolibry avatar Apr 08 '22 05:04 coolibry

update about this request : in image properties, when i clic on input : imageWidth, imageHeight function changeSizes run and change value to keep ratio,

then is it possible to trigger changeSizes function after crop ? also if picture is smaller than imageDefaultWidth, then set to original value.

coolibry avatar Apr 15 '22 19:04 coolibry