@leoyin/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.
41 lines (40 loc) • 1.64 kB
JavaScript
;
var __defProp = Object.defineProperty;
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
const Quill = require("quill");
const formats = require("./formats.cjs.js");
const tooltip = require("./tooltip.cjs.js");
class MathliveModule {
constructor(quill) {
__publicField(this, "tooltip");
this.quill = quill;
this.tooltip = new tooltip.MathliveTooltip(quill);
this.quill.root.addEventListener(
"click",
(e) => {
if (!this.quill.isEnabled()) return;
const path = e.composedPath();
if (!path || path.length <= 0) return;
const mathliveNode = path.find((node) => node.tagName && node.tagName.toUpperCase() === formats.MathliveBlot.tagName.toUpperCase() && node.classList.contains(formats.MathliveBlot.className));
const mathliveBlot = Quill.find(mathliveNode);
if (mathliveBlot) {
const { value, mode } = formats.MathliveBlot.value(mathliveBlot.domNode);
if (mode === "dialog") {
this.createDialog(value);
}
}
},
true
);
}
static register() {
Quill.register({ [`formats/${formats.MathliveBlot.blotName}`]: formats.MathliveBlot }, true);
}
createDialog(value) {
this.tooltip.edit(value);
}
}
exports.MathliveModule = MathliveModule;
//# sourceMappingURL=module.cjs.js.map