mirror of
https://github.com/ankitects/anki.git
synced 2025-09-18 14:02:21 -04:00
save custom colour palette on colour picker open and input
there doesn't seem to be an event fired when the picker is cancelled/closed, so it's still possible for work to be lost
This commit is contained in:
parent
ed7228af30
commit
7bde95f221
3 changed files with 14 additions and 1 deletions
|
@ -4,6 +4,7 @@ License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html
|
||||||
-->
|
-->
|
||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
import Shortcut from "$lib/components/Shortcut.svelte";
|
import Shortcut from "$lib/components/Shortcut.svelte";
|
||||||
|
import { saveCustomColours } from "@generated/backend";
|
||||||
|
|
||||||
export let keyCombination: string | null = null;
|
export let keyCombination: string | null = null;
|
||||||
export let value: string;
|
export let value: string;
|
||||||
|
@ -11,7 +12,15 @@ License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html
|
||||||
let inputRef: HTMLInputElement;
|
let inputRef: HTMLInputElement;
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<input bind:this={inputRef} tabindex="-1" type="color" bind:value on:input on:change />
|
<input
|
||||||
|
bind:this={inputRef}
|
||||||
|
tabindex="-1"
|
||||||
|
type="color"
|
||||||
|
bind:value
|
||||||
|
on:input
|
||||||
|
on:change
|
||||||
|
on:click={() => saveCustomColours({})}
|
||||||
|
/>
|
||||||
|
|
||||||
{#if keyCombination}
|
{#if keyCombination}
|
||||||
<Shortcut {keyCombination} on:action={() => inputRef.click()} />
|
<Shortcut {keyCombination} on:action={() => inputRef.click()} />
|
||||||
|
|
|
@ -19,6 +19,7 @@ License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html
|
||||||
import ColorPicker from "./ColorPicker.svelte";
|
import ColorPicker from "./ColorPicker.svelte";
|
||||||
import { context as editorToolbarContext } from "./EditorToolbar.svelte";
|
import { context as editorToolbarContext } from "./EditorToolbar.svelte";
|
||||||
import WithColorHelper from "./WithColorHelper.svelte";
|
import WithColorHelper from "./WithColorHelper.svelte";
|
||||||
|
import { saveCustomColours } from "@generated/backend";
|
||||||
|
|
||||||
export let color: string;
|
export let color: string;
|
||||||
|
|
||||||
|
@ -133,6 +134,7 @@ License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html
|
||||||
on:input={(event) => {
|
on:input={(event) => {
|
||||||
color = setColor(event);
|
color = setColor(event);
|
||||||
bridgeCommand(`lastHighlightColor:${color}`);
|
bridgeCommand(`lastHighlightColor:${color}`);
|
||||||
|
saveCustomColours({});
|
||||||
}}
|
}}
|
||||||
on:change={() => setTextColor()}
|
on:change={() => setTextColor()}
|
||||||
/>
|
/>
|
||||||
|
|
|
@ -22,6 +22,7 @@ License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html
|
||||||
import ColorPicker from "./ColorPicker.svelte";
|
import ColorPicker from "./ColorPicker.svelte";
|
||||||
import { context as editorToolbarContext } from "./EditorToolbar.svelte";
|
import { context as editorToolbarContext } from "./EditorToolbar.svelte";
|
||||||
import WithColorHelper from "./WithColorHelper.svelte";
|
import WithColorHelper from "./WithColorHelper.svelte";
|
||||||
|
import { saveCustomColours } from "@generated/backend";
|
||||||
|
|
||||||
export let color: string;
|
export let color: string;
|
||||||
|
|
||||||
|
@ -152,6 +153,7 @@ License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html
|
||||||
on:input={(event) => {
|
on:input={(event) => {
|
||||||
color = setColor(event);
|
color = setColor(event);
|
||||||
bridgeCommand(`lastTextColor:${color}`);
|
bridgeCommand(`lastTextColor:${color}`);
|
||||||
|
saveCustomColours({});
|
||||||
}}
|
}}
|
||||||
on:change={() => {
|
on:change={() => {
|
||||||
// Delay added to work around intermittent failures on macOS/Qt6.5
|
// Delay added to work around intermittent failures on macOS/Qt6.5
|
||||||
|
|
Loading…
Reference in a new issue