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.78 kB
"use strict"; 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 editor_utils = require("../../../config/editor.utils.cjs.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 (!editor_utils.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 editor_utils.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; exports.LinkBlot = LinkBlot; //# sourceMappingURL=link.cjs.js.map