add: 讨论

This commit is contained in:
yi-ge 2020-07-10 10:03:49 +08:00
parent ee4be3a0b9
commit 221cd42fb3

View File

@ -101,7 +101,7 @@ export default {
//
if (process.client) {
if (!window.editorObj && window.Vditor) {
const editorConfig = {
window.editorObj = new window.Vditor('editor', {
toolbar: [
'emoji',
'headings',
@ -143,13 +143,59 @@ export default {
toolbarConfig: {
pin: true
},
cache: {
enable: true
},
placeholder: '我们书写的不是代码,而是人生'
})
window.editorReplyObj = new window.Vditor('editor-reply', {
toolbar: [
'emoji',
'headings',
'bold',
'italic',
'strike',
'link',
'list',
'ordered-list',
'outdent',
'indent',
'quote',
'line',
'code',
'inline-code',
'upload',
'insert-before',
'insert-after',
'undo',
'redo',
{
name: 'more',
toolbar: [
'table',
'fullscreen',
'edit-mode',
'check',
'both',
'code-theme',
'content-theme',
'export',
'outline',
'preview',
'format',
'devtools'
]
}],
height: 220,
toolbarConfig: {
pin: true
},
cache: {
enable: false
},
placeholder: '我们书写的不是代码,而是人生'
}
window.editorObj = new window.Vditor('editor', editorConfig)
window.editorReplyObj = new window.Vditor('editor-reply', editorConfig)
})
}
const comments = this.comments
@ -343,19 +389,22 @@ export default {
if (cancel) {
this.replyID = null
this.replyLastID = null
document.getElementById('comment').appendChild(editorReplyObject)
window.location.hash = '_'
} else {
this.replyID = id
this.replyLastID = replyLastID
document.getElementById('comment_ID_' + id).appendChild(editorReplyObject)
const comment = this.commentsMap.get(replyLastID)
window.editorReplyObj.setValue('', true)
window.editorReplyObj.focus()
if (replyLastID !== null) {
window.editorReplyObj.insertValue('> ' + comment.comment_content + ' \n\n\n', true)
// window.editorReplyObj.getCursorPosition()
// window.editorReplyObj.setSelectionRange(pos, pos)
}
this.$nextTick(() => {
window.editorReplyObj.focus()
if (replyLastID !== null) {
window.editorReplyObj.insertValue('> ' + comment.comment_content + ' \n\n\n', true)
} else {
window.editorReplyObj.insertValue('', true)
}
window.location.hash = '#comment_ID_' + id
})
}
}
},