Commit b05092ef authored by Luke "Jared" Bennett's avatar Luke "Jared" Bennett

Move ideEl and monacoInstance to Store from 'self' or helper

parent 87b9af80
...@@ -7,7 +7,7 @@ import monacoLoader from './monaco_loader'; ...@@ -7,7 +7,7 @@ import monacoLoader from './monaco_loader';
export default class RepoEditor { export default class RepoEditor {
constructor(el) { constructor(el) {
this.initMonaco(); this.initMonaco();
this.el = el; Store.ideEl = el;
} }
addMonacoEvents() { addMonacoEvents() {
...@@ -21,26 +21,26 @@ export default class RepoEditor { ...@@ -21,26 +21,26 @@ export default class RepoEditor {
initMonaco() { initMonaco() {
monacoLoader(['vs/editor/editor.main'], () => { monacoLoader(['vs/editor/editor.main'], () => {
this.monacoEditor = monaco.editor.create(this.el, { this.monacoEditor = monaco.editor.create(Store.ideEl, {
model: null, model: null,
readOnly: true, readOnly: true,
contextmenu: false, contextmenu: false,
}); });
Helper.monacoInstance = monaco; Store.monacoInstance = this.monacoEditor;
this.initVue(); this.initVue();
this.addMonacoEvents(); this.addMonacoEvents();
}); });
} }
initVue() { initVue() {
const self = this;
this.vue = new Vue({ this.vue = new Vue({
data: () => Store, data: () => Store,
created() { created() {
this.showHide(); this.showHide();
if (this.blobRaw !== '') { if (this.blobRaw !== '') {
self.monacoEditor.setModel( this.monacoInstance.setModel(
monaco.editor.createModel( monaco.editor.createModel(
this.blobRaw, this.blobRaw,
'plain', 'plain',
...@@ -52,16 +52,16 @@ export default class RepoEditor { ...@@ -52,16 +52,16 @@ export default class RepoEditor {
methods: { methods: {
showHide() { showHide() {
if (!this.openedFiles.length || (this.binary && !this.activeFile.raw)) { if (!this.openedFiles.length || (this.binary && !this.activeFile.raw)) {
self.el.style.display = 'none'; this.ideEl.style.display = 'none';
} else { } else {
self.el.style.display = 'inline-block'; this.ideEl.style.display = 'inline-block';
} }
}, },
}, },
watch: { watch: {
activeLine() { activeLine() {
self.monacoEditor.setPosition({ this.monacoInstance.setPosition({
lineNumber: this.activeLine, lineNumber: this.activeLine,
column: 1, column: 1,
}); });
...@@ -78,7 +78,7 @@ export default class RepoEditor { ...@@ -78,7 +78,7 @@ export default class RepoEditor {
readOnly = true; readOnly = true;
} }
self.monacoEditor.updateOptions({ this.monacoInstance.updateOptions({
readOnly, readOnly,
}); });
}, },
...@@ -104,9 +104,9 @@ export default class RepoEditor { ...@@ -104,9 +104,9 @@ export default class RepoEditor {
if (!this.isTree) { if (!this.isTree) {
// kill the current model; // kill the current model;
self.monacoEditor.setModel(null); this.monacoInstance.setModel(null);
// then create the new one // then create the new one
self.monacoEditor.setModel( this.monacoInstance.setModel(
monaco.editor.createModel( monaco.editor.createModel(
this.blobRaw, this.blobRaw,
Helper Helper
......
...@@ -8,8 +8,6 @@ const RepoHelper = { ...@@ -8,8 +8,6 @@ const RepoHelper = {
return Object.hasOwnProperty.call(data, 'blobs'); return Object.hasOwnProperty.call(data, 'blobs');
}, },
monacoInstance: undefined,
Time: window.performance Time: window.performance
&& window.performance.now && window.performance.now
? window.performance ? window.performance
......
const RepoStore = { const RepoStore = {
ideEl: {},
monacoInstance: {},
service: '', service: '',
editor: '', editor: '',
sidebar: '', sidebar: '',
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment