mirror of
https://github.com/ankitects/anki.git
synced 2025-09-18 22:12:21 -04:00
Reimplement "Show Duplicates" button in editor (#1550)
* Add "Show duplicates" to LabelContainer
* Avoid bubbling down the duplicate logic into EditorField
* Move duplicate link into its own slot
to center it between name/description and field-state.
* Revert "Move duplicate link into its own slot"
This reverts commit 3a4511042d
.
* Justify dupes within FieldState
to achieve the same result as before while avoiding additional logic within EditorField.
Co-Authored-By: Henrik Giesel <hengiesel@gmail.com>
This commit is contained in:
parent
4966f3cc44
commit
cc5ba4ed84
4 changed files with 33 additions and 2 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,
|
||||||
|
|
25
ts/editor/DuplicateLink.svelte
Normal file
25
ts/editor/DuplicateLink.svelte
Normal file
|
@ -0,0 +1,25 @@
|
||||||
|
<!--
|
||||||
|
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);
|
||||||
|
text-align: center;
|
||||||
|
flex-grow: 1;
|
||||||
|
}
|
||||||
|
</style>
|
|
@ -2,13 +2,15 @@
|
||||||
Copyright: Ankitects Pty Ltd and contributors
|
Copyright: Ankitects Pty Ltd and contributors
|
||||||
License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html
|
License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html
|
||||||
-->
|
-->
|
||||||
<span class="field-state justify-content-between">
|
<span class="field-state justify-content-end">
|
||||||
<slot />
|
<slot />
|
||||||
</span>
|
</span>
|
||||||
|
|
||||||
<style lang="scss">
|
<style lang="scss">
|
||||||
.field-state {
|
.field-state {
|
||||||
display: flex;
|
display: flex;
|
||||||
|
justify-content: flex;
|
||||||
|
flex-grow: 1;
|
||||||
|
|
||||||
& > :global(*) {
|
& > :global(*) {
|
||||||
margin-left: 2px;
|
margin-left: 2px;
|
||||||
|
|
|
@ -50,6 +50,7 @@ License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html
|
||||||
import Notification from "./Notification.svelte";
|
import Notification from "./Notification.svelte";
|
||||||
import Absolute from "../components/Absolute.svelte";
|
import Absolute from "../components/Absolute.svelte";
|
||||||
import Badge from "../components/Badge.svelte";
|
import Badge from "../components/Badge.svelte";
|
||||||
|
import DuplicateLink from "./DuplicateLink.svelte";
|
||||||
|
|
||||||
import DecoratedElements from "./DecoratedElements.svelte";
|
import DecoratedElements from "./DecoratedElements.svelte";
|
||||||
import RichTextInput from "./RichTextInput.svelte";
|
import RichTextInput from "./RichTextInput.svelte";
|
||||||
|
@ -299,6 +300,9 @@ License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html
|
||||||
: "transparent"}
|
: "transparent"}
|
||||||
>
|
>
|
||||||
<svelte:fragment slot="field-state">
|
<svelte:fragment slot="field-state">
|
||||||
|
{#if cols[index] === "dupe"}
|
||||||
|
<DuplicateLink />
|
||||||
|
{/if}
|
||||||
<RichTextBadge bind:off={richTextsHidden[index]} />
|
<RichTextBadge bind:off={richTextsHidden[index]} />
|
||||||
<PlainTextBadge bind:off={plainTextsHidden[index]} />
|
<PlainTextBadge bind:off={plainTextsHidden[index]} />
|
||||||
{#if stickies}
|
{#if stickies}
|
||||||
|
|
Loading…
Reference in a new issue