refactor: Remove useless react data and destory ace editor

This commit is contained in:
freedomlang 2019-12-05 17:36:29 +08:00 committed by Henrique Dias
parent 12d6415f7f
commit ae893abc5f
1 changed files with 4 additions and 8 deletions

View File

@ -18,10 +18,7 @@ export default {
...mapState(['req'])
},
data: function () {
return {
content: null,
editor: null
}
return {}
},
created () {
window.addEventListener('keydown', this.keyEvent)
@ -30,16 +27,15 @@ export default {
beforeDestroy () {
window.removeEventListener('keydown', this.keyEvent)
document.getElementById('save-button').removeEventListener('click', this.save)
this.editor.destroy();
},
mounted: function () {
if (this.req.content === undefined || this.req.content === null) {
this.req.content = ''
}
const fileContent = this.req.content || '';
this.editor = ace.edit('editor', {
maxLines: Infinity,
minLines: 20,
value: this.req.content,
value: fileContent,
showPrintMargin: false,
readOnly: this.req.type === 'textImmutable',
theme: 'ace/theme/chrome',