Use new note.ephemeral_card method in clayout
This commit is contained in:
parent
4d119cada2
commit
2483ef4517
@ -12,6 +12,7 @@ import anki._backend.backend_pb2 as _pb
|
||||
from anki import hooks
|
||||
from anki.models import NoteType
|
||||
from anki.utils import joinFields
|
||||
from anki.consts import MODEL_STD
|
||||
|
||||
|
||||
class Note:
|
||||
@ -82,7 +83,11 @@ class Note:
|
||||
card.did = 1
|
||||
|
||||
model = self.model()
|
||||
template = copy.copy(model["tmpls"][ord])
|
||||
template = copy.copy(
|
||||
model["tmpls"][ord]
|
||||
if model["type"] == MODEL_STD
|
||||
else model["tmpls"][0]
|
||||
)
|
||||
# may differ in cloze case
|
||||
template["ord"] = card.ord
|
||||
|
||||
|
@ -475,8 +475,9 @@ class CardLayout(QDialog):
|
||||
def _renderPreview(self) -> None:
|
||||
self.cancelPreviewTimer()
|
||||
|
||||
c = self.rendered_card = self.ephemeral_card_for_rendering()
|
||||
|
||||
c = self.rendered_card = self.note.ephemeral_card(
|
||||
self.ord, fill_empty=self.fill_empty_action_toggled
|
||||
)
|
||||
ti = self.maybeTextInput
|
||||
|
||||
bodyclass = theme_manager.body_classes_for_card_ord(
|
||||
@ -536,24 +537,6 @@ class CardLayout(QDialog):
|
||||
repl = answerRepl
|
||||
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
|
||||
######################################################################
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user