summernote-webpack
Version:
Super simple WYSIWYG editor
39 lines (32 loc) • 991 B
JavaScript
define(function () {
var Placeholder = function (context) {
var self = this;
var $editingArea = context.layoutInfo.editingArea;
var options = context.options;
this.events = {
'summernote.init summernote.change': function () {
self.update();
},
'summernote.codeview.toggled': function () {
self.update();
}
};
this.shouldInitialize = function () {
return !!options.placeholder;
};
this.initialize = function () {
this.$placeholder = $('<div class="note-placeholder">');
this.$placeholder.on('click', function () {
context.invoke('focus');
}).text(options.placeholder).prependTo($editingArea);
};
this.destroy = function () {
this.$placeholder.remove();
};
this.update = function () {
var isShow = !context.invoke('codeview.isActivated') && context.invoke('editor.isEmpty');
this.$placeholder.toggle(isShow);
};
};
return Placeholder;
});