diff --git a/main.js b/main.js index 4b39733..c56fad7 100644 --- a/main.js +++ b/main.js @@ -153,12 +153,14 @@ var AttachmentCleanPasteModule = class extends BaseModule { textarea.inputEl.style.width = "100%"; }); } - async processAll(files, editor, settings) { + async processAll(files, editor, settings, evt) { const matchingFiles = Array.from(files).filter( (f) => this.shouldProcess(f.name, settings) ); if (matchingFiles.length === 0) return; + evt.preventDefault(); + evt.stopPropagation(); const links = []; for (const file of matchingFiles) { const link = await this.processFile(file, settings); @@ -175,9 +177,7 @@ var AttachmentCleanPasteModule = class extends BaseModule { const files = (_a = evt.clipboardData) == null ? void 0 : _a.files; if (!files || files.length === 0) return; - evt.preventDefault(); - evt.stopPropagation(); - await this.processAll(files, editor, settings); + await this.processAll(files, editor, settings, evt); }; } createDropHandler(settings) { @@ -186,9 +186,7 @@ var AttachmentCleanPasteModule = class extends BaseModule { const files = (_a = evt.dataTransfer) == null ? void 0 : _a.files; if (!files || files.length === 0) return; - evt.preventDefault(); - evt.stopPropagation(); - await this.processAll(files, editor, settings); + await this.processAll(files, editor, settings, evt); }; } shouldProcess(filename, settings) { diff --git a/manifest.json b/manifest.json index bc225ae..3763928 100644 --- a/manifest.json +++ b/manifest.json @@ -1,7 +1,7 @@ { "id": "zeroq-qol-modules", "name": "ZeroQ QoL Modules", - "version": "1.1.4", + "version": "1.1.5", "minAppVersion": "0.15.0", "description": "QoL Modules", "author": "oqyude", diff --git a/package.json b/package.json index 490915b..22bd47b 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "zeroq-qol-modules", - "version": "1.1.4", + "version": "1.1.5", "description": "Modular Obsidian plugin with toggleable QoL modules", "main": "main.js", "scripts": { diff --git a/src/modules/attachment-clean-paste/index.ts b/src/modules/attachment-clean-paste/index.ts index a21442e..e9864ea 100644 --- a/src/modules/attachment-clean-paste/index.ts +++ b/src/modules/attachment-clean-paste/index.ts @@ -75,12 +75,16 @@ export class AttachmentCleanPasteModule extends BaseModule { files: FileList, editor: Editor, settings: AttachmentCleanPasteSettings, + evt: ClipboardEvent | DragEvent, ): Promise { const matchingFiles = Array.from(files).filter((f) => this.shouldProcess(f.name, settings), ); if (matchingFiles.length === 0) return; + evt.preventDefault(); + evt.stopPropagation(); + const links: string[] = []; for (const file of matchingFiles) { const link = await this.processFile(file, settings); @@ -100,10 +104,7 @@ export class AttachmentCleanPasteModule extends BaseModule { const files = evt.clipboardData?.files; if (!files || files.length === 0) return; - evt.preventDefault(); - evt.stopPropagation(); - - await this.processAll(files, editor, settings); + await this.processAll(files, editor, settings, evt); }; } @@ -116,10 +117,7 @@ export class AttachmentCleanPasteModule extends BaseModule { const files = evt.dataTransfer?.files; if (!files || files.length === 0) return; - evt.preventDefault(); - evt.stopPropagation(); - - await this.processAll(files, editor, settings); + await this.processAll(files, editor, settings, evt); }; }