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.

41 lines (40 loc) 1.49 kB
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); import Quill from "quill"; import { MathliveBlot } from "./formats.es.js"; import { MathliveTooltip } from "./tooltip.es.js"; class MathliveModule { constructor(quill) { __publicField(this, "tooltip"); this.quill = quill; this.tooltip = new 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() === MathliveBlot.tagName.toUpperCase() && node.classList.contains(MathliveBlot.className)); const mathliveBlot = Quill.find(mathliveNode); if (mathliveBlot) { const { value, mode } = MathliveBlot.value(mathliveBlot.domNode); if (mode === "dialog") { this.createDialog(value); } } }, true ); } static register() { Quill.register({ [`formats/${MathliveBlot.blotName}`]: MathliveBlot }, true); } createDialog(value) { this.tooltip.edit(value); } } export { MathliveModule }; //# sourceMappingURL=module.es.js.map