diff --git a/src/lib/components/modals/CopyPasteModal.svelte b/src/lib/components/modals/CopyPasteModal.svelte
index be3da6b8..9cc023f0 100644
--- a/src/lib/components/modals/CopyPasteModal.svelte
+++ b/src/lib/components/modals/CopyPasteModal.svelte
@@ -14,7 +14,7 @@
-
These actions are unavailable via the menu. Please use:
+
Clipboard permission is disabled by your browser. You can use:
diff --git a/src/lib/components/modes/tablemode/TableMode.svelte b/src/lib/components/modes/tablemode/TableMode.svelte
index 07ec7edb..6b52402b 100644
--- a/src/lib/components/modes/tablemode/TableMode.svelte
+++ b/src/lib/components/modes/tablemode/TableMode.svelte
@@ -1108,8 +1108,16 @@
setTimeout(focus)
}
- function handlePasteFromMenu() {
- copyPasteModalOpen = true
+ async function handlePasteFromMenu() {
+ try {
+ const clipboardText = await navigator.clipboard.readText()
+
+ _paste(clipboardText)
+ } catch (err) {
+ console.error(err)
+
+ copyPasteModalOpen = true
+ }
}
function handleClearPastedJson() {
@@ -1353,7 +1361,12 @@
function handlePaste(event: ClipboardEvent) {
event.preventDefault()
- const clipboardText = event.clipboardData?.getData('text/plain') as string | undefined
+ const clipboardText = event.clipboardData?.getData('text/plain')
+
+ _paste(clipboardText)
+ }
+
+ function _paste(clipboardText: string | undefined) {
if (clipboardText === undefined) {
return
}
@@ -1361,7 +1374,7 @@
onPaste({
clipboardText,
json,
- selection: selection,
+ selection,
readOnly,
parser,
onPatch: handlePatch,
diff --git a/src/lib/components/modes/treemode/TreeMode.svelte b/src/lib/components/modes/treemode/TreeMode.svelte
index f542fd77..e4e6adab 100644
--- a/src/lib/components/modes/treemode/TreeMode.svelte
+++ b/src/lib/components/modes/treemode/TreeMode.svelte
@@ -750,7 +750,24 @@
function handlePaste(event: ClipboardEvent) {
event.preventDefault()
- const clipboardText = event.clipboardData?.getData('text/plain') as string | undefined
+ const clipboardText = event.clipboardData?.getData('text/plain')
+
+ _paste(clipboardText)
+ }
+
+ async function handlePasteFromMenu() {
+ try {
+ const clipboardText = await navigator.clipboard.readText()
+
+ _paste(clipboardText)
+ } catch (err) {
+ console.error(err)
+
+ copyPasteModalOpen = true
+ }
+ }
+
+ function _paste(clipboardText: string | undefined) {
if (clipboardText === undefined) {
return
}
@@ -767,10 +784,6 @@
})
}
- function handlePasteFromMenu() {
- copyPasteModalOpen = true
- }
-
function openRepairModal(text: string, onApply: (repairedText: string) => void) {
jsonRepairModalProps = {
text,