Commit 631ee31f authored by Jacob Schatz's avatar Jacob Schatz

Initial line linking.

parent a9555221
......@@ -9,6 +9,20 @@ export default class RepoEditor {
this.el = document.getElementById('ide');
}
addMonacoEvents() {
this.vue.$watch('activeFile.lineNumber', () => {
console.log('cahnged')
})
this.monacoEditor.onMouseUp(this.onMonacoEditorMouseUp);
}
onMonacoEditorMouseUp(e) {
if(e.target.element.className === 'line-numbers') {
location.hash = `L${e.target.position.lineNumber}`;
Store.activeLine = e.target.position.lineNumber;
}
}
initMonaco() {
window.require.config({ paths: { vs: '/monaco-editor/min/vs' } });
window.require(['vs/editor/editor.main'], () => {
......@@ -19,10 +33,12 @@ export default class RepoEditor {
readOnly: true,
contextmenu: false,
}
)
);
Helper.monacoInstance = monaco;
this.initVue();
monaco.languages.getLanguages();
this.addMonacoEvents();
});
}
......@@ -54,6 +70,13 @@ export default class RepoEditor {
},
watch: {
activeLine() {
self.monacoEditor.setPosition({
lineNumber: this.activeLine,
column: 1
});
},
isTree() {
this.showHide();
},
......
......@@ -14,7 +14,7 @@ export default class RepoSidebar {
el: '#repo-file-buttons',
data: () => Store,
template: `
<div id='repo-file-buttons' v-if='!isTree'>
<div id='repo-file-buttons' v-if='isMini'>
<a :href='rawFileURL' target='_blank' class='btn btn-default'>Download file</a>
<div class="btn-group" role="group" aria-label="File actions">
<a :href='blameFileUrl' class='btn btn-default'>Blame</a>
......@@ -35,8 +35,7 @@ export default class RepoSidebar {
return this.activeFile.extension === 'md';
},
rawFileURL() {
console.log(this.activeFile)
rawFileURL() {
return Helper.getRawURLFromBlobURL(this.activeFile.url);
},
......
......@@ -37,7 +37,6 @@ let RepoHelper = {
split[blobIndex] = 'tree';
}
joined = split.join('/');
console.log(split)
return split.join('/');
},
......@@ -164,14 +163,12 @@ let RepoHelper = {
// may be tree or file.
getContent(file) {
console.log('file')
const loadingData = this.setLoading(true);
Service.getContent()
.then((response) => {
let data = response.data;
this.setLoading(false, loadingData);
Store.isTree = this.isTree(data);
if(!Store.isTree) {
if(!file) {
file = data;
......@@ -185,7 +182,6 @@ let RepoHelper = {
data
);
data.binary = true;
console.log('file1', file)
if(!file.url) {
file.url = location.pathname;
}
......@@ -194,7 +190,6 @@ let RepoHelper = {
this.setActiveFile(data);
} else {
Store.blobRaw = data.plain;
console.log('file2', file)
if(!file.url) {
file.url = location.pathname;
}
......@@ -219,7 +214,6 @@ let RepoHelper = {
}
})
.catch((response)=> {
console.log('response',response)
this.setLoading(false, loadingData);
new Flash('Unable to load the file at this time.')
});
......
......@@ -35,6 +35,7 @@ export default class RepoSidebar {
methods: {
addPopEventListener() {
window.addEventListener('popstate', () => {
if(location.href.indexOf('#') > -1) return;
this.linkClicked({
url: location.href
});
......
......@@ -21,6 +21,7 @@ let RepoStore = {
size: 0,
url: ''
},
activeLine: 0,
files: [],
binary: false,
binaryMimeType: '',
......
......@@ -27,10 +27,19 @@ header {
.panel-right{
display: inline-block;
width: 85%;
.monaco-editor.vs .cursor {
background: rgba(255,255,255,0);
border-color: rgba(255,255,255,0);
.monaco-editor.vs {
.line-numbers{
cursor: pointer;
&:hover {
text-decoration: underline;
}
}
.cursor {
background: rgba(255,255,255,0);
border-color: rgba(255,255,255,0);
}
}
#tabs {
......
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