Add commenting and track-changes keyboard shortcuts.

This commit is contained in:
Paulo Reis 2017-05-19 15:28:49 +01:00
parent 832764dd3d
commit 957b201fc1
3 changed files with 37 additions and 2 deletions

View file

@ -51,6 +51,8 @@ div.full-size(
file-name="editor.open_doc_name",
on-ctrl-enter="recompileViaKey",
on-ctrl-j="toggleReviewPanel",
on-ctrl-shift-c="addNewCommentFromKbdShortcut",
on-ctrl-shift-a="toggleTrackChangesFromKbdShortcut",
syntax-validation="settings.syntaxValidation",
review-panel="reviewPanel",
events-bridge="reviewPanelEventsBridge"

View file

@ -50,8 +50,10 @@ define [
annotations: "="
navigateHighlights: "="
fileName: "="
onCtrlEnter: "="
onCtrlJ: "="
onCtrlEnter: "=" # Compile
onCtrlJ: "=" # Toggle the review panel
onCtrlShiftC: "=" # Add a new comment
onCtrlShiftA: "=" # Toggle track-changes on/off
syntaxValidation: "="
reviewPanel: "="
eventsBridge: "="
@ -172,6 +174,26 @@ define [
callback()
readOnly: true
scope.$watch "onCtrlShiftC", (callback) ->
if callback?
editor.commands.addCommand
name: "add-new-comment",
bindKey: win: "Ctrl-Shift-C", mac: "Command-Shift-C"
exec: (editor) =>
selection = editor.getSelection()
if !selection.isEmpty()
callback()
readOnly: true
scope.$watch "onCtrlShiftA", (callback) ->
if callback?
editor.commands.addCommand
name: "toggle-track-changes",
bindKey: win: "Ctrl-Shift-A", mac: "Command-Shift-A"
exec: (editor) =>
callback()
readOnly: true
# Make '/' work for search in vim mode.
editor.showCommandLine = (arg) =>
if arg == "/"

View file

@ -329,6 +329,11 @@ define [
$scope.$broadcast "comment:start_adding"
$scope.toggleReviewPanel()
$scope.addNewCommentFromKbdShortcut = () ->
$scope.$broadcast "comment:start_adding"
if !$scope.ui.reviewPanelOpen
$scope.toggleReviewPanel()
$scope.startNewComment = () ->
$scope.$broadcast "comment:select_line"
$timeout () ->
@ -479,6 +484,12 @@ define [
event_tracking.sendMB "rp-trackchanges-toggle", { value }
else
$scope.openTrackChangesUpgradeModal()
$scope.toggleTrackChangesFromKbdShortcut = () ->
if $scope.editor.wantTrackChanges
$scope.toggleTrackChanges false
else
$scope.toggleTrackChanges true
ide.socket.on "toggle-track-changes", (value) ->
$scope.$apply () ->