diff --git a/packages/nc-gui/components/smartsheet/grid/Table.vue b/packages/nc-gui/components/smartsheet/grid/Table.vue index c48f41b669..4c90c5b913 100644 --- a/packages/nc-gui/components/smartsheet/grid/Table.vue +++ b/packages/nc-gui/components/smartsheet/grid/Table.vue @@ -169,7 +169,7 @@ const predictNextFormulas = async () => { await _predictNextFormulas(meta) } -const { paste } = usePaste() +const { paste } = usePaste(true) // #Refs diff --git a/packages/nc-gui/composables/usePaste.ts b/packages/nc-gui/composables/usePaste.ts index c9c35e19bd..0d70a447a7 100644 --- a/packages/nc-gui/composables/usePaste.ts +++ b/packages/nc-gui/composables/usePaste.ts @@ -1,4 +1,8 @@ -export const usePaste = () => { +import { useI18n, message } from '#imports' + +export const usePaste = (showDialogIfFailed = false) => { + const { t } = useI18n() + const paste = async (): Promise => { try { // Check if the Clipboard API is supported @@ -23,6 +27,10 @@ export const usePaste = () => { document.dispatchEvent(pasteEvent) return true } catch (e) { + if (!showDialogIfFailed) throw new Error(t('msg.error.pasteFromClipboardError')) + + message.error(t('msg.error.pasteFromClipboardError')) + return false } } diff --git a/packages/nc-gui/lang/en.json b/packages/nc-gui/lang/en.json index a4883cffb7..b2875c9f0e 100644 --- a/packages/nc-gui/lang/en.json +++ b/packages/nc-gui/lang/en.json @@ -1288,7 +1288,8 @@ "duplicateParameterKeysAreNotAllowed": "Duplicate parameter keys are not allowed", "fieldRequired": "{value} cannot be empty.", "projectNotAccessible": "Base not accessible", - "copyToClipboardError": "Failed to copy to clipboard" + "copyToClipboardError": "Failed to copy to clipboard", + "pasteFromClipboardError": "Failed to paste from clipboard" }, "toast": { "exportMetadata": "Base metadata exported successfully",