You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
75 lines
2.1 KiB
75 lines
2.1 KiB
// @ts-nocheck
|
|
import Quill from "quill";
|
|
import "./quill-video"
|
|
|
|
if (Quill.prototype.destroy === undefined) {
|
|
Quill.prototype.destroy = function () {
|
|
if (!this.emitter) return;
|
|
// Disable the editor to prevent further user input
|
|
this.enable(false);
|
|
|
|
// Remove event listeners managed by Quill
|
|
this.emitter.listeners = {};
|
|
this.emitter.off();
|
|
|
|
// Clear clipboard event handlers
|
|
if (this.clipboard && this.clipboard.off) {
|
|
this.clipboard.off();
|
|
}
|
|
|
|
// Remove keyboard bindings
|
|
this.keyboard.bindings = {};
|
|
|
|
// Clear history stack
|
|
this.history.clear();
|
|
|
|
// Remove toolbar event handlers (if toolbar module exists)
|
|
if (this.theme && this.theme.modules.toolbar) {
|
|
this.theme.modules.toolbar.container.remove();
|
|
}
|
|
|
|
// Remove tooltip (if present)
|
|
if (this.theme && this.theme.tooltip) {
|
|
this.theme.tooltip.root.remove();
|
|
}
|
|
|
|
// Remove all Quill-added classes from the container
|
|
const container = this.container;
|
|
container.classList.forEach((cls) => {
|
|
if (cls.startsWith('ql-')) {
|
|
container.classList.remove(cls);
|
|
}
|
|
});
|
|
|
|
// Restore the original container content (before Quill modified it)
|
|
container.innerHTML = this.root.innerHTML;
|
|
|
|
// Remove Quill-specific DOM elements
|
|
this.root.remove();
|
|
|
|
// Nullify references to allow garbage collection
|
|
this.root = null;
|
|
this.scroll = null;
|
|
this.emitter = null;
|
|
this.clipboard = null;
|
|
this.keyboard = null;
|
|
this.history = null;
|
|
this.theme = null;
|
|
this.container = null;
|
|
|
|
// Override isEnabled to prevent errors after destruction
|
|
this.isEnabled = function () {
|
|
return false;
|
|
};
|
|
|
|
// Remove the instance from Quill's internal registry (if any)
|
|
if (Quill.instances && Quill.instances[this.id]) {
|
|
delete Quill.instances[this.id];
|
|
}
|
|
};
|
|
}
|
|
|
|
export {
|
|
Quill
|
|
}
|
|
export default Quill
|
|
|