mirror of
https://github.com/ankitects/anki.git
synced 2025-09-23 16:26:40 -04:00
Make sure editor note is saved before triggering buttons (#2995)
This commit is contained in:
parent
db02c95eb5
commit
5f9e07ea7a
1 changed files with 9 additions and 2 deletions
|
@ -4,6 +4,7 @@
|
|||
from __future__ import annotations
|
||||
|
||||
import base64
|
||||
import functools
|
||||
import html
|
||||
import itertools
|
||||
import json
|
||||
|
@ -238,12 +239,18 @@ require("anki/ui").loaded.then(() => require("anki/NoteEditor").instances[0].too
|
|||
) -> str:
|
||||
"""Assign func to bridge cmd, register shortcut, return button"""
|
||||
if func:
|
||||
self._links[cmd] = func
|
||||
|
||||
def wrapped_func(editor: Editor) -> None:
|
||||
self.call_after_note_saved(
|
||||
functools.partial(func, editor), keepFocus=True
|
||||
)
|
||||
|
||||
self._links[cmd] = wrapped_func
|
||||
|
||||
if keys:
|
||||
|
||||
def on_activated() -> None:
|
||||
func(self)
|
||||
wrapped_func(self)
|
||||
|
||||
if toggleable:
|
||||
# generate a random id for triggering toggle
|
||||
|
|
Loading…
Reference in a new issue