Link cards/notes and preview them in extra window [Official thread]

@throw: since early 2020 I have this part in my add-on description on ankiweb:

# Compatibility, Limitations - the hyperlink features does not work with editable fields created by the addons Edit Field During Review or Edit Field During Review (Cloze). Use the context menu.

If it’s not that limitation:

the code of my add-on has hardly changed over the last 18 months and the original edit field during review add-on hasn’t been updated over a year. So I don’t know which problem could have recently started to occur.

I need more info. Does this problem also occur with Anki 2.1.49 and only these two add-ons (in their most recent version because of a recent updated check) installed or enabled after having restarted anki? Exact steps to reproduce the problem?

1 Like

@beifang: I also like this feature. I guess it makes more sense to have this as a standalone add-on that modifies all card preview windows.

glutanimate had an add-on named “advanced previewer” that allowed this and for a long time he’s been promising to release it soon. I don’t think it makes sense for me to replicate this work and it’s probably impolite to publish a small modification of his old code under my account.

1 Like

The add-on functions well on my old Windows 7 machine but not on my new Windows 10 machine. When I click “Browse” I get the following error message:

Debug info:
Anki 2.1.46 (94913ec2) Python 3.8.6 Qt 5.14.2 PyQt 5.14.2
Platform: Windows 10
Flags: frz=True ao=True sv=2
Add-ons, last update check: 2022-03-18 00:49:25

Caught exception:
Traceback (most recent call last):
File “aqt\webview.py”, line 41, in cmd
File “aqt\webview.py”, line 139, in _onCmd
File “aqt\webview.py”, line 592, in _onBridgeCmd
File “aqt\toolbar.py”, line 168, in _linkHandler
File “aqt\toolbar.py”, line 186, in browseLinkHandler
File “aqt\main.py”, line 1119, in onBrowse
File "aqt_init
.py", line 115, in open
TypeError: init() got an unexpected keyword argument ‘card’

The error seems to be related to the “Link Cards notes…”. When I disable it and restart Anki the Browser is accesible but it is not when the add-on is enabled.

@erfosp : could you check for add-on updates, install those and restart anki and try again. Does this error still persist? I had similar reports that were solved after getting add-on updates.

No! I did what you suggested but the problem remains.

strange. I can’t reproduce the problem in 2.1.46 in Windows 10 or linux. So I can’t help. I have no idea why my add-on should cause this.

Also it’s strange that no other people have reported this. I had a similar bug report and it turned out that my add-on was not the problem after all but another dated one, see Link cards/notes and preview them in extra window [Official thread] - #32 by Liliumanki

maybe have a look at When problems occur - Frequently Asked Questions

How I preview the linked note with show back side option unselected? it always open with back side checked but I don’t want it show up so I can memorize it.
GIF

@Aaron647 : check the add-on options - there’s a setting "card_preview__default_is_answer" or something similar that should be set to false.

Hello,

Is it possible to rename the hyperlink? For example, I would like to rename something like nidd1670121881148 → Antibiotics. This would help me make more sense of the cards.

It’s already on my todo list, see nicer formatting for linked notes: nidd0123 is just ugly and not needed: use the html a tag for hyperlinks · Issue #17 · ijgnd/anki__preview_card_edit_note_in_extra_window_linked_from_reviewer · GitHub

I don’t know when I’ll have time for this.

No worries and thanks

Hi ilgnd,

This is working well, but I get an error message each time I click a link. Do you know why this might be? This is the error message.

Error
An error occurred. Please start Anki while holding down the shift key, which will temporarily disable the add-ons you have installed.
If the issue only occurs when add-ons are enabled, please use the Tools>Add-ons menu item to disable some add-ons and restart Anki, repeat until you discover the add-on that is causing the problem.
When you’ve discovered the add-on that is causing the problem, please report the issue on the add-ons section of our support site.
Debug info:
Anki 2.1.54 (b6a7760c) Python 3.9.7 Qt 6.3.1 PyQt 6.3.1
Platform: Mac 11.4
Flags: frz=True ao=True sv=2
Add-ons, last update check: 2023-01-12 07:41:34
Add-ons possibly involved: ⁨Language Tools - Learn Foreign Languages with Anki⁩

ERROR:root:could not process field update [key:2:1663935550790:


]
Traceback (most recent call last):
File “/Users/oliverlovell/Library/Application Support/Anki2/addons21/771677663/editor_processing.py”, line 252, in process_field_update
from_deck_note_type_field = from_deck_note_type_field = self.languagetools.deck_utils.editor_get_dntf(editor, field_index)
File “/Users/model_it/Library/Application Support/Anki2/addons21/771677663/deck_utils.py”, line 108, in editor_get_dntf
deck_note_type = self.build_deck_note_type_from_editor(editor)
File “/Users/oliverlovell/Library/Application Support/Anki2/addons21/771677663/deck_utils.py”, line 102, in build_deck_note_type_from_editor
deck_note_type = self.build_deck_note_type_from_note_card(note, editor.card)
File “/Users/oliverlovell/Library/Application Support/Anki2/addons21/771677663/deck_utils.py”, line 79, in build_deck_note_type_from_note_card
raise errors.AnkiItemNotFoundError(f’card not found’)
771677663.errors.AnkiItemNotFoundError: card not found
WARNING:urllib3.connectionpool:Retrying (Retry(total=2, connect=None, read=None, redirect=None, status=None)) after connection broken by ‘NewConnectionError(’<urllib3.connection.HTTPSConnection object at 0x1413ed730>: Failed to establish a new connection: [Errno 8] nodename nor servname provided, or not known’)‘: /api/5920286/store/
WARNING:urllib3.connectionpool:Retrying (Retry(total=1, connect=None, read=None, redirect=None, status=None)) after connection broken by ‘NewConnectionError(’<urllib3.connection.HTTPSConnection object at 0x1413edd60>: Failed to establish a new connection: [Errno 8] nodename nor servname provided, or not known’)‘: /api/5920286/store/
WARNING:urllib3.connectionpool:Retrying (Retry(total=0, connect=None, read=None, redirect=None, status=None)) after connection broken by ‘NewConnectionError(’<urllib3.connection.HTTPSConnection object at 0x1413edf40>: Failed to establish a new connection: [Errno 8] nodename nor servname provided, or not known’)': /api/5920286/store/

Thank you so much for creating this add-on. I’ve been keen for something like this for ages, so super excited to have found it!

the error is (most likely) not related to my add-on.

To diagnose this: disable all other add-ons besides mine, restart anki and try again.

If you read the error message you see that it’s coming from the add-on id 771677663 which is Language Tools - Learn Foreign Languages with Anki. the bottom of the error message is about not getting a connection. Maybe you had some trouble with your internet, maybe you use some vpn or maybe some api key that the add-on uses expired? for this ask the person who made this add-on.

一切使用的都很顺利,但是当你有三个屏幕的时候,在第三个屏幕上,anki浏览器上点击笔记,你将看不到相关条目,如下图所示:

Hi, thanks for your add-on! This is a bug report. Installing the plugin and copying a nid went fine, but then I tried to copy a cid and got this error.

I restarted Anki and it seems to be working fine now. But here is the debug info anyway. I will write again if anything else happens.

Anki 24.06.2 (33a92379)  (ao)
Python 3.9.18 Qt 6.6.2 PyQt 6.6.1
Platform: Windows-10-10.0.22631

Traceback (most recent call last):
  File "C:\Users\ngech\AppData\Roaming\Anki2\addons21\1423933177\browser.py", line 49, in <lambda>
    qconnect(browser.action_copy_cid.triggered, lambda _, b=browser:browser_shortcut_helper_cid(b))
  File "C:\Users\ngech\AppData\Roaming\Anki2\addons21\1423933177\browser.py", line 26, in browser_shortcut_helper_cid
    if browser.card.id:
AttributeError: 'NoneType' object has no attribute 'id'

===Add-ons (active)===
(add-on provided name [Add-on folder, installed at, version, is config changed])
FSRS Helper Postpone  Advance  Load Balance  Easy Days  Disperse Siblings ['759844606', 2024-06-22T13:05, 'None', mod]
link Cards Notes and Preview them in extra window ['1423933177', 2023-10-28T06:26, 'None', '']

===IDs of active AnkiWeb add-ons===
1423933177 759844606

===Add-ons (inactive)===
(add-on provided name [Add-on folder, installed at, version, is config changed])

Thanks for the report. If I understand the translation correctly the problem only occurs when you are working with three screens. So far I haven’t seen this problem and I need to think about this.

The area you highlighted in your screenshot with the red arrow some code makes the context menu bigger but no text appears in it. I have no idea how my code should cause this. My add-on code only tells the underlying components that Anki uses to add a context menu entry with text like “copy cid”.

This makes me think maybe the problem is caused by code that I do not control.

The underlying components that Anki uses sometimes have weird bugs. That’s the reason why there are so many different versions of Anki offered when dowloading Anki from https://apps.ankiweb.net/ . You can download a version built with qt5 or with qt6 and you can download an older version of Anki using older versions of qt5/qt6. (The Anki developer is aware of this problem and he’s working on it but fixing this requires a complete overhaul of the anki software that takes multiple years).

It would be interesting to know: If you are not on the latest version: Does updating help? Does this also happen with the other qt version (if you are using qt6 does it also happen with the qt5 version and vice versa). If you are on the latest version does downgrading to 24.04 or 23.10 change anything?

Also make sure to disable all other addons and restart.

@missink : Thanks for your detailled bug report that contains crucial details

You found a bug that I will fix in the next version. This bug is pretty harmless, nothing gets damaged it just slows down copying the card id…

At the moment I can only reproduce this bug under very rare conditions, e.g. I run a search that matches no notes/cards so that I have an empty browser. Then I go to the menu “linking” and select “copy cid”. When I have notes/cards listed in the browser and I use “copy nid”/“copy cid” from the context menu I haven’t had problems.

So at the moment I would just add two lines of code with a logic like this: if no card or note is selected and the the user tries to copy the cid/nid show a tooltip/warning in the lower left corner of the browser with the text “no note/card selected. Aborting …”.

But maybe that’s not enough. I wonder: Does this always happen? often? sometimes? If it happens only sometimes: Do you have an idea what’s different about these cases?

1 Like

Hello, can i make the link appear as the title of the card it links to? like the whole cidd and nidd ids are very long and take up a lot of space, i would like it to look like a simple clickable word, the same way how you can give titles to hyperlinks like this