forked from Vanessa219/vditor
-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.js
104 lines (101 loc) · 2.08 KB
/
index.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
import Vditor from '../src/index'
import '../src/assets/scss/index.scss'
// new VConsole()
let toolbar
if (window.innerWidth < 768) {
toolbar = [
'emoji',
'headings',
'bold',
'italic',
'strike',
'link',
'|',
'list',
'ordered-list',
'check',
'outdent',
'indent',
'|',
'quote',
'line',
'code',
'inline-code',
'insert-before',
'insert-after',
'|',
'upload',
'record',
'table',
'|',
'undo',
'redo',
'|',
'edit-mode',
'content-theme',
'code-theme',
'export',
{
name: 'more',
toolbar: [
'fullscreen',
'both',
'preview',
'info',
'help',
],
}]
}
window.vditor = new Vditor('vditor', {
_lutePath: `http://192.168.0.107:9090/lute.min.js?${new Date().getTime()}`,
// _lutePath: 'src/js/lute/lute.min.js',
toolbar,
mode: 'wysiwyg',
height: window.innerHeight + 100,
outline: true,
debugger: true,
typewriterMode: true,
placeholder: 'Hello, Vditor!',
preview: {
markdown: {
toc: true,
},
},
toolbarConfig: {
pin: true,
},
counter: {
enable: true,
type: 'text',
},
hint: {
emojiPath: 'https://cdn.jsdelivr.net/npm/vditor@1.8.3/dist/images/emoji',
emojiTail: '<a href="https://hacpai.com/settings/function" target="_blank">设置常用表情</a>',
emoji: {
'sd': '💔',
'j': 'https://unpkg.com/vditor@1.3.1/dist/images/emoji/j.png',
},
at: (key) => {
if ('vanessa'.indexOf(key.toLocaleLowerCase()) > -1) {
return [
{
value: '@Vanessa',
html: '<img src="https://avatars0.githubusercontent.com/u/970828?s=60&v=4"/> Vanessa',
}]
}
return []
},
},
tab: '\t',
upload: {
accept: 'image/*,.mp3, .wav, .rar',
token: 'test',
url: '/api/upload/editor',
linkToImgUrl: '/api/upload/fetch',
filename (name) {
return name.replace(/[^(a-zA-Z0-9\u4e00-\u9fa5\.)]/g, '').
replace(/[\?\\/:|<>\*\[\]\(\)\$%\{\}@~]/g, '').
replace('/\\s/g', '')
},
},
})