:
- There is a glitch that appears in some cases using the toolbar. To fix this, the update should be blocked when it occurs through a blur event.
- Also added the ability to override parameters using the element’s summerOptions property.
Here is my update:
ko.bindingHandlers.summernote = new function () {
var isblur = false;
this.init = function (element, valueAccessor, allBindings) {
var value = valueAccessor();
var options = $.extend(value, {
height: 100,
toolbar: [
["style", ["bold", "italic", "underline", "clear"]],
["fontstyle", ["style"]],
["fontsize", ["fontsize"]],
["lists", ["ul", "ol", "paragraph"]],
["links", ["link", "picture"]],
["misc", ["fullscreen", "codeview"]]
],
onblur: function () {
isblur = true;
value($(element).code());
isblur = false;
}
});
$.extend(options, allBindings.get("summerOptions"));
return $(element).summernote(options);
};
this.update = function (element, valueAccessor) {
if (!isblur) {
var value = valueAccessor();
$(element).code(value());
}
};
};
And use:
<textarea data-bind="summernote: Content"></textarea>
Or with overriding options:
<textarea data-bind="summernote: Content, summerOptions: { height: 200 }"></textarea>
source
share