Skip to content

Commit

Permalink
Address feedbacks
Browse files Browse the repository at this point in the history
  • Loading branch information
luin committed Jul 22, 2023
1 parent 453743a commit 0b5e4d4
Showing 1 changed file with 15 additions and 18 deletions.
33 changes: 15 additions & 18 deletions modules/history.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,28 +33,25 @@ class History extends Module<HistoryOptions> {
super(quill, options);
this.quill.on(
Quill.events.EDITOR_CHANGE,
(eventName, delta, oldDelta, source) => {
if (eventName !== Quill.events.TEXT_CHANGE || this.ignoreChange) return;
if (!this.options.userOnly || source === Quill.sources.USER) {
this.record(delta, oldDelta);
} else {
this.transform(delta);
(eventName, value, oldValue, source) => {
if (eventName === Quill.events.SELECTION_CHANGE) {
if (value && source !== Quill.sources.SILENT) {
this.currentRange = value;
}
} else if (eventName === Quill.events.TEXT_CHANGE) {
if (!this.ignoreChange) {
if (!this.options.userOnly || source === Quill.sources.USER) {
this.record(value, oldValue);
} else {
this.transform(value);
}
}

this.currentRange = transformRange(this.currentRange, value);
}
},
);

this.quill.on(Quill.events.EDITOR_CHANGE, (...args) => {
if (args[0] === Quill.events.SELECTION_CHANGE) {
const range = args[1];
if (range && args[3] !== Quill.sources.SILENT) {
this.currentRange = range;
}
} else if (args[0] === Quill.events.TEXT_CHANGE) {
const [, change] = args;
this.currentRange = transformRange(this.currentRange, change);
}
});

this.quill.keyboard.addBinding(
{ key: 'z', shortKey: true },
this.undo.bind(this),
Expand Down

0 comments on commit 0b5e4d4

Please sign in to comment.