feat: show compact vditor toolbar on mobile

This commit is contained in:
Tim
2025-08-06 19:32:56 +08:00
parent 05dbeccdd7
commit fbaa05f146
2 changed files with 24 additions and 19 deletions

View File

@@ -235,7 +235,7 @@ body {
} }
.vditor-toolbar { .vditor-toolbar {
display: none; overflow-x: auto;
} }
.about-content h1, .about-content h1,

View File

@@ -38,6 +38,28 @@ export function createVditor(editorId, options = {}) {
return searchUsers(value) return searchUsers(value)
} }
const isMobile = window.innerWidth <= 768
const toolbar = isMobile
? ['emoji', 'bold', 'italic', 'strike', '|', 'link', 'upload']
: [
'emoji',
'bold',
'italic',
'strike',
'|',
'list',
'line',
'quote',
'code',
'inline-code',
'|',
'undo',
'redo',
'|',
'link',
'upload'
]
let vditor let vditor
vditor = new Vditor(editorId, { vditor = new Vditor(editorId, {
placeholder, placeholder,
@@ -62,24 +84,7 @@ export function createVditor(editorId, options = {}) {
], ],
}, },
cdn: 'https://openisle-1307107697.cos.ap-guangzhou.myqcloud.com/assert/vditor', cdn: 'https://openisle-1307107697.cos.ap-guangzhou.myqcloud.com/assert/vditor',
toolbar: [ toolbar,
'emoji',
'bold',
'italic',
'strike',
'|',
'list',
'line',
'quote',
'code',
'inline-code',
'|',
'undo',
'redo',
'|',
'link',
'upload'
],
upload: { upload: {
accept: 'image/*,video/*', accept: 'image/*,video/*',
multiple: false, multiple: false,