md-editor-rt
Version:
Markdown editor for react, developed in jsx and typescript, dark theme、beautify content by prettier、render articles directly、paste or clip the picture and upload it...
696 lines (695 loc) • 27.2 kB
JavaScript
import { E as ht } from "./chunks/Editor.mjs";
import { default as bt } from "./NormalToolbar.mjs";
import { default as yt } from "./DropdownToolbar.mjs";
import { default as xt } from "./ModalToolbar.mjs";
import { M as kt } from "./chunks/index.mjs";
import { S as Et } from "./chunks/dom.mjs";
import { jsx as ce } from "react/jsx-runtime";
import { useMemo as ge } from "react";
import { p as z } from "./chunks/config.mjs";
import { b as Lt, a as _t, c as Ct, e as Ot } from "./chunks/config.mjs";
import { default as Wt } from "./MdPreview.mjs";
import { M as Dt } from "./chunks/index2.mjs";
import { en_US as Nt, zh_CN as $t } from "./config.mjs";
import { C as M } from "./chunks/ContentPreview.mjs";
function de(e, r) {
for (var t = 0; t < r.length; t++) {
const a = r[t];
if (typeof a != "string" && !Array.isArray(a)) {
for (const o in a)
if (o !== "default" && !(o in e)) {
const i = Object.getOwnPropertyDescriptor(a, o);
i && Object.defineProperty(e, o, i.get ? i : {
enumerable: !0,
get: () => a[o]
});
}
}
}
return Object.freeze(Object.defineProperty(e, Symbol.toStringTag, { value: "Module" }));
}
const ct = (e) => {
const r = ge(() => `${z}-footer-item${e.disabled ? " " + z + "-disabled" : ""}`, [e.disabled]);
return /* @__PURE__ */ ce(
"div",
{
className: r,
onClick: (t) => {
var a;
e.disabled || (a = e.onClick) == null || a.call(e, t);
},
children: e.children
}
);
};
function pe(e) {
return e && e.__esModule && Object.prototype.hasOwnProperty.call(e, "default") ? e.default : e;
}
var F = { exports: {} }, g = {}, N = { exports: {} }, y = {};
function q() {
var e = {};
return e["align-content"] = !1, e["align-items"] = !1, e["align-self"] = !1, e["alignment-adjust"] = !1, e["alignment-baseline"] = !1, e.all = !1, e["anchor-point"] = !1, e.animation = !1, e["animation-delay"] = !1, e["animation-direction"] = !1, e["animation-duration"] = !1, e["animation-fill-mode"] = !1, e["animation-iteration-count"] = !1, e["animation-name"] = !1, e["animation-play-state"] = !1, e["animation-timing-function"] = !1, e.azimuth = !1, e["backface-visibility"] = !1, e.background = !0, e["background-attachment"] = !0, e["background-clip"] = !0, e["background-color"] = !0, e["background-image"] = !0, e["background-origin"] = !0, e["background-position"] = !0, e["background-repeat"] = !0, e["background-size"] = !0, e["baseline-shift"] = !1, e.binding = !1, e.bleed = !1, e["bookmark-label"] = !1, e["bookmark-level"] = !1, e["bookmark-state"] = !1, e.border = !0, e["border-bottom"] = !0, e["border-bottom-color"] = !0, e["border-bottom-left-radius"] = !0, e["border-bottom-right-radius"] = !0, e["border-bottom-style"] = !0, e["border-bottom-width"] = !0, e["border-collapse"] = !0, e["border-color"] = !0, e["border-image"] = !0, e["border-image-outset"] = !0, e["border-image-repeat"] = !0, e["border-image-slice"] = !0, e["border-image-source"] = !0, e["border-image-width"] = !0, e["border-left"] = !0, e["border-left-color"] = !0, e["border-left-style"] = !0, e["border-left-width"] = !0, e["border-radius"] = !0, e["border-right"] = !0, e["border-right-color"] = !0, e["border-right-style"] = !0, e["border-right-width"] = !0, e["border-spacing"] = !0, e["border-style"] = !0, e["border-top"] = !0, e["border-top-color"] = !0, e["border-top-left-radius"] = !0, e["border-top-right-radius"] = !0, e["border-top-style"] = !0, e["border-top-width"] = !0, e["border-width"] = !0, e.bottom = !1, e["box-decoration-break"] = !0, e["box-shadow"] = !0, e["box-sizing"] = !0, e["box-snap"] = !0, e["box-suppress"] = !0, e["break-after"] = !0, e["break-before"] = !0, e["break-inside"] = !0, e["caption-side"] = !1, e.chains = !1, e.clear = !0, e.clip = !1, e["clip-path"] = !1, e["clip-rule"] = !1, e.color = !0, e["color-interpolation-filters"] = !0, e["column-count"] = !1, e["column-fill"] = !1, e["column-gap"] = !1, e["column-rule"] = !1, e["column-rule-color"] = !1, e["column-rule-style"] = !1, e["column-rule-width"] = !1, e["column-span"] = !1, e["column-width"] = !1, e.columns = !1, e.contain = !1, e.content = !1, e["counter-increment"] = !1, e["counter-reset"] = !1, e["counter-set"] = !1, e.crop = !1, e.cue = !1, e["cue-after"] = !1, e["cue-before"] = !1, e.cursor = !1, e.direction = !1, e.display = !0, e["display-inside"] = !0, e["display-list"] = !0, e["display-outside"] = !0, e["dominant-baseline"] = !1, e.elevation = !1, e["empty-cells"] = !1, e.filter = !1, e.flex = !1, e["flex-basis"] = !1, e["flex-direction"] = !1, e["flex-flow"] = !1, e["flex-grow"] = !1, e["flex-shrink"] = !1, e["flex-wrap"] = !1, e.float = !1, e["float-offset"] = !1, e["flood-color"] = !1, e["flood-opacity"] = !1, e["flow-from"] = !1, e["flow-into"] = !1, e.font = !0, e["font-family"] = !0, e["font-feature-settings"] = !0, e["font-kerning"] = !0, e["font-language-override"] = !0, e["font-size"] = !0, e["font-size-adjust"] = !0, e["font-stretch"] = !0, e["font-style"] = !0, e["font-synthesis"] = !0, e["font-variant"] = !0, e["font-variant-alternates"] = !0, e["font-variant-caps"] = !0, e["font-variant-east-asian"] = !0, e["font-variant-ligatures"] = !0, e["font-variant-numeric"] = !0, e["font-variant-position"] = !0, e["font-weight"] = !0, e.grid = !1, e["grid-area"] = !1, e["grid-auto-columns"] = !1, e["grid-auto-flow"] = !1, e["grid-auto-rows"] = !1, e["grid-column"] = !1, e["grid-column-end"] = !1, e["grid-column-start"] = !1, e["grid-row"] = !1, e["grid-row-end"] = !1, e["grid-row-start"] = !1, e["grid-template"] = !1, e["grid-template-areas"] = !1, e["grid-template-columns"] = !1, e["grid-template-rows"] = !1, e["hanging-punctuation"] = !1, e.height = !0, e.hyphens = !1, e.icon = !1, e["image-orientation"] = !1, e["image-resolution"] = !1, e["ime-mode"] = !1, e["initial-letters"] = !1, e["inline-box-align"] = !1, e["justify-content"] = !1, e["justify-items"] = !1, e["justify-self"] = !1, e.left = !1, e["letter-spacing"] = !0, e["lighting-color"] = !0, e["line-box-contain"] = !1, e["line-break"] = !1, e["line-grid"] = !1, e["line-height"] = !1, e["line-snap"] = !1, e["line-stacking"] = !1, e["line-stacking-ruby"] = !1, e["line-stacking-shift"] = !1, e["line-stacking-strategy"] = !1, e["list-style"] = !0, e["list-style-image"] = !0, e["list-style-position"] = !0, e["list-style-type"] = !0, e.margin = !0, e["margin-bottom"] = !0, e["margin-left"] = !0, e["margin-right"] = !0, e["margin-top"] = !0, e["marker-offset"] = !1, e["marker-side"] = !1, e.marks = !1, e.mask = !1, e["mask-box"] = !1, e["mask-box-outset"] = !1, e["mask-box-repeat"] = !1, e["mask-box-slice"] = !1, e["mask-box-source"] = !1, e["mask-box-width"] = !1, e["mask-clip"] = !1, e["mask-image"] = !1, e["mask-origin"] = !1, e["mask-position"] = !1, e["mask-repeat"] = !1, e["mask-size"] = !1, e["mask-source-type"] = !1, e["mask-type"] = !1, e["max-height"] = !0, e["max-lines"] = !1, e["max-width"] = !0, e["min-height"] = !0, e["min-width"] = !0, e["move-to"] = !1, e["nav-down"] = !1, e["nav-index"] = !1, e["nav-left"] = !1, e["nav-right"] = !1, e["nav-up"] = !1, e["object-fit"] = !1, e["object-position"] = !1, e.opacity = !1, e.order = !1, e.orphans = !1, e.outline = !1, e["outline-color"] = !1, e["outline-offset"] = !1, e["outline-style"] = !1, e["outline-width"] = !1, e.overflow = !1, e["overflow-wrap"] = !1, e["overflow-x"] = !1, e["overflow-y"] = !1, e.padding = !0, e["padding-bottom"] = !0, e["padding-left"] = !0, e["padding-right"] = !0, e["padding-top"] = !0, e.page = !1, e["page-break-after"] = !1, e["page-break-before"] = !1, e["page-break-inside"] = !1, e["page-policy"] = !1, e.pause = !1, e["pause-after"] = !1, e["pause-before"] = !1, e.perspective = !1, e["perspective-origin"] = !1, e.pitch = !1, e["pitch-range"] = !1, e["play-during"] = !1, e.position = !1, e["presentation-level"] = !1, e.quotes = !1, e["region-fragment"] = !1, e.resize = !1, e.rest = !1, e["rest-after"] = !1, e["rest-before"] = !1, e.richness = !1, e.right = !1, e.rotation = !1, e["rotation-point"] = !1, e["ruby-align"] = !1, e["ruby-merge"] = !1, e["ruby-position"] = !1, e["shape-image-threshold"] = !1, e["shape-outside"] = !1, e["shape-margin"] = !1, e.size = !1, e.speak = !1, e["speak-as"] = !1, e["speak-header"] = !1, e["speak-numeral"] = !1, e["speak-punctuation"] = !1, e["speech-rate"] = !1, e.stress = !1, e["string-set"] = !1, e["tab-size"] = !1, e["table-layout"] = !1, e["text-align"] = !0, e["text-align-last"] = !0, e["text-combine-upright"] = !0, e["text-decoration"] = !0, e["text-decoration-color"] = !0, e["text-decoration-line"] = !0, e["text-decoration-skip"] = !0, e["text-decoration-style"] = !0, e["text-emphasis"] = !0, e["text-emphasis-color"] = !0, e["text-emphasis-position"] = !0, e["text-emphasis-style"] = !0, e["text-height"] = !0, e["text-indent"] = !0, e["text-justify"] = !0, e["text-orientation"] = !0, e["text-overflow"] = !0, e["text-shadow"] = !0, e["text-space-collapse"] = !0, e["text-transform"] = !0, e["text-underline-position"] = !0, e["text-wrap"] = !0, e.top = !1, e.transform = !1, e["transform-origin"] = !1, e["transform-style"] = !1, e.transition = !1, e["transition-delay"] = !1, e["transition-duration"] = !1, e["transition-property"] = !1, e["transition-timing-function"] = !1, e["unicode-bidi"] = !1, e["vertical-align"] = !1, e.visibility = !1, e["voice-balance"] = !1, e["voice-duration"] = !1, e["voice-family"] = !1, e["voice-pitch"] = !1, e["voice-range"] = !1, e["voice-rate"] = !1, e["voice-stress"] = !1, e["voice-volume"] = !1, e.volume = !1, e["white-space"] = !1, e.widows = !1, e.width = !0, e["will-change"] = !1, e["word-break"] = !0, e["word-spacing"] = !0, e["word-wrap"] = !0, e["wrap-flow"] = !1, e["wrap-through"] = !1, e["writing-mode"] = !1, e["z-index"] = !1, e;
}
function ve(e, r, t) {
}
function he(e, r, t) {
}
var me = /javascript\s*\:/img;
function be(e, r) {
return me.test(r) ? "" : r;
}
y.whiteList = q();
y.getDefaultWhiteList = q;
y.onAttr = ve;
y.onIgnoreAttr = he;
y.safeAttrValue = be;
var we = {
indexOf: function(e, r) {
var t, a;
if (Array.prototype.indexOf)
return e.indexOf(r);
for (t = 0, a = e.length; t < a; t++)
if (e[t] === r)
return t;
return -1;
},
forEach: function(e, r, t) {
var a, o;
if (Array.prototype.forEach)
return e.forEach(r, t);
for (a = 0, o = e.length; a < o; a++)
r.call(t, e[a], a, e);
},
trim: function(e) {
return String.prototype.trim ? e.trim() : e.replace(/(^\s*)|(\s*$)/g, "");
},
trimRight: function(e) {
return String.prototype.trimRight ? e.trimRight() : e.replace(/(\s*$)/g, "");
}
}, S = we;
function ye(e, r) {
e = S.trimRight(e), e[e.length - 1] !== ";" && (e += ";");
var t = e.length, a = !1, o = 0, i = 0, f = "";
function s() {
if (!a) {
var u = S.trim(e.slice(o, i)), l = u.indexOf(":");
if (l !== -1) {
var d = S.trim(u.slice(0, l)), p = S.trim(u.slice(l + 1));
if (d) {
var v = r(o, f.length, d, p, u);
v && (f += v + "; ");
}
}
}
o = i + 1;
}
for (; i < t; i++) {
var n = e[i];
if (n === "/" && e[i + 1] === "*") {
var c = e.indexOf("*/", i + 2);
if (c === -1) break;
i = c + 1, o = i + 1, a = !1;
} else n === "(" ? a = !0 : n === ")" ? a = !1 : n === ";" ? a || s() : n === `
` && s();
}
return S.trim(f);
}
var Ae = ye, _ = y, xe = Ae;
function U(e) {
return e == null;
}
function Te(e) {
var r = {};
for (var t in e)
r[t] = e[t];
return r;
}
function Z(e) {
e = Te(e || {}), e.whiteList = e.whiteList || _.whiteList, e.onAttr = e.onAttr || _.onAttr, e.onIgnoreAttr = e.onIgnoreAttr || _.onIgnoreAttr, e.safeAttrValue = e.safeAttrValue || _.safeAttrValue, this.options = e;
}
Z.prototype.process = function(e) {
if (e = e || "", e = e.toString(), !e) return "";
var r = this, t = r.options, a = t.whiteList, o = t.onAttr, i = t.onIgnoreAttr, f = t.safeAttrValue, s = xe(e, function(n, c, u, l, d) {
var p = a[u], v = !1;
if (p === !0 ? v = p : typeof p == "function" ? v = p(l) : p instanceof RegExp && (v = p.test(l)), v !== !0 && (v = !1), l = f(u, l), !!l) {
var I = {
position: c,
sourcePosition: n,
source: d,
isWhite: v
};
if (v) {
var h = o(u, l, I);
return U(h) ? u + ":" + l : h;
} else {
var h = i(u, l, I);
if (!U(h))
return h;
}
}
});
return s;
};
var ke = Z;
(function(e, r) {
var t = y, a = ke;
function o(f, s) {
var n = new a(s);
return n.process(f);
}
r = e.exports = o, r.FilterCSS = a;
for (var i in t) r[i] = t[i];
typeof window < "u" && (window.filterCSS = e.exports);
})(N, N.exports);
var $ = N.exports, V = {
indexOf: function(e, r) {
var t, a;
if (Array.prototype.indexOf)
return e.indexOf(r);
for (t = 0, a = e.length; t < a; t++)
if (e[t] === r)
return t;
return -1;
},
forEach: function(e, r, t) {
var a, o;
if (Array.prototype.forEach)
return e.forEach(r, t);
for (a = 0, o = e.length; a < o; a++)
r.call(t, e[a], a, e);
},
trim: function(e) {
return String.prototype.trim ? e.trim() : e.replace(/(^\s*)|(\s*$)/g, "");
},
spaceIndex: function(e) {
var r = /\s|\n|\t/, t = r.exec(e);
return t ? t.index : -1;
}
}, Se = $.FilterCSS, Ee = $.getDefaultWhiteList, W = V;
function J() {
return {
a: ["target", "href", "title"],
abbr: ["title"],
address: [],
area: ["shape", "coords", "href", "alt"],
article: [],
aside: [],
audio: [
"autoplay",
"controls",
"crossorigin",
"loop",
"muted",
"preload",
"src"
],
b: [],
bdi: ["dir"],
bdo: ["dir"],
big: [],
blockquote: ["cite"],
br: [],
caption: [],
center: [],
cite: [],
code: [],
col: ["align", "valign", "span", "width"],
colgroup: ["align", "valign", "span", "width"],
dd: [],
del: ["datetime"],
details: ["open"],
div: [],
dl: [],
dt: [],
em: [],
figcaption: [],
figure: [],
font: ["color", "size", "face"],
footer: [],
h1: [],
h2: [],
h3: [],
h4: [],
h5: [],
h6: [],
header: [],
hr: [],
i: [],
img: ["src", "alt", "title", "width", "height", "loading"],
ins: ["datetime"],
kbd: [],
li: [],
mark: [],
nav: [],
ol: [],
p: [],
pre: [],
s: [],
section: [],
small: [],
span: [],
sub: [],
summary: [],
sup: [],
strong: [],
strike: [],
table: ["width", "border", "align", "valign"],
tbody: ["align", "valign"],
td: ["width", "rowspan", "colspan", "align", "valign"],
tfoot: ["align", "valign"],
th: ["width", "rowspan", "colspan", "align", "valign"],
thead: ["align", "valign"],
tr: ["rowspan", "align", "valign"],
tt: [],
u: [],
ul: [],
video: [
"autoplay",
"controls",
"crossorigin",
"loop",
"muted",
"playsinline",
"poster",
"preload",
"src",
"height",
"width"
]
};
}
var K = new Se();
function Ie(e, r, t) {
}
function Le(e, r, t) {
}
function _e(e, r, t) {
}
function Ce(e, r, t) {
}
function Y(e) {
return e.replace(Pe, "<").replace(We, ">");
}
function Oe(e, r, t, a) {
if (t = ne(t), r === "href" || r === "src") {
if (t = W.trim(t), t === "#") return "#";
if (!(t.substr(0, 7) === "http://" || t.substr(0, 8) === "https://" || t.substr(0, 7) === "mailto:" || t.substr(0, 4) === "tel:" || t.substr(0, 11) === "data:image/" || t.substr(0, 6) === "ftp://" || t.substr(0, 2) === "./" || t.substr(0, 3) === "../" || t[0] === "#" || t[0] === "/"))
return "";
} else if (r === "background") {
if (C.lastIndex = 0, C.test(t))
return "";
} else if (r === "style") {
if (B.lastIndex = 0, B.test(t) || (H.lastIndex = 0, H.test(t) && (C.lastIndex = 0, C.test(t))))
return "";
a !== !1 && (a = a || K, t = a.process(t));
}
return t = se(t), t;
}
var Pe = /</g, We = />/g, Re = /"/g, De = /"/g, Fe = /&#([a-zA-Z0-9]*);?/gim, Ne = /:?/gim, $e = /&newline;?/gim, C = /((j\s*a\s*v\s*a|v\s*b|l\s*i\s*v\s*e)\s*s\s*c\s*r\s*i\s*p\s*t\s*|m\s*o\s*c\s*h\s*a):/gi, B = /e\s*x\s*p\s*r\s*e\s*s\s*s\s*i\s*o\s*n\s*\(.*/gi, H = /u\s*r\s*l\s*\(.*/gi;
function ee(e) {
return e.replace(Re, """);
}
function te(e) {
return e.replace(De, '"');
}
function re(e) {
return e.replace(Fe, function(t, a) {
return a[0] === "x" || a[0] === "X" ? String.fromCharCode(parseInt(a.substr(1), 16)) : String.fromCharCode(parseInt(a, 10));
});
}
function ae(e) {
return e.replace(Ne, ":").replace($e, " ");
}
function ie(e) {
for (var r = "", t = 0, a = e.length; t < a; t++)
r += e.charCodeAt(t) < 32 ? " " : e.charAt(t);
return W.trim(r);
}
function ne(e) {
return e = te(e), e = re(e), e = ae(e), e = ie(e), e;
}
function se(e) {
return e = ee(e), e = Y(e), e;
}
function Ve() {
return "";
}
function Xe(e, r) {
typeof r != "function" && (r = function() {
});
var t = !Array.isArray(e);
function a(f) {
return t ? !0 : W.indexOf(e, f) !== -1;
}
var o = [], i = !1;
return {
onIgnoreTag: function(f, s, n) {
if (a(f))
if (n.isClosing) {
var c = "[/removed]", u = n.position + c.length;
return o.push([
i !== !1 ? i : n.position,
u
]), i = !1, c;
} else
return i || (i = n.position), "[removed]";
else
return r(f, s, n);
},
remove: function(f) {
var s = "", n = 0;
return W.forEach(o, function(c) {
s += f.slice(n, c[0]), n = c[1];
}), s += f.slice(n), s;
}
};
}
function Ge(e) {
for (var r = "", t = 0; t < e.length; ) {
var a = e.indexOf("<!--", t);
if (a === -1) {
r += e.slice(t);
break;
}
r += e.slice(t, a);
var o = e.indexOf("-->", a);
if (o === -1)
break;
t = o + 3;
}
return r;
}
function ze(e) {
var r = e.split("");
return r = r.filter(function(t) {
var a = t.charCodeAt(0);
return a === 127 ? !1 : a <= 31 ? a === 10 || a === 13 : !0;
}), r.join("");
}
g.whiteList = J();
g.getDefaultWhiteList = J;
g.onTag = Ie;
g.onIgnoreTag = Le;
g.onTagAttr = _e;
g.onIgnoreTagAttr = Ce;
g.safeAttrValue = Oe;
g.escapeHtml = Y;
g.escapeQuote = ee;
g.unescapeQuote = te;
g.escapeHtmlEntities = re;
g.escapeDangerHtml5Entities = ae;
g.clearNonPrintableCharacter = ie;
g.friendlyAttrValue = ne;
g.escapeAttrValue = se;
g.onIgnoreTagStripAll = Ve;
g.StripTagBody = Xe;
g.stripCommentTag = Ge;
g.stripBlankChar = ze;
g.attributeWrapSign = '"';
g.cssFilter = K;
g.getDefaultCSSWhiteList = Ee;
var R = {}, w = V;
function Me(e) {
var r = w.spaceIndex(e), t;
return r === -1 ? t = e.slice(1, -1) : t = e.slice(1, r + 1), t = w.trim(t).toLowerCase(), t.slice(0, 1) === "/" && (t = t.slice(1)), t.slice(-1) === "/" && (t = t.slice(0, -1)), t;
}
function Ue(e) {
return e.slice(0, 2) === "</";
}
function Be(e, r, t) {
var a = "", o = 0, i = !1, f = !1, s = 0, n = e.length, c = "", u = "";
e: for (s = 0; s < n; s++) {
var l = e.charAt(s);
if (i === !1) {
if (l === "<") {
i = s;
continue;
}
} else if (f === !1) {
if (l === "<") {
a += t(e.slice(o, s)), i = s, o = s;
continue;
}
if (l === ">" || s === n - 1) {
a += t(e.slice(o, i)), u = e.slice(i, s + 1), c = Me(u), a += r(
i,
a.length,
c,
u,
Ue(u)
), o = s + 1, i = !1;
continue;
}
if (l === '"' || l === "'")
for (var d = 1, p = e.charAt(s - d); p.trim() === "" || p === "="; ) {
if (p === "=") {
f = l;
continue e;
}
p = e.charAt(s - ++d);
}
} else if (l === f) {
f = !1;
continue;
}
}
return o < n && (a += t(e.substr(o))), a;
}
var He = /[^a-zA-Z0-9\\_:.-]/gim;
function Qe(e, r) {
var t = 0, a = 0, o = [], i = !1, f = e.length;
function s(d, p) {
if (d = w.trim(d), d = d.replace(He, "").toLowerCase(), !(d.length < 1)) {
var v = r(d, p || "");
v && o.push(v);
}
}
for (var n = 0; n < f; n++) {
var c = e.charAt(n), u, l;
if (i === !1 && c === "=") {
i = e.slice(t, n), t = n + 1, a = e.charAt(t) === '"' || e.charAt(t) === "'" ? t : qe(e, n + 1);
continue;
}
if (i !== !1 && n === a) {
if (l = e.indexOf(c, n + 1), l === -1)
break;
u = w.trim(e.slice(a + 1, l)), s(i, u), i = !1, n = l, t = n + 1;
continue;
}
if (/\s|\n|\t/.test(c))
if (e = e.replace(/\s|\n|\t/g, " "), i === !1)
if (l = je(e, n), l === -1) {
u = w.trim(e.slice(t, n)), s(u), i = !1, t = n + 1;
continue;
} else {
n = l - 1;
continue;
}
else if (l = Ze(e, n - 1), l === -1) {
u = w.trim(e.slice(t, n)), u = Q(u), s(i, u), i = !1, t = n + 1;
continue;
} else
continue;
}
return t < e.length && (i === !1 ? s(e.slice(t)) : s(i, Q(w.trim(e.slice(t))))), w.trim(o.join(" "));
}
function je(e, r) {
for (; r < e.length; r++) {
var t = e[r];
if (t !== " ")
return t === "=" ? r : -1;
}
}
function qe(e, r) {
for (; r < e.length; r++) {
var t = e[r];
if (t !== " ")
return t === "'" || t === '"' ? r : -1;
}
}
function Ze(e, r) {
for (; r > 0; r--) {
var t = e[r];
if (t !== " ")
return t === "=" ? r : -1;
}
}
function Je(e) {
return e[0] === '"' && e[e.length - 1] === '"' || e[0] === "'" && e[e.length - 1] === "'";
}
function Q(e) {
return Je(e) ? e.substr(1, e.length - 2) : e;
}
R.parseTag = Be;
R.parseAttr = Qe;
var Ke = $.FilterCSS, m = g, oe = R, Ye = oe.parseTag, et = oe.parseAttr, P = V;
function O(e) {
return e == null;
}
function tt(e) {
var r = P.spaceIndex(e);
if (r === -1)
return {
html: "",
closing: e[e.length - 2] === "/"
};
e = P.trim(e.slice(r + 1, -1));
var t = e[e.length - 1] === "/";
return t && (e = P.trim(e.slice(0, -1))), {
html: e,
closing: t
};
}
function rt(e) {
var r = {};
for (var t in e)
r[t] = e[t];
return r;
}
function at(e) {
var r = {};
for (var t in e)
Array.isArray(e[t]) ? r[t.toLowerCase()] = e[t].map(function(a) {
return a.toLowerCase();
}) : r[t.toLowerCase()] = e[t];
return r;
}
function le(e) {
e = rt(e || {}), e.stripIgnoreTag && (e.onIgnoreTag && console.error(
'Notes: cannot use these two options "stripIgnoreTag" and "onIgnoreTag" at the same time'
), e.onIgnoreTag = m.onIgnoreTagStripAll), e.whiteList || e.allowList ? e.whiteList = at(e.whiteList || e.allowList) : e.whiteList = m.whiteList, this.attributeWrapSign = e.singleQuotedAttributeValue === !0 ? "'" : m.attributeWrapSign, e.onTag = e.onTag || m.onTag, e.onTagAttr = e.onTagAttr || m.onTagAttr, e.onIgnoreTag = e.onIgnoreTag || m.onIgnoreTag, e.onIgnoreTagAttr = e.onIgnoreTagAttr || m.onIgnoreTagAttr, e.safeAttrValue = e.safeAttrValue || m.safeAttrValue, e.escapeHtml = e.escapeHtml || m.escapeHtml, this.options = e, e.css === !1 ? this.cssFilter = !1 : (e.css = e.css || {}, this.cssFilter = new Ke(e.css));
}
le.prototype.process = function(e) {
if (e = e || "", e = e.toString(), !e) return "";
var r = this, t = r.options, a = t.whiteList, o = t.onTag, i = t.onIgnoreTag, f = t.onTagAttr, s = t.onIgnoreTagAttr, n = t.safeAttrValue, c = t.escapeHtml, u = r.attributeWrapSign, l = r.cssFilter;
t.stripBlankChar && (e = m.stripBlankChar(e)), t.allowCommentTag || (e = m.stripCommentTag(e));
var d = !1;
t.stripIgnoreTagBody && (d = m.StripTagBody(
t.stripIgnoreTagBody,
i
), i = d.onIgnoreTag);
var p = Ye(
e,
function(v, I, h, b, fe) {
var L = {
sourcePosition: v,
position: I,
isClosing: fe,
isWhite: Object.prototype.hasOwnProperty.call(a, h)
}, T = o(h, b, L);
if (!O(T)) return T;
if (L.isWhite) {
if (L.isClosing)
return "</" + h + ">";
var X = tt(b), ue = a[h], G = et(X.html, function(A, x) {
var D = P.indexOf(ue, A) !== -1, k = f(h, A, x, D);
return O(k) ? D ? (x = n(h, A, x, l), x ? A + "=" + u + x + u : A) : (k = s(h, A, x, D), O(k) ? void 0 : k) : k;
});
return b = "<" + h, G && (b += " " + G), X.closing && (b += " /"), b += ">", b;
} else
return T = i(h, b, L), O(T) ? c(b) : T;
},
c
);
return d && (p = d.remove(p)), p;
};
var it = le;
(function(e, r) {
var t = g, a = R, o = it;
function i(s, n) {
var c = new o(n);
return c.process(s);
}
r = e.exports = i, r.filterXSS = i, r.FilterXSS = o, function() {
for (var s in t)
r[s] = t[s];
for (var n in a)
r[n] = a[n];
}(), typeof window < "u" && (window.filterXSS = e.exports);
function f() {
return typeof self < "u" && typeof DedicatedWorkerGlobalScope < "u" && self instanceof DedicatedWorkerGlobalScope;
}
f() && (self.filterXSS = e.exports);
})(F, F.exports);
var E = F.exports;
const nt = /* @__PURE__ */ pe(E), st = /* @__PURE__ */ de({
__proto__: null,
default: nt
}, [E]), j = {
img: ["class"],
// 支持任务列表
input: ["class", "disabled", "type", "checked"],
// 主要支持youtobe、腾讯视频、哔哩哔哩等内嵌视频代码
iframe: [
"class",
"width",
"height",
"src",
"title",
"border",
"frameborder",
"framespacing",
"allow",
"allowfullscreen"
]
}, gt = (e, r) => {
const { extendedWhiteList: t = {}, xss: a = {} } = r;
let o;
if (typeof a == "function")
o = new E.FilterXSS(a(st));
else {
const i = E.getDefaultWhiteList();
[...Object.keys(t), ...Object.keys(j)].forEach((s) => {
const n = i[s] || [], c = j[s] || [], u = t[s] || [];
i[s] = [
.../* @__PURE__ */ new Set([...n, ...c, ...u])
];
}), o = new E.FilterXSS({
whiteList: i,
// 自定义的优先级最高
...a
});
}
e.core.ruler.after("linkify", "xss", (i) => {
for (let f = 0; f < i.tokens.length; f++) {
const s = i.tokens[f];
switch (s.type) {
case "html_block": {
s.content = o.process(s.content);
break;
}
case "inline": {
(s.children || []).forEach((c) => {
c.type === "html_inline" && (c.content = o.process(c.content));
});
break;
}
}
}
});
}, dt = () => {
Object.keys(M).forEach((e) => {
const r = document.getElementById(M[e]);
r && r.remove();
});
};
export {
yt as DropdownToolbar,
Dt as MdCatalog,
ht as MdEditor,
kt as MdModal,
Wt as MdPreview,
xt as ModalToolbar,
ct as NormalFooterToolbar,
bt as NormalToolbar,
Et as StrIcon,
gt as XSSPlugin,
Lt as allFooter,
_t as allToolbar,
dt as clearSideEffects,
Ct as config,
Ot as editorExtensionsAttrs,
Nt as en_US,
z as prefix,
$t as zh_CN
};