From 08c845ff006ef60ee9f8c7855f845511a525fd92 Mon Sep 17 00:00:00 2001 From: Gazook89 <58999374+Gazook89@users.noreply.github.com> Date: Mon, 6 Sep 2021 20:35:55 -0500 Subject: [PATCH] add underline hotkey and change italic hotkey to * Using `*` rather than `_` characters for italics is more inline with existing snippets. --- shared/naturalcrit/codeEditor/codeEditor.jsx | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/shared/naturalcrit/codeEditor/codeEditor.jsx b/shared/naturalcrit/codeEditor/codeEditor.jsx index 9707bde56..f32a7e130 100644 --- a/shared/naturalcrit/codeEditor/codeEditor.jsx +++ b/shared/naturalcrit/codeEditor/codeEditor.jsx @@ -51,6 +51,8 @@ const CodeEditor = createClass({ 'Cmd-B' : this.makeBold, 'Ctrl-I' : this.makeItalic, 'Cmd-I' : this.makeItalic, + 'Ctrl-U' : this.makeUnderline, + 'Cmd-U' : this.makeUnderline, 'Ctrl-M' : this.makeSpan, 'Cmd-M' : this.makeSpan, 'Ctrl-/' : this.makeComment, @@ -73,14 +75,23 @@ const CodeEditor = createClass({ }, makeItalic : function() { - const selection = this.codeMirror.getSelection(), t = selection.slice(0, 1) === '_' && selection.slice(-1) === '_'; - this.codeMirror.replaceSelection(t ? selection.slice(1, -1) : `_${selection}_`, 'around'); + const selection = this.codeMirror.getSelection(), t = selection.slice(0, 1) === '*' && selection.slice(-1) === '*'; + this.codeMirror.replaceSelection(t ? selection.slice(1, -1) : `*${selection}*`, 'around'); if(selection.length === 0){ const cursor = this.codeMirror.getCursor(); this.codeMirror.setCursor({ line: cursor.line, ch: cursor.ch - 1 }); } }, + makeUnderline : function() { + const selection = this.codeMirror.getSelection(), t = selection.slice(0, 3) === '' && selection.slice(-4) === ''; + this.codeMirror.replaceSelection(t ? selection.slice(3, -4) : `${selection}`, 'around'); + if(selection.length === 0){ + const cursor = this.codeMirror.getCursor(); + this.codeMirror.setCursor({ line: cursor.line, ch: cursor.ch - 4 }); + } + }, + makeSpan : function() { const selection = this.codeMirror.getSelection(), t = selection.slice(0, 2) === '{{' && selection.slice(-2) === '}}'; this.codeMirror.replaceSelection(t ? selection.slice(2, -2) : `{{ ${selection}}}`, 'around');