Setup
// create a new Editable object, and configure it as needed
var editable = new Editable({
// here you can pass an iframe window if required (default: main window)
window: window,
// activate the default behaviour for merge, split and insert (default: true)
defaultBehavior: true,
// fire selection events on mouse move (default: false)
mouseMoveSelectionChanges: false,
// control the 'spellcheck' attribute on editable elements (default: true)
browserSpellcheck: true
});
// add and initialize a block element to make it editable
editable.add(elem)
Setup Highlighting
editable.setupHighlighting({
// control when the highlighting is triggered
checkOnInit: true,
checkOnFocus: false,
checkOnChange: true,
// debounce calls to the spellcheckService
throttle: 500,
spellcheck: {
marker: '<span class="highlight-spellcheck"></span>',
spellcheckService: function (text, callback) {
// Return an array of words to be highlighted.
// This only works with complete words. The spellchecker
// wont highlight parts of words.
callback(['happy'])
}
},
whitespace: {
marker: '<span class="highlight-whitespace"></span>'
}
})