aqt.editor
==========

.. py:module:: aqt.editor


Classes
-------

.. autoapisummary::

   aqt.editor.NoteInfo
   aqt.editor.NewEditor
   aqt.editor.NewEditorWebView


Functions
---------

.. autoapisummary::

   aqt.editor.on_editor_ready


Module Contents
---------------

.. py:function:: on_editor_ready(func: collections.abc.Callable) -> collections.abc.Callable

.. py:class:: NoteInfo

   Used to hold partial note info fetched from the webview


   .. py:attribute:: id
      :type:  anki.notes.NoteId | None


   .. py:attribute:: mid
      :type:  anki.models.NotetypeId


   .. py:attribute:: fields
      :type:  list[str]


.. py:class:: 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.


   .. py:attribute:: mw


   .. py:attribute:: widget


   .. py:attribute:: parentWindow


   .. py:attribute:: nid
      :type:  anki.notes.NoteId | None
      :value: None



   .. py:attribute:: note
      :type:  anki.notes.Note | None
      :value: None



   .. py:attribute:: addMode


   .. py:attribute:: editorMode


   .. py:attribute:: currentField
      :type:  int | None
      :value: None



   .. py:attribute:: last_field_index
      :type:  int | None
      :value: None



   .. py:attribute:: card
      :type:  anki.cards.Card | None
      :value: None



   .. py:attribute:: state
      :type:  EditorState


   .. py:method:: setupOuter() -> None


   .. py:method:: add_webview() -> None


   .. py:method:: setupWeb() -> None


   .. py:method:: resourceToData(path: str) -> str

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



   .. py:method:: 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



   .. py:method:: setupShortcuts() -> None


   .. py:method:: setupColourPalette() -> None


   .. py:method:: onFields() -> None


   .. py:method:: onCardLayout() -> None


   .. py:method:: onBridgeCmd(cmd: str) -> Any


   .. py:method:: signal_state_change(new_state: EditorState, old_state: EditorState) -> None


   .. py:method:: set_nid(nid: anki.notes.NoteId | None, mid: int, focus_to: int | None = None) -> None

      Make note with ID `nid` the current note.



   .. py:method:: set_note(note: anki.notes.Note | None, hide: bool = True, focusTo: int | None = None) -> None

      Make NOTE the current note.



   .. py:method:: 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


   .. py:method:: reload_note() -> None


   .. py:method:: reload_note_if_empty(deck_id: anki.decks.DeckId | None = None, notetype_id: anki.models.NotetypeId | None = None) -> None


   .. py:method:: call_after_note_saved(callback: collections.abc.Callable, keepFocus: bool = False) -> None

      Save unsaved edits then call callback().



   .. py:attribute:: saveNow


   .. py:method:: on_note_saved() -> None


   .. py:method:: cleanup() -> None


   .. py:attribute:: setNote


   .. py:method:: onPaste() -> None


   .. py:method:: onCut() -> None


   .. py:method:: onCopy() -> None


   .. py:method:: isURL(s: str) -> bool


   .. py:method:: inlinedImageToFilename(txt: str) -> str


   .. py:method:: setup_mask_editor(image_path: str) -> None


   .. py:method:: 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.



   .. py:method:: 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



   .. py:method:: get_note_info(on_done: collections.abc.Callable[[NoteInfo], None]) -> None


.. py:class:: NewEditorWebView(parent: QWidget, editor: NewEditor)

   Bases: :py:obj:`aqt.webview.AnkiWebView`


   .. py:attribute:: editor


   .. py:method:: onCut() -> None


   .. py:method:: onCopy() -> None


   .. py:method:: onPaste() -> None


