md-editor-v3 2.0.1 → 2.1.0-beta.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 CHANGED
@@ -247,12 +247,12 @@ const handler = () => {
247
247
 
248
248
  | name | param | description |
249
249
  | --- | --- | --- |
250
- | onChange | v:string | Content changed event(bind to `oninput` of `textarea`) |
251
- | onSave | v:string | Save content event, `ctrl+s`and click button will be triggered also |
252
- | onUploadImg | files:Array<File>, callback:Function | Upload picture event, when picture is uploading the modal will not close, please provide right urls to the callback function |
253
- | onHtmlChanged | h:string | Compile markdown successful event, you can use it to get the html code |
254
- | onGetCatalog | list: HeadList[] | Get catalog of article |
255
- | onError | err: { name: string; message: string } | Catch run-time error, `Cropper`,`fullScreen` and `prettier` are used when they are not loaded |
250
+ | onChange | `value: string` | Content changed event(bind to `oninput` of `textarea`) |
251
+ | onSave | `value: string` | Save content event, `ctrl+s`and click button will be triggered also |
252
+ | onUploadImg | `files: Array<File>, callback: (urls: Array<string>) => void` | Upload picture event, when picture is uploading the modal will not close, please provide right urls to the callback function |
253
+ | onHtmlChanged | `html: string` | Compile markdown successful event, you can use it to get the html code |
254
+ | onGetCatalog | `list: Array<HeadList>` | Get catalog of article |
255
+ | onError | `err: { name: string; message: string }` | Catch run-time error, `Cropper`, `fullScreen` and `prettier` are used when they are not loaded |
256
256
 
257
257
  ## Config
258
258
 
@@ -1,5 +1,5 @@
1
1
  import { PropType, CSSProperties } from 'vue';
2
- import { ToolbarNames, HeadList, MarkedHeadingId, Themes, InnerError } from './type';
2
+ import { ToolbarNames, HeadList, MarkedHeadingId, Themes, InnerError, Footers } from './type';
3
3
  export declare const markedHeadingId: MarkedHeadingId;
4
4
  declare const Editor: import("vue").DefineComponent<{
5
5
  modelValue: {
@@ -119,6 +119,17 @@ declare const Editor: import("vue").DefineComponent<{
119
119
  type: PropType<string>;
120
120
  default: string;
121
121
  };
122
+ footers: {
123
+ type: PropType<Footers[]>;
124
+ default: Footers[];
125
+ };
126
+ scrollAuto: {
127
+ type: PropType<boolean>;
128
+ default: boolean;
129
+ };
130
+ defFooters: {
131
+ type: PropType<string | JSX.Element>;
132
+ };
122
133
  }, () => JSX.Element, unknown, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, import("vue").EmitsOptions, "onSave" | "onError" | "onUploadImg" | "onChange" | "onHtmlChanged" | "onGetCatalog" | "update:modelValue", import("vue").VNodeProps & import("vue").AllowedComponentProps & import("vue").ComponentCustomProps, Readonly<import("vue").ExtractPropTypes<{
123
134
  modelValue: {
124
135
  type: PropType<string>;
@@ -237,6 +248,17 @@ declare const Editor: import("vue").DefineComponent<{
237
248
  type: PropType<string>;
238
249
  default: string;
239
250
  };
251
+ footers: {
252
+ type: PropType<Footers[]>;
253
+ default: Footers[];
254
+ };
255
+ scrollAuto: {
256
+ type: PropType<boolean>;
257
+ default: boolean;
258
+ };
259
+ defFooters: {
260
+ type: PropType<string | JSX.Element>;
261
+ };
240
262
  }>>, {
241
263
  pageFullScreen: boolean;
242
264
  preview: boolean;
@@ -251,6 +273,7 @@ declare const Editor: import("vue").DefineComponent<{
251
273
  previewTheme: string;
252
274
  style: string | CSSProperties;
253
275
  class: string;
276
+ scrollAuto: boolean;
254
277
  modelValue: string;
255
278
  language: string;
256
279
  toolbars: ToolbarNames[];
@@ -262,5 +285,6 @@ declare const Editor: import("vue").DefineComponent<{
262
285
  placeholder: string;
263
286
  noKatex: boolean;
264
287
  codeTheme: string;
288
+ footers: Footers[];
265
289
  }>;
266
290
  export default Editor;
@@ -3,6 +3,7 @@ import { MarkedHeadingId, Themes } from '../../type';
3
3
  export interface TocItem {
4
4
  text: string;
5
5
  level: number;
6
+ index: number;
6
7
  children?: Array<TocItem>;
7
8
  }
8
9
  declare const MdCatalog: import("vue").DefineComponent<{
@@ -22,6 +22,7 @@ declare const _default: {
22
22
  previewTheme: string;
23
23
  style: string | import("vue").CSSProperties;
24
24
  class: string;
25
+ scrollAuto: boolean;
25
26
  modelValue: string;
26
27
  language: string;
27
28
  toolbars: import("./type").ToolbarNames[];
@@ -33,6 +34,7 @@ declare const _default: {
33
34
  placeholder: string;
34
35
  noKatex: boolean;
35
36
  codeTheme: string;
37
+ footers: import("./type").Footers[];
36
38
  }> & Omit<Readonly<import("vue").ExtractPropTypes<{
37
39
  modelValue: {
38
40
  type: import("vue").PropType<string>;
@@ -151,7 +153,18 @@ declare const _default: {
151
153
  type: import("vue").PropType<string>;
152
154
  default: string;
153
155
  };
154
- }>> & import("vue").VNodeProps & import("vue").AllowedComponentProps & import("vue").ComponentCustomProps, "pageFullScreen" | "preview" | "htmlPreview" | "editorId" | "noPrettier" | "tabWidth" | "theme" | "historyLength" | "previewOnly" | "showCodeRowNumber" | "previewTheme" | "style" | "class" | "modelValue" | "language" | "toolbars" | "toolbarsExclude" | "markedHeadingId" | "tableShape" | "noMermaid" | "sanitize" | "placeholder" | "noKatex" | "codeTheme">;
156
+ footers: {
157
+ type: import("vue").PropType<import("./type").Footers[]>;
158
+ default: import("./type").Footers[];
159
+ };
160
+ scrollAuto: {
161
+ type: import("vue").PropType<boolean>;
162
+ default: boolean;
163
+ };
164
+ defFooters: {
165
+ type: import("vue").PropType<string | JSX.Element>;
166
+ };
167
+ }>> & import("vue").VNodeProps & import("vue").AllowedComponentProps & import("vue").ComponentCustomProps, "pageFullScreen" | "preview" | "htmlPreview" | "editorId" | "noPrettier" | "tabWidth" | "theme" | "historyLength" | "previewOnly" | "showCodeRowNumber" | "previewTheme" | "style" | "class" | "scrollAuto" | "modelValue" | "language" | "toolbars" | "toolbarsExclude" | "markedHeadingId" | "tableShape" | "noMermaid" | "sanitize" | "placeholder" | "noKatex" | "codeTheme" | "footers">;
155
168
  $attrs: {
156
169
  [x: string]: unknown;
157
170
  };
@@ -283,6 +296,17 @@ declare const _default: {
283
296
  type: import("vue").PropType<string>;
284
297
  default: string;
285
298
  };
299
+ footers: {
300
+ type: import("vue").PropType<import("./type").Footers[]>;
301
+ default: import("./type").Footers[];
302
+ };
303
+ scrollAuto: {
304
+ type: import("vue").PropType<boolean>;
305
+ default: boolean;
306
+ };
307
+ defFooters: {
308
+ type: import("vue").PropType<string | JSX.Element>;
309
+ };
286
310
  }>>, () => JSX.Element, unknown, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, import("vue").EmitsOptions, string, {
287
311
  pageFullScreen: boolean;
288
312
  preview: boolean;
@@ -297,6 +321,7 @@ declare const _default: {
297
321
  previewTheme: string;
298
322
  style: string | import("vue").CSSProperties;
299
323
  class: string;
324
+ scrollAuto: boolean;
300
325
  modelValue: string;
301
326
  language: string;
302
327
  toolbars: import("./type").ToolbarNames[];
@@ -308,6 +333,7 @@ declare const _default: {
308
333
  placeholder: string;
309
334
  noKatex: boolean;
310
335
  codeTheme: string;
336
+ footers: import("./type").Footers[];
311
337
  }> & {
312
338
  beforeCreate?: ((() => void) | (() => void)[]) | undefined;
313
339
  created?: ((() => void) | (() => void)[]) | undefined;
@@ -446,6 +472,17 @@ declare const _default: {
446
472
  type: import("vue").PropType<string>;
447
473
  default: string;
448
474
  };
475
+ footers: {
476
+ type: import("vue").PropType<import("./type").Footers[]>;
477
+ default: import("./type").Footers[];
478
+ };
479
+ scrollAuto: {
480
+ type: import("vue").PropType<boolean>;
481
+ default: boolean;
482
+ };
483
+ defFooters: {
484
+ type: import("vue").PropType<string | JSX.Element>;
485
+ };
449
486
  }>> & import("vue").ShallowUnwrapRef<() => JSX.Element> & {} & {} & import("vue").ComponentCustomProperties;
450
487
  __isFragment?: undefined;
451
488
  __isTeleport?: undefined;
@@ -568,6 +605,17 @@ declare const _default: {
568
605
  type: import("vue").PropType<string>;
569
606
  default: string;
570
607
  };
608
+ footers: {
609
+ type: import("vue").PropType<import("./type").Footers[]>;
610
+ default: import("./type").Footers[];
611
+ };
612
+ scrollAuto: {
613
+ type: import("vue").PropType<boolean>;
614
+ default: boolean;
615
+ };
616
+ defFooters: {
617
+ type: import("vue").PropType<string | JSX.Element>;
618
+ };
571
619
  }>>, () => JSX.Element, unknown, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, import("vue").EmitsOptions, "onSave" | "onError" | "onUploadImg" | "onChange" | "onHtmlChanged" | "onGetCatalog" | "update:modelValue", {
572
620
  pageFullScreen: boolean;
573
621
  preview: boolean;
@@ -582,6 +630,7 @@ declare const _default: {
582
630
  previewTheme: string;
583
631
  style: string | import("vue").CSSProperties;
584
632
  class: string;
633
+ scrollAuto: boolean;
585
634
  modelValue: string;
586
635
  language: string;
587
636
  toolbars: import("./type").ToolbarNames[];
@@ -593,6 +642,7 @@ declare const _default: {
593
642
  placeholder: string;
594
643
  noKatex: boolean;
595
644
  codeTheme: string;
645
+ footers: import("./type").Footers[];
596
646
  }> & import("vue").VNodeProps & import("vue").AllowedComponentProps & import("vue").ComponentCustomProps & {
597
647
  readonly NormalToolbar: typeof NormalToolbar;
598
648
  readonly DropdownToolbar: typeof DropdownToolbar;
@@ -87,6 +87,10 @@ export interface StaticTextDefaultValue {
87
87
  inline: string;
88
88
  block: string;
89
89
  };
90
+ footer?: {
91
+ markdownTotal: string;
92
+ scrollAuto: string;
93
+ };
90
94
  }
91
95
  export interface StaticTextDefault {
92
96
  'zh-CN': StaticTextDefaultValue;
@@ -94,6 +98,7 @@ export interface StaticTextDefault {
94
98
  }
95
99
  export declare type StaticTextDefaultKey = keyof StaticTextDefault;
96
100
  export declare type ToolbarNames = keyof ToolbarTips | number;
101
+ export declare type Footers = '=' | 'mardownTotal' | 'scrollSwitch' | number;
97
102
  export interface SettingType {
98
103
  pageFullScreen: boolean;
99
104
  fullscreen: boolean;
@@ -106,7 +111,7 @@ export interface HeadList {
106
111
  text: string;
107
112
  level: 1 | 2 | 3 | 4 | 5 | 6;
108
113
  }
109
- export declare type MarkedHeadingId = (text: string, level: number) => string;
114
+ export declare type MarkedHeadingId = (text: string, level: number, index: number) => string;
110
115
  export interface MermaidTemplate {
111
116
  /**
112
117
  * 流程图
@@ -17,7 +17,7 @@ var __spreadValues = (a, b) => {
17
17
  return a;
18
18
  };
19
19
  var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
20
- import { onMounted, onBeforeUnmount, provide, computed, reactive, watch, ref, defineComponent, createVNode, cloneVNode, nextTick, inject, Fragment, toRef, isVNode } from "vue";
20
+ import { onMounted, onBeforeUnmount, provide, computed, reactive, watch, ref, defineComponent, createVNode, cloneVNode, nextTick, inject, Fragment, toRef, createTextVNode, isVNode } from "vue";
21
21
  const prefix = "md";
22
22
  const iconfontUrl = "https://at.alicdn.com/t/font_2605852_pqekijay2ij.js";
23
23
  const cdnBase = "https://cdnjs.cloudflare.com/ajax/libs";
@@ -64,6 +64,7 @@ const allToolbar = [
64
64
  "catalog",
65
65
  "github"
66
66
  ];
67
+ const allFooter = ["mardownTotal", "=", "scrollSwitch"];
67
68
  const staticTextDefault = {
68
69
  "zh-CN": {
69
70
  toolbarTips: {
@@ -138,6 +139,10 @@ const staticTextDefault = {
138
139
  katex: {
139
140
  inline: "\u884C\u5185\u516C\u5F0F",
140
141
  block: "\u5757\u7EA7\u516C\u5F0F"
142
+ },
143
+ footer: {
144
+ markdownTotal: "\u5B57\u6570",
145
+ scrollAuto: "\u540C\u6B65\u6EDA\u52A8"
141
146
  }
142
147
  },
143
148
  "en-US": {
@@ -213,6 +218,10 @@ const staticTextDefault = {
213
218
  katex: {
214
219
  inline: "inline",
215
220
  block: "block"
221
+ },
222
+ footer: {
223
+ markdownTotal: "Word Count",
224
+ scrollAuto: "Scroll Auto"
216
225
  }
217
226
  }
218
227
  };
@@ -906,7 +915,7 @@ const getSlot = ({
906
915
  const targetSlot = (instance == null ? void 0 : instance.$slots[name]) || (ctx == null ? void 0 : ctx.slots[name]);
907
916
  return (targetSlot ? targetSlot(instance) : "") || props2[name];
908
917
  };
909
- var style$3 = "";
918
+ var style$4 = "";
910
919
  var Dropdown = defineComponent({
911
920
  props: {
912
921
  trigger: {
@@ -1035,7 +1044,7 @@ var Dropdown = defineComponent({
1035
1044
  };
1036
1045
  }
1037
1046
  });
1038
- var style$2 = "";
1047
+ var style$3 = "";
1039
1048
  var Modal = defineComponent({
1040
1049
  props: {
1041
1050
  title: {
@@ -1308,7 +1317,7 @@ var LinkModal = defineComponent({
1308
1317
  });
1309
1318
  }
1310
1319
  });
1311
- var style$1 = "";
1320
+ var style$2 = "";
1312
1321
  var ClipModal = defineComponent({
1313
1322
  props: {
1314
1323
  visible: {
@@ -5246,7 +5255,7 @@ var kaTexExtensions = {
5246
5255
  return (_a = text.match(/\$[^\n]*/)) == null ? void 0 : _a.index;
5247
5256
  },
5248
5257
  tokenizer(text) {
5249
- if (/^\$[^\n]*/.test(text)) {
5258
+ if (/^\$[^\n]*\$/.test(text)) {
5250
5259
  const match = splitKatexValue(text);
5251
5260
  const token = {
5252
5261
  type: "KaTexInlineExtension",
@@ -5411,7 +5420,7 @@ const useMarked = (props2, mermaidData) => {
5411
5420
  return markedCode.call(renderer, code, language, isEscaped);
5412
5421
  };
5413
5422
  renderer.image = (href, title = "", desc = "") => {
5414
- return `<span class="figure"><img src="${href}" title="${title}" alt="${desc}"><span class="figcaption">${desc}</span></span>`;
5423
+ return `<span class="figure"><img src="${href}" title="${title}" alt="${desc}" zoom><span class="figcaption">${desc}</span></span>`;
5415
5424
  };
5416
5425
  renderer.listitem = (text, task) => {
5417
5426
  if (task) {
@@ -5430,7 +5439,7 @@ const useMarked = (props2, mermaidData) => {
5430
5439
  if (isNewHeading) {
5431
5440
  return newHeading.call(renderer, text, level, raw, slugger);
5432
5441
  }
5433
- const id = props2.markedHeadingId(raw, level);
5442
+ const id = props2.markedHeadingId(raw, level, heads.value.length);
5434
5443
  if (text !== raw) {
5435
5444
  return `<h${level} id="${id}">${text}</h${level}>`;
5436
5445
  } else {
@@ -5559,14 +5568,9 @@ const useAutoScroll = (props2, html, textAreaRef, previewRef, htmlRef) => {
5559
5568
  pre.appendChild(copyButton);
5560
5569
  });
5561
5570
  };
5562
- onMounted(() => {
5563
- if (previewRef.value || htmlRef.value) {
5564
- [initScrollAuto, clearScrollAuto] = scrollAuto(textAreaRef.value, previewRef.value || htmlRef.value);
5565
- }
5566
- });
5567
5571
  const htmlChanged = () => {
5568
5572
  nextTick(() => {
5569
- if (props2.setting.preview && !previewOnly) {
5573
+ if (props2.setting.preview && !previewOnly && props2.scrollAuto) {
5570
5574
  clearScrollAuto();
5571
5575
  initScrollAuto();
5572
5576
  }
@@ -5585,7 +5589,19 @@ const useAutoScroll = (props2, html, textAreaRef, previewRef, htmlRef) => {
5585
5589
  watch(() => html.value, htmlChanged);
5586
5590
  watch(() => props2.setting.preview, settingPreviewChanged);
5587
5591
  watch(() => props2.setting.htmlPreview, settingPreviewChanged);
5588
- onMounted(htmlChanged);
5592
+ watch(() => props2.scrollAuto, (sa) => {
5593
+ if (sa) {
5594
+ initScrollAuto();
5595
+ } else {
5596
+ clearScrollAuto();
5597
+ }
5598
+ });
5599
+ onMounted(() => {
5600
+ initCopyEntry();
5601
+ if (!previewOnly && props2.scrollAuto && (previewRef.value || htmlRef.value)) {
5602
+ [initScrollAuto, clearScrollAuto] = scrollAuto(textAreaRef.value, previewRef.value || htmlRef.value);
5603
+ }
5604
+ });
5589
5605
  };
5590
5606
  const useAutoGenrator = (props2, textAreaRef) => {
5591
5607
  const previewOnly = inject("previewOnly");
@@ -5713,7 +5729,7 @@ const usePasteUpload = (textAreaRef) => {
5713
5729
  const userZoom = (html) => {
5714
5730
  const editorId = inject("editorId");
5715
5731
  const zoomHander = debounce(() => {
5716
- const imgs = document.querySelectorAll(`#${editorId}-preview img`);
5732
+ const imgs = document.querySelectorAll(`#${editorId}-preview img[zoom]`);
5717
5733
  if (imgs.length === 0) {
5718
5734
  return;
5719
5735
  }
@@ -5773,6 +5789,9 @@ var Content = defineComponent({
5773
5789
  mermaidTemplate: {
5774
5790
  type: Object,
5775
5791
  default: () => ({})
5792
+ },
5793
+ scrollAuto: {
5794
+ type: Boolean
5776
5795
  }
5777
5796
  },
5778
5797
  setup(props2) {
@@ -5832,6 +5851,144 @@ var Content = defineComponent({
5832
5851
  };
5833
5852
  }
5834
5853
  });
5854
+ var MarkdownTotal = defineComponent({
5855
+ props: {
5856
+ modelValue: {
5857
+ type: String,
5858
+ default: ""
5859
+ }
5860
+ },
5861
+ setup(props2) {
5862
+ const ult = inject("usedLanguageText");
5863
+ return () => {
5864
+ var _a;
5865
+ return createVNode("div", {
5866
+ "class": `${prefix}-footer-item`
5867
+ }, [createVNode("label", {
5868
+ "class": `${prefix}-footer-label`
5869
+ }, [(_a = ult.value.footer) == null ? void 0 : _a.markdownTotal, createTextVNode(":")]), createVNode("span", null, [props2.modelValue.length])]);
5870
+ };
5871
+ }
5872
+ });
5873
+ var style$1 = "";
5874
+ var Checkbox = defineComponent({
5875
+ props: {
5876
+ checked: {
5877
+ type: Boolean,
5878
+ default: false
5879
+ },
5880
+ onChange: {
5881
+ type: Function,
5882
+ default: () => () => {
5883
+ }
5884
+ }
5885
+ },
5886
+ setup(props2) {
5887
+ return () => {
5888
+ return createVNode("div", {
5889
+ "class": [`${prefix}-checkbox`, props2.checked && `${prefix}-checkbox-checked`],
5890
+ "onClick": () => {
5891
+ props2.onChange(!props2.checked);
5892
+ }
5893
+ }, null);
5894
+ };
5895
+ }
5896
+ });
5897
+ var ScrollAuto = defineComponent({
5898
+ props: {
5899
+ scrollAuto: {
5900
+ type: Boolean
5901
+ },
5902
+ onScrollAutoChange: {
5903
+ type: Function,
5904
+ default: () => () => {
5905
+ }
5906
+ }
5907
+ },
5908
+ setup(props2) {
5909
+ const ult = inject("usedLanguageText");
5910
+ return () => {
5911
+ var _a;
5912
+ return createVNode("div", {
5913
+ "class": `${prefix}-footer-item`
5914
+ }, [createVNode("label", {
5915
+ "class": `${prefix}-footer-label`,
5916
+ "onClick": () => {
5917
+ props2.onScrollAutoChange(!props2.scrollAuto);
5918
+ }
5919
+ }, [(_a = ult.value.footer) == null ? void 0 : _a.scrollAuto]), createVNode(Checkbox, {
5920
+ "checked": props2.scrollAuto,
5921
+ "onChange": props2.onScrollAutoChange
5922
+ }, null)]);
5923
+ };
5924
+ }
5925
+ });
5926
+ var Footer = defineComponent({
5927
+ name: "MDEditorFooter",
5928
+ props: {
5929
+ modelValue: {
5930
+ type: String,
5931
+ default: ""
5932
+ },
5933
+ footers: {
5934
+ type: Array,
5935
+ default: []
5936
+ },
5937
+ scrollAuto: {
5938
+ type: Boolean
5939
+ },
5940
+ onScrollAutoChange: {
5941
+ type: Function,
5942
+ default: () => () => {
5943
+ }
5944
+ },
5945
+ defFooters: {
5946
+ type: Object
5947
+ }
5948
+ },
5949
+ setup(props2) {
5950
+ const splitedItems = computed(() => {
5951
+ const moduleSplitIndex = props2.footers.indexOf("=");
5952
+ const barLeft = moduleSplitIndex === -1 ? props2.footers : props2.footers.slice(0, moduleSplitIndex);
5953
+ const barRight = moduleSplitIndex === -1 ? [] : props2.footers.slice(moduleSplitIndex, Number.MAX_SAFE_INTEGER);
5954
+ return [barLeft, barRight];
5955
+ });
5956
+ const footerRender = (name) => {
5957
+ if (allFooter.includes(name)) {
5958
+ switch (name) {
5959
+ case "mardownTotal": {
5960
+ return createVNode(MarkdownTotal, {
5961
+ "modelValue": props2.modelValue
5962
+ }, null);
5963
+ }
5964
+ case "scrollSwitch": {
5965
+ return createVNode(ScrollAuto, {
5966
+ "scrollAuto": props2.scrollAuto,
5967
+ "onScrollAutoChange": props2.onScrollAutoChange
5968
+ }, null);
5969
+ }
5970
+ }
5971
+ } else if (props2.defFooters instanceof Array) {
5972
+ return props2.defFooters[name] || "";
5973
+ } else if (props2.defFooters && props2.defFooters.children instanceof Array) {
5974
+ return props2.defFooters.children[name] || "";
5975
+ } else {
5976
+ return "";
5977
+ }
5978
+ };
5979
+ return () => {
5980
+ const LeftFooter = splitedItems.value[0].map((name) => footerRender(name));
5981
+ const RightFooter = splitedItems.value[1].map((name) => footerRender(name));
5982
+ return createVNode("div", {
5983
+ "class": `${prefix}-footer`
5984
+ }, [createVNode("div", {
5985
+ "class": `${prefix}-footer-left`
5986
+ }, [LeftFooter]), createVNode("div", {
5987
+ "class": `${prefix}-footer-right`
5988
+ }, [RightFooter])]);
5989
+ };
5990
+ }
5991
+ });
5835
5992
  const CatalogLink = defineComponent({
5836
5993
  props: {
5837
5994
  tocItem: {
@@ -5848,14 +6005,18 @@ const CatalogLink = defineComponent({
5848
6005
  default: ""
5849
6006
  }
5850
6007
  },
5851
- setup(props2) {
6008
+ setup({
6009
+ tocItem,
6010
+ markedHeadingId: markedHeadingId2,
6011
+ scrollElement
6012
+ }) {
5852
6013
  return () => createVNode("div", {
5853
6014
  "class": `${prefix}-catalog-link`,
5854
6015
  "onClick": (e) => {
5855
6016
  e.stopPropagation();
5856
- const id = props2.markedHeadingId(props2.tocItem.text, props2.tocItem.level);
6017
+ const id = markedHeadingId2(tocItem.text, tocItem.level, tocItem.index);
5857
6018
  const targetHeadEle = document.getElementById(id);
5858
- const scrollContainer = props2.scrollElement instanceof Element ? props2.scrollElement : document.querySelector(props2.scrollElement);
6019
+ const scrollContainer = scrollElement instanceof Element ? scrollElement : document.querySelector(scrollElement);
5859
6020
  if (targetHeadEle && scrollContainer) {
5860
6021
  let par = targetHeadEle.offsetParent;
5861
6022
  let offsetTop = targetHeadEle.offsetTop;
@@ -5872,14 +6033,14 @@ const CatalogLink = defineComponent({
5872
6033
  }
5873
6034
  }
5874
6035
  }, [createVNode("span", {
5875
- "title": props2.tocItem.text
5876
- }, [props2.tocItem.text]), createVNode("div", {
6036
+ "title": tocItem.text
6037
+ }, [tocItem.text]), createVNode("div", {
5877
6038
  "class": `${prefix}-catalog-wrapper`
5878
- }, [props2.tocItem.children && props2.tocItem.children.map((item) => createVNode(CatalogLink, {
5879
- "markedHeadingId": props2.markedHeadingId,
6039
+ }, [tocItem.children && tocItem.children.map((item) => createVNode(CatalogLink, {
6040
+ "markedHeadingId": markedHeadingId2,
5880
6041
  "key": item.text,
5881
6042
  "tocItem": item,
5882
- "scrollElement": props2.scrollElement
6043
+ "scrollElement": scrollElement
5883
6044
  }, null))])]);
5884
6045
  }
5885
6046
  });
@@ -5918,10 +6079,11 @@ const MdCatalog = defineComponent({
5918
6079
  state.list.forEach(({
5919
6080
  text,
5920
6081
  level
5921
- }) => {
6082
+ }, index2) => {
5922
6083
  const item = {
5923
6084
  level,
5924
- text
6085
+ text,
6086
+ index: index2 + 1
5925
6087
  };
5926
6088
  if (tocItems.length === 0) {
5927
6089
  tocItems.push(item);
@@ -6090,6 +6252,17 @@ const props = {
6090
6252
  codeTheme: {
6091
6253
  type: String,
6092
6254
  default: "atom"
6255
+ },
6256
+ footers: {
6257
+ type: Array,
6258
+ default: allFooter
6259
+ },
6260
+ scrollAuto: {
6261
+ type: Boolean,
6262
+ default: true
6263
+ },
6264
+ defFooters: {
6265
+ type: [String, Object]
6093
6266
  }
6094
6267
  };
6095
6268
  const Editor = defineComponent({
@@ -6101,6 +6274,9 @@ const Editor = defineComponent({
6101
6274
  editorId
6102
6275
  } = props2;
6103
6276
  const extension = Editor.extension || {};
6277
+ const state = reactive({
6278
+ scrollAuto: props2.scrollAuto
6279
+ });
6104
6280
  useKeyBoard(props2, context);
6105
6281
  useProvide(props2, extension);
6106
6282
  useExpansion(props2, extension);
@@ -6110,11 +6286,15 @@ const Editor = defineComponent({
6110
6286
  bus.clear(editorId);
6111
6287
  });
6112
6288
  return () => {
6113
- var _a;
6289
+ var _a, _b;
6114
6290
  const defToolbars = getSlot({
6115
6291
  props: props2,
6116
6292
  ctx: context
6117
6293
  }, "defToolbars");
6294
+ const defFooters = getSlot({
6295
+ props: props2,
6296
+ ctx: context
6297
+ }, "defFooters");
6118
6298
  return createVNode("div", {
6119
6299
  "id": editorId,
6120
6300
  "class": [prefix, props2.class, props2.theme === "dark" && `${prefix}-dark`, setting.fullscreen || setting.pageFullScreen ? `${prefix}-fullscreen` : "", props2.previewOnly && `${prefix}-previewOnly`],
@@ -6157,7 +6337,14 @@ const Editor = defineComponent({
6157
6337
  "sanitize": props2.sanitize,
6158
6338
  "placeholder": props2.placeholder,
6159
6339
  "noKatex": props2.noKatex,
6160
- "mermaidTemplate": (_a = extension == null ? void 0 : extension.editorConfig) == null ? void 0 : _a.mermaidTemplate
6340
+ "mermaidTemplate": (_a = extension == null ? void 0 : extension.editorConfig) == null ? void 0 : _a.mermaidTemplate,
6341
+ "scrollAuto": state.scrollAuto
6342
+ }, null), !props2.previewOnly && ((_b = props2.footers) == null ? void 0 : _b.length) > 0 && createVNode(Footer, {
6343
+ "modelValue": props2.modelValue,
6344
+ "footers": props2.footers,
6345
+ "defFooters": defFooters,
6346
+ "scrollAuto": state.scrollAuto,
6347
+ "onScrollAutoChange": (v) => state.scrollAuto = v
6161
6348
  }, null), catalogShow.value && createVNode(MdCatalog, {
6162
6349
  "theme": props2.theme,
6163
6350
  "style": {