@yltrcc/vditor 0.0.7 โ 0.0.8
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/dist/index.css +2 -2
- package/dist/index.js +14 -7
- package/dist/index.min.js +1 -1
- package/dist/method.js +3 -3
- package/dist/method.min.js +1 -1
- package/dist/ts/wysiwyg/index.d.ts +1 -0
- package/dist/types/index.d.ts +3 -0
- package/package.json +79 -79
- package/src/ts/constants.ts +90 -90
- package/src/ts/markdown/docLink.ts +202 -202
- package/src/ts/toolbar/Info.ts +43 -43
- package/src/ts/util/Options.ts +455 -454
- package/src/ts/wysiwyg/afterRenderEvent.ts +54 -47
- package/src/ts/wysiwyg/highlightToolbarWYSIWYG.ts +1156 -1156
- package/src/ts/wysiwyg/index.ts +2 -1
package/src/ts/util/Options.ts
CHANGED
|
@@ -1,454 +1,455 @@
|
|
|
1
|
-
import {Constants} from "../constants";
|
|
2
|
-
import {merge} from "./merge";
|
|
3
|
-
|
|
4
|
-
export class Options {
|
|
5
|
-
public options: IOptions;
|
|
6
|
-
private defaultOptions: IOptions = {
|
|
7
|
-
rtl: false,
|
|
8
|
-
after: undefined,
|
|
9
|
-
cache: {
|
|
10
|
-
enable: true,
|
|
11
|
-
},
|
|
12
|
-
cdn: Constants.CDN,
|
|
13
|
-
classes: {
|
|
14
|
-
preview: "",
|
|
15
|
-
},
|
|
16
|
-
comment: {
|
|
17
|
-
enable: false,
|
|
18
|
-
},
|
|
19
|
-
counter: {
|
|
20
|
-
enable: false,
|
|
21
|
-
type: "markdown",
|
|
22
|
-
},
|
|
23
|
-
customRenders: [],
|
|
24
|
-
debugger: false,
|
|
25
|
-
fullscreen: {
|
|
26
|
-
index: 90,
|
|
27
|
-
},
|
|
28
|
-
height: "auto",
|
|
29
|
-
hint: {
|
|
30
|
-
delay: 200,
|
|
31
|
-
emoji: {
|
|
32
|
-
"+1": "๐",
|
|
33
|
-
"-1": "๐",
|
|
34
|
-
"confused": "๐",
|
|
35
|
-
"eyes": "๐๏ธ",
|
|
36
|
-
"heart": "โค๏ธ",
|
|
37
|
-
"rocket": "๐๏ธ",
|
|
38
|
-
"smile": "๐",
|
|
39
|
-
"tada": "๐๏ธ",
|
|
40
|
-
},
|
|
41
|
-
emojiPath: `${Constants.CDN}/dist/images/emoji`,
|
|
42
|
-
extend: [],
|
|
43
|
-
parse: true,
|
|
44
|
-
},
|
|
45
|
-
icon: "ant",
|
|
46
|
-
lang: "zh_CN",
|
|
47
|
-
mode: "ir",
|
|
48
|
-
outline: {
|
|
49
|
-
enable: false,
|
|
50
|
-
position: "left",
|
|
51
|
-
},
|
|
52
|
-
placeholder: "",
|
|
53
|
-
preview: {
|
|
54
|
-
actions: ["desktop", "tablet", "mobile", "mp-wechat", "zhihu"],
|
|
55
|
-
delay: 1000,
|
|
56
|
-
hljs: Constants.HLJS_OPTIONS,
|
|
57
|
-
markdown: Constants.MARKDOWN_OPTIONS,
|
|
58
|
-
math: Constants.MATH_OPTIONS,
|
|
59
|
-
maxWidth: 800,
|
|
60
|
-
mode: "both",
|
|
61
|
-
theme: Constants.THEME_OPTIONS,
|
|
62
|
-
render: {
|
|
63
|
-
media: {
|
|
64
|
-
enable: true,
|
|
65
|
-
}
|
|
66
|
-
}
|
|
67
|
-
},
|
|
68
|
-
link: {
|
|
69
|
-
isOpen: true,
|
|
70
|
-
},
|
|
71
|
-
image: {
|
|
72
|
-
isPreview: true,
|
|
73
|
-
},
|
|
74
|
-
resize: {
|
|
75
|
-
enable: false,
|
|
76
|
-
position: "bottom",
|
|
77
|
-
},
|
|
78
|
-
theme: "classic",
|
|
79
|
-
toolbar: [
|
|
80
|
-
"emoji",
|
|
81
|
-
"headings",
|
|
82
|
-
"bold",
|
|
83
|
-
"italic",
|
|
84
|
-
"strike",
|
|
85
|
-
"link",
|
|
86
|
-
"|",
|
|
87
|
-
"list",
|
|
88
|
-
"ordered-list",
|
|
89
|
-
"check",
|
|
90
|
-
"outdent",
|
|
91
|
-
"indent",
|
|
92
|
-
"|",
|
|
93
|
-
"quote",
|
|
94
|
-
"line",
|
|
95
|
-
"code",
|
|
96
|
-
"inline-code",
|
|
97
|
-
"insert-before",
|
|
98
|
-
"insert-after",
|
|
99
|
-
"|",
|
|
100
|
-
"upload",
|
|
101
|
-
"record",
|
|
102
|
-
"table",
|
|
103
|
-
"|",
|
|
104
|
-
"undo",
|
|
105
|
-
"redo",
|
|
106
|
-
"|",
|
|
107
|
-
"fullscreen",
|
|
108
|
-
"edit-mode",
|
|
109
|
-
{
|
|
110
|
-
name: "more",
|
|
111
|
-
toolbar: [
|
|
112
|
-
"both",
|
|
113
|
-
"code-theme",
|
|
114
|
-
"content-theme",
|
|
115
|
-
"export",
|
|
116
|
-
"outline",
|
|
117
|
-
"preview",
|
|
118
|
-
"devtools",
|
|
119
|
-
"info",
|
|
120
|
-
"help",
|
|
121
|
-
],
|
|
122
|
-
},
|
|
123
|
-
],
|
|
124
|
-
toolbarConfig: {
|
|
125
|
-
hide: false,
|
|
126
|
-
pin: false,
|
|
127
|
-
},
|
|
128
|
-
typewriterMode: false,
|
|
129
|
-
undoDelay: 800,
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
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
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
}
|
|
1
|
+
import {Constants} from "../constants";
|
|
2
|
+
import {merge} from "./merge";
|
|
3
|
+
|
|
4
|
+
export class Options {
|
|
5
|
+
public options: IOptions;
|
|
6
|
+
private defaultOptions: IOptions = {
|
|
7
|
+
rtl: false,
|
|
8
|
+
after: undefined,
|
|
9
|
+
cache: {
|
|
10
|
+
enable: true,
|
|
11
|
+
},
|
|
12
|
+
cdn: Constants.CDN,
|
|
13
|
+
classes: {
|
|
14
|
+
preview: "",
|
|
15
|
+
},
|
|
16
|
+
comment: {
|
|
17
|
+
enable: false,
|
|
18
|
+
},
|
|
19
|
+
counter: {
|
|
20
|
+
enable: false,
|
|
21
|
+
type: "markdown",
|
|
22
|
+
},
|
|
23
|
+
customRenders: [],
|
|
24
|
+
debugger: false,
|
|
25
|
+
fullscreen: {
|
|
26
|
+
index: 90,
|
|
27
|
+
},
|
|
28
|
+
height: "auto",
|
|
29
|
+
hint: {
|
|
30
|
+
delay: 200,
|
|
31
|
+
emoji: {
|
|
32
|
+
"+1": "๐",
|
|
33
|
+
"-1": "๐",
|
|
34
|
+
"confused": "๐",
|
|
35
|
+
"eyes": "๐๏ธ",
|
|
36
|
+
"heart": "โค๏ธ",
|
|
37
|
+
"rocket": "๐๏ธ",
|
|
38
|
+
"smile": "๐",
|
|
39
|
+
"tada": "๐๏ธ",
|
|
40
|
+
},
|
|
41
|
+
emojiPath: `${Constants.CDN}/dist/images/emoji`,
|
|
42
|
+
extend: [],
|
|
43
|
+
parse: true,
|
|
44
|
+
},
|
|
45
|
+
icon: "ant",
|
|
46
|
+
lang: "zh_CN",
|
|
47
|
+
mode: "ir",
|
|
48
|
+
outline: {
|
|
49
|
+
enable: false,
|
|
50
|
+
position: "left",
|
|
51
|
+
},
|
|
52
|
+
placeholder: "",
|
|
53
|
+
preview: {
|
|
54
|
+
actions: ["desktop", "tablet", "mobile", "mp-wechat", "zhihu"],
|
|
55
|
+
delay: 1000,
|
|
56
|
+
hljs: Constants.HLJS_OPTIONS,
|
|
57
|
+
markdown: Constants.MARKDOWN_OPTIONS,
|
|
58
|
+
math: Constants.MATH_OPTIONS,
|
|
59
|
+
maxWidth: 800,
|
|
60
|
+
mode: "both",
|
|
61
|
+
theme: Constants.THEME_OPTIONS,
|
|
62
|
+
render: {
|
|
63
|
+
media: {
|
|
64
|
+
enable: true,
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
},
|
|
68
|
+
link: {
|
|
69
|
+
isOpen: true,
|
|
70
|
+
},
|
|
71
|
+
image: {
|
|
72
|
+
isPreview: true,
|
|
73
|
+
},
|
|
74
|
+
resize: {
|
|
75
|
+
enable: false,
|
|
76
|
+
position: "bottom",
|
|
77
|
+
},
|
|
78
|
+
theme: "classic",
|
|
79
|
+
toolbar: [
|
|
80
|
+
"emoji",
|
|
81
|
+
"headings",
|
|
82
|
+
"bold",
|
|
83
|
+
"italic",
|
|
84
|
+
"strike",
|
|
85
|
+
"link",
|
|
86
|
+
"|",
|
|
87
|
+
"list",
|
|
88
|
+
"ordered-list",
|
|
89
|
+
"check",
|
|
90
|
+
"outdent",
|
|
91
|
+
"indent",
|
|
92
|
+
"|",
|
|
93
|
+
"quote",
|
|
94
|
+
"line",
|
|
95
|
+
"code",
|
|
96
|
+
"inline-code",
|
|
97
|
+
"insert-before",
|
|
98
|
+
"insert-after",
|
|
99
|
+
"|",
|
|
100
|
+
"upload",
|
|
101
|
+
"record",
|
|
102
|
+
"table",
|
|
103
|
+
"|",
|
|
104
|
+
"undo",
|
|
105
|
+
"redo",
|
|
106
|
+
"|",
|
|
107
|
+
"fullscreen",
|
|
108
|
+
"edit-mode",
|
|
109
|
+
{
|
|
110
|
+
name: "more",
|
|
111
|
+
toolbar: [
|
|
112
|
+
"both",
|
|
113
|
+
"code-theme",
|
|
114
|
+
"content-theme",
|
|
115
|
+
"export",
|
|
116
|
+
"outline",
|
|
117
|
+
"preview",
|
|
118
|
+
"devtools",
|
|
119
|
+
"info",
|
|
120
|
+
"help",
|
|
121
|
+
],
|
|
122
|
+
},
|
|
123
|
+
],
|
|
124
|
+
toolbarConfig: {
|
|
125
|
+
hide: false,
|
|
126
|
+
pin: false,
|
|
127
|
+
},
|
|
128
|
+
typewriterMode: false,
|
|
129
|
+
undoDelay: 800,
|
|
130
|
+
docLinkDelay: 50,
|
|
131
|
+
upload: {
|
|
132
|
+
extraData: {},
|
|
133
|
+
fieldName: "file[]",
|
|
134
|
+
filename: (name: string) => name.replace(/\W/g, ""),
|
|
135
|
+
linkToImgUrl: "",
|
|
136
|
+
max: 10 * 1024 * 1024,
|
|
137
|
+
multiple: true,
|
|
138
|
+
url: "",
|
|
139
|
+
withCredentials: false,
|
|
140
|
+
},
|
|
141
|
+
value: "",
|
|
142
|
+
width: "auto",
|
|
143
|
+
};
|
|
144
|
+
|
|
145
|
+
constructor(options: IOptions) {
|
|
146
|
+
this.options = options;
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
public merge(): IOptions {
|
|
150
|
+
if (this.options) {
|
|
151
|
+
if (this.options.toolbar) {
|
|
152
|
+
this.options.toolbar = this.mergeToolbar(this.options.toolbar);
|
|
153
|
+
} else {
|
|
154
|
+
this.options.toolbar = this.mergeToolbar(this.defaultOptions.toolbar);
|
|
155
|
+
}
|
|
156
|
+
if (this.options.preview?.theme?.list) {
|
|
157
|
+
this.defaultOptions.preview.theme.list = this.options.preview.theme.list;
|
|
158
|
+
}
|
|
159
|
+
if (this.options.preview?.render?.media?.enable) {
|
|
160
|
+
this.defaultOptions.preview.render.media.enable = this.options.preview.render.media.enable;
|
|
161
|
+
}
|
|
162
|
+
if (this.options.hint?.emoji) {
|
|
163
|
+
this.defaultOptions.hint.emoji = this.options.hint.emoji;
|
|
164
|
+
}
|
|
165
|
+
if (this.options.comment) {
|
|
166
|
+
this.defaultOptions.comment = this.options.comment;
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
if (this.options.cdn) {
|
|
170
|
+
if (!this.options.preview?.theme?.path) {
|
|
171
|
+
this.defaultOptions.preview.theme.path = `${this.options.cdn}/dist/css/content-theme`
|
|
172
|
+
}
|
|
173
|
+
if (!this.options.hint?.emojiPath) {
|
|
174
|
+
this.defaultOptions.hint.emojiPath = `${this.options.cdn}/dist/images/emoji`;
|
|
175
|
+
}
|
|
176
|
+
}
|
|
177
|
+
}
|
|
178
|
+
|
|
179
|
+
const mergedOptions = merge(this.defaultOptions, this.options);
|
|
180
|
+
|
|
181
|
+
if (mergedOptions.cache.enable && !mergedOptions.cache.id) {
|
|
182
|
+
throw new Error(
|
|
183
|
+
"need options.cache.id, see https://ld246.com/article/1549638745630#options",
|
|
184
|
+
);
|
|
185
|
+
}
|
|
186
|
+
|
|
187
|
+
return mergedOptions;
|
|
188
|
+
}
|
|
189
|
+
|
|
190
|
+
private mergeToolbar(toolbar: Array<string | IMenuItem>) {
|
|
191
|
+
const toolbarItem = [
|
|
192
|
+
{
|
|
193
|
+
icon: '<svg><use xlink:href="#vditor-icon-export"></use></svg>',
|
|
194
|
+
name: "export",
|
|
195
|
+
tipPosition: "ne",
|
|
196
|
+
},
|
|
197
|
+
{
|
|
198
|
+
hotkey: "โE",
|
|
199
|
+
icon: '<svg><use xlink:href="#vditor-icon-emoji"></use></svg>',
|
|
200
|
+
name: "emoji",
|
|
201
|
+
tipPosition: "ne",
|
|
202
|
+
},
|
|
203
|
+
{
|
|
204
|
+
hotkey: "โH",
|
|
205
|
+
icon:
|
|
206
|
+
'<svg><use xlink:href="#vditor-icon-headings"></use></svg>',
|
|
207
|
+
name: "headings",
|
|
208
|
+
tipPosition: "ne",
|
|
209
|
+
},
|
|
210
|
+
{
|
|
211
|
+
hotkey: "โB",
|
|
212
|
+
icon: '<svg><use xlink:href="#vditor-icon-bold"></use></svg>',
|
|
213
|
+
name: "bold",
|
|
214
|
+
prefix: "**",
|
|
215
|
+
suffix: "**",
|
|
216
|
+
tipPosition: "ne",
|
|
217
|
+
},
|
|
218
|
+
{
|
|
219
|
+
hotkey: "โI",
|
|
220
|
+
icon: '<svg><use xlink:href="#vditor-icon-italic"></use></svg>',
|
|
221
|
+
name: "italic",
|
|
222
|
+
prefix: "*",
|
|
223
|
+
suffix: "*",
|
|
224
|
+
tipPosition: "ne",
|
|
225
|
+
},
|
|
226
|
+
{
|
|
227
|
+
hotkey: "โD",
|
|
228
|
+
icon: '<svg><use xlink:href="#vditor-icon-strike"></use></svg>',
|
|
229
|
+
name: "strike",
|
|
230
|
+
prefix: "~~",
|
|
231
|
+
suffix: "~~",
|
|
232
|
+
tipPosition: "ne",
|
|
233
|
+
},
|
|
234
|
+
{
|
|
235
|
+
hotkey: "โK",
|
|
236
|
+
icon: '<svg><use xlink:href="#vditor-icon-link"></use></svg>',
|
|
237
|
+
name: "link",
|
|
238
|
+
prefix: "[",
|
|
239
|
+
suffix: "](https://)",
|
|
240
|
+
tipPosition: "n",
|
|
241
|
+
},
|
|
242
|
+
{
|
|
243
|
+
name: "|",
|
|
244
|
+
},
|
|
245
|
+
{
|
|
246
|
+
hotkey: "โL",
|
|
247
|
+
icon: '<svg><use xlink:href="#vditor-icon-list"></use></svg>',
|
|
248
|
+
name: "list",
|
|
249
|
+
prefix: "* ",
|
|
250
|
+
tipPosition: "n",
|
|
251
|
+
},
|
|
252
|
+
{
|
|
253
|
+
hotkey: "โO",
|
|
254
|
+
icon:
|
|
255
|
+
'<svg><use xlink:href="#vditor-icon-ordered-list"></use></svg>',
|
|
256
|
+
name: "ordered-list",
|
|
257
|
+
prefix: "1. ",
|
|
258
|
+
tipPosition: "n",
|
|
259
|
+
},
|
|
260
|
+
{
|
|
261
|
+
hotkey: "โJ",
|
|
262
|
+
icon: '<svg><use xlink:href="#vditor-icon-check"></use></svg>',
|
|
263
|
+
name: "check",
|
|
264
|
+
prefix: "* [ ] ",
|
|
265
|
+
tipPosition: "n",
|
|
266
|
+
},
|
|
267
|
+
{
|
|
268
|
+
hotkey: "โงโI",
|
|
269
|
+
icon:
|
|
270
|
+
'<svg><use xlink:href="#vditor-icon-outdent"></use></svg>',
|
|
271
|
+
name: "outdent",
|
|
272
|
+
tipPosition: "n",
|
|
273
|
+
},
|
|
274
|
+
{
|
|
275
|
+
hotkey: "โงโO",
|
|
276
|
+
icon: '<svg><use xlink:href="#vditor-icon-indent"></use></svg>',
|
|
277
|
+
name: "indent",
|
|
278
|
+
tipPosition: "n",
|
|
279
|
+
},
|
|
280
|
+
{
|
|
281
|
+
name: "|",
|
|
282
|
+
},
|
|
283
|
+
{
|
|
284
|
+
hotkey: "โ;",
|
|
285
|
+
icon: '<svg><use xlink:href="#vditor-icon-quote"></use></svg>',
|
|
286
|
+
name: "quote",
|
|
287
|
+
prefix: "> ",
|
|
288
|
+
tipPosition: "n",
|
|
289
|
+
},
|
|
290
|
+
{
|
|
291
|
+
hotkey: "โงโH",
|
|
292
|
+
icon: '<svg><use xlink:href="#vditor-icon-line"></use></svg>',
|
|
293
|
+
name: "line",
|
|
294
|
+
prefix: "---",
|
|
295
|
+
tipPosition: "n",
|
|
296
|
+
},
|
|
297
|
+
{
|
|
298
|
+
hotkey: "โU",
|
|
299
|
+
icon: '<svg><use xlink:href="#vditor-icon-code"></use></svg>',
|
|
300
|
+
name: "code",
|
|
301
|
+
prefix: "```",
|
|
302
|
+
suffix: "\n```",
|
|
303
|
+
tipPosition: "n",
|
|
304
|
+
},
|
|
305
|
+
{
|
|
306
|
+
hotkey: "โG",
|
|
307
|
+
icon:
|
|
308
|
+
'<svg><use xlink:href="#vditor-icon-inline-code"></use></svg>',
|
|
309
|
+
name: "inline-code",
|
|
310
|
+
prefix: "`",
|
|
311
|
+
suffix: "`",
|
|
312
|
+
tipPosition: "n",
|
|
313
|
+
},
|
|
314
|
+
{
|
|
315
|
+
hotkey: "โงโB",
|
|
316
|
+
icon: '<svg><use xlink:href="#vditor-icon-before"></use></svg>',
|
|
317
|
+
name: "insert-before",
|
|
318
|
+
tipPosition: "n",
|
|
319
|
+
},
|
|
320
|
+
{
|
|
321
|
+
hotkey: "โงโE",
|
|
322
|
+
icon: '<svg><use xlink:href="#vditor-icon-after"></use></svg>',
|
|
323
|
+
name: "insert-after",
|
|
324
|
+
tipPosition: "n",
|
|
325
|
+
},
|
|
326
|
+
{
|
|
327
|
+
name: "|",
|
|
328
|
+
},
|
|
329
|
+
{
|
|
330
|
+
icon: '<svg><use xlink:href="#vditor-icon-upload"></use></svg>',
|
|
331
|
+
name: "upload",
|
|
332
|
+
tipPosition: "n",
|
|
333
|
+
},
|
|
334
|
+
{
|
|
335
|
+
icon: '<svg><use xlink:href="#vditor-icon-record"></use></svg>',
|
|
336
|
+
name: "record",
|
|
337
|
+
tipPosition: "n",
|
|
338
|
+
},
|
|
339
|
+
{
|
|
340
|
+
hotkey: "โM",
|
|
341
|
+
icon: '<svg><use xlink:href="#vditor-icon-table"></use></svg>',
|
|
342
|
+
name: "table",
|
|
343
|
+
prefix: "| col1",
|
|
344
|
+
suffix:
|
|
345
|
+
" | col2 | col3 |\n| --- | --- | --- |\n| | | |\n| | | |",
|
|
346
|
+
tipPosition: "n",
|
|
347
|
+
},
|
|
348
|
+
{
|
|
349
|
+
name: "|",
|
|
350
|
+
},
|
|
351
|
+
{
|
|
352
|
+
hotkey: "โZ",
|
|
353
|
+
icon: '<svg><use xlink:href="#vditor-icon-undo"></use></svg>',
|
|
354
|
+
name: "undo",
|
|
355
|
+
tipPosition: "nw",
|
|
356
|
+
},
|
|
357
|
+
{
|
|
358
|
+
hotkey: "โY",
|
|
359
|
+
icon: '<svg><use xlink:href="#vditor-icon-redo"></use></svg>',
|
|
360
|
+
name: "redo",
|
|
361
|
+
tipPosition: "nw",
|
|
362
|
+
},
|
|
363
|
+
{
|
|
364
|
+
name: "|",
|
|
365
|
+
},
|
|
366
|
+
{
|
|
367
|
+
icon: '<svg><use xlink:href="#vditor-icon-more"></use></svg>',
|
|
368
|
+
name: "more",
|
|
369
|
+
tipPosition: "e",
|
|
370
|
+
},
|
|
371
|
+
{
|
|
372
|
+
hotkey: "โ'",
|
|
373
|
+
icon:
|
|
374
|
+
'<svg><use xlink:href="#vditor-icon-fullscreen"></use></svg>',
|
|
375
|
+
name: "fullscreen",
|
|
376
|
+
tipPosition: "nw",
|
|
377
|
+
},
|
|
378
|
+
{
|
|
379
|
+
icon: '<svg><use xlink:href="#vditor-icon-edit"></use></svg>',
|
|
380
|
+
name: "edit-mode",
|
|
381
|
+
tipPosition: "nw",
|
|
382
|
+
},
|
|
383
|
+
{
|
|
384
|
+
hotkey: "โP",
|
|
385
|
+
icon: '<svg><use xlink:href="#vditor-icon-both"></use></svg>',
|
|
386
|
+
name: "both",
|
|
387
|
+
tipPosition: "nw",
|
|
388
|
+
},
|
|
389
|
+
{
|
|
390
|
+
icon:
|
|
391
|
+
'<svg><use xlink:href="#vditor-icon-preview"></use></svg>',
|
|
392
|
+
name: "preview",
|
|
393
|
+
tipPosition: "nw",
|
|
394
|
+
},
|
|
395
|
+
{
|
|
396
|
+
icon:
|
|
397
|
+
'<svg><use xlink:href="#vditor-icon-align-center"></use></svg>',
|
|
398
|
+
name: "outline",
|
|
399
|
+
tipPosition: "nw",
|
|
400
|
+
},
|
|
401
|
+
{
|
|
402
|
+
icon: '<svg><use xlink:href="#vditor-icon-theme"></use></svg>',
|
|
403
|
+
name: "content-theme",
|
|
404
|
+
tipPosition: "nw",
|
|
405
|
+
},
|
|
406
|
+
{
|
|
407
|
+
icon:
|
|
408
|
+
'<svg><use xlink:href="#vditor-icon-code-theme"></use></svg>',
|
|
409
|
+
name: "code-theme",
|
|
410
|
+
tipPosition: "nw",
|
|
411
|
+
},
|
|
412
|
+
{
|
|
413
|
+
icon: '<svg><use xlink:href="#vditor-icon-bug"></use></svg>',
|
|
414
|
+
name: "devtools",
|
|
415
|
+
tipPosition: "nw",
|
|
416
|
+
},
|
|
417
|
+
{
|
|
418
|
+
icon: '<svg><use xlink:href="#vditor-icon-info"></use></svg>',
|
|
419
|
+
name: "info",
|
|
420
|
+
tipPosition: "nw",
|
|
421
|
+
},
|
|
422
|
+
{
|
|
423
|
+
icon: '<svg><use xlink:href="#vditor-icon-help"></use></svg>',
|
|
424
|
+
name: "help",
|
|
425
|
+
tipPosition: "nw",
|
|
426
|
+
},
|
|
427
|
+
{
|
|
428
|
+
name: "br",
|
|
429
|
+
},
|
|
430
|
+
];
|
|
431
|
+
const toolbarResult: IMenuItem[] = [];
|
|
432
|
+
toolbar.forEach((menuItem: IMenuItem) => {
|
|
433
|
+
let currentMenuItem = menuItem;
|
|
434
|
+
toolbarItem.forEach((defaultMenuItem: IMenuItem) => {
|
|
435
|
+
if (
|
|
436
|
+
typeof menuItem === "string" &&
|
|
437
|
+
defaultMenuItem.name === menuItem
|
|
438
|
+
) {
|
|
439
|
+
currentMenuItem = defaultMenuItem;
|
|
440
|
+
}
|
|
441
|
+
if (
|
|
442
|
+
typeof menuItem === "object" &&
|
|
443
|
+
defaultMenuItem.name === menuItem.name
|
|
444
|
+
) {
|
|
445
|
+
currentMenuItem = Object.assign({}, defaultMenuItem, menuItem);
|
|
446
|
+
}
|
|
447
|
+
});
|
|
448
|
+
if (menuItem.toolbar) {
|
|
449
|
+
currentMenuItem.toolbar = this.mergeToolbar(menuItem.toolbar);
|
|
450
|
+
}
|
|
451
|
+
toolbarResult.push(currentMenuItem);
|
|
452
|
+
});
|
|
453
|
+
return toolbarResult;
|
|
454
|
+
}
|
|
455
|
+
}
|