vditor 3.8.5 → 3.8.9

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 (60) hide show
  1. package/README.md +48 -45
  2. package/dist/index.css +2 -2
  3. package/dist/index.d.ts +4 -1
  4. package/dist/index.min.js +722 -858
  5. package/dist/js/i18n/en_US.js +85 -0
  6. package/dist/js/i18n/ja_JP.js +85 -0
  7. package/dist/js/i18n/ko_KR.js +85 -0
  8. package/dist/js/i18n/ru_RU.js +85 -0
  9. package/dist/js/i18n/zh_CN.js +85 -0
  10. package/dist/js/i18n/zh_TW.js +85 -0
  11. package/dist/js/lute/lute.min.js +31 -28
  12. package/dist/method.d.ts +4 -1
  13. package/dist/method.min.js +157 -543
  14. package/dist/ts/markdown/adapterRender.d.ts +33 -0
  15. package/dist/ts/markdown/codeRender.d.ts +1 -2
  16. package/dist/ts/ui/initUI.d.ts +1 -0
  17. package/dist/ts/wysiwyg/index.d.ts +2 -0
  18. package/dist/types/index.d.ts +773 -0
  19. package/package.json +4 -4
  20. package/src/assets/.DS_Store +0 -0
  21. package/src/assets/scss/_content.scss +4 -0
  22. package/src/assets/scss/_reset.scss +11 -0
  23. package/src/index.ts +156 -97
  24. package/src/method.ts +6 -2
  25. package/src/ts/.DS_Store +0 -0
  26. package/src/ts/export/index.ts +7 -5
  27. package/src/ts/hint/index.ts +20 -11
  28. package/src/ts/markdown/abcRender.ts +3 -2
  29. package/src/ts/markdown/adapterRender.ts +33 -0
  30. package/src/ts/markdown/chartRender.ts +3 -2
  31. package/src/ts/markdown/codeRender.ts +5 -6
  32. package/src/ts/markdown/flowchartRender.ts +3 -2
  33. package/src/ts/markdown/graphvizRender.ts +13 -11
  34. package/src/ts/markdown/mathRender.ts +5 -4
  35. package/src/ts/markdown/mermaidRender.ts +4 -2
  36. package/src/ts/markdown/mindmapRender.ts +3 -2
  37. package/src/ts/markdown/plantumlRender.ts +3 -2
  38. package/src/ts/markdown/previewRender.ts +26 -4
  39. package/src/ts/preview/image.ts +2 -4
  40. package/src/ts/preview/index.ts +2 -5
  41. package/src/ts/toolbar/EditMode.ts +3 -4
  42. package/src/ts/toolbar/Headings.ts +6 -6
  43. package/src/ts/toolbar/Info.ts +1 -1
  44. package/src/ts/toolbar/MenuItem.ts +1 -3
  45. package/src/ts/toolbar/Record.ts +3 -4
  46. package/src/ts/ui/initUI.ts +19 -5
  47. package/src/ts/upload/index.ts +11 -11
  48. package/src/ts/util/Options.ts +255 -196
  49. package/src/ts/util/editorCommonEvent.ts +2 -2
  50. package/src/ts/util/fixBrowserBehavior.ts +10 -6
  51. package/src/ts/util/processCode.ts +1 -1
  52. package/src/ts/wysiwyg/highlightToolbarWYSIWYG.ts +298 -138
  53. package/src/ts/wysiwyg/index.ts +9 -4
  54. package/CHANGELOG.md +0 -1053
  55. package/dist/images/.DS_Store +0 -0
  56. package/dist/js/.DS_Store +0 -0
  57. package/dist/js/lute/.DS_Store +0 -0
  58. package/dist/js/mathjax/.DS_Store +0 -0
  59. package/dist/ts/i18n/index.d.ts +0 -2
  60. package/src/ts/i18n/index.ts +0 -476
@@ -1,5 +1,5 @@
1
- import {Constants} from "../constants";
2
- import {merge} from "./merge";
1
+ import { Constants } from "../constants";
2
+ import { merge } from "./merge";
3
3
 
4
4
  export class Options {
5
5
  public options: IOptions;
@@ -106,7 +106,8 @@ export class Options {
106
106
  "info",
107
107
  "help",
108
108
  ],
109
- }],
109
+ },
110
+ ],
110
111
  toolbarConfig: {
111
112
  hide: false,
112
113
  pin: false,
@@ -152,211 +153,269 @@ export class Options {
152
153
  const mergedOptions = merge(this.defaultOptions, this.options);
153
154
 
154
155
  if (mergedOptions.cache.enable && !mergedOptions.cache.id) {
155
- throw new Error("need options.cache.id, see https://ld246.com/article/1549638745630#options");
156
+ throw new Error(
157
+ "need options.cache.id, see https://ld246.com/article/1549638745630#options",
158
+ );
156
159
  }
157
160
 
158
161
  return mergedOptions;
159
162
  }
160
163
 
161
164
  private mergeToolbar(toolbar: Array<string | IMenuItem>) {
162
- const toolbarItem = [{
163
- icon: '<svg><use xlink:href="#vditor-icon-export"></use></svg>',
164
- name: "export",
165
- tipPosition: "ne",
166
- }, {
167
- hotkey: "⌘E",
168
- icon: '<svg><use xlink:href="#vditor-icon-emoji"></use></svg>',
169
- name: "emoji",
170
- tipPosition: "ne",
171
- }, {
172
- hotkey: "⌘H",
173
- icon: '<svg><use xlink:href="#vditor-icon-headings"></use></svg>',
174
- name: "headings",
175
- tipPosition: "ne",
176
- }, {
177
- hotkey: "⌘B",
178
- icon: '<svg><use xlink:href="#vditor-icon-bold"></use></svg>',
179
- name: "bold",
180
- prefix: "**",
181
- suffix: "**",
182
- tipPosition: "ne",
183
- }, {
184
- hotkey: "⌘I",
185
- icon: '<svg><use xlink:href="#vditor-icon-italic"></use></svg>',
186
- name: "italic",
187
- prefix: "*",
188
- suffix: "*",
189
- tipPosition: "ne",
190
- }, {
191
- hotkey: "⌘D",
192
- icon: '<svg><use xlink:href="#vditor-icon-strike"></use></svg>',
193
- name: "strike",
194
- prefix: "~~",
195
- suffix: "~~",
196
- tipPosition: "ne",
197
- }, {
198
- hotkey: "⌘K",
199
- icon: '<svg><use xlink:href="#vditor-icon-link"></use></svg>',
200
- name: "link",
201
- prefix: "[",
202
- suffix: "](https://)",
203
- tipPosition: "n",
204
- }, {
205
- name: "|",
206
- }, {
207
- hotkey: "⌘L",
208
- icon: '<svg><use xlink:href="#vditor-icon-list"></use></svg>',
209
- name: "list",
210
- prefix: "* ",
211
- tipPosition: "n",
212
- }, {
213
- hotkey: "⌘O",
214
- icon: '<svg><use xlink:href="#vditor-icon-ordered-list"></use></svg>',
215
- name: "ordered-list",
216
- prefix: "1. ",
217
- tipPosition: "n",
218
- }, {
219
- hotkey: "⌘J",
220
- icon: '<svg><use xlink:href="#vditor-icon-check"></use></svg>',
221
- name: "check",
222
- prefix: "* [ ] ",
223
- tipPosition: "n",
224
- }, {
225
- hotkey: "⇧⌘I",
226
- icon: '<svg><use xlink:href="#vditor-icon-outdent"></use></svg>',
227
- name: "outdent",
228
- tipPosition: "n",
229
- }, {
230
- hotkey: "⇧⌘O",
231
- icon: '<svg><use xlink:href="#vditor-icon-indent"></use></svg>',
232
- name: "indent",
233
- tipPosition: "n",
234
- }, {
235
- name: "|",
236
- }, {
237
- hotkey: "⌘;",
238
- icon: '<svg><use xlink:href="#vditor-icon-quote"></use></svg>',
239
- name: "quote",
240
- prefix: "> ",
241
- tipPosition: "n",
242
- }, {
243
- hotkey: "⇧⌘H",
244
- icon: '<svg><use xlink:href="#vditor-icon-line"></use></svg>',
245
- name: "line",
246
- prefix: "---",
247
- tipPosition: "n",
248
- }, {
249
- hotkey: "⌘U",
250
- icon: '<svg><use xlink:href="#vditor-icon-code"></use></svg>',
251
- name: "code",
252
- prefix: "```",
253
- suffix: "\n```",
254
- tipPosition: "n",
255
- }, {
256
- hotkey: "⌘G",
257
- icon: '<svg><use xlink:href="#vditor-icon-inline-code"></use></svg>',
258
- name: "inline-code",
259
- prefix: "`",
260
- suffix: "`",
261
- tipPosition: "n",
262
- }, {
263
- hotkey: "⇧⌘B",
264
- icon: '<svg><use xlink:href="#vditor-icon-before"></use></svg>',
265
- name: "insert-before",
266
- tipPosition: "n",
267
- }, {
268
- hotkey: "⇧⌘E",
269
- icon: '<svg><use xlink:href="#vditor-icon-after"></use></svg>',
270
- name: "insert-after",
271
- tipPosition: "n",
272
- }, {
273
- name: "|",
274
- }, {
275
- icon: '<svg><use xlink:href="#vditor-icon-upload"></use></svg>',
276
- name: "upload",
277
- tipPosition: "n",
278
- }, {
279
- icon: '<svg><use xlink:href="#vditor-icon-record"></use></svg>',
280
- name: "record",
281
- tipPosition: "n",
282
- }, {
283
- hotkey: "⌘M",
284
- icon: '<svg><use xlink:href="#vditor-icon-table"></use></svg>',
285
- name: "table",
286
- prefix: "| col1",
287
- suffix: " | col2 | col3 |\n| --- | --- | --- |\n| | | |\n| | | |",
288
- tipPosition: "n",
289
- }, {
290
- name: "|",
291
- }, {
292
- hotkey: "⌘Z",
293
- icon: '<svg><use xlink:href="#vditor-icon-undo"></use></svg>',
294
- name: "undo",
295
- tipPosition: "nw",
296
- }, {
297
- hotkey: "⌘Y",
298
- icon: '<svg><use xlink:href="#vditor-icon-redo"></use></svg>',
299
- name: "redo",
300
- tipPosition: "nw",
301
- }, {
302
- name: "|",
303
- }, {
304
- icon: '<svg><use xlink:href="#vditor-icon-more"></use></svg>',
305
- name: "more",
306
- tipPosition: "e",
307
- }, {
308
- hotkey: "⌘'",
309
- icon: '<svg><use xlink:href="#vditor-icon-fullscreen"></use></svg>',
310
- name: "fullscreen",
311
- tipPosition: "nw",
312
- }, {
313
- icon: '<svg><use xlink:href="#vditor-icon-edit"></use></svg>',
314
- name: "edit-mode",
315
- tipPosition: "nw",
316
- }, {
317
- hotkey: "⌘P",
318
- icon: '<svg><use xlink:href="#vditor-icon-both"></use></svg>',
319
- name: "both",
320
- tipPosition: "nw",
321
- }, {
322
- icon: '<svg><use xlink:href="#vditor-icon-preview"></use></svg>',
323
- name: "preview",
324
- tipPosition: "nw",
325
- }, {
326
- icon: '<svg><use xlink:href="#vditor-icon-align-center"></use></svg>',
327
- name: "outline",
328
- tipPosition: "nw",
329
- }, {
330
- icon: '<svg><use xlink:href="#vditor-icon-theme"></use></svg>',
331
- name: "content-theme",
332
- tipPosition: "nw",
333
- }, {
334
- icon: '<svg><use xlink:href="#vditor-icon-code-theme"></use></svg>',
335
- name: "code-theme",
336
- tipPosition: "nw",
337
- }, {
338
- icon: '<svg><use xlink:href="#vditor-icon-bug"></use></svg>',
339
- name: "devtools",
340
- tipPosition: "nw",
341
- }, {
342
- icon: '<svg><use xlink:href="#vditor-icon-info"></use></svg>',
343
- name: "info",
344
- tipPosition: "nw",
345
- }, {
346
- icon: '<svg><use xlink:href="#vditor-icon-help"></use></svg>',
347
- name: "help",
348
- tipPosition: "nw",
349
- }, {
350
- name: "br",
351
- }];
165
+ const toolbarItem = [
166
+ {
167
+ icon: '<svg><use xlink:href="#vditor-icon-export"></use></svg>',
168
+ name: "export",
169
+ tipPosition: "ne",
170
+ },
171
+ {
172
+ hotkey: "⌘E",
173
+ icon: '<svg><use xlink:href="#vditor-icon-emoji"></use></svg>',
174
+ name: "emoji",
175
+ tipPosition: "ne",
176
+ },
177
+ {
178
+ hotkey: "⌘H",
179
+ icon:
180
+ '<svg><use xlink:href="#vditor-icon-headings"></use></svg>',
181
+ name: "headings",
182
+ tipPosition: "ne",
183
+ },
184
+ {
185
+ hotkey: "⌘B",
186
+ icon: '<svg><use xlink:href="#vditor-icon-bold"></use></svg>',
187
+ name: "bold",
188
+ prefix: "**",
189
+ suffix: "**",
190
+ tipPosition: "ne",
191
+ },
192
+ {
193
+ hotkey: "⌘I",
194
+ icon: '<svg><use xlink:href="#vditor-icon-italic"></use></svg>',
195
+ name: "italic",
196
+ prefix: "*",
197
+ suffix: "*",
198
+ tipPosition: "ne",
199
+ },
200
+ {
201
+ hotkey: "⌘D",
202
+ icon: '<svg><use xlink:href="#vditor-icon-strike"></use></svg>',
203
+ name: "strike",
204
+ prefix: "~~",
205
+ suffix: "~~",
206
+ tipPosition: "ne",
207
+ },
208
+ {
209
+ hotkey: "⌘K",
210
+ icon: '<svg><use xlink:href="#vditor-icon-link"></use></svg>',
211
+ name: "link",
212
+ prefix: "[",
213
+ suffix: "](https://)",
214
+ tipPosition: "n",
215
+ },
216
+ {
217
+ name: "|",
218
+ },
219
+ {
220
+ hotkey: "⌘L",
221
+ icon: '<svg><use xlink:href="#vditor-icon-list"></use></svg>',
222
+ name: "list",
223
+ prefix: "* ",
224
+ tipPosition: "n",
225
+ },
226
+ {
227
+ hotkey: "⌘O",
228
+ icon:
229
+ '<svg><use xlink:href="#vditor-icon-ordered-list"></use></svg>',
230
+ name: "ordered-list",
231
+ prefix: "1. ",
232
+ tipPosition: "n",
233
+ },
234
+ {
235
+ hotkey: "⌘J",
236
+ icon: '<svg><use xlink:href="#vditor-icon-check"></use></svg>',
237
+ name: "check",
238
+ prefix: "* [ ] ",
239
+ tipPosition: "n",
240
+ },
241
+ {
242
+ hotkey: "⇧⌘I",
243
+ icon:
244
+ '<svg><use xlink:href="#vditor-icon-outdent"></use></svg>',
245
+ name: "outdent",
246
+ tipPosition: "n",
247
+ },
248
+ {
249
+ hotkey: "⇧⌘O",
250
+ icon: '<svg><use xlink:href="#vditor-icon-indent"></use></svg>',
251
+ name: "indent",
252
+ tipPosition: "n",
253
+ },
254
+ {
255
+ name: "|",
256
+ },
257
+ {
258
+ hotkey: "⌘;",
259
+ icon: '<svg><use xlink:href="#vditor-icon-quote"></use></svg>',
260
+ name: "quote",
261
+ prefix: "> ",
262
+ tipPosition: "n",
263
+ },
264
+ {
265
+ hotkey: "⇧⌘H",
266
+ icon: '<svg><use xlink:href="#vditor-icon-line"></use></svg>',
267
+ name: "line",
268
+ prefix: "---",
269
+ tipPosition: "n",
270
+ },
271
+ {
272
+ hotkey: "⌘U",
273
+ icon: '<svg><use xlink:href="#vditor-icon-code"></use></svg>',
274
+ name: "code",
275
+ prefix: "```",
276
+ suffix: "\n```",
277
+ tipPosition: "n",
278
+ },
279
+ {
280
+ hotkey: "⌘G",
281
+ icon:
282
+ '<svg><use xlink:href="#vditor-icon-inline-code"></use></svg>',
283
+ name: "inline-code",
284
+ prefix: "`",
285
+ suffix: "`",
286
+ tipPosition: "n",
287
+ },
288
+ {
289
+ hotkey: "⇧⌘B",
290
+ icon: '<svg><use xlink:href="#vditor-icon-before"></use></svg>',
291
+ name: "insert-before",
292
+ tipPosition: "n",
293
+ },
294
+ {
295
+ hotkey: "⇧⌘E",
296
+ icon: '<svg><use xlink:href="#vditor-icon-after"></use></svg>',
297
+ name: "insert-after",
298
+ tipPosition: "n",
299
+ },
300
+ {
301
+ name: "|",
302
+ },
303
+ {
304
+ icon: '<svg><use xlink:href="#vditor-icon-upload"></use></svg>',
305
+ name: "upload",
306
+ tipPosition: "n",
307
+ },
308
+ {
309
+ icon: '<svg><use xlink:href="#vditor-icon-record"></use></svg>',
310
+ name: "record",
311
+ tipPosition: "n",
312
+ },
313
+ {
314
+ hotkey: "⌘M",
315
+ icon: '<svg><use xlink:href="#vditor-icon-table"></use></svg>',
316
+ name: "table",
317
+ prefix: "| col1",
318
+ suffix:
319
+ " | col2 | col3 |\n| --- | --- | --- |\n| | | |\n| | | |",
320
+ tipPosition: "n",
321
+ },
322
+ {
323
+ name: "|",
324
+ },
325
+ {
326
+ hotkey: "⌘Z",
327
+ icon: '<svg><use xlink:href="#vditor-icon-undo"></use></svg>',
328
+ name: "undo",
329
+ tipPosition: "nw",
330
+ },
331
+ {
332
+ hotkey: "⌘Y",
333
+ icon: '<svg><use xlink:href="#vditor-icon-redo"></use></svg>',
334
+ name: "redo",
335
+ tipPosition: "nw",
336
+ },
337
+ {
338
+ name: "|",
339
+ },
340
+ {
341
+ icon: '<svg><use xlink:href="#vditor-icon-more"></use></svg>',
342
+ name: "more",
343
+ tipPosition: "e",
344
+ },
345
+ {
346
+ hotkey: "⌘'",
347
+ icon:
348
+ '<svg><use xlink:href="#vditor-icon-fullscreen"></use></svg>',
349
+ name: "fullscreen",
350
+ tipPosition: "nw",
351
+ },
352
+ {
353
+ icon: '<svg><use xlink:href="#vditor-icon-edit"></use></svg>',
354
+ name: "edit-mode",
355
+ tipPosition: "nw",
356
+ },
357
+ {
358
+ hotkey: "⌘P",
359
+ icon: '<svg><use xlink:href="#vditor-icon-both"></use></svg>',
360
+ name: "both",
361
+ tipPosition: "nw",
362
+ },
363
+ {
364
+ icon:
365
+ '<svg><use xlink:href="#vditor-icon-preview"></use></svg>',
366
+ name: "preview",
367
+ tipPosition: "nw",
368
+ },
369
+ {
370
+ icon:
371
+ '<svg><use xlink:href="#vditor-icon-align-center"></use></svg>',
372
+ name: "outline",
373
+ tipPosition: "nw",
374
+ },
375
+ {
376
+ icon: '<svg><use xlink:href="#vditor-icon-theme"></use></svg>',
377
+ name: "content-theme",
378
+ tipPosition: "nw",
379
+ },
380
+ {
381
+ icon:
382
+ '<svg><use xlink:href="#vditor-icon-code-theme"></use></svg>',
383
+ name: "code-theme",
384
+ tipPosition: "nw",
385
+ },
386
+ {
387
+ icon: '<svg><use xlink:href="#vditor-icon-bug"></use></svg>',
388
+ name: "devtools",
389
+ tipPosition: "nw",
390
+ },
391
+ {
392
+ icon: '<svg><use xlink:href="#vditor-icon-info"></use></svg>',
393
+ name: "info",
394
+ tipPosition: "nw",
395
+ },
396
+ {
397
+ icon: '<svg><use xlink:href="#vditor-icon-help"></use></svg>',
398
+ name: "help",
399
+ tipPosition: "nw",
400
+ },
401
+ {
402
+ name: "br",
403
+ },
404
+ ];
352
405
  const toolbarResult: IMenuItem[] = [];
353
406
  toolbar.forEach((menuItem: IMenuItem) => {
354
407
  let currentMenuItem = menuItem;
355
408
  toolbarItem.forEach((defaultMenuItem: IMenuItem) => {
356
- if (typeof menuItem === "string" && defaultMenuItem.name === menuItem) {
409
+ if (
410
+ typeof menuItem === "string" &&
411
+ defaultMenuItem.name === menuItem
412
+ ) {
357
413
  currentMenuItem = defaultMenuItem;
358
414
  }
359
- if (typeof menuItem === "object" && defaultMenuItem.name === menuItem.name) {
415
+ if (
416
+ typeof menuItem === "object" &&
417
+ defaultMenuItem.name === menuItem.name
418
+ ) {
360
419
  currentMenuItem = Object.assign({}, defaultMenuItem, menuItem);
361
420
  }
362
421
  });
@@ -22,7 +22,7 @@ export const focusEvent = (vditor: IVditor, editorElement: HTMLElement) => {
22
22
  if (vditor.options.focus) {
23
23
  vditor.options.focus(getMarkdown(vditor));
24
24
  }
25
- hidePanel(vditor, ["subToolbar"]);
25
+ hidePanel(vditor, ["subToolbar", "hint"]);
26
26
  });
27
27
  };
28
28
 
@@ -62,7 +62,7 @@ export const dropEvent = (vditor: IVditor, editorElement: HTMLElement) => {
62
62
  if (event.dataTransfer.getData(Constants.DROP_EDITOR)) {
63
63
  // 编辑器内选中文字拖拽
64
64
  execAfterRender(vditor);
65
- } else if (event.dataTransfer.types[0] === "Files" || event.dataTransfer.types.includes("text/html")) {
65
+ } else if (event.dataTransfer.types.includes("Files") || event.dataTransfer.types.includes("text/html")) {
66
66
  // 外部文件拖入编辑器中或者编辑器内选中文字拖拽
67
67
  paste(vditor, event, {
68
68
  pasteCode: (code: string) => {
@@ -2,7 +2,7 @@ import {Constants} from "../constants";
2
2
  import {input as IRInput} from "../ir/input";
3
3
  import {processAfterRender} from "../ir/process";
4
4
  import {processAfterRender as processSVAfterRender, processPaste} from "../sv/process";
5
- import {uploadFiles} from "../upload";
5
+ import {uploadFiles} from "../upload/index";
6
6
  import {setHeaders} from "../upload/setHeaders";
7
7
  import {afterRenderEvent} from "../wysiwyg/afterRenderEvent";
8
8
  import {input} from "../wysiwyg/input";
@@ -228,9 +228,13 @@ export const listToggle = (vditor: IVditor, range: Range, type: string, cancel =
228
228
  let element;
229
229
  if (type === "list") {
230
230
  element = document.createElement("ul");
231
+ element.setAttribute("data-marker", "*");
231
232
  } else {
232
233
  element = document.createElement("ol");
234
+ element.setAttribute("data-marker", "1.");
233
235
  }
236
+ element.setAttribute("data-block", "0");
237
+ element.setAttribute("data-tight", itemElement.parentElement.getAttribute("data-tight"));
234
238
  element.innerHTML = itemElement.parentElement.innerHTML;
235
239
  itemElement.parentElement.parentNode.replaceChild(element, itemElement.parentElement);
236
240
  }
@@ -973,7 +977,7 @@ export const fixCodeBlock = (vditor: IVditor, event: KeyboardEvent, codeRenderEl
973
977
  if (event.key === "Backspace" && !isCtrl(event) && !event.shiftKey && !event.altKey) {
974
978
  const codePosition = getSelectPosition(codeRenderElement, vditor[vditor.currentMode].element, range);
975
979
  if ((codePosition.start === 0 ||
976
- (codePosition.start === 1 && codeRenderElement.innerText === "\n")) // 空代码块,光标在 \n 后
980
+ (codePosition.start === 1 && codeRenderElement.innerText === "\n")) // 空代码块,光标在 \n 后
977
981
  && range.toString() === "") {
978
982
  codeRenderElement.parentElement.outerHTML =
979
983
  `<p data-block="0"><wbr>${codeRenderElement.firstElementChild.innerHTML}</p>`;
@@ -1089,7 +1093,7 @@ export const fixTask = (vditor: IVditor, range: Range, event: KeyboardEvent) =>
1089
1093
  if (event.key === "Backspace" && !isCtrl(event) && !event.shiftKey && !event.altKey && range.toString() === ""
1090
1094
  && range.startOffset === 1
1091
1095
  && ((startContainer.nodeType === 3 && startContainer.previousSibling &&
1092
- (startContainer.previousSibling as HTMLElement).tagName === "INPUT")
1096
+ (startContainer.previousSibling as HTMLElement).tagName === "INPUT")
1093
1097
  || startContainer.nodeType !== 3)) {
1094
1098
  const previousElement = taskItemElement.previousElementSibling;
1095
1099
  taskItemElement.querySelector("input").remove();
@@ -1260,7 +1264,7 @@ export const paste = async (vditor: IVditor, event: (ClipboardEvent | DragEvent)
1260
1264
  } else {
1261
1265
  textHTML = event.dataTransfer.getData("text/html");
1262
1266
  textPlain = event.dataTransfer.getData("text/plain");
1263
- if (event.dataTransfer.types[0] === "Files") {
1267
+ if (event.dataTransfer.types.includes("Files")) {
1264
1268
  files = event.dataTransfer.items;
1265
1269
  }
1266
1270
  }
@@ -1351,7 +1355,7 @@ export const paste = async (vditor: IVditor, event: (ClipboardEvent | DragEvent)
1351
1355
  if (doc.body) {
1352
1356
  textHTML = doc.body.innerHTML;
1353
1357
  }
1354
-
1358
+ textHTML = Lute.Sanitize(textHTML);
1355
1359
  vditor.wysiwyg.getComments(vditor);
1356
1360
 
1357
1361
  // process code
@@ -1406,7 +1410,7 @@ export const paste = async (vditor: IVditor, event: (ClipboardEvent | DragEvent)
1406
1410
  processPaste(vditor, vditor.lute.HTML2Md(tempElement.innerHTML).trimRight());
1407
1411
  }
1408
1412
  vditor.outline.render(vditor);
1409
- } else if (files.length > 0 && vditor.options.upload.url) {
1413
+ } else if (files.length > 0 && (vditor.options.upload.url || vditor.options.upload.handler)) {
1410
1414
  await uploadFiles(vditor, files);
1411
1415
  } else if (textPlain.trim() !== "" && files.length === 0) {
1412
1416
  if (vditor.currentMode === "ir") {
@@ -83,7 +83,7 @@ export const processCodeRender = (previewPanel: HTMLElement, vditor: IVditor) =>
83
83
  mathRender(previewPanel, {cdn: vditor.options.cdn, math: vditor.options.preview.math});
84
84
  } else {
85
85
  highlightRender(Object.assign({}, vditor.options.preview.hljs), previewPanel, vditor.options.cdn);
86
- codeRender(previewPanel, vditor.options.lang);
86
+ codeRender(previewPanel);
87
87
  }
88
88
 
89
89
  previewPanel.setAttribute("data-render", "1");