diff --git a/client/homebrew/editor/snippetbar/snippets/snippets.js b/client/homebrew/editor/snippetbar/snippets/snippets.js index 2ac8c7ea0..b30a96e7c 100644 --- a/client/homebrew/editor/snippetbar/snippets/snippets.js +++ b/client/homebrew/editor/snippetbar/snippets/snippets.js @@ -113,6 +113,13 @@ module.exports = [ ' }\n' + '' }, + { + name : 'Add Comment', + icon : 'fas fa-code', /* might need to be fa-solid fa-comment-code --not sure, Gazook */ + gen : dedent`\n + + ` + }, ] }, diff --git a/client/homebrew/editor/snippetbar/snippetsLegacy/snippets.js b/client/homebrew/editor/snippetbar/snippetsLegacy/snippets.js index 2d4e2d0e4..3ce871d91 100644 --- a/client/homebrew/editor/snippetbar/snippetsLegacy/snippets.js +++ b/client/homebrew/editor/snippetbar/snippetsLegacy/snippets.js @@ -100,6 +100,11 @@ module.exports = [ ' }\n' + '' }, + { + name : 'Add Comment', + icon : 'fas fa-code', + gen : `\n\n\n` + } ] }, diff --git a/shared/naturalcrit/codeEditor/codeEditor.jsx b/shared/naturalcrit/codeEditor/codeEditor.jsx index a40c48436..bbfdbfa75 100644 --- a/shared/naturalcrit/codeEditor/codeEditor.jsx +++ b/shared/naturalcrit/codeEditor/codeEditor.jsx @@ -53,6 +53,14 @@ const CodeEditor = createClass({ 'Cmd-I' : this.makeItalic, 'Ctrl-M' : this.makeSpan, 'Cmd-M' : this.makeSpan, + 'Ctrl-B' : this.makeBold, + 'Cmd-B' : this.makeBold, + 'Ctrl-I' : this.makeItalic, + 'Cmd-I' : this.makeItalic, + 'Ctrl-M' : this.makeSpan, + 'Cmd-M' : this.makeSpan, + 'Ctrl-/' : this.makeComment, + 'Cmd-/' : this.makeComment, } }); @@ -88,6 +96,15 @@ const CodeEditor = createClass({ } }, + makeComment : function() { + const selection = this.codeMirror.getSelection(), t = selection.slice(0, 4) === ''; + this.codeMirror.replaceSelection(t ? selection.slice(4, -3) : ``, 'around'); + if(selection.length === 0){ + const cursor = this.codeMirror.getCursor(); + this.codeMirror.setCursor({ line: cursor.line, ch: cursor.ch - 4 }); + } + }, + //=-- Externally used -==// setCursorPosition : function(line, char){ setTimeout(()=>{