mirror of
https://github.com/naturalcrit/homebrewery.git
synced 2026-01-09 09:22:38 +00:00
add hotkeys for and empty <spans>
makeNbsp, makeSpace, removeSpace
This commit is contained in:
@@ -53,6 +53,12 @@ const CodeEditor = createClass({
|
|||||||
'Cmd-I' : this.makeItalic,
|
'Cmd-I' : this.makeItalic,
|
||||||
'Ctrl-U' : this.makeUnderline,
|
'Ctrl-U' : this.makeUnderline,
|
||||||
'Cmd-U' : this.makeUnderline,
|
'Cmd-U' : this.makeUnderline,
|
||||||
|
'Ctrl-.' : this.makeNbsp,
|
||||||
|
'Cmd-.' : this.makeNbsp,
|
||||||
|
'Shift-Ctrl-.' : this.makeSpace,
|
||||||
|
'Shift-Cmd-.' : this.makeSpace,
|
||||||
|
'Shift-Ctrl-,' : this.removeSpace,
|
||||||
|
'Shift-Cmd-,' : this.removeSpace,
|
||||||
'Ctrl-M' : this.makeSpan,
|
'Ctrl-M' : this.makeSpan,
|
||||||
'Cmd-M' : this.makeSpan,
|
'Cmd-M' : this.makeSpan,
|
||||||
'Shift-Ctrl-M' : this.makeDiv,
|
'Shift-Ctrl-M' : this.makeDiv,
|
||||||
@@ -85,6 +91,30 @@ const CodeEditor = createClass({
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
|
makeNbsp : function() {
|
||||||
|
this.codeMirror.replaceSelection(' ', 'end');
|
||||||
|
},
|
||||||
|
|
||||||
|
makeSpace : function() {
|
||||||
|
const selection = this.codeMirror.getSelection();
|
||||||
|
const t = selection.slice(0, 8) === '{{width:' && selection.slice(0 -4) === '% }}';
|
||||||
|
if(t){
|
||||||
|
const percent = parseInt(selection.slice(8, -4)) + 10;
|
||||||
|
this.codeMirror.replaceSelection(percent < 90 ? `{{width:${percent}% }}` : '{{width:100% }}', 'around');
|
||||||
|
} else {
|
||||||
|
this.codeMirror.replaceSelection(`{{width:10% }}`, 'around');
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
|
removeSpace : function() {
|
||||||
|
const selection = this.codeMirror.getSelection();
|
||||||
|
const t = selection.slice(0, 8) === '{{width:' && selection.slice(0 -4) === '% }}';
|
||||||
|
if(t){
|
||||||
|
const percent = parseInt(selection.slice(8, -4)) - 10;
|
||||||
|
this.codeMirror.replaceSelection(percent > 10 ? `{{width:${percent}% }}` : '', 'around');
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
makeUnderline : function() {
|
makeUnderline : function() {
|
||||||
const selection = this.codeMirror.getSelection(), t = selection.slice(0, 3) === '<u>' && selection.slice(-4) === '</u>';
|
const selection = this.codeMirror.getSelection(), t = selection.slice(0, 3) === '<u>' && selection.slice(-4) === '</u>';
|
||||||
this.codeMirror.replaceSelection(t ? selection.slice(3, -4) : `<u>${selection}</u>`, 'around');
|
this.codeMirror.replaceSelection(t ? selection.slice(3, -4) : `<u>${selection}</u>`, 'around');
|
||||||
|
|||||||
Reference in New Issue
Block a user