@lakamark/modulo-editor 0.2.0-alpha.1 → 0.2.0-alpha.2
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 +22 -4
- package/dist/modulo-editor.js +76 -770
- package/dist/modulo-editor.js.map +1 -1
- package/dist/modulo-editor.umd.cjs +1 -2
- package/dist/modulo-editor.umd.cjs.map +1 -1
- package/dist/types/core/Builder/DefaultModuloEditorBuilder.d.ts +31 -110
- package/dist/types/core/Builder/DefaultModuloEditorBuilder.d.ts.map +1 -1
- package/dist/types/core/ModuloEditor.d.ts.map +1 -1
- package/dist/types/core/contracts/ModuloEditorBuilder.d.ts +18 -18
- package/dist/types/core/contracts/ModuloEditorBuilder.d.ts.map +1 -1
- package/dist/types/presets/builtin/DefaultEditorPreset.d.ts +7 -0
- package/dist/types/presets/builtin/DefaultEditorPreset.d.ts.map +1 -0
- package/dist/types/presets/builtin/SafeMarkdownPreset.d.ts +7 -0
- package/dist/types/presets/builtin/SafeMarkdownPreset.d.ts.map +1 -0
- package/dist/types/presets/builtin/StarterKitPreset.d.ts +7 -0
- package/dist/types/presets/builtin/StarterKitPreset.d.ts.map +1 -0
- package/dist/types/presets/builtin/index.d.ts +4 -0
- package/dist/types/presets/builtin/index.d.ts.map +1 -0
- package/dist/types/presets/contracts/EditorPreset.d.ts +6 -0
- package/dist/types/presets/contracts/EditorPreset.d.ts.map +1 -0
- package/dist/types/presets/contracts/index.d.ts +2 -0
- package/dist/types/presets/contracts/index.d.ts.map +1 -0
- package/dist/types/presets/index.d.ts +3 -0
- package/dist/types/presets/index.d.ts.map +1 -0
- package/package.json +1 -1
package/dist/modulo-editor.js
CHANGED
|
@@ -147,793 +147,89 @@ var u = class {
|
|
|
147
147
|
};
|
|
148
148
|
//#endregion
|
|
149
149
|
//#region src/commands/setup/setupEditorCommands.ts
|
|
150
|
-
function
|
|
150
|
+
function f(e, t) {
|
|
151
151
|
let n = l(t.builtinCommands), r = t.commands ?? [];
|
|
152
152
|
i(r);
|
|
153
153
|
for (let t of n) e.register(t);
|
|
154
154
|
for (let t of r) e.register(t);
|
|
155
155
|
}
|
|
156
156
|
//#endregion
|
|
157
|
-
//#region src/
|
|
158
|
-
var
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
}), e.appendChild(n), this.textarea = n;
|
|
169
|
-
}
|
|
170
|
-
getState() {
|
|
171
|
-
let e = this.getElement();
|
|
172
|
-
return {
|
|
173
|
-
value: e.value,
|
|
174
|
-
selectionStart: e.selectionStart ?? 0,
|
|
175
|
-
selectionEnd: e.selectionEnd ?? 0
|
|
176
|
-
};
|
|
177
|
-
}
|
|
178
|
-
setSelection(e, t) {
|
|
179
|
-
this.getElement().setSelectionRange(e, t);
|
|
180
|
-
}
|
|
181
|
-
getValue() {
|
|
182
|
-
return this.textarea?.value ?? "";
|
|
183
|
-
}
|
|
184
|
-
setValue(e) {
|
|
185
|
-
this.textarea && (this.textarea.value = e);
|
|
186
|
-
}
|
|
187
|
-
focus() {
|
|
188
|
-
this.textarea?.focus();
|
|
189
|
-
}
|
|
190
|
-
onChange(e) {
|
|
191
|
-
return this.listeners.push(e), () => {
|
|
192
|
-
this.listeners = this.listeners.filter((t) => t !== e);
|
|
193
|
-
};
|
|
194
|
-
}
|
|
195
|
-
destroy() {
|
|
196
|
-
this.textarea?.remove(), this.textarea = null, this.listeners = [];
|
|
197
|
-
}
|
|
198
|
-
generateId() {
|
|
199
|
-
return `mo-editor-${Math.random().toString(36).slice(2)}`;
|
|
200
|
-
}
|
|
201
|
-
setTextareaAttributes(e, t) {
|
|
202
|
-
e.id = this.generateId(), e.className = "mo-editor__textarea", e.value = t, e.spellcheck = !1, e.ariaLabel = "Markdown editor";
|
|
203
|
-
}
|
|
204
|
-
getElement() {
|
|
205
|
-
if (!this.textarea) throw Error("Textarea input adapter is not mounted.");
|
|
206
|
-
return this.textarea;
|
|
207
|
-
}
|
|
208
|
-
}, p = class {
|
|
209
|
-
element = null;
|
|
210
|
-
mount(e) {
|
|
211
|
-
this.element = e;
|
|
212
|
-
}
|
|
213
|
-
render(e) {
|
|
214
|
-
this.element && (this.element.innerHTML = e);
|
|
215
|
-
}
|
|
216
|
-
destroy() {
|
|
217
|
-
this.element && (this.element.innerHTML = ""), this.element = null;
|
|
218
|
-
}
|
|
219
|
-
}, te = class {
|
|
220
|
-
textarea = null;
|
|
221
|
-
mount(e) {
|
|
222
|
-
this.textarea = e;
|
|
223
|
-
}
|
|
224
|
-
getValue() {
|
|
225
|
-
return this.textarea?.value ?? "";
|
|
226
|
-
}
|
|
227
|
-
setValue(e) {
|
|
228
|
-
this.textarea && (this.textarea.value = e);
|
|
229
|
-
}
|
|
230
|
-
destroy() {
|
|
231
|
-
this.textarea = null;
|
|
232
|
-
}
|
|
233
|
-
}, ne = class {
|
|
234
|
-
name;
|
|
235
|
-
commandName;
|
|
236
|
-
content;
|
|
237
|
-
button = null;
|
|
238
|
-
api = null;
|
|
157
|
+
//#region src/core/Builder/DefaultModuloEditorBuilder.ts
|
|
158
|
+
var p = class {
|
|
159
|
+
domResolver;
|
|
160
|
+
input;
|
|
161
|
+
output;
|
|
162
|
+
textareaBridge;
|
|
163
|
+
markdown;
|
|
164
|
+
plugins = [];
|
|
165
|
+
document;
|
|
166
|
+
commands = [];
|
|
167
|
+
root;
|
|
239
168
|
constructor(e) {
|
|
240
|
-
this.
|
|
241
|
-
}
|
|
242
|
-
setup(e) {
|
|
243
|
-
let t = e.slots.toolbar;
|
|
244
|
-
if (!t) return;
|
|
245
|
-
this.api = e;
|
|
246
|
-
let n = document.createElement("button");
|
|
247
|
-
n.type = "button", this.renderButtonContent(n), n.addEventListener("click", this.handleClick), t.appendChild(n), this.button = n;
|
|
248
|
-
}
|
|
249
|
-
destroy() {
|
|
250
|
-
this.button &&= (this.button.removeEventListener("click", this.handleClick), this.button.remove(), null), this.api = null;
|
|
251
|
-
}
|
|
252
|
-
renderButtonContent(e) {
|
|
253
|
-
let t = typeof this.content == "function" ? this.content() : this.content;
|
|
254
|
-
if (typeof t == "string") {
|
|
255
|
-
e.textContent = t;
|
|
256
|
-
return;
|
|
257
|
-
}
|
|
258
|
-
e.appendChild(t);
|
|
259
|
-
}
|
|
260
|
-
handleClick = () => {
|
|
261
|
-
this.api?.commands.has(this.commandName) && this.api.executeCommand(this.commandName);
|
|
262
|
-
};
|
|
263
|
-
}, re = class extends ne {
|
|
264
|
-
constructor() {
|
|
265
|
-
super({
|
|
266
|
-
pluginName: "toolbar-bold",
|
|
267
|
-
commandName: "bold",
|
|
268
|
-
content: "Bold"
|
|
269
|
-
});
|
|
169
|
+
this.root = e;
|
|
270
170
|
}
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
super({
|
|
274
|
-
pluginName: "toolbar-italic",
|
|
275
|
-
commandName: "italic",
|
|
276
|
-
content: "Italic"
|
|
277
|
-
});
|
|
171
|
+
usePreset(e) {
|
|
172
|
+
return e.apply(this), this;
|
|
278
173
|
}
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
super({
|
|
282
|
-
pluginName: `toolbar-heading-${e}`,
|
|
283
|
-
commandName: `heading-${e}`,
|
|
284
|
-
content: `H${e}`
|
|
285
|
-
});
|
|
174
|
+
withDomResolver(e) {
|
|
175
|
+
return this.domResolver = e, this;
|
|
286
176
|
}
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
//#region src/plugins/toolbar/createDefaultToolbarPlugins.ts
|
|
290
|
-
function h(e = {}) {
|
|
291
|
-
let { headings: t = [
|
|
292
|
-
1,
|
|
293
|
-
2,
|
|
294
|
-
3
|
|
295
|
-
] } = e;
|
|
296
|
-
return [
|
|
297
|
-
new re(),
|
|
298
|
-
new ie(),
|
|
299
|
-
...t.map((e) => new m(e))
|
|
300
|
-
];
|
|
301
|
-
}
|
|
302
|
-
//#endregion
|
|
303
|
-
//#region src/markdown/config/DefaultHtmlSanitizerConfig.ts
|
|
304
|
-
var g = {
|
|
305
|
-
allowedTags: [
|
|
306
|
-
"p",
|
|
307
|
-
"strong",
|
|
308
|
-
"em",
|
|
309
|
-
"code",
|
|
310
|
-
"pre",
|
|
311
|
-
"ul",
|
|
312
|
-
"ol",
|
|
313
|
-
"li",
|
|
314
|
-
"blockquote",
|
|
315
|
-
"a"
|
|
316
|
-
],
|
|
317
|
-
allowedAttributes: { a: ["href", "title"] }
|
|
318
|
-
}, ae = class {
|
|
319
|
-
parse(e) {
|
|
320
|
-
let t = document.createElement("p");
|
|
321
|
-
return t.textContent = e, t.outerHTML;
|
|
322
|
-
}
|
|
323
|
-
}, oe = class {
|
|
324
|
-
parser;
|
|
325
|
-
sanitize;
|
|
326
|
-
constructor(e, t) {
|
|
327
|
-
this.parser = e, this.sanitize = t;
|
|
177
|
+
withInput(e) {
|
|
178
|
+
return this.input = e, this;
|
|
328
179
|
}
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
return this.sanitize.sanitize(t);
|
|
180
|
+
withOutput(e) {
|
|
181
|
+
return this.output = e, this;
|
|
332
182
|
}
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
return e;
|
|
336
|
-
}, y ||= function(e) {
|
|
337
|
-
return e;
|
|
338
|
-
}, x ||= function(e, t) {
|
|
339
|
-
var n = [...arguments].slice(2);
|
|
340
|
-
return e.apply(t, n);
|
|
341
|
-
}, S ||= function(e) {
|
|
342
|
-
return new e(...[...arguments].slice(1));
|
|
343
|
-
};
|
|
344
|
-
var de = O(Array.prototype.forEach), fe = O(Array.prototype.lastIndexOf), pe = O(Array.prototype.pop), C = O(Array.prototype.push), me = O(Array.prototype.splice), he = O(String.prototype.toLowerCase), ge = O(String.prototype.toString), _e = O(String.prototype.match), w = O(String.prototype.replace), ve = O(String.prototype.indexOf), ye = O(String.prototype.trim), T = O(Object.prototype.hasOwnProperty), E = O(RegExp.prototype.test), D = be(TypeError);
|
|
345
|
-
function O(e) {
|
|
346
|
-
return function(t) {
|
|
347
|
-
t instanceof RegExp && (t.lastIndex = 0);
|
|
348
|
-
var n = [...arguments].slice(1);
|
|
349
|
-
return x(e, t, n);
|
|
350
|
-
};
|
|
351
|
-
}
|
|
352
|
-
function be(e) {
|
|
353
|
-
return function() {
|
|
354
|
-
return S(e, [...arguments]);
|
|
355
|
-
};
|
|
356
|
-
}
|
|
357
|
-
function k(e, t) {
|
|
358
|
-
let n = arguments.length > 2 && arguments[2] !== void 0 ? arguments[2] : he;
|
|
359
|
-
ce && ce(e, null);
|
|
360
|
-
let r = t.length;
|
|
361
|
-
for (; r--;) {
|
|
362
|
-
let i = t[r];
|
|
363
|
-
if (typeof i == "string") {
|
|
364
|
-
let e = n(i);
|
|
365
|
-
e !== i && (le(t) || (t[r] = e), i = e);
|
|
366
|
-
}
|
|
367
|
-
e[i] = !0;
|
|
183
|
+
withTextareaBridge(e) {
|
|
184
|
+
return this.textareaBridge = e, this;
|
|
368
185
|
}
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
function xe(e) {
|
|
372
|
-
for (let t = 0; t < e.length; t++) T(e, t) || (e[t] = null);
|
|
373
|
-
return e;
|
|
374
|
-
}
|
|
375
|
-
function A(e) {
|
|
376
|
-
let t = b(null);
|
|
377
|
-
for (let [n, r] of se(e)) T(e, n) && (Array.isArray(r) ? t[n] = xe(r) : r && typeof r == "object" && r.constructor === Object ? t[n] = A(r) : t[n] = r);
|
|
378
|
-
return t;
|
|
379
|
-
}
|
|
380
|
-
function j(e, t) {
|
|
381
|
-
for (; e !== null;) {
|
|
382
|
-
let n = _(e, t);
|
|
383
|
-
if (n) {
|
|
384
|
-
if (n.get) return O(n.get);
|
|
385
|
-
if (typeof n.value == "function") return O(n.value);
|
|
386
|
-
}
|
|
387
|
-
e = ue(e);
|
|
186
|
+
withMarkdown(e) {
|
|
187
|
+
return this.markdown = e, this;
|
|
388
188
|
}
|
|
389
|
-
|
|
390
|
-
return
|
|
189
|
+
withPlugins(e) {
|
|
190
|
+
return this.plugins = [...e], this;
|
|
391
191
|
}
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
var Se = v(/* @__PURE__ */ "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".split(".")), Ce = v(/* @__PURE__ */ "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".split(".")), we = v([
|
|
395
|
-
"feBlend",
|
|
396
|
-
"feColorMatrix",
|
|
397
|
-
"feComponentTransfer",
|
|
398
|
-
"feComposite",
|
|
399
|
-
"feConvolveMatrix",
|
|
400
|
-
"feDiffuseLighting",
|
|
401
|
-
"feDisplacementMap",
|
|
402
|
-
"feDistantLight",
|
|
403
|
-
"feDropShadow",
|
|
404
|
-
"feFlood",
|
|
405
|
-
"feFuncA",
|
|
406
|
-
"feFuncB",
|
|
407
|
-
"feFuncG",
|
|
408
|
-
"feFuncR",
|
|
409
|
-
"feGaussianBlur",
|
|
410
|
-
"feImage",
|
|
411
|
-
"feMerge",
|
|
412
|
-
"feMergeNode",
|
|
413
|
-
"feMorphology",
|
|
414
|
-
"feOffset",
|
|
415
|
-
"fePointLight",
|
|
416
|
-
"feSpecularLighting",
|
|
417
|
-
"feSpotLight",
|
|
418
|
-
"feTile",
|
|
419
|
-
"feTurbulence"
|
|
420
|
-
]), Te = v([
|
|
421
|
-
"animate",
|
|
422
|
-
"color-profile",
|
|
423
|
-
"cursor",
|
|
424
|
-
"discard",
|
|
425
|
-
"font-face",
|
|
426
|
-
"font-face-format",
|
|
427
|
-
"font-face-name",
|
|
428
|
-
"font-face-src",
|
|
429
|
-
"font-face-uri",
|
|
430
|
-
"foreignobject",
|
|
431
|
-
"hatch",
|
|
432
|
-
"hatchpath",
|
|
433
|
-
"mesh",
|
|
434
|
-
"meshgradient",
|
|
435
|
-
"meshpatch",
|
|
436
|
-
"meshrow",
|
|
437
|
-
"missing-glyph",
|
|
438
|
-
"script",
|
|
439
|
-
"set",
|
|
440
|
-
"solidcolor",
|
|
441
|
-
"unknown",
|
|
442
|
-
"use"
|
|
443
|
-
]), Ee = v(/* @__PURE__ */ "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".split(".")), De = v([
|
|
444
|
-
"maction",
|
|
445
|
-
"maligngroup",
|
|
446
|
-
"malignmark",
|
|
447
|
-
"mlongdiv",
|
|
448
|
-
"mscarries",
|
|
449
|
-
"mscarry",
|
|
450
|
-
"msgroup",
|
|
451
|
-
"mstack",
|
|
452
|
-
"msline",
|
|
453
|
-
"msrow",
|
|
454
|
-
"semantics",
|
|
455
|
-
"annotation",
|
|
456
|
-
"annotation-xml",
|
|
457
|
-
"mprescripts",
|
|
458
|
-
"none"
|
|
459
|
-
]), Oe = v(["#text"]), ke = v(/* @__PURE__ */ "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".split(".")), Ae = v(/* @__PURE__ */ "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".split(".")), je = v(/* @__PURE__ */ "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".split(".")), Me = v([
|
|
460
|
-
"xlink:href",
|
|
461
|
-
"xml:id",
|
|
462
|
-
"xlink:title",
|
|
463
|
-
"xml:space",
|
|
464
|
-
"xmlns:xlink"
|
|
465
|
-
]), Ne = y(/\{\{[\w\W]*|[\w\W]*\}\}/gm), Pe = y(/<%[\w\W]*|[\w\W]*%>/gm), Fe = y(/\$\{[\w\W]*/gm), M = y(/^data-[\-\w.\u00B7-\uFFFF]+$/), Ie = y(/^aria-[\-\w]+$/), Le = y(/^(?:(?:(?:f|ht)tps?|mailto|tel|callto|sms|cid|xmpp|matrix):|[^a-z]|[a-z+.\-]+(?:[^a-z+.\-:]|$))/i), N = y(/^(?:\w+script|data):/i), Re = y(/[\u0000-\u0020\u00A0\u1680\u180E\u2000-\u2029\u205F\u3000]/g), ze = y(/^html$/i), P = y(/^[a-z][.\w]*(-[.\w]+)+$/i), Be = /* @__PURE__ */ Object.freeze({
|
|
466
|
-
__proto__: null,
|
|
467
|
-
ARIA_ATTR: Ie,
|
|
468
|
-
ATTR_WHITESPACE: Re,
|
|
469
|
-
CUSTOM_ELEMENT: P,
|
|
470
|
-
DATA_ATTR: M,
|
|
471
|
-
DOCTYPE_NAME: ze,
|
|
472
|
-
ERB_EXPR: Pe,
|
|
473
|
-
IS_ALLOWED_URI: Le,
|
|
474
|
-
IS_SCRIPT_OR_DATA: N,
|
|
475
|
-
MUSTACHE_EXPR: Ne,
|
|
476
|
-
TMPLIT_EXPR: Fe
|
|
477
|
-
}), F = {
|
|
478
|
-
element: 1,
|
|
479
|
-
attribute: 2,
|
|
480
|
-
text: 3,
|
|
481
|
-
cdataSection: 4,
|
|
482
|
-
entityReference: 5,
|
|
483
|
-
entityNode: 6,
|
|
484
|
-
progressingInstruction: 7,
|
|
485
|
-
comment: 8,
|
|
486
|
-
document: 9,
|
|
487
|
-
documentType: 10,
|
|
488
|
-
documentFragment: 11,
|
|
489
|
-
notation: 12
|
|
490
|
-
}, Ve = function() {
|
|
491
|
-
return typeof window > "u" ? null : window;
|
|
492
|
-
}, He = function(e, t) {
|
|
493
|
-
if (typeof e != "object" || typeof e.createPolicy != "function") return null;
|
|
494
|
-
let n = null, r = "data-tt-policy-suffix";
|
|
495
|
-
t && t.hasAttribute(r) && (n = t.getAttribute(r));
|
|
496
|
-
let i = "dompurify" + (n ? "#" + n : "");
|
|
497
|
-
try {
|
|
498
|
-
return e.createPolicy(i, {
|
|
499
|
-
createHTML(e) {
|
|
500
|
-
return e;
|
|
501
|
-
},
|
|
502
|
-
createScriptURL(e) {
|
|
503
|
-
return e;
|
|
504
|
-
}
|
|
505
|
-
});
|
|
506
|
-
} catch {
|
|
507
|
-
return console.warn("TrustedTypes policy " + i + " could not be created."), null;
|
|
508
|
-
}
|
|
509
|
-
}, Ue = function() {
|
|
510
|
-
return {
|
|
511
|
-
afterSanitizeAttributes: [],
|
|
512
|
-
afterSanitizeElements: [],
|
|
513
|
-
afterSanitizeShadowDOM: [],
|
|
514
|
-
beforeSanitizeAttributes: [],
|
|
515
|
-
beforeSanitizeElements: [],
|
|
516
|
-
beforeSanitizeShadowDOM: [],
|
|
517
|
-
uponSanitizeAttribute: [],
|
|
518
|
-
uponSanitizeElement: [],
|
|
519
|
-
uponSanitizeShadowNode: []
|
|
520
|
-
};
|
|
521
|
-
};
|
|
522
|
-
function We() {
|
|
523
|
-
let e = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : Ve(), t = (e) => We(e);
|
|
524
|
-
if (t.version = "3.3.3", t.removed = [], !e || !e.document || e.document.nodeType !== F.document || !e.Element) return t.isSupported = !1, t;
|
|
525
|
-
let { document: n } = e, r = n, i = r.currentScript, { DocumentFragment: a, HTMLTemplateElement: o, Node: s, Element: c, NodeFilter: l, NamedNodeMap: u = e.NamedNodeMap || e.MozNamedAttrMap, HTMLFormElement: d, DOMParser: ee, trustedTypes: f } = e, p = c.prototype, te = j(p, "cloneNode"), ne = j(p, "remove"), re = j(p, "nextSibling"), ie = j(p, "childNodes"), m = j(p, "parentNode");
|
|
526
|
-
if (typeof o == "function") {
|
|
527
|
-
let e = n.createElement("template");
|
|
528
|
-
e.content && e.content.ownerDocument && (n = e.content.ownerDocument);
|
|
529
|
-
}
|
|
530
|
-
let h, g = "", { implementation: ae, createNodeIterator: oe, createDocumentFragment: ce, getElementsByTagName: le } = n, { importNode: ue } = r, _ = Ue();
|
|
531
|
-
t.isSupported = typeof se == "function" && typeof m == "function" && ae && ae.createHTMLDocument !== void 0;
|
|
532
|
-
let { MUSTACHE_EXPR: y, ERB_EXPR: x, TMPLIT_EXPR: S, DATA_ATTR: O, ARIA_ATTR: be, IS_SCRIPT_OR_DATA: xe, ATTR_WHITESPACE: Ne, CUSTOM_ELEMENT: Pe } = Be, { IS_ALLOWED_URI: Fe } = Be, M = null, Ie = k({}, [
|
|
533
|
-
...Se,
|
|
534
|
-
...Ce,
|
|
535
|
-
...we,
|
|
536
|
-
...Ee,
|
|
537
|
-
...Oe
|
|
538
|
-
]), N = null, Re = k({}, [
|
|
539
|
-
...ke,
|
|
540
|
-
...Ae,
|
|
541
|
-
...je,
|
|
542
|
-
...Me
|
|
543
|
-
]), P = Object.seal(b(null, {
|
|
544
|
-
tagNameCheck: {
|
|
545
|
-
writable: !0,
|
|
546
|
-
configurable: !1,
|
|
547
|
-
enumerable: !0,
|
|
548
|
-
value: null
|
|
549
|
-
},
|
|
550
|
-
attributeNameCheck: {
|
|
551
|
-
writable: !0,
|
|
552
|
-
configurable: !1,
|
|
553
|
-
enumerable: !0,
|
|
554
|
-
value: null
|
|
555
|
-
},
|
|
556
|
-
allowCustomizedBuiltInElements: {
|
|
557
|
-
writable: !0,
|
|
558
|
-
configurable: !1,
|
|
559
|
-
enumerable: !0,
|
|
560
|
-
value: !1
|
|
561
|
-
}
|
|
562
|
-
})), I = null, L = null, R = Object.seal(b(null, {
|
|
563
|
-
tagCheck: {
|
|
564
|
-
writable: !0,
|
|
565
|
-
configurable: !1,
|
|
566
|
-
enumerable: !0,
|
|
567
|
-
value: null
|
|
568
|
-
},
|
|
569
|
-
attributeCheck: {
|
|
570
|
-
writable: !0,
|
|
571
|
-
configurable: !1,
|
|
572
|
-
enumerable: !0,
|
|
573
|
-
value: null
|
|
574
|
-
}
|
|
575
|
-
})), Ge = !0, Ke = !0, qe = !1, Je = !0, z = !1, Ye = !0, B = !1, Xe = !1, Ze = !1, V = !1, Qe = !1, $e = !1, et = !0, tt = !1, nt = !0, H = !1, U = {}, W = null, rt = k({}, [
|
|
576
|
-
"annotation-xml",
|
|
577
|
-
"audio",
|
|
578
|
-
"colgroup",
|
|
579
|
-
"desc",
|
|
580
|
-
"foreignobject",
|
|
581
|
-
"head",
|
|
582
|
-
"iframe",
|
|
583
|
-
"math",
|
|
584
|
-
"mi",
|
|
585
|
-
"mn",
|
|
586
|
-
"mo",
|
|
587
|
-
"ms",
|
|
588
|
-
"mtext",
|
|
589
|
-
"noembed",
|
|
590
|
-
"noframes",
|
|
591
|
-
"noscript",
|
|
592
|
-
"plaintext",
|
|
593
|
-
"script",
|
|
594
|
-
"style",
|
|
595
|
-
"svg",
|
|
596
|
-
"template",
|
|
597
|
-
"thead",
|
|
598
|
-
"title",
|
|
599
|
-
"video",
|
|
600
|
-
"xmp"
|
|
601
|
-
]), it = null, at = k({}, [
|
|
602
|
-
"audio",
|
|
603
|
-
"video",
|
|
604
|
-
"img",
|
|
605
|
-
"source",
|
|
606
|
-
"image",
|
|
607
|
-
"track"
|
|
608
|
-
]), ot = null, st = k({}, [
|
|
609
|
-
"alt",
|
|
610
|
-
"class",
|
|
611
|
-
"for",
|
|
612
|
-
"id",
|
|
613
|
-
"label",
|
|
614
|
-
"name",
|
|
615
|
-
"pattern",
|
|
616
|
-
"placeholder",
|
|
617
|
-
"role",
|
|
618
|
-
"summary",
|
|
619
|
-
"title",
|
|
620
|
-
"value",
|
|
621
|
-
"style",
|
|
622
|
-
"xmlns"
|
|
623
|
-
]), ct = "http://www.w3.org/1998/Math/MathML", lt = "http://www.w3.org/2000/svg", G = "http://www.w3.org/1999/xhtml", K = G, ut = !1, dt = null, ft = k({}, [
|
|
624
|
-
ct,
|
|
625
|
-
lt,
|
|
626
|
-
G
|
|
627
|
-
], ge), pt = k({}, [
|
|
628
|
-
"mi",
|
|
629
|
-
"mo",
|
|
630
|
-
"mn",
|
|
631
|
-
"ms",
|
|
632
|
-
"mtext"
|
|
633
|
-
]), q = k({}, ["annotation-xml"]), mt = k({}, [
|
|
634
|
-
"title",
|
|
635
|
-
"style",
|
|
636
|
-
"font",
|
|
637
|
-
"a",
|
|
638
|
-
"script"
|
|
639
|
-
]), J = null, ht = ["application/xhtml+xml", "text/html"], Y = null, X = null, gt = n.createElement("form"), _t = function(e) {
|
|
640
|
-
return e instanceof RegExp || e instanceof Function;
|
|
641
|
-
}, vt = function() {
|
|
642
|
-
let e = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : {};
|
|
643
|
-
if (!(X && X === e)) {
|
|
644
|
-
if ((!e || typeof e != "object") && (e = {}), e = A(e), J = ht.indexOf(e.PARSER_MEDIA_TYPE) === -1 ? "text/html" : e.PARSER_MEDIA_TYPE, Y = J === "application/xhtml+xml" ? ge : he, M = T(e, "ALLOWED_TAGS") ? k({}, e.ALLOWED_TAGS, Y) : Ie, N = T(e, "ALLOWED_ATTR") ? k({}, e.ALLOWED_ATTR, Y) : Re, dt = T(e, "ALLOWED_NAMESPACES") ? k({}, e.ALLOWED_NAMESPACES, ge) : ft, ot = T(e, "ADD_URI_SAFE_ATTR") ? k(A(st), e.ADD_URI_SAFE_ATTR, Y) : st, it = T(e, "ADD_DATA_URI_TAGS") ? k(A(at), e.ADD_DATA_URI_TAGS, Y) : at, W = T(e, "FORBID_CONTENTS") ? k({}, e.FORBID_CONTENTS, Y) : rt, I = T(e, "FORBID_TAGS") ? k({}, e.FORBID_TAGS, Y) : A({}), L = T(e, "FORBID_ATTR") ? k({}, e.FORBID_ATTR, Y) : A({}), U = T(e, "USE_PROFILES") ? e.USE_PROFILES : !1, Ge = e.ALLOW_ARIA_ATTR !== !1, Ke = e.ALLOW_DATA_ATTR !== !1, qe = e.ALLOW_UNKNOWN_PROTOCOLS || !1, Je = e.ALLOW_SELF_CLOSE_IN_ATTR !== !1, z = e.SAFE_FOR_TEMPLATES || !1, Ye = e.SAFE_FOR_XML !== !1, B = e.WHOLE_DOCUMENT || !1, V = e.RETURN_DOM || !1, Qe = e.RETURN_DOM_FRAGMENT || !1, $e = e.RETURN_TRUSTED_TYPE || !1, Ze = e.FORCE_BODY || !1, et = e.SANITIZE_DOM !== !1, tt = e.SANITIZE_NAMED_PROPS || !1, nt = e.KEEP_CONTENT !== !1, H = e.IN_PLACE || !1, Fe = e.ALLOWED_URI_REGEXP || Le, K = e.NAMESPACE || G, pt = e.MATHML_TEXT_INTEGRATION_POINTS || pt, q = e.HTML_INTEGRATION_POINTS || q, P = e.CUSTOM_ELEMENT_HANDLING || {}, e.CUSTOM_ELEMENT_HANDLING && _t(e.CUSTOM_ELEMENT_HANDLING.tagNameCheck) && (P.tagNameCheck = e.CUSTOM_ELEMENT_HANDLING.tagNameCheck), e.CUSTOM_ELEMENT_HANDLING && _t(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), z && (Ke = !1), Qe && (V = !0), U && (M = k({}, Oe), N = b(null), U.html === !0 && (k(M, Se), k(N, ke)), U.svg === !0 && (k(M, Ce), k(N, Ae), k(N, Me)), U.svgFilters === !0 && (k(M, we), k(N, Ae), k(N, Me)), U.mathMl === !0 && (k(M, Ee), k(N, je), k(N, Me))), T(e, "ADD_TAGS") || (R.tagCheck = null), T(e, "ADD_ATTR") || (R.attributeCheck = null), e.ADD_TAGS && (typeof e.ADD_TAGS == "function" ? R.tagCheck = e.ADD_TAGS : (M === Ie && (M = A(M)), k(M, e.ADD_TAGS, Y))), e.ADD_ATTR && (typeof e.ADD_ATTR == "function" ? R.attributeCheck = e.ADD_ATTR : (N === Re && (N = A(N)), k(N, e.ADD_ATTR, Y))), e.ADD_URI_SAFE_ATTR && k(ot, e.ADD_URI_SAFE_ATTR, Y), e.FORBID_CONTENTS && (W === rt && (W = A(W)), k(W, e.FORBID_CONTENTS, Y)), e.ADD_FORBID_CONTENTS && (W === rt && (W = A(W)), k(W, e.ADD_FORBID_CONTENTS, Y)), nt && (M["#text"] = !0), B && k(M, [
|
|
645
|
-
"html",
|
|
646
|
-
"head",
|
|
647
|
-
"body"
|
|
648
|
-
]), M.table && (k(M, ["tbody"]), delete I.tbody), e.TRUSTED_TYPES_POLICY) {
|
|
649
|
-
if (typeof e.TRUSTED_TYPES_POLICY.createHTML != "function") throw D("TRUSTED_TYPES_POLICY configuration option must provide a \"createHTML\" hook.");
|
|
650
|
-
if (typeof e.TRUSTED_TYPES_POLICY.createScriptURL != "function") throw D("TRUSTED_TYPES_POLICY configuration option must provide a \"createScriptURL\" hook.");
|
|
651
|
-
h = e.TRUSTED_TYPES_POLICY, g = h.createHTML("");
|
|
652
|
-
} else h === void 0 && (h = He(f, i)), h !== null && typeof g == "string" && (g = h.createHTML(""));
|
|
653
|
-
v && v(e), X = e;
|
|
654
|
-
}
|
|
655
|
-
}, yt = k({}, [
|
|
656
|
-
...Ce,
|
|
657
|
-
...we,
|
|
658
|
-
...Te
|
|
659
|
-
]), bt = k({}, [...Ee, ...De]), xt = function(e) {
|
|
660
|
-
let t = m(e);
|
|
661
|
-
(!t || !t.tagName) && (t = {
|
|
662
|
-
namespaceURI: K,
|
|
663
|
-
tagName: "template"
|
|
664
|
-
});
|
|
665
|
-
let n = he(e.tagName), r = he(t.tagName);
|
|
666
|
-
return dt[e.namespaceURI] ? e.namespaceURI === lt ? t.namespaceURI === G ? n === "svg" : t.namespaceURI === ct ? n === "svg" && (r === "annotation-xml" || pt[r]) : !!yt[n] : e.namespaceURI === ct ? t.namespaceURI === G ? n === "math" : t.namespaceURI === lt ? n === "math" && q[r] : !!bt[n] : e.namespaceURI === G ? t.namespaceURI === lt && !q[r] || t.namespaceURI === ct && !pt[r] ? !1 : !bt[n] && (mt[n] || !yt[n]) : !!(J === "application/xhtml+xml" && dt[e.namespaceURI]) : !1;
|
|
667
|
-
}, Z = function(e) {
|
|
668
|
-
C(t.removed, { element: e });
|
|
669
|
-
try {
|
|
670
|
-
m(e).removeChild(e);
|
|
671
|
-
} catch {
|
|
672
|
-
ne(e);
|
|
673
|
-
}
|
|
674
|
-
}, Q = function(e, n) {
|
|
675
|
-
try {
|
|
676
|
-
C(t.removed, {
|
|
677
|
-
attribute: n.getAttributeNode(e),
|
|
678
|
-
from: n
|
|
679
|
-
});
|
|
680
|
-
} catch {
|
|
681
|
-
C(t.removed, {
|
|
682
|
-
attribute: null,
|
|
683
|
-
from: n
|
|
684
|
-
});
|
|
685
|
-
}
|
|
686
|
-
if (n.removeAttribute(e), e === "is") if (V || Qe) try {
|
|
687
|
-
Z(n);
|
|
688
|
-
} catch {}
|
|
689
|
-
else try {
|
|
690
|
-
n.setAttribute(e, "");
|
|
691
|
-
} catch {}
|
|
692
|
-
}, St = function(e) {
|
|
693
|
-
let t = null, r = null;
|
|
694
|
-
if (Ze) e = "<remove></remove>" + e;
|
|
695
|
-
else {
|
|
696
|
-
let t = _e(e, /^[\r\n\t ]+/);
|
|
697
|
-
r = t && t[0];
|
|
698
|
-
}
|
|
699
|
-
J === "application/xhtml+xml" && K === G && (e = "<html xmlns=\"http://www.w3.org/1999/xhtml\"><head></head><body>" + e + "</body></html>");
|
|
700
|
-
let i = h ? h.createHTML(e) : e;
|
|
701
|
-
if (K === G) try {
|
|
702
|
-
t = new ee().parseFromString(i, J);
|
|
703
|
-
} catch {}
|
|
704
|
-
if (!t || !t.documentElement) {
|
|
705
|
-
t = ae.createDocument(K, "template", null);
|
|
706
|
-
try {
|
|
707
|
-
t.documentElement.innerHTML = ut ? g : i;
|
|
708
|
-
} catch {}
|
|
709
|
-
}
|
|
710
|
-
let a = t.body || t.documentElement;
|
|
711
|
-
return e && r && a.insertBefore(n.createTextNode(r), a.childNodes[0] || null), K === G ? le.call(t, B ? "html" : "body")[0] : B ? t.documentElement : a;
|
|
712
|
-
}, Ct = function(e) {
|
|
713
|
-
return oe.call(e.ownerDocument || e, e, l.SHOW_ELEMENT | l.SHOW_COMMENT | l.SHOW_TEXT | l.SHOW_PROCESSING_INSTRUCTION | l.SHOW_CDATA_SECTION, null);
|
|
714
|
-
}, wt = function(e) {
|
|
715
|
-
return e instanceof d && (typeof e.nodeName != "string" || typeof e.textContent != "string" || typeof e.removeChild != "function" || !(e.attributes instanceof u) || typeof e.removeAttribute != "function" || typeof e.setAttribute != "function" || typeof e.namespaceURI != "string" || typeof e.insertBefore != "function" || typeof e.hasChildNodes != "function");
|
|
716
|
-
}, Tt = function(e) {
|
|
717
|
-
return typeof s == "function" && e instanceof s;
|
|
718
|
-
};
|
|
719
|
-
function $(e, n, r) {
|
|
720
|
-
de(e, (e) => {
|
|
721
|
-
e.call(t, n, r, X);
|
|
722
|
-
});
|
|
192
|
+
withDocument(e) {
|
|
193
|
+
return this.document = e, this;
|
|
723
194
|
}
|
|
724
|
-
|
|
725
|
-
|
|
726
|
-
if ($(_.beforeSanitizeElements, e, null), wt(e)) return Z(e), !0;
|
|
727
|
-
let r = Y(e.nodeName);
|
|
728
|
-
if ($(_.uponSanitizeElement, e, {
|
|
729
|
-
tagName: r,
|
|
730
|
-
allowedTags: M
|
|
731
|
-
}), Ye && e.hasChildNodes() && !Tt(e.firstElementChild) && E(/<[/\w!]/g, e.innerHTML) && E(/<[/\w!]/g, e.textContent) || e.nodeType === F.progressingInstruction || Ye && e.nodeType === F.comment && E(/<[/\w]/g, e.data)) return Z(e), !0;
|
|
732
|
-
if (!(R.tagCheck instanceof Function && R.tagCheck(r)) && (!M[r] || I[r])) {
|
|
733
|
-
if (!I[r] && Ot(r) && (P.tagNameCheck instanceof RegExp && E(P.tagNameCheck, r) || P.tagNameCheck instanceof Function && P.tagNameCheck(r))) return !1;
|
|
734
|
-
if (nt && !W[r]) {
|
|
735
|
-
let t = m(e) || e.parentNode, n = ie(e) || e.childNodes;
|
|
736
|
-
if (n && t) {
|
|
737
|
-
let r = n.length;
|
|
738
|
-
for (let i = r - 1; i >= 0; --i) {
|
|
739
|
-
let r = te(n[i], !0);
|
|
740
|
-
r.__removalCount = (e.__removalCount || 0) + 1, t.insertBefore(r, re(e));
|
|
741
|
-
}
|
|
742
|
-
}
|
|
743
|
-
}
|
|
744
|
-
return Z(e), !0;
|
|
745
|
-
}
|
|
746
|
-
return e instanceof c && !xt(e) || (r === "noscript" || r === "noembed" || r === "noframes") && E(/<\/no(script|embed|frames)/i, e.innerHTML) ? (Z(e), !0) : (z && e.nodeType === F.text && (n = e.textContent, de([
|
|
747
|
-
y,
|
|
748
|
-
x,
|
|
749
|
-
S
|
|
750
|
-
], (e) => {
|
|
751
|
-
n = w(n, e, " ");
|
|
752
|
-
}), e.textContent !== n && (C(t.removed, { element: e.cloneNode() }), e.textContent = n)), $(_.afterSanitizeElements, e, null), !1);
|
|
753
|
-
}, Dt = function(e, t, r) {
|
|
754
|
-
if (L[t] || et && (t === "id" || t === "name") && (r in n || r in gt)) return !1;
|
|
755
|
-
if (!(Ke && !L[t] && E(O, t)) && !(Ge && E(be, t)) && !(R.attributeCheck instanceof Function && R.attributeCheck(t, e))) {
|
|
756
|
-
if (!N[t] || L[t]) {
|
|
757
|
-
if (!(Ot(e) && (P.tagNameCheck instanceof RegExp && E(P.tagNameCheck, e) || P.tagNameCheck instanceof Function && P.tagNameCheck(e)) && (P.attributeNameCheck instanceof RegExp && E(P.attributeNameCheck, t) || P.attributeNameCheck instanceof Function && P.attributeNameCheck(t, e)) || t === "is" && P.allowCustomizedBuiltInElements && (P.tagNameCheck instanceof RegExp && E(P.tagNameCheck, r) || P.tagNameCheck instanceof Function && P.tagNameCheck(r)))) return !1;
|
|
758
|
-
} else if (!ot[t] && !E(Fe, w(r, Ne, "")) && !((t === "src" || t === "xlink:href" || t === "href") && e !== "script" && ve(r, "data:") === 0 && it[e]) && !(qe && !E(xe, w(r, Ne, ""))) && r) return !1;
|
|
759
|
-
}
|
|
760
|
-
return !0;
|
|
761
|
-
}, Ot = function(e) {
|
|
762
|
-
return e !== "annotation-xml" && _e(e, Pe);
|
|
763
|
-
}, kt = function(e) {
|
|
764
|
-
$(_.beforeSanitizeAttributes, e, null);
|
|
765
|
-
let { attributes: n } = e;
|
|
766
|
-
if (!n || wt(e)) return;
|
|
767
|
-
let r = {
|
|
768
|
-
attrName: "",
|
|
769
|
-
attrValue: "",
|
|
770
|
-
keepAttr: !0,
|
|
771
|
-
allowedAttributes: N,
|
|
772
|
-
forceKeepAttr: void 0
|
|
773
|
-
}, i = n.length;
|
|
774
|
-
for (; i--;) {
|
|
775
|
-
let { name: a, namespaceURI: o, value: s } = n[i], c = Y(a), l = s, u = a === "value" ? l : ye(l);
|
|
776
|
-
if (r.attrName = c, r.attrValue = u, r.keepAttr = !0, r.forceKeepAttr = void 0, $(_.uponSanitizeAttribute, e, r), u = r.attrValue, tt && (c === "id" || c === "name") && (Q(a, e), u = "user-content-" + u), Ye && E(/((--!?|])>)|<\/(style|script|title|xmp|textarea|noscript|iframe|noembed|noframes)/i, u)) {
|
|
777
|
-
Q(a, e);
|
|
778
|
-
continue;
|
|
779
|
-
}
|
|
780
|
-
if (c === "attributename" && _e(u, "href")) {
|
|
781
|
-
Q(a, e);
|
|
782
|
-
continue;
|
|
783
|
-
}
|
|
784
|
-
if (r.forceKeepAttr) continue;
|
|
785
|
-
if (!r.keepAttr) {
|
|
786
|
-
Q(a, e);
|
|
787
|
-
continue;
|
|
788
|
-
}
|
|
789
|
-
if (!Je && E(/\/>/i, u)) {
|
|
790
|
-
Q(a, e);
|
|
791
|
-
continue;
|
|
792
|
-
}
|
|
793
|
-
z && de([
|
|
794
|
-
y,
|
|
795
|
-
x,
|
|
796
|
-
S
|
|
797
|
-
], (e) => {
|
|
798
|
-
u = w(u, e, " ");
|
|
799
|
-
});
|
|
800
|
-
let d = Y(e.nodeName);
|
|
801
|
-
if (!Dt(d, c, u)) {
|
|
802
|
-
Q(a, e);
|
|
803
|
-
continue;
|
|
804
|
-
}
|
|
805
|
-
if (h && typeof f == "object" && typeof f.getAttributeType == "function" && !o) switch (f.getAttributeType(d, c)) {
|
|
806
|
-
case "TrustedHTML":
|
|
807
|
-
u = h.createHTML(u);
|
|
808
|
-
break;
|
|
809
|
-
case "TrustedScriptURL":
|
|
810
|
-
u = h.createScriptURL(u);
|
|
811
|
-
break;
|
|
812
|
-
}
|
|
813
|
-
if (u !== l) try {
|
|
814
|
-
o ? e.setAttributeNS(o, a, u) : e.setAttribute(a, u), wt(e) ? Z(e) : pe(t.removed);
|
|
815
|
-
} catch {
|
|
816
|
-
Q(a, e);
|
|
817
|
-
}
|
|
818
|
-
}
|
|
819
|
-
$(_.afterSanitizeAttributes, e, null);
|
|
820
|
-
}, At = function e(t) {
|
|
821
|
-
let n = null, r = Ct(t);
|
|
822
|
-
for ($(_.beforeSanitizeShadowDOM, t, null); n = r.nextNode();) $(_.uponSanitizeShadowNode, n, null), Et(n), kt(n), n.content instanceof a && e(n.content);
|
|
823
|
-
$(_.afterSanitizeShadowDOM, t, null);
|
|
824
|
-
};
|
|
825
|
-
return t.sanitize = function(e) {
|
|
826
|
-
let n = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : {}, i = null, o = null, c = null, l = null;
|
|
827
|
-
if (ut = !e, ut && (e = "<!-->"), typeof e != "string" && !Tt(e)) if (typeof e.toString == "function") {
|
|
828
|
-
if (e = e.toString(), typeof e != "string") throw D("dirty is not a string, aborting");
|
|
829
|
-
} else throw D("toString is not a function");
|
|
830
|
-
if (!t.isSupported) return e;
|
|
831
|
-
if (Xe || vt(n), t.removed = [], typeof e == "string" && (H = !1), H) {
|
|
832
|
-
if (e.nodeName) {
|
|
833
|
-
let t = Y(e.nodeName);
|
|
834
|
-
if (!M[t] || I[t]) throw D("root node is forbidden and cannot be sanitized in-place");
|
|
835
|
-
}
|
|
836
|
-
} else if (e instanceof s) i = St("<!---->"), o = i.ownerDocument.importNode(e, !0), o.nodeType === F.element && o.nodeName === "BODY" || o.nodeName === "HTML" ? i = o : i.appendChild(o);
|
|
837
|
-
else {
|
|
838
|
-
if (!V && !z && !B && e.indexOf("<") === -1) return h && $e ? h.createHTML(e) : e;
|
|
839
|
-
if (i = St(e), !i) return V ? null : $e ? g : "";
|
|
840
|
-
}
|
|
841
|
-
i && Ze && Z(i.firstChild);
|
|
842
|
-
let u = Ct(H ? e : i);
|
|
843
|
-
for (; c = u.nextNode();) Et(c), kt(c), c.content instanceof a && At(c.content);
|
|
844
|
-
if (H) return e;
|
|
845
|
-
if (V) {
|
|
846
|
-
if (Qe) for (l = ce.call(i.ownerDocument); i.firstChild;) l.appendChild(i.firstChild);
|
|
847
|
-
else l = i;
|
|
848
|
-
return (N.shadowroot || N.shadowrootmode) && (l = ue.call(r, l, !0)), l;
|
|
849
|
-
}
|
|
850
|
-
let d = B ? i.outerHTML : i.innerHTML;
|
|
851
|
-
return B && M["!doctype"] && i.ownerDocument && i.ownerDocument.doctype && i.ownerDocument.doctype.name && E(ze, i.ownerDocument.doctype.name) && (d = "<!DOCTYPE " + i.ownerDocument.doctype.name + ">\n" + d), z && de([
|
|
852
|
-
y,
|
|
853
|
-
x,
|
|
854
|
-
S
|
|
855
|
-
], (e) => {
|
|
856
|
-
d = w(d, e, " ");
|
|
857
|
-
}), h && $e ? h.createHTML(d) : d;
|
|
858
|
-
}, t.setConfig = function() {
|
|
859
|
-
vt(arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : {}), Xe = !0;
|
|
860
|
-
}, t.clearConfig = function() {
|
|
861
|
-
X = null, Xe = !1;
|
|
862
|
-
}, t.isValidAttribute = function(e, t, n) {
|
|
863
|
-
return X || vt({}), Dt(Y(e), Y(t), n);
|
|
864
|
-
}, t.addHook = function(e, t) {
|
|
865
|
-
typeof t == "function" && C(_[e], t);
|
|
866
|
-
}, t.removeHook = function(e, t) {
|
|
867
|
-
if (t !== void 0) {
|
|
868
|
-
let n = fe(_[e], t);
|
|
869
|
-
return n === -1 ? void 0 : me(_[e], n, 1)[0];
|
|
870
|
-
}
|
|
871
|
-
return pe(_[e]);
|
|
872
|
-
}, t.removeHooks = function(e) {
|
|
873
|
-
_[e] = [];
|
|
874
|
-
}, t.removeAllHooks = function() {
|
|
875
|
-
_ = Ue();
|
|
876
|
-
}, t;
|
|
877
|
-
}
|
|
878
|
-
var I = We(), L = class {
|
|
879
|
-
config;
|
|
880
|
-
constructor(e) {
|
|
881
|
-
this.config = e;
|
|
195
|
+
withCommands(e) {
|
|
196
|
+
return this.commands = [...e], this;
|
|
882
197
|
}
|
|
883
|
-
|
|
884
|
-
return
|
|
885
|
-
|
|
886
|
-
|
|
887
|
-
|
|
198
|
+
build() {
|
|
199
|
+
return new m({
|
|
200
|
+
root: this.requireRootElement(),
|
|
201
|
+
domResolver: this.domResolver,
|
|
202
|
+
input: this.requireInput(),
|
|
203
|
+
output: this.requireOutput(),
|
|
204
|
+
textareaBridge: this.textareaBridge,
|
|
205
|
+
markdown: this.requireMarkdown(),
|
|
206
|
+
plugins: this.plugins,
|
|
207
|
+
commands: this.commands,
|
|
208
|
+
document: this.resolveDocument()
|
|
888
209
|
});
|
|
889
210
|
}
|
|
890
|
-
|
|
891
|
-
if (
|
|
892
|
-
let
|
|
893
|
-
|
|
894
|
-
|
|
895
|
-
t.add(e);
|
|
896
|
-
});
|
|
897
|
-
}), [...t];
|
|
898
|
-
}
|
|
899
|
-
}, R = class {
|
|
900
|
-
plugins;
|
|
901
|
-
root;
|
|
902
|
-
initialized = !1;
|
|
903
|
-
constructor(e) {
|
|
904
|
-
this.root = e;
|
|
905
|
-
}
|
|
906
|
-
use(...e) {
|
|
907
|
-
return this.assertNotInitialized(), this.plugins = e, this;
|
|
211
|
+
requireRootElement() {
|
|
212
|
+
if (this.root instanceof HTMLElement) return this.root;
|
|
213
|
+
let e = document.querySelector(this.root);
|
|
214
|
+
if (!(e instanceof HTMLElement)) throw Error(`ModuloEditorBuilder could not resolve root element from selector "${this.root}".`);
|
|
215
|
+
return e;
|
|
908
216
|
}
|
|
909
|
-
|
|
910
|
-
|
|
217
|
+
requireInput() {
|
|
218
|
+
if (!this.input) throw Error("ModuloEditorBuilder requires an input adapter.");
|
|
219
|
+
return this.input;
|
|
911
220
|
}
|
|
912
|
-
|
|
913
|
-
if (this.
|
|
914
|
-
|
|
915
|
-
this.initialized = !0;
|
|
916
|
-
let r = new Ge({
|
|
917
|
-
root: e,
|
|
918
|
-
domResolver: t,
|
|
919
|
-
input: new f(),
|
|
920
|
-
output: new p(),
|
|
921
|
-
markdown: new oe(new ae(), new L(g)),
|
|
922
|
-
textareaBridge: new te(),
|
|
923
|
-
plugins: n
|
|
924
|
-
});
|
|
925
|
-
return r.init(), r;
|
|
221
|
+
requireOutput() {
|
|
222
|
+
if (!this.output) throw Error("ModuloEditorBuilder requires an output adapter.");
|
|
223
|
+
return this.output;
|
|
926
224
|
}
|
|
927
|
-
|
|
928
|
-
if (
|
|
929
|
-
|
|
930
|
-
if (!(t instanceof HTMLElement)) throw Error(`ModuloEditor: root element "${e}" not found.`);
|
|
931
|
-
return t;
|
|
225
|
+
requireMarkdown() {
|
|
226
|
+
if (!this.markdown) throw Error("ModuloEditorBuilder requires a markdown processor.");
|
|
227
|
+
return this.markdown;
|
|
932
228
|
}
|
|
933
|
-
|
|
934
|
-
|
|
229
|
+
resolveDocument() {
|
|
230
|
+
return this.document ?? new d();
|
|
935
231
|
}
|
|
936
|
-
},
|
|
232
|
+
}, m = class {
|
|
937
233
|
document;
|
|
938
234
|
input;
|
|
939
235
|
output;
|
|
@@ -946,16 +242,16 @@ var I = We(), L = class {
|
|
|
946
242
|
unsubscribeInputChange;
|
|
947
243
|
initialized = !1;
|
|
948
244
|
slots;
|
|
949
|
-
constructor({ document: n = new d(), input: r, output: i, markdown: a, commands: o = [], plugins: s = [], builtinCommands: c = !0, root: l, domResolver:
|
|
950
|
-
this.document = n, this.input = r, this.output = i, this.markdown = a, this.plugins = s, this.root = l, this.domResolver =
|
|
951
|
-
let
|
|
952
|
-
|
|
245
|
+
constructor({ document: n = new d(), input: r, output: i, markdown: a, commands: o = [], plugins: s = [], builtinCommands: c = !0, root: l, domResolver: p, textareaBridge: m }) {
|
|
246
|
+
this.document = n, this.input = r, this.output = i, this.markdown = a, this.plugins = s, this.root = l, this.domResolver = p ?? new u(), this.textareaBridge = m;
|
|
247
|
+
let h = new e();
|
|
248
|
+
f(h, {
|
|
953
249
|
builtinCommands: c,
|
|
954
250
|
commands: o
|
|
955
|
-
}), this.commands = new t(
|
|
251
|
+
}), this.commands = new t(h, () => this.createCommandContext());
|
|
956
252
|
}
|
|
957
253
|
static create(e) {
|
|
958
|
-
return new
|
|
254
|
+
return new p(e);
|
|
959
255
|
}
|
|
960
256
|
init() {
|
|
961
257
|
if (this.initialized) return;
|
|
@@ -1011,8 +307,18 @@ var I = We(), L = class {
|
|
|
1011
307
|
}
|
|
1012
308
|
};
|
|
1013
309
|
}
|
|
310
|
+
}, h = class {
|
|
311
|
+
parser;
|
|
312
|
+
sanitize;
|
|
313
|
+
constructor(e, t) {
|
|
314
|
+
this.parser = e, this.sanitize = t;
|
|
315
|
+
}
|
|
316
|
+
toHtml(e) {
|
|
317
|
+
let t = this.parser.parse(e);
|
|
318
|
+
return this.sanitize.sanitize(t);
|
|
319
|
+
}
|
|
1014
320
|
};
|
|
1015
321
|
//#endregion
|
|
1016
|
-
export {
|
|
322
|
+
export { h as DefaultMarkdownProcessor, m as ModuloEditor };
|
|
1017
323
|
|
|
1018
324
|
//# sourceMappingURL=modulo-editor.js.map
|