I have a one line textfield. (input type='text')
I don't have a textarea.
This textfield allows the user to enter small strings in a simple DSL. To give you an idea they look like this:
- from milan to london
- from italy(rome,florence) to uk
I was thinking to replace this textfield with codemirror
my questions are:
- is using code mirror for one line textarea a good idea ?
- has anybody done this ?
- are there any other approaches to make a textfield more 'colourful' ?
Thanks,
Well, there is a way to make a single-line editor using rich capabilities of CodeMirror. First, you'll have to add a full-featured CodeMirror object (use a textarea).
Assume you've got
var cm = CodeMirror(...)
. (Usevalue: ""
). Then doThis works just fine for me.
You could just run a regex on the field when somebody hits a key.
When the event happens you do a str.replace on the content of a contentEditable element which is about one line high kinda like this:
for that kind of approach you wouldn't need a code-editor, and you could just style your tags with these classes...
simples