mirror of
https://github.com/ankitects/anki.git
synced 2025-09-24 00:36:38 -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
|
from __future__ import annotations
|
||||||
|
|
||||||
import base64
|
import base64
|
||||||
|
import functools
|
||||||
import html
|
import html
|
||||||
import itertools
|
import itertools
|
||||||
import json
|
import json
|
||||||
|
@ -238,12 +239,18 @@ require("anki/ui").loaded.then(() => require("anki/NoteEditor").instances[0].too
|
||||||
) -> str:
|
) -> str:
|
||||||
"""Assign func to bridge cmd, register shortcut, return button"""
|
"""Assign func to bridge cmd, register shortcut, return button"""
|
||||||
if func:
|
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:
|
if keys:
|
||||||
|
|
||||||
def on_activated() -> None:
|
def on_activated() -> None:
|
||||||
func(self)
|
wrapped_func(self)
|
||||||
|
|
||||||
if toggleable:
|
if toggleable:
|
||||||
# generate a random id for triggering toggle
|
# generate a random id for triggering toggle
|
||||||
|
|
Loading…
Reference in a new issue