Closed lishid closed 2 years ago
Here are some improvements you can look into:
https://github.com/jordanhandy/obsidian-cloudinary-uploader/blob/2cab25efd73dc752de314b17af8408e9314dbf55/src/main.ts#L42 This logic seems faulty - if files.length is equal to 0 then it shouldn't be able to access files[0].
files.length
files[0]
https://github.com/jordanhandy/obsidian-cloudinary-uploader/blob/2cab25efd73dc752de314b17af8408e9314dbf55/src/main.ts#L47 Need to move this up one line.
https://github.com/jordanhandy/obsidian-cloudinary-uploader/blob/2cab25efd73dc752de314b17af8408e9314dbf55/src/main.ts#L79 You don't want to do this - because editor-paste runs for every paste event. Doing so will break regular pasting text.
editor-paste
https://github.com/jordanhandy/obsidian-cloudinary-uploader/blob/2cab25efd73dc752de314b17af8408e9314dbf55/src/main.ts#L90 Instead of using getValue() and split('\n'), you should use getLine() and lineCount.
getValue()
split('\n')
getLine()
lineCount
Recommendations should be implemented with 277ddf389dd4a188ac41cab3f1a297856f4ebdc7
Here are some improvements you can look into:
https://github.com/jordanhandy/obsidian-cloudinary-uploader/blob/2cab25efd73dc752de314b17af8408e9314dbf55/src/main.ts#L42 This logic seems faulty - if
files.length
is equal to 0 then it shouldn't be able to accessfiles[0]
.https://github.com/jordanhandy/obsidian-cloudinary-uploader/blob/2cab25efd73dc752de314b17af8408e9314dbf55/src/main.ts#L47 Need to move this up one line.
https://github.com/jordanhandy/obsidian-cloudinary-uploader/blob/2cab25efd73dc752de314b17af8408e9314dbf55/src/main.ts#L79 You don't want to do this - because
editor-paste
runs for every paste event. Doing so will break regular pasting text.https://github.com/jordanhandy/obsidian-cloudinary-uploader/blob/2cab25efd73dc752de314b17af8408e9314dbf55/src/main.ts#L90 Instead of using
getValue()
andsplit('\n')
, you should usegetLine()
andlineCount
.