Skip to content

Commit

Permalink
Fix limiting composition characters
Browse files Browse the repository at this point in the history
  • Loading branch information
lqez committed Dec 23, 2019
1 parent 57eb6be commit 778f50b
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions src/js/base/module/Editor.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ export default class Editor {

this.editable = this.$editable[0];
this.lastRange = null;
this.snapshot = null;

this.style = new Style();
this.table = new Table();
Expand Down Expand Up @@ -339,7 +340,8 @@ export default class Editor {
}
this.context.triggerEvent('keydown', event);

this.history.recordUndo();
// keep a snapshot to limit text on input event
this.snapshot = this.history.makeSnapshot();

if (!event.isDefaultPrevented()) {
if (this.options.shortcuts) {
Expand Down Expand Up @@ -375,8 +377,9 @@ export default class Editor {
this.setLastRange();
this.context.triggerEvent('paste', event);
}).on('input', (event) => {
if (this.isLimited(0)) {
this.history.undo();
// To limit composition characters (e.g. Korean)
if (this.isLimited(0) && this.snapshot) {
this.history.applySnapshot(this.snapshot);
}
});

Expand Down

0 comments on commit 778f50b

Please sign in to comment.