mirror of
https://github.com/ankitects/anki.git
synced 2025-09-25 09:16:38 -04:00
Add "Show duplicates" to LabelContainer
This commit is contained in:
parent
afff4fc437
commit
fffeedc59c
3 changed files with 18 additions and 5 deletions
|
@ -127,7 +127,7 @@ class Editor:
|
||||||
|
|
||||||
# then load page
|
# then load page
|
||||||
self.web.stdHtml(
|
self.web.stdHtml(
|
||||||
"", # % tr.editing_show_duplicates(),
|
"",
|
||||||
css=["css/editor.css"],
|
css=["css/editor.css"],
|
||||||
js=["js/editor.js"],
|
js=["js/editor.js"],
|
||||||
context=self,
|
context=self,
|
||||||
|
|
|
@ -28,6 +28,7 @@ License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
|
import * as tr from "../lib/ftl";
|
||||||
import EditingArea from "./EditingArea.svelte";
|
import EditingArea from "./EditingArea.svelte";
|
||||||
import LabelContainer from "./LabelContainer.svelte";
|
import LabelContainer from "./LabelContainer.svelte";
|
||||||
import LabelDescription from "./LabelDescription.svelte";
|
import LabelDescription from "./LabelDescription.svelte";
|
||||||
|
@ -44,6 +45,7 @@ License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html
|
||||||
export let content: Writable<string>;
|
export let content: Writable<string>;
|
||||||
export let field: FieldData;
|
export let field: FieldData;
|
||||||
export let autofocus = false;
|
export let autofocus = false;
|
||||||
|
export let dupes = false;
|
||||||
|
|
||||||
export let api: (Partial<EditorFieldAPI> & Destroyable) | undefined = undefined;
|
export let api: (Partial<EditorFieldAPI> & Destroyable) | undefined = undefined;
|
||||||
|
|
||||||
|
@ -75,7 +77,7 @@ License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html
|
||||||
on:focusout
|
on:focusout
|
||||||
on:click={() => editingArea.focus?.()}
|
on:click={() => editingArea.focus?.()}
|
||||||
>
|
>
|
||||||
<LabelContainer>
|
<LabelContainer --label-color={dupes ? "var(--flag1-bg)" : "transparent"}>
|
||||||
<span>
|
<span>
|
||||||
<LabelName>
|
<LabelName>
|
||||||
{field.name}
|
{field.name}
|
||||||
|
@ -84,6 +86,11 @@ License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html
|
||||||
<LabelDescription description={field.description} />
|
<LabelDescription description={field.description} />
|
||||||
{/if}
|
{/if}
|
||||||
</span>
|
</span>
|
||||||
|
{#if dupes}
|
||||||
|
<span class="dupes" on:click={() => globalThis.pycmd("dupes")}
|
||||||
|
>{tr.editingShowDuplicates()}
|
||||||
|
</span>
|
||||||
|
{/if}
|
||||||
<FieldState><slot name="field-state" /></FieldState>
|
<FieldState><slot name="field-state" /></FieldState>
|
||||||
</LabelContainer>
|
</LabelContainer>
|
||||||
<EditingArea
|
<EditingArea
|
||||||
|
@ -113,4 +120,12 @@ License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html
|
||||||
box-shadow: 0 0 0 3px var(--focus-shadow);
|
box-shadow: 0 0 0 3px var(--focus-shadow);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.dupes {
|
||||||
|
cursor: pointer;
|
||||||
|
color: var(--highlight-fg);
|
||||||
|
&:hover {
|
||||||
|
text-decoration: underline;
|
||||||
|
}
|
||||||
|
}
|
||||||
</style>
|
</style>
|
||||||
|
|
|
@ -283,6 +283,7 @@ License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html
|
||||||
{field}
|
{field}
|
||||||
content={fieldStores[index]}
|
content={fieldStores[index]}
|
||||||
autofocus={index === focusTo}
|
autofocus={index === focusTo}
|
||||||
|
dupes={cols[index] === "dupe"}
|
||||||
api={fields[index]}
|
api={fields[index]}
|
||||||
on:focusin={() => {
|
on:focusin={() => {
|
||||||
$currentField = fields[index];
|
$currentField = fields[index];
|
||||||
|
@ -294,9 +295,6 @@ License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html
|
||||||
`blur:${index}:${getNoteId()}:${get(fieldStores[index])}`,
|
`blur:${index}:${getNoteId()}:${get(fieldStores[index])}`,
|
||||||
);
|
);
|
||||||
}}
|
}}
|
||||||
--label-color={cols[index] === "dupe"
|
|
||||||
? "var(--flag1-bg)"
|
|
||||||
: "transparent"}
|
|
||||||
>
|
>
|
||||||
<svelte:fragment slot="field-state">
|
<svelte:fragment slot="field-state">
|
||||||
<RichTextBadge bind:off={richTextsHidden[index]} />
|
<RichTextBadge bind:off={richTextsHidden[index]} />
|
||||||
|
|
Loading…
Reference in a new issue