mirror of
https://github.com/ankitects/anki.git
synced 2025-09-18 22:12:21 -04:00
Copy sticky fields
This commit is contained in:
parent
7a98aa0644
commit
a3bf145007
1 changed files with 14 additions and 1 deletions
|
@ -37,6 +37,7 @@ License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html
|
||||||
reviewerCardId: bigint | null;
|
reviewerCardId: bigint | null;
|
||||||
initial: boolean;
|
initial: boolean;
|
||||||
copyFromNote: Note | null;
|
copyFromNote: Note | null;
|
||||||
|
stickyFieldsFrom: Note | null;
|
||||||
}
|
}
|
||||||
|
|
||||||
import { registerPackage } from "@tslib/runtime-require";
|
import { registerPackage } from "@tslib/runtime-require";
|
||||||
|
@ -587,7 +588,7 @@ License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html
|
||||||
note.id = noteId;
|
note.id = noteId;
|
||||||
addNoteToHistory(note!);
|
addNoteToHistory(note!);
|
||||||
lastAddedNote = note;
|
lastAddedNote = note;
|
||||||
await loadNote();
|
await loadNote({ stickyFieldsFrom: note });
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function addCurrentNote(deckId: bigint) {
|
export async function addCurrentNote(deckId: bigint) {
|
||||||
|
@ -966,6 +967,7 @@ License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html
|
||||||
reviewerCardId,
|
reviewerCardId,
|
||||||
initial,
|
initial,
|
||||||
copyFromNote,
|
copyFromNote,
|
||||||
|
stickyFieldsFrom,
|
||||||
}: LoadNoteArgs) {
|
}: LoadNoteArgs) {
|
||||||
let homeDeckId = 0n;
|
let homeDeckId = 0n;
|
||||||
if (reviewerCardId) {
|
if (reviewerCardId) {
|
||||||
|
@ -1062,6 +1064,15 @@ License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html
|
||||||
note!.tags = copyFromNote.tags;
|
note!.tags = copyFromNote.tags;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (stickyFieldsFrom) {
|
||||||
|
for (let i = 0; i < notetype.fields.length; i++) {
|
||||||
|
if (notetype.fields[i].config?.sticky && stickyFieldsFrom.fields[i]) {
|
||||||
|
note!.fields[i] = stickyFieldsFrom.fields[i];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
note!.tags = stickyFieldsFrom.tags;
|
||||||
|
}
|
||||||
|
|
||||||
const fieldValues = (
|
const fieldValues = (
|
||||||
await Promise.all(
|
await Promise.all(
|
||||||
note!.fields.map((field) => encodeIriPaths({ val: field })),
|
note!.fields.map((field) => encodeIriPaths({ val: field })),
|
||||||
|
@ -1145,6 +1156,7 @@ License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html
|
||||||
reviewerCardId = reviewerCard ? reviewerCard.id : null,
|
reviewerCardId = reviewerCard ? reviewerCard.id : null,
|
||||||
initial = false,
|
initial = false,
|
||||||
copyFromNote = null,
|
copyFromNote = null,
|
||||||
|
stickyFieldsFrom = null,
|
||||||
}: Partial<LoadNoteArgs> = {}) {
|
}: Partial<LoadNoteArgs> = {}) {
|
||||||
loadDebouncer.schedule(async () => {
|
loadDebouncer.schedule(async () => {
|
||||||
await loadNoteInner({
|
await loadNoteInner({
|
||||||
|
@ -1156,6 +1168,7 @@ License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html
|
||||||
reviewerCardId,
|
reviewerCardId,
|
||||||
initial,
|
initial,
|
||||||
copyFromNote,
|
copyFromNote,
|
||||||
|
stickyFieldsFrom,
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue