Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to edit some content after loading it by mEditor.loadData(someData)? thnks #228

Open
boby1975 opened this issue May 15, 2020 · 20 comments

Comments

@boby1975
Copy link

No description provided.

@vikas-jain-plutus
Copy link

I am also facing the same issue. After calling the mEditor.loadData() method, I am not able to edit the loaded data.
Can you guys please give me some solution?

@vikas-jain-plutus
Copy link

Can anyone help me with this? It's really a very emerging issue right now.

@vikas-jain-plutus
Copy link

Thanks in Advance...

@vikas-jain-plutus
Copy link

@boby1975 Can you please help me with this part?

@vikas-jain-plutus
Copy link

@bmadaras @lijunjieone @richfuns Anyone can help me on this question?

@boby1975
Copy link
Author

@boby1975 Can you please help me with this part?

Use richEditor.setHtml(htmlString)

@vikas-jain-plutus
Copy link

@boby1975 yes I have used the richEditor.setHtml(htmlString) method. But still, I am not able to focus on the Editor after display the data. Is there anything I`m missing?
Please let me know.

@boby1975
Copy link
Author

Try this richEditor.setInputEnabled(true)

@vikas-jain-plutus
Copy link

@boby1975 I have used the following methods to enable the Editor View after loading the data.
mEditor.setHtml(Globals.getInstance().currentClub.getDescription());
mEditor.setInputEnabled(true);
mEditor.setClickable(true);
mEditor.setFocusable(true);
mEditor.setFocusableInTouchMode(true);
mEditor.setSaveEnabled(true);

@vikas-jain-plutus
Copy link

@boby1975 Thanks for your help...
It's appreciated...

@vikas-jain-plutus
Copy link

@boby1975 I need one more help from you...
How can we send an image with bitmap or Base64?
Right now Editor only accepts Url in String.

@boby1975
Copy link
Author

@boby1975 I have used the following methods to enable the Editor View after loading the data.
mEditor.setHtml(Globals.getInstance().currentClub.getDescription());
mEditor.setInputEnabled(true);
mEditor.setClickable(true);
mEditor.setFocusable(true);
mEditor.setFocusableInTouchMode(true);
mEditor.setSaveEnabled(true);

may be this helps
in my class RichEditor
..
public RichEditor(Context context, AttributeSet attrs, int defStyleAttr) {
super(context, attrs, defStyleAttr);

    setVerticalScrollBarEnabled(false);
    setHorizontalScrollBarEnabled(false);
    getSettings().setJavaScriptEnabled(true);
    getSettings().setUseWideViewPort(true);
    getSettings().setLoadWithOverviewMode(true);
    getSettings().setLayoutAlgorithm(WebSettings.LayoutAlgorithm.TEXT_AUTOSIZING);
    getSettings().setSupportZoom(true);

    setWebChromeClient(new WebChromeClient());
    setWebViewClient(createWebviewClient());
    loadUrl(SETUP_HTML);

    applyAttributes(context, attrs);
}

@boby1975
Copy link
Author

boby1975 commented Feb 25, 2021

@boby1975 I need one more help from you...
How can we send an image with bitmap or Base64?
Right now Editor only accepts Url in String.

You can insert image by url and base64 as well when editor has focus
examples:
file file_oops.png is located in assets folder
String imagePath = "file:https:///android_asset/file_oops.png";
richEditor.insertImage(imagePath, "fileName");

or base64 image
String imageBase64 = "data:image/png;base64, iVBORw0KGgoAAAANSUhEUgAAAAUAAAAFCAYAAACNbyblAAAAHElEQVQI12P4//8/w38GIAXDIBKE0DHxgljNBAAO9TXL0Y4OHwAAAABJRU5ErkJggg==";
richEditor.insertImage(imageBase64, "fileName");

PS
in rich_editor.js you can change/add some functions
example
RE.insertImage = function(url, alt) {
var html = '<img src="' + url + '"' + ' style="width: 300px; display: block; vertical-align: top; margin: 5px auto; text-align: center; font-family: Nunito, Arial, sans-serif; box-sizing: border-box; max-width: 100%; padding: 0px; border: 0px; outline: 0px; font-size: 100%; background: transparent;"' + ' alt="' + alt + '" />';
RE.insertHTML(html);
}

@vikas-jain-plutus
Copy link

vikas-jain-plutus commented Feb 25, 2021

@boby1975 Do I need to append "data:image/png;base64," this string with base64 data string in richEditor.insertImage(imageBase64, "fileName") method?

@boby1975
Copy link
Author

Yes. See my working example above

@vikas-jain-plutus
Copy link

@boby1975 I have prepared base 64 String with appending "data:image/png;base64,. But still, HTML not loaded on the preview. IF I am using a local path for displaying an image, It will load the image..but at the same time, we can`t see those images on the server or iOS.

@vikas-jain-plutus
Copy link

@boby1975 Can you please help me with my previous comment?

@vikas-jain-plutus
Copy link

@boby1975 I have used base64 image
String imageBase64 = "data:image/png;base64, iVBORw0KGgoAAAANSUhEUgAAAAUAAAAFCAYAAACNbyblAAAAHElEQVQI12P4//8/w38GIAXDIBKE0DHxgljNBAAO9TXL0Y4OHwAAAABJRU5ErkJggg==";
richEditor.insertImage(imageBase64, "fileName");
An editor couldn`t load the Image HTML using the above code. Can you please help me?

@mohamed99akram
Copy link

For Base64, use this function(loadDataWithBaseURL). but it is slow in loading.

@shukrifathil
Copy link

@vikas-jain-plutus were you able to solve the base64 load issue? I'm in a similar boat cause my app needs to load image as base64 as well.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants