md-editor-v3 4.21.1 → 4.21.3

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 (38) hide show
  1. package/lib/cjs/MdEditor.cjs +14 -8
  2. package/lib/cjs/ModalToolbar.cjs +26 -11
  3. package/lib/cjs/NormalToolbar.cjs +18 -5
  4. package/lib/cjs/chunks/config.cjs +178 -186
  5. package/lib/cjs/chunks/dom.cjs +64 -52
  6. package/lib/cjs/chunks/index.cjs +66 -42
  7. package/lib/cjs/chunks/index2.cjs +22 -9
  8. package/lib/cjs/chunks/index3.cjs +8 -4
  9. package/lib/cjs/index.cjs +2 -1
  10. package/lib/es/MdEditor.mjs +14 -8
  11. package/lib/es/ModalToolbar.mjs +26 -11
  12. package/lib/es/NormalToolbar.mjs +18 -5
  13. package/lib/es/chunks/config.mjs +178 -186
  14. package/lib/es/chunks/dom.mjs +64 -52
  15. package/lib/es/chunks/index.mjs +66 -42
  16. package/lib/es/chunks/index2.mjs +22 -9
  17. package/lib/es/chunks/index3.mjs +8 -4
  18. package/lib/es/index.mjs +2 -1
  19. package/lib/types/DropdownToolbar/DropdownToolbar.d.ts +40 -0
  20. package/lib/types/DropdownToolbar/index.d.ts +94 -0
  21. package/lib/types/MdCatalog/MdCatalog.d.ts +12 -0
  22. package/lib/types/MdCatalog/index.d.ts +28 -0
  23. package/lib/types/MdEditor/Editor.d.ts +70 -0
  24. package/lib/types/MdEditor/config.d.ts +7 -7
  25. package/lib/types/MdEditor/index.d.ts +166 -0
  26. package/lib/types/MdEditor/layouts/Toolbar/index.d.ts +6 -0
  27. package/lib/types/MdEditor/layouts/Toolbar/props.d.ts +3 -0
  28. package/lib/types/MdEditor/props.d.ts +26 -0
  29. package/lib/types/MdPreview/MdPreview.d.ts +12 -0
  30. package/lib/types/MdPreview/index.d.ts +28 -0
  31. package/lib/types/ModalToolbar/ModalToolbar.d.ts +44 -0
  32. package/lib/types/ModalToolbar/index.d.ts +102 -0
  33. package/lib/types/NormalFooterToolbar/NormalFooterToolbar.d.ts +5 -1
  34. package/lib/types/NormalFooterToolbar/index.d.ts +13 -3
  35. package/lib/types/NormalToolbar/NormalToolbar.d.ts +35 -0
  36. package/lib/types/NormalToolbar/index.d.ts +79 -0
  37. package/lib/umd/index.js +42 -42
  38. package/package.json +1 -1
@@ -229,31 +229,33 @@ const useMermaid = (props) => {
229
229
  await Promise.allSettled(
230
230
  Array.from(mermaidSourceEles).map((ele) => {
231
231
  const handler = async (item) => {
232
+ var _a;
232
233
  let mermaidHtml = mermaidCache.get(item.innerText);
233
234
  if (!mermaidHtml) {
234
235
  const idRand = randomId();
235
- const render = mermaidRef.value.renderAsync || mermaidRef.value.render;
236
- let svg = "";
236
+ let result = { svg: "" };
237
237
  try {
238
- svg = await render(idRand, item.innerText, svgContainingElement);
239
- } catch (error) {
238
+ result = await mermaidRef.value.render(
239
+ idRand,
240
+ item.innerText,
241
+ svgContainingElement
242
+ );
243
+ mermaidHtml = await props.sanitizeMermaid(result.svg);
244
+ const p = document.createElement("p");
245
+ p.className = `${prefix}-mermaid`;
246
+ p.setAttribute("data-processed", "");
247
+ p.innerHTML = mermaidHtml;
248
+ (_a = p.children[0]) == null ? void 0 : _a.removeAttribute("height");
249
+ mermaidCache.set(item.innerText, p.innerHTML);
250
+ if (item.dataset.line !== void 0) {
251
+ p.dataset.line = item.dataset.line;
252
+ }
253
+ item.replaceWith(p);
254
+ } catch {
255
+ }
256
+ if (--count === 0) {
257
+ svgContainingElement.remove();
240
258
  }
241
- mermaidHtml = await props.sanitizeMermaid(
242
- typeof svg === "string" ? svg : svg.svg
243
- );
244
- }
245
- const p = document.createElement("p");
246
- p.className = `${prefix}-mermaid`;
247
- p.setAttribute("data-processed", "");
248
- p.innerHTML = mermaidHtml;
249
- p.children[0].removeAttribute("height");
250
- mermaidCache.set(item.innerText, p.innerHTML);
251
- if (item.dataset.line !== void 0) {
252
- p.dataset.line = item.dataset.line;
253
- }
254
- item.replaceWith(p);
255
- if (--count === 0) {
256
- svgContainingElement.remove();
257
259
  }
258
260
  };
259
261
  return handler(ele);
@@ -3000,7 +3002,8 @@ const mdPreviewProps = {
3000
3002
  * input回调事件
3001
3003
  */
3002
3004
  onChange: {
3003
- type: Function
3005
+ type: Function,
3006
+ default: void 0
3004
3007
  },
3005
3008
  /**
3006
3009
  * 主题,支持light和dark
@@ -3033,13 +3036,15 @@ const mdPreviewProps = {
3033
3036
  * html变化事件
3034
3037
  */
3035
3038
  onHtmlChanged: {
3036
- type: Function
3039
+ type: Function,
3040
+ default: void 0
3037
3041
  },
3038
3042
  /**
3039
3043
  * 获取目录结构
3040
3044
  */
3041
3045
  onGetCatalog: {
3042
- type: Function
3046
+ type: Function,
3047
+ default: void 0
3043
3048
  },
3044
3049
  /**
3045
3050
  * 编辑器唯一标识
@@ -3128,7 +3133,8 @@ const mdPreviewProps = {
3128
3133
  * @default false
3129
3134
  */
3130
3135
  noIconfont: {
3131
- type: Boolean
3136
+ type: Boolean,
3137
+ default: void 0
3132
3138
  },
3133
3139
  /**
3134
3140
  * 复制代码格式化方法
@@ -3206,13 +3212,15 @@ const editorProps = {
3206
3212
  * input回调事件
3207
3213
  */
3208
3214
  onSave: {
3209
- type: Function
3215
+ type: Function,
3216
+ default: void 0
3210
3217
  },
3211
3218
  /**
3212
3219
  * 上传图片事件
3213
3220
  */
3214
3221
  onUploadImg: {
3215
- type: Function
3222
+ type: Function,
3223
+ default: void 0
3216
3224
  },
3217
3225
  /**
3218
3226
  * 是否页面内全屏
@@ -3296,7 +3304,8 @@ const editorProps = {
3296
3304
  * @default [6, 4]
3297
3305
  */
3298
3306
  tableShape: {
3299
- type: Array
3307
+ type: Array,
3308
+ default: [6, 4]
3300
3309
  },
3301
3310
  /**
3302
3311
  * 空提示
@@ -3311,13 +3320,15 @@ const editorProps = {
3311
3320
  * 自定义的工具栏列表
3312
3321
  */
3313
3322
  defToolbars: {
3314
- type: [String, Object]
3323
+ type: [String, Object],
3324
+ default: void 0
3315
3325
  },
3316
3326
  /**
3317
3327
  * 内部错误捕获
3318
3328
  */
3319
3329
  onError: {
3320
- type: Function
3330
+ type: Function,
3331
+ default: void 0
3321
3332
  },
3322
3333
  /**
3323
3334
  * 页脚列表显示顺序
@@ -3339,7 +3350,8 @@ const editorProps = {
3339
3350
  * 自定义的也叫工具组件列表
3340
3351
  */
3341
3352
  defFooters: {
3342
- type: [String, Object]
3353
+ type: [String, Object],
3354
+ default: void 0
3343
3355
  },
3344
3356
  /**
3345
3357
  * 是否禁用上传图片
@@ -3347,7 +3359,8 @@ const editorProps = {
3347
3359
  * @default false
3348
3360
  */
3349
3361
  noUploadImg: {
3350
- type: Boolean
3362
+ type: Boolean,
3363
+ default: false
3351
3364
  },
3352
3365
  /**
3353
3366
  * 文本区域自动获得焦点
@@ -3355,7 +3368,8 @@ const editorProps = {
3355
3368
  * @default false
3356
3369
  */
3357
3370
  autoFocus: {
3358
- type: Boolean
3371
+ type: Boolean,
3372
+ default: false
3359
3373
  },
3360
3374
  /**
3361
3375
  * 禁用文本区域
@@ -3363,7 +3377,8 @@ const editorProps = {
3363
3377
  * @default false
3364
3378
  */
3365
3379
  disabled: {
3366
- type: Boolean
3380
+ type: Boolean,
3381
+ default: false
3367
3382
  },
3368
3383
  /**
3369
3384
  * 文本区域为只读
@@ -3371,13 +3386,15 @@ const editorProps = {
3371
3386
  * @default false
3372
3387
  */
3373
3388
  readOnly: {
3374
- type: Boolean
3389
+ type: Boolean,
3390
+ default: false
3375
3391
  },
3376
3392
  /**
3377
3393
  * 文本区域允许的最大字符数
3378
3394
  */
3379
3395
  maxLength: {
3380
- type: Number
3396
+ type: Number,
3397
+ default: void 0
3381
3398
  },
3382
3399
  /**
3383
3400
  * 是否启用自动识别粘贴代码类别
@@ -3386,19 +3403,22 @@ const editorProps = {
3386
3403
  * @default false
3387
3404
  */
3388
3405
  autoDetectCode: {
3389
- type: Boolean
3406
+ type: Boolean,
3407
+ default: false
3390
3408
  },
3391
3409
  /**
3392
3410
  * 输入框失去焦点时触发事件
3393
3411
  */
3394
3412
  onBlur: {
3395
- type: Function
3413
+ type: Function,
3414
+ default: void 0
3396
3415
  },
3397
3416
  /**
3398
3417
  * 输入框获得焦点时触发事件
3399
3418
  */
3400
3419
  onFocus: {
3401
- type: Function
3420
+ type: Function,
3421
+ default: void 0
3402
3422
  },
3403
3423
  /**
3404
3424
  * @codemirror/autocomplete匹配关键词的方法列表
@@ -3411,7 +3431,8 @@ const editorProps = {
3411
3431
  * })
3412
3432
  */
3413
3433
  completions: {
3414
- type: Array
3434
+ type: Array,
3435
+ default: void 0
3415
3436
  },
3416
3437
  /**
3417
3438
  * 是否在工具栏下面显示对应的文字名称
@@ -3426,10 +3447,12 @@ const editorProps = {
3426
3447
  * 字符输入事件
3427
3448
  */
3428
3449
  onInput: {
3429
- type: Function
3450
+ type: Function,
3451
+ default: void 0
3430
3452
  },
3431
3453
  onDrop: {
3432
- type: Function
3454
+ type: Function,
3455
+ default: void 0
3433
3456
  },
3434
3457
  /**
3435
3458
  * 输入框的默认宽度
@@ -3445,7 +3468,8 @@ const editorProps = {
3445
3468
  * 输入框宽度变化事件
3446
3469
  */
3447
3470
  onInputBoxWitdhChange: {
3448
- type: Function
3471
+ type: Function,
3472
+ default: void 0
3449
3473
  },
3450
3474
  /**
3451
3475
  * 替换粘贴的图片链接
@@ -128,39 +128,52 @@ const props = {
128
128
  default: ""
129
129
  },
130
130
  visible: {
131
- type: Boolean
131
+ type: Boolean,
132
+ default: void 0
132
133
  },
133
134
  // 展示在工具栏的内容,通常是个图标
134
135
  trigger: {
135
- type: [String, Object]
136
+ type: [String, Object],
137
+ default: void 0
136
138
  },
137
139
  onChange: {
138
- type: Function
140
+ type: Function,
141
+ default: void 0
139
142
  },
140
143
  // 下拉框中的内容
141
144
  overlay: {
142
- type: [String, Object]
145
+ type: [String, Object],
146
+ default: void 0
143
147
  },
144
148
  /**
145
149
  * ==没有意义,仅用于规避克隆组件自动嵌入insert方法时,传入的是该组件而产生的waring
146
150
  */
147
151
  insert: {
148
- type: Function
152
+ type: Function,
153
+ default: void 0
149
154
  },
150
155
  language: {
151
- type: String
156
+ type: String,
157
+ default: void 0
152
158
  },
153
159
  theme: {
154
- type: String
160
+ type: String,
161
+ default: void 0
155
162
  },
156
163
  previewTheme: {
157
- type: String
164
+ type: String,
165
+ default: void 0
166
+ },
167
+ codeTheme: {
168
+ type: String,
169
+ default: void 0
158
170
  },
159
171
  /**
160
172
  * ==结束
161
173
  */
162
174
  default: {
163
- type: [String, Object]
175
+ type: [String, Object],
176
+ default: void 0
164
177
  }
165
178
  };
166
179
  const DropdownToolbar = /* @__PURE__ */ defineComponent({
@@ -353,7 +353,8 @@ const props = {
353
353
  * 编辑器的Id,务必与需要绑定的编辑器Id相同
354
354
  */
355
355
  editorId: {
356
- type: String
356
+ type: String,
357
+ default: void 0
357
358
  },
358
359
  class: {
359
360
  type: String,
@@ -370,7 +371,8 @@ const props = {
370
371
  * 默认:#md-editor-preview-wrapper
371
372
  */
372
373
  scrollElement: {
373
- type: [String, Object]
374
+ type: [String, Object],
375
+ default: void 0
374
376
  },
375
377
  theme: {
376
378
  type: String,
@@ -395,10 +397,12 @@ const props = {
395
397
  default: 0
396
398
  },
397
399
  onClick: {
398
- type: Function
400
+ type: Function,
401
+ default: void 0
399
402
  },
400
403
  onActive: {
401
- type: Function
404
+ type: Function,
405
+ default: void 0
402
406
  },
403
407
  /**
404
408
  * 滚动容器是否在web component中,默认不在
package/lib/es/index.mjs CHANGED
@@ -12,7 +12,8 @@ import { d, b, c, e, i, a } from "./chunks/config.mjs";
12
12
  import { en_US, zh_CN } from "./config.mjs";
13
13
  const props = {
14
14
  onClick: {
15
- type: Function
15
+ type: Function,
16
+ default: void 0
16
17
  }
17
18
  };
18
19
  const NormalFooterToolbar = /* @__PURE__ */ defineComponent({
@@ -7,40 +7,53 @@ declare const _default: import("vue").DefineComponent<{
7
7
  };
8
8
  visible: {
9
9
  type: PropType<boolean>;
10
+ default: undefined;
10
11
  };
11
12
  trigger: {
12
13
  type: PropType<string | VNode<import("vue").RendererNode, import("vue").RendererElement, {
13
14
  [key: string]: any;
14
15
  }>>;
16
+ default: undefined;
15
17
  };
16
18
  onChange: {
17
19
  type: PropType<(visible: boolean) => void>;
20
+ default: undefined;
18
21
  };
19
22
  overlay: {
20
23
  type: PropType<string | VNode<import("vue").RendererNode, import("vue").RendererElement, {
21
24
  [key: string]: any;
22
25
  }>>;
26
+ default: undefined;
23
27
  };
24
28
  /**
25
29
  * ==没有意义,仅用于规避克隆组件自动嵌入insert方法时,传入的是该组件而产生的waring
26
30
  */
27
31
  insert: {
28
32
  type: PropType<() => void>;
33
+ default: undefined;
29
34
  };
30
35
  language: {
31
36
  type: PropType<string>;
37
+ default: undefined;
32
38
  };
33
39
  theme: {
34
40
  type: PropType<Themes>;
41
+ default: undefined;
35
42
  };
36
43
  previewTheme: {
37
44
  type: PropType<string>;
45
+ default: undefined;
46
+ };
47
+ codeTheme: {
48
+ type: PropType<string>;
49
+ default: undefined;
38
50
  };
39
51
  /**
40
52
  * ==结束
41
53
  */
42
54
  default: {
43
55
  type: PropType<string | Element>;
56
+ default: undefined;
44
57
  };
45
58
  }, () => import("vue/jsx-runtime").JSX.Element, unknown, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, "onChange"[], "onChange", import("vue").PublicProps, Readonly<ExtractPropTypes<{
46
59
  title: {
@@ -49,44 +62,71 @@ declare const _default: import("vue").DefineComponent<{
49
62
  };
50
63
  visible: {
51
64
  type: PropType<boolean>;
65
+ default: undefined;
52
66
  };
53
67
  trigger: {
54
68
  type: PropType<string | VNode<import("vue").RendererNode, import("vue").RendererElement, {
55
69
  [key: string]: any;
56
70
  }>>;
71
+ default: undefined;
57
72
  };
58
73
  onChange: {
59
74
  type: PropType<(visible: boolean) => void>;
75
+ default: undefined;
60
76
  };
61
77
  overlay: {
62
78
  type: PropType<string | VNode<import("vue").RendererNode, import("vue").RendererElement, {
63
79
  [key: string]: any;
64
80
  }>>;
81
+ default: undefined;
65
82
  };
66
83
  /**
67
84
  * ==没有意义,仅用于规避克隆组件自动嵌入insert方法时,传入的是该组件而产生的waring
68
85
  */
69
86
  insert: {
70
87
  type: PropType<() => void>;
88
+ default: undefined;
71
89
  };
72
90
  language: {
73
91
  type: PropType<string>;
92
+ default: undefined;
74
93
  };
75
94
  theme: {
76
95
  type: PropType<Themes>;
96
+ default: undefined;
77
97
  };
78
98
  previewTheme: {
79
99
  type: PropType<string>;
100
+ default: undefined;
101
+ };
102
+ codeTheme: {
103
+ type: PropType<string>;
104
+ default: undefined;
80
105
  };
81
106
  /**
82
107
  * ==结束
83
108
  */
84
109
  default: {
85
110
  type: PropType<string | Element>;
111
+ default: undefined;
86
112
  };
87
113
  }>> & {
88
114
  onOnChange?: ((...args: any[]) => any) | undefined;
89
115
  }, {
116
+ default: string | Element;
90
117
  title: string;
118
+ onChange: (visible: boolean) => void;
119
+ insert: () => void;
120
+ language: string;
121
+ theme: Themes;
122
+ previewTheme: string;
123
+ codeTheme: string;
124
+ overlay: string | VNode<import("vue").RendererNode, import("vue").RendererElement, {
125
+ [key: string]: any;
126
+ }>;
127
+ visible: boolean;
128
+ trigger: string | VNode<import("vue").RendererNode, import("vue").RendererElement, {
129
+ [key: string]: any;
130
+ }>;
91
131
  }, {}>;
92
132
  export default _default;