mirror of
https://github.com/naturalcrit/homebrewery.git
synced 2026-01-14 21:32:41 +00:00
add makeDiv hotkey - V3 Curly Divs
Shift-Cmd/Ctrl-M makes a curly div.
This commit is contained in:
@@ -55,6 +55,8 @@ const CodeEditor = createClass({
|
|||||||
'Cmd-U' : this.makeUnderline,
|
'Cmd-U' : this.makeUnderline,
|
||||||
'Ctrl-M' : this.makeSpan,
|
'Ctrl-M' : this.makeSpan,
|
||||||
'Cmd-M' : this.makeSpan,
|
'Cmd-M' : this.makeSpan,
|
||||||
|
'Shift-Ctrl-M' : this.makeDiv,
|
||||||
|
'Shift-Cmd-M' : this.makeDiv,
|
||||||
'Ctrl-/' : this.makeComment,
|
'Ctrl-/' : this.makeComment,
|
||||||
'Cmd-/' : this.makeComment
|
'Cmd-/' : this.makeComment
|
||||||
}
|
}
|
||||||
@@ -101,6 +103,15 @@ const CodeEditor = createClass({
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
|
makeDiv : function() {
|
||||||
|
const selection = this.codeMirror.getSelection(), t = selection.slice(0, 2) === '{{' && selection.slice(-2) === '}}';
|
||||||
|
this.codeMirror.replaceSelection(t ? selection.slice(2, -2) : `{{\n${selection}\n}}`, 'around');
|
||||||
|
if(selection.length === 0){
|
||||||
|
const cursor = this.codeMirror.getCursor();
|
||||||
|
this.codeMirror.setCursor({ line: cursor.line - 1, ch: cursor.ch }); // set to -2? if wanting to enter classes etc. if so, get rid of first \n when replacing selection
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
makeComment : function() {
|
makeComment : function() {
|
||||||
const selection = this.codeMirror.getSelection(), t = selection.slice(0, 4) === '<!--' && selection.slice(-3) === '-->';
|
const selection = this.codeMirror.getSelection(), t = selection.slice(0, 4) === '<!--' && selection.slice(-3) === '-->';
|
||||||
this.codeMirror.replaceSelection(t ? selection.slice(4, -3) : `<!-- ${selection} -->`, 'around');
|
this.codeMirror.replaceSelection(t ? selection.slice(4, -3) : `<!-- ${selection} -->`, 'around');
|
||||||
|
|||||||
Reference in New Issue
Block a user