Closed tangent-q closed 4 years ago
Hi @dankito ,
Not really. I am expecting height and width to be set set automatically. (For my app, I need it to be 100% Width programmatically and user should not do it). Basically trying to achieve fit to width image programatically.
Right now, I can insert url, alternate text and rotation but it would have been great if there were width and height optional params.
I have done these changes but I am unable to build it properly. I have raised an issue here as well for the build: https://github.com/jitpack/jitpack.io/issues/4230
If you can help me with the build, I can provide a PR for this improvement.
Hi,
the build issue may is that you don't have build RichTextEditorCommon locally. Does it help if you toggle the comments in RichTextEditorAndroid/build.gradle like this:
// implementation "$mavenGroup:$richTextEditorCommonMavenArtifactId:$version"
implementation project(":RichTextEditorCommon")
(May the same has to be done in RichTextEditorJavaFx/build.gradle.)
Would it help you if i change the insertImage() function like this:
insertImage: function(url, alt, width, height, rotation) {
var imageElement = document.createElement('img');
imageElement.setAttribute('src', url);
if(alt) {
imageElement.setAttribute('alt', alt);
}
if(width) {
imageElement.setAttribute('width', width);
}
if(height) {
imageElement.setAttribute('height', height);
}
if(this._isImageResizingEnabled) {
imageElement.setAttribute('class', resizableImageClass);
}
if(rotation) {
this._setImageRotation(imageElement, rotation);
}
this._insertHtml(imageElement.outerHTML);
},
And the Kotlin code accordingly:
open fun insertImage(url: String, alt: String, width: String? = null, height: String? = null, rotation: Int = 0) {
executeEditorJavaScriptFunction("insertImage('$url', '$alt', '$width', '$height', $rotation)")
}
I would suggest String as type for width and height so that you can set the dimension yourself, e.g. '100%', '450px' etc.
Hi @dankito,
Going to try the the changes you suggested for the build issue.
For the insertImage
, yes I was expecting exactly like the one you mentioned above and I agree with you on keeping width and height as strings.
Thanks,
Hi @dankito I am still unable to get my changes on Jit pack after your build suggestions. If you can apply the above changes from your end and release, that will be really helpful. Thanks
Hi @tangentq-admin,
just released version 2.0.18 that contains above code.
Please check if it works for you.
Hi @dankito ,
Yes, that indeed works.
Thank you so much for your help!!
Hi,
this can be done directly in editor, just grab an image at the corner, then you can resize it.
Is this what you requested?