mirror of
https://github.com/ankitects/anki.git
synced 2025-09-24 16:56:36 -04:00
Merge branch 'fresh-fields' of https://github.com/kleinerpirat/anki into fresh-fields
This commit is contained in:
commit
441956922b
7 changed files with 24 additions and 20 deletions
|
@ -6,9 +6,9 @@ Very brief notes for now.
|
||||||
|
|
||||||
At the highest level, Anki is logically separated into two parts.
|
At the highest level, Anki is logically separated into two parts.
|
||||||
|
|
||||||
A neat visualization
|
A neat visualization of the file layout is available here:
|
||||||
of the file layout is available here:
|
<https://mango-dune-07a8b7110.1.azurestaticapps.net/?repo=ankitects%2Fanki>
|
||||||
<https://octo-repo-visualization.vercel.app/?repo=ankitects%2Fanki>
|
(or go to <https://githubnext.com/projects/repo-visualization#explore-for-yourself> and enter `ankitects/anki`).
|
||||||
|
|
||||||
### Library (rslib & pylib)
|
### Library (rslib & pylib)
|
||||||
|
|
||||||
|
|
|
@ -313,7 +313,7 @@ class AnkiExporter(Exporter):
|
||||||
# such as update the deck description
|
# such as update the deck description
|
||||||
pass
|
pass
|
||||||
|
|
||||||
def removeSystemTags(self, tags: str) -> Any:
|
def removeSystemTags(self, tags: str) -> str:
|
||||||
return self.src.tags.rem_from_str("marked leech", tags)
|
return self.src.tags.rem_from_str("marked leech", tags)
|
||||||
|
|
||||||
def _modelHasMedia(self, model, fname) -> bool:
|
def _modelHasMedia(self, model, fname) -> bool:
|
||||||
|
@ -464,7 +464,7 @@ class AnkiCollectionPackage21bExporter(AnkiCollectionPackageExporter):
|
||||||
|
|
||||||
|
|
||||||
def exporters(col: Collection) -> list[tuple[str, Any]]:
|
def exporters(col: Collection) -> list[tuple[str, Any]]:
|
||||||
def id(obj):
|
def id(obj) -> tuple[str, Exporter]:
|
||||||
if callable(obj.key):
|
if callable(obj.key):
|
||||||
key_str = obj.key(col)
|
key_str = obj.key(col)
|
||||||
else:
|
else:
|
||||||
|
|
|
@ -7,7 +7,6 @@ import html
|
||||||
import os
|
import os
|
||||||
import re
|
import re
|
||||||
from dataclasses import dataclass
|
from dataclasses import dataclass
|
||||||
from typing import Any
|
|
||||||
|
|
||||||
import anki
|
import anki
|
||||||
import anki.collection
|
import anki.collection
|
||||||
|
@ -168,7 +167,7 @@ def _save_latex_image(
|
||||||
log.close()
|
log.close()
|
||||||
|
|
||||||
|
|
||||||
def _err_msg(col: anki.collection.Collection, type: str, texpath: str) -> Any:
|
def _err_msg(col: anki.collection.Collection, type: str, texpath: str) -> str:
|
||||||
msg = f"{col.tr.media_error_executing(val=type)}<br>"
|
msg = f"{col.tr.media_error_executing(val=type)}<br>"
|
||||||
msg += f"{col.tr.media_generated_file(val=texpath)}<br>"
|
msg += f"{col.tr.media_generated_file(val=texpath)}<br>"
|
||||||
try:
|
try:
|
||||||
|
|
|
@ -8,7 +8,7 @@ import pprint
|
||||||
import re
|
import re
|
||||||
import sys
|
import sys
|
||||||
import time
|
import time
|
||||||
from typing import Any, Callable
|
from typing import Callable
|
||||||
|
|
||||||
from anki import media_pb2
|
from anki import media_pb2
|
||||||
from anki._legacy import DeprecatedNamesMixin, deprecated_keywords
|
from anki._legacy import DeprecatedNamesMixin, deprecated_keywords
|
||||||
|
@ -142,7 +142,7 @@ class MediaManager(DeprecatedNamesMixin):
|
||||||
files.append(fname)
|
files.append(fname)
|
||||||
return files
|
return files
|
||||||
|
|
||||||
def transform_names(self, txt: str, func: Callable) -> Any:
|
def transform_names(self, txt: str, func: Callable) -> str:
|
||||||
for reg in self.regexps:
|
for reg in self.regexps:
|
||||||
txt = re.sub(reg, func, txt)
|
txt = re.sub(reg, func, txt)
|
||||||
return txt
|
return txt
|
||||||
|
|
|
@ -4,7 +4,7 @@
|
||||||
from __future__ import annotations
|
from __future__ import annotations
|
||||||
|
|
||||||
import copy
|
import copy
|
||||||
from typing import Any, NewType, Sequence
|
from typing import NewType, Sequence
|
||||||
|
|
||||||
import anki # pylint: disable=unused-import
|
import anki # pylint: disable=unused-import
|
||||||
import anki.cards
|
import anki.cards
|
||||||
|
@ -182,7 +182,7 @@ class Note(DeprecatedNamesMixin):
|
||||||
"Add tag. Duplicates will be stripped on save."
|
"Add tag. Duplicates will be stripped on save."
|
||||||
self.tags.append(tag)
|
self.tags.append(tag)
|
||||||
|
|
||||||
def string_tags(self) -> Any:
|
def string_tags(self) -> str:
|
||||||
return self.col.tags.join(self.tags)
|
return self.col.tags.join(self.tags)
|
||||||
|
|
||||||
def set_tags_from_str(self, tags: str) -> None:
|
def set_tags_from_str(self, tags: str) -> None:
|
||||||
|
|
|
@ -161,14 +161,8 @@ impl Collection {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn flag_name(n: u8) -> &'static str {
|
fn flag_name(n: u8) -> String {
|
||||||
match n {
|
format!("flag{n}")
|
||||||
1 => "flag1",
|
|
||||||
2 => "flag2",
|
|
||||||
3 => "flag3",
|
|
||||||
4 => "flag4",
|
|
||||||
_ => "",
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fn fill_empty_fields(note: &mut Note, qfmt: &str, nt: &Notetype, tr: &I18n) {
|
fn fill_empty_fields(note: &mut Note, qfmt: &str, nt: &Notetype, tr: &I18n) {
|
||||||
|
|
|
@ -13,10 +13,21 @@ License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html
|
||||||
export let columnOptions: ColumnOption[];
|
export let columnOptions: ColumnOption[];
|
||||||
export let tagsColumn: number;
|
export let tagsColumn: number;
|
||||||
export let globalNotetype: ImportExport.CsvMetadata.MappedNotetype | null;
|
export let globalNotetype: ImportExport.CsvMetadata.MappedNotetype | null;
|
||||||
|
|
||||||
|
let lastNotetypeId: number | undefined = -1;
|
||||||
|
let fieldNamesPromise: Promise<string[]>;
|
||||||
|
|
||||||
|
$: if (globalNotetype?.id !== lastNotetypeId) {
|
||||||
|
lastNotetypeId = globalNotetype?.id;
|
||||||
|
fieldNamesPromise =
|
||||||
|
globalNotetype === null
|
||||||
|
? Promise.resolve([])
|
||||||
|
: getNotetypeFields(globalNotetype.id);
|
||||||
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
{#if globalNotetype}
|
{#if globalNotetype}
|
||||||
{#await getNotetypeFields(globalNotetype.id) then fieldNames}
|
{#await fieldNamesPromise then fieldNames}
|
||||||
{#each fieldNames as label, idx}
|
{#each fieldNames as label, idx}
|
||||||
<!-- first index is treated specially, because it must be assigned some column -->
|
<!-- first index is treated specially, because it must be assigned some column -->
|
||||||
<MapperRow
|
<MapperRow
|
||||||
|
|
Loading…
Reference in a new issue