Annotating text in UIWebView - iphone

I am writing a app that has a UIWebView that displays a HTML5 page. I want to annotate some text on the web page and save it in SQLite database. The annotated text must be changed to a specific color as a visual effect.
Any suggestions that how can I select and get the text back in Objective-C?

You have two choices:
Parse the HTML5 document by hand
Inject Javascript into the page and walk the document. See Search and highlight text in UIWebView

Related

Using contentEditable inside Flutter's webview

For an application I need a document that is able to record and display among each other any type (text, audio, video, HTML, maybe PDF) that the user enters or inserts.
At first I wanted to use a listview with different types of widgets (textfields, video via plugin, webview via plugin etc.), but it seemed much too complicated to me. For example, how could I have selected parts of a text field, the following image and parts of the next text field at the same time?
Actually, the document format that I need already exists: HTML. If you set the attribute "contentEditable" accordingly, it is not a big problem to let the user change the document in any way with the help of JS. And this is exactly my problem: If I use the Webview (Developer Preview) of the Flutter team (webview_flutter), the attribute "contentEditable" is apparently ignored. I can't mark text and no keyboard appears.
Am I doing something wrong or does the plugin not (yet) support this attribute? Otherwise, is there an alternative? I have to say that I am an absolute beginner in Flutter.

How to select text in DTAttributedTextView?

I'm using DTCoreText DTAttributedTextView in my app to highlight the urls in my text. My other criteria is to be able to select by tapping and holding similar to UITextView. However, DTAttributedTextView doesn't seem to to use a UITextView as a placeholder. Anybody has an idea how I can achieve this?
Thanks
That's a feature that's only available via the paid version of DTCoreText.
from the github page
This is useful for drawing simple rich text like any HTML document without having to use a UIWebView. For text selection and highlighting (as you might need for an Editor or Reader) there is the commercial DTRichTextEditor component which can be purchased in the Cocoanetics Parts Store.

CQ5 - Widget for displaying sample HTML

I am trying to build a widget that has an area that will display sample of ~20 line HTML code. This sample code must be selectable so the user will be able to copy + paste it into their own text editor.
Currently I am using an xtype displayfield and using the fieldDescription to put my HTML code inside. I realized though that this fieldDescription does not allow me to format my code. I also tried using an xtype textarea and setting the emptyText as my HTML code, but clicking in the textarea would remove the HTML code.
The user story for this is that I have a textarea where the user will be populating a textarea with HTML code. This HTML code must be structured in a certain way so the CSS will format their code correctly. I want to include an example of how this HTML code should be structured.
EDIT - It will be great if I can apply the font-face Courier to this for ease of readability.
Try using value property of textarea.
Set ignoreData to true to avoid the value being populated from content.
To make sure it doesn't get saved back as a property - leave name empty, or just set a value that doesn't start with ./
To achieve different font face - play with CSS on a page. If you want to add specific CSS class to your widget, use overCls property.
Find more on the documentation

How to search text in UIWebView Consists of number of pages and the text should be highlighted in iPhone?

I parsed epub file into UIWebView.I tried to add UISearchBar for to find text and to be highlighted. For this i added UIWebViewSearch.js file. In my UIWebView i have so many pages. If click on next the next page is displayed or click on previous page previous page ids displayed. For this how to search the text in UIWebView ,How the text will be selected?
If anyone knows please help me.
Thanks in advance...........
There are plenty of examples on the web of JavaScript search and highlight functionalities.
Here is an example.
Once you have working JavaScript to search for terms and highlight them in the web page, you will need to call your JS and pass it the text that was entered in the UISearchBar.
This can be achieved by using:
NSString *jsCall = [NSString stringWithFormat:#"searchAndHighlight('%#');", yourSearchText];
[webView stringByEvaluatingJavaScriptFromString:jsCall];
UIWebView Class Reference

Best approach for adding non-web links to UITextView

I am creating a dictionary-style app that presents a tableview full of words, and when a word is selected, a UITextView is displayed that shows the definition of the word. What I would like to do is add a line that says "See also: synonym1, synonym2" where synonym1 and synonym2 are links that will take the user to the definition for the synonym that is touched.
What is the best way to add these dynamic links? Buttons? Somehow add a small UIWebView a UItable on the fly?
Thanks!
I would replace your UITextView with a UIWebView and use that contain your description text and your links. It's fairly trivial to generate HTML on the fly for something like that.
You could register a custom URL scheme for your app, or you could intercept links as they're clicked.
If your links are always grouped together there's no reason why you couldn't use a bunch of UIButtons inside a custom view, but then you'd have to handle layout and wrapping on your own. It seems a lot easier to do it in HTML.