mirror of
https://github.com/ankitects/anki.git
synced 2025-09-24 16:56:36 -04:00
Move showDupes()
This commit is contained in:
parent
0966cd4552
commit
8391761bc2
3 changed files with 30 additions and 25 deletions
|
@ -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,
|
||||
|
|
|
@ -3,12 +3,29 @@ Copyright: Ankitects Pty Ltd and contributors
|
|||
License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html
|
||||
-->
|
||||
<script lang="ts">
|
||||
import { searchInBrowser } from "@generated/backend";
|
||||
import * as tr from "@generated/ftl";
|
||||
import { bridgeCommand } from "@tslib/bridgecommand";
|
||||
import type { Note } from "@generated/anki/notes_pb";
|
||||
|
||||
export let note: Note | null = null;
|
||||
|
||||
function showDupes() {
|
||||
if (note) {
|
||||
searchInBrowser({
|
||||
filter: {
|
||||
case: "dupe",
|
||||
value: {
|
||||
notetypeId: note.notetypeId,
|
||||
firstField: note.fields[0],
|
||||
},
|
||||
},
|
||||
});
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<span class="duplicate-link-container">
|
||||
<a class="duplicate-link" href="/#" on:click={() => bridgeCommand("dupes")}>
|
||||
<a class="duplicate-link" href="/#" on:click={showDupes}>
|
||||
{tr.editingShowDuplicates()}
|
||||
</a>
|
||||
</span>
|
||||
|
|
|
@ -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.
|
|||
</svelte:fragment>
|
||||
<FieldState>
|
||||
{#if cols[index] === "dupe"}
|
||||
<DuplicateLink />
|
||||
<DuplicateLink {note} />
|
||||
{/if}
|
||||
{#if mode === "add"}
|
||||
<StickyBadge
|
||||
|
|
Loading…
Reference in a new issue