mirror of
https://github.com/ankitects/anki.git
synced 2025-09-24 08:46:37 -04:00
Merge pull request #1 from hgiesel/editor-show-dupes
Avoid bubbling down the duplicate logic into EditorField
This commit is contained in:
commit
027c8595a7
3 changed files with 31 additions and 17 deletions
23
ts/editor/DuplicateLink.svelte
Normal file
23
ts/editor/DuplicateLink.svelte
Normal file
|
@ -0,0 +1,23 @@
|
|||
<!--
|
||||
Copyright: Ankitects Pty Ltd and contributors
|
||||
License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html
|
||||
-->
|
||||
<script lang="ts">
|
||||
import * as tr from "../lib/ftl";
|
||||
import { bridgeCommand } from "../lib/bridgecommand";
|
||||
</script>
|
||||
|
||||
<a
|
||||
class="duplicate-link"
|
||||
href="/#"
|
||||
tabindex="-1"
|
||||
on:click={() => bridgeCommand("dupes")}
|
||||
>
|
||||
{tr.editingShowDuplicates()}
|
||||
</a>
|
||||
|
||||
<style lang="scss">
|
||||
.duplicate-link {
|
||||
color: var(--highlight-color);
|
||||
}
|
||||
</style>
|
|
@ -28,7 +28,6 @@ License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html
|
|||
</script>
|
||||
|
||||
<script lang="ts">
|
||||
import * as tr from "../lib/ftl";
|
||||
import EditingArea from "./EditingArea.svelte";
|
||||
import LabelContainer from "./LabelContainer.svelte";
|
||||
import LabelDescription from "./LabelDescription.svelte";
|
||||
|
@ -45,7 +44,6 @@ License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html
|
|||
export let content: Writable<string>;
|
||||
export let field: FieldData;
|
||||
export let autofocus = false;
|
||||
export let dupes = false;
|
||||
|
||||
export let api: (Partial<EditorFieldAPI> & Destroyable) | undefined = undefined;
|
||||
|
||||
|
@ -77,7 +75,7 @@ License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html
|
|||
on:focusout
|
||||
on:click={() => editingArea.focus?.()}
|
||||
>
|
||||
<LabelContainer --label-color={dupes ? "var(--flag1-bg)" : "transparent"}>
|
||||
<LabelContainer>
|
||||
<span>
|
||||
<LabelName>
|
||||
{field.name}
|
||||
|
@ -86,11 +84,6 @@ License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html
|
|||
<LabelDescription description={field.description} />
|
||||
{/if}
|
||||
</span>
|
||||
{#if dupes}
|
||||
<span class="dupes" on:click={() => globalThis.pycmd("dupes")}
|
||||
>{tr.editingShowDuplicates()}
|
||||
</span>
|
||||
{/if}
|
||||
<FieldState><slot name="field-state" /></FieldState>
|
||||
</LabelContainer>
|
||||
<EditingArea
|
||||
|
@ -120,12 +113,4 @@ License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html
|
|||
box-shadow: 0 0 0 3px var(--focus-shadow);
|
||||
}
|
||||
}
|
||||
|
||||
.dupes {
|
||||
cursor: pointer;
|
||||
color: var(--highlight-fg);
|
||||
&:hover {
|
||||
text-decoration: underline;
|
||||
}
|
||||
}
|
||||
</style>
|
||||
|
|
|
@ -50,6 +50,7 @@ License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html
|
|||
import Notification from "./Notification.svelte";
|
||||
import Absolute from "../components/Absolute.svelte";
|
||||
import Badge from "../components/Badge.svelte";
|
||||
import DuplicateLink from "./DuplicateLink.svelte";
|
||||
|
||||
import DecoratedElements from "./DecoratedElements.svelte";
|
||||
import RichTextInput from "./RichTextInput.svelte";
|
||||
|
@ -283,7 +284,6 @@ License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html
|
|||
{field}
|
||||
content={fieldStores[index]}
|
||||
autofocus={index === focusTo}
|
||||
dupes={cols[index] === "dupe"}
|
||||
api={fields[index]}
|
||||
on:focusin={() => {
|
||||
$currentField = fields[index];
|
||||
|
@ -295,8 +295,14 @@ License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html
|
|||
`blur:${index}:${getNoteId()}:${get(fieldStores[index])}`,
|
||||
);
|
||||
}}
|
||||
--label-color={cols[index] === "dupe"
|
||||
? "var(--flag1-bg)"
|
||||
: "transparent"}
|
||||
>
|
||||
<svelte:fragment slot="field-state">
|
||||
{#if cols[index] === "dupe"}
|
||||
<DuplicateLink />
|
||||
{/if}
|
||||
<RichTextBadge bind:off={richTextsHidden[index]} />
|
||||
<PlainTextBadge bind:off={plainTextsHidden[index]} />
|
||||
{#if stickies}
|
||||
|
|
Loading…
Reference in a new issue