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.
- package/README.md +48 -45
- package/dist/index.css +2 -2
- package/dist/index.d.ts +4 -1
- package/dist/index.min.js +722 -858
- package/dist/js/i18n/en_US.js +85 -0
- package/dist/js/i18n/ja_JP.js +85 -0
- package/dist/js/i18n/ko_KR.js +85 -0
- package/dist/js/i18n/ru_RU.js +85 -0
- package/dist/js/i18n/zh_CN.js +85 -0
- package/dist/js/i18n/zh_TW.js +85 -0
- package/dist/js/lute/lute.min.js +31 -28
- package/dist/method.d.ts +4 -1
- package/dist/method.min.js +157 -543
- package/dist/ts/markdown/adapterRender.d.ts +33 -0
- package/dist/ts/markdown/codeRender.d.ts +1 -2
- package/dist/ts/ui/initUI.d.ts +1 -0
- package/dist/ts/wysiwyg/index.d.ts +2 -0
- package/dist/types/index.d.ts +773 -0
- package/package.json +4 -4
- package/src/assets/.DS_Store +0 -0
- package/src/assets/scss/_content.scss +4 -0
- package/src/assets/scss/_reset.scss +11 -0
- package/src/index.ts +156 -97
- package/src/method.ts +6 -2
- package/src/ts/.DS_Store +0 -0
- package/src/ts/export/index.ts +7 -5
- package/src/ts/hint/index.ts +20 -11
- package/src/ts/markdown/abcRender.ts +3 -2
- package/src/ts/markdown/adapterRender.ts +33 -0
- package/src/ts/markdown/chartRender.ts +3 -2
- package/src/ts/markdown/codeRender.ts +5 -6
- package/src/ts/markdown/flowchartRender.ts +3 -2
- package/src/ts/markdown/graphvizRender.ts +13 -11
- package/src/ts/markdown/mathRender.ts +5 -4
- package/src/ts/markdown/mermaidRender.ts +4 -2
- package/src/ts/markdown/mindmapRender.ts +3 -2
- package/src/ts/markdown/plantumlRender.ts +3 -2
- package/src/ts/markdown/previewRender.ts +26 -4
- package/src/ts/preview/image.ts +2 -4
- package/src/ts/preview/index.ts +2 -5
- package/src/ts/toolbar/EditMode.ts +3 -4
- package/src/ts/toolbar/Headings.ts +6 -6
- package/src/ts/toolbar/Info.ts +1 -1
- package/src/ts/toolbar/MenuItem.ts +1 -3
- package/src/ts/toolbar/Record.ts +3 -4
- package/src/ts/ui/initUI.ts +19 -5
- package/src/ts/upload/index.ts +11 -11
- package/src/ts/util/Options.ts +255 -196
- package/src/ts/util/editorCommonEvent.ts +2 -2
- package/src/ts/util/fixBrowserBehavior.ts +10 -6
- package/src/ts/util/processCode.ts +1 -1
- package/src/ts/wysiwyg/highlightToolbarWYSIWYG.ts +298 -138
- package/src/ts/wysiwyg/index.ts +9 -4
- package/CHANGELOG.md +0 -1053
- package/dist/images/.DS_Store +0 -0
- package/dist/js/.DS_Store +0 -0
- package/dist/js/lute/.DS_Store +0 -0
- package/dist/js/mathjax/.DS_Store +0 -0
- package/dist/ts/i18n/index.d.ts +0 -2
- package/src/ts/i18n/index.ts +0 -476
package/src/ts/util/Options.ts
CHANGED
|
@@ -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(
|
|
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
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
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 (
|
|
409
|
+
if (
|
|
410
|
+
typeof menuItem === "string" &&
|
|
411
|
+
defaultMenuItem.name === menuItem
|
|
412
|
+
) {
|
|
357
413
|
currentMenuItem = defaultMenuItem;
|
|
358
414
|
}
|
|
359
|
-
if (
|
|
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
|
|
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
|
-
|
|
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
|
-
|
|
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
|
|
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
|
|
86
|
+
codeRender(previewPanel);
|
|
87
87
|
}
|
|
88
88
|
|
|
89
89
|
previewPanel.setAttribute("data-render", "1");
|