md-editor-v3 4.21.0 → 5.0.0-0
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 +3 -3
- package/lib/cjs/MdEditor.cjs +123 -53
- package/lib/cjs/ModalToolbar.cjs +20 -10
- package/lib/cjs/chunks/config.cjs +0 -15
- package/lib/cjs/chunks/dom.cjs +6 -2
- package/lib/cjs/chunks/index.cjs +174 -1441
- package/lib/cjs/chunks/index2.cjs +19 -9
- package/lib/cjs/chunks/index3.cjs +58 -28
- package/lib/cjs/chunks/index4.cjs +538 -10
- package/lib/cjs/chunks/index5.cjs +0 -7
- package/lib/cjs/config.cjs +0 -2
- package/lib/cjs/index.cjs +1311 -3
- package/lib/es/MdEditor.mjs +125 -55
- package/lib/es/ModalToolbar.mjs +20 -10
- package/lib/es/chunks/config.mjs +4 -19
- package/lib/es/chunks/dom.mjs +6 -2
- package/lib/es/chunks/index.mjs +181 -1448
- package/lib/es/chunks/index2.mjs +19 -9
- package/lib/es/chunks/index3.mjs +60 -30
- package/lib/es/chunks/index4.mjs +541 -13
- package/lib/es/chunks/index5.mjs +2 -9
- package/lib/es/config.mjs +3 -5
- package/lib/es/index.mjs +1314 -6
- package/lib/preview.css +20 -7
- package/lib/style.css +20 -7
- package/lib/types/DropdownToolbar/DropdownToolbar.d.ts +46 -87
- package/lib/types/DropdownToolbar/index.d.ts +2 -171
- package/lib/types/MdCatalog/CatalogLink.d.ts +18 -35
- package/lib/types/MdCatalog/MdCatalog.d.ts +29 -129
- package/lib/types/MdCatalog/index.d.ts +2 -194
- package/lib/types/MdEditor/Editor.d.ts +584 -427
- package/lib/types/MdEditor/components/Checkbox/index.d.ts +7 -20
- package/lib/types/MdEditor/components/Divider/index.d.ts +1 -1
- package/lib/types/MdEditor/components/Dropdown/index.d.ts +16 -40
- package/lib/types/MdEditor/components/Icon/Github.d.ts +2 -0
- package/lib/types/MdEditor/components/Icon/Icon.d.ts +7 -5
- package/lib/types/MdEditor/components/Icon/Str.d.ts +2 -1
- package/lib/types/MdEditor/components/Icon/index.d.ts +5 -5
- package/lib/types/MdEditor/components/Modal/Modal.d.ts +29 -90
- package/lib/types/MdEditor/components/Modal/index.d.ts +2 -223
- package/lib/types/MdEditor/composition.d.ts +26 -8
- package/lib/types/MdEditor/config.d.ts +0 -2
- package/lib/types/MdEditor/index.d.ts +2 -1017
- package/lib/types/MdEditor/layouts/Content/ContentPreview.d.ts +35 -127
- package/lib/types/MdEditor/layouts/Content/composition/useCodeMirror.d.ts +2 -2
- package/lib/types/MdEditor/layouts/Content/composition/useHighlight.d.ts +1 -1
- package/lib/types/MdEditor/layouts/Content/composition/useKatex.d.ts +1 -1
- package/lib/types/MdEditor/layouts/Content/composition/useMarkdownIt.d.ts +2 -2
- package/lib/types/MdEditor/layouts/Content/composition/useMermaid.d.ts +2 -2
- package/lib/types/MdEditor/layouts/Content/composition/useResize.d.ts +1 -1
- package/lib/types/MdEditor/layouts/Content/index.d.ts +73 -255
- package/lib/types/MdEditor/layouts/Content/markdownIt/xss/index.d.ts +1 -2
- package/lib/types/MdEditor/layouts/Content/props.d.ts +3 -3
- package/lib/types/MdEditor/layouts/Footer/MarkdownTotal.d.ts +4 -4
- package/lib/types/MdEditor/layouts/Footer/ScrollAuto.d.ts +7 -18
- package/lib/types/MdEditor/layouts/Footer/index.d.ts +20 -50
- package/lib/types/MdEditor/layouts/Modals/Clip.d.ts +10 -29
- package/lib/types/MdEditor/layouts/Modals/Link.d.ts +12 -37
- package/lib/types/MdEditor/layouts/Modals/index.d.ts +13 -44
- package/lib/types/MdEditor/layouts/Toolbar/TableShape.d.ts +7 -20
- package/lib/types/MdEditor/layouts/Toolbar/index.d.ts +31 -93
- package/lib/types/MdEditor/layouts/Toolbar/props.d.ts +4 -6
- package/lib/types/MdEditor/props.d.ts +66 -24
- package/lib/types/MdEditor/type.d.ts +1 -20
- package/lib/types/MdEditor/utils/index.d.ts +0 -4
- package/lib/types/MdPreview/MdPreview.d.ts +491 -206
- package/lib/types/MdPreview/composition/useExpose.d.ts +3 -1
- package/lib/types/MdPreview/index.d.ts +2 -538
- package/lib/types/ModalToolbar/ModalToolbar.d.ts +57 -143
- package/lib/types/ModalToolbar/index.d.ts +2 -309
- package/lib/types/NormalFooterToolbar/NormalFooterToolbar.d.ts +7 -10
- package/lib/types/NormalFooterToolbar/index.d.ts +2 -37
- package/lib/types/NormalToolbar/NormalToolbar.d.ts +21 -53
- package/lib/types/NormalToolbar/index.d.ts +2 -115
- package/lib/types/config.d.ts +1 -1
- package/lib/types/index.d.ts +1 -0
- package/lib/umd/index.js +283 -64
- package/package.json +21 -28
- package/lib/types/MdEditor/components/Popper/index.d.ts +0 -15
package/lib/cjs/chunks/index.cjs
CHANGED
|
@@ -3,38 +3,19 @@ const vue = require("vue");
|
|
|
3
3
|
const config = require("./config.cjs");
|
|
4
4
|
const eventName = require("./event-name.cjs");
|
|
5
5
|
const dom = require("./dom.cjs");
|
|
6
|
-
const util
|
|
6
|
+
const util = require("@vavt/util");
|
|
7
7
|
const mediumZoom = require("medium-zoom");
|
|
8
8
|
const copy = require("copy-to-clipboard");
|
|
9
9
|
const mdit = require("markdown-it");
|
|
10
10
|
const ImageFiguresPlugin = require("markdown-it-image-figures");
|
|
11
11
|
const SubPlugin = require("markdown-it-sub");
|
|
12
12
|
const SupPlugin = require("markdown-it-sup");
|
|
13
|
-
const index
|
|
13
|
+
const index = require("./index5.cjs");
|
|
14
14
|
const lruCache = require("lru-cache");
|
|
15
|
-
function _mergeNamespaces(n, m) {
|
|
16
|
-
for (var i = 0; i < m.length; i++) {
|
|
17
|
-
const e = m[i];
|
|
18
|
-
if (typeof e !== "string" && !Array.isArray(e)) {
|
|
19
|
-
for (const k in e) {
|
|
20
|
-
if (k !== "default" && !(k in n)) {
|
|
21
|
-
const d = Object.getOwnPropertyDescriptor(e, k);
|
|
22
|
-
if (d) {
|
|
23
|
-
Object.defineProperty(n, k, d.get ? d : {
|
|
24
|
-
enumerable: true,
|
|
25
|
-
get: () => e[k]
|
|
26
|
-
});
|
|
27
|
-
}
|
|
28
|
-
}
|
|
29
|
-
}
|
|
30
|
-
}
|
|
31
|
-
}
|
|
32
|
-
return Object.freeze(Object.defineProperty(n, Symbol.toStringTag, { value: "Module" }));
|
|
33
|
-
}
|
|
34
15
|
const userZoom = (props, html) => {
|
|
35
16
|
const editorId = vue.inject("editorId");
|
|
36
17
|
const { noImgZoomIn } = props;
|
|
37
|
-
const zoomHander = util
|
|
18
|
+
const zoomHander = util.debounce(() => {
|
|
38
19
|
const imgs = document.querySelectorAll(
|
|
39
20
|
`#${editorId}-preview img:not(.not-zoom):not(.medium-zoom-image)`
|
|
40
21
|
);
|
|
@@ -131,7 +112,7 @@ const useHighlight = (props) => {
|
|
|
131
112
|
vue.watch(
|
|
132
113
|
() => highlight.value.css,
|
|
133
114
|
() => {
|
|
134
|
-
if (props.noHighlight ||
|
|
115
|
+
if (props.noHighlight || config.configOption.editorExtensions.highlight.instance) {
|
|
135
116
|
return;
|
|
136
117
|
}
|
|
137
118
|
dom.updateHandler("link", {
|
|
@@ -232,7 +213,7 @@ const useMermaid = (props) => {
|
|
|
232
213
|
const handler = async (item) => {
|
|
233
214
|
let mermaidHtml = mermaidCache.get(item.innerText);
|
|
234
215
|
if (!mermaidHtml) {
|
|
235
|
-
const idRand = util
|
|
216
|
+
const idRand = util.randomId();
|
|
236
217
|
const render = mermaidRef.value.renderAsync || mermaidRef.value.render;
|
|
237
218
|
let svg = "";
|
|
238
219
|
try {
|
|
@@ -465,7 +446,7 @@ const AdmonitionPlugin = (md, options) => {
|
|
|
465
446
|
options = options || {};
|
|
466
447
|
const markers = 3, markerStr = options.marker || "!", markerChar = markerStr.charCodeAt(0), markerLen = markerStr.length;
|
|
467
448
|
let type = "", title = "";
|
|
468
|
-
const render = (tokens, idx, _options, _env,
|
|
449
|
+
const render = (tokens, idx, _options, _env, self) => {
|
|
469
450
|
const token = tokens[idx];
|
|
470
451
|
if (token.type === "admonition_open") {
|
|
471
452
|
tokens[idx].attrPush([
|
|
@@ -475,7 +456,7 @@ const AdmonitionPlugin = (md, options) => {
|
|
|
475
456
|
} else if (token.type === "admonition_title_open") {
|
|
476
457
|
tokens[idx].attrPush(["class", `${config.prefix}-admonition-title`]);
|
|
477
458
|
}
|
|
478
|
-
return
|
|
459
|
+
return self.renderToken(tokens, idx, _options);
|
|
479
460
|
};
|
|
480
461
|
const validate = (params) => {
|
|
481
462
|
const array = params.trim().split(" ", 2);
|
|
@@ -600,23 +581,19 @@ const HeadingPlugin = (md, options) => {
|
|
|
600
581
|
}
|
|
601
582
|
return md.renderer.renderToken(tokens, idx, options);
|
|
602
583
|
};
|
|
603
|
-
md.renderer.rules.heading_close = (tokens, idx, opts, _env,
|
|
604
|
-
return
|
|
584
|
+
md.renderer.rules.heading_close = (tokens, idx, opts, _env, self) => {
|
|
585
|
+
return self.renderToken(tokens, idx, opts);
|
|
605
586
|
};
|
|
606
587
|
};
|
|
588
|
+
const iconMaps = {
|
|
589
|
+
copy: `<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-copy ${config.prefix}-icon"><rect width="14" height="14" x="8" y="8" rx="2" ry="2"/><path d="M4 16c-1.1 0-2-.9-2-2V4c0-1.1.9-2 2-2h10c1.1 0 2 .9 2 2"/></svg>`,
|
|
590
|
+
"collapse-tips": `<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-circle-chevron-left ${config.prefix}-icon"><circle cx="12" cy="12" r="10"/><path d="m14 16-4-4 4-4"/></svg>`
|
|
591
|
+
};
|
|
607
592
|
const StrIcon = (name, customIcon) => {
|
|
608
593
|
if (typeof customIcon[name] === "string") {
|
|
609
594
|
return customIcon[name];
|
|
610
595
|
}
|
|
611
|
-
|
|
612
|
-
switch (config.configOption.iconfontType) {
|
|
613
|
-
case "svg": {
|
|
614
|
-
return `<svg class="${config.prefix}-icon" aria-hidden="true"><use xlink:href="#${config.prefix}-icon-${name}"></use></svg>`;
|
|
615
|
-
}
|
|
616
|
-
default: {
|
|
617
|
-
return defaultStr;
|
|
618
|
-
}
|
|
619
|
-
}
|
|
596
|
+
return iconMaps[name];
|
|
620
597
|
};
|
|
621
598
|
const StrIcon$1 = StrIcon;
|
|
622
599
|
const codetabs = (md, _opts) => {
|
|
@@ -651,26 +628,30 @@ const codetabs = (md, _opts) => {
|
|
|
651
628
|
if (GROUP === null) {
|
|
652
629
|
const { open: open2, tagContainer: tagContainer2, tagHeader: tagHeader2 } = getTagType(tokens[idx]);
|
|
653
630
|
const addAttrs2 = [["class", `${config.prefix}-code`]];
|
|
654
|
-
open2
|
|
631
|
+
if (open2) addAttrs2.push(["open", ""]);
|
|
655
632
|
const tmpToken2 = {
|
|
656
633
|
attrs: mergeAttrs(tokens[idx], addAttrs2)
|
|
657
634
|
};
|
|
658
635
|
tokens[idx].info = tokens[idx].info.replace(mandatoryRe, "");
|
|
659
636
|
const codeRendered = defaultRender(tokens, idx, options, env, slf);
|
|
660
|
-
return
|
|
661
|
-
<${
|
|
662
|
-
|
|
663
|
-
|
|
664
|
-
<
|
|
665
|
-
|
|
666
|
-
|
|
667
|
-
|
|
668
|
-
|
|
637
|
+
return `
|
|
638
|
+
<${tagContainer2} ${slf.renderAttrs(tmpToken2)}>
|
|
639
|
+
<${tagHeader2} class="${config.prefix}-code-head">
|
|
640
|
+
<div class="${config.prefix}-code-flag"><span></span><span></span><span></span></div>
|
|
641
|
+
<div class="${config.prefix}-code-action">
|
|
642
|
+
<span class="${config.prefix}-code-lang">${tokens[idx].info.trim()}</span>
|
|
643
|
+
<span class="${config.prefix}-copy-button" data-tips="${codeCodeText}"${isIcon ? " data-is-icon=true" : ""}>${copyBtnHtml}</span>
|
|
644
|
+
${tagContainer2 === "details" ? collapseTips : ""}
|
|
645
|
+
</div>
|
|
646
|
+
</${tagHeader2}>
|
|
647
|
+
${codeRendered}
|
|
648
|
+
</${tagContainer2}>
|
|
649
|
+
`;
|
|
669
650
|
}
|
|
670
651
|
let token, group, tab, checked, labels = "", pres = "", langs = "";
|
|
671
652
|
const { open, tagContainer, tagHeader } = getTagType(tokens[idx]);
|
|
672
653
|
const addAttrs = [["class", `${config.prefix}-code`]];
|
|
673
|
-
open
|
|
654
|
+
if (open) addAttrs.push(["open", ""]);
|
|
674
655
|
const tmpToken = {
|
|
675
656
|
attrs: mergeAttrs(tokens[idx], addAttrs)
|
|
676
657
|
};
|
|
@@ -684,1319 +665,60 @@ const codetabs = (md, _opts) => {
|
|
|
684
665
|
token.hidden = true;
|
|
685
666
|
const className = `${config.prefix}-codetab-${_opts.editorId}-${idx}-${i - idx}`;
|
|
686
667
|
checked = i - idx > 0 ? "" : "checked";
|
|
687
|
-
labels +=
|
|
688
|
-
|
|
689
|
-
<
|
|
668
|
+
labels += `
|
|
669
|
+
<li>
|
|
670
|
+
<input
|
|
671
|
+
type="radio"
|
|
672
|
+
id="label-${config.prefix}-codetab-label-1-${_opts.editorId}-${idx}-${i - idx}"
|
|
673
|
+
name="${config.prefix}-codetab-label-${_opts.editorId}-${idx}"
|
|
674
|
+
class="${className}"
|
|
675
|
+
${checked}
|
|
676
|
+
>
|
|
677
|
+
<label
|
|
678
|
+
for="label-${config.prefix}-codetab-label-1-${_opts.editorId}-${idx}-${i - idx}"
|
|
679
|
+
onclick="this.getRootNode().querySelectorAll('.${className}').forEach(e => e.click())"
|
|
680
|
+
>
|
|
681
|
+
${tab || getLangName(token)}
|
|
682
|
+
</label>
|
|
690
683
|
</li>`;
|
|
691
|
-
pres +=
|
|
692
|
-
|
|
693
|
-
|
|
694
|
-
|
|
695
|
-
|
|
696
|
-
|
|
697
|
-
|
|
698
|
-
|
|
699
|
-
|
|
700
|
-
|
|
701
|
-
|
|
702
|
-
<
|
|
703
|
-
|
|
704
|
-
|
|
705
|
-
|
|
706
|
-
|
|
684
|
+
pres += `
|
|
685
|
+
<div role="tabpanel">
|
|
686
|
+
<input
|
|
687
|
+
type="radio"
|
|
688
|
+
name="${config.prefix}-codetab-pre-${_opts.editorId}-${idx}"
|
|
689
|
+
class="${className}"
|
|
690
|
+
${checked}
|
|
691
|
+
role="presentation">
|
|
692
|
+
${defaultRender(tokens, i, options, env, slf)}
|
|
693
|
+
</div>`;
|
|
694
|
+
langs += `
|
|
695
|
+
<input
|
|
696
|
+
type="radio"
|
|
697
|
+
name="${config.prefix}-codetab-lang-${_opts.editorId}-${idx}"
|
|
698
|
+
class="${className}"
|
|
699
|
+
${checked}
|
|
700
|
+
role="presentation">
|
|
701
|
+
<span class=${config.prefix}-code-lang role="note">${getLangName(token)}</span>`;
|
|
702
|
+
}
|
|
703
|
+
return `
|
|
704
|
+
<${tagContainer} ${slf.renderAttrs(tmpToken)}>
|
|
705
|
+
<${tagHeader} class="${config.prefix}-code-head">
|
|
706
|
+
<div class="${config.prefix}-code-flag">
|
|
707
|
+
<ul class="${config.prefix}-codetab-label" role="tablist">${labels}</ul>
|
|
708
|
+
</div>
|
|
709
|
+
<div class="${config.prefix}-code-action">
|
|
710
|
+
<span class="${config.prefix}-codetab-lang">${langs}</span>
|
|
711
|
+
<span class="${config.prefix}-copy-button" data-tips="${codeCodeText}"${isIcon ? " data-is-icon=true" : ""}>${copyBtnHtml}</span>
|
|
712
|
+
${tagContainer === "details" ? collapseTips : ""}
|
|
713
|
+
</div>
|
|
714
|
+
</${tagHeader}>
|
|
715
|
+
${pres}
|
|
716
|
+
</${tagContainer}>
|
|
717
|
+
`;
|
|
707
718
|
};
|
|
708
719
|
md.renderer.rules.fence = fenceGroup;
|
|
709
720
|
md.renderer.rules.code_block = fenceGroup;
|
|
710
721
|
};
|
|
711
|
-
function getDefaultExportFromCjs(x) {
|
|
712
|
-
return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, "default") ? x["default"] : x;
|
|
713
|
-
}
|
|
714
|
-
var lib$1 = { exports: {} };
|
|
715
|
-
var _default$1 = {};
|
|
716
|
-
var lib = { exports: {} };
|
|
717
|
-
var _default = {};
|
|
718
|
-
function getDefaultWhiteList$1() {
|
|
719
|
-
var whiteList = {};
|
|
720
|
-
whiteList["align-content"] = false;
|
|
721
|
-
whiteList["align-items"] = false;
|
|
722
|
-
whiteList["align-self"] = false;
|
|
723
|
-
whiteList["alignment-adjust"] = false;
|
|
724
|
-
whiteList["alignment-baseline"] = false;
|
|
725
|
-
whiteList["all"] = false;
|
|
726
|
-
whiteList["anchor-point"] = false;
|
|
727
|
-
whiteList["animation"] = false;
|
|
728
|
-
whiteList["animation-delay"] = false;
|
|
729
|
-
whiteList["animation-direction"] = false;
|
|
730
|
-
whiteList["animation-duration"] = false;
|
|
731
|
-
whiteList["animation-fill-mode"] = false;
|
|
732
|
-
whiteList["animation-iteration-count"] = false;
|
|
733
|
-
whiteList["animation-name"] = false;
|
|
734
|
-
whiteList["animation-play-state"] = false;
|
|
735
|
-
whiteList["animation-timing-function"] = false;
|
|
736
|
-
whiteList["azimuth"] = false;
|
|
737
|
-
whiteList["backface-visibility"] = false;
|
|
738
|
-
whiteList["background"] = true;
|
|
739
|
-
whiteList["background-attachment"] = true;
|
|
740
|
-
whiteList["background-clip"] = true;
|
|
741
|
-
whiteList["background-color"] = true;
|
|
742
|
-
whiteList["background-image"] = true;
|
|
743
|
-
whiteList["background-origin"] = true;
|
|
744
|
-
whiteList["background-position"] = true;
|
|
745
|
-
whiteList["background-repeat"] = true;
|
|
746
|
-
whiteList["background-size"] = true;
|
|
747
|
-
whiteList["baseline-shift"] = false;
|
|
748
|
-
whiteList["binding"] = false;
|
|
749
|
-
whiteList["bleed"] = false;
|
|
750
|
-
whiteList["bookmark-label"] = false;
|
|
751
|
-
whiteList["bookmark-level"] = false;
|
|
752
|
-
whiteList["bookmark-state"] = false;
|
|
753
|
-
whiteList["border"] = true;
|
|
754
|
-
whiteList["border-bottom"] = true;
|
|
755
|
-
whiteList["border-bottom-color"] = true;
|
|
756
|
-
whiteList["border-bottom-left-radius"] = true;
|
|
757
|
-
whiteList["border-bottom-right-radius"] = true;
|
|
758
|
-
whiteList["border-bottom-style"] = true;
|
|
759
|
-
whiteList["border-bottom-width"] = true;
|
|
760
|
-
whiteList["border-collapse"] = true;
|
|
761
|
-
whiteList["border-color"] = true;
|
|
762
|
-
whiteList["border-image"] = true;
|
|
763
|
-
whiteList["border-image-outset"] = true;
|
|
764
|
-
whiteList["border-image-repeat"] = true;
|
|
765
|
-
whiteList["border-image-slice"] = true;
|
|
766
|
-
whiteList["border-image-source"] = true;
|
|
767
|
-
whiteList["border-image-width"] = true;
|
|
768
|
-
whiteList["border-left"] = true;
|
|
769
|
-
whiteList["border-left-color"] = true;
|
|
770
|
-
whiteList["border-left-style"] = true;
|
|
771
|
-
whiteList["border-left-width"] = true;
|
|
772
|
-
whiteList["border-radius"] = true;
|
|
773
|
-
whiteList["border-right"] = true;
|
|
774
|
-
whiteList["border-right-color"] = true;
|
|
775
|
-
whiteList["border-right-style"] = true;
|
|
776
|
-
whiteList["border-right-width"] = true;
|
|
777
|
-
whiteList["border-spacing"] = true;
|
|
778
|
-
whiteList["border-style"] = true;
|
|
779
|
-
whiteList["border-top"] = true;
|
|
780
|
-
whiteList["border-top-color"] = true;
|
|
781
|
-
whiteList["border-top-left-radius"] = true;
|
|
782
|
-
whiteList["border-top-right-radius"] = true;
|
|
783
|
-
whiteList["border-top-style"] = true;
|
|
784
|
-
whiteList["border-top-width"] = true;
|
|
785
|
-
whiteList["border-width"] = true;
|
|
786
|
-
whiteList["bottom"] = false;
|
|
787
|
-
whiteList["box-decoration-break"] = true;
|
|
788
|
-
whiteList["box-shadow"] = true;
|
|
789
|
-
whiteList["box-sizing"] = true;
|
|
790
|
-
whiteList["box-snap"] = true;
|
|
791
|
-
whiteList["box-suppress"] = true;
|
|
792
|
-
whiteList["break-after"] = true;
|
|
793
|
-
whiteList["break-before"] = true;
|
|
794
|
-
whiteList["break-inside"] = true;
|
|
795
|
-
whiteList["caption-side"] = false;
|
|
796
|
-
whiteList["chains"] = false;
|
|
797
|
-
whiteList["clear"] = true;
|
|
798
|
-
whiteList["clip"] = false;
|
|
799
|
-
whiteList["clip-path"] = false;
|
|
800
|
-
whiteList["clip-rule"] = false;
|
|
801
|
-
whiteList["color"] = true;
|
|
802
|
-
whiteList["color-interpolation-filters"] = true;
|
|
803
|
-
whiteList["column-count"] = false;
|
|
804
|
-
whiteList["column-fill"] = false;
|
|
805
|
-
whiteList["column-gap"] = false;
|
|
806
|
-
whiteList["column-rule"] = false;
|
|
807
|
-
whiteList["column-rule-color"] = false;
|
|
808
|
-
whiteList["column-rule-style"] = false;
|
|
809
|
-
whiteList["column-rule-width"] = false;
|
|
810
|
-
whiteList["column-span"] = false;
|
|
811
|
-
whiteList["column-width"] = false;
|
|
812
|
-
whiteList["columns"] = false;
|
|
813
|
-
whiteList["contain"] = false;
|
|
814
|
-
whiteList["content"] = false;
|
|
815
|
-
whiteList["counter-increment"] = false;
|
|
816
|
-
whiteList["counter-reset"] = false;
|
|
817
|
-
whiteList["counter-set"] = false;
|
|
818
|
-
whiteList["crop"] = false;
|
|
819
|
-
whiteList["cue"] = false;
|
|
820
|
-
whiteList["cue-after"] = false;
|
|
821
|
-
whiteList["cue-before"] = false;
|
|
822
|
-
whiteList["cursor"] = false;
|
|
823
|
-
whiteList["direction"] = false;
|
|
824
|
-
whiteList["display"] = true;
|
|
825
|
-
whiteList["display-inside"] = true;
|
|
826
|
-
whiteList["display-list"] = true;
|
|
827
|
-
whiteList["display-outside"] = true;
|
|
828
|
-
whiteList["dominant-baseline"] = false;
|
|
829
|
-
whiteList["elevation"] = false;
|
|
830
|
-
whiteList["empty-cells"] = false;
|
|
831
|
-
whiteList["filter"] = false;
|
|
832
|
-
whiteList["flex"] = false;
|
|
833
|
-
whiteList["flex-basis"] = false;
|
|
834
|
-
whiteList["flex-direction"] = false;
|
|
835
|
-
whiteList["flex-flow"] = false;
|
|
836
|
-
whiteList["flex-grow"] = false;
|
|
837
|
-
whiteList["flex-shrink"] = false;
|
|
838
|
-
whiteList["flex-wrap"] = false;
|
|
839
|
-
whiteList["float"] = false;
|
|
840
|
-
whiteList["float-offset"] = false;
|
|
841
|
-
whiteList["flood-color"] = false;
|
|
842
|
-
whiteList["flood-opacity"] = false;
|
|
843
|
-
whiteList["flow-from"] = false;
|
|
844
|
-
whiteList["flow-into"] = false;
|
|
845
|
-
whiteList["font"] = true;
|
|
846
|
-
whiteList["font-family"] = true;
|
|
847
|
-
whiteList["font-feature-settings"] = true;
|
|
848
|
-
whiteList["font-kerning"] = true;
|
|
849
|
-
whiteList["font-language-override"] = true;
|
|
850
|
-
whiteList["font-size"] = true;
|
|
851
|
-
whiteList["font-size-adjust"] = true;
|
|
852
|
-
whiteList["font-stretch"] = true;
|
|
853
|
-
whiteList["font-style"] = true;
|
|
854
|
-
whiteList["font-synthesis"] = true;
|
|
855
|
-
whiteList["font-variant"] = true;
|
|
856
|
-
whiteList["font-variant-alternates"] = true;
|
|
857
|
-
whiteList["font-variant-caps"] = true;
|
|
858
|
-
whiteList["font-variant-east-asian"] = true;
|
|
859
|
-
whiteList["font-variant-ligatures"] = true;
|
|
860
|
-
whiteList["font-variant-numeric"] = true;
|
|
861
|
-
whiteList["font-variant-position"] = true;
|
|
862
|
-
whiteList["font-weight"] = true;
|
|
863
|
-
whiteList["grid"] = false;
|
|
864
|
-
whiteList["grid-area"] = false;
|
|
865
|
-
whiteList["grid-auto-columns"] = false;
|
|
866
|
-
whiteList["grid-auto-flow"] = false;
|
|
867
|
-
whiteList["grid-auto-rows"] = false;
|
|
868
|
-
whiteList["grid-column"] = false;
|
|
869
|
-
whiteList["grid-column-end"] = false;
|
|
870
|
-
whiteList["grid-column-start"] = false;
|
|
871
|
-
whiteList["grid-row"] = false;
|
|
872
|
-
whiteList["grid-row-end"] = false;
|
|
873
|
-
whiteList["grid-row-start"] = false;
|
|
874
|
-
whiteList["grid-template"] = false;
|
|
875
|
-
whiteList["grid-template-areas"] = false;
|
|
876
|
-
whiteList["grid-template-columns"] = false;
|
|
877
|
-
whiteList["grid-template-rows"] = false;
|
|
878
|
-
whiteList["hanging-punctuation"] = false;
|
|
879
|
-
whiteList["height"] = true;
|
|
880
|
-
whiteList["hyphens"] = false;
|
|
881
|
-
whiteList["icon"] = false;
|
|
882
|
-
whiteList["image-orientation"] = false;
|
|
883
|
-
whiteList["image-resolution"] = false;
|
|
884
|
-
whiteList["ime-mode"] = false;
|
|
885
|
-
whiteList["initial-letters"] = false;
|
|
886
|
-
whiteList["inline-box-align"] = false;
|
|
887
|
-
whiteList["justify-content"] = false;
|
|
888
|
-
whiteList["justify-items"] = false;
|
|
889
|
-
whiteList["justify-self"] = false;
|
|
890
|
-
whiteList["left"] = false;
|
|
891
|
-
whiteList["letter-spacing"] = true;
|
|
892
|
-
whiteList["lighting-color"] = true;
|
|
893
|
-
whiteList["line-box-contain"] = false;
|
|
894
|
-
whiteList["line-break"] = false;
|
|
895
|
-
whiteList["line-grid"] = false;
|
|
896
|
-
whiteList["line-height"] = false;
|
|
897
|
-
whiteList["line-snap"] = false;
|
|
898
|
-
whiteList["line-stacking"] = false;
|
|
899
|
-
whiteList["line-stacking-ruby"] = false;
|
|
900
|
-
whiteList["line-stacking-shift"] = false;
|
|
901
|
-
whiteList["line-stacking-strategy"] = false;
|
|
902
|
-
whiteList["list-style"] = true;
|
|
903
|
-
whiteList["list-style-image"] = true;
|
|
904
|
-
whiteList["list-style-position"] = true;
|
|
905
|
-
whiteList["list-style-type"] = true;
|
|
906
|
-
whiteList["margin"] = true;
|
|
907
|
-
whiteList["margin-bottom"] = true;
|
|
908
|
-
whiteList["margin-left"] = true;
|
|
909
|
-
whiteList["margin-right"] = true;
|
|
910
|
-
whiteList["margin-top"] = true;
|
|
911
|
-
whiteList["marker-offset"] = false;
|
|
912
|
-
whiteList["marker-side"] = false;
|
|
913
|
-
whiteList["marks"] = false;
|
|
914
|
-
whiteList["mask"] = false;
|
|
915
|
-
whiteList["mask-box"] = false;
|
|
916
|
-
whiteList["mask-box-outset"] = false;
|
|
917
|
-
whiteList["mask-box-repeat"] = false;
|
|
918
|
-
whiteList["mask-box-slice"] = false;
|
|
919
|
-
whiteList["mask-box-source"] = false;
|
|
920
|
-
whiteList["mask-box-width"] = false;
|
|
921
|
-
whiteList["mask-clip"] = false;
|
|
922
|
-
whiteList["mask-image"] = false;
|
|
923
|
-
whiteList["mask-origin"] = false;
|
|
924
|
-
whiteList["mask-position"] = false;
|
|
925
|
-
whiteList["mask-repeat"] = false;
|
|
926
|
-
whiteList["mask-size"] = false;
|
|
927
|
-
whiteList["mask-source-type"] = false;
|
|
928
|
-
whiteList["mask-type"] = false;
|
|
929
|
-
whiteList["max-height"] = true;
|
|
930
|
-
whiteList["max-lines"] = false;
|
|
931
|
-
whiteList["max-width"] = true;
|
|
932
|
-
whiteList["min-height"] = true;
|
|
933
|
-
whiteList["min-width"] = true;
|
|
934
|
-
whiteList["move-to"] = false;
|
|
935
|
-
whiteList["nav-down"] = false;
|
|
936
|
-
whiteList["nav-index"] = false;
|
|
937
|
-
whiteList["nav-left"] = false;
|
|
938
|
-
whiteList["nav-right"] = false;
|
|
939
|
-
whiteList["nav-up"] = false;
|
|
940
|
-
whiteList["object-fit"] = false;
|
|
941
|
-
whiteList["object-position"] = false;
|
|
942
|
-
whiteList["opacity"] = false;
|
|
943
|
-
whiteList["order"] = false;
|
|
944
|
-
whiteList["orphans"] = false;
|
|
945
|
-
whiteList["outline"] = false;
|
|
946
|
-
whiteList["outline-color"] = false;
|
|
947
|
-
whiteList["outline-offset"] = false;
|
|
948
|
-
whiteList["outline-style"] = false;
|
|
949
|
-
whiteList["outline-width"] = false;
|
|
950
|
-
whiteList["overflow"] = false;
|
|
951
|
-
whiteList["overflow-wrap"] = false;
|
|
952
|
-
whiteList["overflow-x"] = false;
|
|
953
|
-
whiteList["overflow-y"] = false;
|
|
954
|
-
whiteList["padding"] = true;
|
|
955
|
-
whiteList["padding-bottom"] = true;
|
|
956
|
-
whiteList["padding-left"] = true;
|
|
957
|
-
whiteList["padding-right"] = true;
|
|
958
|
-
whiteList["padding-top"] = true;
|
|
959
|
-
whiteList["page"] = false;
|
|
960
|
-
whiteList["page-break-after"] = false;
|
|
961
|
-
whiteList["page-break-before"] = false;
|
|
962
|
-
whiteList["page-break-inside"] = false;
|
|
963
|
-
whiteList["page-policy"] = false;
|
|
964
|
-
whiteList["pause"] = false;
|
|
965
|
-
whiteList["pause-after"] = false;
|
|
966
|
-
whiteList["pause-before"] = false;
|
|
967
|
-
whiteList["perspective"] = false;
|
|
968
|
-
whiteList["perspective-origin"] = false;
|
|
969
|
-
whiteList["pitch"] = false;
|
|
970
|
-
whiteList["pitch-range"] = false;
|
|
971
|
-
whiteList["play-during"] = false;
|
|
972
|
-
whiteList["position"] = false;
|
|
973
|
-
whiteList["presentation-level"] = false;
|
|
974
|
-
whiteList["quotes"] = false;
|
|
975
|
-
whiteList["region-fragment"] = false;
|
|
976
|
-
whiteList["resize"] = false;
|
|
977
|
-
whiteList["rest"] = false;
|
|
978
|
-
whiteList["rest-after"] = false;
|
|
979
|
-
whiteList["rest-before"] = false;
|
|
980
|
-
whiteList["richness"] = false;
|
|
981
|
-
whiteList["right"] = false;
|
|
982
|
-
whiteList["rotation"] = false;
|
|
983
|
-
whiteList["rotation-point"] = false;
|
|
984
|
-
whiteList["ruby-align"] = false;
|
|
985
|
-
whiteList["ruby-merge"] = false;
|
|
986
|
-
whiteList["ruby-position"] = false;
|
|
987
|
-
whiteList["shape-image-threshold"] = false;
|
|
988
|
-
whiteList["shape-outside"] = false;
|
|
989
|
-
whiteList["shape-margin"] = false;
|
|
990
|
-
whiteList["size"] = false;
|
|
991
|
-
whiteList["speak"] = false;
|
|
992
|
-
whiteList["speak-as"] = false;
|
|
993
|
-
whiteList["speak-header"] = false;
|
|
994
|
-
whiteList["speak-numeral"] = false;
|
|
995
|
-
whiteList["speak-punctuation"] = false;
|
|
996
|
-
whiteList["speech-rate"] = false;
|
|
997
|
-
whiteList["stress"] = false;
|
|
998
|
-
whiteList["string-set"] = false;
|
|
999
|
-
whiteList["tab-size"] = false;
|
|
1000
|
-
whiteList["table-layout"] = false;
|
|
1001
|
-
whiteList["text-align"] = true;
|
|
1002
|
-
whiteList["text-align-last"] = true;
|
|
1003
|
-
whiteList["text-combine-upright"] = true;
|
|
1004
|
-
whiteList["text-decoration"] = true;
|
|
1005
|
-
whiteList["text-decoration-color"] = true;
|
|
1006
|
-
whiteList["text-decoration-line"] = true;
|
|
1007
|
-
whiteList["text-decoration-skip"] = true;
|
|
1008
|
-
whiteList["text-decoration-style"] = true;
|
|
1009
|
-
whiteList["text-emphasis"] = true;
|
|
1010
|
-
whiteList["text-emphasis-color"] = true;
|
|
1011
|
-
whiteList["text-emphasis-position"] = true;
|
|
1012
|
-
whiteList["text-emphasis-style"] = true;
|
|
1013
|
-
whiteList["text-height"] = true;
|
|
1014
|
-
whiteList["text-indent"] = true;
|
|
1015
|
-
whiteList["text-justify"] = true;
|
|
1016
|
-
whiteList["text-orientation"] = true;
|
|
1017
|
-
whiteList["text-overflow"] = true;
|
|
1018
|
-
whiteList["text-shadow"] = true;
|
|
1019
|
-
whiteList["text-space-collapse"] = true;
|
|
1020
|
-
whiteList["text-transform"] = true;
|
|
1021
|
-
whiteList["text-underline-position"] = true;
|
|
1022
|
-
whiteList["text-wrap"] = true;
|
|
1023
|
-
whiteList["top"] = false;
|
|
1024
|
-
whiteList["transform"] = false;
|
|
1025
|
-
whiteList["transform-origin"] = false;
|
|
1026
|
-
whiteList["transform-style"] = false;
|
|
1027
|
-
whiteList["transition"] = false;
|
|
1028
|
-
whiteList["transition-delay"] = false;
|
|
1029
|
-
whiteList["transition-duration"] = false;
|
|
1030
|
-
whiteList["transition-property"] = false;
|
|
1031
|
-
whiteList["transition-timing-function"] = false;
|
|
1032
|
-
whiteList["unicode-bidi"] = false;
|
|
1033
|
-
whiteList["vertical-align"] = false;
|
|
1034
|
-
whiteList["visibility"] = false;
|
|
1035
|
-
whiteList["voice-balance"] = false;
|
|
1036
|
-
whiteList["voice-duration"] = false;
|
|
1037
|
-
whiteList["voice-family"] = false;
|
|
1038
|
-
whiteList["voice-pitch"] = false;
|
|
1039
|
-
whiteList["voice-range"] = false;
|
|
1040
|
-
whiteList["voice-rate"] = false;
|
|
1041
|
-
whiteList["voice-stress"] = false;
|
|
1042
|
-
whiteList["voice-volume"] = false;
|
|
1043
|
-
whiteList["volume"] = false;
|
|
1044
|
-
whiteList["white-space"] = false;
|
|
1045
|
-
whiteList["widows"] = false;
|
|
1046
|
-
whiteList["width"] = true;
|
|
1047
|
-
whiteList["will-change"] = false;
|
|
1048
|
-
whiteList["word-break"] = true;
|
|
1049
|
-
whiteList["word-spacing"] = true;
|
|
1050
|
-
whiteList["word-wrap"] = true;
|
|
1051
|
-
whiteList["wrap-flow"] = false;
|
|
1052
|
-
whiteList["wrap-through"] = false;
|
|
1053
|
-
whiteList["writing-mode"] = false;
|
|
1054
|
-
whiteList["z-index"] = false;
|
|
1055
|
-
return whiteList;
|
|
1056
|
-
}
|
|
1057
|
-
function onAttr(name, value, options) {
|
|
1058
|
-
}
|
|
1059
|
-
function onIgnoreAttr(name, value, options) {
|
|
1060
|
-
}
|
|
1061
|
-
var REGEXP_URL_JAVASCRIPT = /javascript\s*\:/img;
|
|
1062
|
-
function safeAttrValue$1(name, value) {
|
|
1063
|
-
if (REGEXP_URL_JAVASCRIPT.test(value)) return "";
|
|
1064
|
-
return value;
|
|
1065
|
-
}
|
|
1066
|
-
_default.whiteList = getDefaultWhiteList$1();
|
|
1067
|
-
_default.getDefaultWhiteList = getDefaultWhiteList$1;
|
|
1068
|
-
_default.onAttr = onAttr;
|
|
1069
|
-
_default.onIgnoreAttr = onIgnoreAttr;
|
|
1070
|
-
_default.safeAttrValue = safeAttrValue$1;
|
|
1071
|
-
var util$1 = {
|
|
1072
|
-
indexOf: function(arr, item) {
|
|
1073
|
-
var i, j;
|
|
1074
|
-
if (Array.prototype.indexOf) {
|
|
1075
|
-
return arr.indexOf(item);
|
|
1076
|
-
}
|
|
1077
|
-
for (i = 0, j = arr.length; i < j; i++) {
|
|
1078
|
-
if (arr[i] === item) {
|
|
1079
|
-
return i;
|
|
1080
|
-
}
|
|
1081
|
-
}
|
|
1082
|
-
return -1;
|
|
1083
|
-
},
|
|
1084
|
-
forEach: function(arr, fn, scope) {
|
|
1085
|
-
var i, j;
|
|
1086
|
-
if (Array.prototype.forEach) {
|
|
1087
|
-
return arr.forEach(fn, scope);
|
|
1088
|
-
}
|
|
1089
|
-
for (i = 0, j = arr.length; i < j; i++) {
|
|
1090
|
-
fn.call(scope, arr[i], i, arr);
|
|
1091
|
-
}
|
|
1092
|
-
},
|
|
1093
|
-
trim: function(str) {
|
|
1094
|
-
if (String.prototype.trim) {
|
|
1095
|
-
return str.trim();
|
|
1096
|
-
}
|
|
1097
|
-
return str.replace(/(^\s*)|(\s*$)/g, "");
|
|
1098
|
-
},
|
|
1099
|
-
trimRight: function(str) {
|
|
1100
|
-
if (String.prototype.trimRight) {
|
|
1101
|
-
return str.trimRight();
|
|
1102
|
-
}
|
|
1103
|
-
return str.replace(/(\s*$)/g, "");
|
|
1104
|
-
}
|
|
1105
|
-
};
|
|
1106
|
-
var _$3 = util$1;
|
|
1107
|
-
function parseStyle$1(css2, onAttr2) {
|
|
1108
|
-
css2 = _$3.trimRight(css2);
|
|
1109
|
-
if (css2[css2.length - 1] !== ";") css2 += ";";
|
|
1110
|
-
var cssLength = css2.length;
|
|
1111
|
-
var isParenthesisOpen = false;
|
|
1112
|
-
var lastPos = 0;
|
|
1113
|
-
var i = 0;
|
|
1114
|
-
var retCSS = "";
|
|
1115
|
-
function addNewAttr() {
|
|
1116
|
-
if (!isParenthesisOpen) {
|
|
1117
|
-
var source = _$3.trim(css2.slice(lastPos, i));
|
|
1118
|
-
var j2 = source.indexOf(":");
|
|
1119
|
-
if (j2 !== -1) {
|
|
1120
|
-
var name = _$3.trim(source.slice(0, j2));
|
|
1121
|
-
var value = _$3.trim(source.slice(j2 + 1));
|
|
1122
|
-
if (name) {
|
|
1123
|
-
var ret = onAttr2(lastPos, retCSS.length, name, value, source);
|
|
1124
|
-
if (ret) retCSS += ret + "; ";
|
|
1125
|
-
}
|
|
1126
|
-
}
|
|
1127
|
-
}
|
|
1128
|
-
lastPos = i + 1;
|
|
1129
|
-
}
|
|
1130
|
-
for (; i < cssLength; i++) {
|
|
1131
|
-
var c = css2[i];
|
|
1132
|
-
if (c === "/" && css2[i + 1] === "*") {
|
|
1133
|
-
var j = css2.indexOf("*/", i + 2);
|
|
1134
|
-
if (j === -1) break;
|
|
1135
|
-
i = j + 1;
|
|
1136
|
-
lastPos = i + 1;
|
|
1137
|
-
isParenthesisOpen = false;
|
|
1138
|
-
} else if (c === "(") {
|
|
1139
|
-
isParenthesisOpen = true;
|
|
1140
|
-
} else if (c === ")") {
|
|
1141
|
-
isParenthesisOpen = false;
|
|
1142
|
-
} else if (c === ";") {
|
|
1143
|
-
if (isParenthesisOpen) ;
|
|
1144
|
-
else {
|
|
1145
|
-
addNewAttr();
|
|
1146
|
-
}
|
|
1147
|
-
} else if (c === "\n") {
|
|
1148
|
-
addNewAttr();
|
|
1149
|
-
}
|
|
1150
|
-
}
|
|
1151
|
-
return _$3.trim(retCSS);
|
|
1152
|
-
}
|
|
1153
|
-
var parser$2 = parseStyle$1;
|
|
1154
|
-
var DEFAULT$1 = _default;
|
|
1155
|
-
var parseStyle = parser$2;
|
|
1156
|
-
function isNull$1(obj) {
|
|
1157
|
-
return obj === void 0 || obj === null;
|
|
1158
|
-
}
|
|
1159
|
-
function shallowCopyObject$1(obj) {
|
|
1160
|
-
var ret = {};
|
|
1161
|
-
for (var i in obj) {
|
|
1162
|
-
ret[i] = obj[i];
|
|
1163
|
-
}
|
|
1164
|
-
return ret;
|
|
1165
|
-
}
|
|
1166
|
-
function FilterCSS$2(options) {
|
|
1167
|
-
options = shallowCopyObject$1(options || {});
|
|
1168
|
-
options.whiteList = options.whiteList || DEFAULT$1.whiteList;
|
|
1169
|
-
options.onAttr = options.onAttr || DEFAULT$1.onAttr;
|
|
1170
|
-
options.onIgnoreAttr = options.onIgnoreAttr || DEFAULT$1.onIgnoreAttr;
|
|
1171
|
-
options.safeAttrValue = options.safeAttrValue || DEFAULT$1.safeAttrValue;
|
|
1172
|
-
this.options = options;
|
|
1173
|
-
}
|
|
1174
|
-
FilterCSS$2.prototype.process = function(css2) {
|
|
1175
|
-
css2 = css2 || "";
|
|
1176
|
-
css2 = css2.toString();
|
|
1177
|
-
if (!css2) return "";
|
|
1178
|
-
var me = this;
|
|
1179
|
-
var options = me.options;
|
|
1180
|
-
var whiteList = options.whiteList;
|
|
1181
|
-
var onAttr2 = options.onAttr;
|
|
1182
|
-
var onIgnoreAttr2 = options.onIgnoreAttr;
|
|
1183
|
-
var safeAttrValue2 = options.safeAttrValue;
|
|
1184
|
-
var retCSS = parseStyle(css2, function(sourcePosition, position, name, value, source) {
|
|
1185
|
-
var check = whiteList[name];
|
|
1186
|
-
var isWhite = false;
|
|
1187
|
-
if (check === true) isWhite = check;
|
|
1188
|
-
else if (typeof check === "function") isWhite = check(value);
|
|
1189
|
-
else if (check instanceof RegExp) isWhite = check.test(value);
|
|
1190
|
-
if (isWhite !== true) isWhite = false;
|
|
1191
|
-
value = safeAttrValue2(name, value);
|
|
1192
|
-
if (!value) return;
|
|
1193
|
-
var opts = {
|
|
1194
|
-
position,
|
|
1195
|
-
sourcePosition,
|
|
1196
|
-
source,
|
|
1197
|
-
isWhite
|
|
1198
|
-
};
|
|
1199
|
-
if (isWhite) {
|
|
1200
|
-
var ret = onAttr2(name, value, opts);
|
|
1201
|
-
if (isNull$1(ret)) {
|
|
1202
|
-
return name + ":" + value;
|
|
1203
|
-
} else {
|
|
1204
|
-
return ret;
|
|
1205
|
-
}
|
|
1206
|
-
} else {
|
|
1207
|
-
var ret = onIgnoreAttr2(name, value, opts);
|
|
1208
|
-
if (!isNull$1(ret)) {
|
|
1209
|
-
return ret;
|
|
1210
|
-
}
|
|
1211
|
-
}
|
|
1212
|
-
});
|
|
1213
|
-
return retCSS;
|
|
1214
|
-
};
|
|
1215
|
-
var css = FilterCSS$2;
|
|
1216
|
-
(function(module2, exports2) {
|
|
1217
|
-
var DEFAULT2 = _default;
|
|
1218
|
-
var FilterCSS2 = css;
|
|
1219
|
-
function filterCSS(html, options) {
|
|
1220
|
-
var xss2 = new FilterCSS2(options);
|
|
1221
|
-
return xss2.process(html);
|
|
1222
|
-
}
|
|
1223
|
-
exports2 = module2.exports = filterCSS;
|
|
1224
|
-
exports2.FilterCSS = FilterCSS2;
|
|
1225
|
-
for (var i in DEFAULT2) exports2[i] = DEFAULT2[i];
|
|
1226
|
-
if (typeof window !== "undefined") {
|
|
1227
|
-
window.filterCSS = module2.exports;
|
|
1228
|
-
}
|
|
1229
|
-
})(lib, lib.exports);
|
|
1230
|
-
var libExports$1 = lib.exports;
|
|
1231
|
-
var util = {
|
|
1232
|
-
indexOf: function(arr, item) {
|
|
1233
|
-
var i, j;
|
|
1234
|
-
if (Array.prototype.indexOf) {
|
|
1235
|
-
return arr.indexOf(item);
|
|
1236
|
-
}
|
|
1237
|
-
for (i = 0, j = arr.length; i < j; i++) {
|
|
1238
|
-
if (arr[i] === item) {
|
|
1239
|
-
return i;
|
|
1240
|
-
}
|
|
1241
|
-
}
|
|
1242
|
-
return -1;
|
|
1243
|
-
},
|
|
1244
|
-
forEach: function(arr, fn, scope) {
|
|
1245
|
-
var i, j;
|
|
1246
|
-
if (Array.prototype.forEach) {
|
|
1247
|
-
return arr.forEach(fn, scope);
|
|
1248
|
-
}
|
|
1249
|
-
for (i = 0, j = arr.length; i < j; i++) {
|
|
1250
|
-
fn.call(scope, arr[i], i, arr);
|
|
1251
|
-
}
|
|
1252
|
-
},
|
|
1253
|
-
trim: function(str) {
|
|
1254
|
-
if (String.prototype.trim) {
|
|
1255
|
-
return str.trim();
|
|
1256
|
-
}
|
|
1257
|
-
return str.replace(/(^\s*)|(\s*$)/g, "");
|
|
1258
|
-
},
|
|
1259
|
-
spaceIndex: function(str) {
|
|
1260
|
-
var reg = /\s|\n|\t/;
|
|
1261
|
-
var match = reg.exec(str);
|
|
1262
|
-
return match ? match.index : -1;
|
|
1263
|
-
}
|
|
1264
|
-
};
|
|
1265
|
-
var FilterCSS$1 = libExports$1.FilterCSS;
|
|
1266
|
-
var getDefaultCSSWhiteList = libExports$1.getDefaultWhiteList;
|
|
1267
|
-
var _$2 = util;
|
|
1268
|
-
function getDefaultWhiteList() {
|
|
1269
|
-
return {
|
|
1270
|
-
a: ["target", "href", "title"],
|
|
1271
|
-
abbr: ["title"],
|
|
1272
|
-
address: [],
|
|
1273
|
-
area: ["shape", "coords", "href", "alt"],
|
|
1274
|
-
article: [],
|
|
1275
|
-
aside: [],
|
|
1276
|
-
audio: [
|
|
1277
|
-
"autoplay",
|
|
1278
|
-
"controls",
|
|
1279
|
-
"crossorigin",
|
|
1280
|
-
"loop",
|
|
1281
|
-
"muted",
|
|
1282
|
-
"preload",
|
|
1283
|
-
"src"
|
|
1284
|
-
],
|
|
1285
|
-
b: [],
|
|
1286
|
-
bdi: ["dir"],
|
|
1287
|
-
bdo: ["dir"],
|
|
1288
|
-
big: [],
|
|
1289
|
-
blockquote: ["cite"],
|
|
1290
|
-
br: [],
|
|
1291
|
-
caption: [],
|
|
1292
|
-
center: [],
|
|
1293
|
-
cite: [],
|
|
1294
|
-
code: [],
|
|
1295
|
-
col: ["align", "valign", "span", "width"],
|
|
1296
|
-
colgroup: ["align", "valign", "span", "width"],
|
|
1297
|
-
dd: [],
|
|
1298
|
-
del: ["datetime"],
|
|
1299
|
-
details: ["open"],
|
|
1300
|
-
div: [],
|
|
1301
|
-
dl: [],
|
|
1302
|
-
dt: [],
|
|
1303
|
-
em: [],
|
|
1304
|
-
figcaption: [],
|
|
1305
|
-
figure: [],
|
|
1306
|
-
font: ["color", "size", "face"],
|
|
1307
|
-
footer: [],
|
|
1308
|
-
h1: [],
|
|
1309
|
-
h2: [],
|
|
1310
|
-
h3: [],
|
|
1311
|
-
h4: [],
|
|
1312
|
-
h5: [],
|
|
1313
|
-
h6: [],
|
|
1314
|
-
header: [],
|
|
1315
|
-
hr: [],
|
|
1316
|
-
i: [],
|
|
1317
|
-
img: ["src", "alt", "title", "width", "height", "loading"],
|
|
1318
|
-
ins: ["datetime"],
|
|
1319
|
-
kbd: [],
|
|
1320
|
-
li: [],
|
|
1321
|
-
mark: [],
|
|
1322
|
-
nav: [],
|
|
1323
|
-
ol: [],
|
|
1324
|
-
p: [],
|
|
1325
|
-
pre: [],
|
|
1326
|
-
s: [],
|
|
1327
|
-
section: [],
|
|
1328
|
-
small: [],
|
|
1329
|
-
span: [],
|
|
1330
|
-
sub: [],
|
|
1331
|
-
summary: [],
|
|
1332
|
-
sup: [],
|
|
1333
|
-
strong: [],
|
|
1334
|
-
strike: [],
|
|
1335
|
-
table: ["width", "border", "align", "valign"],
|
|
1336
|
-
tbody: ["align", "valign"],
|
|
1337
|
-
td: ["width", "rowspan", "colspan", "align", "valign"],
|
|
1338
|
-
tfoot: ["align", "valign"],
|
|
1339
|
-
th: ["width", "rowspan", "colspan", "align", "valign"],
|
|
1340
|
-
thead: ["align", "valign"],
|
|
1341
|
-
tr: ["rowspan", "align", "valign"],
|
|
1342
|
-
tt: [],
|
|
1343
|
-
u: [],
|
|
1344
|
-
ul: [],
|
|
1345
|
-
video: [
|
|
1346
|
-
"autoplay",
|
|
1347
|
-
"controls",
|
|
1348
|
-
"crossorigin",
|
|
1349
|
-
"loop",
|
|
1350
|
-
"muted",
|
|
1351
|
-
"playsinline",
|
|
1352
|
-
"poster",
|
|
1353
|
-
"preload",
|
|
1354
|
-
"src",
|
|
1355
|
-
"height",
|
|
1356
|
-
"width"
|
|
1357
|
-
]
|
|
1358
|
-
};
|
|
1359
|
-
}
|
|
1360
|
-
var defaultCSSFilter = new FilterCSS$1();
|
|
1361
|
-
function onTag(tag, html, options) {
|
|
1362
|
-
}
|
|
1363
|
-
function onIgnoreTag(tag, html, options) {
|
|
1364
|
-
}
|
|
1365
|
-
function onTagAttr(tag, name, value) {
|
|
1366
|
-
}
|
|
1367
|
-
function onIgnoreTagAttr(tag, name, value) {
|
|
1368
|
-
}
|
|
1369
|
-
function escapeHtml(html) {
|
|
1370
|
-
return html.replace(REGEXP_LT, "<").replace(REGEXP_GT, ">");
|
|
1371
|
-
}
|
|
1372
|
-
function safeAttrValue(tag, name, value, cssFilter) {
|
|
1373
|
-
value = friendlyAttrValue(value);
|
|
1374
|
-
if (name === "href" || name === "src") {
|
|
1375
|
-
value = _$2.trim(value);
|
|
1376
|
-
if (value === "#") return "#";
|
|
1377
|
-
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] === "/")) {
|
|
1378
|
-
return "";
|
|
1379
|
-
}
|
|
1380
|
-
} else if (name === "background") {
|
|
1381
|
-
REGEXP_DEFAULT_ON_TAG_ATTR_4.lastIndex = 0;
|
|
1382
|
-
if (REGEXP_DEFAULT_ON_TAG_ATTR_4.test(value)) {
|
|
1383
|
-
return "";
|
|
1384
|
-
}
|
|
1385
|
-
} else if (name === "style") {
|
|
1386
|
-
REGEXP_DEFAULT_ON_TAG_ATTR_7.lastIndex = 0;
|
|
1387
|
-
if (REGEXP_DEFAULT_ON_TAG_ATTR_7.test(value)) {
|
|
1388
|
-
return "";
|
|
1389
|
-
}
|
|
1390
|
-
REGEXP_DEFAULT_ON_TAG_ATTR_8.lastIndex = 0;
|
|
1391
|
-
if (REGEXP_DEFAULT_ON_TAG_ATTR_8.test(value)) {
|
|
1392
|
-
REGEXP_DEFAULT_ON_TAG_ATTR_4.lastIndex = 0;
|
|
1393
|
-
if (REGEXP_DEFAULT_ON_TAG_ATTR_4.test(value)) {
|
|
1394
|
-
return "";
|
|
1395
|
-
}
|
|
1396
|
-
}
|
|
1397
|
-
if (cssFilter !== false) {
|
|
1398
|
-
cssFilter = cssFilter || defaultCSSFilter;
|
|
1399
|
-
value = cssFilter.process(value);
|
|
1400
|
-
}
|
|
1401
|
-
}
|
|
1402
|
-
value = escapeAttrValue(value);
|
|
1403
|
-
return value;
|
|
1404
|
-
}
|
|
1405
|
-
var REGEXP_LT = /</g;
|
|
1406
|
-
var REGEXP_GT = />/g;
|
|
1407
|
-
var REGEXP_QUOTE = /"/g;
|
|
1408
|
-
var REGEXP_QUOTE_2 = /"/g;
|
|
1409
|
-
var REGEXP_ATTR_VALUE_1 = /&#([a-zA-Z0-9]*);?/gim;
|
|
1410
|
-
var REGEXP_ATTR_VALUE_COLON = /:?/gim;
|
|
1411
|
-
var REGEXP_ATTR_VALUE_NEWLINE = /&newline;?/gim;
|
|
1412
|
-
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;
|
|
1413
|
-
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;
|
|
1414
|
-
var REGEXP_DEFAULT_ON_TAG_ATTR_8 = /u\s*r\s*l\s*\(.*/gi;
|
|
1415
|
-
function escapeQuote(str) {
|
|
1416
|
-
return str.replace(REGEXP_QUOTE, """);
|
|
1417
|
-
}
|
|
1418
|
-
function unescapeQuote(str) {
|
|
1419
|
-
return str.replace(REGEXP_QUOTE_2, '"');
|
|
1420
|
-
}
|
|
1421
|
-
function escapeHtmlEntities(str) {
|
|
1422
|
-
return str.replace(REGEXP_ATTR_VALUE_1, function replaceUnicode(str2, code) {
|
|
1423
|
-
return code[0] === "x" || code[0] === "X" ? String.fromCharCode(parseInt(code.substr(1), 16)) : String.fromCharCode(parseInt(code, 10));
|
|
1424
|
-
});
|
|
1425
|
-
}
|
|
1426
|
-
function escapeDangerHtml5Entities(str) {
|
|
1427
|
-
return str.replace(REGEXP_ATTR_VALUE_COLON, ":").replace(REGEXP_ATTR_VALUE_NEWLINE, " ");
|
|
1428
|
-
}
|
|
1429
|
-
function clearNonPrintableCharacter(str) {
|
|
1430
|
-
var str2 = "";
|
|
1431
|
-
for (var i = 0, len = str.length; i < len; i++) {
|
|
1432
|
-
str2 += str.charCodeAt(i) < 32 ? " " : str.charAt(i);
|
|
1433
|
-
}
|
|
1434
|
-
return _$2.trim(str2);
|
|
1435
|
-
}
|
|
1436
|
-
function friendlyAttrValue(str) {
|
|
1437
|
-
str = unescapeQuote(str);
|
|
1438
|
-
str = escapeHtmlEntities(str);
|
|
1439
|
-
str = escapeDangerHtml5Entities(str);
|
|
1440
|
-
str = clearNonPrintableCharacter(str);
|
|
1441
|
-
return str;
|
|
1442
|
-
}
|
|
1443
|
-
function escapeAttrValue(str) {
|
|
1444
|
-
str = escapeQuote(str);
|
|
1445
|
-
str = escapeHtml(str);
|
|
1446
|
-
return str;
|
|
1447
|
-
}
|
|
1448
|
-
function onIgnoreTagStripAll() {
|
|
1449
|
-
return "";
|
|
1450
|
-
}
|
|
1451
|
-
function StripTagBody(tags, next) {
|
|
1452
|
-
if (typeof next !== "function") {
|
|
1453
|
-
next = function() {
|
|
1454
|
-
};
|
|
1455
|
-
}
|
|
1456
|
-
var isRemoveAllTag = !Array.isArray(tags);
|
|
1457
|
-
function isRemoveTag(tag) {
|
|
1458
|
-
if (isRemoveAllTag) return true;
|
|
1459
|
-
return _$2.indexOf(tags, tag) !== -1;
|
|
1460
|
-
}
|
|
1461
|
-
var removeList = [];
|
|
1462
|
-
var posStart = false;
|
|
1463
|
-
return {
|
|
1464
|
-
onIgnoreTag: function(tag, html, options) {
|
|
1465
|
-
if (isRemoveTag(tag)) {
|
|
1466
|
-
if (options.isClosing) {
|
|
1467
|
-
var ret = "[/removed]";
|
|
1468
|
-
var end = options.position + ret.length;
|
|
1469
|
-
removeList.push([
|
|
1470
|
-
posStart !== false ? posStart : options.position,
|
|
1471
|
-
end
|
|
1472
|
-
]);
|
|
1473
|
-
posStart = false;
|
|
1474
|
-
return ret;
|
|
1475
|
-
} else {
|
|
1476
|
-
if (!posStart) {
|
|
1477
|
-
posStart = options.position;
|
|
1478
|
-
}
|
|
1479
|
-
return "[removed]";
|
|
1480
|
-
}
|
|
1481
|
-
} else {
|
|
1482
|
-
return next(tag, html, options);
|
|
1483
|
-
}
|
|
1484
|
-
},
|
|
1485
|
-
remove: function(html) {
|
|
1486
|
-
var rethtml = "";
|
|
1487
|
-
var lastPos = 0;
|
|
1488
|
-
_$2.forEach(removeList, function(pos) {
|
|
1489
|
-
rethtml += html.slice(lastPos, pos[0]);
|
|
1490
|
-
lastPos = pos[1];
|
|
1491
|
-
});
|
|
1492
|
-
rethtml += html.slice(lastPos);
|
|
1493
|
-
return rethtml;
|
|
1494
|
-
}
|
|
1495
|
-
};
|
|
1496
|
-
}
|
|
1497
|
-
function stripCommentTag(html) {
|
|
1498
|
-
var retHtml = "";
|
|
1499
|
-
var lastPos = 0;
|
|
1500
|
-
while (lastPos < html.length) {
|
|
1501
|
-
var i = html.indexOf("<!--", lastPos);
|
|
1502
|
-
if (i === -1) {
|
|
1503
|
-
retHtml += html.slice(lastPos);
|
|
1504
|
-
break;
|
|
1505
|
-
}
|
|
1506
|
-
retHtml += html.slice(lastPos, i);
|
|
1507
|
-
var j = html.indexOf("-->", i);
|
|
1508
|
-
if (j === -1) {
|
|
1509
|
-
break;
|
|
1510
|
-
}
|
|
1511
|
-
lastPos = j + 3;
|
|
1512
|
-
}
|
|
1513
|
-
return retHtml;
|
|
1514
|
-
}
|
|
1515
|
-
function stripBlankChar(html) {
|
|
1516
|
-
var chars = html.split("");
|
|
1517
|
-
chars = chars.filter(function(char) {
|
|
1518
|
-
var c = char.charCodeAt(0);
|
|
1519
|
-
if (c === 127) return false;
|
|
1520
|
-
if (c <= 31) {
|
|
1521
|
-
if (c === 10 || c === 13) return true;
|
|
1522
|
-
return false;
|
|
1523
|
-
}
|
|
1524
|
-
return true;
|
|
1525
|
-
});
|
|
1526
|
-
return chars.join("");
|
|
1527
|
-
}
|
|
1528
|
-
_default$1.whiteList = getDefaultWhiteList();
|
|
1529
|
-
_default$1.getDefaultWhiteList = getDefaultWhiteList;
|
|
1530
|
-
_default$1.onTag = onTag;
|
|
1531
|
-
_default$1.onIgnoreTag = onIgnoreTag;
|
|
1532
|
-
_default$1.onTagAttr = onTagAttr;
|
|
1533
|
-
_default$1.onIgnoreTagAttr = onIgnoreTagAttr;
|
|
1534
|
-
_default$1.safeAttrValue = safeAttrValue;
|
|
1535
|
-
_default$1.escapeHtml = escapeHtml;
|
|
1536
|
-
_default$1.escapeQuote = escapeQuote;
|
|
1537
|
-
_default$1.unescapeQuote = unescapeQuote;
|
|
1538
|
-
_default$1.escapeHtmlEntities = escapeHtmlEntities;
|
|
1539
|
-
_default$1.escapeDangerHtml5Entities = escapeDangerHtml5Entities;
|
|
1540
|
-
_default$1.clearNonPrintableCharacter = clearNonPrintableCharacter;
|
|
1541
|
-
_default$1.friendlyAttrValue = friendlyAttrValue;
|
|
1542
|
-
_default$1.escapeAttrValue = escapeAttrValue;
|
|
1543
|
-
_default$1.onIgnoreTagStripAll = onIgnoreTagStripAll;
|
|
1544
|
-
_default$1.StripTagBody = StripTagBody;
|
|
1545
|
-
_default$1.stripCommentTag = stripCommentTag;
|
|
1546
|
-
_default$1.stripBlankChar = stripBlankChar;
|
|
1547
|
-
_default$1.attributeWrapSign = '"';
|
|
1548
|
-
_default$1.cssFilter = defaultCSSFilter;
|
|
1549
|
-
_default$1.getDefaultCSSWhiteList = getDefaultCSSWhiteList;
|
|
1550
|
-
var parser$1 = {};
|
|
1551
|
-
var _$1 = util;
|
|
1552
|
-
function getTagName(html) {
|
|
1553
|
-
var i = _$1.spaceIndex(html);
|
|
1554
|
-
var tagName;
|
|
1555
|
-
if (i === -1) {
|
|
1556
|
-
tagName = html.slice(1, -1);
|
|
1557
|
-
} else {
|
|
1558
|
-
tagName = html.slice(1, i + 1);
|
|
1559
|
-
}
|
|
1560
|
-
tagName = _$1.trim(tagName).toLowerCase();
|
|
1561
|
-
if (tagName.slice(0, 1) === "/") tagName = tagName.slice(1);
|
|
1562
|
-
if (tagName.slice(-1) === "/") tagName = tagName.slice(0, -1);
|
|
1563
|
-
return tagName;
|
|
1564
|
-
}
|
|
1565
|
-
function isClosing(html) {
|
|
1566
|
-
return html.slice(0, 2) === "</";
|
|
1567
|
-
}
|
|
1568
|
-
function parseTag$1(html, onTag2, escapeHtml2) {
|
|
1569
|
-
var rethtml = "";
|
|
1570
|
-
var lastPos = 0;
|
|
1571
|
-
var tagStart = false;
|
|
1572
|
-
var quoteStart = false;
|
|
1573
|
-
var currentPos = 0;
|
|
1574
|
-
var len = html.length;
|
|
1575
|
-
var currentTagName = "";
|
|
1576
|
-
var currentHtml = "";
|
|
1577
|
-
chariterator: for (currentPos = 0; currentPos < len; currentPos++) {
|
|
1578
|
-
var c = html.charAt(currentPos);
|
|
1579
|
-
if (tagStart === false) {
|
|
1580
|
-
if (c === "<") {
|
|
1581
|
-
tagStart = currentPos;
|
|
1582
|
-
continue;
|
|
1583
|
-
}
|
|
1584
|
-
} else {
|
|
1585
|
-
if (quoteStart === false) {
|
|
1586
|
-
if (c === "<") {
|
|
1587
|
-
rethtml += escapeHtml2(html.slice(lastPos, currentPos));
|
|
1588
|
-
tagStart = currentPos;
|
|
1589
|
-
lastPos = currentPos;
|
|
1590
|
-
continue;
|
|
1591
|
-
}
|
|
1592
|
-
if (c === ">" || currentPos === len - 1) {
|
|
1593
|
-
rethtml += escapeHtml2(html.slice(lastPos, tagStart));
|
|
1594
|
-
currentHtml = html.slice(tagStart, currentPos + 1);
|
|
1595
|
-
currentTagName = getTagName(currentHtml);
|
|
1596
|
-
rethtml += onTag2(
|
|
1597
|
-
tagStart,
|
|
1598
|
-
rethtml.length,
|
|
1599
|
-
currentTagName,
|
|
1600
|
-
currentHtml,
|
|
1601
|
-
isClosing(currentHtml)
|
|
1602
|
-
);
|
|
1603
|
-
lastPos = currentPos + 1;
|
|
1604
|
-
tagStart = false;
|
|
1605
|
-
continue;
|
|
1606
|
-
}
|
|
1607
|
-
if (c === '"' || c === "'") {
|
|
1608
|
-
var i = 1;
|
|
1609
|
-
var ic = html.charAt(currentPos - i);
|
|
1610
|
-
while (ic.trim() === "" || ic === "=") {
|
|
1611
|
-
if (ic === "=") {
|
|
1612
|
-
quoteStart = c;
|
|
1613
|
-
continue chariterator;
|
|
1614
|
-
}
|
|
1615
|
-
ic = html.charAt(currentPos - ++i);
|
|
1616
|
-
}
|
|
1617
|
-
}
|
|
1618
|
-
} else {
|
|
1619
|
-
if (c === quoteStart) {
|
|
1620
|
-
quoteStart = false;
|
|
1621
|
-
continue;
|
|
1622
|
-
}
|
|
1623
|
-
}
|
|
1624
|
-
}
|
|
1625
|
-
}
|
|
1626
|
-
if (lastPos < len) {
|
|
1627
|
-
rethtml += escapeHtml2(html.substr(lastPos));
|
|
1628
|
-
}
|
|
1629
|
-
return rethtml;
|
|
1630
|
-
}
|
|
1631
|
-
var REGEXP_ILLEGAL_ATTR_NAME = /[^a-zA-Z0-9\\_:.-]/gim;
|
|
1632
|
-
function parseAttr$1(html, onAttr2) {
|
|
1633
|
-
var lastPos = 0;
|
|
1634
|
-
var lastMarkPos = 0;
|
|
1635
|
-
var retAttrs = [];
|
|
1636
|
-
var tmpName = false;
|
|
1637
|
-
var len = html.length;
|
|
1638
|
-
function addAttr(name, value) {
|
|
1639
|
-
name = _$1.trim(name);
|
|
1640
|
-
name = name.replace(REGEXP_ILLEGAL_ATTR_NAME, "").toLowerCase();
|
|
1641
|
-
if (name.length < 1) return;
|
|
1642
|
-
var ret = onAttr2(name, value || "");
|
|
1643
|
-
if (ret) retAttrs.push(ret);
|
|
1644
|
-
}
|
|
1645
|
-
for (var i = 0; i < len; i++) {
|
|
1646
|
-
var c = html.charAt(i);
|
|
1647
|
-
var v, j;
|
|
1648
|
-
if (tmpName === false && c === "=") {
|
|
1649
|
-
tmpName = html.slice(lastPos, i);
|
|
1650
|
-
lastPos = i + 1;
|
|
1651
|
-
lastMarkPos = html.charAt(lastPos) === '"' || html.charAt(lastPos) === "'" ? lastPos : findNextQuotationMark(html, i + 1);
|
|
1652
|
-
continue;
|
|
1653
|
-
}
|
|
1654
|
-
if (tmpName !== false) {
|
|
1655
|
-
if (i === lastMarkPos) {
|
|
1656
|
-
j = html.indexOf(c, i + 1);
|
|
1657
|
-
if (j === -1) {
|
|
1658
|
-
break;
|
|
1659
|
-
} else {
|
|
1660
|
-
v = _$1.trim(html.slice(lastMarkPos + 1, j));
|
|
1661
|
-
addAttr(tmpName, v);
|
|
1662
|
-
tmpName = false;
|
|
1663
|
-
i = j;
|
|
1664
|
-
lastPos = i + 1;
|
|
1665
|
-
continue;
|
|
1666
|
-
}
|
|
1667
|
-
}
|
|
1668
|
-
}
|
|
1669
|
-
if (/\s|\n|\t/.test(c)) {
|
|
1670
|
-
html = html.replace(/\s|\n|\t/g, " ");
|
|
1671
|
-
if (tmpName === false) {
|
|
1672
|
-
j = findNextEqual(html, i);
|
|
1673
|
-
if (j === -1) {
|
|
1674
|
-
v = _$1.trim(html.slice(lastPos, i));
|
|
1675
|
-
addAttr(v);
|
|
1676
|
-
tmpName = false;
|
|
1677
|
-
lastPos = i + 1;
|
|
1678
|
-
continue;
|
|
1679
|
-
} else {
|
|
1680
|
-
i = j - 1;
|
|
1681
|
-
continue;
|
|
1682
|
-
}
|
|
1683
|
-
} else {
|
|
1684
|
-
j = findBeforeEqual(html, i - 1);
|
|
1685
|
-
if (j === -1) {
|
|
1686
|
-
v = _$1.trim(html.slice(lastPos, i));
|
|
1687
|
-
v = stripQuoteWrap(v);
|
|
1688
|
-
addAttr(tmpName, v);
|
|
1689
|
-
tmpName = false;
|
|
1690
|
-
lastPos = i + 1;
|
|
1691
|
-
continue;
|
|
1692
|
-
} else {
|
|
1693
|
-
continue;
|
|
1694
|
-
}
|
|
1695
|
-
}
|
|
1696
|
-
}
|
|
1697
|
-
}
|
|
1698
|
-
if (lastPos < html.length) {
|
|
1699
|
-
if (tmpName === false) {
|
|
1700
|
-
addAttr(html.slice(lastPos));
|
|
1701
|
-
} else {
|
|
1702
|
-
addAttr(tmpName, stripQuoteWrap(_$1.trim(html.slice(lastPos))));
|
|
1703
|
-
}
|
|
1704
|
-
}
|
|
1705
|
-
return _$1.trim(retAttrs.join(" "));
|
|
1706
|
-
}
|
|
1707
|
-
function findNextEqual(str, i) {
|
|
1708
|
-
for (; i < str.length; i++) {
|
|
1709
|
-
var c = str[i];
|
|
1710
|
-
if (c === " ") continue;
|
|
1711
|
-
if (c === "=") return i;
|
|
1712
|
-
return -1;
|
|
1713
|
-
}
|
|
1714
|
-
}
|
|
1715
|
-
function findNextQuotationMark(str, i) {
|
|
1716
|
-
for (; i < str.length; i++) {
|
|
1717
|
-
var c = str[i];
|
|
1718
|
-
if (c === " ") continue;
|
|
1719
|
-
if (c === "'" || c === '"') return i;
|
|
1720
|
-
return -1;
|
|
1721
|
-
}
|
|
1722
|
-
}
|
|
1723
|
-
function findBeforeEqual(str, i) {
|
|
1724
|
-
for (; i > 0; i--) {
|
|
1725
|
-
var c = str[i];
|
|
1726
|
-
if (c === " ") continue;
|
|
1727
|
-
if (c === "=") return i;
|
|
1728
|
-
return -1;
|
|
1729
|
-
}
|
|
1730
|
-
}
|
|
1731
|
-
function isQuoteWrapString(text) {
|
|
1732
|
-
if (text[0] === '"' && text[text.length - 1] === '"' || text[0] === "'" && text[text.length - 1] === "'") {
|
|
1733
|
-
return true;
|
|
1734
|
-
} else {
|
|
1735
|
-
return false;
|
|
1736
|
-
}
|
|
1737
|
-
}
|
|
1738
|
-
function stripQuoteWrap(text) {
|
|
1739
|
-
if (isQuoteWrapString(text)) {
|
|
1740
|
-
return text.substr(1, text.length - 2);
|
|
1741
|
-
} else {
|
|
1742
|
-
return text;
|
|
1743
|
-
}
|
|
1744
|
-
}
|
|
1745
|
-
parser$1.parseTag = parseTag$1;
|
|
1746
|
-
parser$1.parseAttr = parseAttr$1;
|
|
1747
|
-
var FilterCSS = libExports$1.FilterCSS;
|
|
1748
|
-
var DEFAULT = _default$1;
|
|
1749
|
-
var parser = parser$1;
|
|
1750
|
-
var parseTag = parser.parseTag;
|
|
1751
|
-
var parseAttr = parser.parseAttr;
|
|
1752
|
-
var _ = util;
|
|
1753
|
-
function isNull(obj) {
|
|
1754
|
-
return obj === void 0 || obj === null;
|
|
1755
|
-
}
|
|
1756
|
-
function getAttrs(html) {
|
|
1757
|
-
var i = _.spaceIndex(html);
|
|
1758
|
-
if (i === -1) {
|
|
1759
|
-
return {
|
|
1760
|
-
html: "",
|
|
1761
|
-
closing: html[html.length - 2] === "/"
|
|
1762
|
-
};
|
|
1763
|
-
}
|
|
1764
|
-
html = _.trim(html.slice(i + 1, -1));
|
|
1765
|
-
var isClosing2 = html[html.length - 1] === "/";
|
|
1766
|
-
if (isClosing2) html = _.trim(html.slice(0, -1));
|
|
1767
|
-
return {
|
|
1768
|
-
html,
|
|
1769
|
-
closing: isClosing2
|
|
1770
|
-
};
|
|
1771
|
-
}
|
|
1772
|
-
function shallowCopyObject(obj) {
|
|
1773
|
-
var ret = {};
|
|
1774
|
-
for (var i in obj) {
|
|
1775
|
-
ret[i] = obj[i];
|
|
1776
|
-
}
|
|
1777
|
-
return ret;
|
|
1778
|
-
}
|
|
1779
|
-
function keysToLowerCase(obj) {
|
|
1780
|
-
var ret = {};
|
|
1781
|
-
for (var i in obj) {
|
|
1782
|
-
if (Array.isArray(obj[i])) {
|
|
1783
|
-
ret[i.toLowerCase()] = obj[i].map(function(item) {
|
|
1784
|
-
return item.toLowerCase();
|
|
1785
|
-
});
|
|
1786
|
-
} else {
|
|
1787
|
-
ret[i.toLowerCase()] = obj[i];
|
|
1788
|
-
}
|
|
1789
|
-
}
|
|
1790
|
-
return ret;
|
|
1791
|
-
}
|
|
1792
|
-
function FilterXSS(options) {
|
|
1793
|
-
options = shallowCopyObject(options || {});
|
|
1794
|
-
if (options.stripIgnoreTag) {
|
|
1795
|
-
if (options.onIgnoreTag) {
|
|
1796
|
-
console.error(
|
|
1797
|
-
'Notes: cannot use these two options "stripIgnoreTag" and "onIgnoreTag" at the same time'
|
|
1798
|
-
);
|
|
1799
|
-
}
|
|
1800
|
-
options.onIgnoreTag = DEFAULT.onIgnoreTagStripAll;
|
|
1801
|
-
}
|
|
1802
|
-
if (options.whiteList || options.allowList) {
|
|
1803
|
-
options.whiteList = keysToLowerCase(options.whiteList || options.allowList);
|
|
1804
|
-
} else {
|
|
1805
|
-
options.whiteList = DEFAULT.whiteList;
|
|
1806
|
-
}
|
|
1807
|
-
this.attributeWrapSign = options.singleQuotedAttributeValue === true ? "'" : DEFAULT.attributeWrapSign;
|
|
1808
|
-
options.onTag = options.onTag || DEFAULT.onTag;
|
|
1809
|
-
options.onTagAttr = options.onTagAttr || DEFAULT.onTagAttr;
|
|
1810
|
-
options.onIgnoreTag = options.onIgnoreTag || DEFAULT.onIgnoreTag;
|
|
1811
|
-
options.onIgnoreTagAttr = options.onIgnoreTagAttr || DEFAULT.onIgnoreTagAttr;
|
|
1812
|
-
options.safeAttrValue = options.safeAttrValue || DEFAULT.safeAttrValue;
|
|
1813
|
-
options.escapeHtml = options.escapeHtml || DEFAULT.escapeHtml;
|
|
1814
|
-
this.options = options;
|
|
1815
|
-
if (options.css === false) {
|
|
1816
|
-
this.cssFilter = false;
|
|
1817
|
-
} else {
|
|
1818
|
-
options.css = options.css || {};
|
|
1819
|
-
this.cssFilter = new FilterCSS(options.css);
|
|
1820
|
-
}
|
|
1821
|
-
}
|
|
1822
|
-
FilterXSS.prototype.process = function(html) {
|
|
1823
|
-
html = html || "";
|
|
1824
|
-
html = html.toString();
|
|
1825
|
-
if (!html) return "";
|
|
1826
|
-
var me = this;
|
|
1827
|
-
var options = me.options;
|
|
1828
|
-
var whiteList = options.whiteList;
|
|
1829
|
-
var onTag2 = options.onTag;
|
|
1830
|
-
var onIgnoreTag2 = options.onIgnoreTag;
|
|
1831
|
-
var onTagAttr2 = options.onTagAttr;
|
|
1832
|
-
var onIgnoreTagAttr2 = options.onIgnoreTagAttr;
|
|
1833
|
-
var safeAttrValue2 = options.safeAttrValue;
|
|
1834
|
-
var escapeHtml2 = options.escapeHtml;
|
|
1835
|
-
var attributeWrapSign = me.attributeWrapSign;
|
|
1836
|
-
var cssFilter = me.cssFilter;
|
|
1837
|
-
if (options.stripBlankChar) {
|
|
1838
|
-
html = DEFAULT.stripBlankChar(html);
|
|
1839
|
-
}
|
|
1840
|
-
if (!options.allowCommentTag) {
|
|
1841
|
-
html = DEFAULT.stripCommentTag(html);
|
|
1842
|
-
}
|
|
1843
|
-
var stripIgnoreTagBody = false;
|
|
1844
|
-
if (options.stripIgnoreTagBody) {
|
|
1845
|
-
stripIgnoreTagBody = DEFAULT.StripTagBody(
|
|
1846
|
-
options.stripIgnoreTagBody,
|
|
1847
|
-
onIgnoreTag2
|
|
1848
|
-
);
|
|
1849
|
-
onIgnoreTag2 = stripIgnoreTagBody.onIgnoreTag;
|
|
1850
|
-
}
|
|
1851
|
-
var retHtml = parseTag(
|
|
1852
|
-
html,
|
|
1853
|
-
function(sourcePosition, position, tag, html2, isClosing2) {
|
|
1854
|
-
var info = {
|
|
1855
|
-
sourcePosition,
|
|
1856
|
-
position,
|
|
1857
|
-
isClosing: isClosing2,
|
|
1858
|
-
isWhite: Object.prototype.hasOwnProperty.call(whiteList, tag)
|
|
1859
|
-
};
|
|
1860
|
-
var ret = onTag2(tag, html2, info);
|
|
1861
|
-
if (!isNull(ret)) return ret;
|
|
1862
|
-
if (info.isWhite) {
|
|
1863
|
-
if (info.isClosing) {
|
|
1864
|
-
return "</" + tag + ">";
|
|
1865
|
-
}
|
|
1866
|
-
var attrs = getAttrs(html2);
|
|
1867
|
-
var whiteAttrList = whiteList[tag];
|
|
1868
|
-
var attrsHtml = parseAttr(attrs.html, function(name, value) {
|
|
1869
|
-
var isWhiteAttr = _.indexOf(whiteAttrList, name) !== -1;
|
|
1870
|
-
var ret2 = onTagAttr2(tag, name, value, isWhiteAttr);
|
|
1871
|
-
if (!isNull(ret2)) return ret2;
|
|
1872
|
-
if (isWhiteAttr) {
|
|
1873
|
-
value = safeAttrValue2(tag, name, value, cssFilter);
|
|
1874
|
-
if (value) {
|
|
1875
|
-
return name + "=" + attributeWrapSign + value + attributeWrapSign;
|
|
1876
|
-
} else {
|
|
1877
|
-
return name;
|
|
1878
|
-
}
|
|
1879
|
-
} else {
|
|
1880
|
-
ret2 = onIgnoreTagAttr2(tag, name, value, isWhiteAttr);
|
|
1881
|
-
if (!isNull(ret2)) return ret2;
|
|
1882
|
-
return;
|
|
1883
|
-
}
|
|
1884
|
-
});
|
|
1885
|
-
html2 = "<" + tag;
|
|
1886
|
-
if (attrsHtml) html2 += " " + attrsHtml;
|
|
1887
|
-
if (attrs.closing) html2 += " /";
|
|
1888
|
-
html2 += ">";
|
|
1889
|
-
return html2;
|
|
1890
|
-
} else {
|
|
1891
|
-
ret = onIgnoreTag2(tag, html2, info);
|
|
1892
|
-
if (!isNull(ret)) return ret;
|
|
1893
|
-
return escapeHtml2(html2);
|
|
1894
|
-
}
|
|
1895
|
-
},
|
|
1896
|
-
escapeHtml2
|
|
1897
|
-
);
|
|
1898
|
-
if (stripIgnoreTagBody) {
|
|
1899
|
-
retHtml = stripIgnoreTagBody.remove(retHtml);
|
|
1900
|
-
}
|
|
1901
|
-
return retHtml;
|
|
1902
|
-
};
|
|
1903
|
-
var xss$1 = FilterXSS;
|
|
1904
|
-
(function(module2, exports2) {
|
|
1905
|
-
var DEFAULT2 = _default$1;
|
|
1906
|
-
var parser2 = parser$1;
|
|
1907
|
-
var FilterXSS2 = xss$1;
|
|
1908
|
-
function filterXSS(html, options) {
|
|
1909
|
-
var xss2 = new FilterXSS2(options);
|
|
1910
|
-
return xss2.process(html);
|
|
1911
|
-
}
|
|
1912
|
-
exports2 = module2.exports = filterXSS;
|
|
1913
|
-
exports2.filterXSS = filterXSS;
|
|
1914
|
-
exports2.FilterXSS = FilterXSS2;
|
|
1915
|
-
(function() {
|
|
1916
|
-
for (var i in DEFAULT2) {
|
|
1917
|
-
exports2[i] = DEFAULT2[i];
|
|
1918
|
-
}
|
|
1919
|
-
for (var j in parser2) {
|
|
1920
|
-
exports2[j] = parser2[j];
|
|
1921
|
-
}
|
|
1922
|
-
})();
|
|
1923
|
-
if (typeof window !== "undefined") {
|
|
1924
|
-
window.filterXSS = module2.exports;
|
|
1925
|
-
}
|
|
1926
|
-
function isWorkerEnv() {
|
|
1927
|
-
return typeof self !== "undefined" && typeof DedicatedWorkerGlobalScope !== "undefined" && self instanceof DedicatedWorkerGlobalScope;
|
|
1928
|
-
}
|
|
1929
|
-
if (isWorkerEnv()) {
|
|
1930
|
-
self.filterXSS = module2.exports;
|
|
1931
|
-
}
|
|
1932
|
-
})(lib$1, lib$1.exports);
|
|
1933
|
-
var libExports = lib$1.exports;
|
|
1934
|
-
const index = /* @__PURE__ */ getDefaultExportFromCjs(libExports);
|
|
1935
|
-
const xss = /* @__PURE__ */ _mergeNamespaces({
|
|
1936
|
-
__proto__: null,
|
|
1937
|
-
default: index
|
|
1938
|
-
}, [libExports]);
|
|
1939
|
-
const MdWhiteList = {
|
|
1940
|
-
img: ["class"],
|
|
1941
|
-
// 支持任务列表
|
|
1942
|
-
input: ["class", "disabled", "type", "checked"],
|
|
1943
|
-
// 主要支持youtobe、腾讯视频、哔哩哔哩等内嵌视频代码
|
|
1944
|
-
iframe: [
|
|
1945
|
-
"class",
|
|
1946
|
-
"width",
|
|
1947
|
-
"height",
|
|
1948
|
-
"src",
|
|
1949
|
-
"title",
|
|
1950
|
-
"border",
|
|
1951
|
-
"frameborder",
|
|
1952
|
-
"framespacing",
|
|
1953
|
-
"allow",
|
|
1954
|
-
"allowfullscreen"
|
|
1955
|
-
]
|
|
1956
|
-
};
|
|
1957
|
-
const XSSPlugin = (md, options) => {
|
|
1958
|
-
const { extendedWhiteList = {}, xss: xssOption = {} } = options;
|
|
1959
|
-
let xssIns;
|
|
1960
|
-
if (typeof xssOption === "function") {
|
|
1961
|
-
xssIns = new libExports.FilterXSS(xssOption(xss));
|
|
1962
|
-
} else {
|
|
1963
|
-
const whiteList = libExports.getDefaultWhiteList();
|
|
1964
|
-
const keys = [...Object.keys(extendedWhiteList), ...Object.keys(MdWhiteList)];
|
|
1965
|
-
keys.forEach((key) => {
|
|
1966
|
-
const xssWhiteItem = whiteList[key] || [];
|
|
1967
|
-
const innerWhiteItem = MdWhiteList[key] || [];
|
|
1968
|
-
const userDefWhiteItem = extendedWhiteList[key] || [];
|
|
1969
|
-
whiteList[key] = [
|
|
1970
|
-
.../* @__PURE__ */ new Set([...xssWhiteItem, ...innerWhiteItem, ...userDefWhiteItem])
|
|
1971
|
-
];
|
|
1972
|
-
});
|
|
1973
|
-
xssIns = new libExports.FilterXSS({
|
|
1974
|
-
whiteList,
|
|
1975
|
-
// 自定义的优先级最高
|
|
1976
|
-
...xssOption
|
|
1977
|
-
});
|
|
1978
|
-
}
|
|
1979
|
-
md.core.ruler.after("linkify", "xss", (state) => {
|
|
1980
|
-
for (let i = 0; i < state.tokens.length; i++) {
|
|
1981
|
-
const cur = state.tokens[i];
|
|
1982
|
-
switch (cur.type) {
|
|
1983
|
-
case "html_block": {
|
|
1984
|
-
cur.content = xssIns.process(cur.content);
|
|
1985
|
-
break;
|
|
1986
|
-
}
|
|
1987
|
-
case "inline": {
|
|
1988
|
-
const inlineTokens = cur.children || [];
|
|
1989
|
-
inlineTokens.forEach((it) => {
|
|
1990
|
-
if (it.type === "html_inline") {
|
|
1991
|
-
it.content = xssIns.process(it.content);
|
|
1992
|
-
}
|
|
1993
|
-
});
|
|
1994
|
-
break;
|
|
1995
|
-
}
|
|
1996
|
-
}
|
|
1997
|
-
}
|
|
1998
|
-
});
|
|
1999
|
-
};
|
|
2000
722
|
const attrSet = (token, name, value) => {
|
|
2001
723
|
const index2 = token.attrIndex(name);
|
|
2002
724
|
const attr = [name, value];
|
|
@@ -2159,11 +881,6 @@ const useMarkdownIt = (props, previewOnly) => {
|
|
|
2159
881
|
customIconRef
|
|
2160
882
|
}
|
|
2161
883
|
},
|
|
2162
|
-
{
|
|
2163
|
-
type: "xss",
|
|
2164
|
-
plugin: XSSPlugin,
|
|
2165
|
-
options: {}
|
|
2166
|
-
},
|
|
2167
884
|
{
|
|
2168
885
|
type: "sub",
|
|
2169
886
|
plugin: SubPlugin,
|
|
@@ -2217,7 +934,7 @@ const useMarkdownIt = (props, previewOnly) => {
|
|
|
2217
934
|
} else {
|
|
2218
935
|
codeHtml = md.utils.escapeHtml(str);
|
|
2219
936
|
}
|
|
2220
|
-
const codeSpan = showCodeRowNumber ? index
|
|
937
|
+
const codeSpan = showCodeRowNumber ? index.generateCodeRowNumber(
|
|
2221
938
|
codeHtml.replace(/^\n+|\n+$/g, ""),
|
|
2222
939
|
str.replace(/^\n+|\n+$/g, "")
|
|
2223
940
|
) : `<span class="${config.prefix}-code-block">${codeHtml.replace(/^\n+|\n+$/g, "")}</span>`;
|
|
@@ -2225,7 +942,7 @@ const useMarkdownIt = (props, previewOnly) => {
|
|
|
2225
942
|
}
|
|
2226
943
|
});
|
|
2227
944
|
initLineNumber(md);
|
|
2228
|
-
const key = vue.ref(`_article-key_${util
|
|
945
|
+
const key = vue.ref(`_article-key_${util.randomId()}`);
|
|
2229
946
|
const html = vue.ref(props.sanitize(md.render(props.modelValue)));
|
|
2230
947
|
const updatedTodo = () => {
|
|
2231
948
|
eventName.bus.emit(editorId, eventName.BUILD_FINISHED, html.value);
|
|
@@ -2249,7 +966,7 @@ const useMarkdownIt = (props, previewOnly) => {
|
|
|
2249
966
|
});
|
|
2250
967
|
vue.watch(
|
|
2251
968
|
[vue.toRef(props, "modelValue"), needReRender, reRenderRef, languageRef],
|
|
2252
|
-
util
|
|
969
|
+
util.debounce(markHtml, previewOnly ? 0 : editorConfig.renderDelay)
|
|
2253
970
|
);
|
|
2254
971
|
vue.watch(
|
|
2255
972
|
() => props.setting.preview,
|
|
@@ -2276,7 +993,7 @@ const useMarkdownIt = (props, previewOnly) => {
|
|
|
2276
993
|
eventName.bus.on(editorId, {
|
|
2277
994
|
name: eventName.RERENDER,
|
|
2278
995
|
callback: () => {
|
|
2279
|
-
key.value = `_article-key_${util
|
|
996
|
+
key.value = `_article-key_${util.randomId()}`;
|
|
2280
997
|
markHtml();
|
|
2281
998
|
}
|
|
2282
999
|
});
|
|
@@ -2479,10 +1196,10 @@ const contentProps = {
|
|
|
2479
1196
|
default: () => {
|
|
2480
1197
|
}
|
|
2481
1198
|
},
|
|
2482
|
-
|
|
1199
|
+
inputBoxWidth: {
|
|
2483
1200
|
type: String
|
|
2484
1201
|
},
|
|
2485
|
-
|
|
1202
|
+
oninputBoxWidthChange: {
|
|
2486
1203
|
type: Function
|
|
2487
1204
|
},
|
|
2488
1205
|
transformImgUrl: {
|
|
@@ -2524,8 +1241,8 @@ const ContentPreview = /* @__PURE__ */ vue.defineComponent({
|
|
|
2524
1241
|
};
|
|
2525
1242
|
}
|
|
2526
1243
|
});
|
|
2527
|
-
const useOnSave = (props, context) => {
|
|
2528
|
-
const { editorId } =
|
|
1244
|
+
const useOnSave = (props, context, options) => {
|
|
1245
|
+
const { editorId } = options;
|
|
2529
1246
|
const state = vue.reactive({
|
|
2530
1247
|
// 是否已编译成html
|
|
2531
1248
|
buildFinished: false,
|
|
@@ -2573,9 +1290,9 @@ const useOnSave = (props, context) => {
|
|
|
2573
1290
|
});
|
|
2574
1291
|
};
|
|
2575
1292
|
const useProvidePreview = (props, rootRef) => {
|
|
2576
|
-
const { editorId } = props;
|
|
2577
1293
|
const hljsUrls = config.configOption.editorExtensions.highlight;
|
|
2578
1294
|
const hljsAttrs = config.configOption.editorExtensionsAttrs.highlight;
|
|
1295
|
+
const editorId = useEditorId(props);
|
|
2579
1296
|
vue.provide("editorId", editorId);
|
|
2580
1297
|
vue.provide("rootRef", rootRef);
|
|
2581
1298
|
vue.provide(
|
|
@@ -2616,8 +1333,8 @@ const useProvidePreview = (props, rootRef) => {
|
|
|
2616
1333
|
...config.staticTextDefault,
|
|
2617
1334
|
...config.configOption.editorConfig.languageUserDefined
|
|
2618
1335
|
};
|
|
2619
|
-
return util
|
|
2620
|
-
util
|
|
1336
|
+
return util.deepMerge(
|
|
1337
|
+
util.deepClone(config.staticTextDefault["en-US"]),
|
|
2621
1338
|
allText[props.language] || {}
|
|
2622
1339
|
);
|
|
2623
1340
|
});
|
|
@@ -2630,32 +1347,11 @@ const useProvidePreview = (props, rootRef) => {
|
|
|
2630
1347
|
"customIcon",
|
|
2631
1348
|
vue.computed(() => props.customIcon)
|
|
2632
1349
|
);
|
|
1350
|
+
return { editorId };
|
|
2633
1351
|
};
|
|
2634
1352
|
const useProvide = (props, rootRef) => {
|
|
2635
|
-
useProvidePreview(props, rootRef);
|
|
2636
1353
|
vue.provide("tabWidth", props.tabWidth);
|
|
2637
|
-
|
|
2638
|
-
const useExpansionPreview = (props) => {
|
|
2639
|
-
vue.onMounted(() => {
|
|
2640
|
-
const { editorExtensions, editorExtensionsAttrs, iconfontType } = config.configOption;
|
|
2641
|
-
if (props.noIconfont) {
|
|
2642
|
-
return;
|
|
2643
|
-
}
|
|
2644
|
-
if (iconfontType === "svg") {
|
|
2645
|
-
dom.appendHandler("script", {
|
|
2646
|
-
...editorExtensionsAttrs.iconfont,
|
|
2647
|
-
src: editorExtensions.iconfont,
|
|
2648
|
-
id: `${config.prefix}-icon`
|
|
2649
|
-
});
|
|
2650
|
-
} else {
|
|
2651
|
-
dom.appendHandler("link", {
|
|
2652
|
-
...editorExtensionsAttrs.iconfontClass,
|
|
2653
|
-
rel: "stylesheet",
|
|
2654
|
-
href: editorExtensions.iconfontClass,
|
|
2655
|
-
id: `${config.prefix}-icon-class`
|
|
2656
|
-
});
|
|
2657
|
-
}
|
|
2658
|
-
});
|
|
1354
|
+
return useProvidePreview(props, rootRef);
|
|
2659
1355
|
};
|
|
2660
1356
|
const useExpansion = (props) => {
|
|
2661
1357
|
const { noPrettier, noUploadImg } = props;
|
|
@@ -2665,9 +1361,9 @@ const useExpansion = (props) => {
|
|
|
2665
1361
|
const noCropperScript = noUploadImg || editorExtensions.cropper.instance;
|
|
2666
1362
|
vue.onMounted(() => {
|
|
2667
1363
|
if (!noCropperScript) {
|
|
2668
|
-
const { js = {}, css
|
|
1364
|
+
const { js = {}, css = {} } = editorExtensionsAttrs.cropper || {};
|
|
2669
1365
|
dom.appendHandler("link", {
|
|
2670
|
-
...
|
|
1366
|
+
...css,
|
|
2671
1367
|
rel: "stylesheet",
|
|
2672
1368
|
href: editorExtensions.cropper.css,
|
|
2673
1369
|
id: `${config.prefix}-cropperCss`
|
|
@@ -2695,10 +1391,9 @@ const useExpansion = (props) => {
|
|
|
2695
1391
|
});
|
|
2696
1392
|
}
|
|
2697
1393
|
});
|
|
2698
|
-
useExpansionPreview(props);
|
|
2699
1394
|
};
|
|
2700
|
-
const useErrorCatcher = (props, context) => {
|
|
2701
|
-
const { editorId } =
|
|
1395
|
+
const useErrorCatcher = (props, context, options) => {
|
|
1396
|
+
const { editorId } = options;
|
|
2702
1397
|
vue.onMounted(() => {
|
|
2703
1398
|
eventName.bus.on(editorId, {
|
|
2704
1399
|
name: eventName.ERROR_CATCHER,
|
|
@@ -2712,8 +1407,8 @@ const useErrorCatcher = (props, context) => {
|
|
|
2712
1407
|
});
|
|
2713
1408
|
});
|
|
2714
1409
|
};
|
|
2715
|
-
const useConfig = (props, context) => {
|
|
2716
|
-
const { editorId } =
|
|
1410
|
+
const useConfig = (props, context, options) => {
|
|
1411
|
+
const { editorId } = options;
|
|
2717
1412
|
const setting = vue.reactive({
|
|
2718
1413
|
pageFullscreen: props.pageFullscreen,
|
|
2719
1414
|
fullscreen: false,
|
|
@@ -2772,7 +1467,7 @@ const useConfig = (props, context) => {
|
|
|
2772
1467
|
desc: "",
|
|
2773
1468
|
urls
|
|
2774
1469
|
});
|
|
2775
|
-
cb
|
|
1470
|
+
cb == null ? void 0 : cb();
|
|
2776
1471
|
};
|
|
2777
1472
|
if (props.onUploadImg) {
|
|
2778
1473
|
props.onUploadImg(files, insertHanlder);
|
|
@@ -2786,8 +1481,8 @@ const useConfig = (props, context) => {
|
|
|
2786
1481
|
});
|
|
2787
1482
|
return [setting, updateSetting];
|
|
2788
1483
|
};
|
|
2789
|
-
const useCatalog = (props) => {
|
|
2790
|
-
const { editorId } =
|
|
1484
|
+
const useCatalog = (props, options) => {
|
|
1485
|
+
const { editorId } = options;
|
|
2791
1486
|
const catalogShow = vue.ref(false);
|
|
2792
1487
|
vue.onMounted(() => {
|
|
2793
1488
|
eventName.bus.on(editorId, {
|
|
@@ -2806,8 +1501,8 @@ const useCatalog = (props) => {
|
|
|
2806
1501
|
});
|
|
2807
1502
|
return catalogVisible;
|
|
2808
1503
|
};
|
|
2809
|
-
const useExpose$1 = (props, ctx,
|
|
2810
|
-
const { editorId } =
|
|
1504
|
+
const useExpose$1 = (props, ctx, options) => {
|
|
1505
|
+
const { editorId, catalogVisible, setting, updateSetting, codeRef } = options;
|
|
2811
1506
|
vue.watch(
|
|
2812
1507
|
() => setting.pageFullscreen,
|
|
2813
1508
|
(newVal) => {
|
|
@@ -2924,9 +1619,9 @@ const useExpose$1 = (props, ctx, catalogVisible, setting, updateSetting, codeRef
|
|
|
2924
1619
|
insert(generate) {
|
|
2925
1620
|
eventName.bus.emit(editorId, eventName.REPLACE, "universal", { generate });
|
|
2926
1621
|
},
|
|
2927
|
-
focus(
|
|
1622
|
+
focus(options2) {
|
|
2928
1623
|
var _a;
|
|
2929
|
-
(_a = codeRef.value) == null ? void 0 : _a.focus(
|
|
1624
|
+
(_a = codeRef.value) == null ? void 0 : _a.focus(options2);
|
|
2930
1625
|
},
|
|
2931
1626
|
rerender() {
|
|
2932
1627
|
eventName.bus.emit(editorId, eventName.RERENDER);
|
|
@@ -2952,6 +1647,10 @@ const useExpose$1 = (props, ctx, catalogVisible, setting, updateSetting, codeRef
|
|
|
2952
1647
|
};
|
|
2953
1648
|
ctx.expose(exposeParam);
|
|
2954
1649
|
};
|
|
1650
|
+
const useEditorId = (props) => {
|
|
1651
|
+
const defaultId = vue.useId();
|
|
1652
|
+
return props.id || props.editorId || `${config.prefix}-${defaultId}`;
|
|
1653
|
+
};
|
|
2955
1654
|
const mdHeadingId = (text) => text;
|
|
2956
1655
|
const mdPreviewProps = {
|
|
2957
1656
|
/**
|
|
@@ -2967,7 +1666,8 @@ const mdPreviewProps = {
|
|
|
2967
1666
|
* input回调事件
|
|
2968
1667
|
*/
|
|
2969
1668
|
onChange: {
|
|
2970
|
-
type: Function
|
|
1669
|
+
type: Function,
|
|
1670
|
+
default: void 0
|
|
2971
1671
|
},
|
|
2972
1672
|
/**
|
|
2973
1673
|
* 主题,支持light和dark
|
|
@@ -3000,22 +1700,34 @@ const mdPreviewProps = {
|
|
|
3000
1700
|
* html变化事件
|
|
3001
1701
|
*/
|
|
3002
1702
|
onHtmlChanged: {
|
|
3003
|
-
type: Function
|
|
1703
|
+
type: Function,
|
|
1704
|
+
default: void 0
|
|
3004
1705
|
},
|
|
3005
1706
|
/**
|
|
3006
1707
|
* 获取目录结构
|
|
3007
1708
|
*/
|
|
3008
1709
|
onGetCatalog: {
|
|
3009
|
-
type: Function
|
|
1710
|
+
type: Function,
|
|
1711
|
+
default: void 0
|
|
3010
1712
|
},
|
|
3011
1713
|
/**
|
|
3012
1714
|
* 编辑器唯一标识
|
|
3013
1715
|
*
|
|
3014
1716
|
* @default 'md-editor-v3'
|
|
1717
|
+
* @deprecated 5.x版本开始使用 id 替换
|
|
3015
1718
|
*/
|
|
3016
1719
|
editorId: {
|
|
3017
1720
|
type: String,
|
|
3018
|
-
default:
|
|
1721
|
+
default: void 0
|
|
1722
|
+
},
|
|
1723
|
+
/**
|
|
1724
|
+
* 5.x版本开始 editorId 的替换
|
|
1725
|
+
*
|
|
1726
|
+
* @default 'md-editor-v3'
|
|
1727
|
+
*/
|
|
1728
|
+
id: {
|
|
1729
|
+
type: String,
|
|
1730
|
+
default: void 0
|
|
3019
1731
|
},
|
|
3020
1732
|
/**
|
|
3021
1733
|
* 预览中代码是否显示行号
|
|
@@ -3095,7 +1807,8 @@ const mdPreviewProps = {
|
|
|
3095
1807
|
* @default false
|
|
3096
1808
|
*/
|
|
3097
1809
|
noIconfont: {
|
|
3098
|
-
type: Boolean
|
|
1810
|
+
type: Boolean,
|
|
1811
|
+
default: void 0
|
|
3099
1812
|
},
|
|
3100
1813
|
/**
|
|
3101
1814
|
* 复制代码格式化方法
|
|
@@ -3173,13 +1886,15 @@ const editorProps = {
|
|
|
3173
1886
|
* input回调事件
|
|
3174
1887
|
*/
|
|
3175
1888
|
onSave: {
|
|
3176
|
-
type: Function
|
|
1889
|
+
type: Function,
|
|
1890
|
+
default: void 0
|
|
3177
1891
|
},
|
|
3178
1892
|
/**
|
|
3179
1893
|
* 上传图片事件
|
|
3180
1894
|
*/
|
|
3181
1895
|
onUploadImg: {
|
|
3182
|
-
type: Function
|
|
1896
|
+
type: Function,
|
|
1897
|
+
default: void 0
|
|
3183
1898
|
},
|
|
3184
1899
|
/**
|
|
3185
1900
|
* 是否页面内全屏
|
|
@@ -3263,7 +1978,8 @@ const editorProps = {
|
|
|
3263
1978
|
* @default [6, 4]
|
|
3264
1979
|
*/
|
|
3265
1980
|
tableShape: {
|
|
3266
|
-
type: Array
|
|
1981
|
+
type: Array,
|
|
1982
|
+
default: void 0
|
|
3267
1983
|
},
|
|
3268
1984
|
/**
|
|
3269
1985
|
* 空提示
|
|
@@ -3278,13 +1994,15 @@ const editorProps = {
|
|
|
3278
1994
|
* 自定义的工具栏列表
|
|
3279
1995
|
*/
|
|
3280
1996
|
defToolbars: {
|
|
3281
|
-
type: [String, Object]
|
|
1997
|
+
type: [String, Object],
|
|
1998
|
+
default: void 0
|
|
3282
1999
|
},
|
|
3283
2000
|
/**
|
|
3284
2001
|
* 内部错误捕获
|
|
3285
2002
|
*/
|
|
3286
2003
|
onError: {
|
|
3287
|
-
type: Function
|
|
2004
|
+
type: Function,
|
|
2005
|
+
default: void 0
|
|
3288
2006
|
},
|
|
3289
2007
|
/**
|
|
3290
2008
|
* 页脚列表显示顺序
|
|
@@ -3306,7 +2024,8 @@ const editorProps = {
|
|
|
3306
2024
|
* 自定义的也叫工具组件列表
|
|
3307
2025
|
*/
|
|
3308
2026
|
defFooters: {
|
|
3309
|
-
type: [String, Object]
|
|
2027
|
+
type: [String, Object],
|
|
2028
|
+
default: void 0
|
|
3310
2029
|
},
|
|
3311
2030
|
/**
|
|
3312
2031
|
* 是否禁用上传图片
|
|
@@ -3314,7 +2033,8 @@ const editorProps = {
|
|
|
3314
2033
|
* @default false
|
|
3315
2034
|
*/
|
|
3316
2035
|
noUploadImg: {
|
|
3317
|
-
type: Boolean
|
|
2036
|
+
type: Boolean,
|
|
2037
|
+
default: void 0
|
|
3318
2038
|
},
|
|
3319
2039
|
/**
|
|
3320
2040
|
* 文本区域自动获得焦点
|
|
@@ -3322,7 +2042,8 @@ const editorProps = {
|
|
|
3322
2042
|
* @default false
|
|
3323
2043
|
*/
|
|
3324
2044
|
autoFocus: {
|
|
3325
|
-
type: Boolean
|
|
2045
|
+
type: Boolean,
|
|
2046
|
+
default: void 0
|
|
3326
2047
|
},
|
|
3327
2048
|
/**
|
|
3328
2049
|
* 禁用文本区域
|
|
@@ -3330,7 +2051,8 @@ const editorProps = {
|
|
|
3330
2051
|
* @default false
|
|
3331
2052
|
*/
|
|
3332
2053
|
disabled: {
|
|
3333
|
-
type: Boolean
|
|
2054
|
+
type: Boolean,
|
|
2055
|
+
default: void 0
|
|
3334
2056
|
},
|
|
3335
2057
|
/**
|
|
3336
2058
|
* 文本区域为只读
|
|
@@ -3338,13 +2060,15 @@ const editorProps = {
|
|
|
3338
2060
|
* @default false
|
|
3339
2061
|
*/
|
|
3340
2062
|
readOnly: {
|
|
3341
|
-
type: Boolean
|
|
2063
|
+
type: Boolean,
|
|
2064
|
+
default: void 0
|
|
3342
2065
|
},
|
|
3343
2066
|
/**
|
|
3344
2067
|
* 文本区域允许的最大字符数
|
|
3345
2068
|
*/
|
|
3346
2069
|
maxLength: {
|
|
3347
|
-
type: Number
|
|
2070
|
+
type: Number,
|
|
2071
|
+
default: void 0
|
|
3348
2072
|
},
|
|
3349
2073
|
/**
|
|
3350
2074
|
* 是否启用自动识别粘贴代码类别
|
|
@@ -3353,19 +2077,22 @@ const editorProps = {
|
|
|
3353
2077
|
* @default false
|
|
3354
2078
|
*/
|
|
3355
2079
|
autoDetectCode: {
|
|
3356
|
-
type: Boolean
|
|
2080
|
+
type: Boolean,
|
|
2081
|
+
default: void 0
|
|
3357
2082
|
},
|
|
3358
2083
|
/**
|
|
3359
2084
|
* 输入框失去焦点时触发事件
|
|
3360
2085
|
*/
|
|
3361
2086
|
onBlur: {
|
|
3362
|
-
type: Function
|
|
2087
|
+
type: Function,
|
|
2088
|
+
default: void 0
|
|
3363
2089
|
},
|
|
3364
2090
|
/**
|
|
3365
2091
|
* 输入框获得焦点时触发事件
|
|
3366
2092
|
*/
|
|
3367
2093
|
onFocus: {
|
|
3368
|
-
type: Function
|
|
2094
|
+
type: Function,
|
|
2095
|
+
default: void 0
|
|
3369
2096
|
},
|
|
3370
2097
|
/**
|
|
3371
2098
|
* @codemirror/autocomplete匹配关键词的方法列表
|
|
@@ -3378,7 +2105,8 @@ const editorProps = {
|
|
|
3378
2105
|
* })
|
|
3379
2106
|
*/
|
|
3380
2107
|
completions: {
|
|
3381
|
-
type: Array
|
|
2108
|
+
type: Array,
|
|
2109
|
+
default: void 0
|
|
3382
2110
|
},
|
|
3383
2111
|
/**
|
|
3384
2112
|
* 是否在工具栏下面显示对应的文字名称
|
|
@@ -3393,10 +2121,12 @@ const editorProps = {
|
|
|
3393
2121
|
* 字符输入事件
|
|
3394
2122
|
*/
|
|
3395
2123
|
onInput: {
|
|
3396
|
-
type: Function
|
|
2124
|
+
type: Function,
|
|
2125
|
+
default: void 0
|
|
3397
2126
|
},
|
|
3398
2127
|
onDrop: {
|
|
3399
|
-
type: Function
|
|
2128
|
+
type: Function,
|
|
2129
|
+
default: void 0
|
|
3400
2130
|
},
|
|
3401
2131
|
/**
|
|
3402
2132
|
* 输入框的默认宽度
|
|
@@ -3404,15 +2134,16 @@ const editorProps = {
|
|
|
3404
2134
|
* @example '100px'/'50%'
|
|
3405
2135
|
* @default '50%
|
|
3406
2136
|
*/
|
|
3407
|
-
|
|
2137
|
+
inputBoxWidth: {
|
|
3408
2138
|
type: String,
|
|
3409
2139
|
default: "50%"
|
|
3410
2140
|
},
|
|
3411
2141
|
/**
|
|
3412
2142
|
* 输入框宽度变化事件
|
|
3413
2143
|
*/
|
|
3414
|
-
|
|
3415
|
-
type: Function
|
|
2144
|
+
oninputBoxWidthChange: {
|
|
2145
|
+
type: Function,
|
|
2146
|
+
default: void 0
|
|
3416
2147
|
},
|
|
3417
2148
|
/**
|
|
3418
2149
|
* 替换粘贴的图片链接
|
|
@@ -3440,10 +2171,10 @@ const editorEmits = [
|
|
|
3440
2171
|
"onFocus",
|
|
3441
2172
|
"onInput",
|
|
3442
2173
|
"onDrop",
|
|
3443
|
-
"
|
|
2174
|
+
"oninputBoxWidthChange"
|
|
3444
2175
|
];
|
|
3445
|
-
const useExpose = (props, ctx) => {
|
|
3446
|
-
const { editorId } =
|
|
2176
|
+
const useExpose = (props, ctx, options) => {
|
|
2177
|
+
const { editorId } = options;
|
|
3447
2178
|
const exposeParam = {
|
|
3448
2179
|
rerender() {
|
|
3449
2180
|
eventName.bus.emit(editorId, eventName.RERENDER);
|
|
@@ -3457,15 +2188,17 @@ const MdPreview = /* @__PURE__ */ vue.defineComponent({
|
|
|
3457
2188
|
emits: mdPreviewEmits,
|
|
3458
2189
|
setup(props, ctx) {
|
|
3459
2190
|
const {
|
|
3460
|
-
editorId,
|
|
3461
2191
|
noKatex,
|
|
3462
2192
|
noMermaid,
|
|
3463
2193
|
noHighlight
|
|
3464
2194
|
} = props;
|
|
3465
2195
|
const rootRef = vue.ref();
|
|
3466
|
-
|
|
3467
|
-
|
|
3468
|
-
|
|
2196
|
+
const {
|
|
2197
|
+
editorId
|
|
2198
|
+
} = useProvidePreview(props, rootRef);
|
|
2199
|
+
useExpose(props, ctx, {
|
|
2200
|
+
editorId
|
|
2201
|
+
});
|
|
3469
2202
|
vue.onBeforeUnmount(() => {
|
|
3470
2203
|
eventName.bus.clear(editorId);
|
|
3471
2204
|
});
|