@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.34 kB
JavaScript
;
var _a;
Object.defineProperties(exports, { __esModule: { value: true }, [Symbol.toStringTag]: { value: "Module" } });
const Quill = require("quill");
const editor_utils = require("../../../config/editor.utils.cjs.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 (!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", _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";
exports.default = Link$1;
//# sourceMappingURL=link.cjs.js.map