Revert "Use new note.ephemeral_card method in clayout"
This partially reverts commit 2483ef4517
.
This commit is contained in:
parent
586ea07869
commit
6e9dfefb24
@ -1,16 +1,18 @@
|
||||
# Copyright: Ankitects Pty Ltd and contributors
|
||||
# License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html
|
||||
|
||||
import copy
|
||||
import json
|
||||
import re
|
||||
from concurrent.futures import Future
|
||||
from typing import Any, Dict, List, Match, Optional
|
||||
|
||||
import aqt
|
||||
from anki.cards import Card
|
||||
from anki.consts import *
|
||||
from anki.errors import TemplateError
|
||||
from anki.lang import without_unicode_isolation
|
||||
from anki.notes import Note
|
||||
from anki.template import TemplateRenderContext
|
||||
from aqt import AnkiQt, gui_hooks
|
||||
from aqt.forms.browserdisp import Ui_Dialog
|
||||
from aqt.qt import *
|
||||
@ -472,9 +474,8 @@ class CardLayout(QDialog):
|
||||
def _renderPreview(self) -> None:
|
||||
self.cancelPreviewTimer()
|
||||
|
||||
c = self.rendered_card = self.note.ephemeral_card(
|
||||
self.ord, fill_empty=self.fill_empty_action_toggled
|
||||
)
|
||||
c = self.rendered_card = self.ephemeral_card_for_rendering()
|
||||
|
||||
ti = self.maybeTextInput
|
||||
|
||||
bodyclass = theme_manager.body_classes_for_card_ord(
|
||||
@ -534,6 +535,24 @@ 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