@editora/plugins 1.0.9 → 1.0.11
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +5 -0
- package/dist/code.cjs.js +17 -17
- package/dist/code.esm.js +278 -224
- package/dist/media-manager.cjs.js +21 -21
- package/dist/media-manager.esm.js +117 -115
- package/dist/slash-commands.cjs.js +3 -3
- package/dist/slash-commands.esm.js +149 -149
- package/dist/template.cjs.js +21 -20
- package/dist/template.esm.js +713 -165
- package/package.json +13 -7
- package/LICENSE +0 -21
package/dist/template.esm.js
CHANGED
|
@@ -1,28 +1,576 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
1
|
+
const {
|
|
2
|
+
entries: Ht,
|
|
3
|
+
setPrototypeOf: wt,
|
|
4
|
+
isFrozen: gn,
|
|
5
|
+
getPrototypeOf: hn,
|
|
6
|
+
getOwnPropertyDescriptor: Tn
|
|
7
|
+
} = Object;
|
|
8
|
+
let {
|
|
9
|
+
freeze: R,
|
|
10
|
+
seal: O,
|
|
11
|
+
create: De
|
|
12
|
+
} = Object, {
|
|
13
|
+
apply: et,
|
|
14
|
+
construct: tt
|
|
15
|
+
} = typeof Reflect < "u" && Reflect;
|
|
16
|
+
R || (R = function(t) {
|
|
17
|
+
return t;
|
|
18
|
+
});
|
|
19
|
+
O || (O = function(t) {
|
|
20
|
+
return t;
|
|
21
|
+
});
|
|
22
|
+
et || (et = function(t, o) {
|
|
23
|
+
for (var l = arguments.length, c = new Array(l > 2 ? l - 2 : 0), f = 2; f < l; f++)
|
|
24
|
+
c[f - 2] = arguments[f];
|
|
25
|
+
return t.apply(o, c);
|
|
26
|
+
});
|
|
27
|
+
tt || (tt = function(t) {
|
|
28
|
+
for (var o = arguments.length, l = new Array(o > 1 ? o - 1 : 0), c = 1; c < o; c++)
|
|
29
|
+
l[c - 1] = arguments[c];
|
|
30
|
+
return new t(...l);
|
|
31
|
+
});
|
|
32
|
+
const Re = L(Array.prototype.forEach), bn = L(Array.prototype.lastIndexOf), Ct = L(Array.prototype.pop), se = L(Array.prototype.push), En = L(Array.prototype.splice), we = L(String.prototype.toLowerCase), $e = L(String.prototype.toString), qe = L(String.prototype.match), ce = L(String.prototype.replace), An = L(String.prototype.indexOf), _n = L(String.prototype.trim), C = L(Object.prototype.hasOwnProperty), x = L(RegExp.prototype.test), ue = yn(TypeError);
|
|
33
|
+
function L(n) {
|
|
34
|
+
return function(t) {
|
|
35
|
+
t instanceof RegExp && (t.lastIndex = 0);
|
|
36
|
+
for (var o = arguments.length, l = new Array(o > 1 ? o - 1 : 0), c = 1; c < o; c++)
|
|
37
|
+
l[c - 1] = arguments[c];
|
|
38
|
+
return et(n, t, l);
|
|
39
|
+
};
|
|
40
|
+
}
|
|
41
|
+
function yn(n) {
|
|
42
|
+
return function() {
|
|
43
|
+
for (var t = arguments.length, o = new Array(t), l = 0; l < t; l++)
|
|
44
|
+
o[l] = arguments[l];
|
|
45
|
+
return tt(n, o);
|
|
46
|
+
};
|
|
47
|
+
}
|
|
48
|
+
function s(n, t) {
|
|
49
|
+
let o = arguments.length > 2 && arguments[2] !== void 0 ? arguments[2] : we;
|
|
50
|
+
wt && wt(n, null);
|
|
51
|
+
let l = t.length;
|
|
52
|
+
for (; l--; ) {
|
|
53
|
+
let c = t[l];
|
|
54
|
+
if (typeof c == "string") {
|
|
55
|
+
const f = o(c);
|
|
56
|
+
f !== c && (gn(t) || (t[l] = f), c = f);
|
|
57
|
+
}
|
|
58
|
+
n[c] = !0;
|
|
59
|
+
}
|
|
60
|
+
return n;
|
|
61
|
+
}
|
|
62
|
+
function vn(n) {
|
|
63
|
+
for (let t = 0; t < n.length; t++)
|
|
64
|
+
C(n, t) || (n[t] = null);
|
|
65
|
+
return n;
|
|
66
|
+
}
|
|
67
|
+
function I(n) {
|
|
68
|
+
const t = De(null);
|
|
69
|
+
for (const [o, l] of Ht(n))
|
|
70
|
+
C(n, o) && (Array.isArray(l) ? t[o] = vn(l) : l && typeof l == "object" && l.constructor === Object ? t[o] = I(l) : t[o] = l);
|
|
71
|
+
return t;
|
|
72
|
+
}
|
|
73
|
+
function pe(n, t) {
|
|
74
|
+
for (; n !== null; ) {
|
|
75
|
+
const l = Tn(n, t);
|
|
76
|
+
if (l) {
|
|
77
|
+
if (l.get)
|
|
78
|
+
return L(l.get);
|
|
79
|
+
if (typeof l.value == "function")
|
|
80
|
+
return L(l.value);
|
|
81
|
+
}
|
|
82
|
+
n = hn(n);
|
|
83
|
+
}
|
|
84
|
+
function o() {
|
|
85
|
+
return null;
|
|
86
|
+
}
|
|
87
|
+
return o;
|
|
88
|
+
}
|
|
89
|
+
const Ot = R(["a", "abbr", "acronym", "address", "area", "article", "aside", "audio", "b", "bdi", "bdo", "big", "blink", "blockquote", "body", "br", "button", "canvas", "caption", "center", "cite", "code", "col", "colgroup", "content", "data", "datalist", "dd", "decorator", "del", "details", "dfn", "dialog", "dir", "div", "dl", "dt", "element", "em", "fieldset", "figcaption", "figure", "font", "footer", "form", "h1", "h2", "h3", "h4", "h5", "h6", "head", "header", "hgroup", "hr", "html", "i", "img", "input", "ins", "kbd", "label", "legend", "li", "main", "map", "mark", "marquee", "menu", "menuitem", "meter", "nav", "nobr", "ol", "optgroup", "option", "output", "p", "picture", "pre", "progress", "q", "rp", "rt", "ruby", "s", "samp", "search", "section", "select", "shadow", "slot", "small", "source", "spacer", "span", "strike", "strong", "style", "sub", "summary", "sup", "table", "tbody", "td", "template", "textarea", "tfoot", "th", "thead", "time", "tr", "track", "tt", "u", "ul", "var", "video", "wbr"]), Xe = R(["svg", "a", "altglyph", "altglyphdef", "altglyphitem", "animatecolor", "animatemotion", "animatetransform", "circle", "clippath", "defs", "desc", "ellipse", "enterkeyhint", "exportparts", "filter", "font", "g", "glyph", "glyphref", "hkern", "image", "inputmode", "line", "lineargradient", "marker", "mask", "metadata", "mpath", "part", "path", "pattern", "polygon", "polyline", "radialgradient", "rect", "stop", "style", "switch", "symbol", "text", "textpath", "title", "tref", "tspan", "view", "vkern"]), Ze = R(["feBlend", "feColorMatrix", "feComponentTransfer", "feComposite", "feConvolveMatrix", "feDiffuseLighting", "feDisplacementMap", "feDistantLight", "feDropShadow", "feFlood", "feFuncA", "feFuncB", "feFuncG", "feFuncR", "feGaussianBlur", "feImage", "feMerge", "feMergeNode", "feMorphology", "feOffset", "fePointLight", "feSpecularLighting", "feSpotLight", "feTile", "feTurbulence"]), Sn = R(["animate", "color-profile", "cursor", "discard", "font-face", "font-face-format", "font-face-name", "font-face-src", "font-face-uri", "foreignobject", "hatch", "hatchpath", "mesh", "meshgradient", "meshpatch", "meshrow", "missing-glyph", "script", "set", "solidcolor", "unknown", "use"]), Ke = R(["math", "menclose", "merror", "mfenced", "mfrac", "mglyph", "mi", "mlabeledtr", "mmultiscripts", "mn", "mo", "mover", "mpadded", "mphantom", "mroot", "mrow", "ms", "mspace", "msqrt", "mstyle", "msub", "msup", "msubsup", "mtable", "mtd", "mtext", "mtr", "munder", "munderover", "mprescripts"]), xn = R(["maction", "maligngroup", "malignmark", "mlongdiv", "mscarries", "mscarry", "msgroup", "mstack", "msline", "msrow", "semantics", "annotation", "annotation-xml", "mprescripts", "none"]), Mt = R(["#text"]), Nt = R(["accept", "action", "align", "alt", "autocapitalize", "autocomplete", "autopictureinpicture", "autoplay", "background", "bgcolor", "border", "capture", "cellpadding", "cellspacing", "checked", "cite", "class", "clear", "color", "cols", "colspan", "controls", "controlslist", "coords", "crossorigin", "datetime", "decoding", "default", "dir", "disabled", "disablepictureinpicture", "disableremoteplayback", "download", "draggable", "enctype", "enterkeyhint", "exportparts", "face", "for", "headers", "height", "hidden", "high", "href", "hreflang", "id", "inert", "inputmode", "integrity", "ismap", "kind", "label", "lang", "list", "loading", "loop", "low", "max", "maxlength", "media", "method", "min", "minlength", "multiple", "muted", "name", "nonce", "noshade", "novalidate", "nowrap", "open", "optimum", "part", "pattern", "placeholder", "playsinline", "popover", "popovertarget", "popovertargetaction", "poster", "preload", "pubdate", "radiogroup", "readonly", "rel", "required", "rev", "reversed", "role", "rows", "rowspan", "spellcheck", "scope", "selected", "shape", "size", "sizes", "slot", "span", "srclang", "start", "src", "srcset", "step", "style", "summary", "tabindex", "title", "translate", "type", "usemap", "valign", "value", "width", "wrap", "xmlns", "slot"]), Qe = R(["accent-height", "accumulate", "additive", "alignment-baseline", "amplitude", "ascent", "attributename", "attributetype", "azimuth", "basefrequency", "baseline-shift", "begin", "bias", "by", "class", "clip", "clippathunits", "clip-path", "clip-rule", "color", "color-interpolation", "color-interpolation-filters", "color-profile", "color-rendering", "cx", "cy", "d", "dx", "dy", "diffuseconstant", "direction", "display", "divisor", "dur", "edgemode", "elevation", "end", "exponent", "fill", "fill-opacity", "fill-rule", "filter", "filterunits", "flood-color", "flood-opacity", "font-family", "font-size", "font-size-adjust", "font-stretch", "font-style", "font-variant", "font-weight", "fx", "fy", "g1", "g2", "glyph-name", "glyphref", "gradientunits", "gradienttransform", "height", "href", "id", "image-rendering", "in", "in2", "intercept", "k", "k1", "k2", "k3", "k4", "kerning", "keypoints", "keysplines", "keytimes", "lang", "lengthadjust", "letter-spacing", "kernelmatrix", "kernelunitlength", "lighting-color", "local", "marker-end", "marker-mid", "marker-start", "markerheight", "markerunits", "markerwidth", "maskcontentunits", "maskunits", "max", "mask", "mask-type", "media", "method", "mode", "min", "name", "numoctaves", "offset", "operator", "opacity", "order", "orient", "orientation", "origin", "overflow", "paint-order", "path", "pathlength", "patterncontentunits", "patterntransform", "patternunits", "points", "preservealpha", "preserveaspectratio", "primitiveunits", "r", "rx", "ry", "radius", "refx", "refy", "repeatcount", "repeatdur", "restart", "result", "rotate", "scale", "seed", "shape-rendering", "slope", "specularconstant", "specularexponent", "spreadmethod", "startoffset", "stddeviation", "stitchtiles", "stop-color", "stop-opacity", "stroke-dasharray", "stroke-dashoffset", "stroke-linecap", "stroke-linejoin", "stroke-miterlimit", "stroke-opacity", "stroke", "stroke-width", "style", "surfacescale", "systemlanguage", "tabindex", "tablevalues", "targetx", "targety", "transform", "transform-origin", "text-anchor", "text-decoration", "text-rendering", "textlength", "type", "u1", "u2", "unicode", "values", "viewbox", "visibility", "version", "vert-adv-y", "vert-origin-x", "vert-origin-y", "width", "word-spacing", "wrap", "writing-mode", "xchannelselector", "ychannelselector", "x", "x1", "x2", "xmlns", "y", "y1", "y2", "z", "zoomandpan"]), It = R(["accent", "accentunder", "align", "bevelled", "close", "columnsalign", "columnlines", "columnspan", "denomalign", "depth", "dir", "display", "displaystyle", "encoding", "fence", "frame", "height", "href", "id", "largeop", "length", "linethickness", "lspace", "lquote", "mathbackground", "mathcolor", "mathsize", "mathvariant", "maxsize", "minsize", "movablelimits", "notation", "numalign", "open", "rowalign", "rowlines", "rowspacing", "rowspan", "rspace", "rquote", "scriptlevel", "scriptminsize", "scriptsizemultiplier", "selection", "separator", "separators", "stretchy", "subscriptshift", "supscriptshift", "symmetric", "voffset", "width", "xmlns"]), Le = R(["xlink:href", "xml:id", "xlink:title", "xml:space", "xmlns:xlink"]), Rn = O(/\{\{[\w\W]*|[\w\W]*\}\}/gm), Ln = O(/<%[\w\W]*|[\w\W]*%>/gm), Dn = O(/\$\{[\w\W]*/gm), wn = O(/^data-[\-\w.\u00B7-\uFFFF]+$/), Cn = O(/^aria-[\-\w]+$/), Ut = O(
|
|
90
|
+
/^(?:(?:(?:f|ht)tps?|mailto|tel|callto|sms|cid|xmpp|matrix):|[^a-z]|[a-z+.\-]+(?:[^a-z+.\-:]|$))/i
|
|
91
|
+
// eslint-disable-line no-useless-escape
|
|
92
|
+
), On = O(/^(?:\w+script|data):/i), Mn = O(
|
|
93
|
+
/[\u0000-\u0020\u00A0\u1680\u180E\u2000-\u2029\u205F\u3000]/g
|
|
94
|
+
// eslint-disable-line no-control-regex
|
|
95
|
+
), zt = O(/^html$/i), Nn = O(/^[a-z][.\w]*(-[.\w]+)+$/i);
|
|
96
|
+
var kt = /* @__PURE__ */ Object.freeze({
|
|
97
|
+
__proto__: null,
|
|
98
|
+
ARIA_ATTR: Cn,
|
|
99
|
+
ATTR_WHITESPACE: Mn,
|
|
100
|
+
CUSTOM_ELEMENT: Nn,
|
|
101
|
+
DATA_ATTR: wn,
|
|
102
|
+
DOCTYPE_NAME: zt,
|
|
103
|
+
ERB_EXPR: Ln,
|
|
104
|
+
IS_ALLOWED_URI: Ut,
|
|
105
|
+
IS_SCRIPT_OR_DATA: On,
|
|
106
|
+
MUSTACHE_EXPR: Rn,
|
|
107
|
+
TMPLIT_EXPR: Dn
|
|
108
|
+
});
|
|
109
|
+
const de = {
|
|
110
|
+
element: 1,
|
|
111
|
+
text: 3,
|
|
112
|
+
// Deprecated
|
|
113
|
+
progressingInstruction: 7,
|
|
114
|
+
comment: 8,
|
|
115
|
+
document: 9
|
|
116
|
+
}, In = function() {
|
|
117
|
+
return typeof window > "u" ? null : window;
|
|
118
|
+
}, kn = function(t, o) {
|
|
119
|
+
if (typeof t != "object" || typeof t.createPolicy != "function")
|
|
120
|
+
return null;
|
|
121
|
+
let l = null;
|
|
122
|
+
const c = "data-tt-policy-suffix";
|
|
123
|
+
o && o.hasAttribute(c) && (l = o.getAttribute(c));
|
|
124
|
+
const f = "dompurify" + (l ? "#" + l : "");
|
|
125
|
+
try {
|
|
126
|
+
return t.createPolicy(f, {
|
|
127
|
+
createHTML(w) {
|
|
128
|
+
return w;
|
|
129
|
+
},
|
|
130
|
+
createScriptURL(w) {
|
|
131
|
+
return w;
|
|
132
|
+
}
|
|
133
|
+
});
|
|
134
|
+
} catch {
|
|
135
|
+
return console.warn("TrustedTypes policy " + f + " could not be created."), null;
|
|
136
|
+
}
|
|
137
|
+
}, Pt = function() {
|
|
138
|
+
return {
|
|
139
|
+
afterSanitizeAttributes: [],
|
|
140
|
+
afterSanitizeElements: [],
|
|
141
|
+
afterSanitizeShadowDOM: [],
|
|
142
|
+
beforeSanitizeAttributes: [],
|
|
143
|
+
beforeSanitizeElements: [],
|
|
144
|
+
beforeSanitizeShadowDOM: [],
|
|
145
|
+
uponSanitizeAttribute: [],
|
|
146
|
+
uponSanitizeElement: [],
|
|
147
|
+
uponSanitizeShadowNode: []
|
|
148
|
+
};
|
|
149
|
+
};
|
|
150
|
+
function Bt() {
|
|
151
|
+
let n = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : In();
|
|
152
|
+
const t = (i) => Bt(i);
|
|
153
|
+
if (t.version = "3.3.2", t.removed = [], !n || !n.document || n.document.nodeType !== de.document || !n.Element)
|
|
154
|
+
return t.isSupported = !1, t;
|
|
155
|
+
let {
|
|
156
|
+
document: o
|
|
157
|
+
} = n;
|
|
158
|
+
const l = o, c = l.currentScript, {
|
|
159
|
+
DocumentFragment: f,
|
|
160
|
+
HTMLTemplateElement: w,
|
|
161
|
+
Node: z,
|
|
162
|
+
Element: b,
|
|
163
|
+
NodeFilter: E,
|
|
164
|
+
NamedNodeMap: W = n.NamedNodeMap || n.MozNamedAttrMap,
|
|
165
|
+
HTMLFormElement: j,
|
|
166
|
+
DOMParser: Oe,
|
|
167
|
+
trustedTypes: he
|
|
168
|
+
} = n, re = b.prototype, qt = pe(re, "cloneNode"), Xt = pe(re, "remove"), Zt = pe(re, "nextSibling"), Kt = pe(re, "childNodes"), Te = pe(re, "parentNode");
|
|
169
|
+
if (typeof w == "function") {
|
|
170
|
+
const i = o.createElement("template");
|
|
171
|
+
i.content && i.content.ownerDocument && (o = i.content.ownerDocument);
|
|
172
|
+
}
|
|
173
|
+
let v, oe = "";
|
|
174
|
+
const {
|
|
175
|
+
implementation: Me,
|
|
176
|
+
createNodeIterator: Qt,
|
|
177
|
+
createDocumentFragment: Jt,
|
|
178
|
+
getElementsByTagName: en
|
|
179
|
+
} = o, {
|
|
180
|
+
importNode: tn
|
|
181
|
+
} = l;
|
|
182
|
+
let S = Pt();
|
|
183
|
+
t.isSupported = typeof Ht == "function" && typeof Te == "function" && Me && Me.createHTMLDocument !== void 0;
|
|
184
|
+
const {
|
|
185
|
+
MUSTACHE_EXPR: Ne,
|
|
186
|
+
ERB_EXPR: Ie,
|
|
187
|
+
TMPLIT_EXPR: ke,
|
|
188
|
+
DATA_ATTR: nn,
|
|
189
|
+
ARIA_ATTR: rn,
|
|
190
|
+
IS_SCRIPT_OR_DATA: on,
|
|
191
|
+
ATTR_WHITESPACE: at,
|
|
192
|
+
CUSTOM_ELEMENT: an
|
|
193
|
+
} = kt;
|
|
194
|
+
let {
|
|
195
|
+
IS_ALLOWED_URI: it
|
|
196
|
+
} = kt, h = null;
|
|
197
|
+
const lt = s({}, [...Ot, ...Xe, ...Ze, ...Ke, ...Mt]);
|
|
198
|
+
let A = null;
|
|
199
|
+
const st = s({}, [...Nt, ...Qe, ...It, ...Le]);
|
|
200
|
+
let p = Object.seal(De(null, {
|
|
201
|
+
tagNameCheck: {
|
|
202
|
+
writable: !0,
|
|
203
|
+
configurable: !1,
|
|
204
|
+
enumerable: !0,
|
|
205
|
+
value: null
|
|
206
|
+
},
|
|
207
|
+
attributeNameCheck: {
|
|
208
|
+
writable: !0,
|
|
209
|
+
configurable: !1,
|
|
210
|
+
enumerable: !0,
|
|
211
|
+
value: null
|
|
212
|
+
},
|
|
213
|
+
allowCustomizedBuiltInElements: {
|
|
214
|
+
writable: !0,
|
|
215
|
+
configurable: !1,
|
|
216
|
+
enumerable: !0,
|
|
217
|
+
value: !1
|
|
218
|
+
}
|
|
219
|
+
})), ae = null, be = null;
|
|
220
|
+
const B = Object.seal(De(null, {
|
|
221
|
+
tagCheck: {
|
|
222
|
+
writable: !0,
|
|
223
|
+
configurable: !1,
|
|
224
|
+
enumerable: !0,
|
|
225
|
+
value: null
|
|
226
|
+
},
|
|
227
|
+
attributeCheck: {
|
|
228
|
+
writable: !0,
|
|
229
|
+
configurable: !1,
|
|
230
|
+
enumerable: !0,
|
|
231
|
+
value: null
|
|
232
|
+
}
|
|
233
|
+
}));
|
|
234
|
+
let ct = !0, Pe = !0, ut = !1, pt = !0, $ = !1, Ee = !0, V = !1, Fe = !1, He = !1, q = !1, Ae = !1, _e = !1, dt = !0, mt = !1;
|
|
235
|
+
const ln = "user-content-";
|
|
236
|
+
let Ue = !0, ie = !1, X = {}, M = null;
|
|
237
|
+
const ze = s({}, ["annotation-xml", "audio", "colgroup", "desc", "foreignobject", "head", "iframe", "math", "mi", "mn", "mo", "ms", "mtext", "noembed", "noframes", "noscript", "plaintext", "script", "style", "svg", "template", "thead", "title", "video", "xmp"]);
|
|
238
|
+
let ft = null;
|
|
239
|
+
const gt = s({}, ["audio", "video", "img", "source", "image", "track"]);
|
|
240
|
+
let Be = null;
|
|
241
|
+
const ht = s({}, ["alt", "class", "for", "id", "label", "name", "pattern", "placeholder", "role", "summary", "title", "value", "style", "xmlns"]), ye = "http://www.w3.org/1998/Math/MathML", ve = "http://www.w3.org/2000/svg", F = "http://www.w3.org/1999/xhtml";
|
|
242
|
+
let Z = F, Ge = !1, We = null;
|
|
243
|
+
const sn = s({}, [ye, ve, F], $e);
|
|
244
|
+
let Se = s({}, ["mi", "mo", "mn", "ms", "mtext"]), xe = s({}, ["annotation-xml"]);
|
|
245
|
+
const cn = s({}, ["title", "style", "font", "a", "script"]);
|
|
246
|
+
let le = null;
|
|
247
|
+
const un = ["application/xhtml+xml", "text/html"], pn = "text/html";
|
|
248
|
+
let g = null, K = null;
|
|
249
|
+
const dn = o.createElement("form"), Tt = function(e) {
|
|
250
|
+
return e instanceof RegExp || e instanceof Function;
|
|
251
|
+
}, je = function() {
|
|
252
|
+
let e = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : {};
|
|
253
|
+
if (!(K && K === e)) {
|
|
254
|
+
if ((!e || typeof e != "object") && (e = {}), e = I(e), le = // eslint-disable-next-line unicorn/prefer-includes
|
|
255
|
+
un.indexOf(e.PARSER_MEDIA_TYPE) === -1 ? pn : e.PARSER_MEDIA_TYPE, g = le === "application/xhtml+xml" ? $e : we, h = C(e, "ALLOWED_TAGS") ? s({}, e.ALLOWED_TAGS, g) : lt, A = C(e, "ALLOWED_ATTR") ? s({}, e.ALLOWED_ATTR, g) : st, We = C(e, "ALLOWED_NAMESPACES") ? s({}, e.ALLOWED_NAMESPACES, $e) : sn, Be = C(e, "ADD_URI_SAFE_ATTR") ? s(I(ht), e.ADD_URI_SAFE_ATTR, g) : ht, ft = C(e, "ADD_DATA_URI_TAGS") ? s(I(gt), e.ADD_DATA_URI_TAGS, g) : gt, M = C(e, "FORBID_CONTENTS") ? s({}, e.FORBID_CONTENTS, g) : ze, ae = C(e, "FORBID_TAGS") ? s({}, e.FORBID_TAGS, g) : I({}), be = C(e, "FORBID_ATTR") ? s({}, e.FORBID_ATTR, g) : I({}), X = C(e, "USE_PROFILES") ? e.USE_PROFILES : !1, ct = e.ALLOW_ARIA_ATTR !== !1, Pe = e.ALLOW_DATA_ATTR !== !1, ut = e.ALLOW_UNKNOWN_PROTOCOLS || !1, pt = e.ALLOW_SELF_CLOSE_IN_ATTR !== !1, $ = e.SAFE_FOR_TEMPLATES || !1, Ee = e.SAFE_FOR_XML !== !1, V = e.WHOLE_DOCUMENT || !1, q = e.RETURN_DOM || !1, Ae = e.RETURN_DOM_FRAGMENT || !1, _e = e.RETURN_TRUSTED_TYPE || !1, He = e.FORCE_BODY || !1, dt = e.SANITIZE_DOM !== !1, mt = e.SANITIZE_NAMED_PROPS || !1, Ue = e.KEEP_CONTENT !== !1, ie = e.IN_PLACE || !1, it = e.ALLOWED_URI_REGEXP || Ut, Z = e.NAMESPACE || F, Se = e.MATHML_TEXT_INTEGRATION_POINTS || Se, xe = e.HTML_INTEGRATION_POINTS || xe, p = e.CUSTOM_ELEMENT_HANDLING || {}, e.CUSTOM_ELEMENT_HANDLING && Tt(e.CUSTOM_ELEMENT_HANDLING.tagNameCheck) && (p.tagNameCheck = e.CUSTOM_ELEMENT_HANDLING.tagNameCheck), e.CUSTOM_ELEMENT_HANDLING && Tt(e.CUSTOM_ELEMENT_HANDLING.attributeNameCheck) && (p.attributeNameCheck = e.CUSTOM_ELEMENT_HANDLING.attributeNameCheck), e.CUSTOM_ELEMENT_HANDLING && typeof e.CUSTOM_ELEMENT_HANDLING.allowCustomizedBuiltInElements == "boolean" && (p.allowCustomizedBuiltInElements = e.CUSTOM_ELEMENT_HANDLING.allowCustomizedBuiltInElements), $ && (Pe = !1), Ae && (q = !0), X && (h = s({}, Mt), A = De(null), X.html === !0 && (s(h, Ot), s(A, Nt)), X.svg === !0 && (s(h, Xe), s(A, Qe), s(A, Le)), X.svgFilters === !0 && (s(h, Ze), s(A, Qe), s(A, Le)), X.mathMl === !0 && (s(h, Ke), s(A, It), s(A, Le))), C(e, "ADD_TAGS") || (B.tagCheck = null), C(e, "ADD_ATTR") || (B.attributeCheck = null), e.ADD_TAGS && (typeof e.ADD_TAGS == "function" ? B.tagCheck = e.ADD_TAGS : (h === lt && (h = I(h)), s(h, e.ADD_TAGS, g))), e.ADD_ATTR && (typeof e.ADD_ATTR == "function" ? B.attributeCheck = e.ADD_ATTR : (A === st && (A = I(A)), s(A, e.ADD_ATTR, g))), e.ADD_URI_SAFE_ATTR && s(Be, e.ADD_URI_SAFE_ATTR, g), e.FORBID_CONTENTS && (M === ze && (M = I(M)), s(M, e.FORBID_CONTENTS, g)), e.ADD_FORBID_CONTENTS && (M === ze && (M = I(M)), s(M, e.ADD_FORBID_CONTENTS, g)), Ue && (h["#text"] = !0), V && s(h, ["html", "head", "body"]), h.table && (s(h, ["tbody"]), delete ae.tbody), e.TRUSTED_TYPES_POLICY) {
|
|
256
|
+
if (typeof e.TRUSTED_TYPES_POLICY.createHTML != "function")
|
|
257
|
+
throw ue('TRUSTED_TYPES_POLICY configuration option must provide a "createHTML" hook.');
|
|
258
|
+
if (typeof e.TRUSTED_TYPES_POLICY.createScriptURL != "function")
|
|
259
|
+
throw ue('TRUSTED_TYPES_POLICY configuration option must provide a "createScriptURL" hook.');
|
|
260
|
+
v = e.TRUSTED_TYPES_POLICY, oe = v.createHTML("");
|
|
261
|
+
} else
|
|
262
|
+
v === void 0 && (v = kn(he, c)), v !== null && typeof oe == "string" && (oe = v.createHTML(""));
|
|
263
|
+
R && R(e), K = e;
|
|
264
|
+
}
|
|
265
|
+
}, bt = s({}, [...Xe, ...Ze, ...Sn]), Et = s({}, [...Ke, ...xn]), mn = function(e) {
|
|
266
|
+
let r = Te(e);
|
|
267
|
+
(!r || !r.tagName) && (r = {
|
|
268
|
+
namespaceURI: Z,
|
|
269
|
+
tagName: "template"
|
|
270
|
+
});
|
|
271
|
+
const a = we(e.tagName), u = we(r.tagName);
|
|
272
|
+
return We[e.namespaceURI] ? e.namespaceURI === ve ? r.namespaceURI === F ? a === "svg" : r.namespaceURI === ye ? a === "svg" && (u === "annotation-xml" || Se[u]) : !!bt[a] : e.namespaceURI === ye ? r.namespaceURI === F ? a === "math" : r.namespaceURI === ve ? a === "math" && xe[u] : !!Et[a] : e.namespaceURI === F ? r.namespaceURI === ve && !xe[u] || r.namespaceURI === ye && !Se[u] ? !1 : !Et[a] && (cn[a] || !bt[a]) : !!(le === "application/xhtml+xml" && We[e.namespaceURI]) : !1;
|
|
273
|
+
}, N = function(e) {
|
|
274
|
+
se(t.removed, {
|
|
275
|
+
element: e
|
|
276
|
+
});
|
|
277
|
+
try {
|
|
278
|
+
Te(e).removeChild(e);
|
|
279
|
+
} catch {
|
|
280
|
+
Xt(e);
|
|
281
|
+
}
|
|
282
|
+
}, Y = function(e, r) {
|
|
7
283
|
try {
|
|
8
|
-
|
|
284
|
+
se(t.removed, {
|
|
285
|
+
attribute: r.getAttributeNode(e),
|
|
286
|
+
from: r
|
|
287
|
+
});
|
|
9
288
|
} catch {
|
|
289
|
+
se(t.removed, {
|
|
290
|
+
attribute: null,
|
|
291
|
+
from: r
|
|
292
|
+
});
|
|
293
|
+
}
|
|
294
|
+
if (r.removeAttribute(e), e === "is")
|
|
295
|
+
if (q || Ae)
|
|
296
|
+
try {
|
|
297
|
+
N(r);
|
|
298
|
+
} catch {
|
|
299
|
+
}
|
|
300
|
+
else
|
|
301
|
+
try {
|
|
302
|
+
r.setAttribute(e, "");
|
|
303
|
+
} catch {
|
|
304
|
+
}
|
|
305
|
+
}, At = function(e) {
|
|
306
|
+
let r = null, a = null;
|
|
307
|
+
if (He)
|
|
308
|
+
e = "<remove></remove>" + e;
|
|
309
|
+
else {
|
|
310
|
+
const d = qe(e, /^[\r\n\t ]+/);
|
|
311
|
+
a = d && d[0];
|
|
312
|
+
}
|
|
313
|
+
le === "application/xhtml+xml" && Z === F && (e = '<html xmlns="http://www.w3.org/1999/xhtml"><head></head><body>' + e + "</body></html>");
|
|
314
|
+
const u = v ? v.createHTML(e) : e;
|
|
315
|
+
if (Z === F)
|
|
316
|
+
try {
|
|
317
|
+
r = new Oe().parseFromString(u, le);
|
|
318
|
+
} catch {
|
|
319
|
+
}
|
|
320
|
+
if (!r || !r.documentElement) {
|
|
321
|
+
r = Me.createDocument(Z, "template", null);
|
|
322
|
+
try {
|
|
323
|
+
r.documentElement.innerHTML = Ge ? oe : u;
|
|
324
|
+
} catch {
|
|
325
|
+
}
|
|
326
|
+
}
|
|
327
|
+
const y = r.body || r.documentElement;
|
|
328
|
+
return e && a && y.insertBefore(o.createTextNode(a), y.childNodes[0] || null), Z === F ? en.call(r, V ? "html" : "body")[0] : V ? r.documentElement : y;
|
|
329
|
+
}, _t = function(e) {
|
|
330
|
+
return Qt.call(
|
|
331
|
+
e.ownerDocument || e,
|
|
332
|
+
e,
|
|
333
|
+
// eslint-disable-next-line no-bitwise
|
|
334
|
+
E.SHOW_ELEMENT | E.SHOW_COMMENT | E.SHOW_TEXT | E.SHOW_PROCESSING_INSTRUCTION | E.SHOW_CDATA_SECTION,
|
|
335
|
+
null
|
|
336
|
+
);
|
|
337
|
+
}, Ve = function(e) {
|
|
338
|
+
return e instanceof j && (typeof e.nodeName != "string" || typeof e.textContent != "string" || typeof e.removeChild != "function" || !(e.attributes instanceof W) || typeof e.removeAttribute != "function" || typeof e.setAttribute != "function" || typeof e.namespaceURI != "string" || typeof e.insertBefore != "function" || typeof e.hasChildNodes != "function");
|
|
339
|
+
}, yt = function(e) {
|
|
340
|
+
return typeof z == "function" && e instanceof z;
|
|
341
|
+
};
|
|
342
|
+
function H(i, e, r) {
|
|
343
|
+
Re(i, (a) => {
|
|
344
|
+
a.call(t, e, r, K);
|
|
345
|
+
});
|
|
346
|
+
}
|
|
347
|
+
const vt = function(e) {
|
|
348
|
+
let r = null;
|
|
349
|
+
if (H(S.beforeSanitizeElements, e, null), Ve(e))
|
|
350
|
+
return N(e), !0;
|
|
351
|
+
const a = g(e.nodeName);
|
|
352
|
+
if (H(S.uponSanitizeElement, e, {
|
|
353
|
+
tagName: a,
|
|
354
|
+
allowedTags: h
|
|
355
|
+
}), Ee && e.hasChildNodes() && !yt(e.firstElementChild) && x(/<[/\w!]/g, e.innerHTML) && x(/<[/\w!]/g, e.textContent) || e.nodeType === de.progressingInstruction || Ee && e.nodeType === de.comment && x(/<[/\w]/g, e.data))
|
|
356
|
+
return N(e), !0;
|
|
357
|
+
if (!(B.tagCheck instanceof Function && B.tagCheck(a)) && (!h[a] || ae[a])) {
|
|
358
|
+
if (!ae[a] && xt(a) && (p.tagNameCheck instanceof RegExp && x(p.tagNameCheck, a) || p.tagNameCheck instanceof Function && p.tagNameCheck(a)))
|
|
359
|
+
return !1;
|
|
360
|
+
if (Ue && !M[a]) {
|
|
361
|
+
const u = Te(e) || e.parentNode, y = Kt(e) || e.childNodes;
|
|
362
|
+
if (y && u) {
|
|
363
|
+
const d = y.length;
|
|
364
|
+
for (let D = d - 1; D >= 0; --D) {
|
|
365
|
+
const U = qt(y[D], !0);
|
|
366
|
+
U.__removalCount = (e.__removalCount || 0) + 1, u.insertBefore(U, Zt(e));
|
|
367
|
+
}
|
|
368
|
+
}
|
|
369
|
+
}
|
|
370
|
+
return N(e), !0;
|
|
371
|
+
}
|
|
372
|
+
return e instanceof b && !mn(e) || (a === "noscript" || a === "noembed" || a === "noframes") && x(/<\/no(script|embed|frames)/i, e.innerHTML) ? (N(e), !0) : ($ && e.nodeType === de.text && (r = e.textContent, Re([Ne, Ie, ke], (u) => {
|
|
373
|
+
r = ce(r, u, " ");
|
|
374
|
+
}), e.textContent !== r && (se(t.removed, {
|
|
375
|
+
element: e.cloneNode()
|
|
376
|
+
}), e.textContent = r)), H(S.afterSanitizeElements, e, null), !1);
|
|
377
|
+
}, St = function(e, r, a) {
|
|
378
|
+
if (be[r] || dt && (r === "id" || r === "name") && (a in o || a in dn))
|
|
379
|
+
return !1;
|
|
380
|
+
if (!(Pe && !be[r] && x(nn, r))) {
|
|
381
|
+
if (!(ct && x(rn, r))) {
|
|
382
|
+
if (!(B.attributeCheck instanceof Function && B.attributeCheck(r, e))) {
|
|
383
|
+
if (!A[r] || be[r]) {
|
|
384
|
+
if (
|
|
385
|
+
// First condition does a very basic check if a) it's basically a valid custom element tagname AND
|
|
386
|
+
// b) if the tagName passes whatever the user has configured for CUSTOM_ELEMENT_HANDLING.tagNameCheck
|
|
387
|
+
// and c) if the attribute name passes whatever the user has configured for CUSTOM_ELEMENT_HANDLING.attributeNameCheck
|
|
388
|
+
!(xt(e) && (p.tagNameCheck instanceof RegExp && x(p.tagNameCheck, e) || p.tagNameCheck instanceof Function && p.tagNameCheck(e)) && (p.attributeNameCheck instanceof RegExp && x(p.attributeNameCheck, r) || p.attributeNameCheck instanceof Function && p.attributeNameCheck(r, e)) || // Alternative, second condition checks if it's an `is`-attribute, AND
|
|
389
|
+
// the value passes whatever the user has configured for CUSTOM_ELEMENT_HANDLING.tagNameCheck
|
|
390
|
+
r === "is" && p.allowCustomizedBuiltInElements && (p.tagNameCheck instanceof RegExp && x(p.tagNameCheck, a) || p.tagNameCheck instanceof Function && p.tagNameCheck(a)))
|
|
391
|
+
) return !1;
|
|
392
|
+
} else if (!Be[r]) {
|
|
393
|
+
if (!x(it, ce(a, at, ""))) {
|
|
394
|
+
if (!((r === "src" || r === "xlink:href" || r === "href") && e !== "script" && An(a, "data:") === 0 && ft[e])) {
|
|
395
|
+
if (!(ut && !x(on, ce(a, at, "")))) {
|
|
396
|
+
if (a)
|
|
397
|
+
return !1;
|
|
398
|
+
}
|
|
399
|
+
}
|
|
400
|
+
}
|
|
401
|
+
}
|
|
402
|
+
}
|
|
403
|
+
}
|
|
10
404
|
}
|
|
405
|
+
return !0;
|
|
406
|
+
}, xt = function(e) {
|
|
407
|
+
return e !== "annotation-xml" && qe(e, an);
|
|
408
|
+
}, Rt = function(e) {
|
|
409
|
+
H(S.beforeSanitizeAttributes, e, null);
|
|
410
|
+
const {
|
|
411
|
+
attributes: r
|
|
412
|
+
} = e;
|
|
413
|
+
if (!r || Ve(e))
|
|
414
|
+
return;
|
|
415
|
+
const a = {
|
|
416
|
+
attrName: "",
|
|
417
|
+
attrValue: "",
|
|
418
|
+
keepAttr: !0,
|
|
419
|
+
allowedAttributes: A,
|
|
420
|
+
forceKeepAttr: void 0
|
|
421
|
+
};
|
|
422
|
+
let u = r.length;
|
|
423
|
+
for (; u--; ) {
|
|
424
|
+
const y = r[u], {
|
|
425
|
+
name: d,
|
|
426
|
+
namespaceURI: D,
|
|
427
|
+
value: U
|
|
428
|
+
} = y, Q = g(d), Ye = U;
|
|
429
|
+
let _ = d === "value" ? Ye : _n(Ye);
|
|
430
|
+
if (a.attrName = Q, a.attrValue = _, a.keepAttr = !0, a.forceKeepAttr = void 0, H(S.uponSanitizeAttribute, e, a), _ = a.attrValue, mt && (Q === "id" || Q === "name") && (Y(d, e), _ = ln + _), Ee && x(/((--!?|])>)|<\/(style|script|title|xmp|textarea|noscript|iframe|noembed|noframes)/i, _)) {
|
|
431
|
+
Y(d, e);
|
|
432
|
+
continue;
|
|
433
|
+
}
|
|
434
|
+
if (Q === "attributename" && qe(_, "href")) {
|
|
435
|
+
Y(d, e);
|
|
436
|
+
continue;
|
|
437
|
+
}
|
|
438
|
+
if (a.forceKeepAttr)
|
|
439
|
+
continue;
|
|
440
|
+
if (!a.keepAttr) {
|
|
441
|
+
Y(d, e);
|
|
442
|
+
continue;
|
|
443
|
+
}
|
|
444
|
+
if (!pt && x(/\/>/i, _)) {
|
|
445
|
+
Y(d, e);
|
|
446
|
+
continue;
|
|
447
|
+
}
|
|
448
|
+
$ && Re([Ne, Ie, ke], (Dt) => {
|
|
449
|
+
_ = ce(_, Dt, " ");
|
|
450
|
+
});
|
|
451
|
+
const Lt = g(e.nodeName);
|
|
452
|
+
if (!St(Lt, Q, _)) {
|
|
453
|
+
Y(d, e);
|
|
454
|
+
continue;
|
|
455
|
+
}
|
|
456
|
+
if (v && typeof he == "object" && typeof he.getAttributeType == "function" && !D)
|
|
457
|
+
switch (he.getAttributeType(Lt, Q)) {
|
|
458
|
+
case "TrustedHTML": {
|
|
459
|
+
_ = v.createHTML(_);
|
|
460
|
+
break;
|
|
461
|
+
}
|
|
462
|
+
case "TrustedScriptURL": {
|
|
463
|
+
_ = v.createScriptURL(_);
|
|
464
|
+
break;
|
|
465
|
+
}
|
|
466
|
+
}
|
|
467
|
+
if (_ !== Ye)
|
|
468
|
+
try {
|
|
469
|
+
D ? e.setAttributeNS(D, d, _) : e.setAttribute(d, _), Ve(e) ? N(e) : Ct(t.removed);
|
|
470
|
+
} catch {
|
|
471
|
+
Y(d, e);
|
|
472
|
+
}
|
|
473
|
+
}
|
|
474
|
+
H(S.afterSanitizeAttributes, e, null);
|
|
475
|
+
}, fn = function i(e) {
|
|
476
|
+
let r = null;
|
|
477
|
+
const a = _t(e);
|
|
478
|
+
for (H(S.beforeSanitizeShadowDOM, e, null); r = a.nextNode(); )
|
|
479
|
+
H(S.uponSanitizeShadowNode, r, null), vt(r), Rt(r), r.content instanceof f && i(r.content);
|
|
480
|
+
H(S.afterSanitizeShadowDOM, e, null);
|
|
481
|
+
};
|
|
482
|
+
return t.sanitize = function(i) {
|
|
483
|
+
let e = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : {}, r = null, a = null, u = null, y = null;
|
|
484
|
+
if (Ge = !i, Ge && (i = "<!-->"), typeof i != "string" && !yt(i))
|
|
485
|
+
if (typeof i.toString == "function") {
|
|
486
|
+
if (i = i.toString(), typeof i != "string")
|
|
487
|
+
throw ue("dirty is not a string, aborting");
|
|
488
|
+
} else
|
|
489
|
+
throw ue("toString is not a function");
|
|
490
|
+
if (!t.isSupported)
|
|
491
|
+
return i;
|
|
492
|
+
if (Fe || je(e), t.removed = [], typeof i == "string" && (ie = !1), ie) {
|
|
493
|
+
if (i.nodeName) {
|
|
494
|
+
const U = g(i.nodeName);
|
|
495
|
+
if (!h[U] || ae[U])
|
|
496
|
+
throw ue("root node is forbidden and cannot be sanitized in-place");
|
|
497
|
+
}
|
|
498
|
+
} else if (i instanceof z)
|
|
499
|
+
r = At("<!---->"), a = r.ownerDocument.importNode(i, !0), a.nodeType === de.element && a.nodeName === "BODY" || a.nodeName === "HTML" ? r = a : r.appendChild(a);
|
|
500
|
+
else {
|
|
501
|
+
if (!q && !$ && !V && // eslint-disable-next-line unicorn/prefer-includes
|
|
502
|
+
i.indexOf("<") === -1)
|
|
503
|
+
return v && _e ? v.createHTML(i) : i;
|
|
504
|
+
if (r = At(i), !r)
|
|
505
|
+
return q ? null : _e ? oe : "";
|
|
506
|
+
}
|
|
507
|
+
r && He && N(r.firstChild);
|
|
508
|
+
const d = _t(ie ? i : r);
|
|
509
|
+
for (; u = d.nextNode(); )
|
|
510
|
+
vt(u), Rt(u), u.content instanceof f && fn(u.content);
|
|
511
|
+
if (ie)
|
|
512
|
+
return i;
|
|
513
|
+
if (q) {
|
|
514
|
+
if (Ae)
|
|
515
|
+
for (y = Jt.call(r.ownerDocument); r.firstChild; )
|
|
516
|
+
y.appendChild(r.firstChild);
|
|
517
|
+
else
|
|
518
|
+
y = r;
|
|
519
|
+
return (A.shadowroot || A.shadowrootmode) && (y = tn.call(l, y, !0)), y;
|
|
520
|
+
}
|
|
521
|
+
let D = V ? r.outerHTML : r.innerHTML;
|
|
522
|
+
return V && h["!doctype"] && r.ownerDocument && r.ownerDocument.doctype && r.ownerDocument.doctype.name && x(zt, r.ownerDocument.doctype.name) && (D = "<!DOCTYPE " + r.ownerDocument.doctype.name + `>
|
|
523
|
+
` + D), $ && Re([Ne, Ie, ke], (U) => {
|
|
524
|
+
D = ce(D, U, " ");
|
|
525
|
+
}), v && _e ? v.createHTML(D) : D;
|
|
526
|
+
}, t.setConfig = function() {
|
|
527
|
+
let i = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : {};
|
|
528
|
+
je(i), Fe = !0;
|
|
529
|
+
}, t.clearConfig = function() {
|
|
530
|
+
K = null, Fe = !1;
|
|
531
|
+
}, t.isValidAttribute = function(i, e, r) {
|
|
532
|
+
K || je({});
|
|
533
|
+
const a = g(i), u = g(e);
|
|
534
|
+
return St(a, u, r);
|
|
535
|
+
}, t.addHook = function(i, e) {
|
|
536
|
+
typeof e == "function" && se(S[i], e);
|
|
537
|
+
}, t.removeHook = function(i, e) {
|
|
538
|
+
if (e !== void 0) {
|
|
539
|
+
const r = bn(S[i], e);
|
|
540
|
+
return r === -1 ? void 0 : En(S[i], r, 1)[0];
|
|
541
|
+
}
|
|
542
|
+
return Ct(S[i]);
|
|
543
|
+
}, t.removeHooks = function(i) {
|
|
544
|
+
S[i] = [];
|
|
545
|
+
}, t.removeAllHooks = function() {
|
|
546
|
+
S = Pt();
|
|
547
|
+
}, t;
|
|
11
548
|
}
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
}
|
|
21
|
-
|
|
549
|
+
var Pn = Bt();
|
|
550
|
+
let m = null, P = null, J = null, T = null, ee = "", te = "", me = "insert", fe = null, k = null, Ce = null;
|
|
551
|
+
function Gt(n, t) {
|
|
552
|
+
if (t === n.innerHTML) return;
|
|
553
|
+
const o = window.execEditorCommand || window.executeEditorCommand;
|
|
554
|
+
if (typeof o == "function")
|
|
555
|
+
try {
|
|
556
|
+
o("recordDomTransaction", n, t, n.innerHTML);
|
|
557
|
+
} catch {
|
|
558
|
+
}
|
|
559
|
+
}
|
|
560
|
+
function Fn(n) {
|
|
561
|
+
if (!n) return null;
|
|
562
|
+
let t = n.startContainer;
|
|
563
|
+
for (; t && t !== document.body; ) {
|
|
564
|
+
if (t.nodeType === Node.ELEMENT_NODE) {
|
|
565
|
+
const o = t;
|
|
566
|
+
if (o.getAttribute("contenteditable") === "true")
|
|
567
|
+
return o;
|
|
568
|
+
}
|
|
569
|
+
t = t.parentNode;
|
|
22
570
|
}
|
|
23
571
|
return null;
|
|
24
572
|
}
|
|
25
|
-
const
|
|
573
|
+
const Hn = [
|
|
26
574
|
{
|
|
27
575
|
id: "formal-letter",
|
|
28
576
|
name: "Formal Letter",
|
|
@@ -94,54 +642,54 @@ const z = [
|
|
|
94
642
|
<p>A: [Answer here]</p>`
|
|
95
643
|
}
|
|
96
644
|
];
|
|
97
|
-
let
|
|
98
|
-
const
|
|
99
|
-
const
|
|
100
|
-
return Array.from(
|
|
101
|
-
},
|
|
102
|
-
const
|
|
103
|
-
return
|
|
104
|
-
(
|
|
645
|
+
let ne = [...Hn];
|
|
646
|
+
const Wt = () => ne, Zn = (n) => ne.filter((t) => t.category === n), jt = () => {
|
|
647
|
+
const n = new Set(ne.map((t) => t.category));
|
|
648
|
+
return Array.from(n);
|
|
649
|
+
}, Un = (n) => {
|
|
650
|
+
const t = n.toLowerCase();
|
|
651
|
+
return ne.filter(
|
|
652
|
+
(o) => o.name.toLowerCase().includes(t) || o.description?.toLowerCase().includes(t) || o.tags?.some((l) => l.toLowerCase().includes(t))
|
|
105
653
|
);
|
|
106
|
-
},
|
|
654
|
+
}, Vt = (n) => Pn.sanitize(n, {
|
|
107
655
|
ALLOWED_TAGS: ["p", "br", "strong", "em", "u", "h1", "h2", "h3", "h4", "ul", "ol", "li", "blockquote", "table", "thead", "tbody", "tr", "th", "td", "a", "span"],
|
|
108
656
|
ALLOWED_ATTR: ["href", "target", "class", "data-key", "data-category"]
|
|
109
|
-
}),
|
|
110
|
-
function
|
|
111
|
-
|
|
112
|
-
const
|
|
113
|
-
|
|
657
|
+
}), Kn = (n) => ne.some((t) => t.id === n.id) ? (console.warn(`Template with ID ${n.id} already exists`), !1) : (ne.push(n), !0), Qn = (n) => !!(n.id && n.name && n.category && n.html && n.html.trim().length > 0);
|
|
658
|
+
function zn(n) {
|
|
659
|
+
P = document.createElement("div"), P.className = "rte-dialog-overlay", Wn(n) && P.classList.add("rte-ui-theme-dark"), P.addEventListener("click", () => G()), m = document.createElement("div"), m.className = "rte-dialog rte-template-dialog", m.addEventListener("click", (o) => o.stopPropagation());
|
|
660
|
+
const t = jt();
|
|
661
|
+
t.length > 0 && !ee && (ee = t[0]), ge(), P.appendChild(m), document.body.appendChild(P), Bn(), Xn();
|
|
114
662
|
}
|
|
115
|
-
function
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
}, document.addEventListener("keydown",
|
|
663
|
+
function Bn() {
|
|
664
|
+
Yt(), fe = (n) => {
|
|
665
|
+
n.key === "Escape" && (!P || !m || (n.preventDefault(), n.stopPropagation(), G()));
|
|
666
|
+
}, document.addEventListener("keydown", fe, !0);
|
|
119
667
|
}
|
|
120
|
-
function
|
|
121
|
-
|
|
668
|
+
function Yt() {
|
|
669
|
+
fe && (document.removeEventListener("keydown", fe, !0), fe = null);
|
|
122
670
|
}
|
|
123
|
-
const
|
|
124
|
-
const
|
|
125
|
-
if (!
|
|
126
|
-
const
|
|
127
|
-
return (
|
|
671
|
+
const Gn = '[data-theme="dark"], .dark, .editora-theme-dark', nt = () => {
|
|
672
|
+
const n = window.getSelection();
|
|
673
|
+
if (!n || n.rangeCount === 0) return null;
|
|
674
|
+
const t = n.anchorNode;
|
|
675
|
+
return (t instanceof HTMLElement ? t : t?.parentElement)?.closest(
|
|
128
676
|
".rte-content, .editora-content"
|
|
129
677
|
) || null;
|
|
130
|
-
},
|
|
131
|
-
const
|
|
132
|
-
return
|
|
678
|
+
}, Wn = (n) => {
|
|
679
|
+
const t = n || nt();
|
|
680
|
+
return t ? !!t.closest(Gn) : !1;
|
|
133
681
|
};
|
|
134
|
-
function
|
|
135
|
-
const
|
|
136
|
-
if (
|
|
137
|
-
if (
|
|
138
|
-
const
|
|
139
|
-
return
|
|
682
|
+
function rt() {
|
|
683
|
+
const n = Fn(J);
|
|
684
|
+
if (n) return n;
|
|
685
|
+
if (Ce?.isConnected) return Ce;
|
|
686
|
+
const t = nt();
|
|
687
|
+
return t || document.querySelector(".rte-content, .editora-content");
|
|
140
688
|
}
|
|
141
|
-
function
|
|
142
|
-
if (!
|
|
143
|
-
const
|
|
144
|
-
|
|
689
|
+
function ge() {
|
|
690
|
+
if (!m) return;
|
|
691
|
+
const n = jt(), t = ot();
|
|
692
|
+
m.innerHTML = `
|
|
145
693
|
<div class="rte-dialog-header">
|
|
146
694
|
<h2>Insert Template</h2>
|
|
147
695
|
<button class="rte-dialog-close" aria-label="Close">✕</button>
|
|
@@ -152,49 +700,49 @@ function y() {
|
|
|
152
700
|
<input
|
|
153
701
|
type="text"
|
|
154
702
|
placeholder="Search templates..."
|
|
155
|
-
value="${
|
|
703
|
+
value="${te}"
|
|
156
704
|
class="rte-input rte-template-search"
|
|
157
705
|
aria-label="Search templates"
|
|
158
706
|
/>
|
|
159
707
|
|
|
160
708
|
<!-- Category Tabs -->
|
|
161
709
|
<div class="rte-tabs">
|
|
162
|
-
${
|
|
163
|
-
<button class="rte-tab ${
|
|
164
|
-
${
|
|
710
|
+
${n.map((o) => `
|
|
711
|
+
<button class="rte-tab ${ee === o ? "active" : ""}" data-category="${o}">
|
|
712
|
+
${o}
|
|
165
713
|
</button>
|
|
166
714
|
`).join("")}
|
|
167
715
|
</div>
|
|
168
716
|
|
|
169
717
|
<!-- Template List -->
|
|
170
718
|
<div class="rte-template-list">
|
|
171
|
-
${
|
|
719
|
+
${t.length > 0 ? t.map((o) => `
|
|
172
720
|
<div
|
|
173
|
-
class="rte-template-item ${
|
|
174
|
-
data-template-id="${
|
|
721
|
+
class="rte-template-item ${T?.id === o.id ? "selected" : ""}"
|
|
722
|
+
data-template-id="${o.id}"
|
|
175
723
|
>
|
|
176
|
-
<div class="template-name">${
|
|
177
|
-
${
|
|
724
|
+
<div class="template-name">${o.name}</div>
|
|
725
|
+
${o.description ? `<div class="template-description">${o.description}</div>` : ""}
|
|
178
726
|
</div>
|
|
179
727
|
`).join("") : '<div class="rte-empty-state">No templates found</div>'}
|
|
180
728
|
</div>
|
|
181
729
|
|
|
182
730
|
<!-- Preview -->
|
|
183
|
-
${
|
|
731
|
+
${T ? `
|
|
184
732
|
<div class="rte-template-preview">
|
|
185
733
|
<strong>Preview:</strong>
|
|
186
|
-
<div class="template-preview-content">${
|
|
734
|
+
<div class="template-preview-content">${T.html}</div>
|
|
187
735
|
</div>
|
|
188
736
|
` : ""}
|
|
189
737
|
|
|
190
738
|
<!-- Insert Mode Toggle -->
|
|
191
739
|
<div class="rte-insert-mode">
|
|
192
740
|
<label>
|
|
193
|
-
<input type="radio" name="insertMode" value="insert" ${
|
|
741
|
+
<input type="radio" name="insertMode" value="insert" ${me === "insert" ? "checked" : ""} />
|
|
194
742
|
Insert at cursor
|
|
195
743
|
</label>
|
|
196
744
|
<label>
|
|
197
|
-
<input type="radio" name="insertMode" value="replace" ${
|
|
745
|
+
<input type="radio" name="insertMode" value="replace" ${me === "replace" ? "checked" : ""} />
|
|
198
746
|
Replace document
|
|
199
747
|
</label>
|
|
200
748
|
</div>
|
|
@@ -202,15 +750,15 @@ function y() {
|
|
|
202
750
|
|
|
203
751
|
<div class="rte-dialog-footer">
|
|
204
752
|
<button class="rte-button-secondary rte-cancel-btn">Cancel</button>
|
|
205
|
-
<button class="rte-button-primary rte-insert-btn" ${
|
|
206
|
-
${
|
|
753
|
+
<button class="rte-button-primary rte-insert-btn" ${T ? "" : "disabled"}>
|
|
754
|
+
${me === "insert" ? "Insert" : "Replace"}
|
|
207
755
|
</button>
|
|
208
756
|
</div>
|
|
209
|
-
`,
|
|
757
|
+
`, Vn();
|
|
210
758
|
}
|
|
211
|
-
function
|
|
212
|
-
if (!
|
|
213
|
-
|
|
759
|
+
function jn() {
|
|
760
|
+
if (!m) return;
|
|
761
|
+
m.innerHTML = `
|
|
214
762
|
<div class="rte-dialog-header">
|
|
215
763
|
<h2>Replace Document?</h2>
|
|
216
764
|
</div>
|
|
@@ -222,105 +770,105 @@ function O() {
|
|
|
222
770
|
<button class="rte-button-primary rte-confirm-replace-btn">Replace</button>
|
|
223
771
|
</div>
|
|
224
772
|
`;
|
|
225
|
-
const
|
|
226
|
-
|
|
773
|
+
const n = m.querySelector(".rte-cancel-warning-btn"), t = m.querySelector(".rte-confirm-replace-btn");
|
|
774
|
+
n?.addEventListener("click", () => ge()), t?.addEventListener("click", () => Yn());
|
|
227
775
|
}
|
|
228
|
-
function
|
|
229
|
-
const
|
|
230
|
-
return
|
|
776
|
+
function ot() {
|
|
777
|
+
const n = Wt();
|
|
778
|
+
return te.trim() ? Un(te) : ee ? n.filter((t) => t.category === ee) : n;
|
|
231
779
|
}
|
|
232
|
-
function
|
|
233
|
-
if (!
|
|
234
|
-
|
|
235
|
-
const l =
|
|
236
|
-
l?.addEventListener("input", (
|
|
237
|
-
|
|
238
|
-
|
|
780
|
+
function Vn() {
|
|
781
|
+
if (!m) return;
|
|
782
|
+
m.querySelector(".rte-dialog-close")?.addEventListener("click", () => G()), m.querySelector(".rte-cancel-btn")?.addEventListener("click", () => G()), m.querySelector(".rte-insert-btn")?.addEventListener("click", () => Je());
|
|
783
|
+
const l = m.querySelector(".rte-template-search");
|
|
784
|
+
l?.addEventListener("input", (b) => {
|
|
785
|
+
k !== null && cancelAnimationFrame(k), te = b.target.value, k = requestAnimationFrame(() => {
|
|
786
|
+
k = null, Ft();
|
|
239
787
|
});
|
|
240
|
-
}), l?.addEventListener("keydown", (
|
|
241
|
-
|
|
242
|
-
}),
|
|
243
|
-
const
|
|
244
|
-
if (!
|
|
245
|
-
const
|
|
246
|
-
|
|
788
|
+
}), l?.addEventListener("keydown", (b) => {
|
|
789
|
+
b.key === "Enter" && T ? Je() : b.key === "Escape" && G();
|
|
790
|
+
}), m.querySelector(".rte-tabs")?.addEventListener("click", (b) => {
|
|
791
|
+
const W = b.target.closest(".rte-tab");
|
|
792
|
+
if (!W) return;
|
|
793
|
+
const j = W.getAttribute("data-category");
|
|
794
|
+
j && (ee = j, te = "", k !== null && (cancelAnimationFrame(k), k = null), Ft());
|
|
247
795
|
});
|
|
248
|
-
const
|
|
249
|
-
const
|
|
250
|
-
if (!
|
|
251
|
-
const
|
|
252
|
-
return
|
|
796
|
+
const f = m.querySelector(".rte-template-list"), w = (b) => {
|
|
797
|
+
const W = b.target.closest(".rte-template-item");
|
|
798
|
+
if (!W) return null;
|
|
799
|
+
const j = W.getAttribute("data-template-id");
|
|
800
|
+
return j && Wt().find((Oe) => Oe.id === j) || null;
|
|
253
801
|
};
|
|
254
|
-
|
|
255
|
-
const
|
|
256
|
-
|
|
257
|
-
}),
|
|
258
|
-
const
|
|
259
|
-
|
|
260
|
-
}),
|
|
261
|
-
const
|
|
262
|
-
!
|
|
802
|
+
f?.addEventListener("click", (b) => {
|
|
803
|
+
const E = w(b);
|
|
804
|
+
E && (T = E, ge());
|
|
805
|
+
}), f?.addEventListener("dblclick", (b) => {
|
|
806
|
+
const E = w(b);
|
|
807
|
+
E && (T = E, Je());
|
|
808
|
+
}), m.querySelector(".rte-insert-mode")?.addEventListener("change", (b) => {
|
|
809
|
+
const E = b.target;
|
|
810
|
+
!E || E.name !== "insertMode" || (me = E.value, ge());
|
|
263
811
|
});
|
|
264
812
|
}
|
|
265
|
-
function
|
|
266
|
-
const
|
|
267
|
-
|
|
813
|
+
function Ft() {
|
|
814
|
+
const n = ot();
|
|
815
|
+
n.length > 0 ? (!T || !n.find((t) => t.id === T.id)) && (T = n[0]) : T = null, ge();
|
|
268
816
|
}
|
|
269
|
-
function
|
|
270
|
-
if (
|
|
271
|
-
if (
|
|
272
|
-
if (
|
|
273
|
-
|
|
817
|
+
function Je() {
|
|
818
|
+
if (T)
|
|
819
|
+
if (me === "replace") {
|
|
820
|
+
if (rt()?.innerHTML?.trim()) {
|
|
821
|
+
jn();
|
|
274
822
|
return;
|
|
275
823
|
}
|
|
276
|
-
|
|
824
|
+
$t(T), G();
|
|
277
825
|
} else
|
|
278
|
-
|
|
826
|
+
$n(T), G();
|
|
279
827
|
}
|
|
280
|
-
function
|
|
281
|
-
|
|
828
|
+
function Yn() {
|
|
829
|
+
T && ($t(T), G());
|
|
282
830
|
}
|
|
283
|
-
function
|
|
284
|
-
const
|
|
285
|
-
if (!
|
|
286
|
-
const
|
|
287
|
-
if (!
|
|
288
|
-
if (
|
|
289
|
-
|
|
831
|
+
function $n(n) {
|
|
832
|
+
const t = window.getSelection();
|
|
833
|
+
if (!t) return;
|
|
834
|
+
const o = rt();
|
|
835
|
+
if (!o) return;
|
|
836
|
+
if (J)
|
|
837
|
+
t.removeAllRanges(), t.addRange(J);
|
|
290
838
|
else {
|
|
291
|
-
const
|
|
292
|
-
|
|
839
|
+
const z = document.createRange();
|
|
840
|
+
z.selectNodeContents(o), z.collapse(!1), t.removeAllRanges(), t.addRange(z);
|
|
293
841
|
}
|
|
294
|
-
if (
|
|
295
|
-
const l =
|
|
296
|
-
l.deleteContents(), l.insertNode(
|
|
297
|
-
const
|
|
298
|
-
|
|
842
|
+
if (t.rangeCount === 0) return;
|
|
843
|
+
const l = t.getRangeAt(0), c = o?.innerHTML ?? "", f = document.createRange().createContextualFragment(Vt(n.html));
|
|
844
|
+
l.deleteContents(), l.insertNode(f);
|
|
845
|
+
const w = document.createRange();
|
|
846
|
+
w.setStartAfter(l.endContainer), w.collapse(!0), t.removeAllRanges(), t.addRange(w), o && (Gt(o, c), o.dispatchEvent(new Event("input", { bubbles: !0 })));
|
|
299
847
|
}
|
|
300
|
-
function
|
|
301
|
-
const
|
|
302
|
-
if (
|
|
303
|
-
const
|
|
304
|
-
|
|
848
|
+
function $t(n) {
|
|
849
|
+
const t = rt();
|
|
850
|
+
if (t) {
|
|
851
|
+
const o = t.innerHTML;
|
|
852
|
+
t.innerHTML = Vt(n.html), Gt(t, o), t.dispatchEvent(new Event("input", { bubbles: !0 }));
|
|
305
853
|
}
|
|
306
854
|
}
|
|
307
|
-
function
|
|
308
|
-
|
|
855
|
+
function G() {
|
|
856
|
+
Yt(), k !== null && (cancelAnimationFrame(k), k = null), P && (P.remove(), P = null), m = null, J = null, te = "", Ce = null;
|
|
309
857
|
}
|
|
310
|
-
function
|
|
311
|
-
const
|
|
312
|
-
|
|
313
|
-
const
|
|
314
|
-
|
|
315
|
-
const l =
|
|
316
|
-
|
|
858
|
+
function qn(n) {
|
|
859
|
+
const t = window.getSelection();
|
|
860
|
+
t && t.rangeCount > 0 ? J = t.getRangeAt(0).cloneRange() : J = null;
|
|
861
|
+
const o = ot();
|
|
862
|
+
o.length > 0 && !T && (T = o[0]);
|
|
863
|
+
const l = n?.contentElement instanceof HTMLElement ? n.contentElement : nt();
|
|
864
|
+
Ce = l || null, zn(l);
|
|
317
865
|
}
|
|
318
|
-
function
|
|
866
|
+
function Xn() {
|
|
319
867
|
if (typeof document > "u") return;
|
|
320
|
-
const
|
|
321
|
-
if (document.getElementById(
|
|
322
|
-
const
|
|
323
|
-
|
|
868
|
+
const n = "template-plugin-dialog-styles";
|
|
869
|
+
if (document.getElementById(n)) return;
|
|
870
|
+
const t = document.createElement("style");
|
|
871
|
+
t.id = n, t.textContent = `
|
|
324
872
|
.rte-dialog-overlay {
|
|
325
873
|
--rte-tmpl-overlay-bg: rgba(15, 23, 36, 0.56);
|
|
326
874
|
--rte-tmpl-dialog-bg: #fff;
|
|
@@ -557,9 +1105,9 @@ function Y() {
|
|
|
557
1105
|
.rte-button-secondary:hover {
|
|
558
1106
|
background-color: var(--rte-tmpl-subtle-hover);
|
|
559
1107
|
}
|
|
560
|
-
`, document.head.appendChild(
|
|
1108
|
+
`, document.head.appendChild(t);
|
|
561
1109
|
}
|
|
562
|
-
const
|
|
1110
|
+
const Jn = () => ({
|
|
563
1111
|
name: "template",
|
|
564
1112
|
toolbar: [
|
|
565
1113
|
{
|
|
@@ -569,18 +1117,18 @@ const te = () => ({
|
|
|
569
1117
|
}
|
|
570
1118
|
],
|
|
571
1119
|
commands: {
|
|
572
|
-
insertTemplate: (
|
|
1120
|
+
insertTemplate: (n, t) => (qn(t), !0)
|
|
573
1121
|
},
|
|
574
1122
|
keymap: {}
|
|
575
1123
|
});
|
|
576
1124
|
export {
|
|
577
|
-
|
|
578
|
-
|
|
579
|
-
|
|
580
|
-
|
|
581
|
-
|
|
582
|
-
|
|
583
|
-
|
|
584
|
-
|
|
585
|
-
|
|
1125
|
+
Hn as PREDEFINED_TEMPLATES,
|
|
1126
|
+
Jn as TemplatePlugin,
|
|
1127
|
+
Kn as addCustomTemplate,
|
|
1128
|
+
Wt as getAllTemplates,
|
|
1129
|
+
jt as getTemplateCategories,
|
|
1130
|
+
Zn as getTemplatesByCategory,
|
|
1131
|
+
Vt as sanitizeTemplate,
|
|
1132
|
+
Un as searchTemplates,
|
|
1133
|
+
Qn as validateTemplate
|
|
586
1134
|
};
|