From 72fc630e8190dc6ef24832c4955fae85cf67edcd Mon Sep 17 00:00:00 2001 From: Mick O'Brien Date: Wed, 8 Oct 2014 15:44:01 +0100 Subject: [PATCH] Added keyboard shortcuts to bold and italicise text --- .../ide/editor/directives/aceEditor.coffee | 28 +++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/services/web/public/coffee/ide/editor/directives/aceEditor.coffee b/services/web/public/coffee/ide/editor/directives/aceEditor.coffee index 86e1637094..eed9b114de 100644 --- a/services/web/public/coffee/ide/editor/directives/aceEditor.coffee +++ b/services/web/public/coffee/ide/editor/directives/aceEditor.coffee @@ -78,6 +78,34 @@ define [ readOnly: true editor.commands.removeCommand "replace" + # Bold text on CMD+B + editor.commands.addCommand + name: "bold", + bindKey: win: "Ctrl-B", mac: "Command-B" + exec: (editor) -> + selection = editor.getSelection() + if selection.$isEmpty + editor.insert("\\textbf{}") + editor.navigateLeft(1) + else + text = editor.getCopyText() + editor.insert("\\textbf{" + text + "}") + readOnly: false + + # Italicise text on CMD+I + editor.commands.addCommand + name: "italics", + bindKey: win: "Ctrl-I", mac: "Command-I" + exec: (editor) -> + selection = editor.getSelection() + if selection.$isEmpty + editor.insert("\\textit{}") + editor.navigateLeft(1) + else + text = editor.getCopyText() + editor.insert("\\textit{" + text + "}") + readOnly: false + scope.$watch "onCtrlEnter", (callback) -> if callback? editor.commands.addCommand