@opentiny/fluent-editor
Version:
A rich text editor based on Quill 2.0, which extends rich modules and formats on the basis of Quill. It's powerful and out-of-the-box.
32 lines (31 loc) • 876 B
JavaScript
import Quill from "quill";
import Action from "./Action.es.js";
class DeleteAction extends Action {
constructor() {
super(...arguments);
this.onKeyUp = (event) => {
if (!this.formatter.currentSpec) {
return;
}
if (event.keyCode === 46 || event.keyCode === 8) {
const blot = Quill.find(this.formatter.currentSpec.getTargetElement());
if (blot) {
blot.deleteAt(0);
}
this.formatter.hide();
}
};
}
onCreate() {
document.addEventListener("keyup", this.onKeyUp, true);
this.formatter.quill.root.addEventListener("input", this.onKeyUp, true);
}
onDestroy() {
document.removeEventListener("keyup", this.onKeyUp);
this.formatter.quill.root.removeEventListener("input", this.onKeyUp);
}
}
export {
DeleteAction as default
};
//# sourceMappingURL=DeleteAction.es.js.map