update vditor config

This commit is contained in:
x ronger 2020-10-18 14:43:02 +08:00
parent 119e4ed0d9
commit e21fb6d829
6 changed files with 169 additions and 172 deletions

View File

@ -86,6 +86,7 @@ export default {
return { return {
tokenURL: { tokenURL: {
URL: '', URL: '',
linkToImageURL: '',
token: '' token: ''
}, },
tagIconPath: '', tagIconPath: '',
@ -97,9 +98,8 @@ export default {
methods: { methods: {
_initEditor(data) { _initEditor(data) {
let _ts = this; let _ts = this;
let toolbar;
if (window.innerWidth < 768) { let toolbar = [
toolbar = [
'emoji', 'emoji',
'headings', 'headings',
'bold', 'bold',
@ -128,20 +128,15 @@ export default {
'redo', 'redo',
'|', '|',
'edit-mode', 'edit-mode',
'content-theme',
'code-theme',
{ {
name: 'more', name: 'more',
toolbar: [ toolbar: [
'fullscreen', 'fullscreen',
'both', 'both',
'format',
'preview', 'preview',
'info', 'info'
'help',
], ],
}] }]
}
return new Vue.Vditor(data.id, { return new Vue.Vditor(data.id, {
toolbar, toolbar,
mode: 'sv', mode: 'sv',
@ -179,9 +174,11 @@ export default {
upload: { upload: {
max: 10 * 1024 * 1024, max: 10 * 1024 * 1024,
url: this.tokenURL.URL, url: this.tokenURL.URL,
linkToImgUrl: this.tokenURL.URL, linkToImgUrl: this.tokenURL.linkToImageURL,
token: this.tokenURL.token, token: this.tokenURL.token,
filename: name => name.replace(/\?|\\|\/|:|\||<|>|\*|\[|\]|\s+/g, '-') filename: name => name.replace(/[^(a-zA-Z0-9\u4e00-\u9fa5\.)]/g, '').
replace(/[\?\\/:|<>\*\[\]\(\)\$%\{\}@~]/g, '').
replace('/\\s/g', '')
}, },
height: data.height, height: data.height,
counter: 102400, counter: 102400,
@ -248,8 +245,9 @@ export default {
if (res) { if (res) {
_ts.$store.commit('setUploadHeaders', res.uploadToken); _ts.$store.commit('setUploadHeaders', res.uploadToken);
_ts.$set(_ts, 'tokenURL', { _ts.$set(_ts, 'tokenURL', {
token: res.uploadToken || '', token: responseData.uploadToken || '',
URL: res.uploadURL || '', URL: responseData.uploadURL || '',
linkToImageURL: responseData.linkToImageURL || ''
}) })
} }
}); });

View File

@ -102,6 +102,7 @@ export default {
loading: false, loading: false,
tokenURL: { tokenURL: {
URL: '', URL: '',
linkToImageURL: '',
token: '' token: ''
}, },
topicIconPath: '', topicIconPath: '',
@ -111,9 +112,8 @@ export default {
methods: { methods: {
_initEditor(data) { _initEditor(data) {
let _ts = this; let _ts = this;
let toolbar;
if (window.innerWidth < 768) { let toolbar = [
toolbar = [
'emoji', 'emoji',
'headings', 'headings',
'bold', 'bold',
@ -142,20 +142,15 @@ export default {
'redo', 'redo',
'|', '|',
'edit-mode', 'edit-mode',
'content-theme',
'code-theme',
{ {
name: 'more', name: 'more',
toolbar: [ toolbar: [
'fullscreen', 'fullscreen',
'both', 'both',
'format',
'preview', 'preview',
'info', 'info'
'help',
], ],
}] }]
}
return new Vue.Vditor(data.id, { return new Vue.Vditor(data.id, {
toolbar, toolbar,
mode: 'sv', mode: 'sv',
@ -193,9 +188,11 @@ export default {
upload: { upload: {
max: 10 * 1024 * 1024, max: 10 * 1024 * 1024,
url: this.tokenURL.URL, url: this.tokenURL.URL,
linkToImgUrl: this.tokenURL.URL, linkToImgUrl: this.tokenURL.linkToImageURL,
token: this.tokenURL.token, token: this.tokenURL.token,
filename: name => name.replace(/\?|\\|\/|:|\||<|>|\*|\[|\]|\s+/g, '-') filename: name => name.replace(/[^(a-zA-Z0-9\u4e00-\u9fa5\.)]/g, '').
replace(/[\?\\/:|<>\*\[\]\(\)\$%\{\}@~]/g, '').
replace('/\\s/g', '')
}, },
height: data.height, height: data.height,
counter: 102400, counter: 102400,

View File

@ -71,7 +71,11 @@
data() { data() {
return { return {
contentEditor: null, contentEditor: null,
tokenURL: {}, tokenURL: {
URL: '',
linkToImageURL: '',
token: ''
},
idArticle: 0, idArticle: 0,
articleTitle: '', articleTitle: '',
articleContent: '', articleContent: '',
@ -88,51 +92,45 @@
methods: { methods: {
_initEditor(data) { _initEditor(data) {
let _ts = this; let _ts = this;
let toolbar;
if (window.innerWidth < 768) { let toolbar = [
toolbar = [ 'emoji',
'emoji', 'headings',
'headings', 'bold',
'bold', 'italic',
'italic', 'strike',
'strike', 'link',
'link', '|',
'|', 'list',
'list', 'ordered-list',
'ordered-list', 'check',
'check', 'outdent',
'outdent', 'indent',
'indent', '|',
'|', 'quote',
'quote', 'line',
'line', 'code',
'code', 'inline-code',
'inline-code', 'insert-before',
'insert-before', 'insert-after',
'insert-after', '|',
'|', 'upload',
'upload', // 'record',
'record', 'table',
'table', '|',
'|', 'undo',
'undo', 'redo',
'redo', '|',
'|', 'edit-mode',
'edit-mode', {
'content-theme', name: 'more',
'code-theme', toolbar: [
{ 'fullscreen',
name: 'more', 'both',
toolbar: [ 'preview',
'fullscreen', 'info'
'both', ],
'format', }]
'preview',
'info',
'help',
],
}]
}
return new Vue.Vditor(data.id, { return new Vue.Vditor(data.id, {
toolbar, toolbar,
mode: 'sv', mode: 'sv',
@ -170,9 +168,11 @@
upload: { upload: {
max: 10 * 1024 * 1024, max: 10 * 1024 * 1024,
url: this.tokenURL.URL, url: this.tokenURL.URL,
linkToImgUrl: this.tokenURL.URL, linkToImgUrl: this.tokenURL.linkToImageURL,
token: this.tokenURL.token, token: this.tokenURL.token,
filename: name => name.replace(/\?|\\|\/|:|\||<|>|\*|\[|\]|\s+/g, '-') filename: name => name.replace(/[^(a-zA-Z0-9\u4e00-\u9fa5\.)]/g, '').
replace(/[\?\\/:|<>\*\[\]\(\)\$%\{\}@~]/g, '').
replace('/\\s/g', '')
}, },
height: data.height, height: data.height,
counter: 102400, counter: 102400,
@ -298,6 +298,7 @@
if (res) { if (res) {
if (res.message) { if (res.message) {
_ts.$message(res.message); _ts.$message(res.message);
_ts.doLoading = false;
return false; return false;
} }
localStorage.removeItem('article-title'); localStorage.removeItem('article-title');
@ -326,6 +327,7 @@
_ts.$set(_ts, 'tokenURL', { _ts.$set(_ts, 'tokenURL', {
token: responseData.uploadToken || '', token: responseData.uploadToken || '',
URL: responseData.uploadURL || '', URL: responseData.uploadURL || '',
linkToImageURL: responseData.linkToImageURL || ''
}) })
} }

View File

@ -1,4 +1,4 @@
<template> template>
<client-only> <client-only>
<el-row class="wrapper" v-if="user"> <el-row class="wrapper" v-if="user">
<el-col> <el-col>
@ -55,7 +55,11 @@
data() { data() {
return { return {
contentEditor: null, contentEditor: null,
tokenURL: {}, tokenURL: {
URL: '',
linkToImageURL: '',
token: ''
},
drawer: false, drawer: false,
direction: 'btt', direction: 'btt',
initEditor: false, initEditor: false,
@ -77,51 +81,45 @@
methods: { methods: {
_initEditor(data) { _initEditor(data) {
let _ts = this; let _ts = this;
let toolbar;
if (window.innerWidth < 768) { let toolbar = [
toolbar = [ 'emoji',
'emoji', 'headings',
'headings', 'bold',
'bold', 'italic',
'italic', 'strike',
'strike', 'link',
'link', '|',
'|', 'list',
'list', 'ordered-list',
'ordered-list', 'check',
'check', 'outdent',
'outdent', 'indent',
'indent', '|',
'|', 'quote',
'quote', 'line',
'line', 'code',
'code', 'inline-code',
'inline-code', 'insert-before',
'insert-before', 'insert-after',
'insert-after', '|',
'|', 'upload',
'upload', 'record',
'record', 'table',
'table', '|',
'|', 'undo',
'undo', 'redo',
'redo', '|',
'|', 'edit-mode',
'edit-mode', {
'content-theme', name: 'more',
'code-theme', toolbar: [
{ 'fullscreen',
name: 'more', 'both',
toolbar: [ 'preview',
'fullscreen', 'info'
'both', ],
'format', }]
'preview',
'info',
'help',
],
}]
}
return new Vue.Vditor(data.id, { return new Vue.Vditor(data.id, {
toolbar, toolbar,
mode: 'sv', mode: 'sv',
@ -150,10 +148,12 @@
}, },
upload: { upload: {
max: 10 * 1024 * 1024, max: 10 * 1024 * 1024,
url: this.tokenURL?.URL, url: this.tokenURL.URL,
linkToImgUrl: this.tokenURL?.URL, linkToImgUrl: this.tokenURL.linkToImageURL,
token: this.tokenURL?.token, token: this.tokenURL.token,
filename: name => name.replace(/\?|\\|\/|:|\||<|>|\*|\[|\]|\s+/g, '-') filename: name => name.replace(/[^(a-zA-Z0-9\u4e00-\u9fa5\.)]/g, '').
replace(/[\?\\/:|<>\*\[\]\(\)\$%\{\}@~]/g, '').
replace('/\\s/g', '')
}, },
height: data.height, height: data.height,
counter: 102400, counter: 102400,
@ -194,6 +194,7 @@
_ts.$set(_ts, 'tokenURL', { _ts.$set(_ts, 'tokenURL', {
token: responseData.uploadToken || '', token: responseData.uploadToken || '',
URL: responseData.uploadURL || '', URL: responseData.uploadURL || '',
linkToImageURL: responseData.linkToImageURL || ''
}) })
} }
} }

View File

@ -93,6 +93,7 @@
loading: false, loading: false,
tokenURL: { tokenURL: {
URL: '', URL: '',
linkToImageURL: '',
token: '' token: ''
}, },
headImgUrl: '', headImgUrl: '',
@ -102,51 +103,45 @@
methods: { methods: {
_initEditor(data) { _initEditor(data) {
let _ts = this; let _ts = this;
let toolbar;
if (window.innerWidth < 768) { let toolbar = [
toolbar = [ 'emoji',
'emoji', 'headings',
'headings', 'bold',
'bold', 'italic',
'italic', 'strike',
'strike', 'link',
'link', '|',
'|', 'list',
'list', 'ordered-list',
'ordered-list', 'check',
'check', 'outdent',
'outdent', 'indent',
'indent', '|',
'|', 'quote',
'quote', 'line',
'line', 'code',
'code', 'inline-code',
'inline-code', 'insert-before',
'insert-before', 'insert-after',
'insert-after', '|',
'|', 'upload',
'upload', 'record',
'record', 'table',
'table', '|',
'|', 'undo',
'undo', 'redo',
'redo', '|',
'|', 'edit-mode',
'edit-mode', {
'content-theme', name: 'more',
'code-theme', toolbar: [
{ 'fullscreen',
name: 'more', 'both',
toolbar: [ 'preview',
'fullscreen', 'info'
'both', ],
'format', }]
'preview',
'info',
'help',
],
}]
}
return new Vue.Vditor(data.id, { return new Vue.Vditor(data.id, {
toolbar, toolbar,
mode: 'sv', mode: 'sv',
@ -179,9 +174,11 @@
upload: { upload: {
max: 10 * 1024 * 1024, max: 10 * 1024 * 1024,
url: this.tokenURL.URL, url: this.tokenURL.URL,
linkToImgUrl: this.tokenURL.URL, linkToImgUrl: this.tokenURL.linkToImageURL,
token: this.tokenURL.token, token: this.tokenURL.token,
filename: name => name.replace(/\?|\\|\/|:|\||<|>|\*|\[|\]|\s+/g, '-') filename: name => name.replace(/[^(a-zA-Z0-9\u4e00-\u9fa5\.)]/g, '').
replace(/[\?\\/:|<>\*\[\]\(\)\$%\{\}@~]/g, '').
replace('/\\s/g', '')
}, },
height: data.height, height: data.height,
counter: 102400, counter: 102400,
@ -279,8 +276,9 @@
if (res) { if (res) {
_ts.$store.commit('setUploadHeaders', res.uploadToken); _ts.$store.commit('setUploadHeaders', res.uploadToken);
_ts.$set(_ts, 'tokenURL', { _ts.$set(_ts, 'tokenURL', {
token: res.uploadToken || '', token: responseData.uploadToken || '',
URL: res.uploadURL || '', URL: responseData.uploadURL || '',
linkToImageURL: responseData.linkToImageURL || ''
}) })
} }
}); });

View File

@ -97,6 +97,7 @@
svgShow: false, svgShow: false,
tokenURL: { tokenURL: {
URL: '', URL: '',
linkToImageURL: '',
token: '' token: ''
}, },
avatarUrl: '', avatarUrl: '',