From 710def86ee8b4662a13f0edf3b95ded3dff9ae15 Mon Sep 17 00:00:00 2001 From: Nito Date: Mon, 15 Sep 2025 09:40:05 +0200 Subject: [PATCH] don't log error when no image paste was attempted --- main.ts | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/main.ts b/main.ts index 34878a8..e05530e 100644 --- a/main.ts +++ b/main.ts @@ -9,6 +9,9 @@ export default class PasteImageIntoProperty extends Plugin { handlePaste(evt: ClipboardEvent) { const activeEl = document.activeElement as HTMLElement; + if (!evt.clipboardData || evt.clipboardData.types[0] != 'Files') + return false; + const isFrontmatterFieldSupported = this.isSupportedFrontmatterField(activeEl); if (isFrontmatterFieldSupported) this.handleImagePaste(evt, activeEl); @@ -29,13 +32,7 @@ export default class PasteImageIntoProperty extends Plugin { } async handleImagePaste(evt: ClipboardEvent, target: HTMLElement) { - if (!evt.clipboardData) - return; - - if(evt.clipboardData.types[0] != 'Files') - return; - - const items: DataTransferItemList = evt.clipboardData.items; + const items: DataTransferItemList = evt.clipboardData!.items; for (let i = 0; i < items.length; i++) { const item = items[i];