UNPKG

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...

712 lines (711 loc) 28.7 kB
import { E as Ne } from "./chunks/Editor.mjs"; import { default as Ve } from "./NormalToolbar.mjs"; import { default as Ue } from "./DropdownToolbar.mjs"; import { default as ze } from "./ModalToolbar.mjs"; import { M as Be } from "./chunks/index.mjs"; import { S as Qe } from "./chunks/dom.mjs"; import { jsx as we } from "react/jsx-runtime"; import { p as re } from "./chunks/config.mjs"; import { b as Ze, a as Je, c as Ke, e as Ye } from "./chunks/config.mjs"; import { c as ye } from "./chunks/index2.mjs"; import { default as rr } from "./MdPreview.mjs"; import { M as ar } from "./chunks/index3.mjs"; import { en_US as nr, zh_CN as sr } from "./config.mjs"; import { C as te } from "./chunks/hooks.mjs"; function Ae(t, n) { for (var i = 0; i < n.length; i++) { const l = n[i]; if (typeof l != "string" && !Array.isArray(l)) { for (const g in l) if (g !== "default" && !(g in t)) { const e = Object.getOwnPropertyDescriptor(l, g); e && Object.defineProperty(t, g, e.get ? e : { enumerable: !0, get: () => l[g] }); } } } return Object.freeze(Object.defineProperty(t, Symbol.toStringTag, { value: "Module" })); } const Pe = (t) => /* @__PURE__ */ we( "div", { className: ye([ `${re}-footer-item`, t.disabled && `${re}-disabled` ]), onClick: (n) => { t.disabled || t.onClick?.(n); }, children: t.children } ); function xe(t) { return t && t.__esModule && Object.prototype.hasOwnProperty.call(t, "default") ? t.default : t; } var z = { exports: {} }, w = {}, M = { exports: {} }, N = {}, ae; function pe() { if (ae) return N; ae = 1; function t() { 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 n(e, v, u) { } function i(e, v, u) { } var l = /javascript\s*\:/img; function g(e, v) { return l.test(v) ? "" : v; } return N.whiteList = t(), N.getDefaultWhiteList = t, N.onAttr = n, N.onIgnoreAttr = i, N.safeAttrValue = g, N; } var Q, ie; function ve() { return ie || (ie = 1, Q = { indexOf: function(t, n) { var i, l; if (Array.prototype.indexOf) return t.indexOf(n); for (i = 0, l = t.length; i < l; i++) if (t[i] === n) return i; return -1; }, forEach: function(t, n, i) { var l, g; if (Array.prototype.forEach) return t.forEach(n, i); for (l = 0, g = t.length; l < g; l++) n.call(i, t[l], l, t); }, trim: function(t) { return String.prototype.trim ? t.trim() : t.replace(/(^\s*)|(\s*$)/g, ""); }, trimRight: function(t) { return String.prototype.trimRight ? t.trimRight() : t.replace(/(\s*$)/g, ""); } }), Q; } var j, ne; function Te() { if (ne) return j; ne = 1; var t = ve(); function n(i, l) { i = t.trimRight(i), i[i.length - 1] !== ";" && (i += ";"); var g = i.length, e = !1, v = 0, u = 0, x = ""; function k() { if (!e) { var f = t.trim(i.slice(v, u)), a = f.indexOf(":"); if (a !== -1) { var y = t.trim(f.slice(0, a)), T = t.trim(f.slice(a + 1)); if (y) { var c = l(v, x.length, y, T, f); c && (x += c + "; "); } } } v = u + 1; } for (; u < g; u++) { var S = i[u]; if (S === "/" && i[u + 1] === "*") { var r = i.indexOf("*/", u + 2); if (r === -1) break; u = r + 1, v = u + 1, e = !1; } else S === "(" ? e = !0 : S === ")" ? e = !1 : S === ";" ? e || k() : S === ` ` && k(); } return t.trim(x); } return j = n, j; } var Z, se; function ke() { if (se) return Z; se = 1; var t = pe(), n = Te(); ve(); function i(e) { return e == null; } function l(e) { var v = {}; for (var u in e) v[u] = e[u]; return v; } function g(e) { e = l(e || {}), e.whiteList = e.whiteList || t.whiteList, e.onAttr = e.onAttr || t.onAttr, e.onIgnoreAttr = e.onIgnoreAttr || t.onIgnoreAttr, e.safeAttrValue = e.safeAttrValue || t.safeAttrValue, this.options = e; } return g.prototype.process = function(e) { if (e = e || "", e = e.toString(), !e) return ""; var v = this, u = v.options, x = u.whiteList, k = u.onAttr, S = u.onIgnoreAttr, r = u.safeAttrValue, f = n(e, function(a, y, T, c, I) { var p = x[T], d = !1; if (p === !0 ? d = p : typeof p == "function" ? d = p(c) : p instanceof RegExp && (d = p.test(c)), d !== !0 && (d = !1), c = r(T, c), !!c) { var L = { position: y, sourcePosition: a, source: I, isWhite: d }; if (d) { var b = k(T, c, L); return i(b) ? T + ":" + c : b; } else { var b = S(T, c, L); if (!i(b)) return b; } } }); return f; }, Z = g, Z; } var oe; function Y() { return oe || (oe = 1, (function(t, n) { var i = pe(), l = ke(); function g(v, u) { var x = new l(u); return x.process(v); } n = t.exports = g, n.FilterCSS = l; for (var e in i) n[e] = i[e]; typeof window < "u" && (window.filterCSS = t.exports); })(M, M.exports)), M.exports; } var J, le; function ee() { return le || (le = 1, J = { indexOf: function(t, n) { var i, l; if (Array.prototype.indexOf) return t.indexOf(n); for (i = 0, l = t.length; i < l; i++) if (t[i] === n) return i; return -1; }, forEach: function(t, n, i) { var l, g; if (Array.prototype.forEach) return t.forEach(n, i); for (l = 0, g = t.length; l < g; l++) n.call(i, t[l], l, t); }, trim: function(t) { return String.prototype.trim ? t.trim() : t.replace(/(^\s*)|(\s*$)/g, ""); }, spaceIndex: function(t) { var n = /\s|\n|\t/, i = n.exec(t); return i ? i.index : -1; } }), J; } var fe; function he() { if (fe) return w; fe = 1; var t = Y().FilterCSS, n = Y().getDefaultWhiteList, i = ee(); function l() { 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 g = new t(); function e(s, m, o) { } function v(s, m, o) { } function u(s, m, o) { } function x(s, m, o) { } function k(s) { return s.replace(r, "&lt;").replace(f, "&gt;"); } function S(s, m, o, h) { if (o = $(o), m === "href" || m === "src") { if (o = i.trim(o), o === "#") return "#"; if (!(o.substr(0, 7) === "http://" || o.substr(0, 8) === "https://" || o.substr(0, 7) === "mailto:" || o.substr(0, 4) === "tel:" || o.substr(0, 11) === "data:image/" || o.substr(0, 6) === "ftp://" || o.substr(0, 2) === "./" || o.substr(0, 3) === "../" || o[0] === "#" || o[0] === "/")) return ""; } else if (m === "background") { if (p.lastIndex = 0, p.test(o)) return ""; } else if (m === "style") { if (d.lastIndex = 0, d.test(o) || (L.lastIndex = 0, L.test(o) && (p.lastIndex = 0, p.test(o)))) return ""; h !== !1 && (h = h || g, o = h.process(o)); } return o = R(o), o; } var r = /</g, f = />/g, a = /"/g, y = /&quot;/g, T = /&#([a-zA-Z0-9]*);?/gim, c = /&colon;?/gim, I = /&newline;?/gim, p = /((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, d = /e\s*x\s*p\s*r\s*e\s*s\s*s\s*i\s*o\s*n\s*\(.*/gi, L = /u\s*r\s*l\s*\(.*/gi; function b(s) { return s.replace(a, "&quot;"); } function A(s) { return s.replace(y, '"'); } function E(s) { return s.replace(T, function(o, h) { return h[0] === "x" || h[0] === "X" ? String.fromCharCode(parseInt(h.substr(1), 16)) : String.fromCharCode(parseInt(h, 10)); }); } function _(s) { return s.replace(c, ":").replace(I, " "); } function D(s) { for (var m = "", o = 0, h = s.length; o < h; o++) m += s.charCodeAt(o) < 32 ? " " : s.charAt(o); return i.trim(m); } function $(s) { return s = A(s), s = E(s), s = _(s), s = D(s), s; } function R(s) { return s = b(s), s = k(s), s; } function P() { return ""; } function H(s, m) { typeof m != "function" && (m = function() { }); var o = !Array.isArray(s); function h(C) { return o ? !0 : i.indexOf(s, C) !== -1; } var O = [], W = !1; return { onIgnoreTag: function(C, V, q) { if (h(C)) if (q.isClosing) { var G = "[/removed]", be = q.position + G.length; return O.push([ W !== !1 ? W : q.position, be ]), W = !1, G; } else return W || (W = q.position), "[removed]"; else return m(C, V, q); }, remove: function(C) { var V = "", q = 0; return i.forEach(O, function(G) { V += C.slice(q, G[0]), q = G[1]; }), V += C.slice(q), V; } }; } function X(s) { for (var m = "", o = 0; o < s.length; ) { var h = s.indexOf("<!--", o); if (h === -1) { m += s.slice(o); break; } m += s.slice(o, h); var O = s.indexOf("-->", h); if (O === -1) break; o = O + 3; } return m; } function F(s) { var m = s.split(""); return m = m.filter(function(o) { var h = o.charCodeAt(0); return h === 127 ? !1 : h <= 31 ? h === 10 || h === 13 : !0; }), m.join(""); } return w.whiteList = l(), w.getDefaultWhiteList = l, w.onTag = e, w.onIgnoreTag = v, w.onTagAttr = u, w.onIgnoreTagAttr = x, w.safeAttrValue = S, w.escapeHtml = k, w.escapeQuote = b, w.unescapeQuote = A, w.escapeHtmlEntities = E, w.escapeDangerHtml5Entities = _, w.clearNonPrintableCharacter = D, w.friendlyAttrValue = $, w.escapeAttrValue = R, w.onIgnoreTagStripAll = P, w.StripTagBody = H, w.stripCommentTag = X, w.stripBlankChar = F, w.attributeWrapSign = '"', w.cssFilter = g, w.getDefaultCSSWhiteList = n, w; } var B = {}, ue; function me() { if (ue) return B; ue = 1; var t = ee(); function n(r) { var f = t.spaceIndex(r), a; return f === -1 ? a = r.slice(1, -1) : a = r.slice(1, f + 1), a = t.trim(a).toLowerCase(), a.slice(0, 1) === "/" && (a = a.slice(1)), a.slice(-1) === "/" && (a = a.slice(0, -1)), a; } function i(r) { return r.slice(0, 2) === "</"; } function l(r, f, a) { var y = "", T = 0, c = !1, I = !1, p = 0, d = r.length, L = "", b = ""; e: for (p = 0; p < d; p++) { var A = r.charAt(p); if (c === !1) { if (A === "<") { c = p; continue; } } else if (I === !1) { if (A === "<") { y += a(r.slice(T, p)), c = p, T = p; continue; } if (A === ">" || p === d - 1) { y += a(r.slice(T, c)), b = r.slice(c, p + 1), L = n(b), y += f( c, y.length, L, b, i(b) ), T = p + 1, c = !1; continue; } if (A === '"' || A === "'") for (var E = 1, _ = r.charAt(p - E); _.trim() === "" || _ === "="; ) { if (_ === "=") { I = A; continue e; } _ = r.charAt(p - ++E); } } else if (A === I) { I = !1; continue; } } return T < d && (y += a(r.substr(T))), y; } var g = /[^a-zA-Z0-9\\_:.-]/gim; function e(r, f) { var a = 0, y = 0, T = [], c = !1, I = r.length; function p(E, _) { if (E = t.trim(E), E = E.replace(g, "").toLowerCase(), !(E.length < 1)) { var D = f(E, _ || ""); D && T.push(D); } } for (var d = 0; d < I; d++) { var L = r.charAt(d), b, A; if (c === !1 && L === "=") { c = r.slice(a, d), a = d + 1, y = r.charAt(a) === '"' || r.charAt(a) === "'" ? a : u(r, d + 1); continue; } if (c !== !1 && d === y) { if (A = r.indexOf(L, d + 1), A === -1) break; b = t.trim(r.slice(y + 1, A)), p(c, b), c = !1, d = A, a = d + 1; continue; } if (/\s|\n|\t/.test(L)) if (r = r.replace(/\s|\n|\t/g, " "), c === !1) if (A = v(r, d), A === -1) { b = t.trim(r.slice(a, d)), p(b), c = !1, a = d + 1; continue; } else { d = A - 1; continue; } else if (A = x(r, d - 1), A === -1) { b = t.trim(r.slice(a, d)), b = S(b), p(c, b), c = !1, a = d + 1; continue; } else continue; } return a < r.length && (c === !1 ? p(r.slice(a)) : p(c, S(t.trim(r.slice(a))))), t.trim(T.join(" ")); } function v(r, f) { for (; f < r.length; f++) { var a = r[f]; if (a !== " ") return a === "=" ? f : -1; } } function u(r, f) { for (; f < r.length; f++) { var a = r[f]; if (a !== " ") return a === "'" || a === '"' ? f : -1; } } function x(r, f) { for (; f > 0; f--) { var a = r[f]; if (a !== " ") return a === "=" ? f : -1; } } function k(r) { return r[0] === '"' && r[r.length - 1] === '"' || r[0] === "'" && r[r.length - 1] === "'"; } function S(r) { return k(r) ? r.substr(1, r.length - 2) : r; } return B.parseTag = l, B.parseAttr = e, B; } var K, ce; function Se() { if (ce) return K; ce = 1; var t = Y().FilterCSS, n = he(), i = me(), l = i.parseTag, g = i.parseAttr, e = ee(); function v(r) { return r == null; } function u(r) { var f = e.spaceIndex(r); if (f === -1) return { html: "", closing: r[r.length - 2] === "/" }; r = e.trim(r.slice(f + 1, -1)); var a = r[r.length - 1] === "/"; return a && (r = e.trim(r.slice(0, -1))), { html: r, closing: a }; } function x(r) { var f = {}; for (var a in r) f[a] = r[a]; return f; } function k(r) { var f = {}; for (var a in r) Array.isArray(r[a]) ? f[a.toLowerCase()] = r[a].map(function(y) { return y.toLowerCase(); }) : f[a.toLowerCase()] = r[a]; return f; } function S(r) { r = x(r || {}), r.stripIgnoreTag && (r.onIgnoreTag && console.error( 'Notes: cannot use these two options "stripIgnoreTag" and "onIgnoreTag" at the same time' ), r.onIgnoreTag = n.onIgnoreTagStripAll), r.whiteList || r.allowList ? r.whiteList = k(r.whiteList || r.allowList) : r.whiteList = n.whiteList, this.attributeWrapSign = r.singleQuotedAttributeValue === !0 ? "'" : n.attributeWrapSign, r.onTag = r.onTag || n.onTag, r.onTagAttr = r.onTagAttr || n.onTagAttr, r.onIgnoreTag = r.onIgnoreTag || n.onIgnoreTag, r.onIgnoreTagAttr = r.onIgnoreTagAttr || n.onIgnoreTagAttr, r.safeAttrValue = r.safeAttrValue || n.safeAttrValue, r.escapeHtml = r.escapeHtml || n.escapeHtml, this.options = r, r.css === !1 ? this.cssFilter = !1 : (r.css = r.css || {}, this.cssFilter = new t(r.css)); } return S.prototype.process = function(r) { if (r = r || "", r = r.toString(), !r) return ""; var f = this, a = f.options, y = a.whiteList, T = a.onTag, c = a.onIgnoreTag, I = a.onTagAttr, p = a.onIgnoreTagAttr, d = a.safeAttrValue, L = a.escapeHtml, b = f.attributeWrapSign, A = f.cssFilter; a.stripBlankChar && (r = n.stripBlankChar(r)), a.allowCommentTag || (r = n.stripCommentTag(r)); var E = !1; a.stripIgnoreTagBody && (E = n.StripTagBody( a.stripIgnoreTagBody, c ), c = E.onIgnoreTag); var _ = l( r, function(D, $, R, P, H) { var X = { sourcePosition: D, position: $, isClosing: H, isWhite: Object.prototype.hasOwnProperty.call(y, R) }, F = T(R, P, X); if (!v(F)) return F; if (X.isWhite) { if (X.isClosing) return "</" + R + ">"; var s = u(P), m = y[R], o = g(s.html, function(h, O) { var W = e.indexOf(m, h) !== -1, C = I(R, h, O, W); return v(C) ? W ? (O = d(R, h, O, A), O ? h + "=" + b + O + b : h) : (C = p(R, h, O, W), v(C) ? void 0 : C) : C; }); return P = "<" + R, o && (P += " " + o), s.closing && (P += " /"), P += ">", P; } else return F = c(R, P, X), v(F) ? L(P) : F; }, L ); return E && (_ = E.remove(_)), _; }, K = S, K; } var ge; function Ee() { return ge || (ge = 1, (function(t, n) { var i = he(), l = me(), g = Se(); function e(u, x) { var k = new g(x); return k.process(u); } n = t.exports = e, n.filterXSS = e, n.FilterXSS = g, (function() { for (var u in i) n[u] = i[u]; for (var x in l) n[x] = l[x]; })(), typeof window < "u" && (window.filterXSS = t.exports); function v() { return typeof self < "u" && typeof DedicatedWorkerGlobalScope < "u" && self instanceof DedicatedWorkerGlobalScope; } v() && (self.filterXSS = t.exports); })(z, z.exports)), z.exports; } var U = Ee(); const Le = /* @__PURE__ */ xe(U), _e = /* @__PURE__ */ Ae({ __proto__: null, default: Le }, [U]), de = { img: ["class"], // 支持任务列表 input: ["class", "disabled", "type", "checked"], // 主要支持youtobe、腾讯视频、哔哩哔哩等内嵌视频代码 iframe: [ "class", "width", "height", "src", "title", "border", "frameborder", "framespacing", "allow", "allowfullscreen" ] }, We = (t, n) => { const { extendedWhiteList: i = {}, xss: l = {} } = n; let g; if (typeof l == "function") g = new U.FilterXSS(l(_e)); else { const e = U.getDefaultWhiteList(); [...Object.keys(i), ...Object.keys(de)].forEach((u) => { const x = e[u] || [], k = de[u] || [], S = i[u] || []; e[u] = [ .../* @__PURE__ */ new Set([...x, ...k, ...S]) ]; }), g = new U.FilterXSS({ whiteList: e, // 自定义的优先级最高 ...l }); } t.core.ruler.after("linkify", "xss", (e) => { for (let v = 0; v < e.tokens.length; v++) { const u = e.tokens[v]; switch (u.type) { case "html_block": { u.content = g.process(u.content); break; } case "inline": { (u.children || []).forEach((k) => { k.type === "html_inline" && (k.content = g.process(k.content)); }); break; } } } }); }, qe = () => { Object.keys(te).forEach((t) => { const n = document.getElementById(te[t]); n && n.remove(); }); }; export { Ue as DropdownToolbar, ar as MdCatalog, Ne as MdEditor, Be as MdModal, rr as MdPreview, ze as ModalToolbar, Pe as NormalFooterToolbar, Ve as NormalToolbar, Qe as StrIcon, We as XSSPlugin, Ze as allFooter, Je as allToolbar, qe as clearSideEffects, Ke as config, Ye as editorExtensionsAttrs, nr as en_US, re as prefix, sr as zh_CN };