richeditor-android icon indicating copy to clipboard operation
richeditor-android copied to clipboard

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

Open boby1975 opened this issue 4 years ago • 20 comments

boby1975 avatar May 15 '20 14:05 boby1975

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 avatar Feb 18 '21 07:02 vikas-jain-plutus

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

vikas-jain-plutus avatar Feb 18 '21 18:02 vikas-jain-plutus

Thanks in Advance...

vikas-jain-plutus avatar Feb 18 '21 18:02 vikas-jain-plutus

@boby1975 Can you please help me with this part?

vikas-jain-plutus avatar Feb 24 '21 12:02 vikas-jain-plutus

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

vikas-jain-plutus avatar Feb 24 '21 12:02 vikas-jain-plutus

@boby1975 Can you please help me with this part?

Use richEditor.setHtml(htmlString)

boby1975 avatar Feb 24 '21 13:02 boby1975

@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.

vikas-jain-plutus avatar Feb 24 '21 14:02 vikas-jain-plutus

Try this richEditor.setInputEnabled(true)

boby1975 avatar Feb 24 '21 19:02 boby1975

@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 avatar Feb 25 '21 05:02 vikas-jain-plutus

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

vikas-jain-plutus avatar Feb 25 '21 07:02 vikas-jain-plutus

@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.

vikas-jain-plutus avatar Feb 25 '21 08:02 vikas-jain-plutus

@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 avatar Feb 25 '21 18:02 boby1975

@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:///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); }

boby1975 avatar Feb 25 '21 18:02 boby1975

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

vikas-jain-plutus avatar Feb 25 '21 18:02 vikas-jain-plutus

Yes. See my working example above

boby1975 avatar Feb 25 '21 20:02 boby1975

@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 avatar Feb 26 '21 12:02 vikas-jain-plutus

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

vikas-jain-plutus avatar Mar 04 '21 06:03 vikas-jain-plutus

@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?

vikas-jain-plutus avatar Mar 04 '21 06:03 vikas-jain-plutus

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

mohamed99akram avatar Nov 17 '21 21:11 mohamed99akram

@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.

shukrifathil avatar Dec 24 '21 04:12 shukrifathil