Skip to content

Commit

Permalink
refactor: return image url instead of void
Browse files Browse the repository at this point in the history
  • Loading branch information
gavvvr committed Jun 29, 2024
1 parent 995b19b commit ffd7855
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions src/ImgurPlugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,7 @@ export default class ImgurPlugin extends Plugin {
// with any text added by the plugin
this.getEditor().replaceSelection('\n')

const promises: Promise<void>[] = []
const promises: Promise<any>[] = []
const filesFailedToUpload: File[] = []
for (let i = 0; i < files.length; i += 1) {
const image = files[i]
Expand Down Expand Up @@ -233,8 +233,12 @@ export default class ImgurPlugin extends Plugin {
const arrayBuffer = await this.app.vault.readBinary(file)
const fileToUpload = new File([arrayBuffer], file.name)
editor.replaceRange('\n', end, end)
await this.uploadFileAndEmbedImgurImage(fileToUpload, { ch: 0, line: end.line + 1 })
const imageUrl = await this.uploadFileAndEmbedImgurImage(fileToUpload, {
ch: 0,
line: end.line + 1,
})
editor.replaceRange(`<!--${editor.getRange(start, end)}-->`, start, end)
return imageUrl
}

get imgUploader(): ImageUploader {
Expand Down

0 comments on commit ffd7855

Please sign in to comment.