Allow native paste into table cells
This commit is contained in:
parent
fc21c80d64
commit
691d6b04bb
|
@ -2,9 +2,16 @@
|
||||||
import { Modal, ModalContent, ProgressBar } from "@budibase/bbui"
|
import { Modal, ModalContent, ProgressBar } from "@budibase/bbui"
|
||||||
import { getContext, onMount } from "svelte"
|
import { getContext, onMount } from "svelte"
|
||||||
import { sleep } from "../../../utils/utils"
|
import { sleep } from "../../../utils/utils"
|
||||||
|
import { get } from "svelte/store"
|
||||||
|
|
||||||
const { clipboard, subscribe, copyAllowed, pasteAllowed, selectedCellCount } =
|
const {
|
||||||
getContext("grid")
|
clipboard,
|
||||||
|
subscribe,
|
||||||
|
copyAllowed,
|
||||||
|
pasteAllowed,
|
||||||
|
selectedCellCount,
|
||||||
|
focusedCellAPI,
|
||||||
|
} = getContext("grid")
|
||||||
const duration = 260
|
const duration = 260
|
||||||
|
|
||||||
let modal
|
let modal
|
||||||
|
@ -19,10 +26,15 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
const handlePasteRequest = async () => {
|
const handlePasteRequest = async () => {
|
||||||
|
// If a cell is active then let the native paste action take over
|
||||||
|
if (get(focusedCellAPI)?.isActive()) {
|
||||||
|
return
|
||||||
|
}
|
||||||
progressPercentage = 0
|
progressPercentage = 0
|
||||||
if (!$pasteAllowed) {
|
if (!$pasteAllowed) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
// Prompt if paste will update multiple cells
|
// Prompt if paste will update multiple cells
|
||||||
const multiCellPaste = $selectedCellCount > 1
|
const multiCellPaste = $selectedCellCount > 1
|
||||||
const prompt = $clipboard.multiCellCopy || multiCellPaste
|
const prompt = $clipboard.multiCellCopy || multiCellPaste
|
||||||
|
|
|
@ -58,7 +58,7 @@
|
||||||
case "c":
|
case "c":
|
||||||
return handle(() => dispatch("copy"))
|
return handle(() => dispatch("copy"))
|
||||||
case "v":
|
case "v":
|
||||||
return handle(() => dispatch("paste"))
|
return dispatch("paste")
|
||||||
case "Enter":
|
case "Enter":
|
||||||
return handle(() => {
|
return handle(() => {
|
||||||
if ($config.canAddRows) {
|
if ($config.canAddRows) {
|
||||||
|
|
Loading…
Reference in New Issue