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.

44 lines (43 loc) 1.66 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 { hadProtocol, sanitize } from "../../../config/editor.utils.es.js"; const Inline = Quill.import("blots/inline"); const _LinkBlot = class _LinkBlot extends Inline { static create(value) { const node = super.create(value); let href = value; if (!hadProtocol(href) && this.autoProtocol) { href = `${this.autoProtocol}://${value}`; } href = this.sanitize(href); node.setAttribute("href", href); node.setAttribute("target", "_blank"); return node; } static formats(domNode) { return domNode.getAttribute("href"); } static sanitize(url) { return sanitize(url, this.PROTOCOL_WHITELIST) ? url : this.SANITIZED_URL; } format(name, value) { if (name !== this.statics.blotName || [false, null].includes(value)) { super.format(name, value); } else { this.domNode.setAttribute("href", _LinkBlot.sanitize(value)); } } }; __publicField(_LinkBlot, "blotName", "link"); __publicField(_LinkBlot, "tagName", "A"); __publicField(_LinkBlot, "SANITIZED_URL", "about:blank"); __publicField(_LinkBlot, "PROTOCOL_WHITELIST", ["http", "https", "mailto", "tel"]); __publicField(_LinkBlot, "className", "ql-normal-link"); __publicField(_LinkBlot, "autoProtocol", ""); let LinkBlot = _LinkBlot; export { LinkBlot }; //# sourceMappingURL=link.es.js.map