Skip to content

Commit

Permalink
Use editor-change event to call onChange and onChangeSelection proper…
Browse files Browse the repository at this point in the history
…ties (#382)

* Use editor-change to register selection change and text change

* Use normal function notation

* Fix function binding of editor-change callback
  • Loading branch information
bakkerjoeri authored and alexkrolick committed Oct 27, 2018
1 parent 916a18e commit eb45701
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions src/mixin.js
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,15 @@ var QuillMixin = {
}
}.bind(this);

editor.on('text-change', this.handleTextChange);
editor.on('selection-change', this.handleSelectionChange);
editor.on('editor-change', function(eventType, rangeOrDelta, oldRangeOrOldDelta, source) {
if (eventType === Quill.events.SELECTION_CHANGE) {
this.handleSelectionChange(rangeOrDelta, oldRangeOrOldDelta, source);
}

if (eventType === Quill.events.TEXT_CHANGE) {
this.handleTextChange(rangeOrDelta, oldRangeOrOldDelta, source);
}
}.bind(this));
},

unhookEditor: function(editor) {
Expand Down

0 comments on commit eb45701

Please sign in to comment.