mirror of
https://github.com/naturalcrit/homebrewery.git
synced 2026-01-07 07:42:39 +00:00
matched functionality of link hotkey in github
This commit is contained in:
@@ -102,12 +102,11 @@ const CodeEditor = createClass({
|
|||||||
},
|
},
|
||||||
|
|
||||||
makeLink : function() {
|
makeLink : function() {
|
||||||
const selection = this.codeMirror.getSelection(), t = selection.slice(0, 1) === '[' && selection.slice(-3) === ']()';
|
const selection = this.codeMirror.getSelection(), t = selection.slice(0, 1) === '[' && selection.slice(-6) === '](url)';
|
||||||
this.codeMirror.replaceSelection(t ? selection.slice(1, -3) : `[${selection}]()`);
|
this.codeMirror.replaceSelection(t ? selection.slice(1, -6) : `[${selection}](url)`);
|
||||||
if((selection.slice(0, 1) !== '[' || selection.slice(-3) !== ']()') || selection.length === 0){
|
if((selection.slice(0, 1) !== '[' || selection.slice(-6) !== '](url)') || selection.length === 0){
|
||||||
const cursor = this.codeMirror.getCursor();
|
const cursor = this.codeMirror.getCursor();
|
||||||
console.log('hello');
|
this.codeMirror.setSelection({ line: cursor.line, ch: cursor.ch - 4 }, { line: cursor.line, ch: cursor.ch - 1 });
|
||||||
this.codeMirror.setCursor({ line: cursor.line, ch: cursor.ch - 1 });
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user