Dynamic html editor - android

My program works like this:
I have a WebView that loads assets/index.html. In this HTML I have the "Download Button", and am using Ajax to call a function to download HTML from a website. Then, the user has an option to open this downloaded HTML file inside the WebView (using the myWebView.loadUrl).
How can I make the user allowed to "edit" the HTML? I want them to be able to select text and edit the colour/font/background/bold/italic/etc. and then save and it update the HTML file with the edited text (probably with tags, <b><i>Edited Text</b></i> in the place of the normal edited text?
I think it is better to use JavaScript to do this, then when they click "Save", it calls a method to save and the next time the user clicks to "See the html in the WebView" it shows the styled text.
How can I do this? Maybe using JavaScript/jQuery text Editor like this (http://jqueryte.com/demos)?
I don't know about performance issues, since every time the user edits something the application will have to parse from file, show in WebView, edit, than write again full text to the file.
Can anyone offer some examples? directions? or better advice?

Add attribute contenteditable to your <body>
<body contenteditable='true'>
Now your <body> is editable.

Related

How to stop "Next" button replacing "Go" button on android 7 soft keyboard while focusing an input of asp website

When I focus on an input of the website on some browsers in Android 7 (Chrome, Firefox...), the "Go" button was replaced by "Next" button. It will be helpful for the form have multiple fields but it's terrible for the asp website, because there is only one form tag in the whole page. It means when I have multiple form in a page, it just moves the focus from this form to another form when I click the "Go/Next" button instead of submitting the form.
Do we have any attribute for the input to ask the OS stop replacing the "Go" button?
Best regards,
Hanh Dang
If you set UseSubmitBehavior="false" the button will be rendered as a <button> <input type='button'> element with JavaScript that causes the postback (instead of a <input type='submit'> element) and this may be enough to trick the Android browser (btw which browser are you using?) into thinking there is no way to submit the form and it not display the Go button for the last form entry box.
Edit
I see your comment that this did not work. Depending on the type of JavaScript framework you are using you may be able to code a traditional <button> (or anything else like <a class='btn'>) and use GetPostBackEventReference to generate the code to manually initiate a postback (or just call __doPostBack - not recommended but hey, this is old asp.net, right!?).

How can I copy all visible text of a webView?

I have a webView that loads a page. How do I copy all visible text on the webView? I don't want the innerHTML. I want the visible text. In other words, I want the same text that can be achieved by "selecting all" and copying.
Use a HTML parser which can give you nodes under your body element and keep aggregating text present inside each node. You could use this https://jsoup.org/
as a parser, it is quite established.

Inverse/Reverse of Html.fromHtml(String)

I am creating a note application for myself. To style my notes, I write html tags, click a button and show styled version with html. from html.. But the problem is, I need to store the text with html tags not without it so when I get the data from the database, I get the text with style.
So I wonder is there any way to decode embedded html tags other than storing the string before html. from html function and acting accordingly? Also i can click the button anytime then continue typing which is very hard to track. Because i run this function to stylize ;
text.setText(Html.fromHtml(text.getText().toString()));
Which means i lose the tag info.
Thanks in advance.
If the user of the app write the html tags, the app should store them.
So as you suggest yourself, you will have to store the string before calling Html.fromHtml.

How can I get entered text from Android WebView and use it in my code

I have a WebView that has a textfield in it, in which the user enters some text. On a button press I want to extract this text from the WebView and store it in a String so that I can use it later in some other native code.
Note: This text entry must be done in a WebView, and cannot be moved to an EditText.
You need to get access to the function behind the button (ie the webview you're accessing has to provide it)
Basically, this post will help you accomplish what you're looking for :
https://stackoverflow.com/a/9581016/4232337

WebView android does not wrap the text

I've searched the Internet for a solution but I can't find it.
I have a WebView that display text, Just text. I want to wrap the text in the WebView, is that possible, or what?
And I want to make the user be able to select a certain text in the WebView and make him able to send the selected text by SMS, is that possible to?
I found the solution. You have to add some div tag on your web document, and then add a css class. I did this:
<div class="wrap">
with a css class like this:
.wrap {
word-wrap:break-word;
}
If the content in the WebView is something that you yourself have created or have control of, use a stylesheet optimized for mobile devices, or you can use jTouch or jQuery Mobile
If your content is literally plain text (no HTML markup), then the WebView will be treating it as preformatted text and won't wrap or insert linebreaks.
Try wrapping your text in an HTML wrapper:
<html><body>My text goes here</body></html>

Categories

Resources