From ca9a8173bd51c8994033a107ccbb8c8b67a31aea Mon Sep 17 00:00:00 2001 From: Gazook89 <58999374+Gazook89@users.noreply.github.com> Date: Sat, 7 Aug 2021 22:43:15 -0500 Subject: [PATCH 1/3] Add HTML Comment Hotkey Resubmission of #1492 from new clone (old clone was deleted). --- .../editor/snippetbar/snippets/snippets.js | 7 +++++++ .../snippetbar/snippetsLegacy/snippets.js | 7 +++++++ shared/naturalcrit/codeEditor/codeEditor.jsx | 17 +++++++++++++++++ 3 files changed, 31 insertions(+) diff --git a/client/homebrew/editor/snippetbar/snippets/snippets.js b/client/homebrew/editor/snippetbar/snippets/snippets.js index 2ac8c7ea0..99226832d 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-comment-code', /* might need to be fa-solid fa-comment-code --not sure, Gazook */ + gen : dedent`\n + + \n` + }, ] }, diff --git a/client/homebrew/editor/snippetbar/snippetsLegacy/snippets.js b/client/homebrew/editor/snippetbar/snippetsLegacy/snippets.js index 2d4e2d0e4..830e5d194 100644 --- a/client/homebrew/editor/snippetbar/snippetsLegacy/snippets.js +++ b/client/homebrew/editor/snippetbar/snippetsLegacy/snippets.js @@ -100,6 +100,13 @@ module.exports = [ ' }\n' + '' }, + { + name : 'Add Comment', + icon : 'fas fa-comment-code', /* might need to be fa-solid fa-comment-code --not sure, Gazook */ + gen : dedent`\n + + \n` + }, ] }, diff --git a/shared/naturalcrit/codeEditor/codeEditor.jsx b/shared/naturalcrit/codeEditor/codeEditor.jsx index a40c48436..6de06cf81 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 - 3 }); + } + }, + //=-- Externally used -==// setCursorPosition : function(line, char){ setTimeout(()=>{ From 37d11ec303d440db7f62de66f74f51a24f8d1fe7 Mon Sep 17 00:00:00 2001 From: Gazook89 <58999374+Gazook89@users.noreply.github.com> Date: Sat, 7 Aug 2021 22:49:51 -0500 Subject: [PATCH 2/3] Add spaces to satisfy circleCI --- shared/naturalcrit/codeEditor/codeEditor.jsx | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/shared/naturalcrit/codeEditor/codeEditor.jsx b/shared/naturalcrit/codeEditor/codeEditor.jsx index 6de06cf81..7af4c12b4 100644 --- a/shared/naturalcrit/codeEditor/codeEditor.jsx +++ b/shared/naturalcrit/codeEditor/codeEditor.jsx @@ -47,12 +47,12 @@ const CodeEditor = createClass({ indentWithTabs : true, tabSize : 2, extraKeys : { - '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-B' : this.makeBold, + 'Cmd-B' : this.makeBold, + 'Ctrl-I' : this.makeItalic, + 'Cmd-I' : this.makeItalic, + 'Ctrl-M' : this.makeSpan, + 'Cmd-M' : this.makeSpan, 'Ctrl-B' : this.makeBold, 'Cmd-B' : this.makeBold, 'Ctrl-I' : this.makeItalic, From 86184f85954598e403afd3c4218dc56358ca3568 Mon Sep 17 00:00:00 2001 From: Trevor Buckner Date: Sun, 8 Aug 2021 22:13:23 -0400 Subject: [PATCH 3/3] Changed shortcut to CTRL + /, fixed icon --- .../editor/snippetbar/snippets/snippets.js | 6 ++-- .../snippetbar/snippetsLegacy/snippets.js | 8 ++--- shared/naturalcrit/codeEditor/codeEditor.jsx | 32 +++++++++---------- 3 files changed, 22 insertions(+), 24 deletions(-) diff --git a/client/homebrew/editor/snippetbar/snippets/snippets.js b/client/homebrew/editor/snippetbar/snippets/snippets.js index 99226832d..b30a96e7c 100644 --- a/client/homebrew/editor/snippetbar/snippets/snippets.js +++ b/client/homebrew/editor/snippetbar/snippets/snippets.js @@ -115,10 +115,10 @@ module.exports = [ }, { name : 'Add Comment', - icon : 'fas fa-comment-code', /* might need to be fa-solid fa-comment-code --not sure, Gazook */ + icon : 'fas fa-code', /* might need to be fa-solid fa-comment-code --not sure, Gazook */ gen : dedent`\n - - \n` + + ` }, ] }, diff --git a/client/homebrew/editor/snippetbar/snippetsLegacy/snippets.js b/client/homebrew/editor/snippetbar/snippetsLegacy/snippets.js index 830e5d194..3ce871d91 100644 --- a/client/homebrew/editor/snippetbar/snippetsLegacy/snippets.js +++ b/client/homebrew/editor/snippetbar/snippetsLegacy/snippets.js @@ -102,11 +102,9 @@ module.exports = [ }, { name : 'Add Comment', - icon : 'fas fa-comment-code', /* might need to be fa-solid fa-comment-code --not sure, Gazook */ - gen : dedent`\n - - \n` - }, + icon : 'fas fa-code', + gen : `\n\n\n` + } ] }, diff --git a/shared/naturalcrit/codeEditor/codeEditor.jsx b/shared/naturalcrit/codeEditor/codeEditor.jsx index 7af4c12b4..bbfdbfa75 100644 --- a/shared/naturalcrit/codeEditor/codeEditor.jsx +++ b/shared/naturalcrit/codeEditor/codeEditor.jsx @@ -47,20 +47,20 @@ const CodeEditor = createClass({ indentWithTabs : true, tabSize : 2, extraKeys : { - '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-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, + '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-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, } }); @@ -98,10 +98,10 @@ const CodeEditor = createClass({ makeComment : function() { const selection = this.codeMirror.getSelection(), t = selection.slice(0, 4) === ''; - this.codeMirror.replaceSelection(t ? selection.slice(4, -3) : ``, 'around'); + 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 - 3 }); + this.codeMirror.setCursor({ line: cursor.line, ch: cursor.ch - 4 }); } },