"use strict"; Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" }); const MdEditor = require("./MdEditor.cjs"); const MdPreview = require("./chunks/index.cjs"); const NormalToolbar = require("./NormalToolbar.cjs"); const DropdownToolbar = require("./chunks/index2.cjs"); const ModalToolbar = require("./ModalToolbar.cjs"); const MdCatalog = require("./chunks/index3.cjs"); const MdModal = require("./chunks/index4.cjs"); const vue = require("vue"); const vueTsx = require("./chunks/vue-tsx.cjs"); const config$1 = require("./chunks/config.cjs"); const config = require("./config.cjs"); function _mergeNamespaces(n, m) { for (var i = 0; i < m.length; i++) { const e = m[i]; if (typeof e !== "string" && !Array.isArray(e)) { for (const k in e) { if (k !== "default" && !(k in n)) { const d = Object.getOwnPropertyDescriptor(e, k); if (d) { Object.defineProperty(n, k, d.get ? d : { enumerable: true, get: () => e[k] }); } } } } } return Object.freeze(Object.defineProperty(n, Symbol.toStringTag, { value: "Module" })); } const props = { onClick: { type: Function, default: void 0 } }; const NormalFooterToolbar = /* @__PURE__ */ vue.defineComponent({ name: "NormalFooterToolbar", props, emits: ["onClick"], setup(props2, ctx) { return () => { const Children = vueTsx.getSlot({ props: props2, ctx }); return vue.createVNode("div", { "class": `${config$1.prefix}-footer-item`, "onClick": (e) => { if (props2.onClick instanceof Function) { props2.onClick(e); } else { ctx.emit("onClick", e); } } }, [Children]); }; } }); NormalFooterToolbar.install = (app) => { app.component(NormalFooterToolbar.name, NormalFooterToolbar); return app; }; function getDefaultExportFromCjs(x) { return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, "default") ? x["default"] : x; } var lib$1 = { exports: {} }; var _default$1 = {}; var lib = { exports: {} }; var _default = {}; function getDefaultWhiteList$1() { var whiteList = {}; whiteList["align-content"] = false; whiteList["align-items"] = false; whiteList["align-self"] = false; whiteList["alignment-adjust"] = false; whiteList["alignment-baseline"] = false; whiteList["all"] = false; whiteList["anchor-point"] = false; whiteList["animation"] = false; whiteList["animation-delay"] = false; whiteList["animation-direction"] = false; whiteList["animation-duration"] = false; whiteList["animation-fill-mode"] = false; whiteList["animation-iteration-count"] = false; whiteList["animation-name"] = false; whiteList["animation-play-state"] = false; whiteList["animation-timing-function"] = false; whiteList["azimuth"] = false; whiteList["backface-visibility"] = false; whiteList["background"] = true; whiteList["background-attachment"] = true; whiteList["background-clip"] = true; whiteList["background-color"] = true; whiteList["background-image"] = true; whiteList["background-origin"] = true; whiteList["background-position"] = true; whiteList["background-repeat"] = true; whiteList["background-size"] = true; whiteList["baseline-shift"] = false; whiteList["binding"] = false; whiteList["bleed"] = false; whiteList["bookmark-label"] = false; whiteList["bookmark-level"] = false; whiteList["bookmark-state"] = false; whiteList["border"] = true; whiteList["border-bottom"] = true; whiteList["border-bottom-color"] = true; whiteList["border-bottom-left-radius"] = true; whiteList["border-bottom-right-radius"] = true; whiteList["border-bottom-style"] = true; whiteList["border-bottom-width"] = true; whiteList["border-collapse"] = true; whiteList["border-color"] = true; whiteList["border-image"] = true; whiteList["border-image-outset"] = true; whiteList["border-image-repeat"] = true; whiteList["border-image-slice"] = true; whiteList["border-image-source"] = true; whiteList["border-image-width"] = true; whiteList["border-left"] = true; whiteList["border-left-color"] = true; whiteList["border-left-style"] = true; whiteList["border-left-width"] = true; whiteList["border-radius"] = true; whiteList["border-right"] = true; whiteList["border-right-color"] = true; whiteList["border-right-style"] = true; whiteList["border-right-width"] = true; whiteList["border-spacing"] = true; whiteList["border-style"] = true; whiteList["border-top"] = true; whiteList["border-top-color"] = true; whiteList["border-top-left-radius"] = true; whiteList["border-top-right-radius"] = true; whiteList["border-top-style"] = true; whiteList["border-top-width"] = true; whiteList["border-width"] = true; whiteList["bottom"] = false; whiteList["box-decoration-break"] = true; whiteList["box-shadow"] = true; whiteList["box-sizing"] = true; whiteList["box-snap"] = true; whiteList["box-suppress"] = true; whiteList["break-after"] = true; whiteList["break-before"] = true; whiteList["break-inside"] = true; whiteList["caption-side"] = false; whiteList["chains"] = false; whiteList["clear"] = true; whiteList["clip"] = false; whiteList["clip-path"] = false; whiteList["clip-rule"] = false; whiteList["color"] = true; whiteList["color-interpolation-filters"] = true; whiteList["column-count"] = false; whiteList["column-fill"] = false; whiteList["column-gap"] = false; whiteList["column-rule"] = false; whiteList["column-rule-color"] = false; whiteList["column-rule-style"] = false; whiteList["column-rule-width"] = false; whiteList["column-span"] = false; whiteList["column-width"] = false; whiteList["columns"] = false; whiteList["contain"] = false; whiteList["content"] = false; whiteList["counter-increment"] = false; whiteList["counter-reset"] = false; whiteList["counter-set"] = false; whiteList["crop"] = false; whiteList["cue"] = false; whiteList["cue-after"] = false; whiteList["cue-before"] = false; whiteList["cursor"] = false; whiteList["direction"] = false; whiteList["display"] = true; whiteList["display-inside"] = true; whiteList["display-list"] = true; whiteList["display-outside"] = true; whiteList["dominant-baseline"] = false; whiteList["elevation"] = false; whiteList["empty-cells"] = false; whiteList["filter"] = false; whiteList["flex"] = false; whiteList["flex-basis"] = false; whiteList["flex-direction"] = false; whiteList["flex-flow"] = false; whiteList["flex-grow"] = false; whiteList["flex-shrink"] = false; whiteList["flex-wrap"] = false; whiteList["float"] = false; whiteList["float-offset"] = false; whiteList["flood-color"] = false; whiteList["flood-opacity"] = false; whiteList["flow-from"] = false; whiteList["flow-into"] = false; whiteList["font"] = true; whiteList["font-family"] = true; whiteList["font-feature-settings"] = true; whiteList["font-kerning"] = true; whiteList["font-language-override"] = true; whiteList["font-size"] = true; whiteList["font-size-adjust"] = true; whiteList["font-stretch"] = true; whiteList["font-style"] = true; whiteList["font-synthesis"] = true; whiteList["font-variant"] = true; whiteList["font-variant-alternates"] = true; whiteList["font-variant-caps"] = true; whiteList["font-variant-east-asian"] = true; whiteList["font-variant-ligatures"] = true; whiteList["font-variant-numeric"] = true; whiteList["font-variant-position"] = true; whiteList["font-weight"] = true; whiteList["grid"] = false; whiteList["grid-area"] = false; whiteList["grid-auto-columns"] = false; whiteList["grid-auto-flow"] = false; whiteList["grid-auto-rows"] = false; whiteList["grid-column"] = false; whiteList["grid-column-end"] = false; whiteList["grid-column-start"] = false; whiteList["grid-row"] = false; whiteList["grid-row-end"] = false; whiteList["grid-row-start"] = false; whiteList["grid-template"] = false; whiteList["grid-template-areas"] = false; whiteList["grid-template-columns"] = false; whiteList["grid-template-rows"] = false; whiteList["hanging-punctuation"] = false; whiteList["height"] = true; whiteList["hyphens"] = false; whiteList["icon"] = false; whiteList["image-orientation"] = false; whiteList["image-resolution"] = false; whiteList["ime-mode"] = false; whiteList["initial-letters"] = false; whiteList["inline-box-align"] = false; whiteList["justify-content"] = false; whiteList["justify-items"] = false; whiteList["justify-self"] = false; whiteList["left"] = false; whiteList["letter-spacing"] = true; whiteList["lighting-color"] = true; whiteList["line-box-contain"] = false; whiteList["line-break"] = false; whiteList["line-grid"] = false; whiteList["line-height"] = false; whiteList["line-snap"] = false; whiteList["line-stacking"] = false; whiteList["line-stacking-ruby"] = false; whiteList["line-stacking-shift"] = false; whiteList["line-stacking-strategy"] = false; whiteList["list-style"] = true; whiteList["list-style-image"] = true; whiteList["list-style-position"] = true; whiteList["list-style-type"] = true; whiteList["margin"] = true; whiteList["margin-bottom"] = true; whiteList["margin-left"] = true; whiteList["margin-right"] = true; whiteList["margin-top"] = true; whiteList["marker-offset"] = false; whiteList["marker-side"] = false; whiteList["marks"] = false; whiteList["mask"] = false; whiteList["mask-box"] = false; whiteList["mask-box-outset"] = false; whiteList["mask-box-repeat"] = false; whiteList["mask-box-slice"] = false; whiteList["mask-box-source"] = false; whiteList["mask-box-width"] = false; whiteList["mask-clip"] = false; whiteList["mask-image"] = false; whiteList["mask-origin"] = false; whiteList["mask-position"] = false; whiteList["mask-repeat"] = false; whiteList["mask-size"] = false; whiteList["mask-source-type"] = false; whiteList["mask-type"] = false; whiteList["max-height"] = true; whiteList["max-lines"] = false; whiteList["max-width"] = true; whiteList["min-height"] = true; whiteList["min-width"] = true; whiteList["move-to"] = false; whiteList["nav-down"] = false; whiteList["nav-index"] = false; whiteList["nav-left"] = false; whiteList["nav-right"] = false; whiteList["nav-up"] = false; whiteList["object-fit"] = false; whiteList["object-position"] = false; whiteList["opacity"] = false; whiteList["order"] = false; whiteList["orphans"] = false; whiteList["outline"] = false; whiteList["outline-color"] = false; whiteList["outline-offset"] = false; whiteList["outline-style"] = false; whiteList["outline-width"] = false; whiteList["overflow"] = false; whiteList["overflow-wrap"] = false; whiteList["overflow-x"] = false; whiteList["overflow-y"] = false; whiteList["padding"] = true; whiteList["padding-bottom"] = true; whiteList["padding-left"] = true; whiteList["padding-right"] = true; whiteList["padding-top"] = true; whiteList["page"] = false; whiteList["page-break-after"] = false; whiteList["page-break-before"] = false; whiteList["page-break-inside"] = false; whiteList["page-policy"] = false; whiteList["pause"] = false; whiteList["pause-after"] = false; whiteList["pause-before"] = false; whiteList["perspective"] = false; whiteList["perspective-origin"] = false; whiteList["pitch"] = false; whiteList["pitch-range"] = false; whiteList["play-during"] = false; whiteList["position"] = false; whiteList["presentation-level"] = false; whiteList["quotes"] = false; whiteList["region-fragment"] = false; whiteList["resize"] = false; whiteList["rest"] = false; whiteList["rest-after"] = false; whiteList["rest-before"] = false; whiteList["richness"] = false; whiteList["right"] = false; whiteList["rotation"] = false; whiteList["rotation-point"] = false; whiteList["ruby-align"] = false; whiteList["ruby-merge"] = false; whiteList["ruby-position"] = false; whiteList["shape-image-threshold"] = false; whiteList["shape-outside"] = false; whiteList["shape-margin"] = false; whiteList["size"] = false; whiteList["speak"] = false; whiteList["speak-as"] = false; whiteList["speak-header"] = false; whiteList["speak-numeral"] = false; whiteList["speak-punctuation"] = false; whiteList["speech-rate"] = false; whiteList["stress"] = false; whiteList["string-set"] = false; whiteList["tab-size"] = false; whiteList["table-layout"] = false; whiteList["text-align"] = true; whiteList["text-align-last"] = true; whiteList["text-combine-upright"] = true; whiteList["text-decoration"] = true; whiteList["text-decoration-color"] = true; whiteList["text-decoration-line"] = true; whiteList["text-decoration-skip"] = true; whiteList["text-decoration-style"] = true; whiteList["text-emphasis"] = true; whiteList["text-emphasis-color"] = true; whiteList["text-emphasis-position"] = true; whiteList["text-emphasis-style"] = true; whiteList["text-height"] = true; whiteList["text-indent"] = true; whiteList["text-justify"] = true; whiteList["text-orientation"] = true; whiteList["text-overflow"] = true; whiteList["text-shadow"] = true; whiteList["text-space-collapse"] = true; whiteList["text-transform"] = true; whiteList["text-underline-position"] = true; whiteList["text-wrap"] = true; whiteList["top"] = false; whiteList["transform"] = false; whiteList["transform-origin"] = false; whiteList["transform-style"] = false; whiteList["transition"] = false; whiteList["transition-delay"] = false; whiteList["transition-duration"] = false; whiteList["transition-property"] = false; whiteList["transition-timing-function"] = false; whiteList["unicode-bidi"] = false; whiteList["vertical-align"] = false; whiteList["visibility"] = false; whiteList["voice-balance"] = false; whiteList["voice-duration"] = false; whiteList["voice-family"] = false; whiteList["voice-pitch"] = false; whiteList["voice-range"] = false; whiteList["voice-rate"] = false; whiteList["voice-stress"] = false; whiteList["voice-volume"] = false; whiteList["volume"] = false; whiteList["white-space"] = false; whiteList["widows"] = false; whiteList["width"] = true; whiteList["will-change"] = false; whiteList["word-break"] = true; whiteList["word-spacing"] = true; whiteList["word-wrap"] = true; whiteList["wrap-flow"] = false; whiteList["wrap-through"] = false; whiteList["writing-mode"] = false; whiteList["z-index"] = false; return whiteList; } function onAttr(name, value, options) { } function onIgnoreAttr(name, value, options) { } var REGEXP_URL_JAVASCRIPT = /javascript\s*\:/img; function safeAttrValue$1(name, value) { if (REGEXP_URL_JAVASCRIPT.test(value)) return ""; return value; } _default.whiteList = getDefaultWhiteList$1(); _default.getDefaultWhiteList = getDefaultWhiteList$1; _default.onAttr = onAttr; _default.onIgnoreAttr = onIgnoreAttr; _default.safeAttrValue = safeAttrValue$1; var util$1 = { indexOf: function(arr, item) { var i, j; if (Array.prototype.indexOf) { return arr.indexOf(item); } for (i = 0, j = arr.length; i < j; i++) { if (arr[i] === item) { return i; } } return -1; }, forEach: function(arr, fn, scope) { var i, j; if (Array.prototype.forEach) { return arr.forEach(fn, scope); } for (i = 0, j = arr.length; i < j; i++) { fn.call(scope, arr[i], i, arr); } }, trim: function(str) { if (String.prototype.trim) { return str.trim(); } return str.replace(/(^\s*)|(\s*$)/g, ""); }, trimRight: function(str) { if (String.prototype.trimRight) { return str.trimRight(); } return str.replace(/(\s*$)/g, ""); } }; var _$3 = util$1; function parseStyle$1(css2, onAttr2) { css2 = _$3.trimRight(css2); if (css2[css2.length - 1] !== ";") css2 += ";"; var cssLength = css2.length; var isParenthesisOpen = false; var lastPos = 0; var i = 0; var retCSS = ""; function addNewAttr() { if (!isParenthesisOpen) { var source = _$3.trim(css2.slice(lastPos, i)); var j2 = source.indexOf(":"); if (j2 !== -1) { var name = _$3.trim(source.slice(0, j2)); var value = _$3.trim(source.slice(j2 + 1)); if (name) { var ret = onAttr2(lastPos, retCSS.length, name, value, source); if (ret) retCSS += ret + "; "; } } } lastPos = i + 1; } for (; i < cssLength; i++) { var c = css2[i]; if (c === "/" && css2[i + 1] === "*") { var j = css2.indexOf("*/", i + 2); if (j === -1) break; i = j + 1; lastPos = i + 1; isParenthesisOpen = false; } else if (c === "(") { isParenthesisOpen = true; } else if (c === ")") { isParenthesisOpen = false; } else if (c === ";") { if (isParenthesisOpen) ; else { addNewAttr(); } } else if (c === "\n") { addNewAttr(); } } return _$3.trim(retCSS); } var parser$2 = parseStyle$1; var DEFAULT$1 = _default; var parseStyle = parser$2; function isNull$1(obj) { return obj === void 0 || obj === null; } function shallowCopyObject$1(obj) { var ret = {}; for (var i in obj) { ret[i] = obj[i]; } return ret; } function FilterCSS$2(options) { options = shallowCopyObject$1(options || {}); options.whiteList = options.whiteList || DEFAULT$1.whiteList; options.onAttr = options.onAttr || DEFAULT$1.onAttr; options.onIgnoreAttr = options.onIgnoreAttr || DEFAULT$1.onIgnoreAttr; options.safeAttrValue = options.safeAttrValue || DEFAULT$1.safeAttrValue; this.options = options; } FilterCSS$2.prototype.process = function(css2) { css2 = css2 || ""; css2 = css2.toString(); if (!css2) return ""; var me = this; var options = me.options; var whiteList = options.whiteList; var onAttr2 = options.onAttr; var onIgnoreAttr2 = options.onIgnoreAttr; var safeAttrValue2 = options.safeAttrValue; var retCSS = parseStyle(css2, function(sourcePosition, position, name, value, source) { var check = whiteList[name]; var isWhite = false; if (check === true) isWhite = check; else if (typeof check === "function") isWhite = check(value); else if (check instanceof RegExp) isWhite = check.test(value); if (isWhite !== true) isWhite = false; value = safeAttrValue2(name, value); if (!value) return; var opts = { position, sourcePosition, source, isWhite }; if (isWhite) { var ret = onAttr2(name, value, opts); if (isNull$1(ret)) { return name + ":" + value; } else { return ret; } } else { var ret = onIgnoreAttr2(name, value, opts); if (!isNull$1(ret)) { return ret; } } }); return retCSS; }; var css = FilterCSS$2; (function(module2, exports2) { var DEFAULT2 = _default; var FilterCSS2 = css; function filterCSS(html, options) { var xss2 = new FilterCSS2(options); return xss2.process(html); } exports2 = module2.exports = filterCSS; exports2.FilterCSS = FilterCSS2; for (var i in DEFAULT2) exports2[i] = DEFAULT2[i]; if (typeof window !== "undefined") { window.filterCSS = module2.exports; } })(lib, lib.exports); var libExports$1 = lib.exports; var util = { indexOf: function(arr, item) { var i, j; if (Array.prototype.indexOf) { return arr.indexOf(item); } for (i = 0, j = arr.length; i < j; i++) { if (arr[i] === item) { return i; } } return -1; }, forEach: function(arr, fn, scope) { var i, j; if (Array.prototype.forEach) { return arr.forEach(fn, scope); } for (i = 0, j = arr.length; i < j; i++) { fn.call(scope, arr[i], i, arr); } }, trim: function(str) { if (String.prototype.trim) { return str.trim(); } return str.replace(/(^\s*)|(\s*$)/g, ""); }, spaceIndex: function(str) { var reg = /\s|\n|\t/; var match = reg.exec(str); return match ? match.index : -1; } }; var FilterCSS$1 = libExports$1.FilterCSS; var getDefaultCSSWhiteList = libExports$1.getDefaultWhiteList; var _$2 = util; function getDefaultWhiteList() { return { a: ["target", "href", "title"], abbr: ["title"], address: [], area: ["shape", "coords", "href", "alt"], article: [], aside: [], audio: [ "autoplay", "controls", "crossorigin", "loop", "muted", "preload", "src" ], b: [], bdi: ["dir"], bdo: ["dir"], big: [], blockquote: ["cite"], br: [], caption: [], center: [], cite: [], code: [], col: ["align", "valign", "span", "width"], colgroup: ["align", "valign", "span", "width"], dd: [], del: ["datetime"], details: ["open"], div: [], dl: [], dt: [], em: [], figcaption: [], figure: [], font: ["color", "size", "face"], footer: [], h1: [], h2: [], h3: [], h4: [], h5: [], h6: [], header: [], hr: [], i: [], img: ["src", "alt", "title", "width", "height", "loading"], ins: ["datetime"], kbd: [], li: [], mark: [], nav: [], ol: [], p: [], pre: [], s: [], section: [], small: [], span: [], sub: [], summary: [], sup: [], strong: [], strike: [], table: ["width", "border", "align", "valign"], tbody: ["align", "valign"], td: ["width", "rowspan", "colspan", "align", "valign"], tfoot: ["align", "valign"], th: ["width", "rowspan", "colspan", "align", "valign"], thead: ["align", "valign"], tr: ["rowspan", "align", "valign"], tt: [], u: [], ul: [], video: [ "autoplay", "controls", "crossorigin", "loop", "muted", "playsinline", "poster", "preload", "src", "height", "width" ] }; } var defaultCSSFilter = new FilterCSS$1(); function onTag(tag, html, options) { } function onIgnoreTag(tag, html, options) { } function onTagAttr(tag, name, value) { } function onIgnoreTagAttr(tag, name, value) { } function escapeHtml(html) { return html.replace(REGEXP_LT, "<").replace(REGEXP_GT, ">"); } function safeAttrValue(tag, name, value, cssFilter) { value = friendlyAttrValue(value); if (name === "href" || name === "src") { value = _$2.trim(value); if (value === "#") return "#"; if (!(value.substr(0, 7) === "http://" || value.substr(0, 8) === "https://" || value.substr(0, 7) === "mailto:" || value.substr(0, 4) === "tel:" || value.substr(0, 11) === "data:image/" || value.substr(0, 6) === "ftp://" || value.substr(0, 2) === "./" || value.substr(0, 3) === "../" || value[0] === "#" || value[0] === "/")) { return ""; } } else if (name === "background") { REGEXP_DEFAULT_ON_TAG_ATTR_4.lastIndex = 0; if (REGEXP_DEFAULT_ON_TAG_ATTR_4.test(value)) { return ""; } } else if (name === "style") { REGEXP_DEFAULT_ON_TAG_ATTR_7.lastIndex = 0; if (REGEXP_DEFAULT_ON_TAG_ATTR_7.test(value)) { return ""; } REGEXP_DEFAULT_ON_TAG_ATTR_8.lastIndex = 0; if (REGEXP_DEFAULT_ON_TAG_ATTR_8.test(value)) { REGEXP_DEFAULT_ON_TAG_ATTR_4.lastIndex = 0; if (REGEXP_DEFAULT_ON_TAG_ATTR_4.test(value)) { return ""; } } if (cssFilter !== false) { cssFilter = cssFilter || defaultCSSFilter; value = cssFilter.process(value); } } value = escapeAttrValue(value); return value; } var REGEXP_LT = //g; var REGEXP_QUOTE = /"/g; var REGEXP_QUOTE_2 = /"/g; var REGEXP_ATTR_VALUE_1 = /&#([a-zA-Z0-9]*);?/gim; var REGEXP_ATTR_VALUE_COLON = /:?/gim; var REGEXP_ATTR_VALUE_NEWLINE = /&newline;?/gim; var REGEXP_DEFAULT_ON_TAG_ATTR_4 = /((j\s*a\s*v\s*a|v\s*b|l\s*i\s*v\s*e)\s*s\s*c\s*r\s*i\s*p\s*t\s*|m\s*o\s*c\s*h\s*a):/gi; var REGEXP_DEFAULT_ON_TAG_ATTR_7 = /e\s*x\s*p\s*r\s*e\s*s\s*s\s*i\s*o\s*n\s*\(.*/gi; var REGEXP_DEFAULT_ON_TAG_ATTR_8 = /u\s*r\s*l\s*\(.*/gi; function escapeQuote(str) { return str.replace(REGEXP_QUOTE, """); } function unescapeQuote(str) { return str.replace(REGEXP_QUOTE_2, '"'); } function escapeHtmlEntities(str) { return str.replace(REGEXP_ATTR_VALUE_1, function replaceUnicode(str2, code) { return code[0] === "x" || code[0] === "X" ? String.fromCharCode(parseInt(code.substr(1), 16)) : String.fromCharCode(parseInt(code, 10)); }); } function escapeDangerHtml5Entities(str) { return str.replace(REGEXP_ATTR_VALUE_COLON, ":").replace(REGEXP_ATTR_VALUE_NEWLINE, " "); } function clearNonPrintableCharacter(str) { var str2 = ""; for (var i = 0, len = str.length; i < len; i++) { str2 += str.charCodeAt(i) < 32 ? " " : str.charAt(i); } return _$2.trim(str2); } function friendlyAttrValue(str) { str = unescapeQuote(str); str = escapeHtmlEntities(str); str = escapeDangerHtml5Entities(str); str = clearNonPrintableCharacter(str); return str; } function escapeAttrValue(str) { str = escapeQuote(str); str = escapeHtml(str); return str; } function onIgnoreTagStripAll() { return ""; } function StripTagBody(tags, next) { if (typeof next !== "function") { next = function() { }; } var isRemoveAllTag = !Array.isArray(tags); function isRemoveTag(tag) { if (isRemoveAllTag) return true; return _$2.indexOf(tags, tag) !== -1; } var removeList = []; var posStart = false; return { onIgnoreTag: function(tag, html, options) { if (isRemoveTag(tag)) { if (options.isClosing) { var ret = "[/removed]"; var end = options.position + ret.length; removeList.push([ posStart !== false ? posStart : options.position, end ]); posStart = false; return ret; } else { if (!posStart) { posStart = options.position; } return "[removed]"; } } else { return next(tag, html, options); } }, remove: function(html) { var rethtml = ""; var lastPos = 0; _$2.forEach(removeList, function(pos) { rethtml += html.slice(lastPos, pos[0]); lastPos = pos[1]; }); rethtml += html.slice(lastPos); return rethtml; } }; } function stripCommentTag(html) { var retHtml = ""; var lastPos = 0; while (lastPos < html.length) { var i = html.indexOf("", i); if (j === -1) { break; } lastPos = j + 3; } return retHtml; } function stripBlankChar(html) { var chars = html.split(""); chars = chars.filter(function(char) { var c = char.charCodeAt(0); if (c === 127) return false; if (c <= 31) { if (c === 10 || c === 13) return true; return false; } return true; }); return chars.join(""); } _default$1.whiteList = getDefaultWhiteList(); _default$1.getDefaultWhiteList = getDefaultWhiteList; _default$1.onTag = onTag; _default$1.onIgnoreTag = onIgnoreTag; _default$1.onTagAttr = onTagAttr; _default$1.onIgnoreTagAttr = onIgnoreTagAttr; _default$1.safeAttrValue = safeAttrValue; _default$1.escapeHtml = escapeHtml; _default$1.escapeQuote = escapeQuote; _default$1.unescapeQuote = unescapeQuote; _default$1.escapeHtmlEntities = escapeHtmlEntities; _default$1.escapeDangerHtml5Entities = escapeDangerHtml5Entities; _default$1.clearNonPrintableCharacter = clearNonPrintableCharacter; _default$1.friendlyAttrValue = friendlyAttrValue; _default$1.escapeAttrValue = escapeAttrValue; _default$1.onIgnoreTagStripAll = onIgnoreTagStripAll; _default$1.StripTagBody = StripTagBody; _default$1.stripCommentTag = stripCommentTag; _default$1.stripBlankChar = stripBlankChar; _default$1.attributeWrapSign = '"'; _default$1.cssFilter = defaultCSSFilter; _default$1.getDefaultCSSWhiteList = getDefaultCSSWhiteList; var parser$1 = {}; var _$1 = util; function getTagName(html) { var i = _$1.spaceIndex(html); var tagName; if (i === -1) { tagName = html.slice(1, -1); } else { tagName = html.slice(1, i + 1); } tagName = _$1.trim(tagName).toLowerCase(); if (tagName.slice(0, 1) === "/") tagName = tagName.slice(1); if (tagName.slice(-1) === "/") tagName = tagName.slice(0, -1); return tagName; } function isClosing(html) { return html.slice(0, 2) === "" || currentPos === len - 1) { rethtml += escapeHtml2(html.slice(lastPos, tagStart)); currentHtml = html.slice(tagStart, currentPos + 1); currentTagName = getTagName(currentHtml); rethtml += onTag2( tagStart, rethtml.length, currentTagName, currentHtml, isClosing(currentHtml) ); lastPos = currentPos + 1; tagStart = false; continue; } if (c === '"' || c === "'") { var i = 1; var ic = html.charAt(currentPos - i); while (ic.trim() === "" || ic === "=") { if (ic === "=") { quoteStart = c; continue chariterator; } ic = html.charAt(currentPos - ++i); } } } else { if (c === quoteStart) { quoteStart = false; continue; } } } } if (lastPos < len) { rethtml += escapeHtml2(html.substr(lastPos)); } return rethtml; } var REGEXP_ILLEGAL_ATTR_NAME = /[^a-zA-Z0-9\\_:.-]/gim; function parseAttr$1(html, onAttr2) { var lastPos = 0; var lastMarkPos = 0; var retAttrs = []; var tmpName = false; var len = html.length; function addAttr(name, value) { name = _$1.trim(name); name = name.replace(REGEXP_ILLEGAL_ATTR_NAME, "").toLowerCase(); if (name.length < 1) return; var ret = onAttr2(name, value || ""); if (ret) retAttrs.push(ret); } for (var i = 0; i < len; i++) { var c = html.charAt(i); var v, j; if (tmpName === false && c === "=") { tmpName = html.slice(lastPos, i); lastPos = i + 1; lastMarkPos = html.charAt(lastPos) === '"' || html.charAt(lastPos) === "'" ? lastPos : findNextQuotationMark(html, i + 1); continue; } if (tmpName !== false) { if (i === lastMarkPos) { j = html.indexOf(c, i + 1); if (j === -1) { break; } else { v = _$1.trim(html.slice(lastMarkPos + 1, j)); addAttr(tmpName, v); tmpName = false; i = j; lastPos = i + 1; continue; } } } if (/\s|\n|\t/.test(c)) { html = html.replace(/\s|\n|\t/g, " "); if (tmpName === false) { j = findNextEqual(html, i); if (j === -1) { v = _$1.trim(html.slice(lastPos, i)); addAttr(v); tmpName = false; lastPos = i + 1; continue; } else { i = j - 1; continue; } } else { j = findBeforeEqual(html, i - 1); if (j === -1) { v = _$1.trim(html.slice(lastPos, i)); v = stripQuoteWrap(v); addAttr(tmpName, v); tmpName = false; lastPos = i + 1; continue; } else { continue; } } } } if (lastPos < html.length) { if (tmpName === false) { addAttr(html.slice(lastPos)); } else { addAttr(tmpName, stripQuoteWrap(_$1.trim(html.slice(lastPos)))); } } return _$1.trim(retAttrs.join(" ")); } function findNextEqual(str, i) { for (; i < str.length; i++) { var c = str[i]; if (c === " ") continue; if (c === "=") return i; return -1; } } function findNextQuotationMark(str, i) { for (; i < str.length; i++) { var c = str[i]; if (c === " ") continue; if (c === "'" || c === '"') return i; return -1; } } function findBeforeEqual(str, i) { for (; i > 0; i--) { var c = str[i]; if (c === " ") continue; if (c === "=") return i; return -1; } } function isQuoteWrapString(text) { if (text[0] === '"' && text[text.length - 1] === '"' || text[0] === "'" && text[text.length - 1] === "'") { return true; } else { return false; } } function stripQuoteWrap(text) { if (isQuoteWrapString(text)) { return text.substr(1, text.length - 2); } else { return text; } } parser$1.parseTag = parseTag$1; parser$1.parseAttr = parseAttr$1; var FilterCSS = libExports$1.FilterCSS; var DEFAULT = _default$1; var parser = parser$1; var parseTag = parser.parseTag; var parseAttr = parser.parseAttr; var _ = util; function isNull(obj) { return obj === void 0 || obj === null; } function getAttrs(html) { var i = _.spaceIndex(html); if (i === -1) { return { html: "", closing: html[html.length - 2] === "/" }; } html = _.trim(html.slice(i + 1, -1)); var isClosing2 = html[html.length - 1] === "/"; if (isClosing2) html = _.trim(html.slice(0, -1)); return { html, closing: isClosing2 }; } function shallowCopyObject(obj) { var ret = {}; for (var i in obj) { ret[i] = obj[i]; } return ret; } function keysToLowerCase(obj) { var ret = {}; for (var i in obj) { if (Array.isArray(obj[i])) { ret[i.toLowerCase()] = obj[i].map(function(item) { return item.toLowerCase(); }); } else { ret[i.toLowerCase()] = obj[i]; } } return ret; } function FilterXSS(options) { options = shallowCopyObject(options || {}); if (options.stripIgnoreTag) { if (options.onIgnoreTag) { console.error( 'Notes: cannot use these two options "stripIgnoreTag" and "onIgnoreTag" at the same time' ); } options.onIgnoreTag = DEFAULT.onIgnoreTagStripAll; } if (options.whiteList || options.allowList) { options.whiteList = keysToLowerCase(options.whiteList || options.allowList); } else { options.whiteList = DEFAULT.whiteList; } this.attributeWrapSign = options.singleQuotedAttributeValue === true ? "'" : DEFAULT.attributeWrapSign; options.onTag = options.onTag || DEFAULT.onTag; options.onTagAttr = options.onTagAttr || DEFAULT.onTagAttr; options.onIgnoreTag = options.onIgnoreTag || DEFAULT.onIgnoreTag; options.onIgnoreTagAttr = options.onIgnoreTagAttr || DEFAULT.onIgnoreTagAttr; options.safeAttrValue = options.safeAttrValue || DEFAULT.safeAttrValue; options.escapeHtml = options.escapeHtml || DEFAULT.escapeHtml; this.options = options; if (options.css === false) { this.cssFilter = false; } else { options.css = options.css || {}; this.cssFilter = new FilterCSS(options.css); } } FilterXSS.prototype.process = function(html) { html = html || ""; html = html.toString(); if (!html) return ""; var me = this; var options = me.options; var whiteList = options.whiteList; var onTag2 = options.onTag; var onIgnoreTag2 = options.onIgnoreTag; var onTagAttr2 = options.onTagAttr; var onIgnoreTagAttr2 = options.onIgnoreTagAttr; var safeAttrValue2 = options.safeAttrValue; var escapeHtml2 = options.escapeHtml; var attributeWrapSign = me.attributeWrapSign; var cssFilter = me.cssFilter; if (options.stripBlankChar) { html = DEFAULT.stripBlankChar(html); } if (!options.allowCommentTag) { html = DEFAULT.stripCommentTag(html); } var stripIgnoreTagBody = false; if (options.stripIgnoreTagBody) { stripIgnoreTagBody = DEFAULT.StripTagBody( options.stripIgnoreTagBody, onIgnoreTag2 ); onIgnoreTag2 = stripIgnoreTagBody.onIgnoreTag; } var retHtml = parseTag( html, function(sourcePosition, position, tag, html2, isClosing2) { var info = { sourcePosition, position, isClosing: isClosing2, isWhite: Object.prototype.hasOwnProperty.call(whiteList, tag) }; var ret = onTag2(tag, html2, info); if (!isNull(ret)) return ret; if (info.isWhite) { if (info.isClosing) { return ""; } var attrs = getAttrs(html2); var whiteAttrList = whiteList[tag]; var attrsHtml = parseAttr(attrs.html, function(name, value) { var isWhiteAttr = _.indexOf(whiteAttrList, name) !== -1; var ret2 = onTagAttr2(tag, name, value, isWhiteAttr); if (!isNull(ret2)) return ret2; if (isWhiteAttr) { value = safeAttrValue2(tag, name, value, cssFilter); if (value) { return name + "=" + attributeWrapSign + value + attributeWrapSign; } else { return name; } } else { ret2 = onIgnoreTagAttr2(tag, name, value, isWhiteAttr); if (!isNull(ret2)) return ret2; return; } }); html2 = "<" + tag; if (attrsHtml) html2 += " " + attrsHtml; if (attrs.closing) html2 += " /"; html2 += ">"; return html2; } else { ret = onIgnoreTag2(tag, html2, info); if (!isNull(ret)) return ret; return escapeHtml2(html2); } }, escapeHtml2 ); if (stripIgnoreTagBody) { retHtml = stripIgnoreTagBody.remove(retHtml); } return retHtml; }; var xss$1 = FilterXSS; (function(module2, exports2) { var DEFAULT2 = _default$1; var parser2 = parser$1; var FilterXSS2 = xss$1; function filterXSS(html, options) { var xss2 = new FilterXSS2(options); return xss2.process(html); } exports2 = module2.exports = filterXSS; exports2.filterXSS = filterXSS; exports2.FilterXSS = FilterXSS2; (function() { for (var i in DEFAULT2) { exports2[i] = DEFAULT2[i]; } for (var j in parser2) { exports2[j] = parser2[j]; } })(); if (typeof window !== "undefined") { window.filterXSS = module2.exports; } function isWorkerEnv() { return typeof self !== "undefined" && typeof DedicatedWorkerGlobalScope !== "undefined" && self instanceof DedicatedWorkerGlobalScope; } if (isWorkerEnv()) { self.filterXSS = module2.exports; } })(lib$1, lib$1.exports); var libExports = lib$1.exports; const index = /* @__PURE__ */ getDefaultExportFromCjs(libExports); const xss = /* @__PURE__ */ _mergeNamespaces({ __proto__: null, default: index }, [libExports]); const MdWhiteList = { img: ["class"], // 支持任务列表 input: ["class", "disabled", "type", "checked"], // 主要支持youtobe、腾讯视频、哔哩哔哩等内嵌视频代码 iframe: [ "class", "width", "height", "src", "title", "border", "frameborder", "framespacing", "allow", "allowfullscreen" ] }; const XSSPlugin = (md, options) => { const { extendedWhiteList = {}, xss: xssOption = {} } = options; let xssIns; if (typeof xssOption === "function") { xssIns = new libExports.FilterXSS(xssOption(xss)); } else { const whiteList = libExports.getDefaultWhiteList(); const keys = [...Object.keys(extendedWhiteList), ...Object.keys(MdWhiteList)]; keys.forEach((key) => { const xssWhiteItem = whiteList[key] || []; const innerWhiteItem = MdWhiteList[key] || []; const userDefWhiteItem = extendedWhiteList[key] || []; whiteList[key] = [ .../* @__PURE__ */ new Set([...xssWhiteItem, ...innerWhiteItem, ...userDefWhiteItem]) ]; }); xssIns = new libExports.FilterXSS({ whiteList, // 自定义的优先级最高 ...xssOption }); } md.core.ruler.after("linkify", "xss", (state) => { for (let i = 0; i < state.tokens.length; i++) { const cur = state.tokens[i]; switch (cur.type) { case "html_block": { cur.content = xssIns.process(cur.content); break; } case "inline": { const inlineTokens = cur.children || []; inlineTokens.forEach((it) => { if (it.type === "html_inline") { it.content = xssIns.process(it.content); } }); break; } } } }); }; const clearSideEffects = () => { Object.keys(MdPreview.CDN_IDS).forEach((key) => { const ele = document.getElementById(MdPreview.CDN_IDS[key]); if (ele) { ele.remove(); } }); }; exports.MdEditor = MdEditor; exports.MdPreview = MdPreview.MdPreview; exports.StrIcon = MdPreview.StrIcon; exports.NormalToolbar = NormalToolbar; exports.DropdownToolbar = DropdownToolbar.DropdownToolbar; exports.ModalToolbar = ModalToolbar; exports.MdCatalog = MdCatalog.MdCatalog; exports.MdModal = MdModal.MdModal; exports.allFooter = config$1.allFooter; exports.allToolbar = config$1.allToolbar; exports.config = config$1.config; exports.editorExtensionsAttrs = config$1.editorExtensionsAttrs; exports.en_US = config.en_US; exports.zh_CN = config.zh_CN; exports.NormalFooterToolbar = NormalFooterToolbar; exports.XSSPlugin = XSSPlugin; exports.clearSideEffects = clearSideEffects;