mirror of
https://github.com/ankitects/anki.git
synced 2025-09-18 22:12:21 -04:00
Revert "Use new note.ephemeral_card method in clayout"
This partially reverts commit 2483ef4517
.
This commit is contained in:
parent
586ea07869
commit
6e9dfefb24
1 changed files with 23 additions and 4 deletions
|
@ -1,16 +1,18 @@
|
||||||
# Copyright: Ankitects Pty Ltd and contributors
|
# Copyright: Ankitects Pty Ltd and contributors
|
||||||
# License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html
|
# License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html
|
||||||
|
import copy
|
||||||
import json
|
import json
|
||||||
import re
|
import re
|
||||||
from concurrent.futures import Future
|
from concurrent.futures import Future
|
||||||
from typing import Any, Dict, List, Match, Optional
|
from typing import Any, Dict, List, Match, Optional
|
||||||
|
|
||||||
import aqt
|
import aqt
|
||||||
|
from anki.cards import Card
|
||||||
from anki.consts import *
|
from anki.consts import *
|
||||||
from anki.errors import TemplateError
|
from anki.errors import TemplateError
|
||||||
from anki.lang import without_unicode_isolation
|
from anki.lang import without_unicode_isolation
|
||||||
from anki.notes import Note
|
from anki.notes import Note
|
||||||
|
from anki.template import TemplateRenderContext
|
||||||
from aqt import AnkiQt, gui_hooks
|
from aqt import AnkiQt, gui_hooks
|
||||||
from aqt.forms.browserdisp import Ui_Dialog
|
from aqt.forms.browserdisp import Ui_Dialog
|
||||||
from aqt.qt import *
|
from aqt.qt import *
|
||||||
|
@ -472,9 +474,8 @@ class CardLayout(QDialog):
|
||||||
def _renderPreview(self) -> None:
|
def _renderPreview(self) -> None:
|
||||||
self.cancelPreviewTimer()
|
self.cancelPreviewTimer()
|
||||||
|
|
||||||
c = self.rendered_card = self.note.ephemeral_card(
|
c = self.rendered_card = self.ephemeral_card_for_rendering()
|
||||||
self.ord, fill_empty=self.fill_empty_action_toggled
|
|
||||||
)
|
|
||||||
ti = self.maybeTextInput
|
ti = self.maybeTextInput
|
||||||
|
|
||||||
bodyclass = theme_manager.body_classes_for_card_ord(
|
bodyclass = theme_manager.body_classes_for_card_ord(
|
||||||
|
@ -534,6 +535,24 @@ class CardLayout(QDialog):
|
||||||
repl = answerRepl
|
repl = answerRepl
|
||||||
return re.sub(r"\[\[type:.+?\]\]", repl, txt)
|
return re.sub(r"\[\[type:.+?\]\]", repl, txt)
|
||||||
|
|
||||||
|
def ephemeral_card_for_rendering(self) -> Card:
|
||||||
|
card = Card(self.col)
|
||||||
|
card.ord = self.ord
|
||||||
|
card.did = 1
|
||||||
|
template = copy.copy(self.current_template())
|
||||||
|
# may differ in cloze case
|
||||||
|
template["ord"] = card.ord
|
||||||
|
output = TemplateRenderContext.from_card_layout(
|
||||||
|
self.note,
|
||||||
|
card,
|
||||||
|
notetype=self.model,
|
||||||
|
template=template,
|
||||||
|
fill_empty=self.fill_empty_action_toggled,
|
||||||
|
).render()
|
||||||
|
card.set_render_output(output)
|
||||||
|
card._note = self.note
|
||||||
|
return card
|
||||||
|
|
||||||
# Card operations
|
# Card operations
|
||||||
######################################################################
|
######################################################################
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue