@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.
43 lines (42 loc) • 1.45 kB
JavaScript
;
Object.defineProperties(exports, { __esModule: { value: true }, [Symbol.toStringTag]: { value: "Module" } });
const Quill = require("quill");
const constants = require("../constants.cjs.js");
const Embed = Quill.imports["blots/embed"];
class DocumentLink extends Embed {
static create(value) {
const node = super.create(value);
node.setAttribute("href", value.link);
node.setAttribute("title", value.text);
node.setAttribute("target", "_blank");
node.setAttribute("icon-link", value.icon);
const icon = document.createElement("span");
icon.classList.add("ql-doc-link-icon");
icon.style.background = `url(${value.icon}) no-repeat center`;
icon.style.backgroundSize = "contain";
node.insertAdjacentElement("afterbegin", icon);
const text = document.createTextNode(value.text);
node.appendChild(text);
return node;
}
static value(domNode) {
return {
link: domNode.getAttribute("href"),
icon: domNode.getAttribute("icon-link"),
text: domNode.textContent
};
}
constructor(scroll, domNode, data) {
super(scroll, domNode, data);
this.docData = data;
}
remove() {
this.scroll.emitter.emit(constants.ON_DOC_LINK_REMOVE, this.docData);
return super.remove();
}
}
DocumentLink.blotName = "doc-link";
DocumentLink.tagName = "A";
DocumentLink.className = "ql-doc-link";
exports.default = DocumentLink;
//# sourceMappingURL=doc-link.cjs.js.map