mirror of
https://gitcode.com/gh_mirrors/hy/Hydro.git
synced 2026-10-19 09:38:19 +08:00
ui: file upload support
This commit is contained in:
1 parent
2539dfa412
commit
595f28b1df
5 files changed
+64
-22
No files matched your search
@@ -5,8 +5,8 @@ export const config = {
|
||||
toolbar: [
|
||||
'emoji', 'headings', 'bold', 'italic', 'strike', 'link', '|',
|
||||
'list', 'ordered-list', 'check', 'outdent', 'indent', '|',
|
||||
'quote', 'line', 'code', 'inline-code', '|',
|
||||
'upload', 'record', 'table', '|',
|
||||
'quote', 'line', 'code', 'inline-code', 'table', '|',
|
||||
'upload', 'record', '|',
|
||||
'edit-mode', 'content-theme', 'code-theme', 'export', 'preview',
|
||||
],
|
||||
mode: 'ir',
|
||||
@@ -38,20 +38,11 @@ export default class CmEditor extends DOMAttachedObject {
|
||||
await new Promise((resolve) => {
|
||||
this.editor = new Vditor(ele, {
|
||||
...config,
|
||||
...this.options,
|
||||
after: resolve,
|
||||
input(v) { $dom.text(v); },
|
||||
value,
|
||||
cache: { id: Math.random().toString() },
|
||||
upload: {
|
||||
accept: 'image/*,.mp3, .wav, .zip',
|
||||
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', '');
|
||||
},
|
||||
},
|
||||
});
|
||||
});
|
||||
$(ele).addClass('textbox');
|
||||
@@ -71,10 +62,6 @@ export default class CmEditor extends DOMAttachedObject {
|
||||
return ret;
|
||||
}
|
||||
|
||||
destory() {
|
||||
this.editor.destory();
|
||||
}
|
||||
|
||||
focus() {
|
||||
this.ensureValid();
|
||||
this.editor.focus();
|
||||
|
||||
Reference in new issue
Block a user