xRyul / obsidian-image-converter

⚡️ Convert and compress images from one format to another by drag'n'dropping or pasting files into the note.
MIT License
111 stars 11 forks source link

[Improvement] Cursor after pasting image is behind image #34

Open TimonGisler opened 6 months ago

TimonGisler commented 6 months ago

First of all, thanks for this amazing plugin. Thanks to the compression, my images are now only a third its size. And being able to specify a default size is also something that I greatly appreciate (its how I found this plugin at first :D).

Anyway, there is a small inconvenience. After pasting an image the cursor is now behind the image link. Which means I have to move my cursor again to the front to continue writing.

Nothing big, but it would improve my quality of life a little bit, if it were possible to fix that. : )

Thanks for your work

Video to demonstrate the inconvenience:

https://github.com/xRyul/obsidian-image-converter/assets/49547606/af572636-c79b-43f7-8439-0a0eae73b30b

amogh-w commented 5 months ago

This is happening due to this code.

editor.setCursor({ line: currentLine, ch: 0 });

After pasting the file and renaming, it places the cursor at the start position. I commented the line and generated a main.js file, replaced into my plugins folder and the cursor seems to be fine after pasting.

main.js.zip

I am still learning Obsidian Plugins, so I am not sure what the correct logic should be. Perhaps it should be an easy fix for @xRyul

aravindk100 commented 2 months ago

Thank you @amogh-w for sharing this main.js file. This annoyance was really painful when taking notes on meetings with lots of slides but thanks to you I was able to overcome it. Appreciate the sharing.