From f65d39b510df52eb37b4e82a0ba4d8026418519e Mon Sep 17 00:00:00 2001 From: Wing-Kam Wong Date: Thu, 24 Nov 2022 13:31:47 +0800 Subject: [PATCH] feat(nc-gui): keyboard manoeuvre - Alt + R & Alt + C --- .../nc-gui/components/smartsheet/Grid.vue | 30 +++++++++++++++++-- 1 file changed, 28 insertions(+), 2 deletions(-) diff --git a/packages/nc-gui/components/smartsheet/Grid.vue b/packages/nc-gui/components/smartsheet/Grid.vue index d007bfb074..e56ebc7f75 100644 --- a/packages/nc-gui/components/smartsheet/Grid.vue +++ b/packages/nc-gui/components/smartsheet/Grid.vue @@ -95,6 +95,10 @@ const tbodyEl = ref() const gridWrapper = ref() const tableHead = ref() +const isAddingColumnAllowed = !readOnly.value && !isLocked.value && isUIAllowed('add-column') && !isSqlView.value + +const isAddingEmptyRowAllowed = !isView && !isLocked.value && hasEditPermission && !isSqlView.value + const { isLoading, loadData, @@ -187,6 +191,7 @@ const { selectCell, selectBlock, selectedRange, clearRangeRows, startSelectRange } const cmdOrCtrl = isMac() ? e.metaKey : e.ctrlKey + const altOrOptionKey = e.altKey if (e.key === ' ') { if (selected.row !== null && !editEnabled) { e.preventDefault() @@ -205,6 +210,7 @@ const { selectCell, selectBlock, selectedRange, clearRangeRows, startSelectRange return true } } + if (cmdOrCtrl) { switch (e.key) { case 'ArrowUp': @@ -233,6 +239,26 @@ const { selectCell, selectBlock, selectedRange, clearRangeRows, startSelectRange return true } } + + if (altOrOptionKey) { + switch (e.keyCode) { + // wingkwong + case 82: { + // ALT + R + if (isAddingEmptyRowAllowed) { + addEmptyRow() + } + break + } + case 67: { + // ALT + C + if (isAddingColumnAllowed) { + addColumnDropdown.value = true + } + break + } + } + } }, ) @@ -607,7 +633,7 @@ watch( - +