From 20bcaa43394f1198b27cfc7640399ce4bd122ddf Mon Sep 17 00:00:00 2001 From: Matthew Harrison-Jones Date: Mon, 19 Aug 2013 15:10:53 +0100 Subject: [PATCH 1/2] Included missing Mac 'code' keyboard shortcut --- core/client/views/editor.js | 1 + 1 file changed, 1 insertion(+) diff --git a/core/client/views/editor.js b/core/client/views/editor.js index 58f8a06f4a..21c888098f 100644 --- a/core/client/views/editor.js +++ b/core/client/views/editor.js @@ -14,6 +14,7 @@ {'key': 'Meta+I', 'style': 'italic'}, {'key': 'Ctrl+Alt+U', 'style': 'strike'}, {'key': 'Ctrl+Shift+K', 'style': 'code'}, + {'key': 'Meta+K', 'style': 'code'}, {'key': 'Ctrl+Alt+1', 'style': 'h1'}, {'key': 'Ctrl+Alt+2', 'style': 'h2'}, {'key': 'Ctrl+Alt+3', 'style': 'h3'}, From 346bf2d91e97427772f16cb7b74e57773ea86dab Mon Sep 17 00:00:00 2001 From: Matthew Harrison-Jones Date: Tue, 20 Aug 2013 12:44:47 +0100 Subject: [PATCH 2/2] Improved the keyboard shortcuts for lists and when no text is selected. The cursor will now be placed in the middle of the inserted Markdown when no text is selected. Lists keep tabbed format. --- core/client/markdown-actions.js | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/core/client/markdown-actions.js b/core/client/markdown-actions.js index 3823024109..f76d826983 100644 --- a/core/client/markdown-actions.js +++ b/core/client/markdown-actions.js @@ -15,7 +15,7 @@ self.replace(); }, replace: function () { - var text = this.elem.getSelection(), pass = true, md, cursor, line, word, converter; + var text = this.elem.getSelection(), pass = true, md, cursor, line, word, letterCount, converter; switch (this.style) { case "h1": cursor = this.elem.getCursor(); @@ -93,13 +93,18 @@ break; case "copyHTML": converter = new Showdown.converter(); - md = converter.makeHtml(text); + if (text) { + md = converter.makeHtml(text); + } else { + md = converter.makeHtml(this.elem.getValue()); + } + $(".modal-copyToHTML-content").text(md).selectText(); $(".js-modal").center(); pass = false; break; case "list": - md = text.replace(/^/gm, "* "); + md = text.replace(/^(\s*)(\w\W*)/gm, "$1* $2"); this.elem.replaceSelection(md, "end"); pass = false; break; @@ -113,6 +118,11 @@ } if (pass && md) { this.elem.replaceSelection(md, "end"); + if (!text) { + letterCount = md.length; + cursor = this.elem.getCursor(); + this.elem.setCursor({line: cursor.line, ch: cursor.ch - (letterCount / 2)}); + } } } };