1
0
Fork 0
mirror of synced 2024-09-10 06:26:02 +12:00

Fix issue with pasting from multi to single cell

This commit is contained in:
Andrew Kingston 2024-06-23 15:08:01 +01:00
parent eabb6c94d0
commit 06aa4ba09c
No known key found for this signature in database
2 changed files with 12 additions and 12 deletions

View file

@ -47,9 +47,9 @@
}
// Sugar for preventing default
const handle = async fn => {
const handle = fn => {
e.preventDefault()
await fn()
fn()
}
// Handle certain key presses regardless of selection state

View file

@ -16,18 +16,19 @@ export const deriveStores = context => {
const { clipboard, focusedCellAPI, selectedCellCount, config } = context
// Derive whether or not we're able to copy
const copyAllowed = derived(
[focusedCellAPI, selectedCellCount],
([$focusedCellAPI, $selectedCellCount]) => {
return $focusedCellAPI || $selectedCellCount
}
)
const copyAllowed = derived(focusedCellAPI, $focusedCellAPI => {
return $focusedCellAPI != null
})
// Derive whether or not we're able to paste
const pasteAllowed = derived(
[clipboard, focusedCellAPI, selectedCellCount, config],
([$clipboard, $focusedCellAPI, $selectedCellCount, $config]) => {
if ($clipboard.value == null || !$config.canEditRows) {
if (
$clipboard.value == null ||
!$config.canEditRows ||
!$focusedCellAPI
) {
return false
}
@ -40,8 +41,7 @@ export const deriveStores = context => {
) {
return false
}
return $focusedCellAPI || $selectedCellCount
return true
}
)
@ -183,7 +183,7 @@ export const createActions = context => {
get(focusedCellAPI).setValue(value[0][0])
} else {
// Select the new cells to paste into, then paste
selectedCells.actions.updateTarget(targetCellId)
selectedCells.actions.selectRange($focusedCellId, targetCellId)
await pasteIntoSelectedCells(value)
}
}