Tippy Tooltips [Official Support]

I am on macOS. The shortcut doesn’t work.

Ah… I think I know what’s the problem. I set the target syntax of the TS build to ESNext. There’s probably something in the compiled output that isn’t supported by the browser macOS uses.

I had a similar issue a long time ago with CSS Injector:

1 Like

@ferophila I pushed an update to AnkiWeb. Does it work now? No rush, thanks for the report and testing!

1 Like

Thanks, it works now. The update has helped me to discover one more problem
:smiley:

When I check “Tooltips Enabled” and “Show tooltips on front side” and save the dialogue, none of the options is saved. In case I check “Tooltips Enabled” again and also “Show tooltips on front side” an error message shows up:

Anki 2.1.58 (ab8b1465) Python 3.9.15 Qt 5.14.2 PyQt 5.14.1
Platform: macOS-12.6.3-x86_64-i386-64bit
Flags: frz=True ao=True sv=3
Add-ons, last update check: 2023-02-17 22:17:37
Möglicherweise beteiligte Erweiterungen: <U+2068>Anki Tooltips<U+2069>

Caught exception:
Traceback (most recent call last):
  File "/Users/ferophila/Library/Application Support/Anki2/addons21/1840818335/gui/dialogs/model_settings.py", line 48, in accept
    self.callback(
  File "/Users/ferophila/Library/Application Support/Anki2/addons21/1840818335/qt/models.py", line 33, in set_settings
    update_model(mw.col.models.get(mid))
  File "/Users/ferophila/Library/Application Support/Anki2/addons21/1840818335/utils.py", line 78, in update_model
    mw.col.models.update_dict(model)
  File "anki.models", line 223, in update_dict
  File "anki._backend_generated", line 861, in update_notetype_legacy
  File "anki._backend", line 156, in _run_command
anki.errors.BackendError: JsonError { info: "invalid type: boolean `false`, expected a string at line 1 column 320" }

An error also occurs when unchecking the second box after the dialogue was opened again:

Anki 2.1.58 (ab8b1465) Python 3.9.15 Qt 5.14.2 PyQt 5.14.1
Platform: macOS-12.6.3-x86_64-i386-64bit
Flags: frz=True ao=True sv=3
Add-ons, last update check: 2023-02-17 22:17:37
Möglicherweise beteiligte Erweiterungen: <U+2068>Anki Tooltips<U+2069>
Caught exception:
Traceback (most recent call last):
  File "/Users/ferophila/Library/Application Support/Anki2/addons21/1840818335/gui/dialogs/model_settings.py", line 48, in accept
    self.callback(
  File "/Users/ferophila/Library/Application Support/Anki2/addons21/1840818335/qt/models.py", line 33, in set_settings
    update_model(mw.col.models.get(mid))
  File "/Users/ferophila/Library/Application Support/Anki2/addons21/1840818335/utils.py", line 78, in update_model
    mw.col.models.update_dict(model)
  File "anki.models", line 223, in update_dict
  File "anki._backend_generated", line 861, in update_notetype_legacy
  File "anki._backend", line 156, in _run_command
anki.errors.BackendError: JsonError { info: "invalid type: boolean `false`, expected a string at line 1 column 213" }
1 Like

Thanks! This will help me reproduce Can not enable Tooltips on front side · Issue #3 · kleinerpirat/anki-tooltips · GitHub.

I don’t have much time over the weekend in February, but I’ll try to fix this as soon as possible.

Hi @kleinerpirat,
I’ve been working on a script for my studies (I’ve mainly repurposed the templates you’ve previously shared with some original code to fit my needs and polished them :sweat_smile:). I want to share them with my classmates and other people at my university, so I thought about making it a standalone add-on but I think it may be useful to many other people, so I was wondering if you were planning on making it possible to share the scripts/templates for your add-on somewhere (like on the github repo for example), otherwise I’ll just go ahead and make it its own add-on. The script btw is more like a tool that queries wikimedia to look up any word and show the info in the tooltip, in the same fashion that wikipedia articles show their tooltips, but for all and any words/terms. No URLs!

That wikimedia script sounds really nice :+1:

Currently I don’t have any plans regarding the sharing of template scripts. This sounds more like a job for Asset Manager. Although my add-on also deals with script insertion into card templates, that is not its main purpose.

Oh I understand. I was thinking more of a platform to share the script on since it would be weird to share the script directly and it wouldn’t reach as many people. I think I will opt to make it a standalone add-on. In that case, would it be okay to use some of your code (specifically the wikipedia template)? I think I will implement popper and tippy directly into the add-on for a more user-friendly installation process.

Sure, go ahead! Sorry I can’t help you with such a platform right now. It would be a bit too involved. You can take the GitHub repo as a reference for how to insert scripts.

Oh, and have you considered simply including the script in a template of yours and sharing that with your friends via AnkiWeb, GitHub or some other filesharing service?

yeah I did. Definitely will be the first release, but it has some drawbacks. I think in the future it would be more beneficial if it is an add-on but we’ll see. Thanks for the feedback and for the code, much appreciated!

Hi. Since the last update the add-on seems to be giving me bugs in the Browser.

When I load a note whose notetype has x fields, if I then move to another note whose notetype has x1<x fields, Anki has trouble loading the second notetype.
The fields all display the names of those of the previous notenotype, they use the same font-family, and there are “supernumerary” fields that display the content they had in the previously loaded note.
(with “supernumerary” fields I mean any field whose position is greater than x-x1. E.g. if the first notetype has 25 fields and the second has 20 fields, there are 5 supernumerary fields)

Once you move from a notetype with x fields to another with x1<x fields, the fields are “stuck”. That is to say, even if you move to another notetype with x2>x fields, Anki still keeps displaying the same field names, font-families, the “supernumerary” fields (that in this case are not actually supernumerary) keep displaying the same content etc.
Once the fields are “stuck”, you also cannot open the HTML editor.

Closing and re-opening the Browser resets it.

Windows 10
Version ⁨2.1.58 (ab8b1465)⁩
Python 3.9.15 Qt 6.4.2 PyQt 6.4.0

Tested with only Anki Tooltips installed.

2 Likes

Thank you for the report. You’ve revealed a fatal error in my use of lifecycle.onMount, the part of the JS API that allows add-on authors to hook into the creation of Svelte components. It is fixed now.

For devs, here’s the GitHub issue with solution: Crash in browser due to missing callbacks in lifecycle.onMount · Issue #4 · kleinerpirat/anki-tooltips · GitHub

2 Likes

anyone else facing the problem that when pasting with cmd + V, it also gets pasted at the very beginning even if the cursor is positioned and the end of the sentence?

happens with text and pictures. I’m curious, why is that?

That was an issue with an earlier version of the add-on, when it was still called “Tippy Tooltips”.
Are you sure you’re on the latest version? You can check by going to Add-ons > Check for Updates.

Hi. I noticed a small bug with HTML tags in the most recent version of the add-on. Not sure when it started occurring.

Steps to reproduce:

  1. Open the Add card window

  2. Write some HTML tag in the “not-HTML” part of the field, e.g. <span>HelloWorld</span>

  3. Preview the card: the tags will be omitted and only HelloWorld will be shown.

  4. Return to the Add card window → change notetype: the pseudo span tags will become true span tags.

Windows 10
Anki 2.1.60 (76d88073)⁩
Python 3.9.15 Qt 6.4.2 PyQt 6.4.0
I didn’t test it with only Anki Tooltips installed, but the problem seems to disappear if I toggle the add-on.

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, repeating 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 to the add-on author.
Debug info:
Anki 2.1.62 (b5fa47e3) Python 3.9.15 Qt 6.5.0 PyQt 6.5.0
Platform: Windows-10-10.0.19045
Flags: frz=True ao=True sv=3
Add-ons, last update check: 2023-04-26 11:39:10

C:\Users\UserName\AppData\Roaming\Anki2\addons21\1840818335\qt\editor.py:44: MarkupResemblesLocatorWarning: The input looks more like a filename than markup. You may want to open this file and pass the filehandle into Beautiful Soup.
  soup = BeautifulSoup(txt, "html.parser")

Thanks for the report, I’ll see to it. I’ve encountered this error before and thought I had fixed it.

2 Likes

The addon works perfecty, thank you so much, absolutely essential! Is it possible to only remove the underline of the speech bubble?

Probably related: the add-on interferes with the correct functioning of HTML entities (e.g. &nbsp; &amp; &lt;). Only entities added while the add-on was active are affected.

Steps to reproduce:

  1. Add a new note containing an HTML entity (e.g. &amp;).
  2. Go to the Browser bar, type &amp;, search → the note will not appear among the search results.
  3. If you instead just type the actual representation of the HTML entity (e.g. &), the note will be included in the Browser’s search results.

This means, for example, that any &nbsp; added while the add-on was active cannot be searched for in the Browser, nor removed using Anki’s Find and Replace, nbspRemover or editor: batch replace in one field, also with regex - AnkiWeb.

It seems that the “normal” HTML entities can be restored by disabling the add-on and then making any edit to the content of the field they are in.

I have just released WikiLookup add-on on AnkiWeb. Much of its code is inspired by your Anki Tooltips add-on (however, I did credit you on the add-on’s page if that is ok with you :smiling_face:)
But during the development, which was entirely on a Windows machine, I was testing it on Anki for MacOS and came across a weird bug? Probably lack of support. WikLookup uses Tippy.js and the popup animation is the same as in Anki Tooltip’s style.css
It works fine on Anki for Windows. However, in MacOS, the animation does not work at all, but rather the tooltip just appears and disappears, and .tippy-arrow either does not appear (as is the case in WikiLookup) or has highly incorrect proportions (as is the case in Anki Tooltips) as far as my tests go. Do you have any idea if Anki for MacOS has a different CSS engine? or is it a Tippy.js problem?

If you have any questions I’ll gladly help, since I want this to be resolved as soon as possible.