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

Initial line linking.

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