md-editor-v3 5.3.0-1 → 5.3.0-2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -2745,14 +2745,17 @@ const useCodeMirror = (props2) => {
2745
2745
  };
2746
2746
  };
2747
2747
  const useResize = (props2, contentRef, resizeRef) => {
2748
+ const compatibledInputBoxWidth = vue.computed(() => {
2749
+ return /px$/.test(`${props2.inputBoxWidth}`) ? "50%" : props2.inputBoxWidth;
2750
+ });
2748
2751
  const state2 = vue.reactive({
2749
- resizedWidth: props2.inputBoxWidth
2752
+ resizedWidth: compatibledInputBoxWidth.value
2750
2753
  });
2751
2754
  const inputWrapperStyle = vue.reactive({
2752
- width: props2.inputBoxWidth
2755
+ width: compatibledInputBoxWidth.value
2753
2756
  });
2754
2757
  const resizeOperateStyle = vue.reactive({
2755
- left: props2.inputBoxWidth,
2758
+ left: compatibledInputBoxWidth.value,
2756
2759
  display: "initial"
2757
2760
  });
2758
2761
  const resizeMousemove = (e) => {
@@ -2760,12 +2763,12 @@ const useResize = (props2, contentRef, resizeRef) => {
2760
2763
  const maxWidth = ((_a = contentRef.value) == null ? void 0 : _a.offsetWidth) || 0;
2761
2764
  const contentX = ((_b = contentRef.value) == null ? void 0 : _b.getBoundingClientRect().x) || 0;
2762
2765
  let nextWidth = e.x - contentX;
2763
- if (nextWidth < config.MinInputBoxWidth) {
2764
- nextWidth = config.MinInputBoxWidth;
2765
- } else if (nextWidth > maxWidth - config.MinInputBoxWidth) {
2766
- nextWidth = maxWidth - config.MinInputBoxWidth;
2766
+ if (nextWidth / maxWidth < config.MinInputBoxWidth) {
2767
+ nextWidth = maxWidth * config.MinInputBoxWidth;
2768
+ } else if (nextWidth > maxWidth - maxWidth * config.MinInputBoxWidth) {
2769
+ nextWidth = maxWidth - maxWidth * config.MinInputBoxWidth;
2767
2770
  }
2768
- const ibw = `${nextWidth}px`;
2771
+ const ibw = `${nextWidth / maxWidth * 100}%`;
2769
2772
  inputWrapperStyle.width = ibw;
2770
2773
  resizeOperateStyle.left = ibw;
2771
2774
  state2.resizedWidth = ibw;
@@ -2793,16 +2796,11 @@ const useResize = (props2, contentRef, resizeRef) => {
2793
2796
  document.removeEventListener("mousedown", resizeMousedown);
2794
2797
  document.removeEventListener("mouseup", resizeMouseup);
2795
2798
  });
2796
- vue.watch(
2797
- () => props2.inputBoxWidth,
2798
- (nVal) => {
2799
- if (nVal) {
2800
- state2.resizedWidth = nVal;
2801
- inputWrapperStyle.width = nVal;
2802
- resizeOperateStyle.left = nVal;
2803
- }
2804
- }
2805
- );
2799
+ vue.watch([compatibledInputBoxWidth], ([nVal]) => {
2800
+ state2.resizedWidth = nVal;
2801
+ inputWrapperStyle.width = nVal;
2802
+ resizeOperateStyle.left = nVal;
2803
+ });
2806
2804
  vue.watch(
2807
2805
  [
2808
2806
  vue.toRef(props2.setting, "htmlPreview"),
@@ -2866,7 +2864,9 @@ const Content = /* @__PURE__ */ vue.defineComponent({
2866
2864
  });
2867
2865
  return () => {
2868
2866
  return vue.createVNode("div", {
2869
- "class": `${config.prefix}-content`,
2867
+ "class": `${config.prefix}-content`
2868
+ }, [vue.createVNode("div", {
2869
+ "class": `${config.prefix}-content-wrapper`,
2870
2870
  "ref": contentRef
2871
2871
  }, [vue.createVNode("div", {
2872
2872
  "class": `${config.prefix}-input-wrapper`,
@@ -2896,9 +2896,9 @@ const Content = /* @__PURE__ */ vue.defineComponent({
2896
2896
  "codeFoldable": props2.codeFoldable,
2897
2897
  "autoFoldThreshold": props2.autoFoldThreshold,
2898
2898
  "onRemount": props2.onRemount
2899
- }, null), props2.catalogVisible && vue.createVNode(MdCatalog.MdCatalog, {
2899
+ }, null)]), props2.catalogVisible && vue.createVNode(MdCatalog.MdCatalog, {
2900
2900
  "theme": props2.theme,
2901
- "class": `${config.prefix}-catalog-editor`,
2901
+ "class": `${config.prefix}-catalog-editor ${config.prefix}-catalog-${props2.catalogLayout}`,
2902
2902
  "editorId": editorId,
2903
2903
  "mdHeadingId": props2.mdHeadingId,
2904
2904
  "key": "internal-catalog",
@@ -3247,7 +3247,8 @@ const Editor = /* @__PURE__ */ vue.defineComponent({
3247
3247
  props2.onRemount();
3248
3248
  }
3249
3249
  ctx.emit("onRemount");
3250
- }
3250
+ },
3251
+ "catalogLayout": props2.catalogLayout
3251
3252
  }, null), props2.footers.length > 0 && vue.createVNode(Footer, {
3252
3253
  "modelValue": props2.modelValue,
3253
3254
  "footers": props2.footers,
@@ -429,7 +429,7 @@ const config = (option) => {
429
429
  }
430
430
  });
431
431
  };
432
- const MinInputBoxWidth = 170;
432
+ const MinInputBoxWidth = 0.1;
433
433
  exports.MinInputBoxWidth = MinInputBoxWidth;
434
434
  exports.allFooter = allFooter;
435
435
  exports.allToolbar = allToolbar;
@@ -1251,6 +1251,9 @@ const contentProps = {
1251
1251
  transformImgUrl: {
1252
1252
  type: Function,
1253
1253
  default: (t) => t
1254
+ },
1255
+ catalogLayout: {
1256
+ type: String
1254
1257
  }
1255
1258
  };
1256
1259
  const ContentPreview = /* @__PURE__ */ vue.defineComponent({
@@ -2202,6 +2205,20 @@ const editorProps = {
2202
2205
  transformImgUrl: {
2203
2206
  type: Function,
2204
2207
  default: (t) => t
2208
+ },
2209
+ /**
2210
+ * 内置的目录显示的状态
2211
+ *
2212
+ * 'fixed': 悬浮在内容上方
2213
+ * 'flat': 展示在右侧
2214
+ *
2215
+ * \>=5.3.0
2216
+ *
2217
+ * @default 'fixed'
2218
+ */
2219
+ catalogLayout: {
2220
+ type: String,
2221
+ default: "fixed"
2205
2222
  }
2206
2223
  };
2207
2224
  const mdPreviewEmits = [
@@ -586,7 +586,7 @@ const MdCatalog = /* @__PURE__ */ vue.defineComponent({
586
586
  const getEditorView = (view) => {
587
587
  editorViewRef.value = view;
588
588
  };
589
- vue.watch(() => props2.syncWith, () => {
589
+ vue.watch([() => props2.syncWith, editorViewRef], () => {
590
590
  catalogChangedHandler(state.list);
591
591
  });
592
592
  vue.onMounted(() => {
@@ -2744,14 +2744,17 @@ const useCodeMirror = (props2) => {
2744
2744
  };
2745
2745
  };
2746
2746
  const useResize = (props2, contentRef, resizeRef) => {
2747
+ const compatibledInputBoxWidth = computed(() => {
2748
+ return /px$/.test(`${props2.inputBoxWidth}`) ? "50%" : props2.inputBoxWidth;
2749
+ });
2747
2750
  const state = reactive({
2748
- resizedWidth: props2.inputBoxWidth
2751
+ resizedWidth: compatibledInputBoxWidth.value
2749
2752
  });
2750
2753
  const inputWrapperStyle = reactive({
2751
- width: props2.inputBoxWidth
2754
+ width: compatibledInputBoxWidth.value
2752
2755
  });
2753
2756
  const resizeOperateStyle = reactive({
2754
- left: props2.inputBoxWidth,
2757
+ left: compatibledInputBoxWidth.value,
2755
2758
  display: "initial"
2756
2759
  });
2757
2760
  const resizeMousemove = (e) => {
@@ -2759,12 +2762,12 @@ const useResize = (props2, contentRef, resizeRef) => {
2759
2762
  const maxWidth = ((_a = contentRef.value) == null ? void 0 : _a.offsetWidth) || 0;
2760
2763
  const contentX = ((_b = contentRef.value) == null ? void 0 : _b.getBoundingClientRect().x) || 0;
2761
2764
  let nextWidth = e.x - contentX;
2762
- if (nextWidth < MinInputBoxWidth) {
2763
- nextWidth = MinInputBoxWidth;
2764
- } else if (nextWidth > maxWidth - MinInputBoxWidth) {
2765
- nextWidth = maxWidth - MinInputBoxWidth;
2765
+ if (nextWidth / maxWidth < MinInputBoxWidth) {
2766
+ nextWidth = maxWidth * MinInputBoxWidth;
2767
+ } else if (nextWidth > maxWidth - maxWidth * MinInputBoxWidth) {
2768
+ nextWidth = maxWidth - maxWidth * MinInputBoxWidth;
2766
2769
  }
2767
- const ibw = `${nextWidth}px`;
2770
+ const ibw = `${nextWidth / maxWidth * 100}%`;
2768
2771
  inputWrapperStyle.width = ibw;
2769
2772
  resizeOperateStyle.left = ibw;
2770
2773
  state.resizedWidth = ibw;
@@ -2792,16 +2795,11 @@ const useResize = (props2, contentRef, resizeRef) => {
2792
2795
  document.removeEventListener("mousedown", resizeMousedown);
2793
2796
  document.removeEventListener("mouseup", resizeMouseup);
2794
2797
  });
2795
- watch(
2796
- () => props2.inputBoxWidth,
2797
- (nVal) => {
2798
- if (nVal) {
2799
- state.resizedWidth = nVal;
2800
- inputWrapperStyle.width = nVal;
2801
- resizeOperateStyle.left = nVal;
2802
- }
2803
- }
2804
- );
2798
+ watch([compatibledInputBoxWidth], ([nVal]) => {
2799
+ state.resizedWidth = nVal;
2800
+ inputWrapperStyle.width = nVal;
2801
+ resizeOperateStyle.left = nVal;
2802
+ });
2805
2803
  watch(
2806
2804
  [
2807
2805
  toRef(props2.setting, "htmlPreview"),
@@ -2865,7 +2863,9 @@ const Content = /* @__PURE__ */ defineComponent({
2865
2863
  });
2866
2864
  return () => {
2867
2865
  return createVNode("div", {
2868
- "class": `${prefix}-content`,
2866
+ "class": `${prefix}-content`
2867
+ }, [createVNode("div", {
2868
+ "class": `${prefix}-content-wrapper`,
2869
2869
  "ref": contentRef
2870
2870
  }, [createVNode("div", {
2871
2871
  "class": `${prefix}-input-wrapper`,
@@ -2895,9 +2895,9 @@ const Content = /* @__PURE__ */ defineComponent({
2895
2895
  "codeFoldable": props2.codeFoldable,
2896
2896
  "autoFoldThreshold": props2.autoFoldThreshold,
2897
2897
  "onRemount": props2.onRemount
2898
- }, null), props2.catalogVisible && createVNode(MdCatalog, {
2898
+ }, null)]), props2.catalogVisible && createVNode(MdCatalog, {
2899
2899
  "theme": props2.theme,
2900
- "class": `${prefix}-catalog-editor`,
2900
+ "class": `${prefix}-catalog-editor ${prefix}-catalog-${props2.catalogLayout}`,
2901
2901
  "editorId": editorId,
2902
2902
  "mdHeadingId": props2.mdHeadingId,
2903
2903
  "key": "internal-catalog",
@@ -3246,7 +3246,8 @@ const Editor = /* @__PURE__ */ defineComponent({
3246
3246
  props2.onRemount();
3247
3247
  }
3248
3248
  ctx.emit("onRemount");
3249
- }
3249
+ },
3250
+ "catalogLayout": props2.catalogLayout
3250
3251
  }, null), props2.footers.length > 0 && createVNode(Footer, {
3251
3252
  "modelValue": props2.modelValue,
3252
3253
  "footers": props2.footers,
@@ -428,7 +428,7 @@ const config = (option) => {
428
428
  }
429
429
  });
430
430
  };
431
- const MinInputBoxWidth = 170;
431
+ const MinInputBoxWidth = 0.1;
432
432
  export {
433
433
  MinInputBoxWidth as M,
434
434
  allToolbar as a,
@@ -1250,6 +1250,9 @@ const contentProps = {
1250
1250
  transformImgUrl: {
1251
1251
  type: Function,
1252
1252
  default: (t) => t
1253
+ },
1254
+ catalogLayout: {
1255
+ type: String
1253
1256
  }
1254
1257
  };
1255
1258
  const ContentPreview = /* @__PURE__ */ defineComponent({
@@ -2201,6 +2204,20 @@ const editorProps = {
2201
2204
  transformImgUrl: {
2202
2205
  type: Function,
2203
2206
  default: (t) => t
2207
+ },
2208
+ /**
2209
+ * 内置的目录显示的状态
2210
+ *
2211
+ * 'fixed': 悬浮在内容上方
2212
+ * 'flat': 展示在右侧
2213
+ *
2214
+ * \>=5.3.0
2215
+ *
2216
+ * @default 'fixed'
2217
+ */
2218
+ catalogLayout: {
2219
+ type: String,
2220
+ default: "fixed"
2204
2221
  }
2205
2222
  };
2206
2223
  const mdPreviewEmits = [
@@ -585,7 +585,7 @@ const MdCatalog = /* @__PURE__ */ defineComponent({
585
585
  const getEditorView = (view) => {
586
586
  editorViewRef.value = view;
587
587
  };
588
- watch(() => props2.syncWith, () => {
588
+ watch([() => props2.syncWith, editorViewRef], () => {
589
589
  catalogChangedHandler(state.list);
590
590
  });
591
591
  onMounted(() => {
package/lib/preview.css CHANGED
@@ -13,12 +13,9 @@
13
13
  --md-scrollbar-thumb-color: #0000004d;
14
14
  --md-scrollbar-thumb-hover-color: #00000059;
15
15
  --md-scrollbar-thumb-active-color: #00000061;
16
- position: absolute;
17
16
  overflow: auto;
18
- top: 0;
19
- right: 0;
20
17
  height: 100%;
21
- background-color: var(--md-bk-color-outstand);
18
+ background-color: var(--md-bk-color);
22
19
  border-left: 1px solid var(--md-border-color);
23
20
  width: 200px;
24
21
  box-sizing: border-box;
@@ -30,6 +27,13 @@
30
27
  list-style: none;
31
28
  font-feature-settings: 'tnum';
32
29
  z-index: 2;
30
+ }.md-editor-catalog-fixed {
31
+ position: absolute;
32
+ top: 0;
33
+ right: 0;
34
+ }.md-editor-catalog-flat {
35
+ position: initial;
36
+ flex-shrink: 0;
33
37
  }.md-editor-catalog-indicator {
34
38
  height: 18px;
35
39
  width: 4px;
package/lib/style.css CHANGED
@@ -120,6 +120,11 @@
120
120
  flex: 1;
121
121
  height: 0;
122
122
  flex-shrink: 0;
123
+ }.md-editor-content-wrapper {
124
+ display: flex;
125
+ flex: 1;
126
+ width: 0;
127
+ position: relative;
123
128
  }.md-editor-resize-operate {
124
129
  position: absolute;
125
130
  width: 2px;
@@ -458,12 +463,9 @@
458
463
  --md-scrollbar-thumb-color: #0000004d;
459
464
  --md-scrollbar-thumb-hover-color: #00000059;
460
465
  --md-scrollbar-thumb-active-color: #00000061;
461
- position: absolute;
462
466
  overflow: auto;
463
- top: 0;
464
- right: 0;
465
467
  height: 100%;
466
- background-color: var(--md-bk-color-outstand);
468
+ background-color: var(--md-bk-color);
467
469
  border-left: 1px solid var(--md-border-color);
468
470
  width: 200px;
469
471
  box-sizing: border-box;
@@ -475,6 +477,13 @@
475
477
  list-style: none;
476
478
  font-feature-settings: 'tnum';
477
479
  z-index: 2;
480
+ }.md-editor-catalog-fixed {
481
+ position: absolute;
482
+ top: 0;
483
+ right: 0;
484
+ }.md-editor-catalog-flat {
485
+ position: initial;
486
+ flex-shrink: 0;
478
487
  }.md-editor-catalog-indicator {
479
488
  height: 18px;
480
489
  width: 4px;
@@ -21,6 +21,7 @@ declare const Editor: import("vue").DefineComponent<{
21
21
  readonly showToolbarName: boolean;
22
22
  readonly inputBoxWidth: string;
23
23
  readonly transformImgUrl: (t: string) => string | Promise<string>;
24
+ readonly catalogLayout: "fixed" | "flat";
24
25
  readonly modelValue: string;
25
26
  readonly theme: import("./type").Themes;
26
27
  readonly showCodeRowNumber: boolean;
@@ -292,6 +293,7 @@ declare const Editor: import("vue").DefineComponent<{
292
293
  readonly showToolbarName: boolean;
293
294
  readonly inputBoxWidth: string;
294
295
  readonly transformImgUrl: (t: string) => string | Promise<string>;
296
+ readonly catalogLayout: "fixed" | "flat";
295
297
  readonly modelValue: string;
296
298
  readonly theme: import("./type").Themes;
297
299
  readonly showCodeRowNumber: boolean;
@@ -598,6 +600,7 @@ declare const Editor: import("vue").DefineComponent<{
598
600
  showToolbarName: boolean;
599
601
  inputBoxWidth: string;
600
602
  transformImgUrl: (t: string) => string | Promise<string>;
603
+ catalogLayout: "fixed" | "flat";
601
604
  modelValue: string;
602
605
  theme: import("./type").Themes;
603
606
  editorId: string;
@@ -26,5 +26,6 @@ export declare const configOption: ConfigOption;
26
26
  export declare const config: Config;
27
27
  /**
28
28
  * 拖拽时最小的宽度
29
+ * 5.3.0开始使用百分比,不能小于10%
29
30
  */
30
- export declare const MinInputBoxWidth = 170;
31
+ export declare const MinInputBoxWidth = 0.1;
@@ -27,6 +27,7 @@ declare const _default: import("vue").DefineComponent<{
27
27
  readonly autoDetectCode: boolean | undefined;
28
28
  readonly completions: import("@codemirror/autocomplete").CompletionSource[] | undefined;
29
29
  readonly inputBoxWidth: string | undefined;
30
+ readonly catalogLayout: "fixed" | "flat" | undefined;
30
31
  readonly noImgZoomIn: boolean | undefined;
31
32
  readonly sanitizeMermaid: ((h: string) => Promise<string>) | undefined;
32
33
  readonly codeFoldable: boolean | undefined;
@@ -64,6 +65,7 @@ declare const _default: import("vue").DefineComponent<{
64
65
  readonly autoDetectCode: boolean | undefined;
65
66
  readonly completions: import("@codemirror/autocomplete").CompletionSource[] | undefined;
66
67
  readonly inputBoxWidth: string | undefined;
68
+ readonly catalogLayout: "fixed" | "flat" | undefined;
67
69
  readonly noImgZoomIn: boolean | undefined;
68
70
  readonly sanitizeMermaid: ((h: string) => Promise<string>) | undefined;
69
71
  readonly codeFoldable: boolean | undefined;
@@ -140,6 +140,9 @@ export declare const contentProps: {
140
140
  type: PropType<(t: string) => string | Promise<string>>;
141
141
  default: (t: string) => string;
142
142
  };
143
+ catalogLayout: {
144
+ type: PropType<"fixed" | "flat">;
145
+ };
143
146
  modelValue: {
144
147
  type: PropType<string>;
145
148
  default: string;
@@ -500,6 +500,20 @@ export declare const editorProps: {
500
500
  type: PropType<(t: string) => string | Promise<string>>;
501
501
  default: (t: string) => string;
502
502
  };
503
+ /**
504
+ * 内置的目录显示的状态
505
+ *
506
+ * 'fixed': 悬浮在内容上方
507
+ * 'flat': 展示在右侧
508
+ *
509
+ * \>=5.3.0
510
+ *
511
+ * @default 'fixed'
512
+ */
513
+ catalogLayout: {
514
+ type: PropType<"fixed" | "flat">;
515
+ default: string;
516
+ };
503
517
  /**
504
518
  * markdown content.
505
519
  *