mirror of
https://github.com/naturalcrit/homebrewery.git
synced 2025-12-25 11:52:39 +00:00
Add Hotkey Ctrl/Cmd + K to create Link
This commit is contained in:
@@ -54,7 +54,9 @@ const CodeEditor = createClass({
|
||||
'Ctrl-M' : this.makeSpan,
|
||||
'Cmd-M' : this.makeSpan,
|
||||
'Ctrl-/' : this.makeComment,
|
||||
'Cmd-/' : this.makeComment
|
||||
'Cmd-/' : this.makeComment,
|
||||
'Ctrl-K' : this.makeLink,
|
||||
'Cmd-K' : this.makeLink
|
||||
}
|
||||
});
|
||||
|
||||
@@ -99,6 +101,15 @@ const CodeEditor = createClass({
|
||||
}
|
||||
},
|
||||
|
||||
makeLink : function() {
|
||||
const selection = this.codeMirror.getSelection(), t = selection.slice(0, 1) === '[' && selection.slice(-3) === ']()';
|
||||
this.codeMirror.replaceSelection(t ? selection.slice(1, -3) : `[${selection}]()`, 'around');
|
||||
if(selection.length === 0){
|
||||
const cursor = this.codeMirror.getCursor();
|
||||
this.codeMirror.setCursor({ line: cursor.line, ch: cursor.ch - 3 });
|
||||
}
|
||||
},
|
||||
|
||||
//=-- Externally used -==//
|
||||
setCursorPosition : function(line, char){
|
||||
setTimeout(()=>{
|
||||
|
||||
Reference in New Issue
Block a user