UNPKG

@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.

33 lines (32 loc) 925 B
import Quill from "quill"; import File from "./formats/file.es.js"; import FileBar from "./modules/file-bar.es.js"; const Module = Quill.imports["core/module"]; class FileModule extends Module { static register() { Quill.register("formats/file", File, true); } constructor(quill, options) { super(quill, options); this.quill = quill; quill.root.addEventListener("click", (event) => this.clickEvent(event), false); } clickEvent(event) { event.preventDefault(); const target = event.target; const fileDom = target.closest("a.ql-file-item"); if (fileDom) { if (this.fileBar) { this.fileBar.destroy(); } this.fileBar = new FileBar(this.quill, fileDom); } else if (this.fileBar && !target.closest(".ql-file-bar")) { this.fileBar.destroy(); this.fileBar = null; } } } export { FileModule as default }; //# sourceMappingURL=index.es.js.map