Arthur-Milchior / anki-link-to-open-browser

Allow to add links in field/note to open the browser with some search
GNU General Public License v3.0
7 stars 3 forks source link

Copy and paste (likely user specific issue) #5

Open RonilPatel7 opened 4 years ago

RonilPatel7 commented 4 years ago

I have been able to generate this issue (regarding copy and paste of my link) on 2 separate computers running Windows 7 with Anki v2.1.26

As you suggested, I disabled all add ons and still have the issue as demonstrated in this video. Any thoughts or guidance would be appreciated. Thank you for all your help!

https://www.dropbox.com/s/lyyf5ctz5onrl28/Issue5%20-%20Links%20with%20Note%20ID.mp4?dl=0

RonilPatel7 commented 4 years ago

I was able able to test it on a Apple Mac running macOS Mojave v10.14.6 with Anki 2.1.26 and noted that the issue was not present; the copy and paste worked as expected with all of my other add ons running

Arthur-Milchior commented 4 years ago

Since I can't reproduce, I don't even know how to check easily when the problem occur. Is the link stripped when you copy or when you paste ? May be by posting to a word/libreoffice/google doc, you can then analyze the link and see whether the command is still in it or not.

But even with this information, I still have no clue what I would do with it. My add-on does not deal in any way with copy/paste; and I do not want to ever deal with it. Copy/paste is a very basic thing, it would be a nightmare to debug it. I don't deal with it. Anki essentially do not deal with it. It deals with what occurs when you paste media, when you paste formatted text, it allows you to decide whether you want to keep formatting or not. But even if you pasted with ctrl+shift+v, it would be stripping all formatting, it would not be stripping only part of it. I assume that Qt deal with copy-paste, and even Qt is probably delegating it to the browser (I believe it's supposed to be chromium), which probably delegate some it to the operating system.

I hate this bug, because it means that there is fundamentally something that I don't understand here. It's not just a silly mistake of mine (I made quite a lot) but some fact about this system that I'm so ignorant that I currently don't know what I am looking for. That has not often be the case with anki, which is mostly a program which does not do anything special as far as user interface goes

RonilPatel7 commented 4 years ago

I noticed that it was potentially happening with the old "internal references" add on as well: https://github.com/glutanimate/internal-references/issues/5

ijgnd commented 4 years ago

I can't reproduce the problem on my linux computer.

But I can reproduce the problem on Windows 10 with Anki 2.1.26 and just the addons Links between notes, cards, to open browser and previewer and Opening the same window multiple time.

When I copy something that has <a onclick="pycmd(' this part is properly added to the clipboard: The text editor Notepad++ offers an option "Edit->Paste Special->Past Html Content" and there I clearly see this part.

When I use my add-on editor: paste raw unfiltered full html in Windows 10 I can paste and preserve the link. This add-on basically does these steps:

mode = QClipboard.Clipboard
mime = editor_instance.mw.app.clipboard().mimeData(mode=mode)
html, _ = editor_instance.web._processMime(mime)
editor_instance.note.fields[field_idx] = html 
editor_instance.note.flush()
RonilPatel7 commented 4 years ago

@ijgnd Thank you telling me about "paste unfiltered full HTML" this will be a great workaround!

ijgnd commented 1 year ago

this odd behavior (that qtwebengine removes this link only in windows) no longer seems to occur in Windows 10 with Anki 2.1.55qt6 beta6.