From 8391761bc227f9e0b4b52b0cd5460216ce3b9115 Mon Sep 17 00:00:00 2001 From: Abdo Date: Mon, 2 Jun 2025 03:41:58 +0300 Subject: [PATCH] Move showDupes() --- qt/aqt/editor.py | 18 +----------------- ts/routes/editor/DuplicateLink.svelte | 21 +++++++++++++++++++-- ts/routes/editor/NoteEditor.svelte | 16 ++++++++++------ 3 files changed, 30 insertions(+), 25 deletions(-) diff --git a/qt/aqt/editor.py b/qt/aqt/editor.py index 8653ec384..a0c931970 100644 --- a/qt/aqt/editor.py +++ b/qt/aqt/editor.py @@ -30,7 +30,7 @@ import aqt.operations import aqt.sound from anki._legacy import deprecated from anki.cards import Card -from anki.collection import Config, SearchNode +from anki.collection import Config from anki.consts import MODEL_CLOZE from anki.hooks import runFilter from anki.httpclient import HttpClient @@ -588,21 +588,6 @@ require("anki/ui").loaded.then(() => require("anki/NoteEditor").instances[0].too "}); " ) - def showDupes(self) -> None: - assert self.note is not None - aqt.dialogs.open( - "Browser", - self.mw, - search=( - SearchNode( - dupe=SearchNode.Dupe( - notetype_id=self.note_type()["id"], - first_field=self.note.fields[0], - ) - ), - ), - ) - def fieldsAreBlank(self, previousNote: Note | None = None) -> bool: if not self.note: return True @@ -1268,7 +1253,6 @@ require("anki/ui").loaded.then(() => require("anki/NoteEditor").instances[0].too attach=Editor.onAddMedia, record=Editor.onRecSound, more=Editor.onAdvanced, - dupes=Editor.showDupes, paste=Editor.onPaste, cutOrCopy=Editor.onCutOrCopy, htmlEdit=Editor.onHtmlEdit, diff --git a/ts/routes/editor/DuplicateLink.svelte b/ts/routes/editor/DuplicateLink.svelte index 3a83cb2f1..d58083af3 100644 --- a/ts/routes/editor/DuplicateLink.svelte +++ b/ts/routes/editor/DuplicateLink.svelte @@ -3,12 +3,29 @@ Copyright: Ankitects Pty Ltd and contributors License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html --> - bridgeCommand("dupes")}> + {tr.editingShowDuplicates()} diff --git a/ts/routes/editor/NoteEditor.svelte b/ts/routes/editor/NoteEditor.svelte index e287dadf7..ec83fe969 100644 --- a/ts/routes/editor/NoteEditor.svelte +++ b/ts/routes/editor/NoteEditor.svelte @@ -585,7 +585,12 @@ License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html }); } - async function loadNote(nid: bigint, notetypeId: bigint, focusTo: number, originalNoteId: bigint | null) { + async function loadNote( + nid: bigint, + notetypeId: bigint, + focusTo: number, + originalNoteId: bigint | null, + ) { const notetype = await getNotetype({ ntid: notetypeId, }); @@ -647,10 +652,10 @@ License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html if (mode === "add") { setSticky(notetype.fields.map((field) => field.config?.sticky ?? false)); } - if(isImageOcclusion) { + if (isImageOcclusion) { const imageField = note!.fields[ioFields.image]; // TODO: last_io_image_path - if(mode !== "add") { + if (mode !== "add") { setupMaskEditor({ html: imageField, mode: { @@ -658,8 +663,7 @@ License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html noteId: nid, }, }); - } - else if(originalNoteId) { + } else if (originalNoteId) { setupMaskEditor({ html: imageField, mode: { @@ -863,7 +867,7 @@ components and functionality for general note editing. {#if cols[index] === "dupe"} - + {/if} {#if mode === "add"}