mirror of
https://github.com/ankitects/anki.git
synced 2025-09-19 14:32:22 -04:00
add whitespace preservation flag; only show active card models when previewing
This commit is contained in:
parent
a5af8fb8e9
commit
ae388595da
2 changed files with 9 additions and 6 deletions
11
anki/deck.py
11
anki/deck.py
|
@ -1533,7 +1533,7 @@ where facts.id not in (select distinct factId from cards)""")
|
|||
def previewFact(self, oldFact):
|
||||
"Duplicate fact and generate cards for preview. Don't add to deck."
|
||||
# check we have card models available
|
||||
cms = self.availableCardModels(oldFact, checkActive=False)
|
||||
cms = self.availableCardModels(oldFact, checkActive=True)
|
||||
if not cms:
|
||||
return []
|
||||
fact = self.cloneFact(oldFact)
|
||||
|
@ -1642,13 +1642,15 @@ facts.id = cards.factId""", id=model.id))
|
|||
def rebuildCSS(self):
|
||||
# css for all fields
|
||||
def _genCSS(prefix, row):
|
||||
(id, fam, siz, col, align, rtl) = row
|
||||
(id, fam, siz, col, align, rtl, pre) = row
|
||||
t = ""
|
||||
if fam: t += 'font-family:"%s";' % toPlatformFont(fam)
|
||||
if siz: t += 'font-size:%dpx;' % siz
|
||||
if col: t += 'color:%s;' % col
|
||||
if rtl == "rtl":
|
||||
t += "direction:rtl;unicode-bidi:embed;"
|
||||
if pre:
|
||||
t += "white-space:pre-wrap;"
|
||||
if align != -1:
|
||||
if align == 0: align = "center"
|
||||
elif align == 1: align = "left"
|
||||
|
@ -1658,9 +1660,10 @@ facts.id = cards.factId""", id=model.id))
|
|||
t = "%s%s {%s}\n" % (prefix, hexifyID(id), t)
|
||||
return t
|
||||
css = "".join([_genCSS(".fm", row) for row in self.s.all("""
|
||||
select id, quizFontFamily, quizFontSize, quizFontColour, -1, features from fieldModels""")])
|
||||
select id, quizFontFamily, quizFontSize, quizFontColour, -1,
|
||||
features, editFontFamily from fieldModels""")])
|
||||
cardRows = self.s.all("""
|
||||
select id, null, null, null, questionAlign, 0 from cardModels""")
|
||||
select id, null, null, null, questionAlign, 0, 0 from cardModels""")
|
||||
css += "".join([_genCSS("#cmq", row) for row in cardRows])
|
||||
css += "".join([_genCSS("#cma", row) for row in cardRows])
|
||||
css += "".join([".cmb%s {background:%s;}\n" %
|
||||
|
|
|
@ -47,9 +47,9 @@ fieldModelsTable = Table(
|
|||
Column('numeric', Boolean, nullable=False, default=False),
|
||||
# display
|
||||
Column('quizFontFamily', UnicodeText),
|
||||
Column('quizFontSize', Integer),
|
||||
Column('quizFontSize', Integer, default=20),
|
||||
Column('quizFontColour', String(7)),
|
||||
Column('editFontFamily', UnicodeText), # unused
|
||||
Column('editFontFamily', Boolean, default=True), # reused as <pre> toggle
|
||||
Column('editFontSize', Integer, default=20))
|
||||
|
||||
class FieldModel(object):
|
||||
|
|
Loading…
Reference in a new issue