Commit 7869cbaa authored by Jacob Schatz's avatar Jacob Schatz

Gets syntax highlighting working.

parent 7216a1f1
/* global monaco */ /* global monaco */
import Vue from 'vue'; import Vue from 'vue';
import Store from './repo_store' import Store from './repo_store'
import Helper from './repo_helper'
export default class RepoEditor { export default class RepoEditor {
constructor() { constructor() {
...@@ -17,6 +18,7 @@ export default class RepoEditor { ...@@ -17,6 +18,7 @@ export default class RepoEditor {
model: null model: null
} }
) )
Helper.monacoInstance = monaco;
this.initVue(); this.initVue();
}); });
} }
...@@ -59,7 +61,7 @@ export default class RepoEditor { ...@@ -59,7 +61,7 @@ export default class RepoEditor {
self.monacoEditor.setModel( self.monacoEditor.setModel(
monaco.editor.createModel( monaco.editor.createModel(
this.blobRaw, this.blobRaw,
'plain' this.activeFile.mime_type
) )
); );
} }
......
...@@ -6,12 +6,14 @@ let RepoHelper = { ...@@ -6,12 +6,14 @@ let RepoHelper = {
return data.hasOwnProperty('blobs'); return data.hasOwnProperty('blobs');
}, },
monacoInstance: undefined,
Time: window.performance Time: window.performance
&& window.performance.now && window.performance.now
? window.performance ? window.performance
: Date, : Date,
getLanguagesForMimeType(mimetypeNeedle, monaco) { getLanguagesForMimeType(mimetypeNeedle) {
const langs = monaco.languages.getLanguages(); const langs = monaco.languages.getLanguages();
let lang = ''; let lang = '';
langs.every((lang) => { langs.every((lang) => {
...@@ -62,6 +64,9 @@ let RepoHelper = { ...@@ -62,6 +64,9 @@ let RepoHelper = {
setActiveFile(file) { setActiveFile(file) {
Store.openedFiles = Store.openedFiles.map((openedFile) => { Store.openedFiles = Store.openedFiles.map((openedFile) => {
openedFile.active = file.url === openedFile.url; openedFile.active = file.url === openedFile.url;
if(openedFile.active) {
Store.activeFile = openedFile;
}
return openedFile; return openedFile;
}); });
Store.blobRaw = file.plain; Store.blobRaw = file.plain;
......
...@@ -10,6 +10,7 @@ let RepoStore = { ...@@ -10,6 +10,7 @@ let RepoStore = {
blobRaw: '', blobRaw: '',
blobRendered: '', blobRendered: '',
openedFiles: [], openedFiles: [],
activeFile: '',
files: [] files: []
}; };
export default RepoStore; export default RepoStore;
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