Anki 2.1.51 Release Candidate

Hi all,

Hot on the heels of the 2.1.50 release, a 2.1.51 release candidate is available with a few fixes, and a few changes that didn’t make the 2.1.50 release. The plan is to give this a week or two of testing before a stable release, and there may be an rc2 depending on what crops up before then.

https://betas.ankiweb.net/anki2.1.51.html

4 Likes

AnkiConnect issue has been resolved in this version 2.51.rc1.
Tanks.

1 Like

My card browser is crashing when I type in “\(” to a card with existing MathJax on it. (Version 2.1.50, MacOS). The crash freezes the card editor and prevents Anki from closing (only manually killing the process works) Where should I report this?

The field in question is:

Let <anki-mathjax>X</anki-mathjax> be a Markov jump process<sup>D78</sup> where:<br><ul><li>there are <anki-mathjax>n</anki-mathjax> states, be a&nbsp;</li><li>the transition forces are <anki-mathjax>\mu_{ij}</anki-mathjax> where <anki-mathjax>1 \leq i,j \leq n</anki-mathjax>,</li><li>the observation time in state <anki-mathjax>i</anki-mathjax> is <anki-mathjax>v_i</anki-mathjax>,</li><li>the observed number of transitions from state <anki-mathjax>i</anki-mathjax> to state <anki-mathjax>j</anki-mathjax> is <anki-mathjax>d_{ij}</anki-mathjax></li></ul>Then the likelihood function for <anki-mathjax>X</anki-mathjax> is&nbsp;<anki-mathjax block="true">\begin{align}L &amp; = {{c1::\prod_{i=1}^n \left(e^{-\left(\sum_{k \neq i} \mu_{ik}\right)v_i} \prod_{k \neq i} \mu_{ik}^{d_{ik} }\right)\\ &amp; = \prod_{i \neq j} \left(e^{-\mu_{ij} v_i} \mu_{ij}^{d_{ij} }\right)}}\end{align}.</anki-mathjax>
1 Like

I could reproduce this error on 2.1.50, but it seems to be fixed with 2.1.51.

You can download it here: Index of /downloads/beta/

1 Like

A weird new bug: When editing a text field (whether in the “Add” or “Browser” window), pressing SHIFT cancels a just invoked formatting mode (bold, underline or italic).

Steps to reproduce:

  1. Open the “Add” window
  2. Highlight a content field
  3. Press CTRL+B to invoke bold formatting (the “B” in the toolbar shows that it’s activated)
  4. Type “Horse” (holding down the SHIFT key to type the capital “H”)

Expected result: Horse
Actual result: Horse

It seems to only occur if SHIFT is the first key pressed after invoking the formatting mode.

Using this version:

    Anki 2.1.51 (51a0641b) Python 3.9.10 Qt 6.2.2 PyQt 6.2.2
    Platform: Linux
    Flags: frz=True ao=False sv=3
1 Like

In my Language Tools addon, I have some field-specific actions and I noticed that the editor context menu can be triggered by right-clicking not just inside the fields, but also on the field header and that’s great because it’s a more user friendly way of allowing per-field actions. I noticed however that the right-click must be preceded with a left click in order to select the right field.
over here i’ve selected a field and the right-click context menu shows the right actions


but here, I’ve right-clicked on the “Sound” header, and i’m getting the context menu from the “Chinese” field. I’d like to get the context menu for the Sound field.

1 Like
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.51 (51a0641b) Python 3.9.7 Qt 6.2.2 PyQt 6.2.2
Platform: Windows 10
Flags: frz=True ao=True sv=3
Add-ons, last update check: 2022-04-11 13:09:58

Caught exception:
Traceback (most recent call last):
  File "aqt.taskman", line 99, in _on_closures_pending
  File "aqt.taskman", line 69, in <lambda>
  File "aqt.taskman", line 88, in wrapped_done
  File "aqt.sync", line 116, in on_future_done
  File "aqt.main", line 963, in on_collection_sync_finished
  File "aqt.main", line 766, in reset
  File "aqt.main", line 718, in _synthesize_op_did_execute_from_reset
  File "aqt.hooks_gen", line 2951, in __call__
  File "aqt.browser.browser", line 151, in on_operation_did_execute
AttributeError: 'Browser' object has no attribute 'editor'

I am not sure if a field should also get focus when its label is right-clicked. But even with the current Anki code, you can use QCursor.pos() and document.elementFromPoint() to detect which field contains the element that exists at the right-clicked position, regardless of whether it is focused or not.

example code and screenshot
  • TypeScript
function getClickedField(x: number, y: number): Element | undefined {
    const clickedElement = document.elementFromPoint(x, y);
    return [...document.querySelectorAll(".editor-field")].find((field) =>
        field.contains(clickedElement)
    );
}

function getLabel(x: number, y: number): string | null | undefined {
    return getClickedField(x, y)?.querySelector(".label-name")?.textContent;
}
  • Python
from __future__ import annotations

from aqt import editor, gui_hooks, mw, qt, webview

mw.addonManager.setWebExports(__name__, r".*\.js")
addon_package = mw.addonManager.addonFromModule(__name__)


def on_webview_will_set_content(
    web_content: webview.WebContent, context: object | None
) -> None:
    if isinstance(context, editor.Editor):
        web_content.js.append(f"/_addons/{addon_package}/ts/my_script.js")


def on_editor_will_show_context_menu(
    editor_webview: editor.EditorWebView, menu: qt.QMenu
) -> None:
    def callback(label: str | None) -> None:
        if label:
            menu.addAction(f"label: {label}", lambda *_: print(label))

    # get cursor position
    point = editor_webview.mapFromGlobal(qt.QCursor.pos())

    editor_webview.evalWithCallback(f"getLabel({point.x()}, {point.y()});", callback)


gui_hooks.webview_will_set_content.append(on_webview_will_set_content)
gui_hooks.editor_will_show_context_menu.append(on_editor_will_show_context_menu)
  • Screenshot

right-clicked-element

1 Like

Haven’t had time to try this yet but on 2.1.50 if an add-on has an error on startup, anki just shuts down instead of loading without the add-on. Has that been reported and/or fixed yet? (didn’t see it in the change log)

Added to Pressing shift cancels pending bold status · Issue #1795 · ankitects/anki · GitHub

Please rule out add-ons: When problems occur - Frequently Asked Questions

If an error happens as the plugin loads, Anki can catch that and show a message. But if the add-on replaces parts of Anki’s code, which in turn breaks the later part of the startup process, there’s not much that can be done about that.

Anki starting…
Initial setup…
Running with temporary Qt5 compatibility shims.
Run with DISABLE_QT5_COMPAT=1 to confirm compatibility with Qt6.
Traceback (most recent call last):
File “”, line 1, in
File “aqt”, line 45, in
File “aqt.gui_hooks”, line 11, in
File “aqt.hooks_gen”, line 18, in
File “aqt.qt”, line 20, in
File “aqt.qt.qt5_compat”, line 15, in
ModuleNotFoundError: No module named ‘PyQt6.QtCore’
Pressione qualquer tecla para continuar. . .

.

This issue occurs in anki qt5. I don’t know why, but this is causing my anki to not open. Only does open in qt6.

It is happening since anki 2.1.50 beta.

Not sure what would cause that. Tried uninstalling Anki, removing \program files\anki, and then installing the Qt5 version again?

It worked. Sorry :3

Anki 2.1.50 changed all bolding in the editor to use <strong> (rather than <b>) – this means that any template which has styling specifically for <b> no longer works for new cards made by Anki 2.1.50 and later (also if you bold any part of a field, any old <b> tags are switched to <strong>).

I get that <strong> is more HTML-compliant (same with <em> over <i>) but this seems like a regression. This is still an issue with the 2.1.51 beta. Would it be possible to switch back to <b>?

I’ve added switch back to b/i instead of strong/em? · Issue #1807 · ankitects/anki · GitHub

Release candidate 2 is now available:

https://betas.ankiweb.net/anki2.1.51.html#release-candidate-2

1 Like

When will regular users be compelled to upgrade to 2.1.50 or 2.1.51?

If you are asking when users will be notified inside the app that an update is available, probably not for a few months.

got it, that answers my question. I need to be ready to maintain a 2.1.49 branch for some time then.

It seems the Future due is broken:

vs the stable release: