aqt.editor#

Classes#

NoteInfo

Used to hold partial note info fetched from the webview

NewEditor

The screen that embeds an editing widget should listen for changes via

NewEditorWebView

Functions#

on_editor_ready(→ collections.abc.Callable)

Module Contents#

aqt.editor.on_editor_ready(func: collections.abc.Callable) collections.abc.Callable#
class aqt.editor.NoteInfo#

Used to hold partial note info fetched from the webview

id: anki.notes.NoteId | None#
mid: anki.models.NotetypeId#
fields: list[str]#
class aqt.editor.NewEditor(mw: aqt.AnkiQt, widget: QWidget, parentWindow: QWidget, addMode: bool | None = None, *, editor_mode: EditorMode = EditorMode.EDIT_CURRENT)#

The screen that embeds an editing widget should listen for changes via the operation_did_execute hook, and call set_note() when the editor needs redrawing.

The editor will cause that hook to be fired when it saves changes. To avoid an unwanted refresh, the parent widget should check if handler corresponds to this editor instance, and ignore the change if it does.

mw#
widget#
parentWindow#
nid: anki.notes.NoteId | None = None#
note: anki.notes.Note | None = None#
addMode#
editorMode#
currentField: int | None = None#
last_field_index: int | None = None#
card: anki.cards.Card | None = None#
state: EditorState#
setupOuter() None#
add_webview() None#
setupWeb() None#
resourceToData(path: str) str#

Convert a file (specified by a path) into a data URI.

addButton(icon: str | None, cmd: str, func: collections.abc.Callable[[NewEditor], None], tip: str = '', label: str = '', id: str | None = None, toggleable: bool = False, keys: str | None = None, disables: bool = True, rightside: bool = True) str#

Assign func to bridge cmd, register shortcut, return button

setupShortcuts() None#
setupColourPalette() None#
onFields() None#
onCardLayout() None#
onBridgeCmd(cmd: str) Any#
signal_state_change(new_state: EditorState, old_state: EditorState) None#
set_nid(nid: anki.notes.NoteId | None, mid: int, focus_to: int | None = None) None#

Make note with ID nid the current note.

set_note(note: anki.notes.Note | None, hide: bool = True, focusTo: int | None = None) None#

Make NOTE the current note.

load_note(mid: int | None = None, deck_id: anki.decks.DeckId | None = None, original_note_id: anki.notes.NoteId | None = None, focus_to: int | None = None) None#
reload_note() None#
reload_note_if_empty(deck_id: anki.decks.DeckId | None = None, notetype_id: anki.models.NotetypeId | None = None) None#
call_after_note_saved(callback: collections.abc.Callable, keepFocus: bool = False) None#

Save unsaved edits then call callback().

saveNow#
on_note_saved() None#
cleanup() None#
setNote#
onPaste() None#
onCut() None#
onCopy() None#
isURL(s: str) bool#
inlinedImageToFilename(txt: str) str#
setup_mask_editor(image_path: str) None#
setup_mask_editor_for_new_note(image_path: str)#

Set-up IO mask editor for adding new notes Presupposes that active editor notetype is an image occlusion notetype Args:

image_path: Absolute path to image.

setup_mask_editor_for_existing_note(image_path: str | None = None)#

Set-up IO mask editor for editing existing notes Presupposes that active editor notetype is an image occlusion notetype Args:

image_path: (Optional) Absolute path to image that should replace current

image

get_note_info(on_done: collections.abc.Callable[[NoteInfo], None]) None#
class aqt.editor.NewEditorWebView(parent: QWidget, editor: NewEditor)#

Bases: aqt.webview.AnkiWebView

editor#
onCut() None#
onCopy() None#
onPaste() None#