Class who wrap string that match regex. Is dependent of jQuery $el.html() and $el.text(). This class if often used in a contenteditable="true" context.
CSS:
key.red {color:red;}
key.green {color:green;}
HTML:
<pre contenteditable="true" id="editor">${key1} and ${key3} will be green, ${key2} will be red</pre>
JavaScript:
var greenKeys = ['key1', 'key3'];
var editor = new SmartEditor('#editor', {
regexps: {
'(\\$\\{([a-zA-Z0-9-_]{1,60})\\})': function(key) {
return (linkedKeys.indexOf(key) > -1) ? 'green' : 'red';
}
}
});
var editor = new SmartEditor(el, options);
Update the text inside the editor. Will also trigger a render()
editor.setContent(content);