md-editor-v3 4.21.1 → 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.
Files changed (79) hide show
  1. package/README.md +3 -3
  2. package/lib/cjs/MdEditor.cjs +50 -26
  3. package/lib/cjs/ModalToolbar.cjs +20 -10
  4. package/lib/cjs/chunks/config.cjs +0 -15
  5. package/lib/cjs/chunks/dom.cjs +6 -2
  6. package/lib/cjs/chunks/index.cjs +111 -1412
  7. package/lib/cjs/chunks/index2.cjs +19 -9
  8. package/lib/cjs/chunks/index3.cjs +47 -17
  9. package/lib/cjs/chunks/index4.cjs +538 -10
  10. package/lib/cjs/chunks/index5.cjs +0 -7
  11. package/lib/cjs/config.cjs +0 -2
  12. package/lib/cjs/index.cjs +1311 -3
  13. package/lib/es/MdEditor.mjs +52 -28
  14. package/lib/es/ModalToolbar.mjs +20 -10
  15. package/lib/es/chunks/config.mjs +4 -19
  16. package/lib/es/chunks/dom.mjs +6 -2
  17. package/lib/es/chunks/index.mjs +118 -1419
  18. package/lib/es/chunks/index2.mjs +19 -9
  19. package/lib/es/chunks/index3.mjs +49 -19
  20. package/lib/es/chunks/index4.mjs +541 -13
  21. package/lib/es/chunks/index5.mjs +2 -9
  22. package/lib/es/config.mjs +3 -5
  23. package/lib/es/index.mjs +1314 -6
  24. package/lib/preview.css +20 -7
  25. package/lib/style.css +20 -7
  26. package/lib/types/DropdownToolbar/DropdownToolbar.d.ts +46 -87
  27. package/lib/types/DropdownToolbar/index.d.ts +2 -171
  28. package/lib/types/MdCatalog/CatalogLink.d.ts +18 -35
  29. package/lib/types/MdCatalog/MdCatalog.d.ts +29 -129
  30. package/lib/types/MdCatalog/index.d.ts +2 -194
  31. package/lib/types/MdEditor/Editor.d.ts +584 -427
  32. package/lib/types/MdEditor/components/Checkbox/index.d.ts +7 -20
  33. package/lib/types/MdEditor/components/Divider/index.d.ts +1 -1
  34. package/lib/types/MdEditor/components/Dropdown/index.d.ts +16 -40
  35. package/lib/types/MdEditor/components/Icon/Github.d.ts +2 -0
  36. package/lib/types/MdEditor/components/Icon/Icon.d.ts +7 -5
  37. package/lib/types/MdEditor/components/Icon/Str.d.ts +2 -1
  38. package/lib/types/MdEditor/components/Icon/index.d.ts +5 -5
  39. package/lib/types/MdEditor/components/Modal/Modal.d.ts +29 -90
  40. package/lib/types/MdEditor/components/Modal/index.d.ts +2 -223
  41. package/lib/types/MdEditor/composition.d.ts +26 -8
  42. package/lib/types/MdEditor/config.d.ts +0 -2
  43. package/lib/types/MdEditor/index.d.ts +2 -1017
  44. package/lib/types/MdEditor/layouts/Content/ContentPreview.d.ts +35 -127
  45. package/lib/types/MdEditor/layouts/Content/composition/useCodeMirror.d.ts +2 -2
  46. package/lib/types/MdEditor/layouts/Content/composition/useHighlight.d.ts +1 -1
  47. package/lib/types/MdEditor/layouts/Content/composition/useKatex.d.ts +1 -1
  48. package/lib/types/MdEditor/layouts/Content/composition/useMarkdownIt.d.ts +2 -2
  49. package/lib/types/MdEditor/layouts/Content/composition/useMermaid.d.ts +2 -2
  50. package/lib/types/MdEditor/layouts/Content/composition/useResize.d.ts +1 -1
  51. package/lib/types/MdEditor/layouts/Content/index.d.ts +73 -255
  52. package/lib/types/MdEditor/layouts/Content/markdownIt/xss/index.d.ts +1 -2
  53. package/lib/types/MdEditor/layouts/Content/props.d.ts +3 -3
  54. package/lib/types/MdEditor/layouts/Footer/MarkdownTotal.d.ts +4 -4
  55. package/lib/types/MdEditor/layouts/Footer/ScrollAuto.d.ts +7 -18
  56. package/lib/types/MdEditor/layouts/Footer/index.d.ts +20 -50
  57. package/lib/types/MdEditor/layouts/Modals/Clip.d.ts +10 -29
  58. package/lib/types/MdEditor/layouts/Modals/Link.d.ts +12 -37
  59. package/lib/types/MdEditor/layouts/Modals/index.d.ts +13 -44
  60. package/lib/types/MdEditor/layouts/Toolbar/TableShape.d.ts +7 -20
  61. package/lib/types/MdEditor/layouts/Toolbar/index.d.ts +31 -93
  62. package/lib/types/MdEditor/layouts/Toolbar/props.d.ts +4 -6
  63. package/lib/types/MdEditor/props.d.ts +66 -24
  64. package/lib/types/MdEditor/type.d.ts +1 -20
  65. package/lib/types/MdEditor/utils/index.d.ts +0 -4
  66. package/lib/types/MdPreview/MdPreview.d.ts +491 -206
  67. package/lib/types/MdPreview/composition/useExpose.d.ts +3 -1
  68. package/lib/types/MdPreview/index.d.ts +2 -538
  69. package/lib/types/ModalToolbar/ModalToolbar.d.ts +57 -143
  70. package/lib/types/ModalToolbar/index.d.ts +2 -309
  71. package/lib/types/NormalFooterToolbar/NormalFooterToolbar.d.ts +7 -10
  72. package/lib/types/NormalFooterToolbar/index.d.ts +2 -37
  73. package/lib/types/NormalToolbar/NormalToolbar.d.ts +21 -53
  74. package/lib/types/NormalToolbar/index.d.ts +2 -115
  75. package/lib/types/config.d.ts +1 -1
  76. package/lib/types/index.d.ts +1 -0
  77. package/lib/umd/index.js +241 -56
  78. package/package.json +21 -20
  79. package/lib/types/MdEditor/components/Popper/index.d.ts +0 -15
@@ -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$2 = require("@vavt/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$1 = require("./index5.cjs");
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$2.debounce(() => {
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
  );
@@ -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$2.randomId();
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, self2) => {
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 self2.renderToken(tokens, idx, _options);
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, self2) => {
604
- return self2.renderToken(tokens, idx, opts);
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
- const defaultStr = `<i class="${config.prefix}-iconfont ${config.prefix}-icon-${name}"></i>`;
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,7 +628,7 @@ 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 && addAttrs2.push(["open", ""]);
631
+ if (open2) addAttrs2.push(["open", ""]);
655
632
  const tmpToken2 = {
656
633
  attrs: mergeAttrs(tokens[idx], addAttrs2)
657
634
  };
@@ -674,7 +651,7 @@ const codetabs = (md, _opts) => {
674
651
  let token, group, tab, checked, labels = "", pres = "", langs = "";
675
652
  const { open, tagContainer, tagHeader } = getTagType(tokens[idx]);
676
653
  const addAttrs = [["class", `${config.prefix}-code`]];
677
- open && addAttrs.push(["open", ""]);
654
+ if (open) addAttrs.push(["open", ""]);
678
655
  const tmpToken = {
679
656
  attrs: mergeAttrs(tokens[idx], addAttrs)
680
657
  };
@@ -742,1295 +719,6 @@ const codetabs = (md, _opts) => {
742
719
  md.renderer.rules.fence = fenceGroup;
743
720
  md.renderer.rules.code_block = fenceGroup;
744
721
  };
745
- function getDefaultExportFromCjs(x) {
746
- return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, "default") ? x["default"] : x;
747
- }
748
- var lib$1 = { exports: {} };
749
- var _default$1 = {};
750
- var lib = { exports: {} };
751
- var _default = {};
752
- function getDefaultWhiteList$1() {
753
- var whiteList = {};
754
- whiteList["align-content"] = false;
755
- whiteList["align-items"] = false;
756
- whiteList["align-self"] = false;
757
- whiteList["alignment-adjust"] = false;
758
- whiteList["alignment-baseline"] = false;
759
- whiteList["all"] = false;
760
- whiteList["anchor-point"] = false;
761
- whiteList["animation"] = false;
762
- whiteList["animation-delay"] = false;
763
- whiteList["animation-direction"] = false;
764
- whiteList["animation-duration"] = false;
765
- whiteList["animation-fill-mode"] = false;
766
- whiteList["animation-iteration-count"] = false;
767
- whiteList["animation-name"] = false;
768
- whiteList["animation-play-state"] = false;
769
- whiteList["animation-timing-function"] = false;
770
- whiteList["azimuth"] = false;
771
- whiteList["backface-visibility"] = false;
772
- whiteList["background"] = true;
773
- whiteList["background-attachment"] = true;
774
- whiteList["background-clip"] = true;
775
- whiteList["background-color"] = true;
776
- whiteList["background-image"] = true;
777
- whiteList["background-origin"] = true;
778
- whiteList["background-position"] = true;
779
- whiteList["background-repeat"] = true;
780
- whiteList["background-size"] = true;
781
- whiteList["baseline-shift"] = false;
782
- whiteList["binding"] = false;
783
- whiteList["bleed"] = false;
784
- whiteList["bookmark-label"] = false;
785
- whiteList["bookmark-level"] = false;
786
- whiteList["bookmark-state"] = false;
787
- whiteList["border"] = true;
788
- whiteList["border-bottom"] = true;
789
- whiteList["border-bottom-color"] = true;
790
- whiteList["border-bottom-left-radius"] = true;
791
- whiteList["border-bottom-right-radius"] = true;
792
- whiteList["border-bottom-style"] = true;
793
- whiteList["border-bottom-width"] = true;
794
- whiteList["border-collapse"] = true;
795
- whiteList["border-color"] = true;
796
- whiteList["border-image"] = true;
797
- whiteList["border-image-outset"] = true;
798
- whiteList["border-image-repeat"] = true;
799
- whiteList["border-image-slice"] = true;
800
- whiteList["border-image-source"] = true;
801
- whiteList["border-image-width"] = true;
802
- whiteList["border-left"] = true;
803
- whiteList["border-left-color"] = true;
804
- whiteList["border-left-style"] = true;
805
- whiteList["border-left-width"] = true;
806
- whiteList["border-radius"] = true;
807
- whiteList["border-right"] = true;
808
- whiteList["border-right-color"] = true;
809
- whiteList["border-right-style"] = true;
810
- whiteList["border-right-width"] = true;
811
- whiteList["border-spacing"] = true;
812
- whiteList["border-style"] = true;
813
- whiteList["border-top"] = true;
814
- whiteList["border-top-color"] = true;
815
- whiteList["border-top-left-radius"] = true;
816
- whiteList["border-top-right-radius"] = true;
817
- whiteList["border-top-style"] = true;
818
- whiteList["border-top-width"] = true;
819
- whiteList["border-width"] = true;
820
- whiteList["bottom"] = false;
821
- whiteList["box-decoration-break"] = true;
822
- whiteList["box-shadow"] = true;
823
- whiteList["box-sizing"] = true;
824
- whiteList["box-snap"] = true;
825
- whiteList["box-suppress"] = true;
826
- whiteList["break-after"] = true;
827
- whiteList["break-before"] = true;
828
- whiteList["break-inside"] = true;
829
- whiteList["caption-side"] = false;
830
- whiteList["chains"] = false;
831
- whiteList["clear"] = true;
832
- whiteList["clip"] = false;
833
- whiteList["clip-path"] = false;
834
- whiteList["clip-rule"] = false;
835
- whiteList["color"] = true;
836
- whiteList["color-interpolation-filters"] = true;
837
- whiteList["column-count"] = false;
838
- whiteList["column-fill"] = false;
839
- whiteList["column-gap"] = false;
840
- whiteList["column-rule"] = false;
841
- whiteList["column-rule-color"] = false;
842
- whiteList["column-rule-style"] = false;
843
- whiteList["column-rule-width"] = false;
844
- whiteList["column-span"] = false;
845
- whiteList["column-width"] = false;
846
- whiteList["columns"] = false;
847
- whiteList["contain"] = false;
848
- whiteList["content"] = false;
849
- whiteList["counter-increment"] = false;
850
- whiteList["counter-reset"] = false;
851
- whiteList["counter-set"] = false;
852
- whiteList["crop"] = false;
853
- whiteList["cue"] = false;
854
- whiteList["cue-after"] = false;
855
- whiteList["cue-before"] = false;
856
- whiteList["cursor"] = false;
857
- whiteList["direction"] = false;
858
- whiteList["display"] = true;
859
- whiteList["display-inside"] = true;
860
- whiteList["display-list"] = true;
861
- whiteList["display-outside"] = true;
862
- whiteList["dominant-baseline"] = false;
863
- whiteList["elevation"] = false;
864
- whiteList["empty-cells"] = false;
865
- whiteList["filter"] = false;
866
- whiteList["flex"] = false;
867
- whiteList["flex-basis"] = false;
868
- whiteList["flex-direction"] = false;
869
- whiteList["flex-flow"] = false;
870
- whiteList["flex-grow"] = false;
871
- whiteList["flex-shrink"] = false;
872
- whiteList["flex-wrap"] = false;
873
- whiteList["float"] = false;
874
- whiteList["float-offset"] = false;
875
- whiteList["flood-color"] = false;
876
- whiteList["flood-opacity"] = false;
877
- whiteList["flow-from"] = false;
878
- whiteList["flow-into"] = false;
879
- whiteList["font"] = true;
880
- whiteList["font-family"] = true;
881
- whiteList["font-feature-settings"] = true;
882
- whiteList["font-kerning"] = true;
883
- whiteList["font-language-override"] = true;
884
- whiteList["font-size"] = true;
885
- whiteList["font-size-adjust"] = true;
886
- whiteList["font-stretch"] = true;
887
- whiteList["font-style"] = true;
888
- whiteList["font-synthesis"] = true;
889
- whiteList["font-variant"] = true;
890
- whiteList["font-variant-alternates"] = true;
891
- whiteList["font-variant-caps"] = true;
892
- whiteList["font-variant-east-asian"] = true;
893
- whiteList["font-variant-ligatures"] = true;
894
- whiteList["font-variant-numeric"] = true;
895
- whiteList["font-variant-position"] = true;
896
- whiteList["font-weight"] = true;
897
- whiteList["grid"] = false;
898
- whiteList["grid-area"] = false;
899
- whiteList["grid-auto-columns"] = false;
900
- whiteList["grid-auto-flow"] = false;
901
- whiteList["grid-auto-rows"] = false;
902
- whiteList["grid-column"] = false;
903
- whiteList["grid-column-end"] = false;
904
- whiteList["grid-column-start"] = false;
905
- whiteList["grid-row"] = false;
906
- whiteList["grid-row-end"] = false;
907
- whiteList["grid-row-start"] = false;
908
- whiteList["grid-template"] = false;
909
- whiteList["grid-template-areas"] = false;
910
- whiteList["grid-template-columns"] = false;
911
- whiteList["grid-template-rows"] = false;
912
- whiteList["hanging-punctuation"] = false;
913
- whiteList["height"] = true;
914
- whiteList["hyphens"] = false;
915
- whiteList["icon"] = false;
916
- whiteList["image-orientation"] = false;
917
- whiteList["image-resolution"] = false;
918
- whiteList["ime-mode"] = false;
919
- whiteList["initial-letters"] = false;
920
- whiteList["inline-box-align"] = false;
921
- whiteList["justify-content"] = false;
922
- whiteList["justify-items"] = false;
923
- whiteList["justify-self"] = false;
924
- whiteList["left"] = false;
925
- whiteList["letter-spacing"] = true;
926
- whiteList["lighting-color"] = true;
927
- whiteList["line-box-contain"] = false;
928
- whiteList["line-break"] = false;
929
- whiteList["line-grid"] = false;
930
- whiteList["line-height"] = false;
931
- whiteList["line-snap"] = false;
932
- whiteList["line-stacking"] = false;
933
- whiteList["line-stacking-ruby"] = false;
934
- whiteList["line-stacking-shift"] = false;
935
- whiteList["line-stacking-strategy"] = false;
936
- whiteList["list-style"] = true;
937
- whiteList["list-style-image"] = true;
938
- whiteList["list-style-position"] = true;
939
- whiteList["list-style-type"] = true;
940
- whiteList["margin"] = true;
941
- whiteList["margin-bottom"] = true;
942
- whiteList["margin-left"] = true;
943
- whiteList["margin-right"] = true;
944
- whiteList["margin-top"] = true;
945
- whiteList["marker-offset"] = false;
946
- whiteList["marker-side"] = false;
947
- whiteList["marks"] = false;
948
- whiteList["mask"] = false;
949
- whiteList["mask-box"] = false;
950
- whiteList["mask-box-outset"] = false;
951
- whiteList["mask-box-repeat"] = false;
952
- whiteList["mask-box-slice"] = false;
953
- whiteList["mask-box-source"] = false;
954
- whiteList["mask-box-width"] = false;
955
- whiteList["mask-clip"] = false;
956
- whiteList["mask-image"] = false;
957
- whiteList["mask-origin"] = false;
958
- whiteList["mask-position"] = false;
959
- whiteList["mask-repeat"] = false;
960
- whiteList["mask-size"] = false;
961
- whiteList["mask-source-type"] = false;
962
- whiteList["mask-type"] = false;
963
- whiteList["max-height"] = true;
964
- whiteList["max-lines"] = false;
965
- whiteList["max-width"] = true;
966
- whiteList["min-height"] = true;
967
- whiteList["min-width"] = true;
968
- whiteList["move-to"] = false;
969
- whiteList["nav-down"] = false;
970
- whiteList["nav-index"] = false;
971
- whiteList["nav-left"] = false;
972
- whiteList["nav-right"] = false;
973
- whiteList["nav-up"] = false;
974
- whiteList["object-fit"] = false;
975
- whiteList["object-position"] = false;
976
- whiteList["opacity"] = false;
977
- whiteList["order"] = false;
978
- whiteList["orphans"] = false;
979
- whiteList["outline"] = false;
980
- whiteList["outline-color"] = false;
981
- whiteList["outline-offset"] = false;
982
- whiteList["outline-style"] = false;
983
- whiteList["outline-width"] = false;
984
- whiteList["overflow"] = false;
985
- whiteList["overflow-wrap"] = false;
986
- whiteList["overflow-x"] = false;
987
- whiteList["overflow-y"] = false;
988
- whiteList["padding"] = true;
989
- whiteList["padding-bottom"] = true;
990
- whiteList["padding-left"] = true;
991
- whiteList["padding-right"] = true;
992
- whiteList["padding-top"] = true;
993
- whiteList["page"] = false;
994
- whiteList["page-break-after"] = false;
995
- whiteList["page-break-before"] = false;
996
- whiteList["page-break-inside"] = false;
997
- whiteList["page-policy"] = false;
998
- whiteList["pause"] = false;
999
- whiteList["pause-after"] = false;
1000
- whiteList["pause-before"] = false;
1001
- whiteList["perspective"] = false;
1002
- whiteList["perspective-origin"] = false;
1003
- whiteList["pitch"] = false;
1004
- whiteList["pitch-range"] = false;
1005
- whiteList["play-during"] = false;
1006
- whiteList["position"] = false;
1007
- whiteList["presentation-level"] = false;
1008
- whiteList["quotes"] = false;
1009
- whiteList["region-fragment"] = false;
1010
- whiteList["resize"] = false;
1011
- whiteList["rest"] = false;
1012
- whiteList["rest-after"] = false;
1013
- whiteList["rest-before"] = false;
1014
- whiteList["richness"] = false;
1015
- whiteList["right"] = false;
1016
- whiteList["rotation"] = false;
1017
- whiteList["rotation-point"] = false;
1018
- whiteList["ruby-align"] = false;
1019
- whiteList["ruby-merge"] = false;
1020
- whiteList["ruby-position"] = false;
1021
- whiteList["shape-image-threshold"] = false;
1022
- whiteList["shape-outside"] = false;
1023
- whiteList["shape-margin"] = false;
1024
- whiteList["size"] = false;
1025
- whiteList["speak"] = false;
1026
- whiteList["speak-as"] = false;
1027
- whiteList["speak-header"] = false;
1028
- whiteList["speak-numeral"] = false;
1029
- whiteList["speak-punctuation"] = false;
1030
- whiteList["speech-rate"] = false;
1031
- whiteList["stress"] = false;
1032
- whiteList["string-set"] = false;
1033
- whiteList["tab-size"] = false;
1034
- whiteList["table-layout"] = false;
1035
- whiteList["text-align"] = true;
1036
- whiteList["text-align-last"] = true;
1037
- whiteList["text-combine-upright"] = true;
1038
- whiteList["text-decoration"] = true;
1039
- whiteList["text-decoration-color"] = true;
1040
- whiteList["text-decoration-line"] = true;
1041
- whiteList["text-decoration-skip"] = true;
1042
- whiteList["text-decoration-style"] = true;
1043
- whiteList["text-emphasis"] = true;
1044
- whiteList["text-emphasis-color"] = true;
1045
- whiteList["text-emphasis-position"] = true;
1046
- whiteList["text-emphasis-style"] = true;
1047
- whiteList["text-height"] = true;
1048
- whiteList["text-indent"] = true;
1049
- whiteList["text-justify"] = true;
1050
- whiteList["text-orientation"] = true;
1051
- whiteList["text-overflow"] = true;
1052
- whiteList["text-shadow"] = true;
1053
- whiteList["text-space-collapse"] = true;
1054
- whiteList["text-transform"] = true;
1055
- whiteList["text-underline-position"] = true;
1056
- whiteList["text-wrap"] = true;
1057
- whiteList["top"] = false;
1058
- whiteList["transform"] = false;
1059
- whiteList["transform-origin"] = false;
1060
- whiteList["transform-style"] = false;
1061
- whiteList["transition"] = false;
1062
- whiteList["transition-delay"] = false;
1063
- whiteList["transition-duration"] = false;
1064
- whiteList["transition-property"] = false;
1065
- whiteList["transition-timing-function"] = false;
1066
- whiteList["unicode-bidi"] = false;
1067
- whiteList["vertical-align"] = false;
1068
- whiteList["visibility"] = false;
1069
- whiteList["voice-balance"] = false;
1070
- whiteList["voice-duration"] = false;
1071
- whiteList["voice-family"] = false;
1072
- whiteList["voice-pitch"] = false;
1073
- whiteList["voice-range"] = false;
1074
- whiteList["voice-rate"] = false;
1075
- whiteList["voice-stress"] = false;
1076
- whiteList["voice-volume"] = false;
1077
- whiteList["volume"] = false;
1078
- whiteList["white-space"] = false;
1079
- whiteList["widows"] = false;
1080
- whiteList["width"] = true;
1081
- whiteList["will-change"] = false;
1082
- whiteList["word-break"] = true;
1083
- whiteList["word-spacing"] = true;
1084
- whiteList["word-wrap"] = true;
1085
- whiteList["wrap-flow"] = false;
1086
- whiteList["wrap-through"] = false;
1087
- whiteList["writing-mode"] = false;
1088
- whiteList["z-index"] = false;
1089
- return whiteList;
1090
- }
1091
- function onAttr(name, value, options) {
1092
- }
1093
- function onIgnoreAttr(name, value, options) {
1094
- }
1095
- var REGEXP_URL_JAVASCRIPT = /javascript\s*\:/img;
1096
- function safeAttrValue$1(name, value) {
1097
- if (REGEXP_URL_JAVASCRIPT.test(value)) return "";
1098
- return value;
1099
- }
1100
- _default.whiteList = getDefaultWhiteList$1();
1101
- _default.getDefaultWhiteList = getDefaultWhiteList$1;
1102
- _default.onAttr = onAttr;
1103
- _default.onIgnoreAttr = onIgnoreAttr;
1104
- _default.safeAttrValue = safeAttrValue$1;
1105
- var util$1 = {
1106
- indexOf: function(arr, item) {
1107
- var i, j;
1108
- if (Array.prototype.indexOf) {
1109
- return arr.indexOf(item);
1110
- }
1111
- for (i = 0, j = arr.length; i < j; i++) {
1112
- if (arr[i] === item) {
1113
- return i;
1114
- }
1115
- }
1116
- return -1;
1117
- },
1118
- forEach: function(arr, fn, scope) {
1119
- var i, j;
1120
- if (Array.prototype.forEach) {
1121
- return arr.forEach(fn, scope);
1122
- }
1123
- for (i = 0, j = arr.length; i < j; i++) {
1124
- fn.call(scope, arr[i], i, arr);
1125
- }
1126
- },
1127
- trim: function(str) {
1128
- if (String.prototype.trim) {
1129
- return str.trim();
1130
- }
1131
- return str.replace(/(^\s*)|(\s*$)/g, "");
1132
- },
1133
- trimRight: function(str) {
1134
- if (String.prototype.trimRight) {
1135
- return str.trimRight();
1136
- }
1137
- return str.replace(/(\s*$)/g, "");
1138
- }
1139
- };
1140
- var _$3 = util$1;
1141
- function parseStyle$1(css2, onAttr2) {
1142
- css2 = _$3.trimRight(css2);
1143
- if (css2[css2.length - 1] !== ";") css2 += ";";
1144
- var cssLength = css2.length;
1145
- var isParenthesisOpen = false;
1146
- var lastPos = 0;
1147
- var i = 0;
1148
- var retCSS = "";
1149
- function addNewAttr() {
1150
- if (!isParenthesisOpen) {
1151
- var source = _$3.trim(css2.slice(lastPos, i));
1152
- var j2 = source.indexOf(":");
1153
- if (j2 !== -1) {
1154
- var name = _$3.trim(source.slice(0, j2));
1155
- var value = _$3.trim(source.slice(j2 + 1));
1156
- if (name) {
1157
- var ret = onAttr2(lastPos, retCSS.length, name, value, source);
1158
- if (ret) retCSS += ret + "; ";
1159
- }
1160
- }
1161
- }
1162
- lastPos = i + 1;
1163
- }
1164
- for (; i < cssLength; i++) {
1165
- var c = css2[i];
1166
- if (c === "/" && css2[i + 1] === "*") {
1167
- var j = css2.indexOf("*/", i + 2);
1168
- if (j === -1) break;
1169
- i = j + 1;
1170
- lastPos = i + 1;
1171
- isParenthesisOpen = false;
1172
- } else if (c === "(") {
1173
- isParenthesisOpen = true;
1174
- } else if (c === ")") {
1175
- isParenthesisOpen = false;
1176
- } else if (c === ";") {
1177
- if (isParenthesisOpen) ;
1178
- else {
1179
- addNewAttr();
1180
- }
1181
- } else if (c === "\n") {
1182
- addNewAttr();
1183
- }
1184
- }
1185
- return _$3.trim(retCSS);
1186
- }
1187
- var parser$2 = parseStyle$1;
1188
- var DEFAULT$1 = _default;
1189
- var parseStyle = parser$2;
1190
- function isNull$1(obj) {
1191
- return obj === void 0 || obj === null;
1192
- }
1193
- function shallowCopyObject$1(obj) {
1194
- var ret = {};
1195
- for (var i in obj) {
1196
- ret[i] = obj[i];
1197
- }
1198
- return ret;
1199
- }
1200
- function FilterCSS$2(options) {
1201
- options = shallowCopyObject$1(options || {});
1202
- options.whiteList = options.whiteList || DEFAULT$1.whiteList;
1203
- options.onAttr = options.onAttr || DEFAULT$1.onAttr;
1204
- options.onIgnoreAttr = options.onIgnoreAttr || DEFAULT$1.onIgnoreAttr;
1205
- options.safeAttrValue = options.safeAttrValue || DEFAULT$1.safeAttrValue;
1206
- this.options = options;
1207
- }
1208
- FilterCSS$2.prototype.process = function(css2) {
1209
- css2 = css2 || "";
1210
- css2 = css2.toString();
1211
- if (!css2) return "";
1212
- var me = this;
1213
- var options = me.options;
1214
- var whiteList = options.whiteList;
1215
- var onAttr2 = options.onAttr;
1216
- var onIgnoreAttr2 = options.onIgnoreAttr;
1217
- var safeAttrValue2 = options.safeAttrValue;
1218
- var retCSS = parseStyle(css2, function(sourcePosition, position, name, value, source) {
1219
- var check = whiteList[name];
1220
- var isWhite = false;
1221
- if (check === true) isWhite = check;
1222
- else if (typeof check === "function") isWhite = check(value);
1223
- else if (check instanceof RegExp) isWhite = check.test(value);
1224
- if (isWhite !== true) isWhite = false;
1225
- value = safeAttrValue2(name, value);
1226
- if (!value) return;
1227
- var opts = {
1228
- position,
1229
- sourcePosition,
1230
- source,
1231
- isWhite
1232
- };
1233
- if (isWhite) {
1234
- var ret = onAttr2(name, value, opts);
1235
- if (isNull$1(ret)) {
1236
- return name + ":" + value;
1237
- } else {
1238
- return ret;
1239
- }
1240
- } else {
1241
- var ret = onIgnoreAttr2(name, value, opts);
1242
- if (!isNull$1(ret)) {
1243
- return ret;
1244
- }
1245
- }
1246
- });
1247
- return retCSS;
1248
- };
1249
- var css = FilterCSS$2;
1250
- (function(module2, exports2) {
1251
- var DEFAULT2 = _default;
1252
- var FilterCSS2 = css;
1253
- function filterCSS(html, options) {
1254
- var xss2 = new FilterCSS2(options);
1255
- return xss2.process(html);
1256
- }
1257
- exports2 = module2.exports = filterCSS;
1258
- exports2.FilterCSS = FilterCSS2;
1259
- for (var i in DEFAULT2) exports2[i] = DEFAULT2[i];
1260
- if (typeof window !== "undefined") {
1261
- window.filterCSS = module2.exports;
1262
- }
1263
- })(lib, lib.exports);
1264
- var libExports$1 = lib.exports;
1265
- var util = {
1266
- indexOf: function(arr, item) {
1267
- var i, j;
1268
- if (Array.prototype.indexOf) {
1269
- return arr.indexOf(item);
1270
- }
1271
- for (i = 0, j = arr.length; i < j; i++) {
1272
- if (arr[i] === item) {
1273
- return i;
1274
- }
1275
- }
1276
- return -1;
1277
- },
1278
- forEach: function(arr, fn, scope) {
1279
- var i, j;
1280
- if (Array.prototype.forEach) {
1281
- return arr.forEach(fn, scope);
1282
- }
1283
- for (i = 0, j = arr.length; i < j; i++) {
1284
- fn.call(scope, arr[i], i, arr);
1285
- }
1286
- },
1287
- trim: function(str) {
1288
- if (String.prototype.trim) {
1289
- return str.trim();
1290
- }
1291
- return str.replace(/(^\s*)|(\s*$)/g, "");
1292
- },
1293
- spaceIndex: function(str) {
1294
- var reg = /\s|\n|\t/;
1295
- var match = reg.exec(str);
1296
- return match ? match.index : -1;
1297
- }
1298
- };
1299
- var FilterCSS$1 = libExports$1.FilterCSS;
1300
- var getDefaultCSSWhiteList = libExports$1.getDefaultWhiteList;
1301
- var _$2 = util;
1302
- function getDefaultWhiteList() {
1303
- return {
1304
- a: ["target", "href", "title"],
1305
- abbr: ["title"],
1306
- address: [],
1307
- area: ["shape", "coords", "href", "alt"],
1308
- article: [],
1309
- aside: [],
1310
- audio: [
1311
- "autoplay",
1312
- "controls",
1313
- "crossorigin",
1314
- "loop",
1315
- "muted",
1316
- "preload",
1317
- "src"
1318
- ],
1319
- b: [],
1320
- bdi: ["dir"],
1321
- bdo: ["dir"],
1322
- big: [],
1323
- blockquote: ["cite"],
1324
- br: [],
1325
- caption: [],
1326
- center: [],
1327
- cite: [],
1328
- code: [],
1329
- col: ["align", "valign", "span", "width"],
1330
- colgroup: ["align", "valign", "span", "width"],
1331
- dd: [],
1332
- del: ["datetime"],
1333
- details: ["open"],
1334
- div: [],
1335
- dl: [],
1336
- dt: [],
1337
- em: [],
1338
- figcaption: [],
1339
- figure: [],
1340
- font: ["color", "size", "face"],
1341
- footer: [],
1342
- h1: [],
1343
- h2: [],
1344
- h3: [],
1345
- h4: [],
1346
- h5: [],
1347
- h6: [],
1348
- header: [],
1349
- hr: [],
1350
- i: [],
1351
- img: ["src", "alt", "title", "width", "height", "loading"],
1352
- ins: ["datetime"],
1353
- kbd: [],
1354
- li: [],
1355
- mark: [],
1356
- nav: [],
1357
- ol: [],
1358
- p: [],
1359
- pre: [],
1360
- s: [],
1361
- section: [],
1362
- small: [],
1363
- span: [],
1364
- sub: [],
1365
- summary: [],
1366
- sup: [],
1367
- strong: [],
1368
- strike: [],
1369
- table: ["width", "border", "align", "valign"],
1370
- tbody: ["align", "valign"],
1371
- td: ["width", "rowspan", "colspan", "align", "valign"],
1372
- tfoot: ["align", "valign"],
1373
- th: ["width", "rowspan", "colspan", "align", "valign"],
1374
- thead: ["align", "valign"],
1375
- tr: ["rowspan", "align", "valign"],
1376
- tt: [],
1377
- u: [],
1378
- ul: [],
1379
- video: [
1380
- "autoplay",
1381
- "controls",
1382
- "crossorigin",
1383
- "loop",
1384
- "muted",
1385
- "playsinline",
1386
- "poster",
1387
- "preload",
1388
- "src",
1389
- "height",
1390
- "width"
1391
- ]
1392
- };
1393
- }
1394
- var defaultCSSFilter = new FilterCSS$1();
1395
- function onTag(tag, html, options) {
1396
- }
1397
- function onIgnoreTag(tag, html, options) {
1398
- }
1399
- function onTagAttr(tag, name, value) {
1400
- }
1401
- function onIgnoreTagAttr(tag, name, value) {
1402
- }
1403
- function escapeHtml(html) {
1404
- return html.replace(REGEXP_LT, "&lt;").replace(REGEXP_GT, "&gt;");
1405
- }
1406
- function safeAttrValue(tag, name, value, cssFilter) {
1407
- value = friendlyAttrValue(value);
1408
- if (name === "href" || name === "src") {
1409
- value = _$2.trim(value);
1410
- if (value === "#") return "#";
1411
- 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] === "/")) {
1412
- return "";
1413
- }
1414
- } else if (name === "background") {
1415
- REGEXP_DEFAULT_ON_TAG_ATTR_4.lastIndex = 0;
1416
- if (REGEXP_DEFAULT_ON_TAG_ATTR_4.test(value)) {
1417
- return "";
1418
- }
1419
- } else if (name === "style") {
1420
- REGEXP_DEFAULT_ON_TAG_ATTR_7.lastIndex = 0;
1421
- if (REGEXP_DEFAULT_ON_TAG_ATTR_7.test(value)) {
1422
- return "";
1423
- }
1424
- REGEXP_DEFAULT_ON_TAG_ATTR_8.lastIndex = 0;
1425
- if (REGEXP_DEFAULT_ON_TAG_ATTR_8.test(value)) {
1426
- REGEXP_DEFAULT_ON_TAG_ATTR_4.lastIndex = 0;
1427
- if (REGEXP_DEFAULT_ON_TAG_ATTR_4.test(value)) {
1428
- return "";
1429
- }
1430
- }
1431
- if (cssFilter !== false) {
1432
- cssFilter = cssFilter || defaultCSSFilter;
1433
- value = cssFilter.process(value);
1434
- }
1435
- }
1436
- value = escapeAttrValue(value);
1437
- return value;
1438
- }
1439
- var REGEXP_LT = /</g;
1440
- var REGEXP_GT = />/g;
1441
- var REGEXP_QUOTE = /"/g;
1442
- var REGEXP_QUOTE_2 = /&quot;/g;
1443
- var REGEXP_ATTR_VALUE_1 = /&#([a-zA-Z0-9]*);?/gim;
1444
- var REGEXP_ATTR_VALUE_COLON = /&colon;?/gim;
1445
- var REGEXP_ATTR_VALUE_NEWLINE = /&newline;?/gim;
1446
- 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;
1447
- 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;
1448
- var REGEXP_DEFAULT_ON_TAG_ATTR_8 = /u\s*r\s*l\s*\(.*/gi;
1449
- function escapeQuote(str) {
1450
- return str.replace(REGEXP_QUOTE, "&quot;");
1451
- }
1452
- function unescapeQuote(str) {
1453
- return str.replace(REGEXP_QUOTE_2, '"');
1454
- }
1455
- function escapeHtmlEntities(str) {
1456
- return str.replace(REGEXP_ATTR_VALUE_1, function replaceUnicode(str2, code) {
1457
- return code[0] === "x" || code[0] === "X" ? String.fromCharCode(parseInt(code.substr(1), 16)) : String.fromCharCode(parseInt(code, 10));
1458
- });
1459
- }
1460
- function escapeDangerHtml5Entities(str) {
1461
- return str.replace(REGEXP_ATTR_VALUE_COLON, ":").replace(REGEXP_ATTR_VALUE_NEWLINE, " ");
1462
- }
1463
- function clearNonPrintableCharacter(str) {
1464
- var str2 = "";
1465
- for (var i = 0, len = str.length; i < len; i++) {
1466
- str2 += str.charCodeAt(i) < 32 ? " " : str.charAt(i);
1467
- }
1468
- return _$2.trim(str2);
1469
- }
1470
- function friendlyAttrValue(str) {
1471
- str = unescapeQuote(str);
1472
- str = escapeHtmlEntities(str);
1473
- str = escapeDangerHtml5Entities(str);
1474
- str = clearNonPrintableCharacter(str);
1475
- return str;
1476
- }
1477
- function escapeAttrValue(str) {
1478
- str = escapeQuote(str);
1479
- str = escapeHtml(str);
1480
- return str;
1481
- }
1482
- function onIgnoreTagStripAll() {
1483
- return "";
1484
- }
1485
- function StripTagBody(tags, next) {
1486
- if (typeof next !== "function") {
1487
- next = function() {
1488
- };
1489
- }
1490
- var isRemoveAllTag = !Array.isArray(tags);
1491
- function isRemoveTag(tag) {
1492
- if (isRemoveAllTag) return true;
1493
- return _$2.indexOf(tags, tag) !== -1;
1494
- }
1495
- var removeList = [];
1496
- var posStart = false;
1497
- return {
1498
- onIgnoreTag: function(tag, html, options) {
1499
- if (isRemoveTag(tag)) {
1500
- if (options.isClosing) {
1501
- var ret = "[/removed]";
1502
- var end = options.position + ret.length;
1503
- removeList.push([
1504
- posStart !== false ? posStart : options.position,
1505
- end
1506
- ]);
1507
- posStart = false;
1508
- return ret;
1509
- } else {
1510
- if (!posStart) {
1511
- posStart = options.position;
1512
- }
1513
- return "[removed]";
1514
- }
1515
- } else {
1516
- return next(tag, html, options);
1517
- }
1518
- },
1519
- remove: function(html) {
1520
- var rethtml = "";
1521
- var lastPos = 0;
1522
- _$2.forEach(removeList, function(pos) {
1523
- rethtml += html.slice(lastPos, pos[0]);
1524
- lastPos = pos[1];
1525
- });
1526
- rethtml += html.slice(lastPos);
1527
- return rethtml;
1528
- }
1529
- };
1530
- }
1531
- function stripCommentTag(html) {
1532
- var retHtml = "";
1533
- var lastPos = 0;
1534
- while (lastPos < html.length) {
1535
- var i = html.indexOf("<!--", lastPos);
1536
- if (i === -1) {
1537
- retHtml += html.slice(lastPos);
1538
- break;
1539
- }
1540
- retHtml += html.slice(lastPos, i);
1541
- var j = html.indexOf("-->", i);
1542
- if (j === -1) {
1543
- break;
1544
- }
1545
- lastPos = j + 3;
1546
- }
1547
- return retHtml;
1548
- }
1549
- function stripBlankChar(html) {
1550
- var chars = html.split("");
1551
- chars = chars.filter(function(char) {
1552
- var c = char.charCodeAt(0);
1553
- if (c === 127) return false;
1554
- if (c <= 31) {
1555
- if (c === 10 || c === 13) return true;
1556
- return false;
1557
- }
1558
- return true;
1559
- });
1560
- return chars.join("");
1561
- }
1562
- _default$1.whiteList = getDefaultWhiteList();
1563
- _default$1.getDefaultWhiteList = getDefaultWhiteList;
1564
- _default$1.onTag = onTag;
1565
- _default$1.onIgnoreTag = onIgnoreTag;
1566
- _default$1.onTagAttr = onTagAttr;
1567
- _default$1.onIgnoreTagAttr = onIgnoreTagAttr;
1568
- _default$1.safeAttrValue = safeAttrValue;
1569
- _default$1.escapeHtml = escapeHtml;
1570
- _default$1.escapeQuote = escapeQuote;
1571
- _default$1.unescapeQuote = unescapeQuote;
1572
- _default$1.escapeHtmlEntities = escapeHtmlEntities;
1573
- _default$1.escapeDangerHtml5Entities = escapeDangerHtml5Entities;
1574
- _default$1.clearNonPrintableCharacter = clearNonPrintableCharacter;
1575
- _default$1.friendlyAttrValue = friendlyAttrValue;
1576
- _default$1.escapeAttrValue = escapeAttrValue;
1577
- _default$1.onIgnoreTagStripAll = onIgnoreTagStripAll;
1578
- _default$1.StripTagBody = StripTagBody;
1579
- _default$1.stripCommentTag = stripCommentTag;
1580
- _default$1.stripBlankChar = stripBlankChar;
1581
- _default$1.attributeWrapSign = '"';
1582
- _default$1.cssFilter = defaultCSSFilter;
1583
- _default$1.getDefaultCSSWhiteList = getDefaultCSSWhiteList;
1584
- var parser$1 = {};
1585
- var _$1 = util;
1586
- function getTagName(html) {
1587
- var i = _$1.spaceIndex(html);
1588
- var tagName;
1589
- if (i === -1) {
1590
- tagName = html.slice(1, -1);
1591
- } else {
1592
- tagName = html.slice(1, i + 1);
1593
- }
1594
- tagName = _$1.trim(tagName).toLowerCase();
1595
- if (tagName.slice(0, 1) === "/") tagName = tagName.slice(1);
1596
- if (tagName.slice(-1) === "/") tagName = tagName.slice(0, -1);
1597
- return tagName;
1598
- }
1599
- function isClosing(html) {
1600
- return html.slice(0, 2) === "</";
1601
- }
1602
- function parseTag$1(html, onTag2, escapeHtml2) {
1603
- var rethtml = "";
1604
- var lastPos = 0;
1605
- var tagStart = false;
1606
- var quoteStart = false;
1607
- var currentPos = 0;
1608
- var len = html.length;
1609
- var currentTagName = "";
1610
- var currentHtml = "";
1611
- chariterator: for (currentPos = 0; currentPos < len; currentPos++) {
1612
- var c = html.charAt(currentPos);
1613
- if (tagStart === false) {
1614
- if (c === "<") {
1615
- tagStart = currentPos;
1616
- continue;
1617
- }
1618
- } else {
1619
- if (quoteStart === false) {
1620
- if (c === "<") {
1621
- rethtml += escapeHtml2(html.slice(lastPos, currentPos));
1622
- tagStart = currentPos;
1623
- lastPos = currentPos;
1624
- continue;
1625
- }
1626
- if (c === ">" || currentPos === len - 1) {
1627
- rethtml += escapeHtml2(html.slice(lastPos, tagStart));
1628
- currentHtml = html.slice(tagStart, currentPos + 1);
1629
- currentTagName = getTagName(currentHtml);
1630
- rethtml += onTag2(
1631
- tagStart,
1632
- rethtml.length,
1633
- currentTagName,
1634
- currentHtml,
1635
- isClosing(currentHtml)
1636
- );
1637
- lastPos = currentPos + 1;
1638
- tagStart = false;
1639
- continue;
1640
- }
1641
- if (c === '"' || c === "'") {
1642
- var i = 1;
1643
- var ic = html.charAt(currentPos - i);
1644
- while (ic.trim() === "" || ic === "=") {
1645
- if (ic === "=") {
1646
- quoteStart = c;
1647
- continue chariterator;
1648
- }
1649
- ic = html.charAt(currentPos - ++i);
1650
- }
1651
- }
1652
- } else {
1653
- if (c === quoteStart) {
1654
- quoteStart = false;
1655
- continue;
1656
- }
1657
- }
1658
- }
1659
- }
1660
- if (lastPos < len) {
1661
- rethtml += escapeHtml2(html.substr(lastPos));
1662
- }
1663
- return rethtml;
1664
- }
1665
- var REGEXP_ILLEGAL_ATTR_NAME = /[^a-zA-Z0-9\\_:.-]/gim;
1666
- function parseAttr$1(html, onAttr2) {
1667
- var lastPos = 0;
1668
- var lastMarkPos = 0;
1669
- var retAttrs = [];
1670
- var tmpName = false;
1671
- var len = html.length;
1672
- function addAttr(name, value) {
1673
- name = _$1.trim(name);
1674
- name = name.replace(REGEXP_ILLEGAL_ATTR_NAME, "").toLowerCase();
1675
- if (name.length < 1) return;
1676
- var ret = onAttr2(name, value || "");
1677
- if (ret) retAttrs.push(ret);
1678
- }
1679
- for (var i = 0; i < len; i++) {
1680
- var c = html.charAt(i);
1681
- var v, j;
1682
- if (tmpName === false && c === "=") {
1683
- tmpName = html.slice(lastPos, i);
1684
- lastPos = i + 1;
1685
- lastMarkPos = html.charAt(lastPos) === '"' || html.charAt(lastPos) === "'" ? lastPos : findNextQuotationMark(html, i + 1);
1686
- continue;
1687
- }
1688
- if (tmpName !== false) {
1689
- if (i === lastMarkPos) {
1690
- j = html.indexOf(c, i + 1);
1691
- if (j === -1) {
1692
- break;
1693
- } else {
1694
- v = _$1.trim(html.slice(lastMarkPos + 1, j));
1695
- addAttr(tmpName, v);
1696
- tmpName = false;
1697
- i = j;
1698
- lastPos = i + 1;
1699
- continue;
1700
- }
1701
- }
1702
- }
1703
- if (/\s|\n|\t/.test(c)) {
1704
- html = html.replace(/\s|\n|\t/g, " ");
1705
- if (tmpName === false) {
1706
- j = findNextEqual(html, i);
1707
- if (j === -1) {
1708
- v = _$1.trim(html.slice(lastPos, i));
1709
- addAttr(v);
1710
- tmpName = false;
1711
- lastPos = i + 1;
1712
- continue;
1713
- } else {
1714
- i = j - 1;
1715
- continue;
1716
- }
1717
- } else {
1718
- j = findBeforeEqual(html, i - 1);
1719
- if (j === -1) {
1720
- v = _$1.trim(html.slice(lastPos, i));
1721
- v = stripQuoteWrap(v);
1722
- addAttr(tmpName, v);
1723
- tmpName = false;
1724
- lastPos = i + 1;
1725
- continue;
1726
- } else {
1727
- continue;
1728
- }
1729
- }
1730
- }
1731
- }
1732
- if (lastPos < html.length) {
1733
- if (tmpName === false) {
1734
- addAttr(html.slice(lastPos));
1735
- } else {
1736
- addAttr(tmpName, stripQuoteWrap(_$1.trim(html.slice(lastPos))));
1737
- }
1738
- }
1739
- return _$1.trim(retAttrs.join(" "));
1740
- }
1741
- function findNextEqual(str, i) {
1742
- for (; i < str.length; i++) {
1743
- var c = str[i];
1744
- if (c === " ") continue;
1745
- if (c === "=") return i;
1746
- return -1;
1747
- }
1748
- }
1749
- function findNextQuotationMark(str, i) {
1750
- for (; i < str.length; i++) {
1751
- var c = str[i];
1752
- if (c === " ") continue;
1753
- if (c === "'" || c === '"') return i;
1754
- return -1;
1755
- }
1756
- }
1757
- function findBeforeEqual(str, i) {
1758
- for (; i > 0; i--) {
1759
- var c = str[i];
1760
- if (c === " ") continue;
1761
- if (c === "=") return i;
1762
- return -1;
1763
- }
1764
- }
1765
- function isQuoteWrapString(text) {
1766
- if (text[0] === '"' && text[text.length - 1] === '"' || text[0] === "'" && text[text.length - 1] === "'") {
1767
- return true;
1768
- } else {
1769
- return false;
1770
- }
1771
- }
1772
- function stripQuoteWrap(text) {
1773
- if (isQuoteWrapString(text)) {
1774
- return text.substr(1, text.length - 2);
1775
- } else {
1776
- return text;
1777
- }
1778
- }
1779
- parser$1.parseTag = parseTag$1;
1780
- parser$1.parseAttr = parseAttr$1;
1781
- var FilterCSS = libExports$1.FilterCSS;
1782
- var DEFAULT = _default$1;
1783
- var parser = parser$1;
1784
- var parseTag = parser.parseTag;
1785
- var parseAttr = parser.parseAttr;
1786
- var _ = util;
1787
- function isNull(obj) {
1788
- return obj === void 0 || obj === null;
1789
- }
1790
- function getAttrs(html) {
1791
- var i = _.spaceIndex(html);
1792
- if (i === -1) {
1793
- return {
1794
- html: "",
1795
- closing: html[html.length - 2] === "/"
1796
- };
1797
- }
1798
- html = _.trim(html.slice(i + 1, -1));
1799
- var isClosing2 = html[html.length - 1] === "/";
1800
- if (isClosing2) html = _.trim(html.slice(0, -1));
1801
- return {
1802
- html,
1803
- closing: isClosing2
1804
- };
1805
- }
1806
- function shallowCopyObject(obj) {
1807
- var ret = {};
1808
- for (var i in obj) {
1809
- ret[i] = obj[i];
1810
- }
1811
- return ret;
1812
- }
1813
- function keysToLowerCase(obj) {
1814
- var ret = {};
1815
- for (var i in obj) {
1816
- if (Array.isArray(obj[i])) {
1817
- ret[i.toLowerCase()] = obj[i].map(function(item) {
1818
- return item.toLowerCase();
1819
- });
1820
- } else {
1821
- ret[i.toLowerCase()] = obj[i];
1822
- }
1823
- }
1824
- return ret;
1825
- }
1826
- function FilterXSS(options) {
1827
- options = shallowCopyObject(options || {});
1828
- if (options.stripIgnoreTag) {
1829
- if (options.onIgnoreTag) {
1830
- console.error(
1831
- 'Notes: cannot use these two options "stripIgnoreTag" and "onIgnoreTag" at the same time'
1832
- );
1833
- }
1834
- options.onIgnoreTag = DEFAULT.onIgnoreTagStripAll;
1835
- }
1836
- if (options.whiteList || options.allowList) {
1837
- options.whiteList = keysToLowerCase(options.whiteList || options.allowList);
1838
- } else {
1839
- options.whiteList = DEFAULT.whiteList;
1840
- }
1841
- this.attributeWrapSign = options.singleQuotedAttributeValue === true ? "'" : DEFAULT.attributeWrapSign;
1842
- options.onTag = options.onTag || DEFAULT.onTag;
1843
- options.onTagAttr = options.onTagAttr || DEFAULT.onTagAttr;
1844
- options.onIgnoreTag = options.onIgnoreTag || DEFAULT.onIgnoreTag;
1845
- options.onIgnoreTagAttr = options.onIgnoreTagAttr || DEFAULT.onIgnoreTagAttr;
1846
- options.safeAttrValue = options.safeAttrValue || DEFAULT.safeAttrValue;
1847
- options.escapeHtml = options.escapeHtml || DEFAULT.escapeHtml;
1848
- this.options = options;
1849
- if (options.css === false) {
1850
- this.cssFilter = false;
1851
- } else {
1852
- options.css = options.css || {};
1853
- this.cssFilter = new FilterCSS(options.css);
1854
- }
1855
- }
1856
- FilterXSS.prototype.process = function(html) {
1857
- html = html || "";
1858
- html = html.toString();
1859
- if (!html) return "";
1860
- var me = this;
1861
- var options = me.options;
1862
- var whiteList = options.whiteList;
1863
- var onTag2 = options.onTag;
1864
- var onIgnoreTag2 = options.onIgnoreTag;
1865
- var onTagAttr2 = options.onTagAttr;
1866
- var onIgnoreTagAttr2 = options.onIgnoreTagAttr;
1867
- var safeAttrValue2 = options.safeAttrValue;
1868
- var escapeHtml2 = options.escapeHtml;
1869
- var attributeWrapSign = me.attributeWrapSign;
1870
- var cssFilter = me.cssFilter;
1871
- if (options.stripBlankChar) {
1872
- html = DEFAULT.stripBlankChar(html);
1873
- }
1874
- if (!options.allowCommentTag) {
1875
- html = DEFAULT.stripCommentTag(html);
1876
- }
1877
- var stripIgnoreTagBody = false;
1878
- if (options.stripIgnoreTagBody) {
1879
- stripIgnoreTagBody = DEFAULT.StripTagBody(
1880
- options.stripIgnoreTagBody,
1881
- onIgnoreTag2
1882
- );
1883
- onIgnoreTag2 = stripIgnoreTagBody.onIgnoreTag;
1884
- }
1885
- var retHtml = parseTag(
1886
- html,
1887
- function(sourcePosition, position, tag, html2, isClosing2) {
1888
- var info = {
1889
- sourcePosition,
1890
- position,
1891
- isClosing: isClosing2,
1892
- isWhite: Object.prototype.hasOwnProperty.call(whiteList, tag)
1893
- };
1894
- var ret = onTag2(tag, html2, info);
1895
- if (!isNull(ret)) return ret;
1896
- if (info.isWhite) {
1897
- if (info.isClosing) {
1898
- return "</" + tag + ">";
1899
- }
1900
- var attrs = getAttrs(html2);
1901
- var whiteAttrList = whiteList[tag];
1902
- var attrsHtml = parseAttr(attrs.html, function(name, value) {
1903
- var isWhiteAttr = _.indexOf(whiteAttrList, name) !== -1;
1904
- var ret2 = onTagAttr2(tag, name, value, isWhiteAttr);
1905
- if (!isNull(ret2)) return ret2;
1906
- if (isWhiteAttr) {
1907
- value = safeAttrValue2(tag, name, value, cssFilter);
1908
- if (value) {
1909
- return name + "=" + attributeWrapSign + value + attributeWrapSign;
1910
- } else {
1911
- return name;
1912
- }
1913
- } else {
1914
- ret2 = onIgnoreTagAttr2(tag, name, value, isWhiteAttr);
1915
- if (!isNull(ret2)) return ret2;
1916
- return;
1917
- }
1918
- });
1919
- html2 = "<" + tag;
1920
- if (attrsHtml) html2 += " " + attrsHtml;
1921
- if (attrs.closing) html2 += " /";
1922
- html2 += ">";
1923
- return html2;
1924
- } else {
1925
- ret = onIgnoreTag2(tag, html2, info);
1926
- if (!isNull(ret)) return ret;
1927
- return escapeHtml2(html2);
1928
- }
1929
- },
1930
- escapeHtml2
1931
- );
1932
- if (stripIgnoreTagBody) {
1933
- retHtml = stripIgnoreTagBody.remove(retHtml);
1934
- }
1935
- return retHtml;
1936
- };
1937
- var xss$1 = FilterXSS;
1938
- (function(module2, exports2) {
1939
- var DEFAULT2 = _default$1;
1940
- var parser2 = parser$1;
1941
- var FilterXSS2 = xss$1;
1942
- function filterXSS(html, options) {
1943
- var xss2 = new FilterXSS2(options);
1944
- return xss2.process(html);
1945
- }
1946
- exports2 = module2.exports = filterXSS;
1947
- exports2.filterXSS = filterXSS;
1948
- exports2.FilterXSS = FilterXSS2;
1949
- (function() {
1950
- for (var i in DEFAULT2) {
1951
- exports2[i] = DEFAULT2[i];
1952
- }
1953
- for (var j in parser2) {
1954
- exports2[j] = parser2[j];
1955
- }
1956
- })();
1957
- if (typeof window !== "undefined") {
1958
- window.filterXSS = module2.exports;
1959
- }
1960
- function isWorkerEnv() {
1961
- return typeof self !== "undefined" && typeof DedicatedWorkerGlobalScope !== "undefined" && self instanceof DedicatedWorkerGlobalScope;
1962
- }
1963
- if (isWorkerEnv()) {
1964
- self.filterXSS = module2.exports;
1965
- }
1966
- })(lib$1, lib$1.exports);
1967
- var libExports = lib$1.exports;
1968
- const index = /* @__PURE__ */ getDefaultExportFromCjs(libExports);
1969
- const xss = /* @__PURE__ */ _mergeNamespaces({
1970
- __proto__: null,
1971
- default: index
1972
- }, [libExports]);
1973
- const MdWhiteList = {
1974
- img: ["class"],
1975
- // 支持任务列表
1976
- input: ["class", "disabled", "type", "checked"],
1977
- // 主要支持youtobe、腾讯视频、哔哩哔哩等内嵌视频代码
1978
- iframe: [
1979
- "class",
1980
- "width",
1981
- "height",
1982
- "src",
1983
- "title",
1984
- "border",
1985
- "frameborder",
1986
- "framespacing",
1987
- "allow",
1988
- "allowfullscreen"
1989
- ]
1990
- };
1991
- const XSSPlugin = (md, options) => {
1992
- const { extendedWhiteList = {}, xss: xssOption = {} } = options;
1993
- let xssIns;
1994
- if (typeof xssOption === "function") {
1995
- xssIns = new libExports.FilterXSS(xssOption(xss));
1996
- } else {
1997
- const whiteList = libExports.getDefaultWhiteList();
1998
- const keys = [...Object.keys(extendedWhiteList), ...Object.keys(MdWhiteList)];
1999
- keys.forEach((key) => {
2000
- const xssWhiteItem = whiteList[key] || [];
2001
- const innerWhiteItem = MdWhiteList[key] || [];
2002
- const userDefWhiteItem = extendedWhiteList[key] || [];
2003
- whiteList[key] = [
2004
- .../* @__PURE__ */ new Set([...xssWhiteItem, ...innerWhiteItem, ...userDefWhiteItem])
2005
- ];
2006
- });
2007
- xssIns = new libExports.FilterXSS({
2008
- whiteList,
2009
- // 自定义的优先级最高
2010
- ...xssOption
2011
- });
2012
- }
2013
- md.core.ruler.after("linkify", "xss", (state) => {
2014
- for (let i = 0; i < state.tokens.length; i++) {
2015
- const cur = state.tokens[i];
2016
- switch (cur.type) {
2017
- case "html_block": {
2018
- cur.content = xssIns.process(cur.content);
2019
- break;
2020
- }
2021
- case "inline": {
2022
- const inlineTokens = cur.children || [];
2023
- inlineTokens.forEach((it) => {
2024
- if (it.type === "html_inline") {
2025
- it.content = xssIns.process(it.content);
2026
- }
2027
- });
2028
- break;
2029
- }
2030
- }
2031
- }
2032
- });
2033
- };
2034
722
  const attrSet = (token, name, value) => {
2035
723
  const index2 = token.attrIndex(name);
2036
724
  const attr = [name, value];
@@ -2193,11 +881,6 @@ const useMarkdownIt = (props, previewOnly) => {
2193
881
  customIconRef
2194
882
  }
2195
883
  },
2196
- {
2197
- type: "xss",
2198
- plugin: XSSPlugin,
2199
- options: {}
2200
- },
2201
884
  {
2202
885
  type: "sub",
2203
886
  plugin: SubPlugin,
@@ -2251,7 +934,7 @@ const useMarkdownIt = (props, previewOnly) => {
2251
934
  } else {
2252
935
  codeHtml = md.utils.escapeHtml(str);
2253
936
  }
2254
- const codeSpan = showCodeRowNumber ? index$1.generateCodeRowNumber(
937
+ const codeSpan = showCodeRowNumber ? index.generateCodeRowNumber(
2255
938
  codeHtml.replace(/^\n+|\n+$/g, ""),
2256
939
  str.replace(/^\n+|\n+$/g, "")
2257
940
  ) : `<span class="${config.prefix}-code-block">${codeHtml.replace(/^\n+|\n+$/g, "")}</span>`;
@@ -2259,7 +942,7 @@ const useMarkdownIt = (props, previewOnly) => {
2259
942
  }
2260
943
  });
2261
944
  initLineNumber(md);
2262
- const key = vue.ref(`_article-key_${util$2.randomId()}`);
945
+ const key = vue.ref(`_article-key_${util.randomId()}`);
2263
946
  const html = vue.ref(props.sanitize(md.render(props.modelValue)));
2264
947
  const updatedTodo = () => {
2265
948
  eventName.bus.emit(editorId, eventName.BUILD_FINISHED, html.value);
@@ -2283,7 +966,7 @@ const useMarkdownIt = (props, previewOnly) => {
2283
966
  });
2284
967
  vue.watch(
2285
968
  [vue.toRef(props, "modelValue"), needReRender, reRenderRef, languageRef],
2286
- util$2.debounce(markHtml, previewOnly ? 0 : editorConfig.renderDelay)
969
+ util.debounce(markHtml, previewOnly ? 0 : editorConfig.renderDelay)
2287
970
  );
2288
971
  vue.watch(
2289
972
  () => props.setting.preview,
@@ -2310,7 +993,7 @@ const useMarkdownIt = (props, previewOnly) => {
2310
993
  eventName.bus.on(editorId, {
2311
994
  name: eventName.RERENDER,
2312
995
  callback: () => {
2313
- key.value = `_article-key_${util$2.randomId()}`;
996
+ key.value = `_article-key_${util.randomId()}`;
2314
997
  markHtml();
2315
998
  }
2316
999
  });
@@ -2513,10 +1196,10 @@ const contentProps = {
2513
1196
  default: () => {
2514
1197
  }
2515
1198
  },
2516
- inputBoxWitdh: {
1199
+ inputBoxWidth: {
2517
1200
  type: String
2518
1201
  },
2519
- onInputBoxWitdhChange: {
1202
+ oninputBoxWidthChange: {
2520
1203
  type: Function
2521
1204
  },
2522
1205
  transformImgUrl: {
@@ -2558,8 +1241,8 @@ const ContentPreview = /* @__PURE__ */ vue.defineComponent({
2558
1241
  };
2559
1242
  }
2560
1243
  });
2561
- const useOnSave = (props, context) => {
2562
- const { editorId } = props;
1244
+ const useOnSave = (props, context, options) => {
1245
+ const { editorId } = options;
2563
1246
  const state = vue.reactive({
2564
1247
  // 是否已编译成html
2565
1248
  buildFinished: false,
@@ -2607,9 +1290,9 @@ const useOnSave = (props, context) => {
2607
1290
  });
2608
1291
  };
2609
1292
  const useProvidePreview = (props, rootRef) => {
2610
- const { editorId } = props;
2611
1293
  const hljsUrls = config.configOption.editorExtensions.highlight;
2612
1294
  const hljsAttrs = config.configOption.editorExtensionsAttrs.highlight;
1295
+ const editorId = useEditorId(props);
2613
1296
  vue.provide("editorId", editorId);
2614
1297
  vue.provide("rootRef", rootRef);
2615
1298
  vue.provide(
@@ -2650,8 +1333,8 @@ const useProvidePreview = (props, rootRef) => {
2650
1333
  ...config.staticTextDefault,
2651
1334
  ...config.configOption.editorConfig.languageUserDefined
2652
1335
  };
2653
- return util$2.deepMerge(
2654
- util$2.deepClone(config.staticTextDefault["en-US"]),
1336
+ return util.deepMerge(
1337
+ util.deepClone(config.staticTextDefault["en-US"]),
2655
1338
  allText[props.language] || {}
2656
1339
  );
2657
1340
  });
@@ -2664,32 +1347,11 @@ const useProvidePreview = (props, rootRef) => {
2664
1347
  "customIcon",
2665
1348
  vue.computed(() => props.customIcon)
2666
1349
  );
1350
+ return { editorId };
2667
1351
  };
2668
1352
  const useProvide = (props, rootRef) => {
2669
- useProvidePreview(props, rootRef);
2670
1353
  vue.provide("tabWidth", props.tabWidth);
2671
- };
2672
- const useExpansionPreview = (props) => {
2673
- vue.onMounted(() => {
2674
- const { editorExtensions, editorExtensionsAttrs, iconfontType } = config.configOption;
2675
- if (props.noIconfont) {
2676
- return;
2677
- }
2678
- if (iconfontType === "svg") {
2679
- dom.appendHandler("script", {
2680
- ...editorExtensionsAttrs.iconfont,
2681
- src: editorExtensions.iconfont,
2682
- id: `${config.prefix}-icon`
2683
- });
2684
- } else {
2685
- dom.appendHandler("link", {
2686
- ...editorExtensionsAttrs.iconfontClass,
2687
- rel: "stylesheet",
2688
- href: editorExtensions.iconfontClass,
2689
- id: `${config.prefix}-icon-class`
2690
- });
2691
- }
2692
- });
1354
+ return useProvidePreview(props, rootRef);
2693
1355
  };
2694
1356
  const useExpansion = (props) => {
2695
1357
  const { noPrettier, noUploadImg } = props;
@@ -2699,9 +1361,9 @@ const useExpansion = (props) => {
2699
1361
  const noCropperScript = noUploadImg || editorExtensions.cropper.instance;
2700
1362
  vue.onMounted(() => {
2701
1363
  if (!noCropperScript) {
2702
- const { js = {}, css: css2 = {} } = editorExtensionsAttrs.cropper || {};
1364
+ const { js = {}, css = {} } = editorExtensionsAttrs.cropper || {};
2703
1365
  dom.appendHandler("link", {
2704
- ...css2,
1366
+ ...css,
2705
1367
  rel: "stylesheet",
2706
1368
  href: editorExtensions.cropper.css,
2707
1369
  id: `${config.prefix}-cropperCss`
@@ -2729,10 +1391,9 @@ const useExpansion = (props) => {
2729
1391
  });
2730
1392
  }
2731
1393
  });
2732
- useExpansionPreview(props);
2733
1394
  };
2734
- const useErrorCatcher = (props, context) => {
2735
- const { editorId } = props;
1395
+ const useErrorCatcher = (props, context, options) => {
1396
+ const { editorId } = options;
2736
1397
  vue.onMounted(() => {
2737
1398
  eventName.bus.on(editorId, {
2738
1399
  name: eventName.ERROR_CATCHER,
@@ -2746,8 +1407,8 @@ const useErrorCatcher = (props, context) => {
2746
1407
  });
2747
1408
  });
2748
1409
  };
2749
- const useConfig = (props, context) => {
2750
- const { editorId } = props;
1410
+ const useConfig = (props, context, options) => {
1411
+ const { editorId } = options;
2751
1412
  const setting = vue.reactive({
2752
1413
  pageFullscreen: props.pageFullscreen,
2753
1414
  fullscreen: false,
@@ -2806,7 +1467,7 @@ const useConfig = (props, context) => {
2806
1467
  desc: "",
2807
1468
  urls
2808
1469
  });
2809
- cb && cb();
1470
+ cb == null ? void 0 : cb();
2810
1471
  };
2811
1472
  if (props.onUploadImg) {
2812
1473
  props.onUploadImg(files, insertHanlder);
@@ -2820,8 +1481,8 @@ const useConfig = (props, context) => {
2820
1481
  });
2821
1482
  return [setting, updateSetting];
2822
1483
  };
2823
- const useCatalog = (props) => {
2824
- const { editorId } = props;
1484
+ const useCatalog = (props, options) => {
1485
+ const { editorId } = options;
2825
1486
  const catalogShow = vue.ref(false);
2826
1487
  vue.onMounted(() => {
2827
1488
  eventName.bus.on(editorId, {
@@ -2840,8 +1501,8 @@ const useCatalog = (props) => {
2840
1501
  });
2841
1502
  return catalogVisible;
2842
1503
  };
2843
- const useExpose$1 = (props, ctx, catalogVisible, setting, updateSetting, codeRef) => {
2844
- const { editorId } = props;
1504
+ const useExpose$1 = (props, ctx, options) => {
1505
+ const { editorId, catalogVisible, setting, updateSetting, codeRef } = options;
2845
1506
  vue.watch(
2846
1507
  () => setting.pageFullscreen,
2847
1508
  (newVal) => {
@@ -2958,9 +1619,9 @@ const useExpose$1 = (props, ctx, catalogVisible, setting, updateSetting, codeRef
2958
1619
  insert(generate) {
2959
1620
  eventName.bus.emit(editorId, eventName.REPLACE, "universal", { generate });
2960
1621
  },
2961
- focus(options) {
1622
+ focus(options2) {
2962
1623
  var _a;
2963
- (_a = codeRef.value) == null ? void 0 : _a.focus(options);
1624
+ (_a = codeRef.value) == null ? void 0 : _a.focus(options2);
2964
1625
  },
2965
1626
  rerender() {
2966
1627
  eventName.bus.emit(editorId, eventName.RERENDER);
@@ -2986,6 +1647,10 @@ const useExpose$1 = (props, ctx, catalogVisible, setting, updateSetting, codeRef
2986
1647
  };
2987
1648
  ctx.expose(exposeParam);
2988
1649
  };
1650
+ const useEditorId = (props) => {
1651
+ const defaultId = vue.useId();
1652
+ return props.id || props.editorId || `${config.prefix}-${defaultId}`;
1653
+ };
2989
1654
  const mdHeadingId = (text) => text;
2990
1655
  const mdPreviewProps = {
2991
1656
  /**
@@ -3001,7 +1666,8 @@ const mdPreviewProps = {
3001
1666
  * input回调事件
3002
1667
  */
3003
1668
  onChange: {
3004
- type: Function
1669
+ type: Function,
1670
+ default: void 0
3005
1671
  },
3006
1672
  /**
3007
1673
  * 主题,支持light和dark
@@ -3034,22 +1700,34 @@ const mdPreviewProps = {
3034
1700
  * html变化事件
3035
1701
  */
3036
1702
  onHtmlChanged: {
3037
- type: Function
1703
+ type: Function,
1704
+ default: void 0
3038
1705
  },
3039
1706
  /**
3040
1707
  * 获取目录结构
3041
1708
  */
3042
1709
  onGetCatalog: {
3043
- type: Function
1710
+ type: Function,
1711
+ default: void 0
3044
1712
  },
3045
1713
  /**
3046
1714
  * 编辑器唯一标识
3047
1715
  *
3048
1716
  * @default 'md-editor-v3'
1717
+ * @deprecated 5.x版本开始使用 id 替换
3049
1718
  */
3050
1719
  editorId: {
3051
1720
  type: String,
3052
- default: () => index$1.getNextId("md-editor-v3_")
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
3053
1731
  },
3054
1732
  /**
3055
1733
  * 预览中代码是否显示行号
@@ -3129,7 +1807,8 @@ const mdPreviewProps = {
3129
1807
  * @default false
3130
1808
  */
3131
1809
  noIconfont: {
3132
- type: Boolean
1810
+ type: Boolean,
1811
+ default: void 0
3133
1812
  },
3134
1813
  /**
3135
1814
  * 复制代码格式化方法
@@ -3207,13 +1886,15 @@ const editorProps = {
3207
1886
  * input回调事件
3208
1887
  */
3209
1888
  onSave: {
3210
- type: Function
1889
+ type: Function,
1890
+ default: void 0
3211
1891
  },
3212
1892
  /**
3213
1893
  * 上传图片事件
3214
1894
  */
3215
1895
  onUploadImg: {
3216
- type: Function
1896
+ type: Function,
1897
+ default: void 0
3217
1898
  },
3218
1899
  /**
3219
1900
  * 是否页面内全屏
@@ -3297,7 +1978,8 @@ const editorProps = {
3297
1978
  * @default [6, 4]
3298
1979
  */
3299
1980
  tableShape: {
3300
- type: Array
1981
+ type: Array,
1982
+ default: void 0
3301
1983
  },
3302
1984
  /**
3303
1985
  * 空提示
@@ -3312,13 +1994,15 @@ const editorProps = {
3312
1994
  * 自定义的工具栏列表
3313
1995
  */
3314
1996
  defToolbars: {
3315
- type: [String, Object]
1997
+ type: [String, Object],
1998
+ default: void 0
3316
1999
  },
3317
2000
  /**
3318
2001
  * 内部错误捕获
3319
2002
  */
3320
2003
  onError: {
3321
- type: Function
2004
+ type: Function,
2005
+ default: void 0
3322
2006
  },
3323
2007
  /**
3324
2008
  * 页脚列表显示顺序
@@ -3340,7 +2024,8 @@ const editorProps = {
3340
2024
  * 自定义的也叫工具组件列表
3341
2025
  */
3342
2026
  defFooters: {
3343
- type: [String, Object]
2027
+ type: [String, Object],
2028
+ default: void 0
3344
2029
  },
3345
2030
  /**
3346
2031
  * 是否禁用上传图片
@@ -3348,7 +2033,8 @@ const editorProps = {
3348
2033
  * @default false
3349
2034
  */
3350
2035
  noUploadImg: {
3351
- type: Boolean
2036
+ type: Boolean,
2037
+ default: void 0
3352
2038
  },
3353
2039
  /**
3354
2040
  * 文本区域自动获得焦点
@@ -3356,7 +2042,8 @@ const editorProps = {
3356
2042
  * @default false
3357
2043
  */
3358
2044
  autoFocus: {
3359
- type: Boolean
2045
+ type: Boolean,
2046
+ default: void 0
3360
2047
  },
3361
2048
  /**
3362
2049
  * 禁用文本区域
@@ -3364,7 +2051,8 @@ const editorProps = {
3364
2051
  * @default false
3365
2052
  */
3366
2053
  disabled: {
3367
- type: Boolean
2054
+ type: Boolean,
2055
+ default: void 0
3368
2056
  },
3369
2057
  /**
3370
2058
  * 文本区域为只读
@@ -3372,13 +2060,15 @@ const editorProps = {
3372
2060
  * @default false
3373
2061
  */
3374
2062
  readOnly: {
3375
- type: Boolean
2063
+ type: Boolean,
2064
+ default: void 0
3376
2065
  },
3377
2066
  /**
3378
2067
  * 文本区域允许的最大字符数
3379
2068
  */
3380
2069
  maxLength: {
3381
- type: Number
2070
+ type: Number,
2071
+ default: void 0
3382
2072
  },
3383
2073
  /**
3384
2074
  * 是否启用自动识别粘贴代码类别
@@ -3387,19 +2077,22 @@ const editorProps = {
3387
2077
  * @default false
3388
2078
  */
3389
2079
  autoDetectCode: {
3390
- type: Boolean
2080
+ type: Boolean,
2081
+ default: void 0
3391
2082
  },
3392
2083
  /**
3393
2084
  * 输入框失去焦点时触发事件
3394
2085
  */
3395
2086
  onBlur: {
3396
- type: Function
2087
+ type: Function,
2088
+ default: void 0
3397
2089
  },
3398
2090
  /**
3399
2091
  * 输入框获得焦点时触发事件
3400
2092
  */
3401
2093
  onFocus: {
3402
- type: Function
2094
+ type: Function,
2095
+ default: void 0
3403
2096
  },
3404
2097
  /**
3405
2098
  * @codemirror/autocomplete匹配关键词的方法列表
@@ -3412,7 +2105,8 @@ const editorProps = {
3412
2105
  * })
3413
2106
  */
3414
2107
  completions: {
3415
- type: Array
2108
+ type: Array,
2109
+ default: void 0
3416
2110
  },
3417
2111
  /**
3418
2112
  * 是否在工具栏下面显示对应的文字名称
@@ -3427,10 +2121,12 @@ const editorProps = {
3427
2121
  * 字符输入事件
3428
2122
  */
3429
2123
  onInput: {
3430
- type: Function
2124
+ type: Function,
2125
+ default: void 0
3431
2126
  },
3432
2127
  onDrop: {
3433
- type: Function
2128
+ type: Function,
2129
+ default: void 0
3434
2130
  },
3435
2131
  /**
3436
2132
  * 输入框的默认宽度
@@ -3438,15 +2134,16 @@ const editorProps = {
3438
2134
  * @example '100px'/'50%'
3439
2135
  * @default '50%
3440
2136
  */
3441
- inputBoxWitdh: {
2137
+ inputBoxWidth: {
3442
2138
  type: String,
3443
2139
  default: "50%"
3444
2140
  },
3445
2141
  /**
3446
2142
  * 输入框宽度变化事件
3447
2143
  */
3448
- onInputBoxWitdhChange: {
3449
- type: Function
2144
+ oninputBoxWidthChange: {
2145
+ type: Function,
2146
+ default: void 0
3450
2147
  },
3451
2148
  /**
3452
2149
  * 替换粘贴的图片链接
@@ -3474,10 +2171,10 @@ const editorEmits = [
3474
2171
  "onFocus",
3475
2172
  "onInput",
3476
2173
  "onDrop",
3477
- "onInputBoxWitdhChange"
2174
+ "oninputBoxWidthChange"
3478
2175
  ];
3479
- const useExpose = (props, ctx) => {
3480
- const { editorId } = props;
2176
+ const useExpose = (props, ctx, options) => {
2177
+ const { editorId } = options;
3481
2178
  const exposeParam = {
3482
2179
  rerender() {
3483
2180
  eventName.bus.emit(editorId, eventName.RERENDER);
@@ -3491,15 +2188,17 @@ const MdPreview = /* @__PURE__ */ vue.defineComponent({
3491
2188
  emits: mdPreviewEmits,
3492
2189
  setup(props, ctx) {
3493
2190
  const {
3494
- editorId,
3495
2191
  noKatex,
3496
2192
  noMermaid,
3497
2193
  noHighlight
3498
2194
  } = props;
3499
2195
  const rootRef = vue.ref();
3500
- useProvidePreview(props, rootRef);
3501
- useExpansionPreview(props);
3502
- useExpose(props, ctx);
2196
+ const {
2197
+ editorId
2198
+ } = useProvidePreview(props, rootRef);
2199
+ useExpose(props, ctx, {
2200
+ editorId
2201
+ });
3503
2202
  vue.onBeforeUnmount(() => {
3504
2203
  eventName.bus.clear(editorId);
3505
2204
  });