Skip to content

jfdesgagne/smarteditor.js

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 

Repository files navigation

smarteditor.js

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.

Example Of Use

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';
    }
  }
});

Api

var editor = new SmartEditor(el, options);

Update the text inside the editor. Will also trigger a render()

editor.setContent(content);

About

Class who wrap string that match regex

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published