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.

40 lines (39 loc) 1.2 kB
var _a; import Quill from "quill"; import { hadProtocol, sanitize } from "../../../config/editor.utils.es.js"; const Inline = Quill.import("blots/inline"); let Link$1 = (_a = class 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", _a.sanitize(value)); } } }, _a.autoProtocol = "", _a); Link$1.blotName = "link"; Link$1.tagName = "A"; Link$1.SANITIZED_URL = "about:blank"; Link$1.PROTOCOL_WHITELIST = ["http", "https", "mailto", "tel"]; Link$1.className = "ql-normal-link"; export { Link$1 as default }; //# sourceMappingURL=link.es.js.map