diff options
| author | 果物リン <fruitriin@riinswork.space> | 2025-10-09 09:29:47 +0900 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2025-10-09 09:29:47 +0900 |
| commit | 41aa0c8efebf2e443ba7372762948b5e56cfd990 (patch) | |
| tree | 513daf97c8fd128ea73892f739a2babe73aa9a57 /packages/frontend/src/components/grid/MkGrid.vue | |
| parent | fix: aliasesの区切り文字が一致していないのを修正 (#16622) (diff) | |
| download | misskey-41aa0c8efebf2e443ba7372762948b5e56cfd990.tar.gz misskey-41aa0c8efebf2e443ba7372762948b5e56cfd990.tar.bz2 misskey-41aa0c8efebf2e443ba7372762948b5e56cfd990.zip | |
[カスタム絵文字beta]MacのCmdキー対応とCtrl/Cmd+Arrowキー対応 (#16621)
* [カスタム絵文字beta]MacのCmdキー対応とCtrl/Cmd+Arrowキー対応
* Update packages/frontend/src/components/grid/MkGrid.vue
Co-authored-by: かっこかり <67428053+kakkokari-gtyih@users.noreply.github.com>
---------
Co-authored-by: かっこかり <67428053+kakkokari-gtyih@users.noreply.github.com>
Diffstat (limited to 'packages/frontend/src/components/grid/MkGrid.vue')
| -rw-r--r-- | packages/frontend/src/components/grid/MkGrid.vue | 262 |
1 files changed, 122 insertions, 140 deletions
diff --git a/packages/frontend/src/components/grid/MkGrid.vue b/packages/frontend/src/components/grid/MkGrid.vue index a175485a7e..96d9e35773 100644 --- a/packages/frontend/src/components/grid/MkGrid.vue +++ b/packages/frontend/src/components/grid/MkGrid.vue @@ -71,7 +71,7 @@ import { import * as os from '@/os.js'; import { createColumn } from '@/components/grid/column.js'; import { createRow, defaultGridRowSetting, resetRow } from '@/components/grid/row.js'; -import { handleKeyEvent } from '@/utility/key-event.js'; +import { makeHotkey } from '@/utility/hotkey.js'; type RowHolder = { row: GridRow, @@ -289,161 +289,143 @@ function onKeyDown(ev: KeyboardEvent) { const max = availableBounds.value; const bounds = rangedBounds.value; - handleKeyEvent(ev, [ - { - code: 'Delete', handler: () => { - if (rangedRows.value.length > 0) { - if (rowSetting.events.delete) { - rowSetting.events.delete(rangedRows.value); - } - } else { - const context = createContext(); - removeDataFromGrid(context, (cell) => { - emitCellValue(cell, undefined); - }); + makeHotkey({ + 'delete': () => { + if (rangedRows.value.length > 0) { + if (rowSetting.events.delete) { + rowSetting.events.delete(rangedRows.value); } - }, - }, - { - code: 'KeyC', modifiers: ['Control'], handler: () => { - const context = createContext(); - copyGridDataToClipboard(data.value, context); - }, - }, - { - code: 'KeyV', modifiers: ['Control'], handler: async () => { - const _cells = cells.value; + } else { const context = createContext(); - await pasteToGridFromClipboard(context, (row, col, parsedValue) => { - emitCellValue(_cells[row.index].cells[col.index], parsedValue); + removeDataFromGrid(context, (cell) => { + emitCellValue(cell, undefined); }); - }, + } }, - { - code: 'ArrowRight', modifiers: ['Control', 'Shift'], handler: () => { - updateSelectionRange({ - leftTop: { col: selectedCellAddress.col, row: bounds.leftTop.row }, - rightBottom: { col: max.rightBottom.col, row: bounds.rightBottom.row }, - }); - }, + 'ctrl+c|meta+c': () => { + const context = createContext(); + copyGridDataToClipboard(data.value, context); }, - { - code: 'ArrowLeft', modifiers: ['Control', 'Shift'], handler: () => { - updateSelectionRange({ - leftTop: { col: max.leftTop.col, row: bounds.leftTop.row }, - rightBottom: { col: selectedCellAddress.col, row: bounds.rightBottom.row }, - }); - }, + 'ctrl+v|meta+v': async () => { + const _cells = cells.value; + const context = createContext(); + await pasteToGridFromClipboard(context, (row, col, parsedValue) => { + emitCellValue(_cells[row.index].cells[col.index], parsedValue); + }); }, - { - code: 'ArrowUp', modifiers: ['Control', 'Shift'], handler: () => { - updateSelectionRange({ - leftTop: { col: bounds.leftTop.col, row: max.leftTop.row }, - rightBottom: { col: bounds.rightBottom.col, row: selectedCellAddress.row }, - }); - }, + 'ctrl+shift+right|meta+shift+right': () => { + updateSelectionRange({ + leftTop: { col: selectedCellAddress.col, row: bounds.leftTop.row }, + rightBottom: { col: max.rightBottom.col, row: bounds.rightBottom.row }, + }); }, - { - code: 'ArrowDown', modifiers: ['Control', 'Shift'], handler: () => { - updateSelectionRange({ - leftTop: { col: bounds.leftTop.col, row: selectedCellAddress.row }, - rightBottom: { col: bounds.rightBottom.col, row: max.rightBottom.row }, - }); - }, + 'ctrl+shift+left|meta+shift+left': () => { + updateSelectionRange({ + leftTop: { col: max.leftTop.col, row: bounds.leftTop.row }, + rightBottom: { col: selectedCellAddress.col, row: bounds.rightBottom.row }, + }); }, - { - code: 'ArrowRight', modifiers: ['Shift'], handler: () => { - updateSelectionRange({ - leftTop: { - col: bounds.leftTop.col < selectedCellAddress.col - ? bounds.leftTop.col + 1 - : selectedCellAddress.col, - row: bounds.leftTop.row, - }, - rightBottom: { - col: (bounds.rightBottom.col > selectedCellAddress.col || bounds.leftTop.col === selectedCellAddress.col) - ? bounds.rightBottom.col + 1 - : selectedCellAddress.col, - row: bounds.rightBottom.row, - }, - }); - }, + 'ctrl+shift+up|meta+shift+up': () => { + updateSelectionRange({ + leftTop: { col: bounds.leftTop.col, row: max.leftTop.row }, + rightBottom: { col: bounds.rightBottom.col, row: selectedCellAddress.row }, + }); }, - { - code: 'ArrowLeft', modifiers: ['Shift'], handler: () => { - updateSelectionRange({ - leftTop: { - col: (bounds.leftTop.col < selectedCellAddress.col || bounds.rightBottom.col === selectedCellAddress.col) - ? bounds.leftTop.col - 1 - : selectedCellAddress.col, - row: bounds.leftTop.row, - }, - rightBottom: { - col: bounds.rightBottom.col > selectedCellAddress.col - ? bounds.rightBottom.col - 1 - : selectedCellAddress.col, - row: bounds.rightBottom.row, - }, - }); - }, + 'ctrl+shift+down|meta+shift+down': () => { + updateSelectionRange({ + leftTop: { col: bounds.leftTop.col, row: selectedCellAddress.row }, + rightBottom: { col: bounds.rightBottom.col, row: max.rightBottom.row }, + }); }, - { - code: 'ArrowUp', modifiers: ['Shift'], handler: () => { - updateSelectionRange({ - leftTop: { - col: bounds.leftTop.col, - row: (bounds.leftTop.row < selectedCellAddress.row || bounds.rightBottom.row === selectedCellAddress.row) - ? bounds.leftTop.row - 1 - : selectedCellAddress.row, - }, - rightBottom: { - col: bounds.rightBottom.col, - row: bounds.rightBottom.row > selectedCellAddress.row - ? bounds.rightBottom.row - 1 - : selectedCellAddress.row, - }, - }); - }, + 'ctrl+right|meta+right': () => { + selectionCell({ col: max.rightBottom.col, row: selectedCellAddress.row }); }, - { - code: 'ArrowDown', modifiers: ['Shift'], handler: () => { - updateSelectionRange({ - leftTop: { - col: bounds.leftTop.col, - row: bounds.leftTop.row < selectedCellAddress.row - ? bounds.leftTop.row + 1 - : selectedCellAddress.row, - }, - rightBottom: { - col: bounds.rightBottom.col, - row: (bounds.rightBottom.row > selectedCellAddress.row || bounds.leftTop.row === selectedCellAddress.row) - ? bounds.rightBottom.row + 1 - : selectedCellAddress.row, - }, - }); - }, + 'ctrl+left|meta+left': () => { + selectionCell({ col: max.leftTop.col, row: selectedCellAddress.row }); + }, + 'ctrl+up|meta+up': () => { + selectionCell({ col: selectedCellAddress.col, row: max.leftTop.row }); + }, + 'ctrl+down|meta+down': () => { + selectionCell({ col: selectedCellAddress.col, row: max.rightBottom.row }); + }, + 'shift+right': () => { + updateSelectionRange({ + leftTop: { + col: bounds.leftTop.col < selectedCellAddress.col + ? bounds.leftTop.col + 1 + : selectedCellAddress.col, + row: bounds.leftTop.row, + }, + rightBottom: { + col: (bounds.rightBottom.col > selectedCellAddress.col || bounds.leftTop.col === selectedCellAddress.col) + ? bounds.rightBottom.col + 1 + : selectedCellAddress.col, + row: bounds.rightBottom.row, + }, + }); + }, + 'shift+left': () => { + updateSelectionRange({ + leftTop: { + col: (bounds.leftTop.col < selectedCellAddress.col || bounds.rightBottom.col === selectedCellAddress.col) + ? bounds.leftTop.col - 1 + : selectedCellAddress.col, + row: bounds.leftTop.row, + }, + rightBottom: { + col: bounds.rightBottom.col > selectedCellAddress.col + ? bounds.rightBottom.col - 1 + : selectedCellAddress.col, + row: bounds.rightBottom.row, + }, + }); + }, + 'shift+up': () => { + updateSelectionRange({ + leftTop: { + col: bounds.leftTop.col, + row: (bounds.leftTop.row < selectedCellAddress.row || bounds.rightBottom.row === selectedCellAddress.row) + ? bounds.leftTop.row - 1 + : selectedCellAddress.row, + }, + rightBottom: { + col: bounds.rightBottom.col, + row: bounds.rightBottom.row > selectedCellAddress.row + ? bounds.rightBottom.row - 1 + : selectedCellAddress.row, + }, + }); + }, + 'shift+down': () => { + updateSelectionRange({ + leftTop: { + col: bounds.leftTop.col, + row: bounds.leftTop.row < selectedCellAddress.row + ? bounds.leftTop.row + 1 + : selectedCellAddress.row, + }, + rightBottom: { + col: bounds.rightBottom.col, + row: (bounds.rightBottom.row > selectedCellAddress.row || bounds.leftTop.row === selectedCellAddress.row) + ? bounds.rightBottom.row + 1 + : selectedCellAddress.row, + }, + }); }, - { - code: 'ArrowDown', handler: () => { - selectionCell({ col: selectedCellAddress.col, row: selectedCellAddress.row + 1 }); - }, + 'down': () => { + selectionCell({ col: selectedCellAddress.col, row: selectedCellAddress.row + 1 }); }, - { - code: 'ArrowUp', handler: () => { - selectionCell({ col: selectedCellAddress.col, row: selectedCellAddress.row - 1 }); - }, + 'up': () => { + selectionCell({ col: selectedCellAddress.col, row: selectedCellAddress.row - 1 }); }, - { - code: 'ArrowRight', handler: () => { - selectionCell({ col: selectedCellAddress.col + 1, row: selectedCellAddress.row }); - }, + 'right': () => { + selectionCell({ col: selectedCellAddress.col + 1, row: selectedCellAddress.row }); }, - { - code: 'ArrowLeft', handler: () => { - selectionCell({ col: selectedCellAddress.col - 1, row: selectedCellAddress.row }); - }, + 'left': () => { + selectionCell({ col: selectedCellAddress.col - 1, row: selectedCellAddress.row }); }, - ]); + }, [])(ev); break; } |