refactor: Remove useless react data and destory ace editor
This commit is contained in:
parent
12d6415f7f
commit
ae893abc5f
|
@ -18,10 +18,7 @@ export default {
|
||||||
...mapState(['req'])
|
...mapState(['req'])
|
||||||
},
|
},
|
||||||
data: function () {
|
data: function () {
|
||||||
return {
|
return {}
|
||||||
content: null,
|
|
||||||
editor: null
|
|
||||||
}
|
|
||||||
},
|
},
|
||||||
created () {
|
created () {
|
||||||
window.addEventListener('keydown', this.keyEvent)
|
window.addEventListener('keydown', this.keyEvent)
|
||||||
|
@ -30,16 +27,15 @@ export default {
|
||||||
beforeDestroy () {
|
beforeDestroy () {
|
||||||
window.removeEventListener('keydown', this.keyEvent)
|
window.removeEventListener('keydown', this.keyEvent)
|
||||||
document.getElementById('save-button').removeEventListener('click', this.save)
|
document.getElementById('save-button').removeEventListener('click', this.save)
|
||||||
|
this.editor.destroy();
|
||||||
},
|
},
|
||||||
mounted: function () {
|
mounted: function () {
|
||||||
if (this.req.content === undefined || this.req.content === null) {
|
const fileContent = this.req.content || '';
|
||||||
this.req.content = ''
|
|
||||||
}
|
|
||||||
|
|
||||||
this.editor = ace.edit('editor', {
|
this.editor = ace.edit('editor', {
|
||||||
maxLines: Infinity,
|
maxLines: Infinity,
|
||||||
minLines: 20,
|
minLines: 20,
|
||||||
value: this.req.content,
|
value: fileContent,
|
||||||
showPrintMargin: false,
|
showPrintMargin: false,
|
||||||
readOnly: this.req.type === 'textImmutable',
|
readOnly: this.req.type === 'textImmutable',
|
||||||
theme: 'ace/theme/chrome',
|
theme: 'ace/theme/chrome',
|
||||||
|
|
Loading…
Reference in New Issue