Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to select text using CodeMirror2 code in UIWebview IOS 5

I tried to used CodeMirror 2 for making a text editor in UIWebview IOS 5. But i had problem in text selection. I couldn't select text.

This is codemirror code in codemirror.js,

// Wraps and hides input textarea:
'<div style="overflow: hidden; position: relative; ' + 
             'width: 3px; height: 0px;">' + 
    '<textarea style="position: absolute; padding: 0; ' +
                     'width: 1px;" wrap="off" autocorrect="off" ' +
                     'autocapitalize="off">' + 
    '</textarea>' +
'</div>' +

from that code, I think i have to use "div" with contenteditable properties. I plan to change textarea become "div" with contenteditable property becouse for now, iOS 5 has support contenteditable property. But, i'm not sure how to do that. Any one know how to solve my problem?

Thank you

like image 840
R. Dewi Avatar asked Jan 03 '12 08:01

R. Dewi


1 Answers

CodeMirror was build in a way to avoid using contentEditable, because is not implemented the same across browsers.

This is a demo of a custom build of CodeMirror2 that works on iOS (I am not the author): http://www.litech.org/~schanzer/iOS/

If you're interested in the changes that were made to make it work try searching for "iOS" or "CHANGE" in the source, or use it as it is.

Here the updated source

like image 138
Navaru Avatar answered Nov 15 '22 12:11

Navaru