From 72fc630e8190dc6ef24832c4955fae85cf67edcd Mon Sep 17 00:00:00 2001 From: Mick O'Brien Date: Wed, 8 Oct 2014 15:44:01 +0100 Subject: [PATCH 1/3] 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 From b7db72e574c2a1841642bdb9b86c139f420f51a7 Mon Sep 17 00:00:00 2001 From: Mick O'Brien Date: Wed, 8 Oct 2014 16:17:38 +0100 Subject: [PATCH 2/3] Replace $isEmpty check --- .../web/public/coffee/ide/editor/directives/aceEditor.coffee | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/services/web/public/coffee/ide/editor/directives/aceEditor.coffee b/services/web/public/coffee/ide/editor/directives/aceEditor.coffee index eed9b114de..c5f8fc8352 100644 --- a/services/web/public/coffee/ide/editor/directives/aceEditor.coffee +++ b/services/web/public/coffee/ide/editor/directives/aceEditor.coffee @@ -84,7 +84,7 @@ define [ bindKey: win: "Ctrl-B", mac: "Command-B" exec: (editor) -> selection = editor.getSelection() - if selection.$isEmpty + if selection.isEmpty() editor.insert("\\textbf{}") editor.navigateLeft(1) else @@ -98,7 +98,7 @@ define [ bindKey: win: "Ctrl-I", mac: "Command-I" exec: (editor) -> selection = editor.getSelection() - if selection.$isEmpty + if selection.isEmpty() editor.insert("\\textit{}") editor.navigateLeft(1) else From 834e27f3c557673b7fc6e411de3081b179e388ee Mon Sep 17 00:00:00 2001 From: Mick O'Brien Date: Wed, 8 Oct 2014 16:34:44 +0100 Subject: [PATCH 3/3] Fix indentation in italics shortcut --- .../coffee/ide/editor/directives/aceEditor.coffee | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/services/web/public/coffee/ide/editor/directives/aceEditor.coffee b/services/web/public/coffee/ide/editor/directives/aceEditor.coffee index c5f8fc8352..fdfe5a86b7 100644 --- a/services/web/public/coffee/ide/editor/directives/aceEditor.coffee +++ b/services/web/public/coffee/ide/editor/directives/aceEditor.coffee @@ -97,13 +97,13 @@ define [ 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 + "}") + 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) ->