From 691d6b04bb3e1a9e0a17b73169134eb27e00c5ba Mon Sep 17 00:00:00 2001 From: Andrew Kingston Date: Thu, 8 Aug 2024 12:18:06 +0100 Subject: [PATCH] Allow native paste into table cells --- .../grid/controls/ClipboardHandler.svelte | 16 ++++++++++++++-- .../grid/overlays/KeyboardManager.svelte | 2 +- 2 files changed, 15 insertions(+), 3 deletions(-) diff --git a/packages/frontend-core/src/components/grid/controls/ClipboardHandler.svelte b/packages/frontend-core/src/components/grid/controls/ClipboardHandler.svelte index 142f6419ad..774767a75e 100644 --- a/packages/frontend-core/src/components/grid/controls/ClipboardHandler.svelte +++ b/packages/frontend-core/src/components/grid/controls/ClipboardHandler.svelte @@ -2,9 +2,16 @@ import { Modal, ModalContent, ProgressBar } from "@budibase/bbui" import { getContext, onMount } from "svelte" import { sleep } from "../../../utils/utils" + import { get } from "svelte/store" - const { clipboard, subscribe, copyAllowed, pasteAllowed, selectedCellCount } = - getContext("grid") + const { + clipboard, + subscribe, + copyAllowed, + pasteAllowed, + selectedCellCount, + focusedCellAPI, + } = getContext("grid") const duration = 260 let modal @@ -19,10 +26,15 @@ } const handlePasteRequest = async () => { + // If a cell is active then let the native paste action take over + if (get(focusedCellAPI)?.isActive()) { + return + } progressPercentage = 0 if (!$pasteAllowed) { return } + // Prompt if paste will update multiple cells const multiCellPaste = $selectedCellCount > 1 const prompt = $clipboard.multiCellCopy || multiCellPaste diff --git a/packages/frontend-core/src/components/grid/overlays/KeyboardManager.svelte b/packages/frontend-core/src/components/grid/overlays/KeyboardManager.svelte index 27273fb598..b04870e521 100644 --- a/packages/frontend-core/src/components/grid/overlays/KeyboardManager.svelte +++ b/packages/frontend-core/src/components/grid/overlays/KeyboardManager.svelte @@ -58,7 +58,7 @@ case "c": return handle(() => dispatch("copy")) case "v": - return handle(() => dispatch("paste")) + return dispatch("paste") case "Enter": return handle(() => { if ($config.canAddRows) {