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
@@ -230,31 +230,33 @@ const useMermaid = (props) => {
230
230
  await Promise.allSettled(
231
231
  Array.from(mermaidSourceEles).map((ele) => {
232
232
  const handler = async (item) => {
233
+ var _a;
233
234
  let mermaidHtml = mermaidCache.get(item.innerText);
234
235
  if (!mermaidHtml) {
235
236
  const idRand = util$2.randomId();
236
- const render = mermaidRef.value.renderAsync || mermaidRef.value.render;
237
- let svg = "";
237
+ let result = { svg: "" };
238
238
  try {
239
- svg = await render(idRand, item.innerText, svgContainingElement);
240
- } catch (error) {
239
+ result = await mermaidRef.value.render(
240
+ idRand,
241
+ item.innerText,
242
+ svgContainingElement
243
+ );
244
+ mermaidHtml = await props.sanitizeMermaid(result.svg);
245
+ const p = document.createElement("p");
246
+ p.className = `${config.prefix}-mermaid`;
247
+ p.setAttribute("data-processed", "");
248
+ p.innerHTML = mermaidHtml;
249
+ (_a = p.children[0]) == null ? void 0 : _a.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
+ } catch {
256
+ }
257
+ if (--count === 0) {
258
+ svgContainingElement.remove();
241
259
  }
242
- mermaidHtml = await props.sanitizeMermaid(
243
- typeof svg === "string" ? svg : svg.svg
244
- );
245
- }
246
- const p = document.createElement("p");
247
- p.className = `${config.prefix}-mermaid`;
248
- p.setAttribute("data-processed", "");
249
- p.innerHTML = mermaidHtml;
250
- p.children[0].removeAttribute("height");
251
- mermaidCache.set(item.innerText, p.innerHTML);
252
- if (item.dataset.line !== void 0) {
253
- p.dataset.line = item.dataset.line;
254
- }
255
- item.replaceWith(p);
256
- if (--count === 0) {
257
- svgContainingElement.remove();
258
260
  }
259
261
  };
260
262
  return handler(ele);
@@ -3001,7 +3003,8 @@ const mdPreviewProps = {
3001
3003
  * input回调事件
3002
3004
  */
3003
3005
  onChange: {
3004
- type: Function
3006
+ type: Function,
3007
+ default: void 0
3005
3008
  },
3006
3009
  /**
3007
3010
  * 主题,支持light和dark
@@ -3034,13 +3037,15 @@ const mdPreviewProps = {
3034
3037
  * html变化事件
3035
3038
  */
3036
3039
  onHtmlChanged: {
3037
- type: Function
3040
+ type: Function,
3041
+ default: void 0
3038
3042
  },
3039
3043
  /**
3040
3044
  * 获取目录结构
3041
3045
  */
3042
3046
  onGetCatalog: {
3043
- type: Function
3047
+ type: Function,
3048
+ default: void 0
3044
3049
  },
3045
3050
  /**
3046
3051
  * 编辑器唯一标识
@@ -3129,7 +3134,8 @@ const mdPreviewProps = {
3129
3134
  * @default false
3130
3135
  */
3131
3136
  noIconfont: {
3132
- type: Boolean
3137
+ type: Boolean,
3138
+ default: void 0
3133
3139
  },
3134
3140
  /**
3135
3141
  * 复制代码格式化方法
@@ -3207,13 +3213,15 @@ const editorProps = {
3207
3213
  * input回调事件
3208
3214
  */
3209
3215
  onSave: {
3210
- type: Function
3216
+ type: Function,
3217
+ default: void 0
3211
3218
  },
3212
3219
  /**
3213
3220
  * 上传图片事件
3214
3221
  */
3215
3222
  onUploadImg: {
3216
- type: Function
3223
+ type: Function,
3224
+ default: void 0
3217
3225
  },
3218
3226
  /**
3219
3227
  * 是否页面内全屏
@@ -3297,7 +3305,8 @@ const editorProps = {
3297
3305
  * @default [6, 4]
3298
3306
  */
3299
3307
  tableShape: {
3300
- type: Array
3308
+ type: Array,
3309
+ default: [6, 4]
3301
3310
  },
3302
3311
  /**
3303
3312
  * 空提示
@@ -3312,13 +3321,15 @@ const editorProps = {
3312
3321
  * 自定义的工具栏列表
3313
3322
  */
3314
3323
  defToolbars: {
3315
- type: [String, Object]
3324
+ type: [String, Object],
3325
+ default: void 0
3316
3326
  },
3317
3327
  /**
3318
3328
  * 内部错误捕获
3319
3329
  */
3320
3330
  onError: {
3321
- type: Function
3331
+ type: Function,
3332
+ default: void 0
3322
3333
  },
3323
3334
  /**
3324
3335
  * 页脚列表显示顺序
@@ -3340,7 +3351,8 @@ const editorProps = {
3340
3351
  * 自定义的也叫工具组件列表
3341
3352
  */
3342
3353
  defFooters: {
3343
- type: [String, Object]
3354
+ type: [String, Object],
3355
+ default: void 0
3344
3356
  },
3345
3357
  /**
3346
3358
  * 是否禁用上传图片
@@ -3348,7 +3360,8 @@ const editorProps = {
3348
3360
  * @default false
3349
3361
  */
3350
3362
  noUploadImg: {
3351
- type: Boolean
3363
+ type: Boolean,
3364
+ default: false
3352
3365
  },
3353
3366
  /**
3354
3367
  * 文本区域自动获得焦点
@@ -3356,7 +3369,8 @@ const editorProps = {
3356
3369
  * @default false
3357
3370
  */
3358
3371
  autoFocus: {
3359
- type: Boolean
3372
+ type: Boolean,
3373
+ default: false
3360
3374
  },
3361
3375
  /**
3362
3376
  * 禁用文本区域
@@ -3364,7 +3378,8 @@ const editorProps = {
3364
3378
  * @default false
3365
3379
  */
3366
3380
  disabled: {
3367
- type: Boolean
3381
+ type: Boolean,
3382
+ default: false
3368
3383
  },
3369
3384
  /**
3370
3385
  * 文本区域为只读
@@ -3372,13 +3387,15 @@ const editorProps = {
3372
3387
  * @default false
3373
3388
  */
3374
3389
  readOnly: {
3375
- type: Boolean
3390
+ type: Boolean,
3391
+ default: false
3376
3392
  },
3377
3393
  /**
3378
3394
  * 文本区域允许的最大字符数
3379
3395
  */
3380
3396
  maxLength: {
3381
- type: Number
3397
+ type: Number,
3398
+ default: void 0
3382
3399
  },
3383
3400
  /**
3384
3401
  * 是否启用自动识别粘贴代码类别
@@ -3387,19 +3404,22 @@ const editorProps = {
3387
3404
  * @default false
3388
3405
  */
3389
3406
  autoDetectCode: {
3390
- type: Boolean
3407
+ type: Boolean,
3408
+ default: false
3391
3409
  },
3392
3410
  /**
3393
3411
  * 输入框失去焦点时触发事件
3394
3412
  */
3395
3413
  onBlur: {
3396
- type: Function
3414
+ type: Function,
3415
+ default: void 0
3397
3416
  },
3398
3417
  /**
3399
3418
  * 输入框获得焦点时触发事件
3400
3419
  */
3401
3420
  onFocus: {
3402
- type: Function
3421
+ type: Function,
3422
+ default: void 0
3403
3423
  },
3404
3424
  /**
3405
3425
  * @codemirror/autocomplete匹配关键词的方法列表
@@ -3412,7 +3432,8 @@ const editorProps = {
3412
3432
  * })
3413
3433
  */
3414
3434
  completions: {
3415
- type: Array
3435
+ type: Array,
3436
+ default: void 0
3416
3437
  },
3417
3438
  /**
3418
3439
  * 是否在工具栏下面显示对应的文字名称
@@ -3427,10 +3448,12 @@ const editorProps = {
3427
3448
  * 字符输入事件
3428
3449
  */
3429
3450
  onInput: {
3430
- type: Function
3451
+ type: Function,
3452
+ default: void 0
3431
3453
  },
3432
3454
  onDrop: {
3433
- type: Function
3455
+ type: Function,
3456
+ default: void 0
3434
3457
  },
3435
3458
  /**
3436
3459
  * 输入框的默认宽度
@@ -3446,7 +3469,8 @@ const editorProps = {
3446
3469
  * 输入框宽度变化事件
3447
3470
  */
3448
3471
  onInputBoxWitdhChange: {
3449
- type: Function
3472
+ type: Function,
3473
+ default: void 0
3450
3474
  },
3451
3475
  /**
3452
3476
  * 替换粘贴的图片链接
@@ -129,39 +129,52 @@ const props = {
129
129
  default: ""
130
130
  },
131
131
  visible: {
132
- type: Boolean
132
+ type: Boolean,
133
+ default: void 0
133
134
  },
134
135
  // 展示在工具栏的内容,通常是个图标
135
136
  trigger: {
136
- type: [String, Object]
137
+ type: [String, Object],
138
+ default: void 0
137
139
  },
138
140
  onChange: {
139
- type: Function
141
+ type: Function,
142
+ default: void 0
140
143
  },
141
144
  // 下拉框中的内容
142
145
  overlay: {
143
- type: [String, Object]
146
+ type: [String, Object],
147
+ default: void 0
144
148
  },
145
149
  /**
146
150
  * ==没有意义,仅用于规避克隆组件自动嵌入insert方法时,传入的是该组件而产生的waring
147
151
  */
148
152
  insert: {
149
- type: Function
153
+ type: Function,
154
+ default: void 0
150
155
  },
151
156
  language: {
152
- type: String
157
+ type: String,
158
+ default: void 0
153
159
  },
154
160
  theme: {
155
- type: String
161
+ type: String,
162
+ default: void 0
156
163
  },
157
164
  previewTheme: {
158
- type: String
165
+ type: String,
166
+ default: void 0
167
+ },
168
+ codeTheme: {
169
+ type: String,
170
+ default: void 0
159
171
  },
160
172
  /**
161
173
  * ==结束
162
174
  */
163
175
  default: {
164
- type: [String, Object]
176
+ type: [String, Object],
177
+ default: void 0
165
178
  }
166
179
  };
167
180
  const DropdownToolbar = /* @__PURE__ */ vue.defineComponent({
@@ -354,7 +354,8 @@ const props = {
354
354
  * 编辑器的Id,务必与需要绑定的编辑器Id相同
355
355
  */
356
356
  editorId: {
357
- type: String
357
+ type: String,
358
+ default: void 0
358
359
  },
359
360
  class: {
360
361
  type: String,
@@ -371,7 +372,8 @@ const props = {
371
372
  * 默认:#md-editor-preview-wrapper
372
373
  */
373
374
  scrollElement: {
374
- type: [String, Object]
375
+ type: [String, Object],
376
+ default: void 0
375
377
  },
376
378
  theme: {
377
379
  type: String,
@@ -396,10 +398,12 @@ const props = {
396
398
  default: 0
397
399
  },
398
400
  onClick: {
399
- type: Function
401
+ type: Function,
402
+ default: void 0
400
403
  },
401
404
  onActive: {
402
- type: Function
405
+ type: Function,
406
+ default: void 0
403
407
  },
404
408
  /**
405
409
  * 滚动容器是否在web component中,默认不在
package/lib/cjs/index.cjs CHANGED
@@ -13,7 +13,8 @@ const config$1 = require("./chunks/config.cjs");
13
13
  const config = require("./config.cjs");
14
14
  const props = {
15
15
  onClick: {
16
- type: Function
16
+ type: Function,
17
+ default: void 0
17
18
  }
18
19
  };
19
20
  const NormalFooterToolbar = /* @__PURE__ */ vue.defineComponent({
@@ -82,6 +82,9 @@ const toolbarProps = {
82
82
  },
83
83
  catalogVisible: {
84
84
  type: Boolean
85
+ },
86
+ codeTheme: {
87
+ type: String
85
88
  }
86
89
  };
87
90
  const useSreenfull = (props2) => {
@@ -578,7 +581,7 @@ const ToolBar = /* @__PURE__ */ defineComponent({
578
581
  uploadRef.value.addEventListener("change", uploadHandler);
579
582
  });
580
583
  const barRender = (barItem) => {
581
- var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y, _z, _A, _B, _C, _D, _E, _F, _G, _H, _I, _J, _K, _L, _M, _N, _O, _P, _Q, _R, _S, _T, _U, _V, _W, _X, _Y, _Z, __, _$, _aa, _ba, _ca, _da, _ea, _fa, _ga, _ha, _ia, _ja, _ka, _la, _ma, _na, _oa;
584
+ var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y, _z, _A, _B, _C, _D, _E, _F, _G, _H, _I, _J, _K, _L, _M, _N, _O, _P, _Q, _R, _S, _T, _U, _V, _W, _X, _Y, _Z, __, _$, _aa, _ba, _ca, _da, _ea, _fa, _ga, _ha, _ia, _ja, _ka, _la, _ma, _na, _oa, _pa, _qa, _ra, _sa, _ta, _ua, _va, _wa;
582
585
  if (allToolbar.includes(barItem)) {
583
586
  switch (barItem) {
584
587
  case "-": {
@@ -1190,9 +1193,10 @@ const ToolBar = /* @__PURE__ */ defineComponent({
1190
1193
  const defItem = props2.defToolbars[barItem];
1191
1194
  if (defItem) {
1192
1195
  const defItemCloned = cloneVNode(defItem, {
1193
- theme: theme.value,
1194
- previewTheme: previewTheme.value,
1195
- language: language.value,
1196
+ theme: ((_pa = defItem.props) == null ? void 0 : _pa.theme) || theme.value,
1197
+ previewTheme: ((_qa = defItem.props) == null ? void 0 : _qa.theme) || previewTheme.value,
1198
+ language: ((_ra = defItem.props) == null ? void 0 : _ra.theme) || language.value,
1199
+ codeTheme: ((_sa = defItem.props) == null ? void 0 : _sa.codeTheme) || props2.codeTheme,
1196
1200
  insert(generate) {
1197
1201
  bus.emit(editorId, REPLACE, "universal", {
1198
1202
  generate
@@ -1206,9 +1210,10 @@ const ToolBar = /* @__PURE__ */ defineComponent({
1206
1210
  const defItem = props2.defToolbars.children[barItem];
1207
1211
  if (defItem) {
1208
1212
  const defItemCloned = cloneVNode(defItem, {
1209
- theme: theme.value,
1210
- previewTheme: previewTheme.value,
1211
- language: language.value,
1213
+ theme: ((_ta = defItem.props) == null ? void 0 : _ta.theme) || theme.value,
1214
+ previewTheme: ((_ua = defItem.props) == null ? void 0 : _ua.theme) || previewTheme.value,
1215
+ language: ((_va = defItem.props) == null ? void 0 : _va.theme) || language.value,
1216
+ codeTheme: ((_wa = defItem.props) == null ? void 0 : _wa.codeTheme) || props2.codeTheme,
1212
1217
  insert(generate) {
1213
1218
  bus.emit(editorId, REPLACE, "universal", {
1214
1219
  generate
@@ -3023,7 +3028,8 @@ const Editor = /* @__PURE__ */ defineComponent({
3023
3028
  "defToolbars": defToolbars,
3024
3029
  "noUploadImg": noUploadImg,
3025
3030
  "showToolbarName": props2.showToolbarName,
3026
- "catalogVisible": catalogVisible.value
3031
+ "catalogVisible": catalogVisible.value,
3032
+ "codeTheme": props2.codeTheme
3027
3033
  }, null), createVNode(Content, {
3028
3034
  "ref": codeRef,
3029
3035
  "modelValue": props2.modelValue,
@@ -15,7 +15,8 @@ const props = {
15
15
  default: ""
16
16
  },
17
17
  visible: {
18
- type: Boolean
18
+ type: Boolean,
19
+ default: void 0
19
20
  },
20
21
  width: {
21
22
  type: String,
@@ -27,13 +28,16 @@ const props = {
27
28
  },
28
29
  // 展示在工具栏的内容,通常是个图标
29
30
  trigger: {
30
- type: [String, Object]
31
+ type: [String, Object],
32
+ default: void 0
31
33
  },
32
34
  onClick: {
33
- type: Function
35
+ type: Function,
36
+ default: void 0
34
37
  },
35
38
  onClose: {
36
- type: Function
39
+ type: Function,
40
+ default: void 0
37
41
  },
38
42
  /**
39
43
  * 显示全屏按钮
@@ -47,13 +51,16 @@ const props = {
47
51
  default: false
48
52
  },
49
53
  onAdjust: {
50
- type: Function
54
+ type: Function,
55
+ default: void 0
51
56
  },
52
57
  class: {
53
- type: String
58
+ type: String,
59
+ default: void 0
54
60
  },
55
61
  style: {
56
- type: [Object, String]
62
+ type: [Object, String],
63
+ default: void 0
57
64
  },
58
65
  showMask: {
59
66
  type: Boolean,
@@ -63,16 +70,24 @@ const props = {
63
70
  * ==没有意义,仅用于规避克隆组件自动嵌入insert方法时,传入的是该组件而产生的waring
64
71
  */
65
72
  insert: {
66
- type: Function
73
+ type: Function,
74
+ default: void 0
67
75
  },
68
76
  language: {
69
- type: String
77
+ type: String,
78
+ default: void 0
70
79
  },
71
80
  theme: {
72
- type: String
81
+ type: String,
82
+ default: void 0
73
83
  },
74
84
  previewTheme: {
75
- type: String
85
+ type: String,
86
+ default: void 0
87
+ },
88
+ codeTheme: {
89
+ type: String,
90
+ default: void 0
76
91
  }
77
92
  /**
78
93
  * ==结束
@@ -8,22 +8,35 @@ const props = {
8
8
  },
9
9
  // 展示在工具栏的内容,通常是个图标
10
10
  trigger: {
11
- type: [String, Object]
11
+ type: [String, Object],
12
+ default: void 0
12
13
  },
13
14
  onClick: {
14
- type: Function
15
+ type: Function,
16
+ default: void 0
15
17
  },
16
18
  /**
17
19
  * ==没有意义,仅用于规避克隆组件自动嵌入insert方法时,传入的是该组件而产生的waring
18
20
  */
19
21
  insert: {
20
- type: Function
22
+ type: Function,
23
+ default: void 0
21
24
  },
22
25
  language: {
23
- type: String
26
+ type: String,
27
+ default: void 0
24
28
  },
25
29
  theme: {
26
- type: String
30
+ type: String,
31
+ default: void 0
32
+ },
33
+ previewTheme: {
34
+ type: String,
35
+ default: void 0
36
+ },
37
+ codeTheme: {
38
+ type: String,
39
+ default: void 0
27
40
  }
28
41
  /**
29
42
  * ==结束