Closed shouya closed 7 months ago
When you drag and drop images, they're pasted at the cursor, unlike when you copy-paste them. So the issue probably can't be resolved in this add-on. This add-on takes mime data coming from Anki, modifies it and returns it back. It doesn't handle cursor position.
But if I'm wrong please correct me.
When you drag and drop images, they're pasted at the cursor
I tried dragging an image from browser, but the image was still inserted at the beginning. And the input box doesn't seem to support dragging image to move it around.
The only resort, which I currently rely on, is to shift-select the image in the text box, Ctrl-X, and then Ctrl-V at the desired location. Note that click-select on the image doesn't work with the cut/pasting, I have to select it by placing the cursor to the right of the image, press "Shift-\<Left>" to select it.
I'm not sure if this is an issue with my environment. Just to provide more information, I use Anki 23.12.1 under Debian running XMonad without a DE. The Anki's video driver is OpenGL. I couldn't find the exact version of AJT/PasteImageAsWebP I'm using, but I believe it's the latest version available on AnkiWeb (updated on 2024-02-11).
I did more experiments and found that if I turn off "Show this dialog" for all three options, the dialogue won't show up and the converted image is pasted at the expected place. From this evidence I suspect it's the modal dialogue that's stealing the focus on the text field, making it lose track of the cursor position.
For the time being, I'm satisfied with this solution. I rarely need to tweak the settings anyway. I would suggest leaving the dialogue disabled for copy-pasting by default.
BTW it seems to be a bug that even if "Show this dialog" is only enabled for "Toolbar and menus", the dialog still shows up for pasting.
I think Anki should remember cursor position before the process mime hook fires. Otherwise the position might shift during mime processing.
I tried dragging an image from browser, but the image was still inserted at the beginning.
This wasn't the case when I tested it for some reason.
BTW it seems to be a bug that even if "Show this dialog" is only enabled for "Toolbar and menus", the dialog still shows up for pasting.
"Toolbar and menus" includes copy-pasting, but doesn't include drag-and-dropping.
"Toolbar and menus" includes copy-pasting, but doesn't include drag-and-dropping.
I thought it was a mistake and was trying to send a PR (#29). If this is intended may I ask why is this designed so?
No, it is a feature. When you paste an image, you use a menu (right click > paste) so it is logical for this action to fall under the "toolbar and menus" category. When you use a keyboard shortcut, the shortcut is attached to the same action as well.
I see. Then how about we instead make a distinction between "toolbar" and "paste"? I think it's quite sensible for the toolbar button to show up a dialogue, probably a bit less so for pasting.
Then how about we instead make a distinction between "toolbar" and "paste"?
Yes, seems good.
First of all, thanks for this wonderful add-on!
A small annoyance I had when pasting image using this add-on while editing cards is that the inserted image comes into the beginning of the text input. I think it would be nice to have the image inserted at the cursor position instead of the beginning, since such behavior is consistent with the default image pasting ux.
Steps to reproduce:
Expected outcome:
The text box should now contains "test\<image>|". Where
|
indicates the new cursor position.Actual outcome:
The text box shows "\<image>test|".