mirror of
https://github.com/ankitects/anki.git
synced 2025-09-21 15:32:23 -04:00
show saved custom colours as possible options in colour picker
this is primarily for mobile clients, as qt currently ignores this
This commit is contained in:
parent
7b347cf5ac
commit
42afefb3e3
1 changed files with 16 additions and 1 deletions
|
@ -55,6 +55,7 @@ License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html
|
||||||
onWheelDragX,
|
onWheelDragX,
|
||||||
} from "./tools/tool-zoom";
|
} from "./tools/tool-zoom";
|
||||||
import { fillMask } from "./tools/tool-fill";
|
import { fillMask } from "./tools/tool-fill";
|
||||||
|
import { getCustomColours } from "@generated/backend";
|
||||||
|
|
||||||
export let canvas;
|
export let canvas;
|
||||||
export let iconSize;
|
export let iconSize;
|
||||||
|
@ -76,6 +77,16 @@ License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html
|
||||||
let colourRef: HTMLInputElement | undefined;
|
let colourRef: HTMLInputElement | undefined;
|
||||||
const colour = writable(SHAPE_MASK_COLOR);
|
const colour = writable(SHAPE_MASK_COLOR);
|
||||||
|
|
||||||
|
const customColorPickerPalette = writable<string[]>([]);
|
||||||
|
|
||||||
|
async function loadCustomColours() {
|
||||||
|
customColorPickerPalette.set(
|
||||||
|
(await getCustomColours({})).colours.filter(
|
||||||
|
(hex) => !hex.startsWith("#ffffff"),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
function onClick(event: MouseEvent) {
|
function onClick(event: MouseEvent) {
|
||||||
const upperCanvas = document.querySelector(".upper-canvas");
|
const upperCanvas = document.querySelector(".upper-canvas");
|
||||||
if (event.target == upperCanvas) {
|
if (event.target == upperCanvas) {
|
||||||
|
@ -233,6 +244,7 @@ License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html
|
||||||
on(document, "touchstart", onTouchstart),
|
on(document, "touchstart", onTouchstart),
|
||||||
on(document, "mousemove", onMousemoveDocument),
|
on(document, "mousemove", onMousemoveDocument),
|
||||||
);
|
);
|
||||||
|
loadCustomColours();
|
||||||
});
|
});
|
||||||
|
|
||||||
onDestroy(() => {
|
onDestroy(() => {
|
||||||
|
@ -241,7 +253,10 @@ License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<datalist id="colour-palette">
|
<datalist id="colour-palette">
|
||||||
<option value={SHAPE_MASK_COLOR}></option>
|
<option>{SHAPE_MASK_COLOR}</option>
|
||||||
|
{#each $customColorPickerPalette as colour}
|
||||||
|
<option>{colour}</option>
|
||||||
|
{/each}
|
||||||
</datalist>
|
</datalist>
|
||||||
|
|
||||||
<input
|
<input
|
||||||
|
|
Loading…
Reference in a new issue