Browse Source

feat(nc-gui): keyboard manoeuvre - Alt + R & Alt + C

pull/4482/head
Wing-Kam Wong 2 years ago
parent
commit
f65d39b510
  1. 30
      packages/nc-gui/components/smartsheet/Grid.vue

30
packages/nc-gui/components/smartsheet/Grid.vue

@ -95,6 +95,10 @@ const tbodyEl = ref<HTMLElement>()
const gridWrapper = ref<HTMLElement>() const gridWrapper = ref<HTMLElement>()
const tableHead = ref<HTMLElement>() const tableHead = ref<HTMLElement>()
const isAddingColumnAllowed = !readOnly.value && !isLocked.value && isUIAllowed('add-column') && !isSqlView.value
const isAddingEmptyRowAllowed = !isView && !isLocked.value && hasEditPermission && !isSqlView.value
const { const {
isLoading, isLoading,
loadData, loadData,
@ -187,6 +191,7 @@ const { selectCell, selectBlock, selectedRange, clearRangeRows, startSelectRange
} }
const cmdOrCtrl = isMac() ? e.metaKey : e.ctrlKey const cmdOrCtrl = isMac() ? e.metaKey : e.ctrlKey
const altOrOptionKey = e.altKey
if (e.key === ' ') { if (e.key === ' ') {
if (selected.row !== null && !editEnabled) { if (selected.row !== null && !editEnabled) {
e.preventDefault() e.preventDefault()
@ -205,6 +210,7 @@ const { selectCell, selectBlock, selectedRange, clearRangeRows, startSelectRange
return true return true
} }
} }
if (cmdOrCtrl) { if (cmdOrCtrl) {
switch (e.key) { switch (e.key) {
case 'ArrowUp': case 'ArrowUp':
@ -233,6 +239,26 @@ const { selectCell, selectBlock, selectedRange, clearRangeRows, startSelectRange
return true 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(
</div> </div>
</th> </th>
<th <th
v-if="!readOnly && !isLocked && isUIAllowed('add-column') && !isSqlView" v-if="isAddingColumnAllowed"
v-e="['c:column:add']" v-e="['c:column:add']"
class="cursor-pointer" class="cursor-pointer"
@click.stop="addColumnDropdown = true" @click.stop="addColumnDropdown = true"
@ -741,7 +767,7 @@ watch(
</template> </template>
</LazySmartsheetRow> </LazySmartsheetRow>
<tr v-if="!isView && !isLocked && hasEditPermission && !isSqlView"> <tr v-if="isAddingEmptyRowAllowed">
<td <td
v-e="['c:row:add:grid-bottom']" v-e="['c:row:add:grid-bottom']"
:colspan="visibleColLength + 1" :colspan="visibleColLength + 1"

Loading…
Cancel
Save